This is a fork of the WordPress Plugin Boilerplate project and adds support for Namespaces and Autoloader. It requires PHP 5.6 and greater.
The wp-plugin-name
directory contains the source code - a fully executable WordPress plugin.
- The Boilerplate is based on the Plugin API, Coding Standards, and Documentation Standards.
- All classes, functions, and variables are documented so that you know what you need to change.
- The Boilerplate uses a strict file organization scheme that corresponds both to the WordPress Plugin Repository structure, and that makes it easy to organize the files that compose the plugin.
- The project includes a
.pot
file as a starting point for internationalization.
The Boilerplate can be installed directly into your plugins folder "as-is". You will want to rename it and the classes inside of it to fit your needs.
- Copy wp-plugin-name to your plugin's directory and rename it to your plugin's name
- Perform a find and replace at the project level as follows:
- Find the text
wp-plugin-name
and replace withyour-plugin-name
in all files - Find the text
WP_Plugin_Name
and replace withYour_Plugin_Name
in all files - Rename the
css
andjs
files underinc\admin\css
,inc\admin\js\
,inc\views\js
,inc\views\css
and replace the stringwp-plugin-name
withyour-plugin-name
- Rename the
pot
file underlanguages
and replace the stringwp-plugin-name
withyour-plugin-name
- Find the text
http://example.com
and replace with your URI in all files - Find the text
Your Name or Your Company
and replace with your name in all files
- Find the text
- Activate the plugin
# After having downloaded and extracted the archive, navigate to the folder containing the plugin
$ mv wp-plugin-name my-awesome-plugin
$ cd my-awesome-plugin
# Replace text for "example.com/wp-plugin-name-uri" and "example.com"
$ grep -rl "example.com/wp-plugin-name-uri" ./* | xargs sed -i "s/example.com\/wp-plugin-name-uri/somedomain.com\/my-awesome-plugin-uri/g"
$ grep -rl "example.com" ./* | xargs sed -i "s/example.com/somedomain.com/g"
# Replace text for "wp-plugin-name"
$ grep -rl "wp-plugin-name" ./* | xargs sed -i "s/wp-plugin-name/my-awesome-plugin/g"
# Replace Namespace references for the text "WP_Plugin_Name"
$ grep -rl "WP_Plugin_Name" ./* | xargs sed -i "s/WP_Plugin_Name/My_Awesome_Plugin/g"
# Rename Files with the text "wp-plugin-name" in them
$ find . -iname '*wp-plugin-name*' -exec rename 's/wp-plugin-name/my-awesome-plugin/' {} \;
# Replace text for Your Name
$ grep -rl "Your Name or Your Company" ./* | xargs sed -i "s/Your Name or Your Company/Your Name/g"
Note that this will activate the source code of the Boilerplate, but because the Boilerplate has no real functionality there will be no menu items, meta boxes, or custom post types added.
If you want to include your own classes, or third-party libraries
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 partswp-plugin-name/inc/libraries
- libraries that the plugin may use
Requires PHP 5.6.0
or greater
The WordPress Plugin Boilerplate uses a variable ($this->plugin_text_domain
) to store the text domain, used when internationalizing strings. To take advantage of this method, there are tools that are recommended for providing correct, translatable files:
Any of the above tools should provide you with the proper tooling to internationalize the plugin. However, if you face problems translating the strings with an automated tool/process, replace $this->plugin_text_domain
with the literal string of your plugin's text domain throughout the plugin.
- Here's a discussion from the original project in favor of using variables
- The Plugin Handbook Recommended Way (i.e. not to use variables)
The WordPress Plugin Boilerplate is licensed under the GPL v2 or later.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
A copy of the license is included in the root of the plugin’s directory. The file is named LICENSE
.
If you opt to use third-party code that is not compatible with v2, then you may need to switch to using code that is GPL v3 compatible.
For reference, here's a discussion that covers the Apache 2.0 License used by Bootstrap.
The original launch of this version of the boilerplate included the folder structure needed for using your plugin on WordPress.org. That folder structure has been moved to its own repo here: https://github.com/DevinVinson/Plugin-Directory-Boilerplate
The WordPress Plugin Boilerplate was started in 2011 by Tom McFarlin and has since included a number of great contributions. In March of 2015 the project was handed over by Tom to Devin Vinson