wpconstructor / scripts
WPConstructor Scripts: Composer-driven PHP scripts for building, backing up, and distributing WordPress plugins consistently and safely.
This package is auto-updated.
Last update: 2026-04-01 13:37:14 UTC
README
A collection of Composer-driven PHP scripts for building, backing up, and distributing WordPress plugins consistently and safely.
Why I Built WPConstructor Scripts
While building WordPress plugins, I kept repeating the same Composer scripts—copying assets, creating ZIPs, backing up files, and securing directories. It became repetitive and error-prone.
So I built WPConstructor Scripts: a reusable setup that handles all the common plugin build tasks in one place, instead of rewriting them every time.
Installation
Install WPConstructor Scripts via Composer as a dev dependency:
composer require wpconstructor/scripts --dev
Then, add the following to your plugin’s composer.json under the "scripts" section:
"scripts": { "build:update": "php vendor/wpconstructor/scripts/scripts/build-vendor.php && php vendor/wpconstructor/scripts bin/copy-assets.php && php vendor/wpconstructor/scripts/scripts/add-index-php.php && npx @wpconstructor minify-assets assets", "build": "php vendor/wpconstructor/scripts/bin/run-build.php", "cfp": "php vendor/wpconstructor/scripts/bin/cfp.php", "clean": "php vendor/wpconstructor/scripts/bin/clean.php", "backup:packages": "php vendor/wpconstructor/scripts/bin/backup-packages.php", "backup:plugin": "php vendor/wpconstructor/scripts/bin/backup-plugin.php", "backup:all-plugins": "php vendor/wpconstructor/scripts/bin/backup-all-plugins.php" }
Usage Examples
Asset & Security Helpers
- Build Update
composer run build:update
Updates plugin assets to the correct directories, creating nested folders like:
assets/wpconstructor/dashboard/images.
- Add Index Files (included in build)
Automatically addsindex.phpto all asset directories to prevent directory listing.
Build & Distribution
- Build Plugin
composer run build
Runs the full build process:
- Copies vendor files to
dist-vendor - Removes empty directories
- Adds
index.phpfiles - Creates a distributable ZIP in
dist/plugin-name-version-date.zip
- Clean Project
composer run clean
Removes empty directories and cleans build artifacts.
Maintenance Utilities
- Check File Permissions
composer run cfp
Scans your WordPress installation for files without write permissions.
Backup Scripts
- Backup Current Plugin
composer run backup:plugin
Creates a backup of the current plugin in wordpress-root/../plugin-backups.
- Backup All Plugins
composer run backup:all-plugins
Backs up all plugins to wordpress-root/../all-plugins-backup.
Optional:
composer run backup:all-plugins -- --only-wpconstr
- Backup Packages Directory
composer run backup:packages
Backs up the entire packages directory to wordpress-root/../packages-backup.
One Workflow, Everywhere
With WPConstructor Scripts, every plugin build looks the same:
- Assets copied
- Vendors trimmed
- Empty directories removed
- Index files added
- ZIP created
- Backups secured
No guessing. No half-forgotten steps. No copy-pasting scripts between repos.
License
MIT License © 2026 by WPConstructor