PluginWP is a modern starting point for building WordPress plugins using React and the block editor components. It brings a more maintainable and scalable approach to plugin development by introducing concepts from Laravel, such as the Service Container and Service Providers.
- Modern PHP architecture inspired by Laravel
- React-based block editor components
- Composer and npm support
- Pre-configured build tools and scripts
- Easy-to-follow structure for scalable plugin development
Create your plugin project:
Clone this repository or click Use this template to create a new project on GitHub.
git clone https://github.com/jrtashjian/pluginwp.git yourpluginslug
cd yourpluginslug
Customize plugin details:
Replace all occurrences of PluginWP Author
with your actual author name:
find . -type f -not -path "./.git/*" -exec sed -i 's/PluginWP Author/Actual Author Name/g' {} +
Replace all occurrences of PluginWP
with your plugin slug (e.g., YourPluginSlug
):
find . -type f -not -path "./.git/*" -exec sed -i 's/PluginWP/YourPluginSlug/g' {} +
Replace all occurrences of pluginwp
with your lowercase plugin slug (e.g., yourpluginslug
):
find . -type f -not -path "./.git/*" -exec sed -i 's/pluginwp/yourpluginslug/g' {} +
Finally, rename the main plugin file:
mv pluginwp.php yourpluginslug.php
Install the necessary dependencies:
composer install
npm install
composer lint
: Run PHP_CodeSniffer on all PHP files usingphpcs.xml.dist
.composer lint-prefixed
: Run PHP_CodeSniffer on prefixed vendor files usingphpcs-prefixed.xml.dist
.composer format
: Automatically fix fixable PHP coding standard issues using PHPCBF.composer test
: Run the PHPUnit test suite.composer makepot
: Generate a .pot file for translations using WP-CLI.composer build-release
: Build a distributable plugin archive.composer phpscoper
: Run PHP-Scoper to prefix vendor dependencies.
npm run build
: Compile all scripts and styles for distribution.npm run build:analyze-bundles
: Build and analyze bundle sizes with webpack-bundle-analyzer.npm run start
: Start the development build process.npm run format:php
: Run Composer'sformat
script inside the wp-env container.npm run lint:css
: Lint all SCSS files using WordPress stylelint config.npm run lint:css:fix
: Lint and automatically fix SCSS files.npm run lint:js
: Lint JavaScript files using WordPress ESLint config.npm run lint:js:fix
: Lint and automatically fix JavaScript files.npm run lint:php
: Run Composer'slint
script inside the wp-env container.npm run lint:php:prefixed
: Run Composer'slint-prefixed
script inside the wp-env container.npm run mailhog
: Start a MailHog SMTP testing server in Docker.npm run packages-update
: Update all @wordpress packages to the specified dist-tag.npm run test:php
: Run all PHP linting and unit tests.npm run test:unit:php:coverage
: Run PHPUnit with code coverage report.npm run test:unit:php:setup
: Start wp-env with Xdebug for code coverage.npm run test:unit:php
: Run PHPUnit setup and then the test suite.npm run wp-env
: Start and manage the local WordPress environment using @wordpress/env.npm run version
: Update version numbers and stage changes for commit.
For more details, see the scripts
section in composer.json
and package.json
.
Contributions are welcome! Please open issues or submit pull requests to help improve this project.
This project is open source and available under the GNU General Public License v2.0 or later (GPL-2.0+).
Now go build something awesome! 🚀