This is Part Two in our WordPress Plugin Development Master Series.
Looking for Part One? Go here.
What is a Plugin Boilerplate? A Plugin Boilerplate is a pre-built framework of files and folders that are useful for any medium sized plugin.
The boilerplate will be using has concise, well-documented, object oriented code. It has a well thought out structure for building a robust WordPress Plugin.
Boilerplates save you time by already implementing the baseline code wrappers, hooks and functionality you will need.
Creating Your Plugin From Boilerplate
WordPress Plugin Boilerplate by Tom McFarlin & Devin Vinson is the boilerplate I use when I start a new WordPress Plugin.
Go to https://wppb.me/ and type in your plugin details like the screenshot below.
Take the generated my-lms.zip file and move it to your wp-content/plugins directory.
Un-zip the plugin and delete the .zip file.
Open the my-lms folder in your favorite IDE or Code Editor.
Boilerplate Structure Overview
The following is a screenshot of the generated plugin boilerplate.
I expanded the folders so you can see the plugin structure.
Inside the admin folder is where you’ll want to place your code for the admin area.
Inside the includes has an activator and deactivator class where you put code that will run when your plugin is activated or deactivated.
For example when your plugin is activated you might want to update the wp_options table with data.
The public folder is where you put any front facing functionality and where you enqueue styles and scripts for the frontend.
Congratulations you just created a WordPress Plugin using a boilerplate.
In Part Three you are gonna learn how to use Enqueue Styles and Scripts from inside a plugin.
Do you have a Plugin Boilerplate you’d like to recommend? Comment below.