Yeoman generator for WordPress plugins.
If you don't have Yeoman installed:
npm install -g yo
To install generator-plugin-wp from npm, run:
npm install -g generator-plugin-wp
To use generator-plugin-wp,
cd to your WordPress plugins folder and:
You'll be prompted with steps for creating your plugin.
Once your nifty new plugin has been generated,
cd into your new plugin's
directory. While in the plugin directory, you can run additional commands
called sub-generators to automatically generate files to enhance your plugin.
yo plugin-wp:include <include-name>Basic Include
yo plugin-wp:cpt <cpt-name>Custom Post Type
yo plugin-wp:cli <cli-command-name>WP CLI Command
yo plugin-wp:taxonomy <taxonomy-name>Taxonomy
yo plugin-wp:options <options-name>Option Page
yo plugin-wp:widget <widget-name>Widget
yo plugin-wp:endpoint <class-name>WP-API Endpoint
For the names of the include, cpt, options, and widget subgenerators remember that the plugin prefix will be added to the class name so no need to include the original plugin name there. Think of it as the file name for each instead.
By default the plugin generator adds some built in tests for you to add on to as
you develop your plugin. To run these tests run the
in the bin folder with the proper database details for your local setup.
Once you've run the
install-wp-tests.sh script you can run just
the main folder of your plugin.
If you don't want tests included in your plugin when it is generated run the
main generator with the
By default PHP 5.2 is not supported in the generated plugin. To generate a plugin
with PHP 5.2 support, run the main generator with the
CMB2 is included by default with the options sub-generator. It can also be a useful tool with CPT and taxonomy sub-generators using the --cmb2 flag.
Adding Packages with Composer
If you chose composer as the autoloader option during the plugin's initiation, you can use composer to add additional dependencies.
cd into our new plugin's directory and add CMB2:
composer require webdevstudios/cmb2
CMB2 will now appear under
-plugins -wds-foo-plugin -vendor -webdevstudios -cmb2
The following humans contributed to this awesome generator: