Passed
Push — master ( e0709e...805894 )
by Chris
06:51
created
includes/admin/routes.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 			return;
43 43
 		}
44 44
 
45
-		$site_license    = array(
45
+		$site_license = array(
46 46
 			'key'         => MonsterInsights()->license->get_site_license_key(),
47 47
 			'type'        => MonsterInsights()->license->get_site_license_type(),
48 48
 			'is_disabled' => MonsterInsights()->license->site_license_disabled(),
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
 		// Array fields are needed even if empty.
103 103
 		$array_fields = array( 'view_reports', 'save_settings', 'ignore_users' );
104 104
 		foreach ( $array_fields as $array_field ) {
105
-			if ( ! isset( $options[ $array_field ] ) ) {
106
-				$options[ $array_field ] = array();
105
+			if ( ! isset( $options[$array_field] ) ) {
106
+				$options[$array_field] = array();
107 107
 			}
108 108
 		}
109 109
 		if ( isset( $options['custom_code'] ) ) {
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 						}
178 178
 					}
179 179
 					if ( $empty ) {
180
-						unset( $value[ $key ] );
180
+						unset( $value[$key] );
181 181
 					}
182 182
 				}
183 183
 			}
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 				} else {
228 228
 					$addon = $this->get_addon( $installed_plugins, $addons_type, $addon, $slug );
229 229
 				}
230
-				$parsed_addons[ $addon->slug ] = $addon;
230
+				$parsed_addons[$addon->slug] = $addon;
231 231
 			}
232 232
 		}
233 233
 
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 		$installed       = false;
317 317
 		$plugin_basename = monsterinsights_get_plugin_basename_from_slug( $slug );
318 318
 
319
-		if ( isset( $installed_plugins[ $plugin_basename ] ) ) {
319
+		if ( isset( $installed_plugins[$plugin_basename] ) ) {
320 320
 			$installed = true;
321 321
 
322 322
 			if ( is_multisite() && is_network_admin() ) {
@@ -459,8 +459,8 @@  discard block
 block discarded – undo
459 459
 		);
460 460
 
461 461
 		foreach ( $exclude as $e ) {
462
-			if ( ! empty( $new_settings[ $e ] ) ) {
463
-				unset( $new_settings[ $e ] );
462
+			if ( ! empty( $new_settings[$e] ) ) {
463
+				unset( $new_settings[$e] );
464 464
 			}
465 465
 		}
466 466
 
@@ -471,8 +471,8 @@  discard block
 block discarded – undo
471 471
 		}
472 472
 
473 473
 		foreach ( $exclude as $e ) {
474
-			if ( ! empty( $settings[ $e ] ) ) {
475
-				$new_settings = $settings[ $e ];
474
+			if ( ! empty( $settings[$e] ) ) {
475
+				$new_settings = $settings[$e];
476 476
 			}
477 477
 		}
478 478
 
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
 			),
631 631
 			admin_url( 'admin.php' )
632 632
 		);
633
-		$url    = esc_url( $url );
633
+		$url = esc_url( $url );
634 634
 
635 635
 		ob_start();
636 636
 		if ( false === ( $creds = request_filesystem_credentials( $url, $method, false, false, null ) ) ) {
Please login to merge, or discard this patch.
lite/includes/admin/reports/report-year-in-review.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -47,17 +47,17 @@
 block discarded – undo
47 47
 		if ( ! empty( $data['data']['countries'] ) ) {
48 48
 			$country_names = monsterinsights_get_country_list( true );
49 49
 			foreach ( $data['data']['countries'] as $key => $country ) {
50
-				$data['data']['countries'][ $key ]['name'] = isset( $country_names[ $country['iso'] ] ) ? $country_names[ $country['iso'] ] : $country['iso'];
50
+				$data['data']['countries'][$key]['name'] = isset( $country_names[$country['iso']] ) ? $country_names[$country['iso']] : $country['iso'];
51 51
 			}
52 52
 		}
53 53
 
54 54
 		// Escape urls for the top pages report.
55 55
 		if ( ! empty( $data['data']['toppages'] ) ) {
56 56
 			foreach ( $data['data']['toppages'] as $key => $page ) {
57
-				$title = $data['data']['toppages'][ $key ]['title'];
58
-				$url   = '(not set)' === $title ? '' : esc_url( $data['data']['toppages'][ $key ]['hostname'] );
57
+				$title = $data['data']['toppages'][$key]['title'];
58
+				$url   = '(not set)' === $title ? '' : esc_url( $data['data']['toppages'][$key]['hostname'] );
59 59
 
60
-				$data['data']['toppages'][ $key ]['hostname'] = $url;
60
+				$data['data']['toppages'][$key]['hostname'] = $url;
61 61
 			}
62 62
 		}
63 63
 
Please login to merge, or discard this patch.
includes/api-request.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -155,25 +155,25 @@  discard block
 block discarded – undo
155 155
 		$this->network   = is_network_admin() || ! empty( $args['network'] );
156 156
 
157 157
 		$default_token   = $this->network ? MonsterInsights()->auth->get_network_token() : MonsterInsights()->auth->get_token();
158
-		$default_key     = $this->network ? MonsterInsights()->auth->get_network_key()   : MonsterInsights()->auth->get_key();
158
+		$default_key     = $this->network ? MonsterInsights()->auth->get_network_key() : MonsterInsights()->auth->get_key();
159 159
 
160
-		$this->token     = ! empty( $args['token'] )     ? $args['token']  : $default_token;
161
-		$this->key       = ! empty( $args['key'] ) 	     ? $args['key']    : $default_key;
162
-		$this->tt        = ! empty( $args['tt'] ) 		 ? $args['tt']     : '';
163
-		$this->return    = ! empty( $args['return'] )    ? $args['return'] : '';
164
-		$this->start     = ! empty( $args['start'] )	 ? $args['start']  : '';
165
-		$this->end       = ! empty( $args['end'] )  	 ? $args['end']    : '';
160
+		$this->token     = ! empty( $args['token'] ) ? $args['token'] : $default_token;
161
+		$this->key       = ! empty( $args['key'] ) ? $args['key'] : $default_key;
162
+		$this->tt        = ! empty( $args['tt'] ) ? $args['tt'] : '';
163
+		$this->return    = ! empty( $args['return'] ) ? $args['return'] : '';
164
+		$this->start     = ! empty( $args['start'] ) ? $args['start'] : '';
165
+		$this->end       = ! empty( $args['end'] ) ? $args['end'] : '';
166 166
 
167 167
 		// We need to do this hack so that the network panel + the site_url of the main site are distinct
168 168
 		$this->site_url  = is_network_admin() ? network_admin_url() : site_url();
169 169
 
170 170
 		if ( monsterinsights_is_pro_version() ) {
171
-			$this->license   = $this->network ? MonsterInsights()->license->get_network_license_key() : MonsterInsights()->license->get_site_license_key();
171
+			$this->license = $this->network ? MonsterInsights()->license->get_network_license_key() : MonsterInsights()->license->get_site_license_key();
172 172
 		}
173 173
 		$this->plugin    = MonsterInsights()->plugin_slug;
174 174
 		$this->miversion = MONSTERINSIGHTS_VERSION;
175
-		$this->sitei     = ! empty( $args['sitei'] )   ? $args['sitei'] : '';
176
-		$this->testurl   = ! empty( $args['testurl'] ) ? $args['testurl']    : '';
175
+		$this->sitei     = ! empty( $args['sitei'] ) ? $args['sitei'] : '';
176
+		$this->testurl   = ! empty( $args['testurl'] ) ? $args['testurl'] : '';
177 177
 	}
178 178
 
179 179
 	/**
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 	public function request() {
187 187
 		// Make sure we're not blocked
188 188
 		$blocked = $this->is_blocked( $this->url );
189
-		if ( $blocked || is_wp_error( $blocked )  ) {
189
+		if ( $blocked || is_wp_error( $blocked ) ) {
190 190
 			if ( is_wp_error( $blocked ) ) {
191 191
 				return new WP_Error( 'api-error', sprintf( __( 'The firewall of your server is blocking outbound calls. Please contact your hosting provider to fix this issue. %s', 'google-analytics-for-wordpress' ), $blocked->get_error_message() ) );
192 192
 			} else {
@@ -243,14 +243,14 @@  discard block
 block discarded – undo
243 243
 		}
244 244
 
245 245
 		if ( 'GET' == $this->method ) {
246
-			$body['time']   = time(); // just to avoid caching
246
+			$body['time'] = time(); // just to avoid caching
247 247
 		}
248 248
 
249
-		$body['timezone'] = date('e');
249
+		$body['timezone'] = date( 'e' );
250 250
 
251 251
 		$body['network']  = $this->network ? 'network' : 'site';
252 252
 
253
-		$body['ip']   = ! empty( $_SERVER['SERVER_ADDR'] ) ? $_SERVER['SERVER_ADDR'] : '';
253
+		$body['ip'] = ! empty( $_SERVER['SERVER_ADDR'] ) ? $_SERVER['SERVER_ADDR'] : '';
254 254
 
255 255
 		// This filter will be removed in the future.
256 256
 		$body   = apply_filters( 'monsterinsights_api_request_body', $body );
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 		);
282 282
 
283 283
 		// Perform the query and retrieve the response.
284
-		$response      = 'GET' == $this->method ? wp_remote_get( esc_url_raw( $this->url ) . '?' . $string, $data ) : wp_remote_post( esc_url_raw( $this->url ), $data );
284
+		$response = 'GET' == $this->method ? wp_remote_get( esc_url_raw( $this->url ) . '?' . $string, $data ) : wp_remote_post( esc_url_raw( $this->url ), $data );
285 285
 
286 286
 		//return new WP_Error( 'debug', '<pre>' . var_export( $response, true ) . '</pre>' );
287 287
 
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 
301 301
 		// If not a 200 status header, send back error.
302 302
 		if ( 200 != $response_code ) {
303
-			$type  = ! empty( $response_body['type'] ) ? $response_body['type'] : 'api-error';
303
+			$type = ! empty( $response_body['type'] ) ? $response_body['type'] : 'api-error';
304 304
 
305 305
 			if ( empty( $response_code ) ) {
306 306
 				return new WP_Error( $type, __( 'The API was unreachable.', 'google-analytics-for-wordpress' ) );
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 		// and for image linking purposes in Google Images. We use it to test outbound connections since it is run on google.com
389 389
 		// and is only a few bytes large. Plus on Google's main CDN so it loads in most places in 0.07 seconds or less. Perfect for our
390 390
 		// use case of quickly testing outbound connections.
391
-		$testurl = ! empty( $this->testurl ) ? $this->testurl :'http://www.google.com/blank.html';
391
+		$testurl = ! empty( $this->testurl ) ? $this->testurl : 'http://www.google.com/blank.html';
392 392
 		if ( defined( 'WP_HTTP_BLOCK_EXTERNAL' ) && WP_HTTP_BLOCK_EXTERNAL ) {
393 393
 			if ( defined( 'WP_ACCESSIBLE_HOSTS' ) ) {
394 394
 				$wp_http      = new WP_Http();
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 						'body'          => ''
404 404
 					);
405 405
 					$response = wp_remote_get( $testurl, $params );
406
-					if( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
406
+					if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
407 407
 						return false;
408 408
 					} else {
409 409
 						if ( is_wp_error( $response ) ) {
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 			);
426 426
 			$response = wp_remote_get( $testurl, $params );
427 427
 
428
-			if( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
428
+			if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
429 429
 				return false;
430 430
 			} else {
431 431
 				if ( is_wp_error( $response ) ) {
Please login to merge, or discard this patch.
includes/admin/common.php 2 patches
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 		'kad_admin_js', // Pinnacle theme
379 379
 		'dt-chart', // DesignThemes core features plugin
380 380
 		'tweeetshare_font_script', // TweetShare - Click To Tweet
381
-		'tweeetshare_jquery_script',  // TweetShare - Click To Tweet
381
+		'tweeetshare_jquery_script', // TweetShare - Click To Tweet
382 382
 		'tweeetshare_jqueryui_script', // TweetShare - Click To Tweet
383 383
 		'tweeetshare_custom_script', // TweetShare - Click To Tweet
384 384
 		'imagify-promise-polyfill', // Imagify
@@ -397,16 +397,16 @@  discard block
 block discarded – undo
397 397
 		'rml-modal', // WP Real Media Library
398 398
 		'rml-order', // WP Real Media Library
399 399
 		'rml-meta', // WP Real Media Library
400
-		'rml-uploader',  // WP Real Media Library
401
-		'rml-options',  // WP Real Media Library
402
-		'rml-usersettings',  // WP Real Media Library
400
+		'rml-uploader', // WP Real Media Library
401
+		'rml-options', // WP Real Media Library
402
+		'rml-usersettings', // WP Real Media Library
403 403
 		'rml-main', // WP Real Media Library
404 404
 		'control-panel-sweet-alert', // Ken Theme
405 405
 		'sweet-alert-js', // Vitrine Theme
406 406
 		'theme-admin-script', // Vitrine Theme
407 407
 		'sweetalert', //  Church Suite Theme by Webnus
408 408
 		'be_alerts_charts', //  WooCommerce bolder product alerts
409
-		'magayo-lottery-results',  //  Magayo Lottery Results
409
+		'magayo-lottery-results', //  Magayo Lottery Results
410 410
 		'control-panel-sweet-alert', // Ken Theme
411 411
 		'cpm_chart', // WP Project Manager
412 412
 		'adminscripts', //  Artisan Nayma Theme
@@ -501,20 +501,20 @@  discard block
 block discarded – undo
501 501
 
502 502
 	global $wp_styles;
503 503
 	foreach ( $wp_styles->queue as $handle ) {
504
-		if ( strpos( $wp_styles->registered[ $handle ]->src, 'wp-content' ) === false ) {
504
+		if ( strpos( $wp_styles->registered[$handle]->src, 'wp-content' ) === false ) {
505 505
 			return;
506 506
 		}
507 507
 
508
-		if ( strpos( $wp_styles->registered[ $handle ]->handle, 'monsterinsights' ) !== false ) {
508
+		if ( strpos( $wp_styles->registered[$handle]->handle, 'monsterinsights' ) !== false ) {
509 509
 			return;
510 510
 		}
511 511
 
512 512
 		foreach ( $third_party as $partial ) {
513
-			if ( strpos( $wp_styles->registered[ $handle ]->handle, $partial ) !== false ) {
513
+			if ( strpos( $wp_styles->registered[$handle]->handle, $partial ) !== false ) {
514 514
 				wp_dequeue_style( $handle ); // Remove css file from MI screen
515 515
 				wp_deregister_style( $handle );
516 516
 				break;
517
-			} else if ( strpos( $wp_styles->registered[ $handle ]->src, $partial ) !== false ) {
517
+			} else if ( strpos( $wp_styles->registered[$handle]->src, $partial ) !== false ) {
518 518
 				wp_dequeue_style( $handle ); // Remove css file from MI screen
519 519
 				wp_deregister_style( $handle );
520 520
 				break;
@@ -524,20 +524,20 @@  discard block
 block discarded – undo
524 524
 
525 525
 	global $wp_scripts;
526 526
 	foreach ( $wp_scripts->queue as $handle ) {
527
-		if ( strpos( $wp_scripts->registered[ $handle ]->src, 'wp-content' ) === false ) {
527
+		if ( strpos( $wp_scripts->registered[$handle]->src, 'wp-content' ) === false ) {
528 528
 			return;
529 529
 		}
530 530
 
531
-		if ( strpos( $wp_scripts->registered[ $handle ]->handle, 'monsterinsights' ) !== false ) {
531
+		if ( strpos( $wp_scripts->registered[$handle]->handle, 'monsterinsights' ) !== false ) {
532 532
 			return;
533 533
 		}
534 534
 
535 535
 		foreach ( $third_party as $partial ) {
536
-			if ( strpos( $wp_scripts->registered[ $handle ]->handle, $partial ) !== false ) {
536
+			if ( strpos( $wp_scripts->registered[$handle]->handle, $partial ) !== false ) {
537 537
 				wp_dequeue_script( $handle ); // Remove JS file from MI screen
538 538
 				wp_deregister_script( $handle );
539 539
 				break;
540
-			} else if ( strpos( $wp_scripts->registered[ $handle ]->src, $partial ) !== false ) {
540
+			} else if ( strpos( $wp_scripts->registered[$handle]->src, $partial ) !== false ) {
541 541
 				wp_dequeue_script( $handle ); // Remove JS file from MI screen
542 542
 				wp_deregister_script( $handle );
543 543
 				break;
@@ -611,14 +611,14 @@  discard block
 block discarded – undo
611 611
 		foreach ( $wp_filter['user_admin_notices']->callbacks as $priority => $hooks ) {
612 612
 			foreach ( $hooks as $name => $arr ) {
613 613
 				if ( is_object( $arr['function'] ) && $arr['function'] instanceof Closure ) {
614
-					unset( $wp_filter['user_admin_notices']->callbacks[ $priority ][ $name ] );
614
+					unset( $wp_filter['user_admin_notices']->callbacks[$priority][$name] );
615 615
 					continue;
616 616
 				}
617 617
 				if ( ! empty( $arr['function'][0] ) && is_object( $arr['function'][0] ) && strpos( strtolower( get_class( $arr['function'][0] ) ), 'monsterinsights' ) !== false ) {
618 618
 					continue;
619 619
 				}
620 620
 				if ( ! empty( $name ) && strpos( $name, 'monsterinsights' ) === false ) {
621
-					unset( $wp_filter['user_admin_notices']->callbacks[ $priority ][ $name ] );
621
+					unset( $wp_filter['user_admin_notices']->callbacks[$priority][$name] );
622 622
 				}
623 623
 			}
624 624
 		}
@@ -628,14 +628,14 @@  discard block
 block discarded – undo
628 628
 		foreach ( $wp_filter['admin_notices']->callbacks as $priority => $hooks ) {
629 629
 			foreach ( $hooks as $name => $arr ) {
630 630
 				if ( is_object( $arr['function'] ) && $arr['function'] instanceof Closure ) {
631
-					unset( $wp_filter['admin_notices']->callbacks[ $priority ][ $name ] );
631
+					unset( $wp_filter['admin_notices']->callbacks[$priority][$name] );
632 632
 					continue;
633 633
 				}
634 634
 				if ( ! empty( $arr['function'][0] ) && is_object( $arr['function'][0] ) && strpos( strtolower( get_class( $arr['function'][0] ) ), 'monsterinsights' ) !== false ) {
635 635
 					continue;
636 636
 				}
637 637
 				if ( ! empty( $name ) && strpos( $name, 'monsterinsights' ) === false ) {
638
-					unset( $wp_filter['admin_notices']->callbacks[ $priority ][ $name ] );
638
+					unset( $wp_filter['admin_notices']->callbacks[$priority][$name] );
639 639
 				}
640 640
 			}
641 641
 		}
@@ -645,14 +645,14 @@  discard block
 block discarded – undo
645 645
 		foreach ( $wp_filter['all_admin_notices']->callbacks as $priority => $hooks ) {
646 646
 			foreach ( $hooks as $name => $arr ) {
647 647
 				if ( is_object( $arr['function'] ) && $arr['function'] instanceof Closure ) {
648
-					unset( $wp_filter['all_admin_notices']->callbacks[ $priority ][ $name ] );
648
+					unset( $wp_filter['all_admin_notices']->callbacks[$priority][$name] );
649 649
 					continue;
650 650
 				}
651 651
 				if ( ! empty( $arr['function'][0] ) && is_object( $arr['function'][0] ) && strpos( strtolower( get_class( $arr['function'][0] ) ), 'monsterinsights' ) !== false ) {
652 652
 					continue;
653 653
 				}
654 654
 				if ( ! empty( $name ) && strpos( $name, 'monsterinsights' ) === false ) {
655
-					unset( $wp_filter['all_admin_notices']->callbacks[ $priority ][ $name ] );
655
+					unset( $wp_filter['all_admin_notices']->callbacks[$priority][$name] );
656 656
 				}
657 657
 			}
658 658
 		}
@@ -713,10 +713,10 @@  discard block
 block discarded – undo
713 713
 	// Put together redirect URL
714 714
 	$url = add_query_arg(
715 715
 		array(
716
-			'utm_source'   => $source,   // Pro/Lite Plugin
717
-			'utm_medium'   => sanitize_key( $medium ),   // Area of MonsterInsights (example Reports)
716
+			'utm_source'   => $source, // Pro/Lite Plugin
717
+			'utm_medium'   => sanitize_key( $medium ), // Area of MonsterInsights (example Reports)
718 718
 			'utm_campaign' => sanitize_key( $campaign ), // Which link (example eCommerce Report)
719
-			'utm_content'  => $content,  // Version number of MI
719
+			'utm_content'  => $content, // Version number of MI
720 720
 		),
721 721
 		trailingslashit( $url )
722 722
 	);
@@ -811,10 +811,10 @@  discard block
 block discarded – undo
811 811
  */
812 812
 function monsterinsights_yearinreview_admin_menu_tooltip() {
813 813
 
814
-	$dismiss_tooltip 		= get_option( 'monsterinsights_yearinreview_dismiss_admin_tooltip', false );
815
-	$activated				= get_option( 'monsterinsights_over_time', array() );
816
-	$ua_code 				= monsterinsights_get_ua();
817
-	$dashboards_disabled 	= monsterinsights_get_option( 'dashboards_disabled', false );
814
+	$dismiss_tooltip = get_option( 'monsterinsights_yearinreview_dismiss_admin_tooltip', false );
815
+	$activated = get_option( 'monsterinsights_over_time', array() );
816
+	$ua_code = monsterinsights_get_ua();
817
+	$dashboards_disabled = monsterinsights_get_option( 'dashboards_disabled', false );
818 818
 	
819 819
 	if ( $dashboards_disabled ) {
820 820
 		return;
@@ -830,7 +830,7 @@  discard block
 block discarded – undo
830 830
 	}
831 831
 
832 832
 	// equivalent to: 01/01/2020 @ 12:00am (UTC)
833
-	$new_year  = '1577836800';
833
+	$new_year = '1577836800';
834 834
 
835 835
 	// equivalent to: 01/02/2020 @ 12:00am (UTC)
836 836
 	$start_time = '1577923200';
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
 	// equivalent to: 01/13/2020 @ 12:00am (UTC)
839 839
 	$end_time = '1578873600';
840 840
 
841
-	if ( $dismiss_tooltip )  {
841
+	if ( $dismiss_tooltip ) {
842 842
 		return;
843 843
 	}
844 844
 	
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -838,7 +838,7 @@
 block discarded – undo
838 838
 	// equivalent to: 01/13/2020 @ 12:00am (UTC)
839 839
 	$end_time = '1578873600';
840 840
 
841
-	if ( $dismiss_tooltip )  {
841
+	if ( $dismiss_tooltip ) {
842 842
 		return;
843 843
 	}
844 844
 	
Please login to merge, or discard this patch.
includes/admin/ajax.php 1 patch
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -51,60 +51,60 @@  discard block
 block discarded – undo
51 51
     check_ajax_referer( 'monsterinsights-install', 'nonce' );
52 52
 
53 53
     if ( ! current_user_can( 'install_plugins' ) ) {
54
-        echo json_encode( true );
54
+	echo json_encode( true );
55 55
     }
56 56
 
57 57
     // Install the addon.
58 58
     if ( isset( $_POST['plugin'] ) ) {
59
-        $download_url = $_POST['plugin'];
60
-        global $hook_suffix;
61
-
62
-        // Set the current screen to avoid undefined notices.
63
-        set_current_screen();
64
-
65
-        // Prepare variables.
66
-        $method = '';
67
-        $url    = add_query_arg(
68
-            array(
69
-                'page' => 'monsterinsights-settings'
70
-            ),
71
-            admin_url( 'admin.php' )
72
-        );
73
-        $url = esc_url( $url );
74
-
75
-        // Start output bufferring to catch the filesystem form if credentials are needed.
76
-        ob_start();
77
-        if ( false === ( $creds = request_filesystem_credentials( $url, $method, false, false, null ) ) ) {
78
-            $form = ob_get_clean();
79
-            echo json_encode( array( 'form' => $form ) );
80
-            wp_die();
81
-        }
82
-
83
-        // If we are not authenticated, make it happen now.
84
-        if ( ! WP_Filesystem( $creds ) ) {
85
-            ob_start();
86
-            request_filesystem_credentials( $url, $method, true, false, null );
87
-            $form = ob_get_clean();
88
-            echo json_encode( array( 'form' => $form ) );
89
-            wp_die();
90
-        }
91
-
92
-        // We do not need any extra credentials if we have gotten this far, so let's install the plugin.
93
-        require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
94
-        $base = MonsterInsights();
95
-        require_once plugin_dir_path( $base->file ) . '/includes/admin/licensing/skin.php';
96
-
97
-        // Create the plugin upgrader with our custom skin.
98
-        $installer = new Plugin_Upgrader( $skin = new MonsterInsights_Skin() );
99
-        $installer->install( $download_url );
100
-
101
-        // Flush the cache and return the newly installed plugin basename.
102
-        wp_cache_flush();
103
-        if ( $installer->plugin_info() ) {
104
-            $plugin_basename = $installer->plugin_info();
105
-            echo json_encode( array( 'plugin' => $plugin_basename ) );
106
-            wp_die();
107
-        }
59
+	$download_url = $_POST['plugin'];
60
+	global $hook_suffix;
61
+
62
+	// Set the current screen to avoid undefined notices.
63
+	set_current_screen();
64
+
65
+	// Prepare variables.
66
+	$method = '';
67
+	$url    = add_query_arg(
68
+	    array(
69
+		'page' => 'monsterinsights-settings'
70
+	    ),
71
+	    admin_url( 'admin.php' )
72
+	);
73
+	$url = esc_url( $url );
74
+
75
+	// Start output bufferring to catch the filesystem form if credentials are needed.
76
+	ob_start();
77
+	if ( false === ( $creds = request_filesystem_credentials( $url, $method, false, false, null ) ) ) {
78
+	    $form = ob_get_clean();
79
+	    echo json_encode( array( 'form' => $form ) );
80
+	    wp_die();
81
+	}
82
+
83
+	// If we are not authenticated, make it happen now.
84
+	if ( ! WP_Filesystem( $creds ) ) {
85
+	    ob_start();
86
+	    request_filesystem_credentials( $url, $method, true, false, null );
87
+	    $form = ob_get_clean();
88
+	    echo json_encode( array( 'form' => $form ) );
89
+	    wp_die();
90
+	}
91
+
92
+	// We do not need any extra credentials if we have gotten this far, so let's install the plugin.
93
+	require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
94
+	$base = MonsterInsights();
95
+	require_once plugin_dir_path( $base->file ) . '/includes/admin/licensing/skin.php';
96
+
97
+	// Create the plugin upgrader with our custom skin.
98
+	$installer = new Plugin_Upgrader( $skin = new MonsterInsights_Skin() );
99
+	$installer->install( $download_url );
100
+
101
+	// Flush the cache and return the newly installed plugin basename.
102
+	wp_cache_flush();
103
+	if ( $installer->plugin_info() ) {
104
+	    $plugin_basename = $installer->plugin_info();
105
+	    echo json_encode( array( 'plugin' => $plugin_basename ) );
106
+	    wp_die();
107
+	}
108 108
     }
109 109
 
110 110
     // Send back a response.
@@ -126,21 +126,21 @@  discard block
 block discarded – undo
126 126
     check_ajax_referer( 'monsterinsights-activate', 'nonce' );
127 127
 
128 128
     if ( ! current_user_can( 'activate_plugins' ) ) {
129
-        echo json_encode( true );
129
+	echo json_encode( true );
130 130
     }
131 131
 
132 132
     // Activate the addon.
133 133
     if ( isset( $_POST['plugin'] ) ) {
134
-        if ( isset( $_POST['isnetwork'] ) &&  $_POST['isnetwork'] ) {
135
-            $activate = activate_plugin( $_POST['plugin'], NULL, true );
136
-        } else {
137
-            $activate = activate_plugin( $_POST['plugin'] );
138
-        }
139
-
140
-        if ( is_wp_error( $activate ) ) {
141
-            echo json_encode( array( 'error' => $activate->get_error_message() ) );
142
-            wp_die();
143
-        }
134
+	if ( isset( $_POST['isnetwork'] ) &&  $_POST['isnetwork'] ) {
135
+	    $activate = activate_plugin( $_POST['plugin'], NULL, true );
136
+	} else {
137
+	    $activate = activate_plugin( $_POST['plugin'] );
138
+	}
139
+
140
+	if ( is_wp_error( $activate ) ) {
141
+	    echo json_encode( array( 'error' => $activate->get_error_message() ) );
142
+	    wp_die();
143
+	}
144 144
     }
145 145
 
146 146
     echo json_encode( true );
@@ -161,16 +161,16 @@  discard block
 block discarded – undo
161 161
     check_ajax_referer( 'monsterinsights-deactivate', 'nonce' );
162 162
 
163 163
     if ( ! current_user_can( 'activate_plugins' ) ) {
164
-        echo json_encode( true );
164
+	echo json_encode( true );
165 165
     }
166 166
 
167 167
     // Deactivate the addon.
168 168
     if ( isset( $_POST['plugin'] ) ) {
169
-        if ( isset( $_POST['isnetwork'] ) && $_POST['isnetwork'] ) {
170
-            $deactivate = deactivate_plugins( $_POST['plugin'], false, true );
171
-        } else {
172
-            $deactivate = deactivate_plugins( $_POST['plugin'] );
173
-        }
169
+	if ( isset( $_POST['isnetwork'] ) && $_POST['isnetwork'] ) {
170
+	    $deactivate = deactivate_plugins( $_POST['plugin'], false, true );
171
+	} else {
172
+	    $deactivate = deactivate_plugins( $_POST['plugin'] );
173
+	}
174 174
     }
175 175
 
176 176
     echo json_encode( true );
@@ -193,12 +193,12 @@  discard block
 block discarded – undo
193 193
 
194 194
     // Deactivate the notice
195 195
     if ( isset( $_POST['notice'] ) ) {
196
-        // Init the notice class and mark notice as deactivated
197
-        MonsterInsights()->notices->dismiss( $_POST['notice'] );
196
+	// Init the notice class and mark notice as deactivated
197
+	MonsterInsights()->notices->dismiss( $_POST['notice'] );
198 198
 
199
-        // Return true
200
-        echo json_encode( true );
201
-        wp_die();
199
+	// Return true
200
+	echo json_encode( true );
201
+	wp_die();
202 202
     }
203 203
 
204 204
     // If here, an error occurred
Please login to merge, or discard this patch.