A WordPress plugin boilerplate that emphasizes code quality.
This boilerplate provides you with a solid foundation to rapidly start your custom plugin development project. It's fully compliant with PHPCS and WPCS coding standards. It's modular in design. Emphasis is given to SOLID principles. Validators are built right into the plugin, pre-configured and pre-wired for you to use.
You are free to use this plugin. Rename it. Change the namespace and author information. It's yours to use.
- Provides modular, well-organized architecture to group functionality and features together.
- No Constants. Eliminates the need for constant definitions. No more polluting the global space. Instead it uses private helper functions.
- Purposeful, expressive naming strategies to clearly tell you what is happening and why.
- No prefixes. Prefixes make it harder to read. This plugin uses namespacing instead, providing for better conflict protection and intent expression.
- Better asset versioning by using each file's modification timestamp instead of hard-coded version numbers.
Wiring up test suites can be challenging. This plugin handles it for you.
- Separation of Unit and Integration testing suites.
- Bootstrapping for each suite is all done for you.
- Test cases are built in for you.
- Brain Monkey is built in and ready for you to use.
- Initial integration tests are provided for the helper functionality in the plugin's bootstrap file.
- Sample unit test is provided too.
- Composer scripts are configured (for Mac and Windows), providing a fast, easy shortcut to run each test suite and all of the tests:
- Run the unit tests via
composer test-unit
. - Run the integration tests via
composer test-integration
. - Run all of the tests via
composer run-tests
.
- Run the unit tests via
Psst, need help getting rolling? Check out this hands-on coding labs:
Code validators sniff out any compliance issues in your code. It looks for issues with your code's formatting, naming conventions, security, construction, and more. This plugin includes:
- PHPCS and WordPress Coding Standard (WPCS) sniffers.
- Variable analyzer.
- Pre-configured composer scripts (for Mac and Windows), providing a fast, easy shortcut to run validators on the
src
, tests, or both:- Run for just the plugin's code via
composer phpcs-src
. - Run for just the tests via
composer phphcs-tests
. - Run all of the code via
composer run-phpcs
.
- Run for just the plugin's code via
- Open your favorite command line tool.
- Navigate to your project's
wp-content/plugins
directory. - Clone this repository to your local machine by typing:
git clone https://github.com/KnowTheCode/starter-plugin.git name-of-your-plugin
.- Replace
name-of-your-plugin
with the name you are giving to your plugin.
- Replace
- Navigate into your new plugin's directory.
- Install the composer packages by typing:
composer install
.
Bam, you are ready to customize it for your project's needs.
The next step is to rename the namespace, plugin's file header, and the author information.
- Do a global search and replace in your favorite editor to replace
KnowTheCode\StarterPlugin
with your namespace. Remember, the standard isYourNameOrCompanyName\PluginName
. - Open up the
boostrap.php
file. - Change the plugin's file header information for your needs:
- Change the opening short description.
- Change the author and author's URI.
- Change the
Plugin's Name
andPlugin URI
. - Change the
Description
. - Change the
Text Domain
.
- Do a global search and replace to change the
@author
fromhellofromTonya
to your name. - Do a global search and replace to change the
@link
fromhttps://knowthecode.io
to your URI.
Bam, you are ready to start building your plugin.