Jetpack::is_staging_site PHP Method

is_staging_site() public static method

Checks whether the home and siteurl specifically are whitelisted Written so that we don't have re-check $key and $value params every time we want to check if this site is whitelisted, for example in footer.php
Since: 3.8.0
public static is_staging_site ( ) : boolean
return boolean True = already whitelisted False = not whitelisted
    public static function is_staging_site()
    {
        $is_staging = false;
        $known_staging = array('urls' => array('#\\.staging\\.wpengine\\.com$#i', '#\\.staging\\.kinsta\\.com$#i'), 'constants' => array('IS_WPE_SNAPSHOT', 'KINSTA_DEV_ENV', 'WPSTAGECOACH_STAGING', 'JETPACK_STAGING_MODE'));
        /**
         * Filters the flags of known staging sites.
         *
         * @since 3.9.0
         *
         * @param array $known_staging {
         *     An array of arrays that each are used to check if the current site is staging.
         *     @type array $urls      URLs of staging sites in regex to check against site_url.
         *     @type array $constants PHP constants of known staging/developement environments.
         *  }
         */
        $known_staging = apply_filters('jetpack_known_staging', $known_staging);
        if (isset($known_staging['urls'])) {
            foreach ($known_staging['urls'] as $url) {
                if (preg_match($url, site_url())) {
                    $is_staging = true;
                    break;
                }
            }
        }
        if (isset($known_staging['constants'])) {
            foreach ($known_staging['constants'] as $constant) {
                if (defined($constant) && constant($constant)) {
                    $is_staging = true;
                }
            }
        }
        // Last, let's check if sync is erroring due to an IDC. If so, set the site to staging mode.
        if (!$is_staging && self::validate_sync_error_idc_option()) {
            $is_staging = true;
        }
        /**
         * Filters is_staging_site check.
         *
         * @since 3.9.0
         *
         * @param bool $is_staging If the current site is a staging site.
         */
        return apply_filters('jetpack_is_staging_site', $is_staging);
    }

Usage Example

    _e('Disconnect Jetpack', 'jetpack');
    ?>
</h4>
						<a class="button" id="jetpack-disconnect" href="#"><?php 
    esc_html_e('Disconnect site from WordPress.com', 'jetpack');
    ?>
</a>
					</div>
				</div>

				<div id="jetpack-disconnect-content">
					<div class="j-row">
						<div class="j-col j-lrg-12 j-md-12 j-sm-12">

							<?php 
    if (!Jetpack::is_staging_site()) {
        ?>
								<h2><?php 
        _e('Disconnecting Jetpack', 'jetpack');
        ?>
</h2>
								<p><?php 
        _e('Before you completely disconnect Jetpack is there anything we can do to help?', 'jetpack');
        ?>
</p>
								<a class="button" id="confirm-disconnect" title="<?php 
        esc_attr_e('Disconnect Jetpack', 'jetpack');
        ?>
" href="<?php 
        echo wp_nonce_url(Jetpack::admin_url('action=disconnect'), 'jetpack-disconnect');
        ?>
All Usage Examples Of Jetpack::is_staging_site
Jetpack