public static function uninstall() { global $wpdb; if (is_multisite()) { // Cleanup Network install foreach (wp_get_sites(array('limit' => apply_filters('gadwp_sites_limit', 100))) as $blog) { switch_to_blog($blog['blog_id']); $sqlquery = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE 'gadwp_cache_%%'"); delete_option('gadash_options'); restore_current_blog(); } delete_site_option('gadash_network_options'); } else { // Cleanup Single install $sqlquery = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE 'gadwp_cache_%%'"); delete_option('gadash_options'); } GADWP_Tools::unset_cookie('default_metric'); GADWP_Tools::unset_cookie('default_dimension'); GADWP_Tools::unset_cookie('default_view'); }
private function maintain_compatibility() { $flag = false; if (GADWP_CURRENT_VERSION != get_option('gadwp_version')) { $rebuild_token = json_decode($this->options['ga_dash_token']); // v4.8.2 if (is_object($rebuild_token) && !isset($rebuild_token->token_type)) { if (isset($this->options['ga_dash_refresh_token'])) { $rebuild_token->refresh_token = $this->options['ga_dash_refresh_token']; } $rebuild_token->token_type = "Bearer"; $this->options['ga_dash_token'] = json_encode($rebuild_token); unset($this->options['ga_dash_refresh_token']); $this->set_plugin_options(true); } else { unset($this->options['ga_dash_refresh_token']); } GADWP_Tools::clear_cache(); GADWP_Tools::clear_transients(); // 4.8.3 to be removed after a few months $flag = true; GADWP_Tools::delete_cache('last_error'); update_option('gadwp_version', GADWP_CURRENT_VERSION); update_option('gadwp_got_updated', true); if (is_multisite()) { // Cleanup errors and cookies on the entire network foreach (wp_get_sites(array('limit' => apply_filters('gadwp_sites_limit', 100))) as $blog) { switch_to_blog($blog['blog_id']); GADWP_Tools::delete_cache('gapi_errors'); restore_current_blog(); } } else { GADWP_Tools::delete_cache('gapi_errors'); } GADWP_Tools::unset_cookie('default_metric'); GADWP_Tools::unset_cookie('default_dimension'); } if (!isset($this->options['ga_enhanced_links'])) { $this->options['ga_enhanced_links'] = 0; $flag = true; } if (!isset($this->options['ga_dash_network'])) { $this->options['ga_dash_network'] = 0; $flag = true; } if (!isset($this->options['ga_enhanced_excludesa'])) { $this->options['ga_dash_excludesa'] = 0; $flag = true; } if (!isset($this->options['ga_dash_remarketing'])) { $this->options['ga_dash_remarketing'] = 0; $flag = true; } if (!isset($this->options['ga_dash_adsense'])) { $this->options['ga_dash_adsense'] = 0; $flag = true; } if (!isset($this->options['ga_speed_samplerate'])) { $this->options['ga_speed_samplerate'] = 1; $flag = true; } if (!isset($this->options['automatic_updates_minorversion'])) { $this->options['automatic_updates_minorversion'] = 1; $flag = true; } if (!isset($this->options['ga_event_bouncerate'])) { $this->options['ga_event_bouncerate'] = 0; $flag = true; } if (!is_array($this->options['ga_dash_access_front']) || empty($this->options['ga_dash_access_front'])) { $this->options['ga_dash_access_front'] = array(); $this->options['ga_dash_access_front'][] = 'administrator'; $flag = true; } if (!is_array($this->options['ga_dash_profile_list'])) { $this->options['ga_dash_profile_list'] = array(); $flag = true; } if (!is_array($this->options['ga_dash_access_back']) || empty($this->options['ga_dash_access_back'])) { $this->options['ga_dash_access_back'] = array(); $this->options['ga_dash_access_back'][] = 'administrator'; $flag = true; } if (!is_array($this->options['ga_track_exclude'])) { $this->options['ga_track_exclude'] = array(); $flag = true; } if (!isset($this->options['ga_crossdomain_tracking'])) { $this->options['ga_crossdomain_tracking'] = 0; $flag = true; } if (!isset($this->options['ga_crossdomain_list'])) { $this->options['ga_crossdomain_list'] = ''; $flag = true; } if (!isset($this->options['ga_author_dimindex'])) { $this->options['ga_author_dimindex'] = 0; $flag = true; } if (!isset($this->options['ga_category_dimindex'])) { $this->options['ga_category_dimindex'] = 0; $flag = true; } if (!isset($this->options['ga_user_dimindex'])) { $this->options['ga_user_dimindex'] = 0; $flag = true; } if (!isset($this->options['ga_pubyear_dimindex'])) { $this->options['ga_pubyear_dimindex'] = 0; $flag = true; } if (!isset($this->options['ga_event_affiliates'])) { $this->options['ga_event_affiliates'] = '/out/'; $flag = true; } if (!isset($this->options['ga_aff_tracking'])) { $this->options['ga_aff_tracking'] = 0; $flag = true; } if (!isset($this->options['ga_hash_tracking'])) { $this->options['ga_hash_tracking'] = 0; $flag = true; } if (!isset($this->options['backend_item_reports'])) { // v4.8 $this->options['backend_item_reports'] = 1; $flag = true; } if (isset($this->options['ga_dash_default_metric'])) { // v4.8.1 unset($this->options['ga_dash_default_metric']); $flag = true; } if (isset($this->options['ga_dash_default_dimension'])) { // v4.8.1 unset($this->options['ga_dash_default_dimension']); $flag = true; } if (isset($this->options['item_reports'])) { // v4.8 $this->options['backend_item_reports'] = $this->options['item_reports']; unset($this->options['item_reports']); $flag = true; } if (isset($this->options['ga_dash_frontend_stats'])) { // v4.8 $this->options['frontend_item_reports'] = $this->options['ga_dash_frontend_stats']; unset($this->options['ga_dash_frontend_stats']); $flag = true; } if (!isset($this->options['dashboard_widget'])) { // v4.7 $this->options['dashboard_widget'] = 1; $flag = true; } if (!isset($this->options['api_backoff'])) { // v4.8.1.3 $this->options['api_backoff'] = 0; $flag = true; } if (isset($this->options['ga_tracking_code'])) { unset($this->options['ga_tracking_code']); $flag = true; } if (isset($this->options['ga_dash_frontend_keywords'])) { // v4.8 unset($this->options['ga_dash_frontend_keywords']); $flag = true; } if (isset($this->options['ga_dash_jailadmins'])) { // v4.7 if (isset($this->options['ga_dash_jailadmins'])) { $this->options['switch_profile'] = 0; unset($this->options['ga_dash_jailadmins']); $flag = true; } else { $this->options['switch_profile'] = 1; unset($this->options['ga_dash_jailadmins']); $flag = true; } } if ($flag) { $this->set_plugin_options(false); } }
/** * Handles the token reset process * * @param * $all */ public function reset_token($all = true) { $this->gadwp->config->options['ga_dash_token'] = ""; if ($all) { $this->gadwp->config->options['ga_dash_tableid_jail'] = ""; $this->gadwp->config->options['ga_dash_profile_list'] = array(); try { $this->client->revokeToken(); } catch (Exception $e) { if (is_multisite() && $this->gadwp->config->options['ga_dash_network']) { $this->gadwp->config->set_plugin_options(true); } else { $this->gadwp->config->set_plugin_options(); } } } if (is_multisite() && $this->gadwp->config->options['ga_dash_network']) { $this->gadwp->config->set_plugin_options(true); } else { $this->gadwp->config->set_plugin_options(); } GADWP_Tools::unset_cookie('default_metric'); GADWP_Tools::unset_cookie('default_dimension'); GADWP_Tools::unset_cookie('default_view'); }
public static function clear_cache() { global $wpdb; $sqlquery = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE 'gadwp_cache_qr%%'"); GADWP_Tools::unset_cookie('default_metric'); GADWP_Tools::unset_cookie('default_dimension'); GADWP_Tools::unset_cookie('default_view'); }