Code Snippets

black samsung flat screen computer monitor

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

Creating an application that interfaces with OpenAI’s API using PHP (potentially within the WordPress ecosystem), HTML, and vanilla JavaScript involves several steps. Below is a comprehensive guide to building a clean, attractive, and performant interface that allows users to interact with various OpenAI API features, including model selection (e.g., DALL·E 3 for image generation), prompt

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 »

PHP error log - operator not supported

[] operator not supported for strings – PHP

I had a problem with Revolution Slider on a WordPress installation when upgrading to PHP 7.2+. It would generate the error – PHP Fatal error: [] operator not supported for strings in C:[path]\wp-content\plugins\revslider\includes\framework\base-admin.class.php:71 The problem was from the plugin attempting to use the short array push syntax on a string: The solution was to modify

[] operator not supported for strings – PHP Read More »