Passed
Push — master ( 8161cf...b8b7ed )
by Chris
04:50
created
includes/admin/api-auth.php 2 patches
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -28,19 +28,19 @@  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, 'authenticate' ) );
39
+		add_action( 'wp_ajax_nopriv_monsterinsights_is_installed', array( $this, 'is_installed' ) );
40
+		add_action( 'wp_ajax_nopriv_monsterinsights_rauthenticate', array( $this, 'authenticate' ) );
41 41
 	}
42 42
 
43
-	public function get_tt(){
43
+	public function get_tt() {
44 44
 		$tt = is_network_admin() ? get_site_option( 'monsterinsights_network_tt', '' ) : get_option( 'monsterinsights_site_tt', '' );
45 45
 		if ( empty( $tt ) ) {
46 46
 			// if TT is empty, generate a new one, save it and then return it
@@ -50,12 +50,12 @@  discard block
 block discarded – undo
50 50
 		return $tt;
51 51
 	}
52 52
 
53
-	public function rotate_tt(){
53
+	public function rotate_tt() {
54 54
 		$tt = $this->generate_tt();
55 55
 		is_network_admin() ? update_site_option( 'monsterinsights_network_tt', $tt ) : update_option( 'monsterinsights_site_tt', $tt );
56 56
 	}
57 57
 
58
-	public function generate_tt(){
58
+	public function generate_tt() {
59 59
 		return hash( 'sha512', wp_generate_password( 128, true, true ) . AUTH_SALT . uniqid( "", true ) );
60 60
 	}
61 61
 
@@ -73,14 +73,14 @@  discard block
 block discarded – undo
73 73
 		);
74 74
 	}
75 75
 
76
-	public function maybe_authenticate(){
76
+	public function maybe_authenticate() {
77 77
 
78 78
 		// Check nonce
79 79
 		check_ajax_referer( 'mi-admin-nonce', 'nonce' );
80 80
 
81 81
 		// current user can authenticate
82 82
 		if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
83
-			wp_send_json_error( array(	'message' => __( "You don't have permission to authenticate MonsterInsights.", 'google-analytics-for-wordpress' ) ) );
83
+			wp_send_json_error( array( 'message' => __( "You don't have permission to authenticate MonsterInsights.", 'google-analytics-for-wordpress' ) ) );
84 84
 		}
85 85
 
86 86
 		if ( ! empty( $_REQUEST['isnetwork'] ) && $_REQUEST['isnetwork'] ) {
@@ -90,14 +90,14 @@  discard block
 block discarded – undo
90 90
 		// Only for Pro users, require a license key to be entered first so we can link to things.
91 91
 		$valid = is_network_admin() ? MonsterInsights()->license->is_network_licensed() : MonsterInsights()->license->is_site_licensed();
92 92
 		if ( monsterinsights_is_pro_version() && ! $valid ) {
93
-			wp_send_json_error( array(	'message' => __( "Cannot authenticate. Please enter a valid, active license key for MonsterInsights Pro into the settings.", 'google-analytics-for-wordpress' ) ) );
93
+			wp_send_json_error( array( 'message' => __( "Cannot authenticate. Please enter a valid, active license key for MonsterInsights Pro into the settings.", 'google-analytics-for-wordpress' ) ) );
94 94
 		}
95 95
 
96 96
 		// we do not have a current auth
97 97
 		if ( ! $this->is_network_admin() && MonsterInsights()->auth->is_authed() ) {
98
-			wp_send_json_error( array(	'message' => __( "Cannot authenticate. Please re-authenticate.", 'google-analytics-for-wordpress' ) ) );
98
+			wp_send_json_error( array( 'message' => __( "Cannot authenticate. Please re-authenticate.", 'google-analytics-for-wordpress' ) ) );
99 99
 		} else if ( $this->is_network_admin() && MonsterInsights()->auth->is_network_authed() ) {
100
-			wp_send_json_error( array(	'message' => __( "Cannot network authenticate. Please re-authenticate on the network settings panel.", 'google-analytics-for-wordpress' ) ) );
100
+			wp_send_json_error( array( 'message' => __( "Cannot network authenticate. Please re-authenticate on the network settings panel.", 'google-analytics-for-wordpress' ) ) );
101 101
 		}
102 102
 
103 103
 		$sitei = $this->get_sitei();
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 		wp_send_json_success();
205 205
 	}
206 206
 
207
-	public function authenticate_listener(){
207
+	public function authenticate_listener() {
208 208
 		// Make sure it's for us
209 209
 		if ( empty( $_REQUEST['mi-oauth-action'] ) || $_REQUEST['mi-oauth-action'] !== 'auth' ) {
210 210
 			return;
@@ -221,12 +221,12 @@  discard block
 block discarded – undo
221 221
 		}
222 222
 
223 223
 		// Make sure has required params
224
-		if ( empty( $_REQUEST['key'] )      ||
225
-			 empty( $_REQUEST['token'] )    ||
226
-			 empty( $_REQUEST['ua'] )       ||
227
-			 empty( $_REQUEST['miview'] )   ||
228
-			 empty( $_REQUEST['a'] )        ||
229
-			 empty( $_REQUEST['w'] )        ||
224
+		if ( empty( $_REQUEST['key'] ) ||
225
+			 empty( $_REQUEST['token'] ) ||
226
+			 empty( $_REQUEST['ua'] ) ||
227
+			 empty( $_REQUEST['miview'] ) ||
228
+			 empty( $_REQUEST['a'] ) ||
229
+			 empty( $_REQUEST['w'] ) ||
230 230
 			 empty( $_REQUEST['p'] )
231 231
 		) {
232 232
 			return;
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 		$where = $this->is_network_admin() ? 'network' : 'site';
266 266
 		MonsterInsights()->reporting->delete_aggregate_data( $where );
267 267
 
268
-		$url = $this->is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' )  : admin_url( 'admin.php?page=monsterinsights_settings' ) ;
268
+		$url = $this->is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' );
269 269
 		$url = add_query_arg( array(
270 270
 			 'mi_action' => 'auth',
271 271
 			 'success'   => 'true',
@@ -274,14 +274,14 @@  discard block
 block discarded – undo
274 274
 		exit;
275 275
 	}
276 276
 
277
-	public function maybe_reauthenticate(){
277
+	public function maybe_reauthenticate() {
278 278
 
279 279
 		// Check nonce
280 280
 		check_ajax_referer( 'mi-admin-nonce', 'nonce' );
281 281
 
282 282
 		// current user can authenticate
283 283
 		if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
284
-			wp_send_json_error( array(	'message' => __( "You don't have permission to re-authenticate MonsterInsights.", 'google-analytics-for-wordpress' ) ) );
284
+			wp_send_json_error( array( 'message' => __( "You don't have permission to re-authenticate MonsterInsights.", 'google-analytics-for-wordpress' ) ) );
285 285
 		}
286 286
 
287 287
 		if ( ! empty( $_REQUEST['isnetwork'] ) && $_REQUEST['isnetwork'] ) {
@@ -291,14 +291,14 @@  discard block
 block discarded – undo
291 291
 		// Only for Pro users, require a license key to be entered first so we can link to things.
292 292
 		$valid = is_network_admin() ? MonsterInsights()->license->is_network_licensed() : MonsterInsights()->license->is_site_licensed();
293 293
 		if ( monsterinsights_is_pro_version() && ! $valid ) {
294
-			wp_send_json_error( array(	'message' => __( "Cannot re-authenticate. Please enter a valid, active license key for MonsterInsights Pro into the settings.", 'google-analytics-for-wordpress' ) ) );
294
+			wp_send_json_error( array( 'message' => __( "Cannot re-authenticate. Please enter a valid, active license key for MonsterInsights Pro into the settings.", 'google-analytics-for-wordpress' ) ) );
295 295
 		}
296 296
 
297 297
 		// we do have a current auth
298 298
 		if ( ! $this->is_network_admin() && ! MonsterInsights()->auth->is_authed() ) {
299
-			wp_send_json_error( array(	'message' => __( "Cannot re-authenticate. Please authenticate.", 'google-analytics-for-wordpress' ) ) );
299
+			wp_send_json_error( array( 'message' => __( "Cannot re-authenticate. Please authenticate.", 'google-analytics-for-wordpress' ) ) );
300 300
 		} else if ( $this->is_network_admin() && ! MonsterInsights()->auth->is_network_authed() ) {
301
-			wp_send_json_error( array(	'message' => __( "Cannot re-authenticate the network. Please authenticate on the network settings panel.", 'google-analytics-for-wordpress' ) ) );
301
+			wp_send_json_error( array( 'message' => __( "Cannot re-authenticate the network. Please authenticate on the network settings panel.", 'google-analytics-for-wordpress' ) ) );
302 302
 		}
303 303
 
304 304
 		$siteurl = add_query_arg( array(
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 		wp_send_json_success( array( 'redirect' => $siteurl ) );
324 324
 	}
325 325
 
326
-	public function reauthenticate_listener(){
326
+	public function reauthenticate_listener() {
327 327
 		// Make sure it's for us
328 328
 		if ( empty( $_REQUEST['mi-oauth-action'] ) || $_REQUEST['mi-oauth-action'] !== 'reauth' ) {
329 329
 			return;
@@ -341,10 +341,10 @@  discard block
 block discarded – undo
341 341
 
342 342
 		// Make sure has required params
343 343
 		if (
344
-			 empty( $_REQUEST['ua'] )       ||
345
-			 empty( $_REQUEST['miview'] )   ||
346
-			 empty( $_REQUEST['a'] )        ||
347
-			 empty( $_REQUEST['w'] )        ||
344
+			 empty( $_REQUEST['ua'] ) ||
345
+			 empty( $_REQUEST['miview'] ) ||
346
+			 empty( $_REQUEST['a'] ) ||
347
+			 empty( $_REQUEST['w'] ) ||
348 348
 			 empty( $_REQUEST['p'] )       
349 349
 		) {
350 350
 			return;
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 		$where = $this->is_network_admin() ? 'network' : 'site';
385 385
 		MonsterInsights()->reporting->delete_aggregate_data( $where );
386 386
 
387
-		$url = $this->is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' )  : admin_url( 'admin.php?page=monsterinsights_settings' ) ;
387
+		$url = $this->is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' );
388 388
 		$url = add_query_arg( array(
389 389
 			 'mi_action' => 'reauth',
390 390
 			 'success'   => 'true',
@@ -393,14 +393,14 @@  discard block
 block discarded – undo
393 393
 		exit;
394 394
 	}
395 395
 
396
-	public function maybe_verify(){
396
+	public function maybe_verify() {
397 397
 
398 398
 		// Check nonce
399 399
 		check_ajax_referer( 'mi-admin-nonce', 'nonce' );
400 400
 
401 401
 		// current user can verify
402 402
 		if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
403
-			wp_send_json_error( array(	'message' => __( "You don't have permission to verify MonsterInsights.", 'google-analytics-for-wordpress' ) ) );
403
+			wp_send_json_error( array( 'message' => __( "You don't have permission to verify MonsterInsights.", 'google-analytics-for-wordpress' ) ) );
404 404
 		}
405 405
 
406 406
 		if ( ! empty( $_REQUEST['isnetwork'] ) && $_REQUEST['isnetwork'] ) {
@@ -409,25 +409,25 @@  discard block
 block discarded – undo
409 409
 
410 410
 		// we have an auth to verify
411 411
 		if ( $this->is_network_admin() && ! MonsterInsights()->auth->is_network_authed() ) {
412
-			wp_send_json_error( array(	'message' => __( "Cannot verify. Please authenticate.", 'google-analytics-for-wordpress' ) ) );
412
+			wp_send_json_error( array( 'message' => __( "Cannot verify. Please authenticate.", 'google-analytics-for-wordpress' ) ) );
413 413
 		} else if ( ! $this->is_network_admin() && ! MonsterInsights()->auth->is_authed() ) {
414
-			wp_send_json_error( array(	'message' => __( "Cannot verify. Please authenticate.", 'google-analytics-for-wordpress' ) ) );
414
+			wp_send_json_error( array( 'message' => __( "Cannot verify. Please authenticate.", 'google-analytics-for-wordpress' ) ) );
415 415
 		}
416 416
 
417 417
 		$valid = is_network_admin() ? MonsterInsights()->license->is_network_licensed() : MonsterInsights()->license->is_site_licensed();
418 418
 		if ( monsterinsights_is_pro_version() && ! $valid ) {
419
-			wp_send_json_error( array(	'message' => __( "Cannot verify. Please enter a valid, active license key for MonsterInsights Pro into the settings.", 'google-analytics-for-wordpress' ) ) );
419
+			wp_send_json_error( array( 'message' => __( "Cannot verify. Please enter a valid, active license key for MonsterInsights Pro into the settings.", 'google-analytics-for-wordpress' ) ) );
420 420
 		}
421 421
 
422 422
 		$worked = $this->verify_auth();
423
-		if ( $worked && ! is_wp_error(  $worked ) ) {
423
+		if ( $worked && ! is_wp_error( $worked ) ) {
424 424
 			wp_send_json_success( array( 'message' => __( "Successfully verified.", 'google-analytics-for-wordpress' ) ) );
425 425
 		} else {
426 426
 			wp_send_json_error( array( 'message' => __( "Could not verify.", 'google-analytics-for-wordpress' ) ) );
427 427
 		}
428 428
 	}
429 429
 
430
-	public function verify_auth( $credentials = array() ){
430
+	public function verify_auth( $credentials = array() ) {
431 431
 		$creds = ! empty( $credentials ) ? $credentials : ( $this->is_network_admin() ? MonsterInsights()->auth->get_network_analytics_profile( true ) : MonsterInsights()->auth->get_analytics_profile( true ) );
432 432
 
433 433
 		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,20 +460,20 @@  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
 		$valid = is_network_admin() ? MonsterInsights()->license->is_network_licensed() : MonsterInsights()->license->is_site_licensed();
469 469
 		if ( monsterinsights_is_pro_version() && ! $valid ) {
470
-			wp_send_json_error( array(	'message' => __( "Cannot deauthenticate. Please enter a valid, active license key for MonsterInsights Pro into the settings.", 'google-analytics-for-wordpress' ) ) );
470
+			wp_send_json_error( array( 'message' => __( "Cannot deauthenticate. Please enter a valid, active license key for MonsterInsights Pro into the settings.", 'google-analytics-for-wordpress' ) ) );
471 471
 		}
472 472
 
473 473
 		$force = ! empty( $_REQUEST['forcedelete'] ) && $_REQUEST['forcedelete'] === 'true';
474 474
 
475 475
 		$worked = $this->delete_auth( $force );
476
-		if ( $worked && ! is_wp_error(  $worked ) ) {
476
+		if ( $worked && ! is_wp_error( $worked ) ) {
477 477
 			wp_send_json_success( array( 'message' => __( "Successfully deauthenticated.", 'google-analytics-for-wordpress' ) ) );
478 478
 		} else {
479 479
 			if ( $force ) {
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
 		}
485 485
 	}
486 486
 
487
-	public function delete_auth( $force = false ){
487
+	public function delete_auth( $force = false ) {
488 488
 		if ( $this->is_network_admin() && ! MonsterInsights()->auth->is_network_authed() ) {
489 489
 			return false;
490 490
 		} else if ( ! $this->is_network_admin() && ! MonsterInsights()->auth->is_authed() ) {
@@ -500,13 +500,13 @@  discard block
 block discarded – undo
500 500
 		// If we have a new siteurl enabled option and the profile site doesn't match the current site, deactivate anyways
501 501
 		if ( is_network_admin() ) {
502 502
 			$siteurl = network_admin_url();
503
-			if ( ! empty( $creds['neturl' ] ) && $creds['neturl'] !== $siteurl ) {
503
+			if ( ! empty( $creds['neturl'] ) && $creds['neturl'] !== $siteurl ) {
504 504
 				MonsterInsights()->auth->delete_network_analytics_profile( true );
505 505
 				return true;
506 506
 			}
507 507
 		} else {
508 508
 			$siteurl = site_url();
509
-			if ( ! empty( $creds['siteurl' ] ) && $creds['siteurl'] !== $siteurl ) {
509
+			if ( ! empty( $creds['siteurl'] ) && $creds['siteurl'] !== $siteurl ) {
510 510
 				MonsterInsights()->auth->delete_analytics_profile( true );
511 511
 				return true;
512 512
 			}
@@ -548,15 +548,15 @@  discard block
 block discarded – undo
548 548
 		// 	return $sitei;
549 549
 		// }
550 550
 
551
-		$auth_key        = defined( 'AUTH_KEY' )        ? AUTH_KEY 		  : '';
551
+		$auth_key        = defined( 'AUTH_KEY' ) ? AUTH_KEY 		  : '';
552 552
 		$secure_auth_key = defined( 'SECURE_AUTH_KEY' ) ? SECURE_AUTH_KEY : '';
553
-		$logged_in_key   = defined( 'LOGGED_IN_KEY' )   ? LOGGED_IN_KEY   : '';
553
+		$logged_in_key   = defined( 'LOGGED_IN_KEY' ) ? LOGGED_IN_KEY   : '';
554 554
 
555 555
 		$sitei = $auth_key . $secure_auth_key . $logged_in_key;
556
-		$sitei = preg_replace('/[^a-zA-Z0-9]/', '', $sitei );
556
+		$sitei = preg_replace( '/[^a-zA-Z0-9]/', '', $sitei );
557 557
 		$sitei = sanitize_text_field( $sitei );
558 558
 		$sitei = trim( $sitei );
559
-		$sitei = ( strlen($sitei) > 30 ) ? substr($sitei, 0, 30 ) : $sitei;
559
+		$sitei = ( strlen( $sitei ) > 30 ) ? substr( $sitei, 0, 30 ) : $sitei;
560 560
 		return $sitei;
561 561
 	}
562 562
 }
563 563
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 		add_action( 'wp_ajax_nopriv_monsterinsights_rauthenticate',   array( $this, 'authenticate' ) );
41 41
 	}
42 42
 
43
-	public function get_tt(){
43
+	public function get_tt() {
44 44
 		$tt = is_network_admin() ? get_site_option( 'monsterinsights_network_tt', '' ) : get_option( 'monsterinsights_site_tt', '' );
45 45
 		if ( empty( $tt ) ) {
46 46
 			// if TT is empty, generate a new one, save it and then return it
@@ -50,12 +50,12 @@  discard block
 block discarded – undo
50 50
 		return $tt;
51 51
 	}
52 52
 
53
-	public function rotate_tt(){
53
+	public function rotate_tt() {
54 54
 		$tt = $this->generate_tt();
55 55
 		is_network_admin() ? update_site_option( 'monsterinsights_network_tt', $tt ) : update_option( 'monsterinsights_site_tt', $tt );
56 56
 	}
57 57
 
58
-	public function generate_tt(){
58
+	public function generate_tt() {
59 59
 		return hash( 'sha512', wp_generate_password( 128, true, true ) . AUTH_SALT . uniqid( "", true ) );
60 60
 	}
61 61
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 		);
74 74
 	}
75 75
 
76
-	public function maybe_authenticate(){
76
+	public function maybe_authenticate() {
77 77
 
78 78
 		// Check nonce
79 79
 		check_ajax_referer( 'mi-admin-nonce', 'nonce' );
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 		wp_send_json_success();
205 205
 	}
206 206
 
207
-	public function authenticate_listener(){
207
+	public function authenticate_listener() {
208 208
 		// Make sure it's for us
209 209
 		if ( empty( $_REQUEST['mi-oauth-action'] ) || $_REQUEST['mi-oauth-action'] !== 'auth' ) {
210 210
 			return;
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 		exit;
275 275
 	}
276 276
 
277
-	public function maybe_reauthenticate(){
277
+	public function maybe_reauthenticate() {
278 278
 
279 279
 		// Check nonce
280 280
 		check_ajax_referer( 'mi-admin-nonce', 'nonce' );
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 		wp_send_json_success( array( 'redirect' => $siteurl ) );
324 324
 	}
325 325
 
326
-	public function reauthenticate_listener(){
326
+	public function reauthenticate_listener() {
327 327
 		// Make sure it's for us
328 328
 		if ( empty( $_REQUEST['mi-oauth-action'] ) || $_REQUEST['mi-oauth-action'] !== 'reauth' ) {
329 329
 			return;
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
 		exit;
394 394
 	}
395 395
 
396
-	public function maybe_verify(){
396
+	public function maybe_verify() {
397 397
 
398 398
 		// Check nonce
399 399
 		check_ajax_referer( 'mi-admin-nonce', 'nonce' );
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 		}
428 428
 	}
429 429
 
430
-	public function verify_auth( $credentials = array() ){
430
+	public function verify_auth( $credentials = array() ) {
431 431
 		$creds = ! empty( $credentials ) ? $credentials : ( $this->is_network_admin() ? MonsterInsights()->auth->get_network_analytics_profile( true ) : MonsterInsights()->auth->get_analytics_profile( true ) );
432 432
 
433 433
 		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' );
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
 		}
485 485
 	}
486 486
 
487
-	public function delete_auth( $force = false ){
487
+	public function delete_auth( $force = false ) {
488 488
 		if ( $this->is_network_admin() && ! MonsterInsights()->auth->is_network_authed() ) {
489 489
 			return false;
490 490
 		} else if ( ! $this->is_network_admin() && ! MonsterInsights()->auth->is_authed() ) {
Please login to merge, or discard this patch.
includes/admin/common.php 1 patch
Spacing   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -155,32 +155,32 @@  discard block
 block discarded – undo
155 155
 				'copytoclip'       				=> esc_html__( 'Copy to Clipboard', 'google-analytics-for-wordpress' ),
156 156
 				'failed'           				=> esc_html__( 'Failed!', 'google-analytics-for-wordpress' ),
157 157
 				'admin_nonce'      				=> wp_create_nonce( 'mi-admin-nonce' ),
158
-				'shorten'         				=> esc_html__( 'Shorten URL' ,'google-analytics-for-wordpress'),
159
-				'shortened'        				=> esc_html__( 'Shortened!' ,'google-analytics-for-wordpress'),
160
-				'working'          				=> esc_html__( 'Working...' ,'google-analytics-for-wordpress'),
161
-				'importtext'       				=> esc_html__( 'Import' ,'google-analytics-for-wordpress'),
162
-				'imported'         				=> esc_html__( 'Imported!' ,'google-analytics-for-wordpress'),
163
-				'redirect_loading_title_text'   => esc_html__( 'Preparing to redirect:' ,'google-analytics-for-wordpress'),
164
-				'redirect_loading_text_text'    => esc_html__( "You'll be redirected momentarily to complete authentication. This may take a couple seconds." ,'google-analytics-for-wordpress'),
165
-				'redirect_loading_error_title'  => esc_html__( "Authentication Error:" ,'google-analytics-for-wordpress'),
166
-				'deauth_loading_title_text'  	=> esc_html__( 'Deauthenticating....' ,'google-analytics-for-wordpress'),
167
-				'deauth_loading_text_text'   	=> esc_html__( "We're deactivating your site. This may take a couple seconds." ,'google-analytics-for-wordpress'),
168
-				'deauth_loading_error_title' 	=> esc_html__( "Deactivation Error:" ,'google-analytics-for-wordpress'),
169
-				'deauth_success_title_text'  	=> esc_html__( 'Deactivated Successfully!' ,'google-analytics-for-wordpress'),
170
-				'deauth_success_text_text'   	=> esc_html__( "You've disconnected your site from MonsterInsights. Your site is no longer being tracked by Google Analytics and you won't see reports anymore." ,'google-analytics-for-wordpress'),
171
-				'verify_loading_title_text'  	=> esc_html__( 'Verifying....' ,'google-analytics-for-wordpress'),
172
-				'verify_loading_text_text'   	=> esc_html__( "We're verifying your site. This may take a couple seconds." ,'google-analytics-for-wordpress'),
173
-				'verify_loading_error_title' 	=> esc_html__( "Verification Error:" ,'google-analytics-for-wordpress'),
174
-				'verify_success_title_text' 	=> esc_html__( 'Verified Successfully!' ,'google-analytics-for-wordpress'),
175
-				'verify_success_text_text'  	=> esc_html__( "Your site is connected to MonsterInsights!" ,'google-analytics-for-wordpress'),
176
-				'ok_text' 						=> esc_html__( "OK" ,'google-analytics-for-wordpress'),
177
-				'force_deauth_button_text'  	=> esc_html__( "Force Deauthenticate" ,'google-analytics-for-wordpress'),
158
+				'shorten'         				=> esc_html__( 'Shorten URL', 'google-analytics-for-wordpress' ),
159
+				'shortened'        				=> esc_html__( 'Shortened!', 'google-analytics-for-wordpress' ),
160
+				'working'          				=> esc_html__( 'Working...', 'google-analytics-for-wordpress' ),
161
+				'importtext'       				=> esc_html__( 'Import', 'google-analytics-for-wordpress' ),
162
+				'imported'         				=> esc_html__( 'Imported!', 'google-analytics-for-wordpress' ),
163
+				'redirect_loading_title_text'   => esc_html__( 'Preparing to redirect:', 'google-analytics-for-wordpress' ),
164
+				'redirect_loading_text_text'    => esc_html__( "You'll be redirected momentarily to complete authentication. This may take a couple seconds.", 'google-analytics-for-wordpress' ),
165
+				'redirect_loading_error_title'  => esc_html__( "Authentication Error:", 'google-analytics-for-wordpress' ),
166
+				'deauth_loading_title_text'  	=> esc_html__( 'Deauthenticating....', 'google-analytics-for-wordpress' ),
167
+				'deauth_loading_text_text'   	=> esc_html__( "We're deactivating your site. This may take a couple seconds.", 'google-analytics-for-wordpress' ),
168
+				'deauth_loading_error_title' 	=> esc_html__( "Deactivation Error:", 'google-analytics-for-wordpress' ),
169
+				'deauth_success_title_text'  	=> esc_html__( 'Deactivated Successfully!', 'google-analytics-for-wordpress' ),
170
+				'deauth_success_text_text'   	=> esc_html__( "You've disconnected your site from MonsterInsights. Your site is no longer being tracked by Google Analytics and you won't see reports anymore.", 'google-analytics-for-wordpress' ),
171
+				'verify_loading_title_text'  	=> esc_html__( 'Verifying....', 'google-analytics-for-wordpress' ),
172
+				'verify_loading_text_text'   	=> esc_html__( "We're verifying your site. This may take a couple seconds.", 'google-analytics-for-wordpress' ),
173
+				'verify_loading_error_title' 	=> esc_html__( "Verification Error:", 'google-analytics-for-wordpress' ),
174
+				'verify_success_title_text' 	=> esc_html__( 'Verified Successfully!', 'google-analytics-for-wordpress' ),
175
+				'verify_success_text_text'  	=> esc_html__( "Your site is connected to MonsterInsights!", 'google-analytics-for-wordpress' ),
176
+				'ok_text' 						=> esc_html__( "OK", 'google-analytics-for-wordpress' ),
177
+				'force_deauth_button_text'  	=> esc_html__( "Force Deauthenticate", 'google-analytics-for-wordpress' ),
178 178
 				'refresh_report_title'          => esc_html__( 'Refreshing Report', 'google-analytics-for-wordpress' ),
179 179
 				'refresh_report_text'           => esc_html__( 'Loading new report data...', 'google-analytics-for-wordpress' ),
180 180
 				'refresh_report_success_text'   => esc_html__( 'Success', 'google-analytics-for-wordpress' ),
181 181
 				'refresh_report_success_text'   => esc_html__( 'Retrieved the new report data successfully', 'google-analytics-for-wordpress' ),
182 182
 				'refresh_report_failure_title'  => esc_html__( 'Error', 'google-analytics-for-wordpress' ),
183
-				'timezone'						=> date('e'),
183
+				'timezone'						=> date( 'e' ),
184 184
 			)
185 185
 		);
186 186
 
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 		'kad_admin_js', // Pinnacle theme
243 243
 		'dt-chart', // DesignThemes core features plugin
244 244
 		'tweeetshare_font_script', // TweetShare - Click To Tweet
245
-		'tweeetshare_jquery_script',  // TweetShare - Click To Tweet
245
+		'tweeetshare_jquery_script', // TweetShare - Click To Tweet
246 246
 		'tweeetshare_jqueryui_script', // TweetShare - Click To Tweet
247 247
 		'tweeetshare_custom_script', // TweetShare - Click To Tweet
248 248
 		'imagify-promise-polyfill', // Imagify 
@@ -261,16 +261,16 @@  discard block
 block discarded – undo
261 261
 		'rml-modal', // WP Real Media Library
262 262
 		'rml-order', // WP Real Media Library
263 263
 		'rml-meta', // WP Real Media Library
264
-		'rml-uploader',  // WP Real Media Library
265
-		'rml-options',  // WP Real Media Library
266
-		'rml-usersettings',  // WP Real Media Library
264
+		'rml-uploader', // WP Real Media Library
265
+		'rml-options', // WP Real Media Library
266
+		'rml-usersettings', // WP Real Media Library
267 267
 		'rml-main', // WP Real Media Library
268 268
 		'control-panel-sweet-alert', // Ken Theme
269 269
 		'sweet-alert-js', // Vitrine Theme
270 270
 		'theme-admin-script', // Vitrine Theme
271 271
 		'sweetalert', //  Church Suite Theme by Webnus
272 272
 		'be_alerts_charts', //  WooCommerce bolder product alerts
273
- 		'magayo-lottery-results',  //  Magayo Lottery Results
273
+ 		'magayo-lottery-results', //  Magayo Lottery Results
274 274
 		'control-panel-sweet-alert', // Ken Theme
275 275
 		'cpm_chart', // WP Project Manager
276 276
 		'adminscripts', //  Artisan Nayma Theme
@@ -350,15 +350,15 @@  discard block
 block discarded – undo
350 350
 
351 351
 	global $wp_styles;
352 352
 	foreach ( $wp_styles->queue as $handle ) {
353
-		if ( strpos( $wp_styles->registered[$handle]->src, 'wp-content') === false ) {
353
+		if ( strpos( $wp_styles->registered[$handle]->src, 'wp-content' ) === false ) {
354 354
 			return;
355 355
 		}
356 356
 		
357
-		if ( strpos( $wp_styles->registered[$handle]->handle, 'monsterinsights') !== false ) {
357
+		if ( strpos( $wp_styles->registered[$handle]->handle, 'monsterinsights' ) !== false ) {
358 358
 			return;
359 359
 		}
360 360
 
361
-		foreach( $third_party as $partial ) {
361
+		foreach ( $third_party as $partial ) {
362 362
 			if ( strpos( $wp_styles->registered[$handle]->handle, $partial ) !== false ) {
363 363
 				wp_dequeue_style( $handle ); // Remove css file from MI screen
364 364
 				wp_deregister_style( $handle );
@@ -373,15 +373,15 @@  discard block
 block discarded – undo
373 373
 
374 374
 	global $wp_scripts;
375 375
 	foreach ( $wp_scripts->queue as $handle ) {
376
-		if ( strpos( $wp_scripts->registered[$handle]->src, 'wp-content') === false ) {
376
+		if ( strpos( $wp_scripts->registered[$handle]->src, 'wp-content' ) === false ) {
377 377
 			return;
378 378
 		}
379 379
 		
380
-		if ( strpos( $wp_scripts->registered[$handle]->handle, 'monsterinsights') !== false ) {
380
+		if ( strpos( $wp_scripts->registered[$handle]->handle, 'monsterinsights' ) !== false ) {
381 381
 			return;
382 382
 		}
383 383
 
384
-		foreach( $third_party as $partial ) {
384
+		foreach ( $third_party as $partial ) {
385 385
 			if ( strpos( $wp_scripts->registered[$handle]->handle, $partial ) !== false ) {
386 386
 				wp_dequeue_script( $handle ); // Remove JS file from MI screen
387 387
 				wp_deregister_script( $handle );
@@ -396,47 +396,47 @@  discard block
 block discarded – undo
396 396
 
397 397
 	// Remove actions from themes that are not following best practices and break the admin doing so
398 398
 		// Theme: Newspaper by tagDiv
399
-			remove_action('admin_enqueue_scripts', 'load_wp_admin_js');
400
-			remove_action('admin_enqueue_scripts', 'load_wp_admin_css');
401
-			remove_action('admin_print_scripts-widgets.php', 'td_on_admin_print_scripts_farbtastic');
402
-			remove_action('admin_print_styles-widgets.php', 'td_on_admin_print_styles_farbtastic');
403
-			remove_action('admin_print_footer_scripts', 'check_if_media_uploads_is_loaded', 9999);
404
-			remove_action('print_media_templates', 'td_custom_gallery_settings_hook');
405
-			remove_action('print_media_templates', 'td_change_backbone_js_hook');
406
-			remove_action('admin_head', 'tdc_on_admin_head'); //  TagDiv Composer Fix
407
-			remove_action('print_media_templates', 'us_media_templates'); // Impreza Theme Fix
408
-			remove_action('admin_footer', 'gt3pg_add_gallery_template'); // GT3 Photo & Video Gallery By GT3 Themes Plugin Fix
399
+			remove_action( 'admin_enqueue_scripts', 'load_wp_admin_js' );
400
+			remove_action( 'admin_enqueue_scripts', 'load_wp_admin_css' );
401
+			remove_action( 'admin_print_scripts-widgets.php', 'td_on_admin_print_scripts_farbtastic' );
402
+			remove_action( 'admin_print_styles-widgets.php', 'td_on_admin_print_styles_farbtastic' );
403
+			remove_action( 'admin_print_footer_scripts', 'check_if_media_uploads_is_loaded', 9999 );
404
+			remove_action( 'print_media_templates', 'td_custom_gallery_settings_hook' );
405
+			remove_action( 'print_media_templates', 'td_change_backbone_js_hook' );
406
+			remove_action( 'admin_head', 'tdc_on_admin_head' ); //  TagDiv Composer Fix
407
+			remove_action( 'print_media_templates', 'us_media_templates' ); // Impreza Theme Fix
408
+			remove_action( 'admin_footer', 'gt3pg_add_gallery_template' ); // GT3 Photo & Video Gallery By GT3 Themes Plugin Fix
409 409
 		// Plugin WP Booklist:
410
-			remove_action('admin_footer', 'wpbooklist_jre_dismiss_prem_notice_forever_action_javascript');
411
-			remove_action('admin_footer', 'wpbooklist_dashboard_add_book_action_javascript');
412
-			remove_action('admin_footer', 'wpbooklist_edit_book_show_form_action_javascript');
413
-			remove_action('admin_footer', 'wpbooklist_show_book_in_colorbox_action_javascript');
414
-			remove_action('admin_footer', 'wpbooklist_new_lib_shortcode_action_javascript');
415
-			remove_action('admin_footer', 'wpbooklist_dashboard_save_library_display_options_action_javascript');
416
-			remove_action('admin_footer', 'wpbooklist_dashboard_save_post_display_options_action_javascript');
417
-			remove_action('admin_footer', 'wpbooklist_dashboard_save_page_display_options_action_javascript');
418
-			remove_action('admin_footer', 'wpbooklist_update_display_options_action_javascript');
419
-			remove_action('admin_footer', 'wpbooklist_edit_book_pagination_action_javascript');
420
-			remove_action('admin_footer', 'wpbooklist_edit_book_switch_lib_action_javascript');
421
-			remove_action('admin_footer', 'wpbooklist_edit_book_search_action_javascript');
422
-			remove_action('admin_footer', 'wpbooklist_edit_book_actual_action_javascript');
423
-			remove_action('admin_footer', 'wpbooklist_delete_book_action_javascript');
424
-			remove_action('admin_footer', 'wpbooklist_user_apis_action_javascript');
425
-			remove_action('admin_footer', 'wpbooklist_upload_new_stylepak_action_javascript');
426
-			remove_action('admin_footer', 'wpbooklist_upload_new_post_template_action_javascript');
427
-			remove_action('admin_footer', 'wpbooklist_upload_new_page_template_action_javascript');
428
-			remove_action('admin_footer', 'wpbooklist_create_db_library_backup_action_javascript');
429
-			remove_action('admin_footer', 'wpbooklist_restore_db_library_backup_action_javascript');
430
-			remove_action('admin_footer', 'wpbooklist_create_csv_action_javascript');
431
-			remove_action('admin_footer', 'wpbooklist_amazon_localization_action_javascript');
432
-			remove_action('admin_footer', 'wpbooklist_delete_book_bulk_action_javascript');
433
-			remove_action('admin_footer', 'wpbooklist_reorder_action_javascript');
434
-			remove_action('admin_footer', 'wpbooklist_exit_results_action_javascript');
435
-			remove_action('admin_footer', 'wpbooklist_storytime_select_category_action_javascript');
436
-			remove_action('admin_footer', 'wpbooklist_storytime_get_story_action_javascript');
437
-			remove_action('admin_footer', 'wpbooklist_storytime_expand_browse_action_javascript');
438
-			remove_action('admin_footer', 'wpbooklist_storytime_save_settings_action_javascript');
439
-			remove_action('admin_footer', 'wpbooklist_delete_story_action_javascript');
410
+			remove_action( 'admin_footer', 'wpbooklist_jre_dismiss_prem_notice_forever_action_javascript' );
411
+			remove_action( 'admin_footer', 'wpbooklist_dashboard_add_book_action_javascript' );
412
+			remove_action( 'admin_footer', 'wpbooklist_edit_book_show_form_action_javascript' );
413
+			remove_action( 'admin_footer', 'wpbooklist_show_book_in_colorbox_action_javascript' );
414
+			remove_action( 'admin_footer', 'wpbooklist_new_lib_shortcode_action_javascript' );
415
+			remove_action( 'admin_footer', 'wpbooklist_dashboard_save_library_display_options_action_javascript' );
416
+			remove_action( 'admin_footer', 'wpbooklist_dashboard_save_post_display_options_action_javascript' );
417
+			remove_action( 'admin_footer', 'wpbooklist_dashboard_save_page_display_options_action_javascript' );
418
+			remove_action( 'admin_footer', 'wpbooklist_update_display_options_action_javascript' );
419
+			remove_action( 'admin_footer', 'wpbooklist_edit_book_pagination_action_javascript' );
420
+			remove_action( 'admin_footer', 'wpbooklist_edit_book_switch_lib_action_javascript' );
421
+			remove_action( 'admin_footer', 'wpbooklist_edit_book_search_action_javascript' );
422
+			remove_action( 'admin_footer', 'wpbooklist_edit_book_actual_action_javascript' );
423
+			remove_action( 'admin_footer', 'wpbooklist_delete_book_action_javascript' );
424
+			remove_action( 'admin_footer', 'wpbooklist_user_apis_action_javascript' );
425
+			remove_action( 'admin_footer', 'wpbooklist_upload_new_stylepak_action_javascript' );
426
+			remove_action( 'admin_footer', 'wpbooklist_upload_new_post_template_action_javascript' );
427
+			remove_action( 'admin_footer', 'wpbooklist_upload_new_page_template_action_javascript' );
428
+			remove_action( 'admin_footer', 'wpbooklist_create_db_library_backup_action_javascript' );
429
+			remove_action( 'admin_footer', 'wpbooklist_restore_db_library_backup_action_javascript' );
430
+			remove_action( 'admin_footer', 'wpbooklist_create_csv_action_javascript' );
431
+			remove_action( 'admin_footer', 'wpbooklist_amazon_localization_action_javascript' );
432
+			remove_action( 'admin_footer', 'wpbooklist_delete_book_bulk_action_javascript' );
433
+			remove_action( 'admin_footer', 'wpbooklist_reorder_action_javascript' );
434
+			remove_action( 'admin_footer', 'wpbooklist_exit_results_action_javascript' );
435
+			remove_action( 'admin_footer', 'wpbooklist_storytime_select_category_action_javascript' );
436
+			remove_action( 'admin_footer', 'wpbooklist_storytime_get_story_action_javascript' );
437
+			remove_action( 'admin_footer', 'wpbooklist_storytime_expand_browse_action_javascript' );
438
+			remove_action( 'admin_footer', 'wpbooklist_storytime_save_settings_action_javascript' );
439
+			remove_action( 'admin_footer', 'wpbooklist_delete_story_action_javascript' );
440 440
 }
441 441
 add_action( 'admin_enqueue_scripts', 'monsterinsights_remove_conflicting_asset_files', 9999 );
442 442
 
@@ -448,66 +448,66 @@  discard block
 block discarded – undo
448 448
  *
449 449
  * @return null Return early if not on the proper screen.
450 450
  */
451
-function hide_non_monsterinsights_warnings () {
451
+function hide_non_monsterinsights_warnings() {
452 452
 	// Bail if we're not on a MonsterInsights screen.
453 453
 	if ( empty( $_REQUEST['page'] ) || strpos( $_REQUEST['page'], 'monsterinsights' ) === false ) {
454 454
 		return;
455 455
 	}
456 456
 
457 457
 	global $wp_filter;
458
-	if ( !empty( $wp_filter['user_admin_notices']->callbacks ) && is_array( $wp_filter['user_admin_notices']->callbacks ) ) {
459
-		foreach( $wp_filter['user_admin_notices']->callbacks as $priority => $hooks ) {
458
+	if ( ! empty( $wp_filter['user_admin_notices']->callbacks ) && is_array( $wp_filter['user_admin_notices']->callbacks ) ) {
459
+		foreach ( $wp_filter['user_admin_notices']->callbacks as $priority => $hooks ) {
460 460
 			foreach ( $hooks as $name => $arr ) {
461 461
 				if ( is_object( $arr['function'] ) && $arr['function'] instanceof Closure ) {
462
-					unset( $wp_filter['user_admin_notices']->callbacks[ $priority ][ $name ] );
462
+					unset( $wp_filter['user_admin_notices']->callbacks[$priority][$name] );
463 463
 					continue;
464 464
 				}
465 465
 				if ( ! empty( $arr['function'][0] ) && is_object( $arr['function'][0] ) && strpos( strtolower( get_class( $arr['function'][0] ) ), 'monsterinsights' ) !== false ) {
466 466
 					continue;
467 467
 				}
468
-				if ( !empty( $name ) && strpos( $name, 'monsterinsights' ) === false ) {
468
+				if ( ! empty( $name ) && strpos( $name, 'monsterinsights' ) === false ) {
469 469
 					unset( $wp_filter['user_admin_notices']->callbacks[$priority][$name] );
470 470
 				}
471 471
 			}
472 472
 		}
473 473
 	}
474 474
 
475
-	if ( !empty( $wp_filter['admin_notices']->callbacks ) && is_array( $wp_filter['admin_notices']->callbacks ) ) {
476
-		foreach( $wp_filter['admin_notices']->callbacks as $priority => $hooks ) {
475
+	if ( ! empty( $wp_filter['admin_notices']->callbacks ) && is_array( $wp_filter['admin_notices']->callbacks ) ) {
476
+		foreach ( $wp_filter['admin_notices']->callbacks as $priority => $hooks ) {
477 477
 			foreach ( $hooks as $name => $arr ) {
478 478
 				if ( is_object( $arr['function'] ) && $arr['function'] instanceof Closure ) {
479
-					unset( $wp_filter['admin_notices']->callbacks[ $priority ][ $name ] );
479
+					unset( $wp_filter['admin_notices']->callbacks[$priority][$name] );
480 480
 					continue;
481 481
 				}
482 482
 				if ( ! empty( $arr['function'][0] ) && is_object( $arr['function'][0] ) && strpos( strtolower( get_class( $arr['function'][0] ) ), 'monsterinsights' ) !== false ) {
483 483
 					continue;
484 484
 				}
485
-				if ( !empty( $name ) && strpos( $name, 'monsterinsights' ) === false ) {
485
+				if ( ! empty( $name ) && strpos( $name, 'monsterinsights' ) === false ) {
486 486
 					unset( $wp_filter['admin_notices']->callbacks[$priority][$name] );
487 487
 				}
488 488
 			}
489 489
 		}
490 490
 	}
491 491
 
492
-	if ( !empty( $wp_filter['all_admin_notices']->callbacks ) && is_array( $wp_filter['all_admin_notices']->callbacks ) ) {
493
-		foreach( $wp_filter['all_admin_notices']->callbacks as $priority => $hooks ) {
492
+	if ( ! empty( $wp_filter['all_admin_notices']->callbacks ) && is_array( $wp_filter['all_admin_notices']->callbacks ) ) {
493
+		foreach ( $wp_filter['all_admin_notices']->callbacks as $priority => $hooks ) {
494 494
 			foreach ( $hooks as $name => $arr ) {
495 495
 				if ( is_object( $arr['function'] ) && $arr['function'] instanceof Closure ) {
496
-					unset( $wp_filter['all_admin_notices']->callbacks[ $priority ][ $name ] );
496
+					unset( $wp_filter['all_admin_notices']->callbacks[$priority][$name] );
497 497
 					continue;
498 498
 				}
499 499
 				if ( ! empty( $arr['function'][0] ) && is_object( $arr['function'][0] ) && strpos( strtolower( get_class( $arr['function'][0] ) ), 'monsterinsights' ) !== false ) {
500 500
 					continue;
501 501
 				}
502
-				if ( !empty( $name ) && strpos( $name, 'monsterinsights' ) === false ) {
502
+				if ( ! empty( $name ) && strpos( $name, 'monsterinsights' ) === false ) {
503 503
 					unset( $wp_filter['all_admin_notices']->callbacks[$priority][$name] );
504 504
 				}
505 505
 			}
506 506
 		}
507 507
 	}
508 508
 }
509
-add_action('admin_print_scripts', 'hide_non_monsterinsights_warnings');  
510
-add_action('admin_head', 'hide_non_monsterinsights_warnings', PHP_INT_MAX  );  
509
+add_action( 'admin_print_scripts', 'hide_non_monsterinsights_warnings' );  
510
+add_action( 'admin_head', 'hide_non_monsterinsights_warnings', PHP_INT_MAX );  
511 511
 
512 512
 /**
513 513
  * Called whenever an upgrade button / link is displayed in Lite, this function will
@@ -536,33 +536,33 @@  discard block
 block discarded – undo
536 536
 	}
537 537
 
538 538
 	// Get the ShareASale ID
539
-	$shareasale_id   = monsterinsights_get_shareasale_id();
539
+	$shareasale_id = monsterinsights_get_shareasale_id();
540 540
 
541 541
 	// If we have a shareasale ID return the shareasale url
542 542
 	if ( ! empty( $shareasale_id ) ) {
543
-		$shareasale_id  = absint( $shareasale_id );
543
+		$shareasale_id = absint( $shareasale_id );
544 544
 		return esc_url( monsterinsights_get_shareasale_url( $shareasale_id, $url ) );
545 545
 	} else {
546 546
 		return esc_url( $url );
547 547
 	}
548 548
 }
549 549
 
550
-function monsterinsights_get_url( $medium = '', $campaign = '', $url = '', $escape = true  ) {
550
+function monsterinsights_get_url( $medium = '', $campaign = '', $url = '', $escape = true ) {
551 551
 	// Setup Campaign variables
552
-	$source          = monsterinsights_is_pro_version()   ? 'proplugin' : 'liteplugin';
553
-	$medium          = ! empty( $medium )   ? $medium     : 'defaultmedium';
554
-	$campaign        = ! empty( $campaign ) ? $campaign   : 'defaultcampaign';
555
-	$content 		 = MONSTERINSIGHTS_VERSION;
556
-	$default_url     = monsterinsights_is_pro_version()   ? '' : 'lite/';
552
+	$source          = monsterinsights_is_pro_version() ? 'proplugin' : 'liteplugin';
553
+	$medium          = ! empty( $medium ) ? $medium : 'defaultmedium';
554
+	$campaign        = ! empty( $campaign ) ? $campaign : 'defaultcampaign';
555
+	$content = MONSTERINSIGHTS_VERSION;
556
+	$default_url     = monsterinsights_is_pro_version() ? '' : 'lite/';
557 557
 	$url             = ! empty( $url ) ? $url : 'https://www.monsterinsights.com/' . $default_url;
558 558
 
559 559
 	// Put together redirect URL
560 560
 	$url = add_query_arg(
561 561
 		array(
562
-		    'utm_source'   => $source,   // Pro/Lite Plugin
563
-		    'utm_medium'   => sanitize_key( $medium ),   // Area of MonsterInsights (example Reports)
562
+		    'utm_source'   => $source, // Pro/Lite Plugin
563
+		    'utm_medium'   => sanitize_key( $medium ), // Area of MonsterInsights (example Reports)
564 564
 		    'utm_campaign' => sanitize_key( $campaign ), // Which link (example eCommerce Report)
565
-		    'utm_content'  => $content,  // Version number of MI
565
+		    'utm_content'  => $content, // Version number of MI
566 566
 		),
567 567
 		trailingslashit( $url )
568 568
 	);
@@ -600,13 +600,13 @@  discard block
 block discarded – undo
600 600
 	$custom = false;
601 601
 	if ( defined( 'MONSTERINSIGHTS_SHAREASALE_REDIRECT_URL' ) ) {
602 602
 		$shareasale_redirect = MONSTERINSIGHTS_SHAREASALE_REDIRECT_URL;
603
-		$custom 			 = true;
603
+		$custom = true;
604 604
 	}
605 605
 
606 606
 	// If there's no constant, check if there's an option.
607 607
 	if ( empty( $custom ) ) {
608 608
 		$shareasale_redirect = get_option( 'monsterinsights_shareasale_redirect_url', '' );
609
-		$custom 			 = true;
609
+		$custom = true;
610 610
 	}
611 611
 
612 612
 	// Whether we have an ID or not, filter the ID.
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
 	return $shareasale_url;
616 616
 }
617 617
 
618
-function monsterinsights_settings_ublock_error_js(){
618
+function monsterinsights_settings_ublock_error_js() {
619 619
 	echo "<script type='text/javascript'>\n";
620 620
 	echo "jQuery( document ).ready( function( $ ) {
621 621
 			if ( window.uorigindetected == null){
@@ -631,9 +631,9 @@  discard block
 block discarded – undo
631 631
 }
632 632
 
633 633
 function monsterinsights_ublock_notice() {
634
-	ob_start();?>
634
+	ob_start(); ?>
635 635
 	<div id="monsterinsights-ublock-origin-error" class="error inline" style="display:none;">
636
-		<?php echo sprintf( esc_html__( 'MonsterInsights has detected that it\'s files are being blocked. This is usually caused by a adblock browser plugin (particularly uBlock Origin), or a conflicting WordPress theme or plugin. This issue only affects the admin side of MonsterInsights. To solve this, ensure MonsterInsights is whitelisted for your website URL in any adblock browser plugin you use. For step by step directions on how to do this, %1$sclick here%2$s. If this doesn\'t solve the issue (rare), send us a ticket %3$shere%2$s and we\'ll be happy to help diagnose the issue.', 'google-analytics-for-wordpress'), '<a href="https://monsterinsights.com/docs/monsterinsights-asset-files-blocked/" target="_blank" rel="noopener noreferrer" referrer="no-referrer">', '</a>', '<a href="https://monsterinsights.com/contact/" target="_blank" rel="noopener noreferrer" referrer="no-referrer">');
636
+		<?php echo sprintf( esc_html__( 'MonsterInsights has detected that it\'s files are being blocked. This is usually caused by a adblock browser plugin (particularly uBlock Origin), or a conflicting WordPress theme or plugin. This issue only affects the admin side of MonsterInsights. To solve this, ensure MonsterInsights is whitelisted for your website URL in any adblock browser plugin you use. For step by step directions on how to do this, %1$sclick here%2$s. If this doesn\'t solve the issue (rare), send us a ticket %3$shere%2$s and we\'ll be happy to help diagnose the issue.', 'google-analytics-for-wordpress' ), '<a href="https://monsterinsights.com/docs/monsterinsights-asset-files-blocked/" target="_blank" rel="noopener noreferrer" referrer="no-referrer">', '</a>', '<a href="https://monsterinsights.com/contact/" target="_blank" rel="noopener noreferrer" referrer="no-referrer">' );
637 637
 		?>
638 638
 	</div>
639 639
 	<?php
Please login to merge, or discard this patch.
includes/api-request.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -146,20 +146,20 @@  discard block
 block discarded – undo
146 146
 		$this->network   = is_network_admin() || ! empty( $args['network'] );
147 147
 
148 148
 		$default_token   = $this->network ? MonsterInsights()->auth->get_network_token() : MonsterInsights()->auth->get_token();
149
-		$default_key     = $this->network ? MonsterInsights()->auth->get_network_key()   : MonsterInsights()->auth->get_key();
149
+		$default_key     = $this->network ? MonsterInsights()->auth->get_network_key() : MonsterInsights()->auth->get_key();
150 150
 
151
-		$this->token     = ! empty( $args['token'] )     ? $args['token']  : $default_token;
152
-		$this->key       = ! empty( $args['key'] ) 	     ? $args['key']    : $default_key;
153
-		$this->tt        = ! empty( $args['tt'] ) 		 ? $args['tt']     : '';
154
-		$this->return    = ! empty( $args['return'] )    ? $args['return'] : '';
155
-		$this->start     = ! empty( $args['start'] )	 ? $args['start']  : '';
156
-		$this->end       = ! empty( $args['end'] )  	 ? $args['end']    : '';
151
+		$this->token     = ! empty( $args['token'] ) ? $args['token'] : $default_token;
152
+		$this->key       = ! empty( $args['key'] ) ? $args['key'] : $default_key;
153
+		$this->tt        = ! empty( $args['tt'] ) ? $args['tt'] : '';
154
+		$this->return    = ! empty( $args['return'] ) ? $args['return'] : '';
155
+		$this->start     = ! empty( $args['start'] ) ? $args['start'] : '';
156
+		$this->end       = ! empty( $args['end'] ) ? $args['end'] : '';
157 157
 
158 158
 		// We need to do this hack so that the network panel + the site_url of the main site are distinct
159 159
 		$this->site_url  = is_network_admin() ? network_admin_url() : site_url();
160 160
 
161 161
 		if ( monsterinsights_is_pro_version() ) {
162
-			$this->license   = $this->network ? MonsterInsights()->license->get_network_license_key() : MonsterInsights()->license->get_site_license_key();
162
+			$this->license = $this->network ? MonsterInsights()->license->get_network_license_key() : MonsterInsights()->license->get_site_license_key();
163 163
 		}
164 164
 		$this->plugin    = MonsterInsights()->plugin_slug;
165 165
 		$this->miversion = MONSTERINSIGHTS_VERSION;
@@ -228,14 +228,14 @@  discard block
 block discarded – undo
228 228
 		}
229 229
 
230 230
 		if ( 'GET' == $this->method ) {
231
-			$body['time']   = time(); // just to avoid caching
231
+			$body['time'] = time(); // just to avoid caching
232 232
 		}
233 233
 
234
-		$body['timezone'] = date('e');
234
+		$body['timezone'] = date( 'e' );
235 235
 
236 236
 		$body['network']  = $this->network ? 'network' : 'site';
237 237
 
238
-		$body['ip']   = ! empty( $_SERVER['SERVER_ADDR'] ) ? $_SERVER['SERVER_ADDR'] : '';
238
+		$body['ip'] = ! empty( $_SERVER['SERVER_ADDR'] ) ? $_SERVER['SERVER_ADDR'] : '';
239 239
 
240 240
 		// This filter will be removed in the future.
241 241
 		$body   = apply_filters( 'monsterinsights_api_request_body', $body );
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 
280 280
 		// If not a 200 status header, send back error.
281 281
 		if ( 200 != $response_code ) {
282
-			$type  = ! empty( $response_body['type'] ) ? $response_body['type'] : 'api-error';
282
+			$type = ! empty( $response_body['type'] ) ? $response_body['type'] : 'api-error';
283 283
 			
284 284
 			if ( empty( $response_code ) ) {
285 285
 				return new WP_Error( $type, __( 'The API was unreachable.', 'google-analytics-for-wordpress' ) );
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 						'body'          => ''
385 385
 					);
386 386
 					$response = wp_remote_get( $testurl, $params );
387
-					if( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
387
+					if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
388 388
 						return false;
389 389
 					} else {
390 390
 						return true;
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
 			);
403 403
 			$response = wp_remote_get( $testurl, $params );
404 404
 			
405
-			if( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
405
+			if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
406 406
 				return false;
407 407
 			} else {
408 408
 				return true;
Please login to merge, or discard this patch.