summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/vendor/automattic/jetpack-status/src/class-status.php')
-rw-r--r--plugins/jetpack/vendor/automattic/jetpack-status/src/class-status.php68
1 files changed, 68 insertions, 0 deletions
diff --git a/plugins/jetpack/vendor/automattic/jetpack-status/src/class-status.php b/plugins/jetpack/vendor/automattic/jetpack-status/src/class-status.php
index f87ca9af..5a299056 100644
--- a/plugins/jetpack/vendor/automattic/jetpack-status/src/class-status.php
+++ b/plugins/jetpack/vendor/automattic/jetpack-status/src/class-status.php
@@ -80,4 +80,72 @@ class Status {
}
return 1 === (int) $some_users;
}
+
+ /**
+ * If is a staging site.
+ *
+ * @todo Add IDC detection to a package.
+ *
+ * @return bool
+ */
+ public function is_staging_site() {
+ $is_staging = false;
+
+ $known_staging = array(
+ 'urls' => array(
+ '#\.staging\.wpengine\.com$#i', // WP Engine.
+ '#\.staging\.kinsta\.com$#i', // Kinsta.com.
+ '#\.stage\.site$#i', // DreamPress.
+ ),
+ 'constants' => array(
+ 'IS_WPE_SNAPSHOT', // WP Engine.
+ 'KINSTA_DEV_ENV', // Kinsta.com.
+ 'WPSTAGECOACH_STAGING', // WP Stagecoach.
+ 'JETPACK_STAGING_MODE', // 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, 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 && 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 );
+ }
}