Skip to content

WP-CLI

Two commands let hosts, agencies and deploy scripts check a site from the command line.

wp staging-guard status

Says whether the site is treated as a staging site, and why.

wp staging-guard status
wp staging-guard status --format=json
Field Meaning
state The verdict's name, such as declared, address or original (the reasons)
copy yes on a staging site
this_address This site's address
live_address The live site's recorded address
declared_source, declared_env What wp-config.php or the hosting says, if anything
reason The reason, as on the Status tab
email stopped or sent
scheduled_tasks paused or running
gateways_held The payment gateways held in test mode

wp staging-guard test

Runs the self-test and prints one row per protection: id, status (working, partial, failing, unused) and detail.

wp staging-guard test
wp staging-guard test --format=json

On the live site it shows what a staging site made from it would do, without changing anything, and says so. Only the results go to standard output, so --format=json, csv or yaml can be read by a script; messages go to standard error.

Check that a site is a staging site

On a staging site, add --expect-staging so the command also fails when the site is not treated as one:

wp staging-guard test --expect-staging

Use it in a deploy or sync script, straight after copying the live site, before anything else runs. --expect-copy is the same option under its older name.

Exit codes

Exit code When
0 Every protection in use works, or some are partial (a warning says so)
1 A protection is not working
1 With --expect-staging: the site is not treated as a staging site
1 The plugin is switched off in wp-config.php
1 On a site whose live address is not known yet, so a staging site made from it would not be recognised

A deploy script can stop on exit code 1:

wp staging-guard test --expect-staging || exit 1