• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
Jetpack a2z

Jetpack a2z

Jetpack a2z

  • Home
  • Plugins
  • Blocks
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / Status::is_staging_site() – If is a staging site.

You appear to be a bot. Output may be restricted

Description

If is a staging site.

Usage

$bool = Status::is_staging_site();

Parameters

Returns

bool

TO DO

Add IDC detection to a package.

Source

File name: jetpack/vendor/automattic/jetpack-status/src/class-status.php


Lines:

1 to 76 of 76
  public function is_staging_site() {
    // Core's wp_get_environment_type allows for a few specific options. We should default to bowing out gracefully for anything other than production or local.
    $is_staging = ! in_array( \wp_get_environment_type(), array( 'production', 'local' ), true );

    $known_staging = array(
      'urls'      => array(
        '#\.staging\.wpengine\.com$#i', // WP Engine.
        '#\.staging\.kinsta\.com$#i',   // Kinsta.com.
        '#\.kinsta\.cloud$#i',          // Kinsta.com.
        '#\.stage\.site$#i',            // DreamPress.
        '#\.newspackstaging\.com$#i',   // Newspack.
        '#\.pantheonsite\.io$#i',       // Pantheon.
        '#\.flywheelsites\.com$#i',     // Flywheel.
        '#\.flywheelstaging\.com$#i',   // Flywheel.
        '#\.cloudwaysapps\.com$#i',     // Cloudways.
        '#\.azurewebsites\.net$#i',     // Azure.
        '#\.wpserveur\.net$#i',         // WPServeur.
        '#\-liquidwebsites\.com$#i',    // Liquidweb.
      ),
      'constants' => array(
        'IS_WPE_SNAPSHOT',      // WP Engine.
        'KINSTA_DEV_ENV',       // Kinsta.com.
        'WPSTAGECOACH_STAGING', // WP Stagecoach.
        'JETPACK_STAGING_MODE', // Generic.
        'WP_LOCAL_DEV',         // Generic.
      ),
    );
    
/**
 * 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, wp_parse_url( site_url(), PHP_URL_HOST ) ) ) {
          $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 && method_exists( 'Jetpack', 'validate_sync_error_idc_option' ) && \Jetpack::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 );
  }
 

 View on GitHub View on Trac

Share this:

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Pinterest (Opens in new window)

Related

Published: 4 April 2020 | Last updated: 10 December 2020

Primary Sidebar

Information

Function name: Status::is_staging_site
Class ref: Status
Plugin ref: Jetpack
Version: 9.2
Sourcefile: vendor/automattic/jetpack-status/src/class-status.php
File ref: vendor/automattic/jetpack-status/src/class-status.php
Deprecated?: No
API Letters: I,S

Footer

Jetpack a2z
Jetpack a2z
Jetpack a2z
WordPress 5.6
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  jetpack.wp-a2z.org
© Copyright Jetpack a2z 2014-2021. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites