This is the boilerplate for a WordPress plugin development environment, including (and enforcing) WordPress Standards, PHP namespaces and a lando server setup that's ready to be used for testing and debugging.
The project is intended to be used with WordPress 5+, PHP 7+ and at least lando version 3.0beta.
It's also expected to be used along with VSCode. I haven't tested any other editors.
It modifies the contents under plugin-name using the preset.json, ultimately renaming the folder to the plugin-slug
set in the preset.json
file.
To use this generator, you need to have node
installed (use nvm). I tested this with version 12.16.3 of node, but I suppose it should work with at least version 6 onwards:
- Clone the project to your computer:
git clone https://github.com/skaparate/wp-lando-plugin-boilerplate
. - Rename the file
preset.example
to preset.json. - Fill the file with your project data (explained below).
- Run the generator:
node generator.js
.
After that, read the instructions on the README of the plugin. It tells you where to get Lando (and docker) and explains some custom commands.
This file is used to tell the generator about some project settings, specifically, it includes:
- display-name: This is the display name of the plugin. It's as the WordPress
Plugin Name:
and the README title. - plugin-slug: As the name implies, is the machine name of the plugin. This is used for the plugin folder name, the main file name and to derive some other variables.
- plugin-slug-prefix (Optional): This is a prefix that's prepended to the plugin slug. If the plugin slug is
my-plugin
and this is set toskp
, then the slug becomesskp-my-plugin
. - plugin-text-domain (Optional): Used for i18n. It can be a string or false. If set to false, the plugin-text-domain is not removed from the files nor replaced. When empty, the text domain is derived from the plugin slug (not including the slug prefix).
- base-namespace: The namespace and package used for the
@package
comment and the PHPnamespace
.
To run the tests, simply run yarn run test
.
I hope this is useful to someone :).