Code Snippets

WordPress Block Patterns Programmatically

How to Display WordPress Block Patterns Programmatically (No Plugins Required)

I was customizing a WordPress installation and I wanted to output a WordPress Block Pattern programmatically. The pattern had been created in the admin, using the post editor. I tried getting an instance of the pattern using it’s slug as such: All this does is return null. WordPress Patterns – Stored in Posts Table The […]

How to Display WordPress Block Patterns Programmatically (No Plugins Required) Read More »

create your own chat gpt interface

Create your own Chat GPT Interface plugin for WordPress using OpenAI’s API

A great way to get around the sometimes high costs of premium AI service plans is to create your own Chat GPT interface. You can the same functionality for a fraction of the cost when using your own interface that connects to OpenAI’s API. Creating an application that interfaces with OpenAI’s API using PHP (potentially

Create your own Chat GPT Interface plugin for WordPress using OpenAI’s API Read More »

Loading Indicator

Loading Indicator PHP Function (with JS and CSS)

Creating a Loading Indicator with PHP, JavaScript, and CSS A loading indicator is a visual cue that informs users that a process is underway, enhancing user experience by providing feedback during wait times. This snippet demonstrates how to create one using PHP, JavaScript, and CSS. This handy function wraps some HTML, CSS, and JS to create a pulsing circle and

Loading Indicator PHP Function (with JS and CSS) Read More »

PHP Current Directory

How to get current directory, filename and code line number in PHP

In PHP, there are several built-in functions that can be used to obtain information about the current script’s directory, filename, and code line number. Getting the Current Directory To get the absolute path of the directory containing the current script, you can use the dirname(__FILE__) function. For example: This will set the $current_directory variable to

How to get current directory, filename and code line number in PHP Read More »