Passed
Push — master ( 6f0a6d...90a9ca )
by
unknown
09:41
created
includes/admin/admin.php 1 patch
Indentation   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -27,22 +27,22 @@  discard block
 block discarded – undo
27 27
     $menu_icon_inline = monsterinsights_get_inline_menu_icon();
28 28
 
29 29
     if ( $hook === 'monsterinsights_settings' ) {
30
-        // If dashboards disabled, first settings page
31
-        add_menu_page( __( 'MonsterInsights', 'google-analytics-for-wordpress' ), __( 'Insights', 'google-analytics-for-wordpress' ) . MonsterInsights()->notifications->get_menu_count(), 'monsterinsights_save_settings', 'monsterinsights_settings', 'monsterinsights_settings_page',  $menu_icon_inline, '100.00013467543' );
32
-        $hook = 'monsterinsights_settings';
30
+	// If dashboards disabled, first settings page
31
+	add_menu_page( __( 'MonsterInsights', 'google-analytics-for-wordpress' ), __( 'Insights', 'google-analytics-for-wordpress' ) . MonsterInsights()->notifications->get_menu_count(), 'monsterinsights_save_settings', 'monsterinsights_settings', 'monsterinsights_settings_page',  $menu_icon_inline, '100.00013467543' );
32
+	$hook = 'monsterinsights_settings';
33 33
 
34
-        add_submenu_page( $hook, __( 'MonsterInsights', 'google-analytics-for-wordpress' ), __( 'Settings', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', 'monsterinsights_settings' );
34
+	add_submenu_page( $hook, __( 'MonsterInsights', 'google-analytics-for-wordpress' ), __( 'Settings', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', 'monsterinsights_settings' );
35 35
     } else {
36
-        // if dashboards enabled, first dashboard
37
-        add_menu_page( __( 'General:', 'google-analytics-for-wordpress' ), __( 'Insights', 'google-analytics-for-wordpress' ) . MonsterInsights()->notifications->get_menu_count(), 'monsterinsights_view_dashboard', 'monsterinsights_reports', 'monsterinsights_reports_page',  $menu_icon_inline, '100.00013467543' );
36
+	// if dashboards enabled, first dashboard
37
+	add_menu_page( __( 'General:', 'google-analytics-for-wordpress' ), __( 'Insights', 'google-analytics-for-wordpress' ) . MonsterInsights()->notifications->get_menu_count(), 'monsterinsights_view_dashboard', 'monsterinsights_reports', 'monsterinsights_reports_page',  $menu_icon_inline, '100.00013467543' );
38 38
 
39
-        add_submenu_page( $hook, __( 'General Reports:', 'google-analytics-for-wordpress' ), __( 'Reports', 'google-analytics-for-wordpress' ), 'monsterinsights_view_dashboard', 'monsterinsights_reports', 'monsterinsights_reports_page' );
39
+	add_submenu_page( $hook, __( 'General Reports:', 'google-analytics-for-wordpress' ), __( 'Reports', 'google-analytics-for-wordpress' ), 'monsterinsights_view_dashboard', 'monsterinsights_reports', 'monsterinsights_reports_page' );
40 40
 
41
-        // then settings page
42
-        add_submenu_page( $hook, __( 'MonsterInsights', 'google-analytics-for-wordpress' ), __( 'Settings', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', 'monsterinsights_settings', 'monsterinsights_settings_page' );
41
+	// then settings page
42
+	add_submenu_page( $hook, __( 'MonsterInsights', 'google-analytics-for-wordpress' ), __( 'Settings', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', 'monsterinsights_settings', 'monsterinsights_settings_page' );
43 43
 
44
-        // Add dashboard submenu.
45
-        add_submenu_page( 'index.php', __( 'General Reports:', 'google-analytics-for-wordpress' ), __( 'Insights', 'google-analytics-for-wordpress' ), 'monsterinsights_view_dashboard', 'admin.php?page=monsterinsights_reports' );
44
+	// Add dashboard submenu.
45
+	add_submenu_page( 'index.php', __( 'General Reports:', 'google-analytics-for-wordpress' ), __( 'Insights', 'google-analytics-for-wordpress' ), 'monsterinsights_view_dashboard', 'admin.php?page=monsterinsights_reports' );
46 46
     }
47 47
 
48 48
     $submenu_base = add_query_arg( 'page', 'monsterinsights_settings', admin_url( 'admin.php' ) );
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
     // then addons
57 57
     $network_key = monsterinsights_is_pro_version() ? MonsterInsights()->license->get_network_license_key() : '';
58 58
     if ( ! monsterinsights_is_network_active() || ( monsterinsights_is_network_active() && empty( $network_key ) ) ) {
59
-        add_submenu_page( $hook, __( 'Addons:', 'google-analytics-for-wordpress' ), '<span style="color:' . monsterinsights_menu_highlight_color() . '"> ' . __( 'Addons', 'google-analytics-for-wordpress' ) . '</span>', 'monsterinsights_save_settings', $submenu_base . '#/addons' );
59
+	add_submenu_page( $hook, __( 'Addons:', 'google-analytics-for-wordpress' ), '<span style="color:' . monsterinsights_menu_highlight_color() . '"> ' . __( 'Addons', 'google-analytics-for-wordpress' ) . '</span>', 'monsterinsights_save_settings', $submenu_base . '#/addons' );
60 60
     }
61 61
 
62 62
     // Add About us page.
@@ -67,9 +67,9 @@  discard block
 block discarded – undo
67 67
 function monsterinsights_get_menu_hook() {
68 68
     $dashboards_disabled = monsterinsights_get_option( 'dashboards_disabled', false );
69 69
     if ( $dashboards_disabled || ( current_user_can( 'monsterinsights_save_settings' ) && ! current_user_can( 'monsterinsights_view_dashboard' ) ) ) {
70
-        return 'monsterinsights_settings';
70
+	return 'monsterinsights_settings';
71 71
     } else {
72
-        return 'monsterinsights_reports';
72
+	return 'monsterinsights_reports';
73 73
     }
74 74
 }
75 75
 
@@ -80,12 +80,12 @@  discard block
 block discarded – undo
80 80
     // First, let's see if this is an MS network enabled plugin. If it is, we should load the license
81 81
     // menu page and the updater on the network panel
82 82
     if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
83
-        require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
83
+	require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
84 84
     }
85 85
 
86 86
     $plugin = plugin_basename( MONSTERINSIGHTS_PLUGIN_FILE );
87 87
     if ( ! is_plugin_active_for_network( $plugin ) ) {
88
-        return;
88
+	return;
89 89
     }
90 90
 
91 91
     $menu_icon_inline = monsterinsights_get_inline_menu_icon();
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 function monsterinsights_add_admin_body_class( $classes ) {
117 117
     $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : false;
118 118
     if ( empty( $screen ) || empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) === false ) {
119
-        return $classes;
119
+	return $classes;
120 120
     }
121 121
 
122 122
     return "$classes monsterinsights_page ";
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
     $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : false;
134 134
 
135 135
     if ( empty( $screen ) || empty( $screen->id ) || strpos( $screen->id, 'monsterinsights_tools' ) === false || 'insights_page_monsterinsights_tools' === $screen->id  ) {
136
-        return $classes;
136
+	return $classes;
137 137
     }
138 138
 
139 139
     return "$classes insights_page_monsterinsights_tools ";
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 function monsterinsights_add_admin_body_class_addons_page( $classes ) {
150 150
     $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : false;
151 151
     if ( empty( $screen ) || empty( $screen->id ) || strpos( $screen->id, 'monsterinsights_addons' ) === false || 'insights_page_monsterinsights_addons' === $screen->id  ) {
152
-        return $classes;
152
+	return $classes;
153 153
     }
154 154
 
155 155
     return "$classes insights_page_monsterinsights_addons ";
@@ -169,17 +169,17 @@  discard block
 block discarded – undo
169 169
 
170 170
     // If lite, show a link where they can get pro from
171 171
     if ( ! monsterinsights_is_pro_version() ) {
172
-        $get_pro = '<a title="' . esc_html__( 'Get MonsterInsights Pro', 'google-analytics-for-wordpress' ) .'" href="'. monsterinsights_get_upgrade_link( 'all-plugins', 'upgrade-link', "https://www.monsterinsights.com/docs/" ) .'">' . esc_html__( 'Get MonsterInsights Pro', 'google-analytics-for-wordpress' ) . '</a>';
173
-        array_unshift( $links, $get_pro );
172
+	$get_pro = '<a title="' . esc_html__( 'Get MonsterInsights Pro', 'google-analytics-for-wordpress' ) .'" href="'. monsterinsights_get_upgrade_link( 'all-plugins', 'upgrade-link', "https://www.monsterinsights.com/docs/" ) .'">' . esc_html__( 'Get MonsterInsights Pro', 'google-analytics-for-wordpress' ) . '</a>';
173
+	array_unshift( $links, $get_pro );
174 174
     }
175 175
 
176 176
     // If Lite, support goes to forum. If pro, it goes to our website
177 177
     if ( monsterinsights_is_pro_version() ) {
178
-        $support = '<a title="MonsterInsights Pro Support" href="'. monsterinsights_get_url( 'all-plugins', 'pro-support-link', "https://www.monsterinsights.com/my-account/support/" ) .'">' . esc_html__( 'Support', 'google-analytics-for-wordpress' ) . '</a>';
179
-        array_unshift( $links, $support );
178
+	$support = '<a title="MonsterInsights Pro Support" href="'. monsterinsights_get_url( 'all-plugins', 'pro-support-link', "https://www.monsterinsights.com/my-account/support/" ) .'">' . esc_html__( 'Support', 'google-analytics-for-wordpress' ) . '</a>';
179
+	array_unshift( $links, $support );
180 180
     } else {
181
-        $support = '<a title="MonsterInsights Lite Support" href="'. monsterinsights_get_url( 'all-plugins', 'lite-support-link', "https://www.monsterinsights.com/lite-support/" ) .'">' . esc_html__( 'Support', 'google-analytics-for-wordpress' ) . '</a>';
182
-        array_unshift( $links, $support );
181
+	$support = '<a title="MonsterInsights Lite Support" href="'. monsterinsights_get_url( 'all-plugins', 'lite-support-link', "https://www.monsterinsights.com/lite-support/" ) .'">' . esc_html__( 'Support', 'google-analytics-for-wordpress' ) . '</a>';
182
+	array_unshift( $links, $support );
183 183
     }
184 184
 
185 185
 	if ( is_network_admin() ) {
@@ -208,26 +208,26 @@  discard block
 block discarded – undo
208 208
 function monsterinsights_load_admin_partial( $template, $data = array() ) {
209 209
 
210 210
     if ( monsterinsights_is_pro_version() ) {
211
-        $dir = trailingslashit( plugin_dir_path( MonsterInsights()->file ) . 'pro/includes/admin/partials' );
211
+	$dir = trailingslashit( plugin_dir_path( MonsterInsights()->file ) . 'pro/includes/admin/partials' );
212 212
 
213
-        if ( file_exists( $dir . $template . '.php' ) ) {
214
-            require_once(  $dir . $template . '.php' );
215
-            return true;
216
-        }
213
+	if ( file_exists( $dir . $template . '.php' ) ) {
214
+	    require_once(  $dir . $template . '.php' );
215
+	    return true;
216
+	}
217 217
     } else {
218
-        $dir = trailingslashit( plugin_dir_path( MonsterInsights()->file ) . 'lite/includes/admin/partials' );
218
+	$dir = trailingslashit( plugin_dir_path( MonsterInsights()->file ) . 'lite/includes/admin/partials' );
219 219
 
220
-        if ( file_exists( $dir . $template . '.php' ) ) {
221
-            require_once(  $dir . $template . '.php' );
222
-            return true;
223
-        }
220
+	if ( file_exists( $dir . $template . '.php' ) ) {
221
+	    require_once(  $dir . $template . '.php' );
222
+	    return true;
223
+	}
224 224
     }
225 225
 
226 226
     $dir = trailingslashit( plugin_dir_path( MonsterInsights()->file ) . 'includes/admin/partials' );
227 227
 
228 228
     if ( file_exists( $dir . $template . '.php' ) ) {
229
-        require_once(  $dir . $template . '.php' );
230
-        return true;
229
+	require_once(  $dir . $template . '.php' );
230
+	return true;
231 231
     }
232 232
 
233 233
     return false;
@@ -244,9 +244,9 @@  discard block
 block discarded – undo
244 244
 function monsterinsights_admin_footer( $text ) {
245 245
     global $current_screen;
246 246
     if ( ! empty( $current_screen->id ) && strpos( $current_screen->id, 'monsterinsights' ) !== false ) {
247
-        $url  = 'https://wordpress.org/support/view/plugin-reviews/google-analytics-for-wordpress?filter=5';
248
-        // Translators: Placeholders add a link to the wordpress.org repository.
249
-        $text = sprintf( esc_html__( 'Please rate %1$sMonsterInsights%2$s on %3$s %4$sWordPress.org%5$s to help us spread the word. Thank you from the MonsterInsights team!', 'google-analytics-for-wordpress' ), '<strong>', '</strong>', '<a class="monsterinsights-no-text-decoration" href="' .  $url . '" target="_blank" rel="noopener noreferrer"><i class="monstericon-star"></i><i class="monstericon-star"></i><i class="monstericon-star"></i><i class="monstericon-star"></i><i class="monstericon-star"></i></a>', '<a href="' . $url . '" target="_blank" rel="noopener noreferrer">', '</a>' );
247
+	$url  = 'https://wordpress.org/support/view/plugin-reviews/google-analytics-for-wordpress?filter=5';
248
+	// Translators: Placeholders add a link to the wordpress.org repository.
249
+	$text = sprintf( esc_html__( 'Please rate %1$sMonsterInsights%2$s on %3$s %4$sWordPress.org%5$s to help us spread the word. Thank you from the MonsterInsights team!', 'google-analytics-for-wordpress' ), '<strong>', '</strong>', '<a class="monsterinsights-no-text-decoration" href="' .  $url . '" target="_blank" rel="noopener noreferrer"><i class="monstericon-star"></i><i class="monstericon-star"></i><i class="monstericon-star"></i><i class="monstericon-star"></i><i class="monstericon-star"></i></a>', '<a href="' . $url . '" target="_blank" rel="noopener noreferrer">', '</a>' );
250 250
     }
251 251
     return $text;
252 252
 }
@@ -257,12 +257,12 @@  discard block
 block discarded – undo
257 257
     // Don't show on MonsterInsights pages
258 258
     $screen = get_current_screen();
259 259
     if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) !== false ) {
260
-        return;
260
+	return;
261 261
     }
262 262
 
263 263
     // Make sure they have the permissions to do something
264 264
     if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
265
-        return;
265
+	return;
266 266
     }
267 267
 
268 268
     // Priority:
@@ -280,89 +280,89 @@  discard block
 block discarded – undo
280 280
     // 1. Google Analytics not authenticated
281 281
 	if ( ! is_network_admin() && ! monsterinsights_get_ua() && ! defined( 'MONSTERINSIGHTS_DISABLE_TRACKING' ) ) {
282 282
 
283
-        $submenu_base = is_network_admin() ? add_query_arg( 'page', 'monsterinsights_network', network_admin_url( 'admin.php' ) ) : add_query_arg( 'page', 'monsterinsights_settings', admin_url( 'admin.php' ) );
284
-        $title     = esc_html__( 'Please Setup Website Analytics to See Audience Insights', 'google-analytics-for-wordpress' );
285
-        $primary   = esc_html__( 'Connect MonsterInsights and Setup Website Analytics', 'google-analytics-for-wordpress' );
286
-        $urlone    = is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights-onboarding' ) : admin_url( 'admin.php?page=monsterinsights-onboarding' );
287
-        $secondary = esc_html__( 'Learn More', 'google-analytics-for-wordpress' );
288
-        $urltwo    = $submenu_base . '#/about/getting-started';
289
-        $message   = esc_html__( 'MonsterInsights, WordPress analytics plugin, helps you connect your website with Google Analytics, so you can see how people find and use your website. Over 2 million website owners use MonsterInsights to see the stats that matter and grow their business.', 'google-analytics-for-wordpress' );
290
-        echo '<div class="notice notice-info"><p style="font-weight:700">'. $title .'</p><p>'. $message.'</p><p><a href="'. $urlone .'" class="button-primary">'. $primary .'</a>&nbsp;&nbsp;&nbsp;<a href="'. $urltwo .'" class="button-secondary">'. $secondary .'</a></p></div>';
291
-        return;
283
+	$submenu_base = is_network_admin() ? add_query_arg( 'page', 'monsterinsights_network', network_admin_url( 'admin.php' ) ) : add_query_arg( 'page', 'monsterinsights_settings', admin_url( 'admin.php' ) );
284
+	$title     = esc_html__( 'Please Setup Website Analytics to See Audience Insights', 'google-analytics-for-wordpress' );
285
+	$primary   = esc_html__( 'Connect MonsterInsights and Setup Website Analytics', 'google-analytics-for-wordpress' );
286
+	$urlone    = is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights-onboarding' ) : admin_url( 'admin.php?page=monsterinsights-onboarding' );
287
+	$secondary = esc_html__( 'Learn More', 'google-analytics-for-wordpress' );
288
+	$urltwo    = $submenu_base . '#/about/getting-started';
289
+	$message   = esc_html__( 'MonsterInsights, WordPress analytics plugin, helps you connect your website with Google Analytics, so you can see how people find and use your website. Over 2 million website owners use MonsterInsights to see the stats that matter and grow their business.', 'google-analytics-for-wordpress' );
290
+	echo '<div class="notice notice-info"><p style="font-weight:700">'. $title .'</p><p>'. $message.'</p><p><a href="'. $urlone .'" class="button-primary">'. $primary .'</a>&nbsp;&nbsp;&nbsp;<a href="'. $urltwo .'" class="button-secondary">'. $secondary .'</a></p></div>';
291
+	return;
292 292
     }
293 293
 
294 294
     // 2. License key not entered for pro
295 295
     $key = monsterinsights_is_pro_version() ? MonsterInsights()->license->get_license_key() : '';
296 296
     if ( monsterinsights_is_pro_version() && empty( $key ) ) {
297
-        $page = is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' );
298
-        // Translators: Adds a link to retrieve the license.
299
-        $message = sprintf( esc_html__( 'Warning: No valid license key has been entered for MonsterInsights. You are currently not getting updates, and are not able to view reports. %1$sPlease click here to enter your license key and begin receiving updates and reports.%2$s', 'google-analytics-for-wordpress' ), '<a href="'. esc_url( $page ) . '">', '</a>' );
300
-        echo '<div class="error"><p>'. $message.'</p></div>';
301
-        return;
297
+	$page = is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' );
298
+	// Translators: Adds a link to retrieve the license.
299
+	$message = sprintf( esc_html__( 'Warning: No valid license key has been entered for MonsterInsights. You are currently not getting updates, and are not able to view reports. %1$sPlease click here to enter your license key and begin receiving updates and reports.%2$s', 'google-analytics-for-wordpress' ), '<a href="'. esc_url( $page ) . '">', '</a>' );
300
+	echo '<div class="error"><p>'. $message.'</p></div>';
301
+	return;
302 302
     }
303 303
 
304 304
     // 3. License key not valid/okay for pro
305 305
     if ( monsterinsights_is_pro_version() ) {
306
-        $message = '';
307
-        if ( MonsterInsights()->license->get_site_license_key() ){
308
-            if ( MonsterInsights()->license->site_license_expired() ) {
309
-	            // Translators: Adds a link to the license renewal.
310
-                $message = sprintf( esc_html__( 'Your license key for MonsterInsights has expired. %1$sPlease click here to renew your license key.%2$s', 'google-analytics-for-wordpress' ), '<a href="'. monsterinsights_get_url( 'admin-notices', 'expired-license', "https://www.monsterinsights.com/login/" ) .'" target="_blank" rel="noopener noreferrer" referrer="no-referrer">', '</a>' );
311
-            } else if ( MonsterInsights()->license->site_license_disabled() ) {
312
-                $message = esc_html__( 'Your license key for MonsterInsights has been disabled. Please use a different key.', 'google-analytics-for-wordpress' );
313
-            } else if ( MonsterInsights()->license->site_license_invalid() ) {
314
-                $message = esc_html__( 'Your license key for MonsterInsights is invalid. The key no longer exists or the user associated with the key has been deleted. Please use a different key.', 'google-analytics-for-wordpress' );
315
-            }
316
-        } else if ( MonsterInsights()->license->get_network_license_key() ) {
317
-            if ( MonsterInsights()->license->network_license_expired() ) {
318
-            	// Translators: Adds a link to renew license.
319
-                $message = sprintf( esc_html__( 'Your network license key for MonsterInsights has expired. %1$sPlease click here to renew your license key.%2$s', 'google-analytics-for-wordpress' ), '<a href="'. monsterinsights_get_url( 'admin-notices', 'expired-license', "https://www.monsterinsights.com/login/" ) .'" target="_blank" rel="noopener noreferrer" referrer="no-referrer">', '</a>' );
320
-            } else if ( MonsterInsights()->license->network_license_disabled() ) {
321
-                $message = esc_html__( 'Your network license key for MonsterInsights has been disabled. Please use a different key.', 'google-analytics-for-wordpress' );
322
-            } else if ( MonsterInsights()->license->network_license_invalid() ) {
323
-                $message = esc_html__( 'Your network license key for MonsterInsights is invalid. The key no longer exists or the user associated with the key has been deleted. Please use a different key.', 'google-analytics-for-wordpress' );
324
-            }
325
-        }
326
-        if ( ! empty( $message ) ) {
327
-            echo '<div class="error"><p>'. $message.'</p></div>';
328
-            return;
329
-        }
306
+	$message = '';
307
+	if ( MonsterInsights()->license->get_site_license_key() ){
308
+	    if ( MonsterInsights()->license->site_license_expired() ) {
309
+		    // Translators: Adds a link to the license renewal.
310
+		$message = sprintf( esc_html__( 'Your license key for MonsterInsights has expired. %1$sPlease click here to renew your license key.%2$s', 'google-analytics-for-wordpress' ), '<a href="'. monsterinsights_get_url( 'admin-notices', 'expired-license', "https://www.monsterinsights.com/login/" ) .'" target="_blank" rel="noopener noreferrer" referrer="no-referrer">', '</a>' );
311
+	    } else if ( MonsterInsights()->license->site_license_disabled() ) {
312
+		$message = esc_html__( 'Your license key for MonsterInsights has been disabled. Please use a different key.', 'google-analytics-for-wordpress' );
313
+	    } else if ( MonsterInsights()->license->site_license_invalid() ) {
314
+		$message = esc_html__( 'Your license key for MonsterInsights is invalid. The key no longer exists or the user associated with the key has been deleted. Please use a different key.', 'google-analytics-for-wordpress' );
315
+	    }
316
+	} else if ( MonsterInsights()->license->get_network_license_key() ) {
317
+	    if ( MonsterInsights()->license->network_license_expired() ) {
318
+	    	// Translators: Adds a link to renew license.
319
+		$message = sprintf( esc_html__( 'Your network license key for MonsterInsights has expired. %1$sPlease click here to renew your license key.%2$s', 'google-analytics-for-wordpress' ), '<a href="'. monsterinsights_get_url( 'admin-notices', 'expired-license', "https://www.monsterinsights.com/login/" ) .'" target="_blank" rel="noopener noreferrer" referrer="no-referrer">', '</a>' );
320
+	    } else if ( MonsterInsights()->license->network_license_disabled() ) {
321
+		$message = esc_html__( 'Your network license key for MonsterInsights has been disabled. Please use a different key.', 'google-analytics-for-wordpress' );
322
+	    } else if ( MonsterInsights()->license->network_license_invalid() ) {
323
+		$message = esc_html__( 'Your network license key for MonsterInsights is invalid. The key no longer exists or the user associated with the key has been deleted. Please use a different key.', 'google-analytics-for-wordpress' );
324
+	    }
325
+	}
326
+	if ( ! empty( $message ) ) {
327
+	    echo '<div class="error"><p>'. $message.'</p></div>';
328
+	    return;
329
+	}
330 330
     }
331 331
 
332 332
     // 4. Notices for PHP/WP version deprecations
333 333
     if ( current_user_can( 'update_core' ) ) {
334
-        global $wp_version;
335
-
336
-        // PHP 5.2-5.5
337
-        if ( version_compare( phpversion(), '5.6', '<' ) ) {
338
-            $url = monsterinsights_get_url( 'global-notice', 'settings-page', 'https://www.monsterinsights.com/docs/update-php/' );
339
-            // Translators: Placeholders add the PHP version, a link to the MonsterInsights blog and a line break.
340
-            $message = sprintf( esc_html__( 'Your site is running an outdated, insecure version of PHP (%1$s), which could be putting your site at risk for being hacked.%4$sWordPress stopped supporting your PHP version in April, 2019.%4$sUpdating PHP only takes a few minutes and will make your website significantly faster and more secure.%4$s%2$sLearn more about updating PHP%3$s', 'google-analytics-for-wordpress' ), phpversion(), '<a href="' . $url . '" target="_blank">', '</a>', '<br>' );
341
-            echo '<div class="error"><p>'. $message.'</p></div>';
342
-            return;
343
-        }
344
-        // WordPress 3.0 - 4.5
345
-        else if ( version_compare( $wp_version, '4.9', '<' ) ) {
346
-            $url = monsterinsights_get_url( 'global-notice', 'settings-page', 'https://www.monsterinsights.com/docs/update-wordpress/' );
347
-            // Translators: Placeholders add the current WordPress version and links to the MonsterInsights blog
348
-            $message = sprintf( esc_html__( 'Your site is running an outdated version of WordPress (%1$s).%4$sMonsterInsights will stop supporting WordPress versions lower than 4.9 in 2020.%4$sUpdating WordPress takes just a few minutes and will also solve many bugs that exist in your WordPress install.%4$s%2$sLearn more about updating WordPress%3$s', 'google-analytics-for-wordpress' ), $wp_version, '<a href="' . $url . '" target="_blank">', '</a>', '<br>' );
349
-            echo '<div class="error"><p>'. $message.'</p></div>';
350
-            return;
351
-        }
352
-        // PHP 5.4/5.5
353
-        // else if ( version_compare( phpversion(), '5.6', '<' ) ) {
354
-        //  $url = monsterinsights_get_url( 'global-notice', 'settings-page', 'https://www.monsterinsights.com/docs/update-php/' );
355
-        //  $message = sprintf( esc_html__( 'Your site is running an outdated, insecure version of PHP (%1$s), which could be putting your site at risk for being hacked.%4$sWordPress will stop supporting your PHP version in April, 2019.%4$sUpdating PHP only takes a few minutes and will make your website significantly faster and more secure.%4$s%2$sLearn more about updating PHP%3$s', 'google-analytics-for-wordpress' ), phpversion(), '<a href="' . $url . '" target="_blank">', '</a>', '<br>' );
356
-        //  echo '<div class="error"><p>'. $message.'</p></div>';
357
-        //  return;
358
-        // }
359
-        // // WordPress 4.6 - 4.8
360
-        // else if ( version_compare( $wp_version, '4.9', '<' ) ) {
361
-        //  $url = monsterinsights_get_url( 'global-notice', 'settings-page', 'https://www.monsterinsights.com/docs/update-wordpress/' );
362
-        //  $message = sprintf( esc_html__( 'Your site is running an outdated version of WordPress (%1$s).%4$sMonsterInsights will stop supporting WordPress versions lower than 4.9 in October, 2019.%4$sUpdating WordPress takes just a few minutes and will also solve many bugs that exist in your WordPress install.%4$s%2$sLearn more about updating WordPress%3$s', 'google-analytics-for-wordpress' ), $wp_version, '<a href="' . $url . '" target="_blank">', '</a>', '<br>' );
363
-        //  echo '<div class="error"><p>'. $message.'</p></div>';
364
-        //  return;
365
-        // }
334
+	global $wp_version;
335
+
336
+	// PHP 5.2-5.5
337
+	if ( version_compare( phpversion(), '5.6', '<' ) ) {
338
+	    $url = monsterinsights_get_url( 'global-notice', 'settings-page', 'https://www.monsterinsights.com/docs/update-php/' );
339
+	    // Translators: Placeholders add the PHP version, a link to the MonsterInsights blog and a line break.
340
+	    $message = sprintf( esc_html__( 'Your site is running an outdated, insecure version of PHP (%1$s), which could be putting your site at risk for being hacked.%4$sWordPress stopped supporting your PHP version in April, 2019.%4$sUpdating PHP only takes a few minutes and will make your website significantly faster and more secure.%4$s%2$sLearn more about updating PHP%3$s', 'google-analytics-for-wordpress' ), phpversion(), '<a href="' . $url . '" target="_blank">', '</a>', '<br>' );
341
+	    echo '<div class="error"><p>'. $message.'</p></div>';
342
+	    return;
343
+	}
344
+	// WordPress 3.0 - 4.5
345
+	else if ( version_compare( $wp_version, '4.9', '<' ) ) {
346
+	    $url = monsterinsights_get_url( 'global-notice', 'settings-page', 'https://www.monsterinsights.com/docs/update-wordpress/' );
347
+	    // Translators: Placeholders add the current WordPress version and links to the MonsterInsights blog
348
+	    $message = sprintf( esc_html__( 'Your site is running an outdated version of WordPress (%1$s).%4$sMonsterInsights will stop supporting WordPress versions lower than 4.9 in 2020.%4$sUpdating WordPress takes just a few minutes and will also solve many bugs that exist in your WordPress install.%4$s%2$sLearn more about updating WordPress%3$s', 'google-analytics-for-wordpress' ), $wp_version, '<a href="' . $url . '" target="_blank">', '</a>', '<br>' );
349
+	    echo '<div class="error"><p>'. $message.'</p></div>';
350
+	    return;
351
+	}
352
+	// PHP 5.4/5.5
353
+	// else if ( version_compare( phpversion(), '5.6', '<' ) ) {
354
+	//  $url = monsterinsights_get_url( 'global-notice', 'settings-page', 'https://www.monsterinsights.com/docs/update-php/' );
355
+	//  $message = sprintf( esc_html__( 'Your site is running an outdated, insecure version of PHP (%1$s), which could be putting your site at risk for being hacked.%4$sWordPress will stop supporting your PHP version in April, 2019.%4$sUpdating PHP only takes a few minutes and will make your website significantly faster and more secure.%4$s%2$sLearn more about updating PHP%3$s', 'google-analytics-for-wordpress' ), phpversion(), '<a href="' . $url . '" target="_blank">', '</a>', '<br>' );
356
+	//  echo '<div class="error"><p>'. $message.'</p></div>';
357
+	//  return;
358
+	// }
359
+	// // WordPress 4.6 - 4.8
360
+	// else if ( version_compare( $wp_version, '4.9', '<' ) ) {
361
+	//  $url = monsterinsights_get_url( 'global-notice', 'settings-page', 'https://www.monsterinsights.com/docs/update-wordpress/' );
362
+	//  $message = sprintf( esc_html__( 'Your site is running an outdated version of WordPress (%1$s).%4$sMonsterInsights will stop supporting WordPress versions lower than 4.9 in October, 2019.%4$sUpdating WordPress takes just a few minutes and will also solve many bugs that exist in your WordPress install.%4$s%2$sLearn more about updating WordPress%3$s', 'google-analytics-for-wordpress' ), $wp_version, '<a href="' . $url . '" target="_blank">', '</a>', '<br>' );
363
+	//  echo '<div class="error"><p>'. $message.'</p></div>';
364
+	//  return;
365
+	// }
366 366
     }
367 367
 
368 368
     // 5. Optin setting not configured
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
 
393 393
     $notices   = get_option( 'monsterinsights_notices' );
394 394
     if ( ! is_array( $notices ) ) {
395
-        $notices = array();
395
+	$notices = array();
396 396
     }
397 397
 
398 398
     // 6. Authenticate, not manual
@@ -436,75 +436,75 @@  discard block
 block discarded – undo
436 436
 
437 437
     // 8. WooUpsell
438 438
     if ( ! monsterinsights_is_pro_version() && class_exists( 'WooCommerce' ) ) {
439
-        if ( ! isset( $notices['monsterinsights_woocommerce_tracking_available' ] ) ) {
440
-            echo '<div class="notice notice-success is-dismissible monsterinsights-notice monsterinsights-wooedd-upsell-row" data-notice="monsterinsights_woocommerce_tracking_available">';
441
-                echo '<div class="monsterinsights-wooedd-upsell-left">';
442
-                    echo '<p><strong>';
443
-                    echo esc_html( 'Enhanced Ecommerce Analytics for Your WooCommerce Store', 'google-analytics-for-wordpress' );
444
-                    echo '</strong></p>';
445
-                    echo '<img class="monsterinsights-wooedd-upsell-image monsterinsights-wooedd-upsell-image-small" src="' . trailingslashit( MONSTERINSIGHTS_PLUGIN_URL ) . 'assets/images/upsell/woo-edd-upsell.png">';
446
-                    echo '<p>';
447
-                    echo esc_html( 'MonsterInsights Pro gives you detailed stats and insights about your customers.', 'google-analytics-for-wordpress' );
448
-                    echo '</p>';
449
-                    echo '<p>';
450
-                    echo esc_html( 'This helps you make data-driven decisions about your content, and marketing strategy so you can increase your website traffic, leads, and sales.', 'google-analytics-for-wordpress' );
451
-                    echo '</p>';
452
-                    echo '<p>';
453
-                    echo esc_html( 'Pro customers also get Form Tracking, Custom Dimensions Tracking, UserID Tracking and much more.', 'google-analytics-for-wordpress' );
454
-                    echo '</p>';
455
-                    echo '<p>';
456
-                    echo esc_html( 'Start making data-driven decisions to grow your business.', 'google-analytics-for-wordpress' );
457
-                    echo '</p>';
458
-                    // Translators: Placeholders add a link to the MonsterInsights website.
459
-                    echo sprintf( esc_html__( '%1$sGet MonsterInsights Pro%2$s', 'google-analytics-for-wordpress' ), '<a class="button button-primary button-hero" href="'. monsterinsights_get_upgrade_link( 'admin-notices', 'woocommerce-upgrade' ) .'">', ' &raquo;</a>' );
460
-                    echo '</p>';
461
-                echo '</div><div class="monsterinsights-wooedd-upsell-right">';
462
-                    echo '<img class="monsterinsights-wooedd-upsell-image monsterinsights-wooedd-upsell-image-large" src="' . trailingslashit( MONSTERINSIGHTS_PLUGIN_URL ) . 'assets/images/upsell/woo-edd-upsell.png">';
463
-                echo '</div>';
464
-            echo '</div>';
465
-            echo '<style type="text/css">.monsterinsights-wooedd-upsell-left{width:50%;display:table-cell;float:left}.monsterinsights-wooedd-upsell-right{width:50%;display:table-cell;float:left}.monsterinsights-wooedd-upsell-image{width:100%;height:auto;padding:20px}.monsterinsights-wooedd-upsell-image-small{display:none}.monsterinsights-wooedd-upsell-row{display:table}.monsterinsights-wooedd-upsell-left p{margin:1em 0;font-size:16px}@media (max-width:900px){.monsterinsights-wooedd-upsell-left{width:100%}.monsterinsights-wooedd-upsell-right{display:none}.monsterinsights-wooedd-upsell-image-small{display:block}.monsterinsights-wooedd-upsell-image-large{display:none}}</style>';
466
-            return;
467
-        }
439
+	if ( ! isset( $notices['monsterinsights_woocommerce_tracking_available' ] ) ) {
440
+	    echo '<div class="notice notice-success is-dismissible monsterinsights-notice monsterinsights-wooedd-upsell-row" data-notice="monsterinsights_woocommerce_tracking_available">';
441
+		echo '<div class="monsterinsights-wooedd-upsell-left">';
442
+		    echo '<p><strong>';
443
+		    echo esc_html( 'Enhanced Ecommerce Analytics for Your WooCommerce Store', 'google-analytics-for-wordpress' );
444
+		    echo '</strong></p>';
445
+		    echo '<img class="monsterinsights-wooedd-upsell-image monsterinsights-wooedd-upsell-image-small" src="' . trailingslashit( MONSTERINSIGHTS_PLUGIN_URL ) . 'assets/images/upsell/woo-edd-upsell.png">';
446
+		    echo '<p>';
447
+		    echo esc_html( 'MonsterInsights Pro gives you detailed stats and insights about your customers.', 'google-analytics-for-wordpress' );
448
+		    echo '</p>';
449
+		    echo '<p>';
450
+		    echo esc_html( 'This helps you make data-driven decisions about your content, and marketing strategy so you can increase your website traffic, leads, and sales.', 'google-analytics-for-wordpress' );
451
+		    echo '</p>';
452
+		    echo '<p>';
453
+		    echo esc_html( 'Pro customers also get Form Tracking, Custom Dimensions Tracking, UserID Tracking and much more.', 'google-analytics-for-wordpress' );
454
+		    echo '</p>';
455
+		    echo '<p>';
456
+		    echo esc_html( 'Start making data-driven decisions to grow your business.', 'google-analytics-for-wordpress' );
457
+		    echo '</p>';
458
+		    // Translators: Placeholders add a link to the MonsterInsights website.
459
+		    echo sprintf( esc_html__( '%1$sGet MonsterInsights Pro%2$s', 'google-analytics-for-wordpress' ), '<a class="button button-primary button-hero" href="'. monsterinsights_get_upgrade_link( 'admin-notices', 'woocommerce-upgrade' ) .'">', ' &raquo;</a>' );
460
+		    echo '</p>';
461
+		echo '</div><div class="monsterinsights-wooedd-upsell-right">';
462
+		    echo '<img class="monsterinsights-wooedd-upsell-image monsterinsights-wooedd-upsell-image-large" src="' . trailingslashit( MONSTERINSIGHTS_PLUGIN_URL ) . 'assets/images/upsell/woo-edd-upsell.png">';
463
+		echo '</div>';
464
+	    echo '</div>';
465
+	    echo '<style type="text/css">.monsterinsights-wooedd-upsell-left{width:50%;display:table-cell;float:left}.monsterinsights-wooedd-upsell-right{width:50%;display:table-cell;float:left}.monsterinsights-wooedd-upsell-image{width:100%;height:auto;padding:20px}.monsterinsights-wooedd-upsell-image-small{display:none}.monsterinsights-wooedd-upsell-row{display:table}.monsterinsights-wooedd-upsell-left p{margin:1em 0;font-size:16px}@media (max-width:900px){.monsterinsights-wooedd-upsell-left{width:100%}.monsterinsights-wooedd-upsell-right{display:none}.monsterinsights-wooedd-upsell-image-small{display:block}.monsterinsights-wooedd-upsell-image-large{display:none}}</style>';
466
+	    return;
467
+	}
468 468
     }
469 469
 
470 470
     // 9. EDDUpsell
471 471
     if ( ! monsterinsights_is_pro_version() && class_exists( 'Easy_Digital_Downloads' ) ) {
472
-        if ( ! isset( $notices['monsterinsights_edd_tracking_available' ] ) ) {
473
-            echo '<div class="notice notice-success is-dismissible monsterinsights-notice monsterinsights-wooedd-upsell-row" data-notice="monsterinsights_edd_tracking_available">';
474
-                echo '<div class="monsterinsights-wooedd-upsell-left">';
475
-                    echo '<p><strong>';
476
-                    echo esc_html( 'Enhanced Ecommerce Analytics for Your Easy Digital Downloads Store', 'google-analytics-for-wordpress' );
477
-                    echo '</strong></p>';
478
-                    echo '<img class="monsterinsights-wooedd-upsell-image monsterinsights-wooedd-upsell-image-small" src="' . trailingslashit( MONSTERINSIGHTS_PLUGIN_URL ) . 'assets/images/upsell/woo-edd-upsell.png">';
479
-                    echo '<p>';
480
-                    echo esc_html( 'MonsterInsights Pro gives you detailed stats and insights about your customers.', 'google-analytics-for-wordpress' );
481
-                    echo '</p>';
482
-                    echo '<p>';
483
-                    echo esc_html( 'This helps you make data-driven decisions about your content, and marketing strategy so you can increase your website traffic, leads, and sales.', 'google-analytics-for-wordpress' );
484
-                    echo '</p>';
485
-                    echo '<p>';
486
-                    echo esc_html( 'Pro customers also get Form Tracking, Custom Dimensions Tracking, UserID Tracking and much more.', 'google-analytics-for-wordpress' );
487
-                    echo '</p>';
488
-                    echo '<p>';
489
-                    echo esc_html( 'Start making data-driven decisions to grow your business.', 'google-analytics-for-wordpress' );
490
-                    echo '</p>';
491
-                    echo sprintf( esc_html__( '%1$sGet MonsterInsights Pro%2$s', 'google-analytics-for-wordpress' ), '<a class="button button-primary button-hero" href="'. monsterinsights_get_upgrade_link( 'admin-notices', 'edd-upgrade' ) .'">', ' &raquo;</a>' );
492
-                    echo '</p>';
493
-                echo '</div><div class="monsterinsights-wooedd-upsell-right">';
494
-                    echo '<img class="monsterinsights-wooedd-upsell-image monsterinsights-wooedd-upsell-image-large" src="' . trailingslashit( MONSTERINSIGHTS_PLUGIN_URL ) . 'assets/images/upsell/woo-edd-upsell.png">';
495
-                echo '</div>';
496
-            echo '</div>';
497
-            return;
498
-        }
472
+	if ( ! isset( $notices['monsterinsights_edd_tracking_available' ] ) ) {
473
+	    echo '<div class="notice notice-success is-dismissible monsterinsights-notice monsterinsights-wooedd-upsell-row" data-notice="monsterinsights_edd_tracking_available">';
474
+		echo '<div class="monsterinsights-wooedd-upsell-left">';
475
+		    echo '<p><strong>';
476
+		    echo esc_html( 'Enhanced Ecommerce Analytics for Your Easy Digital Downloads Store', 'google-analytics-for-wordpress' );
477
+		    echo '</strong></p>';
478
+		    echo '<img class="monsterinsights-wooedd-upsell-image monsterinsights-wooedd-upsell-image-small" src="' . trailingslashit( MONSTERINSIGHTS_PLUGIN_URL ) . 'assets/images/upsell/woo-edd-upsell.png">';
479
+		    echo '<p>';
480
+		    echo esc_html( 'MonsterInsights Pro gives you detailed stats and insights about your customers.', 'google-analytics-for-wordpress' );
481
+		    echo '</p>';
482
+		    echo '<p>';
483
+		    echo esc_html( 'This helps you make data-driven decisions about your content, and marketing strategy so you can increase your website traffic, leads, and sales.', 'google-analytics-for-wordpress' );
484
+		    echo '</p>';
485
+		    echo '<p>';
486
+		    echo esc_html( 'Pro customers also get Form Tracking, Custom Dimensions Tracking, UserID Tracking and much more.', 'google-analytics-for-wordpress' );
487
+		    echo '</p>';
488
+		    echo '<p>';
489
+		    echo esc_html( 'Start making data-driven decisions to grow your business.', 'google-analytics-for-wordpress' );
490
+		    echo '</p>';
491
+		    echo sprintf( esc_html__( '%1$sGet MonsterInsights Pro%2$s', 'google-analytics-for-wordpress' ), '<a class="button button-primary button-hero" href="'. monsterinsights_get_upgrade_link( 'admin-notices', 'edd-upgrade' ) .'">', ' &raquo;</a>' );
492
+		    echo '</p>';
493
+		echo '</div><div class="monsterinsights-wooedd-upsell-right">';
494
+		    echo '<img class="monsterinsights-wooedd-upsell-image monsterinsights-wooedd-upsell-image-large" src="' . trailingslashit( MONSTERINSIGHTS_PLUGIN_URL ) . 'assets/images/upsell/woo-edd-upsell.png">';
495
+		echo '</div>';
496
+	    echo '</div>';
497
+	    return;
498
+	}
499 499
     }
500 500
 
501 501
     if ( isset( $notices['monsterinsights_cross_domains_extracted'] ) && false === $notices['monsterinsights_cross_domains_extracted'] ) {
502
-        $page = is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' );
503
-        $page = $page . '#/advanced';
504
-        // Translators: Adds a link to the settings panel.
505
-        $message = sprintf( esc_html__( 'Warning: MonsterInsights found cross-domain settings in the custom code field and converted them to the new settings structure.  %1$sPlease click here to review and remove the code no longer needed.%2$s', 'google-analytics-for-wordpress' ), '<a href="'. esc_url( $page ) . '">', '</a>' );
506
-        echo '<div class="notice notice-success is-dismissible monsterinsights-notice" data-notice="monsterinsights_cross_domains_extracted"><p>'. $message.'</p></div>';
507
-        return;
502
+	$page = is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' );
503
+	$page = $page . '#/advanced';
504
+	// Translators: Adds a link to the settings panel.
505
+	$message = sprintf( esc_html__( 'Warning: MonsterInsights found cross-domain settings in the custom code field and converted them to the new settings structure.  %1$sPlease click here to review and remove the code no longer needed.%2$s', 'google-analytics-for-wordpress' ), '<a href="'. esc_url( $page ) . '">', '</a>' );
506
+	echo '<div class="notice notice-success is-dismissible monsterinsights-notice" data-notice="monsterinsights_cross_domains_extracted"><p>'. $message.'</p></div>';
507
+	return;
508 508
     }
509 509
 }
510 510
 add_action( 'admin_notices', 'monsterinsights_admin_setup_notices' );
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
 // AM Notices
515 515
 function monsterinsights_am_notice_optout( $super_admin ) {
516 516
     if ( monsterinsights_get_option( 'hide_am_notices', false ) || monsterinsights_get_option( 'network_hide_am_notices', false ) ) {
517
-        return false;
517
+	return false;
518 518
     }
519 519
     return $super_admin;
520 520
 }
Please login to merge, or discard this patch.
includes/admin/notification-event.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -229,9 +229,9 @@
 block discarded – undo
229 229
 		$schedule['minute'] = rand( 0, 59 );
230 230
 		$schedule['second'] = rand( 0, 59 );
231 231
 		$schedule['offset'] = ( $schedule['day'] * DAY_IN_SECONDS ) +
232
-		                      ( $schedule['hour'] * HOUR_IN_SECONDS ) +
233
-		                      ( $schedule['minute'] * MINUTE_IN_SECONDS ) +
234
-		                      $schedule['second'];
232
+				      ( $schedule['hour'] * HOUR_IN_SECONDS ) +
233
+				      ( $schedule['minute'] * MINUTE_IN_SECONDS ) +
234
+				      $schedule['second'];
235 235
 		$date               = strtotime( $this->notification_first_run_time ) + $schedule['offset'];
236 236
 
237 237
 		return $date;
Please login to merge, or discard this patch.
includes/admin/ajax.php 1 patch
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -58,53 +58,53 @@  discard block
 block discarded – undo
58 58
 
59 59
     // Install the addon.
60 60
     if ( isset( $_POST['plugin'] ) ) {
61
-        $download_url = $_POST['plugin'];
62
-        global $hook_suffix;
63
-
64
-        // Set the current screen to avoid undefined notices.
65
-        set_current_screen();
66
-
67
-        // Prepare variables.
68
-        $method = '';
69
-        $url    = add_query_arg(
70
-            array(
71
-                'page' => 'monsterinsights-settings'
72
-            ),
73
-            admin_url( 'admin.php' )
74
-        );
75
-        $url = esc_url( $url );
76
-
77
-        // Start output bufferring to catch the filesystem form if credentials are needed.
78
-        ob_start();
79
-        if ( false === ( $creds = request_filesystem_credentials( $url, $method, false, false, null ) ) ) {
80
-            $form = ob_get_clean();
81
-            echo json_encode( array( 'form' => $form ) );
82
-            wp_die();
83
-        }
84
-
85
-        // If we are not authenticated, make it happen now.
86
-        if ( ! WP_Filesystem( $creds ) ) {
87
-            ob_start();
88
-            request_filesystem_credentials( $url, $method, true, false, null );
89
-            $form = ob_get_clean();
90
-            echo json_encode( array( 'form' => $form ) );
91
-            wp_die();
92
-        }
93
-
94
-        // We do not need any extra credentials if we have gotten this far, so let's install the plugin.
61
+	$download_url = $_POST['plugin'];
62
+	global $hook_suffix;
63
+
64
+	// Set the current screen to avoid undefined notices.
65
+	set_current_screen();
66
+
67
+	// Prepare variables.
68
+	$method = '';
69
+	$url    = add_query_arg(
70
+	    array(
71
+		'page' => 'monsterinsights-settings'
72
+	    ),
73
+	    admin_url( 'admin.php' )
74
+	);
75
+	$url = esc_url( $url );
76
+
77
+	// Start output bufferring to catch the filesystem form if credentials are needed.
78
+	ob_start();
79
+	if ( false === ( $creds = request_filesystem_credentials( $url, $method, false, false, null ) ) ) {
80
+	    $form = ob_get_clean();
81
+	    echo json_encode( array( 'form' => $form ) );
82
+	    wp_die();
83
+	}
84
+
85
+	// If we are not authenticated, make it happen now.
86
+	if ( ! WP_Filesystem( $creds ) ) {
87
+	    ob_start();
88
+	    request_filesystem_credentials( $url, $method, true, false, null );
89
+	    $form = ob_get_clean();
90
+	    echo json_encode( array( 'form' => $form ) );
91
+	    wp_die();
92
+	}
93
+
94
+	// We do not need any extra credentials if we have gotten this far, so let's install the plugin.
95 95
 	    monsterinsights_require_upgrader( false );
96 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
-        }
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.
@@ -133,16 +133,16 @@  discard block
 block discarded – undo
133 133
 
134 134
     // Activate the addon.
135 135
     if ( isset( $_POST['plugin'] ) ) {
136
-        if ( isset( $_POST['isnetwork'] ) &&  $_POST['isnetwork'] ) {
137
-            $activate = activate_plugin( $_POST['plugin'], NULL, true );
138
-        } else {
139
-            $activate = activate_plugin( $_POST['plugin'] );
140
-        }
141
-
142
-        if ( is_wp_error( $activate ) ) {
143
-            echo json_encode( array( 'error' => $activate->get_error_message() ) );
144
-            wp_die();
145
-        }
136
+	if ( isset( $_POST['isnetwork'] ) &&  $_POST['isnetwork'] ) {
137
+	    $activate = activate_plugin( $_POST['plugin'], NULL, true );
138
+	} else {
139
+	    $activate = activate_plugin( $_POST['plugin'] );
140
+	}
141
+
142
+	if ( is_wp_error( $activate ) ) {
143
+	    echo json_encode( array( 'error' => $activate->get_error_message() ) );
144
+	    wp_die();
145
+	}
146 146
     }
147 147
 
148 148
     echo json_encode( true );
@@ -170,11 +170,11 @@  discard block
 block discarded – undo
170 170
 
171 171
     // Deactivate the addon.
172 172
     if ( isset( $_POST['plugin'] ) ) {
173
-        if ( isset( $_POST['isnetwork'] ) && $_POST['isnetwork'] ) {
174
-            $deactivate = deactivate_plugins( $_POST['plugin'], false, true );
175
-        } else {
176
-            $deactivate = deactivate_plugins( $_POST['plugin'] );
177
-        }
173
+	if ( isset( $_POST['isnetwork'] ) && $_POST['isnetwork'] ) {
174
+	    $deactivate = deactivate_plugins( $_POST['plugin'], false, true );
175
+	} else {
176
+	    $deactivate = deactivate_plugins( $_POST['plugin'] );
177
+	}
178 178
     }
179 179
 
180 180
     echo json_encode( true );
@@ -197,12 +197,12 @@  discard block
 block discarded – undo
197 197
 
198 198
     // Deactivate the notice
199 199
     if ( isset( $_POST['notice'] ) ) {
200
-        // Init the notice class and mark notice as deactivated
201
-        MonsterInsights()->notices->dismiss( $_POST['notice'] );
200
+	// Init the notice class and mark notice as deactivated
201
+	MonsterInsights()->notices->dismiss( $_POST['notice'] );
202 202
 
203
-        // Return true
204
-        echo json_encode( true );
205
-        wp_die();
203
+	// Return true
204
+	echo json_encode( true );
205
+	wp_die();
206 206
     }
207 207
 
208 208
     // If here, an error occurred
Please login to merge, or discard this patch.