A modern, modular WordPress plugin boilerplate with PSR-4 autoloading, Webpack 5 asset bundling, live reload, and code quality tools designed for streamlined, standards-compliant plugin development.
A boilerplate for creating WordPress plugins, featuring a pre-configured build process and a structured PHP foundation.
This boilerplate provides a structured starting point for plugin development, including a Webpack 5 configuration, a Dependency Injection Container, and a modular PHP architecture.
postcss-preset-env
.wpcs
) for PHP.Before you begin, please ensure you have the following installed:
Clone the Repository:
git clone https://github.com/code-soup/wordpress-plugin-boilerplate.git my-awesome-plugin
cd my-awesome-plugin
Run the Setup Script:
This script will ask for your plugin’s details and configure the boilerplate files for you.
# First, make the script executable
chmod u+x setup.sh
# Then, run the script
sh setup.sh
Install Dependencies:
Once the setup is complete, install the necessary PHP and Node.js dependencies.
# Install PHP dependencies
composer install
# Install Node.js dependencies
yarn install
Run the Development Server:
For live-reloading and automatic recompilation of assets during development.
yarn dev
This boilerplate comes with a set of pre-configured scripts for development tasks.
composer lint
: Lints all PHP files for syntax errors.composer wpcs
: Checks PHP files against the WordPress Coding Standards.composer cbf
: Automatically fixes many phpcs
errors.yarn dev
: Starts the webpack dev server with Hot Module Replacement.yarn build
: Compiles and optimizes all assets for a production environment.yarn build:dev
: Compiles assets for development without optimization.yarn lint
: Runs both the script and style linters.
yarn lint:scripts
: Lints JavaScript files with ESLint.yarn lint:styles
: Lints SCSS files with Stylelint.yarn clean
: Deletes the dist
folder and the webpack cache.includes/
: Contains all the PHP source code for the plugin.
core/
: The core bootstrap and DI container logic.admin/
: Code specific to the WordPress admin area.frontend/
: Code specific to the public-facing parts of the site.providers/
: Service providers for registering plugin features.src/
: Contains all the raw, un-compiled frontend assets.
scripts/
: JavaScript files.styles/
: SCSS files.images/
, icons/
, fonts/
: Other static assets.config/
: The entire Webpack configuration.dist/
: The output directory for all compiled assets. This directory is automatically generated.languages/
: Contains translation files (.pot
, .po
, .mo
).For more detailed information on specific topics, please refer to the documentation in the /docs
directory.
Hooker
service to add actions and filters.If you encounter a bug or have a feature request, please submit an issue on GitHub. When creating an issue, provide a clear, descriptive title and include as much detail as possible to help us understand and reproduce the problem.
This project is licensed under the GPLv3 License.