Passed
Branch master (82fe3a)
by Chris
02:49
created
includes/install.php 3 patches
Spacing   +163 added lines, -163 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  */
14 14
 
15 15
 // Exit if accessed directly
16
-if ( ! defined( 'ABSPATH' ) ) { 
16
+if ( ! defined('ABSPATH')) { 
17 17
 	exit;
18 18
 }
19 19
 
@@ -58,54 +58,54 @@  discard block
 block discarded – undo
58 58
 	public function init() {
59 59
 
60 60
 		// Get a copy of the current MI settings.
61
-		$this->new_settings = get_option( monsterinsights_get_option_name() );
61
+		$this->new_settings = get_option(monsterinsights_get_option_name());
62 62
 
63 63
 
64
-		$version = get_option( 'monsterinsights_current_version', false );
65
-		$yoast   = get_option( 'yst_ga', false );
64
+		$version = get_option('monsterinsights_current_version', false);
65
+		$yoast   = get_option('yst_ga', false);
66 66
 		$cachec  = false; // have we forced an object cache to be cleared already (so we don't clear it unnecessarily)
67 67
 
68 68
 		// if new install and have not used Yoast previously
69
-		if ( ! $version && ! $yoast ) {
69
+		if ( ! $version && ! $yoast) {
70 70
 
71 71
 			$this->new_install();
72 72
 			// This is the version used for MI upgrade routines.
73
-			update_option( 'monsterinsights_db_version', '6.2.0' );
73
+			update_option('monsterinsights_db_version', '6.2.0');
74 74
 			
75
-		} else if ( ! $version && $yoast ) { // if new install and has used Yoast previously
75
+		} else if ( ! $version && $yoast) { // if new install and has used Yoast previously
76 76
 
77 77
 			$this->upgrade_from_yoast();
78 78
 			// This is the version used for MI upgrade routines.
79
-			update_option( 'monsterinsights_db_version', '6.2.0' );
79
+			update_option('monsterinsights_db_version', '6.2.0');
80 80
 
81
-			if ( ! $cachec ) {
81
+			if ( ! $cachec) {
82 82
 				wp_cache_flush();
83 83
 				$cachec = true;
84 84
 			}
85 85
 			
86 86
 		} else { // if existing install
87
-			if ( version_compare( $version, '6.0.2', '<' ) ) {
87
+			if (version_compare($version, '6.0.2', '<')) {
88 88
 				$this->v602_upgrades();
89 89
 			}
90 90
 			
91
-			if ( version_compare( $version, '6.0.11', '<' ) ) {
91
+			if (version_compare($version, '6.0.11', '<')) {
92 92
 				$this->v6011_upgrades();
93 93
 
94
-				if ( ! $cachec ) {
94
+				if ( ! $cachec) {
95 95
 					wp_cache_flush();
96 96
 					$cachec = true;
97 97
 				}
98 98
 			}
99
-			if ( version_compare( $version, '6.2.0', '<' ) ) {
99
+			if (version_compare($version, '6.2.0', '<')) {
100 100
 				$this->v620_upgrades();
101 101
 			}
102 102
 
103
-			update_option( 'monsterinsights_db_version', '6.2.0' );
103
+			update_option('monsterinsights_db_version', '6.2.0');
104 104
 			
105 105
 			// @todo: doc as nonpublic
106 106
 			
107
-			update_option( 'monsterinsights_version_upgraded_from', $version );
108
-			do_action( 'monsterinsights_after_existing_upgrade_routine', $version );
107
+			update_option('monsterinsights_version_upgraded_from', $version);
108
+			do_action('monsterinsights_after_existing_upgrade_routine', $version);
109 109
 		}
110 110
 
111 111
 		// This hook is used primarily by the Pro version to run some Pro
@@ -114,16 +114,16 @@  discard block
 block discarded – undo
114 114
 		// relocated, and/or altered without warning at any time. You've been warned.
115 115
 		// As this hook is not for public use, we've intentionally not docbloc'd this
116 116
 		// hook to avoid developers seeing it future public dev docs.
117
-		do_action( 'monsterinsights_after_install_routine', $version );
117
+		do_action('monsterinsights_after_install_routine', $version);
118 118
 
119 119
 		// This is the version of the MI settings themselves
120
-		update_option( 'monsterinsights_settings_version', '6.0.0' );
120
+		update_option('monsterinsights_settings_version', '6.0.0');
121 121
 
122 122
 		// This is the version of MI installed
123
-		update_option( 'monsterinsights_current_version', MONSTERINSIGHTS_VERSION );
123
+		update_option('monsterinsights_current_version', MONSTERINSIGHTS_VERSION);
124 124
 
125 125
 		// This is where we save MI settings
126
-		update_option( monsterinsights_get_option_name(), $this->new_settings );
126
+		update_option(monsterinsights_get_option_name(), $this->new_settings);
127 127
 
128 128
 		// This is where we redirect to the MI welcome page
129 129
 		//set_transient( '_monsterinsights_activation_redirect', true, 30 ); @todo: Investigate
@@ -223,16 +223,16 @@  discard block
 block discarded – undo
223 223
 			'installed_pro'     => monsterinsights_is_pro_version(),
224 224
 		);
225 225
 
226
-		update_option( 'monsterinsights_over_time', $data );
226
+		update_option('monsterinsights_over_time', $data);
227 227
 
228 228
 		// Add cron job
229
-		if ( ! wp_next_scheduled( 'monsterinsights_daily_cron' ) ) {
229
+		if ( ! wp_next_scheduled('monsterinsights_daily_cron')) {
230 230
 			// Set the next event of fetching data
231
-			wp_schedule_event( strtotime( date( 'Y-m-d', strtotime( 'tomorrow' ) ) . ' 00:05:00 ' ), 'daily', 'monsterinsights_daily_cron' );
231
+			wp_schedule_event(strtotime(date('Y-m-d', strtotime('tomorrow')) . ' 00:05:00 '), 'daily', 'monsterinsights_daily_cron');
232 232
 		}
233 233
 
234 234
 		// Let addons + MI Pro/Lite hook in here. @todo: doc as nonpublic
235
-		do_action( 'monsterinsights_after_new_install_routine', MONSTERINSIGHTS_VERSION );
235
+		do_action('monsterinsights_after_new_install_routine', MONSTERINSIGHTS_VERSION);
236 236
 	}
237 237
 
238 238
 	/**
@@ -248,27 +248,27 @@  discard block
 block discarded – undo
248 248
 	 */
249 249
 	public function upgrade_from_yoast() {
250 250
 		// Do Yoast's Old Routines
251
-		$options = get_option( 'yst_ga', array() );
252
-		if ( ! empty( $options['ga_general'] ) ) {
251
+		$options = get_option('yst_ga', array());
252
+		if ( ! empty($options['ga_general'])) {
253 253
 			$options = $options['ga_general'];
254 254
 		}
255 255
 
256 256
 		$tracking_code = null;
257
-		if ( ! empty( $options['analytics_profile'] ) && ! empty( $options['analytics_profile_code'] ) ) {
257
+		if ( ! empty($options['analytics_profile']) && ! empty($options['analytics_profile_code'])) {
258 258
 			$tracking_code = $options['analytics_profile_code'];
259
-		} else if ( ! empty( $options['analytics_profile'] ) && empty( $options['analytics_profile_code'] ) ) {
259
+		} else if ( ! empty($options['analytics_profile']) && empty($options['analytics_profile_code'])) {
260 260
 			// Analytics profile is still holding the UA code
261 261
 			$tracking_code = $options['analytics_profile'];
262 262
 		}
263 263
 
264
-		if ( ! empty( $options['manual_ua_code_field'] ) && ! empty( $options['manual_ua_code'] ) ) {
264
+		if ( ! empty($options['manual_ua_code_field']) && ! empty($options['manual_ua_code'])) {
265 265
 			$tracking_code = $options['manual_ua_code_field'];
266 266
 		}
267 267
 
268
-		if ( ! isset( $options['version'] ) && is_null( $tracking_code ) ) {
269
-			$old_options = get_option( 'Yoast_Google_Analytics' );
270
-			if ( isset( $old_options ) && is_array( $old_options ) ) {
271
-				if ( isset( $old_options['uastring'] ) && '' !== trim( $old_options['uastring'] ) ) {
268
+		if ( ! isset($options['version']) && is_null($tracking_code)) {
269
+			$old_options = get_option('Yoast_Google_Analytics');
270
+			if (isset($old_options) && is_array($old_options)) {
271
+				if (isset($old_options['uastring']) && '' !== trim($old_options['uastring'])) {
272 272
 					// Save UA as manual UA, instead of saving all the old GA crap
273 273
 					$options['manual_ua_code']       = 1;
274 274
 					$options['manual_ua_code_field'] = $old_options['uastring'];
@@ -282,44 +282,44 @@  discard block
 block discarded – undo
282 282
 				$options['track_internal_as_label']    = $old_options['internallinklabel'];
283 283
 				$options['extensions_of_files']        = $old_options['dlextensions'];
284 284
 			}
285
-			delete_option( 'Yoast_Google_Analytics' );
285
+			delete_option('Yoast_Google_Analytics');
286 286
 		}
287 287
 		// 5.0.0 to 5.0.1 fix of ignore users array
288
-		if ( ! isset( $options['version'] ) || version_compare( $options['version'], '5.0.1', '<' ) ) {
289
-			if ( isset( $options['ignore_users'] ) && ! is_array( $options['ignore_users'] ) ) {
288
+		if ( ! isset($options['version']) || version_compare($options['version'], '5.0.1', '<')) {
289
+			if (isset($options['ignore_users']) && ! is_array($options['ignore_users'])) {
290 290
 				$options['ignore_users'] = (array) $options['ignore_users'];
291 291
 			}
292 292
 		}
293 293
 		// 5.1.2+ Remove firebug_lite from options, if set
294
-		if ( ! isset ( $options['version'] ) || version_compare( $options['version'], '5.1.2', '<' ) ) {
295
-			if ( isset( $options['firebug_lite'] ) ) {
296
-				unset( $options['firebug_lite'] );
294
+		if ( ! isset ($options['version']) || version_compare($options['version'], '5.1.2', '<')) {
295
+			if (isset($options['firebug_lite'])) {
296
+				unset($options['firebug_lite']);
297 297
 			}
298 298
 		}
299 299
 		// 5.2.8+ Add disabled dashboards option
300
-		if ( ! isset ( $options['dashboards_disabled'] ) || version_compare( $options['version'], '5.2.8', '>' ) ) {
300
+		if ( ! isset ($options['dashboards_disabled']) || version_compare($options['version'], '5.2.8', '>')) {
301 301
 			$options['dashboards_disabled'] = 0;
302 302
 		}
303 303
 		// Check is API option already exists - if not add it
304
-		$yst_ga_api = get_option( 'yst_ga_api' );
305
-		if ( $yst_ga_api === false ) {
306
-			add_option( 'yst_ga_api', array(), '', 'no' );
304
+		$yst_ga_api = get_option('yst_ga_api');
305
+		if ($yst_ga_api === false) {
306
+			add_option('yst_ga_api', array(), '', 'no');
307 307
 		}
308 308
 		// Fallback to make sure every default option has a value
309 309
 		$defaults = $this->get_yoast_default_values();
310
-		if ( is_array( $defaults ) ) {
311
-			foreach ( $defaults[ 'ga_general' ] as $key => $value ) {
312
-				if ( ! isset( $options[ $key ] ) ) {
313
-					$options[ $key ] = $value;
310
+		if (is_array($defaults)) {
311
+			foreach ($defaults['ga_general'] as $key => $value) {
312
+				if ( ! isset($options[$key])) {
313
+					$options[$key] = $value;
314 314
 				}
315 315
 			}
316 316
 		}
317 317
 
318 318
 		// Set to the current version now that we've done all needed upgrades
319 319
 		$options['version'] = '5.5.3'; // Last Yoast codebase version
320
-		$saved_options = get_option( 'yst_ga' );
321
-		$saved_options[ 'ga_general' ] = $options;
322
-		update_option( 'yst_ga', $saved_options );
320
+		$saved_options = get_option('yst_ga');
321
+		$saved_options['ga_general'] = $options;
322
+		update_option('yst_ga', $saved_options);
323 323
 
324 324
 
325 325
 		// Do license key switchover 
@@ -327,117 +327,117 @@  discard block
 block discarded – undo
327 327
 			$found   = false;
328 328
 			$network = false;
329 329
 			// Try network active Premium
330
-			$is_key = get_site_option( 'google-analytics-by-yoast-premium_license', array() );
331
-			if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) && is_multisite() ){
332
-				$key    = $is_key['key'];
330
+			$is_key = get_site_option('google-analytics-by-yoast-premium_license', array());
331
+			if ($is_key && ! empty($is_key) && is_array($is_key) && ! empty($is_key['key']) && is_multisite()) {
332
+				$key = $is_key['key'];
333 333
 				$found = true;
334 334
 				$network = true;
335 335
 			}
336 336
 
337 337
 			// Try single site Premium
338
-			if ( ! $found ) {
339
-				$is_key = get_option( 'google-analytics-by-yoast-premium_license', array() );
340
-				if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) ){
341
-					$key    = $is_key['key'];
338
+			if ( ! $found) {
339
+				$is_key = get_option('google-analytics-by-yoast-premium_license', array());
340
+				if ($is_key && ! empty($is_key) && is_array($is_key) && ! empty($is_key['key'])) {
341
+					$key = $is_key['key'];
342 342
 					$found = true;
343 343
 				}				
344 344
 			}
345 345
 
346 346
 			// Try network active Premium
347
-			if ( ! $found ) {
348
-				$is_key = get_site_option( 'monsterinsights-pro_license', array() );
349
-				if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) && is_multisite() ){
350
-					$key    = $is_key['key'];
347
+			if ( ! $found) {
348
+				$is_key = get_site_option('monsterinsights-pro_license', array());
349
+				if ($is_key && ! empty($is_key) && is_array($is_key) && ! empty($is_key['key']) && is_multisite()) {
350
+					$key = $is_key['key'];
351 351
 					$found = true;
352 352
 					$network = true;
353 353
 				}				
354 354
 			}
355 355
 			
356 356
 			// Try single site Premium
357
-			if ( ! $found ) {
358
-				$is_key = get_option( 'monsterinsights-pro_license', array() );
359
-				if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) ){
360
-					$key    = $is_key['key'];
357
+			if ( ! $found) {
358
+				$is_key = get_option('monsterinsights-pro_license', array());
359
+				if ($is_key && ! empty($is_key) && is_array($is_key) && ! empty($is_key['key'])) {
360
+					$key = $is_key['key'];
361 361
 					$found = true;
362 362
 				}				
363 363
 			}
364 364
 			
365 365
 			// Try network active ecommmerce
366
-			if ( ! $found ) {
367
-				$is_key = get_site_option( 'ecommerce-addon_license', array() );
368
-				if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) && is_multisite() ){
369
-					$key    = $is_key['key'];
366
+			if ( ! $found) {
367
+				$is_key = get_site_option('ecommerce-addon_license', array());
368
+				if ($is_key && ! empty($is_key) && is_array($is_key) && ! empty($is_key['key']) && is_multisite()) {
369
+					$key = $is_key['key'];
370 370
 					$found = true;
371 371
 					$network = true;
372 372
 				}
373 373
 			}
374 374
 			// Try single site ecommerce
375
-			if ( ! $found ) {
376
-				$is_key = get_option( 'ecommerce-addon_license', array() );
377
-				if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) ){
378
-					$key    = $is_key['key'];
375
+			if ( ! $found) {
376
+				$is_key = get_option('ecommerce-addon_license', array());
377
+				if ($is_key && ! empty($is_key) && is_array($is_key) && ! empty($is_key['key'])) {
378
+					$key = $is_key['key'];
379 379
 					$found = true;
380 380
 				}				
381 381
 			}
382 382
 
383 383
 			// set as new key for monsterinsights
384
-			if ( $found && ! empty( $key ) ) {
384
+			if ($found && ! empty($key)) {
385 385
 				// In pro, install custom dimensions + ads. In lite, just save the key
386
-				do_action( 'monsterinsights_upgrade_from_yoast', $key, $network );
386
+				do_action('monsterinsights_upgrade_from_yoast', $key, $network);
387 387
 			}
388 388
 
389 389
 		// Next up: Settings Migration
390 390
 		
391
-			$options = get_option( 'yst_ga', array() );
392
-			if ( ! empty( $options['ga_general'] ) ) {
391
+			$options = get_option('yst_ga', array());
392
+			if ( ! empty($options['ga_general'])) {
393 393
 				$options = $options['ga_general'];
394 394
 			}
395 395
 
396 396
 
397 397
 			// Let's remove the defaults
398
-			if ( isset( $options['ga_general'] ) ) {
399
-				unset( $options['ga_general'] );
398
+			if (isset($options['ga_general'])) {
399
+				unset($options['ga_general']);
400 400
 			}
401 401
 
402 402
 			// Let's remove unused options
403
-			if ( isset( $options['yoast_ga_nonce'] ) ) {
404
-				unset( $options['yoast_ga_nonce'] );
403
+			if (isset($options['yoast_ga_nonce'])) {
404
+				unset($options['yoast_ga_nonce']);
405 405
 			}			
406
-			if ( isset( $options['ga-form-settings'] ) ) {
407
-				unset( $options['ga-form-settings'] );
406
+			if (isset($options['ga-form-settings'])) {
407
+				unset($options['ga-form-settings']);
408 408
 			}
409
-			if ( isset( $options['string_error_custom_dimensions'] ) ) {
410
-				unset( $options['string_error_custom_dimensions'] );
409
+			if (isset($options['string_error_custom_dimensions'])) {
410
+				unset($options['string_error_custom_dimensions']);
411 411
 			}
412
-			if ( isset( $options['custom_metrics'] ) ) {
413
-				unset( $options['custom_metrics'] );
412
+			if (isset($options['custom_metrics'])) {
413
+				unset($options['custom_metrics']);
414 414
 			}	
415
-			if ( isset( $options['track_full_url'] ) ) {
416
-				unset( $options['track_full_url'] );
415
+			if (isset($options['track_full_url'])) {
416
+				unset($options['track_full_url']);
417 417
 			}	
418
-			if ( isset( $options['version'] ) ) {
419
-				unset( $options['version'] );
418
+			if (isset($options['version'])) {
419
+				unset($options['version']);
420 420
 			}
421 421
 
422 422
 			// Migrate universal to tracking_mode
423
-			if ( isset( $options['enable_universal'] ) ) {
424
-				unset( $options['enable_universal'] );
423
+			if (isset($options['enable_universal'])) {
424
+				unset($options['enable_universal']);
425 425
 				$options['tracking_mode'] = 'analytics';
426 426
 			} else {
427 427
 				$options['tracking_mode'] = 'ga';
428 428
 			}
429 429
 
430 430
 			// Migrate events tracking
431
-			if ( isset( $options['track_outbound'] ) ) {
432
-				unset( $options['track_outbound'] );
431
+			if (isset($options['track_outbound'])) {
432
+				unset($options['track_outbound']);
433 433
 				$options['events_mode'] = 'php';
434 434
 			} else {
435 435
 				$options['events_mode'] = 'none';
436 436
 			}
437 437
 
438 438
 			// Migrate anonymous_data to allow tracking
439
-			if ( isset( $options['anonymous_data'] ) ) {
440
-				unset( $options['anonymous_data'] );
439
+			if (isset($options['anonymous_data'])) {
440
+				unset($options['anonymous_data']);
441 441
 				$options['allow_tracking'] = 1;
442 442
 			} else {
443 443
 				$options['allow_tracking'] = 0;
@@ -446,42 +446,42 @@  discard block
 block discarded – undo
446 446
 		
447 447
 		// Migrate GA profile data if there
448 448
 			// first let's try to salvage the current profile
449
-			$access_token  = get_option( 'yoast-ga-access_token', array() );
450
-			$refresh_token = get_option( 'yoast-ga-refresh_token', array() );
451
-			$profiles      = get_option( 'yst_ga_api', array() );
449
+			$access_token  = get_option('yoast-ga-access_token', array());
450
+			$refresh_token = get_option('yoast-ga-refresh_token', array());
451
+			$profiles      = get_option('yst_ga_api', array());
452 452
 
453
-			$profile_name  = ! empty( $options['analytics_profile'] ) ? $options['analytics_profile'] : ''; 
453
+			$profile_name  = ! empty($options['analytics_profile']) ? $options['analytics_profile'] : ''; 
454 454
 
455
-				if ( empty( $refresh_token ) && ! empty( $access_token['refresh_token'] ) ) {
455
+				if (empty($refresh_token) && ! empty($access_token['refresh_token'])) {
456 456
 					$refresh_token = $access_token['refresh_token'];
457 457
 				}
458 458
 	
459 459
 				// We need a name and a profile
460
-				if ( ! empty( $refresh_token ) && ! empty( $options['analytics_profile'] ) && ! empty( $profiles['ga_api_response_accounts'] ) ) {
460
+				if ( ! empty($refresh_token) && ! empty($options['analytics_profile']) && ! empty($profiles['ga_api_response_accounts'])) {
461 461
 					// See if we have an access token
462
-					if ( ! empty( $access_token['access_token'] ) ) {
463
-						if ( monsterinsights_is_pro_version() ) {
464
-							update_option( 'monsterinsights_pro_access_token', $access_token['access_token'] );
462
+					if ( ! empty($access_token['access_token'])) {
463
+						if (monsterinsights_is_pro_version()) {
464
+							update_option('monsterinsights_pro_access_token', $access_token['access_token']);
465 465
 						} else {
466
-							update_option( 'monsterinsights_lite_access_token', $access_token['access_token'] );
466
+							update_option('monsterinsights_lite_access_token', $access_token['access_token']);
467 467
 						}
468 468
 					}
469 469
 
470 470
 					// We need a refresh token
471
-					if ( monsterinsights_is_pro_version() ) {
472
-						update_option( 'monsterinsights_pro_refresh_token', $refresh_token );
471
+					if (monsterinsights_is_pro_version()) {
472
+						update_option('monsterinsights_pro_refresh_token', $refresh_token);
473 473
 					} else {
474
-						update_option( 'monsterinsights_lite_refresh_token', $refresh_token );
474
+						update_option('monsterinsights_lite_refresh_token', $refresh_token);
475 475
 					}
476 476
 
477 477
 					// If we can find the profile in the response save the name
478
-					if ( ! empty( $profiles['ga_api_response_accounts'] ) && is_array( $profiles['ga_api_response_accounts'] ) ) {
479
-						foreach ( $profiles['ga_api_response_accounts'] as $account ) {
480
-							foreach ( $account['items'] as $profile ) {
481
-								foreach ( $profile['items'] as $subprofile ) {
482
-									if ( isset( $subprofile['id'] ) && $subprofile['id'] == $profile_name ) {
478
+					if ( ! empty($profiles['ga_api_response_accounts']) && is_array($profiles['ga_api_response_accounts'])) {
479
+						foreach ($profiles['ga_api_response_accounts'] as $account) {
480
+							foreach ($account['items'] as $profile) {
481
+								foreach ($profile['items'] as $subprofile) {
482
+									if (isset($subprofile['id']) && $subprofile['id'] == $profile_name) {
483 483
 										$options['analytics_profile_name'] = $subprofile['name'];
484
-										if ( empty( $options['analytics_profile_code'] ) ) {
484
+										if (empty($options['analytics_profile_code'])) {
485 485
 											$options['analytics_profile_code'] = $subprofile['ua_code'];
486 486
 										}
487 487
 										break 3;
@@ -493,36 +493,36 @@  discard block
 block discarded – undo
493 493
 					$options['cron_last_run'] = strtotime("-25 hours");
494 494
 				} else {
495 495
 					// if UA in manual code field, remove analytics profile fields if set
496
-					if ( ! empty( $options['manual_ua_code_field' ] ) ) {
497
-						if ( isset( $options['analytics_profile_code'] ) ) {
498
-							unset( $options['analytics_profile_code'] );
496
+					if ( ! empty($options['manual_ua_code_field'])) {
497
+						if (isset($options['analytics_profile_code'])) {
498
+							unset($options['analytics_profile_code']);
499 499
 						}
500
-						if ( isset( $options['analytics_profile'] ) ) {
501
-							unset( $options['analytics_profile'] );
500
+						if (isset($options['analytics_profile'])) {
501
+							unset($options['analytics_profile']);
502 502
 						}
503 503
 						$options['manual_ua_code'] = $options['manual_ua_code_field'];
504
-						delete_option( 'yoast-ga-access_token' );
505
-						delete_option( 'yoast-ga-refresh_token' );
506
-						delete_option( 'yst_ga_api' );
507
-					} else if ( ! empty( $options['analytics_profile_code' ] ) ) {
504
+						delete_option('yoast-ga-access_token');
505
+						delete_option('yoast-ga-refresh_token');
506
+						delete_option('yst_ga_api');
507
+					} else if ( ! empty($options['analytics_profile_code'])) {
508 508
 					// if UA in profile fields, remove others and use that
509 509
 						$options['manual_ua_code'] = $options['analytics_profile_code'];
510
-						if ( isset( $options['analytics_profile_code'] ) ) {
511
-							unset( $options['analytics_profile_code'] );
510
+						if (isset($options['analytics_profile_code'])) {
511
+							unset($options['analytics_profile_code']);
512 512
 						}
513
-						if ( isset( $options['analytics_profile'] ) ) {
514
-							unset( $options['analytics_profile'] );
513
+						if (isset($options['analytics_profile'])) {
514
+							unset($options['analytics_profile']);
515 515
 						}
516
-						delete_option( 'yoast-ga-access_token' );
517
-						delete_option( 'yoast-ga-refresh_token' );
518
-						delete_option( 'yst_ga_api' );
519
-					}  else {
516
+						delete_option('yoast-ga-access_token');
517
+						delete_option('yoast-ga-refresh_token');
518
+						delete_option('yst_ga_api');
519
+					} else {
520 520
 					// if UA in profile profiles, remove others and use that
521
-						if ( ! empty( $options['analytics_profile' ] ) && ! empty( $profiles['ga_api_response_accounts'] ) && is_array( $profiles['ga_api_response_accounts'] ) ) {
522
-							foreach ( $profiles as $account ) {
523
-								foreach ( $account['items'] as $profile ) {
524
-									foreach ( $profile['items'] as $subprofile ) {
525
-										if ( isset( $subprofile['id'] ) && $subprofile['id'] == $options['analytics_profile' ] ) {
521
+						if ( ! empty($options['analytics_profile']) && ! empty($profiles['ga_api_response_accounts']) && is_array($profiles['ga_api_response_accounts'])) {
522
+							foreach ($profiles as $account) {
523
+								foreach ($account['items'] as $profile) {
524
+									foreach ($profile['items'] as $subprofile) {
525
+										if (isset($subprofile['id']) && $subprofile['id'] == $options['analytics_profile']) {
526 526
 											$options['manual_ua_code'] = $subprofile['ua_code'];
527 527
 											break 3;
528 528
 										}
@@ -530,14 +530,14 @@  discard block
 block discarded – undo
530 530
 								}
531 531
 							}
532 532
 						}
533
-						delete_option( 'yoast-ga-access_token' );
534
-						delete_option( 'yoast-ga-refresh_token' );
535
-						delete_option( 'yst_ga_api' );
533
+						delete_option('yoast-ga-access_token');
534
+						delete_option('yoast-ga-refresh_token');
535
+						delete_option('yst_ga_api');
536 536
 					}
537 537
 				}
538 538
 			
539
-			if ( isset( $options['manual_ua_code_field'] ) ) {
540
-				unset( $options['manual_ua_code_field'] );
539
+			if (isset($options['manual_ua_code_field'])) {
540
+				unset($options['manual_ua_code_field']);
541 541
 			}
542 542
 
543 543
 		// oAuth Stir Data Tank
@@ -552,12 +552,12 @@  discard block
 block discarded – undo
552 552
 			'installed_pro'     => monsterinsights_is_pro_version(),
553 553
 		);
554 554
 
555
-		update_option( 'monsterinsights_over_time', $data );
555
+		update_option('monsterinsights_over_time', $data);
556 556
 		
557 557
 		// Add the cron job
558
-		if ( ! wp_next_scheduled( 'monsterinsights_daily_cron' ) ) {
558
+		if ( ! wp_next_scheduled('monsterinsights_daily_cron')) {
559 559
 			// Set the next event of fetching data
560
-			wp_schedule_event( strtotime( date( 'Y-m-d', strtotime( 'tomorrow' ) ) . ' 00:05:00 ' ), 'daily', 'monsterinsights_daily_cron' );
560
+			wp_schedule_event(strtotime(date('Y-m-d', strtotime('tomorrow')) . ' 00:05:00 '), 'daily', 'monsterinsights_daily_cron');
561 561
 		}
562 562
 		
563 563
 		// Finish up
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
 				'anonymous_data'             => 0,
579 579
 				'enable_universal'           => 1,
580 580
 				'demographics'               => 0,
581
-				'ignore_users'               => array( 'administrator', 'editor' ),
581
+				'ignore_users'               => array('administrator', 'editor'),
582 582
 				'dashboards_disabled'        => 0,
583 583
 				'anonymize_ips'              => 0,
584 584
 				'track_download_as'          => 'event',
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
 				'debug_mode'                 => 0,
594 594
 			)
595 595
 		);
596
-		$options = apply_filters( 'yst_ga_default-ga-values', $options, 'ga_general' );
596
+		$options = apply_filters('yst_ga_default-ga-values', $options, 'ga_general');
597 597
 		return $options;
598 598
 	}
599 599
 
@@ -609,7 +609,7 @@  discard block
 block discarded – undo
609 609
 			'tracking_mode'              => 'analytics',
610 610
 			'events_mode'                => 'js',
611 611
 			'demographics'               => 1,
612
-			'ignore_users'               => array( 'administrator', 'editor' ),
612
+			'ignore_users'               => array('administrator', 'editor'),
613 613
 			'dashboards_disabled'        => 0,
614 614
 			'anonymize_ips'              => 0,
615 615
 			'track_download_as'          => 'event',
@@ -641,12 +641,12 @@  discard block
 block discarded – undo
641 641
 	 * @return void
642 642
 	 */
643 643
 	public function v602_upgrades() {
644
-		$options = get_option( 'yst_ga', array() );
645
-		if ( ( empty( $this->new_settings[ 'manual_ua_code'] ) || $this->new_settings[ 'manual_ua_code']  === '1' )  &&  
646
-			 empty( $this->new_settings[ 'analytics_profile_code'] ) &&
647
-			 ! empty( $options ) &&
648
-			 is_array( $options ) &&
649
-			 ! empty( $options['ga_general']['manual_ua_code_field'] )
644
+		$options = get_option('yst_ga', array());
645
+		if ((empty($this->new_settings['manual_ua_code']) || $this->new_settings['manual_ua_code'] === '1') &&  
646
+			 empty($this->new_settings['analytics_profile_code']) &&
647
+			 ! empty($options) &&
648
+			 is_array($options) &&
649
+			 ! empty($options['ga_general']['manual_ua_code_field'])
650 650
 		) {
651 651
 			$this->new_settings['manual_ua_code'] = $options['ga_general']['manual_ua_code_field'];
652 652
 		}
@@ -664,18 +664,18 @@  discard block
 block discarded – undo
664 664
 	 */
665 665
 	public function v6011_upgrades() {
666 666
 		// If old tracking checkin exists, remove it
667
-		if ( wp_next_scheduled( 'monsterinsights_send_tracking_checkin' ) ) {
668
-			wp_clear_scheduled_hook( 'monsterinsights_send_tracking_checkin' );
667
+		if (wp_next_scheduled('monsterinsights_send_tracking_checkin')) {
668
+			wp_clear_scheduled_hook('monsterinsights_send_tracking_checkin');
669 669
 		}
670 670
 
671 671
 		// Remove Weekly cron
672
-		if ( wp_next_scheduled( 'monsterinsights_weekly_cron' ) ) {
673
-			wp_clear_scheduled_hook( 'monsterinsights_weekly_cron' );
672
+		if (wp_next_scheduled('monsterinsights_weekly_cron')) {
673
+			wp_clear_scheduled_hook('monsterinsights_weekly_cron');
674 674
 		}
675 675
 
676 676
 		// Remove Yoast cron
677
-		if ( wp_next_scheduled( 'yst_ga_aggregate_data' ) ) {
678
-			wp_clear_scheduled_hook( 'yst_ga_aggregate_data' );
677
+		if (wp_next_scheduled('yst_ga_aggregate_data')) {
678
+			wp_clear_scheduled_hook('yst_ga_aggregate_data');
679 679
 		}
680 680
 	}
681 681
 
@@ -691,8 +691,8 @@  discard block
 block discarded – undo
691 691
 	 */
692 692
 	public function v620_upgrades() {
693 693
 		// Turns off debug mode if its on.
694
-		if ( empty( $this->new_settings['debug_mode' ] ) ) {
695
-			$this->new_settings['debug_mode' ] = 0;
694
+		if (empty($this->new_settings['debug_mode'])) {
695
+			$this->new_settings['debug_mode'] = 0;
696 696
 		}
697 697
 	}
698 698
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -516,7 +516,7 @@
 block discarded – undo
516 516
 						delete_option( 'yoast-ga-access_token' );
517 517
 						delete_option( 'yoast-ga-refresh_token' );
518 518
 						delete_option( 'yst_ga_api' );
519
-					}  else {
519
+					} else {
520 520
 					// if UA in profile profiles, remove others and use that
521 521
 						if ( ! empty( $options['analytics_profile' ] ) && ! empty( $profiles['ga_api_response_accounts'] ) && is_array( $profiles['ga_api_response_accounts'] ) ) {
522 522
 							foreach ( $profiles as $account ) {
Please login to merge, or discard this patch.
Indentation   +667 added lines, -667 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 
15 15
 // Exit if accessed directly
16 16
 if ( ! defined( 'ABSPATH' ) ) { 
17
-	exit;
17
+    exit;
18 18
 }
19 19
 
20 20
 /**
@@ -29,693 +29,693 @@  discard block
 block discarded – undo
29 29
  */
30 30
 class MonsterInsights_Install {
31 31
 
32
-	/**
33
-	 * MI Settings.
34
-	 *
35
-	 * @since 6.0.0
36
-	 * @access public
37
-	 * @var array $new_settings When the init() function starts, initially
38
-	 *      					contains the original settings. At the end 
39
-	 *      				 	of init() contains the settings to save.
40
-	 */	
41
-	public $new_settings = array();
42
-
43
-	/**
44
-	 * Install/Upgrade routine.
45
-	 *
46
-	 * This function is what is called to actually install MI data on new installs and to do
47
-	 * behind the scenes upgrades on MI upgrades. If this function contains a bug, the results 
48
-	 * can be catastrophic. This function gets the highest priority in all of MI for unit tests.
49
-	 *
50
-	 * @since 6.0.0
51
-	 * @access public
52
-	 *
53
-	 * @todo  I'd like to add preflight checks here.
54
-	 * @todo  I'd like to add a recovery system here.
55
-	 * 
56
-	 * @return void
57
-	 */
58
-	public function init() {
59
-
60
-		// Get a copy of the current MI settings.
61
-		$this->new_settings = get_option( monsterinsights_get_option_name() );
62
-
63
-
64
-		$version = get_option( 'monsterinsights_current_version', false );
65
-		$yoast   = get_option( 'yst_ga', false );
66
-		$cachec  = false; // have we forced an object cache to be cleared already (so we don't clear it unnecessarily)
67
-
68
-		// if new install and have not used Yoast previously
69
-		if ( ! $version && ! $yoast ) {
70
-
71
-			$this->new_install();
72
-			// This is the version used for MI upgrade routines.
73
-			update_option( 'monsterinsights_db_version', '6.2.0' );
32
+    /**
33
+     * MI Settings.
34
+     *
35
+     * @since 6.0.0
36
+     * @access public
37
+     * @var array $new_settings When the init() function starts, initially
38
+     *      					contains the original settings. At the end 
39
+     *      				 	of init() contains the settings to save.
40
+     */	
41
+    public $new_settings = array();
42
+
43
+    /**
44
+     * Install/Upgrade routine.
45
+     *
46
+     * This function is what is called to actually install MI data on new installs and to do
47
+     * behind the scenes upgrades on MI upgrades. If this function contains a bug, the results 
48
+     * can be catastrophic. This function gets the highest priority in all of MI for unit tests.
49
+     *
50
+     * @since 6.0.0
51
+     * @access public
52
+     *
53
+     * @todo  I'd like to add preflight checks here.
54
+     * @todo  I'd like to add a recovery system here.
55
+     * 
56
+     * @return void
57
+     */
58
+    public function init() {
59
+
60
+        // Get a copy of the current MI settings.
61
+        $this->new_settings = get_option( monsterinsights_get_option_name() );
62
+
63
+
64
+        $version = get_option( 'monsterinsights_current_version', false );
65
+        $yoast   = get_option( 'yst_ga', false );
66
+        $cachec  = false; // have we forced an object cache to be cleared already (so we don't clear it unnecessarily)
67
+
68
+        // if new install and have not used Yoast previously
69
+        if ( ! $version && ! $yoast ) {
70
+
71
+            $this->new_install();
72
+            // This is the version used for MI upgrade routines.
73
+            update_option( 'monsterinsights_db_version', '6.2.0' );
74 74
 			
75
-		} else if ( ! $version && $yoast ) { // if new install and has used Yoast previously
75
+        } else if ( ! $version && $yoast ) { // if new install and has used Yoast previously
76 76
 
77
-			$this->upgrade_from_yoast();
78
-			// This is the version used for MI upgrade routines.
79
-			update_option( 'monsterinsights_db_version', '6.2.0' );
77
+            $this->upgrade_from_yoast();
78
+            // This is the version used for MI upgrade routines.
79
+            update_option( 'monsterinsights_db_version', '6.2.0' );
80 80
 
81
-			if ( ! $cachec ) {
82
-				wp_cache_flush();
83
-				$cachec = true;
84
-			}
81
+            if ( ! $cachec ) {
82
+                wp_cache_flush();
83
+                $cachec = true;
84
+            }
85 85
 			
86
-		} else { // if existing install
87
-			if ( version_compare( $version, '6.0.2', '<' ) ) {
88
-				$this->v602_upgrades();
89
-			}
86
+        } else { // if existing install
87
+            if ( version_compare( $version, '6.0.2', '<' ) ) {
88
+                $this->v602_upgrades();
89
+            }
90 90
 			
91
-			if ( version_compare( $version, '6.0.11', '<' ) ) {
92
-				$this->v6011_upgrades();
93
-
94
-				if ( ! $cachec ) {
95
-					wp_cache_flush();
96
-					$cachec = true;
97
-				}
98
-			}
99
-			if ( version_compare( $version, '6.2.0', '<' ) ) {
100
-				$this->v620_upgrades();
101
-			}
102
-
103
-			update_option( 'monsterinsights_db_version', '6.2.0' );
91
+            if ( version_compare( $version, '6.0.11', '<' ) ) {
92
+                $this->v6011_upgrades();
93
+
94
+                if ( ! $cachec ) {
95
+                    wp_cache_flush();
96
+                    $cachec = true;
97
+                }
98
+            }
99
+            if ( version_compare( $version, '6.2.0', '<' ) ) {
100
+                $this->v620_upgrades();
101
+            }
102
+
103
+            update_option( 'monsterinsights_db_version', '6.2.0' );
104 104
 			
105
-			// @todo: doc as nonpublic
105
+            // @todo: doc as nonpublic
106 106
 			
107
-			update_option( 'monsterinsights_version_upgraded_from', $version );
108
-			do_action( 'monsterinsights_after_existing_upgrade_routine', $version );
109
-		}
110
-
111
-		// This hook is used primarily by the Pro version to run some Pro
112
-		// specific install stuff. Please do not use this hook. It is not 
113
-		// considered a public hook by MI's dev team and can/will be removed, 
114
-		// relocated, and/or altered without warning at any time. You've been warned.
115
-		// As this hook is not for public use, we've intentionally not docbloc'd this
116
-		// hook to avoid developers seeing it future public dev docs.
117
-		do_action( 'monsterinsights_after_install_routine', $version );
118
-
119
-		// This is the version of the MI settings themselves
120
-		update_option( 'monsterinsights_settings_version', '6.0.0' );
121
-
122
-		// This is the version of MI installed
123
-		update_option( 'monsterinsights_current_version', MONSTERINSIGHTS_VERSION );
124
-
125
-		// This is where we save MI settings
126
-		update_option( monsterinsights_get_option_name(), $this->new_settings );
127
-
128
-		// This is where we redirect to the MI welcome page
129
-		//set_transient( '_monsterinsights_activation_redirect', true, 30 ); @todo: Investigate
130
-
131
-		// There's no code for this function below this. Just an explanation
132
-		// of the MI core options.
133
-
134
-		/** 
135
-		 * Explanation of MonsterInsights core options
136
-		 *
137
-		 * By now your head is probably spinning trying to figure
138
-		 * out what all of these version options are for. Note, I've abbreviated
139
-		 * "monsterinsights" to "mi" in the options names to make this table easier
140
-		 * to read.
141
-		 *
142
-		 * Here's a basic rundown:
143
-		 *
144
-		 * mi_settings_version: Used to store the version 
145
-		 * 						of the MI settings. We use this
146
-		 * 						so we can do upgrade routines where
147
-		 * 						we'd have to do different actions based
148
-		 * 						on the version the settings were installed
149
-		 * 						in. For example: if we made a mistake with 
150
-		 * 						the value we saved as the default for 
151
-		 * 						a select setting, we can detect the version
152
-		 * 						containing this mistake and correct it.
153
-		 *
154
-		 * mi_current_version:  This starts with the actual version MI was
155
-		 * 						installed on. We use this version to 
156
-		 * 						determine whether or not a site needs
157
-		 * 						to run one of the behind the scenes
158
-		 * 						MI upgrade routines. This version is updated
159
-		 * 						every time a minor or major background upgrade
160
-		 * 						routine is run. Generally lags behind the 
161
-		 * 						MONSTERINSIGHTS_VERSION constant by at most a couple minor
162
-		 * 						versions. Never lags behind by 1 major version
163
-		 * 						or more.
164
-		 *
165
-		 * mi_db_version: 		This is different from mi_current_version.
166
-		 * 						Unlike the former, this is used to determine
167
-		 * 						if a site needs to run a *user* initiated
168
-		 * 						upgrade routine (see MI_Upgrade class). This
169
-		 * 						value is only update when a user initiated
170
-		 * 						upgrade routine is done. Because we do very
171
-		 * 						few user initiated upgrades compared to 
172
-		 * 						automatic ones, this version can lag behind by
173
-		 * 						2 or even 3 major versions. Generally contains
174
-		 * 						the current major version.
175
-		 *
176
-		 * mi_settings:		    Returned by monsterinsights_get_option_name(), this
177
-		 * 						is actually "monsterinsights_settings" for both pro
178
-		 * 						and lite version. However we use a helper function to 
179
-		 * 						retrieve the option name in case we ever decide down the
180
-		 * 						road to maintain seperate options for the Lite and Pro versions.
181
-		 * 					 	If you need to access MI's settings directly, (as opposed to our
182
-		 * 					 	monsterinsights_get_option helper which uses the option name helper
183
-		 * 					 	automatically), you should use this function to get the 
184
-		 * 					 	name of the option to retrieve.
185
-		 *
186
-		 * yst_ga:			    Yoast's old settings option. We no longer use this, though
187
-		 * 						for backwards compatibility reasons we store the updated settings
188
-		 * 						in this just for a little while longer. These settings are migrated
189
-		 * 						to the new settings option when you upgrade to MonsterInsights
190
-		 * 						6.0 or higher automatically.
191
-		 *
192
-		 * yst_* & yoast_*:		These are options from when the plugin was developed by
193
-		 * 						Yoast, and also of the few point releases we did after
194
-		 * 						the acquisition. Note, while we currently do backcompat
195
-		 * 						on some of these options so other plugins will continue working
196
-		 * 						please realize there will be a point in the near future that we 
197
-		 * 						will no longer support them. Please do not use them anymore.
198
-		 */			
199
-	}
200
-
201
-
202
-	/**
203
-	 * New MonsterInsights Install routine.
204
-	 *
205
-	 * This function installs all of the default
206
-	 * things on new MI installs. Flight 5476 with 
207
-	 * non-stop service to a whole world of 
208
-	 * possibilities is now boarding.
209
-	 *
210
-	 * @since 6.0.0
211
-	 * @access public
212
-	 * 
213
-	 * @return void
214
-	 */
215
-	public function new_install() {
216
-
217
-		// Add default settings values
218
-		$this->new_settings = $this->get_monsterinsights_default_values();
219
-
220
-		$data = array(
221
-			'installed_version' => MONSTERINSIGHTS_VERSION,
222
-			'installed_date'    => time(),
223
-			'installed_pro'     => monsterinsights_is_pro_version(),
224
-		);
225
-
226
-		update_option( 'monsterinsights_over_time', $data );
227
-
228
-		// Add cron job
229
-		if ( ! wp_next_scheduled( 'monsterinsights_daily_cron' ) ) {
230
-			// Set the next event of fetching data
231
-			wp_schedule_event( strtotime( date( 'Y-m-d', strtotime( 'tomorrow' ) ) . ' 00:05:00 ' ), 'daily', 'monsterinsights_daily_cron' );
232
-		}
233
-
234
-		// Let addons + MI Pro/Lite hook in here. @todo: doc as nonpublic
235
-		do_action( 'monsterinsights_after_new_install_routine', MONSTERINSIGHTS_VERSION );
236
-	}
237
-
238
-	/**
239
-	 * Upgrade from Yoast.
240
-	 *
241
-	 * This function does the upgrade routine from Yoast to this plugin version.
242
-	 * Includes all of Yoast's previous routines.
243
-	 *
244
-	 * @since 6.0.0
245
-	 * @access public
246
-	 * 
247
-	 * @return void
248
-	 */
249
-	public function upgrade_from_yoast() {
250
-		// Do Yoast's Old Routines
251
-		$options = get_option( 'yst_ga', array() );
252
-		if ( ! empty( $options['ga_general'] ) ) {
253
-			$options = $options['ga_general'];
254
-		}
255
-
256
-		$tracking_code = null;
257
-		if ( ! empty( $options['analytics_profile'] ) && ! empty( $options['analytics_profile_code'] ) ) {
258
-			$tracking_code = $options['analytics_profile_code'];
259
-		} else if ( ! empty( $options['analytics_profile'] ) && empty( $options['analytics_profile_code'] ) ) {
260
-			// Analytics profile is still holding the UA code
261
-			$tracking_code = $options['analytics_profile'];
262
-		}
263
-
264
-		if ( ! empty( $options['manual_ua_code_field'] ) && ! empty( $options['manual_ua_code'] ) ) {
265
-			$tracking_code = $options['manual_ua_code_field'];
266
-		}
267
-
268
-		if ( ! isset( $options['version'] ) && is_null( $tracking_code ) ) {
269
-			$old_options = get_option( 'Yoast_Google_Analytics' );
270
-			if ( isset( $old_options ) && is_array( $old_options ) ) {
271
-				if ( isset( $old_options['uastring'] ) && '' !== trim( $old_options['uastring'] ) ) {
272
-					// Save UA as manual UA, instead of saving all the old GA crap
273
-					$options['manual_ua_code']       = 1;
274
-					$options['manual_ua_code_field'] = $old_options['uastring'];
275
-				}
276
-				// Other settings
277
-				$options['allow_anchor']               = $old_options['allowanchor'];
278
-				$options['add_allow_linker']           = $old_options['allowlinker'];
279
-				$options['anonymous_data']             = $old_options['anonymizeip'];
280
-				$options['track_outbound']             = $old_options['trackoutbound'];
281
-				$options['track_internal_as_outbound'] = $old_options['internallink'];
282
-				$options['track_internal_as_label']    = $old_options['internallinklabel'];
283
-				$options['extensions_of_files']        = $old_options['dlextensions'];
284
-			}
285
-			delete_option( 'Yoast_Google_Analytics' );
286
-		}
287
-		// 5.0.0 to 5.0.1 fix of ignore users array
288
-		if ( ! isset( $options['version'] ) || version_compare( $options['version'], '5.0.1', '<' ) ) {
289
-			if ( isset( $options['ignore_users'] ) && ! is_array( $options['ignore_users'] ) ) {
290
-				$options['ignore_users'] = (array) $options['ignore_users'];
291
-			}
292
-		}
293
-		// 5.1.2+ Remove firebug_lite from options, if set
294
-		if ( ! isset ( $options['version'] ) || version_compare( $options['version'], '5.1.2', '<' ) ) {
295
-			if ( isset( $options['firebug_lite'] ) ) {
296
-				unset( $options['firebug_lite'] );
297
-			}
298
-		}
299
-		// 5.2.8+ Add disabled dashboards option
300
-		if ( ! isset ( $options['dashboards_disabled'] ) || version_compare( $options['version'], '5.2.8', '>' ) ) {
301
-			$options['dashboards_disabled'] = 0;
302
-		}
303
-		// Check is API option already exists - if not add it
304
-		$yst_ga_api = get_option( 'yst_ga_api' );
305
-		if ( $yst_ga_api === false ) {
306
-			add_option( 'yst_ga_api', array(), '', 'no' );
307
-		}
308
-		// Fallback to make sure every default option has a value
309
-		$defaults = $this->get_yoast_default_values();
310
-		if ( is_array( $defaults ) ) {
311
-			foreach ( $defaults[ 'ga_general' ] as $key => $value ) {
312
-				if ( ! isset( $options[ $key ] ) ) {
313
-					$options[ $key ] = $value;
314
-				}
315
-			}
316
-		}
317
-
318
-		// Set to the current version now that we've done all needed upgrades
319
-		$options['version'] = '5.5.3'; // Last Yoast codebase version
320
-		$saved_options = get_option( 'yst_ga' );
321
-		$saved_options[ 'ga_general' ] = $options;
322
-		update_option( 'yst_ga', $saved_options );
323
-
324
-
325
-		// Do license key switchover 
326
-			$key     = '';
327
-			$found   = false;
328
-			$network = false;
329
-			// Try network active Premium
330
-			$is_key = get_site_option( 'google-analytics-by-yoast-premium_license', array() );
331
-			if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) && is_multisite() ){
332
-				$key    = $is_key['key'];
333
-				$found = true;
334
-				$network = true;
335
-			}
336
-
337
-			// Try single site Premium
338
-			if ( ! $found ) {
339
-				$is_key = get_option( 'google-analytics-by-yoast-premium_license', array() );
340
-				if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) ){
341
-					$key    = $is_key['key'];
342
-					$found = true;
343
-				}				
344
-			}
345
-
346
-			// Try network active Premium
347
-			if ( ! $found ) {
348
-				$is_key = get_site_option( 'monsterinsights-pro_license', array() );
349
-				if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) && is_multisite() ){
350
-					$key    = $is_key['key'];
351
-					$found = true;
352
-					$network = true;
353
-				}				
354
-			}
107
+            update_option( 'monsterinsights_version_upgraded_from', $version );
108
+            do_action( 'monsterinsights_after_existing_upgrade_routine', $version );
109
+        }
110
+
111
+        // This hook is used primarily by the Pro version to run some Pro
112
+        // specific install stuff. Please do not use this hook. It is not 
113
+        // considered a public hook by MI's dev team and can/will be removed, 
114
+        // relocated, and/or altered without warning at any time. You've been warned.
115
+        // As this hook is not for public use, we've intentionally not docbloc'd this
116
+        // hook to avoid developers seeing it future public dev docs.
117
+        do_action( 'monsterinsights_after_install_routine', $version );
118
+
119
+        // This is the version of the MI settings themselves
120
+        update_option( 'monsterinsights_settings_version', '6.0.0' );
121
+
122
+        // This is the version of MI installed
123
+        update_option( 'monsterinsights_current_version', MONSTERINSIGHTS_VERSION );
124
+
125
+        // This is where we save MI settings
126
+        update_option( monsterinsights_get_option_name(), $this->new_settings );
127
+
128
+        // This is where we redirect to the MI welcome page
129
+        //set_transient( '_monsterinsights_activation_redirect', true, 30 ); @todo: Investigate
130
+
131
+        // There's no code for this function below this. Just an explanation
132
+        // of the MI core options.
133
+
134
+        /** 
135
+         * Explanation of MonsterInsights core options
136
+         *
137
+         * By now your head is probably spinning trying to figure
138
+         * out what all of these version options are for. Note, I've abbreviated
139
+         * "monsterinsights" to "mi" in the options names to make this table easier
140
+         * to read.
141
+         *
142
+         * Here's a basic rundown:
143
+         *
144
+         * mi_settings_version: Used to store the version 
145
+         * 						of the MI settings. We use this
146
+         * 						so we can do upgrade routines where
147
+         * 						we'd have to do different actions based
148
+         * 						on the version the settings were installed
149
+         * 						in. For example: if we made a mistake with 
150
+         * 						the value we saved as the default for 
151
+         * 						a select setting, we can detect the version
152
+         * 						containing this mistake and correct it.
153
+         *
154
+         * mi_current_version:  This starts with the actual version MI was
155
+         * 						installed on. We use this version to 
156
+         * 						determine whether or not a site needs
157
+         * 						to run one of the behind the scenes
158
+         * 						MI upgrade routines. This version is updated
159
+         * 						every time a minor or major background upgrade
160
+         * 						routine is run. Generally lags behind the 
161
+         * 						MONSTERINSIGHTS_VERSION constant by at most a couple minor
162
+         * 						versions. Never lags behind by 1 major version
163
+         * 						or more.
164
+         *
165
+         * mi_db_version: 		This is different from mi_current_version.
166
+         * 						Unlike the former, this is used to determine
167
+         * 						if a site needs to run a *user* initiated
168
+         * 						upgrade routine (see MI_Upgrade class). This
169
+         * 						value is only update when a user initiated
170
+         * 						upgrade routine is done. Because we do very
171
+         * 						few user initiated upgrades compared to 
172
+         * 						automatic ones, this version can lag behind by
173
+         * 						2 or even 3 major versions. Generally contains
174
+         * 						the current major version.
175
+         *
176
+         * mi_settings:		    Returned by monsterinsights_get_option_name(), this
177
+         * 						is actually "monsterinsights_settings" for both pro
178
+         * 						and lite version. However we use a helper function to 
179
+         * 						retrieve the option name in case we ever decide down the
180
+         * 						road to maintain seperate options for the Lite and Pro versions.
181
+         * 					 	If you need to access MI's settings directly, (as opposed to our
182
+         * 					 	monsterinsights_get_option helper which uses the option name helper
183
+         * 					 	automatically), you should use this function to get the 
184
+         * 					 	name of the option to retrieve.
185
+         *
186
+         * yst_ga:			    Yoast's old settings option. We no longer use this, though
187
+         * 						for backwards compatibility reasons we store the updated settings
188
+         * 						in this just for a little while longer. These settings are migrated
189
+         * 						to the new settings option when you upgrade to MonsterInsights
190
+         * 						6.0 or higher automatically.
191
+         *
192
+         * yst_* & yoast_*:		These are options from when the plugin was developed by
193
+         * 						Yoast, and also of the few point releases we did after
194
+         * 						the acquisition. Note, while we currently do backcompat
195
+         * 						on some of these options so other plugins will continue working
196
+         * 						please realize there will be a point in the near future that we 
197
+         * 						will no longer support them. Please do not use them anymore.
198
+         */			
199
+    }
200
+
201
+
202
+    /**
203
+     * New MonsterInsights Install routine.
204
+     *
205
+     * This function installs all of the default
206
+     * things on new MI installs. Flight 5476 with 
207
+     * non-stop service to a whole world of 
208
+     * possibilities is now boarding.
209
+     *
210
+     * @since 6.0.0
211
+     * @access public
212
+     * 
213
+     * @return void
214
+     */
215
+    public function new_install() {
216
+
217
+        // Add default settings values
218
+        $this->new_settings = $this->get_monsterinsights_default_values();
219
+
220
+        $data = array(
221
+            'installed_version' => MONSTERINSIGHTS_VERSION,
222
+            'installed_date'    => time(),
223
+            'installed_pro'     => monsterinsights_is_pro_version(),
224
+        );
225
+
226
+        update_option( 'monsterinsights_over_time', $data );
227
+
228
+        // Add cron job
229
+        if ( ! wp_next_scheduled( 'monsterinsights_daily_cron' ) ) {
230
+            // Set the next event of fetching data
231
+            wp_schedule_event( strtotime( date( 'Y-m-d', strtotime( 'tomorrow' ) ) . ' 00:05:00 ' ), 'daily', 'monsterinsights_daily_cron' );
232
+        }
233
+
234
+        // Let addons + MI Pro/Lite hook in here. @todo: doc as nonpublic
235
+        do_action( 'monsterinsights_after_new_install_routine', MONSTERINSIGHTS_VERSION );
236
+    }
237
+
238
+    /**
239
+     * Upgrade from Yoast.
240
+     *
241
+     * This function does the upgrade routine from Yoast to this plugin version.
242
+     * Includes all of Yoast's previous routines.
243
+     *
244
+     * @since 6.0.0
245
+     * @access public
246
+     * 
247
+     * @return void
248
+     */
249
+    public function upgrade_from_yoast() {
250
+        // Do Yoast's Old Routines
251
+        $options = get_option( 'yst_ga', array() );
252
+        if ( ! empty( $options['ga_general'] ) ) {
253
+            $options = $options['ga_general'];
254
+        }
255
+
256
+        $tracking_code = null;
257
+        if ( ! empty( $options['analytics_profile'] ) && ! empty( $options['analytics_profile_code'] ) ) {
258
+            $tracking_code = $options['analytics_profile_code'];
259
+        } else if ( ! empty( $options['analytics_profile'] ) && empty( $options['analytics_profile_code'] ) ) {
260
+            // Analytics profile is still holding the UA code
261
+            $tracking_code = $options['analytics_profile'];
262
+        }
263
+
264
+        if ( ! empty( $options['manual_ua_code_field'] ) && ! empty( $options['manual_ua_code'] ) ) {
265
+            $tracking_code = $options['manual_ua_code_field'];
266
+        }
267
+
268
+        if ( ! isset( $options['version'] ) && is_null( $tracking_code ) ) {
269
+            $old_options = get_option( 'Yoast_Google_Analytics' );
270
+            if ( isset( $old_options ) && is_array( $old_options ) ) {
271
+                if ( isset( $old_options['uastring'] ) && '' !== trim( $old_options['uastring'] ) ) {
272
+                    // Save UA as manual UA, instead of saving all the old GA crap
273
+                    $options['manual_ua_code']       = 1;
274
+                    $options['manual_ua_code_field'] = $old_options['uastring'];
275
+                }
276
+                // Other settings
277
+                $options['allow_anchor']               = $old_options['allowanchor'];
278
+                $options['add_allow_linker']           = $old_options['allowlinker'];
279
+                $options['anonymous_data']             = $old_options['anonymizeip'];
280
+                $options['track_outbound']             = $old_options['trackoutbound'];
281
+                $options['track_internal_as_outbound'] = $old_options['internallink'];
282
+                $options['track_internal_as_label']    = $old_options['internallinklabel'];
283
+                $options['extensions_of_files']        = $old_options['dlextensions'];
284
+            }
285
+            delete_option( 'Yoast_Google_Analytics' );
286
+        }
287
+        // 5.0.0 to 5.0.1 fix of ignore users array
288
+        if ( ! isset( $options['version'] ) || version_compare( $options['version'], '5.0.1', '<' ) ) {
289
+            if ( isset( $options['ignore_users'] ) && ! is_array( $options['ignore_users'] ) ) {
290
+                $options['ignore_users'] = (array) $options['ignore_users'];
291
+            }
292
+        }
293
+        // 5.1.2+ Remove firebug_lite from options, if set
294
+        if ( ! isset ( $options['version'] ) || version_compare( $options['version'], '5.1.2', '<' ) ) {
295
+            if ( isset( $options['firebug_lite'] ) ) {
296
+                unset( $options['firebug_lite'] );
297
+            }
298
+        }
299
+        // 5.2.8+ Add disabled dashboards option
300
+        if ( ! isset ( $options['dashboards_disabled'] ) || version_compare( $options['version'], '5.2.8', '>' ) ) {
301
+            $options['dashboards_disabled'] = 0;
302
+        }
303
+        // Check is API option already exists - if not add it
304
+        $yst_ga_api = get_option( 'yst_ga_api' );
305
+        if ( $yst_ga_api === false ) {
306
+            add_option( 'yst_ga_api', array(), '', 'no' );
307
+        }
308
+        // Fallback to make sure every default option has a value
309
+        $defaults = $this->get_yoast_default_values();
310
+        if ( is_array( $defaults ) ) {
311
+            foreach ( $defaults[ 'ga_general' ] as $key => $value ) {
312
+                if ( ! isset( $options[ $key ] ) ) {
313
+                    $options[ $key ] = $value;
314
+                }
315
+            }
316
+        }
317
+
318
+        // Set to the current version now that we've done all needed upgrades
319
+        $options['version'] = '5.5.3'; // Last Yoast codebase version
320
+        $saved_options = get_option( 'yst_ga' );
321
+        $saved_options[ 'ga_general' ] = $options;
322
+        update_option( 'yst_ga', $saved_options );
323
+
324
+
325
+        // Do license key switchover 
326
+            $key     = '';
327
+            $found   = false;
328
+            $network = false;
329
+            // Try network active Premium
330
+            $is_key = get_site_option( 'google-analytics-by-yoast-premium_license', array() );
331
+            if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) && is_multisite() ){
332
+                $key    = $is_key['key'];
333
+                $found = true;
334
+                $network = true;
335
+            }
336
+
337
+            // Try single site Premium
338
+            if ( ! $found ) {
339
+                $is_key = get_option( 'google-analytics-by-yoast-premium_license', array() );
340
+                if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) ){
341
+                    $key    = $is_key['key'];
342
+                    $found = true;
343
+                }				
344
+            }
345
+
346
+            // Try network active Premium
347
+            if ( ! $found ) {
348
+                $is_key = get_site_option( 'monsterinsights-pro_license', array() );
349
+                if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) && is_multisite() ){
350
+                    $key    = $is_key['key'];
351
+                    $found = true;
352
+                    $network = true;
353
+                }				
354
+            }
355 355
 			
356
-			// Try single site Premium
357
-			if ( ! $found ) {
358
-				$is_key = get_option( 'monsterinsights-pro_license', array() );
359
-				if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) ){
360
-					$key    = $is_key['key'];
361
-					$found = true;
362
-				}				
363
-			}
356
+            // Try single site Premium
357
+            if ( ! $found ) {
358
+                $is_key = get_option( 'monsterinsights-pro_license', array() );
359
+                if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) ){
360
+                    $key    = $is_key['key'];
361
+                    $found = true;
362
+                }				
363
+            }
364 364
 			
365
-			// Try network active ecommmerce
366
-			if ( ! $found ) {
367
-				$is_key = get_site_option( 'ecommerce-addon_license', array() );
368
-				if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) && is_multisite() ){
369
-					$key    = $is_key['key'];
370
-					$found = true;
371
-					$network = true;
372
-				}
373
-			}
374
-			// Try single site ecommerce
375
-			if ( ! $found ) {
376
-				$is_key = get_option( 'ecommerce-addon_license', array() );
377
-				if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) ){
378
-					$key    = $is_key['key'];
379
-					$found = true;
380
-				}				
381
-			}
382
-
383
-			// set as new key for monsterinsights
384
-			if ( $found && ! empty( $key ) ) {
385
-				// In pro, install custom dimensions + ads. In lite, just save the key
386
-				do_action( 'monsterinsights_upgrade_from_yoast', $key, $network );
387
-			}
388
-
389
-		// Next up: Settings Migration
365
+            // Try network active ecommmerce
366
+            if ( ! $found ) {
367
+                $is_key = get_site_option( 'ecommerce-addon_license', array() );
368
+                if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) && is_multisite() ){
369
+                    $key    = $is_key['key'];
370
+                    $found = true;
371
+                    $network = true;
372
+                }
373
+            }
374
+            // Try single site ecommerce
375
+            if ( ! $found ) {
376
+                $is_key = get_option( 'ecommerce-addon_license', array() );
377
+                if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) ){
378
+                    $key    = $is_key['key'];
379
+                    $found = true;
380
+                }				
381
+            }
382
+
383
+            // set as new key for monsterinsights
384
+            if ( $found && ! empty( $key ) ) {
385
+                // In pro, install custom dimensions + ads. In lite, just save the key
386
+                do_action( 'monsterinsights_upgrade_from_yoast', $key, $network );
387
+            }
388
+
389
+        // Next up: Settings Migration
390 390
 		
391
-			$options = get_option( 'yst_ga', array() );
392
-			if ( ! empty( $options['ga_general'] ) ) {
393
-				$options = $options['ga_general'];
394
-			}
395
-
396
-
397
-			// Let's remove the defaults
398
-			if ( isset( $options['ga_general'] ) ) {
399
-				unset( $options['ga_general'] );
400
-			}
401
-
402
-			// Let's remove unused options
403
-			if ( isset( $options['yoast_ga_nonce'] ) ) {
404
-				unset( $options['yoast_ga_nonce'] );
405
-			}			
406
-			if ( isset( $options['ga-form-settings'] ) ) {
407
-				unset( $options['ga-form-settings'] );
408
-			}
409
-			if ( isset( $options['string_error_custom_dimensions'] ) ) {
410
-				unset( $options['string_error_custom_dimensions'] );
411
-			}
412
-			if ( isset( $options['custom_metrics'] ) ) {
413
-				unset( $options['custom_metrics'] );
414
-			}	
415
-			if ( isset( $options['track_full_url'] ) ) {
416
-				unset( $options['track_full_url'] );
417
-			}	
418
-			if ( isset( $options['version'] ) ) {
419
-				unset( $options['version'] );
420
-			}
421
-
422
-			// Migrate universal to tracking_mode
423
-			if ( isset( $options['enable_universal'] ) ) {
424
-				unset( $options['enable_universal'] );
425
-				$options['tracking_mode'] = 'analytics';
426
-			} else {
427
-				$options['tracking_mode'] = 'ga';
428
-			}
429
-
430
-			// Migrate events tracking
431
-			if ( isset( $options['track_outbound'] ) ) {
432
-				unset( $options['track_outbound'] );
433
-				$options['events_mode'] = 'php';
434
-			} else {
435
-				$options['events_mode'] = 'none';
436
-			}
437
-
438
-			// Migrate anonymous_data to allow tracking
439
-			if ( isset( $options['anonymous_data'] ) ) {
440
-				unset( $options['anonymous_data'] );
441
-				$options['allow_tracking'] = 1;
442
-			} else {
443
-				$options['allow_tracking'] = 0;
444
-			}
391
+            $options = get_option( 'yst_ga', array() );
392
+            if ( ! empty( $options['ga_general'] ) ) {
393
+                $options = $options['ga_general'];
394
+            }
395
+
396
+
397
+            // Let's remove the defaults
398
+            if ( isset( $options['ga_general'] ) ) {
399
+                unset( $options['ga_general'] );
400
+            }
401
+
402
+            // Let's remove unused options
403
+            if ( isset( $options['yoast_ga_nonce'] ) ) {
404
+                unset( $options['yoast_ga_nonce'] );
405
+            }			
406
+            if ( isset( $options['ga-form-settings'] ) ) {
407
+                unset( $options['ga-form-settings'] );
408
+            }
409
+            if ( isset( $options['string_error_custom_dimensions'] ) ) {
410
+                unset( $options['string_error_custom_dimensions'] );
411
+            }
412
+            if ( isset( $options['custom_metrics'] ) ) {
413
+                unset( $options['custom_metrics'] );
414
+            }	
415
+            if ( isset( $options['track_full_url'] ) ) {
416
+                unset( $options['track_full_url'] );
417
+            }	
418
+            if ( isset( $options['version'] ) ) {
419
+                unset( $options['version'] );
420
+            }
421
+
422
+            // Migrate universal to tracking_mode
423
+            if ( isset( $options['enable_universal'] ) ) {
424
+                unset( $options['enable_universal'] );
425
+                $options['tracking_mode'] = 'analytics';
426
+            } else {
427
+                $options['tracking_mode'] = 'ga';
428
+            }
429
+
430
+            // Migrate events tracking
431
+            if ( isset( $options['track_outbound'] ) ) {
432
+                unset( $options['track_outbound'] );
433
+                $options['events_mode'] = 'php';
434
+            } else {
435
+                $options['events_mode'] = 'none';
436
+            }
437
+
438
+            // Migrate anonymous_data to allow tracking
439
+            if ( isset( $options['anonymous_data'] ) ) {
440
+                unset( $options['anonymous_data'] );
441
+                $options['allow_tracking'] = 1;
442
+            } else {
443
+                $options['allow_tracking'] = 0;
444
+            }
445 445
 
446 446
 		
447
-		// Migrate GA profile data if there
448
-			// first let's try to salvage the current profile
449
-			$access_token  = get_option( 'yoast-ga-access_token', array() );
450
-			$refresh_token = get_option( 'yoast-ga-refresh_token', array() );
451
-			$profiles      = get_option( 'yst_ga_api', array() );
447
+        // Migrate GA profile data if there
448
+            // first let's try to salvage the current profile
449
+            $access_token  = get_option( 'yoast-ga-access_token', array() );
450
+            $refresh_token = get_option( 'yoast-ga-refresh_token', array() );
451
+            $profiles      = get_option( 'yst_ga_api', array() );
452 452
 
453
-			$profile_name  = ! empty( $options['analytics_profile'] ) ? $options['analytics_profile'] : ''; 
453
+            $profile_name  = ! empty( $options['analytics_profile'] ) ? $options['analytics_profile'] : ''; 
454 454
 
455
-				if ( empty( $refresh_token ) && ! empty( $access_token['refresh_token'] ) ) {
456
-					$refresh_token = $access_token['refresh_token'];
457
-				}
455
+                if ( empty( $refresh_token ) && ! empty( $access_token['refresh_token'] ) ) {
456
+                    $refresh_token = $access_token['refresh_token'];
457
+                }
458 458
 	
459
-				// We need a name and a profile
460
-				if ( ! empty( $refresh_token ) && ! empty( $options['analytics_profile'] ) && ! empty( $profiles['ga_api_response_accounts'] ) ) {
461
-					// See if we have an access token
462
-					if ( ! empty( $access_token['access_token'] ) ) {
463
-						if ( monsterinsights_is_pro_version() ) {
464
-							update_option( 'monsterinsights_pro_access_token', $access_token['access_token'] );
465
-						} else {
466
-							update_option( 'monsterinsights_lite_access_token', $access_token['access_token'] );
467
-						}
468
-					}
469
-
470
-					// We need a refresh token
471
-					if ( monsterinsights_is_pro_version() ) {
472
-						update_option( 'monsterinsights_pro_refresh_token', $refresh_token );
473
-					} else {
474
-						update_option( 'monsterinsights_lite_refresh_token', $refresh_token );
475
-					}
476
-
477
-					// If we can find the profile in the response save the name
478
-					if ( ! empty( $profiles['ga_api_response_accounts'] ) && is_array( $profiles['ga_api_response_accounts'] ) ) {
479
-						foreach ( $profiles['ga_api_response_accounts'] as $account ) {
480
-							foreach ( $account['items'] as $profile ) {
481
-								foreach ( $profile['items'] as $subprofile ) {
482
-									if ( isset( $subprofile['id'] ) && $subprofile['id'] == $profile_name ) {
483
-										$options['analytics_profile_name'] = $subprofile['name'];
484
-										if ( empty( $options['analytics_profile_code'] ) ) {
485
-											$options['analytics_profile_code'] = $subprofile['ua_code'];
486
-										}
487
-										break 3;
488
-									}
489
-								}
490
-							}
491
-						}
492
-					}
493
-					$options['cron_last_run'] = strtotime("-25 hours");
494
-				} else {
495
-					// if UA in manual code field, remove analytics profile fields if set
496
-					if ( ! empty( $options['manual_ua_code_field' ] ) ) {
497
-						if ( isset( $options['analytics_profile_code'] ) ) {
498
-							unset( $options['analytics_profile_code'] );
499
-						}
500
-						if ( isset( $options['analytics_profile'] ) ) {
501
-							unset( $options['analytics_profile'] );
502
-						}
503
-						$options['manual_ua_code'] = $options['manual_ua_code_field'];
504
-						delete_option( 'yoast-ga-access_token' );
505
-						delete_option( 'yoast-ga-refresh_token' );
506
-						delete_option( 'yst_ga_api' );
507
-					} else if ( ! empty( $options['analytics_profile_code' ] ) ) {
508
-					// if UA in profile fields, remove others and use that
509
-						$options['manual_ua_code'] = $options['analytics_profile_code'];
510
-						if ( isset( $options['analytics_profile_code'] ) ) {
511
-							unset( $options['analytics_profile_code'] );
512
-						}
513
-						if ( isset( $options['analytics_profile'] ) ) {
514
-							unset( $options['analytics_profile'] );
515
-						}
516
-						delete_option( 'yoast-ga-access_token' );
517
-						delete_option( 'yoast-ga-refresh_token' );
518
-						delete_option( 'yst_ga_api' );
519
-					}  else {
520
-					// if UA in profile profiles, remove others and use that
521
-						if ( ! empty( $options['analytics_profile' ] ) && ! empty( $profiles['ga_api_response_accounts'] ) && is_array( $profiles['ga_api_response_accounts'] ) ) {
522
-							foreach ( $profiles as $account ) {
523
-								foreach ( $account['items'] as $profile ) {
524
-									foreach ( $profile['items'] as $subprofile ) {
525
-										if ( isset( $subprofile['id'] ) && $subprofile['id'] == $options['analytics_profile' ] ) {
526
-											$options['manual_ua_code'] = $subprofile['ua_code'];
527
-											break 3;
528
-										}
529
-									}
530
-								}
531
-							}
532
-						}
533
-						delete_option( 'yoast-ga-access_token' );
534
-						delete_option( 'yoast-ga-refresh_token' );
535
-						delete_option( 'yst_ga_api' );
536
-					}
537
-				}
459
+                // We need a name and a profile
460
+                if ( ! empty( $refresh_token ) && ! empty( $options['analytics_profile'] ) && ! empty( $profiles['ga_api_response_accounts'] ) ) {
461
+                    // See if we have an access token
462
+                    if ( ! empty( $access_token['access_token'] ) ) {
463
+                        if ( monsterinsights_is_pro_version() ) {
464
+                            update_option( 'monsterinsights_pro_access_token', $access_token['access_token'] );
465
+                        } else {
466
+                            update_option( 'monsterinsights_lite_access_token', $access_token['access_token'] );
467
+                        }
468
+                    }
469
+
470
+                    // We need a refresh token
471
+                    if ( monsterinsights_is_pro_version() ) {
472
+                        update_option( 'monsterinsights_pro_refresh_token', $refresh_token );
473
+                    } else {
474
+                        update_option( 'monsterinsights_lite_refresh_token', $refresh_token );
475
+                    }
476
+
477
+                    // If we can find the profile in the response save the name
478
+                    if ( ! empty( $profiles['ga_api_response_accounts'] ) && is_array( $profiles['ga_api_response_accounts'] ) ) {
479
+                        foreach ( $profiles['ga_api_response_accounts'] as $account ) {
480
+                            foreach ( $account['items'] as $profile ) {
481
+                                foreach ( $profile['items'] as $subprofile ) {
482
+                                    if ( isset( $subprofile['id'] ) && $subprofile['id'] == $profile_name ) {
483
+                                        $options['analytics_profile_name'] = $subprofile['name'];
484
+                                        if ( empty( $options['analytics_profile_code'] ) ) {
485
+                                            $options['analytics_profile_code'] = $subprofile['ua_code'];
486
+                                        }
487
+                                        break 3;
488
+                                    }
489
+                                }
490
+                            }
491
+                        }
492
+                    }
493
+                    $options['cron_last_run'] = strtotime("-25 hours");
494
+                } else {
495
+                    // if UA in manual code field, remove analytics profile fields if set
496
+                    if ( ! empty( $options['manual_ua_code_field' ] ) ) {
497
+                        if ( isset( $options['analytics_profile_code'] ) ) {
498
+                            unset( $options['analytics_profile_code'] );
499
+                        }
500
+                        if ( isset( $options['analytics_profile'] ) ) {
501
+                            unset( $options['analytics_profile'] );
502
+                        }
503
+                        $options['manual_ua_code'] = $options['manual_ua_code_field'];
504
+                        delete_option( 'yoast-ga-access_token' );
505
+                        delete_option( 'yoast-ga-refresh_token' );
506
+                        delete_option( 'yst_ga_api' );
507
+                    } else if ( ! empty( $options['analytics_profile_code' ] ) ) {
508
+                    // if UA in profile fields, remove others and use that
509
+                        $options['manual_ua_code'] = $options['analytics_profile_code'];
510
+                        if ( isset( $options['analytics_profile_code'] ) ) {
511
+                            unset( $options['analytics_profile_code'] );
512
+                        }
513
+                        if ( isset( $options['analytics_profile'] ) ) {
514
+                            unset( $options['analytics_profile'] );
515
+                        }
516
+                        delete_option( 'yoast-ga-access_token' );
517
+                        delete_option( 'yoast-ga-refresh_token' );
518
+                        delete_option( 'yst_ga_api' );
519
+                    }  else {
520
+                    // if UA in profile profiles, remove others and use that
521
+                        if ( ! empty( $options['analytics_profile' ] ) && ! empty( $profiles['ga_api_response_accounts'] ) && is_array( $profiles['ga_api_response_accounts'] ) ) {
522
+                            foreach ( $profiles as $account ) {
523
+                                foreach ( $account['items'] as $profile ) {
524
+                                    foreach ( $profile['items'] as $subprofile ) {
525
+                                        if ( isset( $subprofile['id'] ) && $subprofile['id'] == $options['analytics_profile' ] ) {
526
+                                            $options['manual_ua_code'] = $subprofile['ua_code'];
527
+                                            break 3;
528
+                                        }
529
+                                    }
530
+                                }
531
+                            }
532
+                        }
533
+                        delete_option( 'yoast-ga-access_token' );
534
+                        delete_option( 'yoast-ga-refresh_token' );
535
+                        delete_option( 'yst_ga_api' );
536
+                    }
537
+                }
538 538
 			
539
-			if ( isset( $options['manual_ua_code_field'] ) ) {
540
-				unset( $options['manual_ua_code_field'] );
541
-			}
539
+            if ( isset( $options['manual_ua_code_field'] ) ) {
540
+                unset( $options['manual_ua_code_field'] );
541
+            }
542 542
 
543
-		// oAuth Stir Data Tank
544
-			// Will happen automatically as cron_last_run set to 25 hours ago
543
+        // oAuth Stir Data Tank
544
+            // Will happen automatically as cron_last_run set to 25 hours ago
545 545
 
546
-		// Add oAuth version 
547
-				$options['oauth_version'] = '1.0.0';
546
+        // Add oAuth version 
547
+                $options['oauth_version'] = '1.0.0';
548 548
 
549
-		$data = array(
550
-			'installed_version' => MONSTERINSIGHTS_VERSION,
551
-			'installed_date'    => time(),
552
-			'installed_pro'     => monsterinsights_is_pro_version(),
553
-		);
549
+        $data = array(
550
+            'installed_version' => MONSTERINSIGHTS_VERSION,
551
+            'installed_date'    => time(),
552
+            'installed_pro'     => monsterinsights_is_pro_version(),
553
+        );
554 554
 
555
-		update_option( 'monsterinsights_over_time', $data );
555
+        update_option( 'monsterinsights_over_time', $data );
556 556
 		
557
-		// Add the cron job
558
-		if ( ! wp_next_scheduled( 'monsterinsights_daily_cron' ) ) {
559
-			// Set the next event of fetching data
560
-			wp_schedule_event( strtotime( date( 'Y-m-d', strtotime( 'tomorrow' ) ) . ' 00:05:00 ' ), 'daily', 'monsterinsights_daily_cron' );
561
-		}
557
+        // Add the cron job
558
+        if ( ! wp_next_scheduled( 'monsterinsights_daily_cron' ) ) {
559
+            // Set the next event of fetching data
560
+            wp_schedule_event( strtotime( date( 'Y-m-d', strtotime( 'tomorrow' ) ) . ' 00:05:00 ' ), 'daily', 'monsterinsights_daily_cron' );
561
+        }
562 562
 		
563
-		// Finish up
564
-			// Save the new settings
565
-			$this->new_settings = $options;
566
-	}
567
-
568
-	public function get_yoast_default_values() {
569
-		$options = array(
570
-			'ga_general' => array(
571
-				'analytics_profile'          => null,
572
-				'analytics_profile_code'     => null,
573
-				'manual_ua_code'             => 0,
574
-				'manual_ua_code_field'       => null,
575
-				'track_internal_as_outbound' => null,
576
-				'track_internal_as_label'    => null,
577
-				'track_outbound'             => 0,
578
-				'anonymous_data'             => 0,
579
-				'enable_universal'           => 1,
580
-				'demographics'               => 0,
581
-				'ignore_users'               => array( 'administrator', 'editor' ),
582
-				'dashboards_disabled'        => 0,
583
-				'anonymize_ips'              => 0,
584
-				'track_download_as'          => 'event',
585
-				'extensions_of_files'        => 'doc,exe,js,pdf,ppt,tgz,zip,xls',
586
-				'track_full_url'             => 'domain',
587
-				'subdomain_tracking'         => null,
588
-				'tag_links_in_rss'           => 0,
589
-				'allow_anchor'               => 0,
590
-				'add_allow_linker'           => 0,
591
-				'enhanced_link_attribution'  => 0,
592
-				'custom_code'                => null,
593
-				'debug_mode'                 => 0,
594
-			)
595
-		);
596
-		$options = apply_filters( 'yst_ga_default-ga-values', $options, 'ga_general' );
597
-		return $options;
598
-	}
599
-
600
-	public function get_monsterinsights_default_values() {
601
-		return array(
602
-			'analytics_profile'          => '',
603
-			'analytics_profile_code'     => '',
604
-			'manual_ua_code'             => '',
605
-			'track_internal_as_outbound' => 0,
606
-			'track_internal_as_label'    => '',
607
-			'track_outbound'             => 1,
608
-			'allow_tracking'             => 0,
609
-			'tracking_mode'              => 'analytics',
610
-			'events_mode'                => 'js',
611
-			'demographics'               => 1,
612
-			'ignore_users'               => array( 'administrator', 'editor' ),
613
-			'dashboards_disabled'        => 0,
614
-			'anonymize_ips'              => 0,
615
-			'track_download_as'          => 'event',
616
-			'extensions_of_files'        => 'doc,exe,js,pdf,ppt,tgz,zip,xls',
617
-			'subdomain_tracking'         => '',
618
-			'tag_links_in_rss'           => 0,
619
-			'allow_anchor'               => 0,
620
-			'add_allow_linker'           => 0,
621
-			'enhanced_link_attribution'  => 1,
622
-			'custom_code'                => '',
623
-			'debug_mode'                 => 0,
624
-			'anonymous_data'             => 0,
625
-			'save_settings'              => array(),
626
-			'view_reports'               => array(),
627
-		);
628
-	}
629
-
630
-	/**
631
-	 * MonsterInsights Version 6.0.2 upgrades.
632
-	 *
633
-	 * This detects if a manual auth code is in the Yoast settings, and not
634
-	 * in the MI settings, and that oAuth hasn't been performed (caused by the
635
-	 * manual ua code not being transferred during the 6.0 upgrade routine)
636
-	 * and automatically fixes it.
637
-	 *
638
-	 * @since 6.0.2
639
-	 * @access public
640
-	 * 
641
-	 * @return void
642
-	 */
643
-	public function v602_upgrades() {
644
-		$options = get_option( 'yst_ga', array() );
645
-		if ( ( empty( $this->new_settings[ 'manual_ua_code'] ) || $this->new_settings[ 'manual_ua_code']  === '1' )  &&  
646
-			 empty( $this->new_settings[ 'analytics_profile_code'] ) &&
647
-			 ! empty( $options ) &&
648
-			 is_array( $options ) &&
649
-			 ! empty( $options['ga_general']['manual_ua_code_field'] )
650
-		) {
651
-			$this->new_settings['manual_ua_code'] = $options['ga_general']['manual_ua_code_field'];
652
-		}
653
-	}
654
-
655
-	/**
656
-	 * MonsterInsights Version 6.0.11 upgrades.
657
-	 *
658
-	 * This upgrade routine finds and removes the old crons if they exist.
659
-	 *
660
-	 * @since 6.0.11
661
-	 * @access public
662
-	 * 
663
-	 * @return void
664
-	 */
665
-	public function v6011_upgrades() {
666
-		// If old tracking checkin exists, remove it
667
-		if ( wp_next_scheduled( 'monsterinsights_send_tracking_checkin' ) ) {
668
-			wp_clear_scheduled_hook( 'monsterinsights_send_tracking_checkin' );
669
-		}
670
-
671
-		// Remove Weekly cron
672
-		if ( wp_next_scheduled( 'monsterinsights_weekly_cron' ) ) {
673
-			wp_clear_scheduled_hook( 'monsterinsights_weekly_cron' );
674
-		}
675
-
676
-		// Remove Yoast cron
677
-		if ( wp_next_scheduled( 'yst_ga_aggregate_data' ) ) {
678
-			wp_clear_scheduled_hook( 'yst_ga_aggregate_data' );
679
-		}
680
-	}
681
-
682
-	/**
683
-	 * MonsterInsights Version 6.2.0 upgrades.
684
-	 *
685
-	 * Turns off debug mode if its on.
686
-	 *
687
-	 * @since 6.2.0
688
-	 * @access public
689
-	 * 
690
-	 * @return void
691
-	 */
692
-	public function v620_upgrades() {
693
-		// Turns off debug mode if its on.
694
-		if ( empty( $this->new_settings['debug_mode' ] ) ) {
695
-			$this->new_settings['debug_mode' ] = 0;
696
-		}
697
-	}
698
-
699
-	/**
700
-	 * MonsterInsights Version 6.3 upgrades.
701
-	 *
702
-	 * This function does the
703
-	 * upgrade routine from MonsterInsights 6.2->6.3.
704
-	 *
705
-	 * @since 6.3.0
706
-	 * @access public
707
-	 * 
708
-	 * @return void
709
-	 */
710
-	public function v630_upgrades() {
711
-		// Not in use yet.
563
+        // Finish up
564
+            // Save the new settings
565
+            $this->new_settings = $options;
566
+    }
567
+
568
+    public function get_yoast_default_values() {
569
+        $options = array(
570
+            'ga_general' => array(
571
+                'analytics_profile'          => null,
572
+                'analytics_profile_code'     => null,
573
+                'manual_ua_code'             => 0,
574
+                'manual_ua_code_field'       => null,
575
+                'track_internal_as_outbound' => null,
576
+                'track_internal_as_label'    => null,
577
+                'track_outbound'             => 0,
578
+                'anonymous_data'             => 0,
579
+                'enable_universal'           => 1,
580
+                'demographics'               => 0,
581
+                'ignore_users'               => array( 'administrator', 'editor' ),
582
+                'dashboards_disabled'        => 0,
583
+                'anonymize_ips'              => 0,
584
+                'track_download_as'          => 'event',
585
+                'extensions_of_files'        => 'doc,exe,js,pdf,ppt,tgz,zip,xls',
586
+                'track_full_url'             => 'domain',
587
+                'subdomain_tracking'         => null,
588
+                'tag_links_in_rss'           => 0,
589
+                'allow_anchor'               => 0,
590
+                'add_allow_linker'           => 0,
591
+                'enhanced_link_attribution'  => 0,
592
+                'custom_code'                => null,
593
+                'debug_mode'                 => 0,
594
+            )
595
+        );
596
+        $options = apply_filters( 'yst_ga_default-ga-values', $options, 'ga_general' );
597
+        return $options;
598
+    }
599
+
600
+    public function get_monsterinsights_default_values() {
601
+        return array(
602
+            'analytics_profile'          => '',
603
+            'analytics_profile_code'     => '',
604
+            'manual_ua_code'             => '',
605
+            'track_internal_as_outbound' => 0,
606
+            'track_internal_as_label'    => '',
607
+            'track_outbound'             => 1,
608
+            'allow_tracking'             => 0,
609
+            'tracking_mode'              => 'analytics',
610
+            'events_mode'                => 'js',
611
+            'demographics'               => 1,
612
+            'ignore_users'               => array( 'administrator', 'editor' ),
613
+            'dashboards_disabled'        => 0,
614
+            'anonymize_ips'              => 0,
615
+            'track_download_as'          => 'event',
616
+            'extensions_of_files'        => 'doc,exe,js,pdf,ppt,tgz,zip,xls',
617
+            'subdomain_tracking'         => '',
618
+            'tag_links_in_rss'           => 0,
619
+            'allow_anchor'               => 0,
620
+            'add_allow_linker'           => 0,
621
+            'enhanced_link_attribution'  => 1,
622
+            'custom_code'                => '',
623
+            'debug_mode'                 => 0,
624
+            'anonymous_data'             => 0,
625
+            'save_settings'              => array(),
626
+            'view_reports'               => array(),
627
+        );
628
+    }
629
+
630
+    /**
631
+     * MonsterInsights Version 6.0.2 upgrades.
632
+     *
633
+     * This detects if a manual auth code is in the Yoast settings, and not
634
+     * in the MI settings, and that oAuth hasn't been performed (caused by the
635
+     * manual ua code not being transferred during the 6.0 upgrade routine)
636
+     * and automatically fixes it.
637
+     *
638
+     * @since 6.0.2
639
+     * @access public
640
+     * 
641
+     * @return void
642
+     */
643
+    public function v602_upgrades() {
644
+        $options = get_option( 'yst_ga', array() );
645
+        if ( ( empty( $this->new_settings[ 'manual_ua_code'] ) || $this->new_settings[ 'manual_ua_code']  === '1' )  &&  
646
+             empty( $this->new_settings[ 'analytics_profile_code'] ) &&
647
+             ! empty( $options ) &&
648
+             is_array( $options ) &&
649
+             ! empty( $options['ga_general']['manual_ua_code_field'] )
650
+        ) {
651
+            $this->new_settings['manual_ua_code'] = $options['ga_general']['manual_ua_code_field'];
652
+        }
653
+    }
654
+
655
+    /**
656
+     * MonsterInsights Version 6.0.11 upgrades.
657
+     *
658
+     * This upgrade routine finds and removes the old crons if they exist.
659
+     *
660
+     * @since 6.0.11
661
+     * @access public
662
+     * 
663
+     * @return void
664
+     */
665
+    public function v6011_upgrades() {
666
+        // If old tracking checkin exists, remove it
667
+        if ( wp_next_scheduled( 'monsterinsights_send_tracking_checkin' ) ) {
668
+            wp_clear_scheduled_hook( 'monsterinsights_send_tracking_checkin' );
669
+        }
670
+
671
+        // Remove Weekly cron
672
+        if ( wp_next_scheduled( 'monsterinsights_weekly_cron' ) ) {
673
+            wp_clear_scheduled_hook( 'monsterinsights_weekly_cron' );
674
+        }
675
+
676
+        // Remove Yoast cron
677
+        if ( wp_next_scheduled( 'yst_ga_aggregate_data' ) ) {
678
+            wp_clear_scheduled_hook( 'yst_ga_aggregate_data' );
679
+        }
680
+    }
681
+
682
+    /**
683
+     * MonsterInsights Version 6.2.0 upgrades.
684
+     *
685
+     * Turns off debug mode if its on.
686
+     *
687
+     * @since 6.2.0
688
+     * @access public
689
+     * 
690
+     * @return void
691
+     */
692
+    public function v620_upgrades() {
693
+        // Turns off debug mode if its on.
694
+        if ( empty( $this->new_settings['debug_mode' ] ) ) {
695
+            $this->new_settings['debug_mode' ] = 0;
696
+        }
697
+    }
698
+
699
+    /**
700
+     * MonsterInsights Version 6.3 upgrades.
701
+     *
702
+     * This function does the
703
+     * upgrade routine from MonsterInsights 6.2->6.3.
704
+     *
705
+     * @since 6.3.0
706
+     * @access public
707
+     * 
708
+     * @return void
709
+     */
710
+    public function v630_upgrades() {
711
+        // Not in use yet.
712 712
 		
713
-		/**
714
-		 * Running List of Things To Do In 6.1.0's Upgrade Routine
715
-		 *
716
-		 * 1. Drop Yoast yst_ga options if the upgraded from option === 6.0 or higher
717
-		 * 2. Remove yst_ga support from helper options
718
-		 * 3. Remove track_full_url
719
-		 */
720
-	}
713
+        /**
714
+         * Running List of Things To Do In 6.1.0's Upgrade Routine
715
+         *
716
+         * 1. Drop Yoast yst_ga options if the upgraded from option === 6.0 or higher
717
+         * 2. Remove yst_ga support from helper options
718
+         * 3. Remove track_full_url
719
+         */
720
+    }
721 721
 }
Please login to merge, or discard this patch.
includes/options.php 2 patches
Spacing   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -24,11 +24,11 @@  discard block
 block discarded – undo
24 24
 	//if ( $is_network && $use_network_settings ) {
25 25
 	//    return $settings;
26 26
 	//} else if ( $is_network ) {
27
-		$settings = get_option( $option_name );
27
+		$settings = get_option($option_name);
28 28
 	//} else {
29 29
 	//    return $settings;
30 30
 	//}
31
-	if ( empty( $settings ) || ! is_array( $settings ) ) {
31
+	if (empty($settings) || ! is_array($settings)) {
32 32
 		$settings = array();
33 33
 	}
34 34
 	return $settings;
@@ -45,11 +45,11 @@  discard block
 block discarded – undo
45 45
  * @param mixed $default   The default value of the setting key to retrieve.
46 46
  * @return string       The value of the setting.
47 47
  */
48
-function monsterinsights_get_option( $key = '', $default = false ) {
48
+function monsterinsights_get_option($key = '', $default = false) {
49 49
 	global $monsterinsights_settings;
50
-	$value = ! empty( $monsterinsights_settings[ $key ] ) ? $monsterinsights_settings[ $key ] : $default;
51
-	$value = apply_filters( 'monsterinsights_get_option', $value, $key, $default );
52
-	return apply_filters( 'monsterinsights_get_option_' . $key, $value, $key, $default );
50
+	$value = ! empty($monsterinsights_settings[$key]) ? $monsterinsights_settings[$key] : $default;
51
+	$value = apply_filters('monsterinsights_get_option', $value, $key, $default);
52
+	return apply_filters('monsterinsights_get_option_' . $key, $value, $key, $default);
53 53
 }
54 54
 
55 55
 /**
@@ -62,38 +62,38 @@  discard block
 block discarded – undo
62 62
  */
63 63
 function monsterinsights_get_ua() {
64 64
 	$ua = '';
65
-	if ( is_multisite() ) {
66
-		if ( defined( 'MONSTERINSIGHTS_MS_GA_UA' ) && monsterinsights_is_valid_ua( MONSTERINSIGHTS_MS_GA_UA ) ) {
65
+	if (is_multisite()) {
66
+		if (defined('MONSTERINSIGHTS_MS_GA_UA') && monsterinsights_is_valid_ua(MONSTERINSIGHTS_MS_GA_UA)) {
67 67
 			$ua = MONSTERINSIGHTS_MS_GA_UA;
68 68
 		}
69 69
 	}
70 70
 
71
-	if ( is_multisite() ) {
72
-		$ua_code = monsterinsights_is_valid_ua( get_site_option( 'monsterinsights_network_manual_ua_code', '' ) );
73
-		if ( $ua_code ) {
71
+	if (is_multisite()) {
72
+		$ua_code = monsterinsights_is_valid_ua(get_site_option('monsterinsights_network_manual_ua_code', ''));
73
+		if ($ua_code) {
74 74
 			$ua = $ua_code;
75 75
 		}
76 76
 	}
77 77
 
78
-	if ( defined( 'MONSTERINSIGHTS_GA_UA' ) && monsterinsights_is_valid_ua( MONSTERINSIGHTS_GA_UA ) ) {
78
+	if (defined('MONSTERINSIGHTS_GA_UA') && monsterinsights_is_valid_ua(MONSTERINSIGHTS_GA_UA)) {
79 79
 		$ua = MONSTERINSIGHTS_GA_UA;
80 80
 	}
81 81
 
82
-	$ua_code = monsterinsights_is_valid_ua( monsterinsights_get_option( 'analytics_profile_code', '' ) );
82
+	$ua_code = monsterinsights_is_valid_ua(monsterinsights_get_option('analytics_profile_code', ''));
83 83
 
84
-	if ( $ua_code ) {
84
+	if ($ua_code) {
85 85
 		$ua = $ua_code;
86 86
 	}
87 87
 
88
-	$manual_ua_code = monsterinsights_is_valid_ua( monsterinsights_get_option( 'manual_ua_code', '' ) );
88
+	$manual_ua_code = monsterinsights_is_valid_ua(monsterinsights_get_option('manual_ua_code', ''));
89 89
 
90
-	if ( $manual_ua_code ) {
90
+	if ($manual_ua_code) {
91 91
 		$ua = $manual_ua_code;
92 92
 	}
93 93
 
94
-	$ua = apply_filters( 'monsterinsights_get_ua', $ua );
94
+	$ua = apply_filters('monsterinsights_get_ua', $ua);
95 95
 
96
-	return monsterinsights_is_valid_ua( $ua );
96
+	return monsterinsights_is_valid_ua($ua);
97 97
 }
98 98
 
99 99
 /**
@@ -105,10 +105,10 @@  discard block
 block discarded – undo
105 105
  * @param array $args Allow calling functions to give args to use in future applications.
106 106
  * @return string The UA to use on frontend.
107 107
  */
108
-function monsterinsights_get_ua_to_output( $args = array() ) {
108
+function monsterinsights_get_ua_to_output($args = array()) {
109 109
 	$ua = monsterinsights_get_ua();
110
-	$ua = apply_filters( 'monsterinsights_get_ua_to_output', $ua, $args );
111
-	return monsterinsights_is_valid_ua( $ua );
110
+	$ua = apply_filters('monsterinsights_get_ua_to_output', $ua, $args);
111
+	return monsterinsights_is_valid_ua($ua);
112 112
 }
113 113
 
114 114
 /**
@@ -121,15 +121,15 @@  discard block
 block discarded – undo
121 121
  * @param string $value The value to set for the key.
122 122
  * @return boolean True if updated, false if not.
123 123
  */
124
-function monsterinsights_update_option( $key = '', $value = false ) {
124
+function monsterinsights_update_option($key = '', $value = false) {
125 125
 
126 126
 	// If no key, exit
127
-	if ( empty( $key ) ){
127
+	if (empty($key)) {
128 128
 		return false;
129 129
 	}
130 130
 
131
-	if ( empty( $value ) ) {
132
-		$remove_option = monsterinsights_delete_option( $key );
131
+	if (empty($value)) {
132
+		$remove_option = monsterinsights_delete_option($key);
133 133
 		return $remove_option;
134 134
 	}
135 135
 
@@ -143,30 +143,30 @@  discard block
 block discarded – undo
143 143
 	//$is_network            = is_multisite();
144 144
 	//$update_network_option = true;
145 145
 	//if ( ! is_network_admin() && ! ( $is_network && $use_network_settings ) ) {
146
-	   $settings = get_option( $option_name );
146
+	   $settings = get_option($option_name);
147 147
 	//   $update_network_option = false;
148 148
 	//}
149 149
 
150
-	if ( ! is_array( $settings ) ) {
150
+	if ( ! is_array($settings)) {
151 151
 		$settings = array();
152 152
 	}
153 153
 
154 154
 	// Let's let devs alter that value coming in
155
-	$value = apply_filters( 'monsterinsights_update_option', $value, $key );
155
+	$value = apply_filters('monsterinsights_update_option', $value, $key);
156 156
 
157 157
 	// Next let's try to update the value
158
-	$settings[ $key ] = $value;
158
+	$settings[$key] = $value;
159 159
 	$did_update = false;
160 160
 	//if ( $update_network_option ) {
161 161
 	//    $did_update = update_site_option( $option_name, $settings );
162 162
 	//} else {
163
-		$did_update = update_option( $option_name, $settings );
163
+		$did_update = update_option($option_name, $settings);
164 164
 	//}
165 165
 
166 166
 	// If it updated, let's update the global variable
167
-	if ( $did_update ){
167
+	if ($did_update) {
168 168
 		global $monsterinsights_settings;
169
-		$monsterinsights_settings[ $key ] = $value;
169
+		$monsterinsights_settings[$key] = $value;
170 170
 	}
171 171
 
172 172
 	return $did_update;
@@ -181,9 +181,9 @@  discard block
 block discarded – undo
181 181
  * @param string $key   The setting key.
182 182
  * @return boolean True if removed, false if not.
183 183
  */
184
-function monsterinsights_delete_option( $key = '' ) {
184
+function monsterinsights_delete_option($key = '') {
185 185
 	// If no key, exit
186
-	if ( empty( $key ) ){
186
+	if (empty($key)) {
187 187
 		return false;
188 188
 	}
189 189
 
@@ -197,24 +197,24 @@  discard block
 block discarded – undo
197 197
 	//$is_network            = is_multisite();
198 198
 	//$update_network_option = true;
199 199
 	//if ( ! is_network_admin() && ! ( $is_network && $use_network_settings ) ) {
200
-	   $settings = get_option( $option_name );
200
+	   $settings = get_option($option_name);
201 201
 	//   $update_network_option = false;
202 202
 	//}
203 203
 
204 204
 	// Next let's try to remove the key
205
-	if( isset( $settings[ $key ] ) ) {
206
-		unset( $settings[ $key ] );
205
+	if (isset($settings[$key])) {
206
+		unset($settings[$key]);
207 207
 	}
208 208
 
209 209
 	$did_update = false;
210 210
 	//if ( $update_network_option ) {
211 211
 	//    $did_update = update_site_option( 'monsterinsights_settings', $settings );
212 212
 	//} else {
213
-		$did_update = update_option( $option_name, $settings );
213
+		$did_update = update_option($option_name, $settings);
214 214
 	//}
215 215
 
216 216
 	// If it updated, let's update the global variable
217
-	if ( $did_update ){
217
+	if ($did_update) {
218 218
 		global $monsterinsights_settings;
219 219
 		$monsterinsights_settings = $settings;
220 220
 	}
@@ -231,9 +231,9 @@  discard block
 block discarded – undo
231 231
  * @param string $key   The setting key.
232 232
  * @return boolean True if removed, false if not.
233 233
  */
234
-function monsterinsights_delete_options( $keys = array() ) {
234
+function monsterinsights_delete_options($keys = array()) {
235 235
 	// If no keys, exit
236
-	if ( empty( $keys ) || ! is_array( $keys ) ){
236
+	if (empty($keys) || ! is_array($keys)) {
237 237
 		return false;
238 238
 	}
239 239
 
@@ -247,14 +247,14 @@  discard block
 block discarded – undo
247 247
 	//$is_network            = is_multisite();
248 248
 	//$update_network_option = true;
249 249
 	//if ( ! is_network_admin() && ! ( $is_network && $use_network_settings ) ) {
250
-	   $settings = get_option( $option_name );
250
+	   $settings = get_option($option_name);
251 251
 	//   $update_network_option = false;
252 252
 	//}
253 253
 
254 254
 	// Next let's try to remove the keys
255
-	foreach ( $keys as $key ) {
256
-		if( isset( $settings[ $key ] ) ) {
257
-			unset( $settings[ $key ] );
255
+	foreach ($keys as $key) {
256
+		if (isset($settings[$key])) {
257
+			unset($settings[$key]);
258 258
 		}
259 259
 	}
260 260
 
@@ -262,11 +262,11 @@  discard block
 block discarded – undo
262 262
 	//if ( $update_network_option ) {
263 263
 	//    $did_update = update_site_option( 'monsterinsights_settings', $settings );
264 264
 	//} else {
265
-		$did_update = update_option( $option_name, $settings );
265
+		$did_update = update_option($option_name, $settings);
266 266
 	//}
267 267
 
268 268
 	// If it updated, let's update the global variable
269
-	if ( $did_update ){
269
+	if ($did_update) {
270 270
 		global $monsterinsights_settings;
271 271
 		$monsterinsights_settings = $settings;
272 272
 	}
@@ -286,26 +286,26 @@  discard block
 block discarded – undo
286 286
  */
287 287
 function monsterinsights_get_license() {
288 288
 	$license = false;
289
-	if ( defined( 'MONSTERINSIGHTS_LICENSE_KEY' ) && is_string( MONSTERINSIGHTS_LICENSE_KEY ) && strlen( MONSTERINSIGHTS_LICENSE_KEY ) > 10 ) {
290
-		$license = array( 'key' => MONSTERINSIGHTS_LICENSE_KEY );
291
-	} else if ( is_multisite() && monsterinsights_is_network_active() ){
292
-		$network_license = get_site_option( 'monsterinsights_license' );
293
-		if ( ! empty( $network_license['key'] ) && is_string( $network_license['key'] ) && strlen( $network_license['key'] ) > 10 ) {
289
+	if (defined('MONSTERINSIGHTS_LICENSE_KEY') && is_string(MONSTERINSIGHTS_LICENSE_KEY) && strlen(MONSTERINSIGHTS_LICENSE_KEY) > 10) {
290
+		$license = array('key' => MONSTERINSIGHTS_LICENSE_KEY);
291
+	} else if (is_multisite() && monsterinsights_is_network_active()) {
292
+		$network_license = get_site_option('monsterinsights_license');
293
+		if ( ! empty($network_license['key']) && is_string($network_license['key']) && strlen($network_license['key']) > 10) {
294 294
 			$license = $network_license;
295 295
 		} else {
296
-			$site_license = get_option( 'monsterinsights_license' );
297
-			if ( ! empty( $site_license['key'] ) && is_string( $site_license['key'] ) && strlen( $site_license['key'] ) > 10 ) {
296
+			$site_license = get_option('monsterinsights_license');
297
+			if ( ! empty($site_license['key']) && is_string($site_license['key']) && strlen($site_license['key']) > 10) {
298 298
 				$license = $site_license;
299 299
 			}
300 300
 		}
301 301
 	} else {
302
-		$site_license = get_option( 'monsterinsights_license' );
303
-		if ( ! empty( $site_license['key'] ) && is_string( $site_license['key'] ) && strlen( $site_license['key'] ) > 10 ) {
302
+		$site_license = get_option('monsterinsights_license');
303
+		if ( ! empty($site_license['key']) && is_string($site_license['key']) && strlen($site_license['key']) > 10) {
304 304
 			$license = $site_license;
305 305
 		}
306 306
 	}
307 307
 
308
-	return apply_filters( 'monsterinsights_license', $license );
308
+	return apply_filters('monsterinsights_license', $license);
309 309
 }
310 310
 
311 311
 /**
@@ -320,18 +320,18 @@  discard block
 block discarded – undo
320 320
  */
321 321
 function monsterinsights_get_license_key() {
322 322
 	$license = false;
323
-	if ( defined( 'MONSTERINSIGHTS_LICENSE_KEY' ) && is_string( MONSTERINSIGHTS_LICENSE_KEY ) && strlen( MONSTERINSIGHTS_LICENSE_KEY ) > 10 ) {
323
+	if (defined('MONSTERINSIGHTS_LICENSE_KEY') && is_string(MONSTERINSIGHTS_LICENSE_KEY) && strlen(MONSTERINSIGHTS_LICENSE_KEY) > 10) {
324 324
 		$license = MONSTERINSIGHTS_LICENSE_KEY;
325 325
 	} else {
326 326
 		$license = monsterinsights_get_license();
327
-		if ( ! empty( $license['key'] ) && is_string( $license['key'] ) && strlen( $license['key'] ) > 10 ) {
327
+		if ( ! empty($license['key']) && is_string($license['key']) && strlen($license['key']) > 10) {
328 328
 			$license = $license['key'];
329 329
 		} else {
330 330
 			$license = false;
331 331
 		}
332 332
 	}
333 333
 
334
-	return apply_filters( 'monsterinsights_license_key', $license );
334
+	return apply_filters('monsterinsights_license_key', $license);
335 335
 }
336 336
 
337 337
 /**
@@ -344,16 +344,16 @@  discard block
 block discarded – undo
344 344
  * @param string $value The value to set for the key.
345 345
  * @return boolean True if updated, false if not.
346 346
  */
347
-function monsterinsights_update_license_key( $license_key = false, $network = false, $override = false ) {
348
-	if ( ! $license_key || ! is_string( $license_key ) || ! strlen( $license_key ) > 10  ) {
347
+function monsterinsights_update_license_key($license_key = false, $network = false, $override = false) {
348
+	if ( ! $license_key || ! is_string($license_key) || ! strlen($license_key) > 10) {
349 349
 		return false;
350 350
 	}
351 351
 
352
-	if ( $network && is_multisite() && ( is_network_admin() || $override ) ) {
353
-		update_site_option( 'monsterinsights_license', $license_key );
352
+	if ($network && is_multisite() && (is_network_admin() || $override)) {
353
+		update_site_option('monsterinsights_license', $license_key);
354 354
 		return true;
355 355
 	} else {
356
-		update_option( 'monsterinsights_license', $license_key );
356
+		update_option('monsterinsights_license', $license_key);
357 357
 		return true;
358 358
 	}
359 359
 }
@@ -367,12 +367,12 @@  discard block
 block discarded – undo
367 367
  * @param string $key   The setting key.
368 368
  * @return boolean True if removed, false if not.
369 369
  */
370
-function monsterinsights_delete_license_key( $network = false, $override = false ) {
371
-	if ( $network && is_multisite() && ( is_network_admin() || $override ) ) {
372
-		delete_site_option( 'monsterinsights_license' );
370
+function monsterinsights_delete_license_key($network = false, $override = false) {
371
+	if ($network && is_multisite() && (is_network_admin() || $override)) {
372
+		delete_site_option('monsterinsights_license');
373 373
 		return true;
374 374
 	} else {
375
-		delete_option( 'monsterinsights_license' );
375
+		delete_option('monsterinsights_license');
376 376
 		return true;
377 377
 	}
378 378
 }
@@ -389,8 +389,8 @@  discard block
 block discarded – undo
389 389
 function monsterinsights_get_license_key_type() {
390 390
 	$type = false;
391 391
 	$license = monsterinsights_get_license();
392
-	if ( ! empty( $license['type'] ) && is_string( $license['type'] ) ) {
393
-		if ( in_array( $license['type'], array( 'master', 'pro', 'plus', 'basic' ) ) ) {
392
+	if ( ! empty($license['type']) && is_string($license['type'])) {
393
+		if (in_array($license['type'], array('master', 'pro', 'plus', 'basic'))) {
394 394
 			$type = $license['type'];
395 395
 		}
396 396
 	}
@@ -408,10 +408,10 @@  discard block
 block discarded – undo
408 408
 function monsterinsights_get_license_key_errors() {
409 409
 	$errors = false;
410 410
 	$license = monsterinsights_get_license();
411
-	if ( ! empty( $license['type'] ) && is_string( $license['type'] ) && strlen( $license['type'] ) > 3 ) {
412
-		if ( ( isset( $license['is_expired'] )  && $license['is_expired'] ) 
413
-		  || ( isset( $license['is_disabled'] ) && $license['is_disabled'] )
414
-		  || ( isset( $license['is_invalid'] )  && $license['is_invalid'] ) ) {
411
+	if ( ! empty($license['type']) && is_string($license['type']) && strlen($license['type']) > 3) {
412
+		if ((isset($license['is_expired']) && $license['is_expired']) 
413
+		  || (isset($license['is_disabled']) && $license['is_disabled'])
414
+		  || (isset($license['is_invalid']) && $license['is_invalid'])) {
415 415
 			$errors = true;
416 416
 		}
417 417
 	}
@@ -428,18 +428,18 @@  discard block
 block discarded – undo
428 428
  *
429 429
  * @return string|false Return cleaned ua string if valid, else returns false.
430 430
  */
431
-function monsterinsights_is_valid_ua( $ua_code = '' ) {
431
+function monsterinsights_is_valid_ua($ua_code = '') {
432 432
 	$ua_code = (string) $ua_code; // Rare case, but let's make sure it never happens.
433
-	$ua_code = trim( $ua_code );
433
+	$ua_code = trim($ua_code);
434 434
 
435
-	if ( empty( $ua_code ) ) {
435
+	if (empty($ua_code)) {
436 436
 		return '';
437 437
 	}
438 438
 	
439 439
 	// Replace all type of dashes (n-dash, m-dash, minus) with normal dashes.
440
-	$ua_code = str_replace( array( '–', '—', '−' ), '-', $ua_code );
440
+	$ua_code = str_replace(array('–', '—', '−'), '-', $ua_code);
441 441
 	
442
-	if ( preg_match( "/^(UA|YT|MO)-\d{4,}-\d+$/", strval( $ua_code ) ) ) {
442
+	if (preg_match("/^(UA|YT|MO)-\d{4,}-\d+$/", strval($ua_code))) {
443 443
 		return $ua_code;
444 444
 	} else {
445 445
 		return '';
@@ -465,10 +465,10 @@  discard block
 block discarded – undo
465 465
 				'monsterinsights_oauth_status',
466 466
 	);
467 467
 
468
-	foreach ( $exclude as $e ) {
469
-		if ( ! empty( $settings[ $e ] ) ) {
470
-			unset( $settings[ $e ] );
468
+	foreach ($exclude as $e) {
469
+		if ( ! empty($settings[$e])) {
470
+			unset($settings[$e]);
471 471
 		}
472 472
 	}
473
-	return wp_json_encode( $settings );
473
+	return wp_json_encode($settings);
474 474
 }
475 475
\ No newline at end of file
Please login to merge, or discard this patch.
Indentation   +305 added lines, -305 removed lines patch added patch discarded remove patch
@@ -11,27 +11,27 @@  discard block
 block discarded – undo
11 11
 
12 12
 // Exit if accessed directly
13 13
 if ( ! defined( 'ABSPATH' ) ) {
14
-	exit;
14
+    exit;
15 15
 }
16 16
 
17 17
 function monsterinsights_get_options() {
18
-	$settings = array();
19
-	$option_name = monsterinsights_get_option_name();
20
-	//$settings             = get_site_option( $option_name );
21
-	//$use_network_settings = ! empty( $use_network_settings['use_network_settings'] ) ? true : false;
22
-	//$is_network           = is_multisite();
23
-
24
-	//if ( $is_network && $use_network_settings ) {
25
-	//    return $settings;
26
-	//} else if ( $is_network ) {
27
-		$settings = get_option( $option_name );
28
-	//} else {
29
-	//    return $settings;
30
-	//}
31
-	if ( empty( $settings ) || ! is_array( $settings ) ) {
32
-		$settings = array();
33
-	}
34
-	return $settings;
18
+    $settings = array();
19
+    $option_name = monsterinsights_get_option_name();
20
+    //$settings             = get_site_option( $option_name );
21
+    //$use_network_settings = ! empty( $use_network_settings['use_network_settings'] ) ? true : false;
22
+    //$is_network           = is_multisite();
23
+
24
+    //if ( $is_network && $use_network_settings ) {
25
+    //    return $settings;
26
+    //} else if ( $is_network ) {
27
+        $settings = get_option( $option_name );
28
+    //} else {
29
+    //    return $settings;
30
+    //}
31
+    if ( empty( $settings ) || ! is_array( $settings ) ) {
32
+        $settings = array();
33
+    }
34
+    return $settings;
35 35
 }
36 36
 
37 37
 /**
@@ -46,10 +46,10 @@  discard block
 block discarded – undo
46 46
  * @return string       The value of the setting.
47 47
  */
48 48
 function monsterinsights_get_option( $key = '', $default = false ) {
49
-	global $monsterinsights_settings;
50
-	$value = ! empty( $monsterinsights_settings[ $key ] ) ? $monsterinsights_settings[ $key ] : $default;
51
-	$value = apply_filters( 'monsterinsights_get_option', $value, $key, $default );
52
-	return apply_filters( 'monsterinsights_get_option_' . $key, $value, $key, $default );
49
+    global $monsterinsights_settings;
50
+    $value = ! empty( $monsterinsights_settings[ $key ] ) ? $monsterinsights_settings[ $key ] : $default;
51
+    $value = apply_filters( 'monsterinsights_get_option', $value, $key, $default );
52
+    return apply_filters( 'monsterinsights_get_option_' . $key, $value, $key, $default );
53 53
 }
54 54
 
55 55
 /**
@@ -61,39 +61,39 @@  discard block
 block discarded – undo
61 61
  * @return string The UA to use.
62 62
  */
63 63
 function monsterinsights_get_ua() {
64
-	$ua = '';
65
-	if ( is_multisite() ) {
66
-		if ( defined( 'MONSTERINSIGHTS_MS_GA_UA' ) && monsterinsights_is_valid_ua( MONSTERINSIGHTS_MS_GA_UA ) ) {
67
-			$ua = MONSTERINSIGHTS_MS_GA_UA;
68
-		}
69
-	}
64
+    $ua = '';
65
+    if ( is_multisite() ) {
66
+        if ( defined( 'MONSTERINSIGHTS_MS_GA_UA' ) && monsterinsights_is_valid_ua( MONSTERINSIGHTS_MS_GA_UA ) ) {
67
+            $ua = MONSTERINSIGHTS_MS_GA_UA;
68
+        }
69
+    }
70 70
 
71
-	if ( is_multisite() ) {
72
-		$ua_code = monsterinsights_is_valid_ua( get_site_option( 'monsterinsights_network_manual_ua_code', '' ) );
73
-		if ( $ua_code ) {
74
-			$ua = $ua_code;
75
-		}
76
-	}
71
+    if ( is_multisite() ) {
72
+        $ua_code = monsterinsights_is_valid_ua( get_site_option( 'monsterinsights_network_manual_ua_code', '' ) );
73
+        if ( $ua_code ) {
74
+            $ua = $ua_code;
75
+        }
76
+    }
77 77
 
78
-	if ( defined( 'MONSTERINSIGHTS_GA_UA' ) && monsterinsights_is_valid_ua( MONSTERINSIGHTS_GA_UA ) ) {
79
-		$ua = MONSTERINSIGHTS_GA_UA;
80
-	}
78
+    if ( defined( 'MONSTERINSIGHTS_GA_UA' ) && monsterinsights_is_valid_ua( MONSTERINSIGHTS_GA_UA ) ) {
79
+        $ua = MONSTERINSIGHTS_GA_UA;
80
+    }
81 81
 
82
-	$ua_code = monsterinsights_is_valid_ua( monsterinsights_get_option( 'analytics_profile_code', '' ) );
82
+    $ua_code = monsterinsights_is_valid_ua( monsterinsights_get_option( 'analytics_profile_code', '' ) );
83 83
 
84
-	if ( $ua_code ) {
85
-		$ua = $ua_code;
86
-	}
84
+    if ( $ua_code ) {
85
+        $ua = $ua_code;
86
+    }
87 87
 
88
-	$manual_ua_code = monsterinsights_is_valid_ua( monsterinsights_get_option( 'manual_ua_code', '' ) );
88
+    $manual_ua_code = monsterinsights_is_valid_ua( monsterinsights_get_option( 'manual_ua_code', '' ) );
89 89
 
90
-	if ( $manual_ua_code ) {
91
-		$ua = $manual_ua_code;
92
-	}
90
+    if ( $manual_ua_code ) {
91
+        $ua = $manual_ua_code;
92
+    }
93 93
 
94
-	$ua = apply_filters( 'monsterinsights_get_ua', $ua );
94
+    $ua = apply_filters( 'monsterinsights_get_ua', $ua );
95 95
 
96
-	return monsterinsights_is_valid_ua( $ua );
96
+    return monsterinsights_is_valid_ua( $ua );
97 97
 }
98 98
 
99 99
 /**
@@ -106,9 +106,9 @@  discard block
 block discarded – undo
106 106
  * @return string The UA to use on frontend.
107 107
  */
108 108
 function monsterinsights_get_ua_to_output( $args = array() ) {
109
-	$ua = monsterinsights_get_ua();
110
-	$ua = apply_filters( 'monsterinsights_get_ua_to_output', $ua, $args );
111
-	return monsterinsights_is_valid_ua( $ua );
109
+    $ua = monsterinsights_get_ua();
110
+    $ua = apply_filters( 'monsterinsights_get_ua_to_output', $ua, $args );
111
+    return monsterinsights_is_valid_ua( $ua );
112 112
 }
113 113
 
114 114
 /**
@@ -123,155 +123,155 @@  discard block
 block discarded – undo
123 123
  */
124 124
 function monsterinsights_update_option( $key = '', $value = false ) {
125 125
 
126
-	// If no key, exit
127
-	if ( empty( $key ) ){
128
-		return false;
129
-	}
130
-
131
-	if ( empty( $value ) ) {
132
-		$remove_option = monsterinsights_delete_option( $key );
133
-		return $remove_option;
134
-	}
135
-
136
-	$option_name = monsterinsights_get_option_name();
137
-
138
-	// First let's grab the current settings
139
-
140
-	// if on network panel or if on single site using network settings
141
-	//$settings              = get_site_option( $option_name );
142
-	//$use_network_settings  = ! empty( $use_network_settings['use_network_settings'] ) ? true : false;
143
-	//$is_network            = is_multisite();
144
-	//$update_network_option = true;
145
-	//if ( ! is_network_admin() && ! ( $is_network && $use_network_settings ) ) {
146
-	   $settings = get_option( $option_name );
147
-	//   $update_network_option = false;
148
-	//}
149
-
150
-	if ( ! is_array( $settings ) ) {
151
-		$settings = array();
152
-	}
153
-
154
-	// Let's let devs alter that value coming in
155
-	$value = apply_filters( 'monsterinsights_update_option', $value, $key );
156
-
157
-	// Next let's try to update the value
158
-	$settings[ $key ] = $value;
159
-	$did_update = false;
160
-	//if ( $update_network_option ) {
161
-	//    $did_update = update_site_option( $option_name, $settings );
162
-	//} else {
163
-		$did_update = update_option( $option_name, $settings );
164
-	//}
165
-
166
-	// If it updated, let's update the global variable
167
-	if ( $did_update ){
168
-		global $monsterinsights_settings;
169
-		$monsterinsights_settings[ $key ] = $value;
170
-	}
171
-
172
-	return $did_update;
126
+    // If no key, exit
127
+    if ( empty( $key ) ){
128
+        return false;
129
+    }
130
+
131
+    if ( empty( $value ) ) {
132
+        $remove_option = monsterinsights_delete_option( $key );
133
+        return $remove_option;
134
+    }
135
+
136
+    $option_name = monsterinsights_get_option_name();
137
+
138
+    // First let's grab the current settings
139
+
140
+    // if on network panel or if on single site using network settings
141
+    //$settings              = get_site_option( $option_name );
142
+    //$use_network_settings  = ! empty( $use_network_settings['use_network_settings'] ) ? true : false;
143
+    //$is_network            = is_multisite();
144
+    //$update_network_option = true;
145
+    //if ( ! is_network_admin() && ! ( $is_network && $use_network_settings ) ) {
146
+        $settings = get_option( $option_name );
147
+    //   $update_network_option = false;
148
+    //}
149
+
150
+    if ( ! is_array( $settings ) ) {
151
+        $settings = array();
152
+    }
153
+
154
+    // Let's let devs alter that value coming in
155
+    $value = apply_filters( 'monsterinsights_update_option', $value, $key );
156
+
157
+    // Next let's try to update the value
158
+    $settings[ $key ] = $value;
159
+    $did_update = false;
160
+    //if ( $update_network_option ) {
161
+    //    $did_update = update_site_option( $option_name, $settings );
162
+    //} else {
163
+        $did_update = update_option( $option_name, $settings );
164
+    //}
165
+
166
+    // If it updated, let's update the global variable
167
+    if ( $did_update ){
168
+        global $monsterinsights_settings;
169
+        $monsterinsights_settings[ $key ] = $value;
170
+    }
171
+
172
+    return $did_update;
173 173
 }
174 174
 
175
- /**
176
- * Helper method for deleting a setting's value.
177
- *
178
- * @since 6.0.0
179
- * @access public
180
- *
181
- * @param string $key   The setting key.
182
- * @return boolean True if removed, false if not.
183
- */
175
+    /**
176
+     * Helper method for deleting a setting's value.
177
+     *
178
+     * @since 6.0.0
179
+     * @access public
180
+     *
181
+     * @param string $key   The setting key.
182
+     * @return boolean True if removed, false if not.
183
+     */
184 184
 function monsterinsights_delete_option( $key = '' ) {
185
-	// If no key, exit
186
-	if ( empty( $key ) ){
187
-		return false;
188
-	}
189
-
190
-	$option_name = monsterinsights_get_option_name();
191
-
192
-	// First let's grab the current settings
193
-
194
-	// if on network panel or if on single site using network settings
195
-	//$settings              = get_site_option( $option_name );
196
-	//$use_network_settings  = ! empty( $use_network_settings['use_network_settings'] ) ? true : false;
197
-	//$is_network            = is_multisite();
198
-	//$update_network_option = true;
199
-	//if ( ! is_network_admin() && ! ( $is_network && $use_network_settings ) ) {
200
-	   $settings = get_option( $option_name );
201
-	//   $update_network_option = false;
202
-	//}
203
-
204
-	// Next let's try to remove the key
205
-	if( isset( $settings[ $key ] ) ) {
206
-		unset( $settings[ $key ] );
207
-	}
208
-
209
-	$did_update = false;
210
-	//if ( $update_network_option ) {
211
-	//    $did_update = update_site_option( 'monsterinsights_settings', $settings );
212
-	//} else {
213
-		$did_update = update_option( $option_name, $settings );
214
-	//}
215
-
216
-	// If it updated, let's update the global variable
217
-	if ( $did_update ){
218
-		global $monsterinsights_settings;
219
-		$monsterinsights_settings = $settings;
220
-	}
221
-
222
-	return $did_update;
185
+    // If no key, exit
186
+    if ( empty( $key ) ){
187
+        return false;
188
+    }
189
+
190
+    $option_name = monsterinsights_get_option_name();
191
+
192
+    // First let's grab the current settings
193
+
194
+    // if on network panel or if on single site using network settings
195
+    //$settings              = get_site_option( $option_name );
196
+    //$use_network_settings  = ! empty( $use_network_settings['use_network_settings'] ) ? true : false;
197
+    //$is_network            = is_multisite();
198
+    //$update_network_option = true;
199
+    //if ( ! is_network_admin() && ! ( $is_network && $use_network_settings ) ) {
200
+        $settings = get_option( $option_name );
201
+    //   $update_network_option = false;
202
+    //}
203
+
204
+    // Next let's try to remove the key
205
+    if( isset( $settings[ $key ] ) ) {
206
+        unset( $settings[ $key ] );
207
+    }
208
+
209
+    $did_update = false;
210
+    //if ( $update_network_option ) {
211
+    //    $did_update = update_site_option( 'monsterinsights_settings', $settings );
212
+    //} else {
213
+        $did_update = update_option( $option_name, $settings );
214
+    //}
215
+
216
+    // If it updated, let's update the global variable
217
+    if ( $did_update ){
218
+        global $monsterinsights_settings;
219
+        $monsterinsights_settings = $settings;
220
+    }
221
+
222
+    return $did_update;
223 223
 }
224 224
 
225
- /**
226
- * Helper method for deleting multiple settings value.
227
- *
228
- * @since 6.0.0
229
- * @access public
230
- *
231
- * @param string $key   The setting key.
232
- * @return boolean True if removed, false if not.
233
- */
225
+    /**
226
+     * Helper method for deleting multiple settings value.
227
+     *
228
+     * @since 6.0.0
229
+     * @access public
230
+     *
231
+     * @param string $key   The setting key.
232
+     * @return boolean True if removed, false if not.
233
+     */
234 234
 function monsterinsights_delete_options( $keys = array() ) {
235
-	// If no keys, exit
236
-	if ( empty( $keys ) || ! is_array( $keys ) ){
237
-		return false;
238
-	}
239
-
240
-	$option_name = monsterinsights_get_option_name();
241
-
242
-	// First let's grab the current settings
243
-
244
-	// if on network panel or if on single site using network settings
245
-	//$settings              = get_site_option( $option_name );
246
-	//$use_network_settings  = ! empty( $use_network_settings['use_network_settings'] ) ? true : false;
247
-	//$is_network            = is_multisite();
248
-	//$update_network_option = true;
249
-	//if ( ! is_network_admin() && ! ( $is_network && $use_network_settings ) ) {
250
-	   $settings = get_option( $option_name );
251
-	//   $update_network_option = false;
252
-	//}
253
-
254
-	// Next let's try to remove the keys
255
-	foreach ( $keys as $key ) {
256
-		if( isset( $settings[ $key ] ) ) {
257
-			unset( $settings[ $key ] );
258
-		}
259
-	}
260
-
261
-	$did_update = false;
262
-	//if ( $update_network_option ) {
263
-	//    $did_update = update_site_option( 'monsterinsights_settings', $settings );
264
-	//} else {
265
-		$did_update = update_option( $option_name, $settings );
266
-	//}
267
-
268
-	// If it updated, let's update the global variable
269
-	if ( $did_update ){
270
-		global $monsterinsights_settings;
271
-		$monsterinsights_settings = $settings;
272
-	}
273
-
274
-	return $did_update;
235
+    // If no keys, exit
236
+    if ( empty( $keys ) || ! is_array( $keys ) ){
237
+        return false;
238
+    }
239
+
240
+    $option_name = monsterinsights_get_option_name();
241
+
242
+    // First let's grab the current settings
243
+
244
+    // if on network panel or if on single site using network settings
245
+    //$settings              = get_site_option( $option_name );
246
+    //$use_network_settings  = ! empty( $use_network_settings['use_network_settings'] ) ? true : false;
247
+    //$is_network            = is_multisite();
248
+    //$update_network_option = true;
249
+    //if ( ! is_network_admin() && ! ( $is_network && $use_network_settings ) ) {
250
+        $settings = get_option( $option_name );
251
+    //   $update_network_option = false;
252
+    //}
253
+
254
+    // Next let's try to remove the keys
255
+    foreach ( $keys as $key ) {
256
+        if( isset( $settings[ $key ] ) ) {
257
+            unset( $settings[ $key ] );
258
+        }
259
+    }
260
+
261
+    $did_update = false;
262
+    //if ( $update_network_option ) {
263
+    //    $did_update = update_site_option( 'monsterinsights_settings', $settings );
264
+    //} else {
265
+        $did_update = update_option( $option_name, $settings );
266
+    //}
267
+
268
+    // If it updated, let's update the global variable
269
+    if ( $did_update ){
270
+        global $monsterinsights_settings;
271
+        $monsterinsights_settings = $settings;
272
+    }
273
+
274
+    return $did_update;
275 275
 }
276 276
 
277 277
 /**
@@ -285,27 +285,27 @@  discard block
 block discarded – undo
285 285
  * @return string       The value of the setting.
286 286
  */
287 287
 function monsterinsights_get_license() {
288
-	$license = false;
289
-	if ( defined( 'MONSTERINSIGHTS_LICENSE_KEY' ) && is_string( MONSTERINSIGHTS_LICENSE_KEY ) && strlen( MONSTERINSIGHTS_LICENSE_KEY ) > 10 ) {
290
-		$license = array( 'key' => MONSTERINSIGHTS_LICENSE_KEY );
291
-	} else if ( is_multisite() && monsterinsights_is_network_active() ){
292
-		$network_license = get_site_option( 'monsterinsights_license' );
293
-		if ( ! empty( $network_license['key'] ) && is_string( $network_license['key'] ) && strlen( $network_license['key'] ) > 10 ) {
294
-			$license = $network_license;
295
-		} else {
296
-			$site_license = get_option( 'monsterinsights_license' );
297
-			if ( ! empty( $site_license['key'] ) && is_string( $site_license['key'] ) && strlen( $site_license['key'] ) > 10 ) {
298
-				$license = $site_license;
299
-			}
300
-		}
301
-	} else {
302
-		$site_license = get_option( 'monsterinsights_license' );
303
-		if ( ! empty( $site_license['key'] ) && is_string( $site_license['key'] ) && strlen( $site_license['key'] ) > 10 ) {
304
-			$license = $site_license;
305
-		}
306
-	}
307
-
308
-	return apply_filters( 'monsterinsights_license', $license );
288
+    $license = false;
289
+    if ( defined( 'MONSTERINSIGHTS_LICENSE_KEY' ) && is_string( MONSTERINSIGHTS_LICENSE_KEY ) && strlen( MONSTERINSIGHTS_LICENSE_KEY ) > 10 ) {
290
+        $license = array( 'key' => MONSTERINSIGHTS_LICENSE_KEY );
291
+    } else if ( is_multisite() && monsterinsights_is_network_active() ){
292
+        $network_license = get_site_option( 'monsterinsights_license' );
293
+        if ( ! empty( $network_license['key'] ) && is_string( $network_license['key'] ) && strlen( $network_license['key'] ) > 10 ) {
294
+            $license = $network_license;
295
+        } else {
296
+            $site_license = get_option( 'monsterinsights_license' );
297
+            if ( ! empty( $site_license['key'] ) && is_string( $site_license['key'] ) && strlen( $site_license['key'] ) > 10 ) {
298
+                $license = $site_license;
299
+            }
300
+        }
301
+    } else {
302
+        $site_license = get_option( 'monsterinsights_license' );
303
+        if ( ! empty( $site_license['key'] ) && is_string( $site_license['key'] ) && strlen( $site_license['key'] ) > 10 ) {
304
+            $license = $site_license;
305
+        }
306
+    }
307
+
308
+    return apply_filters( 'monsterinsights_license', $license );
309 309
 }
310 310
 
311 311
 /**
@@ -319,19 +319,19 @@  discard block
 block discarded – undo
319 319
  * @return string       The value of the setting.
320 320
  */
321 321
 function monsterinsights_get_license_key() {
322
-	$license = false;
323
-	if ( defined( 'MONSTERINSIGHTS_LICENSE_KEY' ) && is_string( MONSTERINSIGHTS_LICENSE_KEY ) && strlen( MONSTERINSIGHTS_LICENSE_KEY ) > 10 ) {
324
-		$license = MONSTERINSIGHTS_LICENSE_KEY;
325
-	} else {
326
-		$license = monsterinsights_get_license();
327
-		if ( ! empty( $license['key'] ) && is_string( $license['key'] ) && strlen( $license['key'] ) > 10 ) {
328
-			$license = $license['key'];
329
-		} else {
330
-			$license = false;
331
-		}
332
-	}
333
-
334
-	return apply_filters( 'monsterinsights_license_key', $license );
322
+    $license = false;
323
+    if ( defined( 'MONSTERINSIGHTS_LICENSE_KEY' ) && is_string( MONSTERINSIGHTS_LICENSE_KEY ) && strlen( MONSTERINSIGHTS_LICENSE_KEY ) > 10 ) {
324
+        $license = MONSTERINSIGHTS_LICENSE_KEY;
325
+    } else {
326
+        $license = monsterinsights_get_license();
327
+        if ( ! empty( $license['key'] ) && is_string( $license['key'] ) && strlen( $license['key'] ) > 10 ) {
328
+            $license = $license['key'];
329
+        } else {
330
+            $license = false;
331
+        }
332
+    }
333
+
334
+    return apply_filters( 'monsterinsights_license_key', $license );
335 335
 }
336 336
 
337 337
 /**
@@ -345,36 +345,36 @@  discard block
 block discarded – undo
345 345
  * @return boolean True if updated, false if not.
346 346
  */
347 347
 function monsterinsights_update_license_key( $license_key = false, $network = false, $override = false ) {
348
-	if ( ! $license_key || ! is_string( $license_key ) || ! strlen( $license_key ) > 10  ) {
349
-		return false;
350
-	}
351
-
352
-	if ( $network && is_multisite() && ( is_network_admin() || $override ) ) {
353
-		update_site_option( 'monsterinsights_license', $license_key );
354
-		return true;
355
-	} else {
356
-		update_option( 'monsterinsights_license', $license_key );
357
-		return true;
358
-	}
348
+    if ( ! $license_key || ! is_string( $license_key ) || ! strlen( $license_key ) > 10  ) {
349
+        return false;
350
+    }
351
+
352
+    if ( $network && is_multisite() && ( is_network_admin() || $override ) ) {
353
+        update_site_option( 'monsterinsights_license', $license_key );
354
+        return true;
355
+    } else {
356
+        update_option( 'monsterinsights_license', $license_key );
357
+        return true;
358
+    }
359 359
 }
360 360
 
361
- /**
362
- * Helper method for deleting the license key.
363
- *
364
- * @since 6.0.0
365
- * @access public
366
- *
367
- * @param string $key   The setting key.
368
- * @return boolean True if removed, false if not.
369
- */
361
+    /**
362
+     * Helper method for deleting the license key.
363
+     *
364
+     * @since 6.0.0
365
+     * @access public
366
+     *
367
+     * @param string $key   The setting key.
368
+     * @return boolean True if removed, false if not.
369
+     */
370 370
 function monsterinsights_delete_license_key( $network = false, $override = false ) {
371
-	if ( $network && is_multisite() && ( is_network_admin() || $override ) ) {
372
-		delete_site_option( 'monsterinsights_license' );
373
-		return true;
374
-	} else {
375
-		delete_option( 'monsterinsights_license' );
376
-		return true;
377
-	}
371
+    if ( $network && is_multisite() && ( is_network_admin() || $override ) ) {
372
+        delete_site_option( 'monsterinsights_license' );
373
+        return true;
374
+    } else {
375
+        delete_option( 'monsterinsights_license' );
376
+        return true;
377
+    }
378 378
 }
379 379
 
380 380
 
@@ -387,14 +387,14 @@  discard block
 block discarded – undo
387 387
  * @return string $type The user's license key type for MonsterInsights.
388 388
  */
389 389
 function monsterinsights_get_license_key_type() {
390
-	$type = false;
391
-	$license = monsterinsights_get_license();
392
-	if ( ! empty( $license['type'] ) && is_string( $license['type'] ) ) {
393
-		if ( in_array( $license['type'], array( 'master', 'pro', 'plus', 'basic' ) ) ) {
394
-			$type = $license['type'];
395
-		}
396
-	}
397
-	return $type;
390
+    $type = false;
391
+    $license = monsterinsights_get_license();
392
+    if ( ! empty( $license['type'] ) && is_string( $license['type'] ) ) {
393
+        if ( in_array( $license['type'], array( 'master', 'pro', 'plus', 'basic' ) ) ) {
394
+            $type = $license['type'];
395
+        }
396
+    }
397
+    return $type;
398 398
 }
399 399
 
400 400
 /**
@@ -406,16 +406,16 @@  discard block
 block discarded – undo
406 406
  * @return bool True if there are license key errors, false otherwise.
407 407
  */
408 408
 function monsterinsights_get_license_key_errors() {
409
-	$errors = false;
410
-	$license = monsterinsights_get_license();
411
-	if ( ! empty( $license['type'] ) && is_string( $license['type'] ) && strlen( $license['type'] ) > 3 ) {
412
-		if ( ( isset( $license['is_expired'] )  && $license['is_expired'] ) 
413
-		  || ( isset( $license['is_disabled'] ) && $license['is_disabled'] )
414
-		  || ( isset( $license['is_invalid'] )  && $license['is_invalid'] ) ) {
415
-			$errors = true;
416
-		}
417
-	}
418
-	return $errors;
409
+    $errors = false;
410
+    $license = monsterinsights_get_license();
411
+    if ( ! empty( $license['type'] ) && is_string( $license['type'] ) && strlen( $license['type'] ) > 3 ) {
412
+        if ( ( isset( $license['is_expired'] )  && $license['is_expired'] ) 
413
+          || ( isset( $license['is_disabled'] ) && $license['is_disabled'] )
414
+          || ( isset( $license['is_invalid'] )  && $license['is_invalid'] ) ) {
415
+            $errors = true;
416
+        }
417
+    }
418
+    return $errors;
419 419
 }
420 420
 
421 421
 /**
@@ -429,46 +429,46 @@  discard block
 block discarded – undo
429 429
  * @return string|false Return cleaned ua string if valid, else returns false.
430 430
  */
431 431
 function monsterinsights_is_valid_ua( $ua_code = '' ) {
432
-	$ua_code = (string) $ua_code; // Rare case, but let's make sure it never happens.
433
-	$ua_code = trim( $ua_code );
432
+    $ua_code = (string) $ua_code; // Rare case, but let's make sure it never happens.
433
+    $ua_code = trim( $ua_code );
434 434
 
435
-	if ( empty( $ua_code ) ) {
436
-		return '';
437
-	}
435
+    if ( empty( $ua_code ) ) {
436
+        return '';
437
+    }
438 438
 	
439
-	// Replace all type of dashes (n-dash, m-dash, minus) with normal dashes.
440
-	$ua_code = str_replace( array( '–', '—', '−' ), '-', $ua_code );
439
+    // Replace all type of dashes (n-dash, m-dash, minus) with normal dashes.
440
+    $ua_code = str_replace( array( '–', '—', '−' ), '-', $ua_code );
441 441
 	
442
-	if ( preg_match( "/^(UA|YT|MO)-\d{4,}-\d+$/", strval( $ua_code ) ) ) {
443
-		return $ua_code;
444
-	} else {
445
-		return '';
446
-	}
442
+    if ( preg_match( "/^(UA|YT|MO)-\d{4,}-\d+$/", strval( $ua_code ) ) ) {
443
+        return $ua_code;
444
+    } else {
445
+        return '';
446
+    }
447 447
 }
448 448
 
449 449
 function monsterinsights_get_option_name() {
450
-	//if ( monsterinsights_is_pro_version() ) {
451
-		return 'monsterinsights_settings';
452
-	//} else {
453
-	//	return 'monsterinsights_settings';
454
-	//}
450
+    //if ( monsterinsights_is_pro_version() ) {
451
+        return 'monsterinsights_settings';
452
+    //} else {
453
+    //	return 'monsterinsights_settings';
454
+    //}
455 455
 }
456 456
 
457 457
 function monsterinsights_export_settings() {
458
-	$settings = monsterinsights_get_options();
459
-	$exclude  = array( 
460
-				'analytics_profile',
461
-				'analytics_profile_code',
462
-				'analytics_profile_name',
463
-				'oauth_version',
464
-				'cron_last_run',
465
-				'monsterinsights_oauth_status',
466
-	);
467
-
468
-	foreach ( $exclude as $e ) {
469
-		if ( ! empty( $settings[ $e ] ) ) {
470
-			unset( $settings[ $e ] );
471
-		}
472
-	}
473
-	return wp_json_encode( $settings );
458
+    $settings = monsterinsights_get_options();
459
+    $exclude  = array( 
460
+                'analytics_profile',
461
+                'analytics_profile_code',
462
+                'analytics_profile_name',
463
+                'oauth_version',
464
+                'cron_last_run',
465
+                'monsterinsights_oauth_status',
466
+    );
467
+
468
+    foreach ( $exclude as $e ) {
469
+        if ( ! empty( $settings[ $e ] ) ) {
470
+            unset( $settings[ $e ] );
471
+        }
472
+    }
473
+    return wp_json_encode( $settings );
474 474
 }
475 475
\ No newline at end of file
Please login to merge, or discard this patch.
includes/helpers.php 3 patches
Spacing   +339 added lines, -339 removed lines patch added patch discarded remove patch
@@ -10,34 +10,34 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
17
-function monsterinsights_debug_output( $var ) {
18
-	error_log( print_r( $var, true ) . "\n", 3, MONSTERINSIGHTS_PLUGIN_DIR . 'log.txt' );
17
+function monsterinsights_debug_output($var) {
18
+	error_log(print_r($var, true) . "\n", 3, MONSTERINSIGHTS_PLUGIN_DIR . 'log.txt');
19 19
 }
20 20
 
21 21
 function monsterinsights_is_page_reload() {
22 22
 	// Can't be a refresh without having a referrer
23
-	if ( ! isset( $_SERVER['HTTP_REFERER'] ) ) {
23
+	if ( ! isset($_SERVER['HTTP_REFERER'])) {
24 24
 		return false;
25 25
 	}
26 26
 
27 27
 	// IF the referrer is identical to the current page request, then it's a refresh
28
-	return ( parse_url( $_SERVER['HTTP_REFERER'], PHP_URL_PATH ) === parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH ) );
28
+	return (parse_url($_SERVER['HTTP_REFERER'], PHP_URL_PATH) === parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
29 29
 }
30 30
 
31 31
 
32 32
 function monsterinsights_track_user() {
33 33
 	$user        = wp_get_current_user();
34 34
 	$track_user  = true;
35
-	$roles     = monsterinsights_get_option( 'ignore_users', array() );
35
+	$roles = monsterinsights_get_option('ignore_users', array());
36 36
 
37
-	if ( ! empty( $roles ) && is_array( $roles ) ) {
38
-		foreach ( $roles as $role ) {
39
-			if ( is_string( $role ) ) {
40
-				if ( current_user_can( $role ) ) {
37
+	if ( ! empty($roles) && is_array($roles)) {
38
+		foreach ($roles as $role) {
39
+			if (is_string($role)) {
40
+				if (current_user_can($role)) {
41 41
 					$track_user = false;
42 42
 					break;
43 43
 				}
@@ -45,30 +45,30 @@  discard block
 block discarded – undo
45 45
 		}
46 46
 	}
47 47
 
48
-	$track_super_admin = apply_filters( 'monsterinsights_track_super_admins', false );
49
-	if ( $track_super_admin === false && is_super_admin() ) {
48
+	$track_super_admin = apply_filters('monsterinsights_track_super_admins', false);
49
+	if ($track_super_admin === false && is_super_admin()) {
50 50
 		$track_user = false;
51 51
 	}
52 52
 	
53 53
 	// or if UA code is not entered
54 54
 	$ua_code = monsterinsights_get_ua();
55
-	if ( empty( $ua_code ) ) {
55
+	if (empty($ua_code)) {
56 56
 		$track_user = false;
57 57
 	}
58 58
 
59
-	return apply_filters( 'monsterinsights_track_user', $track_user, $user );
59
+	return apply_filters('monsterinsights_track_user', $track_user, $user);
60 60
 }
61 61
 
62
-function monsterinsights_get_client_id( $payment_id = false ) {
63
-	if ( is_object( $payment_id ) ) {
62
+function monsterinsights_get_client_id($payment_id = false) {
63
+	if (is_object($payment_id)) {
64 64
 		$payment_id = $payment_id->ID;
65 65
 	}
66 66
 	$user_cid    = monsterinsights_get_uuid();
67
-	$payment_cid = get_post_meta( $payment_id, '_yoast_gau_uuid', true );
67
+	$payment_cid = get_post_meta($payment_id, '_yoast_gau_uuid', true);
68 68
 
69
-	if ( ! empty( $payment_id ) && ! empty( $saved_cid ) ) {
69
+	if ( ! empty($payment_id) && ! empty($saved_cid)) {
70 70
 		return $saved_cid;
71
-	} else if ( ! empty( $user_cid ) ) {
71
+	} else if ( ! empty($user_cid)) {
72 72
 		return $user_cid;
73 73
 	} else {
74 74
 		return monsterinsights_generate_uuid();
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
  * @return bool|string False if cookie isn't set, GA UUID otherwise
86 86
  */
87 87
 function monsterinsights_get_uuid() {
88
-	if ( empty( $_COOKIE['_ga'] ) ) {
88
+	if (empty($_COOKIE['_ga'])) {
89 89
 		return false;
90 90
 	}
91 91
 	
@@ -98,10 +98,10 @@  discard block
 block discarded – undo
98 98
 	 */
99 99
 
100 100
 	$ga_cookie    = $_COOKIE['_ga'];
101
-	$cookie_parts = explode('.', $ga_cookie );
102
-	if ( is_array( $cookie_parts ) && ! empty( $cookie_parts[2] ) && ! empty( $cookie_parts[3] ) ) {
101
+	$cookie_parts = explode('.', $ga_cookie);
102
+	if (is_array($cookie_parts) && ! empty($cookie_parts[2]) && ! empty($cookie_parts[3])) {
103 103
 		$uuid = (string) $cookie_parts[2] . '.' . (string) $cookie_parts[3];
104
-		if ( is_string( $uuid ) ) {
104
+		if (is_string($uuid)) {
105 105
 			return $uuid;
106 106
 		} else {
107 107
 			return false;
@@ -122,25 +122,25 @@  discard block
 block discarded – undo
122 122
  */
123 123
 function monsterinsights_generate_uuid() {
124 124
 
125
-	return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
125
+	return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
126 126
 
127 127
 		// 32 bits for "time_low"
128
-		mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
128
+		mt_rand(0, 0xffff), mt_rand(0, 0xffff),
129 129
 
130 130
 		// 16 bits for "time_mid"
131
-		mt_rand( 0, 0xffff ),
131
+		mt_rand(0, 0xffff),
132 132
 
133 133
 		// 16 bits for "time_hi_and_version",
134 134
 		// four most significant bits holds version number 4
135
-		mt_rand( 0, 0x0fff ) | 0x4000,
135
+		mt_rand(0, 0x0fff) | 0x4000,
136 136
 
137 137
 		// 16 bits, 8 bits for "clk_seq_hi_res",
138 138
 		// 8 bits for "clk_seq_low",
139 139
 		// two most significant bits holds zero and one for variant DCE1.1
140
-		mt_rand( 0, 0x3fff ) | 0x8000,
140
+		mt_rand(0, 0x3fff) | 0x8000,
141 141
 
142 142
 		// 48 bits for "node"
143
-		mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff )
143
+		mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
144 144
 	);
145 145
 }
146 146
 
@@ -151,28 +151,28 @@  discard block
 block discarded – undo
151 151
  *
152 152
  * @return GA UUID or error code.
153 153
  */
154
-function monsterinsights_get_cookie( $debug = false ) {
155
-	if ( empty( $_COOKIE['_ga'] ) ) {
156
-		return ( $debug ) ? 'FCE' : false;
154
+function monsterinsights_get_cookie($debug = false) {
155
+	if (empty($_COOKIE['_ga'])) {
156
+		return ($debug) ? 'FCE' : false;
157 157
 	}
158 158
 	
159 159
 	$ga_cookie    = $_COOKIE['_ga'];
160
-	$cookie_parts = explode('.', $ga_cookie );
161
-	if ( is_array( $cookie_parts ) && ! empty( $cookie_parts[2] ) && ! empty( $cookie_parts[3] ) ) {
160
+	$cookie_parts = explode('.', $ga_cookie);
161
+	if (is_array($cookie_parts) && ! empty($cookie_parts[2]) && ! empty($cookie_parts[3])) {
162 162
 		$uuid = (string) $cookie_parts[2] . '.' . (string) $cookie_parts[3];
163
-		if ( is_string( $uuid ) ) {
163
+		if (is_string($uuid)) {
164 164
 			return $ga_cookie;
165 165
 		} else {
166
-			return ( $debug ) ? 'FA' : false;
166
+			return ($debug) ? 'FA' : false;
167 167
 		}
168 168
 	} else {
169
-		return ( $debug ) ? 'FAE' : false;
169
+		return ($debug) ? 'FAE' : false;
170 170
 	}
171 171
 }
172 172
 
173 173
 
174 174
 function monsterinsights_generate_ga_client_id() {
175
-	return rand(100000000,999999999) . '.' . time();
175
+	return rand(100000000, 999999999) . '.' . time();
176 176
 }
177 177
  
178 178
 
@@ -187,13 +187,13 @@  discard block
 block discarded – undo
187 187
  *
188 188
  * @return int Hours between the two timestamps, rounded.
189 189
  */
190
-function monsterinsights_hours_between( $start, $stop = false ) {
191
-	if ( $stop === false ) {
190
+function monsterinsights_hours_between($start, $stop = false) {
191
+	if ($stop === false) {
192 192
 		$stop = time();
193 193
 	}
194 194
 
195
-	$diff = (int) abs( $stop -  $start );
196
-	$hours = round( $diff / HOUR_IN_SECONDS );
195
+	$diff = (int) abs($stop - $start);
196
+	$hours = round($diff / HOUR_IN_SECONDS);
197 197
 	return $hours;
198 198
 }
199 199
 
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
  * @return bool True if pro version.
224 224
  */
225 225
 function monsterinsights_is_pro_version() {
226
-	if ( class_exists( 'MonsterInsights' ) ) {
226
+	if (class_exists('MonsterInsights')) {
227 227
 		return true;
228 228
 	} else {
229 229
 		return false;
@@ -247,300 +247,300 @@  discard block
 block discarded – undo
247 247
 	 *
248 248
 	 * @api array $all_roles
249 249
 	 */
250
-	$editable_roles = apply_filters( 'editable_roles', $all_roles );
250
+	$editable_roles = apply_filters('editable_roles', $all_roles);
251 251
 
252
-	foreach ( $editable_roles as $id => $name ) {
253
-		$roles[ $id ] = translate_user_role( $name['name'] );
252
+	foreach ($editable_roles as $id => $name) {
253
+		$roles[$id] = translate_user_role($name['name']);
254 254
 	}
255 255
 
256 256
 	return $roles;
257 257
 }
258 258
 
259 259
 /** Need to escape in advance of passing in $text. */
260
-function monsterinsights_get_message( $type = 'error', $text = '' ) {
260
+function monsterinsights_get_message($type = 'error', $text = '') {
261 261
 	$div = '';
262
-	if ( $type === 'error' || $type === 'alert' || $type === 'success' || $type === 'info' ) {
262
+	if ($type === 'error' || $type === 'alert' || $type === 'success' || $type === 'info') {
263 263
 		$base = MonsterInsights();
264
-		return $base->notices->display_inline_notice( 'monsterinsights_standard_notice', '', $text, $type, false, array( 'skip_message_escape' => true ) );
264
+		return $base->notices->display_inline_notice('monsterinsights_standard_notice', '', $text, $type, false, array('skip_message_escape' => true));
265 265
 	} else {
266 266
 		return '';
267 267
 	}
268 268
 }
269 269
 
270 270
 // Set cookie to expire in 2 years
271
-function monsterinsights_get_cookie_expiration_date( $time ) {
272
-	return date('D, j F Y H:i:s', time() + $time );
271
+function monsterinsights_get_cookie_expiration_date($time) {
272
+	return date('D, j F Y H:i:s', time() + $time);
273 273
 }
274 274
 
275
-function monsterinsights_string_ends_with( $string, $ending ) {
275
+function monsterinsights_string_ends_with($string, $ending) {
276 276
 	$strlen = strlen($string);
277 277
 	$endinglen = strlen($ending);
278
-	if ( $endinglen > $strlen ) {
278
+	if ($endinglen > $strlen) {
279 279
 		return false;
280 280
 	}
281
-	return substr_compare( $string, $ending, $strlen - $endinglen, $endinglen) === 0;
281
+	return substr_compare($string, $ending, $strlen - $endinglen, $endinglen) === 0;
282 282
 }
283 283
 
284
-function monsterinsights_string_starts_with( $string, $start ) {
285
-	return substr( $string, 0, strlen( $start ) ) === $start;
284
+function monsterinsights_string_starts_with($string, $start) {
285
+	return substr($string, 0, strlen($start)) === $start;
286 286
 }
287 287
 
288
-function monsterinsights_get_country_list( $translated = false ) {
289
-	if ( $translated ) {
288
+function monsterinsights_get_country_list($translated = false) {
289
+	if ($translated) {
290 290
 		$countries = array(
291 291
 			''   => '',
292
-			'US' => __( 'United States', 'google-analytics-for-wordpress' ),
293
-			'CA' => __( 'Canada', 'google-analytics-for-wordpress' ),
294
-			'GB' => __( 'United Kingdom', 'google-analytics-for-wordpress' ),
295
-			'AF' => __( 'Afghanistan', 'google-analytics-for-wordpress' ),
296
-			'AX' => __( '&#197;land Islands', 'google-analytics-for-wordpress' ),
297
-			'AL' => __( 'Albania', 'google-analytics-for-wordpress' ),
298
-			'DZ' => __( 'Algeria', 'google-analytics-for-wordpress' ),
299
-			'AS' => __( 'American Samoa', 'google-analytics-for-wordpress' ),
300
-			'AD' => __( 'Andorra', 'google-analytics-for-wordpress' ),
301
-			'AO' => __( 'Angola', 'google-analytics-for-wordpress' ),
302
-			'AI' => __( 'Anguilla', 'google-analytics-for-wordpress' ),
303
-			'AQ' => __( 'Antarctica', 'google-analytics-for-wordpress' ),
304
-			'AG' => __( 'Antigua and Barbuda', 'google-analytics-for-wordpress' ),
305
-			'AR' => __( 'Argentina', 'google-analytics-for-wordpress' ),
306
-			'AM' => __( 'Armenia', 'google-analytics-for-wordpress' ),
307
-			'AW' => __( 'Aruba', 'google-analytics-for-wordpress' ),
308
-			'AU' => __( 'Australia', 'google-analytics-for-wordpress' ),
309
-			'AT' => __( 'Austria', 'google-analytics-for-wordpress' ),
310
-			'AZ' => __( 'Azerbaijan', 'google-analytics-for-wordpress' ),
311
-			'BS' => __( 'Bahamas', 'google-analytics-for-wordpress' ),
312
-			'BH' => __( 'Bahrain', 'google-analytics-for-wordpress' ),
313
-			'BD' => __( 'Bangladesh', 'google-analytics-for-wordpress' ),
314
-			'BB' => __( 'Barbados', 'google-analytics-for-wordpress' ),
315
-			'BY' => __( 'Belarus', 'google-analytics-for-wordpress' ),
316
-			'BE' => __( 'Belgium', 'google-analytics-for-wordpress' ),
317
-			'BZ' => __( 'Belize', 'google-analytics-for-wordpress' ),
318
-			'BJ' => __( 'Benin', 'google-analytics-for-wordpress' ),
319
-			'BM' => __( 'Bermuda', 'google-analytics-for-wordpress' ),
320
-			'BT' => __( 'Bhutan', 'google-analytics-for-wordpress' ),
321
-			'BO' => __( 'Bolivia', 'google-analytics-for-wordpress' ),
322
-			'BQ' => __( 'Bonaire, Saint Eustatius and Saba', 'google-analytics-for-wordpress' ),
323
-			'BA' => __( 'Bosnia and Herzegovina', 'google-analytics-for-wordpress' ),
324
-			'BW' => __( 'Botswana', 'google-analytics-for-wordpress' ),
325
-			'BV' => __( 'Bouvet Island', 'google-analytics-for-wordpress' ),
326
-			'BR' => __( 'Brazil', 'google-analytics-for-wordpress' ),
327
-			'IO' => __( 'British Indian Ocean Territory', 'google-analytics-for-wordpress' ),
328
-			'BN' => __( 'Brunei Darrussalam', 'google-analytics-for-wordpress' ),
329
-			'BG' => __( 'Bulgaria', 'google-analytics-for-wordpress' ),
330
-			'BF' => __( 'Burkina Faso', 'google-analytics-for-wordpress' ),
331
-			'BI' => __( 'Burundi', 'google-analytics-for-wordpress' ),
332
-			'KH' => __( 'Cambodia', 'google-analytics-for-wordpress' ),
333
-			'CM' => __( 'Cameroon', 'google-analytics-for-wordpress' ),
334
-			'CV' => __( 'Cape Verde', 'google-analytics-for-wordpress' ),
335
-			'KY' => __( 'Cayman Islands', 'google-analytics-for-wordpress' ),
336
-			'CF' => __( 'Central African Republic', 'google-analytics-for-wordpress' ),
337
-			'TD' => __( 'Chad', 'google-analytics-for-wordpress' ),
338
-			'CL' => __( 'Chile', 'google-analytics-for-wordpress' ),
339
-			'CN' => __( 'China', 'google-analytics-for-wordpress' ),
340
-			'CX' => __( 'Christmas Island', 'google-analytics-for-wordpress' ),
341
-			'CC' => __( 'Cocos Islands', 'google-analytics-for-wordpress' ),
342
-			'CO' => __( 'Colombia', 'google-analytics-for-wordpress' ),
343
-			'KM' => __( 'Comoros', 'google-analytics-for-wordpress' ),
344
-			'CD' => __( 'Congo, Democratic People\'s Republic', 'google-analytics-for-wordpress' ),
345
-			'CG' => __( 'Congo, Republic of', 'google-analytics-for-wordpress' ),
346
-			'CK' => __( 'Cook Islands', 'google-analytics-for-wordpress' ),
347
-			'CR' => __( 'Costa Rica', 'google-analytics-for-wordpress' ),
348
-			'CI' => __( 'Cote d\'Ivoire', 'google-analytics-for-wordpress' ),
349
-			'HR' => __( 'Croatia/Hrvatska', 'google-analytics-for-wordpress' ),
350
-			'CU' => __( 'Cuba', 'google-analytics-for-wordpress' ),
351
-			'CW' => __( 'Cura&Ccedil;ao', 'google-analytics-for-wordpress' ),
352
-			'CY' => __( 'Cyprus', 'google-analytics-for-wordpress' ),
353
-			'CZ' => __( 'Czechia', 'google-analytics-for-wordpress' ),
354
-			'DK' => __( 'Denmark', 'google-analytics-for-wordpress' ),
355
-			'DJ' => __( 'Djibouti', 'google-analytics-for-wordpress' ),
356
-			'DM' => __( 'Dominica', 'google-analytics-for-wordpress' ),
357
-			'DO' => __( 'Dominican Republic', 'google-analytics-for-wordpress' ),
358
-			'TP' => __( 'East Timor', 'google-analytics-for-wordpress' ),
359
-			'EC' => __( 'Ecuador', 'google-analytics-for-wordpress' ),
360
-			'EG' => __( 'Egypt', 'google-analytics-for-wordpress' ),
361
-			'GQ' => __( 'Equatorial Guinea', 'google-analytics-for-wordpress' ),
362
-			'SV' => __( 'El Salvador', 'google-analytics-for-wordpress' ),
363
-			'ER' => __( 'Eritrea', 'google-analytics-for-wordpress' ),
364
-			'EE' => __( 'Estonia', 'google-analytics-for-wordpress' ),
365
-			'ET' => __( 'Ethiopia', 'google-analytics-for-wordpress' ),
366
-			'FK' => __( 'Falkland Islands', 'google-analytics-for-wordpress' ),
367
-			'FO' => __( 'Faroe Islands', 'google-analytics-for-wordpress' ),
368
-			'FJ' => __( 'Fiji', 'google-analytics-for-wordpress' ),
369
-			'FI' => __( 'Finland', 'google-analytics-for-wordpress' ),
370
-			'FR' => __( 'France', 'google-analytics-for-wordpress' ),
371
-			'GF' => __( 'French Guiana', 'google-analytics-for-wordpress' ),
372
-			'PF' => __( 'French Polynesia', 'google-analytics-for-wordpress' ),
373
-			'TF' => __( 'French Southern Territories', 'google-analytics-for-wordpress' ),
374
-			'GA' => __( 'Gabon', 'google-analytics-for-wordpress' ),
375
-			'GM' => __( 'Gambia', 'google-analytics-for-wordpress' ),
376
-			'GE' => __( 'Georgia', 'google-analytics-for-wordpress' ),
377
-			'DE' => __( 'Germany', 'google-analytics-for-wordpress' ),
378
-			'GR' => __( 'Greece', 'google-analytics-for-wordpress' ),
379
-			'GH' => __( 'Ghana', 'google-analytics-for-wordpress' ),
380
-			'GI' => __( 'Gibraltar', 'google-analytics-for-wordpress' ),
381
-			'GL' => __( 'Greenland', 'google-analytics-for-wordpress' ),
382
-			'GD' => __( 'Grenada', 'google-analytics-for-wordpress' ),
383
-			'GP' => __( 'Guadeloupe', 'google-analytics-for-wordpress' ),
384
-			'GU' => __( 'Guam', 'google-analytics-for-wordpress' ),
385
-			'GT' => __( 'Guatemala', 'google-analytics-for-wordpress' ),
386
-			'GG' => __( 'Guernsey', 'google-analytics-for-wordpress' ),
387
-			'GN' => __( 'Guinea', 'google-analytics-for-wordpress' ),
388
-			'GW' => __( 'Guinea-Bissau', 'google-analytics-for-wordpress' ),
389
-			'GY' => __( 'Guyana', 'google-analytics-for-wordpress' ),
390
-			'HT' => __( 'Haiti', 'google-analytics-for-wordpress' ),
391
-			'HM' => __( 'Heard and McDonald Islands', 'google-analytics-for-wordpress' ),
392
-			'VA' => __( 'Holy See (City Vatican State)', 'google-analytics-for-wordpress' ),
393
-			'HN' => __( 'Honduras', 'google-analytics-for-wordpress' ),
394
-			'HK' => __( 'Hong Kong', 'google-analytics-for-wordpress' ),
395
-			'HU' => __( 'Hungary', 'google-analytics-for-wordpress' ),
396
-			'IS' => __( 'Iceland', 'google-analytics-for-wordpress' ),
397
-			'IN' => __( 'India', 'google-analytics-for-wordpress' ),
398
-			'ID' => __( 'Indonesia', 'google-analytics-for-wordpress' ),
399
-			'IR' => __( 'Iran', 'google-analytics-for-wordpress' ),
400
-			'IQ' => __( 'Iraq', 'google-analytics-for-wordpress' ),
401
-			'IE' => __( 'Ireland', 'google-analytics-for-wordpress' ),
402
-			'IM' => __( 'Isle of Man', 'google-analytics-for-wordpress' ),
403
-			'IL' => __( 'Israel', 'google-analytics-for-wordpress' ),
404
-			'IT' => __( 'Italy', 'google-analytics-for-wordpress' ),
405
-			'JM' => __( 'Jamaica', 'google-analytics-for-wordpress' ),
406
-			'JP' => __( 'Japan', 'google-analytics-for-wordpress' ),
407
-			'JE' => __( 'Jersey', 'google-analytics-for-wordpress' ),
408
-			'JO' => __( 'Jordan', 'google-analytics-for-wordpress' ),
409
-			'KZ' => __( 'Kazakhstan', 'google-analytics-for-wordpress' ),
410
-			'KE' => __( 'Kenya', 'google-analytics-for-wordpress' ),
411
-			'KI' => __( 'Kiribati', 'google-analytics-for-wordpress' ),
412
-			'KW' => __( 'Kuwait', 'google-analytics-for-wordpress' ),
413
-			'KG' => __( 'Kyrgyzstan', 'google-analytics-for-wordpress' ),
414
-			'LA' => __( 'Lao People\'s Democratic Republic', 'google-analytics-for-wordpress' ),
415
-			'LV' => __( 'Latvia', 'google-analytics-for-wordpress' ),
416
-			'LB' => __( 'Lebanon', 'google-analytics-for-wordpress' ),
417
-			'LS' => __( 'Lesotho', 'google-analytics-for-wordpress' ),
418
-			'LR' => __( 'Liberia', 'google-analytics-for-wordpress' ),
419
-			'LY' => __( 'Libyan Arab Jamahiriya', 'google-analytics-for-wordpress' ),
420
-			'LI' => __( 'Liechtenstein', 'google-analytics-for-wordpress' ),
421
-			'LT' => __( 'Lithuania', 'google-analytics-for-wordpress' ),
422
-			'LU' => __( 'Luxembourg', 'google-analytics-for-wordpress' ),
423
-			'MO' => __( 'Macau', 'google-analytics-for-wordpress' ),
424
-			'MK' => __( 'Macedonia', 'google-analytics-for-wordpress' ),
425
-			'MG' => __( 'Madagascar', 'google-analytics-for-wordpress' ),
426
-			'MW' => __( 'Malawi', 'google-analytics-for-wordpress' ),
427
-			'MY' => __( 'Malaysia', 'google-analytics-for-wordpress' ),
428
-			'MV' => __( 'Maldives', 'google-analytics-for-wordpress' ),
429
-			'ML' => __( 'Mali', 'google-analytics-for-wordpress' ),
430
-			'MT' => __( 'Malta', 'google-analytics-for-wordpress' ),
431
-			'MH' => __( 'Marshall Islands', 'google-analytics-for-wordpress' ),
432
-			'MQ' => __( 'Martinique', 'google-analytics-for-wordpress' ),
433
-			'MR' => __( 'Mauritania', 'google-analytics-for-wordpress' ),
434
-			'MU' => __( 'Mauritius', 'google-analytics-for-wordpress' ),
435
-			'YT' => __( 'Mayotte', 'google-analytics-for-wordpress' ),
436
-			'MX' => __( 'Mexico', 'google-analytics-for-wordpress' ),
437
-			'FM' => __( 'Micronesia', 'google-analytics-for-wordpress' ),
438
-			'MD' => __( 'Moldova, Republic of', 'google-analytics-for-wordpress' ),
439
-			'MC' => __( 'Monaco', 'google-analytics-for-wordpress' ),
440
-			'MN' => __( 'Mongolia', 'google-analytics-for-wordpress' ),
441
-			'ME' => __( 'Montenegro', 'google-analytics-for-wordpress' ),
442
-			'MS' => __( 'Montserrat', 'google-analytics-for-wordpress' ),
443
-			'MA' => __( 'Morocco', 'google-analytics-for-wordpress' ),
444
-			'MZ' => __( 'Mozambique', 'google-analytics-for-wordpress' ),
445
-			'MM' => __( 'Myanmar', 'google-analytics-for-wordpress' ),
446
-			'NA' => __( 'Namibia', 'google-analytics-for-wordpress' ),
447
-			'NR' => __( 'Nauru', 'google-analytics-for-wordpress' ),
448
-			'NP' => __( 'Nepal', 'google-analytics-for-wordpress' ),
449
-			'NL' => __( 'Netherlands', 'google-analytics-for-wordpress' ),
450
-			'AN' => __( 'Netherlands Antilles', 'google-analytics-for-wordpress' ),
451
-			'NC' => __( 'New Caledonia', 'google-analytics-for-wordpress' ),
452
-			'NZ' => __( 'New Zealand', 'google-analytics-for-wordpress' ),
453
-			'NI' => __( 'Nicaragua', 'google-analytics-for-wordpress' ),
454
-			'NE' => __( 'Niger', 'google-analytics-for-wordpress' ),
455
-			'NG' => __( 'Nigeria', 'google-analytics-for-wordpress' ),
456
-			'NU' => __( 'Niue', 'google-analytics-for-wordpress' ),
457
-			'NF' => __( 'Norfolk Island', 'google-analytics-for-wordpress' ),
458
-			'KP' => __( 'North Korea', 'google-analytics-for-wordpress' ),
459
-			'MP' => __( 'Northern Mariana Islands', 'google-analytics-for-wordpress' ),
460
-			'NO' => __( 'Norway', 'google-analytics-for-wordpress' ),
461
-			'OM' => __( 'Oman', 'google-analytics-for-wordpress' ),
462
-			'PK' => __( 'Pakistan', 'google-analytics-for-wordpress' ),
463
-			'PW' => __( 'Palau', 'google-analytics-for-wordpress' ),
464
-			'PS' => __( 'Palestinian Territories', 'google-analytics-for-wordpress' ),
465
-			'PA' => __( 'Panama', 'google-analytics-for-wordpress' ),
466
-			'PG' => __( 'Papua New Guinea', 'google-analytics-for-wordpress' ),
467
-			'PY' => __( 'Paraguay', 'google-analytics-for-wordpress' ),
468
-			'PE' => __( 'Peru', 'google-analytics-for-wordpress' ),
469
-			'PH' => __( 'Philippines', 'google-analytics-for-wordpress' ),
470
-			'PN' => __( 'Pitcairn Island', 'google-analytics-for-wordpress' ),
471
-			'PL' => __( 'Poland', 'google-analytics-for-wordpress' ),
472
-			'PT' => __( 'Portugal', 'google-analytics-for-wordpress' ),
473
-			'PR' => __( 'Puerto Rico', 'google-analytics-for-wordpress' ),
474
-			'QA' => __( 'Qatar', 'google-analytics-for-wordpress' ),
475
-			'XK' => __( 'Republic of Kosovo', 'google-analytics-for-wordpress' ),
476
-			'RE' => __( 'Reunion Island', 'google-analytics-for-wordpress' ),
477
-			'RO' => __( 'Romania', 'google-analytics-for-wordpress' ),
478
-			'RU' => __( 'Russian Federation', 'google-analytics-for-wordpress' ),
479
-			'RW' => __( 'Rwanda', 'google-analytics-for-wordpress' ),
480
-			'BL' => __( 'Saint Barth&eacute;lemy', 'google-analytics-for-wordpress' ),
481
-			'SH' => __( 'Saint Helena', 'google-analytics-for-wordpress' ),
482
-			'KN' => __( 'Saint Kitts and Nevis', 'google-analytics-for-wordpress' ),
483
-			'LC' => __( 'Saint Lucia', 'google-analytics-for-wordpress' ),
484
-			'MF' => __( 'Saint Martin (French)', 'google-analytics-for-wordpress' ),
485
-			'SX' => __( 'Saint Martin (Dutch)', 'google-analytics-for-wordpress' ),
486
-			'PM' => __( 'Saint Pierre and Miquelon', 'google-analytics-for-wordpress' ),
487
-			'VC' => __( 'Saint Vincent and the Grenadines', 'google-analytics-for-wordpress' ),
488
-			'SM' => __( 'San Marino', 'google-analytics-for-wordpress' ),
489
-			'ST' => __( 'S&atilde;o Tom&eacute; and Pr&iacute;ncipe', 'google-analytics-for-wordpress' ),
490
-			'SA' => __( 'Saudi Arabia', 'google-analytics-for-wordpress' ),
491
-			'SN' => __( 'Senegal', 'google-analytics-for-wordpress' ),
492
-			'RS' => __( 'Serbia', 'google-analytics-for-wordpress' ),
493
-			'SC' => __( 'Seychelles', 'google-analytics-for-wordpress' ),
494
-			'SL' => __( 'Sierra Leone', 'google-analytics-for-wordpress' ),
495
-			'SG' => __( 'Singapore', 'google-analytics-for-wordpress' ),
496
-			'SK' => __( 'Slovak Republic', 'google-analytics-for-wordpress' ),
497
-			'SI' => __( 'Slovenia', 'google-analytics-for-wordpress' ),
498
-			'SB' => __( 'Solomon Islands', 'google-analytics-for-wordpress' ),
499
-			'SO' => __( 'Somalia', 'google-analytics-for-wordpress' ),
500
-			'ZA' => __( 'South Africa', 'google-analytics-for-wordpress' ),
501
-			'GS' => __( 'South Georgia', 'google-analytics-for-wordpress' ),
502
-			'KR' => __( 'South Korea', 'google-analytics-for-wordpress' ),
503
-			'SS' => __( 'South Sudan', 'google-analytics-for-wordpress' ),
504
-			'ES' => __( 'Spain', 'google-analytics-for-wordpress' ),
505
-			'LK' => __( 'Sri Lanka', 'google-analytics-for-wordpress' ),
506
-			'SD' => __( 'Sudan', 'google-analytics-for-wordpress' ),
507
-			'SR' => __( 'Suriname', 'google-analytics-for-wordpress' ),
508
-			'SJ' => __( 'Svalbard and Jan Mayen Islands', 'google-analytics-for-wordpress' ),
509
-			'SZ' => __( 'Swaziland', 'google-analytics-for-wordpress' ),
510
-			'SE' => __( 'Sweden', 'google-analytics-for-wordpress' ),
511
-			'CH' => __( 'Switzerland', 'google-analytics-for-wordpress' ),
512
-			'SY' => __( 'Syrian Arab Republic', 'google-analytics-for-wordpress' ),
513
-			'TW' => __( 'Taiwan', 'google-analytics-for-wordpress' ),
514
-			'TJ' => __( 'Tajikistan', 'google-analytics-for-wordpress' ),
515
-			'TZ' => __( 'Tanzania', 'google-analytics-for-wordpress' ),
516
-			'TH' => __( 'Thailand', 'google-analytics-for-wordpress' ),
517
-			'TL' => __( 'Timor-Leste', 'google-analytics-for-wordpress' ),
518
-			'TG' => __( 'Togo', 'google-analytics-for-wordpress' ),
519
-			'TK' => __( 'Tokelau', 'google-analytics-for-wordpress' ),
520
-			'TO' => __( 'Tonga', 'google-analytics-for-wordpress' ),
521
-			'TT' => __( 'Trinidad and Tobago', 'google-analytics-for-wordpress' ),
522
-			'TN' => __( 'Tunisia', 'google-analytics-for-wordpress' ),
523
-			'TR' => __( 'Turkey', 'google-analytics-for-wordpress' ),
524
-			'TM' => __( 'Turkmenistan', 'google-analytics-for-wordpress' ),
525
-			'TC' => __( 'Turks and Caicos Islands', 'google-analytics-for-wordpress' ),
526
-			'TV' => __( 'Tuvalu', 'google-analytics-for-wordpress' ),
527
-			'UG' => __( 'Uganda', 'google-analytics-for-wordpress' ),
528
-			'UA' => __( 'Ukraine', 'google-analytics-for-wordpress' ),
529
-			'AE' => __( 'United Arab Emirates', 'google-analytics-for-wordpress' ),
530
-			'UY' => __( 'Uruguay', 'google-analytics-for-wordpress' ),
531
-			'UM' => __( 'US Minor Outlying Islands', 'google-analytics-for-wordpress' ),
532
-			'UZ' => __( 'Uzbekistan', 'google-analytics-for-wordpress' ),
533
-			'VU' => __( 'Vanuatu', 'google-analytics-for-wordpress' ),
534
-			'VE' => __( 'Venezuela', 'google-analytics-for-wordpress' ),
535
-			'VN' => __( 'Vietnam', 'google-analytics-for-wordpress' ),
536
-			'VG' => __( 'Virgin Islands (British)', 'google-analytics-for-wordpress' ),
537
-			'VI' => __( 'Virgin Islands (USA)', 'google-analytics-for-wordpress' ),
538
-			'WF' => __( 'Wallis and Futuna Islands', 'google-analytics-for-wordpress' ),
539
-			'EH' => __( 'Western Sahara', 'google-analytics-for-wordpress' ),
540
-			'WS' => __( 'Western Samoa', 'google-analytics-for-wordpress' ),
541
-			'YE' => __( 'Yemen', 'google-analytics-for-wordpress' ),
542
-			'ZM' => __( 'Zambia', 'google-analytics-for-wordpress' ),
543
-			'ZW' => __( 'Zimbabwe', 'google-analytics-for-wordpress' ),
292
+			'US' => __('United States', 'google-analytics-for-wordpress'),
293
+			'CA' => __('Canada', 'google-analytics-for-wordpress'),
294
+			'GB' => __('United Kingdom', 'google-analytics-for-wordpress'),
295
+			'AF' => __('Afghanistan', 'google-analytics-for-wordpress'),
296
+			'AX' => __('&#197;land Islands', 'google-analytics-for-wordpress'),
297
+			'AL' => __('Albania', 'google-analytics-for-wordpress'),
298
+			'DZ' => __('Algeria', 'google-analytics-for-wordpress'),
299
+			'AS' => __('American Samoa', 'google-analytics-for-wordpress'),
300
+			'AD' => __('Andorra', 'google-analytics-for-wordpress'),
301
+			'AO' => __('Angola', 'google-analytics-for-wordpress'),
302
+			'AI' => __('Anguilla', 'google-analytics-for-wordpress'),
303
+			'AQ' => __('Antarctica', 'google-analytics-for-wordpress'),
304
+			'AG' => __('Antigua and Barbuda', 'google-analytics-for-wordpress'),
305
+			'AR' => __('Argentina', 'google-analytics-for-wordpress'),
306
+			'AM' => __('Armenia', 'google-analytics-for-wordpress'),
307
+			'AW' => __('Aruba', 'google-analytics-for-wordpress'),
308
+			'AU' => __('Australia', 'google-analytics-for-wordpress'),
309
+			'AT' => __('Austria', 'google-analytics-for-wordpress'),
310
+			'AZ' => __('Azerbaijan', 'google-analytics-for-wordpress'),
311
+			'BS' => __('Bahamas', 'google-analytics-for-wordpress'),
312
+			'BH' => __('Bahrain', 'google-analytics-for-wordpress'),
313
+			'BD' => __('Bangladesh', 'google-analytics-for-wordpress'),
314
+			'BB' => __('Barbados', 'google-analytics-for-wordpress'),
315
+			'BY' => __('Belarus', 'google-analytics-for-wordpress'),
316
+			'BE' => __('Belgium', 'google-analytics-for-wordpress'),
317
+			'BZ' => __('Belize', 'google-analytics-for-wordpress'),
318
+			'BJ' => __('Benin', 'google-analytics-for-wordpress'),
319
+			'BM' => __('Bermuda', 'google-analytics-for-wordpress'),
320
+			'BT' => __('Bhutan', 'google-analytics-for-wordpress'),
321
+			'BO' => __('Bolivia', 'google-analytics-for-wordpress'),
322
+			'BQ' => __('Bonaire, Saint Eustatius and Saba', 'google-analytics-for-wordpress'),
323
+			'BA' => __('Bosnia and Herzegovina', 'google-analytics-for-wordpress'),
324
+			'BW' => __('Botswana', 'google-analytics-for-wordpress'),
325
+			'BV' => __('Bouvet Island', 'google-analytics-for-wordpress'),
326
+			'BR' => __('Brazil', 'google-analytics-for-wordpress'),
327
+			'IO' => __('British Indian Ocean Territory', 'google-analytics-for-wordpress'),
328
+			'BN' => __('Brunei Darrussalam', 'google-analytics-for-wordpress'),
329
+			'BG' => __('Bulgaria', 'google-analytics-for-wordpress'),
330
+			'BF' => __('Burkina Faso', 'google-analytics-for-wordpress'),
331
+			'BI' => __('Burundi', 'google-analytics-for-wordpress'),
332
+			'KH' => __('Cambodia', 'google-analytics-for-wordpress'),
333
+			'CM' => __('Cameroon', 'google-analytics-for-wordpress'),
334
+			'CV' => __('Cape Verde', 'google-analytics-for-wordpress'),
335
+			'KY' => __('Cayman Islands', 'google-analytics-for-wordpress'),
336
+			'CF' => __('Central African Republic', 'google-analytics-for-wordpress'),
337
+			'TD' => __('Chad', 'google-analytics-for-wordpress'),
338
+			'CL' => __('Chile', 'google-analytics-for-wordpress'),
339
+			'CN' => __('China', 'google-analytics-for-wordpress'),
340
+			'CX' => __('Christmas Island', 'google-analytics-for-wordpress'),
341
+			'CC' => __('Cocos Islands', 'google-analytics-for-wordpress'),
342
+			'CO' => __('Colombia', 'google-analytics-for-wordpress'),
343
+			'KM' => __('Comoros', 'google-analytics-for-wordpress'),
344
+			'CD' => __('Congo, Democratic People\'s Republic', 'google-analytics-for-wordpress'),
345
+			'CG' => __('Congo, Republic of', 'google-analytics-for-wordpress'),
346
+			'CK' => __('Cook Islands', 'google-analytics-for-wordpress'),
347
+			'CR' => __('Costa Rica', 'google-analytics-for-wordpress'),
348
+			'CI' => __('Cote d\'Ivoire', 'google-analytics-for-wordpress'),
349
+			'HR' => __('Croatia/Hrvatska', 'google-analytics-for-wordpress'),
350
+			'CU' => __('Cuba', 'google-analytics-for-wordpress'),
351
+			'CW' => __('Cura&Ccedil;ao', 'google-analytics-for-wordpress'),
352
+			'CY' => __('Cyprus', 'google-analytics-for-wordpress'),
353
+			'CZ' => __('Czechia', 'google-analytics-for-wordpress'),
354
+			'DK' => __('Denmark', 'google-analytics-for-wordpress'),
355
+			'DJ' => __('Djibouti', 'google-analytics-for-wordpress'),
356
+			'DM' => __('Dominica', 'google-analytics-for-wordpress'),
357
+			'DO' => __('Dominican Republic', 'google-analytics-for-wordpress'),
358
+			'TP' => __('East Timor', 'google-analytics-for-wordpress'),
359
+			'EC' => __('Ecuador', 'google-analytics-for-wordpress'),
360
+			'EG' => __('Egypt', 'google-analytics-for-wordpress'),
361
+			'GQ' => __('Equatorial Guinea', 'google-analytics-for-wordpress'),
362
+			'SV' => __('El Salvador', 'google-analytics-for-wordpress'),
363
+			'ER' => __('Eritrea', 'google-analytics-for-wordpress'),
364
+			'EE' => __('Estonia', 'google-analytics-for-wordpress'),
365
+			'ET' => __('Ethiopia', 'google-analytics-for-wordpress'),
366
+			'FK' => __('Falkland Islands', 'google-analytics-for-wordpress'),
367
+			'FO' => __('Faroe Islands', 'google-analytics-for-wordpress'),
368
+			'FJ' => __('Fiji', 'google-analytics-for-wordpress'),
369
+			'FI' => __('Finland', 'google-analytics-for-wordpress'),
370
+			'FR' => __('France', 'google-analytics-for-wordpress'),
371
+			'GF' => __('French Guiana', 'google-analytics-for-wordpress'),
372
+			'PF' => __('French Polynesia', 'google-analytics-for-wordpress'),
373
+			'TF' => __('French Southern Territories', 'google-analytics-for-wordpress'),
374
+			'GA' => __('Gabon', 'google-analytics-for-wordpress'),
375
+			'GM' => __('Gambia', 'google-analytics-for-wordpress'),
376
+			'GE' => __('Georgia', 'google-analytics-for-wordpress'),
377
+			'DE' => __('Germany', 'google-analytics-for-wordpress'),
378
+			'GR' => __('Greece', 'google-analytics-for-wordpress'),
379
+			'GH' => __('Ghana', 'google-analytics-for-wordpress'),
380
+			'GI' => __('Gibraltar', 'google-analytics-for-wordpress'),
381
+			'GL' => __('Greenland', 'google-analytics-for-wordpress'),
382
+			'GD' => __('Grenada', 'google-analytics-for-wordpress'),
383
+			'GP' => __('Guadeloupe', 'google-analytics-for-wordpress'),
384
+			'GU' => __('Guam', 'google-analytics-for-wordpress'),
385
+			'GT' => __('Guatemala', 'google-analytics-for-wordpress'),
386
+			'GG' => __('Guernsey', 'google-analytics-for-wordpress'),
387
+			'GN' => __('Guinea', 'google-analytics-for-wordpress'),
388
+			'GW' => __('Guinea-Bissau', 'google-analytics-for-wordpress'),
389
+			'GY' => __('Guyana', 'google-analytics-for-wordpress'),
390
+			'HT' => __('Haiti', 'google-analytics-for-wordpress'),
391
+			'HM' => __('Heard and McDonald Islands', 'google-analytics-for-wordpress'),
392
+			'VA' => __('Holy See (City Vatican State)', 'google-analytics-for-wordpress'),
393
+			'HN' => __('Honduras', 'google-analytics-for-wordpress'),
394
+			'HK' => __('Hong Kong', 'google-analytics-for-wordpress'),
395
+			'HU' => __('Hungary', 'google-analytics-for-wordpress'),
396
+			'IS' => __('Iceland', 'google-analytics-for-wordpress'),
397
+			'IN' => __('India', 'google-analytics-for-wordpress'),
398
+			'ID' => __('Indonesia', 'google-analytics-for-wordpress'),
399
+			'IR' => __('Iran', 'google-analytics-for-wordpress'),
400
+			'IQ' => __('Iraq', 'google-analytics-for-wordpress'),
401
+			'IE' => __('Ireland', 'google-analytics-for-wordpress'),
402
+			'IM' => __('Isle of Man', 'google-analytics-for-wordpress'),
403
+			'IL' => __('Israel', 'google-analytics-for-wordpress'),
404
+			'IT' => __('Italy', 'google-analytics-for-wordpress'),
405
+			'JM' => __('Jamaica', 'google-analytics-for-wordpress'),
406
+			'JP' => __('Japan', 'google-analytics-for-wordpress'),
407
+			'JE' => __('Jersey', 'google-analytics-for-wordpress'),
408
+			'JO' => __('Jordan', 'google-analytics-for-wordpress'),
409
+			'KZ' => __('Kazakhstan', 'google-analytics-for-wordpress'),
410
+			'KE' => __('Kenya', 'google-analytics-for-wordpress'),
411
+			'KI' => __('Kiribati', 'google-analytics-for-wordpress'),
412
+			'KW' => __('Kuwait', 'google-analytics-for-wordpress'),
413
+			'KG' => __('Kyrgyzstan', 'google-analytics-for-wordpress'),
414
+			'LA' => __('Lao People\'s Democratic Republic', 'google-analytics-for-wordpress'),
415
+			'LV' => __('Latvia', 'google-analytics-for-wordpress'),
416
+			'LB' => __('Lebanon', 'google-analytics-for-wordpress'),
417
+			'LS' => __('Lesotho', 'google-analytics-for-wordpress'),
418
+			'LR' => __('Liberia', 'google-analytics-for-wordpress'),
419
+			'LY' => __('Libyan Arab Jamahiriya', 'google-analytics-for-wordpress'),
420
+			'LI' => __('Liechtenstein', 'google-analytics-for-wordpress'),
421
+			'LT' => __('Lithuania', 'google-analytics-for-wordpress'),
422
+			'LU' => __('Luxembourg', 'google-analytics-for-wordpress'),
423
+			'MO' => __('Macau', 'google-analytics-for-wordpress'),
424
+			'MK' => __('Macedonia', 'google-analytics-for-wordpress'),
425
+			'MG' => __('Madagascar', 'google-analytics-for-wordpress'),
426
+			'MW' => __('Malawi', 'google-analytics-for-wordpress'),
427
+			'MY' => __('Malaysia', 'google-analytics-for-wordpress'),
428
+			'MV' => __('Maldives', 'google-analytics-for-wordpress'),
429
+			'ML' => __('Mali', 'google-analytics-for-wordpress'),
430
+			'MT' => __('Malta', 'google-analytics-for-wordpress'),
431
+			'MH' => __('Marshall Islands', 'google-analytics-for-wordpress'),
432
+			'MQ' => __('Martinique', 'google-analytics-for-wordpress'),
433
+			'MR' => __('Mauritania', 'google-analytics-for-wordpress'),
434
+			'MU' => __('Mauritius', 'google-analytics-for-wordpress'),
435
+			'YT' => __('Mayotte', 'google-analytics-for-wordpress'),
436
+			'MX' => __('Mexico', 'google-analytics-for-wordpress'),
437
+			'FM' => __('Micronesia', 'google-analytics-for-wordpress'),
438
+			'MD' => __('Moldova, Republic of', 'google-analytics-for-wordpress'),
439
+			'MC' => __('Monaco', 'google-analytics-for-wordpress'),
440
+			'MN' => __('Mongolia', 'google-analytics-for-wordpress'),
441
+			'ME' => __('Montenegro', 'google-analytics-for-wordpress'),
442
+			'MS' => __('Montserrat', 'google-analytics-for-wordpress'),
443
+			'MA' => __('Morocco', 'google-analytics-for-wordpress'),
444
+			'MZ' => __('Mozambique', 'google-analytics-for-wordpress'),
445
+			'MM' => __('Myanmar', 'google-analytics-for-wordpress'),
446
+			'NA' => __('Namibia', 'google-analytics-for-wordpress'),
447
+			'NR' => __('Nauru', 'google-analytics-for-wordpress'),
448
+			'NP' => __('Nepal', 'google-analytics-for-wordpress'),
449
+			'NL' => __('Netherlands', 'google-analytics-for-wordpress'),
450
+			'AN' => __('Netherlands Antilles', 'google-analytics-for-wordpress'),
451
+			'NC' => __('New Caledonia', 'google-analytics-for-wordpress'),
452
+			'NZ' => __('New Zealand', 'google-analytics-for-wordpress'),
453
+			'NI' => __('Nicaragua', 'google-analytics-for-wordpress'),
454
+			'NE' => __('Niger', 'google-analytics-for-wordpress'),
455
+			'NG' => __('Nigeria', 'google-analytics-for-wordpress'),
456
+			'NU' => __('Niue', 'google-analytics-for-wordpress'),
457
+			'NF' => __('Norfolk Island', 'google-analytics-for-wordpress'),
458
+			'KP' => __('North Korea', 'google-analytics-for-wordpress'),
459
+			'MP' => __('Northern Mariana Islands', 'google-analytics-for-wordpress'),
460
+			'NO' => __('Norway', 'google-analytics-for-wordpress'),
461
+			'OM' => __('Oman', 'google-analytics-for-wordpress'),
462
+			'PK' => __('Pakistan', 'google-analytics-for-wordpress'),
463
+			'PW' => __('Palau', 'google-analytics-for-wordpress'),
464
+			'PS' => __('Palestinian Territories', 'google-analytics-for-wordpress'),
465
+			'PA' => __('Panama', 'google-analytics-for-wordpress'),
466
+			'PG' => __('Papua New Guinea', 'google-analytics-for-wordpress'),
467
+			'PY' => __('Paraguay', 'google-analytics-for-wordpress'),
468
+			'PE' => __('Peru', 'google-analytics-for-wordpress'),
469
+			'PH' => __('Philippines', 'google-analytics-for-wordpress'),
470
+			'PN' => __('Pitcairn Island', 'google-analytics-for-wordpress'),
471
+			'PL' => __('Poland', 'google-analytics-for-wordpress'),
472
+			'PT' => __('Portugal', 'google-analytics-for-wordpress'),
473
+			'PR' => __('Puerto Rico', 'google-analytics-for-wordpress'),
474
+			'QA' => __('Qatar', 'google-analytics-for-wordpress'),
475
+			'XK' => __('Republic of Kosovo', 'google-analytics-for-wordpress'),
476
+			'RE' => __('Reunion Island', 'google-analytics-for-wordpress'),
477
+			'RO' => __('Romania', 'google-analytics-for-wordpress'),
478
+			'RU' => __('Russian Federation', 'google-analytics-for-wordpress'),
479
+			'RW' => __('Rwanda', 'google-analytics-for-wordpress'),
480
+			'BL' => __('Saint Barth&eacute;lemy', 'google-analytics-for-wordpress'),
481
+			'SH' => __('Saint Helena', 'google-analytics-for-wordpress'),
482
+			'KN' => __('Saint Kitts and Nevis', 'google-analytics-for-wordpress'),
483
+			'LC' => __('Saint Lucia', 'google-analytics-for-wordpress'),
484
+			'MF' => __('Saint Martin (French)', 'google-analytics-for-wordpress'),
485
+			'SX' => __('Saint Martin (Dutch)', 'google-analytics-for-wordpress'),
486
+			'PM' => __('Saint Pierre and Miquelon', 'google-analytics-for-wordpress'),
487
+			'VC' => __('Saint Vincent and the Grenadines', 'google-analytics-for-wordpress'),
488
+			'SM' => __('San Marino', 'google-analytics-for-wordpress'),
489
+			'ST' => __('S&atilde;o Tom&eacute; and Pr&iacute;ncipe', 'google-analytics-for-wordpress'),
490
+			'SA' => __('Saudi Arabia', 'google-analytics-for-wordpress'),
491
+			'SN' => __('Senegal', 'google-analytics-for-wordpress'),
492
+			'RS' => __('Serbia', 'google-analytics-for-wordpress'),
493
+			'SC' => __('Seychelles', 'google-analytics-for-wordpress'),
494
+			'SL' => __('Sierra Leone', 'google-analytics-for-wordpress'),
495
+			'SG' => __('Singapore', 'google-analytics-for-wordpress'),
496
+			'SK' => __('Slovak Republic', 'google-analytics-for-wordpress'),
497
+			'SI' => __('Slovenia', 'google-analytics-for-wordpress'),
498
+			'SB' => __('Solomon Islands', 'google-analytics-for-wordpress'),
499
+			'SO' => __('Somalia', 'google-analytics-for-wordpress'),
500
+			'ZA' => __('South Africa', 'google-analytics-for-wordpress'),
501
+			'GS' => __('South Georgia', 'google-analytics-for-wordpress'),
502
+			'KR' => __('South Korea', 'google-analytics-for-wordpress'),
503
+			'SS' => __('South Sudan', 'google-analytics-for-wordpress'),
504
+			'ES' => __('Spain', 'google-analytics-for-wordpress'),
505
+			'LK' => __('Sri Lanka', 'google-analytics-for-wordpress'),
506
+			'SD' => __('Sudan', 'google-analytics-for-wordpress'),
507
+			'SR' => __('Suriname', 'google-analytics-for-wordpress'),
508
+			'SJ' => __('Svalbard and Jan Mayen Islands', 'google-analytics-for-wordpress'),
509
+			'SZ' => __('Swaziland', 'google-analytics-for-wordpress'),
510
+			'SE' => __('Sweden', 'google-analytics-for-wordpress'),
511
+			'CH' => __('Switzerland', 'google-analytics-for-wordpress'),
512
+			'SY' => __('Syrian Arab Republic', 'google-analytics-for-wordpress'),
513
+			'TW' => __('Taiwan', 'google-analytics-for-wordpress'),
514
+			'TJ' => __('Tajikistan', 'google-analytics-for-wordpress'),
515
+			'TZ' => __('Tanzania', 'google-analytics-for-wordpress'),
516
+			'TH' => __('Thailand', 'google-analytics-for-wordpress'),
517
+			'TL' => __('Timor-Leste', 'google-analytics-for-wordpress'),
518
+			'TG' => __('Togo', 'google-analytics-for-wordpress'),
519
+			'TK' => __('Tokelau', 'google-analytics-for-wordpress'),
520
+			'TO' => __('Tonga', 'google-analytics-for-wordpress'),
521
+			'TT' => __('Trinidad and Tobago', 'google-analytics-for-wordpress'),
522
+			'TN' => __('Tunisia', 'google-analytics-for-wordpress'),
523
+			'TR' => __('Turkey', 'google-analytics-for-wordpress'),
524
+			'TM' => __('Turkmenistan', 'google-analytics-for-wordpress'),
525
+			'TC' => __('Turks and Caicos Islands', 'google-analytics-for-wordpress'),
526
+			'TV' => __('Tuvalu', 'google-analytics-for-wordpress'),
527
+			'UG' => __('Uganda', 'google-analytics-for-wordpress'),
528
+			'UA' => __('Ukraine', 'google-analytics-for-wordpress'),
529
+			'AE' => __('United Arab Emirates', 'google-analytics-for-wordpress'),
530
+			'UY' => __('Uruguay', 'google-analytics-for-wordpress'),
531
+			'UM' => __('US Minor Outlying Islands', 'google-analytics-for-wordpress'),
532
+			'UZ' => __('Uzbekistan', 'google-analytics-for-wordpress'),
533
+			'VU' => __('Vanuatu', 'google-analytics-for-wordpress'),
534
+			'VE' => __('Venezuela', 'google-analytics-for-wordpress'),
535
+			'VN' => __('Vietnam', 'google-analytics-for-wordpress'),
536
+			'VG' => __('Virgin Islands (British)', 'google-analytics-for-wordpress'),
537
+			'VI' => __('Virgin Islands (USA)', 'google-analytics-for-wordpress'),
538
+			'WF' => __('Wallis and Futuna Islands', 'google-analytics-for-wordpress'),
539
+			'EH' => __('Western Sahara', 'google-analytics-for-wordpress'),
540
+			'WS' => __('Western Samoa', 'google-analytics-for-wordpress'),
541
+			'YE' => __('Yemen', 'google-analytics-for-wordpress'),
542
+			'ZM' => __('Zambia', 'google-analytics-for-wordpress'),
543
+			'ZW' => __('Zimbabwe', 'google-analytics-for-wordpress'),
544 544
 		);
545 545
 	} else {
546 546
 		$countries = array(
@@ -806,15 +806,15 @@  discard block
 block discarded – undo
806 806
 	$wp_seo_active = false; // @todo: improve this check. This is from old Yoast code.
807 807
 	
808 808
 	// Makes sure is_plugin_active is available when called from front end
809
-	include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
810
-	if ( is_plugin_active( 'wordpress-seo/wp-seo.php' ) || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' ) ) {
809
+	include_once(ABSPATH . 'wp-admin/includes/plugin.php');
810
+	if (is_plugin_active('wordpress-seo/wp-seo.php') || is_plugin_active('wordpress-seo-premium/wp-seo-premium.php')) {
811 811
 		$wp_seo_active = true;
812 812
 	}
813 813
 	return $wp_seo_active;
814 814
 }
815 815
 
816 816
 function monsterinsights_get_asset_version() {
817
-	if ( monsterinsights_is_debug_mode() ) {
817
+	if (monsterinsights_is_debug_mode()) {
818 818
 		return time();
819 819
 	} else {
820 820
 		return MONSTERINSIGHTS_VERSION;
@@ -823,30 +823,30 @@  discard block
 block discarded – undo
823 823
 
824 824
 function monsterinsights_is_debug_mode() {
825 825
 	$debug_mode = false;
826
-	if ( defined( 'MONSTERINSIGHTS_DEBUG_MODE' ) && MONSTERINSIGHTS_DEBUG_MODE ) {
826
+	if (defined('MONSTERINSIGHTS_DEBUG_MODE') && MONSTERINSIGHTS_DEBUG_MODE) {
827 827
 		$debug_mode = true;
828 828
 	}
829 829
 	
830
-	if ( monsterinsights_get_option( 'debug_mode', false ) ) {
830
+	if (monsterinsights_get_option('debug_mode', false)) {
831 831
 		$debug_mode = true;
832 832
 	}
833 833
 	
834
-	return apply_filters( 'monsterinsights_is_debug_mode', $debug_mode );
834
+	return apply_filters('monsterinsights_is_debug_mode', $debug_mode);
835 835
 }
836 836
 
837 837
 function monsterinsights_is_network_active() {
838
-	if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
839
-		require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
838
+	if ( ! function_exists('is_plugin_active_for_network')) {
839
+		require_once(ABSPATH . '/wp-admin/includes/plugin.php');
840 840
 	}
841 841
 	 
842
-	if ( is_multisite() && is_plugin_active_for_network( plugin_basename( MONSTERINSIGHTS_PLUGIN_FILE ) ) ) {
842
+	if (is_multisite() && is_plugin_active_for_network(plugin_basename(MONSTERINSIGHTS_PLUGIN_FILE))) {
843 843
 	   return true;
844 844
 	} else {
845 845
 		return false;
846 846
 	}
847 847
 }
848 848
 
849
-if ( ! function_exists ( 'remove_class_filter' ) ) {
849
+if ( ! function_exists('remove_class_filter')) {
850 850
 	/**
851 851
 	 * Remove Class Filter Without Access to Class Object
852 852
 	 *
@@ -864,10 +864,10 @@  discard block
 block discarded – undo
864 864
 	 *
865 865
 	 * @return bool Whether the function is removed.
866 866
 	 */
867
-	function remove_class_filter( $tag, $class_name = '', $method_name = '', $priority = 10 ) {
867
+	function remove_class_filter($tag, $class_name = '', $method_name = '', $priority = 10) {
868 868
 		global $wp_filter;
869 869
 		// Check that filter actually exists first
870
-		if ( ! isset( $wp_filter[ $tag ] ) ) return FALSE;
870
+		if ( ! isset($wp_filter[$tag])) return FALSE;
871 871
 		/**
872 872
 		 * If filter config is an object, means we're using WordPress 4.7+ and the config is no longer
873 873
 		 * a simple array, rather it is an object that implements the ArrayAccess interface.
@@ -876,33 +876,33 @@  discard block
 block discarded – undo
876 876
 		 *
877 877
 		 * @see https://make.wordpress.org/core/2016/09/08/wp_hook-next-generation-actions-and-filters/
878 878
 		 */
879
-		if ( is_object( $wp_filter[ $tag ] ) && isset( $wp_filter[ $tag ]->callbacks ) ) {
880
-			$callbacks = &$wp_filter[ $tag ]->callbacks;
879
+		if (is_object($wp_filter[$tag]) && isset($wp_filter[$tag]->callbacks)) {
880
+			$callbacks = &$wp_filter[$tag]->callbacks;
881 881
 		} else {
882
-			$callbacks = &$wp_filter[ $tag ];
882
+			$callbacks = &$wp_filter[$tag];
883 883
 		}
884 884
 		// Exit if there aren't any callbacks for specified priority
885
-		if ( ! isset( $callbacks[ $priority ] ) || empty( $callbacks[ $priority ] ) ) return FALSE;
885
+		if ( ! isset($callbacks[$priority]) || empty($callbacks[$priority])) return FALSE;
886 886
 		// Loop through each filter for the specified priority, looking for our class & method
887
-		foreach( (array) $callbacks[ $priority ] as $filter_id => $filter ) {
887
+		foreach ((array) $callbacks[$priority] as $filter_id => $filter) {
888 888
 			// Filter should always be an array - array( $this, 'method' ), if not goto next
889
-			if ( ! isset( $filter[ 'function' ] ) || ! is_array( $filter[ 'function' ] ) ) continue;
889
+			if ( ! isset($filter['function']) || ! is_array($filter['function'])) continue;
890 890
 			// If first value in array is not an object, it can't be a class
891
-			if ( ! is_object( $filter[ 'function' ][ 0 ] ) ) continue;
891
+			if ( ! is_object($filter['function'][0])) continue;
892 892
 			// Method doesn't match the one we're looking for, goto next
893
-			if ( $filter[ 'function' ][ 1 ] !== $method_name ) continue;
893
+			if ($filter['function'][1] !== $method_name) continue;
894 894
 			// Method matched, now let's check the Class
895
-			if ( get_class( $filter[ 'function' ][ 0 ] ) === $class_name ) {
895
+			if (get_class($filter['function'][0]) === $class_name) {
896 896
 				// Now let's remove it from the array
897
-				unset( $callbacks[ $priority ][ $filter_id ] );
897
+				unset($callbacks[$priority][$filter_id]);
898 898
 				// and if it was the only filter in that priority, unset that priority
899
-				if ( empty( $callbacks[ $priority ] ) ) unset( $callbacks[ $priority ] );
899
+				if (empty($callbacks[$priority])) unset($callbacks[$priority]);
900 900
 				// and if the only filter for that tag, set the tag to an empty array
901
-				if ( empty( $callbacks ) ) $callbacks = array();
901
+				if (empty($callbacks)) $callbacks = array();
902 902
 				// If using WordPress older than 4.7
903
-				if ( ! is_object( $wp_filter[ $tag ] ) ) {
903
+				if ( ! is_object($wp_filter[$tag])) {
904 904
 					// Remove this filter from merged_filters, which specifies if filters have been sorted
905
-					unset( $GLOBALS[ 'merged_filters' ][ $tag ] );
905
+					unset($GLOBALS['merged_filters'][$tag]);
906 906
 				}
907 907
 				return TRUE;
908 908
 			}
@@ -911,7 +911,7 @@  discard block
 block discarded – undo
911 911
 	}
912 912
 } // End function exists
913 913
 
914
-if ( ! function_exists ( 'remove_class_action' ) ) {
914
+if ( ! function_exists('remove_class_action')) {
915 915
 	/**
916 916
 	 * Remove Class Action Without Access to Class Object
917 917
 	 *
@@ -929,7 +929,7 @@  discard block
 block discarded – undo
929 929
 	 *
930 930
 	 * @return bool               Whether the function is removed.
931 931
 	 */
932
-	function remove_class_action( $tag, $class_name = '', $method_name = '', $priority = 10 ) {
933
-		remove_class_filter( $tag, $class_name, $method_name, $priority );
932
+	function remove_class_action($tag, $class_name = '', $method_name = '', $priority = 10) {
933
+		remove_class_filter($tag, $class_name, $method_name, $priority);
934 934
 	}
935 935
 } // End function exists
936 936
\ No newline at end of file
Please login to merge, or discard this patch.
Indentation   +763 added lines, -763 removed lines patch added patch discarded remove patch
@@ -11,68 +11,68 @@  discard block
 block discarded – undo
11 11
 
12 12
 // Exit if accessed directly
13 13
 if ( ! defined( 'ABSPATH' ) ) {
14
-	exit;
14
+    exit;
15 15
 }
16 16
 
17 17
 function monsterinsights_debug_output( $var ) {
18
-	error_log( print_r( $var, true ) . "\n", 3, MONSTERINSIGHTS_PLUGIN_DIR . 'log.txt' );
18
+    error_log( print_r( $var, true ) . "\n", 3, MONSTERINSIGHTS_PLUGIN_DIR . 'log.txt' );
19 19
 }
20 20
 
21 21
 function monsterinsights_is_page_reload() {
22
-	// Can't be a refresh without having a referrer
23
-	if ( ! isset( $_SERVER['HTTP_REFERER'] ) ) {
24
-		return false;
25
-	}
22
+    // Can't be a refresh without having a referrer
23
+    if ( ! isset( $_SERVER['HTTP_REFERER'] ) ) {
24
+        return false;
25
+    }
26 26
 
27
-	// IF the referrer is identical to the current page request, then it's a refresh
28
-	return ( parse_url( $_SERVER['HTTP_REFERER'], PHP_URL_PATH ) === parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH ) );
27
+    // IF the referrer is identical to the current page request, then it's a refresh
28
+    return ( parse_url( $_SERVER['HTTP_REFERER'], PHP_URL_PATH ) === parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH ) );
29 29
 }
30 30
 
31 31
 
32 32
 function monsterinsights_track_user() {
33
-	$user        = wp_get_current_user();
34
-	$track_user  = true;
35
-	$roles     = monsterinsights_get_option( 'ignore_users', array() );
36
-
37
-	if ( ! empty( $roles ) && is_array( $roles ) ) {
38
-		foreach ( $roles as $role ) {
39
-			if ( is_string( $role ) ) {
40
-				if ( current_user_can( $role ) ) {
41
-					$track_user = false;
42
-					break;
43
-				}
44
-			}
45
-		}
46
-	}
47
-
48
-	$track_super_admin = apply_filters( 'monsterinsights_track_super_admins', false );
49
-	if ( $track_super_admin === false && is_super_admin() ) {
50
-		$track_user = false;
51
-	}
33
+    $user        = wp_get_current_user();
34
+    $track_user  = true;
35
+    $roles     = monsterinsights_get_option( 'ignore_users', array() );
36
+
37
+    if ( ! empty( $roles ) && is_array( $roles ) ) {
38
+        foreach ( $roles as $role ) {
39
+            if ( is_string( $role ) ) {
40
+                if ( current_user_can( $role ) ) {
41
+                    $track_user = false;
42
+                    break;
43
+                }
44
+            }
45
+        }
46
+    }
47
+
48
+    $track_super_admin = apply_filters( 'monsterinsights_track_super_admins', false );
49
+    if ( $track_super_admin === false && is_super_admin() ) {
50
+        $track_user = false;
51
+    }
52 52
 	
53
-	// or if UA code is not entered
54
-	$ua_code = monsterinsights_get_ua();
55
-	if ( empty( $ua_code ) ) {
56
-		$track_user = false;
57
-	}
53
+    // or if UA code is not entered
54
+    $ua_code = monsterinsights_get_ua();
55
+    if ( empty( $ua_code ) ) {
56
+        $track_user = false;
57
+    }
58 58
 
59
-	return apply_filters( 'monsterinsights_track_user', $track_user, $user );
59
+    return apply_filters( 'monsterinsights_track_user', $track_user, $user );
60 60
 }
61 61
 
62 62
 function monsterinsights_get_client_id( $payment_id = false ) {
63
-	if ( is_object( $payment_id ) ) {
64
-		$payment_id = $payment_id->ID;
65
-	}
66
-	$user_cid    = monsterinsights_get_uuid();
67
-	$payment_cid = get_post_meta( $payment_id, '_yoast_gau_uuid', true );
68
-
69
-	if ( ! empty( $payment_id ) && ! empty( $saved_cid ) ) {
70
-		return $saved_cid;
71
-	} else if ( ! empty( $user_cid ) ) {
72
-		return $user_cid;
73
-	} else {
74
-		return monsterinsights_generate_uuid();
75
-	}
63
+    if ( is_object( $payment_id ) ) {
64
+        $payment_id = $payment_id->ID;
65
+    }
66
+    $user_cid    = monsterinsights_get_uuid();
67
+    $payment_cid = get_post_meta( $payment_id, '_yoast_gau_uuid', true );
68
+
69
+    if ( ! empty( $payment_id ) && ! empty( $saved_cid ) ) {
70
+        return $saved_cid;
71
+    } else if ( ! empty( $user_cid ) ) {
72
+        return $user_cid;
73
+    } else {
74
+        return monsterinsights_generate_uuid();
75
+    }
76 76
 }
77 77
 
78 78
 /**
@@ -85,30 +85,30 @@  discard block
 block discarded – undo
85 85
  * @return bool|string False if cookie isn't set, GA UUID otherwise
86 86
  */
87 87
 function monsterinsights_get_uuid() {
88
-	if ( empty( $_COOKIE['_ga'] ) ) {
89
-		return false;
90
-	}
88
+    if ( empty( $_COOKIE['_ga'] ) ) {
89
+        return false;
90
+    }
91 91
 	
92
-	/** 
93
-	 * Example cookie formats:
94
-	 *
95
-	 * GA1.2.XXXXXXX.YYYYY
96
-	 * _ga=1.2.XXXXXXX.YYYYYY -- We want the XXXXXXX.YYYYYY part
97
-	 * 
98
-	 */
99
-
100
-	$ga_cookie    = $_COOKIE['_ga'];
101
-	$cookie_parts = explode('.', $ga_cookie );
102
-	if ( is_array( $cookie_parts ) && ! empty( $cookie_parts[2] ) && ! empty( $cookie_parts[3] ) ) {
103
-		$uuid = (string) $cookie_parts[2] . '.' . (string) $cookie_parts[3];
104
-		if ( is_string( $uuid ) ) {
105
-			return $uuid;
106
-		} else {
107
-			return false;
108
-		}
109
-	} else {
110
-		return false;
111
-	}
92
+    /** 
93
+     * Example cookie formats:
94
+     *
95
+     * GA1.2.XXXXXXX.YYYYY
96
+     * _ga=1.2.XXXXXXX.YYYYYY -- We want the XXXXXXX.YYYYYY part
97
+     * 
98
+     */
99
+
100
+    $ga_cookie    = $_COOKIE['_ga'];
101
+    $cookie_parts = explode('.', $ga_cookie );
102
+    if ( is_array( $cookie_parts ) && ! empty( $cookie_parts[2] ) && ! empty( $cookie_parts[3] ) ) {
103
+        $uuid = (string) $cookie_parts[2] . '.' . (string) $cookie_parts[3];
104
+        if ( is_string( $uuid ) ) {
105
+            return $uuid;
106
+        } else {
107
+            return false;
108
+        }
109
+    } else {
110
+        return false;
111
+    }
112 112
 }
113 113
 
114 114
 
@@ -122,26 +122,26 @@  discard block
 block discarded – undo
122 122
  */
123 123
 function monsterinsights_generate_uuid() {
124 124
 
125
-	return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
125
+    return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
126 126
 
127
-		// 32 bits for "time_low"
128
-		mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
127
+        // 32 bits for "time_low"
128
+        mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
129 129
 
130
-		// 16 bits for "time_mid"
131
-		mt_rand( 0, 0xffff ),
130
+        // 16 bits for "time_mid"
131
+        mt_rand( 0, 0xffff ),
132 132
 
133
-		// 16 bits for "time_hi_and_version",
134
-		// four most significant bits holds version number 4
135
-		mt_rand( 0, 0x0fff ) | 0x4000,
133
+        // 16 bits for "time_hi_and_version",
134
+        // four most significant bits holds version number 4
135
+        mt_rand( 0, 0x0fff ) | 0x4000,
136 136
 
137
-		// 16 bits, 8 bits for "clk_seq_hi_res",
138
-		// 8 bits for "clk_seq_low",
139
-		// two most significant bits holds zero and one for variant DCE1.1
140
-		mt_rand( 0, 0x3fff ) | 0x8000,
137
+        // 16 bits, 8 bits for "clk_seq_hi_res",
138
+        // 8 bits for "clk_seq_low",
139
+        // two most significant bits holds zero and one for variant DCE1.1
140
+        mt_rand( 0, 0x3fff ) | 0x8000,
141 141
 
142
-		// 48 bits for "node"
143
-		mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff )
144
-	);
142
+        // 48 bits for "node"
143
+        mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff )
144
+    );
145 145
 }
146 146
 
147 147
 /**
@@ -152,27 +152,27 @@  discard block
 block discarded – undo
152 152
  * @return GA UUID or error code.
153 153
  */
154 154
 function monsterinsights_get_cookie( $debug = false ) {
155
-	if ( empty( $_COOKIE['_ga'] ) ) {
156
-		return ( $debug ) ? 'FCE' : false;
157
-	}
155
+    if ( empty( $_COOKIE['_ga'] ) ) {
156
+        return ( $debug ) ? 'FCE' : false;
157
+    }
158 158
 	
159
-	$ga_cookie    = $_COOKIE['_ga'];
160
-	$cookie_parts = explode('.', $ga_cookie );
161
-	if ( is_array( $cookie_parts ) && ! empty( $cookie_parts[2] ) && ! empty( $cookie_parts[3] ) ) {
162
-		$uuid = (string) $cookie_parts[2] . '.' . (string) $cookie_parts[3];
163
-		if ( is_string( $uuid ) ) {
164
-			return $ga_cookie;
165
-		} else {
166
-			return ( $debug ) ? 'FA' : false;
167
-		}
168
-	} else {
169
-		return ( $debug ) ? 'FAE' : false;
170
-	}
159
+    $ga_cookie    = $_COOKIE['_ga'];
160
+    $cookie_parts = explode('.', $ga_cookie );
161
+    if ( is_array( $cookie_parts ) && ! empty( $cookie_parts[2] ) && ! empty( $cookie_parts[3] ) ) {
162
+        $uuid = (string) $cookie_parts[2] . '.' . (string) $cookie_parts[3];
163
+        if ( is_string( $uuid ) ) {
164
+            return $ga_cookie;
165
+        } else {
166
+            return ( $debug ) ? 'FA' : false;
167
+        }
168
+    } else {
169
+        return ( $debug ) ? 'FAE' : false;
170
+    }
171 171
 }
172 172
 
173 173
 
174 174
 function monsterinsights_generate_ga_client_id() {
175
-	return rand(100000000,999999999) . '.' . time();
175
+    return rand(100000000,999999999) . '.' . time();
176 176
 }
177 177
  
178 178
 
@@ -188,13 +188,13 @@  discard block
 block discarded – undo
188 188
  * @return int Hours between the two timestamps, rounded.
189 189
  */
190 190
 function monsterinsights_hours_between( $start, $stop = false ) {
191
-	if ( $stop === false ) {
192
-		$stop = time();
193
-	}
191
+    if ( $stop === false ) {
192
+        $stop = time();
193
+    }
194 194
 
195
-	$diff = (int) abs( $stop -  $start );
196
-	$hours = round( $diff / HOUR_IN_SECONDS );
197
-	return $hours;
195
+    $diff = (int) abs( $stop -  $start );
196
+    $hours = round( $diff / HOUR_IN_SECONDS );
197
+    return $hours;
198 198
 }
199 199
 
200 200
 /**
@@ -223,11 +223,11 @@  discard block
 block discarded – undo
223 223
  * @return bool True if pro version.
224 224
  */
225 225
 function monsterinsights_is_pro_version() {
226
-	if ( class_exists( 'MonsterInsights' ) ) {
227
-		return true;
228
-	} else {
229
-		return false;
230
-	}
226
+    if ( class_exists( 'MonsterInsights' ) ) {
227
+        return true;
228
+    } else {
229
+        return false;
230
+    }
231 231
 }
232 232
 
233 233
 
@@ -237,699 +237,699 @@  discard block
 block discarded – undo
237 237
  * @return array
238 238
  */
239 239
 function monsterinsights_get_roles() {
240
-	global $wp_roles;
240
+    global $wp_roles;
241 241
 
242
-	$all_roles = $wp_roles->roles;
243
-	$roles     = array();
242
+    $all_roles = $wp_roles->roles;
243
+    $roles     = array();
244 244
 
245
-	/**
246
-	 * Filter: 'editable_roles' - Allows filtering of the roles shown within the plugin (and elsewhere in WP as it's a WP filter)
247
-	 *
248
-	 * @api array $all_roles
249
-	 */
250
-	$editable_roles = apply_filters( 'editable_roles', $all_roles );
245
+    /**
246
+     * Filter: 'editable_roles' - Allows filtering of the roles shown within the plugin (and elsewhere in WP as it's a WP filter)
247
+     *
248
+     * @api array $all_roles
249
+     */
250
+    $editable_roles = apply_filters( 'editable_roles', $all_roles );
251 251
 
252
-	foreach ( $editable_roles as $id => $name ) {
253
-		$roles[ $id ] = translate_user_role( $name['name'] );
254
-	}
252
+    foreach ( $editable_roles as $id => $name ) {
253
+        $roles[ $id ] = translate_user_role( $name['name'] );
254
+    }
255 255
 
256
-	return $roles;
256
+    return $roles;
257 257
 }
258 258
 
259 259
 /** Need to escape in advance of passing in $text. */
260 260
 function monsterinsights_get_message( $type = 'error', $text = '' ) {
261
-	$div = '';
262
-	if ( $type === 'error' || $type === 'alert' || $type === 'success' || $type === 'info' ) {
263
-		$base = MonsterInsights();
264
-		return $base->notices->display_inline_notice( 'monsterinsights_standard_notice', '', $text, $type, false, array( 'skip_message_escape' => true ) );
265
-	} else {
266
-		return '';
267
-	}
261
+    $div = '';
262
+    if ( $type === 'error' || $type === 'alert' || $type === 'success' || $type === 'info' ) {
263
+        $base = MonsterInsights();
264
+        return $base->notices->display_inline_notice( 'monsterinsights_standard_notice', '', $text, $type, false, array( 'skip_message_escape' => true ) );
265
+    } else {
266
+        return '';
267
+    }
268 268
 }
269 269
 
270 270
 // Set cookie to expire in 2 years
271 271
 function monsterinsights_get_cookie_expiration_date( $time ) {
272
-	return date('D, j F Y H:i:s', time() + $time );
272
+    return date('D, j F Y H:i:s', time() + $time );
273 273
 }
274 274
 
275 275
 function monsterinsights_string_ends_with( $string, $ending ) {
276
-	$strlen = strlen($string);
277
-	$endinglen = strlen($ending);
278
-	if ( $endinglen > $strlen ) {
279
-		return false;
280
-	}
281
-	return substr_compare( $string, $ending, $strlen - $endinglen, $endinglen) === 0;
276
+    $strlen = strlen($string);
277
+    $endinglen = strlen($ending);
278
+    if ( $endinglen > $strlen ) {
279
+        return false;
280
+    }
281
+    return substr_compare( $string, $ending, $strlen - $endinglen, $endinglen) === 0;
282 282
 }
283 283
 
284 284
 function monsterinsights_string_starts_with( $string, $start ) {
285
-	return substr( $string, 0, strlen( $start ) ) === $start;
285
+    return substr( $string, 0, strlen( $start ) ) === $start;
286 286
 }
287 287
 
288 288
 function monsterinsights_get_country_list( $translated = false ) {
289
-	if ( $translated ) {
290
-		$countries = array(
291
-			''   => '',
292
-			'US' => __( 'United States', 'google-analytics-for-wordpress' ),
293
-			'CA' => __( 'Canada', 'google-analytics-for-wordpress' ),
294
-			'GB' => __( 'United Kingdom', 'google-analytics-for-wordpress' ),
295
-			'AF' => __( 'Afghanistan', 'google-analytics-for-wordpress' ),
296
-			'AX' => __( '&#197;land Islands', 'google-analytics-for-wordpress' ),
297
-			'AL' => __( 'Albania', 'google-analytics-for-wordpress' ),
298
-			'DZ' => __( 'Algeria', 'google-analytics-for-wordpress' ),
299
-			'AS' => __( 'American Samoa', 'google-analytics-for-wordpress' ),
300
-			'AD' => __( 'Andorra', 'google-analytics-for-wordpress' ),
301
-			'AO' => __( 'Angola', 'google-analytics-for-wordpress' ),
302
-			'AI' => __( 'Anguilla', 'google-analytics-for-wordpress' ),
303
-			'AQ' => __( 'Antarctica', 'google-analytics-for-wordpress' ),
304
-			'AG' => __( 'Antigua and Barbuda', 'google-analytics-for-wordpress' ),
305
-			'AR' => __( 'Argentina', 'google-analytics-for-wordpress' ),
306
-			'AM' => __( 'Armenia', 'google-analytics-for-wordpress' ),
307
-			'AW' => __( 'Aruba', 'google-analytics-for-wordpress' ),
308
-			'AU' => __( 'Australia', 'google-analytics-for-wordpress' ),
309
-			'AT' => __( 'Austria', 'google-analytics-for-wordpress' ),
310
-			'AZ' => __( 'Azerbaijan', 'google-analytics-for-wordpress' ),
311
-			'BS' => __( 'Bahamas', 'google-analytics-for-wordpress' ),
312
-			'BH' => __( 'Bahrain', 'google-analytics-for-wordpress' ),
313
-			'BD' => __( 'Bangladesh', 'google-analytics-for-wordpress' ),
314
-			'BB' => __( 'Barbados', 'google-analytics-for-wordpress' ),
315
-			'BY' => __( 'Belarus', 'google-analytics-for-wordpress' ),
316
-			'BE' => __( 'Belgium', 'google-analytics-for-wordpress' ),
317
-			'BZ' => __( 'Belize', 'google-analytics-for-wordpress' ),
318
-			'BJ' => __( 'Benin', 'google-analytics-for-wordpress' ),
319
-			'BM' => __( 'Bermuda', 'google-analytics-for-wordpress' ),
320
-			'BT' => __( 'Bhutan', 'google-analytics-for-wordpress' ),
321
-			'BO' => __( 'Bolivia', 'google-analytics-for-wordpress' ),
322
-			'BQ' => __( 'Bonaire, Saint Eustatius and Saba', 'google-analytics-for-wordpress' ),
323
-			'BA' => __( 'Bosnia and Herzegovina', 'google-analytics-for-wordpress' ),
324
-			'BW' => __( 'Botswana', 'google-analytics-for-wordpress' ),
325
-			'BV' => __( 'Bouvet Island', 'google-analytics-for-wordpress' ),
326
-			'BR' => __( 'Brazil', 'google-analytics-for-wordpress' ),
327
-			'IO' => __( 'British Indian Ocean Territory', 'google-analytics-for-wordpress' ),
328
-			'BN' => __( 'Brunei Darrussalam', 'google-analytics-for-wordpress' ),
329
-			'BG' => __( 'Bulgaria', 'google-analytics-for-wordpress' ),
330
-			'BF' => __( 'Burkina Faso', 'google-analytics-for-wordpress' ),
331
-			'BI' => __( 'Burundi', 'google-analytics-for-wordpress' ),
332
-			'KH' => __( 'Cambodia', 'google-analytics-for-wordpress' ),
333
-			'CM' => __( 'Cameroon', 'google-analytics-for-wordpress' ),
334
-			'CV' => __( 'Cape Verde', 'google-analytics-for-wordpress' ),
335
-			'KY' => __( 'Cayman Islands', 'google-analytics-for-wordpress' ),
336
-			'CF' => __( 'Central African Republic', 'google-analytics-for-wordpress' ),
337
-			'TD' => __( 'Chad', 'google-analytics-for-wordpress' ),
338
-			'CL' => __( 'Chile', 'google-analytics-for-wordpress' ),
339
-			'CN' => __( 'China', 'google-analytics-for-wordpress' ),
340
-			'CX' => __( 'Christmas Island', 'google-analytics-for-wordpress' ),
341
-			'CC' => __( 'Cocos Islands', 'google-analytics-for-wordpress' ),
342
-			'CO' => __( 'Colombia', 'google-analytics-for-wordpress' ),
343
-			'KM' => __( 'Comoros', 'google-analytics-for-wordpress' ),
344
-			'CD' => __( 'Congo, Democratic People\'s Republic', 'google-analytics-for-wordpress' ),
345
-			'CG' => __( 'Congo, Republic of', 'google-analytics-for-wordpress' ),
346
-			'CK' => __( 'Cook Islands', 'google-analytics-for-wordpress' ),
347
-			'CR' => __( 'Costa Rica', 'google-analytics-for-wordpress' ),
348
-			'CI' => __( 'Cote d\'Ivoire', 'google-analytics-for-wordpress' ),
349
-			'HR' => __( 'Croatia/Hrvatska', 'google-analytics-for-wordpress' ),
350
-			'CU' => __( 'Cuba', 'google-analytics-for-wordpress' ),
351
-			'CW' => __( 'Cura&Ccedil;ao', 'google-analytics-for-wordpress' ),
352
-			'CY' => __( 'Cyprus', 'google-analytics-for-wordpress' ),
353
-			'CZ' => __( 'Czechia', 'google-analytics-for-wordpress' ),
354
-			'DK' => __( 'Denmark', 'google-analytics-for-wordpress' ),
355
-			'DJ' => __( 'Djibouti', 'google-analytics-for-wordpress' ),
356
-			'DM' => __( 'Dominica', 'google-analytics-for-wordpress' ),
357
-			'DO' => __( 'Dominican Republic', 'google-analytics-for-wordpress' ),
358
-			'TP' => __( 'East Timor', 'google-analytics-for-wordpress' ),
359
-			'EC' => __( 'Ecuador', 'google-analytics-for-wordpress' ),
360
-			'EG' => __( 'Egypt', 'google-analytics-for-wordpress' ),
361
-			'GQ' => __( 'Equatorial Guinea', 'google-analytics-for-wordpress' ),
362
-			'SV' => __( 'El Salvador', 'google-analytics-for-wordpress' ),
363
-			'ER' => __( 'Eritrea', 'google-analytics-for-wordpress' ),
364
-			'EE' => __( 'Estonia', 'google-analytics-for-wordpress' ),
365
-			'ET' => __( 'Ethiopia', 'google-analytics-for-wordpress' ),
366
-			'FK' => __( 'Falkland Islands', 'google-analytics-for-wordpress' ),
367
-			'FO' => __( 'Faroe Islands', 'google-analytics-for-wordpress' ),
368
-			'FJ' => __( 'Fiji', 'google-analytics-for-wordpress' ),
369
-			'FI' => __( 'Finland', 'google-analytics-for-wordpress' ),
370
-			'FR' => __( 'France', 'google-analytics-for-wordpress' ),
371
-			'GF' => __( 'French Guiana', 'google-analytics-for-wordpress' ),
372
-			'PF' => __( 'French Polynesia', 'google-analytics-for-wordpress' ),
373
-			'TF' => __( 'French Southern Territories', 'google-analytics-for-wordpress' ),
374
-			'GA' => __( 'Gabon', 'google-analytics-for-wordpress' ),
375
-			'GM' => __( 'Gambia', 'google-analytics-for-wordpress' ),
376
-			'GE' => __( 'Georgia', 'google-analytics-for-wordpress' ),
377
-			'DE' => __( 'Germany', 'google-analytics-for-wordpress' ),
378
-			'GR' => __( 'Greece', 'google-analytics-for-wordpress' ),
379
-			'GH' => __( 'Ghana', 'google-analytics-for-wordpress' ),
380
-			'GI' => __( 'Gibraltar', 'google-analytics-for-wordpress' ),
381
-			'GL' => __( 'Greenland', 'google-analytics-for-wordpress' ),
382
-			'GD' => __( 'Grenada', 'google-analytics-for-wordpress' ),
383
-			'GP' => __( 'Guadeloupe', 'google-analytics-for-wordpress' ),
384
-			'GU' => __( 'Guam', 'google-analytics-for-wordpress' ),
385
-			'GT' => __( 'Guatemala', 'google-analytics-for-wordpress' ),
386
-			'GG' => __( 'Guernsey', 'google-analytics-for-wordpress' ),
387
-			'GN' => __( 'Guinea', 'google-analytics-for-wordpress' ),
388
-			'GW' => __( 'Guinea-Bissau', 'google-analytics-for-wordpress' ),
389
-			'GY' => __( 'Guyana', 'google-analytics-for-wordpress' ),
390
-			'HT' => __( 'Haiti', 'google-analytics-for-wordpress' ),
391
-			'HM' => __( 'Heard and McDonald Islands', 'google-analytics-for-wordpress' ),
392
-			'VA' => __( 'Holy See (City Vatican State)', 'google-analytics-for-wordpress' ),
393
-			'HN' => __( 'Honduras', 'google-analytics-for-wordpress' ),
394
-			'HK' => __( 'Hong Kong', 'google-analytics-for-wordpress' ),
395
-			'HU' => __( 'Hungary', 'google-analytics-for-wordpress' ),
396
-			'IS' => __( 'Iceland', 'google-analytics-for-wordpress' ),
397
-			'IN' => __( 'India', 'google-analytics-for-wordpress' ),
398
-			'ID' => __( 'Indonesia', 'google-analytics-for-wordpress' ),
399
-			'IR' => __( 'Iran', 'google-analytics-for-wordpress' ),
400
-			'IQ' => __( 'Iraq', 'google-analytics-for-wordpress' ),
401
-			'IE' => __( 'Ireland', 'google-analytics-for-wordpress' ),
402
-			'IM' => __( 'Isle of Man', 'google-analytics-for-wordpress' ),
403
-			'IL' => __( 'Israel', 'google-analytics-for-wordpress' ),
404
-			'IT' => __( 'Italy', 'google-analytics-for-wordpress' ),
405
-			'JM' => __( 'Jamaica', 'google-analytics-for-wordpress' ),
406
-			'JP' => __( 'Japan', 'google-analytics-for-wordpress' ),
407
-			'JE' => __( 'Jersey', 'google-analytics-for-wordpress' ),
408
-			'JO' => __( 'Jordan', 'google-analytics-for-wordpress' ),
409
-			'KZ' => __( 'Kazakhstan', 'google-analytics-for-wordpress' ),
410
-			'KE' => __( 'Kenya', 'google-analytics-for-wordpress' ),
411
-			'KI' => __( 'Kiribati', 'google-analytics-for-wordpress' ),
412
-			'KW' => __( 'Kuwait', 'google-analytics-for-wordpress' ),
413
-			'KG' => __( 'Kyrgyzstan', 'google-analytics-for-wordpress' ),
414
-			'LA' => __( 'Lao People\'s Democratic Republic', 'google-analytics-for-wordpress' ),
415
-			'LV' => __( 'Latvia', 'google-analytics-for-wordpress' ),
416
-			'LB' => __( 'Lebanon', 'google-analytics-for-wordpress' ),
417
-			'LS' => __( 'Lesotho', 'google-analytics-for-wordpress' ),
418
-			'LR' => __( 'Liberia', 'google-analytics-for-wordpress' ),
419
-			'LY' => __( 'Libyan Arab Jamahiriya', 'google-analytics-for-wordpress' ),
420
-			'LI' => __( 'Liechtenstein', 'google-analytics-for-wordpress' ),
421
-			'LT' => __( 'Lithuania', 'google-analytics-for-wordpress' ),
422
-			'LU' => __( 'Luxembourg', 'google-analytics-for-wordpress' ),
423
-			'MO' => __( 'Macau', 'google-analytics-for-wordpress' ),
424
-			'MK' => __( 'Macedonia', 'google-analytics-for-wordpress' ),
425
-			'MG' => __( 'Madagascar', 'google-analytics-for-wordpress' ),
426
-			'MW' => __( 'Malawi', 'google-analytics-for-wordpress' ),
427
-			'MY' => __( 'Malaysia', 'google-analytics-for-wordpress' ),
428
-			'MV' => __( 'Maldives', 'google-analytics-for-wordpress' ),
429
-			'ML' => __( 'Mali', 'google-analytics-for-wordpress' ),
430
-			'MT' => __( 'Malta', 'google-analytics-for-wordpress' ),
431
-			'MH' => __( 'Marshall Islands', 'google-analytics-for-wordpress' ),
432
-			'MQ' => __( 'Martinique', 'google-analytics-for-wordpress' ),
433
-			'MR' => __( 'Mauritania', 'google-analytics-for-wordpress' ),
434
-			'MU' => __( 'Mauritius', 'google-analytics-for-wordpress' ),
435
-			'YT' => __( 'Mayotte', 'google-analytics-for-wordpress' ),
436
-			'MX' => __( 'Mexico', 'google-analytics-for-wordpress' ),
437
-			'FM' => __( 'Micronesia', 'google-analytics-for-wordpress' ),
438
-			'MD' => __( 'Moldova, Republic of', 'google-analytics-for-wordpress' ),
439
-			'MC' => __( 'Monaco', 'google-analytics-for-wordpress' ),
440
-			'MN' => __( 'Mongolia', 'google-analytics-for-wordpress' ),
441
-			'ME' => __( 'Montenegro', 'google-analytics-for-wordpress' ),
442
-			'MS' => __( 'Montserrat', 'google-analytics-for-wordpress' ),
443
-			'MA' => __( 'Morocco', 'google-analytics-for-wordpress' ),
444
-			'MZ' => __( 'Mozambique', 'google-analytics-for-wordpress' ),
445
-			'MM' => __( 'Myanmar', 'google-analytics-for-wordpress' ),
446
-			'NA' => __( 'Namibia', 'google-analytics-for-wordpress' ),
447
-			'NR' => __( 'Nauru', 'google-analytics-for-wordpress' ),
448
-			'NP' => __( 'Nepal', 'google-analytics-for-wordpress' ),
449
-			'NL' => __( 'Netherlands', 'google-analytics-for-wordpress' ),
450
-			'AN' => __( 'Netherlands Antilles', 'google-analytics-for-wordpress' ),
451
-			'NC' => __( 'New Caledonia', 'google-analytics-for-wordpress' ),
452
-			'NZ' => __( 'New Zealand', 'google-analytics-for-wordpress' ),
453
-			'NI' => __( 'Nicaragua', 'google-analytics-for-wordpress' ),
454
-			'NE' => __( 'Niger', 'google-analytics-for-wordpress' ),
455
-			'NG' => __( 'Nigeria', 'google-analytics-for-wordpress' ),
456
-			'NU' => __( 'Niue', 'google-analytics-for-wordpress' ),
457
-			'NF' => __( 'Norfolk Island', 'google-analytics-for-wordpress' ),
458
-			'KP' => __( 'North Korea', 'google-analytics-for-wordpress' ),
459
-			'MP' => __( 'Northern Mariana Islands', 'google-analytics-for-wordpress' ),
460
-			'NO' => __( 'Norway', 'google-analytics-for-wordpress' ),
461
-			'OM' => __( 'Oman', 'google-analytics-for-wordpress' ),
462
-			'PK' => __( 'Pakistan', 'google-analytics-for-wordpress' ),
463
-			'PW' => __( 'Palau', 'google-analytics-for-wordpress' ),
464
-			'PS' => __( 'Palestinian Territories', 'google-analytics-for-wordpress' ),
465
-			'PA' => __( 'Panama', 'google-analytics-for-wordpress' ),
466
-			'PG' => __( 'Papua New Guinea', 'google-analytics-for-wordpress' ),
467
-			'PY' => __( 'Paraguay', 'google-analytics-for-wordpress' ),
468
-			'PE' => __( 'Peru', 'google-analytics-for-wordpress' ),
469
-			'PH' => __( 'Philippines', 'google-analytics-for-wordpress' ),
470
-			'PN' => __( 'Pitcairn Island', 'google-analytics-for-wordpress' ),
471
-			'PL' => __( 'Poland', 'google-analytics-for-wordpress' ),
472
-			'PT' => __( 'Portugal', 'google-analytics-for-wordpress' ),
473
-			'PR' => __( 'Puerto Rico', 'google-analytics-for-wordpress' ),
474
-			'QA' => __( 'Qatar', 'google-analytics-for-wordpress' ),
475
-			'XK' => __( 'Republic of Kosovo', 'google-analytics-for-wordpress' ),
476
-			'RE' => __( 'Reunion Island', 'google-analytics-for-wordpress' ),
477
-			'RO' => __( 'Romania', 'google-analytics-for-wordpress' ),
478
-			'RU' => __( 'Russian Federation', 'google-analytics-for-wordpress' ),
479
-			'RW' => __( 'Rwanda', 'google-analytics-for-wordpress' ),
480
-			'BL' => __( 'Saint Barth&eacute;lemy', 'google-analytics-for-wordpress' ),
481
-			'SH' => __( 'Saint Helena', 'google-analytics-for-wordpress' ),
482
-			'KN' => __( 'Saint Kitts and Nevis', 'google-analytics-for-wordpress' ),
483
-			'LC' => __( 'Saint Lucia', 'google-analytics-for-wordpress' ),
484
-			'MF' => __( 'Saint Martin (French)', 'google-analytics-for-wordpress' ),
485
-			'SX' => __( 'Saint Martin (Dutch)', 'google-analytics-for-wordpress' ),
486
-			'PM' => __( 'Saint Pierre and Miquelon', 'google-analytics-for-wordpress' ),
487
-			'VC' => __( 'Saint Vincent and the Grenadines', 'google-analytics-for-wordpress' ),
488
-			'SM' => __( 'San Marino', 'google-analytics-for-wordpress' ),
489
-			'ST' => __( 'S&atilde;o Tom&eacute; and Pr&iacute;ncipe', 'google-analytics-for-wordpress' ),
490
-			'SA' => __( 'Saudi Arabia', 'google-analytics-for-wordpress' ),
491
-			'SN' => __( 'Senegal', 'google-analytics-for-wordpress' ),
492
-			'RS' => __( 'Serbia', 'google-analytics-for-wordpress' ),
493
-			'SC' => __( 'Seychelles', 'google-analytics-for-wordpress' ),
494
-			'SL' => __( 'Sierra Leone', 'google-analytics-for-wordpress' ),
495
-			'SG' => __( 'Singapore', 'google-analytics-for-wordpress' ),
496
-			'SK' => __( 'Slovak Republic', 'google-analytics-for-wordpress' ),
497
-			'SI' => __( 'Slovenia', 'google-analytics-for-wordpress' ),
498
-			'SB' => __( 'Solomon Islands', 'google-analytics-for-wordpress' ),
499
-			'SO' => __( 'Somalia', 'google-analytics-for-wordpress' ),
500
-			'ZA' => __( 'South Africa', 'google-analytics-for-wordpress' ),
501
-			'GS' => __( 'South Georgia', 'google-analytics-for-wordpress' ),
502
-			'KR' => __( 'South Korea', 'google-analytics-for-wordpress' ),
503
-			'SS' => __( 'South Sudan', 'google-analytics-for-wordpress' ),
504
-			'ES' => __( 'Spain', 'google-analytics-for-wordpress' ),
505
-			'LK' => __( 'Sri Lanka', 'google-analytics-for-wordpress' ),
506
-			'SD' => __( 'Sudan', 'google-analytics-for-wordpress' ),
507
-			'SR' => __( 'Suriname', 'google-analytics-for-wordpress' ),
508
-			'SJ' => __( 'Svalbard and Jan Mayen Islands', 'google-analytics-for-wordpress' ),
509
-			'SZ' => __( 'Swaziland', 'google-analytics-for-wordpress' ),
510
-			'SE' => __( 'Sweden', 'google-analytics-for-wordpress' ),
511
-			'CH' => __( 'Switzerland', 'google-analytics-for-wordpress' ),
512
-			'SY' => __( 'Syrian Arab Republic', 'google-analytics-for-wordpress' ),
513
-			'TW' => __( 'Taiwan', 'google-analytics-for-wordpress' ),
514
-			'TJ' => __( 'Tajikistan', 'google-analytics-for-wordpress' ),
515
-			'TZ' => __( 'Tanzania', 'google-analytics-for-wordpress' ),
516
-			'TH' => __( 'Thailand', 'google-analytics-for-wordpress' ),
517
-			'TL' => __( 'Timor-Leste', 'google-analytics-for-wordpress' ),
518
-			'TG' => __( 'Togo', 'google-analytics-for-wordpress' ),
519
-			'TK' => __( 'Tokelau', 'google-analytics-for-wordpress' ),
520
-			'TO' => __( 'Tonga', 'google-analytics-for-wordpress' ),
521
-			'TT' => __( 'Trinidad and Tobago', 'google-analytics-for-wordpress' ),
522
-			'TN' => __( 'Tunisia', 'google-analytics-for-wordpress' ),
523
-			'TR' => __( 'Turkey', 'google-analytics-for-wordpress' ),
524
-			'TM' => __( 'Turkmenistan', 'google-analytics-for-wordpress' ),
525
-			'TC' => __( 'Turks and Caicos Islands', 'google-analytics-for-wordpress' ),
526
-			'TV' => __( 'Tuvalu', 'google-analytics-for-wordpress' ),
527
-			'UG' => __( 'Uganda', 'google-analytics-for-wordpress' ),
528
-			'UA' => __( 'Ukraine', 'google-analytics-for-wordpress' ),
529
-			'AE' => __( 'United Arab Emirates', 'google-analytics-for-wordpress' ),
530
-			'UY' => __( 'Uruguay', 'google-analytics-for-wordpress' ),
531
-			'UM' => __( 'US Minor Outlying Islands', 'google-analytics-for-wordpress' ),
532
-			'UZ' => __( 'Uzbekistan', 'google-analytics-for-wordpress' ),
533
-			'VU' => __( 'Vanuatu', 'google-analytics-for-wordpress' ),
534
-			'VE' => __( 'Venezuela', 'google-analytics-for-wordpress' ),
535
-			'VN' => __( 'Vietnam', 'google-analytics-for-wordpress' ),
536
-			'VG' => __( 'Virgin Islands (British)', 'google-analytics-for-wordpress' ),
537
-			'VI' => __( 'Virgin Islands (USA)', 'google-analytics-for-wordpress' ),
538
-			'WF' => __( 'Wallis and Futuna Islands', 'google-analytics-for-wordpress' ),
539
-			'EH' => __( 'Western Sahara', 'google-analytics-for-wordpress' ),
540
-			'WS' => __( 'Western Samoa', 'google-analytics-for-wordpress' ),
541
-			'YE' => __( 'Yemen', 'google-analytics-for-wordpress' ),
542
-			'ZM' => __( 'Zambia', 'google-analytics-for-wordpress' ),
543
-			'ZW' => __( 'Zimbabwe', 'google-analytics-for-wordpress' ),
544
-		);
545
-	} else {
546
-		$countries = array(
547
-			''   => '',
548
-			'US' => 'United States',
549
-			'CA' => 'Canada',
550
-			'GB' => 'United Kingdom',
551
-			'AF' => 'Afghanistan',
552
-			'AX' => '&#197;land Islands',
553
-			'AL' => 'Albania',
554
-			'DZ' => 'Algeria',
555
-			'AS' => 'American Samoa',
556
-			'AD' => 'Andorra',
557
-			'AO' => 'Angola',
558
-			'AI' => 'Anguilla',
559
-			'AQ' => 'Antarctica',
560
-			'AG' => 'Antigua and Barbuda',
561
-			'AR' => 'Argentina',
562
-			'AM' => 'Armenia',
563
-			'AW' => 'Aruba',
564
-			'AU' => 'Australia',
565
-			'AT' => 'Austria',
566
-			'AZ' => 'Azerbaijan',
567
-			'BS' => 'Bahamas',
568
-			'BH' => 'Bahrain',
569
-			'BD' => 'Bangladesh',
570
-			'BB' => 'Barbados',
571
-			'BY' => 'Belarus',
572
-			'BE' => 'Belgium',
573
-			'BZ' => 'Belize',
574
-			'BJ' => 'Benin',
575
-			'BM' => 'Bermuda',
576
-			'BT' => 'Bhutan',
577
-			'BO' => 'Bolivia',
578
-			'BQ' => 'Bonaire, Saint Eustatius and Saba',
579
-			'BA' => 'Bosnia and Herzegovina',
580
-			'BW' => 'Botswana',
581
-			'BV' => 'Bouvet Island',
582
-			'BR' => 'Brazil',
583
-			'IO' => 'British Indian Ocean Territory',
584
-			'BN' => 'Brunei Darrussalam',
585
-			'BG' => 'Bulgaria',
586
-			'BF' => 'Burkina Faso',
587
-			'BI' => 'Burundi',
588
-			'KH' => 'Cambodia',
589
-			'CM' => 'Cameroon',
590
-			'CV' => 'Cape Verde',
591
-			'KY' => 'Cayman Islands',
592
-			'CF' => 'Central African Republic',
593
-			'TD' => 'Chad',
594
-			'CL' => 'Chile',
595
-			'CN' => 'China',
596
-			'CX' => 'Christmas Island',
597
-			'CC' => 'Cocos Islands',
598
-			'CO' => 'Colombia',
599
-			'KM' => 'Comoros',
600
-			'CD' => 'Congo, Democratic People\'s Republic',
601
-			'CG' => 'Congo, Republic of',
602
-			'CK' => 'Cook Islands',
603
-			'CR' => 'Costa Rica',
604
-			'CI' => 'Cote d\'Ivoire',
605
-			'HR' => 'Croatia/Hrvatska',
606
-			'CU' => 'Cuba',
607
-			'CW' => 'Cura&Ccedil;ao',
608
-			'CY' => 'Cyprus',
609
-			'CZ' => 'Czechia',
610
-			'DK' => 'Denmark',
611
-			'DJ' => 'Djibouti',
612
-			'DM' => 'Dominica',
613
-			'DO' => 'Dominican Republic',
614
-			'TP' => 'East Timor',
615
-			'EC' => 'Ecuador',
616
-			'EG' => 'Egypt',
617
-			'GQ' => 'Equatorial Guinea',
618
-			'SV' => 'El Salvador',
619
-			'ER' => 'Eritrea',
620
-			'EE' => 'Estonia',
621
-			'ET' => 'Ethiopia',
622
-			'FK' => 'Falkland Islands',
623
-			'FO' => 'Faroe Islands',
624
-			'FJ' => 'Fiji',
625
-			'FI' => 'Finland',
626
-			'FR' => 'France',
627
-			'GF' => 'French Guiana',
628
-			'PF' => 'French Polynesia',
629
-			'TF' => 'French Southern Territories',
630
-			'GA' => 'Gabon',
631
-			'GM' => 'Gambia',
632
-			'GE' => 'Georgia',
633
-			'DE' => 'Germany',
634
-			'GR' => 'Greece',
635
-			'GH' => 'Ghana',
636
-			'GI' => 'Gibraltar',
637
-			'GL' => 'Greenland',
638
-			'GD' => 'Grenada',
639
-			'GP' => 'Guadeloupe',
640
-			'GU' => 'Guam',
641
-			'GT' => 'Guatemala',
642
-			'GG' => 'Guernsey',
643
-			'GN' => 'Guinea',
644
-			'GW' => 'Guinea-Bissau',
645
-			'GY' => 'Guyana',
646
-			'HT' => 'Haiti',
647
-			'HM' => 'Heard and McDonald Islands',
648
-			'VA' => 'Holy See (City Vatican State)',
649
-			'HN' => 'Honduras',
650
-			'HK' => 'Hong Kong',
651
-			'HU' => 'Hungary',
652
-			'IS' => 'Iceland',
653
-			'IN' => 'India',
654
-			'ID' => 'Indonesia',
655
-			'IR' => 'Iran',
656
-			'IQ' => 'Iraq',
657
-			'IE' => 'Ireland',
658
-			'IM' => 'Isle of Man',
659
-			'IL' => 'Israel',
660
-			'IT' => 'Italy',
661
-			'JM' => 'Jamaica',
662
-			'JP' => 'Japan',
663
-			'JE' => 'Jersey',
664
-			'JO' => 'Jordan',
665
-			'KZ' => 'Kazakhstan',
666
-			'KE' => 'Kenya',
667
-			'KI' => 'Kiribati',
668
-			'KW' => 'Kuwait',
669
-			'KG' => 'Kyrgyzstan',
670
-			'LA' => 'Lao People\'s Democratic Republic',
671
-			'LV' => 'Latvia',
672
-			'LB' => 'Lebanon',
673
-			'LS' => 'Lesotho',
674
-			'LR' => 'Liberia',
675
-			'LY' => 'Libyan Arab Jamahiriya',
676
-			'LI' => 'Liechtenstein',
677
-			'LT' => 'Lithuania',
678
-			'LU' => 'Luxembourg',
679
-			'MO' => 'Macau',
680
-			'MK' => 'Macedonia',
681
-			'MG' => 'Madagascar',
682
-			'MW' => 'Malawi',
683
-			'MY' => 'Malaysia',
684
-			'MV' => 'Maldives',
685
-			'ML' => 'Mali',
686
-			'MT' => 'Malta',
687
-			'MH' => 'Marshall Islands',
688
-			'MQ' => 'Martinique',
689
-			'MR' => 'Mauritania',
690
-			'MU' => 'Mauritius',
691
-			'YT' => 'Mayotte',
692
-			'MX' => 'Mexico',
693
-			'FM' => 'Micronesia',
694
-			'MD' => 'Moldova, Republic of',
695
-			'MC' => 'Monaco',
696
-			'MN' => 'Mongolia',
697
-			'ME' => 'Montenegro',
698
-			'MS' => 'Montserrat',
699
-			'MA' => 'Morocco',
700
-			'MZ' => 'Mozambique',
701
-			'MM' => 'Myanmar',
702
-			'NA' => 'Namibia',
703
-			'NR' => 'Nauru',
704
-			'NP' => 'Nepal',
705
-			'NL' => 'Netherlands',
706
-			'AN' => 'Netherlands Antilles',
707
-			'NC' => 'New Caledonia',
708
-			'NZ' => 'New Zealand',
709
-			'NI' => 'Nicaragua',
710
-			'NE' => 'Niger',
711
-			'NG' => 'Nigeria',
712
-			'NU' => 'Niue',
713
-			'NF' => 'Norfolk Island',
714
-			'KP' => 'North Korea',
715
-			'MP' => 'Northern Mariana Islands',
716
-			'NO' => 'Norway',
717
-			'OM' => 'Oman',
718
-			'PK' => 'Pakistan',
719
-			'PW' => 'Palau',
720
-			'PS' => 'Palestinian Territories',
721
-			'PA' => 'Panama',
722
-			'PG' => 'Papua New Guinea',
723
-			'PY' => 'Paraguay',
724
-			'PE' => 'Peru',
725
-			'PH' => 'Philippines',
726
-			'PN' => 'Pitcairn Island',
727
-			'PL' => 'Poland',
728
-			'PT' => 'Portugal',
729
-			'PR' => 'Puerto Rico',
730
-			'QA' => 'Qatar',
731
-			'XK' => 'Republic of Kosovo',
732
-			'RE' => 'Reunion Island',
733
-			'RO' => 'Romania',
734
-			'RU' => 'Russian Federation',
735
-			'RW' => 'Rwanda',
736
-			'BL' => 'Saint Barth&eacute;lemy',
737
-			'SH' => 'Saint Helena',
738
-			'KN' => 'Saint Kitts and Nevis',
739
-			'LC' => 'Saint Lucia',
740
-			'MF' => 'Saint Martin (French)',
741
-			'SX' => 'Saint Martin (Dutch)',
742
-			'PM' => 'Saint Pierre and Miquelon',
743
-			'VC' => 'Saint Vincent and the Grenadines',
744
-			'SM' => 'San Marino',
745
-			'ST' => 'S&atilde;o Tom&eacute; and Pr&iacute;ncipe',
746
-			'SA' => 'Saudi Arabia',
747
-			'SN' => 'Senegal',
748
-			'RS' => 'Serbia',
749
-			'SC' => 'Seychelles',
750
-			'SL' => 'Sierra Leone',
751
-			'SG' => 'Singapore',
752
-			'SK' => 'Slovak Republic',
753
-			'SI' => 'Slovenia',
754
-			'SB' => 'Solomon Islands',
755
-			'SO' => 'Somalia',
756
-			'ZA' => 'South Africa',
757
-			'GS' => 'South Georgia',
758
-			'KR' => 'South Korea',
759
-			'SS' => 'South Sudan',
760
-			'ES' => 'Spain',
761
-			'LK' => 'Sri Lanka',
762
-			'SD' => 'Sudan',
763
-			'SR' => 'Suriname',
764
-			'SJ' => 'Svalbard and Jan Mayen Islands',
765
-			'SZ' => 'Swaziland',
766
-			'SE' => 'Sweden',
767
-			'CH' => 'Switzerland',
768
-			'SY' => 'Syrian Arab Republic',
769
-			'TW' => 'Taiwan',
770
-			'TJ' => 'Tajikistan',
771
-			'TZ' => 'Tanzania',
772
-			'TH' => 'Thailand',
773
-			'TL' => 'Timor-Leste',
774
-			'TG' => 'Togo',
775
-			'TK' => 'Tokelau',
776
-			'TO' => 'Tonga',
777
-			'TT' => 'Trinidad and Tobago',
778
-			'TN' => 'Tunisia',
779
-			'TR' => 'Turkey',
780
-			'TM' => 'Turkmenistan',
781
-			'TC' => 'Turks and Caicos Islands',
782
-			'TV' => 'Tuvalu',
783
-			'UG' => 'Uganda',
784
-			'UA' => 'Ukraine',
785
-			'AE' => 'United Arab Emirates',
786
-			'UY' => 'Uruguay',
787
-			'UM' => 'US Minor Outlying Islands',
788
-			'UZ' => 'Uzbekistan',
789
-			'VU' => 'Vanuatu',
790
-			'VE' => 'Venezuela',
791
-			'VN' => 'Vietnam',
792
-			'VG' => 'Virgin Islands (British)',
793
-			'VI' => 'Virgin Islands (USA)',
794
-			'WF' => 'Wallis and Futuna Islands',
795
-			'EH' => 'Western Sahara',
796
-			'WS' => 'Western Samoa',
797
-			'YE' => 'Yemen',
798
-			'ZM' => 'Zambia',
799
-			'ZW' => 'Zimbabwe',
800
-		);		
801
-	}
802
-	return $countries;
289
+    if ( $translated ) {
290
+        $countries = array(
291
+            ''   => '',
292
+            'US' => __( 'United States', 'google-analytics-for-wordpress' ),
293
+            'CA' => __( 'Canada', 'google-analytics-for-wordpress' ),
294
+            'GB' => __( 'United Kingdom', 'google-analytics-for-wordpress' ),
295
+            'AF' => __( 'Afghanistan', 'google-analytics-for-wordpress' ),
296
+            'AX' => __( '&#197;land Islands', 'google-analytics-for-wordpress' ),
297
+            'AL' => __( 'Albania', 'google-analytics-for-wordpress' ),
298
+            'DZ' => __( 'Algeria', 'google-analytics-for-wordpress' ),
299
+            'AS' => __( 'American Samoa', 'google-analytics-for-wordpress' ),
300
+            'AD' => __( 'Andorra', 'google-analytics-for-wordpress' ),
301
+            'AO' => __( 'Angola', 'google-analytics-for-wordpress' ),
302
+            'AI' => __( 'Anguilla', 'google-analytics-for-wordpress' ),
303
+            'AQ' => __( 'Antarctica', 'google-analytics-for-wordpress' ),
304
+            'AG' => __( 'Antigua and Barbuda', 'google-analytics-for-wordpress' ),
305
+            'AR' => __( 'Argentina', 'google-analytics-for-wordpress' ),
306
+            'AM' => __( 'Armenia', 'google-analytics-for-wordpress' ),
307
+            'AW' => __( 'Aruba', 'google-analytics-for-wordpress' ),
308
+            'AU' => __( 'Australia', 'google-analytics-for-wordpress' ),
309
+            'AT' => __( 'Austria', 'google-analytics-for-wordpress' ),
310
+            'AZ' => __( 'Azerbaijan', 'google-analytics-for-wordpress' ),
311
+            'BS' => __( 'Bahamas', 'google-analytics-for-wordpress' ),
312
+            'BH' => __( 'Bahrain', 'google-analytics-for-wordpress' ),
313
+            'BD' => __( 'Bangladesh', 'google-analytics-for-wordpress' ),
314
+            'BB' => __( 'Barbados', 'google-analytics-for-wordpress' ),
315
+            'BY' => __( 'Belarus', 'google-analytics-for-wordpress' ),
316
+            'BE' => __( 'Belgium', 'google-analytics-for-wordpress' ),
317
+            'BZ' => __( 'Belize', 'google-analytics-for-wordpress' ),
318
+            'BJ' => __( 'Benin', 'google-analytics-for-wordpress' ),
319
+            'BM' => __( 'Bermuda', 'google-analytics-for-wordpress' ),
320
+            'BT' => __( 'Bhutan', 'google-analytics-for-wordpress' ),
321
+            'BO' => __( 'Bolivia', 'google-analytics-for-wordpress' ),
322
+            'BQ' => __( 'Bonaire, Saint Eustatius and Saba', 'google-analytics-for-wordpress' ),
323
+            'BA' => __( 'Bosnia and Herzegovina', 'google-analytics-for-wordpress' ),
324
+            'BW' => __( 'Botswana', 'google-analytics-for-wordpress' ),
325
+            'BV' => __( 'Bouvet Island', 'google-analytics-for-wordpress' ),
326
+            'BR' => __( 'Brazil', 'google-analytics-for-wordpress' ),
327
+            'IO' => __( 'British Indian Ocean Territory', 'google-analytics-for-wordpress' ),
328
+            'BN' => __( 'Brunei Darrussalam', 'google-analytics-for-wordpress' ),
329
+            'BG' => __( 'Bulgaria', 'google-analytics-for-wordpress' ),
330
+            'BF' => __( 'Burkina Faso', 'google-analytics-for-wordpress' ),
331
+            'BI' => __( 'Burundi', 'google-analytics-for-wordpress' ),
332
+            'KH' => __( 'Cambodia', 'google-analytics-for-wordpress' ),
333
+            'CM' => __( 'Cameroon', 'google-analytics-for-wordpress' ),
334
+            'CV' => __( 'Cape Verde', 'google-analytics-for-wordpress' ),
335
+            'KY' => __( 'Cayman Islands', 'google-analytics-for-wordpress' ),
336
+            'CF' => __( 'Central African Republic', 'google-analytics-for-wordpress' ),
337
+            'TD' => __( 'Chad', 'google-analytics-for-wordpress' ),
338
+            'CL' => __( 'Chile', 'google-analytics-for-wordpress' ),
339
+            'CN' => __( 'China', 'google-analytics-for-wordpress' ),
340
+            'CX' => __( 'Christmas Island', 'google-analytics-for-wordpress' ),
341
+            'CC' => __( 'Cocos Islands', 'google-analytics-for-wordpress' ),
342
+            'CO' => __( 'Colombia', 'google-analytics-for-wordpress' ),
343
+            'KM' => __( 'Comoros', 'google-analytics-for-wordpress' ),
344
+            'CD' => __( 'Congo, Democratic People\'s Republic', 'google-analytics-for-wordpress' ),
345
+            'CG' => __( 'Congo, Republic of', 'google-analytics-for-wordpress' ),
346
+            'CK' => __( 'Cook Islands', 'google-analytics-for-wordpress' ),
347
+            'CR' => __( 'Costa Rica', 'google-analytics-for-wordpress' ),
348
+            'CI' => __( 'Cote d\'Ivoire', 'google-analytics-for-wordpress' ),
349
+            'HR' => __( 'Croatia/Hrvatska', 'google-analytics-for-wordpress' ),
350
+            'CU' => __( 'Cuba', 'google-analytics-for-wordpress' ),
351
+            'CW' => __( 'Cura&Ccedil;ao', 'google-analytics-for-wordpress' ),
352
+            'CY' => __( 'Cyprus', 'google-analytics-for-wordpress' ),
353
+            'CZ' => __( 'Czechia', 'google-analytics-for-wordpress' ),
354
+            'DK' => __( 'Denmark', 'google-analytics-for-wordpress' ),
355
+            'DJ' => __( 'Djibouti', 'google-analytics-for-wordpress' ),
356
+            'DM' => __( 'Dominica', 'google-analytics-for-wordpress' ),
357
+            'DO' => __( 'Dominican Republic', 'google-analytics-for-wordpress' ),
358
+            'TP' => __( 'East Timor', 'google-analytics-for-wordpress' ),
359
+            'EC' => __( 'Ecuador', 'google-analytics-for-wordpress' ),
360
+            'EG' => __( 'Egypt', 'google-analytics-for-wordpress' ),
361
+            'GQ' => __( 'Equatorial Guinea', 'google-analytics-for-wordpress' ),
362
+            'SV' => __( 'El Salvador', 'google-analytics-for-wordpress' ),
363
+            'ER' => __( 'Eritrea', 'google-analytics-for-wordpress' ),
364
+            'EE' => __( 'Estonia', 'google-analytics-for-wordpress' ),
365
+            'ET' => __( 'Ethiopia', 'google-analytics-for-wordpress' ),
366
+            'FK' => __( 'Falkland Islands', 'google-analytics-for-wordpress' ),
367
+            'FO' => __( 'Faroe Islands', 'google-analytics-for-wordpress' ),
368
+            'FJ' => __( 'Fiji', 'google-analytics-for-wordpress' ),
369
+            'FI' => __( 'Finland', 'google-analytics-for-wordpress' ),
370
+            'FR' => __( 'France', 'google-analytics-for-wordpress' ),
371
+            'GF' => __( 'French Guiana', 'google-analytics-for-wordpress' ),
372
+            'PF' => __( 'French Polynesia', 'google-analytics-for-wordpress' ),
373
+            'TF' => __( 'French Southern Territories', 'google-analytics-for-wordpress' ),
374
+            'GA' => __( 'Gabon', 'google-analytics-for-wordpress' ),
375
+            'GM' => __( 'Gambia', 'google-analytics-for-wordpress' ),
376
+            'GE' => __( 'Georgia', 'google-analytics-for-wordpress' ),
377
+            'DE' => __( 'Germany', 'google-analytics-for-wordpress' ),
378
+            'GR' => __( 'Greece', 'google-analytics-for-wordpress' ),
379
+            'GH' => __( 'Ghana', 'google-analytics-for-wordpress' ),
380
+            'GI' => __( 'Gibraltar', 'google-analytics-for-wordpress' ),
381
+            'GL' => __( 'Greenland', 'google-analytics-for-wordpress' ),
382
+            'GD' => __( 'Grenada', 'google-analytics-for-wordpress' ),
383
+            'GP' => __( 'Guadeloupe', 'google-analytics-for-wordpress' ),
384
+            'GU' => __( 'Guam', 'google-analytics-for-wordpress' ),
385
+            'GT' => __( 'Guatemala', 'google-analytics-for-wordpress' ),
386
+            'GG' => __( 'Guernsey', 'google-analytics-for-wordpress' ),
387
+            'GN' => __( 'Guinea', 'google-analytics-for-wordpress' ),
388
+            'GW' => __( 'Guinea-Bissau', 'google-analytics-for-wordpress' ),
389
+            'GY' => __( 'Guyana', 'google-analytics-for-wordpress' ),
390
+            'HT' => __( 'Haiti', 'google-analytics-for-wordpress' ),
391
+            'HM' => __( 'Heard and McDonald Islands', 'google-analytics-for-wordpress' ),
392
+            'VA' => __( 'Holy See (City Vatican State)', 'google-analytics-for-wordpress' ),
393
+            'HN' => __( 'Honduras', 'google-analytics-for-wordpress' ),
394
+            'HK' => __( 'Hong Kong', 'google-analytics-for-wordpress' ),
395
+            'HU' => __( 'Hungary', 'google-analytics-for-wordpress' ),
396
+            'IS' => __( 'Iceland', 'google-analytics-for-wordpress' ),
397
+            'IN' => __( 'India', 'google-analytics-for-wordpress' ),
398
+            'ID' => __( 'Indonesia', 'google-analytics-for-wordpress' ),
399
+            'IR' => __( 'Iran', 'google-analytics-for-wordpress' ),
400
+            'IQ' => __( 'Iraq', 'google-analytics-for-wordpress' ),
401
+            'IE' => __( 'Ireland', 'google-analytics-for-wordpress' ),
402
+            'IM' => __( 'Isle of Man', 'google-analytics-for-wordpress' ),
403
+            'IL' => __( 'Israel', 'google-analytics-for-wordpress' ),
404
+            'IT' => __( 'Italy', 'google-analytics-for-wordpress' ),
405
+            'JM' => __( 'Jamaica', 'google-analytics-for-wordpress' ),
406
+            'JP' => __( 'Japan', 'google-analytics-for-wordpress' ),
407
+            'JE' => __( 'Jersey', 'google-analytics-for-wordpress' ),
408
+            'JO' => __( 'Jordan', 'google-analytics-for-wordpress' ),
409
+            'KZ' => __( 'Kazakhstan', 'google-analytics-for-wordpress' ),
410
+            'KE' => __( 'Kenya', 'google-analytics-for-wordpress' ),
411
+            'KI' => __( 'Kiribati', 'google-analytics-for-wordpress' ),
412
+            'KW' => __( 'Kuwait', 'google-analytics-for-wordpress' ),
413
+            'KG' => __( 'Kyrgyzstan', 'google-analytics-for-wordpress' ),
414
+            'LA' => __( 'Lao People\'s Democratic Republic', 'google-analytics-for-wordpress' ),
415
+            'LV' => __( 'Latvia', 'google-analytics-for-wordpress' ),
416
+            'LB' => __( 'Lebanon', 'google-analytics-for-wordpress' ),
417
+            'LS' => __( 'Lesotho', 'google-analytics-for-wordpress' ),
418
+            'LR' => __( 'Liberia', 'google-analytics-for-wordpress' ),
419
+            'LY' => __( 'Libyan Arab Jamahiriya', 'google-analytics-for-wordpress' ),
420
+            'LI' => __( 'Liechtenstein', 'google-analytics-for-wordpress' ),
421
+            'LT' => __( 'Lithuania', 'google-analytics-for-wordpress' ),
422
+            'LU' => __( 'Luxembourg', 'google-analytics-for-wordpress' ),
423
+            'MO' => __( 'Macau', 'google-analytics-for-wordpress' ),
424
+            'MK' => __( 'Macedonia', 'google-analytics-for-wordpress' ),
425
+            'MG' => __( 'Madagascar', 'google-analytics-for-wordpress' ),
426
+            'MW' => __( 'Malawi', 'google-analytics-for-wordpress' ),
427
+            'MY' => __( 'Malaysia', 'google-analytics-for-wordpress' ),
428
+            'MV' => __( 'Maldives', 'google-analytics-for-wordpress' ),
429
+            'ML' => __( 'Mali', 'google-analytics-for-wordpress' ),
430
+            'MT' => __( 'Malta', 'google-analytics-for-wordpress' ),
431
+            'MH' => __( 'Marshall Islands', 'google-analytics-for-wordpress' ),
432
+            'MQ' => __( 'Martinique', 'google-analytics-for-wordpress' ),
433
+            'MR' => __( 'Mauritania', 'google-analytics-for-wordpress' ),
434
+            'MU' => __( 'Mauritius', 'google-analytics-for-wordpress' ),
435
+            'YT' => __( 'Mayotte', 'google-analytics-for-wordpress' ),
436
+            'MX' => __( 'Mexico', 'google-analytics-for-wordpress' ),
437
+            'FM' => __( 'Micronesia', 'google-analytics-for-wordpress' ),
438
+            'MD' => __( 'Moldova, Republic of', 'google-analytics-for-wordpress' ),
439
+            'MC' => __( 'Monaco', 'google-analytics-for-wordpress' ),
440
+            'MN' => __( 'Mongolia', 'google-analytics-for-wordpress' ),
441
+            'ME' => __( 'Montenegro', 'google-analytics-for-wordpress' ),
442
+            'MS' => __( 'Montserrat', 'google-analytics-for-wordpress' ),
443
+            'MA' => __( 'Morocco', 'google-analytics-for-wordpress' ),
444
+            'MZ' => __( 'Mozambique', 'google-analytics-for-wordpress' ),
445
+            'MM' => __( 'Myanmar', 'google-analytics-for-wordpress' ),
446
+            'NA' => __( 'Namibia', 'google-analytics-for-wordpress' ),
447
+            'NR' => __( 'Nauru', 'google-analytics-for-wordpress' ),
448
+            'NP' => __( 'Nepal', 'google-analytics-for-wordpress' ),
449
+            'NL' => __( 'Netherlands', 'google-analytics-for-wordpress' ),
450
+            'AN' => __( 'Netherlands Antilles', 'google-analytics-for-wordpress' ),
451
+            'NC' => __( 'New Caledonia', 'google-analytics-for-wordpress' ),
452
+            'NZ' => __( 'New Zealand', 'google-analytics-for-wordpress' ),
453
+            'NI' => __( 'Nicaragua', 'google-analytics-for-wordpress' ),
454
+            'NE' => __( 'Niger', 'google-analytics-for-wordpress' ),
455
+            'NG' => __( 'Nigeria', 'google-analytics-for-wordpress' ),
456
+            'NU' => __( 'Niue', 'google-analytics-for-wordpress' ),
457
+            'NF' => __( 'Norfolk Island', 'google-analytics-for-wordpress' ),
458
+            'KP' => __( 'North Korea', 'google-analytics-for-wordpress' ),
459
+            'MP' => __( 'Northern Mariana Islands', 'google-analytics-for-wordpress' ),
460
+            'NO' => __( 'Norway', 'google-analytics-for-wordpress' ),
461
+            'OM' => __( 'Oman', 'google-analytics-for-wordpress' ),
462
+            'PK' => __( 'Pakistan', 'google-analytics-for-wordpress' ),
463
+            'PW' => __( 'Palau', 'google-analytics-for-wordpress' ),
464
+            'PS' => __( 'Palestinian Territories', 'google-analytics-for-wordpress' ),
465
+            'PA' => __( 'Panama', 'google-analytics-for-wordpress' ),
466
+            'PG' => __( 'Papua New Guinea', 'google-analytics-for-wordpress' ),
467
+            'PY' => __( 'Paraguay', 'google-analytics-for-wordpress' ),
468
+            'PE' => __( 'Peru', 'google-analytics-for-wordpress' ),
469
+            'PH' => __( 'Philippines', 'google-analytics-for-wordpress' ),
470
+            'PN' => __( 'Pitcairn Island', 'google-analytics-for-wordpress' ),
471
+            'PL' => __( 'Poland', 'google-analytics-for-wordpress' ),
472
+            'PT' => __( 'Portugal', 'google-analytics-for-wordpress' ),
473
+            'PR' => __( 'Puerto Rico', 'google-analytics-for-wordpress' ),
474
+            'QA' => __( 'Qatar', 'google-analytics-for-wordpress' ),
475
+            'XK' => __( 'Republic of Kosovo', 'google-analytics-for-wordpress' ),
476
+            'RE' => __( 'Reunion Island', 'google-analytics-for-wordpress' ),
477
+            'RO' => __( 'Romania', 'google-analytics-for-wordpress' ),
478
+            'RU' => __( 'Russian Federation', 'google-analytics-for-wordpress' ),
479
+            'RW' => __( 'Rwanda', 'google-analytics-for-wordpress' ),
480
+            'BL' => __( 'Saint Barth&eacute;lemy', 'google-analytics-for-wordpress' ),
481
+            'SH' => __( 'Saint Helena', 'google-analytics-for-wordpress' ),
482
+            'KN' => __( 'Saint Kitts and Nevis', 'google-analytics-for-wordpress' ),
483
+            'LC' => __( 'Saint Lucia', 'google-analytics-for-wordpress' ),
484
+            'MF' => __( 'Saint Martin (French)', 'google-analytics-for-wordpress' ),
485
+            'SX' => __( 'Saint Martin (Dutch)', 'google-analytics-for-wordpress' ),
486
+            'PM' => __( 'Saint Pierre and Miquelon', 'google-analytics-for-wordpress' ),
487
+            'VC' => __( 'Saint Vincent and the Grenadines', 'google-analytics-for-wordpress' ),
488
+            'SM' => __( 'San Marino', 'google-analytics-for-wordpress' ),
489
+            'ST' => __( 'S&atilde;o Tom&eacute; and Pr&iacute;ncipe', 'google-analytics-for-wordpress' ),
490
+            'SA' => __( 'Saudi Arabia', 'google-analytics-for-wordpress' ),
491
+            'SN' => __( 'Senegal', 'google-analytics-for-wordpress' ),
492
+            'RS' => __( 'Serbia', 'google-analytics-for-wordpress' ),
493
+            'SC' => __( 'Seychelles', 'google-analytics-for-wordpress' ),
494
+            'SL' => __( 'Sierra Leone', 'google-analytics-for-wordpress' ),
495
+            'SG' => __( 'Singapore', 'google-analytics-for-wordpress' ),
496
+            'SK' => __( 'Slovak Republic', 'google-analytics-for-wordpress' ),
497
+            'SI' => __( 'Slovenia', 'google-analytics-for-wordpress' ),
498
+            'SB' => __( 'Solomon Islands', 'google-analytics-for-wordpress' ),
499
+            'SO' => __( 'Somalia', 'google-analytics-for-wordpress' ),
500
+            'ZA' => __( 'South Africa', 'google-analytics-for-wordpress' ),
501
+            'GS' => __( 'South Georgia', 'google-analytics-for-wordpress' ),
502
+            'KR' => __( 'South Korea', 'google-analytics-for-wordpress' ),
503
+            'SS' => __( 'South Sudan', 'google-analytics-for-wordpress' ),
504
+            'ES' => __( 'Spain', 'google-analytics-for-wordpress' ),
505
+            'LK' => __( 'Sri Lanka', 'google-analytics-for-wordpress' ),
506
+            'SD' => __( 'Sudan', 'google-analytics-for-wordpress' ),
507
+            'SR' => __( 'Suriname', 'google-analytics-for-wordpress' ),
508
+            'SJ' => __( 'Svalbard and Jan Mayen Islands', 'google-analytics-for-wordpress' ),
509
+            'SZ' => __( 'Swaziland', 'google-analytics-for-wordpress' ),
510
+            'SE' => __( 'Sweden', 'google-analytics-for-wordpress' ),
511
+            'CH' => __( 'Switzerland', 'google-analytics-for-wordpress' ),
512
+            'SY' => __( 'Syrian Arab Republic', 'google-analytics-for-wordpress' ),
513
+            'TW' => __( 'Taiwan', 'google-analytics-for-wordpress' ),
514
+            'TJ' => __( 'Tajikistan', 'google-analytics-for-wordpress' ),
515
+            'TZ' => __( 'Tanzania', 'google-analytics-for-wordpress' ),
516
+            'TH' => __( 'Thailand', 'google-analytics-for-wordpress' ),
517
+            'TL' => __( 'Timor-Leste', 'google-analytics-for-wordpress' ),
518
+            'TG' => __( 'Togo', 'google-analytics-for-wordpress' ),
519
+            'TK' => __( 'Tokelau', 'google-analytics-for-wordpress' ),
520
+            'TO' => __( 'Tonga', 'google-analytics-for-wordpress' ),
521
+            'TT' => __( 'Trinidad and Tobago', 'google-analytics-for-wordpress' ),
522
+            'TN' => __( 'Tunisia', 'google-analytics-for-wordpress' ),
523
+            'TR' => __( 'Turkey', 'google-analytics-for-wordpress' ),
524
+            'TM' => __( 'Turkmenistan', 'google-analytics-for-wordpress' ),
525
+            'TC' => __( 'Turks and Caicos Islands', 'google-analytics-for-wordpress' ),
526
+            'TV' => __( 'Tuvalu', 'google-analytics-for-wordpress' ),
527
+            'UG' => __( 'Uganda', 'google-analytics-for-wordpress' ),
528
+            'UA' => __( 'Ukraine', 'google-analytics-for-wordpress' ),
529
+            'AE' => __( 'United Arab Emirates', 'google-analytics-for-wordpress' ),
530
+            'UY' => __( 'Uruguay', 'google-analytics-for-wordpress' ),
531
+            'UM' => __( 'US Minor Outlying Islands', 'google-analytics-for-wordpress' ),
532
+            'UZ' => __( 'Uzbekistan', 'google-analytics-for-wordpress' ),
533
+            'VU' => __( 'Vanuatu', 'google-analytics-for-wordpress' ),
534
+            'VE' => __( 'Venezuela', 'google-analytics-for-wordpress' ),
535
+            'VN' => __( 'Vietnam', 'google-analytics-for-wordpress' ),
536
+            'VG' => __( 'Virgin Islands (British)', 'google-analytics-for-wordpress' ),
537
+            'VI' => __( 'Virgin Islands (USA)', 'google-analytics-for-wordpress' ),
538
+            'WF' => __( 'Wallis and Futuna Islands', 'google-analytics-for-wordpress' ),
539
+            'EH' => __( 'Western Sahara', 'google-analytics-for-wordpress' ),
540
+            'WS' => __( 'Western Samoa', 'google-analytics-for-wordpress' ),
541
+            'YE' => __( 'Yemen', 'google-analytics-for-wordpress' ),
542
+            'ZM' => __( 'Zambia', 'google-analytics-for-wordpress' ),
543
+            'ZW' => __( 'Zimbabwe', 'google-analytics-for-wordpress' ),
544
+        );
545
+    } else {
546
+        $countries = array(
547
+            ''   => '',
548
+            'US' => 'United States',
549
+            'CA' => 'Canada',
550
+            'GB' => 'United Kingdom',
551
+            'AF' => 'Afghanistan',
552
+            'AX' => '&#197;land Islands',
553
+            'AL' => 'Albania',
554
+            'DZ' => 'Algeria',
555
+            'AS' => 'American Samoa',
556
+            'AD' => 'Andorra',
557
+            'AO' => 'Angola',
558
+            'AI' => 'Anguilla',
559
+            'AQ' => 'Antarctica',
560
+            'AG' => 'Antigua and Barbuda',
561
+            'AR' => 'Argentina',
562
+            'AM' => 'Armenia',
563
+            'AW' => 'Aruba',
564
+            'AU' => 'Australia',
565
+            'AT' => 'Austria',
566
+            'AZ' => 'Azerbaijan',
567
+            'BS' => 'Bahamas',
568
+            'BH' => 'Bahrain',
569
+            'BD' => 'Bangladesh',
570
+            'BB' => 'Barbados',
571
+            'BY' => 'Belarus',
572
+            'BE' => 'Belgium',
573
+            'BZ' => 'Belize',
574
+            'BJ' => 'Benin',
575
+            'BM' => 'Bermuda',
576
+            'BT' => 'Bhutan',
577
+            'BO' => 'Bolivia',
578
+            'BQ' => 'Bonaire, Saint Eustatius and Saba',
579
+            'BA' => 'Bosnia and Herzegovina',
580
+            'BW' => 'Botswana',
581
+            'BV' => 'Bouvet Island',
582
+            'BR' => 'Brazil',
583
+            'IO' => 'British Indian Ocean Territory',
584
+            'BN' => 'Brunei Darrussalam',
585
+            'BG' => 'Bulgaria',
586
+            'BF' => 'Burkina Faso',
587
+            'BI' => 'Burundi',
588
+            'KH' => 'Cambodia',
589
+            'CM' => 'Cameroon',
590
+            'CV' => 'Cape Verde',
591
+            'KY' => 'Cayman Islands',
592
+            'CF' => 'Central African Republic',
593
+            'TD' => 'Chad',
594
+            'CL' => 'Chile',
595
+            'CN' => 'China',
596
+            'CX' => 'Christmas Island',
597
+            'CC' => 'Cocos Islands',
598
+            'CO' => 'Colombia',
599
+            'KM' => 'Comoros',
600
+            'CD' => 'Congo, Democratic People\'s Republic',
601
+            'CG' => 'Congo, Republic of',
602
+            'CK' => 'Cook Islands',
603
+            'CR' => 'Costa Rica',
604
+            'CI' => 'Cote d\'Ivoire',
605
+            'HR' => 'Croatia/Hrvatska',
606
+            'CU' => 'Cuba',
607
+            'CW' => 'Cura&Ccedil;ao',
608
+            'CY' => 'Cyprus',
609
+            'CZ' => 'Czechia',
610
+            'DK' => 'Denmark',
611
+            'DJ' => 'Djibouti',
612
+            'DM' => 'Dominica',
613
+            'DO' => 'Dominican Republic',
614
+            'TP' => 'East Timor',
615
+            'EC' => 'Ecuador',
616
+            'EG' => 'Egypt',
617
+            'GQ' => 'Equatorial Guinea',
618
+            'SV' => 'El Salvador',
619
+            'ER' => 'Eritrea',
620
+            'EE' => 'Estonia',
621
+            'ET' => 'Ethiopia',
622
+            'FK' => 'Falkland Islands',
623
+            'FO' => 'Faroe Islands',
624
+            'FJ' => 'Fiji',
625
+            'FI' => 'Finland',
626
+            'FR' => 'France',
627
+            'GF' => 'French Guiana',
628
+            'PF' => 'French Polynesia',
629
+            'TF' => 'French Southern Territories',
630
+            'GA' => 'Gabon',
631
+            'GM' => 'Gambia',
632
+            'GE' => 'Georgia',
633
+            'DE' => 'Germany',
634
+            'GR' => 'Greece',
635
+            'GH' => 'Ghana',
636
+            'GI' => 'Gibraltar',
637
+            'GL' => 'Greenland',
638
+            'GD' => 'Grenada',
639
+            'GP' => 'Guadeloupe',
640
+            'GU' => 'Guam',
641
+            'GT' => 'Guatemala',
642
+            'GG' => 'Guernsey',
643
+            'GN' => 'Guinea',
644
+            'GW' => 'Guinea-Bissau',
645
+            'GY' => 'Guyana',
646
+            'HT' => 'Haiti',
647
+            'HM' => 'Heard and McDonald Islands',
648
+            'VA' => 'Holy See (City Vatican State)',
649
+            'HN' => 'Honduras',
650
+            'HK' => 'Hong Kong',
651
+            'HU' => 'Hungary',
652
+            'IS' => 'Iceland',
653
+            'IN' => 'India',
654
+            'ID' => 'Indonesia',
655
+            'IR' => 'Iran',
656
+            'IQ' => 'Iraq',
657
+            'IE' => 'Ireland',
658
+            'IM' => 'Isle of Man',
659
+            'IL' => 'Israel',
660
+            'IT' => 'Italy',
661
+            'JM' => 'Jamaica',
662
+            'JP' => 'Japan',
663
+            'JE' => 'Jersey',
664
+            'JO' => 'Jordan',
665
+            'KZ' => 'Kazakhstan',
666
+            'KE' => 'Kenya',
667
+            'KI' => 'Kiribati',
668
+            'KW' => 'Kuwait',
669
+            'KG' => 'Kyrgyzstan',
670
+            'LA' => 'Lao People\'s Democratic Republic',
671
+            'LV' => 'Latvia',
672
+            'LB' => 'Lebanon',
673
+            'LS' => 'Lesotho',
674
+            'LR' => 'Liberia',
675
+            'LY' => 'Libyan Arab Jamahiriya',
676
+            'LI' => 'Liechtenstein',
677
+            'LT' => 'Lithuania',
678
+            'LU' => 'Luxembourg',
679
+            'MO' => 'Macau',
680
+            'MK' => 'Macedonia',
681
+            'MG' => 'Madagascar',
682
+            'MW' => 'Malawi',
683
+            'MY' => 'Malaysia',
684
+            'MV' => 'Maldives',
685
+            'ML' => 'Mali',
686
+            'MT' => 'Malta',
687
+            'MH' => 'Marshall Islands',
688
+            'MQ' => 'Martinique',
689
+            'MR' => 'Mauritania',
690
+            'MU' => 'Mauritius',
691
+            'YT' => 'Mayotte',
692
+            'MX' => 'Mexico',
693
+            'FM' => 'Micronesia',
694
+            'MD' => 'Moldova, Republic of',
695
+            'MC' => 'Monaco',
696
+            'MN' => 'Mongolia',
697
+            'ME' => 'Montenegro',
698
+            'MS' => 'Montserrat',
699
+            'MA' => 'Morocco',
700
+            'MZ' => 'Mozambique',
701
+            'MM' => 'Myanmar',
702
+            'NA' => 'Namibia',
703
+            'NR' => 'Nauru',
704
+            'NP' => 'Nepal',
705
+            'NL' => 'Netherlands',
706
+            'AN' => 'Netherlands Antilles',
707
+            'NC' => 'New Caledonia',
708
+            'NZ' => 'New Zealand',
709
+            'NI' => 'Nicaragua',
710
+            'NE' => 'Niger',
711
+            'NG' => 'Nigeria',
712
+            'NU' => 'Niue',
713
+            'NF' => 'Norfolk Island',
714
+            'KP' => 'North Korea',
715
+            'MP' => 'Northern Mariana Islands',
716
+            'NO' => 'Norway',
717
+            'OM' => 'Oman',
718
+            'PK' => 'Pakistan',
719
+            'PW' => 'Palau',
720
+            'PS' => 'Palestinian Territories',
721
+            'PA' => 'Panama',
722
+            'PG' => 'Papua New Guinea',
723
+            'PY' => 'Paraguay',
724
+            'PE' => 'Peru',
725
+            'PH' => 'Philippines',
726
+            'PN' => 'Pitcairn Island',
727
+            'PL' => 'Poland',
728
+            'PT' => 'Portugal',
729
+            'PR' => 'Puerto Rico',
730
+            'QA' => 'Qatar',
731
+            'XK' => 'Republic of Kosovo',
732
+            'RE' => 'Reunion Island',
733
+            'RO' => 'Romania',
734
+            'RU' => 'Russian Federation',
735
+            'RW' => 'Rwanda',
736
+            'BL' => 'Saint Barth&eacute;lemy',
737
+            'SH' => 'Saint Helena',
738
+            'KN' => 'Saint Kitts and Nevis',
739
+            'LC' => 'Saint Lucia',
740
+            'MF' => 'Saint Martin (French)',
741
+            'SX' => 'Saint Martin (Dutch)',
742
+            'PM' => 'Saint Pierre and Miquelon',
743
+            'VC' => 'Saint Vincent and the Grenadines',
744
+            'SM' => 'San Marino',
745
+            'ST' => 'S&atilde;o Tom&eacute; and Pr&iacute;ncipe',
746
+            'SA' => 'Saudi Arabia',
747
+            'SN' => 'Senegal',
748
+            'RS' => 'Serbia',
749
+            'SC' => 'Seychelles',
750
+            'SL' => 'Sierra Leone',
751
+            'SG' => 'Singapore',
752
+            'SK' => 'Slovak Republic',
753
+            'SI' => 'Slovenia',
754
+            'SB' => 'Solomon Islands',
755
+            'SO' => 'Somalia',
756
+            'ZA' => 'South Africa',
757
+            'GS' => 'South Georgia',
758
+            'KR' => 'South Korea',
759
+            'SS' => 'South Sudan',
760
+            'ES' => 'Spain',
761
+            'LK' => 'Sri Lanka',
762
+            'SD' => 'Sudan',
763
+            'SR' => 'Suriname',
764
+            'SJ' => 'Svalbard and Jan Mayen Islands',
765
+            'SZ' => 'Swaziland',
766
+            'SE' => 'Sweden',
767
+            'CH' => 'Switzerland',
768
+            'SY' => 'Syrian Arab Republic',
769
+            'TW' => 'Taiwan',
770
+            'TJ' => 'Tajikistan',
771
+            'TZ' => 'Tanzania',
772
+            'TH' => 'Thailand',
773
+            'TL' => 'Timor-Leste',
774
+            'TG' => 'Togo',
775
+            'TK' => 'Tokelau',
776
+            'TO' => 'Tonga',
777
+            'TT' => 'Trinidad and Tobago',
778
+            'TN' => 'Tunisia',
779
+            'TR' => 'Turkey',
780
+            'TM' => 'Turkmenistan',
781
+            'TC' => 'Turks and Caicos Islands',
782
+            'TV' => 'Tuvalu',
783
+            'UG' => 'Uganda',
784
+            'UA' => 'Ukraine',
785
+            'AE' => 'United Arab Emirates',
786
+            'UY' => 'Uruguay',
787
+            'UM' => 'US Minor Outlying Islands',
788
+            'UZ' => 'Uzbekistan',
789
+            'VU' => 'Vanuatu',
790
+            'VE' => 'Venezuela',
791
+            'VN' => 'Vietnam',
792
+            'VG' => 'Virgin Islands (British)',
793
+            'VI' => 'Virgin Islands (USA)',
794
+            'WF' => 'Wallis and Futuna Islands',
795
+            'EH' => 'Western Sahara',
796
+            'WS' => 'Western Samoa',
797
+            'YE' => 'Yemen',
798
+            'ZM' => 'Zambia',
799
+            'ZW' => 'Zimbabwe',
800
+        );		
801
+    }
802
+    return $countries;
803 803
 }
804 804
 
805 805
 function monsterinsights_is_wp_seo_active( ) {
806
-	$wp_seo_active = false; // @todo: improve this check. This is from old Yoast code.
806
+    $wp_seo_active = false; // @todo: improve this check. This is from old Yoast code.
807 807
 	
808
-	// Makes sure is_plugin_active is available when called from front end
809
-	include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
810
-	if ( is_plugin_active( 'wordpress-seo/wp-seo.php' ) || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' ) ) {
811
-		$wp_seo_active = true;
812
-	}
813
-	return $wp_seo_active;
808
+    // Makes sure is_plugin_active is available when called from front end
809
+    include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
810
+    if ( is_plugin_active( 'wordpress-seo/wp-seo.php' ) || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' ) ) {
811
+        $wp_seo_active = true;
812
+    }
813
+    return $wp_seo_active;
814 814
 }
815 815
 
816 816
 function monsterinsights_get_asset_version() {
817
-	if ( monsterinsights_is_debug_mode() ) {
818
-		return time();
819
-	} else {
820
-		return MONSTERINSIGHTS_VERSION;
821
-	}
817
+    if ( monsterinsights_is_debug_mode() ) {
818
+        return time();
819
+    } else {
820
+        return MONSTERINSIGHTS_VERSION;
821
+    }
822 822
 }
823 823
 
824 824
 function monsterinsights_is_debug_mode() {
825
-	$debug_mode = false;
826
-	if ( defined( 'MONSTERINSIGHTS_DEBUG_MODE' ) && MONSTERINSIGHTS_DEBUG_MODE ) {
827
-		$debug_mode = true;
828
-	}
825
+    $debug_mode = false;
826
+    if ( defined( 'MONSTERINSIGHTS_DEBUG_MODE' ) && MONSTERINSIGHTS_DEBUG_MODE ) {
827
+        $debug_mode = true;
828
+    }
829 829
 	
830
-	if ( monsterinsights_get_option( 'debug_mode', false ) ) {
831
-		$debug_mode = true;
832
-	}
830
+    if ( monsterinsights_get_option( 'debug_mode', false ) ) {
831
+        $debug_mode = true;
832
+    }
833 833
 	
834
-	return apply_filters( 'monsterinsights_is_debug_mode', $debug_mode );
834
+    return apply_filters( 'monsterinsights_is_debug_mode', $debug_mode );
835 835
 }
836 836
 
837 837
 function monsterinsights_is_network_active() {
838
-	if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
839
-		require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
840
-	}
838
+    if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
839
+        require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
840
+    }
841 841
 	 
842
-	if ( is_multisite() && is_plugin_active_for_network( plugin_basename( MONSTERINSIGHTS_PLUGIN_FILE ) ) ) {
843
-	   return true;
844
-	} else {
845
-		return false;
846
-	}
842
+    if ( is_multisite() && is_plugin_active_for_network( plugin_basename( MONSTERINSIGHTS_PLUGIN_FILE ) ) ) {
843
+        return true;
844
+    } else {
845
+        return false;
846
+    }
847 847
 }
848 848
 
849 849
 if ( ! function_exists ( 'remove_class_filter' ) ) {
850
-	/**
851
-	 * Remove Class Filter Without Access to Class Object
852
-	 *
853
-	 * In order to use the core WordPress remove_filter() on a filter added with the callback
854
-	 * to a class, you either have to have access to that class object, or it has to be a call
855
-	 * to a static method.  This method allows you to remove filters with a callback to a class
856
-	 * you don't have access to.
857
-	 *
858
-	 * Works with WordPress 1.2 - 4.7+
859
-	 *
860
-	 * @param string $tag         Filter to remove
861
-	 * @param string $class_name  Class name for the filter's callback
862
-	 * @param string $method_name Method name for the filter's callback
863
-	 * @param int    $priority    Priority of the filter (default 10)
864
-	 *
865
-	 * @return bool Whether the function is removed.
866
-	 */
867
-	function remove_class_filter( $tag, $class_name = '', $method_name = '', $priority = 10 ) {
868
-		global $wp_filter;
869
-		// Check that filter actually exists first
870
-		if ( ! isset( $wp_filter[ $tag ] ) ) return FALSE;
871
-		/**
872
-		 * If filter config is an object, means we're using WordPress 4.7+ and the config is no longer
873
-		 * a simple array, rather it is an object that implements the ArrayAccess interface.
874
-		 *
875
-		 * To be backwards compatible, we set $callbacks equal to the correct array as a reference (so $wp_filter is updated)
876
-		 *
877
-		 * @see https://make.wordpress.org/core/2016/09/08/wp_hook-next-generation-actions-and-filters/
878
-		 */
879
-		if ( is_object( $wp_filter[ $tag ] ) && isset( $wp_filter[ $tag ]->callbacks ) ) {
880
-			$callbacks = &$wp_filter[ $tag ]->callbacks;
881
-		} else {
882
-			$callbacks = &$wp_filter[ $tag ];
883
-		}
884
-		// Exit if there aren't any callbacks for specified priority
885
-		if ( ! isset( $callbacks[ $priority ] ) || empty( $callbacks[ $priority ] ) ) return FALSE;
886
-		// Loop through each filter for the specified priority, looking for our class & method
887
-		foreach( (array) $callbacks[ $priority ] as $filter_id => $filter ) {
888
-			// Filter should always be an array - array( $this, 'method' ), if not goto next
889
-			if ( ! isset( $filter[ 'function' ] ) || ! is_array( $filter[ 'function' ] ) ) continue;
890
-			// If first value in array is not an object, it can't be a class
891
-			if ( ! is_object( $filter[ 'function' ][ 0 ] ) ) continue;
892
-			// Method doesn't match the one we're looking for, goto next
893
-			if ( $filter[ 'function' ][ 1 ] !== $method_name ) continue;
894
-			// Method matched, now let's check the Class
895
-			if ( get_class( $filter[ 'function' ][ 0 ] ) === $class_name ) {
896
-				// Now let's remove it from the array
897
-				unset( $callbacks[ $priority ][ $filter_id ] );
898
-				// and if it was the only filter in that priority, unset that priority
899
-				if ( empty( $callbacks[ $priority ] ) ) unset( $callbacks[ $priority ] );
900
-				// and if the only filter for that tag, set the tag to an empty array
901
-				if ( empty( $callbacks ) ) $callbacks = array();
902
-				// If using WordPress older than 4.7
903
-				if ( ! is_object( $wp_filter[ $tag ] ) ) {
904
-					// Remove this filter from merged_filters, which specifies if filters have been sorted
905
-					unset( $GLOBALS[ 'merged_filters' ][ $tag ] );
906
-				}
907
-				return TRUE;
908
-			}
909
-		}
910
-		return FALSE;
911
-	}
850
+    /**
851
+     * Remove Class Filter Without Access to Class Object
852
+     *
853
+     * In order to use the core WordPress remove_filter() on a filter added with the callback
854
+     * to a class, you either have to have access to that class object, or it has to be a call
855
+     * to a static method.  This method allows you to remove filters with a callback to a class
856
+     * you don't have access to.
857
+     *
858
+     * Works with WordPress 1.2 - 4.7+
859
+     *
860
+     * @param string $tag         Filter to remove
861
+     * @param string $class_name  Class name for the filter's callback
862
+     * @param string $method_name Method name for the filter's callback
863
+     * @param int    $priority    Priority of the filter (default 10)
864
+     *
865
+     * @return bool Whether the function is removed.
866
+     */
867
+    function remove_class_filter( $tag, $class_name = '', $method_name = '', $priority = 10 ) {
868
+        global $wp_filter;
869
+        // Check that filter actually exists first
870
+        if ( ! isset( $wp_filter[ $tag ] ) ) return FALSE;
871
+        /**
872
+         * If filter config is an object, means we're using WordPress 4.7+ and the config is no longer
873
+         * a simple array, rather it is an object that implements the ArrayAccess interface.
874
+         *
875
+         * To be backwards compatible, we set $callbacks equal to the correct array as a reference (so $wp_filter is updated)
876
+         *
877
+         * @see https://make.wordpress.org/core/2016/09/08/wp_hook-next-generation-actions-and-filters/
878
+         */
879
+        if ( is_object( $wp_filter[ $tag ] ) && isset( $wp_filter[ $tag ]->callbacks ) ) {
880
+            $callbacks = &$wp_filter[ $tag ]->callbacks;
881
+        } else {
882
+            $callbacks = &$wp_filter[ $tag ];
883
+        }
884
+        // Exit if there aren't any callbacks for specified priority
885
+        if ( ! isset( $callbacks[ $priority ] ) || empty( $callbacks[ $priority ] ) ) return FALSE;
886
+        // Loop through each filter for the specified priority, looking for our class & method
887
+        foreach( (array) $callbacks[ $priority ] as $filter_id => $filter ) {
888
+            // Filter should always be an array - array( $this, 'method' ), if not goto next
889
+            if ( ! isset( $filter[ 'function' ] ) || ! is_array( $filter[ 'function' ] ) ) continue;
890
+            // If first value in array is not an object, it can't be a class
891
+            if ( ! is_object( $filter[ 'function' ][ 0 ] ) ) continue;
892
+            // Method doesn't match the one we're looking for, goto next
893
+            if ( $filter[ 'function' ][ 1 ] !== $method_name ) continue;
894
+            // Method matched, now let's check the Class
895
+            if ( get_class( $filter[ 'function' ][ 0 ] ) === $class_name ) {
896
+                // Now let's remove it from the array
897
+                unset( $callbacks[ $priority ][ $filter_id ] );
898
+                // and if it was the only filter in that priority, unset that priority
899
+                if ( empty( $callbacks[ $priority ] ) ) unset( $callbacks[ $priority ] );
900
+                // and if the only filter for that tag, set the tag to an empty array
901
+                if ( empty( $callbacks ) ) $callbacks = array();
902
+                // If using WordPress older than 4.7
903
+                if ( ! is_object( $wp_filter[ $tag ] ) ) {
904
+                    // Remove this filter from merged_filters, which specifies if filters have been sorted
905
+                    unset( $GLOBALS[ 'merged_filters' ][ $tag ] );
906
+                }
907
+                return TRUE;
908
+            }
909
+        }
910
+        return FALSE;
911
+    }
912 912
 } // End function exists
913 913
 
914 914
 if ( ! function_exists ( 'remove_class_action' ) ) {
915
-	/**
916
-	 * Remove Class Action Without Access to Class Object
917
-	 *
918
-	 * In order to use the core WordPress remove_action() on an action added with the callback
919
-	 * to a class, you either have to have access to that class object, or it has to be a call
920
-	 * to a static method.  This method allows you to remove actions with a callback to a class
921
-	 * you don't have access to.
922
-	 *
923
-	 * Works with WordPress 1.2 - 4.7+
924
-	 *
925
-	 * @param string $tag         Action to remove
926
-	 * @param string $class_name  Class name for the action's callback
927
-	 * @param string $method_name Method name for the action's callback
928
-	 * @param int    $priority    Priority of the action (default 10)
929
-	 *
930
-	 * @return bool               Whether the function is removed.
931
-	 */
932
-	function remove_class_action( $tag, $class_name = '', $method_name = '', $priority = 10 ) {
933
-		remove_class_filter( $tag, $class_name, $method_name, $priority );
934
-	}
915
+    /**
916
+     * Remove Class Action Without Access to Class Object
917
+     *
918
+     * In order to use the core WordPress remove_action() on an action added with the callback
919
+     * to a class, you either have to have access to that class object, or it has to be a call
920
+     * to a static method.  This method allows you to remove actions with a callback to a class
921
+     * you don't have access to.
922
+     *
923
+     * Works with WordPress 1.2 - 4.7+
924
+     *
925
+     * @param string $tag         Action to remove
926
+     * @param string $class_name  Class name for the action's callback
927
+     * @param string $method_name Method name for the action's callback
928
+     * @param int    $priority    Priority of the action (default 10)
929
+     *
930
+     * @return bool               Whether the function is removed.
931
+     */
932
+    function remove_class_action( $tag, $class_name = '', $method_name = '', $priority = 10 ) {
933
+        remove_class_filter( $tag, $class_name, $method_name, $priority );
934
+    }
935 935
 } // End function exists
936 936
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +21 added lines, -7 removed lines patch added patch discarded remove patch
@@ -867,7 +867,9 @@  discard block
 block discarded – undo
867 867
 	function remove_class_filter( $tag, $class_name = '', $method_name = '', $priority = 10 ) {
868 868
 		global $wp_filter;
869 869
 		// Check that filter actually exists first
870
-		if ( ! isset( $wp_filter[ $tag ] ) ) return FALSE;
870
+		if ( ! isset( $wp_filter[ $tag ] ) ) {
871
+		    return FALSE;
872
+		}
871 873
 		/**
872 874
 		 * If filter config is an object, means we're using WordPress 4.7+ and the config is no longer
873 875
 		 * a simple array, rather it is an object that implements the ArrayAccess interface.
@@ -882,23 +884,35 @@  discard block
 block discarded – undo
882 884
 			$callbacks = &$wp_filter[ $tag ];
883 885
 		}
884 886
 		// Exit if there aren't any callbacks for specified priority
885
-		if ( ! isset( $callbacks[ $priority ] ) || empty( $callbacks[ $priority ] ) ) return FALSE;
887
+		if ( ! isset( $callbacks[ $priority ] ) || empty( $callbacks[ $priority ] ) ) {
888
+		    return FALSE;
889
+		}
886 890
 		// Loop through each filter for the specified priority, looking for our class & method
887 891
 		foreach( (array) $callbacks[ $priority ] as $filter_id => $filter ) {
888 892
 			// Filter should always be an array - array( $this, 'method' ), if not goto next
889
-			if ( ! isset( $filter[ 'function' ] ) || ! is_array( $filter[ 'function' ] ) ) continue;
893
+			if ( ! isset( $filter[ 'function' ] ) || ! is_array( $filter[ 'function' ] ) ) {
894
+			    continue;
895
+			}
890 896
 			// If first value in array is not an object, it can't be a class
891
-			if ( ! is_object( $filter[ 'function' ][ 0 ] ) ) continue;
897
+			if ( ! is_object( $filter[ 'function' ][ 0 ] ) ) {
898
+			    continue;
899
+			}
892 900
 			// Method doesn't match the one we're looking for, goto next
893
-			if ( $filter[ 'function' ][ 1 ] !== $method_name ) continue;
901
+			if ( $filter[ 'function' ][ 1 ] !== $method_name ) {
902
+			    continue;
903
+			}
894 904
 			// Method matched, now let's check the Class
895 905
 			if ( get_class( $filter[ 'function' ][ 0 ] ) === $class_name ) {
896 906
 				// Now let's remove it from the array
897 907
 				unset( $callbacks[ $priority ][ $filter_id ] );
898 908
 				// and if it was the only filter in that priority, unset that priority
899
-				if ( empty( $callbacks[ $priority ] ) ) unset( $callbacks[ $priority ] );
909
+				if ( empty( $callbacks[ $priority ] ) ) {
910
+				    unset( $callbacks[ $priority ] );
911
+				}
900 912
 				// and if the only filter for that tag, set the tag to an empty array
901
-				if ( empty( $callbacks ) ) $callbacks = array();
913
+				if ( empty( $callbacks ) ) {
914
+				    $callbacks = array();
915
+				}
902 916
 				// If using WordPress older than 4.7
903 917
 				if ( ! is_object( $wp_filter[ $tag ] ) ) {
904 918
 					// Remove this filter from merged_filters, which specifies if filters have been sorted
Please login to merge, or discard this patch.
includes/frontend/frontend.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  */
10 10
 
11 11
 // Exit if accessed directly
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
     exit;
14 14
 }
15 15
 
@@ -28,47 +28,47 @@  discard block
 block discarded – undo
28 28
  */
29 29
 function monsterinsights_tracking_script( ) {
30 30
 
31
-    $tracking_mode = monsterinsights_get_option( 'tracking_mode', 'analytics' );
31
+    $tracking_mode = monsterinsights_get_option('tracking_mode', 'analytics');
32 32
 
33
-    require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/class-tracking-abstract.php';
33
+    require_once plugin_dir_path(MONSTERINSIGHTS_PLUGIN_FILE) . 'includes/frontend/class-tracking-abstract.php';
34 34
     $mode = '';
35 35
 
36
-    if ( is_preview() ) {
36
+    if (is_preview()) {
37 37
         $mode = 'preview';
38
-    } else if ( ! monsterinsights_track_user() ) {
38
+    } else if ( ! monsterinsights_track_user()) {
39 39
         $mode = 'disabled';
40
-    } else if ( $tracking_mode === 'analytics' ) {
40
+    } else if ($tracking_mode === 'analytics') {
41 41
         $mode = 'analytics';
42
-    } else if ( $tracking_mode === 'ga' ) {
42
+    } else if ($tracking_mode === 'ga') {
43 43
         $mode = 'ga';
44 44
     } else {
45 45
         //$mode = apply_filters( 'monsterinsights_custom_tracking_name', 'name-of-method' );
46 46
     }
47 47
 
48
-    do_action( 'monsterinsights_tracking_before_' . $mode );
49
-    do_action( 'monsterinsights_tracking_before', $mode );
48
+    do_action('monsterinsights_tracking_before_' . $mode);
49
+    do_action('monsterinsights_tracking_before', $mode);
50 50
 
51
-    switch ( $mode ) {
51
+    switch ($mode) {
52 52
         case 'preview':
53
-            require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/tracking/class-tracking-preview.php';
53
+            require_once plugin_dir_path(MONSTERINSIGHTS_PLUGIN_FILE) . 'includes/frontend/tracking/class-tracking-preview.php';
54 54
             $tracking = new MonsterInsights_Tracking_Preview();
55 55
             echo $tracking->frontend_output();
56 56
             break;
57 57
 
58 58
         case 'disabled':
59
-            require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/tracking/class-tracking-disabled.php';
59
+            require_once plugin_dir_path(MONSTERINSIGHTS_PLUGIN_FILE) . 'includes/frontend/tracking/class-tracking-disabled.php';
60 60
             $tracking = new MonsterInsights_Tracking_Disabled();
61 61
             echo $tracking->frontend_output();
62 62
             break;
63 63
 
64 64
         case 'analytics':
65
-            require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/tracking/class-tracking-analytics.php';
65
+            require_once plugin_dir_path(MONSTERINSIGHTS_PLUGIN_FILE) . 'includes/frontend/tracking/class-tracking-analytics.php';
66 66
             $tracking = new MonsterInsights_Tracking_Analytics();
67 67
             echo $tracking->frontend_output();
68 68
             break;
69 69
 
70 70
         case 'ga':
71
-            require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/tracking/class-tracking-ga.php';
71
+            require_once plugin_dir_path(MONSTERINSIGHTS_PLUGIN_FILE) . 'includes/frontend/tracking/class-tracking-ga.php';
72 72
             $tracking = new MonsterInsights_Tracking_GA();
73 73
             echo $tracking->frontend_output();
74 74
             break;
@@ -78,10 +78,10 @@  discard block
 block discarded – undo
78 78
             break;
79 79
     }
80 80
 
81
-    do_action( 'monsterinsights_tracking_after_' . $mode );
82
-    do_action( 'monsterinsights_tracking_after', $mode );
81
+    do_action('monsterinsights_tracking_after_' . $mode);
82
+    do_action('monsterinsights_tracking_after', $mode);
83 83
 }
84
-add_action( 'wp_head', 'monsterinsights_tracking_script', 6 );
84
+add_action('wp_head', 'monsterinsights_tracking_script', 6);
85 85
 //add_action( 'login_head', 'monsterinsights_tracking_script', 6 );
86 86
 
87 87
 /**
@@ -97,21 +97,21 @@  discard block
 block discarded – undo
97 97
  * @return array Array of the options to use.
98 98
  */
99 99
 function monsterinsights_events_tracking( ) {
100
-    $events_mode   = monsterinsights_get_option( 'events_mode', false );
101
-    $tracking_mode = monsterinsights_get_option( 'tracking_mode', 'analytics' );
100
+    $events_mode   = monsterinsights_get_option('events_mode', false);
101
+    $tracking_mode = monsterinsights_get_option('tracking_mode', 'analytics');
102 102
     $track_user    = monsterinsights_track_user();
103 103
 
104
-    if ( $track_user && $events_mode === 'php' && ( $tracking_mode === 'ga' || $tracking_mode === 'analytics' ) ) {
105
-        require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/events/class-events-php.php';
104
+    if ($track_user && $events_mode === 'php' && ($tracking_mode === 'ga' || $tracking_mode === 'analytics')) {
105
+        require_once plugin_dir_path(MONSTERINSIGHTS_PLUGIN_FILE) . 'includes/frontend/events/class-events-php.php';
106 106
         new MonsterInsights_Events_PHP();
107
-    } else if ( $track_user && $events_mode === 'js' && $tracking_mode === 'analytics' ) {
108
-        require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/events/class-events-js.php';
107
+    } else if ($track_user && $events_mode === 'js' && $tracking_mode === 'analytics') {
108
+        require_once plugin_dir_path(MONSTERINSIGHTS_PLUGIN_FILE) . 'includes/frontend/events/class-events-js.php';
109 109
         new MonsterInsights_Events_JS();
110 110
     } else {
111 111
         // User is in the disabled group or events mode is off
112 112
     }
113 113
 }
114
-add_action( 'template_redirect', 'monsterinsights_events_tracking', 9 );
114
+add_action('template_redirect', 'monsterinsights_events_tracking', 9);
115 115
 
116 116
 /**
117 117
  * Add the UTM source parameters in the RSS feeds to track traffic.
@@ -123,22 +123,22 @@  discard block
 block discarded – undo
123 123
  *
124 124
  * @return string The new link for the RSS feed.
125 125
  */
126
-function monsterinsights_rss_link_tagger( $guid ) {
126
+function monsterinsights_rss_link_tagger($guid) {
127 127
     global $post;
128 128
 
129
-    if ( monsterinsights_get_option( 'tag_links_in_rss', false ) ){
130
-        if ( is_feed() ) {
131
-            if ( monsterinsights_get_option( 'allow_anchor', false ) ) {
129
+    if (monsterinsights_get_option('tag_links_in_rss', false)) {
130
+        if (is_feed()) {
131
+            if (monsterinsights_get_option('allow_anchor', false)) {
132 132
                 $delimiter = '#';
133 133
             } else {
134 134
                 $delimiter = '?';
135
-                if ( strpos( $guid, $delimiter ) > 0 ) {
135
+                if (strpos($guid, $delimiter) > 0) {
136 136
                     $delimiter = '&amp;';
137 137
                 }
138 138
             }
139
-            return $guid . $delimiter . 'utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=' . urlencode( $post->post_name );
139
+            return $guid . $delimiter . 'utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=' . urlencode($post->post_name);
140 140
         }
141 141
     }
142 142
     return $guid;
143 143
 }
144
-add_filter( 'the_permalink_rss', 'monsterinsights_rss_link_tagger', 99 );
145 144
\ No newline at end of file
145
+add_filter('the_permalink_rss', 'monsterinsights_rss_link_tagger', 99);
146 146
\ No newline at end of file
Please login to merge, or discard this patch.
includes/frontend/tracking/class-tracking-analytics.php 2 patches
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  */
10 10
 
11 11
 // Exit if accessed directly
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit;
14 14
 }
15 15
 
@@ -71,94 +71,94 @@  discard block
 block discarded – undo
71 71
 		global $wp_query;
72 72
 		$options = array();
73 73
 
74
-		if ( monsterinsights_get_ua_to_output() ) {
74
+		if (monsterinsights_get_ua_to_output()) {
75 75
 			$ua_code = monsterinsights_get_ua_to_output();
76 76
 		} else {
77 77
 			return $options;
78 78
 		}
79 79
 
80 80
 		$domain = 'auto'; // Default domain value
81
-		if ( monsterinsights_get_option( 'subdomain_tracking', false ) ) {
82
-			$domain = esc_attr( monsterinsights_get_option( 'subdomain_tracking', '' ) );
81
+		if (monsterinsights_get_option('subdomain_tracking', false)) {
82
+			$domain = esc_attr(monsterinsights_get_option('subdomain_tracking', ''));
83 83
 		}
84 84
 
85
-		$allow_linker = monsterinsights_get_option( 'add_allow_linker', false );
86
-		$allow_anchor = monsterinsights_get_option( 'allow_anchor', false );
85
+		$allow_linker = monsterinsights_get_option('add_allow_linker', false);
86
+		$allow_anchor = monsterinsights_get_option('allow_anchor', false);
87 87
 
88 88
 
89 89
 		$create = array();
90
-		if ( $allow_anchor ) {
90
+		if ($allow_anchor) {
91 91
 			$create['allowAnchor'] = true;
92 92
 		}
93 93
 
94
-		if ( $allow_linker ) {
94
+		if ($allow_linker) {
95 95
 			$create['allowLinker'] = true;
96 96
 		}
97 97
 
98
-		$create = apply_filters( 'monsterinsights_frontend_tracking_options_analytics_create', $create );
98
+		$create = apply_filters('monsterinsights_frontend_tracking_options_analytics_create', $create);
99 99
 
100
-		if ( $create && ! empty( $create ) && is_array( $create ) ) {
101
-			$create = json_encode( $create );
102
-			$create = str_replace( '"', "'",  $create );
103
-			$options['create'] = "'create', '" . esc_js( $ua_code ). "', '" . esc_js( $domain ) . "', " . $create;
100
+		if ($create && ! empty($create) && is_array($create)) {
101
+			$create = json_encode($create);
102
+			$create = str_replace('"', "'", $create);
103
+			$options['create'] = "'create', '" . esc_js($ua_code) . "', '" . esc_js($domain) . "', " . $create;
104 104
 		} else {
105
-			$options['create'] = "'create', '" . esc_js( $ua_code ) . "', '" . esc_js( $domain ) . "'";
105
+			$options['create'] = "'create', '" . esc_js($ua_code) . "', '" . esc_js($domain) . "'";
106 106
 		}
107 107
 
108 108
 		$options['forceSSL'] = "'set', 'forceSSL', true";
109 109
 
110
-		if ( monsterinsights_get_option( 'custom_code', false ) ) {
110
+		if (monsterinsights_get_option('custom_code', false)) {
111 111
 			// Add custom code to the view
112 112
 			$options['custom_code'] = array(
113 113
 				'type'  => 'custom_code',
114
-				'value' => stripslashes( monsterinsights_get_option( 'custom_code', '' ) ),
114
+				'value' => stripslashes(monsterinsights_get_option('custom_code', '')),
115 115
 			);
116 116
 		}
117 117
 
118 118
 		// Anonymous data
119
-		if ( monsterinsights_get_option( 'anonymize_ips', false ) ) {
119
+		if (monsterinsights_get_option('anonymize_ips', false)) {
120 120
 			$options['anonymize_ips'] = "'set', 'anonymizeIp', true";
121 121
 		}
122 122
 
123
-		$options = apply_filters( 'monsterinsights_frontend_tracking_options_analytics_before_scripts', $options );
123
+		$options = apply_filters('monsterinsights_frontend_tracking_options_analytics_before_scripts', $options);
124 124
 
125 125
 		// add demographics
126
-		if ( monsterinsights_get_option( 'demographics', false ) ) {
126
+		if (monsterinsights_get_option('demographics', false)) {
127 127
 			$options['demographics'] = "'require', 'displayfeatures'";
128 128
 		}
129 129
 
130 130
 		// Check for Enhanced link attribution
131
-		if ( monsterinsights_get_option( 'enhanced_link_attribution', false ) ) {
131
+		if (monsterinsights_get_option('enhanced_link_attribution', false)) {
132 132
 			$options['enhanced_link_attribution'] = "'require', 'linkid', 'linkid.js'";
133 133
 		}
134 134
 
135
-		$options = apply_filters( 'monsterinsights_frontend_tracking_options_analytics_before_pageview', $options );
136
-		$options = apply_filters( 'monsterinsights_frontend_tracking_options_before_pageview', $options, $this->name, $this->version );
135
+		$options = apply_filters('monsterinsights_frontend_tracking_options_analytics_before_pageview', $options);
136
+		$options = apply_filters('monsterinsights_frontend_tracking_options_before_pageview', $options, $this->name, $this->version);
137 137
 
138
-		if ( is_404() ) {
139
-			if ( monsterinsights_get_option( 'hash_tracking', false ) ) {
138
+		if (is_404()) {
139
+			if (monsterinsights_get_option('hash_tracking', false)) {
140 140
 				$options['send'] = "'send','pageview','/404.html?page=' + document.location.pathname + document.location.search + location.hash + '&from=' + document.referrer";
141 141
 			} else {
142 142
 				$options['send'] = "'send','pageview','/404.html?page=' + document.location.pathname + document.location.search + '&from=' + document.referrer";
143 143
 			}
144
-		} else if ( $wp_query->is_search ) {
144
+		} else if ($wp_query->is_search) {
145 145
 			$pushstr = "'send','pageview','/?s=";
146
-			if ( (int) $wp_query->found_posts === 0 ) {
147
-				$options['send'] = $pushstr . 'no-results:' . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=no-results'";
148
-			} else if ( (int) $wp_query->found_posts === 1 ) {
149
-				$options['send'] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=1-result'";
150
-			} else if ( $wp_query->found_posts > 1 && $wp_query->found_posts < 6 ) {
151
-				$options['send'] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=2-5-results'";
146
+			if ((int) $wp_query->found_posts === 0) {
147
+				$options['send'] = $pushstr . 'no-results:' . rawurlencode($wp_query->query_vars['s']) . "&cat=no-results'";
148
+			} else if ((int) $wp_query->found_posts === 1) {
149
+				$options['send'] = $pushstr . rawurlencode($wp_query->query_vars['s']) . "&cat=1-result'";
150
+			} else if ($wp_query->found_posts > 1 && $wp_query->found_posts < 6) {
151
+				$options['send'] = $pushstr . rawurlencode($wp_query->query_vars['s']) . "&cat=2-5-results'";
152 152
 			} else {
153
-				$options['send'] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=plus-5-results'";
153
+				$options['send'] = $pushstr . rawurlencode($wp_query->query_vars['s']) . "&cat=plus-5-results'";
154 154
 			}
155
-		} else if ( monsterinsights_get_option( 'hash_tracking', false ) ) {
155
+		} else if (monsterinsights_get_option('hash_tracking', false)) {
156 156
 			$options['send'] = "'send','pageview', location.pathname + location.search + location.hash";
157 157
 		} else {
158 158
 			$options['send'] = "'send','pageview'";
159 159
 		}
160 160
 
161
-		$options = apply_filters( 'monsterinsights_frontend_tracking_options_analytics_end', $options );
161
+		$options = apply_filters('monsterinsights_frontend_tracking_options_analytics_end', $options);
162 162
 		return $options;
163 163
 	}
164 164
 
@@ -176,19 +176,19 @@  discard block
 block discarded – undo
176 176
 	 */
177 177
 	public function frontend_output( ) {
178 178
 		$options        = $this->frontend_tracking_options();
179
-		$is_debug_mode  =  monsterinsights_is_debug_mode();
180
-		$src     	    = apply_filters( 'monsterinsights_frontend_output_analytics_src', '//www.google-analytics.com/analytics.js' );
181
-		if ( current_user_can( 'manage_options' ) && $is_debug_mode ) {
182
-			$src     = apply_filters( 'monsterinsights_frontend_output_analytics_src', '//www.google-analytics.com/analytics_debug.js' );
179
+		$is_debug_mode  = monsterinsights_is_debug_mode();
180
+		$src = apply_filters('monsterinsights_frontend_output_analytics_src', '//www.google-analytics.com/analytics.js');
181
+		if (current_user_can('manage_options') && $is_debug_mode) {
182
+			$src = apply_filters('monsterinsights_frontend_output_analytics_src', '//www.google-analytics.com/analytics_debug.js');
183 183
 		}
184
-		$compat  = monsterinsights_get_option( 'gatracker_compatibility_mode', false );
184
+		$compat  = monsterinsights_get_option('gatracker_compatibility_mode', false);
185 185
 		$compat  = $compat ? 'window.ga = __gaTracker;' : '';
186 186
 		ob_start();
187 187
 		?>
188 188
 <!-- This site uses the Google Analytics by MonsterInsights plugin v<?php echo MONSTERINSIGHTS_VERSION; ?> - Using Analytics tracking - https://www.monsterinsights.com/ -->
189
-<?php if ( monsterinsights_get_ua() ) { ?>
189
+<?php if (monsterinsights_get_ua()) { ?>
190 190
 <script type="text/javascript" data-cfasync="false">
191
-	<?php if ( $this->should_do_optout() ) { ?>
191
+	<?php if ($this->should_do_optout()) { ?>
192 192
 	var disableStr = 'ga-disable-<?php echo monsterinsights_get_ua(); ?>';
193 193
 
194 194
 	/* Function to detect opted out users */
@@ -213,15 +213,15 @@  discard block
 block discarded – undo
213 213
 	})(window,document,'script','<?php echo $src; ?>','__gaTracker');
214 214
 
215 215
 <?php
216
-if ( current_user_can( 'manage_options' ) && $is_debug_mode ) {
216
+if (current_user_can('manage_options') && $is_debug_mode) {
217 217
 	echo 'window.ga_debug = {trace: true};';
218 218
 }
219 219
 echo $compat;
220
-if ( count( $options ) >= 1 ) {
221
-	foreach ( $options as $item ) {
222
-		if ( ! is_array( $item ) ) {
220
+if (count($options) >= 1) {
221
+	foreach ($options as $item) {
222
+		if ( ! is_array($item)) {
223 223
 			echo '	__gaTracker(' . $item . ");\n";
224
-		} else if ( ! empty ( $item['value'] ) ) {
224
+		} else if ( ! empty ($item['value'])) {
225 225
 			echo '	' . $item['value'] . "\n";
226 226
 		}
227 227
 	}
@@ -239,6 +239,6 @@  discard block
 block discarded – undo
239 239
 	}
240 240
 
241 241
 	public function should_do_optout() {
242
-		return ! ( defined( 'MI_NO_TRACKING_OPTOUT' ) && MI_NO_TRACKING_OPTOUT );
242
+		return ! (defined('MI_NO_TRACKING_OPTOUT') && MI_NO_TRACKING_OPTOUT);
243 243
 	}
244 244
 }
Please login to merge, or discard this patch.
Indentation   +186 added lines, -186 removed lines patch added patch discarded remove patch
@@ -10,181 +10,181 @@  discard block
 block discarded – undo
10 10
 
11 11
 // Exit if accessed directly
12 12
 if ( ! defined( 'ABSPATH' ) ) {
13
-	exit;
13
+    exit;
14 14
 }
15 15
 
16 16
 class MonsterInsights_Tracking_Analytics extends MonsterInsights_Tracking_Abstract {
17 17
 
18
-	/**
19
-	 * Holds the base class object.
20
-	 *
21
-	 * @since 6.0.0
22
-	 * @access public
23
-	 *
24
-	 * @var object $base Base class object.
25
-	 */
26
-	public $base;
18
+    /**
19
+     * Holds the base class object.
20
+     *
21
+     * @since 6.0.0
22
+     * @access public
23
+     *
24
+     * @var object $base Base class object.
25
+     */
26
+    public $base;
27 27
 	
28
-	/**
29
-	 * Holds the name of the tracking type.
30
-	 *
31
-	 * @since 6.0.0
32
-	 * @access public
33
-	 *
34
-	 * @var string $name Name of the tracking type.
35
-	 */
36
-	public $name = 'analytics';
37
-
38
-	/**
39
-	 * Version of the tracking class.
40
-	 *
41
-	 * @since 6.0.0
42
-	 * @access public
43
-	 *
44
-	 * @var string $version Version of the tracking class.
45
-	 */
46
-	public $version = '1.0.0';
47
-
48
-	/**
49
-	 * Primary class constructor.
50
-	 *
51
-	 * @since 6.0.0
52
-	 * @access public
53
-	 */
54
-	public function __construct() {
55
-		$this->base = MonsterInsights();
56
-	}
57
-
58
-	/**
59
-	 * Get frontend tracking options.
60
-	 *
61
-	 * This function is used to return an array of parameters
62
-	 * for the frontend_output() function to output. These are 
63
-	 * generally dimensions and turned on GA features.
64
-	 *
65
-	 * @since 6.0.0
66
-	 * @access public
67
-	 *
68
-	 * @return array Array of the options to use.
69
-	 */
70
-	public function frontend_tracking_options( ) {
71
-		global $wp_query;
72
-		$options = array();
73
-
74
-		if ( monsterinsights_get_ua_to_output() ) {
75
-			$ua_code = monsterinsights_get_ua_to_output();
76
-		} else {
77
-			return $options;
78
-		}
79
-
80
-		$domain = 'auto'; // Default domain value
81
-		if ( monsterinsights_get_option( 'subdomain_tracking', false ) ) {
82
-			$domain = esc_attr( monsterinsights_get_option( 'subdomain_tracking', '' ) );
83
-		}
84
-
85
-		$allow_linker = monsterinsights_get_option( 'add_allow_linker', false );
86
-		$allow_anchor = monsterinsights_get_option( 'allow_anchor', false );
87
-
88
-
89
-		$create = array();
90
-		if ( $allow_anchor ) {
91
-			$create['allowAnchor'] = true;
92
-		}
93
-
94
-		if ( $allow_linker ) {
95
-			$create['allowLinker'] = true;
96
-		}
97
-
98
-		$create = apply_filters( 'monsterinsights_frontend_tracking_options_analytics_create', $create );
99
-
100
-		if ( $create && ! empty( $create ) && is_array( $create ) ) {
101
-			$create = json_encode( $create );
102
-			$create = str_replace( '"', "'",  $create );
103
-			$options['create'] = "'create', '" . esc_js( $ua_code ). "', '" . esc_js( $domain ) . "', " . $create;
104
-		} else {
105
-			$options['create'] = "'create', '" . esc_js( $ua_code ) . "', '" . esc_js( $domain ) . "'";
106
-		}
107
-
108
-		$options['forceSSL'] = "'set', 'forceSSL', true";
109
-
110
-		if ( monsterinsights_get_option( 'custom_code', false ) ) {
111
-			// Add custom code to the view
112
-			$options['custom_code'] = array(
113
-				'type'  => 'custom_code',
114
-				'value' => stripslashes( monsterinsights_get_option( 'custom_code', '' ) ),
115
-			);
116
-		}
117
-
118
-		// Anonymous data
119
-		if ( monsterinsights_get_option( 'anonymize_ips', false ) ) {
120
-			$options['anonymize_ips'] = "'set', 'anonymizeIp', true";
121
-		}
122
-
123
-		$options = apply_filters( 'monsterinsights_frontend_tracking_options_analytics_before_scripts', $options );
124
-
125
-		// add demographics
126
-		if ( monsterinsights_get_option( 'demographics', false ) ) {
127
-			$options['demographics'] = "'require', 'displayfeatures'";
128
-		}
129
-
130
-		// Check for Enhanced link attribution
131
-		if ( monsterinsights_get_option( 'enhanced_link_attribution', false ) ) {
132
-			$options['enhanced_link_attribution'] = "'require', 'linkid', 'linkid.js'";
133
-		}
134
-
135
-		$options = apply_filters( 'monsterinsights_frontend_tracking_options_analytics_before_pageview', $options );
136
-		$options = apply_filters( 'monsterinsights_frontend_tracking_options_before_pageview', $options, $this->name, $this->version );
137
-
138
-		if ( is_404() ) {
139
-			if ( monsterinsights_get_option( 'hash_tracking', false ) ) {
140
-				$options['send'] = "'send','pageview','/404.html?page=' + document.location.pathname + document.location.search + location.hash + '&from=' + document.referrer";
141
-			} else {
142
-				$options['send'] = "'send','pageview','/404.html?page=' + document.location.pathname + document.location.search + '&from=' + document.referrer";
143
-			}
144
-		} else if ( $wp_query->is_search ) {
145
-			$pushstr = "'send','pageview','/?s=";
146
-			if ( (int) $wp_query->found_posts === 0 ) {
147
-				$options['send'] = $pushstr . 'no-results:' . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=no-results'";
148
-			} else if ( (int) $wp_query->found_posts === 1 ) {
149
-				$options['send'] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=1-result'";
150
-			} else if ( $wp_query->found_posts > 1 && $wp_query->found_posts < 6 ) {
151
-				$options['send'] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=2-5-results'";
152
-			} else {
153
-				$options['send'] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=plus-5-results'";
154
-			}
155
-		} else if ( monsterinsights_get_option( 'hash_tracking', false ) ) {
156
-			$options['send'] = "'send','pageview', location.pathname + location.search + location.hash";
157
-		} else {
158
-			$options['send'] = "'send','pageview'";
159
-		}
160
-
161
-		$options = apply_filters( 'monsterinsights_frontend_tracking_options_analytics_end', $options );
162
-		return $options;
163
-	}
164
-
165
-	/**
166
-	 * Get frontend output.
167
-	 *
168
-	 * This function is used to return the Javascript
169
-	 * to output in the head of the page for the given
170
-	 * tracking method.
171
-	 *
172
-	 * @since 6.0.0
173
-	 * @access public
174
-	 *
175
-	 * @return string Javascript to output.
176
-	 */
177
-	public function frontend_output( ) {
178
-		$options        = $this->frontend_tracking_options();
179
-		$is_debug_mode  =  monsterinsights_is_debug_mode();
180
-		$src     	    = apply_filters( 'monsterinsights_frontend_output_analytics_src', '//www.google-analytics.com/analytics.js' );
181
-		if ( current_user_can( 'manage_options' ) && $is_debug_mode ) {
182
-			$src     = apply_filters( 'monsterinsights_frontend_output_analytics_src', '//www.google-analytics.com/analytics_debug.js' );
183
-		}
184
-		$compat  = monsterinsights_get_option( 'gatracker_compatibility_mode', false );
185
-		$compat  = $compat ? 'window.ga = __gaTracker;' : '';
186
-		ob_start();
187
-		?>
28
+    /**
29
+     * Holds the name of the tracking type.
30
+     *
31
+     * @since 6.0.0
32
+     * @access public
33
+     *
34
+     * @var string $name Name of the tracking type.
35
+     */
36
+    public $name = 'analytics';
37
+
38
+    /**
39
+     * Version of the tracking class.
40
+     *
41
+     * @since 6.0.0
42
+     * @access public
43
+     *
44
+     * @var string $version Version of the tracking class.
45
+     */
46
+    public $version = '1.0.0';
47
+
48
+    /**
49
+     * Primary class constructor.
50
+     *
51
+     * @since 6.0.0
52
+     * @access public
53
+     */
54
+    public function __construct() {
55
+        $this->base = MonsterInsights();
56
+    }
57
+
58
+    /**
59
+     * Get frontend tracking options.
60
+     *
61
+     * This function is used to return an array of parameters
62
+     * for the frontend_output() function to output. These are 
63
+     * generally dimensions and turned on GA features.
64
+     *
65
+     * @since 6.0.0
66
+     * @access public
67
+     *
68
+     * @return array Array of the options to use.
69
+     */
70
+    public function frontend_tracking_options( ) {
71
+        global $wp_query;
72
+        $options = array();
73
+
74
+        if ( monsterinsights_get_ua_to_output() ) {
75
+            $ua_code = monsterinsights_get_ua_to_output();
76
+        } else {
77
+            return $options;
78
+        }
79
+
80
+        $domain = 'auto'; // Default domain value
81
+        if ( monsterinsights_get_option( 'subdomain_tracking', false ) ) {
82
+            $domain = esc_attr( monsterinsights_get_option( 'subdomain_tracking', '' ) );
83
+        }
84
+
85
+        $allow_linker = monsterinsights_get_option( 'add_allow_linker', false );
86
+        $allow_anchor = monsterinsights_get_option( 'allow_anchor', false );
87
+
88
+
89
+        $create = array();
90
+        if ( $allow_anchor ) {
91
+            $create['allowAnchor'] = true;
92
+        }
93
+
94
+        if ( $allow_linker ) {
95
+            $create['allowLinker'] = true;
96
+        }
97
+
98
+        $create = apply_filters( 'monsterinsights_frontend_tracking_options_analytics_create', $create );
99
+
100
+        if ( $create && ! empty( $create ) && is_array( $create ) ) {
101
+            $create = json_encode( $create );
102
+            $create = str_replace( '"', "'",  $create );
103
+            $options['create'] = "'create', '" . esc_js( $ua_code ). "', '" . esc_js( $domain ) . "', " . $create;
104
+        } else {
105
+            $options['create'] = "'create', '" . esc_js( $ua_code ) . "', '" . esc_js( $domain ) . "'";
106
+        }
107
+
108
+        $options['forceSSL'] = "'set', 'forceSSL', true";
109
+
110
+        if ( monsterinsights_get_option( 'custom_code', false ) ) {
111
+            // Add custom code to the view
112
+            $options['custom_code'] = array(
113
+                'type'  => 'custom_code',
114
+                'value' => stripslashes( monsterinsights_get_option( 'custom_code', '' ) ),
115
+            );
116
+        }
117
+
118
+        // Anonymous data
119
+        if ( monsterinsights_get_option( 'anonymize_ips', false ) ) {
120
+            $options['anonymize_ips'] = "'set', 'anonymizeIp', true";
121
+        }
122
+
123
+        $options = apply_filters( 'monsterinsights_frontend_tracking_options_analytics_before_scripts', $options );
124
+
125
+        // add demographics
126
+        if ( monsterinsights_get_option( 'demographics', false ) ) {
127
+            $options['demographics'] = "'require', 'displayfeatures'";
128
+        }
129
+
130
+        // Check for Enhanced link attribution
131
+        if ( monsterinsights_get_option( 'enhanced_link_attribution', false ) ) {
132
+            $options['enhanced_link_attribution'] = "'require', 'linkid', 'linkid.js'";
133
+        }
134
+
135
+        $options = apply_filters( 'monsterinsights_frontend_tracking_options_analytics_before_pageview', $options );
136
+        $options = apply_filters( 'monsterinsights_frontend_tracking_options_before_pageview', $options, $this->name, $this->version );
137
+
138
+        if ( is_404() ) {
139
+            if ( monsterinsights_get_option( 'hash_tracking', false ) ) {
140
+                $options['send'] = "'send','pageview','/404.html?page=' + document.location.pathname + document.location.search + location.hash + '&from=' + document.referrer";
141
+            } else {
142
+                $options['send'] = "'send','pageview','/404.html?page=' + document.location.pathname + document.location.search + '&from=' + document.referrer";
143
+            }
144
+        } else if ( $wp_query->is_search ) {
145
+            $pushstr = "'send','pageview','/?s=";
146
+            if ( (int) $wp_query->found_posts === 0 ) {
147
+                $options['send'] = $pushstr . 'no-results:' . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=no-results'";
148
+            } else if ( (int) $wp_query->found_posts === 1 ) {
149
+                $options['send'] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=1-result'";
150
+            } else if ( $wp_query->found_posts > 1 && $wp_query->found_posts < 6 ) {
151
+                $options['send'] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=2-5-results'";
152
+            } else {
153
+                $options['send'] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=plus-5-results'";
154
+            }
155
+        } else if ( monsterinsights_get_option( 'hash_tracking', false ) ) {
156
+            $options['send'] = "'send','pageview', location.pathname + location.search + location.hash";
157
+        } else {
158
+            $options['send'] = "'send','pageview'";
159
+        }
160
+
161
+        $options = apply_filters( 'monsterinsights_frontend_tracking_options_analytics_end', $options );
162
+        return $options;
163
+    }
164
+
165
+    /**
166
+     * Get frontend output.
167
+     *
168
+     * This function is used to return the Javascript
169
+     * to output in the head of the page for the given
170
+     * tracking method.
171
+     *
172
+     * @since 6.0.0
173
+     * @access public
174
+     *
175
+     * @return string Javascript to output.
176
+     */
177
+    public function frontend_output( ) {
178
+        $options        = $this->frontend_tracking_options();
179
+        $is_debug_mode  =  monsterinsights_is_debug_mode();
180
+        $src     	    = apply_filters( 'monsterinsights_frontend_output_analytics_src', '//www.google-analytics.com/analytics.js' );
181
+        if ( current_user_can( 'manage_options' ) && $is_debug_mode ) {
182
+            $src     = apply_filters( 'monsterinsights_frontend_output_analytics_src', '//www.google-analytics.com/analytics_debug.js' );
183
+        }
184
+        $compat  = monsterinsights_get_option( 'gatracker_compatibility_mode', false );
185
+        $compat  = $compat ? 'window.ga = __gaTracker;' : '';
186
+        ob_start();
187
+        ?>
188 188
 <!-- This site uses the Google Analytics by MonsterInsights plugin v<?php echo MONSTERINSIGHTS_VERSION; ?> - Using Analytics tracking - https://www.monsterinsights.com/ -->
189 189
 <?php if ( monsterinsights_get_ua() ) { ?>
190 190
 <script type="text/javascript" data-cfasync="false">
@@ -214,17 +214,17 @@  discard block
 block discarded – undo
214 214
 
215 215
 <?php
216 216
 if ( current_user_can( 'manage_options' ) && $is_debug_mode ) {
217
-	echo 'window.ga_debug = {trace: true};';
217
+    echo 'window.ga_debug = {trace: true};';
218 218
 }
219 219
 echo $compat;
220 220
 if ( count( $options ) >= 1 ) {
221
-	foreach ( $options as $item ) {
222
-		if ( ! is_array( $item ) ) {
223
-			echo '	__gaTracker(' . $item . ");\n";
224
-		} else if ( ! empty ( $item['value'] ) ) {
225
-			echo '	' . $item['value'] . "\n";
226
-		}
227
-	}
221
+    foreach ( $options as $item ) {
222
+        if ( ! is_array( $item ) ) {
223
+            echo '	__gaTracker(' . $item . ");\n";
224
+        } else if ( ! empty ( $item['value'] ) ) {
225
+            echo '	' . $item['value'] . "\n";
226
+        }
227
+    }
228 228
 }
229 229
 ?>
230 230
 </script>
@@ -233,12 +233,12 @@  discard block
 block discarded – undo
233 233
 <?php } ?>
234 234
 <!-- / Google Analytics by MonsterInsights -->
235 235
 <?php
236
-		$output = ob_get_contents();
237
-		ob_end_clean();
238
-		return $output;
239
-	}
240
-
241
-	public function should_do_optout() {
242
-		return ! ( defined( 'MI_NO_TRACKING_OPTOUT' ) && MI_NO_TRACKING_OPTOUT );
243
-	}
236
+        $output = ob_get_contents();
237
+        ob_end_clean();
238
+        return $output;
239
+    }
240
+
241
+    public function should_do_optout() {
242
+        return ! ( defined( 'MI_NO_TRACKING_OPTOUT' ) && MI_NO_TRACKING_OPTOUT );
243
+    }
244 244
 }
Please login to merge, or discard this patch.
includes/frontend/tracking/class-tracking-preview.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  */
10 10
 
11 11
 // Exit if accessed directly
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
     exit;
14 14
 }
15 15
 
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
      * @return string Javascript to output.
85 85
      */
86 86
     public function frontend_output( ) {
87
-        $output  = '<!-- This site uses the Google Analytics by MonsterInsights plugin v ' . MONSTERINSIGHTS_VERSION .' - https://www.monsterinsights.com/ -->';
88
-        $output .=  '<!-- ' . esc_html__( "You are currently in a preview window. MonsterInsights doesn't track preview window traffic to avoid false visit reports.", 'google-analytics-for-wordpress' ) . ' -->';
89
-        $output .=  '<!-- / Google Analytics by MonsterInsights -->';
87
+        $output  = '<!-- This site uses the Google Analytics by MonsterInsights plugin v ' . MONSTERINSIGHTS_VERSION . ' - https://www.monsterinsights.com/ -->';
88
+        $output .= '<!-- ' . esc_html__("You are currently in a preview window. MonsterInsights doesn't track preview window traffic to avoid false visit reports.", 'google-analytics-for-wordpress') . ' -->';
89
+        $output .= '<!-- / Google Analytics by MonsterInsights -->';
90 90
         return $output;
91 91
     }
92 92
 }
93 93
\ No newline at end of file
Please login to merge, or discard this patch.
includes/frontend/tracking/class-tracking-disabled.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  */
10 10
 
11 11
 // Exit if accessed directly
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
     exit;
14 14
 }
15 15
 
@@ -84,14 +84,14 @@  discard block
 block discarded – undo
84 84
      * @return string Javascript to output.
85 85
      */
86 86
     public function frontend_output( ) {
87
-        $output  = PHP_EOL . '<!-- This site uses the Google Analytics by MonsterInsights plugin v ' . MONSTERINSIGHTS_VERSION .' - https://www.monsterinsights.com/ -->' . PHP_EOL;
87
+        $output = PHP_EOL . '<!-- This site uses the Google Analytics by MonsterInsights plugin v ' . MONSTERINSIGHTS_VERSION . ' - https://www.monsterinsights.com/ -->' . PHP_EOL;
88 88
 
89
-        if ( current_user_can( 'monsterinsights_save_settings' ) ) {
90
-            $output .=  '<!-- ' . sprintf( esc_html__( '@Webmaster, normally you will find the Google Analytics tracking code here, but you are in the disabled user groups. To change this, navigate to Insights %1$s Settings %1$s Ignore Users', 'google-analytics-for-wordpress' ), '->' ) . ' -->' . PHP_EOL;
89
+        if (current_user_can('monsterinsights_save_settings')) {
90
+            $output .= '<!-- ' . sprintf(esc_html__('@Webmaster, normally you will find the Google Analytics tracking code here, but you are in the disabled user groups. To change this, navigate to Insights %1$s Settings %1$s Ignore Users', 'google-analytics-for-wordpress'), '->') . ' -->' . PHP_EOL;
91 91
         } else {
92
-            $output .=  '<!-- ' . esc_html__( 'Normally you will find the Google Analytics tracking code here, but the webmaster disabled your user group.', 'google-analytics-for-wordpress' ) . ' -->' . PHP_EOL;
92
+            $output .= '<!-- ' . esc_html__('Normally you will find the Google Analytics tracking code here, but the webmaster disabled your user group.', 'google-analytics-for-wordpress') . ' -->' . PHP_EOL;
93 93
         }
94
-        $output .=  '<!-- / Google Analytics by MonsterInsights -->' . PHP_EOL . PHP_EOL;
94
+        $output .= '<!-- / Google Analytics by MonsterInsights -->' . PHP_EOL . PHP_EOL;
95 95
         return $output;
96 96
     }
97 97
 }
98 98
\ No newline at end of file
Please login to merge, or discard this patch.
includes/frontend/tracking/class-tracking-ga.php 2 patches
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  */
10 10
 
11 11
 // Exit if accessed directly
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit;
14 14
 }
15 15
 
@@ -71,65 +71,65 @@  discard block
 block discarded – undo
71 71
 		global $wp_query;
72 72
 		$options = array();
73 73
 
74
-		if ( monsterinsights_get_ua_to_output() ) {
74
+		if (monsterinsights_get_ua_to_output()) {
75 75
 			$options['_setAccount'] = "'_setAccount', '" . monsterinsights_get_ua_to_output() . "'";
76 76
 		} else {
77 77
 			return $options;
78 78
 		}
79 79
 
80
-		if ( monsterinsights_get_option( 'subdomain_tracking', false ) ) {
81
-			$options['_setDomainName'] = "'_setDomainName', '" . esc_js( monsterinsights_get_option( 'subdomain_tracking', '' ) ) . "'";
80
+		if (monsterinsights_get_option('subdomain_tracking', false)) {
81
+			$options['_setDomainName'] = "'_setDomainName', '" . esc_js(monsterinsights_get_option('subdomain_tracking', '')) . "'";
82 82
 		}
83 83
 
84
-		if ( monsterinsights_get_option( 'allow_anchor', false ) ) {
84
+		if (monsterinsights_get_option('allow_anchor', false)) {
85 85
 			$options['_setAllowAnchor'] = "'_setAllowAnchor', true";
86 86
 		}
87 87
 
88
-		if ( monsterinsights_get_option( 'add_allow_linker', false ) ) {
88
+		if (monsterinsights_get_option('add_allow_linker', false)) {
89 89
 			$options['_setAllowLinker'] = "'_setAllowLinker', true";
90 90
 		}
91 91
 
92 92
 		// SSL data
93 93
 		$options['_forceSSL'] = "'_gat._forceSSL'";
94 94
 
95
-		if ( monsterinsights_get_option( 'custom_code', false ) ) {
95
+		if (monsterinsights_get_option('custom_code', false)) {
96 96
 			// Add custom code to the view
97 97
 			$options['custom_code'] = array(
98 98
 				'type'  => 'custom_code',
99
-				'value' => esc_js( stripslashes( monsterinsights_get_option( 'custom_code', '' ) ) ),
99
+				'value' => esc_js(stripslashes(monsterinsights_get_option('custom_code', ''))),
100 100
 			);
101 101
 		}
102 102
 
103 103
 		// Anonymous data
104
-		if ( monsterinsights_get_option( 'anonymize_ips', false ) && ! monsterinsights_get_option( 'allowhash', false ) ) {
104
+		if (monsterinsights_get_option('anonymize_ips', false) && ! monsterinsights_get_option('allowhash', false)) {
105 105
 			$options['anonymize_ips'] = "'_gat._anonymizeIp'";
106 106
 		}
107 107
 
108
-		if ( monsterinsights_get_option( 'allowhash', false ) ) {
108
+		if (monsterinsights_get_option('allowhash', false)) {
109 109
 			$options['allowhash'] = "'_gat._anonymizeIp',true";
110 110
 		}
111 111
 
112
-		$options = apply_filters( 'monsterinsights_frontend_tracking_options_ga_before_pageview', $options );
113
-		$options = apply_filters( 'monsterinsights_frontend_tracking_options_before_pageview', $options, $this->name, $this->version );
112
+		$options = apply_filters('monsterinsights_frontend_tracking_options_ga_before_pageview', $options);
113
+		$options = apply_filters('monsterinsights_frontend_tracking_options_before_pageview', $options, $this->name, $this->version);
114 114
 
115
-		if ( is_404() ) {
115
+		if (is_404()) {
116 116
 			$options['_trackPageview'] = "'_trackPageview','/404.html?page=' + document.location.pathname + document.location.search + '&from=' + document.referrer";
117
-		} else if ( $wp_query->is_search ) {
117
+		} else if ($wp_query->is_search) {
118 118
 			$pushstr = "'_trackPageview','/?s=";
119
-			if ( (int) $wp_query->found_posts === 0 ) {
120
-				$options['_trackPageview'] = $pushstr . 'no-results:' . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=no-results'";
121
-			} else if ( (int) $wp_query->found_posts === 1 ) {
122
-				$options['_trackPageview'] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=1-result'";
123
-			} else if ( $wp_query->found_posts > 1 && $wp_query->found_posts < 6 ) {
124
-				$options['_trackPageview'] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=2-5-results'";
119
+			if ((int) $wp_query->found_posts === 0) {
120
+				$options['_trackPageview'] = $pushstr . 'no-results:' . rawurlencode($wp_query->query_vars['s']) . "&cat=no-results'";
121
+			} else if ((int) $wp_query->found_posts === 1) {
122
+				$options['_trackPageview'] = $pushstr . rawurlencode($wp_query->query_vars['s']) . "&cat=1-result'";
123
+			} else if ($wp_query->found_posts > 1 && $wp_query->found_posts < 6) {
124
+				$options['_trackPageview'] = $pushstr . rawurlencode($wp_query->query_vars['s']) . "&cat=2-5-results'";
125 125
 			} else {
126
-				$options['_trackPageview'] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=plus-5-results'";
126
+				$options['_trackPageview'] = $pushstr . rawurlencode($wp_query->query_vars['s']) . "&cat=plus-5-results'";
127 127
 			}
128 128
 		} else {
129 129
 			$options['_trackPageview'] = "'_trackPageview'";
130 130
 		}
131 131
 
132
-		$options = apply_filters( 'monsterinsights_frontend_tracking_options_ga_end', $options );
132
+		$options = apply_filters('monsterinsights_frontend_tracking_options_ga_end', $options);
133 133
 		return $options;
134 134
 	}
135 135
 
@@ -147,21 +147,21 @@  discard block
 block discarded – undo
147 147
 	 */
148 148
 	public function frontend_output( ) {
149 149
 		 $options = $this->frontend_tracking_options();
150
-		 $src     = apply_filters( 'monsterinsights_frontend_output_ga_src', "('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';\n" );
150
+		 $src     = apply_filters('monsterinsights_frontend_output_ga_src', "('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';\n");
151 151
 		 ob_start();
152 152
 		 ?>
153 153
  <!-- This site uses the Google Analytics by MonsterInsights plugin v<?php echo MONSTERINSIGHTS_VERSION; ?> - Using ga.js tracking - https://www.monsterinsights.com/ -->
154
-<?php if ( monsterinsights_get_ua() ) { ?>
154
+<?php if (monsterinsights_get_ua()) { ?>
155 155
 <script type="text/javascript" data-cfasync="false">
156 156
 
157 157
 		var _gaq = _gaq || [];
158 158
 	<?php
159
-	if ( count( $options ) >= 1 ) {
160
-		foreach ( $options as $item ) {
161
-			if ( ! is_array( $item ) ) {
159
+	if (count($options) >= 1) {
160
+		foreach ($options as $item) {
161
+			if ( ! is_array($item)) {
162 162
 				echo '  _gaq.push([' . $item . "]);\n";
163
-			} else if ( isset( $item['value'] ) ) {
164
-				echo '  '.$item['value'] . "\n";
163
+			} else if (isset($item['value'])) {
164
+				echo '  ' . $item['value'] . "\n";
165 165
 			}
166 166
 		}
167 167
 	}
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 			var ga = document.createElement('script');
172 172
 			ga.type = 'text/javascript';
173 173
 			ga.async = true;
174
-			ga.src = <?php echo $src;?>
174
+			ga.src = <?php echo $src; ?>
175 175
 			var s = document.getElementsByTagName('script')[0];
176 176
 			s.parentNode.insertBefore(ga, s);
177 177
 		})();
Please login to merge, or discard this patch.
Indentation   +149 added lines, -149 removed lines patch added patch discarded remove patch
@@ -10,162 +10,162 @@  discard block
 block discarded – undo
10 10
 
11 11
 // Exit if accessed directly
12 12
 if ( ! defined( 'ABSPATH' ) ) {
13
-	exit;
13
+    exit;
14 14
 }
15 15
 
16 16
 class MonsterInsights_Tracking_GA extends MonsterInsights_Tracking_Abstract {
17 17
 
18
-	/**
19
-	 * Holds the base class object.
20
-	 *
21
-	 * @since 6.0.0
22
-	 * @access public
23
-	 *
24
-	 * @var object $base Base class object.
25
-	 */
26
-	public $base;
18
+    /**
19
+     * Holds the base class object.
20
+     *
21
+     * @since 6.0.0
22
+     * @access public
23
+     *
24
+     * @var object $base Base class object.
25
+     */
26
+    public $base;
27 27
 	
28
-	/**
29
-	 * Holds the name of the tracking type.
30
-	 *
31
-	 * @since 6.0.0
32
-	 * @access public
33
-	 *
34
-	 * @var string $name Name of the tracking type.
35
-	 */
36
-	public $name = 'ga';
37
-
38
-	/**
39
-	 * Version of the tracking class.
40
-	 *
41
-	 * @since 6.0.0
42
-	 * @access public
43
-	 *
44
-	 * @var string $version Version of the tracking class.
45
-	 */
46
-	public $version = '1.0.0';
47
-
48
-	/**
49
-	 * Primary class constructor.
50
-	 *
51
-	 * @since 6.0.0
52
-	 * @access public
53
-	 */
54
-	public function __construct() {
55
-		$this->base = MonsterInsights();
56
-	}
57
-
58
-	/**
59
-	 * Get frontend tracking options.
60
-	 *
61
-	 * This function is used to return an array of parameters
62
-	 * for the frontend_output() function to output. These are 
63
-	 * generally dimensions and turned on GA features.
64
-	 *
65
-	 * @since 6.0.0
66
-	 * @access public
67
-	 *
68
-	 * @return array Array of the options to use.
69
-	 */
70
-	public function frontend_tracking_options( ) {
71
-		global $wp_query;
72
-		$options = array();
73
-
74
-		if ( monsterinsights_get_ua_to_output() ) {
75
-			$options['_setAccount'] = "'_setAccount', '" . monsterinsights_get_ua_to_output() . "'";
76
-		} else {
77
-			return $options;
78
-		}
79
-
80
-		if ( monsterinsights_get_option( 'subdomain_tracking', false ) ) {
81
-			$options['_setDomainName'] = "'_setDomainName', '" . esc_js( monsterinsights_get_option( 'subdomain_tracking', '' ) ) . "'";
82
-		}
83
-
84
-		if ( monsterinsights_get_option( 'allow_anchor', false ) ) {
85
-			$options['_setAllowAnchor'] = "'_setAllowAnchor', true";
86
-		}
87
-
88
-		if ( monsterinsights_get_option( 'add_allow_linker', false ) ) {
89
-			$options['_setAllowLinker'] = "'_setAllowLinker', true";
90
-		}
91
-
92
-		// SSL data
93
-		$options['_forceSSL'] = "'_gat._forceSSL'";
94
-
95
-		if ( monsterinsights_get_option( 'custom_code', false ) ) {
96
-			// Add custom code to the view
97
-			$options['custom_code'] = array(
98
-				'type'  => 'custom_code',
99
-				'value' => esc_js( stripslashes( monsterinsights_get_option( 'custom_code', '' ) ) ),
100
-			);
101
-		}
102
-
103
-		// Anonymous data
104
-		if ( monsterinsights_get_option( 'anonymize_ips', false ) && ! monsterinsights_get_option( 'allowhash', false ) ) {
105
-			$options['anonymize_ips'] = "'_gat._anonymizeIp'";
106
-		}
107
-
108
-		if ( monsterinsights_get_option( 'allowhash', false ) ) {
109
-			$options['allowhash'] = "'_gat._anonymizeIp',true";
110
-		}
111
-
112
-		$options = apply_filters( 'monsterinsights_frontend_tracking_options_ga_before_pageview', $options );
113
-		$options = apply_filters( 'monsterinsights_frontend_tracking_options_before_pageview', $options, $this->name, $this->version );
114
-
115
-		if ( is_404() ) {
116
-			$options['_trackPageview'] = "'_trackPageview','/404.html?page=' + document.location.pathname + document.location.search + '&from=' + document.referrer";
117
-		} else if ( $wp_query->is_search ) {
118
-			$pushstr = "'_trackPageview','/?s=";
119
-			if ( (int) $wp_query->found_posts === 0 ) {
120
-				$options['_trackPageview'] = $pushstr . 'no-results:' . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=no-results'";
121
-			} else if ( (int) $wp_query->found_posts === 1 ) {
122
-				$options['_trackPageview'] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=1-result'";
123
-			} else if ( $wp_query->found_posts > 1 && $wp_query->found_posts < 6 ) {
124
-				$options['_trackPageview'] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=2-5-results'";
125
-			} else {
126
-				$options['_trackPageview'] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=plus-5-results'";
127
-			}
128
-		} else {
129
-			$options['_trackPageview'] = "'_trackPageview'";
130
-		}
131
-
132
-		$options = apply_filters( 'monsterinsights_frontend_tracking_options_ga_end', $options );
133
-		return $options;
134
-	}
135
-
136
-	/**
137
-	 * Get frontend output.
138
-	 *
139
-	 * This function is used to return the Javascript
140
-	 * to output in the head of the page for the given
141
-	 * tracking method.
142
-	 *
143
-	 * @since 6.0.0
144
-	 * @access public
145
-	 *
146
-	 * @return string Javascript to output.
147
-	 */
148
-	public function frontend_output( ) {
149
-		 $options = $this->frontend_tracking_options();
150
-		 $src     = apply_filters( 'monsterinsights_frontend_output_ga_src', "('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';\n" );
151
-		 ob_start();
152
-		 ?>
28
+    /**
29
+     * Holds the name of the tracking type.
30
+     *
31
+     * @since 6.0.0
32
+     * @access public
33
+     *
34
+     * @var string $name Name of the tracking type.
35
+     */
36
+    public $name = 'ga';
37
+
38
+    /**
39
+     * Version of the tracking class.
40
+     *
41
+     * @since 6.0.0
42
+     * @access public
43
+     *
44
+     * @var string $version Version of the tracking class.
45
+     */
46
+    public $version = '1.0.0';
47
+
48
+    /**
49
+     * Primary class constructor.
50
+     *
51
+     * @since 6.0.0
52
+     * @access public
53
+     */
54
+    public function __construct() {
55
+        $this->base = MonsterInsights();
56
+    }
57
+
58
+    /**
59
+     * Get frontend tracking options.
60
+     *
61
+     * This function is used to return an array of parameters
62
+     * for the frontend_output() function to output. These are 
63
+     * generally dimensions and turned on GA features.
64
+     *
65
+     * @since 6.0.0
66
+     * @access public
67
+     *
68
+     * @return array Array of the options to use.
69
+     */
70
+    public function frontend_tracking_options( ) {
71
+        global $wp_query;
72
+        $options = array();
73
+
74
+        if ( monsterinsights_get_ua_to_output() ) {
75
+            $options['_setAccount'] = "'_setAccount', '" . monsterinsights_get_ua_to_output() . "'";
76
+        } else {
77
+            return $options;
78
+        }
79
+
80
+        if ( monsterinsights_get_option( 'subdomain_tracking', false ) ) {
81
+            $options['_setDomainName'] = "'_setDomainName', '" . esc_js( monsterinsights_get_option( 'subdomain_tracking', '' ) ) . "'";
82
+        }
83
+
84
+        if ( monsterinsights_get_option( 'allow_anchor', false ) ) {
85
+            $options['_setAllowAnchor'] = "'_setAllowAnchor', true";
86
+        }
87
+
88
+        if ( monsterinsights_get_option( 'add_allow_linker', false ) ) {
89
+            $options['_setAllowLinker'] = "'_setAllowLinker', true";
90
+        }
91
+
92
+        // SSL data
93
+        $options['_forceSSL'] = "'_gat._forceSSL'";
94
+
95
+        if ( monsterinsights_get_option( 'custom_code', false ) ) {
96
+            // Add custom code to the view
97
+            $options['custom_code'] = array(
98
+                'type'  => 'custom_code',
99
+                'value' => esc_js( stripslashes( monsterinsights_get_option( 'custom_code', '' ) ) ),
100
+            );
101
+        }
102
+
103
+        // Anonymous data
104
+        if ( monsterinsights_get_option( 'anonymize_ips', false ) && ! monsterinsights_get_option( 'allowhash', false ) ) {
105
+            $options['anonymize_ips'] = "'_gat._anonymizeIp'";
106
+        }
107
+
108
+        if ( monsterinsights_get_option( 'allowhash', false ) ) {
109
+            $options['allowhash'] = "'_gat._anonymizeIp',true";
110
+        }
111
+
112
+        $options = apply_filters( 'monsterinsights_frontend_tracking_options_ga_before_pageview', $options );
113
+        $options = apply_filters( 'monsterinsights_frontend_tracking_options_before_pageview', $options, $this->name, $this->version );
114
+
115
+        if ( is_404() ) {
116
+            $options['_trackPageview'] = "'_trackPageview','/404.html?page=' + document.location.pathname + document.location.search + '&from=' + document.referrer";
117
+        } else if ( $wp_query->is_search ) {
118
+            $pushstr = "'_trackPageview','/?s=";
119
+            if ( (int) $wp_query->found_posts === 0 ) {
120
+                $options['_trackPageview'] = $pushstr . 'no-results:' . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=no-results'";
121
+            } else if ( (int) $wp_query->found_posts === 1 ) {
122
+                $options['_trackPageview'] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=1-result'";
123
+            } else if ( $wp_query->found_posts > 1 && $wp_query->found_posts < 6 ) {
124
+                $options['_trackPageview'] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=2-5-results'";
125
+            } else {
126
+                $options['_trackPageview'] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=plus-5-results'";
127
+            }
128
+        } else {
129
+            $options['_trackPageview'] = "'_trackPageview'";
130
+        }
131
+
132
+        $options = apply_filters( 'monsterinsights_frontend_tracking_options_ga_end', $options );
133
+        return $options;
134
+    }
135
+
136
+    /**
137
+     * Get frontend output.
138
+     *
139
+     * This function is used to return the Javascript
140
+     * to output in the head of the page for the given
141
+     * tracking method.
142
+     *
143
+     * @since 6.0.0
144
+     * @access public
145
+     *
146
+     * @return string Javascript to output.
147
+     */
148
+    public function frontend_output( ) {
149
+            $options = $this->frontend_tracking_options();
150
+            $src     = apply_filters( 'monsterinsights_frontend_output_ga_src', "('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';\n" );
151
+            ob_start();
152
+            ?>
153 153
  <!-- This site uses the Google Analytics by MonsterInsights plugin v<?php echo MONSTERINSIGHTS_VERSION; ?> - Using ga.js tracking - https://www.monsterinsights.com/ -->
154 154
 <?php if ( monsterinsights_get_ua() ) { ?>
155 155
 <script type="text/javascript" data-cfasync="false">
156 156
 
157 157
 		var _gaq = _gaq || [];
158 158
 	<?php
159
-	if ( count( $options ) >= 1 ) {
160
-		foreach ( $options as $item ) {
161
-			if ( ! is_array( $item ) ) {
162
-				echo '  _gaq.push([' . $item . "]);\n";
163
-			} else if ( isset( $item['value'] ) ) {
164
-				echo '  '.$item['value'] . "\n";
165
-			}
166
-		}
167
-	}
168
-	?>
159
+    if ( count( $options ) >= 1 ) {
160
+        foreach ( $options as $item ) {
161
+            if ( ! is_array( $item ) ) {
162
+                echo '  _gaq.push([' . $item . "]);\n";
163
+            } else if ( isset( $item['value'] ) ) {
164
+                echo '  '.$item['value'] . "\n";
165
+            }
166
+        }
167
+    }
168
+    ?>
169 169
 
170 170
 		(function () {
171 171
 			var ga = document.createElement('script');
@@ -181,8 +181,8 @@  discard block
 block discarded – undo
181 181
 <?php } ?>
182 182
 <!-- / Google Analytics by MonsterInsights -->
183 183
 <?php
184
-		$output = ob_get_contents();
185
-		ob_end_clean();
186
-		return $output;
187
-	}
184
+        $output = ob_get_contents();
185
+        ob_end_clean();
186
+        return $output;
187
+    }
188 188
 }
Please login to merge, or discard this patch.
includes/frontend/class-tracking-abstract.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@
 block discarded – undo
9 9
  */
10 10
 
11 11
 // Exit if accessed directly
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
     exit;
14 14
 }
15 15
 
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -84,6 +84,6 @@
 block discarded – undo
84 84
      * @return string Javascript to output.
85 85
      */
86 86
     public function frontend_output( ) {
87
-         return "<!-- MonsterInsights Abstract Tracking class -->";
87
+            return "<!-- MonsterInsights Abstract Tracking class -->";
88 88
     }
89 89
 }
90 90
\ No newline at end of file
Please login to merge, or discard this patch.