Skip to content

KashIDX/wordpress-plugin-sanitizer

Repository files navigation

WordPress Plugin Sanitizer

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.


🚀 Features

  • 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.

Build

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.

Install

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.sh

You may be prompted to input your mac password; after that is down try running the following:

wordpress-plugin-sanitizer --help

Uninstall

To uninstall the tool run the following:

./uninstall.sh

You may be prompted to input your mac password to finish the process.

🛠 Command

clean

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.

Usage

wordpress-plugin-sanitizer clean --base-dir /path/to/your/plugin/trunk

Example:

wordpress-plugin-sanitizer clean --base-dir /Users/kash/Documents/WordPress-Release/svnversion/idx-broker-platinum/trunk

Arguments

Argument Description Required
--base-dir Path to the trunk/ directory of your plugin repo. ✅ Yes

🧹 What It Removes

The tool removes common development-related files and directories, including:

  • .git/, .github/, .gitignore
  • tests/, *.test.js, *.spec.js
  • node_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.


📦 Example

wordpress-plugin-sanitizer clean --base-dir ./wordpress-plugin-repo/trunk

This command will recursively clean up the trunk/ directory, removing all files not needed for production.


📁 Example Directory Before

trunk/
├── .git/
├── node_modules/
├── src/
├── build/
├── plugin-name.php
├── readme.txt

✅ Example Directory After

trunk/
├── plugin-name.php
├── readme.txt

💡 Best Practices

  • 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.

🔒 Safety

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.

📅 Roadmap

  • Add config file support for custom exclusions
  • Add dry-run mode for previewing deletions
  • Integration with wp-cli
  • Tagging and changelog automation

👤 Author

Developed by Kasheen Mowatt

License: MIT


About

Repo for the sanitizer for the wordpress plugin deployment

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published