SkillAgentSearch skills...

Wordpress Plugin Boilerplate

An organized and object-oriented boilerplate for WordPress plugin development and testing. Includes Composer, Codeception (unit/acceptance testing), PHPCodeSniffer with WordPress Coding Standards to validate your code, TravisCI configuration for automatic testing & continuous integration, Webpack 5 for front-end development incl. BabelJS v7, BrowserSync v2, PostCSS v8, PurgeCSS v3, Autoprefixer, Eslint, Stylelint, SCSS processor, WPPot, and more.

Install / Use

npx skills add brandonkramer/wordpress-plugin-boilerplate

Installs into whichever agent you are using.

README

WordPress Plugin Boilerplate

Build Status PHP 7.1+

<table width='100%' align="center"> <tr> <td align='left' width='100%' colspan='2'> <strong>Plugin boilerplate with modern tools to kickstart your WordPress project</strong><br /> This includes common and modern tools to facilitate plugin development and testing with an organized, object-oriented structure and kick-start a build-workflow for your WordPress plugins. </td> </tr> </table>
  • The Boilerplate is based on the Plugin API , Coding Standards, and Documentation Standards.
  • Includes Composer, Requirements micropackage to test environment requirements for your plugin, Codeception to do unit/acceptance testing, PHPCodeSniffer with WordPress Coding Standards to validate your code, TravisCI configuration for automatic testing & continuous integration, object-oriented code structure for better overview, an automatic class loader that automatically instantiate classes based on type of request.
  • This can be combined with the Webpack 5 workflow for front-end development using the npx quickstart script that includes the Webpack v5 bundler, BabelJS v7, BrowserSync v2, PostCSS v8, PurgeCSS v3, Autoprefixer, Eslint, Stylelint, SCSS processor, WPPot, and more.

Quickstart

Image

Should be run inside your plugins folder (wp-content/plugins).

npx wp-strap plugin

You can also use the npx script with predefined answers to get a quicker start

npx wp-strap plugin "projectName:Your plugin name" "description:Test the plugin" "pluginVersion:1.0.0" license:MIT "author:The Dev Company" authorEmail:hello@the-dev-company.com url:the-dev-company.com webpack:Y codesniffer:Y codeception:Y travisCi:Y css:Sass+PostCSS

It will take a couple of minutes to install after your terminal input; it will clone the git repo's, search and replace all the plugin data, do a composer install, and when it's combined with the Webpack workflow then it wil also do a npm install

<a href="#what-to-configure">Read more about the configuration & build scripts</a>

Features & benefits

Backend

Composer (Namespaces + PSR4 autoloader + Dependency manager)

  • Namespace support to group all of your code under a custom name. That way, your classes, functions, and so on don’t clash with other people’s code running on the site at the same time
  • PSR-4 Autoloader to autoload files and directories in connection with namespaces
  • Includes a dependency manager to easily load in 3rd party libraries from packagist, locked onto specific versions

Object-oriented & classes autoloader

PHPCodeSniffer + WordPress Coding Standards + Automattic's phpcs-neutron-ruleset

  • PHP CodeSniffer is built in with predefined configuration for proper linting. PHP_CodeSniffer is an essential development tool that ensures your code remains clean and consistent.
  • PHPCS is extended with the WordPress Coding Standards & PHPCompatibilityWP for PHP_CodeSniffer which is a collection of PHP_CodeSniffer rules (sniffs) to validate code developed for WordPress. It ensures code quality and adherence to coding conventions, especially the official WordPress Coding Standards.
  • PHPCS is also extented with Automattic's phpcs-neutron-ruleset which is a set of modern (PHP >7) linting guidelines for WordPress development.

Codeception (unit/acceptance testing)

  • Codeception is built in which combines all testing levels (acceptance, functional, integration, unit) with WordPress defined functions, constants, classes and methods in any test.
  • With a flexible set of included modules, tests are easy to write, easy to use, and easy to maintain.

Plugin requirements

  • Requirements micropackage is built in that allows you to test environment requirements to run your plugin. It can test: PHP version, PHP Extensions, WordPress version, Active plugins, Current theme, DocHooks support
  • Easily to configure using a simple array
  • If the plugin doesn't pass the test then it will disable the plugin automatically for the user in WordPress and show a notification in the back-end

TravisCI

  • Ready to use TravisCI configuration for automatic testing & continuous integration which currently only validates the plugin code with PHPCodeSniffer during automated testing when being deployed, but can also be extended to test unit/acceptance cases from Codeception

Prettified errors & Classes debug array

Frontend (Webpack)

For front-end tooling the webpack workflow is being cloned. Read more about this workflow here: https://github.com/wp-strap/wordpress-webpack-workflow

Styling (CSS)

  • Minification in production mode handled by Webpack
  • PostCSS for handy tools during post CSS transformation using Webpack's PostCSS-loader
  • Auto-prefixing using PostCSS's autoprefixer to parse CSS and add vendor prefixes to CSS rules using values from Can I Use. It is recommended by Google and used in Twitter and Alibaba.
  • PurgeCSS which scans your php (template) files to remove unused selectors from your css when in production mode, resulting in smaller css files.
  • Sourcemaps generation for debugging purposes with various styles of source mapping handled by WebPack
  • Stylelint that helps you avoid errors and enforce conventions in your styles. It includes a linting tool for Sass.

Styling when using PostCSS-only

  • Includes postcss-import to consume local files, node modules or web_modules with the @import statement
  • Includes postcss-import-ext-glob that extends postcss-import path resolver to allow glob usage as a path
  • Includes postcss-nested to unwrap nested rules like how Sass does it.
  • Includes postcss-nested-ancestors that introduces ^& selector which let you reference any parent ancestor selector with an easy and customizable interface
  • Includes postcss-advanced-variables that lets you use Sass-like variables, conditionals, and iterators in CSS.

Styling when using Sass+PostCSS

  • Sass to CSS conversion using Webpack's [sass-loader](h

Related Skills

View on GitHub
GitHub Stars109
CategoryDevelopment
Updated4mo ago
Forks32

Languages

PHP

Security Score

82/100

Audited on Mar 27, 2026

No findings