WordPress Plugin development, at first glance, can be a technically overwhelming endeavor for many beginner WordPress developers as well as even intermediate WordPress developers. Recently, I was working with developing a new WordPress Plugin and decided to share my notes for any new WordPress Plugin developers out there.

First, we will start with one file to create our WordPress Plugin. This file will be a PHP file saved with the .php extension. You will want to use your favorite code editor or text editor to create this file. I use Sublime to edit my custom files when developing WordPress Plugins. However, there are several alternatives you can use. See my article on “Popular Free Code Editors” if you need to choose a code editor to use or are interested in trying a new code editor.

Your main plugin must include a header which may look something like this:

 

There are several header fields to provide information about the WordPress Plugin. However, only the Plugin Name field is required.

NOTE: For a comprehensive list and description of additional fields, please view WordPress Header Fields.

 

The following code prevents data leaks and direct data access. Add it to all WordPress Plugin files following the header or the opening PHP tag.

 

WordPress Hooks
Before moving forward with the WordPress Plugin development, you should know a little bit about WordPress Hooks. 

A hook provides a way for code to interact with or modify an existing piece of WordPress code in a particular spot. There are two primary types of Hooks in WordPress: Action Hooks and Filter Hooks. For this short tutorial and example, we will only be using a Filter Hook.

A WordPress Filter Hook takes data or information that it receives, filters it, and modifies or adds to it. You will understand more after reviewing the following code example.

The completed file should like the following PHP source code example below.

Finally, you will take the completed file, place it in a folder, then compress this folder to a Zip file. Then, in the WordPress Admin Plugin section, you will upload this Zip file to install and activate your new custom WordPress Plugin you have developed! Make sure that you name the folder the same name as the PHP file. This naming convention is how WordPress knows which file is the main one for the Plugin.