Skip to content

Commit 13570e4

Browse files
authored
Merge pull request #737 from Automattic/update/analytics-flag
Update the analytics flag
2 parents a81f39c + c8b2538 commit 13570e4

File tree

2 files changed

+12
-22
lines changed

2 files changed

+12
-22
lines changed

common/php/class-module.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function module_enabled( $slug ) {
5151
*
5252
* @since 0.10.0
5353
*
54-
* @return true, if the module is enabled, false otherwise
54+
* @return true, if the feature is enabled, false otherwise
5555
*/
5656
protected function are_vip_features_enabled() {
5757
global $edit_flow;
@@ -60,16 +60,22 @@ protected function are_vip_features_enabled() {
6060
}
6161

6262
/**
63-
* Returns whether vip features have been enabled or not.
63+
* Returns whether analytics has been enabled or not.
64+
*
65+
* It's only enabled if the site is a production WPVIP site.
6466
*
6567
* @since 0.10.0
6668
*
67-
* @return true, if the module is enabled, false otherwise
69+
* @return true, if analytics is enabled, false otherwise
6870
*/
69-
protected function is_analytics_enabled() {
70-
global $edit_flow;
71+
public function is_analytics_enabled() {
72+
// Check if the site is a production WPVIP site and only then enable it
73+
$is_analytics_enabled = $this->is_vip_site( true );
74+
75+
// filter to disable it.
76+
$is_analytics_enabled = apply_filters( 'ef_should_analytics_be_enabled', $is_analytics_enabled );
7177

72-
return 'on' === $edit_flow->settings->module->options->analytics;
78+
return $is_analytics_enabled;
7379
}
7480

7581
/**

modules/settings/settings.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public function __construct() {
2323
'default_options' => array(
2424
'enabled' => 'on',
2525
'vip_features' => $this->is_vip_site() ? 'on' : 'off',
26-
'analytics' => $this->is_vip_site( true ) ? 'on' : 'off',
2726
),
2827
'configure_page_cb' => 'print_default_settings',
2928
'autoload' => true,
@@ -161,7 +160,6 @@ public function settings_page_controller() {
161160
*/
162161
public function register_settings() {
163162
add_settings_section( $this->module->options_group_name . '_general', false, '__return_false', $this->module->options_group_name );
164-
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' );
165163
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' );
166164
}
167165

@@ -258,20 +256,6 @@ public function settings_vip_features_option() {
258256
echo '</select>';
259257
}
260258

261-
public function settings_analytics_option() {
262-
$options = array(
263-
'off' => __( 'Disabled', 'edit-flow' ),
264-
'on' => __( 'Enabled', 'edit-flow' ),
265-
);
266-
echo '<select id="analytics" name="' . esc_attr( $this->module->options_group_name ) . '[analytics]">';
267-
foreach ( $options as $value => $label ) {
268-
echo '<option value="' . esc_attr( $value ) . '"';
269-
echo selected( $this->module->options->analytics, $value );
270-
echo '>' . esc_html( $label ) . '</option>';
271-
}
272-
echo '</select>';
273-
}
274-
275259
public function print_default_footer( $current_module ) {
276260
?>
277261
<?php if ( 'settings' == $current_module->slug ) : ?>

0 commit comments

Comments
 (0)