WP-CLI Support
WP Rollback Pro includes full WP-CLI support, giving developers and agencies a first-class terminal interface for listing available versions and executing rollbacks — including Plugin Vault versions and local backups — without touching the WordPress admin.
Pro Feature
WP-CLI commands are available exclusively in WP Rollback Pro. An active license is required. See Licensing for details.
Prerequisites
- WP-CLI v2.0 or later installed and accessible as
wp - WP Rollback Pro installed and activated with a valid license
- WordPress CLI user with
update_pluginsorupdate_themescapability (see Running as a specific user)
Command Reference
WP Rollback Pro registers two command groups under the wp rollback namespace:
| Command group | Targets |
|---|---|
wp rollback plugin | Installed plugins |
wp rollback theme | Installed themes |
Each group exposes two subcommands: list and run.
wp rollback plugin list <slug>
List all available versions for an installed plugin.
wp rollback plugin list <slug> [--format=<format>]Arguments
| Argument | Required | Description |
|---|---|---|
<slug> | Yes | The plugin slug (e.g. woocommerce, gravity-forms) |
--format | No | Output format: table (default), json, csv, yaml |
Examples
# List versions in a table
wp rollback plugin list woocommerce
# Output as JSON for scripting
wp rollback plugin list woocommerce --format=json
# Pipe CSV output for spreadsheet import
wp rollback plugin list woocommerce --format=csvSample table output
+---------+--------------+------------+---------+
| version | source | released | current |
+---------+--------------+------------+---------+
| 9.2.0 | wordpress.org| — | |
| 9.0.0 | wordpress.org| — | |
| 8.9.1 | vault | 2024-11-05 | |
| 8.7.0 | vault | 2024-09-18 | |
| 8.4.0 | wordpress.org| — | * |
| 8.0.0 | local | — | |
+---------+--------------+------------+---------+The source column indicates where each version comes from:
| Source | Description |
|---|---|
wordpress.org | Available from the WordPress.org repository |
vault | Available in Plugin Vault (Pro, requires licence) |
local | Backed up locally on this server by WP Rollback Pro |
wp rollback theme list <slug>
List all available versions for an installed theme.
wp rollback theme list <slug> [--format=<format>]Usage is identical to wp rollback plugin list. Replace the slug with your theme's directory name.
wp rollback theme list astra
wp rollback theme list astra --format=jsonwp rollback plugin run <slug> <version>
Roll back an installed plugin to a specific version.
wp rollback plugin run <slug> <version> [--force]Arguments
| Argument | Required | Description |
|---|---|---|
<slug> | Yes | The plugin slug |
<version> | Yes | The target version string (e.g. 8.4.0) |
--force | No | Skip the interactive confirmation prompt |
What happens during a run
The command executes the complete WP Rollback Pro pipeline — the same steps triggered by the admin UI:
- Maintenance mode — puts the site in maintenance mode to protect visitors
- Download asset — fetches the target version (from Plugin Vault, local backup, or WordPress.org)
- Backup current version — creates a local backup of the currently-installed files
- Validate package — verifies the ZIP structure (Pro)
- Verify asset — confirms the SHA-256 checksum of the downloaded file (Pro)
- Replace asset — swaps the files on disk
- Cleanup — removes temporary files and disables maintenance mode
Examples
# Interactive rollback with confirmation prompt
wp rollback plugin run woocommerce 8.4.0
# Skip confirmation (useful in deployment scripts)
wp rollback plugin run woocommerce 8.4.0 --force
# Run as a specific WordPress user
wp rollback plugin run woocommerce 8.4.0 --force --user=adminSample output
Roll back plugin "woocommerce" to version 8.4.0? [y/n] y
Rolling back "woocommerce" to 8.4.0 100% [====================================] 0:00 / 0:00
— Enabling maintenance mode
— Downloading asset
— Backing up current version
— Validating package
— Verifying asset integrity
— Replacing asset
— Cleaning up
Success: Successfully rolled back plugin "woocommerce" to version 8.4.0.wp rollback theme run <slug> <version>
Roll back an installed theme to a specific version.
wp rollback theme run <slug> <version> [--force]Usage is identical to wp rollback plugin run.
wp rollback theme run astra 3.9.0
wp rollback theme run astra 3.9.0 --forceRunning as a Specific User
WP-CLI can run as any WordPress user via the global --user flag. For rollback operations, the user must have the update_plugins or update_themes capability.
# Run as user with ID 1
wp rollback plugin run woocommerce 8.4.0 --user=1
# Run as a user by login
wp rollback plugin run woocommerce 8.4.0 --user=adminWhen --user is omitted, WP Rollback Pro automatically uses the first available administrator account for the duration of the operation so that WordPress API calls work correctly.
Using in Deployment Scripts
The --force flag makes the run command fully non-interactive, which is ideal for CI/CD pipelines, staging deployments, or automated recovery workflows.
#!/bin/bash
# Roll back woocommerce and exit with the WP-CLI status code
wp rollback plugin run woocommerce 8.4.0 --force --user=admin
echo "Rollback exited with status $?"WP-CLI exits with code 0 on success and a non-zero code on failure, so you can use standard shell error handling:
wp rollback plugin run woocommerce 8.4.0 --force --user=admin || {
echo "Rollback failed — check WP-CLI output above"
exit 1
}Plugin Vault in the CLI
When you run wp rollback plugin list <slug> for a premium plugin, versions sourced from Plugin Vault are shown with source: vault. The run command will automatically use the Vault as a source when the target version is available there.
Vault Licence Requirement
You must hold a valid, active licence for any plugin or theme you roll back via Plugin Vault — the same requirement as the admin UI. See Plugin Vault for full details.
Vault authentication happens automatically using your stored JWT token. If the token has expired, WP Rollback Pro will silently re-authenticate via your active Pro licence before proceeding.
Troubleshooting
"Could not retrieve version data" on list
This usually means the slug does not match an installed plugin or theme. Verify with:
wp plugin list --fields=name,slug,status
wp theme list --fields=name,slug,status"Rollback failed: …" during run
Check the error message displayed after the failing step. Common causes:
- The target version is not available from any source (Vault, local, or WordPress.org)
- Insufficient filesystem permissions to replace plugin files
- SHA-256 verification failed — the downloaded ZIP may be corrupted
If maintenance mode is left active after a failed rollback, disable it manually:
wp maintenance-mode deactivateVault versions not appearing in list
Ensure your WP Rollback Pro licence is active and the site has successfully authenticated with Plugin Vault. Check the WP Rollback Pro settings page in wp-admin for vault status.