WordPress Boilerplate Plugin – Start Building Your Plugin With Few Steps Ahead

WordPress Boilerplate Plugin is a starter plugin that will help you build your plugin much faster because it already contains several common functionalities that you might need.

As a WordPress Developer I often create custom plugins for clients and always loosing too much time on writing the basic classes and methods so I decided to create a WordPress Boilerplate Plugin that will contain all those common classes and functionalities that I use when I create my plugins.

I worked on the plugin for few years, updating the structure and adding new functionalities using the latest WordPress standards. Finally, I decided to add it on packagist  for easier installation.

Structure of the plugin

The structure of the plugin is pretty simple.

Wordpress Boilerplate Plugin

  • The assets folder contains the CSS and JavaScript files separated for admin and public (front-end) part.
  • The inc folder contains the classes I usually use separate into sub-folders with separate namespaces
    • admin sub-folder contains classes that might be used on the admin dashboard. It comes with one class which has methods to register new page in the admin dashboard and show form with some fields
    • api sub-folder contains classes that might be used for creating REST API and / or to handle AJAX calls. Currently contains two classes AJAX_Handler and API_Handler
    • core sub-folder contains classes that are general for the plugin. Currently contains the autoloader file where I am registering the namespaces and the path to each namespace. (I will probably update this to use composer and psr-4 later)
    • traits sub-folder contains traits that I have written. Currently contains two traits – Singleton and Singleton_Routes. I use Singleton to make any class Singleton and I use Singleton_Routes in the API_Handler class which makes the class Singleton, but also offers method for easier registering of the routes
    • A Shortcode class is also included in inc folder in case I need to create a shortcode.
  • The languages folder contains .mo and .po files for translations
  • The views folder contains the template files that I might need for displaying something. Currently contains the template for the admin dashboard form.

You can remove any file that you don’t need or change the structure to your needs if you think this won’t work for you.

Screenshots of the files in WordPress Boilerplate Plugin

Link to plugin here