Skip to content

For developers

Filters for hosts, agencies and plugin authors. Add them in a must-use plugin or in your plugin's main file, so they are in place before the plugin decides. For most sites, the wp-config.php settings on the Settings page are simpler.

Decide whether the site is a staging site

add_filter( 'gorilla_staging_guard_is_copy', function ( $is_copy ) {
    return 'staging.example.com' === wp_parse_url( home_url(), PHP_URL_HOST ) ? true : $is_copy;
} );

Return true for a staging site, false for the live site, or null to let the plugin decide. It overrides everything except GORILLA_STAGING_GUARD_DISABLE. The Status tab then says "Code on this site says …".

Words that mean a staging site

gorilla_staging_guard_copy_words filters the words that mark an address as a staging site. Each word matches as a whole part of a subdomain or folder name, optionally numbered (staging, staging-2, dev1), never inside another word.

The default words:

Environment shown Words
Staging staging, stage, stag, stg, preprod, preprd, preproduction, preview, demo, beta, alpha, canary, backup, bak, bkp, clone, copy, mirror, snapshot, restore, recovery, migration, migrate, temp, tmp, old, new, wip, training
Test testing, test, tst, qa, qas, qat, sit
Development development, develop, devel, devs, dev
Local local, localhost
Acceptance acceptance, accept, uat
Sandbox sandbox, sbx
add_filter( 'gorilla_staging_guard_copy_words', function ( $words ) {
    $words[] = 'review';
    return $words;
} );

A word added here marks a staging site; the admin bar then shows "Env: Staging".

Other domains of the live site

A staging site refuses requests to the live site's host. If the live site also answers at other domains, for example the other stores of a multi-store network, name them:

add_filter( 'gorilla_staging_guard_live_hosts', function ( $hosts ) {
    $hosts[] = 'shop.example.org';
    return $hosts;
} );

Host names without www.; a host never matches its subdomains.

Payment gateways

gorilla_staging_guard_gateways lists the gateways held in test mode. Each entry has a label and the options the gateway reads its mode from: option name => [ key => test-mode value ], with the key '' for a switch stored as a whole option.

add_filter( 'gorilla_staging_guard_gateways', function ( $gateways ) {
    $gateways['my_gateway'] = array(
        'label'   => 'My Gateway',
        'options' => array( 'woocommerce_my_gateway_settings' => array( 'testmode' => 'yes' ) ),
    );
    return $gateways;
} );

Add the filter when your plugin's file loads, or on plugins_loaded. The value is read as test mode on a staging site and never saved.

Email services

gorilla_staging_guard_email_provider_hosts lists the email services a staging site may not reach. Each host also covers its subdomains.

add_filter( 'gorilla_staging_guard_email_provider_hosts', function ( $hosts ) {
    $hosts[] = 'api.mail.example.net';
    return $hosts;
} );

Mailers that can still send

gorilla_staging_guard_uninterceptable_mailers filters the names the Status tab lists as mailers a staging site cannot stop. Add your plugin's name if it sends on its own connection; remove it once your plugin stops on a staging site.

Your own self-test rows

gorilla_staging_guard_self_test_checks filters the self-test's results, to add checks for other protections. Each result is an array of id, label, status (working, partial, failing or unused) and detail. The rows show on the Status tab and in wp staging-guard test.