Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions common/php/class-module.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

/**
Expand Down
16 changes: 0 additions & 16 deletions modules/settings/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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' );
}

Expand Down Expand Up @@ -258,20 +256,6 @@ public function settings_vip_features_option() {
echo '</select>';
}

public function settings_analytics_option() {
$options = array(
'off' => __( 'Disabled', 'edit-flow' ),
'on' => __( 'Enabled', 'edit-flow' ),
);
echo '<select id="analytics" name="' . esc_attr( $this->module->options_group_name ) . '[analytics]">';
foreach ( $options as $value => $label ) {
echo '<option value="' . esc_attr( $value ) . '"';
echo selected( $this->module->options->analytics, $value );
echo '>' . esc_html( $label ) . '</option>';
}
echo '</select>';
}

public function print_default_footer( $current_module ) {
?>
<?php if ( 'settings' == $current_module->slug ) : ?>
Expand Down