From 60f04b0c947fcdcf95423049e0e7278963abf892 Mon Sep 17 00:00:00 2001 From: ingeniumed Date: Tue, 25 Jun 2024 11:41:42 +1000 Subject: [PATCH] Correct the vip site detection check to work for vip dev-env as well --- common/php/class-module.php | 16 ++++++++++++---- modules/settings/settings.php | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/common/php/class-module.php b/common/php/class-module.php index 619ee327..d9a3e262 100644 --- a/common/php/class-module.php +++ b/common/php/class-module.php @@ -76,12 +76,20 @@ protected function is_analytics_enabled() { * Check if the site is a WPVIP site. * * @since 0.10.0 + * + * @param bool $only_production Whether to only allow production sites to be considered WPVIP sites * @return true, if it is a WPVIP site, false otherwise */ - protected function is_vip_site() { - return defined( 'WPCOM_IS_VIP_ENV' ) && constant( 'WPCOM_IS_VIP_ENV' ) === true - && defined( 'WPCOM_SANDBOXED' ) && constant( 'WPCOM_SANDBOXED' ) === false - && defined( 'FILES_CLIENT_SITE_ID' ); + protected function is_vip_site( $only_production = false ) { + $is_vip_site = defined( 'VIP_GO_ENV' ) + && defined( 'WPCOM_SANDBOXED' ) && constant( 'WPCOM_SANDBOXED' ) === false + && defined( 'FILES_CLIENT_SITE_ID' ); + + if ( $only_production ) { + $is_vip_site = $is_vip_site && defined( 'VIP_GO_ENV' ) && 'production' === constant( 'VIP_GO_ENV' ); + } + + return $is_vip_site; } /** diff --git a/modules/settings/settings.php b/modules/settings/settings.php index cd3e22bf..c389ec12 100644 --- a/modules/settings/settings.php +++ b/modules/settings/settings.php @@ -23,7 +23,7 @@ public function __construct() { 'default_options' => array( 'enabled' => 'on', 'vip_features' => $this->is_vip_site() ? 'on' : 'off', - 'analytics' => $this->is_vip_site() ? 'on' : 'off', + 'analytics' => $this->is_vip_site( true ) ? 'on' : 'off', ), 'configure_page_cb' => 'print_default_settings', 'autoload' => true,