From c8b253824c2eccba7d35fae88d3ab7fddbdab5fd Mon Sep 17 00:00:00 2001 From: ingeniumed Date: Fri, 28 Jun 2024 15:39:01 +1000 Subject: [PATCH] Move the analytics flag to a function and disable it for non vip sites --- common/php/class-module.php | 18 ++++++++++++------ modules/settings/settings.php | 16 ---------------- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/common/php/class-module.php b/common/php/class-module.php index d9a3e262..de43cb4e 100644 --- a/common/php/class-module.php +++ b/common/php/class-module.php @@ -51,7 +51,7 @@ public function module_enabled( $slug ) { * * @since 0.10.0 * - * @return true, if the module is enabled, false otherwise + * @return true, if the feature is enabled, false otherwise */ protected function are_vip_features_enabled() { global $edit_flow; @@ -60,16 +60,22 @@ protected function are_vip_features_enabled() { } /** - * Returns whether vip features have been enabled or not. + * Returns whether analytics has been enabled or not. + * + * It's only enabled if the site is a production WPVIP site. * * @since 0.10.0 * - * @return true, if the module is enabled, false otherwise + * @return true, if analytics is enabled, false otherwise */ - protected function is_analytics_enabled() { - global $edit_flow; + public function is_analytics_enabled() { + // Check if the site is a production WPVIP site and only then enable it + $is_analytics_enabled = $this->is_vip_site( true ); + + // filter to disable it. + $is_analytics_enabled = apply_filters( 'ef_should_analytics_be_enabled', $is_analytics_enabled ); - return 'on' === $edit_flow->settings->module->options->analytics; + return $is_analytics_enabled; } /** diff --git a/modules/settings/settings.php b/modules/settings/settings.php index 2a919633..c1bf8cb4 100644 --- a/modules/settings/settings.php +++ b/modules/settings/settings.php @@ -23,7 +23,6 @@ public function __construct() { 'default_options' => array( 'enabled' => 'on', 'vip_features' => $this->is_vip_site() ? 'on' : 'off', - 'analytics' => $this->is_vip_site( true ) ? 'on' : 'off', ), 'configure_page_cb' => 'print_default_settings', 'autoload' => true, @@ -161,7 +160,6 @@ public function settings_page_controller() { */ public function register_settings() { add_settings_section( $this->module->options_group_name . '_general', false, '__return_false', $this->module->options_group_name ); - add_settings_field( 'analytics', __( 'Turn on analytics', 'edit-flow' ), array( $this, 'settings_analytics_option' ), $this->module->options_group_name, $this->module->options_group_name . '_general' ); add_settings_field( 'vip_features', __( 'Turn on WordPress VIP features', 'edit-flow' ), array( $this, 'settings_vip_features_option' ), $this->module->options_group_name, $this->module->options_group_name . '_general' ); } @@ -258,20 +256,6 @@ public function settings_vip_features_option() { echo ''; } - public function settings_analytics_option() { - $options = array( - 'off' => __( 'Disabled', 'edit-flow' ), - 'on' => __( 'Enabled', 'edit-flow' ), - ); - echo ''; - } - public function print_default_footer( $current_module ) { ?> slug ) : ?>