WordPress Tutorial: How to Create a WordPress Plugin

Step 1 – Name Your WordPress Plugin

WordPress Plugin Name
WordPress Plugin Name

Steps to Create a WordPress Plugin

  1. Name Your WordPress Plugin
  2. Isolate Your Plugin From Other Plugins
  3. Organize Your Plugin Files
  4. Define Directory Paths
  5. Load Plugin Files
  6. Directory Structure
  7. Plugin Activation, Plugin Deactivation, and Plugin Uninstallation
  8. Essential Plugin Files
  9. Security: Protect Plugin Files
  10. Plugin Hierarchy

Think of what you want to do with your plugin and think of a simple name to identify that functionality. This will be the name of your plugin.

For the sake of this tutorial, the plugin name will be “MBE Plugin” with a plugin slug of “mbe-plugin”.

Create a Directory For Your WordPress Plugin

Once you have a name, you need to create a “directory-safe” name of your plugin. This can be referred to as a “plugin slug”. This is something that will be commonly used throughout the development of your plugin. Create a sub-directory in ./wp-content/plugins. This will be the main directory which contains all of the functionality specifically for your plugin.

It should look like this:

This is what mine looks like:

Create the Main WordPress Plugin File

Now that you’ve created a directory to store all of the files which will be related to your plugin, it’s time to create the main plugin file. This is the file which WordPress will look for, in order for WordPress to provide an interface in the back-end for you and/or your users to “activate”, “deactivate” , or “uninstall” your plugin.

This back-end interface would be located at:

Create a file named index.php and place it in the root of your plugin directory. (./wp-content/plugins/mbe-plugin/index.php)

Provide Basic Plugin Information

Open up index.php and create a block comment. At a minimum, you must provide a Plugin Name attribute to this block comment.

I like to provide as much information about my plugin as possible; I think you should as well.

Here’s an example:

If you log into the back-end of your WordPress website and navigate to your-domain.com/wp-admin/plugins.php, you’ll see your plugin is now visible in the list of plugins. At this point, if you were to activate your plugin… Absolutely nothing would happen, because your plugin has zero functionality. All you’ve done this far is essentially tell WordPress about your plugin, but it’s a step in the right direction

Leave a Reply