How to develop a WordPress plugin part 2

Matt and Scott continue the journey down the plugin development road.

If you missed part 1, we suggest going back to that video and starting from the basics. We covered some of the fundamental work you should have done before you actually started coding.

In this episode we’ll jump into choosing the right file structure, prepping your plugin for development and using the WordPress repo.

FreshDev: Part 2 of WordPress plugin development

Watch on YouTube

Plugin file structure

Before we start coding, let’s think about the file structure we’re going to use.

How complex is our plugin? Is it solving something basic for our WordPress install or is it going to be a complex system like a membership plugin?

Single Directory/File

  • Can be useful for beginners
  • Useful if creating a simple or small plugin (plugin does one or two things)
  • Can be messy/unstructured if your plugin has a lot of functionality

Multiple Directories/Files

  • Helps organize code in larger plugins
  • Breaks code into smaller manageable pieces
  • Example Structure:
    • /my-plugin/images
    • /my-plugin/css
    • /my-plugin/includes – PHP includes

    It’s probably safe to say that most plugins your diving into will leverage multiple files and directories. It also makes sense from a good house keeping perspective.

    So we’re almost done with our canvas, it’s time to start coding!

    Plugin specifics

    There’s a few specific things we have to do to prepare our plugin. Prepare it for other author’s to contribute to, for end users to install and for it to be accepted into the WordPress repository.

    Plugin header

    You need to have a properly formed plugin header before it can be uploaded to the repo. It’s almost like your driver’s license, if there’s data missing or invalid, you might not be able to get on your next flight at the airport.

    Plugin Header

    • Top of the main PHP file of your plugin
    • Specify details about the plugin that WP uses to display to the end user
    • Plugin Name, Plugin URI, Author, Description & Version

    What to expect when uploading to the

    Now before you get too far in your WordPress plugin development, consider what you’re going to have to do when uploading to the repo.

    First thing, you will need your properly formed plugin header. Second, you’re going to need that ever important readme file — without it you’re not getting too far. is going to use this information to properly configure the plugins homepage within the repository. Get your screenshots prepared and installation instructions as detailed as possible.

    Remember we want users to find out what our plugin does as quickly and easily as possible.

    You’ll also want to keep in mind that the readme file uses Markup syntax and there are resources for generating a readme files.

    If you researched other plugins as we stated in part 1, you should be ready for this!

    What’s next?

    So that concludes part 2 of WordPress plugin development.

    In the next episode, we’re going to look at the powerful hooks, actions and filters built into WordPress. Stay tuned and post your questions below!

    WordPress plugin development part 1

Leave a Comment

Your email address will not be published.