Bash script that finds WordPress installs on cPanel, DirectAdmin, or Plesk servers and installs a single-file plugin that rejects unauthenticated REST batch API (/batch/v1) requests.
- Run on the hosting server as root
- Bash 4+
- Optional: WP-CLI or PHP CLI (for auto-activation)
WP-CLI is not required. If it is missing, the script falls back to PHP CLI. If that also fails, it prints manual wp-admin steps.
chmod +x deploy-disable-batch-api.sh
sudo bash deploy-disable-batch-api.shDry run (list sites and intended actions, no changes):
sudo bash deploy-disable-batch-api.sh --dry-runVerbose discovery output:
sudo bash deploy-disable-batch-api.sh --verboseOnly creates the plugin file and prints how to activate it in wp-admin. Use this when WP-CLI is not installed and you prefer not to use PHP CLI activation:
sudo bash deploy-disable-batch-api.sh --manual| Mode | What happens |
|---|---|
| Default | 1) WP-CLI → 2) PHP CLI activate_plugin() → 3) print manual steps |
--manual |
Create file only; print wp-admin activation steps for each site |
- Log into WordPress admin
- Open Plugins
- Activate Disable Unauthenticated REST Batch API
The plugin file path is:
/path/to/wordpress/wp-content/plugins/disable-batch-api-for-unauth.php
- Scans common document roots (
/home/*/public_html, DirectAdmin domain paths, Pleskhttpdocs, etc.) - Locates WordPress installs (
wp-config.php+wp-content/) - Writes
wp-content/plugins/disable-batch-api-for-unauth.php - Sets ownership to match the
pluginsdirectory (chown --reference) - Activates via WP-CLI or PHP when possible; otherwise instructs you to activate manually
Safe to re-run; the plugin file is overwritten so content stays correct.