Plugin Boilerplates are a great way to start developing without having to rewrite standard code. They also ensure that all your plugins are consistent with respect to layout and coding practices.
The WordPress Plugin Handbook lists best practices to develop WordPress plugins. Among these are a few Boilerplate Starting Points that you can use instead of writing your own.
I particularly liked the one by DeninVinson but without support for namespaces, one could end up with a lot of include
and require
statements. Namespaces, however, are available in PHP 5.3.0 or greater. Even though WordPress supports legacy systems with a PHP version of 5.2, the minimum recommended PHP version for WordPress at this point of time is PHP 7.
I’ve forked the original project and modified it to add support for autoloading and namespaces. The layout is a bit different compared to the original one. Here’s an overview:
wp-plugin-name/inc/admin
– admin-specific functionalitywp-plugin-name/inc/core
– plugin core to register hooks, load files etcwp-plugin-name/inc/frontend
– public-facing functionalitywp-plugin-name/inc/common
– functionality shared between the admin area and the public-facing parts
You can download my Plugin Boilerplate from here but the minimum required PHP is 5.6.0 or greater.
Happy Coding!
mikeill says
Nicely done. Thanks for this.
Karan NA Gupta says
You’re welcome 🙂
Admin says
This is fantastic. You don’t have the plugin name unnecessarily included in class and file names. Makes maintence much simpler. I plan to use this. Thank you.
Karan NA Gupta says
I’m glad you found it useful!
denishfortp says
Thanks 🙂