@carmopereira/wp-plugin-addons
v1.0.2
Published
Addons to speed up WordPress plugin development for PHP and Gutenberg block plugins
Maintainers
Readme
@carmopereira/wp-plugin-addons
Addons to speed up WordPress plugin development for both traditional PHP plugins and Gutenberg block plugins.
Installation
npm install -g @carmopereira/wp-plugin-addonsOr run directly with npx:
npx @carmopereira/wp-plugin-addonsUsage
1. Scaffold your plugin
You can start from a Gutenberg block plugin or a traditional PHP plugin:
Gutenberg block plugin (create-block)
npx @wordpress/create-block@latest my-plugin --variant=dynamic
cd my-pluginPHP plugin scaffold
npx @carmopereira/wp-php-template
cd my-plugin2. Apply the custom setup
npx @carmopereira/wp-plugin-addons create-block-carmo-addonOr run without arguments to choose interactively:
npx @carmopereira/wp-plugin-addonsWhat gets added
The create-block-carmo-addon setup adds:
Scripts to package.json
prebuild: Automatically updates the version before build (patch version)updateGIT: Interactive script to run git add, commit, and pushsymlink: Script to create a plugin symlink in the WordPress directory
Scripts in the scripts/ folder
sync-version.js: Syncs the version betweenpackage.json, the main PHP file, andblock.jsoncreate-symlink.js: Creates the plugin symlink inwp-content/pluginsupdate-git.js: Simplifies the commit and push process
.gitignore updates
Adds standard entries for build artifacts, logs, etc.
Available scripts
After applying the setup, you can run:
# Create plugin symlink
npm run symlink
# Commit and push
npm run updateGIT
# Build (automatically updates version)
npm run buildRepository structure
carmo-wp-plugin-addons/
├── setups/
│ └── create-block-carmo-addon/
│ ├── setup/
│ │ ├── create-symlink.js
│ │ ├── sync-version.js
│ │ └── update-git.js
│ ├── .gitignore
│ └── package-scripts.json
├── setup.js
├── package.json
├── .npmignore
└── README.mdDevelopment
To test locally:
npm link
cd /path/to/wordpress-project
npx @carmopereira/wp-plugin-addonsPublish to npm
npm login
npm publish --access publicLicense
GPL-2.0-or-later
