Empower your WordPress plugin development with our starter pack, comes pre-configured with Gulp, designed to help you set up a custom WordPress Plugin boilerplate in minutes.
To get started, follow these simple steps:
- Clone this GitHub repository into your WordPress plugins directory.
- In the plugin directory, run the following command:
pnpm i && composer install
After completing these initial steps, let's dive into setting up your plugin for success:
- Automated Setup: Execute
pnpm run setup
to launch the automated setup process. - Plugin Name: Input your desired plugin name when prompted, such as "WP Mail Checker" or "Bulk Email Sender."
- Seamless Configuration: Our script will intelligently update the plugin name and related keywords throughout your plugin files. Look for the "Complete!" message upon successful completion, or troubleshooting messages if needed.
Simplify your development workflow with these commands:
- Watch for Changes: Use
pnpm run dev
to automatically compile your files whenever changes are made. - Build for Release: When ready, run
pnpm run build
to compile your files for release.
Maintain code quality effortlessly with a suite of 8 scripts:
lint:css
for SCSS file linting.lint:js
for JavaScript file linting.lint:php
for PHP file linting.lint
to check CSS, JavaScript, and PHP files together.lint-fix:css
to automatically fix SCSS files.lint-fix:js
for automatic JavaScript file fixes.lint-fix:php
to correct PHP file issues.lint-fix
to tackle CSS, JavaScript, and PHP issues together.
- Install WP-CLI: Follow the official guide and add it to your PATH.
- Create POT File: Execute
pnpm run makepot
to generate a POT file for languages.
To provide clarity, here are the essential keywords in use:
Keyword | Usage |
---|---|
custom-plugin |
Used as a prefix or postfix in various files. |
custom-plugin |
Serves as the plugin's text domain and assets enqueue handle prefix. |
Custom Plugin |
Represents the plugin's name across all plugin files. |
Custom_Plugin |
Used as the final class name and class name prefix. |
custom_plugin |
Used as the main function name and functions name prefix. |
CUSTOM_PLUGIN |
Used as a prefix for constants. |
When configuring your plugin using the Plugin Boilerplate, the Key Insights mentioned earlier serve as placeholders. These placeholders are dynamically replaced with the plugin name you provide during setup.
Running pnpm run setup
is a one-time command that initiates this process. Upon successful completion, it performs several important actions:
- Cleanup: It removes
setup.mjs
,.git
, andREADME.md
files/directories, ensuring a clean start for your project. - Script Removal: The
setup
script itself is deleted from yourpackage.json
to prevent unintended reconfiguration. - Dependency Optimization: Dependencies that were specific to the setup process are removed, leaving only the essential dependencies needed for your plugin development.
This streamlined setup process ensures your plugin starts on the right foot, eliminating unnecessary clutter and dependencies while setting the stage for efficient development.
Your WordPress plugin is organized as follows:
-
custom-plugin.php
: The main plugin file contains essential information, initializes constants, and provides a global function to access the primary class instance. -
gulpfile.mjs
: This file houses Gulp tasks responsible for automating various aspects of your plugin development, such as CSS preprocessing, JavaScript bundling, and asset optimization. -
includes
: Within this directory, you'll find PHP files, organized into classes and function files. Class files start with aclass-
prefix, while function files end with a-functions.php
postfix. Theadmin
subdirectory contains backend-related files. -
src
: Thesrc
directory houses source files for your plugin's assets, such as raw CSS, JavaScript, images, and fonts. You can make modifications to these source files during development. -
assets
: In this directory, you'll find the compiled and optimized assets, including minified CSS and JavaScript files, as well as optimized images and fonts. These build assets are automatically generated by the Gulp tasks configured in thegulpfile.mjs
. Please avoid manual modifications in this directory, as these files are regenerated during thebuild
process.
This structured approach ensures your plugin remains organized, maintainable, and efficient throughout its development lifecycle.
Copyright (C) 2021-2023, Vijay Hardaha. WordPress Plugin Boilerplate is distributed under the terms of the GNU GPL.
We welcome contributions from the WordPress community to make this starter pack even better!
Made with ❤ by Vijay Hardaha