I’ve updated my theme and plugin templates for grunt-init adding Composer to manage dependencies and making both themes and plugins TDD-able out of the box thanks to tdd-helpers.
Installing the templates
Using Terminal browse to the ~/.grunt-init
folder and clone there the templates
git clone https://github.com/lucatume/grunt-wp-theme.git
git clone https://github.com/lucatume/grunt-wp-plugin.git
Using the templates
If grunt-init
and composer
commands are already installed then scaffolding a theme requires browsing to the WordPress themes folder
mkdir new-theme
cd new-theme
grunt-init wp-theme
and after having answered the templates questions
composer install
npm install
grunt
and then use grunt watch
to have grunt
compile in the background while working on the theme or plugin.
Scaffolding a plugin is similar and will require browsing to the plugins folder and
mkdir new-plugin
cd new-plugin
grunt-init wp-plugin
and following steps are the same.
Sugar to me
I’ve enclosed previously global constants in class properties to leave a cleaner global space and that will allow, as an example, getting the path to the theme scripts folder using code like
NewTheme::the('jsAssets');
and similarly in a plugin context
AwesomePlugin::the('path');