Google Analytics for WordPress by MonsterInsights - Version 6.0.2

Version Description

= 6.0.0 =

This is a major release. Please back up your site before upgrading.

Download this release

Release Info

Developer chriscct7
Plugin Icon 128x128 Google Analytics for WordPress by MonsterInsights
Version 6.0.2
Comparing to
See all releases

Code changes from version 6.0.1 to 6.0.2

Files changed (3) hide show
  1. googleanalytics.php +3 -3
  2. includes/install.php +34 -9
  3. readme.txt +4 -1
googleanalytics.php CHANGED
@@ -6,7 +6,7 @@
6
  * Author: MonsterInsights
7
  * Author URI: https://www.monsterinsights.com/
8
  *
9
- * Version: 6.0.1
10
  * Requires at least: 3.9.0
11
  * Tested up to: 4.7.2
12
  *
@@ -69,7 +69,7 @@ final class MonsterInsights_Lite {
69
  * @access public
70
  * @var string $version Plugin version.
71
  */
72
- public $version = '6.0.1';
73
 
74
  /**
75
  * Plugin file.
@@ -177,7 +177,7 @@ final class MonsterInsights_Lite {
177
 
178
  // This does the version to version background upgrade routines and initial install
179
  $mi_version = get_option( 'monsterinsights_current_version', '5.5.3' );
180
- if ( version_compare( $mi_version, '6.0.0', '<' ) ) {
181
  monsterinsights_lite_call_install_and_upgrade();
182
  }
183
 
6
  * Author: MonsterInsights
7
  * Author URI: https://www.monsterinsights.com/
8
  *
9
+ * Version: 6.0.2
10
  * Requires at least: 3.9.0
11
  * Tested up to: 4.7.2
12
  *
69
  * @access public
70
  * @var string $version Plugin version.
71
  */
72
+ public $version = '6.0.2';
73
 
74
  /**
75
  * Plugin file.
177
 
178
  // This does the version to version background upgrade routines and initial install
179
  $mi_version = get_option( 'monsterinsights_current_version', '5.5.3' );
180
+ if ( version_compare( $mi_version, '6.0.2', '<' ) ) {
181
  monsterinsights_lite_call_install_and_upgrade();
182
  }
183
 
includes/install.php CHANGED
@@ -78,9 +78,9 @@ class MonsterInsights_Install {
78
  update_option( 'monsterinsights_db_version', '6.0.0' );
79
 
80
  } else { // if existing install
81
- //if ( version_compare( $version, '6.1.0', '<' ) ) {
82
- // $this->v610_upgrades();
83
- //}
84
  // @todo: doc as nonpublic
85
 
86
  update_option( 'monsterinsights_version_upgraded_from', $version );
@@ -391,9 +391,6 @@ class MonsterInsights_Install {
391
  if ( isset( $options['custom_metrics'] ) ) {
392
  unset( $options['custom_metrics'] );
393
  }
394
- if ( isset( $options['manual_ua_code_field'] ) ) {
395
- unset( $options['manual_ua_code_field'] );
396
- }
397
  if ( isset( $options['track_full_url'] ) ) {
398
  unset( $options['track_full_url'] );
399
  }
@@ -475,13 +472,14 @@ class MonsterInsights_Install {
475
  $options['cron_last_run'] = strtotime("-25 hours");
476
  } else {
477
  // if UA in manual code field, remove analytics profile fields if set
478
- if ( ! empty( $options['manual_ua_code' ] ) ) {
479
  if ( isset( $options['analytics_profile_code'] ) ) {
480
  unset( $options['analytics_profile_code'] );
481
  }
482
  if ( isset( $options['analytics_profile'] ) ) {
483
  unset( $options['analytics_profile'] );
484
  }
 
485
  delete_option( 'yoast-ga-access_token' );
486
  delete_option( 'yoast-ga-refresh_token' );
487
  delete_option( 'yst_ga_api' );
@@ -516,6 +514,10 @@ class MonsterInsights_Install {
516
  delete_option( 'yst_ga_api' );
517
  }
518
  }
 
 
 
 
519
 
520
  // oAuth Stir Data Tank
521
  // Will happen automatically as cron_last_run set to 25 hours ago
@@ -578,8 +580,7 @@ class MonsterInsights_Install {
578
  return array(
579
  'analytics_profile' => '',
580
  'analytics_profile_code' => '',
581
- 'manual_ua_code' => 0,
582
- 'manual_ua_code_field' => '',
583
  'track_internal_as_outbound' => 0,
584
  'track_internal_as_label' => '',
585
  'track_outbound' => 1,
@@ -604,6 +605,30 @@ class MonsterInsights_Install {
604
  );
605
  }
606
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
607
 
608
  /**
609
  * MonsterInsights Version 6.1 upgrades.
78
  update_option( 'monsterinsights_db_version', '6.0.0' );
79
 
80
  } else { // if existing install
81
+ if ( version_compare( $version, '6.0.2', '<' ) ) {
82
+ $this->v602_upgrades();
83
+ }
84
  // @todo: doc as nonpublic
85
 
86
  update_option( 'monsterinsights_version_upgraded_from', $version );
391
  if ( isset( $options['custom_metrics'] ) ) {
392
  unset( $options['custom_metrics'] );
393
  }
 
 
 
394
  if ( isset( $options['track_full_url'] ) ) {
395
  unset( $options['track_full_url'] );
396
  }
472
  $options['cron_last_run'] = strtotime("-25 hours");
473
  } else {
474
  // if UA in manual code field, remove analytics profile fields if set
475
+ if ( ! empty( $options['manual_ua_code_field' ] ) ) {
476
  if ( isset( $options['analytics_profile_code'] ) ) {
477
  unset( $options['analytics_profile_code'] );
478
  }
479
  if ( isset( $options['analytics_profile'] ) ) {
480
  unset( $options['analytics_profile'] );
481
  }
482
+ $options['manual_ua_code'] = $options['manual_ua_code_field'];
483
  delete_option( 'yoast-ga-access_token' );
484
  delete_option( 'yoast-ga-refresh_token' );
485
  delete_option( 'yst_ga_api' );
514
  delete_option( 'yst_ga_api' );
515
  }
516
  }
517
+
518
+ if ( isset( $options['manual_ua_code_field'] ) ) {
519
+ unset( $options['manual_ua_code_field'] );
520
+ }
521
 
522
  // oAuth Stir Data Tank
523
  // Will happen automatically as cron_last_run set to 25 hours ago
580
  return array(
581
  'analytics_profile' => '',
582
  'analytics_profile_code' => '',
583
+ 'manual_ua_code' => '',
 
584
  'track_internal_as_outbound' => 0,
585
  'track_internal_as_label' => '',
586
  'track_outbound' => 1,
605
  );
606
  }
607
 
608
+ /**
609
+ * MonsterInsights Version 6.0.2 upgrades.
610
+ *
611
+ * This detects if a manual auth code is in the Yoast settings, and not
612
+ * in the MI settings, and that oAuth hasn't been performed (caused by the
613
+ * manual ua code not being transferred during the 6.0 upgrade routine)
614
+ * and automatically fixes it.
615
+ *
616
+ * @since 6.0.2
617
+ * @access public
618
+ *
619
+ * @return void
620
+ */
621
+ public function v602_upgrades() {
622
+ $options = get_option( 'yst_ga', array() );
623
+ if ( ( empty( $this->new_settings[ 'manual_ua_code'] ) || $this->new_settings[ 'manual_ua_code'] === '1' ) &&
624
+ empty( $this->new_settings[ 'analytics_profile_code'] ) &&
625
+ ! empty( $options ) &&
626
+ is_array( $options ) &&
627
+ ! empty( $options['ga_general']['manual_ua_code_field'] )
628
+ ) {
629
+ $this->new_settings['manual_ua_code'] = $options['ga_general']['manual_ua_code_field'];
630
+ }
631
+ }
632
 
633
  /**
634
  * MonsterInsights Version 6.1 upgrades.
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.wpbeginner.com/wpbeginner-needs-your-help/
4
  Tags: analytics, analytics dashboard, google analytics, google analytics dashboard, google analytics widget, universal google analytics, statistics, tracking, stats, google, yoast, google analytics by yoast, ga, monster insights, monsterinsights, universal analytics, web stats, ecommerce, ecommerce tracking
5
  Requires at least: 3.9
6
  Tested up to: 4.7.2
7
- Stable tag: 6.0.1
8
  License: GPL v3
9
 
10
  The best Google Analytics plugin for WordPress. See how visitors find and use your website, so you can keep them coming back.
@@ -137,6 +137,9 @@ You can also learn about other <a href="http://www.wpbeginner.com/category/plugi
137
 
138
  == Changelog ==
139
 
 
 
 
140
  = 6.0.1, February 19, 2017 =
141
  * Fixed: Typo that caused an issue with PHP 7 installs.
142
 
4
  Tags: analytics, analytics dashboard, google analytics, google analytics dashboard, google analytics widget, universal google analytics, statistics, tracking, stats, google, yoast, google analytics by yoast, ga, monster insights, monsterinsights, universal analytics, web stats, ecommerce, ecommerce tracking
5
  Requires at least: 3.9
6
  Tested up to: 4.7.2
7
+ Stable tag: 6.0.2
8
  License: GPL v3
9
 
10
  The best Google Analytics plugin for WordPress. See how visitors find and use your website, so you can keep them coming back.
137
 
138
  == Changelog ==
139
 
140
+ = 6.0.2, February 19, 2017 =
141
+ * Fixed: Upgrade routine could drop manual UA codes in certain cases. If you upgraded to 6.0.0 or 6.0.1 and it lost the manual UA code, installing this update will automatically restore the UA code entered as long as you haven't used the oAuth or re-entered the manual UA code.
142
+
143
  = 6.0.1, February 19, 2017 =
144
  * Fixed: Typo that caused an issue with PHP 7 installs.
145