Passed
Push — master ( 82fe3a...5c0e99 )
by Chris
03:23
created
includes/admin/admin.php 3 patches
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -32,26 +32,26 @@  discard block
 block discarded – undo
32 32
     $hook = 'monsterinsights_settings';
33 33
 
34 34
     if ( $dashboards_disabled || ( current_user_can( 'monsterinsights_save_settings' ) && ! current_user_can( 'monsterinsights_view_dashboard' ) ) ) {
35
-        // If dashboards disabled, first settings page
36
-        add_menu_page( __( 'Settings:', 'google-analytics-for-wordpress' ), __( 'Insights', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', 'monsterinsights_settings', 'monsterinsights_settings_page',  plugins_url( 'assets/css/images/[email protected]', $base->file ), '100.00013467543' );
37
-        $hook = 'monsterinsights_settings';
35
+	// If dashboards disabled, first settings page
36
+	add_menu_page( __( 'Settings:', 'google-analytics-for-wordpress' ), __( 'Insights', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', 'monsterinsights_settings', 'monsterinsights_settings_page',  plugins_url( 'assets/css/images/[email protected]', $base->file ), '100.00013467543' );
37
+	$hook = 'monsterinsights_settings';
38 38
 
39
-        add_submenu_page( $hook, __( 'Settings:', 'google-analytics-for-wordpress' ), __( 'Settings', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', 'monsterinsights_settings' );
39
+	add_submenu_page( $hook, __( 'Settings:', 'google-analytics-for-wordpress' ), __( 'Settings', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', 'monsterinsights_settings' );
40 40
     } else {
41
-        // if dashboards enabled, first dashboard
42
-        add_menu_page( __( 'Dashboard:', 'google-analytics-for-wordpress' ), __( 'Insights', 'google-analytics-for-wordpress' ), 'monsterinsights_view_dashboard', 'monsterinsights_dashboard', 'monsterinsights_dashboard_page',  plugins_url( 'assets/css/images/[email protected]', $base->file ), '100.00013467543' );
41
+	// if dashboards enabled, first dashboard
42
+	add_menu_page( __( 'Dashboard:', 'google-analytics-for-wordpress' ), __( 'Insights', 'google-analytics-for-wordpress' ), 'monsterinsights_view_dashboard', 'monsterinsights_dashboard', 'monsterinsights_dashboard_page',  plugins_url( 'assets/css/images/[email protected]', $base->file ), '100.00013467543' );
43 43
 
44
-        $hook = 'monsterinsights_dashboard';
44
+	$hook = 'monsterinsights_dashboard';
45 45
 
46
-        add_submenu_page( $hook, __( 'Dashboard:', 'google-analytics-for-wordpress' ), __( 'Dashboard', 'google-analytics-for-wordpress' ), 'monsterinsights_view_dashboard', 'monsterinsights_dashboard' );
46
+	add_submenu_page( $hook, __( 'Dashboard:', 'google-analytics-for-wordpress' ), __( 'Dashboard', 'google-analytics-for-wordpress' ), 'monsterinsights_view_dashboard', 'monsterinsights_dashboard' );
47 47
 
48
-        // then settings page
49
-        add_submenu_page( $hook, __( 'Settings:', 'google-analytics-for-wordpress' ), __( 'Settings', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', 'monsterinsights_settings', 'monsterinsights_settings_page' );
48
+	// then settings page
49
+	add_submenu_page( $hook, __( 'Settings:', 'google-analytics-for-wordpress' ), __( 'Settings', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', 'monsterinsights_settings', 'monsterinsights_settings_page' );
50 50
     }
51 51
 
52 52
     if ( ! $dashboards_disabled ) {
53
-        // then reports
54
-        add_submenu_page( $hook, __( 'Reports:', 'google-analytics-for-wordpress' ), __( 'Reports', 'google-analytics-for-wordpress' ), 'monsterinsights_view_dashboard', 'monsterinsights_reports', 'monsterinsights_reports_page' );
53
+	// then reports
54
+	add_submenu_page( $hook, __( 'Reports:', 'google-analytics-for-wordpress' ), __( 'Reports', 'google-analytics-for-wordpress' ), 'monsterinsights_view_dashboard', 'monsterinsights_reports', 'monsterinsights_reports_page' );
55 55
     }
56 56
     
57 57
     // then tools
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
     // then addons
61 61
     $network_license = get_site_option( 'monsterinsights_license' );
62 62
     if ( ! monsterinsights_is_network_active() || ( monsterinsights_is_network_active() && empty( $network_license ) ) ) {
63
-        add_submenu_page( $hook, __( 'Addons:', 'google-analytics-for-wordpress' ), '<span style="color:#7cc048"> ' . __( 'Addons', 'google-analytics-for-wordpress' ) . '</span>', 'monsterinsights_save_settings', 'monsterinsights_addons', 'monsterinsights_addons_page' );
63
+	add_submenu_page( $hook, __( 'Addons:', 'google-analytics-for-wordpress' ), '<span style="color:#7cc048"> ' . __( 'Addons', 'google-analytics-for-wordpress' ) . '</span>', 'monsterinsights_save_settings', 'monsterinsights_addons', 'monsterinsights_addons_page' );
64 64
     }
65 65
 }
66 66
 add_action( 'admin_menu', 'monsterinsights_admin_menu' );
@@ -74,12 +74,12 @@  discard block
 block discarded – undo
74 74
     // First, let's see if this is an MS network enabled plugin. If it is, we should load the license 
75 75
     // menu page and the updater on the network panel
76 76
     if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
77
-        require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
77
+	require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
78 78
     }
79 79
 
80 80
     $plugin = plugin_basename( MONSTERINSIGHTS_PLUGIN_FILE );
81 81
     if ( ! is_plugin_active_for_network( $plugin ) ) {
82
-        return;
82
+	return;
83 83
     }
84 84
 
85 85
     $hook = 'monsterinsights_network';
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 function monsterinsights_add_admin_body_class( $classes ) {
102 102
     $screen = get_current_screen(); 
103 103
     if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) === false ) {
104
-        return $classes;
104
+	return $classes;
105 105
     }
106 106
        
107 107
     return "$classes monsterinsights_page ";
@@ -121,17 +121,17 @@  discard block
 block discarded – undo
121 121
 
122 122
     // If lite, show a link where they can get pro from
123 123
     if ( ! monsterinsights_is_pro_version() ) {
124
-        $get_pro = '<a title="Get MonsterInsights Pro" href="https://www.monsterinsights.com/upgrade-to-pro/">' . esc_html__( 'Get MonsterInsights Pro', 'google-analytics-for-wordpress' ) . '</a>';
125
-        array_unshift( $links, $get_pro );
124
+	$get_pro = '<a title="Get MonsterInsights Pro" href="https://www.monsterinsights.com/upgrade-to-pro/">' . esc_html__( 'Get MonsterInsights Pro', 'google-analytics-for-wordpress' ) . '</a>';
125
+	array_unshift( $links, $get_pro );
126 126
     }   
127 127
     
128 128
     // If Lite, support goes to forum. If pro, it goes to our website
129 129
     if ( monsterinsights_is_pro_version() ) {
130
-        $support = '<a title="MonsterInsights Pro Support" href="https://www.monsterinsights.com/my-account/support/">' . esc_html__( 'Support', 'google-analytics-for-wordpress' ) . '</a>';
131
-        array_unshift( $links, $support );
130
+	$support = '<a title="MonsterInsights Pro Support" href="https://www.monsterinsights.com/my-account/support/">' . esc_html__( 'Support', 'google-analytics-for-wordpress' ) . '</a>';
131
+	array_unshift( $links, $support );
132 132
     } else {
133
-        $support = '<a title="MonsterInsights Lite Support" href="https://wordpress.org/support/plugin/google-analytics-for-wordpress">' . esc_html__( 'Support', 'google-analytics-for-wordpress' ) . '</a>';
134
-        array_unshift( $links, $support );      
133
+	$support = '<a title="MonsterInsights Lite Support" href="https://wordpress.org/support/plugin/google-analytics-for-wordpress">' . esc_html__( 'Support', 'google-analytics-for-wordpress' ) . '</a>';
134
+	array_unshift( $links, $support );      
135 135
     }
136 136
 
137 137
     $settings_link = '<a href="' . esc_url( admin_url( 'admin.php?page=monsterinsights_settings' ) ) . '">' . esc_html__( 'Settings', 'google-analytics-for-wordpress' ) . '</a>';
@@ -158,26 +158,26 @@  discard block
 block discarded – undo
158 158
     $base = MonsterInsights();
159 159
 
160 160
     if ( monsterinsights_is_pro_version() ) {
161
-        $dir = trailingslashit( plugin_dir_path( $base->file ) . 'pro/includes/admin/partials' );
161
+	$dir = trailingslashit( plugin_dir_path( $base->file ) . 'pro/includes/admin/partials' );
162 162
     
163
-        if ( file_exists( $dir . $template . '.php' ) ) {
164
-            require_once(  $dir . $template . '.php' );
165
-            return true;
166
-        }
163
+	if ( file_exists( $dir . $template . '.php' ) ) {
164
+	    require_once(  $dir . $template . '.php' );
165
+	    return true;
166
+	}
167 167
     } else {
168
-        $dir = trailingslashit( plugin_dir_path( $base->file ) . 'lite/includes/admin/partials' );
168
+	$dir = trailingslashit( plugin_dir_path( $base->file ) . 'lite/includes/admin/partials' );
169 169
     
170
-        if ( file_exists( $dir . $template . '.php' ) ) {
171
-            require_once(  $dir . $template . '.php' );
172
-            return true;
173
-        }   
170
+	if ( file_exists( $dir . $template . '.php' ) ) {
171
+	    require_once(  $dir . $template . '.php' );
172
+	    return true;
173
+	}   
174 174
     }
175 175
         
176 176
     $dir = trailingslashit( plugin_dir_path( $base->file ) . 'includes/admin/partials' );
177 177
 
178 178
     if ( file_exists( $dir . $template . '.php' ) ) {
179
-        require_once(  $dir . $template . '.php' );
180
-        return true;
179
+	require_once(  $dir . $template . '.php' );
180
+	return true;
181 181
     }
182 182
                 
183 183
     return false;
@@ -196,15 +196,15 @@  discard block
 block discarded – undo
196 196
     // Get the current screen, and check whether we're viewing a MonsterInsights screen;
197 197
     $screen = get_current_screen(); 
198 198
     if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) === false ) {
199
-        return;
199
+	return;
200 200
     }
201 201
 
202 202
     // If here, we're on an MonsterInsights screen, so output the header.
203 203
     monsterinsights_load_admin_partial( 'header', array(
204
-        'mascot'   => plugins_url( 'assets/css/images/mascot.png', $base->file ),
205
-        'logo'     => plugins_url( 'assets/css/images/logo.png', $base->file ),
206
-        '2xmascot' => plugins_url( 'assets/css/images/[email protected]', $base->file ),
207
-        '2xlogo'   => plugins_url( 'assets/css/images/[email protected]', $base->file ),
204
+	'mascot'   => plugins_url( 'assets/css/images/mascot.png', $base->file ),
205
+	'logo'     => plugins_url( 'assets/css/images/logo.png', $base->file ),
206
+	'2xmascot' => plugins_url( 'assets/css/images/[email protected]', $base->file ),
207
+	'2xlogo'   => plugins_url( 'assets/css/images/[email protected]', $base->file ),
208 208
     ) );
209 209
 }
210 210
 add_action( 'in_admin_header','monsterinsights_admin_header', 100 );
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 function monsterinsights_welcome_redirect() {
213 213
     // Bail if no activation redirect
214 214
     if ( ! get_transient( '_monsterinsights_activation_redirect' ) ) {
215
-        return;
215
+	return;
216 216
     }
217 217
 
218 218
     // Delete the redirect transient
@@ -220,15 +220,15 @@  discard block
 block discarded – undo
220 220
 
221 221
     // Bail if activating from network, or bulk
222 222
     if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
223
-        return;
223
+	return;
224 224
     }
225 225
 
226 226
     $upgrade = get_option( 'monsterinsights_version_upgraded_from' );
227 227
     if( ! $upgrade ) { // First time install
228
-        //wp_safe_redirect( admin_url( 'admin.php?page=monsterinsights_settings#monsterinsights-main-tab-general' ) ); exit;
228
+	//wp_safe_redirect( admin_url( 'admin.php?page=monsterinsights_settings#monsterinsights-main-tab-general' ) ); exit;
229 229
     } else { // Update
230
-        return;
231
-        //wp_safe_redirect( admin_url( 'admin.php?page=monsterinsights_settings#monsterinsights-main-tab-general' ) ); exit;
230
+	return;
231
+	//wp_safe_redirect( admin_url( 'admin.php?page=monsterinsights_settings#monsterinsights-main-tab-general' ) ); exit;
232 232
     }
233 233
 }
234 234
 //add_action( 'admin_init', 'monsterinsights_welcome_redirect', 11 ); @todo: Investigate
@@ -244,8 +244,8 @@  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
-        $text = sprintf( esc_html__( 'Please rate %sMonsterInsights%s %s on %sWordPress.org%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">&#9733;&#9733;&#9733;&#9733;&#9733;</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
+	$text = sprintf( esc_html__( 'Please rate %sMonsterInsights%s %s on %sWordPress.org%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">&#9733;&#9733;&#9733;&#9733;&#9733;</a>', '<a href="' . $url . '" target="_blank" rel="noopener noreferrer">', '</a>' );
249 249
     }
250 250
     return $text;
251 251
 }
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
     // Don't show on MonsterInsights pages
256 256
     $screen = get_current_screen(); 
257 257
     if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) !== false ) {
258
-        return;
258
+	return;
259 259
     }
260 260
     
261 261
     $analytics = monsterinsights_get_option( 'tracking_mode', 'analytics' );
@@ -265,33 +265,33 @@  discard block
 block discarded – undo
265 265
     $notices   = get_option( 'monsterinsights_notices' );
266 266
 
267 267
     if ( ! is_array( $notices ) ) {
268
-        $notices = array();
268
+	$notices = array();
269 269
     }
270 270
 
271 271
     if ( $analytics === 'ga' && ! isset( $notices ['monsterinsights_deprecated_ga' ] ) ){
272 272
        echo '<div class="notice notice-error is-dismissible monsterinsights-notice" data-notice="monsterinsights_deprecated_ga">';
273
-            echo '<p>';
274
-            echo sprintf( esc_html__( 'Warning: You\'re currently using deprecated ga.js tracking which we will be removing support for in an upcoming release. We recommend switching to analytics.js, as it is significantly more accurate than ga.js, and allows for functionality (like the more accurate Javascript based events tracking we offer). Further Google Analytics has deprecated support for ga.js, and it may stop working at any time when Google decides to disable it from their server. To switch to using the newer Universal Analytics (analytics.js) %1$sclick here%2$s. Users who do not manually switch over will be automatically switched over in an upcoming release.', 'google-analytics-for-wordpress' ), '<a href="' . $url .'">', '</a>' ); 
275
-            echo '</p>';
276
-        echo '</div>';
273
+	    echo '<p>';
274
+	    echo sprintf( esc_html__( 'Warning: You\'re currently using deprecated ga.js tracking which we will be removing support for in an upcoming release. We recommend switching to analytics.js, as it is significantly more accurate than ga.js, and allows for functionality (like the more accurate Javascript based events tracking we offer). Further Google Analytics has deprecated support for ga.js, and it may stop working at any time when Google decides to disable it from their server. To switch to using the newer Universal Analytics (analytics.js) %1$sclick here%2$s. Users who do not manually switch over will be automatically switched over in an upcoming release.', 'google-analytics-for-wordpress' ), '<a href="' . $url .'">', '</a>' ); 
275
+	    echo '</p>';
276
+	echo '</div>';
277 277
     } else if ( $events === 'php' && ! isset( $notices ['monsterinsights_deprecated_php' ] ) ){
278 278
        echo '<div class="notice notice-error is-dismissible monsterinsights-notice" data-notice="monsterinsights_deprecated_php">';
279
-            echo '<p>';
280
-            echo sprintf( esc_html__( 'Warning: You\'re currently using deprecated PHP based events tracking which we will be removing support for in an upcoming release. We recommend switching to JS events tracking, as it is significantly more accurate than PHP based events tracking. To switch %1$sclick here%2$s. Users who do not manually switch over will be automatically switched over in an upcoming release.', 'google-analytics-for-wordpress' ), '<a href="' . $url .'">', '</a>' ); 
281
-            echo '</p>';
282
-        echo '</div>';
279
+	    echo '<p>';
280
+	    echo sprintf( esc_html__( 'Warning: You\'re currently using deprecated PHP based events tracking which we will be removing support for in an upcoming release. We recommend switching to JS events tracking, as it is significantly more accurate than PHP based events tracking. To switch %1$sclick here%2$s. Users who do not manually switch over will be automatically switched over in an upcoming release.', 'google-analytics-for-wordpress' ), '<a href="' . $url .'">', '</a>' ); 
281
+	    echo '</p>';
282
+	echo '</div>';
283 283
     } else if ( empty( $updates) && ! isset( $notices ['monsterinsights_automatic_updates' ] ) ){ 
284
-        if ( defined( 'MONSTERINSIGHTS_SHOWING_EMPTY_CONFIG_NOTICE' ) && MONSTERINSIGHTS_SHOWING_EMPTY_CONFIG_NOTICE ) {
285
-            return;
286
-        }
287
-        if ( defined( 'MONSTERINSIGHTS_SHOWING_OPTIN_TRACKING_NOTICE' ) && MONSTERINSIGHTS_SHOWING_OPTIN_TRACKING_NOTICE ) {
288
-            return;
289
-        }
290
-        echo '<div class="notice notice-info is-dismissible monsterinsights-notice" data-notice="monsterinsights_automatic_updates">';
291
-            echo '<p>';
292
-            echo sprintf( esc_html__( 'Important: Please %1$sconfigure the Automatic Updates Settings%2$s in MonsterInsights.', 'google-analytics-for-wordpress' ), '<a href="' . $url .'">', '</a>' ); 
293
-            echo '</p>';
294
-        echo '</div>';
284
+	if ( defined( 'MONSTERINSIGHTS_SHOWING_EMPTY_CONFIG_NOTICE' ) && MONSTERINSIGHTS_SHOWING_EMPTY_CONFIG_NOTICE ) {
285
+	    return;
286
+	}
287
+	if ( defined( 'MONSTERINSIGHTS_SHOWING_OPTIN_TRACKING_NOTICE' ) && MONSTERINSIGHTS_SHOWING_OPTIN_TRACKING_NOTICE ) {
288
+	    return;
289
+	}
290
+	echo '<div class="notice notice-info is-dismissible monsterinsights-notice" data-notice="monsterinsights_automatic_updates">';
291
+	    echo '<p>';
292
+	    echo sprintf( esc_html__( 'Important: Please %1$sconfigure the Automatic Updates Settings%2$s in MonsterInsights.', 'google-analytics-for-wordpress' ), '<a href="' . $url .'">', '</a>' ); 
293
+	    echo '</p>';
294
+	echo '</div>';
295 295
     }
296 296
 }
297 297
 add_action( 'admin_notices', 'monsterinsights_deprecated_notices' );
298 298
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -33,13 +33,13 @@  discard block
 block discarded – undo
33 33
 
34 34
     if ( $dashboards_disabled || ( current_user_can( 'monsterinsights_save_settings' ) && ! current_user_can( 'monsterinsights_view_dashboard' ) ) ) {
35 35
         // If dashboards disabled, first settings page
36
-        add_menu_page( __( 'Settings:', 'google-analytics-for-wordpress' ), __( 'Insights', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', 'monsterinsights_settings', 'monsterinsights_settings_page',  plugins_url( 'assets/css/images/[email protected]', $base->file ), '100.00013467543' );
36
+        add_menu_page( __( 'Settings:', 'google-analytics-for-wordpress' ), __( 'Insights', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', 'monsterinsights_settings', 'monsterinsights_settings_page', plugins_url( 'assets/css/images/[email protected]', $base->file ), '100.00013467543' );
37 37
         $hook = 'monsterinsights_settings';
38 38
 
39 39
         add_submenu_page( $hook, __( 'Settings:', 'google-analytics-for-wordpress' ), __( 'Settings', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', 'monsterinsights_settings' );
40 40
     } else {
41 41
         // if dashboards enabled, first dashboard
42
-        add_menu_page( __( 'Dashboard:', 'google-analytics-for-wordpress' ), __( 'Insights', 'google-analytics-for-wordpress' ), 'monsterinsights_view_dashboard', 'monsterinsights_dashboard', 'monsterinsights_dashboard_page',  plugins_url( 'assets/css/images/[email protected]', $base->file ), '100.00013467543' );
42
+        add_menu_page( __( 'Dashboard:', 'google-analytics-for-wordpress' ), __( 'Insights', 'google-analytics-for-wordpress' ), 'monsterinsights_view_dashboard', 'monsterinsights_dashboard', 'monsterinsights_dashboard_page', plugins_url( 'assets/css/images/[email protected]', $base->file ), '100.00013467543' );
43 43
 
44 44
         $hook = 'monsterinsights_dashboard';
45 45
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
     }
84 84
 
85 85
     $hook = 'monsterinsights_network';
86
-    add_menu_page( __( 'Network Settings', 'google-analytics-for-wordpress' ), __( 'Insights', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', 'monsterinsights_network', 'monsterinsights_network_page',  plugins_url( 'assets/css/images/[email protected]', $base->file ), '100.00013467543' );
86
+    add_menu_page( __( 'Network Settings', 'google-analytics-for-wordpress' ), __( 'Insights', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', 'monsterinsights_network', 'monsterinsights_network_page', plugins_url( 'assets/css/images/[email protected]', $base->file ), '100.00013467543' );
87 87
 
88 88
     add_submenu_page( $hook, __( 'Network Settings', 'google-analytics-for-wordpress' ), __( 'Network Settings', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', 'monsterinsights_network', 'monsterinsights_network_page' );
89 89
 
@@ -161,14 +161,14 @@  discard block
 block discarded – undo
161 161
         $dir = trailingslashit( plugin_dir_path( $base->file ) . 'pro/includes/admin/partials' );
162 162
     
163 163
         if ( file_exists( $dir . $template . '.php' ) ) {
164
-            require_once(  $dir . $template . '.php' );
164
+            require_once( $dir . $template . '.php' );
165 165
             return true;
166 166
         }
167 167
     } else {
168 168
         $dir = trailingslashit( plugin_dir_path( $base->file ) . 'lite/includes/admin/partials' );
169 169
     
170 170
         if ( file_exists( $dir . $template . '.php' ) ) {
171
-            require_once(  $dir . $template . '.php' );
171
+            require_once( $dir . $template . '.php' );
172 172
             return true;
173 173
         }   
174 174
     }
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
     $dir = trailingslashit( plugin_dir_path( $base->file ) . 'includes/admin/partials' );
177 177
 
178 178
     if ( file_exists( $dir . $template . '.php' ) ) {
179
-        require_once(  $dir . $template . '.php' );
179
+        require_once( $dir . $template . '.php' );
180 180
         return true;
181 181
     }
182 182
                 
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
         '2xlogo'   => plugins_url( 'assets/css/images/[email protected]', $base->file ),
208 208
     ) );
209 209
 }
210
-add_action( 'in_admin_header','monsterinsights_admin_header', 100 );
210
+add_action( 'in_admin_header', 'monsterinsights_admin_header', 100 );
211 211
 
212 212
 function monsterinsights_welcome_redirect() {
213 213
     // Bail if no activation redirect
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
     }
225 225
 
226 226
     $upgrade = get_option( 'monsterinsights_version_upgraded_from' );
227
-    if( ! $upgrade ) { // First time install
227
+    if ( ! $upgrade ) { // First time install
228 228
         //wp_safe_redirect( admin_url( 'admin.php?page=monsterinsights_settings#monsterinsights-main-tab-general' ) ); exit;
229 229
     } else { // Update
230 230
         return;
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
     global $current_screen;
246 246
     if ( ! empty( $current_screen->id ) && strpos( $current_screen->id, 'monsterinsights' ) !== false ) {
247 247
         $url  = 'https://wordpress.org/support/view/plugin-reviews/google-analytics-for-wordpress?filter=5';
248
-        $text = sprintf( esc_html__( 'Please rate %sMonsterInsights%s %s on %sWordPress.org%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">&#9733;&#9733;&#9733;&#9733;&#9733;</a>', '<a href="' . $url . '" target="_blank" rel="noopener noreferrer">', '</a>' );
248
+        $text = sprintf( esc_html__( 'Please rate %sMonsterInsights%s %s on %sWordPress.org%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">&#9733;&#9733;&#9733;&#9733;&#9733;</a>', '<a href="' . $url . '" target="_blank" rel="noopener noreferrer">', '</a>' );
249 249
     }
250 250
     return $text;
251 251
 }
@@ -268,19 +268,19 @@  discard block
 block discarded – undo
268 268
         $notices = array();
269 269
     }
270 270
 
271
-    if ( $analytics === 'ga' && ! isset( $notices ['monsterinsights_deprecated_ga' ] ) ){
271
+    if ( $analytics === 'ga' && ! isset( $notices ['monsterinsights_deprecated_ga'] ) ) {
272 272
        echo '<div class="notice notice-error is-dismissible monsterinsights-notice" data-notice="monsterinsights_deprecated_ga">';
273 273
             echo '<p>';
274
-            echo sprintf( esc_html__( 'Warning: You\'re currently using deprecated ga.js tracking which we will be removing support for in an upcoming release. We recommend switching to analytics.js, as it is significantly more accurate than ga.js, and allows for functionality (like the more accurate Javascript based events tracking we offer). Further Google Analytics has deprecated support for ga.js, and it may stop working at any time when Google decides to disable it from their server. To switch to using the newer Universal Analytics (analytics.js) %1$sclick here%2$s. Users who do not manually switch over will be automatically switched over in an upcoming release.', 'google-analytics-for-wordpress' ), '<a href="' . $url .'">', '</a>' ); 
274
+            echo sprintf( esc_html__( 'Warning: You\'re currently using deprecated ga.js tracking which we will be removing support for in an upcoming release. We recommend switching to analytics.js, as it is significantly more accurate than ga.js, and allows for functionality (like the more accurate Javascript based events tracking we offer). Further Google Analytics has deprecated support for ga.js, and it may stop working at any time when Google decides to disable it from their server. To switch to using the newer Universal Analytics (analytics.js) %1$sclick here%2$s. Users who do not manually switch over will be automatically switched over in an upcoming release.', 'google-analytics-for-wordpress' ), '<a href="' . $url . '">', '</a>' ); 
275 275
             echo '</p>';
276 276
         echo '</div>';
277
-    } else if ( $events === 'php' && ! isset( $notices ['monsterinsights_deprecated_php' ] ) ){
277
+    } else if ( $events === 'php' && ! isset( $notices ['monsterinsights_deprecated_php'] ) ) {
278 278
        echo '<div class="notice notice-error is-dismissible monsterinsights-notice" data-notice="monsterinsights_deprecated_php">';
279 279
             echo '<p>';
280
-            echo sprintf( esc_html__( 'Warning: You\'re currently using deprecated PHP based events tracking which we will be removing support for in an upcoming release. We recommend switching to JS events tracking, as it is significantly more accurate than PHP based events tracking. To switch %1$sclick here%2$s. Users who do not manually switch over will be automatically switched over in an upcoming release.', 'google-analytics-for-wordpress' ), '<a href="' . $url .'">', '</a>' ); 
280
+            echo sprintf( esc_html__( 'Warning: You\'re currently using deprecated PHP based events tracking which we will be removing support for in an upcoming release. We recommend switching to JS events tracking, as it is significantly more accurate than PHP based events tracking. To switch %1$sclick here%2$s. Users who do not manually switch over will be automatically switched over in an upcoming release.', 'google-analytics-for-wordpress' ), '<a href="' . $url . '">', '</a>' ); 
281 281
             echo '</p>';
282 282
         echo '</div>';
283
-    } else if ( empty( $updates) && ! isset( $notices ['monsterinsights_automatic_updates' ] ) ){ 
283
+    } else if ( empty( $updates ) && ! isset( $notices ['monsterinsights_automatic_updates'] ) ) { 
284 284
         if ( defined( 'MONSTERINSIGHTS_SHOWING_EMPTY_CONFIG_NOTICE' ) && MONSTERINSIGHTS_SHOWING_EMPTY_CONFIG_NOTICE ) {
285 285
             return;
286 286
         }
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
         }
290 290
         echo '<div class="notice notice-info is-dismissible monsterinsights-notice" data-notice="monsterinsights_automatic_updates">';
291 291
             echo '<p>';
292
-            echo sprintf( esc_html__( 'Important: Please %1$sconfigure the Automatic Updates Settings%2$s in MonsterInsights.', 'google-analytics-for-wordpress' ), '<a href="' . $url .'">', '</a>' ); 
292
+            echo sprintf( esc_html__( 'Important: Please %1$sconfigure the Automatic Updates Settings%2$s in MonsterInsights.', 'google-analytics-for-wordpress' ), '<a href="' . $url . '">', '</a>' ); 
293 293
             echo '</p>';
294 294
         echo '</div>';
295 295
     }
Please login to merge, or discard this patch.
Braces   +7 added lines, -5 removed lines patch added patch discarded remove patch
@@ -224,9 +224,11 @@  discard block
 block discarded – undo
224 224
     }
225 225
 
226 226
     $upgrade = get_option( 'monsterinsights_version_upgraded_from' );
227
-    if( ! $upgrade ) { // First time install
227
+    if( ! $upgrade ) {
228
+// First time install
228 229
         //wp_safe_redirect( admin_url( 'admin.php?page=monsterinsights_settings#monsterinsights-main-tab-general' ) ); exit;
229
-    } else { // Update
230
+    } else {
231
+// Update
230 232
         return;
231 233
         //wp_safe_redirect( admin_url( 'admin.php?page=monsterinsights_settings#monsterinsights-main-tab-general' ) ); exit;
232 234
     }
@@ -268,19 +270,19 @@  discard block
 block discarded – undo
268 270
         $notices = array();
269 271
     }
270 272
 
271
-    if ( $analytics === 'ga' && ! isset( $notices ['monsterinsights_deprecated_ga' ] ) ){
273
+    if ( $analytics === 'ga' && ! isset( $notices ['monsterinsights_deprecated_ga' ] ) ) {
272 274
        echo '<div class="notice notice-error is-dismissible monsterinsights-notice" data-notice="monsterinsights_deprecated_ga">';
273 275
             echo '<p>';
274 276
             echo sprintf( esc_html__( 'Warning: You\'re currently using deprecated ga.js tracking which we will be removing support for in an upcoming release. We recommend switching to analytics.js, as it is significantly more accurate than ga.js, and allows for functionality (like the more accurate Javascript based events tracking we offer). Further Google Analytics has deprecated support for ga.js, and it may stop working at any time when Google decides to disable it from their server. To switch to using the newer Universal Analytics (analytics.js) %1$sclick here%2$s. Users who do not manually switch over will be automatically switched over in an upcoming release.', 'google-analytics-for-wordpress' ), '<a href="' . $url .'">', '</a>' ); 
275 277
             echo '</p>';
276 278
         echo '</div>';
277
-    } else if ( $events === 'php' && ! isset( $notices ['monsterinsights_deprecated_php' ] ) ){
279
+    } else if ( $events === 'php' && ! isset( $notices ['monsterinsights_deprecated_php' ] ) ) {
278 280
        echo '<div class="notice notice-error is-dismissible monsterinsights-notice" data-notice="monsterinsights_deprecated_php">';
279 281
             echo '<p>';
280 282
             echo sprintf( esc_html__( 'Warning: You\'re currently using deprecated PHP based events tracking which we will be removing support for in an upcoming release. We recommend switching to JS events tracking, as it is significantly more accurate than PHP based events tracking. To switch %1$sclick here%2$s. Users who do not manually switch over will be automatically switched over in an upcoming release.', 'google-analytics-for-wordpress' ), '<a href="' . $url .'">', '</a>' ); 
281 283
             echo '</p>';
282 284
         echo '</div>';
283
-    } else if ( empty( $updates) && ! isset( $notices ['monsterinsights_automatic_updates' ] ) ){ 
285
+    } else if ( empty( $updates) && ! isset( $notices ['monsterinsights_automatic_updates' ] ) ) {
284 286
         if ( defined( 'MONSTERINSIGHTS_SHOWING_EMPTY_CONFIG_NOTICE' ) && MONSTERINSIGHTS_SHOWING_EMPTY_CONFIG_NOTICE ) {
285 287
             return;
286 288
         }
Please login to merge, or discard this patch.
includes/admin/tracking.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 		add_action( 'monsterinsights_settings_save_general_end', array( $this, 'check_for_settings_optin' ) );
41 41
 		add_action( 'admin_head', array( $this, 'check_for_optin' ) );
42 42
 		add_action( 'admin_head', array( $this, 'check_for_optout' ) );
43
-		add_action( 'admin_notices', array( $this, 'monsterinsights_admin_notice' ),7 );
43
+		add_action( 'admin_notices', array( $this, 'monsterinsights_admin_notice' ), 7 );
44 44
 		add_filter( 'cron_schedules', array( $this, 'add_schedules' ) );
45 45
 		add_action( 'monsterinsights_daily_cron', array( $this, 'send_checkin' ) );
46 46
 	}
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 		$data['autoupdate']    = $update_mode;
101 101
 
102 102
 		// Retrieve current plugin information
103
-		if( ! function_exists( 'get_plugins' ) ) {
103
+		if ( ! function_exists( 'get_plugins' ) ) {
104 104
 			include ABSPATH . '/wp-admin/includes/plugin.php';
105 105
 		}
106 106
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 		foreach ( $plugins as $key => $plugin ) {
111 111
 			if ( in_array( $plugin, $active_plugins ) ) {
112 112
 				// Remove active plugins from list so we can show active and inactive separately
113
-				unset( $plugins[ $key ] );
113
+				unset( $plugins[$key] );
114 114
 			}
115 115
 		}
116 116
 
@@ -130,21 +130,21 @@  discard block
 block discarded – undo
130 130
 	public function send_checkin( $override = false, $ignore_last_checkin = false ) {
131 131
 
132 132
 		$home_url = trailingslashit( home_url() );
133
-		if ( $home_url === 'https://www.monsterinsights.com/'     || 
134
-			 $home_url === 'https://beta.monsterinsights.com/'    ||
133
+		if ( $home_url === 'https://www.monsterinsights.com/' || 
134
+			 $home_url === 'https://beta.monsterinsights.com/' ||
135 135
 			 $home_url === 'https://staging.monsterinsights.com/' ||
136 136
 			 $home_url === 'https://testing.monsterinsights.com/'
137 137
 		) {
138 138
 			return false;
139 139
 		}
140 140
 
141
-		if( ! $this->tracking_allowed() && ! $override ) {
141
+		if ( ! $this->tracking_allowed() && ! $override ) {
142 142
 			return false;
143 143
 		}
144 144
 
145 145
 		// Send a maximum of once per week
146 146
 		$last_send = $this->get_last_send();
147
-		if( is_numeric( $last_send ) && $last_send > strtotime( '-1 week' ) && ! $ignore_last_checkin ) {
147
+		if ( is_numeric( $last_send ) && $last_send > strtotime( '-1 week' ) && ! $ignore_last_checkin ) {
148 148
 			return false;
149 149
 		}
150 150
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 			'user-agent'  => 'MI/' . MONSTERINSIGHTS_VERSION . '; ' . get_bloginfo( 'url' )
161 161
 		) );
162 162
 
163
-		if( is_wp_error( $request ) ) {
163
+		if ( is_wp_error( $request ) ) {
164 164
 			return $request;
165 165
 		}
166 166
 
@@ -289,9 +289,9 @@  discard block
 block discarded – undo
289 289
 		}
290 290
 		
291 291
 		if (
292
-			stristr( network_site_url( '/' ), 'dev'       ) !== false ||
292
+			stristr( network_site_url( '/' ), 'dev' ) !== false ||
293 293
 			stristr( network_site_url( '/' ), 'localhost' ) !== false ||
294
-			stristr( network_site_url( '/' ), ':8888'     ) !== false // This is common with MAMP on OS X
294
+			stristr( network_site_url( '/' ), ':8888' ) !== false // This is common with MAMP on OS X
295 295
 		) {
296 296
 			update_option( 'monsterinsights_tracking_notice', '1' );
297 297
 		} else {
Please login to merge, or discard this patch.
includes/admin/notice.php 2 patches
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -36,11 +36,11 @@  discard block
 block discarded – undo
36 36
      */
37 37
     public function __construct() {
38 38
 
39
-        // Populate $notices
40
-        $this->notices = get_option( 'monsterinsights_notices' );
41
-        if ( ! is_array( $this->notices ) ) {
42
-            $this->notices = array();
43
-        }
39
+	// Populate $notices
40
+	$this->notices = get_option( 'monsterinsights_notices' );
41
+	if ( ! is_array( $this->notices ) ) {
42
+	    $this->notices = array();
43
+	}
44 44
 
45 45
     }
46 46
 
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
      */
56 56
 
57 57
     public function is_dismissed( $notice ) {
58
-        if ( ! isset( $this->notices[ $notice ] ) ) {
59
-            return false;
60
-        }
61
-        return true;
58
+	if ( ! isset( $this->notices[ $notice ] ) ) {
59
+	    return false;
60
+	}
61
+	return true;
62 62
 
63 63
     }
64 64
 
@@ -72,8 +72,8 @@  discard block
 block discarded – undo
72 72
      * @return null
73 73
      */
74 74
     public function dismiss( $notice ) {
75
-        $this->notices[ $notice ] = true;
76
-        update_option( 'monsterinsights_notices', $this->notices );
75
+	$this->notices[ $notice ] = true;
76
+	update_option( 'monsterinsights_notices', $this->notices );
77 77
 
78 78
     }
79 79
 
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
      * @return null
89 89
      */
90 90
     public function undismiss( $notice ) {
91
-        unset( $this->notices[ $notice ] );
92
-        update_option( 'monsterinsights_notices', $this->notices );
91
+	unset( $this->notices[ $notice ] );
92
+	update_option( 'monsterinsights_notices', $this->notices );
93 93
 
94 94
     }
95 95
 
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
      * @param bool      $is_dismissible     User can Dismiss Message (default: false)
109 109
      */ 
110 110
     public function display_inline_notice( $name, $title, $message, $type = 'success', $is_dismissible = false, $args = array() ) {
111
-        /* Available/Planned $args options
111
+	/* Available/Planned $args options
112 112
          * $args = array(
113 113
          *  'primary'    => array(
114 114
          *      'text'   => '',
@@ -127,110 +127,110 @@  discard block
 block discarded – undo
127 127
          */
128 128
 
129 129
 
130
-        // Check if the notice is dismissible, and if so has been dismissed.
131
-        if ( $is_dismissible && $this->is_dismissed( $name ) ) {
132
-            // Nothing to show here, return!
133
-            return '';
134
-        }
130
+	// Check if the notice is dismissible, and if so has been dismissed.
131
+	if ( $is_dismissible && $this->is_dismissed( $name ) ) {
132
+	    // Nothing to show here, return!
133
+	    return '';
134
+	}
135 135
 
136
-        $dismissible = ( $is_dismissible ) ? ' is-dismissible': '';
136
+	$dismissible = ( $is_dismissible ) ? ' is-dismissible': '';
137 137
 
138
-        // Display inline notice
139
-        ob_start();
140
-        ?>
138
+	// Display inline notice
139
+	ob_start();
140
+	?>
141 141
         <div class="monsterinsights-notice <?php echo 'monsterinsights-' . esc_attr( $type ) . '-notice' . $dismissible; ?>" data-notice="<?php echo esc_attr( $name ); ?>">
142 142
             <div class="monsterinsights-notice-icon <?php echo 'monsterinsights-' . esc_attr( $type ) . '-notice-icon'?>">
143 143
             </div>
144 144
             <div class="monsterinsights-notice-text <?php echo 'monsterinsights-' . esc_attr( $type ) . '-notice-text'?>">
145 145
                 <?php
146
-                // Title
147
-                if ( ! empty ( $title ) ) {
148
-                    ?>
146
+		// Title
147
+		if ( ! empty ( $title ) ) {
148
+		    ?>
149 149
                     <p class="monsterinsights-notice-title"><?php echo esc_html( $title ); ?></p>
150 150
                     <?php
151
-                }
151
+		}
152 152
 
153
-                // Message
154
-                if ( ! empty( $message ) ) {
155
-                    if ( empty( $args['skip_message_escape'] ) ) {
156
-                        ?>
153
+		// Message
154
+		if ( ! empty( $message ) ) {
155
+		    if ( empty( $args['skip_message_escape'] ) ) {
156
+			?>
157 157
                         <p class="monsterinsights-notice-message"><?php echo esc_html( $message ); ?></p>
158 158
                         <?php
159
-                    } else {
160
-                        ?>
159
+		    } else {
160
+			?>
161 161
                         <p class="monsterinsights-notice-message"><?php echo $message; ?></p>
162 162
                         <?php
163
-                    }
164
-                }
163
+		    }
164
+		}
165 165
                 
166
-                // Primary Button
167
-                if ( ! empty( $args['primary']['text'] ) ) {
166
+		// Primary Button
167
+		if ( ! empty( $args['primary']['text'] ) ) {
168 168
                     
169
-                    $text = '';
170
-                    if ( ! empty( $args['primary']['text'] ) ) {
171
-                        $text = $args['primary']['text'];
172
-                    }
173
-
174
-                    $url = '#';
175
-                    if ( ! empty( $args['primary']['url'] ) ) {
176
-                        $url = $args['primary']['url'];
177
-                    }
178
-
179
-                    $target = '';
180
-                    if ( ! empty( $args['primary']['target'] ) && $args['primary']['target'] === 'blank') {
181
-                        $target = ' target="_blank" rel="noopener noreferrer"';
182
-                    }
183
-
184
-                    $class = 'button button-primary';
185
-                    if ( ! empty( $args['primary']['class'] ) ) {
186
-                        $class = ' class="'. $args['primary']['class'] . '"';
187
-                    }
188
-                    ?>
169
+		    $text = '';
170
+		    if ( ! empty( $args['primary']['text'] ) ) {
171
+			$text = $args['primary']['text'];
172
+		    }
173
+
174
+		    $url = '#';
175
+		    if ( ! empty( $args['primary']['url'] ) ) {
176
+			$url = $args['primary']['url'];
177
+		    }
178
+
179
+		    $target = '';
180
+		    if ( ! empty( $args['primary']['target'] ) && $args['primary']['target'] === 'blank') {
181
+			$target = ' target="_blank" rel="noopener noreferrer"';
182
+		    }
183
+
184
+		    $class = 'button button-primary';
185
+		    if ( ! empty( $args['primary']['class'] ) ) {
186
+			$class = ' class="'. $args['primary']['class'] . '"';
187
+		    }
188
+		    ?>
189 189
                     <a href="<?php echo esc_attr( $url ); ?>"<?php echo $target; ?><?php echo $class;?>><?php echo esc_html( $text ); ?></a>
190 190
                     <?php
191
-                }
191
+		}
192 192
 
193
-                // Secondary Button
194
-                if ( ! empty( $args['secondary']['text'] ) ) {
193
+		// Secondary Button
194
+		if ( ! empty( $args['secondary']['text'] ) ) {
195 195
                     
196
-                    $text = '';
197
-                    if ( ! empty( $args['secondary']['text'] ) ) {
198
-                        $text = $args['secondary']['text'];
199
-                    }
200
-
201
-                    $url = '#';
202
-                    if ( ! empty( $args['secondary']['url'] ) ) {
203
-                        $url = $args['secondary']['url'];
204
-                    }           
205
-
206
-                    $target = '';
207
-                    if ( ! empty( $args['secondary']['target'] ) && $args['secondary']['target'] === 'blank') {
208
-                        $target = ' target="_blank" rel="noopener noreferrer"';
209
-                    }
210
-
211
-                    $class = 'button button-secondary';
212
-                    if ( ! empty( $args['secondary']['class'] ) ) {
213
-                        $class = ' class="'. $args['secondary']['class'] . '"';
214
-                    }
215
-                    ?>
196
+		    $text = '';
197
+		    if ( ! empty( $args['secondary']['text'] ) ) {
198
+			$text = $args['secondary']['text'];
199
+		    }
200
+
201
+		    $url = '#';
202
+		    if ( ! empty( $args['secondary']['url'] ) ) {
203
+			$url = $args['secondary']['url'];
204
+		    }           
205
+
206
+		    $target = '';
207
+		    if ( ! empty( $args['secondary']['target'] ) && $args['secondary']['target'] === 'blank') {
208
+			$target = ' target="_blank" rel="noopener noreferrer"';
209
+		    }
210
+
211
+		    $class = 'button button-secondary';
212
+		    if ( ! empty( $args['secondary']['class'] ) ) {
213
+			$class = ' class="'. $args['secondary']['class'] . '"';
214
+		    }
215
+		    ?>
216 216
                     <a href="<?php echo esc_attr( $url ); ?>"<?php echo $target; ?><?php echo $class;?>><?php echo esc_html( $text ); ?></a>
217 217
                     <?php
218
-                }
218
+		}
219 219
 
220
-                // Dismiss Button
221
-                if ( $is_dismissible ) {
222
-                    ?>
220
+		// Dismiss Button
221
+		if ( $is_dismissible ) {
222
+		    ?>
223 223
                     <button type="button" class="notice-dismiss<?php echo $dismissible; ?>">
224 224
                         <span class="screen-reader-text">
225 225
                             <?php esc_html_e( 'Dismiss this notice', 'google-analytics-for-wordpress' ); ?>
226 226
                         </span>
227 227
                     </button>
228 228
                     <?php
229
-                }
230
-                ?>
229
+		}
230
+		?>
231 231
             </div>
232 232
         </div>
233 233
         <?php
234
-        return ob_get_clean();
234
+	return ob_get_clean();
235 235
     }
236 236
 }
237 237
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
      */
56 56
 
57 57
     public function is_dismissed( $notice ) {
58
-        if ( ! isset( $this->notices[ $notice ] ) ) {
58
+        if ( ! isset( $this->notices[$notice] ) ) {
59 59
             return false;
60 60
         }
61 61
         return true;
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
      * @return null
73 73
      */
74 74
     public function dismiss( $notice ) {
75
-        $this->notices[ $notice ] = true;
75
+        $this->notices[$notice] = true;
76 76
         update_option( 'monsterinsights_notices', $this->notices );
77 77
 
78 78
     }
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
      * @return null
89 89
      */
90 90
     public function undismiss( $notice ) {
91
-        unset( $this->notices[ $notice ] );
91
+        unset( $this->notices[$notice] );
92 92
         update_option( 'monsterinsights_notices', $this->notices );
93 93
 
94 94
     }
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
             return '';
134 134
         }
135 135
 
136
-        $dismissible = ( $is_dismissible ) ? ' is-dismissible': '';
136
+        $dismissible = ( $is_dismissible ) ? ' is-dismissible' : '';
137 137
 
138 138
         // Display inline notice
139 139
         ob_start();
@@ -177,16 +177,16 @@  discard block
 block discarded – undo
177 177
                     }
178 178
 
179 179
                     $target = '';
180
-                    if ( ! empty( $args['primary']['target'] ) && $args['primary']['target'] === 'blank') {
180
+                    if ( ! empty( $args['primary']['target'] ) && $args['primary']['target'] === 'blank' ) {
181 181
                         $target = ' target="_blank" rel="noopener noreferrer"';
182 182
                     }
183 183
 
184 184
                     $class = 'button button-primary';
185 185
                     if ( ! empty( $args['primary']['class'] ) ) {
186
-                        $class = ' class="'. $args['primary']['class'] . '"';
186
+                        $class = ' class="' . $args['primary']['class'] . '"';
187 187
                     }
188 188
                     ?>
189
-                    <a href="<?php echo esc_attr( $url ); ?>"<?php echo $target; ?><?php echo $class;?>><?php echo esc_html( $text ); ?></a>
189
+                    <a href="<?php echo esc_attr( $url ); ?>"<?php echo $target; ?><?php echo $class; ?>><?php echo esc_html( $text ); ?></a>
190 190
                     <?php
191 191
                 }
192 192
 
@@ -204,16 +204,16 @@  discard block
 block discarded – undo
204 204
                     }           
205 205
 
206 206
                     $target = '';
207
-                    if ( ! empty( $args['secondary']['target'] ) && $args['secondary']['target'] === 'blank') {
207
+                    if ( ! empty( $args['secondary']['target'] ) && $args['secondary']['target'] === 'blank' ) {
208 208
                         $target = ' target="_blank" rel="noopener noreferrer"';
209 209
                     }
210 210
 
211 211
                     $class = 'button button-secondary';
212 212
                     if ( ! empty( $args['secondary']['class'] ) ) {
213
-                        $class = ' class="'. $args['secondary']['class'] . '"';
213
+                        $class = ' class="' . $args['secondary']['class'] . '"';
214 214
                     }
215 215
                     ?>
216
-                    <a href="<?php echo esc_attr( $url ); ?>"<?php echo $target; ?><?php echo $class;?>><?php echo esc_html( $text ); ?></a>
216
+                    <a href="<?php echo esc_attr( $url ); ?>"<?php echo $target; ?><?php echo $class; ?>><?php echo esc_html( $text ); ?></a>
217 217
                     <?php
218 218
                 }
219 219
 
Please login to merge, or discard this patch.
includes/admin/abstract-report.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@
 block discarded – undo
56 56
 
57 57
 	 // Adds the report to the array of reports.
58 58
 	public function add_report( $reports ) {
59
-		$reports[ $this->report_hook ] = $this->report_name;
59
+		$reports[$this->report_hook] = $this->report_name;
60 60
 		return $reports;
61 61
 	}
62 62
 
Please login to merge, or discard this patch.
includes/admin/licensing/skin.php 2 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
      */
26 26
     public function __construct( $args = array() ) {
27 27
 
28
-        parent::__construct();
28
+	parent::__construct();
29 29
 
30 30
     }
31 31
 
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
      */
39 39
     public function set_upgrader( &$upgrader ) {
40 40
 
41
-        if ( is_object( $upgrader ) ) {
42
-            $this->upgrader =& $upgrader;
43
-        }
41
+	if ( is_object( $upgrader ) ) {
42
+	    $this->upgrader =& $upgrader;
43
+	}
44 44
 
45 45
     }
46 46
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
      */
54 54
     public function set_result( $result ) {
55 55
 
56
-        $this->result = $result;
56
+	$this->result = $result;
57 57
 
58 58
     }
59 59
 
@@ -82,10 +82,10 @@  discard block
 block discarded – undo
82 82
      */
83 83
     function error( $errors ) {
84 84
 
85
-        if ( ! empty( $errors ) ) {
86
-            echo json_encode( array( 'error' => esc_html__( 'There was an error installing the addon. Please try again.', 'google-analytics-for-wordpress' ) ) );
87
-            die;
88
-        }
85
+	if ( ! empty( $errors ) ) {
86
+	    echo json_encode( array( 'error' => esc_html__( 'There was an error installing the addon. Please try again.', 'google-analytics-for-wordpress' ) ) );
87
+	    die;
88
+	}
89 89
 
90 90
     }
91 91
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
     public function set_upgrader( &$upgrader ) {
40 40
 
41 41
         if ( is_object( $upgrader ) ) {
42
-            $this->upgrader =& $upgrader;
42
+            $this->upgrader = & $upgrader;
43 43
         }
44 44
 
45 45
     }
Please login to merge, or discard this patch.
includes/admin/licensing/updater.php 2 patches
Indentation   +178 added lines, -178 removed lines patch added patch discarded remove patch
@@ -115,37 +115,37 @@  discard block
 block discarded – undo
115 115
      */
116 116
     public function __construct( array $config ) {
117 117
 
118
-        // Load the base class object.
119
-        $this->base = MonsterInsights();
120
-
121
-        // Set class properties.
122
-        $accepted_args = array(
123
-            'plugin_name',
124
-            'plugin_slug',
125
-            'plugin_path',
126
-            'plugin_url',
127
-            'remote_url',
128
-            'version',
129
-            'key'
130
-        );
131
-        foreach ( $accepted_args as $arg ) {
132
-            $this->$arg = $config[$arg];
133
-        }
134
-
135
-        // If the user cannot update plugins, stop processing here.
136
-        if ( ! current_user_can( 'update_plugins' ) && ( ! defined( 'DOING_CRON' ) || ! DOING_CRON ) ) {
137
-            return;
138
-        }
139
-
140
-        // Load the updater hooks and filters.
141
-        add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'update_plugins_filter' ) );
142
-
143
-        add_filter( 'http_request_args', array( $this, 'http_request_args' ), 10, 2 );
144
-        add_filter( 'plugins_api', array( $this, 'plugins_api' ), 10, 3 );
145
-
146
-        // ManageWP premium update filters
147
-        //add_filter( 'mwp_premium_update_notification', array( $this, 'premium_update_push' ) );
148
-        //add_filter( 'mwp_premium_perform_update', array( $this, 'premium_update' ) );
118
+	// Load the base class object.
119
+	$this->base = MonsterInsights();
120
+
121
+	// Set class properties.
122
+	$accepted_args = array(
123
+	    'plugin_name',
124
+	    'plugin_slug',
125
+	    'plugin_path',
126
+	    'plugin_url',
127
+	    'remote_url',
128
+	    'version',
129
+	    'key'
130
+	);
131
+	foreach ( $accepted_args as $arg ) {
132
+	    $this->$arg = $config[$arg];
133
+	}
134
+
135
+	// If the user cannot update plugins, stop processing here.
136
+	if ( ! current_user_can( 'update_plugins' ) && ( ! defined( 'DOING_CRON' ) || ! DOING_CRON ) ) {
137
+	    return;
138
+	}
139
+
140
+	// Load the updater hooks and filters.
141
+	add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'update_plugins_filter' ) );
142
+
143
+	add_filter( 'http_request_args', array( $this, 'http_request_args' ), 10, 2 );
144
+	add_filter( 'plugins_api', array( $this, 'plugins_api' ), 10, 3 );
145
+
146
+	// ManageWP premium update filters
147
+	//add_filter( 'mwp_premium_update_notification', array( $this, 'premium_update_push' ) );
148
+	//add_filter( 'mwp_premium_perform_update', array( $this, 'premium_update' ) );
149 149
     }
150 150
 
151 151
     /**
@@ -158,33 +158,33 @@  discard block
 block discarded – undo
158 158
      */
159 159
     public function update_plugins_filter( $value ) {
160 160
 
161
-        // If no update object exists, return early.
162
-        if ( empty( $value ) ) {
163
-            return $value;
164
-        }
165
-
166
-        // Run update check by pinging the external API. If it fails, return the default update object.
167
-        if ( ! $this->update ) {
168
-            $this->update = $this->perform_remote_request( 'get-plugin-update', array( 'tgm-updater-plugin' => $this->plugin_slug ) );
169
-            if ( ! $this->update || ! empty( $this->update->error ) ) {
170
-                $this->update = false;
171
-                return $value;
172
-            }
173
-        }
174
-
175
-        // Infuse the update object with our data if the version from the remote API is newer.
176
-        if ( isset( $this->update->new_version ) && version_compare( $this->version, $this->update->new_version, '<' ) ) {
177
-            // The $plugin_update object contains new_version, package, slug and last_update keys.
178
-            //$this->update->full_slug             = $this->plugin_slug;
179
-            //$this->update->name                  = $this->plugin_name;
180
-            $this->update->monsterinsights_plugin  = true;
181
-            $this->update->old_version             = $this->version;
182
-            $this->update->plugin                  = $this->plugin_path;
183
-            $value->response[$this->plugin_path]   = $this->update;
184
-        }
185
-
186
-        // Return the update object.
187
-        return $value;
161
+	// If no update object exists, return early.
162
+	if ( empty( $value ) ) {
163
+	    return $value;
164
+	}
165
+
166
+	// Run update check by pinging the external API. If it fails, return the default update object.
167
+	if ( ! $this->update ) {
168
+	    $this->update = $this->perform_remote_request( 'get-plugin-update', array( 'tgm-updater-plugin' => $this->plugin_slug ) );
169
+	    if ( ! $this->update || ! empty( $this->update->error ) ) {
170
+		$this->update = false;
171
+		return $value;
172
+	    }
173
+	}
174
+
175
+	// Infuse the update object with our data if the version from the remote API is newer.
176
+	if ( isset( $this->update->new_version ) && version_compare( $this->version, $this->update->new_version, '<' ) ) {
177
+	    // The $plugin_update object contains new_version, package, slug and last_update keys.
178
+	    //$this->update->full_slug             = $this->plugin_slug;
179
+	    //$this->update->name                  = $this->plugin_name;
180
+	    $this->update->monsterinsights_plugin  = true;
181
+	    $this->update->old_version             = $this->version;
182
+	    $this->update->plugin                  = $this->plugin_path;
183
+	    $value->response[$this->plugin_path]   = $this->update;
184
+	}
185
+
186
+	// Return the update object.
187
+	return $value;
188 188
 
189 189
     }
190 190
 
@@ -199,12 +199,12 @@  discard block
 block discarded – undo
199 199
      */
200 200
     public function http_request_args( $args, $url ) {
201 201
 
202
-        // If this is an SSL request and we are performing an upgrade routine, disable SSL verification.
203
-        if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'tgm-updater-action=get-plugin-update' ) ) {
204
-            $args['sslverify'] = false;
205
-        }
202
+	// If this is an SSL request and we are performing an upgrade routine, disable SSL verification.
203
+	if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'tgm-updater-action=get-plugin-update' ) ) {
204
+	    $args['sslverify'] = false;
205
+	}
206 206
 
207
-        return $args;
207
+	return $args;
208 208
 
209 209
     }
210 210
 
@@ -221,14 +221,14 @@  discard block
 block discarded – undo
221 221
      */
222 222
     public function plugins_api( $api, $action = '', $args = null ) {
223 223
 
224
-        $plugin = ( 'plugin_information' == $action ) && isset( $args->slug ) && ( $this->plugin_slug == $args->slug );
224
+	$plugin = ( 'plugin_information' == $action ) && isset( $args->slug ) && ( $this->plugin_slug == $args->slug );
225 225
 
226
-        // If our plugin matches the request, set our own plugin data, else return the default response.
227
-        if ( $plugin ) {
228
-            return $this->set_plugins_api( $api );
229
-        } else {
230
-            return $api;
231
-        }
226
+	// If our plugin matches the request, set our own plugin data, else return the default response.
227
+	if ( $plugin ) {
228
+	    return $this->set_plugins_api( $api );
229
+	} else {
230
+	    return $api;
231
+	}
232 232
 
233 233
     }
234 234
 
@@ -242,82 +242,82 @@  discard block
 block discarded – undo
242 242
      */
243 243
     public function set_plugins_api( $default_api ) {
244 244
 
245
-        // Perform the remote request to retrieve our plugin information. If it fails, return the default object.
246
-        if ( ! $this->info ) {
247
-            $this->info = $this->perform_remote_request( 'get-plugin-info', array( 'tgm-updater-plugin' => $this->plugin_slug ) );
248
-            if ( ! $this->info || ! empty( $this->info->error ) ) {
249
-                $this->info = false;
250
-                return $default_api;
251
-            }
252
-        }
253
-
254
-        // Create a new stdClass object and populate it with our plugin information.
255
-        $api                        = new stdClass;
256
-        $api->name                  = isset( $this->info->name )           ? $this->info->name           : '';
257
-        $api->slug                  = isset( $this->info->slug )           ? $this->info->slug           : '';
258
-        $api->version               = isset( $this->info->version )        ? $this->info->version        : '';
259
-        $api->author                = isset( $this->info->author )         ? $this->info->author         : '';
260
-        $api->author_profile        = isset( $this->info->author_profile ) ? $this->info->author_profile : '';
261
-        $api->requires              = isset( $this->info->requires )       ? $this->info->requires       : '';
262
-        $api->tested                = isset( $this->info->tested )         ? $this->info->tested         : '';
263
-        $api->last_updated          = isset( $this->info->last_updated )   ? $this->info->last_updated   : '';
264
-        $api->homepage              = isset( $this->info->homepage )       ? $this->info->homepage       : '';
265
-
266
-        $changelog                  = isset( $this->info->changelog )      ? $this->info->changelog       : '';
267
-        $description                = isset( $this->info->description )    ? $this->info->description     : '';
268
-
269
-        if ( ! empty( $changelog ) ) {
270
-             if ( ! empty( $description ) ) {
271
-                $api->sections['description'] = $description;
272
-                $api->sections['changelog']   = $changelog;
273
-             } else {
274
-                $api->sections['changelog']   = $changelog;
275
-             }
276
-        } else if ( ! empty( $description ) ) {
277
-            $api->sections['description'] = $description;
278
-        } else {
279
-            $api->sections = array();
280
-        }     
281
-
282
-        $api->download_link         = isset( $this->info->download_link )  ? $this->info->download_link  : '';
283
-
284
-        // Return the new API object with our custom data.
285
-        return $api;
245
+	// Perform the remote request to retrieve our plugin information. If it fails, return the default object.
246
+	if ( ! $this->info ) {
247
+	    $this->info = $this->perform_remote_request( 'get-plugin-info', array( 'tgm-updater-plugin' => $this->plugin_slug ) );
248
+	    if ( ! $this->info || ! empty( $this->info->error ) ) {
249
+		$this->info = false;
250
+		return $default_api;
251
+	    }
252
+	}
253
+
254
+	// Create a new stdClass object and populate it with our plugin information.
255
+	$api                        = new stdClass;
256
+	$api->name                  = isset( $this->info->name )           ? $this->info->name           : '';
257
+	$api->slug                  = isset( $this->info->slug )           ? $this->info->slug           : '';
258
+	$api->version               = isset( $this->info->version )        ? $this->info->version        : '';
259
+	$api->author                = isset( $this->info->author )         ? $this->info->author         : '';
260
+	$api->author_profile        = isset( $this->info->author_profile ) ? $this->info->author_profile : '';
261
+	$api->requires              = isset( $this->info->requires )       ? $this->info->requires       : '';
262
+	$api->tested                = isset( $this->info->tested )         ? $this->info->tested         : '';
263
+	$api->last_updated          = isset( $this->info->last_updated )   ? $this->info->last_updated   : '';
264
+	$api->homepage              = isset( $this->info->homepage )       ? $this->info->homepage       : '';
265
+
266
+	$changelog                  = isset( $this->info->changelog )      ? $this->info->changelog       : '';
267
+	$description                = isset( $this->info->description )    ? $this->info->description     : '';
268
+
269
+	if ( ! empty( $changelog ) ) {
270
+	     if ( ! empty( $description ) ) {
271
+		$api->sections['description'] = $description;
272
+		$api->sections['changelog']   = $changelog;
273
+	     } else {
274
+		$api->sections['changelog']   = $changelog;
275
+	     }
276
+	} else if ( ! empty( $description ) ) {
277
+	    $api->sections['description'] = $description;
278
+	} else {
279
+	    $api->sections = array();
280
+	}     
281
+
282
+	$api->download_link         = isset( $this->info->download_link )  ? $this->info->download_link  : '';
283
+
284
+	// Return the new API object with our custom data.
285
+	return $api;
286 286
 
287 287
     }
288 288
 
289 289
     // Integration with ManageWP
290 290
     public function premium_update_push( $premium_update ) {
291
-        if ( ! function_exists( 'get_plugin_data' ) ) {
292
-            include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
293
-        }
294
-
295
-        $update = $this->set_plugins_api( array() );
296
-        if ( ! empty( $update ) && version_compare( MONSTERINSIGHTS_VERSION, $update->version, '<' ) ) {
297
-            $plugin_data                = get_plugin_data( $update->slug );
298
-            $plugin_data['type']        = 'plugin';
299
-            $plugin_data['slug']        = $update->slug;
300
-            $plugin_data['new_version'] = $update->version;
301
-            $premium_update[]           = $plugin_data;
302
-        }
303
-        return $premium_update;
291
+	if ( ! function_exists( 'get_plugin_data' ) ) {
292
+	    include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
293
+	}
294
+
295
+	$update = $this->set_plugins_api( array() );
296
+	if ( ! empty( $update ) && version_compare( MONSTERINSIGHTS_VERSION, $update->version, '<' ) ) {
297
+	    $plugin_data                = get_plugin_data( $update->slug );
298
+	    $plugin_data['type']        = 'plugin';
299
+	    $plugin_data['slug']        = $update->slug;
300
+	    $plugin_data['new_version'] = $update->version;
301
+	    $premium_update[]           = $plugin_data;
302
+	}
303
+	return $premium_update;
304 304
     }
305 305
 
306 306
     // Integration with ManageWP
307 307
     public function premium_update( $premium_update ) {
308
-        if ( ! function_exists( 'get_plugin_data' ) ) {
309
-            include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
310
-        }
311
-
312
-        $update = $this->set_plugins_api( array() );
313
-        if ( ! empty( $update ) && version_compare( MONSTERINSIGHTS_VERSION, $update->version, '<' ) ) {
314
-            $plugin_data                = get_plugin_data( $update->slug );
315
-            $plugin_data['type']        = 'plugin';
316
-            $plugin_data['slug']        = $update->slug;
317
-            $plugin_data['url']         = $update->download_link; // OR provide your own callback function for managing the update
318
-            array_push( $premium_update, $plugin_data );
319
-        }
320
-        return $premium_update;
308
+	if ( ! function_exists( 'get_plugin_data' ) ) {
309
+	    include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
310
+	}
311
+
312
+	$update = $this->set_plugins_api( array() );
313
+	if ( ! empty( $update ) && version_compare( MONSTERINSIGHTS_VERSION, $update->version, '<' ) ) {
314
+	    $plugin_data                = get_plugin_data( $update->slug );
315
+	    $plugin_data['type']        = 'plugin';
316
+	    $plugin_data['slug']        = $update->slug;
317
+	    $plugin_data['url']         = $update->download_link; // OR provide your own callback function for managing the update
318
+	    array_push( $premium_update, $plugin_data );
319
+	}
320
+	return $premium_update;
321 321
     }
322 322
 
323 323
     /**
@@ -333,47 +333,47 @@  discard block
 block discarded – undo
333 333
      */
334 334
     public function perform_remote_request( $action, $body = array(), $headers = array(), $return_format = 'json' ) {
335 335
 
336
-        // Build the body of the request.
337
-        $body = wp_parse_args(
338
-            $body,
339
-            array(
340
-                'tgm-updater-action'     => $action,
341
-                'tgm-updater-key'        => $this->key,
342
-                'tgm-updater-wp-version' => get_bloginfo( 'version' ),
343
-                'tgm-updater-referer'    => site_url(),
344
-                'tgm-updater-mi-version' => MONSTERINSIGHTS_VERSION,
345
-                'tgm-updater-is-pro'     => monsterinsights_is_pro_version(),
346
-            )
347
-        );
348
-        $body = http_build_query( $body, '', '&' );
349
-
350
-        // Build the headers of the request.
351
-        $headers = wp_parse_args(
352
-            $headers,
353
-            array(
354
-                'Content-Type'   => 'application/x-www-form-urlencoded',
355
-                'Content-Length' => strlen( $body )
356
-            )
357
-        );
358
-
359
-        // Setup variable for wp_remote_post.
360
-        $post = array(
361
-            'headers' => $headers,
362
-            'body'    => $body
363
-        );
364
-
365
-        // Perform the query and retrieve the response.
366
-        $response      = wp_remote_post( esc_url_raw( $this->remote_url ), $post );
367
-        $response_code = wp_remote_retrieve_response_code( $response );
368
-        $response_body = wp_remote_retrieve_body( $response );
369
-
370
-        // Bail out early if there are any errors.
371
-        if ( 200 != $response_code || is_wp_error( $response_body ) ) {
372
-            return false;
373
-        }
374
-
375
-        // Return the json decoded content.
376
-        return json_decode( $response_body );
336
+	// Build the body of the request.
337
+	$body = wp_parse_args(
338
+	    $body,
339
+	    array(
340
+		'tgm-updater-action'     => $action,
341
+		'tgm-updater-key'        => $this->key,
342
+		'tgm-updater-wp-version' => get_bloginfo( 'version' ),
343
+		'tgm-updater-referer'    => site_url(),
344
+		'tgm-updater-mi-version' => MONSTERINSIGHTS_VERSION,
345
+		'tgm-updater-is-pro'     => monsterinsights_is_pro_version(),
346
+	    )
347
+	);
348
+	$body = http_build_query( $body, '', '&' );
349
+
350
+	// Build the headers of the request.
351
+	$headers = wp_parse_args(
352
+	    $headers,
353
+	    array(
354
+		'Content-Type'   => 'application/x-www-form-urlencoded',
355
+		'Content-Length' => strlen( $body )
356
+	    )
357
+	);
358
+
359
+	// Setup variable for wp_remote_post.
360
+	$post = array(
361
+	    'headers' => $headers,
362
+	    'body'    => $body
363
+	);
364
+
365
+	// Perform the query and retrieve the response.
366
+	$response      = wp_remote_post( esc_url_raw( $this->remote_url ), $post );
367
+	$response_code = wp_remote_retrieve_response_code( $response );
368
+	$response_body = wp_remote_retrieve_body( $response );
369
+
370
+	// Bail out early if there are any errors.
371
+	if ( 200 != $response_code || is_wp_error( $response_body ) ) {
372
+	    return false;
373
+	}
374
+
375
+	// Return the json decoded content.
376
+	return json_decode( $response_body );
377 377
 
378 378
     }
379 379
 }
380 380
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -253,18 +253,18 @@  discard block
 block discarded – undo
253 253
 
254 254
         // Create a new stdClass object and populate it with our plugin information.
255 255
         $api                        = new stdClass;
256
-        $api->name                  = isset( $this->info->name )           ? $this->info->name           : '';
257
-        $api->slug                  = isset( $this->info->slug )           ? $this->info->slug           : '';
258
-        $api->version               = isset( $this->info->version )        ? $this->info->version        : '';
259
-        $api->author                = isset( $this->info->author )         ? $this->info->author         : '';
256
+        $api->name                  = isset( $this->info->name ) ? $this->info->name : '';
257
+        $api->slug                  = isset( $this->info->slug ) ? $this->info->slug : '';
258
+        $api->version               = isset( $this->info->version ) ? $this->info->version : '';
259
+        $api->author                = isset( $this->info->author ) ? $this->info->author : '';
260 260
         $api->author_profile        = isset( $this->info->author_profile ) ? $this->info->author_profile : '';
261
-        $api->requires              = isset( $this->info->requires )       ? $this->info->requires       : '';
262
-        $api->tested                = isset( $this->info->tested )         ? $this->info->tested         : '';
263
-        $api->last_updated          = isset( $this->info->last_updated )   ? $this->info->last_updated   : '';
264
-        $api->homepage              = isset( $this->info->homepage )       ? $this->info->homepage       : '';
261
+        $api->requires              = isset( $this->info->requires ) ? $this->info->requires : '';
262
+        $api->tested                = isset( $this->info->tested ) ? $this->info->tested : '';
263
+        $api->last_updated          = isset( $this->info->last_updated ) ? $this->info->last_updated : '';
264
+        $api->homepage              = isset( $this->info->homepage ) ? $this->info->homepage : '';
265 265
 
266
-        $changelog                  = isset( $this->info->changelog )      ? $this->info->changelog       : '';
267
-        $description                = isset( $this->info->description )    ? $this->info->description     : '';
266
+        $changelog                  = isset( $this->info->changelog ) ? $this->info->changelog : '';
267
+        $description                = isset( $this->info->description ) ? $this->info->description : '';
268 268
 
269 269
         if ( ! empty( $changelog ) ) {
270 270
              if ( ! empty( $description ) ) {
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
             $api->sections = array();
280 280
         }     
281 281
 
282
-        $api->download_link         = isset( $this->info->download_link )  ? $this->info->download_link  : '';
282
+        $api->download_link = isset( $this->info->download_link ) ? $this->info->download_link : '';
283 283
 
284 284
         // Return the new API object with our custom data.
285 285
         return $api;
Please login to merge, or discard this patch.
includes/admin/licensing/license.php 3 patches
Indentation   +322 added lines, -322 removed lines patch added patch discarded remove patch
@@ -57,29 +57,29 @@  discard block
 block discarded – undo
57 57
      * @since 6.0.0
58 58
      */
59 59
     public function __construct() {
60
-        // Load the base class object.
61
-        $this->base = MonsterInsights();
62
-        add_action( 'admin_init', array( $this, 'admin_init' ) );
60
+	// Load the base class object.
61
+	$this->base = MonsterInsights();
62
+	add_action( 'admin_init', array( $this, 'admin_init' ) );
63 63
     }
64 64
     
65 65
     public function admin_init() {
66
-        // Possibly verify the key.
67
-        $this->maybe_verify_key();
68
-
69
-        // Add potential admin notices for actions around the admin.
70
-        add_action( 'admin_notices', array( $this, 'monsterinsights_notices' ) );
71
-        add_action( 'network_admin_notices', array( $this, 'monsterinsights_notices' ) );
72
-
73
-        // Grab the license key. If it is not set (even after verification), return early.
74
-        $this->key = monsterinsights_get_license_key();
75
-        if ( ! $this->key ) {
76
-            return;
77
-        }
78
-
79
-        // Possibly handle validating, deactivating and refreshing license keys.
80
-        $this->maybe_validate_key();
81
-        $this->maybe_deactivate_key();
82
-        $this->maybe_refresh_key();
66
+	// Possibly verify the key.
67
+	$this->maybe_verify_key();
68
+
69
+	// Add potential admin notices for actions around the admin.
70
+	add_action( 'admin_notices', array( $this, 'monsterinsights_notices' ) );
71
+	add_action( 'network_admin_notices', array( $this, 'monsterinsights_notices' ) );
72
+
73
+	// Grab the license key. If it is not set (even after verification), return early.
74
+	$this->key = monsterinsights_get_license_key();
75
+	if ( ! $this->key ) {
76
+	    return;
77
+	}
78
+
79
+	// Possibly handle validating, deactivating and refreshing license keys.
80
+	$this->maybe_validate_key();
81
+	$this->maybe_deactivate_key();
82
+	$this->maybe_refresh_key();
83 83
     }
84 84
 
85 85
     /**
@@ -91,15 +91,15 @@  discard block
 block discarded – undo
91 91
      */
92 92
     public function maybe_verify_key() {
93 93
         
94
-        if ( ! $this->is_verifying_key() ) {
95
-            return;
96
-        }
94
+	if ( ! $this->is_verifying_key() ) {
95
+	    return;
96
+	}
97 97
 
98
-        if ( ! $this->verify_key_action() ) {
99
-            return;
100
-        }
98
+	if ( ! $this->verify_key_action() ) {
99
+	    return;
100
+	}
101 101
 
102
-        $this->verify_key();
102
+	$this->verify_key();
103 103
 
104 104
     }
105 105
 
@@ -110,41 +110,41 @@  discard block
 block discarded – undo
110 110
      */
111 111
     public function verify_key() {
112 112
 
113
-        // Perform a request to verify the key.
114
-        $verify = $this->perform_remote_request( 'verify-key', array( 'tgm-updater-key' => trim( $_POST['monsterinsights-license-key'] ) ) );
115
-
116
-        // If it returns false, send back a generic error message and return.
117
-        if ( ! $verify ) {
118
-            $this->errors[] = esc_html__( 'There was an error connecting to the remote key API. Please try again later.', 'google-analytics-for-wordpress' );
119
-            return;
120
-        }
121
-
122
-        // If an error is returned, set the error and return.
123
-        if ( ! empty( $verify->error ) ) {
124
-            $this->errors[] = $verify->error;
125
-            return;
126
-        }
127
-
128
-        // Otherwise, our request has been done successfully. Update the option and set the success message.
129
-        if ( is_multisite() && is_network_admin() ) {
130
-            $option                = get_site_option( 'monsterinsights_license' );
131
-            $option['key']         = trim( $_POST['monsterinsights-license-key'] );
132
-            $option['type']        = isset( $verify->type ) ? $verify->type : $option['type'];
133
-            $option['is_expired']  = false;
134
-            $option['is_disabled'] = false;
135
-            $option['is_invalid']  = false;
136
-            $this->success[]       = isset( $verify->success ) ? $verify->success : esc_html__( 'Congratulations! This site is now receiving automatic updates.', 'google-analytics-for-wordpress' );
137
-            update_site_option( 'monsterinsights_license', $option );
138
-        } else {
139
-            $option                = get_option( 'monsterinsights_license' );
140
-            $option['key']         = trim( $_POST['monsterinsights-license-key'] );
141
-            $option['type']        = isset( $verify->type ) ? $verify->type : $option['type'];
142
-            $option['is_expired']  = false;
143
-            $option['is_disabled'] = false;
144
-            $option['is_invalid']  = false;
145
-            $this->success[]       = isset( $verify->success ) ? $verify->success : esc_html__( 'Congratulations! This site is now receiving automatic updates.', 'google-analytics-for-wordpress' );
146
-            update_option( 'monsterinsights_license', $option );        
147
-        }
113
+	// Perform a request to verify the key.
114
+	$verify = $this->perform_remote_request( 'verify-key', array( 'tgm-updater-key' => trim( $_POST['monsterinsights-license-key'] ) ) );
115
+
116
+	// If it returns false, send back a generic error message and return.
117
+	if ( ! $verify ) {
118
+	    $this->errors[] = esc_html__( 'There was an error connecting to the remote key API. Please try again later.', 'google-analytics-for-wordpress' );
119
+	    return;
120
+	}
121
+
122
+	// If an error is returned, set the error and return.
123
+	if ( ! empty( $verify->error ) ) {
124
+	    $this->errors[] = $verify->error;
125
+	    return;
126
+	}
127
+
128
+	// Otherwise, our request has been done successfully. Update the option and set the success message.
129
+	if ( is_multisite() && is_network_admin() ) {
130
+	    $option                = get_site_option( 'monsterinsights_license' );
131
+	    $option['key']         = trim( $_POST['monsterinsights-license-key'] );
132
+	    $option['type']        = isset( $verify->type ) ? $verify->type : $option['type'];
133
+	    $option['is_expired']  = false;
134
+	    $option['is_disabled'] = false;
135
+	    $option['is_invalid']  = false;
136
+	    $this->success[]       = isset( $verify->success ) ? $verify->success : esc_html__( 'Congratulations! This site is now receiving automatic updates.', 'google-analytics-for-wordpress' );
137
+	    update_site_option( 'monsterinsights_license', $option );
138
+	} else {
139
+	    $option                = get_option( 'monsterinsights_license' );
140
+	    $option['key']         = trim( $_POST['monsterinsights-license-key'] );
141
+	    $option['type']        = isset( $verify->type ) ? $verify->type : $option['type'];
142
+	    $option['is_expired']  = false;
143
+	    $option['is_disabled'] = false;
144
+	    $option['is_invalid']  = false;
145
+	    $this->success[]       = isset( $verify->success ) ? $verify->success : esc_html__( 'Congratulations! This site is now receiving automatic updates.', 'google-analytics-for-wordpress' );
146
+	    update_option( 'monsterinsights_license', $option );        
147
+	}
148 148
 
149 149
     }
150 150
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
      */
158 158
     public function is_verifying_key() {
159 159
 
160
-        return isset( $_POST['monsterinsights-license-key'] ) && isset( $_POST['monsterinsights-verify-submit'] );
160
+	return isset( $_POST['monsterinsights-license-key'] ) && isset( $_POST['monsterinsights-verify-submit'] );
161 161
 
162 162
     }
163 163
 
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
      */
171 171
     public function verify_key_action() {
172 172
 
173
-        return isset( $_POST['monsterinsights-verify-submit'] ) && wp_verify_nonce( $_POST['monsterinsights-key-nonce'], 'monsterinsights-key-nonce' );
173
+	return isset( $_POST['monsterinsights-verify-submit'] ) && wp_verify_nonce( $_POST['monsterinsights-key-nonce'], 'monsterinsights-key-nonce' );
174 174
 
175 175
     }
176 176
 
@@ -183,21 +183,21 @@  discard block
 block discarded – undo
183 183
      */
184 184
     public function maybe_validate_key() {
185 185
 
186
-        // Only run every 12 hours.
187
-        $timestamp = get_option( 'monsterinsights_license_updates' );
188
-        if ( ! $timestamp ) {
189
-             $timestamp = strtotime( '+8 hours' );
190
-             update_option( 'monsterinsights_license_updates', $timestamp );
191
-             $this->validate_key();
192
-        } else {
193
-            $current_timestamp = time();
194
-            if ( $current_timestamp < $timestamp ) {
195
-                return;
196
-            } else {
197
-                update_option( 'monsterinsights_license_updates', strtotime( '+8 hours' ) );
198
-                $this->validate_key();
199
-            }
200
-        }
186
+	// Only run every 12 hours.
187
+	$timestamp = get_option( 'monsterinsights_license_updates' );
188
+	if ( ! $timestamp ) {
189
+	     $timestamp = strtotime( '+8 hours' );
190
+	     update_option( 'monsterinsights_license_updates', $timestamp );
191
+	     $this->validate_key();
192
+	} else {
193
+	    $current_timestamp = time();
194
+	    if ( $current_timestamp < $timestamp ) {
195
+		return;
196
+	    } else {
197
+		update_option( 'monsterinsights_license_updates', strtotime( '+8 hours' ) );
198
+		$this->validate_key();
199
+	    }
200
+	}
201 201
     }
202 202
 
203 203
     /**
@@ -209,103 +209,103 @@  discard block
 block discarded – undo
209 209
      */
210 210
     public function validate_key( $forced = false ) {
211 211
 
212
-        $validate = $this->perform_remote_request( 'validate-key', array( 'tgm-updater-key' => $this->key ) );
212
+	$validate = $this->perform_remote_request( 'validate-key', array( 'tgm-updater-key' => $this->key ) );
213 213
 
214
-        // If there was a basic API error in validation, only set the transient for 10 minutes before retrying.
215
-        if ( ! $validate ) {
216
-            // If forced, set contextual success message.
217
-            if ( $forced ) {
218
-                $this->errors[] = esc_html__( 'There was an error connecting to the remote key API. Please try again later.', 'google-analytics-for-wordpress' );
219
-            }
214
+	// If there was a basic API error in validation, only set the transient for 10 minutes before retrying.
215
+	if ( ! $validate ) {
216
+	    // If forced, set contextual success message.
217
+	    if ( $forced ) {
218
+		$this->errors[] = esc_html__( 'There was an error connecting to the remote key API. Please try again later.', 'google-analytics-for-wordpress' );
219
+	    }
220 220
             
221
-            return;
222
-        }
223
-
224
-        // If a key or author error is returned, the license no longer exists or the user has been deleted, so reset license.
225
-        if ( isset( $validate->key ) || isset( $validate->author ) ) {
226
-            $option = array();
227
-            if ( is_multisite() && is_network_admin() ) {
228
-                $option  = get_site_option( 'monsterinsights_license' );
229
-            } else {
230
-                $option = get_option( 'monsterinsights_license' );
231
-            }
232
-            $option['is_expired']  = false;
233
-            $option['is_disabled'] = false;
234
-            $option['is_invalid']  = true;
235
-            if ( is_multisite() && is_network_admin() ) {
236
-                update_site_option( 'monsterinsights_license', $option );
237
-            } else {
238
-                update_option( 'monsterinsights_license', $option );
239
-            }
240
-            return;
241
-        }
242
-
243
-        // If the license has expired, set the transient and expired flag and return.
244
-        if ( isset( $validate->expired ) ) {
245
-            $option = array();
246
-            if ( is_multisite() && is_network_admin() ) {
247
-                $option  = get_site_option( 'monsterinsights_license' );
248
-            } else {
249
-                $option = get_option( 'monsterinsights_license' );
250
-            }
251
-            $option['is_expired']  = true;
252
-            $option['is_disabled'] = false;
253
-            $option['is_invalid']  = false;
254
-            if ( is_multisite() && is_network_admin() ) {
255
-                update_site_option( 'monsterinsights_license', $option );
256
-            } else {
257
-                update_option( 'monsterinsights_license', $option );
258
-            }
259
-            return;
260
-        }
261
-
262
-        // If the license is disabled, set the transient and disabled flag and return.
263
-        if ( isset( $validate->disabled ) ) {
264
-            $option = array();
265
-            if ( is_multisite() && is_network_admin() ) {
266
-                $option  = get_site_option( 'monsterinsights_license' );
267
-            } else {
268
-                $option = get_option( 'monsterinsights_license' );
269
-            }
270
-            $option['is_expired']  = false;
271
-            $option['is_disabled'] = true;
272
-            $option['is_invalid']  = false;
273
-            if ( is_multisite() && is_network_admin() ) {
274
-                update_site_option( 'monsterinsights_license', $option );
275
-            } else {
276
-                update_option( 'monsterinsights_license', $option );
277
-            }
278
-            return;
279
-        }
280
-
281
-        // If forced, set contextual success message.
282
-        if ( ( ! empty( $validate->key ) || ! empty( $this->key ) ) && $forced ) {
283
-            $key = '';
284
-            if ( ! empty( $validate->key ) ) {
285
-                $key = $validate->key;
286
-            } else {
287
-                $key = $this->key;
288
-            }
289
-            delete_transient( '_monsterinsights_addons' );
290
-            monsterinsights_get_addons_data( $key );
291
-            $this->success[] = esc_html__( 'Congratulations! Your key has been refreshed successfully.', 'google-analytics-for-wordpress' );
292
-        }
293
-
294
-        $option = array();
295
-        if ( is_multisite() && is_network_admin() ) {
296
-            $option  = get_site_option( 'monsterinsights_license' );
297
-        } else {
298
-            $option = get_option( 'monsterinsights_license' );
299
-        }
300
-        $option['type']        = isset( $validate->type ) ? $validate->type : $option['type'];
301
-        $option['is_expired']  = false;
302
-        $option['is_disabled'] = false;
303
-        $option['is_invalid']  = false;
304
-        if ( is_multisite() && is_network_admin() ) {
305
-            update_site_option( 'monsterinsights_license', $option );
306
-        } else {
307
-            update_option( 'monsterinsights_license', $option );
308
-        }
221
+	    return;
222
+	}
223
+
224
+	// If a key or author error is returned, the license no longer exists or the user has been deleted, so reset license.
225
+	if ( isset( $validate->key ) || isset( $validate->author ) ) {
226
+	    $option = array();
227
+	    if ( is_multisite() && is_network_admin() ) {
228
+		$option  = get_site_option( 'monsterinsights_license' );
229
+	    } else {
230
+		$option = get_option( 'monsterinsights_license' );
231
+	    }
232
+	    $option['is_expired']  = false;
233
+	    $option['is_disabled'] = false;
234
+	    $option['is_invalid']  = true;
235
+	    if ( is_multisite() && is_network_admin() ) {
236
+		update_site_option( 'monsterinsights_license', $option );
237
+	    } else {
238
+		update_option( 'monsterinsights_license', $option );
239
+	    }
240
+	    return;
241
+	}
242
+
243
+	// If the license has expired, set the transient and expired flag and return.
244
+	if ( isset( $validate->expired ) ) {
245
+	    $option = array();
246
+	    if ( is_multisite() && is_network_admin() ) {
247
+		$option  = get_site_option( 'monsterinsights_license' );
248
+	    } else {
249
+		$option = get_option( 'monsterinsights_license' );
250
+	    }
251
+	    $option['is_expired']  = true;
252
+	    $option['is_disabled'] = false;
253
+	    $option['is_invalid']  = false;
254
+	    if ( is_multisite() && is_network_admin() ) {
255
+		update_site_option( 'monsterinsights_license', $option );
256
+	    } else {
257
+		update_option( 'monsterinsights_license', $option );
258
+	    }
259
+	    return;
260
+	}
261
+
262
+	// If the license is disabled, set the transient and disabled flag and return.
263
+	if ( isset( $validate->disabled ) ) {
264
+	    $option = array();
265
+	    if ( is_multisite() && is_network_admin() ) {
266
+		$option  = get_site_option( 'monsterinsights_license' );
267
+	    } else {
268
+		$option = get_option( 'monsterinsights_license' );
269
+	    }
270
+	    $option['is_expired']  = false;
271
+	    $option['is_disabled'] = true;
272
+	    $option['is_invalid']  = false;
273
+	    if ( is_multisite() && is_network_admin() ) {
274
+		update_site_option( 'monsterinsights_license', $option );
275
+	    } else {
276
+		update_option( 'monsterinsights_license', $option );
277
+	    }
278
+	    return;
279
+	}
280
+
281
+	// If forced, set contextual success message.
282
+	if ( ( ! empty( $validate->key ) || ! empty( $this->key ) ) && $forced ) {
283
+	    $key = '';
284
+	    if ( ! empty( $validate->key ) ) {
285
+		$key = $validate->key;
286
+	    } else {
287
+		$key = $this->key;
288
+	    }
289
+	    delete_transient( '_monsterinsights_addons' );
290
+	    monsterinsights_get_addons_data( $key );
291
+	    $this->success[] = esc_html__( 'Congratulations! Your key has been refreshed successfully.', 'google-analytics-for-wordpress' );
292
+	}
293
+
294
+	$option = array();
295
+	if ( is_multisite() && is_network_admin() ) {
296
+	    $option  = get_site_option( 'monsterinsights_license' );
297
+	} else {
298
+	    $option = get_option( 'monsterinsights_license' );
299
+	}
300
+	$option['type']        = isset( $validate->type ) ? $validate->type : $option['type'];
301
+	$option['is_expired']  = false;
302
+	$option['is_disabled'] = false;
303
+	$option['is_invalid']  = false;
304
+	if ( is_multisite() && is_network_admin() ) {
305
+	    update_site_option( 'monsterinsights_license', $option );
306
+	} else {
307
+	    update_option( 'monsterinsights_license', $option );
308
+	}
309 309
 
310 310
     }
311 311
 
@@ -318,15 +318,15 @@  discard block
 block discarded – undo
318 318
      */
319 319
     public function maybe_deactivate_key() {
320 320
 
321
-        if ( ! $this->is_deactivating_key() ) {
322
-            return;
323
-        }
321
+	if ( ! $this->is_deactivating_key() ) {
322
+	    return;
323
+	}
324 324
 
325
-        if ( ! $this->deactivate_key_action() ) {
326
-            return;
327
-        }
325
+	if ( ! $this->deactivate_key_action() ) {
326
+	    return;
327
+	}
328 328
 
329
-        $this->deactivate_key();
329
+	$this->deactivate_key();
330 330
 
331 331
     }
332 332
 
@@ -337,29 +337,29 @@  discard block
 block discarded – undo
337 337
      */
338 338
     public function deactivate_key() {
339 339
 
340
-        // Perform a request to deactivate the key.
341
-        $deactivate = $this->perform_remote_request( 'deactivate-key', array( 'tgm-updater-key' => $_POST['monsterinsights-license-key'] ) );
342
-
343
-        // If it returns false, send back a generic error message and return.
344
-        if ( ! $deactivate ) {
345
-            $this->errors[] = esc_html__( 'There was an error connecting to the remote key API. Please try again later.', 'google-analytics-for-wordpress' );
346
-            return;
347
-        }
348
-
349
-        // If an error is returned, set the error and return.
350
-        if ( ! empty( $deactivate->error ) && ! monsterinsights_is_debug_mode() ) {
351
-            $this->errors[] = $deactivate->error;
352
-            return;
353
-        }
354
-
355
-        // Otherwise, our request has been done successfully. Reset the option and set the success message.
356
-        $this->success[] = isset( $deactivate->success ) ? $deactivate->success : esc_html__( 'Congratulations! You have deactivated the key from this site successfully.', 'google-analytics-for-wordpress' );
357
-        update_option( 'monsterinsights_license', array() );
358
-        if ( is_multisite() && is_network_admin() ) {
359
-            update_site_option( 'monsterinsights_license', array() );
360
-        } else {
361
-            update_option( 'monsterinsights_license', array() );
362
-        }
340
+	// Perform a request to deactivate the key.
341
+	$deactivate = $this->perform_remote_request( 'deactivate-key', array( 'tgm-updater-key' => $_POST['monsterinsights-license-key'] ) );
342
+
343
+	// If it returns false, send back a generic error message and return.
344
+	if ( ! $deactivate ) {
345
+	    $this->errors[] = esc_html__( 'There was an error connecting to the remote key API. Please try again later.', 'google-analytics-for-wordpress' );
346
+	    return;
347
+	}
348
+
349
+	// If an error is returned, set the error and return.
350
+	if ( ! empty( $deactivate->error ) && ! monsterinsights_is_debug_mode() ) {
351
+	    $this->errors[] = $deactivate->error;
352
+	    return;
353
+	}
354
+
355
+	// Otherwise, our request has been done successfully. Reset the option and set the success message.
356
+	$this->success[] = isset( $deactivate->success ) ? $deactivate->success : esc_html__( 'Congratulations! You have deactivated the key from this site successfully.', 'google-analytics-for-wordpress' );
357
+	update_option( 'monsterinsights_license', array() );
358
+	if ( is_multisite() && is_network_admin() ) {
359
+	    update_site_option( 'monsterinsights_license', array() );
360
+	} else {
361
+	    update_option( 'monsterinsights_license', array() );
362
+	}
363 363
 
364 364
     }
365 365
 
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
      */
373 373
     public function is_deactivating_key() {
374 374
 
375
-        return isset( $_POST['monsterinsights-license-key'] ) && isset( $_POST['monsterinsights-deactivate-submit'] );
375
+	return isset( $_POST['monsterinsights-license-key'] ) && isset( $_POST['monsterinsights-deactivate-submit'] );
376 376
 
377 377
     }
378 378
 
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
      */
386 386
     public function deactivate_key_action() {
387 387
 
388
-        return isset( $_POST['monsterinsights-deactivate-submit'] ) && wp_verify_nonce( $_POST['monsterinsights-key-nonce'], 'monsterinsights-key-nonce' );
388
+	return isset( $_POST['monsterinsights-deactivate-submit'] ) && wp_verify_nonce( $_POST['monsterinsights-key-nonce'], 'monsterinsights-key-nonce' );
389 389
 
390 390
     }
391 391
 
@@ -398,16 +398,16 @@  discard block
 block discarded – undo
398 398
      */
399 399
     public function maybe_refresh_key() {
400 400
 
401
-        if ( ! $this->is_refreshing_key() ) {
402
-            return;
403
-        }
401
+	if ( ! $this->is_refreshing_key() ) {
402
+	    return;
403
+	}
404 404
 
405
-        if ( ! $this->refresh_key_action() ) {
406
-            return;
407
-        }
405
+	if ( ! $this->refresh_key_action() ) {
406
+	    return;
407
+	}
408 408
 
409
-        // Refreshing is simply a word alias for validating a key. Force true to set contextual messages.
410
-        $this->validate_key( true );
409
+	// Refreshing is simply a word alias for validating a key. Force true to set contextual messages.
410
+	$this->validate_key( true );
411 411
 
412 412
     }
413 413
 
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
      */
421 421
     public function is_refreshing_key() {
422 422
 
423
-        return isset( $_POST['monsterinsights-license-key'] ) && isset( $_POST['monsterinsights-refresh-submit'] );
423
+	return isset( $_POST['monsterinsights-license-key'] ) && isset( $_POST['monsterinsights-refresh-submit'] );
424 424
 
425 425
     }
426 426
 
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
      */
434 434
     public function refresh_key_action() {
435 435
 
436
-        return isset( $_POST['monsterinsights-refresh-submit'] ) && wp_verify_nonce( $_POST['monsterinsights-key-nonce'], 'monsterinsights-key-nonce' );
436
+	return isset( $_POST['monsterinsights-refresh-submit'] ) && wp_verify_nonce( $_POST['monsterinsights-key-nonce'], 'monsterinsights-key-nonce' );
437 437
 
438 438
     }
439 439
 
@@ -444,127 +444,127 @@  discard block
 block discarded – undo
444 444
      */
445 445
     public function monsterinsights_notices() {
446 446
 
447
-        // Grab the option and output any nag dealing with license keys.
448
-        $key    = monsterinsights_get_license_key();
447
+	// Grab the option and output any nag dealing with license keys.
448
+	$key    = monsterinsights_get_license_key();
449 449
 
450
-        $option = array();
451
-        if ( is_multisite() && is_network_admin() ) {
452
-            $option = get_site_option( 'monsterinsights_license' );
453
-        } else {
454
-            $option = get_option( 'monsterinsights_license' );
455
-        }
450
+	$option = array();
451
+	if ( is_multisite() && is_network_admin() ) {
452
+	    $option = get_site_option( 'monsterinsights_license' );
453
+	} else {
454
+	    $option = get_option( 'monsterinsights_license' );
455
+	}
456 456
 
457
-        if ( ! monsterinsights_is_pro_version() ) {
458
-            return;
459
-        }
457
+	if ( ! monsterinsights_is_pro_version() ) {
458
+	    return;
459
+	}
460 460
 
461
-        if ( is_multisite() && is_network_admin() ) {
462
-            // If a key has expired, output nag about renewing the key.
463
-            if ( isset( $option['is_expired'] ) && $option['is_expired'] ) :
464
-            ?>
461
+	if ( is_multisite() && is_network_admin() ) {
462
+	    // If a key has expired, output nag about renewing the key.
463
+	    if ( isset( $option['is_expired'] ) && $option['is_expired'] ) :
464
+	    ?>
465 465
             <div class="error">
466 466
                 <p><?php printf( esc_html__( 'Your license key for MonsterInsights has expired. %1$sPlease click here to renew your license key and continue receiving automatic updates.%2$s', 'google-analytics-for-wordpress' ), '<a href="https://www.monsterinsights.com/login/" target="_blank" rel="noopener noreferrer" referrer="no-referrer">', '</a>' ); ?></p>
467 467
             </div>
468 468
             <?php
469
-            endif;
469
+	    endif;
470 470
 
471
-            // If a key has been disabled, output nag about using another key.
472
-            if ( isset( $option['is_disabled'] ) && $option['is_disabled'] ) :
473
-            ?>
471
+	    // If a key has been disabled, output nag about using another key.
472
+	    if ( isset( $option['is_disabled'] ) && $option['is_disabled'] ) :
473
+	    ?>
474 474
             <div class="error">
475 475
                 <p><?php esc_html_e( 'Your license key for MonsterInsights has been disabled. Please use a different key to continue receiving automatic updates.', 'google-analytics-for-wordpress' ); ?></p>
476 476
             </div>
477 477
             <?php
478
-            endif;
478
+	    endif;
479 479
 
480
-            // If a key is invalid, output nag about using another key.
481
-            if ( isset( $option['is_invalid'] ) && $option['is_invalid'] ) :
482
-            ?>
480
+	    // If a key is invalid, output nag about using another key.
481
+	    if ( isset( $option['is_invalid'] ) && $option['is_invalid'] ) :
482
+	    ?>
483 483
             <div class="error">
484 484
                 <p><?php esc_html_e( '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 to continue receiving automatic updates.', 'google-analytics-for-wordpress' ); ?></p>
485 485
             </div>
486 486
             <?php
487
-            endif;
487
+	    endif;
488 488
 
489
-            // If there are any license errors, output them now.
490
-            if ( ! empty( $this->errors ) ) :
491
-            ?>
489
+	    // If there are any license errors, output them now.
490
+	    if ( ! empty( $this->errors ) ) :
491
+	    ?>
492 492
             <div class="error">
493 493
                 <p><?php echo implode( '<br>', $this->errors ); ?></p>
494 494
             </div>
495 495
             <?php
496
-            endif;
496
+	    endif;
497 497
 
498
-            // If there are any success messages, output them now.
499
-            if ( ! empty( $this->success ) ) :
500
-            ?>
498
+	    // If there are any success messages, output them now.
499
+	    if ( ! empty( $this->success ) ) :
500
+	    ?>
501 501
             <div class="updated">
502 502
                 <p><?php echo implode( '<br>', $this->success ); ?></p>
503 503
             </div>
504 504
             <?php
505
-            endif;
506
-        } else {
507
-            // If there is no license key, output nag about ensuring key is set for automatic updates.
508
-            if ( ! $key ) :
509
-                if ( ! monsterinsights_is_pro_version() ) { 
510
-                    return;
511
-                }
512
-                $screen = get_current_screen(); 
513
-                if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) !== false ) {
514
-                    return;
515
-                }
516
-            ?>
505
+	    endif;
506
+	} else {
507
+	    // If there is no license key, output nag about ensuring key is set for automatic updates.
508
+	    if ( ! $key ) :
509
+		if ( ! monsterinsights_is_pro_version() ) { 
510
+		    return;
511
+		}
512
+		$screen = get_current_screen(); 
513
+		if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) !== false ) {
514
+		    return;
515
+		}
516
+	    ?>
517 517
             <div class="error">
518 518
                 <p><?php printf( esc_html__( 'No valid license key has been entered, so automatic updates for MonsterInsights have been turned off. %1$sPlease click here to enter your license key and begin receiving automatic updates.%2$s', 'google-analytics-for-wordpress' ), '<a href="'. esc_url( add_query_arg( array( 'page' => 'monsterinsights_settings' ), admin_url( 'admin.php' ) ) ) . '" target="_blank" rel="noopener noreferrer">', '</a>' ); ?></p>
519 519
             </div>
520 520
             <?php
521
-            endif;
521
+	    endif;
522 522
 
523
-            // If a key has expired, output nag about renewing the key.
524
-            if ( isset( $option['is_expired'] ) && $option['is_expired'] ) :
525
-            ?>
523
+	    // If a key has expired, output nag about renewing the key.
524
+	    if ( isset( $option['is_expired'] ) && $option['is_expired'] ) :
525
+	    ?>
526 526
             <div class="error">
527 527
                 <p><?php printf( esc_html__( 'Your license key for MonsterInsights has expired. %1$sPlease click here to renew your license key and continue receiving automatic updates.%2$s', 'google-analytics-for-wordpress' ), '<a href="https://www.monsterinsights.com/login/" target="_blank" rel="noopener noreferrer">', '</a>' ); ?></p>
528 528
             </div>
529 529
             <?php
530
-            endif;
530
+	    endif;
531 531
 
532
-            // If a key has been disabled, output nag about using another key.
533
-            if ( isset( $option['is_disabled'] ) && $option['is_disabled'] ) :
534
-            ?>
532
+	    // If a key has been disabled, output nag about using another key.
533
+	    if ( isset( $option['is_disabled'] ) && $option['is_disabled'] ) :
534
+	    ?>
535 535
             <div class="error">
536 536
                 <p><?php esc_html_e( 'Your license key for MonsterInsights has been disabled. Please use a different key to continue receiving automatic updates.', 'google-analytics-for-wordpress' ); ?></p>
537 537
             </div>
538 538
             <?php
539
-            endif;
539
+	    endif;
540 540
 
541
-            // If a key is invalid, output nag about using another key.
542
-            if ( isset( $option['is_invalid'] ) && $option['is_invalid'] ) :
543
-            ?>
541
+	    // If a key is invalid, output nag about using another key.
542
+	    if ( isset( $option['is_invalid'] ) && $option['is_invalid'] ) :
543
+	    ?>
544 544
             <div class="error">
545 545
                 <p><?php esc_html_e( '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 to continue receiving automatic updates.', 'google-analytics-for-wordpress' ); ?></p>
546 546
             </div>
547 547
             <?php
548
-            endif;
548
+	    endif;
549 549
 
550
-            // If there are any license errors, output them now.
551
-            if ( ! empty( $this->errors ) ) :
552
-            ?>
550
+	    // If there are any license errors, output them now.
551
+	    if ( ! empty( $this->errors ) ) :
552
+	    ?>
553 553
             <div class="error">
554 554
                 <p><?php echo implode( '<br>', $this->errors ); ?></p>
555 555
             </div>
556 556
             <?php
557
-            endif;
557
+	    endif;
558 558
 
559
-            // If there are any success messages, output them now.
560
-            if ( ! empty( $this->success ) ) :
561
-            ?>
559
+	    // If there are any success messages, output them now.
560
+	    if ( ! empty( $this->success ) ) :
561
+	    ?>
562 562
             <div class="updated">
563 563
                 <p><?php echo implode( '<br>', $this->success ); ?></p>
564 564
             </div>
565 565
             <?php
566
-            endif;
567
-        }
566
+	    endif;
567
+	}
568 568
     }
569 569
 
570 570
     /**
@@ -580,47 +580,47 @@  discard block
 block discarded – undo
580 580
      */
581 581
     public function perform_remote_request( $action, $body = array(), $headers = array(), $return_format = 'json' ) {
582 582
 
583
-        // Build the body of the request.
584
-        $body = wp_parse_args(
585
-            $body,
586
-            array(
587
-                'tgm-updater-action'     => $action,
588
-                'tgm-updater-key'        => $this->key,
589
-                'tgm-updater-wp-version' => get_bloginfo( 'version' ),
590
-                'tgm-updater-referer'    => site_url(),
591
-                'tgm-updater-mi-version' => MONSTERINSIGHTS_VERSION,
592
-                'tgm-updater-is-pro'     => monsterinsights_is_pro_version(),
593
-            )
594
-        );
595
-        $body = http_build_query( $body, '', '&' );
596
-
597
-        // Build the headers of the request.
598
-        $headers = wp_parse_args(
599
-            $headers,
600
-            array(
601
-                'Content-Type'   => 'application/x-www-form-urlencoded',
602
-                'Content-Length' => strlen( $body )
603
-            )
604
-        );
605
-
606
-        // Setup variable for wp_remote_post.
607
-        $post = array(
608
-            'headers' => $headers,
609
-            'body'    => $body
610
-        );
611
-
612
-        // Perform the query and retrieve the response.
613
-        $response      = wp_remote_post( 'https://www.monsterinsights.com', $post );
614
-        $response_code = wp_remote_retrieve_response_code( $response );
615
-        $response_body = wp_remote_retrieve_body( $response );
616
-
617
-        // Bail out early if there are any errors.
618
-        if ( 200 != $response_code || is_wp_error( $response_body ) ) {
619
-            return false;
620
-        }
621
-
622
-        // Return the json decoded content.
623
-        return json_decode( $response_body );
583
+	// Build the body of the request.
584
+	$body = wp_parse_args(
585
+	    $body,
586
+	    array(
587
+		'tgm-updater-action'     => $action,
588
+		'tgm-updater-key'        => $this->key,
589
+		'tgm-updater-wp-version' => get_bloginfo( 'version' ),
590
+		'tgm-updater-referer'    => site_url(),
591
+		'tgm-updater-mi-version' => MONSTERINSIGHTS_VERSION,
592
+		'tgm-updater-is-pro'     => monsterinsights_is_pro_version(),
593
+	    )
594
+	);
595
+	$body = http_build_query( $body, '', '&' );
596
+
597
+	// Build the headers of the request.
598
+	$headers = wp_parse_args(
599
+	    $headers,
600
+	    array(
601
+		'Content-Type'   => 'application/x-www-form-urlencoded',
602
+		'Content-Length' => strlen( $body )
603
+	    )
604
+	);
605
+
606
+	// Setup variable for wp_remote_post.
607
+	$post = array(
608
+	    'headers' => $headers,
609
+	    'body'    => $body
610
+	);
611
+
612
+	// Perform the query and retrieve the response.
613
+	$response      = wp_remote_post( 'https://www.monsterinsights.com', $post );
614
+	$response_code = wp_remote_retrieve_response_code( $response );
615
+	$response_body = wp_remote_retrieve_body( $response );
616
+
617
+	// Bail out early if there are any errors.
618
+	if ( 200 != $response_code || is_wp_error( $response_body ) ) {
619
+	    return false;
620
+	}
621
+
622
+	// Return the json decoded content.
623
+	return json_decode( $response_body );
624 624
 
625 625
     }
626 626
 }
627 627
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
         if ( isset( $validate->key ) || isset( $validate->author ) ) {
226 226
             $option = array();
227 227
             if ( is_multisite() && is_network_admin() ) {
228
-                $option  = get_site_option( 'monsterinsights_license' );
228
+                $option = get_site_option( 'monsterinsights_license' );
229 229
             } else {
230 230
                 $option = get_option( 'monsterinsights_license' );
231 231
             }
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
         if ( isset( $validate->expired ) ) {
245 245
             $option = array();
246 246
             if ( is_multisite() && is_network_admin() ) {
247
-                $option  = get_site_option( 'monsterinsights_license' );
247
+                $option = get_site_option( 'monsterinsights_license' );
248 248
             } else {
249 249
                 $option = get_option( 'monsterinsights_license' );
250 250
             }
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
         if ( isset( $validate->disabled ) ) {
264 264
             $option = array();
265 265
             if ( is_multisite() && is_network_admin() ) {
266
-                $option  = get_site_option( 'monsterinsights_license' );
266
+                $option = get_site_option( 'monsterinsights_license' );
267 267
             } else {
268 268
                 $option = get_option( 'monsterinsights_license' );
269 269
             }
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 
294 294
         $option = array();
295 295
         if ( is_multisite() && is_network_admin() ) {
296
-            $option  = get_site_option( 'monsterinsights_license' );
296
+            $option = get_site_option( 'monsterinsights_license' );
297 297
         } else {
298 298
             $option = get_option( 'monsterinsights_license' );
299 299
         }
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
                 }
516 516
             ?>
517 517
             <div class="error">
518
-                <p><?php printf( esc_html__( 'No valid license key has been entered, so automatic updates for MonsterInsights have been turned off. %1$sPlease click here to enter your license key and begin receiving automatic updates.%2$s', 'google-analytics-for-wordpress' ), '<a href="'. esc_url( add_query_arg( array( 'page' => 'monsterinsights_settings' ), admin_url( 'admin.php' ) ) ) . '" target="_blank" rel="noopener noreferrer">', '</a>' ); ?></p>
518
+                <p><?php printf( esc_html__( 'No valid license key has been entered, so automatic updates for MonsterInsights have been turned off. %1$sPlease click here to enter your license key and begin receiving automatic updates.%2$s', 'google-analytics-for-wordpress' ), '<a href="' . esc_url( add_query_arg( array( 'page' => 'monsterinsights_settings' ), admin_url( 'admin.php' ) ) ) . '" target="_blank" rel="noopener noreferrer">', '</a>' ); ?></p>
519 519
             </div>
520 520
             <?php
521 521
             endif;
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -506,7 +506,7 @@
 block discarded – undo
506 506
         } else {
507 507
             // If there is no license key, output nag about ensuring key is set for automatic updates.
508 508
             if ( ! $key ) :
509
-                if ( ! monsterinsights_is_pro_version() ) { 
509
+                if ( ! monsterinsights_is_pro_version() ) {
510 510
                     return;
511 511
                 }
512 512
                 $screen = get_current_screen(); 
Please login to merge, or discard this patch.
includes/admin/licensing/autoupdate.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -13,20 +13,20 @@  discard block
 block discarded – undo
13 13
 
14 14
     // If this is multisite and is not on the main site, return early.
15 15
     if ( is_multisite() && ! is_main_site() ) {
16
-        return $update;
16
+	return $update;
17 17
     }
18 18
     
19 19
     // If we don't have everything we need, return early.
20 20
     $item = (array) $item;
21 21
     if ( ! isset( $item['new_version'] ) || ! isset( $item['slug'] ) ) {
22
-        return $update;
22
+	return $update;
23 23
     }
24 24
 
25 25
     // If the plugin isn't ours, return early.
26 26
     $is_free = 'google-analytics-for-wordpress' === $item['slug'];
27 27
     $is_paid = isset( $item['monsterinsights_plugin'] ); // see updater class
28 28
     if ( ! $is_free && ! $is_paid ) {
29
-        return $update;
29
+	return $update;
30 30
     }
31 31
 
32 32
     $version           = $is_free ? MONSTERINSIGHTS_LITE_VERSION : $item['old_version'];
@@ -36,20 +36,20 @@  discard block
 block discarded – undo
36 36
     
37 37
     // If the opt in update allows major updates but there is no major version update, return early.
38 38
     if ( $current_major < $new_major ) {
39
-        if ( $automatic_updates === 'all' ) {
40
-            return true;
41
-        } else {
42
-            return $update;
43
-        }
39
+	if ( $automatic_updates === 'all' ) {
40
+	    return true;
41
+	} else {
42
+	    return $update;
43
+	}
44 44
     }
45 45
     
46 46
     // If the opt in update allows minor updates but there is no minor version update, return early.
47 47
     if ( $current_major == $new_major ) {
48
-        if ( $automatic_updates === 'all' || $automatic_updates === 'minor' ) {
49
-            return true;
50
-        } else {
51
-            return $update;
52
-        }
48
+	if ( $automatic_updates === 'all' || $automatic_updates === 'minor' ) {
49
+	    return true;
50
+	} else {
51
+	    return $update;
52
+	}
53 53
     }
54 54
 
55 55
     // All our checks have passed - this plugin can be updated!
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 function monsterinsights_get_major_version( $version ) {
88 88
     $exploded_version = explode( '.', $version );
89 89
     if ( isset( $exploded_version[2] ) ) {
90
-        return $exploded_version[0] . '.' . $exploded_version[1] . '.' . $exploded_version[2];
90
+	return $exploded_version[0] . '.' . $exploded_version[1] . '.' . $exploded_version[2];
91 91
     } else {
92
-        return $exploded_version[0] . '.' . $exploded_version[1] . '.0';
92
+	return $exploded_version[0] . '.' . $exploded_version[1] . '.0';
93 93
     }
94 94
 }
95 95
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/ajax.php 4 patches
Indentation   +88 added lines, -88 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';
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 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.
@@ -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 occured
@@ -215,39 +215,39 @@  discard block
 block discarded – undo
215 215
 
216 216
     $shorten = ! empty( $_POST['url'] ) ? esc_url_raw( $_POST['url'] ) : '';
217 217
     if ( ! current_user_can( 'monsterinsights_view_dashboard' ) ) {
218
-        echo $shorten;
219
-        wp_die();
218
+	echo $shorten;
219
+	wp_die();
220 220
     }
221 221
 
222 222
     $url     = 'https://www.googleapis.com/urlshortener/v1/url';
223 223
 
224 224
     // If no url passed die
225 225
     if ( ! $shorten ) {
226
-        echo $shorten;
227
-        wp_die();
226
+	echo $shorten;
227
+	wp_die();
228 228
     }
229 229
 
230 230
     // if the url is already shortened, don't re-run
231 231
     if ( strpos( $shorten, 'goo.g') !== false ) {
232
-        echo $shorten;
233
-        wp_die();
232
+	echo $shorten;
233
+	wp_die();
234 234
     }
235 235
     
236 236
     $result = wp_remote_post(
237
-        add_query_arg(
238
-            'key', 
239
-            'AIzaSyCfHOlx8NbBVSpmHPqxophzULWSAzWDyio', 
240
-            'https://www.googleapis.com/urlshortener/v1/url'
241
-        ), 
242
-        array(
243
-            'body' => json_encode( array('longUrl' => esc_url_raw( $shorten ) ) ),
244
-            'headers' => array( 'Content-Type' => 'application/json')
245
-        )
237
+	add_query_arg(
238
+	    'key', 
239
+	    'AIzaSyCfHOlx8NbBVSpmHPqxophzULWSAzWDyio', 
240
+	    'https://www.googleapis.com/urlshortener/v1/url'
241
+	), 
242
+	array(
243
+	    'body' => json_encode( array('longUrl' => esc_url_raw( $shorten ) ) ),
244
+	    'headers' => array( 'Content-Type' => 'application/json')
245
+	)
246 246
     );
247 247
 
248 248
     if ( is_wp_error( $result ) ) {
249
-        echo $shorten;
250
-        wp_die();
249
+	echo $shorten;
250
+	wp_die();
251 251
     }
252 252
     $result = json_decode( $result['body'] );
253 253
     $shortlink = $result->id;
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 
132 132
     // Activate the addon.
133 133
     if ( isset( $_POST['plugin'] ) ) {
134
-        if ( isset( $_POST['isnetwork'] ) &&  $_POST['isnetwork'] ) {
134
+        if ( isset( $_POST['isnetwork'] ) && $_POST['isnetwork'] ) {
135 135
             $activate = activate_plugin( $_POST['plugin'], NULL, true );
136 136
         } else {
137 137
             $activate = activate_plugin( $_POST['plugin'] );
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
         wp_die();
220 220
     }
221 221
 
222
-    $url     = 'https://www.googleapis.com/urlshortener/v1/url';
222
+    $url = 'https://www.googleapis.com/urlshortener/v1/url';
223 223
 
224 224
     // If no url passed die
225 225
     if ( ! $shorten ) {
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
     }
229 229
 
230 230
     // if the url is already shortened, don't re-run
231
-    if ( strpos( $shorten, 'goo.g') !== false ) {
231
+    if ( strpos( $shorten, 'goo.g' ) !== false ) {
232 232
         echo $shorten;
233 233
         wp_die();
234 234
     }
@@ -240,8 +240,8 @@  discard block
 block discarded – undo
240 240
             'https://www.googleapis.com/urlshortener/v1/url'
241 241
         ), 
242 242
         array(
243
-            'body' => json_encode( array('longUrl' => esc_url_raw( $shorten ) ) ),
244
-            'headers' => array( 'Content-Type' => 'application/json')
243
+            'body' => json_encode( array( 'longUrl' => esc_url_raw( $shorten ) ) ),
244
+            'headers' => array( 'Content-Type' => 'application/json' )
245 245
         )
246 246
     );
247 247
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -166,7 +166,7 @@
 block discarded – undo
166 166
 
167 167
     // Deactivate the addon.
168 168
     if ( isset( $_POST['plugin'] ) ) {
169
-        if ( isset( $_POST['isnetwork'] ) && $_POST['isnetwork'] ) { 
169
+        if ( isset( $_POST['isnetwork'] ) && $_POST['isnetwork'] ) {
170 170
             $deactivate = deactivate_plugins( $_POST['plugin'], false, true );
171 171
         } else {
172 172
             $deactivate = deactivate_plugins( $_POST['plugin'] );
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -132,7 +132,7 @@
 block discarded – undo
132 132
     // Activate the addon.
133 133
     if ( isset( $_POST['plugin'] ) ) {
134 134
         if ( isset( $_POST['isnetwork'] ) &&  $_POST['isnetwork'] ) {
135
-            $activate = activate_plugin( $_POST['plugin'], NULL, true );
135
+            $activate = activate_plugin( $_POST['plugin'], null, true );
136 136
         } else {
137 137
             $activate = activate_plugin( $_POST['plugin'] );
138 138
         }
Please login to merge, or discard this patch.