WordPress Plugins came into existence as much as 10 years ago. They can be as simple and come up as a single file like Hello Dolly or they can also come up as a complex structure for fulfilling various requirements and functionality.
Having said that, a deep look into WordPress Plugins makes you aware that there is no standardized way of making plugins. This results in poorly coded WordPress Plugins.
So a framework or methodology is needed for raising the quality of code for WordPress Plugins. In this perspective, WordPress Plugin Boilerplate plays an important role in WordPress plugin development. It follows an object oriented way for creating a standardized plugin.
Boilerplate has been coded with OOP principles and is intended for not only intermediate coders but also for beginners who can easily use it. This article shows you how you can get started with it regardless of your coding experience.
Backdrop of Boilerplate
Boilerplate WordPress Plugin is an initiative of Tom McFarlin. He created this plugin to provide a standardized, object-oriented approach to the development of high-quality WordPress Plugins. Boilerplate is one of the best tools to build a new WordPress Plugin with a solid foundation. It comes with essential file and folder structure. Its starter codes let you optimize your workflow. Overall Boilerplate helps you to write WordPress Plugin “the right way.”
The Plugin is built on top of the Plugin API and follows the WordPress Coding and Documentation Standards. Its recent updated version 3.0.0 brings in major improvements in its coding organization such as new folder structure. The plugin is now maintained by Devin Vinson. The development is still continuing as usual, so if you require sorting out any issues, you can report at GitHub repository.
How to Get a Copy of Boilerplate
The easiest way to get a copy of Boilerplate WordPress Plugin is by cloning the git repository. Download Boilerplate
Or else you can download a zip copy from the GitHub repository.
For installing Boilerplate, you have to refer to README.md file. It contains the detailed instructions for installing Boilerplate correctly.
However, the following instructions explain it in a nutshell:
You have to copy the trunk directory into the wp-content/plugins folder
You have to copy the whole Boilerplate directory and then have to create a symbolic link for the trunk subdirectory to the wp-content/plugins//.
Once you have done this, you will find the plugin WordPress Plugin Boilerplate in your plugin list in the admin dashboard.
Then you have to activate simply the plugin and you are ready to go.
WordPress Plugin Boilerplate Generator Tool
Once the plugin is activated, you need to run a search and require to replace the whole Boilerplate codebase. However, doing this is a very tedious and time-consuming process. Luckily enough, there’s an unofficial generator that can automate the process.
This Generator Tool has been developed by Enrique Chavez. You simply require accessing http://wppb.me/ where you have to complete the form located at the bottom of the page for generating a personalized copy of Boilerplate WordPress Plugin. You need to provide the name of your plugin, slug, website, your name and email address; then the tool replaces all the corresponding values in the Boilerplate files.
Using the Boilerplate WordPress Plugin
A basic understanding of WordPress Plugin Development will enable you to use easily Boilerplate for making better WordPress Plugins. So, you don’t need to be an expert in WordPress Plugins development.
Starting a WordPress Plugin Development Project using the Boilerplate WordPress Plugin is actually a pretty straightforward task. It all begins by changing the “plugin-name” folder to your plugin’s name and edit all files (such as PHP, JS, CSS files, and images) changing the “boilerplate values” to your own plugin’s values.
Working with Boilerplate involves dealing with quite a few files and lots of parts to edit even before working to write your own code. However, this should not put you off – as it is only a one time thing.
Here is the list of some of the files and folders:
Plugin-name/admin/: This includes JS files, CSS files, partials, PHP file for an admin-specific class (class-plugin-name-admin.php).
Plugin-name/includes/: This folder is considered as the “backbone” of your plugin and consists of:
Plugin-name/languages/: This folder includes your plugin’s language files
Plugin-name/public/: It includes JS files, CSS files, partials, and the PHP file for a public-facing functionality.
Plugin-name/LICENSE.txt: A copy of the GPL-2 license.
Plugin-name/plugin-name.php: The main plugin file.
Plugin-name/README.txt: A default README file for your plugin.
Plugin-name/uninstall.php: You need to run this file when the user deletes your plugin.
It is important to note here that the folder structure is based on the system of WordPress.org Plugin Repository.
Having seen its utility, it can be easily concluded that Boilerplate WordPress Plugin is a great tool for the development of better WordPress Plugins. However, there is a word of caution. You have to be careful about WordPress Coding Standards, plugin writing processes and security issues in general. If you take care of these issues, development of WordPress Plugins becomes really a thoroughly enjoyable process with Boilerplate WordPress Plugin.