Skip to content

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_plugins or update_themes capability (see Running as a specific user)

Command Reference

WP Rollback Pro registers two command groups under the wp rollback namespace:

Command groupTargets
wp rollback pluginInstalled plugins
wp rollback themeInstalled themes

Each group exposes two subcommands: list and run.


wp rollback plugin list <slug>

List all available versions for an installed plugin.

bash
wp rollback plugin list <slug> [--format=<format>]

Arguments

ArgumentRequiredDescription
<slug>YesThe plugin slug (e.g. woocommerce, gravity-forms)
--formatNoOutput format: table (default), json, csv, yaml

Examples

bash
# 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=csv

Sample 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:

SourceDescription
wordpress.orgAvailable from the WordPress.org repository
vaultAvailable in Plugin Vault (Pro, requires licence)
localBacked up locally on this server by WP Rollback Pro

wp rollback theme list <slug>

List all available versions for an installed theme.

bash
wp rollback theme list <slug> [--format=<format>]

Usage is identical to wp rollback plugin list. Replace the slug with your theme's directory name.

bash
wp rollback theme list astra
wp rollback theme list astra --format=json

wp rollback plugin run <slug> <version>

Roll back an installed plugin to a specific version.

bash
wp rollback plugin run <slug> <version> [--force]

Arguments

ArgumentRequiredDescription
<slug>YesThe plugin slug
<version>YesThe target version string (e.g. 8.4.0)
--forceNoSkip 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:

  1. Maintenance mode — puts the site in maintenance mode to protect visitors
  2. Download asset — fetches the target version (from Plugin Vault, local backup, or WordPress.org)
  3. Backup current version — creates a local backup of the currently-installed files
  4. Validate package — verifies the ZIP structure (Pro)
  5. Verify asset — confirms the SHA-256 checksum of the downloaded file (Pro)
  6. Replace asset — swaps the files on disk
  7. Cleanup — removes temporary files and disables maintenance mode

Examples

bash
# 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=admin

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

bash
wp rollback theme run <slug> <version> [--force]

Usage is identical to wp rollback plugin run.

bash
wp rollback theme run astra 3.9.0
wp rollback theme run astra 3.9.0 --force

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

bash
# 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=admin

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

bash
#!/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:

bash
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:

bash
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:

bash
wp maintenance-mode deactivate

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

Released under the GPL-2.0+ License.