Skip to content

Commit

Permalink
MI 6.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
chriscct7 committed Feb 19, 2017
1 parent 8152bb6 commit 1fd4fbc
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 13 deletions.
6 changes: 3 additions & 3 deletions googleanalytics.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Author: MonsterInsights
* Author URI: https://www.monsterinsights.com/
*
* Version: 6.0.1
* Version: 6.0.2
* Requires at least: 3.9.0
* Tested up to: 4.7.2
*
Expand Down Expand Up @@ -69,7 +69,7 @@ final class MonsterInsights_Lite {
* @access public
* @var string $version Plugin version.
*/
public $version = '6.0.1';
public $version = '6.0.2';

/**
* Plugin file.
Expand Down Expand Up @@ -177,7 +177,7 @@ public static function get_instance() {

// This does the version to version background upgrade routines and initial install
$mi_version = get_option( 'monsterinsights_current_version', '5.5.3' );
if ( version_compare( $mi_version, '6.0.0', '<' ) ) {
if ( version_compare( $mi_version, '6.0.2', '<' ) ) {
monsterinsights_lite_call_install_and_upgrade();
}

Expand Down
43 changes: 34 additions & 9 deletions includes/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ public function init() {
update_option( 'monsterinsights_db_version', '6.0.0' );

} else { // if existing install
//if ( version_compare( $version, '6.1.0', '<' ) ) {
// $this->v610_upgrades();
//}
if ( version_compare( $version, '6.0.2', '<' ) ) {
$this->v602_upgrades();
}
// @todo: doc as nonpublic

update_option( 'monsterinsights_version_upgraded_from', $version );
Expand Down Expand Up @@ -391,9 +391,6 @@ public function upgrade_from_yoast() {
if ( isset( $options['custom_metrics'] ) ) {
unset( $options['custom_metrics'] );
}
if ( isset( $options['manual_ua_code_field'] ) ) {
unset( $options['manual_ua_code_field'] );
}
if ( isset( $options['track_full_url'] ) ) {
unset( $options['track_full_url'] );
}
Expand Down Expand Up @@ -475,13 +472,14 @@ public function upgrade_from_yoast() {
$options['cron_last_run'] = strtotime("-25 hours");
} else {
// if UA in manual code field, remove analytics profile fields if set
if ( ! empty( $options['manual_ua_code' ] ) ) {
if ( ! empty( $options['manual_ua_code_field' ] ) ) {
if ( isset( $options['analytics_profile_code'] ) ) {
unset( $options['analytics_profile_code'] );
}
if ( isset( $options['analytics_profile'] ) ) {
unset( $options['analytics_profile'] );
}
$options['manual_ua_code'] = $options['manual_ua_code_field'];
delete_option( 'yoast-ga-access_token' );
delete_option( 'yoast-ga-refresh_token' );
delete_option( 'yst_ga_api' );
Expand Down Expand Up @@ -516,6 +514,10 @@ public function upgrade_from_yoast() {
delete_option( 'yst_ga_api' );
}
}

if ( isset( $options['manual_ua_code_field'] ) ) {
unset( $options['manual_ua_code_field'] );
}

// oAuth Stir Data Tank
// Will happen automatically as cron_last_run set to 25 hours ago
Expand Down Expand Up @@ -578,8 +580,7 @@ public function get_monsterinsights_default_values() {
return array(
'analytics_profile' => '',
'analytics_profile_code' => '',
'manual_ua_code' => 0,
'manual_ua_code_field' => '',
'manual_ua_code' => '',
'track_internal_as_outbound' => 0,
'track_internal_as_label' => '',
'track_outbound' => 1,
Expand All @@ -604,6 +605,30 @@ public function get_monsterinsights_default_values() {
);
}

/**
* MonsterInsights Version 6.0.2 upgrades.
*
* This detects if a manual auth code is in the Yoast settings, and not
* in the MI settings, and that oAuth hasn't been performed (caused by the
* manual ua code not being transferred during the 6.0 upgrade routine)
* and automatically fixes it.
*
* @since 6.0.2
* @access public
*
* @return void
*/
public function v602_upgrades() {
$options = get_option( 'yst_ga', array() );
if ( ( empty( $this->new_settings[ 'manual_ua_code'] ) || $this->new_settings[ 'manual_ua_code'] === '1' ) &&
empty( $this->new_settings[ 'analytics_profile_code'] ) &&
! empty( $options ) &&
is_array( $options ) &&
! empty( $options['ga_general']['manual_ua_code_field'] )
) {
$this->new_settings['manual_ua_code'] = $options['ga_general']['manual_ua_code_field'];
}
}

/**
* MonsterInsights Version 6.1 upgrades.
Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Donate link: http://www.wpbeginner.com/wpbeginner-needs-your-help/
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
Requires at least: 3.9
Tested up to: 4.7.2
Stable tag: 6.0.1
Stable tag: 6.0.2
License: GPL v3

The best Google Analytics plugin for WordPress. See how visitors find and use your website, so you can keep them coming back.
Expand Down Expand Up @@ -137,6 +137,9 @@ You can also learn about other <a href="http://www.wpbeginner.com/category/plugi

== Changelog ==

= 6.0.2, February 19, 2017 =
* 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.

= 6.0.1, February 19, 2017 =
* Fixed: Typo that caused an issue with PHP 7 installs.

Expand Down

0 comments on commit 1fd4fbc

Please sign in to comment.