wordpress-plugin-sanitizer is a CLI tool designed to streamline the release process of WordPress plugins by removing unnecessary files before deployment. It ensures your plugin trunk is clean, lightweight, and production-ready when pushing updates to the WordPress Plugin Repository.
- Cleans plugin directories before release.
- Removes development-only files (e.g., tests, build tools, dotfiles, node modules).
- Ensures only the necessary production files are included in the plugin trunk.
- Copies a validated plugin source tree into an SVN trunk, overwriting matching files and directories.
The project requires the .NET 10 SDK.
To build and package this tool for macOS use via zip distribution run the following:
chmod +x build-and-package-macos.sh
./build-and-package-macos.sh
This will produce a dist folder with a zip file inside. The zip file is to be distributed for use.
Download the zip file and place zip file where you want the program to files to be. unzip wordpress-plugin-sanitizer-macos.zip then run the following
cd wordpress-plugin-sanitizer
chmod +x install.sh uninstall.sh
./install.shYou may be prompted to input your mac password; after that is down try running the following:
wordpress-plugin-sanitizer --helpTo uninstall the tool run the following:
./uninstall.shYou may be prompted to input your mac password to finish the process.
Removes unnecessary files and folders from a specified base directory. Intended for use on the trunk/ directory of a plugin's Subversion repository before tagging or pushing a new release.
wordpress-plugin-sanitizer clean --base-dir /path/to/your/plugin/trunkExample:
wordpress-plugin-sanitizer clean --base-dir /Users/kash/Documents/WordPress-Release/svnversion/idx-broker-platinum/trunk| Argument | Description | Required |
|---|---|---|
--base-dir |
Path to the trunk/ directory of your plugin repo. |
✅ Yes |
Recursively copies a WordPress plugin source directory into an SVN trunk directory. Existing files with the same name are overwritten, while unrelated files already in the target are preserved.
Before copying, the command verifies that idx-broker-platinum.php exists directly inside the source directory. If it is missing, the command stops without modifying the target.
wordpress-plugin-sanitizer copy --src-dir /path/to/plugin/source --tar-dir /path/to/plugin/trunkExample:
wordpress-plugin-sanitizer copy \
--src-dir /Users/kash/Documents/idx-broker-platinum \
--tar-dir /Users/kash/Documents/WordPress-Release/svnversion/idx-broker-platinum/trunk| Argument | Description | Required |
|---|---|---|
--src-dir |
Plugin source directory containing the validated code. | ✅ Yes |
--tar-dir |
Destination SVN trunk/ directory. |
✅ Yes |
The tool removes common development-related files and directories, including:
.git/,.github/,.gitignoretests/,*.test.js,*.spec.jsnode_modules/,package.json,package-lock.json,yarn.lock, and more!- Any other files configured for exclusion in future versions
Note: The list may be expanded via config in future updates.
wordpress-plugin-sanitizer clean --base-dir ./wordpress-plugin-repo/trunkThis command will recursively clean up the trunk/ directory, removing all files not needed for production.
trunk/
├── .git/
├── node_modules/
├── src/
├── build/
├── plugin-name.php
├── readme.txt
trunk/
├── plugin-name.php
├── readme.txt
- Run this tool as a final step before tagging a release.
- Always keep your development tools and files outside the
trunk/directory or exclude them manually before using this tool.
This tool modifies your directory in place. It is recommended to:
- Commit all changes before running the command.
- Work on a copy if you're unsure.
- Add config file support for custom exclusions
- Add
dry-runmode for previewing deletions - Integration with
wp-cli - Tagging and changelog automation
Developed by Kasheen Mowatt
License: MIT