Passed
Pull Request — master (#508)
by Adam
08:08 queued 04:37
created
includes/admin/api-auth.php 2 patches
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -28,23 +28,23 @@  discard block
 block discarded – undo
28 28
 	public function __construct() {
29 29
 
30 30
 		// Authentication Actions
31
-		add_action( 'wp_ajax_monsterinsights_maybe_authenticate',    array( $this, 'maybe_authenticate' ) );
32
-		add_action( 'wp_ajax_monsterinsights_maybe_reauthenticate',  array( $this, 'maybe_reauthenticate' ) );
33
-		add_action( 'wp_ajax_monsterinsights_maybe_verify',          array( $this, 'maybe_verify' ) );
34
-		add_action( 'wp_ajax_monsterinsights_maybe_delete',          array( $this, 'maybe_delete' ) );
31
+		add_action( 'wp_ajax_monsterinsights_maybe_authenticate', array( $this, 'maybe_authenticate' ) );
32
+		add_action( 'wp_ajax_monsterinsights_maybe_reauthenticate', array( $this, 'maybe_reauthenticate' ) );
33
+		add_action( 'wp_ajax_monsterinsights_maybe_verify', array( $this, 'maybe_verify' ) );
34
+		add_action( 'wp_ajax_monsterinsights_maybe_delete', array( $this, 'maybe_delete' ) );
35 35
 
36
-		add_action( 'admin_init',          							 array( $this, 'authenticate_listener' ) );
37
-		add_action( 'admin_init',          							 array( $this, 'reauthenticate_listener' ) );
36
+		add_action( 'admin_init', array( $this, 'authenticate_listener' ) );
37
+		add_action( 'admin_init', array( $this, 'reauthenticate_listener' ) );
38 38
 
39
-		add_action( 'wp_ajax_nopriv_monsterinsights_is_installed',    array( $this, 'is_installed' ) );
40
-		add_action( 'wp_ajax_nopriv_monsterinsights_rauthenticate',   array( $this, 'rauthenticate' ) );
39
+		add_action( 'wp_ajax_nopriv_monsterinsights_is_installed', array( $this, 'is_installed' ) );
40
+		add_action( 'wp_ajax_nopriv_monsterinsights_rauthenticate', array( $this, 'rauthenticate' ) );
41 41
 
42 42
 		add_filter( 'monsterinsights_maybe_authenticate_siteurl', array( $this, 'before_redirect' ) );
43 43
 
44 44
 		add_action( 'wp_ajax_nopriv_monsterinsights_push_mp_token', array( $this, 'handle_relay_mp_token_push' ) );
45 45
 	}
46 46
 
47
-	public function get_tt(){
47
+	public function get_tt() {
48 48
 		$tt = is_network_admin() ? get_site_option( 'monsterinsights_network_tt', '' ) : get_option( 'monsterinsights_site_tt', '' );
49 49
 		if ( empty( $tt ) ) {
50 50
 			// if TT is empty, generate a new one, save it and then return it
@@ -54,12 +54,12 @@  discard block
 block discarded – undo
54 54
 		return $tt;
55 55
 	}
56 56
 
57
-	public function rotate_tt(){
57
+	public function rotate_tt() {
58 58
 		$tt = $this->generate_tt();
59 59
 		is_network_admin() ? update_site_option( 'monsterinsights_network_tt', $tt ) : update_option( 'monsterinsights_site_tt', $tt );
60 60
 	}
61 61
 
62
-	public function generate_tt(){
62
+	public function generate_tt() {
63 63
 		return hash( 'sha512', wp_generate_password( 128, true, true ) . AUTH_SALT . uniqid( "", true ) );
64 64
 	}
65 65
 
@@ -77,14 +77,14 @@  discard block
 block discarded – undo
77 77
 		);
78 78
 	}
79 79
 
80
-	public function maybe_authenticate(){
80
+	public function maybe_authenticate() {
81 81
 
82 82
 		// Check nonce
83 83
 		check_ajax_referer( 'mi-admin-nonce', 'nonce' );
84 84
 
85 85
 		// current user can authenticate
86 86
 		if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
87
-			wp_send_json_error( array(	'message' => __( "You don't have permission to authenticate MonsterInsights.", 'google-analytics-for-wordpress' ) ) );
87
+			wp_send_json_error( array( 'message' => __( "You don't have permission to authenticate MonsterInsights.", 'google-analytics-for-wordpress' ) ) );
88 88
 		}
89 89
 
90 90
 		if ( ! empty( $_REQUEST['isnetwork'] ) && $_REQUEST['isnetwork'] ) {
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
 
102 102
 		// we do not have a current auth
103 103
 		if ( ! $this->is_network_admin() && MonsterInsights()->auth->is_authed() ) {
104
-			wp_send_json_error( array(	'message' => __( "Cannot authenticate. Please re-authenticate.", 'google-analytics-for-wordpress' ) ) );
104
+			wp_send_json_error( array( 'message' => __( "Cannot authenticate. Please re-authenticate.", 'google-analytics-for-wordpress' ) ) );
105 105
 		} else if ( $this->is_network_admin() && MonsterInsights()->auth->is_network_authed() ) {
106
-			wp_send_json_error( array(	'message' => __( "Cannot network authenticate. Please re-authenticate on the network settings panel.", 'google-analytics-for-wordpress' ) ) );
106
+			wp_send_json_error( array( 'message' => __( "Cannot network authenticate. Please re-authenticate on the network settings panel.", 'google-analytics-for-wordpress' ) ) );
107 107
 		}
108 108
 
109 109
 		$sitei = $this->get_sitei();
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 		wp_send_json_success();
174 174
 	}
175 175
 
176
-	public function authenticate_listener(){
176
+	public function authenticate_listener() {
177 177
 		// Make sure it's for us
178 178
 		if ( empty( $_REQUEST['mi-oauth-action'] ) || $_REQUEST['mi-oauth-action'] !== 'auth' ) {
179 179
 			return;
@@ -191,12 +191,12 @@  discard block
 block discarded – undo
191 191
 
192 192
 		// Make sure has required params
193 193
 		if (
194
-			empty( $_REQUEST['key'] )    ||
195
-			empty( $_REQUEST['token'] )  ||
194
+			empty( $_REQUEST['key'] ) ||
195
+			empty( $_REQUEST['token'] ) ||
196 196
 			empty( $_REQUEST['miview'] ) ||
197
-			empty( $_REQUEST['a'] )      ||
198
-			empty( $_REQUEST['w'] )      ||
199
-			empty( $_REQUEST['p'] )      ||
197
+			empty( $_REQUEST['a'] ) ||
198
+			empty( $_REQUEST['w'] ) ||
199
+			empty( $_REQUEST['p'] ) ||
200 200
 			( empty( $_REQUEST['ua'] ) && empty( $_REQUEST['v4'] ) )
201 201
 		) {
202 202
 			return;
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 			$profile['measurement_protocol_secret'] = sanitize_text_field( $_REQUEST['mp'] );
231 231
 		}
232 232
 
233
-		$profile[ $code_key ] = $code_value;
233
+		$profile[$code_key] = $code_value;
234 234
 
235 235
 		$worked = $this->verify_auth( $profile );
236 236
 		if ( ! $worked || is_wp_error( $worked ) ) {
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 		$where = $this->is_network_admin() ? 'network' : 'site';
245 245
 		MonsterInsights()->reporting->delete_aggregate_data( $where );
246 246
 
247
-		$url = $this->is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' )  : admin_url( 'admin.php?page=monsterinsights_settings' ) ;
247
+		$url = $this->is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' );
248 248
 		$url = add_query_arg( array(
249 249
 			 'mi_action' => 'auth',
250 250
 			 'success'   => 'true',
@@ -254,14 +254,14 @@  discard block
 block discarded – undo
254 254
 		exit;
255 255
 	}
256 256
 
257
-	public function maybe_reauthenticate(){
257
+	public function maybe_reauthenticate() {
258 258
 
259 259
 		// Check nonce
260 260
 		check_ajax_referer( 'mi-admin-nonce', 'nonce' );
261 261
 
262 262
 		// current user can authenticate
263 263
 		if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
264
-			wp_send_json_error( array(	'message' => __( "You don't have permission to re-authenticate MonsterInsights.", 'google-analytics-for-wordpress' ) ) );
264
+			wp_send_json_error( array( 'message' => __( "You don't have permission to re-authenticate MonsterInsights.", 'google-analytics-for-wordpress' ) ) );
265 265
 		}
266 266
 
267 267
 		if ( ! empty( $_REQUEST['isnetwork'] ) && $_REQUEST['isnetwork'] ) {
@@ -278,9 +278,9 @@  discard block
 block discarded – undo
278 278
 
279 279
 		// we do have a current auth
280 280
 		if ( ! $this->is_network_admin() && ! MonsterInsights()->auth->is_authed() ) {
281
-			wp_send_json_error( array(	'message' => __( "Cannot re-authenticate. Please authenticate.", 'google-analytics-for-wordpress' ) ) );
281
+			wp_send_json_error( array( 'message' => __( "Cannot re-authenticate. Please authenticate.", 'google-analytics-for-wordpress' ) ) );
282 282
 		} else if ( $this->is_network_admin() && ! MonsterInsights()->auth->is_network_authed() ) {
283
-			wp_send_json_error( array(	'message' => __( "Cannot re-authenticate the network. Please authenticate on the network settings panel.", 'google-analytics-for-wordpress' ) ) );
283
+			wp_send_json_error( array( 'message' => __( "Cannot re-authenticate the network. Please authenticate on the network settings panel.", 'google-analytics-for-wordpress' ) ) );
284 284
 		}
285 285
 
286 286
 		$siteurl = add_query_arg( array(
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 		wp_send_json_success( array( 'redirect' => $siteurl ) );
307 307
 	}
308 308
 
309
-	public function reauthenticate_listener(){
309
+	public function reauthenticate_listener() {
310 310
 		// Make sure it's for us
311 311
 		if ( empty( $_REQUEST['mi-oauth-action'] ) || $_REQUEST['mi-oauth-action'] !== 'reauth' ) {
312 312
 			return;
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 			$profile['measurement_protocol_secret'] = sanitize_text_field( $_REQUEST['mp'] );
370 370
 		}
371 371
 
372
-		$profile[ $code_key ] = $code_value;
372
+		$profile[$code_key] = $code_value;
373 373
 
374 374
 		// Save Profile
375 375
 		$this->is_network_admin() ? MonsterInsights()->auth->set_network_analytics_profile( $profile ) : MonsterInsights()->auth->set_analytics_profile( $profile );
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 		$where = $this->is_network_admin() ? 'network' : 'site';
379 379
 		MonsterInsights()->reporting->delete_aggregate_data( $where );
380 380
 
381
-		$url = $this->is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' )  : admin_url( 'admin.php?page=monsterinsights_settings' ) ;
381
+		$url = $this->is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' );
382 382
 		$url = add_query_arg( array(
383 383
 			 'mi_action' => 'reauth',
384 384
 			 'success'   => 'true',
@@ -389,14 +389,14 @@  discard block
 block discarded – undo
389 389
 		exit;
390 390
 	}
391 391
 
392
-	public function maybe_verify(){
392
+	public function maybe_verify() {
393 393
 
394 394
 		// Check nonce
395 395
 		check_ajax_referer( 'mi-admin-nonce', 'nonce' );
396 396
 
397 397
 		// current user can verify
398 398
 		if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
399
-			wp_send_json_error( array(	'message' => __( "You don't have permission to verify MonsterInsights.", 'google-analytics-for-wordpress' ) ) );
399
+			wp_send_json_error( array( 'message' => __( "You don't have permission to verify MonsterInsights.", 'google-analytics-for-wordpress' ) ) );
400 400
 		}
401 401
 
402 402
 		if ( ! empty( $_REQUEST['isnetwork'] ) && $_REQUEST['isnetwork'] ) {
@@ -405,9 +405,9 @@  discard block
 block discarded – undo
405 405
 
406 406
 		// we have an auth to verify
407 407
 		if ( $this->is_network_admin() && ! MonsterInsights()->auth->is_network_authed() ) {
408
-			wp_send_json_error( array(	'message' => __( "Cannot verify. Please authenticate.", 'google-analytics-for-wordpress' ) ) );
408
+			wp_send_json_error( array( 'message' => __( "Cannot verify. Please authenticate.", 'google-analytics-for-wordpress' ) ) );
409 409
 		} else if ( ! $this->is_network_admin() && ! MonsterInsights()->auth->is_authed() ) {
410
-			wp_send_json_error( array(	'message' => __( "Cannot verify. Please authenticate.", 'google-analytics-for-wordpress' ) ) );
410
+			wp_send_json_error( array( 'message' => __( "Cannot verify. Please authenticate.", 'google-analytics-for-wordpress' ) ) );
411 411
 		}
412 412
 
413 413
 		if ( monsterinsights_is_pro_version() ) {
@@ -418,14 +418,14 @@  discard block
 block discarded – undo
418 418
 		}
419 419
 
420 420
 		$worked = $this->verify_auth();
421
-		if ( $worked && ! is_wp_error(  $worked ) ) {
421
+		if ( $worked && ! is_wp_error( $worked ) ) {
422 422
 			wp_send_json_success( array( 'message' => __( "Successfully verified.", 'google-analytics-for-wordpress' ) ) );
423 423
 		} else {
424 424
 			wp_send_json_error( array( 'message' => __( "Could not verify.", 'google-analytics-for-wordpress' ) ) );
425 425
 		}
426 426
 	}
427 427
 
428
-	public function verify_auth( $credentials = array() ){
428
+	public function verify_auth( $credentials = array() ) {
429 429
 		$creds = ! empty( $credentials ) ? $credentials : ( $this->is_network_admin() ? MonsterInsights()->auth->get_network_analytics_profile( true ) : MonsterInsights()->auth->get_analytics_profile( true ) );
430 430
 
431 431
 		if ( empty( $creds['key'] ) ) {
@@ -444,14 +444,14 @@  discard block
 block discarded – undo
444 444
 		}
445 445
 	}
446 446
 
447
-	public function maybe_delete(){
447
+	public function maybe_delete() {
448 448
 
449 449
 		// Check nonce
450 450
 		check_ajax_referer( 'mi-admin-nonce', 'nonce' );
451 451
 
452 452
 		// current user can delete
453 453
 		if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
454
-			wp_send_json_error( array(	'message' => __( "You don't have permission to deauthenticate MonsterInsights.", 'google-analytics-for-wordpress' ) ) );
454
+			wp_send_json_error( array( 'message' => __( "You don't have permission to deauthenticate MonsterInsights.", 'google-analytics-for-wordpress' ) ) );
455 455
 		}
456 456
 
457 457
 		if ( ! empty( $_REQUEST['isnetwork'] ) && $_REQUEST['isnetwork'] ) {
@@ -460,9 +460,9 @@  discard block
 block discarded – undo
460 460
 
461 461
 		// we have an auth to delete
462 462
 		if ( $this->is_network_admin() && ! MonsterInsights()->auth->is_network_authed() ) {
463
-			wp_send_json_error( array(	'message' => __( "Cannot deauthenticate. You are not currently authed.", 'google-analytics-for-wordpress' ) ) );
463
+			wp_send_json_error( array( 'message' => __( "Cannot deauthenticate. You are not currently authed.", 'google-analytics-for-wordpress' ) ) );
464 464
 		} else if ( ! $this->is_network_admin() && ! MonsterInsights()->auth->is_authed() ) {
465
-			wp_send_json_error( array(	'message' => __( "Cannot deauthenticate. You are not currently authed.", 'google-analytics-for-wordpress' ) ) );
465
+			wp_send_json_error( array( 'message' => __( "Cannot deauthenticate. You are not currently authed.", 'google-analytics-for-wordpress' ) ) );
466 466
 		}
467 467
 
468 468
 		if ( monsterinsights_is_pro_version() ) {
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
 		$force = ! empty( $_REQUEST['forcedelete'] ) && $_REQUEST['forcedelete'] === 'true';
476 476
 
477 477
 		$worked = $this->delete_auth( $force );
478
-		if ( $worked && ! is_wp_error(  $worked ) ) {
478
+		if ( $worked && ! is_wp_error( $worked ) ) {
479 479
 			wp_send_json_success( array( 'message' => __( "Successfully deauthenticated.", 'google-analytics-for-wordpress' ) ) );
480 480
 		} else {
481 481
 			if ( $force ) {
@@ -486,7 +486,7 @@  discard block
 block discarded – undo
486 486
 		}
487 487
 	}
488 488
 
489
-	public function delete_auth( $force = false ){
489
+	public function delete_auth( $force = false ) {
490 490
 		if ( $this->is_network_admin() && ! MonsterInsights()->auth->is_network_authed() ) {
491 491
 			return false;
492 492
 		} else if ( ! $this->is_network_admin() && ! MonsterInsights()->auth->is_authed() ) {
@@ -502,13 +502,13 @@  discard block
 block discarded – undo
502 502
 		// If we have a new siteurl enabled option and the profile site doesn't match the current site, deactivate anyways
503 503
 		if ( is_network_admin() ) {
504 504
 			$siteurl = network_admin_url();
505
-			if ( ! empty( $creds['neturl' ] ) && $creds['neturl'] !== $siteurl ) {
505
+			if ( ! empty( $creds['neturl'] ) && $creds['neturl'] !== $siteurl ) {
506 506
 				MonsterInsights()->auth->delete_network_analytics_profile( true );
507 507
 				return true;
508 508
 			}
509 509
 		} else {
510 510
 			$siteurl = site_url();
511
-			if ( ! empty( $creds['siteurl' ] ) && $creds['siteurl'] !== $siteurl ) {
511
+			if ( ! empty( $creds['siteurl'] ) && $creds['siteurl'] !== $siteurl ) {
512 512
 				MonsterInsights()->auth->delete_analytics_profile( true );
513 513
 				return true;
514 514
 			}
@@ -585,15 +585,15 @@  discard block
 block discarded – undo
585 585
 		// 	return $sitei;
586 586
 		// }
587 587
 
588
-		$auth_key        = defined( 'AUTH_KEY' )        ? AUTH_KEY 		  : '';
588
+		$auth_key        = defined( 'AUTH_KEY' ) ? AUTH_KEY 		  : '';
589 589
 		$secure_auth_key = defined( 'SECURE_AUTH_KEY' ) ? SECURE_AUTH_KEY : '';
590
-		$logged_in_key   = defined( 'LOGGED_IN_KEY' )   ? LOGGED_IN_KEY   : '';
590
+		$logged_in_key   = defined( 'LOGGED_IN_KEY' ) ? LOGGED_IN_KEY   : '';
591 591
 
592 592
 		$sitei = $auth_key . $secure_auth_key . $logged_in_key;
593
-		$sitei = preg_replace('/[^a-zA-Z0-9]/', '', $sitei );
593
+		$sitei = preg_replace( '/[^a-zA-Z0-9]/', '', $sitei );
594 594
 		$sitei = sanitize_text_field( $sitei );
595 595
 		$sitei = trim( $sitei );
596
-		$sitei = ( strlen($sitei) > 30 ) ? substr($sitei, 0, 30 ) : $sitei;
596
+		$sitei = ( strlen( $sitei ) > 30 ) ? substr( $sitei, 0, 30 ) : $sitei;
597 597
 		return $sitei;
598 598
 	}
599 599
 
Please login to merge, or discard this patch.
Braces   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 		add_action( 'wp_ajax_nopriv_monsterinsights_push_mp_token', array( $this, 'handle_relay_mp_token_push' ) );
45 45
 	}
46 46
 
47
-	public function get_tt(){
47
+	public function get_tt() {
48 48
 		$tt = is_network_admin() ? get_site_option( 'monsterinsights_network_tt', '' ) : get_option( 'monsterinsights_site_tt', '' );
49 49
 		if ( empty( $tt ) ) {
50 50
 			// if TT is empty, generate a new one, save it and then return it
@@ -54,12 +54,12 @@  discard block
 block discarded – undo
54 54
 		return $tt;
55 55
 	}
56 56
 
57
-	public function rotate_tt(){
57
+	public function rotate_tt() {
58 58
 		$tt = $this->generate_tt();
59 59
 		is_network_admin() ? update_site_option( 'monsterinsights_network_tt', $tt ) : update_option( 'monsterinsights_site_tt', $tt );
60 60
 	}
61 61
 
62
-	public function generate_tt(){
62
+	public function generate_tt() {
63 63
 		return hash( 'sha512', wp_generate_password( 128, true, true ) . AUTH_SALT . uniqid( "", true ) );
64 64
 	}
65 65
 
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 		);
78 78
 	}
79 79
 
80
-	public function maybe_authenticate(){
80
+	public function maybe_authenticate() {
81 81
 
82 82
 		// Check nonce
83 83
 		check_ajax_referer( 'mi-admin-nonce', 'nonce' );
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 		wp_send_json_success();
174 174
 	}
175 175
 
176
-	public function authenticate_listener(){
176
+	public function authenticate_listener() {
177 177
 		// Make sure it's for us
178 178
 		if ( empty( $_REQUEST['mi-oauth-action'] ) || $_REQUEST['mi-oauth-action'] !== 'auth' ) {
179 179
 			return;
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 		exit;
255 255
 	}
256 256
 
257
-	public function maybe_reauthenticate(){
257
+	public function maybe_reauthenticate() {
258 258
 
259 259
 		// Check nonce
260 260
 		check_ajax_referer( 'mi-admin-nonce', 'nonce' );
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 		wp_send_json_success( array( 'redirect' => $siteurl ) );
307 307
 	}
308 308
 
309
-	public function reauthenticate_listener(){
309
+	public function reauthenticate_listener() {
310 310
 		// Make sure it's for us
311 311
 		if ( empty( $_REQUEST['mi-oauth-action'] ) || $_REQUEST['mi-oauth-action'] !== 'reauth' ) {
312 312
 			return;
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
 		exit;
390 390
 	}
391 391
 
392
-	public function maybe_verify(){
392
+	public function maybe_verify() {
393 393
 
394 394
 		// Check nonce
395 395
 		check_ajax_referer( 'mi-admin-nonce', 'nonce' );
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 		}
426 426
 	}
427 427
 
428
-	public function verify_auth( $credentials = array() ){
428
+	public function verify_auth( $credentials = array() ) {
429 429
 		$creds = ! empty( $credentials ) ? $credentials : ( $this->is_network_admin() ? MonsterInsights()->auth->get_network_analytics_profile( true ) : MonsterInsights()->auth->get_analytics_profile( true ) );
430 430
 
431 431
 		if ( empty( $creds['key'] ) ) {
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 		}
445 445
 	}
446 446
 
447
-	public function maybe_delete(){
447
+	public function maybe_delete() {
448 448
 
449 449
 		// Check nonce
450 450
 		check_ajax_referer( 'mi-admin-nonce', 'nonce' );
@@ -486,7 +486,7 @@  discard block
 block discarded – undo
486 486
 		}
487 487
 	}
488 488
 
489
-	public function delete_auth( $force = false ){
489
+	public function delete_auth( $force = false ) {
490 490
 		if ( $this->is_network_admin() && ! MonsterInsights()->auth->is_network_authed() ) {
491 491
 			return false;
492 492
 		} else if ( ! $this->is_network_admin() && ! MonsterInsights()->auth->is_authed() ) {
Please login to merge, or discard this patch.
includes/measurement-protocol-v4.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
 
61 61
 		foreach ( $defaults as $key => $default ) {
62 62
 			if ( array_key_exists( $key, $args ) ) {
63
-				$out[ $key ] = $args[ $key ];
63
+				$out[$key] = $args[$key];
64 64
 			} else {
65
-				$out[ $key ] = $default;
65
+				$out[$key] = $default;
66 66
 			}
67 67
 		}
68 68
 
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 
88 88
 		if ( $this->is_debug ) {
89 89
 			foreach ( $body['events'] as $index => $event ) {
90
-				$body['events'][ $index ]['params']['debug_mode'] = true;
90
+				$body['events'][$index]['params']['debug_mode'] = true;
91 91
 			}
92 92
 		}
93 93
 
Please login to merge, or discard this patch.
includes/frontend/tracking/class-tracking-analytics.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -98,8 +98,8 @@  discard block
 block discarded – undo
98 98
 
99 99
 		if ( $create && ! empty( $create ) && is_array( $create ) ) {
100 100
 			$create = json_encode( $create );
101
-			$create = str_replace( '"', "'",  $create );
102
-			$options['create'] = "'create', '" . esc_js( $ua_code ). "', '" . esc_js( $domain ) . "', " . $create;
101
+			$create = str_replace( '"', "'", $create );
102
+			$options['create'] = "'create', '" . esc_js( $ua_code ) . "', '" . esc_js( $domain ) . "', " . $create;
103 103
 		} else {
104 104
 			$options['create'] = "'create', '" . esc_js( $ua_code ) . "', '" . esc_js( $domain ) . "'";
105 105
 		}
@@ -206,22 +206,22 @@  discard block
 block discarded – undo
206 206
 <?php if ( ! $track_user ) {
207 207
 	if ( empty( $ua ) ) {
208 208
 		$reason = __( 'Note: MonsterInsights is not currently configured on this site. The site owner needs to authenticate with Google Analytics in the MonsterInsights settings panel.', 'google-analytics-for-wordpress' );
209
-	    $output .=  '<!-- ' . esc_html( $reason ) . ' -->' . PHP_EOL;
209
+	    $output .= '<!-- ' . esc_html( $reason ) . ' -->' . PHP_EOL;
210 210
 	} else if ( current_user_can( 'monsterinsights_save_settings' ) ) {
211
-		$reason = __( 'Note: MonsterInsights does not track you as a logged-in site administrator to prevent site owners from accidentally skewing their own Google Analytics data.'. PHP_EOL . 'If you are testing Google Analytics code, please do so either logged out or in the private browsing/incognito mode of your web browser.', 'google-analytics-for-wordpress' );
212
-	    $output .=  '<!-- ' . esc_html( $reason ) . ' -->' . PHP_EOL;
211
+		$reason = __( 'Note: MonsterInsights does not track you as a logged-in site administrator to prevent site owners from accidentally skewing their own Google Analytics data.' . PHP_EOL . 'If you are testing Google Analytics code, please do so either logged out or in the private browsing/incognito mode of your web browser.', 'google-analytics-for-wordpress' );
212
+	    $output .= '<!-- ' . esc_html( $reason ) . ' -->' . PHP_EOL;
213 213
 	} else {
214 214
 		$reason = __( 'Note: The site owner has disabled Google Analytics tracking for your user role.', 'google-analytics-for-wordpress' );
215
-	    $output .=  '<!-- ' . esc_html( $reason ) . ' -->' . PHP_EOL;
215
+	    $output .= '<!-- ' . esc_html( $reason ) . ' -->' . PHP_EOL;
216 216
 	}
217 217
 	echo $output;
218 218
 } ?>
219 219
 <?php if ( $ua ) { ?>
220
-<script<?php echo $attr_string;?>>
220
+<script<?php echo $attr_string; ?>>
221 221
     (window.gaDevIds=window.gaDevIds||[]).push("dZGIzZG");
222 222
 	var mi_version         = '<?php echo MONSTERINSIGHTS_VERSION; ?>';
223 223
 	var mi_track_user      = <?php echo ( $track_user ? 'true' : 'false' ); ?>;
224
-	var mi_no_track_reason = <?php echo ( $reason ? "'" . esc_js( $reason)  . "'": "''" ); ?>;
224
+	var mi_no_track_reason = <?php echo ( $reason ? "'" . esc_js( $reason ) . "'" : "''" ); ?>;
225 225
 	<?php do_action( 'monsterinsights_tracking_analytics_frontend_output_after_mi_track_user' ); ?>
226 226
 
227 227
 <?php if ( $this->should_do_optout() ) { ?>
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 	?>
276 276
 	} else {
277 277
 <?php if ( $this->should_do_optout() ) { ?>
278
-		console.log( "<?php echo esc_js( $reason );?>" );
278
+		console.log( "<?php echo esc_js( $reason ); ?>" );
279 279
 		(function() {
280 280
 			/* https://developers.google.com/analytics/devguides/collection/analyticsjs/ */
281 281
 			var noopfn = function() {
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 				}
299 299
 				var f = arguments[len-1];
300 300
 				if ( typeof f !== 'object' || f === null || typeof f.hitCallback !== 'function' ) {
301
-					console.log( '<?php echo esc_js( __("Not running function", "google-analytics-for-wordpress" ) );?> __gaTracker(' + arguments[0] + " ....) <?php echo esc_js( __( "because you are not being tracked.", 'google-analytics-for-wordpress' ) );?> " + mi_no_track_reason );
301
+					console.log( '<?php echo esc_js( __( "Not running function", "google-analytics-for-wordpress" ) ); ?> __gaTracker(' + arguments[0] + " ....) <?php echo esc_js( __( "because you are not being tracked.", 'google-analytics-for-wordpress' ) ); ?> " + mi_no_track_reason );
302 302
 					return;
303 303
 				}
304 304
 				try {
Please login to merge, or discard this patch.
includes/admin/routes.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 			return;
68 68
 		}
69 69
 
70
-		$site_license    = array(
70
+		$site_license = array(
71 71
 			'key'         => MonsterInsights()->license->get_site_license_key(),
72 72
 			'type'        => MonsterInsights()->license->get_site_license_type(),
73 73
 			'is_disabled' => MonsterInsights()->license->site_license_disabled(),
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
 		// Array fields are needed even if empty.
135 135
 		$array_fields = array( 'view_reports', 'save_settings', 'ignore_users' );
136 136
 		foreach ( $array_fields as $array_field ) {
137
-			if ( ! isset( $options[ $array_field ] ) ) {
138
-				$options[ $array_field ] = array();
137
+			if ( ! isset( $options[$array_field] ) ) {
138
+				$options[$array_field] = array();
139 139
 			}
140 140
 		}
141 141
 
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 						}
266 266
 					}
267 267
 					if ( $empty ) {
268
-						unset( $value[ $key ] );
268
+						unset( $value[$key] );
269 269
 					}
270 270
 				}
271 271
 			}
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 				} else {
316 316
 					$addon = $this->get_addon( $installed_plugins, $addons_type, $addon, $slug );
317 317
 				}
318
-				$parsed_addons[ $addon->slug ] = $addon;
318
+				$parsed_addons[$addon->slug] = $addon;
319 319
 			}
320 320
 		}
321 321
 
@@ -365,11 +365,11 @@  discard block
 block discarded – undo
365 365
 		);
366 366
 		// Complianz.
367 367
 		$parsed_addons['complianz'] = array(
368
-			'active' => defined( 'cmplz_plugin') || defined( 'cmplz_premium'),
368
+			'active' => defined( 'cmplz_plugin' ) || defined( 'cmplz_premium' ),
369 369
 		);
370 370
 		// Cookie Yes
371 371
 		$parsed_addons['cookie_yes'] = array(
372
-			'active' => defined( 'CLI_SETTINGS_FIELD'),
372
+			'active' => defined( 'CLI_SETTINGS_FIELD' ),
373 373
 		);
374 374
 		// Fb Instant Articles.
375 375
 		$parsed_addons['instant_articles'] = array(
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
 			'slug'      => 'wp-mail-smtp',
435 435
 		);
436 436
 		// SeedProd.
437
-		$parsed_addons['coming-soon']    = array(
437
+		$parsed_addons['coming-soon'] = array(
438 438
 			'active'    => defined( 'SEEDPROD_VERSION' ),
439 439
 			'icon'      => plugin_dir_url( MONSTERINSIGHTS_PLUGIN_FILE ) . 'assets/images/plugin-seedprod.png',
440 440
 			'title'     => 'SeedProd',
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 			'settings'  => admin_url( 'admin.php?page=seedprod_lite' ),
446 446
 		);
447 447
 		// RafflePress
448
-		$parsed_addons['rafflepress']    = array(
448
+		$parsed_addons['rafflepress'] = array(
449 449
 			'active'    => function_exists( 'rafflepress_lite_activation' ),
450 450
 			'icon'      => plugin_dir_url( MONSTERINSIGHTS_PLUGIN_FILE ) . 'assets/images/pluign-rafflepress.png',
451 451
 			'title'     => 'RafflePress',
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
 		$installed       = false;
556 556
 		$plugin_basename = monsterinsights_get_plugin_basename_from_slug( $slug );
557 557
 
558
-		if ( isset( $installed_plugins[ $plugin_basename ] ) ) {
558
+		if ( isset( $installed_plugins[$plugin_basename] ) ) {
559 559
 			$installed = true;
560 560
 
561 561
 			if ( is_multisite() && is_network_admin() ) {
@@ -570,8 +570,8 @@  discard block
 block discarded – undo
570 570
 
571 571
 		$active_version = false;
572 572
 		if ( $active ) {
573
-			if ( ! empty( $installed_plugins[ $plugin_basename ]['Version'] ) ) {
574
-				$active_version = $installed_plugins[ $plugin_basename ]['Version'];
573
+			if ( ! empty( $installed_plugins[$plugin_basename]['Version'] ) ) {
574
+				$active_version = $installed_plugins[$plugin_basename]['Version'];
575 575
 			}
576 576
 		}
577 577
 
@@ -839,14 +839,14 @@  discard block
 block discarded – undo
839 839
 		);
840 840
 
841 841
 		foreach ( $exclude as $e ) {
842
-			if ( ! empty( $new_settings[ $e ] ) ) {
843
-				unset( $new_settings[ $e ] );
842
+			if ( ! empty( $new_settings[$e] ) ) {
843
+				unset( $new_settings[$e] );
844 844
 			}
845 845
 		}
846 846
 
847 847
 		foreach ( $exclude as $e ) {
848
-			if ( ! empty( $settings[ $e ] ) ) {
849
-				$new_settings = $settings[ $e ];
848
+			if ( ! empty( $settings[$e] ) ) {
849
+				$new_settings = $settings[$e];
850 850
 			}
851 851
 		}
852 852
 
@@ -1006,7 +1006,7 @@  discard block
 block discarded – undo
1006 1006
 			),
1007 1007
 			admin_url( 'admin.php' )
1008 1008
 		);
1009
-		$url    = esc_url( $url );
1009
+		$url = esc_url( $url );
1010 1010
 
1011 1011
 		ob_start();
1012 1012
 		if ( false === ( $creds = request_filesystem_credentials( $url, $method, false, false, null ) ) ) {
@@ -1112,7 +1112,7 @@  discard block
 block discarded – undo
1112 1112
 			$homepage = get_option( 'page_on_front' );
1113 1113
 			if ( ! $homepage ) {
1114 1114
 				$array[] = array(
1115
-					'id'    => - 1,
1115
+					'id'    => -1,
1116 1116
 					'title' => __( 'Homepage', 'google-analytics-for-wordpress' ),
1117 1117
 				);
1118 1118
 			}
@@ -1186,7 +1186,7 @@  discard block
 block discarded – undo
1186 1186
 			if ( ! post_type_supports( $post_type->name, 'editor' ) || 'product' === $post_type->name ) {
1187 1187
 				continue;
1188 1188
 			}
1189
-			$post_types_parsed[ $post_type->name ] = $post_type->labels->singular_name;
1189
+			$post_types_parsed[$post_type->name] = $post_type->labels->singular_name;
1190 1190
 		}
1191 1191
 
1192 1192
 		$post_types_parsed = apply_filters( 'monsterinsights_vue_post_types_editor', $post_types_parsed );
@@ -1308,18 +1308,18 @@  discard block
 block discarded – undo
1308 1308
 			$value        = sanitize_text_field( wp_unslash( $_POST['value'] ) ); // Value of custom style like 12px or #fff.
1309 1309
 			$settings     = get_option( $settings_key, array() );
1310 1310
 
1311
-			if ( ! isset( $settings[ $type ] ) ) {
1312
-				$settings[ $type ] = array();
1311
+			if ( ! isset( $settings[$type] ) ) {
1312
+				$settings[$type] = array();
1313 1313
 			}
1314
-			if ( ! isset( $settings[ $type ][ $theme ] ) ) {
1315
-				$settings[ $type ][ $theme ] = array();
1314
+			if ( ! isset( $settings[$type][$theme] ) ) {
1315
+				$settings[$type][$theme] = array();
1316 1316
 			}
1317 1317
 
1318
-			if ( ! isset( $settings[ $type ][ $theme ][ $object ] ) ) {
1319
-				$settings[ $type ][ $theme ][ $object ] = array();
1318
+			if ( ! isset( $settings[$type][$theme][$object] ) ) {
1319
+				$settings[$type][$theme][$object] = array();
1320 1320
 			}
1321 1321
 
1322
-			$settings[ $type ][ $theme ][ $object ][ $key ] = $value;
1322
+			$settings[$type][$theme][$object][$key] = $value;
1323 1323
 
1324 1324
 			update_option( $settings_key, $settings );
1325 1325
 
Please login to merge, or discard this patch.
includes/frontend/seedprod.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -36,10 +36,10 @@
 block discarded – undo
36 36
 	    require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/events/class-gtag-events.php';
37 37
 	    new MonsterInsights_Gtag_Events();
38 38
 
39
-        // Let's run form tracking if we find it
40
-        if ( function_exists( 'monsterinsights_forms_output_after_script' ) ) {
41
-            monsterinsights_forms_output_after_script( array() );
42
-        }
39
+	// Let's run form tracking if we find it
40
+	if ( function_exists( 'monsterinsights_forms_output_after_script' ) ) {
41
+	    monsterinsights_forms_output_after_script( array() );
42
+	}
43 43
     }
44 44
 }
45 45
 add_action( 'seedprod_monsterinsights_output_tracking', 'monsterinsights_seedprod_tracking', 6, 1 );
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
 	do_action( 'monsterinsights_tracking_after_gtag' );
31 31
     do_action( 'monsterinsights_tracking_after', 'gtag' );
32 32
 
33
-    $track_user    = monsterinsights_track_user();
33
+    $track_user = monsterinsights_track_user();
34 34
 
35 35
     if ( $track_user ) {
36 36
 	    require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/events/class-gtag-events.php';
Please login to merge, or discard this patch.
includes/frontend/tracking/class-tracking-gtag.php 3 patches
Indentation   +138 added lines, -138 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
      */
53 53
     public function frontend_tracking_options_persistent()
54 54
     {
55
-        return apply_filters('monsterinsights_frontend_tracking_options_persistent_gtag_before_pageview', []);
55
+	return apply_filters('monsterinsights_frontend_tracking_options_persistent_gtag_before_pageview', []);
56 56
     }
57 57
 
58 58
     /**
@@ -71,107 +71,107 @@  discard block
 block discarded – undo
71 71
      */
72 72
     public function frontend_tracking_options($type = 'ua', $encoded = false)
73 73
     {
74
-        global $wp_query;
75
-        $options = [];
74
+	global $wp_query;
75
+	$options = [];
76 76
 
77
-        $tracking_ids = monsterinsights_get_tracking_ids();
78
-        if (empty($tracking_ids)) {
79
-            return $encoded ? wp_json_encode($options) : $options;
80
-        }
77
+	$tracking_ids = monsterinsights_get_tracking_ids();
78
+	if (empty($tracking_ids)) {
79
+	    return $encoded ? wp_json_encode($options) : $options;
80
+	}
81 81
 
82
-        $placeholder = '';
82
+	$placeholder = '';
83 83
 
84
-        if ($encoded) {
85
-            $placeholder = '!@#';
86
-        }
84
+	if ($encoded) {
85
+	    $placeholder = '!@#';
86
+	}
87 87
 
88
-        //		$track_user = monsterinsights_track_user();
88
+	//		$track_user = monsterinsights_track_user();
89 89
 //
90
-        //		if ( ! $track_user ) {
91
-        //			$options['create']   = "'create', '" . esc_js( $ua_code ) . "', '" . esc_js( 'auto' ) . "'";
92
-        //			$options['forceSSL'] = "'set', 'forceSSL', true";
93
-        //			$options['send']     = "'send','pageview'";
90
+	//		if ( ! $track_user ) {
91
+	//			$options['create']   = "'create', '" . esc_js( $ua_code ) . "', '" . esc_js( 'auto' ) . "'";
92
+	//			$options['forceSSL'] = "'set', 'forceSSL', true";
93
+	//			$options['send']     = "'send','pageview'";
94 94
 //
95
-        //			return $options;
96
-        //		}
97
-
98
-        $cross_domains = monsterinsights_get_option('cross_domains', []);
99
-        $allow_anchor = monsterinsights_get_option('allow_anchor', false);
100
-
101
-        if ($allow_anchor) {
102
-            $options['allow_anchor'] = 'true';
103
-        }
104
-
105
-        if (class_exists('MonsterInsights_AMP')) {
106
-            $options['use_amp_client_id'] = 'true';
107
-        }
108
-
109
-        $options['forceSSL'] = 'true';
110
-
111
-        // Anonymous data.
112
-        if (monsterinsights_get_option('anonymize_ips', false)) {
113
-            $options['anonymize_ip'] = 'true';
114
-        }
115
-
116
-        $options = apply_filters('monsterinsights_frontend_tracking_options_gtag_before_scripts', $options);
117
-
118
-        // Add Enhanced link attribution.
119
-        if (monsterinsights_get_option('link_attribution', false)) {
120
-            $options['link_attribution'] = 'true';
121
-        }
122
-
123
-        // Add cross-domain tracking.
124
-        if (is_array($cross_domains) && !empty($cross_domains)) {
125
-            $linker_domains = [];
126
-            foreach ($cross_domains as $cross_domain) {
127
-                if (!empty($cross_domain['domain'])) {
128
-                    $linker_domains[] = $cross_domain['domain'];
129
-                }
130
-            }
131
-            $options['linker'] = [
132
-                'domains' => $linker_domains,
133
-            ];
134
-        }
135
-
136
-        if (monsterinsights_is_debug_mode()) {
137
-            $options['debug_mode'] = true;
138
-        }
139
-
140
-        $options = apply_filters('monsterinsights_frontend_tracking_options_gtag_before_pageview', $options, $type);
141
-        $options = apply_filters('monsterinsights_frontend_tracking_options_before_pageview', $options, $this->name, $this->version, $type);
142
-
143
-        if (is_404()) {
144
-            if (monsterinsights_get_option('hash_tracking', false)) {
145
-                $options['page_path'] = "{$placeholder}'/404.html?page=' + document.location.pathname + document.location.search + location.hash + '&from=' + document.referrer{$placeholder}";
146
-            } else {
147
-                $options['page_path'] = "{$placeholder}'/404.html?page=' + document.location.pathname + document.location.search + '&from=' + document.referrer{$placeholder}";
148
-            }
149
-        } elseif ($wp_query->is_search) {
150
-            $pushstr = "'/?s=";
151
-            if (0 === (int) $wp_query->found_posts) {
152
-                $options['page_path'] = $pushstr.'no-results:'.rawurlencode($wp_query->query_vars['s'])."&cat=no-results'";
153
-            } elseif (1 === (int) $wp_query->found_posts) {
154
-                $options['page_path'] = $pushstr.rawurlencode($wp_query->query_vars['s'])."&cat=1-result'";
155
-            } elseif ($wp_query->found_posts > 1 && $wp_query->found_posts < 6) {
156
-                $options['page_path'] = $pushstr.rawurlencode($wp_query->query_vars['s'])."&cat=2-5-results'";
157
-            } else {
158
-                $options['page_path'] = $pushstr.rawurlencode($wp_query->query_vars['s'])."&cat=plus-5-results'";
159
-            }
160
-        } elseif (monsterinsights_get_option('hash_tracking', false)) {
161
-            $options['page_path'] = "{$placeholder}location.pathname + location.search + location.hash{$placeholder}";
162
-        }
163
-
164
-        $options = apply_filters('monsterinsights_frontend_tracking_options_gtag_end', $options, $type);
165
-
166
-        if ($encoded) {
167
-            return str_replace(
168
-                ['"'.$placeholder, $placeholder.'"'],
169
-                '',
170
-                wp_json_encode($options)
171
-            );
172
-        }
173
-
174
-        return $options;
95
+	//			return $options;
96
+	//		}
97
+
98
+	$cross_domains = monsterinsights_get_option('cross_domains', []);
99
+	$allow_anchor = monsterinsights_get_option('allow_anchor', false);
100
+
101
+	if ($allow_anchor) {
102
+	    $options['allow_anchor'] = 'true';
103
+	}
104
+
105
+	if (class_exists('MonsterInsights_AMP')) {
106
+	    $options['use_amp_client_id'] = 'true';
107
+	}
108
+
109
+	$options['forceSSL'] = 'true';
110
+
111
+	// Anonymous data.
112
+	if (monsterinsights_get_option('anonymize_ips', false)) {
113
+	    $options['anonymize_ip'] = 'true';
114
+	}
115
+
116
+	$options = apply_filters('monsterinsights_frontend_tracking_options_gtag_before_scripts', $options);
117
+
118
+	// Add Enhanced link attribution.
119
+	if (monsterinsights_get_option('link_attribution', false)) {
120
+	    $options['link_attribution'] = 'true';
121
+	}
122
+
123
+	// Add cross-domain tracking.
124
+	if (is_array($cross_domains) && !empty($cross_domains)) {
125
+	    $linker_domains = [];
126
+	    foreach ($cross_domains as $cross_domain) {
127
+		if (!empty($cross_domain['domain'])) {
128
+		    $linker_domains[] = $cross_domain['domain'];
129
+		}
130
+	    }
131
+	    $options['linker'] = [
132
+		'domains' => $linker_domains,
133
+	    ];
134
+	}
135
+
136
+	if (monsterinsights_is_debug_mode()) {
137
+	    $options['debug_mode'] = true;
138
+	}
139
+
140
+	$options = apply_filters('monsterinsights_frontend_tracking_options_gtag_before_pageview', $options, $type);
141
+	$options = apply_filters('monsterinsights_frontend_tracking_options_before_pageview', $options, $this->name, $this->version, $type);
142
+
143
+	if (is_404()) {
144
+	    if (monsterinsights_get_option('hash_tracking', false)) {
145
+		$options['page_path'] = "{$placeholder}'/404.html?page=' + document.location.pathname + document.location.search + location.hash + '&from=' + document.referrer{$placeholder}";
146
+	    } else {
147
+		$options['page_path'] = "{$placeholder}'/404.html?page=' + document.location.pathname + document.location.search + '&from=' + document.referrer{$placeholder}";
148
+	    }
149
+	} elseif ($wp_query->is_search) {
150
+	    $pushstr = "'/?s=";
151
+	    if (0 === (int) $wp_query->found_posts) {
152
+		$options['page_path'] = $pushstr.'no-results:'.rawurlencode($wp_query->query_vars['s'])."&cat=no-results'";
153
+	    } elseif (1 === (int) $wp_query->found_posts) {
154
+		$options['page_path'] = $pushstr.rawurlencode($wp_query->query_vars['s'])."&cat=1-result'";
155
+	    } elseif ($wp_query->found_posts > 1 && $wp_query->found_posts < 6) {
156
+		$options['page_path'] = $pushstr.rawurlencode($wp_query->query_vars['s'])."&cat=2-5-results'";
157
+	    } else {
158
+		$options['page_path'] = $pushstr.rawurlencode($wp_query->query_vars['s'])."&cat=plus-5-results'";
159
+	    }
160
+	} elseif (monsterinsights_get_option('hash_tracking', false)) {
161
+	    $options['page_path'] = "{$placeholder}location.pathname + location.search + location.hash{$placeholder}";
162
+	}
163
+
164
+	$options = apply_filters('monsterinsights_frontend_tracking_options_gtag_end', $options, $type);
165
+
166
+	if ($encoded) {
167
+	    return str_replace(
168
+		['"'.$placeholder, $placeholder.'"'],
169
+		'',
170
+		wp_json_encode($options)
171
+	    );
172
+	}
173
+
174
+	return $options;
175 175
     }
176 176
 
177 177
     /**
@@ -187,36 +187,36 @@  discard block
 block discarded – undo
187 187
      */
188 188
     public function frontend_output()
189 189
     {
190
-        $options = $this->frontend_tracking_options('ua', true);
191
-        $options_v4 = $this->frontend_tracking_options('v4', true);
192
-        $persistent = $this->frontend_tracking_options_persistent();
193
-        $connected_type = MonsterInsights()->auth->get_connected_type();
194
-        $v4_id = monsterinsights_get_v4_id_to_output();
195
-        $ua = monsterinsights_get_ua_to_output();
196
-        $main_id = 'ua' === $connected_type ? $ua : $v4_id;
197
-        $src = apply_filters('monsterinsights_frontend_output_gtag_src', '//www.googletagmanager.com/gtag/js?id='.$main_id);
198
-        $compat_mode = apply_filters('monsterinsights_get_option_gtagtracker_compatibility_mode', true);
199
-        $compat = $compat_mode ? 'window.gtag = __gtagTracker;' : '';
200
-        $track_user = monsterinsights_track_user();
201
-        $output = '';
202
-        $reason = '';
203
-        $attr_string = monsterinsights_get_frontend_analytics_script_atts();
204
-        $gtag_async = apply_filters('monsterinsights_frontend_gtag_script_async', true) ? 'async' : '';
205
-        ob_start(); ?>
190
+	$options = $this->frontend_tracking_options('ua', true);
191
+	$options_v4 = $this->frontend_tracking_options('v4', true);
192
+	$persistent = $this->frontend_tracking_options_persistent();
193
+	$connected_type = MonsterInsights()->auth->get_connected_type();
194
+	$v4_id = monsterinsights_get_v4_id_to_output();
195
+	$ua = monsterinsights_get_ua_to_output();
196
+	$main_id = 'ua' === $connected_type ? $ua : $v4_id;
197
+	$src = apply_filters('monsterinsights_frontend_output_gtag_src', '//www.googletagmanager.com/gtag/js?id='.$main_id);
198
+	$compat_mode = apply_filters('monsterinsights_get_option_gtagtracker_compatibility_mode', true);
199
+	$compat = $compat_mode ? 'window.gtag = __gtagTracker;' : '';
200
+	$track_user = monsterinsights_track_user();
201
+	$output = '';
202
+	$reason = '';
203
+	$attr_string = monsterinsights_get_frontend_analytics_script_atts();
204
+	$gtag_async = apply_filters('monsterinsights_frontend_gtag_script_async', true) ? 'async' : '';
205
+	ob_start(); ?>
206 206
 		<!-- This site uses the Google Analytics by MonsterInsights plugin v<?php echo MONSTERINSIGHTS_VERSION; ?> - Using Analytics tracking - https://www.monsterinsights.com/ -->
207 207
 		<?php if (!$track_user) {
208
-            if (empty($v4_id) && empty($ua)) {
209
-                $reason = __('Note: MonsterInsights is not currently configured on this site. The site owner needs to authenticate with Google Analytics in the MonsterInsights settings panel.', 'google-analytics-for-wordpress');
210
-                $output .= '<!-- '.esc_html($reason).' -->'.PHP_EOL;
211
-            } elseif (current_user_can('monsterinsights_save_settings')) {
212
-                $reason = __('Note: MonsterInsights does not track you as a logged-in site administrator to prevent site owners from accidentally skewing their own Google Analytics data.'.PHP_EOL.'If you are testing Google Analytics code, please do so either logged out or in the private browsing/incognito mode of your web browser.', 'google-analytics-for-wordpress');
213
-                $output .= '<!-- '.esc_html($reason).' -->'.PHP_EOL;
214
-            } else {
215
-                $reason = __('Note: The site owner has disabled Google Analytics tracking for your user role.', 'google-analytics-for-wordpress');
216
-                $output .= '<!-- '.esc_html($reason).' -->'.PHP_EOL;
217
-            }
218
-            echo $output;
219
-        } ?>
208
+	    if (empty($v4_id) && empty($ua)) {
209
+		$reason = __('Note: MonsterInsights is not currently configured on this site. The site owner needs to authenticate with Google Analytics in the MonsterInsights settings panel.', 'google-analytics-for-wordpress');
210
+		$output .= '<!-- '.esc_html($reason).' -->'.PHP_EOL;
211
+	    } elseif (current_user_can('monsterinsights_save_settings')) {
212
+		$reason = __('Note: MonsterInsights does not track you as a logged-in site administrator to prevent site owners from accidentally skewing their own Google Analytics data.'.PHP_EOL.'If you are testing Google Analytics code, please do so either logged out or in the private browsing/incognito mode of your web browser.', 'google-analytics-for-wordpress');
213
+		$output .= '<!-- '.esc_html($reason).' -->'.PHP_EOL;
214
+	    } else {
215
+		$reason = __('Note: The site owner has disabled Google Analytics tracking for your user role.', 'google-analytics-for-wordpress');
216
+		$output .= '<!-- '.esc_html($reason).' -->'.PHP_EOL;
217
+	    }
218
+	    echo $output;
219
+	} ?>
220 220
 		<?php if (!empty($v4_id) || !empty($ua)) { ?>
221 221
 			<script src="<?php echo esc_attr($src); ?>" <?php echo $attr_string; ?> <?php echo esc_attr($gtag_async); ?>></script>
222 222
 			<script<?php echo $attr_string; ?>>
@@ -315,12 +315,12 @@  discard block
 block discarded – undo
315 315
 					__gtagTracker( 'set', {
316 316
 						'developer_id.dZGIzZG' : true,
317 317
 						<?php
318
-                        if (!empty($persistent)) {
319
-                            foreach ($persistent as $key => $value) {
320
-                                echo "'".esc_js($key)."' : '".esc_js($value)."',";
321
-                            }
322
-                        }
323
-                        ?>
318
+			if (!empty($persistent)) {
319
+			    foreach ($persistent as $key => $value) {
320
+				echo "'".esc_js($key)."' : '".esc_js($value)."',";
321
+			    }
322
+			}
323
+			?>
324 324
 					} );
325 325
 					<?php if (!empty($v4_id)) { ?>
326 326
 					__gtagTracker( 'config', '<?php echo esc_js($v4_id); ?>', <?php echo $options_v4; ?> );
@@ -328,15 +328,15 @@  discard block
 block discarded – undo
328 328
 					<?php if (!empty($ua)) { ?>
329 329
 					__gtagTracker( 'config', '<?php echo esc_js($ua); ?>', <?php echo $options; ?> );
330 330
 					<?php
331
-                    }
332
-                    /*
331
+		    }
332
+		    /*
333 333
                      * Extend or enhance the functionality by adding custom code to frontend
334 334
                      * tracking via this hook.
335 335
                      *
336 336
                      * @since 7.15.0
337 337
                      */
338
-                    do_action('monsterinsights_frontend_tracking_gtag_after_pageview');
339
-                    ?>
338
+		    do_action('monsterinsights_frontend_tracking_gtag_after_pageview');
339
+		    ?>
340 340
 					<?php echo esc_js($compat); ?>
341 341
 					<?php if (apply_filters('monsterinsights_tracking_gtag_frontend_gatracker_compatibility', true)) { ?>
342 342
 						(function () {
@@ -467,14 +467,14 @@  discard block
 block discarded – undo
467 467
 		<?php } ?>
468 468
 		<!-- / Google Analytics by MonsterInsights -->
469 469
 		<?php
470
-        $output = ob_get_contents();
471
-        ob_end_clean();
470
+	$output = ob_get_contents();
471
+	ob_end_clean();
472 472
 
473
-        return $output;
473
+	return $output;
474 474
     }
475 475
 
476 476
     public function should_do_optout()
477 477
     {
478
-        return !(defined('MI_NO_TRACKING_OPTOUT') && MI_NO_TRACKING_OPTOUT);
478
+	return !(defined('MI_NO_TRACKING_OPTOUT') && MI_NO_TRACKING_OPTOUT);
479 479
     }
480 480
 }
Please login to merge, or discard this patch.
Spacing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 // Exit if accessed directly
11
-if (!defined('ABSPATH')) {
11
+if ( ! defined( 'ABSPATH' ) ) {
12 12
     exit;
13 13
 }
14 14
 
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
      */
53 53
     public function frontend_tracking_options_persistent()
54 54
     {
55
-        return apply_filters('monsterinsights_frontend_tracking_options_persistent_gtag_before_pageview', []);
55
+        return apply_filters( 'monsterinsights_frontend_tracking_options_persistent_gtag_before_pageview', [] );
56 56
     }
57 57
 
58 58
     /**
@@ -69,19 +69,19 @@  discard block
 block discarded – undo
69 69
      *
70 70
      * @since 7.15.0
71 71
      */
72
-    public function frontend_tracking_options($type = 'ua', $encoded = false)
72
+    public function frontend_tracking_options( $type = 'ua', $encoded = false )
73 73
     {
74 74
         global $wp_query;
75 75
         $options = [];
76 76
 
77 77
         $tracking_ids = monsterinsights_get_tracking_ids();
78
-        if (empty($tracking_ids)) {
79
-            return $encoded ? wp_json_encode($options) : $options;
78
+        if ( empty( $tracking_ids ) ) {
79
+            return $encoded ? wp_json_encode( $options ) : $options;
80 80
         }
81 81
 
82 82
         $placeholder = '';
83 83
 
84
-        if ($encoded) {
84
+        if ( $encoded ) {
85 85
             $placeholder = '!@#';
86 86
         }
87 87
 
@@ -95,36 +95,36 @@  discard block
 block discarded – undo
95 95
         //			return $options;
96 96
         //		}
97 97
 
98
-        $cross_domains = monsterinsights_get_option('cross_domains', []);
99
-        $allow_anchor = monsterinsights_get_option('allow_anchor', false);
98
+        $cross_domains = monsterinsights_get_option( 'cross_domains', [] );
99
+        $allow_anchor = monsterinsights_get_option( 'allow_anchor', false );
100 100
 
101
-        if ($allow_anchor) {
101
+        if ( $allow_anchor ) {
102 102
             $options['allow_anchor'] = 'true';
103 103
         }
104 104
 
105
-        if (class_exists('MonsterInsights_AMP')) {
105
+        if ( class_exists( 'MonsterInsights_AMP' ) ) {
106 106
             $options['use_amp_client_id'] = 'true';
107 107
         }
108 108
 
109 109
         $options['forceSSL'] = 'true';
110 110
 
111 111
         // Anonymous data.
112
-        if (monsterinsights_get_option('anonymize_ips', false)) {
112
+        if ( monsterinsights_get_option( 'anonymize_ips', false ) ) {
113 113
             $options['anonymize_ip'] = 'true';
114 114
         }
115 115
 
116
-        $options = apply_filters('monsterinsights_frontend_tracking_options_gtag_before_scripts', $options);
116
+        $options = apply_filters( 'monsterinsights_frontend_tracking_options_gtag_before_scripts', $options );
117 117
 
118 118
         // Add Enhanced link attribution.
119
-        if (monsterinsights_get_option('link_attribution', false)) {
119
+        if ( monsterinsights_get_option( 'link_attribution', false ) ) {
120 120
             $options['link_attribution'] = 'true';
121 121
         }
122 122
 
123 123
         // Add cross-domain tracking.
124
-        if (is_array($cross_domains) && !empty($cross_domains)) {
124
+        if ( is_array( $cross_domains ) && ! empty( $cross_domains ) ) {
125 125
             $linker_domains = [];
126
-            foreach ($cross_domains as $cross_domain) {
127
-                if (!empty($cross_domain['domain'])) {
126
+            foreach ( $cross_domains as $cross_domain ) {
127
+                if ( ! empty( $cross_domain['domain'] ) ) {
128 128
                     $linker_domains[] = $cross_domain['domain'];
129 129
                 }
130 130
             }
@@ -133,41 +133,41 @@  discard block
 block discarded – undo
133 133
             ];
134 134
         }
135 135
 
136
-        if (monsterinsights_is_debug_mode()) {
136
+        if ( monsterinsights_is_debug_mode() ) {
137 137
             $options['debug_mode'] = true;
138 138
         }
139 139
 
140
-        $options = apply_filters('monsterinsights_frontend_tracking_options_gtag_before_pageview', $options, $type);
141
-        $options = apply_filters('monsterinsights_frontend_tracking_options_before_pageview', $options, $this->name, $this->version, $type);
140
+        $options = apply_filters( 'monsterinsights_frontend_tracking_options_gtag_before_pageview', $options, $type );
141
+        $options = apply_filters( 'monsterinsights_frontend_tracking_options_before_pageview', $options, $this->name, $this->version, $type );
142 142
 
143
-        if (is_404()) {
144
-            if (monsterinsights_get_option('hash_tracking', false)) {
143
+        if ( is_404() ) {
144
+            if ( monsterinsights_get_option( 'hash_tracking', false ) ) {
145 145
                 $options['page_path'] = "{$placeholder}'/404.html?page=' + document.location.pathname + document.location.search + location.hash + '&from=' + document.referrer{$placeholder}";
146 146
             } else {
147 147
                 $options['page_path'] = "{$placeholder}'/404.html?page=' + document.location.pathname + document.location.search + '&from=' + document.referrer{$placeholder}";
148 148
             }
149
-        } elseif ($wp_query->is_search) {
149
+        } elseif ( $wp_query->is_search ) {
150 150
             $pushstr = "'/?s=";
151
-            if (0 === (int) $wp_query->found_posts) {
152
-                $options['page_path'] = $pushstr.'no-results:'.rawurlencode($wp_query->query_vars['s'])."&cat=no-results'";
153
-            } elseif (1 === (int) $wp_query->found_posts) {
154
-                $options['page_path'] = $pushstr.rawurlencode($wp_query->query_vars['s'])."&cat=1-result'";
155
-            } elseif ($wp_query->found_posts > 1 && $wp_query->found_posts < 6) {
156
-                $options['page_path'] = $pushstr.rawurlencode($wp_query->query_vars['s'])."&cat=2-5-results'";
151
+            if ( 0 === (int) $wp_query->found_posts ) {
152
+                $options['page_path'] = $pushstr . 'no-results:' . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=no-results'";
153
+            } elseif ( 1 === (int) $wp_query->found_posts ) {
154
+                $options['page_path'] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=1-result'";
155
+            } elseif ( $wp_query->found_posts > 1 && $wp_query->found_posts < 6 ) {
156
+                $options['page_path'] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=2-5-results'";
157 157
             } else {
158
-                $options['page_path'] = $pushstr.rawurlencode($wp_query->query_vars['s'])."&cat=plus-5-results'";
158
+                $options['page_path'] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=plus-5-results'";
159 159
             }
160
-        } elseif (monsterinsights_get_option('hash_tracking', false)) {
160
+        } elseif ( monsterinsights_get_option( 'hash_tracking', false ) ) {
161 161
             $options['page_path'] = "{$placeholder}location.pathname + location.search + location.hash{$placeholder}";
162 162
         }
163 163
 
164
-        $options = apply_filters('monsterinsights_frontend_tracking_options_gtag_end', $options, $type);
164
+        $options = apply_filters( 'monsterinsights_frontend_tracking_options_gtag_end', $options, $type );
165 165
 
166
-        if ($encoded) {
166
+        if ( $encoded ) {
167 167
             return str_replace(
168
-                ['"'.$placeholder, $placeholder.'"'],
168
+                ['"' . $placeholder, $placeholder . '"'],
169 169
                 '',
170
-                wp_json_encode($options)
170
+                wp_json_encode( $options )
171 171
             );
172 172
         }
173 173
 
@@ -187,51 +187,51 @@  discard block
 block discarded – undo
187 187
      */
188 188
     public function frontend_output()
189 189
     {
190
-        $options = $this->frontend_tracking_options('ua', true);
191
-        $options_v4 = $this->frontend_tracking_options('v4', true);
190
+        $options = $this->frontend_tracking_options( 'ua', true );
191
+        $options_v4 = $this->frontend_tracking_options( 'v4', true );
192 192
         $persistent = $this->frontend_tracking_options_persistent();
193 193
         $connected_type = MonsterInsights()->auth->get_connected_type();
194 194
         $v4_id = monsterinsights_get_v4_id_to_output();
195 195
         $ua = monsterinsights_get_ua_to_output();
196 196
         $main_id = 'ua' === $connected_type ? $ua : $v4_id;
197
-        $src = apply_filters('monsterinsights_frontend_output_gtag_src', '//www.googletagmanager.com/gtag/js?id='.$main_id);
198
-        $compat_mode = apply_filters('monsterinsights_get_option_gtagtracker_compatibility_mode', true);
197
+        $src = apply_filters( 'monsterinsights_frontend_output_gtag_src', '//www.googletagmanager.com/gtag/js?id=' . $main_id );
198
+        $compat_mode = apply_filters( 'monsterinsights_get_option_gtagtracker_compatibility_mode', true );
199 199
         $compat = $compat_mode ? 'window.gtag = __gtagTracker;' : '';
200 200
         $track_user = monsterinsights_track_user();
201 201
         $output = '';
202 202
         $reason = '';
203 203
         $attr_string = monsterinsights_get_frontend_analytics_script_atts();
204
-        $gtag_async = apply_filters('monsterinsights_frontend_gtag_script_async', true) ? 'async' : '';
204
+        $gtag_async = apply_filters( 'monsterinsights_frontend_gtag_script_async', true ) ? 'async' : '';
205 205
         ob_start(); ?>
206 206
 		<!-- This site uses the Google Analytics by MonsterInsights plugin v<?php echo MONSTERINSIGHTS_VERSION; ?> - Using Analytics tracking - https://www.monsterinsights.com/ -->
207
-		<?php if (!$track_user) {
208
-            if (empty($v4_id) && empty($ua)) {
209
-                $reason = __('Note: MonsterInsights is not currently configured on this site. The site owner needs to authenticate with Google Analytics in the MonsterInsights settings panel.', 'google-analytics-for-wordpress');
210
-                $output .= '<!-- '.esc_html($reason).' -->'.PHP_EOL;
211
-            } elseif (current_user_can('monsterinsights_save_settings')) {
212
-                $reason = __('Note: MonsterInsights does not track you as a logged-in site administrator to prevent site owners from accidentally skewing their own Google Analytics data.'.PHP_EOL.'If you are testing Google Analytics code, please do so either logged out or in the private browsing/incognito mode of your web browser.', 'google-analytics-for-wordpress');
213
-                $output .= '<!-- '.esc_html($reason).' -->'.PHP_EOL;
207
+		<?php if ( ! $track_user ) {
208
+            if ( empty( $v4_id ) && empty( $ua ) ) {
209
+                $reason = __( 'Note: MonsterInsights is not currently configured on this site. The site owner needs to authenticate with Google Analytics in the MonsterInsights settings panel.', 'google-analytics-for-wordpress' );
210
+                $output .= '<!-- ' . esc_html( $reason ) . ' -->' . PHP_EOL;
211
+            } elseif ( current_user_can( 'monsterinsights_save_settings' ) ) {
212
+                $reason = __( 'Note: MonsterInsights does not track you as a logged-in site administrator to prevent site owners from accidentally skewing their own Google Analytics data.' . PHP_EOL . 'If you are testing Google Analytics code, please do so either logged out or in the private browsing/incognito mode of your web browser.', 'google-analytics-for-wordpress' );
213
+                $output .= '<!-- ' . esc_html( $reason ) . ' -->' . PHP_EOL;
214 214
             } else {
215
-                $reason = __('Note: The site owner has disabled Google Analytics tracking for your user role.', 'google-analytics-for-wordpress');
216
-                $output .= '<!-- '.esc_html($reason).' -->'.PHP_EOL;
215
+                $reason = __( 'Note: The site owner has disabled Google Analytics tracking for your user role.', 'google-analytics-for-wordpress' );
216
+                $output .= '<!-- ' . esc_html( $reason ) . ' -->' . PHP_EOL;
217 217
             }
218 218
             echo $output;
219 219
         } ?>
220
-		<?php if (!empty($v4_id) || !empty($ua)) { ?>
221
-			<script src="<?php echo esc_attr($src); ?>" <?php echo $attr_string; ?> <?php echo esc_attr($gtag_async); ?>></script>
220
+		<?php if ( ! empty( $v4_id ) || ! empty( $ua ) ) { ?>
221
+			<script src="<?php echo esc_attr( $src ); ?>" <?php echo $attr_string; ?> <?php echo esc_attr( $gtag_async ); ?>></script>
222 222
 			<script<?php echo $attr_string; ?>>
223 223
 				var mi_version = '<?php echo MONSTERINSIGHTS_VERSION; ?>';
224 224
 				var mi_track_user = <?php echo $track_user ? 'true' : 'false'; ?>;
225
-				var mi_no_track_reason = <?php echo $reason ? "'".esc_js($reason)."'" : "''"; ?>;
226
-				<?php do_action('monsterinsights_tracking_gtag_frontend_output_after_mi_track_user'); ?>
225
+				var mi_no_track_reason = <?php echo $reason ? "'" . esc_js( $reason ) . "'" : "''"; ?>;
226
+				<?php do_action( 'monsterinsights_tracking_gtag_frontend_output_after_mi_track_user' ); ?>
227 227
 
228
-				<?php if ($this->should_do_optout()) { ?>
228
+				<?php if ( $this->should_do_optout() ) { ?>
229 229
 				var disableStrs = [
230
-					<?php if (!empty($v4_id)) { ?>
231
-					'ga-disable-<?php echo esc_js($v4_id); ?>',
230
+					<?php if ( ! empty( $v4_id ) ) { ?>
231
+					'ga-disable-<?php echo esc_js( $v4_id ); ?>',
232 232
 					<?php } ?>
233
-					<?php if (!empty($ua)) { ?>
234
-					'ga-disable-<?php echo esc_js($ua); ?>',
233
+					<?php if ( ! empty( $ua ) ) { ?>
234
+					'ga-disable-<?php echo esc_js( $ua ); ?>',
235 235
 					<?php } ?>
236 236
 				];
237 237
 
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 						}
290 290
 
291 291
 						if ( type === 'event' ) {
292
-							<?php if ($v4_id) { ?>
292
+							<?php if ( $v4_id ) { ?>
293 293
 								parameters.send_to = monsterinsights_frontend.v4_id;
294 294
 								var hookName = name;
295 295
 								if ( typeof parameters[ 'event_category' ] !== 'undefined' ) {
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
 								}
304 304
 							<?php } ?>
305 305
 
306
-							<?php if ($ua) { ?>
306
+							<?php if ( $ua ) { ?>
307 307
 								parameters.send_to = monsterinsights_frontend.ua;
308 308
 								__gtagDataLayer( type, name, parameters );
309 309
 							<?php } ?>
@@ -315,18 +315,18 @@  discard block
 block discarded – undo
315 315
 					__gtagTracker( 'set', {
316 316
 						'developer_id.dZGIzZG' : true,
317 317
 						<?php
318
-                        if (!empty($persistent)) {
319
-                            foreach ($persistent as $key => $value) {
320
-                                echo "'".esc_js($key)."' : '".esc_js($value)."',";
318
+                        if ( ! empty( $persistent ) ) {
319
+                            foreach ( $persistent as $key => $value ) {
320
+                                echo "'" . esc_js( $key ) . "' : '" . esc_js( $value ) . "',";
321 321
                             }
322 322
                         }
323 323
                         ?>
324 324
 					} );
325
-					<?php if (!empty($v4_id)) { ?>
326
-					__gtagTracker( 'config', '<?php echo esc_js($v4_id); ?>', <?php echo $options_v4; ?> );
325
+					<?php if ( ! empty( $v4_id ) ) { ?>
326
+					__gtagTracker( 'config', '<?php echo esc_js( $v4_id ); ?>', <?php echo $options_v4; ?> );
327 327
 					<?php } ?>
328
-					<?php if (!empty($ua)) { ?>
329
-					__gtagTracker( 'config', '<?php echo esc_js($ua); ?>', <?php echo $options; ?> );
328
+					<?php if ( ! empty( $ua ) ) { ?>
329
+					__gtagTracker( 'config', '<?php echo esc_js( $ua ); ?>', <?php echo $options; ?> );
330 330
 					<?php
331 331
                     }
332 332
                     /*
@@ -335,10 +335,10 @@  discard block
 block discarded – undo
335 335
                      *
336 336
                      * @since 7.15.0
337 337
                      */
338
-                    do_action('monsterinsights_frontend_tracking_gtag_after_pageview');
338
+                    do_action( 'monsterinsights_frontend_tracking_gtag_after_pageview' );
339 339
                     ?>
340
-					<?php echo esc_js($compat); ?>
341
-					<?php if (apply_filters('monsterinsights_tracking_gtag_frontend_gatracker_compatibility', true)) { ?>
340
+					<?php echo esc_js( $compat ); ?>
341
+					<?php if ( apply_filters( 'monsterinsights_tracking_gtag_frontend_gatracker_compatibility', true ) ) { ?>
342 342
 						(function () {
343 343
 							/* https://developers.google.com/analytics/devguides/collection/analyticsjs/ */
344 344
 							/* ga and __gaTracker compatibility shim. */
@@ -450,8 +450,8 @@  discard block
 block discarded – undo
450 450
 						})();
451 451
 					<?php } ?>
452 452
 				} else {
453
-					<?php if ($this->should_do_optout()) { ?>
454
-					console.log( "<?php echo esc_js($reason); ?>" );
453
+					<?php if ( $this->should_do_optout() ) { ?>
454
+					console.log( "<?php echo esc_js( $reason ); ?>" );
455 455
 					( function () {
456 456
 							function __gtagTracker() {
457 457
 								return null;
@@ -475,6 +475,6 @@  discard block
 block discarded – undo
475 475
 
476 476
     public function should_do_optout()
477 477
     {
478
-        return !(defined('MI_NO_TRACKING_OPTOUT') && MI_NO_TRACKING_OPTOUT);
478
+        return ! ( defined( 'MI_NO_TRACKING_OPTOUT' ) && MI_NO_TRACKING_OPTOUT );
479 479
     }
480 480
 }
Please login to merge, or discard this patch.
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -12,8 +12,7 @@  discard block
 block discarded – undo
12 12
     exit;
13 13
 }
14 14
 
15
-class MonsterInsights_Tracking_Gtag extends MonsterInsights_Tracking_Abstract
16
-{
15
+class MonsterInsights_Tracking_Gtag extends MonsterInsights_Tracking_Abstract {
17 16
     /**
18 17
      * Holds the name of the tracking type.
19 18
      *
@@ -37,8 +36,7 @@  discard block
 block discarded – undo
37 36
      *
38 37
      * @since 7.15.0
39 38
      */
40
-    public function __construct()
41
-    {
39
+    public function __construct() {
42 40
     }
43 41
 
44 42
     /**
@@ -50,8 +48,7 @@  discard block
 block discarded – undo
50 48
      *
51 49
      * @since 7.15.0
52 50
      */
53
-    public function frontend_tracking_options_persistent()
54
-    {
51
+    public function frontend_tracking_options_persistent() {
55 52
         return apply_filters('monsterinsights_frontend_tracking_options_persistent_gtag_before_pageview', []);
56 53
     }
57 54
 
@@ -69,8 +66,7 @@  discard block
 block discarded – undo
69 66
      *
70 67
      * @since 7.15.0
71 68
      */
72
-    public function frontend_tracking_options($type = 'ua', $encoded = false)
73
-    {
69
+    public function frontend_tracking_options($type = 'ua', $encoded = false) {
74 70
         global $wp_query;
75 71
         $options = [];
76 72
 
@@ -185,8 +181,7 @@  discard block
 block discarded – undo
185 181
      *
186 182
      * @since 7.15.0
187 183
      */
188
-    public function frontend_output()
189
-    {
184
+    public function frontend_output() {
190 185
         $options = $this->frontend_tracking_options('ua', true);
191 186
         $options_v4 = $this->frontend_tracking_options('v4', true);
192 187
         $persistent = $this->frontend_tracking_options_persistent();
@@ -473,8 +468,7 @@  discard block
 block discarded – undo
473 468
         return $output;
474 469
     }
475 470
 
476
-    public function should_do_optout()
477
-    {
471
+    public function should_do_optout() {
478 472
         return !(defined('MI_NO_TRACKING_OPTOUT') && MI_NO_TRACKING_OPTOUT);
479 473
     }
480 474
 }
Please login to merge, or discard this patch.