Passed
Branch master (82fe3a)
by Chris
02:49
created
includes/admin/partials/header.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,12 +10,12 @@
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 ?>
17 17
 <div id="monsterinsights-header-temp"></div>
18 18
 <div id="monsterinsights-header" class="monsterinsights-header">
19
-	<img class="monsterinsights-header-title" src="<?php echo esc_attr( $data['logo'] ); ?>" srcset="<?php echo esc_attr( $data['2xlogo'] ); ?> 2x" alt="<?php esc_attr__( 'MonsterInsights', 'google-analytics-for-wordpress' ); ?>"/>
20
-	<img class="monsterinsights-header-mascot" src="<?php echo esc_attr( $data['mascot'] ); ?>" srcset="<?php echo esc_attr( $data['2xmascot'] ); ?> 2x" alt="<?php esc_attr__( 'MonsterInsights Mascot', 'google-analytics-for-wordpress' ); ?>"/>
19
+	<img class="monsterinsights-header-title" src="<?php echo esc_attr($data['logo']); ?>" srcset="<?php echo esc_attr($data['2xlogo']); ?> 2x" alt="<?php esc_attr__('MonsterInsights', 'google-analytics-for-wordpress'); ?>"/>
20
+	<img class="monsterinsights-header-mascot" src="<?php echo esc_attr($data['mascot']); ?>" srcset="<?php echo esc_attr($data['2xmascot']); ?> 2x" alt="<?php esc_attr__('MonsterInsights Mascot', 'google-analytics-for-wordpress'); ?>"/>
21 21
 </div>
22 22
\ No newline at end of file
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 
12 12
 // Exit if accessed directly
13 13
 if ( ! defined( 'ABSPATH' ) ) {
14
-	exit;
14
+    exit;
15 15
 }
16 16
 ?>
17 17
 <div id="monsterinsights-header-temp"></div>
Please login to merge, or discard this patch.
includes/admin/google.php 3 patches
Spacing   +178 added lines, -178 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  */
14 14
 
15 15
 // Exit if accessed directly
16
-if ( ! defined( 'ABSPATH' ) ) {
16
+if ( ! defined('ABSPATH')) {
17 17
 	exit;
18 18
 }
19 19
 
@@ -96,21 +96,21 @@  discard block
 block discarded – undo
96 96
 		$this->name          = $this->get_name();
97 97
 		$this->oauth_version = $this->get_oauth_version();
98 98
 		$this->status        = $this->get_status();
99
-		$this->base 		 = MonsterInsights();
99
+		$this->base = MonsterInsights();
100 100
 
101 101
 
102 102
 		// Show any info/error notices
103 103
 		$this->get_notices();
104 104
 
105 105
 		// Authentication Actions
106
-		add_action( 'wp_ajax_monsterinsights_google_view',  array( $this, 'google_auth_view' ) );
107
-		add_action( 'wp_ajax_monsterinsights_google_cancel',  array( $this, 'google_cancel' ) );
106
+		add_action('wp_ajax_monsterinsights_google_view', array($this, 'google_auth_view'));
107
+		add_action('wp_ajax_monsterinsights_google_cancel', array($this, 'google_cancel'));
108 108
 
109
-		add_action( 'admin_init', array( $this, 'deactivate_google' ) ); // Deactivate
109
+		add_action('admin_init', array($this, 'deactivate_google')); // Deactivate
110 110
 	}
111 111
 
112 112
 	private function get_client() {
113
-		return ! empty( $this->client ) ? $this->client : monsterinsights_create_client();
113
+		return ! empty($this->client) ? $this->client : monsterinsights_create_client();
114 114
 	}
115 115
 
116 116
 	private function set_test_client() { 
@@ -127,11 +127,11 @@  discard block
 block discarded – undo
127 127
 	 * @return null
128 128
 	 */
129 129
 	private function get_profile() {
130
-		return monsterinsights_get_option( 'analytics_profile', false );
130
+		return monsterinsights_get_option('analytics_profile', false);
131 131
 	}
132 132
 
133 133
 	private function get_name() {
134
-		return monsterinsights_get_option( 'analytics_profile_name', false );
134
+		return monsterinsights_get_option('analytics_profile_name', false);
135 135
 	}
136 136
 
137 137
 	private function get_ua() {
@@ -139,37 +139,37 @@  discard block
 block discarded – undo
139 139
 	}
140 140
 
141 141
 	private function get_oauth_version() {
142
-		return monsterinsights_get_option( 'oauth_version', '1.0' );
142
+		return monsterinsights_get_option('oauth_version', '1.0');
143 143
 	}
144 144
 
145 145
 	private function get_status() {
146 146
 		$status = 'valid';
147
-		if ( ! empty( $this->profile ) ) {
147
+		if ( ! empty($this->profile)) {
148 148
 			// We are using oAuth
149 149
 			
150
-			$last_run = monsterinsights_get_option( 'cron_last_run', false );
151
-			$failed   = monsterinsights_get_option( 'cron_failed', false );
152
-			$dash_dis = monsterinsights_get_option( 'dashboards_disabled', false );
150
+			$last_run = monsterinsights_get_option('cron_last_run', false);
151
+			$failed   = monsterinsights_get_option('cron_failed', false);
152
+			$dash_dis = monsterinsights_get_option('dashboards_disabled', false);
153 153
 
154 154
 			// See if issue connecting or expired
155
-			if ( ! $dash_dis && $failed && ( $last_run === false || monsterinsights_hours_between( $last_run ) >= 48 )  ) { 
155
+			if ( ! $dash_dis && $failed && ($last_run === false || monsterinsights_hours_between($last_run) >= 48)) { 
156 156
 				$status = 'blocked';
157 157
 			}
158 158
 
159 159
 			$access_token = $this->client->get_access_token();
160 160
 
161 161
 			// Check to make sure access token is there and not expired
162
-			if ( empty( $access_token ) || empty( $access_token['expires'] ) || current_time( 'timestamp' ) >= $access_token['expires'] ) {
162
+			if (empty($access_token) || empty($access_token['expires']) || current_time('timestamp') >= $access_token['expires']) {
163 163
 				$status = 'expired';
164 164
 				return $status;
165 165
 			}
166 166
 
167 167
 			// See if needs permissions
168
-			if ( version_compare( $this->oauth_version, '1.0', '<' ) ) { 
168
+			if (version_compare($this->oauth_version, '1.0', '<')) { 
169 169
 				$status = 'needs-permissions';
170 170
 			}
171 171
 			
172
-		} else if ( ! empty( $this->ua ) ) {
172
+		} else if ( ! empty($this->ua)) {
173 173
 			// We are using manual
174 174
 			
175 175
 		} else {
@@ -182,31 +182,31 @@  discard block
 block discarded – undo
182 182
 
183 183
 	private function get_notices() {
184 184
 		// Notice for no manual or profile GA
185
-		if ( $this->status === 'empty' ) {
186
-			add_action( 'admin_notices', array( $this, 'monsterinsights_show_admin_config_empty_notice' ),6 );
185
+		if ($this->status === 'empty') {
186
+			add_action('admin_notices', array($this, 'monsterinsights_show_admin_config_empty_notice'), 6);
187 187
 		}
188 188
 
189
-		$current_page = filter_input( INPUT_GET, 'page' );
189
+		$current_page = filter_input(INPUT_GET, 'page');
190 190
 
191 191
 		// Only show expired, needs permission, or blocked notices on the MI pages
192 192
 		// We do this because unlike status empty, these only block reporting, not the frontend
193 193
 		// tracking from working, and as a result, these are not as urgent. Plus users generally
194 194
 		// don't like global notices.
195
-		if ( strpos( $current_page, 'monsterinsights' ) === 0 ) {
195
+		if (strpos($current_page, 'monsterinsights') === 0) {
196 196
 		
197 197
 			// Notice for GA Access token expired (needs re-authenticate)
198
-			if ( $this->status === 'expired' ) {
199
-				add_action( 'admin_notices', array( $this, 'monsterinsights_show_admin_config_expired_notice' ),6 );
198
+			if ($this->status === 'expired') {
199
+				add_action('admin_notices', array($this, 'monsterinsights_show_admin_config_expired_notice'), 6);
200 200
 			}
201 201
 			
202 202
 			// Notice for Needs Permissions
203
-			if ( $this->status === 'needs-permissions' ) {
204
-				add_action( 'admin_notices', array( $this, 'monsterinsights_show_admin_config_needs_permissions_notice' ),6 );
203
+			if ($this->status === 'needs-permissions') {
204
+				add_action('admin_notices', array($this, 'monsterinsights_show_admin_config_needs_permissions_notice'), 6);
205 205
 			}
206 206
 
207 207
 			// Notice for trouble connecting to Google
208
-			if ( $this->status === 'blocked' ) {
209
-				add_action( 'admin_notices', array( $this, 'monsterinsights_show_admin_config_blocked_notice' ),6 );
208
+			if ($this->status === 'blocked') {
209
+				add_action('admin_notices', array($this, 'monsterinsights_show_admin_config_blocked_notice'), 6);
210 210
 			}
211 211
 		}
212 212
 	}
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 		$this->status        = $this->get_status();
229 229
 
230 230
 		// Re-get data if possible
231
-		if ( $this->ua === 'valid' ) {
231
+		if ($this->ua === 'valid') {
232 232
 			$this->refresh_dashboard_data();
233 233
 		}
234 234
 	}
@@ -247,20 +247,20 @@  discard block
 block discarded – undo
247 247
 	 */
248 248
 	public function get_profiles() { // @todo: this needs exception handling for a 401 login required		
249 249
 		$accounts = $this->get_profiles_request();
250
-		if ( is_array( $accounts ) ) {
250
+		if (is_array($accounts)) {
251 251
 			return $accounts;
252 252
 		} else {
253 253
 			return array();
254 254
 		}
255 255
 	}
256 256
 
257
-	public function find_selected_profile( $profile_id ) {
257
+	public function find_selected_profile($profile_id) {
258 258
 		$profiles = $this->get_profiles();
259
-		$found  = array();
260
-		foreach ( $profiles as $account ) {
261
-			foreach ( $account['items'] as $profile ) {
262
-				foreach ( $profile['items'] as $subprofile ) {
263
-					if ( isset( $subprofile['id'] ) && $subprofile['id'] == $profile_id ) {
259
+		$found = array();
260
+		foreach ($profiles as $account) {
261
+			foreach ($account['items'] as $profile) {
262
+				foreach ($profile['items'] as $subprofile) {
263
+					if (isset($subprofile['id']) && $subprofile['id'] == $profile_id) {
264 264
 						$found = array(
265 265
 							'id'   => $profile_id,
266 266
 							'ua'   => $subprofile['ua_code'],
@@ -275,10 +275,10 @@  discard block
 block discarded – undo
275 275
 		return $found;
276 276
 	}
277 277
 
278
-	public function save_selected_profile( $profile ) {
279
-		monsterinsights_update_option( 'analytics_profile', $profile['id'] );
280
-		monsterinsights_update_option( 'analytics_profile_code', $profile['ua'] );
281
-		monsterinsights_update_option( 'analytics_profile_name', $profile['name'] );
278
+	public function save_selected_profile($profile) {
279
+		monsterinsights_update_option('analytics_profile', $profile['id']);
280
+		monsterinsights_update_option('analytics_profile_code', $profile['ua']);
281
+		monsterinsights_update_option('analytics_profile_name', $profile['name']);
282 282
 		monsterinsights_set_client_oauth_version();
283 283
 	}
284 284
 
@@ -292,43 +292,43 @@  discard block
 block discarded – undo
292 292
 	 */
293 293
 	private function get_profiles_request() {
294 294
 		global $wp_version;
295
-		$version = str_replace( '-src', '', $wp_version );
295
+		$version = str_replace('-src', '', $wp_version);
296 296
 		$accounts    = array();
297 297
 		$start_index = 1;
298 298
 		$paginate    = false;
299 299
 		$continue    = true;
300
-		while ( $continue ) {
301
-			$body     = array(
300
+		while ($continue) {
301
+			$body = array(
302 302
 				'max-results'  => 1000,
303 303
 				'start-index'  => $paginate ? $start_index + 1000 : $start_index,
304 304
 			);
305
-			if ( $paginate ) {
305
+			if ($paginate) {
306 306
 				$start_index = $start_index + 1000;
307 307
 			}
308
-			$response = $this->client->do_request( 'https://www.googleapis.com/analytics/v3/management/accounts/~all/webproperties/~all/profiles', false, 'GET', $body );
309
-			if ( ! empty( $response ) ) {
308
+			$response = $this->client->do_request('https://www.googleapis.com/analytics/v3/management/accounts/~all/webproperties/~all/profiles', false, 'GET', $body);
309
+			if ( ! empty($response)) {
310 310
 				$response = array(
311
-					'response' => array( 'code' => $this->client->get_http_response_code() ),
312
-					'body'     => json_decode( $response->getResponseBody(), true ),
311
+					'response' => array('code' => $this->client->get_http_response_code()),
312
+					'body'     => json_decode($response->getResponseBody(), true),
313 313
 				);
314 314
 			} else {
315
-				if ( version_compare( $version, '4.6', '<' ) ) {
316
-					return esc_html__( 'MonsterInsights requires WordPress version 4.6 or newer to use oAuth. Please update your WordPress version.', 'google-analytics-for-wordpress' );
315
+				if (version_compare($version, '4.6', '<')) {
316
+					return esc_html__('MonsterInsights requires WordPress version 4.6 or newer to use oAuth. Please update your WordPress version.', 'google-analytics-for-wordpress');
317 317
 				} else {
318
-					if ( ! empty( $accounts ) ) {
318
+					if ( ! empty($accounts)) {
319 319
 						return $accounts;
320 320
 					} else {
321
-						return esc_html__( 'Google Analytics had a connection error or your Google account is not signed up for Google Analytics.', 'google-analytics-for-wordpress' );
321
+						return esc_html__('Google Analytics had a connection error or your Google account is not signed up for Google Analytics.', 'google-analytics-for-wordpress');
322 322
 					}
323 323
 				}
324 324
 			}
325 325
 			
326
-			if ( isset( $response['response']['code'] ) && $response['response']['code'] == 200 ) {
327
-				if ( ! empty( $response['body']['items'] ) && is_array( $response['body']['items'] ) ) {
328
-					foreach ( $response['body']['items'] as $item ) {
326
+			if (isset($response['response']['code']) && $response['response']['code'] == 200) {
327
+				if ( ! empty($response['body']['items']) && is_array($response['body']['items'])) {
328
+					foreach ($response['body']['items'] as $item) {
329 329
 
330 330
 						// Only deal with web properties, not apps.
331
-						if ( isset( $item['type'] ) && 'WEB' != $item['type'] ) {
331
+						if (isset($item['type']) && 'WEB' != $item['type']) {
332 332
 							continue;
333 333
 						}
334 334
 
@@ -375,8 +375,8 @@  discard block
 block discarded – undo
375 375
 						*/
376 376
 
377 377
 
378
-						if ( empty( $accounts[ $item['accountId'] ] ) ) {
379
-							$accounts[ $item['accountId'] ] = array( 
378
+						if (empty($accounts[$item['accountId']])) {
379
+							$accounts[$item['accountId']] = array( 
380 380
 								'id'          => $item['accountId'],
381 381
 								'ua_code'     => $item['webPropertyId'],
382 382
 								'parent_name' => $item['websiteUrl'],
@@ -384,16 +384,16 @@  discard block
 block discarded – undo
384 384
 							);
385 385
 						}
386 386
 
387
-						if ( empty( $accounts[ $item['accountId'] ]['items'][ $item['internalWebPropertyId'] ] ) ) {
388
-							$accounts[ $item['accountId'] ]['items'][ $item['internalWebPropertyId'] ]= array( 
387
+						if (empty($accounts[$item['accountId']]['items'][$item['internalWebPropertyId']])) {
388
+							$accounts[$item['accountId']]['items'][$item['internalWebPropertyId']] = array( 
389 389
 								'id'          => $item['webPropertyId'],
390 390
 								'name'        => $item['websiteUrl'],
391 391
 								'items'       => array(),
392 392
 							);
393 393
 						}
394 394
 
395
-						if ( empty( $accounts[ $item['accountId'] ]['items'][ $item['internalWebPropertyId'] ]['items'][ $item['id'] ] ) ) {
396
-							$accounts[ $item['accountId'] ]['items'][ $item['internalWebPropertyId'] ]['items'][ $item['id'] ] = array( 
395
+						if (empty($accounts[$item['accountId']]['items'][$item['internalWebPropertyId']]['items'][$item['id']])) {
396
+							$accounts[$item['accountId']]['items'][$item['internalWebPropertyId']]['items'][$item['id']] = array( 
397 397
 								'name'    => $item['name'] . ' (' . $item['webPropertyId'] . ')',
398 398
 								'ua_code' => $item['webPropertyId'],
399 399
 								'id'      => $item['id'],
@@ -401,37 +401,37 @@  discard block
 block discarded – undo
401 401
 						}
402 402
 					}
403 403
 				}
404
-			} else if ( isset( $response['response']['code'] ) && $response['response']['code'] !== 200 && ! $paginate ) {
405
-				if ( version_compare( $version, '4.6', '<' ) ) {
406
-					return esc_html__( 'MonsterInsights requires WordPress version 4.6 or newer to use oAuth. Please update your WordPress version.', 'google-analytics-for-wordpress' );
404
+			} else if (isset($response['response']['code']) && $response['response']['code'] !== 200 && ! $paginate) {
405
+				if (version_compare($version, '4.6', '<')) {
406
+					return esc_html__('MonsterInsights requires WordPress version 4.6 or newer to use oAuth. Please update your WordPress version.', 'google-analytics-for-wordpress');
407 407
 				} else {
408
-					if ( ! empty( $accounts ) ) {
408
+					if ( ! empty($accounts)) {
409 409
 						return $accounts;
410 410
 					} else {
411
-						$code = isset( $response['response']['code'] ) ? $response['response']['code'] : 'Unknown';
412
-						$type = isset( $response['body']['error']['errors'][0]['reason'] ) ? $response['body']['error']['errors'][0]['reason'] : false;
413
-						if ( $type === 'insufficientPermissions' ) {
414
-							return esc_html__( 'Please ensure your Google Account is signed up for Google Analytics.', 'google-analytics-for-wordpress' );
415
-						} else if ( $type === 'badRequest' ) {
416
-							return esc_html__( 'Bad Request. Please contact support.', 'google-analytics-for-wordpress' );
417
-						} else if ( $type === 'dailyLimitExceeded' ) {
418
-							return esc_html__( 'Daily Limit Exceeded. Please contact support.', 'google-analytics-for-wordpress' );
419
-						} else if ( $type === 'userRateLimitExceeded' ) {
420
-							return esc_html__( 'User Rate Limit Exceeded. Wait 2 minutes and then try again.', 'google-analytics-for-wordpress' );
421
-						} else if ( $type === 'rateLimitExceeded' ) {
422
-							return esc_html__( 'Project Rate Limit Exceeded. Wait 2 minutes and then try again.', 'google-analytics-for-wordpress' );
423
-						} else if ( $type === 'quotaExceeded' ) {
424
-							return esc_html__( 'Project Rate Limit Quota Exceeded. Wait 2 minutes and then try again.', 'google-analytics-for-wordpress' );
425
-						} else if ( $type === 'internalServerError' || $type === 'backendError' ) {
426
-							return esc_html__( 'Google Analytics is having API issues on their side. Wait 2 minutes and then try again.', 'google-analytics-for-wordpress' );
411
+						$code = isset($response['response']['code']) ? $response['response']['code'] : 'Unknown';
412
+						$type = isset($response['body']['error']['errors'][0]['reason']) ? $response['body']['error']['errors'][0]['reason'] : false;
413
+						if ($type === 'insufficientPermissions') {
414
+							return esc_html__('Please ensure your Google Account is signed up for Google Analytics.', 'google-analytics-for-wordpress');
415
+						} else if ($type === 'badRequest') {
416
+							return esc_html__('Bad Request. Please contact support.', 'google-analytics-for-wordpress');
417
+						} else if ($type === 'dailyLimitExceeded') {
418
+							return esc_html__('Daily Limit Exceeded. Please contact support.', 'google-analytics-for-wordpress');
419
+						} else if ($type === 'userRateLimitExceeded') {
420
+							return esc_html__('User Rate Limit Exceeded. Wait 2 minutes and then try again.', 'google-analytics-for-wordpress');
421
+						} else if ($type === 'rateLimitExceeded') {
422
+							return esc_html__('Project Rate Limit Exceeded. Wait 2 minutes and then try again.', 'google-analytics-for-wordpress');
423
+						} else if ($type === 'quotaExceeded') {
424
+							return esc_html__('Project Rate Limit Quota Exceeded. Wait 2 minutes and then try again.', 'google-analytics-for-wordpress');
425
+						} else if ($type === 'internalServerError' || $type === 'backendError') {
426
+							return esc_html__('Google Analytics is having API issues on their side. Wait 2 minutes and then try again.', 'google-analytics-for-wordpress');
427 427
 						} else {
428
-							return sprintf( esc_html__( 'Google Analytics had a connection error. Error code: %1$s. Reason: %2$s', 'google-analytics-for-wordpress' ), $code, $type );
428
+							return sprintf(esc_html__('Google Analytics had a connection error. Error code: %1$s. Reason: %2$s', 'google-analytics-for-wordpress'), $code, $type);
429 429
 						}
430 430
 					}
431 431
 				}
432 432
 			}
433 433
 
434
-			if ( isset( $response['body']['totalResults'] ) && $start_index < $response['body']['totalResults'] && ! empty( $response['body']['nextLink'] ) ) {
434
+			if (isset($response['body']['totalResults']) && $start_index < $response['body']['totalResults'] && ! empty($response['body']['nextLink'])) {
435 435
 				$paginate    = true;
436 436
 			} else {
437 437
 				$continue    = false;
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
 			'cron_failed',
451 451
 			'cron_last_run',
452 452
 		);
453
-		monsterinsights_delete_options( $options );
453
+		monsterinsights_delete_options($options);
454 454
 
455 455
 		// Destroy the data
456 456
 		$this->base->reports->delete_aggregate_data();
@@ -460,20 +460,20 @@  discard block
 block discarded – undo
460 460
 
461 461
 	private function clear_manual_data() {
462 462
 		// Delete the manual ua code
463
-		monsterinsights_delete_option( 'manual_ua_code' );
463
+		monsterinsights_delete_option('manual_ua_code');
464 464
 	}
465 465
 
466 466
 	public function deactivate_google() {
467 467
 		// Check if user pressed the deactivate button and nonce is valid
468
-		if ( ! isset( $_POST['monsterinsights-google-deauthenticate-submit'] ) ) {
468
+		if ( ! isset($_POST['monsterinsights-google-deauthenticate-submit'])) {
469 469
 			return;
470 470
 		}
471 471
 
472
-		if ( ! wp_verify_nonce( $_POST['monsterinsights-google-authenticated-nonce'], 'monsterinsights-google-authenticated-nonce' ) ) {
472
+		if ( ! wp_verify_nonce($_POST['monsterinsights-google-authenticated-nonce'], 'monsterinsights-google-authenticated-nonce')) {
473 473
 			return;
474 474
 		}
475 475
 
476
-		if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
476
+		if ( ! current_user_can('monsterinsights_save_settings')) {
477 477
 			return;
478 478
 		}
479 479
 
@@ -508,12 +508,12 @@  discard block
 block discarded – undo
508 508
 	 *
509 509
 	 * @return array|null
510 510
 	 */
511
-	public function do_request( $target_request_url ) {
512
-		$response = $this->client->do_request( $target_request_url );
513
-		if ( ! empty( $response ) ) {
511
+	public function do_request($target_request_url) {
512
+		$response = $this->client->do_request($target_request_url);
513
+		if ( ! empty($response)) {
514 514
 			return array(
515
-				'response' => array( 'code' => $this->client->get_http_response_code() ),
516
-				'body'     => json_decode( $response->getResponseBody(), true ),
515
+				'response' => array('code' => $this->client->get_http_response_code()),
516
+				'body'     => json_decode($response->getResponseBody(), true),
517 517
 			);
518 518
 		}
519 519
 	}
@@ -525,113 +525,113 @@  discard block
 block discarded – undo
525 525
 	 *
526 526
 	 * @return boolean
527 527
 	 */
528
-	public function authenticate( $authentication_code = null ) {
528
+	public function authenticate($authentication_code = null) {
529 529
 		// When authentication again we should clean up some stuff
530
-		monsterinsights_delete_options( array( 'cron_last_run', 'cron_failed' ) );
531
-		return $this->client->authenticate_client( $authentication_code );
530
+		monsterinsights_delete_options(array('cron_last_run', 'cron_failed'));
531
+		return $this->client->authenticate_client($authentication_code);
532 532
 	}
533 533
 
534 534
 	public function google_auth_view() {
535
-		$view   = isset( $_POST['view'] ) && in_array( $_POST['view'], array( 'prestart', 'start', 'enterkey', 'selectprofile', 'done' ) ) ? $_POST['view'] : '';
536
-		$reauth = isset( $_POST['reauth'] ) && $_POST['reauth'] && $_POST['reauth'] !== 'false'  ? true : false;
535
+		$view   = isset($_POST['view']) && in_array($_POST['view'], array('prestart', 'start', 'enterkey', 'selectprofile', 'done')) ? $_POST['view'] : '';
536
+		$reauth = isset($_POST['reauth']) && $_POST['reauth'] && $_POST['reauth'] !== 'false' ? true : false;
537 537
 
538
-		if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
539
-			echo esc_html__( 'Permission Denied', 'google-analytics-for-wordpress');
538
+		if ( ! current_user_can('monsterinsights_save_settings')) {
539
+			echo esc_html__('Permission Denied', 'google-analytics-for-wordpress');
540 540
 			wp_die();
541 541
 		}
542 542
 
543 543
 		// We run the save routines, if required, for a view, and then after that send back the results + next view
544 544
 		$nextview = array();
545 545
 
546
-		switch ( $view ) {
546
+		switch ($view) {
547 547
 			case 'start':
548
-				if ( ! $this->is_wp_blocking_google() && ! $this->is_google_on_blacklist() ) {
548
+				if ( ! $this->is_wp_blocking_google() && ! $this->is_google_on_blacklist()) {
549 549
 					$auth_url = $this->create_auth_url();
550
-					$nextview = monsterinsights_google_auth_enterkey_view( $reauth, $auth_url );
550
+					$nextview = monsterinsights_google_auth_enterkey_view($reauth, $auth_url);
551 551
 				} else {
552
-					$error    = esc_html__( 'Cannot connect to Google', 'google-analytics-for-wordpress' );
553
-					$nextview = monsterinsights_google_auth_error_view( $reauth, $error );
552
+					$error    = esc_html__('Cannot connect to Google', 'google-analytics-for-wordpress');
553
+					$nextview = monsterinsights_google_auth_error_view($reauth, $error);
554 554
 				}
555 555
 				break;
556 556
 
557 557
 			case 'enterkey':
558
-				$auth_key = ! empty( $_POST['stepdata'] ) ? sanitize_text_field( $_POST['stepdata'] ) : '';
559
-				if ( $auth_key ) {
560
-					if ( $this->test_authkey( $auth_key ) ) {
558
+				$auth_key = ! empty($_POST['stepdata']) ? sanitize_text_field($_POST['stepdata']) : '';
559
+				if ($auth_key) {
560
+					if ($this->test_authkey($auth_key)) {
561 561
 						$profiles = $this->get_profiles_request();
562
-						delete_option( 'monsterinsights_get_profiles' );
563
-						update_option( 'monsterinsights_get_profiles', $profiles );
564
-						if ( ! empty( $profiles ) && is_array( $profiles ) ) {
565
-							$select = $this->ga_select( $profiles );
566
-							$nextview = monsterinsights_google_auth_selectprofile_view( $reauth, $select );
567
-						} else if ( ! empty( $profiles ) && is_string( $profiles ) ) {
562
+						delete_option('monsterinsights_get_profiles');
563
+						update_option('monsterinsights_get_profiles', $profiles);
564
+						if ( ! empty($profiles) && is_array($profiles)) {
565
+							$select = $this->ga_select($profiles);
566
+							$nextview = monsterinsights_google_auth_selectprofile_view($reauth, $select);
567
+						} else if ( ! empty($profiles) && is_string($profiles)) {
568 568
 							// Error from Google
569 569
 							$auth_url = $this->create_auth_url();
570 570
 							$this->client->clear_data();
571 571
 							$this->set_test_client();
572
-							$nextview = monsterinsights_google_auth_enterkey_view( $reauth, $auth_url, esc_html( $profiles ) );
572
+							$nextview = monsterinsights_google_auth_enterkey_view($reauth, $auth_url, esc_html($profiles));
573 573
 						} else {
574 574
 							// No profiles or not enough permissions
575 575
 							$auth_url = $this->create_auth_url();
576 576
 							$this->client->clear_data();
577 577
 							$this->set_test_client();
578
-							$nextview = monsterinsights_google_auth_enterkey_view( $reauth, $auth_url, esc_html__( 'No profiles viewable for that account. Please use another account.', 'google-analytics-for-wordpress' ) );
578
+							$nextview = monsterinsights_google_auth_enterkey_view($reauth, $auth_url, esc_html__('No profiles viewable for that account. Please use another account.', 'google-analytics-for-wordpress'));
579 579
 						}
580 580
 					} else {
581 581
 						// if bad authentication error message
582 582
 						$auth_url = $this->create_auth_url();
583 583
 						$this->client->clear_data();
584 584
 						$this->set_test_client();
585
-						$nextview = monsterinsights_google_auth_enterkey_view( $reauth, $auth_url, esc_html__( 'Bad Google Code. Please try again.', 'google-analytics-for-wordpress' ) );
585
+						$nextview = monsterinsights_google_auth_enterkey_view($reauth, $auth_url, esc_html__('Bad Google Code. Please try again.', 'google-analytics-for-wordpress'));
586 586
 					}
587 587
 				} else {
588 588
 					$auth_url = $this->create_auth_url();
589 589
 					$this->client->clear_data();
590 590
 					$this->set_test_client();
591 591
 					// if no auth key error message
592
-					$nextview = monsterinsights_google_auth_enterkey_view( $reauth, $auth_url, esc_html__( 'Please paste in your Google code.', 'google-analytics-for-wordpress' ) );
592
+					$nextview = monsterinsights_google_auth_enterkey_view($reauth, $auth_url, esc_html__('Please paste in your Google code.', 'google-analytics-for-wordpress'));
593 593
 				}
594 594
 				break;
595 595
 
596 596
 			case 'selectprofile':
597
-				$profile = ! empty( $_POST['stepdata'] ) ? absint( sanitize_text_field( $_POST['stepdata'] ) ) : '';
598
-				if ( ! empty( $profile ) ) {
597
+				$profile = ! empty($_POST['stepdata']) ? absint(sanitize_text_field($_POST['stepdata'])) : '';
598
+				if ( ! empty($profile)) {
599 599
 					$this->set_test_client();
600
-					$profile = $this->find_selected_profile( $profile );
601
-					if ( ! empty( $profile ) ) {
600
+					$profile = $this->find_selected_profile($profile);
601
+					if ( ! empty($profile)) {
602 602
 
603 603
 						$this->clear_manual_data(); // Just in case we were manual, clear out UA
604 604
 
605 605
 						$this->client->move_test_to_live();
606
-						$this->save_selected_profile( $profile );
606
+						$this->save_selected_profile($profile);
607 607
 						$this->set_client();
608 608
 						$this->reinitialize();
609 609
 
610 610
 						// Refresh reporting data
611 611
 						$this->base->reports->refresh_aggregate_data();
612 612
 
613
-						$nextview = monsterinsights_google_auth_done_view( $reauth );
613
+						$nextview = monsterinsights_google_auth_done_view($reauth);
614 614
 					} else {
615 615
 						// Invalid profile selected
616
-						$profiles = get_option( 'monsterinsights_get_profiles', array() );
617
-						$select   = $this->ga_select( $profiles );
618
-						$nextview = monsterinsights_google_auth_selectprofile_view( $reauth, $select, esc_html__( 'Invalid profile selected.', 'google-analytics-for-wordpress' ) );
616
+						$profiles = get_option('monsterinsights_get_profiles', array());
617
+						$select   = $this->ga_select($profiles);
618
+						$nextview = monsterinsights_google_auth_selectprofile_view($reauth, $select, esc_html__('Invalid profile selected.', 'google-analytics-for-wordpress'));
619 619
 					}
620 620
 				} else { 
621 621
 					// No profile selected
622
-					$profiles = get_option( 'monsterinsights_get_profiles', array() );
623
-					$select   = $this->ga_select( $profiles );
624
-					$nextview = monsterinsights_google_auth_selectprofile_view( $reauth, $select, esc_html__( 'Please select a profile.', 'google-analytics-for-wordpress' ) );
622
+					$profiles = get_option('monsterinsights_get_profiles', array());
623
+					$select   = $this->ga_select($profiles);
624
+					$nextview = monsterinsights_google_auth_selectprofile_view($reauth, $select, esc_html__('Please select a profile.', 'google-analytics-for-wordpress'));
625 625
 				}
626 626
 				break;
627 627
 
628 628
 			case 'done':
629
-				$nextview = monsterinsights_google_auth_done_view( $reauth );
629
+				$nextview = monsterinsights_google_auth_done_view($reauth);
630 630
 				break;
631 631
 				
632 632
 			case 'prestart':
633 633
 			default:
634
-				 $nextview = monsterinsights_google_auth_start_view( $reauth );
634
+				 $nextview = monsterinsights_google_auth_start_view($reauth);
635 635
 				break;
636 636
 		}
637 637
 		echo $nextview;
@@ -639,25 +639,25 @@  discard block
 block discarded – undo
639 639
 	}
640 640
 
641 641
 	public function google_cancel() {
642
-		$view   = isset( $_POST['view'] ) && in_array( $_POST['view'], array( 'prestart', 'start', 'enterkey', 'selectprofile', 'done' ) ) ? $_POST['view'] : '';
643
-		$reauth = isset( $_POST['reauth'] ) && $_POST['reauth'] && $_POST['reauth'] !== 'false'  ? true : false;
642
+		$view   = isset($_POST['view']) && in_array($_POST['view'], array('prestart', 'start', 'enterkey', 'selectprofile', 'done')) ? $_POST['view'] : '';
643
+		$reauth = isset($_POST['reauth']) && $_POST['reauth'] && $_POST['reauth'] !== 'false' ? true : false;
644 644
 
645
-		if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
646
-			echo esc_html__( 'Permission Denied', 'google-analytics-for-wordpress');
645
+		if ( ! current_user_can('monsterinsights_save_settings')) {
646
+			echo esc_html__('Permission Denied', 'google-analytics-for-wordpress');
647 647
 			wp_die();
648 648
 		}
649 649
 
650 650
 		// If we cancelled on enterkey or selectprofile, delete the temp access tokens and set client back to normal client
651
-		if ( $view === 'enterkey' || $view === 'selectprofile' ) {
651
+		if ($view === 'enterkey' || $view === 'selectprofile') {
652 652
 			$this->client->clear_data();
653
-			delete_option( 'monsterinsights_get_profiles' );
653
+			delete_option('monsterinsights_get_profiles');
654 654
 			$this->set_client();
655 655
 		}
656 656
 	}
657 657
 
658
-	private function test_authkey( $authkey ) {
658
+	private function test_authkey($authkey) {
659 659
 		$this->set_test_client();
660
-		$result = $this->authenticate( $authkey );
660
+		$result = $this->authenticate($authkey);
661 661
 		return $result;
662 662
 	}
663 663
 
@@ -666,18 +666,18 @@  discard block
 block discarded – undo
666 666
 	 *
667 667
 	 * @return null|string
668 668
 	 */
669
-	private function ga_select( $profiles = array() ) {
670
-		if ( empty( $profiles ) || ! is_array( $profiles ) ) { 
669
+	private function ga_select($profiles = array()) {
670
+		if (empty($profiles) || ! is_array($profiles)) { 
671 671
 			$profiles = $this->get_profiles();
672 672
 		}
673 673
 		
674 674
 		$optgroups = array();
675
-		foreach ( $profiles as $key => $value ) {
676
-			foreach ( $value['items'] as $subitem ) {
677
-				if ( empty( $optgroups[ $subitem['name'] ]['items'] ) ) {
678
-					$optgroups[ $subitem['name'] ]['items'] = $subitem['items'];
675
+		foreach ($profiles as $key => $value) {
676
+			foreach ($value['items'] as $subitem) {
677
+				if (empty($optgroups[$subitem['name']]['items'])) {
678
+					$optgroups[$subitem['name']]['items'] = $subitem['items'];
679 679
 				} else {
680
-					$optgroups[ $subitem['name'] ]['items'] = array_merge( $optgroups[ $subitem['name'] ]['items'], $subitem['items'] );
680
+					$optgroups[$subitem['name']]['items'] = array_merge($optgroups[$subitem['name']]['items'], $subitem['items']);
681 681
 				}
682 682
 			}
683 683
 		}
@@ -685,17 +685,17 @@  discard block
 block discarded – undo
685 685
 		$values = $optgroups;
686 686
 		$select = '';
687 687
 		$select .= '<div class="monsterinsights_ga_form">';
688
-		$select .= '<label for="monsterinsights_step_data" id="monsterinsights_select_ga_profile_label">' . esc_html__( 'Analytics profile', 'google-analytics-for-wordpress' ) . ':</label>';
689
-		$select .= '<select data-placeholder="' . esc_attr__( 'Select a profile', 'google-analytics-for-wordpress' ) . '" name="monsterinsights_step_data" class="monsterinsights-select300 monsterinsights_select_ga_profile" id="monsterinsights_step_data" style="width:80%;margin-left:10%;margin-right:10%;background-color: #FFF;">';
688
+		$select .= '<label for="monsterinsights_step_data" id="monsterinsights_select_ga_profile_label">' . esc_html__('Analytics profile', 'google-analytics-for-wordpress') . ':</label>';
689
+		$select .= '<select data-placeholder="' . esc_attr__('Select a profile', 'google-analytics-for-wordpress') . '" name="monsterinsights_step_data" class="monsterinsights-select300 monsterinsights_select_ga_profile" id="monsterinsights_step_data" style="width:80%;margin-left:10%;margin-right:10%;background-color: #FFF;">';
690 690
 		$select .= '<option></option>';
691 691
 
692
-		if ( count( $values ) >= 1 ) {
693
-			foreach ( $values as $optgroup => $value ) {
694
-				if ( ! empty( $value['items'] ) ) {
695
-					$select .= $this->create_optgroup( $optgroup, $value );
692
+		if (count($values) >= 1) {
693
+			foreach ($values as $optgroup => $value) {
694
+				if ( ! empty($value['items'])) {
695
+					$select .= $this->create_optgroup($optgroup, $value);
696 696
 				}
697 697
 				else {
698
-					$select .= '<option value="' . esc_attr( $value['id'] ) . '">' . esc_attr( stripslashes( $value['name'] ) ) . '</option>';
698
+					$select .= '<option value="' . esc_attr($value['id']) . '">' . esc_attr(stripslashes($value['name'])) . '</option>';
699 699
 				}
700 700
 			}
701 701
 		}
@@ -713,16 +713,16 @@  discard block
 block discarded – undo
713 713
 	 *
714 714
 	 * @return string
715 715
 	 */
716
-	private function create_optgroup( $optgroup, $value ) {
717
-		$optgroup = '<optgroup label="' . esc_attr( $optgroup ) . '" disabled>';
716
+	private function create_optgroup($optgroup, $value) {
717
+		$optgroup = '<optgroup label="' . esc_attr($optgroup) . '" disabled>';
718 718
 
719
-		foreach ( $value['items'] as $option ) {
720
-			if ( ! empty( $option['items'] ) ) {
719
+		foreach ($value['items'] as $option) {
720
+			if ( ! empty($option['items'])) {
721 721
 
722
-				$optgroup .= $this->create_optgroup( esc_attr( $option['name'] ), $option );
722
+				$optgroup .= $this->create_optgroup(esc_attr($option['name']), $option);
723 723
 			}
724 724
 			else {
725
-				$optgroup .= '<option value="' . esc_attr( $option['id'] ) . '">' . esc_attr( stripslashes( $option['name'] ) ) . '</option>';
725
+				$optgroup .= '<option value="' . esc_attr($option['id']) . '">' . esc_attr(stripslashes($option['name'])) . '</option>';
726 726
 			}
727 727
 		}
728 728
 
@@ -737,10 +737,10 @@  discard block
 block discarded – undo
737 737
 	 * @return bool 
738 738
 	 */
739 739
 	private function is_wp_blocking_google() {
740
-		if ( defined( 'WP_HTTP_BLOCK_EXTERNAL' ) && WP_HTTP_BLOCK_EXTERNAL ) { // @todo: put this in sysinfo 
741
-			if ( defined( 'WP_ACCESSIBLE_HOSTS' ) ) {
740
+		if (defined('WP_HTTP_BLOCK_EXTERNAL') && WP_HTTP_BLOCK_EXTERNAL) { // @todo: put this in sysinfo 
741
+			if (defined('WP_ACCESSIBLE_HOSTS')) {
742 742
 				$on_blacklist = $this->is_google_on_blacklist();
743
-				if ( $on_blacklist ) {
743
+				if ($on_blacklist) {
744 744
 					return true;
745 745
 				} else {
746 746
 					$params = array(
@@ -749,8 +749,8 @@  discard block
 block discarded – undo
749 749
 						'user-agent'    => 'MonsterInsights/' . MONSTERINSIGHTS_VERSION,
750 750
 						'body'          => ''
751 751
 					);
752
-					$response = wp_remote_get( 'https://www.googleapis.com/discovery/v1/apis/analytics/v3/rest', $params );
753
-					if( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
752
+					$response = wp_remote_get('https://www.googleapis.com/discovery/v1/apis/analytics/v3/rest', $params);
753
+					if ( ! is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300) {
754 754
 						return false;
755 755
 					} else {
756 756
 						return true;
@@ -766,9 +766,9 @@  discard block
 block discarded – undo
766 766
 				'user-agent'    => 'MonsterInsights/' . MONSTERINSIGHTS_VERSION,
767 767
 				'body'          => ''
768 768
 			);
769
-			$response = wp_remote_get( 'https://www.googleapis.com/discovery/v1/apis/analytics/v3/rest', $params );
769
+			$response = wp_remote_get('https://www.googleapis.com/discovery/v1/apis/analytics/v3/rest', $params);
770 770
 			
771
-			if( !is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
771
+			if ( ! is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300) {
772 772
 				return false;
773 773
 			} else {
774 774
 				return true;
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
 	 */
784 784
 	private function is_google_on_blacklist() { // @todo: put this in sysinfo
785 785
 		$wp_http = new WP_Http();
786
-		if ( $wp_http->block_request( 'https://www.googleapis.com/discovery/v1/apis/analytics/v3/rest' ) ) {
786
+		if ($wp_http->block_request('https://www.googleapis.com/discovery/v1/apis/analytics/v3/rest')) {
787 787
 			return true;
788 788
 		}
789 789
 
@@ -792,16 +792,16 @@  discard block
 block discarded – undo
792 792
 
793 793
 	public function monsterinsights_show_admin_config_empty_notice() {
794 794
 		$screen = get_current_screen(); 
795
-		if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) !== false ) {
795
+		if (empty($screen->id) || strpos($screen->id, 'monsterinsights') !== false) {
796 796
 			return;
797 797
 		}
798 798
 		
799
-		if ( ! defined( 'MONSTERINSIGHTS_SHOWING_EMPTY_CONFIG_NOTICE' ) ) {
800
-			define( 'MONSTERINSIGHTS_SHOWING_EMPTY_CONFIG_NOTICE', true );
799
+		if ( ! defined('MONSTERINSIGHTS_SHOWING_EMPTY_CONFIG_NOTICE')) {
800
+			define('MONSTERINSIGHTS_SHOWING_EMPTY_CONFIG_NOTICE', true);
801 801
 		}
802 802
 		echo '<div class="error"><p>' . 
803
-			sprintf( esc_html__( 'Please configure your %1$sGoogle Analytics settings%2$s!', 'google-analytics-for-wordpress' ),
804
-				'<a href="' . admin_url( 'admin.php?page=monsterinsights_settings' ) . '">',
803
+			sprintf(esc_html__('Please configure your %1$sGoogle Analytics settings%2$s!', 'google-analytics-for-wordpress'),
804
+				'<a href="' . admin_url('admin.php?page=monsterinsights_settings') . '">',
805 805
 				'</a>'
806 806
 			)
807 807
 		. '</p></div>';
@@ -813,8 +813,8 @@  discard block
 block discarded – undo
813 813
 	public function monsterinsights_show_admin_config_expired_notice() {
814 814
 		echo '<div class="error"><p>' . 
815 815
 			sprintf(
816
-				esc_html__( 'It seems the authentication for the plugin has expired or the connection to Google Analytics is blocked, please try %1$sre-authenticating%2$s with Google Analytics to allow the plugin to fetch data.', 'google-analytics-for-wordpress' ),
817
-				'<a href="' . admin_url( 'admin.php?page=monsterinsights_settings' ) . '">',
816
+				esc_html__('It seems the authentication for the plugin has expired or the connection to Google Analytics is blocked, please try %1$sre-authenticating%2$s with Google Analytics to allow the plugin to fetch data.', 'google-analytics-for-wordpress'),
817
+				'<a href="' . admin_url('admin.php?page=monsterinsights_settings') . '">',
818 818
 				'</a>'
819 819
 			)
820 820
 		. '</p></div>';
@@ -826,8 +826,8 @@  discard block
 block discarded – undo
826 826
 	public function monsterinsights_show_admin_config_needs_permissions_notice() {
827 827
 		echo '<div class="error"><p>' . 
828 828
 			sprintf(
829
-				esc_html__( 'It seems the authentication for the plugin is missing permissions. Please %1$sre-authenticate%2$s with Google Analytics to allow the plugin to fetch data.', 'google-analytics-for-wordpress' ),
830
-				'<a href="' . admin_url( 'admin.php?page=monsterinsights_settings' ) . '">',
829
+				esc_html__('It seems the authentication for the plugin is missing permissions. Please %1$sre-authenticate%2$s with Google Analytics to allow the plugin to fetch data.', 'google-analytics-for-wordpress'),
830
+				'<a href="' . admin_url('admin.php?page=monsterinsights_settings') . '">',
831 831
 				'</a>'
832 832
 			)
833 833
 		. '</p></div>';
@@ -839,7 +839,7 @@  discard block
 block discarded – undo
839 839
 	public function monsterinsights_show_admin_config_blocked_notice() {
840 840
 		echo '<div class="error"><p>' . 
841 841
 			sprintf(
842
-				esc_html__( 'Data is not up-to-date, there was an error in retrieving the data from Google Analytics. This error could be caused by several issues. If the error persists, please see %1$sthis page%2$s.', 'google-analytics-for-wordpress' ),
842
+				esc_html__('Data is not up-to-date, there was an error in retrieving the data from Google Analytics. This error could be caused by several issues. If the error persists, please see %1$sthis page%2$s.', 'google-analytics-for-wordpress'),
843 843
 				'<a href="https://www.monsterinsights.com/docs/blocked-connection/">',
844 844
 				'</a>'
845 845
 			)
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -693,8 +693,7 @@  discard block
 block discarded – undo
693 693
 			foreach ( $values as $optgroup => $value ) {
694 694
 				if ( ! empty( $value['items'] ) ) {
695 695
 					$select .= $this->create_optgroup( $optgroup, $value );
696
-				}
697
-				else {
696
+				} else {
698 697
 					$select .= '<option value="' . esc_attr( $value['id'] ) . '">' . esc_attr( stripslashes( $value['name'] ) ) . '</option>';
699 698
 				}
700 699
 			}
@@ -720,8 +719,7 @@  discard block
 block discarded – undo
720 719
 			if ( ! empty( $option['items'] ) ) {
721 720
 
722 721
 				$optgroup .= $this->create_optgroup( esc_attr( $option['name'] ), $option );
723
-			}
724
-			else {
722
+			} else {
725 723
 				$optgroup .= '<option value="' . esc_attr( $option['id'] ) . '">' . esc_attr( stripslashes( $option['name'] ) ) . '</option>';
726 724
 			}
727 725
 		}
Please login to merge, or discard this patch.
Indentation   +792 added lines, -792 removed lines patch added patch discarded remove patch
@@ -14,345 +14,345 @@  discard block
 block discarded – undo
14 14
 
15 15
 // Exit if accessed directly
16 16
 if ( ! defined( 'ABSPATH' ) ) {
17
-	exit;
17
+    exit;
18 18
 }
19 19
 
20 20
 final class MonsterInsights_GA {
21 21
 
22
-	/**
23
-	 * Holds the GA client object if using oAuth.
24
-	 *
25
-	 * @access public
26
-	 * @since 6.0.0
27
-	 * @var MonsterInsights_GA_Client $client GA client object.
28
-	 */
29
-	public $client;
30
-
31
-	/**
32
-	 * Google Profile ID.
33
-	 *
34
-	 * @access public
35
-	 * @since 6.0.0
36
-	 * @var int $profile ID of profile in use.
37
-	 */
38
-	public $profile;
39
-
40
-	/**
41
-	 * Google UA code.
42
-	 *
43
-	 * @access public
44
-	 * @since 6.0.0
45
-	 * @var string|false $ua Google UA code for the current profile if valid oAuth in use, else false.
46
-	 */
47
-	public $ua;
48
-
49
-	/**
50
-	 * Google profile name.
51
-	 *
52
-	 * @access public
53
-	 * @since 6.0.0
54
-	 * @var string|false $ua Google profile name for the current profile if valid oAuth in use, else false.
55
-	 */
56
-	public $name;
57
-
58
-	/**
59
-	 * Status of Google client object.
60
-	 *
61
-	 * @access public
62
-	 * @since 6.0.0
63
-	 * @var string $status Possible values include manual, expired, valid, needs-permissions, blocked and none.
64
-	 */
65
-	public $status;
66
-
67
-	/**
68
-	 * oAuth Permissions Version.
69
-	 *
70
-	 * @access public
71
-	 * @since 6.0.0
72
-	 * @var string $oauth_version Version of oAuth permissions granted.
73
-	 */
74
-	public $oauth_version;	
75
-
76
-	/**
77
-	 * Holds the base object.
78
-	 *
79
-	 * @access public
80
-	 * @since 6.0.0
81
-	 * @var MonsterInsights $base MonsterInsights Base object.
82
-	 */
83
-	public $base;
84
-
85
-	/**
86
-	 * Primary class constructor.
87
-	 *
88
-	 * @access public
89
-	 * @since 6.0.0
90
-	 */
91
-	public function __construct() {
92
-		// Get object 
93
-		$this->client        = $this->get_client();
94
-		$this->profile       = $this->get_profile();
95
-		$this->ua            = $this->get_ua();
96
-		$this->name          = $this->get_name();
97
-		$this->oauth_version = $this->get_oauth_version();
98
-		$this->status        = $this->get_status();
99
-		$this->base 		 = MonsterInsights();
100
-
101
-
102
-		// Show any info/error notices
103
-		$this->get_notices();
104
-
105
-		// Authentication Actions
106
-		add_action( 'wp_ajax_monsterinsights_google_view',  array( $this, 'google_auth_view' ) );
107
-		add_action( 'wp_ajax_monsterinsights_google_cancel',  array( $this, 'google_cancel' ) );
108
-
109
-		add_action( 'admin_init', array( $this, 'deactivate_google' ) ); // Deactivate
110
-	}
111
-
112
-	private function get_client() {
113
-		return ! empty( $this->client ) ? $this->client : monsterinsights_create_client();
114
-	}
115
-
116
-	private function set_test_client() { 
117
-		$this->client = monsterinsights_create_test_client();
118
-	}
119
-
120
-	private function set_client() { 
121
-		$this->client = monsterinsights_create_client();
122
-	}
123
-
124
-	/**
125
-	 * Get the current GA profile
126
-	 *
127
-	 * @return null
128
-	 */
129
-	private function get_profile() {
130
-		return monsterinsights_get_option( 'analytics_profile', false );
131
-	}
132
-
133
-	private function get_name() {
134
-		return monsterinsights_get_option( 'analytics_profile_name', false );
135
-	}
136
-
137
-	private function get_ua() {
138
-		return monsterinsights_get_ua();
139
-	}
140
-
141
-	private function get_oauth_version() {
142
-		return monsterinsights_get_option( 'oauth_version', '1.0' );
143
-	}
144
-
145
-	private function get_status() {
146
-		$status = 'valid';
147
-		if ( ! empty( $this->profile ) ) {
148
-			// We are using oAuth
22
+    /**
23
+     * Holds the GA client object if using oAuth.
24
+     *
25
+     * @access public
26
+     * @since 6.0.0
27
+     * @var MonsterInsights_GA_Client $client GA client object.
28
+     */
29
+    public $client;
30
+
31
+    /**
32
+     * Google Profile ID.
33
+     *
34
+     * @access public
35
+     * @since 6.0.0
36
+     * @var int $profile ID of profile in use.
37
+     */
38
+    public $profile;
39
+
40
+    /**
41
+     * Google UA code.
42
+     *
43
+     * @access public
44
+     * @since 6.0.0
45
+     * @var string|false $ua Google UA code for the current profile if valid oAuth in use, else false.
46
+     */
47
+    public $ua;
48
+
49
+    /**
50
+     * Google profile name.
51
+     *
52
+     * @access public
53
+     * @since 6.0.0
54
+     * @var string|false $ua Google profile name for the current profile if valid oAuth in use, else false.
55
+     */
56
+    public $name;
57
+
58
+    /**
59
+     * Status of Google client object.
60
+     *
61
+     * @access public
62
+     * @since 6.0.0
63
+     * @var string $status Possible values include manual, expired, valid, needs-permissions, blocked and none.
64
+     */
65
+    public $status;
66
+
67
+    /**
68
+     * oAuth Permissions Version.
69
+     *
70
+     * @access public
71
+     * @since 6.0.0
72
+     * @var string $oauth_version Version of oAuth permissions granted.
73
+     */
74
+    public $oauth_version;	
75
+
76
+    /**
77
+     * Holds the base object.
78
+     *
79
+     * @access public
80
+     * @since 6.0.0
81
+     * @var MonsterInsights $base MonsterInsights Base object.
82
+     */
83
+    public $base;
84
+
85
+    /**
86
+     * Primary class constructor.
87
+     *
88
+     * @access public
89
+     * @since 6.0.0
90
+     */
91
+    public function __construct() {
92
+        // Get object 
93
+        $this->client        = $this->get_client();
94
+        $this->profile       = $this->get_profile();
95
+        $this->ua            = $this->get_ua();
96
+        $this->name          = $this->get_name();
97
+        $this->oauth_version = $this->get_oauth_version();
98
+        $this->status        = $this->get_status();
99
+        $this->base 		 = MonsterInsights();
100
+
101
+
102
+        // Show any info/error notices
103
+        $this->get_notices();
104
+
105
+        // Authentication Actions
106
+        add_action( 'wp_ajax_monsterinsights_google_view',  array( $this, 'google_auth_view' ) );
107
+        add_action( 'wp_ajax_monsterinsights_google_cancel',  array( $this, 'google_cancel' ) );
108
+
109
+        add_action( 'admin_init', array( $this, 'deactivate_google' ) ); // Deactivate
110
+    }
111
+
112
+    private function get_client() {
113
+        return ! empty( $this->client ) ? $this->client : monsterinsights_create_client();
114
+    }
115
+
116
+    private function set_test_client() { 
117
+        $this->client = monsterinsights_create_test_client();
118
+    }
119
+
120
+    private function set_client() { 
121
+        $this->client = monsterinsights_create_client();
122
+    }
123
+
124
+    /**
125
+     * Get the current GA profile
126
+     *
127
+     * @return null
128
+     */
129
+    private function get_profile() {
130
+        return monsterinsights_get_option( 'analytics_profile', false );
131
+    }
132
+
133
+    private function get_name() {
134
+        return monsterinsights_get_option( 'analytics_profile_name', false );
135
+    }
136
+
137
+    private function get_ua() {
138
+        return monsterinsights_get_ua();
139
+    }
140
+
141
+    private function get_oauth_version() {
142
+        return monsterinsights_get_option( 'oauth_version', '1.0' );
143
+    }
144
+
145
+    private function get_status() {
146
+        $status = 'valid';
147
+        if ( ! empty( $this->profile ) ) {
148
+            // We are using oAuth
149 149
 			
150
-			$last_run = monsterinsights_get_option( 'cron_last_run', false );
151
-			$failed   = monsterinsights_get_option( 'cron_failed', false );
152
-			$dash_dis = monsterinsights_get_option( 'dashboards_disabled', false );
153
-
154
-			// See if issue connecting or expired
155
-			if ( ! $dash_dis && $failed && ( $last_run === false || monsterinsights_hours_between( $last_run ) >= 48 )  ) { 
156
-				$status = 'blocked';
157
-			}
158
-
159
-			$access_token = $this->client->get_access_token();
160
-
161
-			// Check to make sure access token is there and not expired
162
-			if ( empty( $access_token ) || empty( $access_token['expires'] ) || current_time( 'timestamp' ) >= $access_token['expires'] ) {
163
-				$status = 'expired';
164
-				return $status;
165
-			}
166
-
167
-			// See if needs permissions
168
-			if ( version_compare( $this->oauth_version, '1.0', '<' ) ) { 
169
-				$status = 'needs-permissions';
170
-			}
150
+            $last_run = monsterinsights_get_option( 'cron_last_run', false );
151
+            $failed   = monsterinsights_get_option( 'cron_failed', false );
152
+            $dash_dis = monsterinsights_get_option( 'dashboards_disabled', false );
153
+
154
+            // See if issue connecting or expired
155
+            if ( ! $dash_dis && $failed && ( $last_run === false || monsterinsights_hours_between( $last_run ) >= 48 )  ) { 
156
+                $status = 'blocked';
157
+            }
158
+
159
+            $access_token = $this->client->get_access_token();
160
+
161
+            // Check to make sure access token is there and not expired
162
+            if ( empty( $access_token ) || empty( $access_token['expires'] ) || current_time( 'timestamp' ) >= $access_token['expires'] ) {
163
+                $status = 'expired';
164
+                return $status;
165
+            }
166
+
167
+            // See if needs permissions
168
+            if ( version_compare( $this->oauth_version, '1.0', '<' ) ) { 
169
+                $status = 'needs-permissions';
170
+            }
171 171
 			
172
-		} else if ( ! empty( $this->ua ) ) {
173
-			// We are using manual
172
+        } else if ( ! empty( $this->ua ) ) {
173
+            // We are using manual
174 174
 			
175
-		} else {
176
-			// We do not have oAuth or manual active
177
-			$status = 'empty';
178
-		}
179
-
180
-		return $status;
181
-	}
182
-
183
-	private function get_notices() {
184
-		// Notice for no manual or profile GA
185
-		if ( $this->status === 'empty' ) {
186
-			add_action( 'admin_notices', array( $this, 'monsterinsights_show_admin_config_empty_notice' ),6 );
187
-		}
188
-
189
-		$current_page = filter_input( INPUT_GET, 'page' );
190
-
191
-		// Only show expired, needs permission, or blocked notices on the MI pages
192
-		// We do this because unlike status empty, these only block reporting, not the frontend
193
-		// tracking from working, and as a result, these are not as urgent. Plus users generally
194
-		// don't like global notices.
195
-		if ( strpos( $current_page, 'monsterinsights' ) === 0 ) {
175
+        } else {
176
+            // We do not have oAuth or manual active
177
+            $status = 'empty';
178
+        }
179
+
180
+        return $status;
181
+    }
182
+
183
+    private function get_notices() {
184
+        // Notice for no manual or profile GA
185
+        if ( $this->status === 'empty' ) {
186
+            add_action( 'admin_notices', array( $this, 'monsterinsights_show_admin_config_empty_notice' ),6 );
187
+        }
188
+
189
+        $current_page = filter_input( INPUT_GET, 'page' );
190
+
191
+        // Only show expired, needs permission, or blocked notices on the MI pages
192
+        // We do this because unlike status empty, these only block reporting, not the frontend
193
+        // tracking from working, and as a result, these are not as urgent. Plus users generally
194
+        // don't like global notices.
195
+        if ( strpos( $current_page, 'monsterinsights' ) === 0 ) {
196 196
 		
197
-			// Notice for GA Access token expired (needs re-authenticate)
198
-			if ( $this->status === 'expired' ) {
199
-				add_action( 'admin_notices', array( $this, 'monsterinsights_show_admin_config_expired_notice' ),6 );
200
-			}
197
+            // Notice for GA Access token expired (needs re-authenticate)
198
+            if ( $this->status === 'expired' ) {
199
+                add_action( 'admin_notices', array( $this, 'monsterinsights_show_admin_config_expired_notice' ),6 );
200
+            }
201 201
 			
202
-			// Notice for Needs Permissions
203
-			if ( $this->status === 'needs-permissions' ) {
204
-				add_action( 'admin_notices', array( $this, 'monsterinsights_show_admin_config_needs_permissions_notice' ),6 );
205
-			}
206
-
207
-			// Notice for trouble connecting to Google
208
-			if ( $this->status === 'blocked' ) {
209
-				add_action( 'admin_notices', array( $this, 'monsterinsights_show_admin_config_blocked_notice' ),6 );
210
-			}
211
-		}
212
-	}
213
-
214
-	/**
215
-	 * Used when switching GA profiles, or switching
216
-	 * to/from oAuth <--> manual, or when reauthenticating
217
-	 * or deleting GA profile.
218
-	 *
219
-	 * @return null
220
-	 */
221
-	private function reinitialize() { 
222
-		// Get object 
223
-		$this->client        = $this->get_client();
224
-		$this->profile       = $this->get_profile();
225
-		$this->ua            = $this->get_ua();
226
-		$this->name          = $this->get_name();
227
-		$this->oauth_version = $this->get_oauth_version();
228
-		$this->status        = $this->get_status();
229
-
230
-		// Re-get data if possible
231
-		if ( $this->ua === 'valid' ) {
232
-			$this->refresh_dashboard_data();
233
-		}
234
-	}
235
-
236
-	public function create_auth_url() {
237
-		return $this->client->createAuthUrl();
238
-	}
239
-
240
-	/**
241
-	 * Getting the analytics profiles
242
-	 *
243
-	 * Doing the request to the Google analytics API and if there is a response, parses this response and return its
244
-	 * array
245
-	 *
246
-	 * @return array
247
-	 */
248
-	public function get_profiles() { // @todo: this needs exception handling for a 401 login required		
249
-		$accounts = $this->get_profiles_request();
250
-		if ( is_array( $accounts ) ) {
251
-			return $accounts;
252
-		} else {
253
-			return array();
254
-		}
255
-	}
256
-
257
-	public function find_selected_profile( $profile_id ) {
258
-		$profiles = $this->get_profiles();
259
-		$found  = array();
260
-		foreach ( $profiles as $account ) {
261
-			foreach ( $account['items'] as $profile ) {
262
-				foreach ( $profile['items'] as $subprofile ) {
263
-					if ( isset( $subprofile['id'] ) && $subprofile['id'] == $profile_id ) {
264
-						$found = array(
265
-							'id'   => $profile_id,
266
-							'ua'   => $subprofile['ua_code'],
267
-							'name' => $subprofile['name'],
268
-
269
-						);
270
-						break 3;
271
-					}
272
-				}
273
-			}
274
-		}
275
-		return $found;
276
-	}
277
-
278
-	public function save_selected_profile( $profile ) {
279
-		monsterinsights_update_option( 'analytics_profile', $profile['id'] );
280
-		monsterinsights_update_option( 'analytics_profile_code', $profile['ua'] );
281
-		monsterinsights_update_option( 'analytics_profile_name', $profile['name'] );
282
-		monsterinsights_set_client_oauth_version();
283
-	}
284
-
285
-
286
-	/**
287
-	 * Get accounts request
288
-	 *
289
-	 * @param array $response
290
-	 *
291
-	 * @return mixed
292
-	 */
293
-	private function get_profiles_request() {
294
-		global $wp_version;
295
-		$version = str_replace( '-src', '', $wp_version );
296
-		$accounts    = array();
297
-		$start_index = 1;
298
-		$paginate    = false;
299
-		$continue    = true;
300
-		while ( $continue ) {
301
-			$body     = array(
302
-				'max-results'  => 1000,
303
-				'start-index'  => $paginate ? $start_index + 1000 : $start_index,
304
-			);
305
-			if ( $paginate ) {
306
-				$start_index = $start_index + 1000;
307
-			}
308
-			$response = $this->client->do_request( 'https://www.googleapis.com/analytics/v3/management/accounts/~all/webproperties/~all/profiles', false, 'GET', $body );
309
-			if ( ! empty( $response ) ) {
310
-				$response = array(
311
-					'response' => array( 'code' => $this->client->get_http_response_code() ),
312
-					'body'     => json_decode( $response->getResponseBody(), true ),
313
-				);
314
-			} else {
315
-				if ( version_compare( $version, '4.6', '<' ) ) {
316
-					return esc_html__( 'MonsterInsights requires WordPress version 4.6 or newer to use oAuth. Please update your WordPress version.', 'google-analytics-for-wordpress' );
317
-				} else {
318
-					if ( ! empty( $accounts ) ) {
319
-						return $accounts;
320
-					} else {
321
-						return esc_html__( 'Google Analytics had a connection error or your Google account is not signed up for Google Analytics.', 'google-analytics-for-wordpress' );
322
-					}
323
-				}
324
-			}
202
+            // Notice for Needs Permissions
203
+            if ( $this->status === 'needs-permissions' ) {
204
+                add_action( 'admin_notices', array( $this, 'monsterinsights_show_admin_config_needs_permissions_notice' ),6 );
205
+            }
206
+
207
+            // Notice for trouble connecting to Google
208
+            if ( $this->status === 'blocked' ) {
209
+                add_action( 'admin_notices', array( $this, 'monsterinsights_show_admin_config_blocked_notice' ),6 );
210
+            }
211
+        }
212
+    }
213
+
214
+    /**
215
+     * Used when switching GA profiles, or switching
216
+     * to/from oAuth <--> manual, or when reauthenticating
217
+     * or deleting GA profile.
218
+     *
219
+     * @return null
220
+     */
221
+    private function reinitialize() { 
222
+        // Get object 
223
+        $this->client        = $this->get_client();
224
+        $this->profile       = $this->get_profile();
225
+        $this->ua            = $this->get_ua();
226
+        $this->name          = $this->get_name();
227
+        $this->oauth_version = $this->get_oauth_version();
228
+        $this->status        = $this->get_status();
229
+
230
+        // Re-get data if possible
231
+        if ( $this->ua === 'valid' ) {
232
+            $this->refresh_dashboard_data();
233
+        }
234
+    }
235
+
236
+    public function create_auth_url() {
237
+        return $this->client->createAuthUrl();
238
+    }
239
+
240
+    /**
241
+     * Getting the analytics profiles
242
+     *
243
+     * Doing the request to the Google analytics API and if there is a response, parses this response and return its
244
+     * array
245
+     *
246
+     * @return array
247
+     */
248
+    public function get_profiles() { // @todo: this needs exception handling for a 401 login required		
249
+        $accounts = $this->get_profiles_request();
250
+        if ( is_array( $accounts ) ) {
251
+            return $accounts;
252
+        } else {
253
+            return array();
254
+        }
255
+    }
256
+
257
+    public function find_selected_profile( $profile_id ) {
258
+        $profiles = $this->get_profiles();
259
+        $found  = array();
260
+        foreach ( $profiles as $account ) {
261
+            foreach ( $account['items'] as $profile ) {
262
+                foreach ( $profile['items'] as $subprofile ) {
263
+                    if ( isset( $subprofile['id'] ) && $subprofile['id'] == $profile_id ) {
264
+                        $found = array(
265
+                            'id'   => $profile_id,
266
+                            'ua'   => $subprofile['ua_code'],
267
+                            'name' => $subprofile['name'],
268
+
269
+                        );
270
+                        break 3;
271
+                    }
272
+                }
273
+            }
274
+        }
275
+        return $found;
276
+    }
277
+
278
+    public function save_selected_profile( $profile ) {
279
+        monsterinsights_update_option( 'analytics_profile', $profile['id'] );
280
+        monsterinsights_update_option( 'analytics_profile_code', $profile['ua'] );
281
+        monsterinsights_update_option( 'analytics_profile_name', $profile['name'] );
282
+        monsterinsights_set_client_oauth_version();
283
+    }
284
+
285
+
286
+    /**
287
+     * Get accounts request
288
+     *
289
+     * @param array $response
290
+     *
291
+     * @return mixed
292
+     */
293
+    private function get_profiles_request() {
294
+        global $wp_version;
295
+        $version = str_replace( '-src', '', $wp_version );
296
+        $accounts    = array();
297
+        $start_index = 1;
298
+        $paginate    = false;
299
+        $continue    = true;
300
+        while ( $continue ) {
301
+            $body     = array(
302
+                'max-results'  => 1000,
303
+                'start-index'  => $paginate ? $start_index + 1000 : $start_index,
304
+            );
305
+            if ( $paginate ) {
306
+                $start_index = $start_index + 1000;
307
+            }
308
+            $response = $this->client->do_request( 'https://www.googleapis.com/analytics/v3/management/accounts/~all/webproperties/~all/profiles', false, 'GET', $body );
309
+            if ( ! empty( $response ) ) {
310
+                $response = array(
311
+                    'response' => array( 'code' => $this->client->get_http_response_code() ),
312
+                    'body'     => json_decode( $response->getResponseBody(), true ),
313
+                );
314
+            } else {
315
+                if ( version_compare( $version, '4.6', '<' ) ) {
316
+                    return esc_html__( 'MonsterInsights requires WordPress version 4.6 or newer to use oAuth. Please update your WordPress version.', 'google-analytics-for-wordpress' );
317
+                } else {
318
+                    if ( ! empty( $accounts ) ) {
319
+                        return $accounts;
320
+                    } else {
321
+                        return esc_html__( 'Google Analytics had a connection error or your Google account is not signed up for Google Analytics.', 'google-analytics-for-wordpress' );
322
+                    }
323
+                }
324
+            }
325 325
 			
326
-			if ( isset( $response['response']['code'] ) && $response['response']['code'] == 200 ) {
327
-				if ( ! empty( $response['body']['items'] ) && is_array( $response['body']['items'] ) ) {
328
-					foreach ( $response['body']['items'] as $item ) {
329
-
330
-						// Only deal with web properties, not apps.
331
-						if ( isset( $item['type'] ) && 'WEB' != $item['type'] ) {
332
-							continue;
333
-						}
334
-
335
-						/**
336
-						 * Future:
337
-						* // Accounts
338
-						* 	// Properties
339
-						* 		// Views
340
-						* $items = array(
341
-						* 	{account_id} => array(
342
-						* 		{property_id} => array(
343
-						* 			{view_id} => array( 
344
-						* 				'account_id'  => '',
345
-						* 				'property_id' => '',
346
-						* 				'view_id'	  => '',
347
-						* 				'url'		  => '',
348
-						* 				'view_name'	  => '',
349
-						* 				'ua_code'	  => '',
350
-						* 			),
351
-						* 		),
352
-						* 	),
353
-						* ),
354
-						**/
355
-						/*
326
+            if ( isset( $response['response']['code'] ) && $response['response']['code'] == 200 ) {
327
+                if ( ! empty( $response['body']['items'] ) && is_array( $response['body']['items'] ) ) {
328
+                    foreach ( $response['body']['items'] as $item ) {
329
+
330
+                        // Only deal with web properties, not apps.
331
+                        if ( isset( $item['type'] ) && 'WEB' != $item['type'] ) {
332
+                            continue;
333
+                        }
334
+
335
+                        /**
336
+                         * Future:
337
+                         * // Accounts
338
+                         * 	// Properties
339
+                         * 		// Views
340
+                         * $items = array(
341
+                         * 	{account_id} => array(
342
+                         * 		{property_id} => array(
343
+                         * 			{view_id} => array( 
344
+                         * 				'account_id'  => '',
345
+                         * 				'property_id' => '',
346
+                         * 				'view_id'	  => '',
347
+                         * 				'url'		  => '',
348
+                         * 				'view_name'	  => '',
349
+                         * 				'ua_code'	  => '',
350
+                         * 			),
351
+                         * 		),
352
+                         * 	),
353
+                         * ),
354
+                         **/
355
+                        /*
356 356
 						CurrenT:
357 357
 						$accounts[ $item['accountId'] ] = array( 
358 358
 							'id'          => $item['accountId'],
@@ -375,474 +375,474 @@  discard block
 block discarded – undo
375 375
 						*/
376 376
 
377 377
 
378
-						if ( empty( $accounts[ $item['accountId'] ] ) ) {
379
-							$accounts[ $item['accountId'] ] = array( 
380
-								'id'          => $item['accountId'],
381
-								'ua_code'     => $item['webPropertyId'],
382
-								'parent_name' => $item['websiteUrl'],
383
-								'items'       => array(),
384
-							);
385
-						}
386
-
387
-						if ( empty( $accounts[ $item['accountId'] ]['items'][ $item['internalWebPropertyId'] ] ) ) {
388
-							$accounts[ $item['accountId'] ]['items'][ $item['internalWebPropertyId'] ]= array( 
389
-								'id'          => $item['webPropertyId'],
390
-								'name'        => $item['websiteUrl'],
391
-								'items'       => array(),
392
-							);
393
-						}
394
-
395
-						if ( empty( $accounts[ $item['accountId'] ]['items'][ $item['internalWebPropertyId'] ]['items'][ $item['id'] ] ) ) {
396
-							$accounts[ $item['accountId'] ]['items'][ $item['internalWebPropertyId'] ]['items'][ $item['id'] ] = array( 
397
-								'name'    => $item['name'] . ' (' . $item['webPropertyId'] . ')',
398
-								'ua_code' => $item['webPropertyId'],
399
-								'id'      => $item['id'],
400
-							);
401
-						}
402
-					}
403
-				}
404
-			} else if ( isset( $response['response']['code'] ) && $response['response']['code'] !== 200 && ! $paginate ) {
405
-				if ( version_compare( $version, '4.6', '<' ) ) {
406
-					return esc_html__( 'MonsterInsights requires WordPress version 4.6 or newer to use oAuth. Please update your WordPress version.', 'google-analytics-for-wordpress' );
407
-				} else {
408
-					if ( ! empty( $accounts ) ) {
409
-						return $accounts;
410
-					} else {
411
-						$code = isset( $response['response']['code'] ) ? $response['response']['code'] : 'Unknown';
412
-						$type = isset( $response['body']['error']['errors'][0]['reason'] ) ? $response['body']['error']['errors'][0]['reason'] : false;
413
-						if ( $type === 'insufficientPermissions' ) {
414
-							return esc_html__( 'Please ensure your Google Account is signed up for Google Analytics.', 'google-analytics-for-wordpress' );
415
-						} else if ( $type === 'badRequest' ) {
416
-							return esc_html__( 'Bad Request. Please contact support.', 'google-analytics-for-wordpress' );
417
-						} else if ( $type === 'dailyLimitExceeded' ) {
418
-							return esc_html__( 'Daily Limit Exceeded. Please contact support.', 'google-analytics-for-wordpress' );
419
-						} else if ( $type === 'userRateLimitExceeded' ) {
420
-							return esc_html__( 'User Rate Limit Exceeded. Wait 2 minutes and then try again.', 'google-analytics-for-wordpress' );
421
-						} else if ( $type === 'rateLimitExceeded' ) {
422
-							return esc_html__( 'Project Rate Limit Exceeded. Wait 2 minutes and then try again.', 'google-analytics-for-wordpress' );
423
-						} else if ( $type === 'quotaExceeded' ) {
424
-							return esc_html__( 'Project Rate Limit Quota Exceeded. Wait 2 minutes and then try again.', 'google-analytics-for-wordpress' );
425
-						} else if ( $type === 'internalServerError' || $type === 'backendError' ) {
426
-							return esc_html__( 'Google Analytics is having API issues on their side. Wait 2 minutes and then try again.', 'google-analytics-for-wordpress' );
427
-						} else {
428
-							return sprintf( esc_html__( 'Google Analytics had a connection error. Error code: %1$s. Reason: %2$s', 'google-analytics-for-wordpress' ), $code, $type );
429
-						}
430
-					}
431
-				}
432
-			}
433
-
434
-			if ( isset( $response['body']['totalResults'] ) && $start_index < $response['body']['totalResults'] && ! empty( $response['body']['nextLink'] ) ) {
435
-				$paginate    = true;
436
-			} else {
437
-				$continue    = false;
438
-			}
439
-		}
440
-		return $accounts;
441
-	}
442
-
443
-	private function clear_oauth_data() {
444
-		// Delete the stored profiles
445
-		$options = array(
446
-			'analytics_profile_code',
447
-			'analytics_profile',
448
-			'analytics_profile_name',
449
-			'oauth_version',
450
-			'cron_failed',
451
-			'cron_last_run',
452
-		);
453
-		monsterinsights_delete_options( $options );
454
-
455
-		// Destroy the data
456
-		$this->base->reports->delete_aggregate_data();
378
+                        if ( empty( $accounts[ $item['accountId'] ] ) ) {
379
+                            $accounts[ $item['accountId'] ] = array( 
380
+                                'id'          => $item['accountId'],
381
+                                'ua_code'     => $item['webPropertyId'],
382
+                                'parent_name' => $item['websiteUrl'],
383
+                                'items'       => array(),
384
+                            );
385
+                        }
386
+
387
+                        if ( empty( $accounts[ $item['accountId'] ]['items'][ $item['internalWebPropertyId'] ] ) ) {
388
+                            $accounts[ $item['accountId'] ]['items'][ $item['internalWebPropertyId'] ]= array( 
389
+                                'id'          => $item['webPropertyId'],
390
+                                'name'        => $item['websiteUrl'],
391
+                                'items'       => array(),
392
+                            );
393
+                        }
394
+
395
+                        if ( empty( $accounts[ $item['accountId'] ]['items'][ $item['internalWebPropertyId'] ]['items'][ $item['id'] ] ) ) {
396
+                            $accounts[ $item['accountId'] ]['items'][ $item['internalWebPropertyId'] ]['items'][ $item['id'] ] = array( 
397
+                                'name'    => $item['name'] . ' (' . $item['webPropertyId'] . ')',
398
+                                'ua_code' => $item['webPropertyId'],
399
+                                'id'      => $item['id'],
400
+                            );
401
+                        }
402
+                    }
403
+                }
404
+            } else if ( isset( $response['response']['code'] ) && $response['response']['code'] !== 200 && ! $paginate ) {
405
+                if ( version_compare( $version, '4.6', '<' ) ) {
406
+                    return esc_html__( 'MonsterInsights requires WordPress version 4.6 or newer to use oAuth. Please update your WordPress version.', 'google-analytics-for-wordpress' );
407
+                } else {
408
+                    if ( ! empty( $accounts ) ) {
409
+                        return $accounts;
410
+                    } else {
411
+                        $code = isset( $response['response']['code'] ) ? $response['response']['code'] : 'Unknown';
412
+                        $type = isset( $response['body']['error']['errors'][0]['reason'] ) ? $response['body']['error']['errors'][0]['reason'] : false;
413
+                        if ( $type === 'insufficientPermissions' ) {
414
+                            return esc_html__( 'Please ensure your Google Account is signed up for Google Analytics.', 'google-analytics-for-wordpress' );
415
+                        } else if ( $type === 'badRequest' ) {
416
+                            return esc_html__( 'Bad Request. Please contact support.', 'google-analytics-for-wordpress' );
417
+                        } else if ( $type === 'dailyLimitExceeded' ) {
418
+                            return esc_html__( 'Daily Limit Exceeded. Please contact support.', 'google-analytics-for-wordpress' );
419
+                        } else if ( $type === 'userRateLimitExceeded' ) {
420
+                            return esc_html__( 'User Rate Limit Exceeded. Wait 2 minutes and then try again.', 'google-analytics-for-wordpress' );
421
+                        } else if ( $type === 'rateLimitExceeded' ) {
422
+                            return esc_html__( 'Project Rate Limit Exceeded. Wait 2 minutes and then try again.', 'google-analytics-for-wordpress' );
423
+                        } else if ( $type === 'quotaExceeded' ) {
424
+                            return esc_html__( 'Project Rate Limit Quota Exceeded. Wait 2 minutes and then try again.', 'google-analytics-for-wordpress' );
425
+                        } else if ( $type === 'internalServerError' || $type === 'backendError' ) {
426
+                            return esc_html__( 'Google Analytics is having API issues on their side. Wait 2 minutes and then try again.', 'google-analytics-for-wordpress' );
427
+                        } else {
428
+                            return sprintf( esc_html__( 'Google Analytics had a connection error. Error code: %1$s. Reason: %2$s', 'google-analytics-for-wordpress' ), $code, $type );
429
+                        }
430
+                    }
431
+                }
432
+            }
433
+
434
+            if ( isset( $response['body']['totalResults'] ) && $start_index < $response['body']['totalResults'] && ! empty( $response['body']['nextLink'] ) ) {
435
+                $paginate    = true;
436
+            } else {
437
+                $continue    = false;
438
+            }
439
+        }
440
+        return $accounts;
441
+    }
442
+
443
+    private function clear_oauth_data() {
444
+        // Delete the stored profiles
445
+        $options = array(
446
+            'analytics_profile_code',
447
+            'analytics_profile',
448
+            'analytics_profile_name',
449
+            'oauth_version',
450
+            'cron_failed',
451
+            'cron_last_run',
452
+        );
453
+        monsterinsights_delete_options( $options );
454
+
455
+        // Destroy the data
456
+        $this->base->reports->delete_aggregate_data();
457 457
 		
458
-		$this->client->clear_data();
459
-	}
460
-
461
-	private function clear_manual_data() {
462
-		// Delete the manual ua code
463
-		monsterinsights_delete_option( 'manual_ua_code' );
464
-	}
465
-
466
-	public function deactivate_google() {
467
-		// Check if user pressed the deactivate button and nonce is valid
468
-		if ( ! isset( $_POST['monsterinsights-google-deauthenticate-submit'] ) ) {
469
-			return;
470
-		}
471
-
472
-		if ( ! wp_verify_nonce( $_POST['monsterinsights-google-authenticated-nonce'], 'monsterinsights-google-authenticated-nonce' ) ) {
473
-			return;
474
-		}
475
-
476
-		if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
477
-			return;
478
-		}
479
-
480
-		// Destroy the client
481
-		$this->clear_oauth_data();
482
-
483
-		// Refresh the client
484
-		$this->reinitialize();
485
-	}
486
-
487
-	public function refresh_dashboard_data( ) {
488
-		// Destroy the data
489
-		$this->base->reports->delete_aggregate_data();
458
+        $this->client->clear_data();
459
+    }
460
+
461
+    private function clear_manual_data() {
462
+        // Delete the manual ua code
463
+        monsterinsights_delete_option( 'manual_ua_code' );
464
+    }
465
+
466
+    public function deactivate_google() {
467
+        // Check if user pressed the deactivate button and nonce is valid
468
+        if ( ! isset( $_POST['monsterinsights-google-deauthenticate-submit'] ) ) {
469
+            return;
470
+        }
471
+
472
+        if ( ! wp_verify_nonce( $_POST['monsterinsights-google-authenticated-nonce'], 'monsterinsights-google-authenticated-nonce' ) ) {
473
+            return;
474
+        }
475
+
476
+        if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
477
+            return;
478
+        }
479
+
480
+        // Destroy the client
481
+        $this->clear_oauth_data();
482
+
483
+        // Refresh the client
484
+        $this->reinitialize();
485
+    }
486
+
487
+    public function refresh_dashboard_data( ) {
488
+        // Destroy the data
489
+        $this->base->reports->delete_aggregate_data();
490 490
 		
491
-		$this->base->reports->run_cron();
492
-	}
493
-
494
-	/**
495
-	 * Check if client has a refresh token
496
-	 * @return bool
497
-	 */
498
-	public function has_refresh_token() {
499
-		return $this->client->is_authenticated();
500
-	}
501
-
502
-	/**
503
-	 * Doing request to Google Analytics
504
-	 *
505
-	 * This method will do a request to google and get the response code and body from content
506
-	 *
507
-	 * @param string $target_request_url
508
-	 *
509
-	 * @return array|null
510
-	 */
511
-	public function do_request( $target_request_url ) {
512
-		$response = $this->client->do_request( $target_request_url );
513
-		if ( ! empty( $response ) ) {
514
-			return array(
515
-				'response' => array( 'code' => $this->client->get_http_response_code() ),
516
-				'body'     => json_decode( $response->getResponseBody(), true ),
517
-			);
518
-		}
519
-	}
491
+        $this->base->reports->run_cron();
492
+    }
493
+
494
+    /**
495
+     * Check if client has a refresh token
496
+     * @return bool
497
+     */
498
+    public function has_refresh_token() {
499
+        return $this->client->is_authenticated();
500
+    }
501
+
502
+    /**
503
+     * Doing request to Google Analytics
504
+     *
505
+     * This method will do a request to google and get the response code and body from content
506
+     *
507
+     * @param string $target_request_url
508
+     *
509
+     * @return array|null
510
+     */
511
+    public function do_request( $target_request_url ) {
512
+        $response = $this->client->do_request( $target_request_url );
513
+        if ( ! empty( $response ) ) {
514
+            return array(
515
+                'response' => array( 'code' => $this->client->get_http_response_code() ),
516
+                'body'     => json_decode( $response->getResponseBody(), true ),
517
+            );
518
+        }
519
+    }
520 520
 	
521
-	/**
522
-	 * Wrapper for authenticate the client. If authentication code is send it will get and check an access token.
523
-	 *
524
-	 * @param mixed $authentication_code
525
-	 *
526
-	 * @return boolean
527
-	 */
528
-	public function authenticate( $authentication_code = null ) {
529
-		// When authentication again we should clean up some stuff
530
-		monsterinsights_delete_options( array( 'cron_last_run', 'cron_failed' ) );
531
-		return $this->client->authenticate_client( $authentication_code );
532
-	}
533
-
534
-	public function google_auth_view() {
535
-		$view   = isset( $_POST['view'] ) && in_array( $_POST['view'], array( 'prestart', 'start', 'enterkey', 'selectprofile', 'done' ) ) ? $_POST['view'] : '';
536
-		$reauth = isset( $_POST['reauth'] ) && $_POST['reauth'] && $_POST['reauth'] !== 'false'  ? true : false;
537
-
538
-		if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
539
-			echo esc_html__( 'Permission Denied', 'google-analytics-for-wordpress');
540
-			wp_die();
541
-		}
542
-
543
-		// We run the save routines, if required, for a view, and then after that send back the results + next view
544
-		$nextview = array();
545
-
546
-		switch ( $view ) {
547
-			case 'start':
548
-				if ( ! $this->is_wp_blocking_google() && ! $this->is_google_on_blacklist() ) {
549
-					$auth_url = $this->create_auth_url();
550
-					$nextview = monsterinsights_google_auth_enterkey_view( $reauth, $auth_url );
551
-				} else {
552
-					$error    = esc_html__( 'Cannot connect to Google', 'google-analytics-for-wordpress' );
553
-					$nextview = monsterinsights_google_auth_error_view( $reauth, $error );
554
-				}
555
-				break;
556
-
557
-			case 'enterkey':
558
-				$auth_key = ! empty( $_POST['stepdata'] ) ? sanitize_text_field( $_POST['stepdata'] ) : '';
559
-				if ( $auth_key ) {
560
-					if ( $this->test_authkey( $auth_key ) ) {
561
-						$profiles = $this->get_profiles_request();
562
-						delete_option( 'monsterinsights_get_profiles' );
563
-						update_option( 'monsterinsights_get_profiles', $profiles );
564
-						if ( ! empty( $profiles ) && is_array( $profiles ) ) {
565
-							$select = $this->ga_select( $profiles );
566
-							$nextview = monsterinsights_google_auth_selectprofile_view( $reauth, $select );
567
-						} else if ( ! empty( $profiles ) && is_string( $profiles ) ) {
568
-							// Error from Google
569
-							$auth_url = $this->create_auth_url();
570
-							$this->client->clear_data();
571
-							$this->set_test_client();
572
-							$nextview = monsterinsights_google_auth_enterkey_view( $reauth, $auth_url, esc_html( $profiles ) );
573
-						} else {
574
-							// No profiles or not enough permissions
575
-							$auth_url = $this->create_auth_url();
576
-							$this->client->clear_data();
577
-							$this->set_test_client();
578
-							$nextview = monsterinsights_google_auth_enterkey_view( $reauth, $auth_url, esc_html__( 'No profiles viewable for that account. Please use another account.', 'google-analytics-for-wordpress' ) );
579
-						}
580
-					} else {
581
-						// if bad authentication error message
582
-						$auth_url = $this->create_auth_url();
583
-						$this->client->clear_data();
584
-						$this->set_test_client();
585
-						$nextview = monsterinsights_google_auth_enterkey_view( $reauth, $auth_url, esc_html__( 'Bad Google Code. Please try again.', 'google-analytics-for-wordpress' ) );
586
-					}
587
-				} else {
588
-					$auth_url = $this->create_auth_url();
589
-					$this->client->clear_data();
590
-					$this->set_test_client();
591
-					// if no auth key error message
592
-					$nextview = monsterinsights_google_auth_enterkey_view( $reauth, $auth_url, esc_html__( 'Please paste in your Google code.', 'google-analytics-for-wordpress' ) );
593
-				}
594
-				break;
595
-
596
-			case 'selectprofile':
597
-				$profile = ! empty( $_POST['stepdata'] ) ? absint( sanitize_text_field( $_POST['stepdata'] ) ) : '';
598
-				if ( ! empty( $profile ) ) {
599
-					$this->set_test_client();
600
-					$profile = $this->find_selected_profile( $profile );
601
-					if ( ! empty( $profile ) ) {
602
-
603
-						$this->clear_manual_data(); // Just in case we were manual, clear out UA
604
-
605
-						$this->client->move_test_to_live();
606
-						$this->save_selected_profile( $profile );
607
-						$this->set_client();
608
-						$this->reinitialize();
609
-
610
-						// Refresh reporting data
611
-						$this->base->reports->refresh_aggregate_data();
612
-
613
-						$nextview = monsterinsights_google_auth_done_view( $reauth );
614
-					} else {
615
-						// Invalid profile selected
616
-						$profiles = get_option( 'monsterinsights_get_profiles', array() );
617
-						$select   = $this->ga_select( $profiles );
618
-						$nextview = monsterinsights_google_auth_selectprofile_view( $reauth, $select, esc_html__( 'Invalid profile selected.', 'google-analytics-for-wordpress' ) );
619
-					}
620
-				} else { 
621
-					// No profile selected
622
-					$profiles = get_option( 'monsterinsights_get_profiles', array() );
623
-					$select   = $this->ga_select( $profiles );
624
-					$nextview = monsterinsights_google_auth_selectprofile_view( $reauth, $select, esc_html__( 'Please select a profile.', 'google-analytics-for-wordpress' ) );
625
-				}
626
-				break;
627
-
628
-			case 'done':
629
-				$nextview = monsterinsights_google_auth_done_view( $reauth );
630
-				break;
521
+    /**
522
+     * Wrapper for authenticate the client. If authentication code is send it will get and check an access token.
523
+     *
524
+     * @param mixed $authentication_code
525
+     *
526
+     * @return boolean
527
+     */
528
+    public function authenticate( $authentication_code = null ) {
529
+        // When authentication again we should clean up some stuff
530
+        monsterinsights_delete_options( array( 'cron_last_run', 'cron_failed' ) );
531
+        return $this->client->authenticate_client( $authentication_code );
532
+    }
533
+
534
+    public function google_auth_view() {
535
+        $view   = isset( $_POST['view'] ) && in_array( $_POST['view'], array( 'prestart', 'start', 'enterkey', 'selectprofile', 'done' ) ) ? $_POST['view'] : '';
536
+        $reauth = isset( $_POST['reauth'] ) && $_POST['reauth'] && $_POST['reauth'] !== 'false'  ? true : false;
537
+
538
+        if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
539
+            echo esc_html__( 'Permission Denied', 'google-analytics-for-wordpress');
540
+            wp_die();
541
+        }
542
+
543
+        // We run the save routines, if required, for a view, and then after that send back the results + next view
544
+        $nextview = array();
545
+
546
+        switch ( $view ) {
547
+            case 'start':
548
+                if ( ! $this->is_wp_blocking_google() && ! $this->is_google_on_blacklist() ) {
549
+                    $auth_url = $this->create_auth_url();
550
+                    $nextview = monsterinsights_google_auth_enterkey_view( $reauth, $auth_url );
551
+                } else {
552
+                    $error    = esc_html__( 'Cannot connect to Google', 'google-analytics-for-wordpress' );
553
+                    $nextview = monsterinsights_google_auth_error_view( $reauth, $error );
554
+                }
555
+                break;
556
+
557
+            case 'enterkey':
558
+                $auth_key = ! empty( $_POST['stepdata'] ) ? sanitize_text_field( $_POST['stepdata'] ) : '';
559
+                if ( $auth_key ) {
560
+                    if ( $this->test_authkey( $auth_key ) ) {
561
+                        $profiles = $this->get_profiles_request();
562
+                        delete_option( 'monsterinsights_get_profiles' );
563
+                        update_option( 'monsterinsights_get_profiles', $profiles );
564
+                        if ( ! empty( $profiles ) && is_array( $profiles ) ) {
565
+                            $select = $this->ga_select( $profiles );
566
+                            $nextview = monsterinsights_google_auth_selectprofile_view( $reauth, $select );
567
+                        } else if ( ! empty( $profiles ) && is_string( $profiles ) ) {
568
+                            // Error from Google
569
+                            $auth_url = $this->create_auth_url();
570
+                            $this->client->clear_data();
571
+                            $this->set_test_client();
572
+                            $nextview = monsterinsights_google_auth_enterkey_view( $reauth, $auth_url, esc_html( $profiles ) );
573
+                        } else {
574
+                            // No profiles or not enough permissions
575
+                            $auth_url = $this->create_auth_url();
576
+                            $this->client->clear_data();
577
+                            $this->set_test_client();
578
+                            $nextview = monsterinsights_google_auth_enterkey_view( $reauth, $auth_url, esc_html__( 'No profiles viewable for that account. Please use another account.', 'google-analytics-for-wordpress' ) );
579
+                        }
580
+                    } else {
581
+                        // if bad authentication error message
582
+                        $auth_url = $this->create_auth_url();
583
+                        $this->client->clear_data();
584
+                        $this->set_test_client();
585
+                        $nextview = monsterinsights_google_auth_enterkey_view( $reauth, $auth_url, esc_html__( 'Bad Google Code. Please try again.', 'google-analytics-for-wordpress' ) );
586
+                    }
587
+                } else {
588
+                    $auth_url = $this->create_auth_url();
589
+                    $this->client->clear_data();
590
+                    $this->set_test_client();
591
+                    // if no auth key error message
592
+                    $nextview = monsterinsights_google_auth_enterkey_view( $reauth, $auth_url, esc_html__( 'Please paste in your Google code.', 'google-analytics-for-wordpress' ) );
593
+                }
594
+                break;
595
+
596
+            case 'selectprofile':
597
+                $profile = ! empty( $_POST['stepdata'] ) ? absint( sanitize_text_field( $_POST['stepdata'] ) ) : '';
598
+                if ( ! empty( $profile ) ) {
599
+                    $this->set_test_client();
600
+                    $profile = $this->find_selected_profile( $profile );
601
+                    if ( ! empty( $profile ) ) {
602
+
603
+                        $this->clear_manual_data(); // Just in case we were manual, clear out UA
604
+
605
+                        $this->client->move_test_to_live();
606
+                        $this->save_selected_profile( $profile );
607
+                        $this->set_client();
608
+                        $this->reinitialize();
609
+
610
+                        // Refresh reporting data
611
+                        $this->base->reports->refresh_aggregate_data();
612
+
613
+                        $nextview = monsterinsights_google_auth_done_view( $reauth );
614
+                    } else {
615
+                        // Invalid profile selected
616
+                        $profiles = get_option( 'monsterinsights_get_profiles', array() );
617
+                        $select   = $this->ga_select( $profiles );
618
+                        $nextview = monsterinsights_google_auth_selectprofile_view( $reauth, $select, esc_html__( 'Invalid profile selected.', 'google-analytics-for-wordpress' ) );
619
+                    }
620
+                } else { 
621
+                    // No profile selected
622
+                    $profiles = get_option( 'monsterinsights_get_profiles', array() );
623
+                    $select   = $this->ga_select( $profiles );
624
+                    $nextview = monsterinsights_google_auth_selectprofile_view( $reauth, $select, esc_html__( 'Please select a profile.', 'google-analytics-for-wordpress' ) );
625
+                }
626
+                break;
627
+
628
+            case 'done':
629
+                $nextview = monsterinsights_google_auth_done_view( $reauth );
630
+                break;
631 631
 				
632
-			case 'prestart':
633
-			default:
634
-				 $nextview = monsterinsights_google_auth_start_view( $reauth );
635
-				break;
636
-		}
637
-		echo $nextview;
638
-		wp_die();
639
-	}
640
-
641
-	public function google_cancel() {
642
-		$view   = isset( $_POST['view'] ) && in_array( $_POST['view'], array( 'prestart', 'start', 'enterkey', 'selectprofile', 'done' ) ) ? $_POST['view'] : '';
643
-		$reauth = isset( $_POST['reauth'] ) && $_POST['reauth'] && $_POST['reauth'] !== 'false'  ? true : false;
644
-
645
-		if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
646
-			echo esc_html__( 'Permission Denied', 'google-analytics-for-wordpress');
647
-			wp_die();
648
-		}
649
-
650
-		// If we cancelled on enterkey or selectprofile, delete the temp access tokens and set client back to normal client
651
-		if ( $view === 'enterkey' || $view === 'selectprofile' ) {
652
-			$this->client->clear_data();
653
-			delete_option( 'monsterinsights_get_profiles' );
654
-			$this->set_client();
655
-		}
656
-	}
657
-
658
-	private function test_authkey( $authkey ) {
659
-		$this->set_test_client();
660
-		$result = $this->authenticate( $authkey );
661
-		return $result;
662
-	}
663
-
664
-	/**
665
-	 * Generates the GA select box
666
-	 *
667
-	 * @return null|string
668
-	 */
669
-	private function ga_select( $profiles = array() ) {
670
-		if ( empty( $profiles ) || ! is_array( $profiles ) ) { 
671
-			$profiles = $this->get_profiles();
672
-		}
632
+            case 'prestart':
633
+            default:
634
+                 $nextview = monsterinsights_google_auth_start_view( $reauth );
635
+                break;
636
+        }
637
+        echo $nextview;
638
+        wp_die();
639
+    }
640
+
641
+    public function google_cancel() {
642
+        $view   = isset( $_POST['view'] ) && in_array( $_POST['view'], array( 'prestart', 'start', 'enterkey', 'selectprofile', 'done' ) ) ? $_POST['view'] : '';
643
+        $reauth = isset( $_POST['reauth'] ) && $_POST['reauth'] && $_POST['reauth'] !== 'false'  ? true : false;
644
+
645
+        if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
646
+            echo esc_html__( 'Permission Denied', 'google-analytics-for-wordpress');
647
+            wp_die();
648
+        }
649
+
650
+        // If we cancelled on enterkey or selectprofile, delete the temp access tokens and set client back to normal client
651
+        if ( $view === 'enterkey' || $view === 'selectprofile' ) {
652
+            $this->client->clear_data();
653
+            delete_option( 'monsterinsights_get_profiles' );
654
+            $this->set_client();
655
+        }
656
+    }
657
+
658
+    private function test_authkey( $authkey ) {
659
+        $this->set_test_client();
660
+        $result = $this->authenticate( $authkey );
661
+        return $result;
662
+    }
663
+
664
+    /**
665
+     * Generates the GA select box
666
+     *
667
+     * @return null|string
668
+     */
669
+    private function ga_select( $profiles = array() ) {
670
+        if ( empty( $profiles ) || ! is_array( $profiles ) ) { 
671
+            $profiles = $this->get_profiles();
672
+        }
673 673
 		
674
-		$optgroups = array();
675
-		foreach ( $profiles as $key => $value ) {
676
-			foreach ( $value['items'] as $subitem ) {
677
-				if ( empty( $optgroups[ $subitem['name'] ]['items'] ) ) {
678
-					$optgroups[ $subitem['name'] ]['items'] = $subitem['items'];
679
-				} else {
680
-					$optgroups[ $subitem['name'] ]['items'] = array_merge( $optgroups[ $subitem['name'] ]['items'], $subitem['items'] );
681
-				}
682
-			}
683
-		}
684
-
685
-		$values = $optgroups;
686
-		$select = '';
687
-		$select .= '<div class="monsterinsights_ga_form">';
688
-		$select .= '<label for="monsterinsights_step_data" id="monsterinsights_select_ga_profile_label">' . esc_html__( 'Analytics profile', 'google-analytics-for-wordpress' ) . ':</label>';
689
-		$select .= '<select data-placeholder="' . esc_attr__( 'Select a profile', 'google-analytics-for-wordpress' ) . '" name="monsterinsights_step_data" class="monsterinsights-select300 monsterinsights_select_ga_profile" id="monsterinsights_step_data" style="width:80%;margin-left:10%;margin-right:10%;background-color: #FFF;">';
690
-		$select .= '<option></option>';
691
-
692
-		if ( count( $values ) >= 1 ) {
693
-			foreach ( $values as $optgroup => $value ) {
694
-				if ( ! empty( $value['items'] ) ) {
695
-					$select .= $this->create_optgroup( $optgroup, $value );
696
-				}
697
-				else {
698
-					$select .= '<option value="' . esc_attr( $value['id'] ) . '">' . esc_attr( stripslashes( $value['name'] ) ) . '</option>';
699
-				}
700
-			}
701
-		}
702
-		$select .= '</select>';
703
-		$select .= '</div>';
704
-		return $select;
705
-	}
706
-
707
-	/**
708
-	 * Creates a optgroup with the items. If items contain items it will create a nested optgroup
709
-	 *
710
-	 * @param string $optgroup
711
-	 * @param array  $value
712
-	 * @param array  $select_value
713
-	 *
714
-	 * @return string
715
-	 */
716
-	private function create_optgroup( $optgroup, $value ) {
717
-		$optgroup = '<optgroup label="' . esc_attr( $optgroup ) . '" disabled>';
718
-
719
-		foreach ( $value['items'] as $option ) {
720
-			if ( ! empty( $option['items'] ) ) {
721
-
722
-				$optgroup .= $this->create_optgroup( esc_attr( $option['name'] ), $option );
723
-			}
724
-			else {
725
-				$optgroup .= '<option value="' . esc_attr( $option['id'] ) . '">' . esc_attr( stripslashes( $option['name'] ) ) . '</option>';
726
-			}
727
-		}
728
-
729
-		$optgroup .= '</optgroup>';
730
-
731
-		return $optgroup;
732
-	}
733
-
734
-	/**
735
-	 * See if Google is on the block_request list.
736
-	 *
737
-	 * @return bool 
738
-	 */
739
-	private function is_wp_blocking_google() {
740
-		if ( defined( 'WP_HTTP_BLOCK_EXTERNAL' ) && WP_HTTP_BLOCK_EXTERNAL ) { // @todo: put this in sysinfo 
741
-			if ( defined( 'WP_ACCESSIBLE_HOSTS' ) ) {
742
-				$on_blacklist = $this->is_google_on_blacklist();
743
-				if ( $on_blacklist ) {
744
-					return true;
745
-				} else {
746
-					$params = array(
747
-						'sslverify'     => false,
748
-						'timeout'       => 60,
749
-						'user-agent'    => 'MonsterInsights/' . MONSTERINSIGHTS_VERSION,
750
-						'body'          => ''
751
-					);
752
-					$response = wp_remote_get( 'https://www.googleapis.com/discovery/v1/apis/analytics/v3/rest', $params );
753
-					if( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
754
-						return false;
755
-					} else {
756
-						return true;
757
-					}
758
-				}
759
-			} else {
760
-				return true;
761
-			}
762
-		} else {
763
-			$params = array(
764
-				'sslverify'     => false,
765
-				'timeout'       => 60,
766
-				'user-agent'    => 'MonsterInsights/' . MONSTERINSIGHTS_VERSION,
767
-				'body'          => ''
768
-			);
769
-			$response = wp_remote_get( 'https://www.googleapis.com/discovery/v1/apis/analytics/v3/rest', $params );
674
+        $optgroups = array();
675
+        foreach ( $profiles as $key => $value ) {
676
+            foreach ( $value['items'] as $subitem ) {
677
+                if ( empty( $optgroups[ $subitem['name'] ]['items'] ) ) {
678
+                    $optgroups[ $subitem['name'] ]['items'] = $subitem['items'];
679
+                } else {
680
+                    $optgroups[ $subitem['name'] ]['items'] = array_merge( $optgroups[ $subitem['name'] ]['items'], $subitem['items'] );
681
+                }
682
+            }
683
+        }
684
+
685
+        $values = $optgroups;
686
+        $select = '';
687
+        $select .= '<div class="monsterinsights_ga_form">';
688
+        $select .= '<label for="monsterinsights_step_data" id="monsterinsights_select_ga_profile_label">' . esc_html__( 'Analytics profile', 'google-analytics-for-wordpress' ) . ':</label>';
689
+        $select .= '<select data-placeholder="' . esc_attr__( 'Select a profile', 'google-analytics-for-wordpress' ) . '" name="monsterinsights_step_data" class="monsterinsights-select300 monsterinsights_select_ga_profile" id="monsterinsights_step_data" style="width:80%;margin-left:10%;margin-right:10%;background-color: #FFF;">';
690
+        $select .= '<option></option>';
691
+
692
+        if ( count( $values ) >= 1 ) {
693
+            foreach ( $values as $optgroup => $value ) {
694
+                if ( ! empty( $value['items'] ) ) {
695
+                    $select .= $this->create_optgroup( $optgroup, $value );
696
+                }
697
+                else {
698
+                    $select .= '<option value="' . esc_attr( $value['id'] ) . '">' . esc_attr( stripslashes( $value['name'] ) ) . '</option>';
699
+                }
700
+            }
701
+        }
702
+        $select .= '</select>';
703
+        $select .= '</div>';
704
+        return $select;
705
+    }
706
+
707
+    /**
708
+     * Creates a optgroup with the items. If items contain items it will create a nested optgroup
709
+     *
710
+     * @param string $optgroup
711
+     * @param array  $value
712
+     * @param array  $select_value
713
+     *
714
+     * @return string
715
+     */
716
+    private function create_optgroup( $optgroup, $value ) {
717
+        $optgroup = '<optgroup label="' . esc_attr( $optgroup ) . '" disabled>';
718
+
719
+        foreach ( $value['items'] as $option ) {
720
+            if ( ! empty( $option['items'] ) ) {
721
+
722
+                $optgroup .= $this->create_optgroup( esc_attr( $option['name'] ), $option );
723
+            }
724
+            else {
725
+                $optgroup .= '<option value="' . esc_attr( $option['id'] ) . '">' . esc_attr( stripslashes( $option['name'] ) ) . '</option>';
726
+            }
727
+        }
728
+
729
+        $optgroup .= '</optgroup>';
730
+
731
+        return $optgroup;
732
+    }
733
+
734
+    /**
735
+     * See if Google is on the block_request list.
736
+     *
737
+     * @return bool 
738
+     */
739
+    private function is_wp_blocking_google() {
740
+        if ( defined( 'WP_HTTP_BLOCK_EXTERNAL' ) && WP_HTTP_BLOCK_EXTERNAL ) { // @todo: put this in sysinfo 
741
+            if ( defined( 'WP_ACCESSIBLE_HOSTS' ) ) {
742
+                $on_blacklist = $this->is_google_on_blacklist();
743
+                if ( $on_blacklist ) {
744
+                    return true;
745
+                } else {
746
+                    $params = array(
747
+                        'sslverify'     => false,
748
+                        'timeout'       => 60,
749
+                        'user-agent'    => 'MonsterInsights/' . MONSTERINSIGHTS_VERSION,
750
+                        'body'          => ''
751
+                    );
752
+                    $response = wp_remote_get( 'https://www.googleapis.com/discovery/v1/apis/analytics/v3/rest', $params );
753
+                    if( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
754
+                        return false;
755
+                    } else {
756
+                        return true;
757
+                    }
758
+                }
759
+            } else {
760
+                return true;
761
+            }
762
+        } else {
763
+            $params = array(
764
+                'sslverify'     => false,
765
+                'timeout'       => 60,
766
+                'user-agent'    => 'MonsterInsights/' . MONSTERINSIGHTS_VERSION,
767
+                'body'          => ''
768
+            );
769
+            $response = wp_remote_get( 'https://www.googleapis.com/discovery/v1/apis/analytics/v3/rest', $params );
770 770
 			
771
-			if( !is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
772
-				return false;
773
-			} else {
774
-				return true;
775
-			}
776
-		}
777
-	}
778
-
779
-	/**
780
-	 * See if Google is on the block_request list.
781
-	 *
782
-	 * @return bool 
783
-	 */
784
-	private function is_google_on_blacklist() { // @todo: put this in sysinfo
785
-		$wp_http = new WP_Http();
786
-		if ( $wp_http->block_request( 'https://www.googleapis.com/discovery/v1/apis/analytics/v3/rest' ) ) {
787
-			return true;
788
-		}
789
-
790
-		return false;
791
-	}
792
-
793
-	public function monsterinsights_show_admin_config_empty_notice() {
794
-		$screen = get_current_screen(); 
795
-		if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) !== false ) {
796
-			return;
797
-		}
771
+            if( !is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
772
+                return false;
773
+            } else {
774
+                return true;
775
+            }
776
+        }
777
+    }
778
+
779
+    /**
780
+     * See if Google is on the block_request list.
781
+     *
782
+     * @return bool 
783
+     */
784
+    private function is_google_on_blacklist() { // @todo: put this in sysinfo
785
+        $wp_http = new WP_Http();
786
+        if ( $wp_http->block_request( 'https://www.googleapis.com/discovery/v1/apis/analytics/v3/rest' ) ) {
787
+            return true;
788
+        }
789
+
790
+        return false;
791
+    }
792
+
793
+    public function monsterinsights_show_admin_config_empty_notice() {
794
+        $screen = get_current_screen(); 
795
+        if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) !== false ) {
796
+            return;
797
+        }
798 798
 		
799
-		if ( ! defined( 'MONSTERINSIGHTS_SHOWING_EMPTY_CONFIG_NOTICE' ) ) {
800
-			define( 'MONSTERINSIGHTS_SHOWING_EMPTY_CONFIG_NOTICE', true );
801
-		}
802
-		echo '<div class="error"><p>' . 
803
-			sprintf( esc_html__( 'Please configure your %1$sGoogle Analytics settings%2$s!', 'google-analytics-for-wordpress' ),
804
-				'<a href="' . admin_url( 'admin.php?page=monsterinsights_settings' ) . '">',
805
-				'</a>'
806
-			)
807
-		. '</p></div>';
808
-	}
809
-
810
-	/**
811
-	 * Throw a warning when the fetching failed
812
-	 */
813
-	public function monsterinsights_show_admin_config_expired_notice() {
814
-		echo '<div class="error"><p>' . 
815
-			sprintf(
816
-				esc_html__( 'It seems the authentication for the plugin has expired or the connection to Google Analytics is blocked, please try %1$sre-authenticating%2$s with Google Analytics to allow the plugin to fetch data.', 'google-analytics-for-wordpress' ),
817
-				'<a href="' . admin_url( 'admin.php?page=monsterinsights_settings' ) . '">',
818
-				'</a>'
819
-			)
820
-		. '</p></div>';
821
-	}
822
-
823
-	/**
824
-	 * Throw a warning when the fetching failed
825
-	 */
826
-	public function monsterinsights_show_admin_config_needs_permissions_notice() {
827
-		echo '<div class="error"><p>' . 
828
-			sprintf(
829
-				esc_html__( 'It seems the authentication for the plugin is missing permissions. Please %1$sre-authenticate%2$s with Google Analytics to allow the plugin to fetch data.', 'google-analytics-for-wordpress' ),
830
-				'<a href="' . admin_url( 'admin.php?page=monsterinsights_settings' ) . '">',
831
-				'</a>'
832
-			)
833
-		. '</p></div>';
834
-	}
835
-
836
-	/**
837
-	 * Throw a warning when the fetching failed
838
-	 */
839
-	public function monsterinsights_show_admin_config_blocked_notice() {
840
-		echo '<div class="error"><p>' . 
841
-			sprintf(
842
-				esc_html__( 'Data is not up-to-date, there was an error in retrieving the data from Google Analytics. This error could be caused by several issues. If the error persists, please see %1$sthis page%2$s.', 'google-analytics-for-wordpress' ),
843
-				'<a href="https://www.monsterinsights.com/docs/blocked-connection/">',
844
-				'</a>'
845
-			)
846
-		. '</p></div>';
847
-	}
799
+        if ( ! defined( 'MONSTERINSIGHTS_SHOWING_EMPTY_CONFIG_NOTICE' ) ) {
800
+            define( 'MONSTERINSIGHTS_SHOWING_EMPTY_CONFIG_NOTICE', true );
801
+        }
802
+        echo '<div class="error"><p>' . 
803
+            sprintf( esc_html__( 'Please configure your %1$sGoogle Analytics settings%2$s!', 'google-analytics-for-wordpress' ),
804
+                '<a href="' . admin_url( 'admin.php?page=monsterinsights_settings' ) . '">',
805
+                '</a>'
806
+            )
807
+        . '</p></div>';
808
+    }
809
+
810
+    /**
811
+     * Throw a warning when the fetching failed
812
+     */
813
+    public function monsterinsights_show_admin_config_expired_notice() {
814
+        echo '<div class="error"><p>' . 
815
+            sprintf(
816
+                esc_html__( 'It seems the authentication for the plugin has expired or the connection to Google Analytics is blocked, please try %1$sre-authenticating%2$s with Google Analytics to allow the plugin to fetch data.', 'google-analytics-for-wordpress' ),
817
+                '<a href="' . admin_url( 'admin.php?page=monsterinsights_settings' ) . '">',
818
+                '</a>'
819
+            )
820
+        . '</p></div>';
821
+    }
822
+
823
+    /**
824
+     * Throw a warning when the fetching failed
825
+     */
826
+    public function monsterinsights_show_admin_config_needs_permissions_notice() {
827
+        echo '<div class="error"><p>' . 
828
+            sprintf(
829
+                esc_html__( 'It seems the authentication for the plugin is missing permissions. Please %1$sre-authenticate%2$s with Google Analytics to allow the plugin to fetch data.', 'google-analytics-for-wordpress' ),
830
+                '<a href="' . admin_url( 'admin.php?page=monsterinsights_settings' ) . '">',
831
+                '</a>'
832
+            )
833
+        . '</p></div>';
834
+    }
835
+
836
+    /**
837
+     * Throw a warning when the fetching failed
838
+     */
839
+    public function monsterinsights_show_admin_config_blocked_notice() {
840
+        echo '<div class="error"><p>' . 
841
+            sprintf(
842
+                esc_html__( 'Data is not up-to-date, there was an error in retrieving the data from Google Analytics. This error could be caused by several issues. If the error persists, please see %1$sthis page%2$s.', 'google-analytics-for-wordpress' ),
843
+                '<a href="https://www.monsterinsights.com/docs/blocked-connection/">',
844
+                '</a>'
845
+            )
846
+        . '</p></div>';
847
+    }
848 848
 }
849 849
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/abstract-report.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -39,28 +39,28 @@  discard block
 block discarded – undo
39 39
 	 * @access public
40 40
 	 * @since 6.0.0
41 41
 	 */
42
-	public function __construct( $range = array() ) {
42
+	public function __construct($range = array()) {
43 43
 
44 44
 		$this->range = monsterinsights_get_report_date_range();
45 45
 
46 46
 		// filter to add tab for this report
47
-		add_filter( 'monsterinsights_get_reports', array( $this, 'add_report' ), 10, 1 );
47
+		add_filter('monsterinsights_get_reports', array($this, 'add_report'), 10, 1);
48 48
 
49 49
 		// filter to show the view for this report
50
-		add_action( 'monsterinsights_tab_reports_' . $this->report_hook, array( $this, 'show_report' ), 10, 1 );
50
+		add_action('monsterinsights_tab_reports_' . $this->report_hook, array($this, 'show_report'), 10, 1);
51 51
 
52
-		add_action( 'monsterinsights_add_aggregate_data', array( $this, 'add_report_data' ), 10, 2 );
53
-		add_action( 'monsterinsights_delete_aggregate_data', array( $this, 'delete_report_data' ), 10, 2 );
52
+		add_action('monsterinsights_add_aggregate_data', array($this, 'add_report_data'), 10, 2);
53
+		add_action('monsterinsights_delete_aggregate_data', array($this, 'delete_report_data'), 10, 2);
54 54
 
55 55
 	}
56 56
 
57 57
 	 // Adds the report to the array of reports.
58
-	public function add_report( $reports ) {
59
-		$reports[ $this->report_hook ] = $this->report_name;
58
+	public function add_report($reports) {
59
+		$reports[$this->report_hook] = $this->report_name;
60 60
 		return $reports;
61 61
 	}
62 62
 
63
-	abstract public function add_report_data( $client, $id ); // Adds/Refreshes the data
63
+	abstract public function add_report_data($client, $id); // Adds/Refreshes the data
64 64
 	abstract public function get_report_data(); // Gets the data
65 65
 	abstract public function delete_report_data(); // Removes report data
66 66
 	abstract public function show_report(); // Outputs the report.
@@ -88,6 +88,6 @@  discard block
 block discarded – undo
88 88
 	 * @return int
89 89
 	 */
90 90
 	protected function get_api_max_limit() {
91
-		return apply_filters( 'monsterinsights_reporting_get_max_api_limit', 300 );
91
+		return apply_filters('monsterinsights_reporting_get_max_api_limit', 300);
92 92
 	}
93 93
 }
94 94
\ No newline at end of file
Please login to merge, or discard this patch.
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -13,81 +13,81 @@
 block discarded – undo
13 13
 
14 14
 // Exit if accessed directly
15 15
 if ( ! defined( 'ABSPATH' ) ) {
16
-	exit;
16
+    exit;
17 17
 }
18 18
 
19 19
 abstract class MonsterInsights_Report {
20 20
 
21
-	public $report_name;
22
-
23
-	public $report_hook;
24
-
25
-	public $range;
26
-
27
-	/**
28
-	 * Holds the GA client object if using oAuth.
29
-	 *
30
-	 * @access public
31
-	 * @since 6.0.0
32
-	 * @var MonsterInsights_GA_Client $client GA client object.
33
-	 */
34
-	public $client;
35
-
36
-	/**
37
-	 * Primary class constructor.
38
-	 *
39
-	 * @access public
40
-	 * @since 6.0.0
41
-	 */
42
-	public function __construct( $range = array() ) {
43
-
44
-		$this->range = monsterinsights_get_report_date_range();
45
-
46
-		// filter to add tab for this report
47
-		add_filter( 'monsterinsights_get_reports', array( $this, 'add_report' ), 10, 1 );
48
-
49
-		// filter to show the view for this report
50
-		add_action( 'monsterinsights_tab_reports_' . $this->report_hook, array( $this, 'show_report' ), 10, 1 );
51
-
52
-		add_action( 'monsterinsights_add_aggregate_data', array( $this, 'add_report_data' ), 10, 2 );
53
-		add_action( 'monsterinsights_delete_aggregate_data', array( $this, 'delete_report_data' ), 10, 2 );
54
-
55
-	}
56
-
57
-	 // Adds the report to the array of reports.
58
-	public function add_report( $reports ) {
59
-		$reports[ $this->report_hook ] = $this->report_name;
60
-		return $reports;
61
-	}
62
-
63
-	abstract public function add_report_data( $client, $id ); // Adds/Refreshes the data
64
-	abstract public function get_report_data(); // Gets the data
65
-	abstract public function delete_report_data(); // Removes report data
66
-	abstract public function show_report(); // Outputs the report.
67
-
68
-	/**
69
-	 * Get the start and and date for aggregation functionality.
70
-	 *
71
-	 * @return array
72
-	 */
73
-	protected function get_date_range() {
74
-		return $this->range;
75
-	}
76
-
77
-	/**
78
-	 * Get the api limit for aggregation functionality.
79
-	 *
80
-	 * By default Google will return 1000 rows at most. They will return less in certain circumstances.
81
-	 * For example, the countries query will never return more than 300 rows as there's not more than 300 values
82
-	 * for ga:countries dimension. If you are a large site you might need to use this filter to lower the number requested. 
83
-	 * We only request 300, as it's the max number for the largest report we need (by country maxes at 300 countries).
84
-	 *
85
-	 * In the future, we'll likely have each report use the limit returned in this function, or a report-set default limit,
86
-	 * whichever is lower.
87
-	 *
88
-	 * @return int
89
-	 */
90
-	protected function get_api_max_limit() {
91
-		return apply_filters( 'monsterinsights_reporting_get_max_api_limit', 300 );
92
-	}
21
+    public $report_name;
22
+
23
+    public $report_hook;
24
+
25
+    public $range;
26
+
27
+    /**
28
+     * Holds the GA client object if using oAuth.
29
+     *
30
+     * @access public
31
+     * @since 6.0.0
32
+     * @var MonsterInsights_GA_Client $client GA client object.
33
+     */
34
+    public $client;
35
+
36
+    /**
37
+     * Primary class constructor.
38
+     *
39
+     * @access public
40
+     * @since 6.0.0
41
+     */
42
+    public function __construct( $range = array() ) {
43
+
44
+        $this->range = monsterinsights_get_report_date_range();
45
+
46
+        // filter to add tab for this report
47
+        add_filter( 'monsterinsights_get_reports', array( $this, 'add_report' ), 10, 1 );
48
+
49
+        // filter to show the view for this report
50
+        add_action( 'monsterinsights_tab_reports_' . $this->report_hook, array( $this, 'show_report' ), 10, 1 );
51
+
52
+        add_action( 'monsterinsights_add_aggregate_data', array( $this, 'add_report_data' ), 10, 2 );
53
+        add_action( 'monsterinsights_delete_aggregate_data', array( $this, 'delete_report_data' ), 10, 2 );
54
+
55
+    }
56
+
57
+        // Adds the report to the array of reports.
58
+    public function add_report( $reports ) {
59
+        $reports[ $this->report_hook ] = $this->report_name;
60
+        return $reports;
61
+    }
62
+
63
+    abstract public function add_report_data( $client, $id ); // Adds/Refreshes the data
64
+    abstract public function get_report_data(); // Gets the data
65
+    abstract public function delete_report_data(); // Removes report data
66
+    abstract public function show_report(); // Outputs the report.
67
+
68
+    /**
69
+     * Get the start and and date for aggregation functionality.
70
+     *
71
+     * @return array
72
+     */
73
+    protected function get_date_range() {
74
+        return $this->range;
75
+    }
76
+
77
+    /**
78
+     * Get the api limit for aggregation functionality.
79
+     *
80
+     * By default Google will return 1000 rows at most. They will return less in certain circumstances.
81
+     * For example, the countries query will never return more than 300 rows as there's not more than 300 values
82
+     * for ga:countries dimension. If you are a large site you might need to use this filter to lower the number requested. 
83
+     * We only request 300, as it's the max number for the largest report we need (by country maxes at 300 countries).
84
+     *
85
+     * In the future, we'll likely have each report use the limit returned in this function, or a report-set default limit,
86
+     * whichever is lower.
87
+     *
88
+     * @return int
89
+     */
90
+    protected function get_api_max_limit() {
91
+        return apply_filters( 'monsterinsights_reporting_get_max_api_limit', 300 );
92
+    }
93 93
 }
94 94
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/admin.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -269,13 +269,13 @@
 block discarded – undo
269 269
     }
270 270
 
271 271
     if ( $analytics === 'ga' && ! isset( $notices ['monsterinsights_deprecated_ga' ] ) ){
272
-       echo '<div class="notice notice-error is-dismissible monsterinsights-notice" data-notice="monsterinsights_deprecated_ga">';
272
+        echo '<div class="notice notice-error is-dismissible monsterinsights-notice" data-notice="monsterinsights_deprecated_ga">';
273 273
             echo '<p>';
274 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 277
     } else if ( $events === 'php' && ! isset( $notices ['monsterinsights_deprecated_php' ] ) ){
278
-       echo '<div class="notice notice-error is-dismissible monsterinsights-notice" data-notice="monsterinsights_deprecated_php">';
278
+        echo '<div class="notice notice-error is-dismissible monsterinsights-notice" data-notice="monsterinsights_deprecated_php">';
279 279
             echo '<p>';
280 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>';
Please login to merge, or discard this patch.
Spacing   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
     exit;
15 15
 }
16 16
 
@@ -27,43 +27,43 @@  discard block
 block discarded – undo
27 27
     // Get the base class object.
28 28
     $base = MonsterInsights();
29 29
     
30
-    $dashboards_disabled = monsterinsights_get_option( 'dashboards_disabled', false );
30
+    $dashboards_disabled = monsterinsights_get_option('dashboards_disabled', false);
31 31
 
32 32
     $hook = 'monsterinsights_settings';
33 33
 
34
-    if ( $dashboards_disabled || ( current_user_can( 'monsterinsights_save_settings' ) && ! current_user_can( 'monsterinsights_view_dashboard' ) ) ) {
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
-        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 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
 
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 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' );
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
-    if ( ! $dashboards_disabled ) {
52
+    if ( ! $dashboards_disabled) {
53 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' );
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
58
-    add_submenu_page( $hook, __( 'Tools:', 'google-analytics-for-wordpress' ), __( 'Tools', 'google-analytics-for-wordpress' ), 'manage_options', 'monsterinsights_tools', 'monsterinsights_tools_page' );
58
+    add_submenu_page($hook, __('Tools:', 'google-analytics-for-wordpress'), __('Tools', 'google-analytics-for-wordpress'), 'manage_options', 'monsterinsights_tools', 'monsterinsights_tools_page');
59 59
     
60 60
     // then addons
61
-    $network_license = get_site_option( 'monsterinsights_license' );
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' );
61
+    $network_license = get_site_option('monsterinsights_license');
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');
64 64
     }
65 65
 }
66
-add_action( 'admin_menu', 'monsterinsights_admin_menu' );
66
+add_action('admin_menu', 'monsterinsights_admin_menu');
67 67
 
68 68
 
69 69
 
@@ -73,24 +73,24 @@  discard block
 block discarded – undo
73 73
 
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
-    if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
77
-        require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
76
+    if ( ! function_exists('is_plugin_active_for_network')) {
77
+        require_once(ABSPATH . '/wp-admin/includes/plugin.php');
78 78
     }
79 79
 
80
-    $plugin = plugin_basename( MONSTERINSIGHTS_PLUGIN_FILE );
81
-    if ( ! is_plugin_active_for_network( $plugin ) ) {
80
+    $plugin = plugin_basename(MONSTERINSIGHTS_PLUGIN_FILE);
81
+    if ( ! is_plugin_active_for_network($plugin)) {
82 82
         return;
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
-    add_submenu_page( $hook, __( 'Network Settings', 'google-analytics-for-wordpress' ), __( 'Network Settings', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', 'monsterinsights_network', 'monsterinsights_network_page' );
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
 
90 90
     // then addons
91
-    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' );
91
+    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');
92 92
 }
93
-add_action( 'network_admin_menu', 'monsterinsights_network_admin_menu', 5 );
93
+add_action('network_admin_menu', 'monsterinsights_network_admin_menu', 5);
94 94
 
95 95
 /**
96 96
  * Adds one or more classes to the body tag in the dashboard.
@@ -98,15 +98,15 @@  discard block
 block discarded – undo
98 98
  * @param  String $classes Current body classes.
99 99
  * @return String          Altered body classes.
100 100
  */
101
-function monsterinsights_add_admin_body_class( $classes ) {
101
+function monsterinsights_add_admin_body_class($classes) {
102 102
     $screen = get_current_screen(); 
103
-    if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) === false ) {
103
+    if (empty($screen->id) || strpos($screen->id, 'monsterinsights') === false) {
104 104
         return $classes;
105 105
     }
106 106
        
107 107
     return "$classes monsterinsights_page ";
108 108
 }
109
-add_filter( 'admin_body_class', 'monsterinsights_add_admin_body_class', 10, 1 );
109
+add_filter('admin_body_class', 'monsterinsights_add_admin_body_class', 10, 1);
110 110
 
111 111
 /**
112 112
  * Add a link to the settings page to the plugins list
@@ -115,31 +115,31 @@  discard block
 block discarded – undo
115 115
  *
116 116
  * @return array $links
117 117
  */
118
-function monsterinsights_add_action_links( $links ) {
119
-    $docs = '<a title="MonsterInsights Knowledge Base" href="https://www.monsterinsights.com/docs/">' . esc_html__( 'Documentation', 'google-analytics-for-wordpress' ) . '</a>';
120
-    array_unshift( $links, $docs );
118
+function monsterinsights_add_action_links($links) {
119
+    $docs = '<a title="MonsterInsights Knowledge Base" href="https://www.monsterinsights.com/docs/">' . esc_html__('Documentation', 'google-analytics-for-wordpress') . '</a>';
120
+    array_unshift($links, $docs);
121 121
 
122 122
     // If lite, show a link where they can get pro from
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 );
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);
126 126
     }   
127 127
     
128 128
     // If Lite, support goes to forum. If pro, it goes to our website
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 );
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);
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
-    $settings_link = '<a href="' . esc_url( admin_url( 'admin.php?page=monsterinsights_settings' ) ) . '">' . esc_html__( 'Settings', 'google-analytics-for-wordpress' ) . '</a>';
138
-    array_unshift( $links, $settings_link );
137
+    $settings_link = '<a href="' . esc_url(admin_url('admin.php?page=monsterinsights_settings')) . '">' . esc_html__('Settings', 'google-analytics-for-wordpress') . '</a>';
138
+    array_unshift($links, $settings_link);
139 139
 
140 140
     return $links;
141 141
 }
142
-add_filter( 'plugin_action_links_' . plugin_basename( MONSTERINSIGHTS_PLUGIN_FILE ), 'monsterinsights_add_action_links' );
142
+add_filter('plugin_action_links_' . plugin_basename(MONSTERINSIGHTS_PLUGIN_FILE), 'monsterinsights_add_action_links');
143 143
 
144 144
 
145 145
 
@@ -153,30 +153,30 @@  discard block
 block discarded – undo
153 153
  * @param   array   $data       Any data to pass to the view
154 154
  * @return  void
155 155
  */
156
-function monsterinsights_load_admin_partial( $template, $data = array() ) {
156
+function monsterinsights_load_admin_partial($template, $data = array()) {
157 157
     // Get the base class object.
158 158
     $base = MonsterInsights();
159 159
 
160
-    if ( monsterinsights_is_pro_version() ) {
161
-        $dir = trailingslashit( plugin_dir_path( $base->file ) . 'pro/includes/admin/partials' );
160
+    if (monsterinsights_is_pro_version()) {
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' );
163
+        if (file_exists($dir . $template . '.php')) {
164
+            require_once($dir . $template . '.php');
165 165
             return true;
166 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' );
170
+        if (file_exists($dir . $template . '.php')) {
171
+            require_once($dir . $template . '.php');
172 172
             return true;
173 173
         }   
174 174
     }
175 175
         
176
-    $dir = trailingslashit( plugin_dir_path( $base->file ) . 'includes/admin/partials' );
176
+    $dir = trailingslashit(plugin_dir_path($base->file) . 'includes/admin/partials');
177 177
 
178
-    if ( file_exists( $dir . $template . '.php' ) ) {
179
-        require_once(  $dir . $template . '.php' );
178
+    if (file_exists($dir . $template . '.php')) {
179
+        require_once($dir . $template . '.php');
180 180
         return true;
181 181
     }
182 182
                 
@@ -195,36 +195,36 @@  discard block
 block discarded – undo
195 195
     
196 196
     // Get the current screen, and check whether we're viewing a MonsterInsights screen;
197 197
     $screen = get_current_screen(); 
198
-    if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) === false ) {
198
+    if (empty($screen->id) || strpos($screen->id, 'monsterinsights') === false) {
199 199
         return;
200 200
     }
201 201
 
202 202
     // If here, we're on an MonsterInsights screen, so output the header.
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 ),
208
-    ) );
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),
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
214
-    if ( ! get_transient( '_monsterinsights_activation_redirect' ) ) {
214
+    if ( ! get_transient('_monsterinsights_activation_redirect')) {
215 215
         return;
216 216
     }
217 217
 
218 218
     // Delete the redirect transient
219
-    delete_transient( '_monsterinsights_activation_redirect' );
219
+    delete_transient('_monsterinsights_activation_redirect');
220 220
 
221 221
     // Bail if activating from network, or bulk
222
-    if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
222
+    if (is_network_admin() || isset($_GET['activate-multi'])) {
223 223
         return;
224 224
     }
225 225
 
226
-    $upgrade = get_option( 'monsterinsights_version_upgraded_from' );
227
-    if( ! $upgrade ) { // First time install
226
+    $upgrade = get_option('monsterinsights_version_upgraded_from');
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;
@@ -241,57 +241,57 @@  discard block
 block discarded – undo
241 241
  * @param string $text
242 242
  * @return string
243 243
  */
244
-function monsterinsights_admin_footer( $text ) {
244
+function monsterinsights_admin_footer($text) {
245 245
     global $current_screen;
246
-    if ( ! empty( $current_screen->id ) && strpos( $current_screen->id, 'monsterinsights' ) !== false ) {
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
 }
252
-add_filter( 'admin_footer_text', 'monsterinsights_admin_footer', 1, 2 );
252
+add_filter('admin_footer_text', 'monsterinsights_admin_footer', 1, 2);
253 253
 
254 254
 function monsterinsights_deprecated_notices() {
255 255
     // Don't show on MonsterInsights pages
256 256
     $screen = get_current_screen(); 
257
-    if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) !== false ) {
257
+    if (empty($screen->id) || strpos($screen->id, 'monsterinsights') !== false) {
258 258
         return;
259 259
     }
260 260
     
261
-    $analytics = monsterinsights_get_option( 'tracking_mode', 'analytics' );
262
-    $events    = monsterinsights_get_option( 'events_mode', false );
263
-    $updates   = monsterinsights_get_option( 'automatic_updates', false );
264
-    $url       = admin_url( 'admin.php?page=monsterinsights_settings' );
265
-    $notices   = get_option( 'monsterinsights_notices' );
261
+    $analytics = monsterinsights_get_option('tracking_mode', 'analytics');
262
+    $events    = monsterinsights_get_option('events_mode', false);
263
+    $updates   = monsterinsights_get_option('automatic_updates', false);
264
+    $url       = admin_url('admin.php?page=monsterinsights_settings');
265
+    $notices   = get_option('monsterinsights_notices');
266 266
 
267
-    if ( ! is_array( $notices ) ) {
267
+    if ( ! is_array($notices)) {
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' ] ) ){ 
284
-        if ( defined( 'MONSTERINSIGHTS_SHOWING_EMPTY_CONFIG_NOTICE' ) && MONSTERINSIGHTS_SHOWING_EMPTY_CONFIG_NOTICE ) {
283
+    } else if (empty($updates) && ! isset($notices ['monsterinsights_automatic_updates'])) { 
284
+        if (defined('MONSTERINSIGHTS_SHOWING_EMPTY_CONFIG_NOTICE') && MONSTERINSIGHTS_SHOWING_EMPTY_CONFIG_NOTICE) {
285 285
             return;
286 286
         }
287
-        if ( defined( 'MONSTERINSIGHTS_SHOWING_OPTIN_TRACKING_NOTICE' ) && MONSTERINSIGHTS_SHOWING_OPTIN_TRACKING_NOTICE ) {
287
+        if (defined('MONSTERINSIGHTS_SHOWING_OPTIN_TRACKING_NOTICE') && MONSTERINSIGHTS_SHOWING_OPTIN_TRACKING_NOTICE) {
288 288
             return;
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
     }
296 296
 }
297
-add_action( 'admin_notices', 'monsterinsights_deprecated_notices' );
298 297
\ No newline at end of file
298
+add_action('admin_notices', 'monsterinsights_deprecated_notices');
299 299
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/settings/tab-tracking.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
     exit;
15 15
 }
16 16
 
@@ -32,14 +32,14 @@  discard block
 block discarded – undo
32 32
             $i      = 0;
33 33
             $class  = '';
34 34
             $is_pro = monsterinsights_is_pro_version();
35
-            foreach ( (array) monsterinsights_get_settings_tabs() as $id => $item ) {
36
-                if ( isset( $item['comingsoon'] ) && $item['comingsoon'] || empty( $item['title'] ) ) {
35
+            foreach ((array) monsterinsights_get_settings_tabs() as $id => $item) {
36
+                if (isset($item['comingsoon']) && $item['comingsoon'] || empty($item['title'])) {
37 37
                     continue;
38 38
                 }
39
-                $class = ( 0 === $i ? 'monsterinsights-active' : '' );
39
+                $class = (0 === $i ? 'monsterinsights-active' : '');
40 40
                 ?>
41
-                <a class="monsterinsights-sub-nav-item monsterinsights-nav-item monsterinsights-active monstericon-<?php echo esc_attr( $id ); ?> <?php echo esc_attr( $class ); ?>" href="#monsterinsights-main-tab-tracking?monsterinsights-sub-tab-<?php echo esc_attr( $id ); ?>" title="<?php echo esc_attr( $item['title'] ); ?>">
42
-                    <?php echo esc_html( $item['title'] ); ?>
41
+                <a class="monsterinsights-sub-nav-item monsterinsights-nav-item monsterinsights-active monstericon-<?php echo esc_attr($id); ?> <?php echo esc_attr($class); ?>" href="#monsterinsights-main-tab-tracking?monsterinsights-sub-tab-<?php echo esc_attr($id); ?>" title="<?php echo esc_attr($item['title']); ?>">
42
+                    <?php echo esc_html($item['title']); ?>
43 43
                 </a>
44 44
                 <?php 
45 45
                 $i++; 
@@ -58,22 +58,22 @@  discard block
 block discarded – undo
58 58
          * not be used by other developers. This hook's behavior may be modified
59 59
          * or the hook may be removed at any time, without warning.
60 60
          */
61
-        do_action( 'monsterinsights_settings_tracking_tab_notice' );
61
+        do_action('monsterinsights_settings_tracking_tab_notice');
62 62
         ?>
63 63
 
64 64
         <!-- Tab Panels -->
65 65
         <div id="monsterinsights-settings-sub-pages" class="monsterinsights-sub-nav-tabs monsterinsights-nav-tabs" data-navigation="#monsterinsights-settings-page-sub-nav">
66 66
             <?php 
67 67
             $i = 0; 
68
-            foreach ( (array) monsterinsights_get_settings_tabs() as $id => $item ) {
69
-                if ( isset( $item['comingsoon'] ) && $item['comingsoon'] || empty( $item['title'] ) ) {
68
+            foreach ((array) monsterinsights_get_settings_tabs() as $id => $item) {
69
+                if (isset($item['comingsoon']) && $item['comingsoon'] || empty($item['title'])) {
70 70
                     continue;
71 71
                 }
72
-                $class = ( 0 === $i ? ' monsterinsights-active' : '' ); 
72
+                $class = (0 === $i ? ' monsterinsights-active' : ''); 
73 73
                 ?>
74
-                 <div id="monsterinsights-sub-tab-<?php echo esc_attr( $id ); ?>" class="monsterinsights-sub-nav-tab monsterinsights-nav-tab<?php echo esc_attr( $class ); ?>">
75
-                    <?php if ( $item['level'] === 'lite' ||  $is_pro ) { ?>
76
-                    <?php echo '<h2 class="monsterinsights-sub-tab-header">' . esc_html( $item['title'] ) . '</h2>'; ?>
74
+                 <div id="monsterinsights-sub-tab-<?php echo esc_attr($id); ?>" class="monsterinsights-sub-nav-tab monsterinsights-nav-tab<?php echo esc_attr($class); ?>">
75
+                    <?php if ($item['level'] === 'lite' || $is_pro) { ?>
76
+                    <?php echo '<h2 class="monsterinsights-sub-tab-header">' . esc_html($item['title']) . '</h2>'; ?>
77 77
                     <?php } ?>
78 78
                      <div class="monsterinsights-subtab-settings-notices">
79 79
                         <?php 
@@ -85,27 +85,27 @@  discard block
 block discarded – undo
85 85
                          * not be used by other developers. This hook's behavior may be modified
86 86
                          * or the hook may be removed at any time, without warning.
87 87
                          */
88
-                        do_action( 'monsterinsights_tracking_' . $id . '_tab_notice' );
88
+                        do_action('monsterinsights_tracking_' . $id . '_tab_notice');
89 89
                         ?>
90 90
                     </div>
91 91
                     <!-- Settings Form -->
92
-                    <?php $class = ( $item['level'] !== 'lite' && ! $is_pro ) ? 'monsterinsights-no-settings-shown' : ''; ?>
93
-                    <form id="monsterinsights-tracking-<?php echo esc_attr( $id );?>-tab" class="<?php echo $class; ?>" method="post">
92
+                    <?php $class = ($item['level'] !== 'lite' && ! $is_pro) ? 'monsterinsights-no-settings-shown' : ''; ?>
93
+                    <form id="monsterinsights-tracking-<?php echo esc_attr($id); ?>-tab" class="<?php echo $class; ?>" method="post">
94 94
                         <table class="form-table">
95 95
                             <tbody>
96 96
                                 <?php
97 97
                                 //do_action( 'monsterinsights_settings_tab_top_' . $id  );
98
-                                echo monsterinsights_get_section_settings( $id, 'tracking' );
98
+                                echo monsterinsights_get_section_settings($id, 'tracking');
99 99
                                 //do_action( 'monsterinsights_settings_tab_bottom_' . $id  );
100 100
                                 ?>
101 101
                             </tbody>
102 102
                         </table>
103
-                        <?php echo monsterinsights_render_submit_field( $id, 'tracking' ); ?>
104
-                        <?php if ( $item['level'] === 'lite' && !$is_pro ) { ?>
103
+                        <?php echo monsterinsights_render_submit_field($id, 'tracking'); ?>
104
+                        <?php if ($item['level'] === 'lite' && ! $is_pro) { ?>
105 105
                             <div class="monsterinsights-upsell-under-box">
106
-                                <h2><?php esc_html_e( "Want even more fine tuned control over your website analytics?", 'google-analytics-for-wordpress' ); ?></h2>
107
-                                <p class="monsterinsights-upsell-lite-text"><?php esc_html_e( "By upgrading to MonsterInsights Pro, you get access to numerous addons and tools that help you better understand what people are doing on your website, so you can keep doing more of what's working. Some of the features include: Ecommerce tracking, Author tracking, Post Type tracking, Ads tracking, Google AMP tracking, Performance optimization, and so much more!", 'google-analytics-for-wordpress' ); ?></p>
108
-                                <p class="monsterinsights-upsell-button-par"><a href="https://www.monsterinsights.com/lite/" class="button button-primary"><?php esc_html_e( "Click here to Upgrade", 'google-analytics-for-wordpress' ); ?></a></p></div>
106
+                                <h2><?php esc_html_e("Want even more fine tuned control over your website analytics?", 'google-analytics-for-wordpress'); ?></h2>
107
+                                <p class="monsterinsights-upsell-lite-text"><?php esc_html_e("By upgrading to MonsterInsights Pro, you get access to numerous addons and tools that help you better understand what people are doing on your website, so you can keep doing more of what's working. Some of the features include: Ecommerce tracking, Author tracking, Post Type tracking, Ads tracking, Google AMP tracking, Performance optimization, and so much more!", 'google-analytics-for-wordpress'); ?></p>
108
+                                <p class="monsterinsights-upsell-button-par"><a href="https://www.monsterinsights.com/lite/" class="button button-primary"><?php esc_html_e("Click here to Upgrade", 'google-analytics-for-wordpress'); ?></a></p></div>
109 109
                         <?php } ?>
110 110
                     </form>
111 111
                 </div>
@@ -117,4 +117,4 @@  discard block
 block discarded – undo
117 117
     </div>
118 118
     <?php
119 119
 }
120
-add_action( 'monsterinsights_tab_settings_tracking', 'monsterinsights_settings_tracking_tab' );
121 120
\ No newline at end of file
121
+add_action('monsterinsights_tab_settings_tracking', 'monsterinsights_settings_tracking_tab');
122 122
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/settings/settings-api.php 3 patches
Spacing   +279 added lines, -279 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( !defined( 'ABSPATH' ) ) exit;
13
+if ( ! defined('ABSPATH')) exit;
14 14
 
15 15
 /**
16 16
  * Get the settings for a section
@@ -18,12 +18,12 @@  discard block
 block discarded – undo
18 18
  * @since 6.0.0
19 19
  * @return void
20 20
 */
21
-function monsterinsights_get_section_settings( $section, $page = 'tracking' ) {
21
+function monsterinsights_get_section_settings($section, $page = 'tracking') {
22 22
 	$output = '';
23 23
 	$settings = monsterinsights_get_registered_settings();
24
-	if ( is_array( $settings ) && ! empty( $settings[$section] ) && is_array( $settings[$section] ) ) {
25
-		foreach ( $settings[$section] as $setting ) {
26
-			$args = wp_parse_args( $setting, array(
24
+	if (is_array($settings) && ! empty($settings[$section]) && is_array($settings[$section])) {
25
+		foreach ($settings[$section] as $setting) {
26
+			$args = wp_parse_args($setting, array(
27 27
 				'id'            => null,
28 28
 				'desc'          => '',
29 29
 				'name'          => '',
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
45 45
 				'allowclear'    => true,
46 46
 				'notice_type'   => 'info',
47 47
 				'no_label'      => false,
48
-			) );
49
-			$output .= monsterinsights_render_field( $args );
48
+			));
49
+			$output .= monsterinsights_render_field($args);
50 50
 		}
51 51
 	}
52 52
 	return $output;
@@ -63,46 +63,46 @@  discard block
 block discarded – undo
63 63
 function monsterinsights_save_settings() {
64 64
 
65 65
 	// Check if user pressed the 'Update' button and nonce is valid
66
-	if ( ! isset( $_POST['monsterinsights-settings-submit'] ) ) {
66
+	if ( ! isset($_POST['monsterinsights-settings-submit'])) {
67 67
 		return;
68 68
 	}
69 69
 
70
-	if ( ! wp_verify_nonce( $_POST['monsterinsights-settings-nonce'], 'monsterinsights-settings-nonce' ) ) {
70
+	if ( ! wp_verify_nonce($_POST['monsterinsights-settings-nonce'], 'monsterinsights-settings-nonce')) {
71 71
 		return;
72 72
 	}
73 73
 
74
-	if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
74
+	if ( ! current_user_can('monsterinsights_save_settings')) {
75 75
 		return;
76 76
 	}
77 77
 
78
-	if ( empty( $_POST['monsterinsights_settings_tab'] ) || empty( $_POST['monsterinsights_settings_sub_tab'] ) || $_POST['monsterinsights_settings_tab'] !== 'tracking' ) {
78
+	if (empty($_POST['monsterinsights_settings_tab']) || empty($_POST['monsterinsights_settings_sub_tab']) || $_POST['monsterinsights_settings_tab'] !== 'tracking') {
79 79
 		return;
80 80
 	}
81 81
 
82 82
 	// get subtab
83 83
 	$settings = monsterinsights_get_registered_settings();
84 84
 	$tab      = $_POST['monsterinsights_settings_sub_tab'];
85
-	if ( empty( $settings ) || !is_array( $settings ) || empty( $settings[ $tab ] ) || ! is_array( $settings[ $tab ] ) ) {
85
+	if (empty($settings) || ! is_array($settings) || empty($settings[$tab]) || ! is_array($settings[$tab])) {
86 86
 		return;
87 87
 	}
88 88
 
89 89
 	// Okay we're good to sanitize, validate, and save this section's settings
90 90
 
91 91
 	// We only care about this sections's settings
92
-	$settings = $settings[ $tab ]; 
92
+	$settings = $settings[$tab]; 
93 93
 
94 94
 	// Run a general sanitization for the tab for special fields
95
-	$input    = ! empty( $_POST['monsterinsights_settings'] ) ? $_POST['monsterinsights_settings'] : array();
96
-	$input    = apply_filters( 'monsterinsights_settings_' . $tab . '_sanitize', $input );
95
+	$input    = ! empty($_POST['monsterinsights_settings']) ? $_POST['monsterinsights_settings'] : array();
96
+	$input    = apply_filters('monsterinsights_settings_' . $tab . '_sanitize', $input);
97 97
 
98
-	foreach( $settings as $id => $setting ) {
98
+	foreach ($settings as $id => $setting) {
99 99
 
100 100
 		// If the value wasn't passed in, set to false, which will delete the option
101
-		$value          = isset( $input[ $id ] ) ? $input[ $id ] : false;
102
-		$previous_value = monsterinsights_get_option( $id, false );
101
+		$value          = isset($input[$id]) ? $input[$id] : false;
102
+		$previous_value = monsterinsights_get_option($id, false);
103 103
 
104 104
 		// Sanitize/Validate
105
-		if ( empty( $setting['type'] ) ) {
105
+		if (empty($setting['type'])) {
106 106
 			continue;
107 107
 		}
108 108
 
@@ -110,11 +110,11 @@  discard block
 block discarded – undo
110 110
 		$non_setting_types = monsterinsights_get_non_setting_types();
111 111
 		$type              = $setting['type'];
112 112
 
113
-		if ( in_array( $type, $non_setting_types ) ) {
113
+		if (in_array($type, $non_setting_types)) {
114 114
 			continue;
115 115
 		}
116 116
 
117
-		$args = wp_parse_args( $setting, array(
117
+		$args = wp_parse_args($setting, array(
118 118
 			'id'            => null,
119 119
 			'desc'          => '',
120 120
 			'name'          => '',
@@ -135,31 +135,31 @@  discard block
 block discarded – undo
135 135
 			'multiple'      => false,
136 136
 			'allowclear'    => true,
137 137
 			'notice_type'   => 'info',
138
-		) );
138
+		));
139 139
 
140 140
 		// Sanitize settings
141
-		$value = apply_filters( 'monsterinsights_settings_sanitize_' . $id  , $value, $id, $args, $previous_value );
142
-		$value = apply_filters( 'monsterinsights_settings_sanitize_' . $type, $value, $id, $args, $previous_value );
143
-		$value = apply_filters( 'monsterinsights_settings_sanitize'         , $value, $id, $args, $previous_value );
141
+		$value = apply_filters('monsterinsights_settings_sanitize_' . $id, $value, $id, $args, $previous_value);
142
+		$value = apply_filters('monsterinsights_settings_sanitize_' . $type, $value, $id, $args, $previous_value);
143
+		$value = apply_filters('monsterinsights_settings_sanitize', $value, $id, $args, $previous_value);
144 144
 
145 145
 		// Save
146
-		if ( ! has_action( 'monsterinsights_settings_save_' . $args['type'] ) ) {
147
-			monsterinsights_update_option( $id, $value );
146
+		if ( ! has_action('monsterinsights_settings_save_' . $args['type'])) {
147
+			monsterinsights_update_option($id, $value);
148 148
 		} else {
149
-			do_action( 'monsterinsights_settings_save_' . $args['type'], $value, $id, $args, $previous_value );
149
+			do_action('monsterinsights_settings_save_' . $args['type'], $value, $id, $args, $previous_value);
150 150
 		}
151 151
 	}
152
-	add_action( 'monsterinsights_tracking_' . $tab . '_tab_notice', 'monsterinsights_updated_settings' );
152
+	add_action('monsterinsights_tracking_' . $tab . '_tab_notice', 'monsterinsights_updated_settings');
153 153
 }
154
-add_action( 'current_screen', 'monsterinsights_save_settings' );
154
+add_action('current_screen', 'monsterinsights_save_settings');
155 155
 
156
-function monsterinsights_is_settings_tab( $tab = '' ){
156
+function monsterinsights_is_settings_tab($tab = '') {
157 157
 	$tabs = monsterinsights_get_settings_tabs();
158
-	if ( empty( $tab ) || empty( $tabs ) || ! is_string( $tab ) || ! is_array( $tabs ) ) {
158
+	if (empty($tab) || empty($tabs) || ! is_string($tab) || ! is_array($tabs)) {
159 159
 		return false;
160 160
 	}
161 161
 
162
-	return !empty( $tabs[$tab]);
162
+	return ! empty($tabs[$tab]);
163 163
 }
164 164
 
165 165
 /**
@@ -169,22 +169,22 @@  discard block
 block discarded – undo
169 169
  * @since  6.0.0
170 170
  * @return array Key is the setting ID, value is the type of setting it is registered as
171 171
  */
172
-function monsterinsights_get_registered_settings_types( $section = '' ) {
172
+function monsterinsights_get_registered_settings_types($section = '') {
173 173
 	$settings      = monsterinsights_get_registered_settings();
174 174
 	$setting_types = array();
175
-	if ( ! empty( $section ) ) {
176
-		if ( ! empty( $settings[$section] ) ) {
177
-			foreach ( $settings[$section] as $setting ) {
178
-				if ( is_array( $setting ) && array_key_exists( 'type', $setting ) ) {
179
-					$setting_types[ $setting['id'] ] = $setting['type'];
175
+	if ( ! empty($section)) {
176
+		if ( ! empty($settings[$section])) {
177
+			foreach ($settings[$section] as $setting) {
178
+				if (is_array($setting) && array_key_exists('type', $setting)) {
179
+					$setting_types[$setting['id']] = $setting['type'];
180 180
 				}
181 181
 			}
182 182
 		}
183 183
 	} else {
184
-		foreach ( $settings as $tab ) {
185
-			foreach ( $tab as $setting ) {
186
-				if ( is_array( $setting ) && array_key_exists( 'type', $setting ) ) {
187
-					$setting_types[ $setting['id'] ] = $setting['type'];
184
+		foreach ($settings as $tab) {
185
+			foreach ($tab as $setting) {
186
+				if (is_array($setting) && array_key_exists('type', $setting)) {
187
+					$setting_types[$setting['id']] = $setting['type'];
188 188
 				}
189 189
 			}
190 190
 		}
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
  * @param array $input The field value
200 200
  * @return string $input Sanitizied value
201 201
  */
202
-function monsterinsights_sanitize_rich_editor_field( $input ) {
202
+function monsterinsights_sanitize_rich_editor_field($input) {
203 203
 	$tags = array(
204 204
 		'p' => array(
205 205
 			'class' => array(),
@@ -241,45 +241,45 @@  discard block
 block discarded – undo
241 241
 
242 242
 	//$allowed_tags = apply_filters( 'monsterinsights_allowed_html_tags', $tags );
243 243
 
244
-	return trim( wp_kses( $input, $allowed_tags ) );
244
+	return trim(wp_kses($input, $allowed_tags));
245 245
 }
246
-add_filter( 'monsterinsights_settings_sanitize_rich_editor', 'monsterinsights_sanitize_rich_editor_field' );
246
+add_filter('monsterinsights_settings_sanitize_rich_editor', 'monsterinsights_sanitize_rich_editor_field');
247 247
 
248
-if ( ! function_exists( 'sanitize_textarea_field' ) ) {
249
-	function sanitize_textarea_field( $str ) {
250
-		$filtered = _sanitize_text_fields( $str, true );
251
-		return apply_filters( 'sanitize_textarea_field', $filtered, $str );
248
+if ( ! function_exists('sanitize_textarea_field')) {
249
+	function sanitize_textarea_field($str) {
250
+		$filtered = _sanitize_text_fields($str, true);
251
+		return apply_filters('sanitize_textarea_field', $filtered, $str);
252 252
 	}
253 253
 }
254 254
 
255
-if ( ! function_exists( 'sanitize_textarea_field' ) ) {
256
-	function _sanitize_text_fields( $str, $keep_newlines = false ) {
257
-		$filtered = wp_check_invalid_utf8( $str );
255
+if ( ! function_exists('sanitize_textarea_field')) {
256
+	function _sanitize_text_fields($str, $keep_newlines = false) {
257
+		$filtered = wp_check_invalid_utf8($str);
258 258
 	 
259
-		if ( strpos($filtered, '<') !== false ) {
260
-			$filtered = wp_pre_kses_less_than( $filtered );
259
+		if (strpos($filtered, '<') !== false) {
260
+			$filtered = wp_pre_kses_less_than($filtered);
261 261
 			// This will strip extra whitespace for us.
262
-			$filtered = wp_strip_all_tags( $filtered, false );
262
+			$filtered = wp_strip_all_tags($filtered, false);
263 263
 	 
264 264
 			// Use html entities in a special case to make sure no later
265 265
 			// newline stripping stage could lead to a functional tag
266 266
 			$filtered = str_replace("<\n", "&lt;\n", $filtered);
267 267
 		}
268 268
 	 
269
-		if ( ! $keep_newlines ) {
270
-			$filtered = preg_replace( '/[\r\n\t ]+/', ' ', $filtered );
269
+		if ( ! $keep_newlines) {
270
+			$filtered = preg_replace('/[\r\n\t ]+/', ' ', $filtered);
271 271
 		}
272
-		$filtered = trim( $filtered );
272
+		$filtered = trim($filtered);
273 273
 	 
274 274
 		$found = false;
275
-		while ( preg_match('/%[a-f0-9]{2}/i', $filtered, $match) ) {
275
+		while (preg_match('/%[a-f0-9]{2}/i', $filtered, $match)) {
276 276
 			$filtered = str_replace($match[0], '', $filtered);
277 277
 			$found = true;
278 278
 		}
279 279
 	 
280
-		if ( $found ) {
280
+		if ($found) {
281 281
 			// Strip out the whitespace that may now exist after removing the octets.
282
-			$filtered = trim( preg_replace('/ +/', ' ', $filtered) );
282
+			$filtered = trim(preg_replace('/ +/', ' ', $filtered));
283 283
 		}
284 284
 	 
285 285
 		return $filtered;
@@ -292,10 +292,10 @@  discard block
 block discarded – undo
292 292
  * @since 6.0.0
293 293
  * @todo  docbloc
294 294
  */
295
-function monsterinsights_sanitize_textarea_field( $value, $id, $setting, $previous_value ) {
296
-	return sanitize_textarea_field( $value );
295
+function monsterinsights_sanitize_textarea_field($value, $id, $setting, $previous_value) {
296
+	return sanitize_textarea_field($value);
297 297
 }
298
-add_filter( 'monsterinsights_settings_sanitize_textarea', 'monsterinsights_sanitize_textarea_field', 10, 4 );
298
+add_filter('monsterinsights_settings_sanitize_textarea', 'monsterinsights_sanitize_textarea_field', 10, 4);
299 299
 
300 300
 /**
301 301
  * Sanitize checkbox fields
@@ -303,10 +303,10 @@  discard block
 block discarded – undo
303 303
  * @since 6.0.0
304 304
  * @todo  docbloc
305 305
  */
306
-function monsterinsights_sanitize_checkbox_field( $value, $id, $setting, $previous_value ) {
306
+function monsterinsights_sanitize_checkbox_field($value, $id, $setting, $previous_value) {
307 307
 	return (bool) $value;
308 308
 }
309
-add_filter( 'monsterinsights_settings_sanitize_checkbox', 'monsterinsights_sanitize_checkbox_field', 10, 4 );
309
+add_filter('monsterinsights_settings_sanitize_checkbox', 'monsterinsights_sanitize_checkbox_field', 10, 4);
310 310
 
311 311
 /**
312 312
  * Sanitize multicheck fields
@@ -314,18 +314,18 @@  discard block
 block discarded – undo
314 314
  * @since 6.0.0
315 315
  * @todo  docbloc
316 316
  */
317
-function monsterinsights_sanitize_multicheck_field( $value, $id, $setting, $previous_value ) {
317
+function monsterinsights_sanitize_multicheck_field($value, $id, $setting, $previous_value) {
318 318
 	$save_value = array();
319
-	if ( ! empty( $value ) && is_array( $value ) ) {
320
-		foreach( $setting['options'] as $key => $option ){
321
-			if ( in_array( $key, $value ) ) {
319
+	if ( ! empty($value) && is_array($value)) {
320
+		foreach ($setting['options'] as $key => $option) {
321
+			if (in_array($key, $value)) {
322 322
 				$save_value[] = $key;
323 323
 			}
324 324
 		}
325 325
 	}
326 326
 	return $save_value;
327 327
 }
328
-add_filter( 'monsterinsights_settings_sanitize_multicheck', 'monsterinsights_sanitize_multicheck_field', 10, 4 );
328
+add_filter('monsterinsights_settings_sanitize_multicheck', 'monsterinsights_sanitize_multicheck_field', 10, 4);
329 329
 
330 330
 /**
331 331
  * Sanitize select fields
@@ -333,28 +333,28 @@  discard block
 block discarded – undo
333 333
  * @since 6.0.0
334 334
  * @todo  docbloc
335 335
  */
336
-function monsterinsights_sanitize_select_field( $value, $id, $setting, $previous_value ) {
337
-	if ( ! empty( $setting['multiple'] ) && $setting['multiple'] ) {
336
+function monsterinsights_sanitize_select_field($value, $id, $setting, $previous_value) {
337
+	if ( ! empty($setting['multiple']) && $setting['multiple']) {
338 338
 		$save_value = array();
339 339
 	} else {
340 340
 		$save_value = '';
341 341
 	}
342
-	if ( ! empty( $value ) && is_array( $value ) ) {
343
-		if ( $setting['multiple'] ) {
344
-			foreach ( $value as $vid => $vname ) {
345
-				foreach( $setting['options'] as $key => $option ){
346
-					if ( $key === $vname ) {
342
+	if ( ! empty($value) && is_array($value)) {
343
+		if ($setting['multiple']) {
344
+			foreach ($value as $vid => $vname) {
345
+				foreach ($setting['options'] as $key => $option) {
346
+					if ($key === $vname) {
347 347
 						$save_value[] = $key;
348 348
 						break;
349 349
 					}
350 350
 				}
351 351
 			}
352 352
 		} else {
353
-			foreach( $setting['options'] as $key => $option ){
354
-				if ( is_array( $value ) && in_array( $key, $value ) ) {
353
+			foreach ($setting['options'] as $key => $option) {
354
+				if (is_array($value) && in_array($key, $value)) {
355 355
 					$save_value = $key;
356 356
 					break;
357
-				} else if ( is_string( $value ) && $key === $value ){
357
+				} else if (is_string($value) && $key === $value) {
358 358
 					$save_value = $key;
359 359
 					break;
360 360
 				}
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 	}
364 364
 	return $save_value;
365 365
 }
366
-add_filter( 'monsterinsights_settings_sanitize_select', 'monsterinsights_sanitize_select_field', 10, 4 );
366
+add_filter('monsterinsights_settings_sanitize_select', 'monsterinsights_sanitize_select_field', 10, 4);
367 367
 
368 368
 
369 369
 /**
@@ -372,18 +372,18 @@  discard block
 block discarded – undo
372 372
  * @since 6.0.0
373 373
  * @todo  docbloc
374 374
  */
375
-function monsterinsights_sanitize_radio_field( $value, $id, $setting, $previous_value ) {
375
+function monsterinsights_sanitize_radio_field($value, $id, $setting, $previous_value) {
376 376
 	$save_value = '';
377
-	if ( ! empty( $value ) ) {
378
-		foreach( $setting['options'] as $key => $option ){
379
-			if ( $key === $value ) {
377
+	if ( ! empty($value)) {
378
+		foreach ($setting['options'] as $key => $option) {
379
+			if ($key === $value) {
380 380
 				$save_value = $key;
381 381
 			}
382 382
 		}
383 383
 	}
384 384
 	return $save_value;
385 385
 }
386
-add_filter( 'monsterinsights_settings_sanitize_radio', 'monsterinsights_sanitize_radio_field', 10, 4 );
386
+add_filter('monsterinsights_settings_sanitize_radio', 'monsterinsights_sanitize_radio_field', 10, 4);
387 387
 
388 388
 /**
389 389
  * Sanitize text fields
@@ -391,10 +391,10 @@  discard block
 block discarded – undo
391 391
  * @since 6.0.0
392 392
  * @todo  docbloc
393 393
  */
394
-function monsterinsights_sanitize_text_field( $value, $id, $setting, $previous_value ) {
395
-	return sanitize_text_field( $value );
394
+function monsterinsights_sanitize_text_field($value, $id, $setting, $previous_value) {
395
+	return sanitize_text_field($value);
396 396
 }
397
-add_filter( 'monsterinsights_settings_sanitize_text', 'monsterinsights_sanitize_text_field', 10, 4 );
397
+add_filter('monsterinsights_settings_sanitize_text', 'monsterinsights_sanitize_text_field', 10, 4);
398 398
 
399 399
 /**
400 400
  * Sanitize password fields
@@ -402,10 +402,10 @@  discard block
 block discarded – undo
402 402
  * @since 6.0.0
403 403
  * @todo  docbloc
404 404
  */
405
-function monsterinsights_sanitize_password_field( $value, $id, $setting, $previous_value ) {
406
-	return sanitize_text_field( $value );
405
+function monsterinsights_sanitize_password_field($value, $id, $setting, $previous_value) {
406
+	return sanitize_text_field($value);
407 407
 }
408
-add_filter( 'monsterinsights_settings_sanitize_password', 'monsterinsights_sanitize_password_field', 10, 4 );
408
+add_filter('monsterinsights_settings_sanitize_password', 'monsterinsights_sanitize_password_field', 10, 4);
409 409
 
410 410
 /**
411 411
  * Sanitize number fields
@@ -413,16 +413,16 @@  discard block
 block discarded – undo
413 413
  * @since 6.0.0
414 414
  * @todo  docbloc
415 415
  */
416
-function monsterinsights_sanitize_number_field( $value, $id, $setting, $previous_value ) {
417
-	if ( is_int( (int) $value ) ) {
416
+function monsterinsights_sanitize_number_field($value, $id, $setting, $previous_value) {
417
+	if (is_int((int) $value)) {
418 418
 		return $value;
419
-	} else if ( is_int( $previous_value ) ) {
419
+	} else if (is_int($previous_value)) {
420 420
 		return $previous_value;
421 421
 	} else {
422 422
 		return 0;
423 423
 	}
424 424
 }
425
-add_filter( 'monsterinsights_settings_sanitize_number', 'monsterinsights_sanitize_number_field', 10, 4 );
425
+add_filter('monsterinsights_settings_sanitize_number', 'monsterinsights_sanitize_number_field', 10, 4);
426 426
 
427 427
 /**
428 428
  * Sanitize unfiltered textarea fields
@@ -430,14 +430,14 @@  discard block
 block discarded – undo
430 430
  * @since 6.0.0
431 431
  * @todo  docbloc
432 432
  */
433
-function monsterinsights_sanitize_unfiltered_textarea_field( $value, $id, $setting, $previous_value ) {
434
-	if ( current_user_can( 'unfiltered_html' ) || current_user_can( 'monsterinsights_unfiltered_html' ) ) {
433
+function monsterinsights_sanitize_unfiltered_textarea_field($value, $id, $setting, $previous_value) {
434
+	if (current_user_can('unfiltered_html') || current_user_can('monsterinsights_unfiltered_html')) {
435 435
 		return $value;
436 436
 	} else {
437 437
 		return $previous_value;
438 438
 	}
439 439
 }
440
-add_filter( 'monsterinsights_settings_unfiltered_textarea_number', 'monsterinsights_sanitize_unfiltered_textarea_field', 10, 4 );
440
+add_filter('monsterinsights_settings_unfiltered_textarea_number', 'monsterinsights_sanitize_unfiltered_textarea_field', 10, 4);
441 441
 
442 442
 /**
443 443
  * Sanitizes a string key for MonsterInsights Settings
@@ -448,9 +448,9 @@  discard block
 block discarded – undo
448 448
  * @param  string $key String key
449 449
  * @return string Sanitized key
450 450
  */
451
-function monsterinsights_sanitize_key( $key ) {
451
+function monsterinsights_sanitize_key($key) {
452 452
 	$raw_key = $key;
453
-	$key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key );
453
+	$key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key);
454 454
 	/**
455 455
 	 * Filter a sanitized key string.
456 456
 	 *
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
 	 * @param string $key     Sanitized key.
459 459
 	 * @param string $raw_key The key prior to sanitization.
460 460
 	 */
461
-	return apply_filters( 'monsterinsights_sanitize_key', $key, $raw_key );
461
+	return apply_filters('monsterinsights_sanitize_key', $key, $raw_key);
462 462
 }
463 463
 
464 464
 /**
@@ -468,13 +468,13 @@  discard block
 block discarded – undo
468 468
  * @param  string|array $class HTML Class Name(s)
469 469
  * @return string $class
470 470
  */
471
-function monsterinsights_sanitize_html_class( $class = '' ) {
471
+function monsterinsights_sanitize_html_class($class = '') {
472 472
 
473
-	if ( is_string( $class ) ) {
474
-		$class = sanitize_html_class( $class );
475
-	} else if ( is_array( $class ) ) {
476
-		$class = array_values( array_map( 'sanitize_html_class', $class ) );
477
-		$class = implode( ' ', array_unique( $class ) );
473
+	if (is_string($class)) {
474
+		$class = sanitize_html_class($class);
475
+	} else if (is_array($class)) {
476
+		$class = array_values(array_map('sanitize_html_class', $class));
477
+		$class = implode(' ', array_unique($class));
478 478
 	}
479 479
 
480 480
 	return $class;
@@ -490,16 +490,16 @@  discard block
 block discarded – undo
490 490
  * @param bool $force Force the pages to be loaded even if not on settings
491 491
  * @return array $pages_options An array of the pages
492 492
  */
493
-function monsterinsights_get_pages( $force = false ) {
494
-	$pages_options = array( '' => '' ); // Blank option
495
-	if( ( ! isset( $_GET['page'] ) || 'monsterinsights_settings' != $_GET['page'] ) && ! $force ) {
493
+function monsterinsights_get_pages($force = false) {
494
+	$pages_options = array('' => ''); // Blank option
495
+	if (( ! isset($_GET['page']) || 'monsterinsights_settings' != $_GET['page']) && ! $force) {
496 496
 		return $pages_options;
497 497
 	}
498 498
 
499 499
 	$pages = get_pages();
500
-	if ( $pages ) {
501
-		foreach ( $pages as $page ) {
502
-			$pages_options[ $page->ID ] = $page->post_title;
500
+	if ($pages) {
501
+		foreach ($pages as $page) {
502
+			$pages_options[$page->ID] = $page->post_title;
503 503
 		}
504 504
 	}
505 505
 
@@ -516,33 +516,33 @@  discard block
 block discarded – undo
516 516
  *
517 517
  * @return void
518 518
  */
519
-function monsterinsights_checkbox_callback( $args ) {
520
-	$monsterinsights_option = monsterinsights_get_option( $args['id'] );
519
+function monsterinsights_checkbox_callback($args) {
520
+	$monsterinsights_option = monsterinsights_get_option($args['id']);
521 521
 
522
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
522
+	if (isset($args['faux']) && true === $args['faux']) {
523 523
 		$name = '';
524 524
 	} else {
525
-		$name = 'name="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . ']"';
525
+		$name = 'name="monsterinsights_settings[' . monsterinsights_sanitize_key($args['id']) . ']"';
526 526
 	}
527 527
 
528
-	$class = monsterinsights_sanitize_html_class( $args['field_class'] );
528
+	$class = monsterinsights_sanitize_html_class($args['field_class']);
529 529
 
530
-	$checked  = ! empty( $monsterinsights_option ) ? checked( 1, $monsterinsights_option, false ) : '';
530
+	$checked  = ! empty($monsterinsights_option) ? checked(1, $monsterinsights_option, false) : '';
531 531
 
532 532
 	$disabled = '';
533 533
 
534
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
534
+	if (isset($args['faux']) && true === $args['faux']) {
535 535
 		// Disable class
536 536
 		$disabled = 'disabled="disabled"';
537 537
 		
538 538
 		// Checked
539
-		$checked  = isset( $args['std'] ) && true === $args['std'] ? checked( 1, 1, false ) : '';
539
+		$checked  = isset($args['std']) && true === $args['std'] ? checked(1, 1, false) : '';
540 540
 	}
541 541
 
542
-	$html     = '<input type="checkbox" id="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . ']"' . $name . ' value="1" ' . $checked . ' class="' . $class . '" ' . $disabled . ' />';
543
-	$html    .= '<p class="description">'  . wp_kses_post( $args['desc'] ) . '</p>';
542
+	$html     = '<input type="checkbox" id="monsterinsights_settings[' . monsterinsights_sanitize_key($args['id']) . ']"' . $name . ' value="1" ' . $checked . ' class="' . $class . '" ' . $disabled . ' />';
543
+	$html    .= '<p class="description">' . wp_kses_post($args['desc']) . '</p>';
544 544
 
545
-	return apply_filters( 'monsterinsights_after_setting_output', $html, $args );
545
+	return apply_filters('monsterinsights_after_setting_output', $html, $args);
546 546
 }
547 547
 
548 548
 /**
@@ -555,22 +555,22 @@  discard block
 block discarded – undo
555 555
  *
556 556
  * @return void
557 557
  */
558
-function monsterinsights_multicheck_callback( $args ) {
559
-	$monsterinsights_option = monsterinsights_get_option( $args['id'] );
558
+function monsterinsights_multicheck_callback($args) {
559
+	$monsterinsights_option = monsterinsights_get_option($args['id']);
560 560
 
561
-	$class = monsterinsights_sanitize_html_class( $args['field_class'] );
561
+	$class = monsterinsights_sanitize_html_class($args['field_class']);
562 562
 
563 563
 	$html = '';
564
-	if ( ! empty( $args['options'] ) ) {
565
-		foreach( $args['options'] as $key => $option ):
566
-			if( isset( $monsterinsights_option[ $key ] ) ) { $enabled = $option; } else { $enabled = NULL; }
567
-			$html .= '<input name="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . '][' . monsterinsights_sanitize_key( $key ) . ']" id="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . '][' . monsterinsights_sanitize_key( $key ) . ']" class="' . $class . '" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked($option, $enabled, false) . '/>&nbsp;';
568
-			$html .= '<label for="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . '][' . monsterinsights_sanitize_key( $key ) . ']">' . wp_kses_post( $option ) . '</label><br/>';
564
+	if ( ! empty($args['options'])) {
565
+		foreach ($args['options'] as $key => $option):
566
+			if (isset($monsterinsights_option[$key])) { $enabled = $option; } else { $enabled = NULL; }
567
+			$html .= '<input name="monsterinsights_settings[' . monsterinsights_sanitize_key($args['id']) . '][' . monsterinsights_sanitize_key($key) . ']" id="monsterinsights_settings[' . monsterinsights_sanitize_key($args['id']) . '][' . monsterinsights_sanitize_key($key) . ']" class="' . $class . '" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/>&nbsp;';
568
+			$html .= '<label for="monsterinsights_settings[' . monsterinsights_sanitize_key($args['id']) . '][' . monsterinsights_sanitize_key($key) . ']">' . wp_kses_post($option) . '</label><br/>';
569 569
 		endforeach;
570 570
 		$html .= '<p class="description">' . $args['desc'] . '</p>';
571 571
 	}
572 572
 
573
-	return apply_filters( 'monsterinsights_after_setting_output', $html, $args );
573
+	return apply_filters('monsterinsights_after_setting_output', $html, $args);
574 574
 }
575 575
 
576 576
 
@@ -584,28 +584,28 @@  discard block
 block discarded – undo
584 584
  *
585 585
  * @return void
586 586
  */
587
-function monsterinsights_radio_callback( $args ) {
588
-	$monsterinsights_options = monsterinsights_get_option( $args['id'] );
587
+function monsterinsights_radio_callback($args) {
588
+	$monsterinsights_options = monsterinsights_get_option($args['id']);
589 589
 
590 590
 	$html = '';
591 591
 
592
-	$class = monsterinsights_sanitize_html_class( $args['field_class'] );
592
+	$class = monsterinsights_sanitize_html_class($args['field_class']);
593 593
 
594
-	foreach ( $args['options'] as $key => $option ) :
594
+	foreach ($args['options'] as $key => $option) :
595 595
 		$checked = false;
596 596
 
597
-		if ( $monsterinsights_options && $monsterinsights_options == $key ) {
597
+		if ($monsterinsights_options && $monsterinsights_options == $key) {
598 598
 			$checked = true;
599
-		} else if( isset( $args['std'] ) && $args['std'] == $key && ! $monsterinsights_options ) {
599
+		} else if (isset($args['std']) && $args['std'] == $key && ! $monsterinsights_options) {
600 600
 			$checked = true;
601 601
 		}
602 602
 
603
-		$html .= '<label for="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . '][' . monsterinsights_sanitize_key( $key ) . ']">';
604
-		$html .= '<input name="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . ']" id="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . '][' . monsterinsights_sanitize_key( $key ) . ']" class="' . $class . '" type="radio" value="' . monsterinsights_sanitize_key( $key ) . '" ' . checked(true, $checked, false) . '/>&nbsp;';
605
-		$html .= esc_html( $option ) . '</label>';
603
+		$html .= '<label for="monsterinsights_settings[' . monsterinsights_sanitize_key($args['id']) . '][' . monsterinsights_sanitize_key($key) . ']">';
604
+		$html .= '<input name="monsterinsights_settings[' . monsterinsights_sanitize_key($args['id']) . ']" id="monsterinsights_settings[' . monsterinsights_sanitize_key($args['id']) . '][' . monsterinsights_sanitize_key($key) . ']" class="' . $class . '" type="radio" value="' . monsterinsights_sanitize_key($key) . '" ' . checked(true, $checked, false) . '/>&nbsp;';
605
+		$html .= esc_html($option) . '</label>';
606 606
 	endforeach;
607 607
 
608
-	$html .= '<p class="description">' . apply_filters( 'monsterinsights_after_setting_output', wp_kses_post( $args['desc'] ), $args ) . '</p>';
608
+	$html .= '<p class="description">' . apply_filters('monsterinsights_after_setting_output', wp_kses_post($args['desc']), $args) . '</p>';
609 609
 
610 610
 	return $html;
611 611
 }
@@ -620,34 +620,34 @@  discard block
 block discarded – undo
620 620
  *
621 621
  * @return void
622 622
  */
623
-function monsterinsights_text_callback( $args ) {
624
-	$monsterinsights_option = monsterinsights_get_option( $args['id'] );
623
+function monsterinsights_text_callback($args) {
624
+	$monsterinsights_option = monsterinsights_get_option($args['id']);
625 625
 
626
-	if ( $monsterinsights_option ) {
626
+	if ($monsterinsights_option) {
627 627
 		$value = $monsterinsights_option;
628
-	} elseif( ! empty( $args['allow_blank'] ) && empty( $monsterinsights_option ) ) {
628
+	} elseif ( ! empty($args['allow_blank']) && empty($monsterinsights_option)) {
629 629
 		$value = '';
630 630
 	} else {
631
-		$value = isset( $args['std'] ) ? $args['std'] : '';
631
+		$value = isset($args['std']) ? $args['std'] : '';
632 632
 	}
633 633
 
634
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
634
+	if (isset($args['faux']) && true === $args['faux']) {
635 635
 		$args['readonly'] = true;
636
-		$value = isset( $args['std'] ) ? $args['std'] : '';
636
+		$value = isset($args['std']) ? $args['std'] : '';
637 637
 		$name  = '';
638 638
 	} else {
639
-		$name = 'name="monsterinsights_settings[' . esc_attr( $args['id'] ) . ']"';
639
+		$name = 'name="monsterinsights_settings[' . esc_attr($args['id']) . ']"';
640 640
 	}
641 641
 
642
-	$class = monsterinsights_sanitize_html_class( $args['field_class'] );
642
+	$class = monsterinsights_sanitize_html_class($args['field_class']);
643 643
 
644
-	$disabled = ! empty( $args['disabled'] ) ? ' disabled="disabled"' : '';
644
+	$disabled = ! empty($args['disabled']) ? ' disabled="disabled"' : '';
645 645
 	$readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
646
-	$size     = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
647
-	$html     = '<input type="text" class="' . $class . ' ' . sanitize_html_class( $size ) . '-text" id="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . $disabled . ' placeholder="' . esc_attr( $args['placeholder'] ) . '"/>';
648
-	$html    .= '<p class="description"> '  . wp_kses_post( $args['desc'] ) . '</p>';
646
+	$size     = (isset($args['size']) && ! is_null($args['size'])) ? $args['size'] : 'regular';
647
+	$html     = '<input type="text" class="' . $class . ' ' . sanitize_html_class($size) . '-text" id="monsterinsights_settings[' . monsterinsights_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"' . $readonly . $disabled . ' placeholder="' . esc_attr($args['placeholder']) . '"/>';
648
+	$html    .= '<p class="description"> ' . wp_kses_post($args['desc']) . '</p>';
649 649
 
650
-	return apply_filters( 'monsterinsights_after_setting_output', $html, $args );
650
+	return apply_filters('monsterinsights_after_setting_output', $html, $args);
651 651
 }
652 652
 
653 653
 /**
@@ -660,34 +660,34 @@  discard block
 block discarded – undo
660 660
  *
661 661
  * @return void
662 662
  */
663
-function monsterinsights_number_callback( $args ) {
664
-	$monsterinsights_option = monsterinsights_get_option( $args['id'] );
663
+function monsterinsights_number_callback($args) {
664
+	$monsterinsights_option = monsterinsights_get_option($args['id']);
665 665
 
666
-	if ( $monsterinsights_option ) {
666
+	if ($monsterinsights_option) {
667 667
 		$value = $monsterinsights_option;
668 668
 	} else {
669
-		$value = isset( $args['std'] ) ? $args['std'] : '';
669
+		$value = isset($args['std']) ? $args['std'] : '';
670 670
 	}
671 671
 
672
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
672
+	if (isset($args['faux']) && true === $args['faux']) {
673 673
 		$args['readonly'] = true;
674
-		$value = isset( $args['std'] ) ? $args['std'] : '';
674
+		$value = isset($args['std']) ? $args['std'] : '';
675 675
 		$name  = '';
676 676
 	} else {
677
-		$name = 'name="monsterinsights_settings[' . esc_attr( $args['id'] ) . ']"';
677
+		$name = 'name="monsterinsights_settings[' . esc_attr($args['id']) . ']"';
678 678
 	}
679 679
 
680
-	$class = monsterinsights_sanitize_html_class( $args['field_class'] );
680
+	$class = monsterinsights_sanitize_html_class($args['field_class']);
681 681
 
682
-	$max  = isset( $args['max'] )  ? $args['max']   : 999999;
683
-	$min  = isset( $args['min'] )  ? $args['min']   : 0;
684
-	$step = isset( $args['step'] ) ? $args['step'] : 1;
682
+	$max  = isset($args['max']) ? $args['max'] : 999999;
683
+	$min  = isset($args['min']) ? $args['min'] : 0;
684
+	$step = isset($args['step']) ? $args['step'] : 1;
685 685
 
686
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
687
-	$html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . $class . ' ' . sanitize_html_class( $size ) . '-text" id="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>';
688
-	$html .= '<p class="description"> '  . wp_kses_post( $args['desc'] ) . '</p>';
686
+	$size = (isset($args['size']) && ! is_null($args['size'])) ? $args['size'] : 'regular';
687
+	$html = '<input type="number" step="' . esc_attr($step) . '" max="' . esc_attr($max) . '" min="' . esc_attr($min) . '" class="' . $class . ' ' . sanitize_html_class($size) . '-text" id="monsterinsights_settings[' . monsterinsights_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"/>';
688
+	$html .= '<p class="description"> ' . wp_kses_post($args['desc']) . '</p>';
689 689
 
690
-	return apply_filters( 'monsterinsights_after_setting_output', $html, $args );
690
+	return apply_filters('monsterinsights_after_setting_output', $html, $args);
691 691
 }
692 692
 
693 693
 /**
@@ -700,21 +700,21 @@  discard block
 block discarded – undo
700 700
  *
701 701
  * @return void
702 702
  */
703
-function monsterinsights_textarea_callback( $args ) {
704
-	$monsterinsights_option = monsterinsights_get_option( $args['id'] );
703
+function monsterinsights_textarea_callback($args) {
704
+	$monsterinsights_option = monsterinsights_get_option($args['id']);
705 705
 
706
-	if ( $monsterinsights_option ) {
706
+	if ($monsterinsights_option) {
707 707
 		$value = $monsterinsights_option;
708 708
 	} else {
709
-		$value = isset( $args['std'] ) ? $args['std'] : '';
709
+		$value = isset($args['std']) ? $args['std'] : '';
710 710
 	}
711 711
 
712
-	$class = monsterinsights_sanitize_html_class( $args['field_class'] );
712
+	$class = monsterinsights_sanitize_html_class($args['field_class']);
713 713
 
714
-	$html = '<textarea class="' . $class . ' large-text" cols="50" rows="5" id="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . ']" name="monsterinsights_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
715
-	$html .= '<p class="description"> '  . wp_kses_post( $args['desc'] ) . '</p>';
714
+	$html = '<textarea class="' . $class . ' large-text" cols="50" rows="5" id="monsterinsights_settings[' . monsterinsights_sanitize_key($args['id']) . ']" name="monsterinsights_settings[' . esc_attr($args['id']) . ']">' . esc_textarea(stripslashes($value)) . '</textarea>';
715
+	$html .= '<p class="description"> ' . wp_kses_post($args['desc']) . '</p>';
716 716
 
717
-	return apply_filters( 'monsterinsights_after_setting_output', $html, $args );
717
+	return apply_filters('monsterinsights_after_setting_output', $html, $args);
718 718
 }
719 719
 
720 720
 
@@ -728,26 +728,26 @@  discard block
 block discarded – undo
728 728
  *
729 729
  * @return void
730 730
  */
731
-function monsterinsights_unfiltered_textarea_callback( $args ) {
731
+function monsterinsights_unfiltered_textarea_callback($args) {
732 732
 	
733
-	if ( current_user_can( 'unfiltered_html' ) || current_user_can( 'monsterinsights_unfiltered_html' ) ) {
734
-		$monsterinsights_option = monsterinsights_get_option( $args['id'] );
733
+	if (current_user_can('unfiltered_html') || current_user_can('monsterinsights_unfiltered_html')) {
734
+		$monsterinsights_option = monsterinsights_get_option($args['id']);
735 735
 
736
-		if ( $monsterinsights_option ) {
736
+		if ($monsterinsights_option) {
737 737
 			$value = $monsterinsights_option;
738 738
 		} else {
739
-			$value = isset( $args['std'] ) ? $args['std'] : '';
739
+			$value = isset($args['std']) ? $args['std'] : '';
740 740
 		}
741 741
 
742
-		$class = monsterinsights_sanitize_html_class( $args['field_class'] );
742
+		$class = monsterinsights_sanitize_html_class($args['field_class']);
743 743
 
744
-		$html = '<textarea class="' . $class . ' large-text" cols="50" rows="5" id="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . ']" name="monsterinsights_settings[' . esc_attr( $args['id'] ) . ']">' . stripslashes( $value ) . '</textarea>';
745
-		$html .= '<p class="description"> '  . wp_kses_post( $args['desc'] ) . '</p>';
744
+		$html = '<textarea class="' . $class . ' large-text" cols="50" rows="5" id="monsterinsights_settings[' . monsterinsights_sanitize_key($args['id']) . ']" name="monsterinsights_settings[' . esc_attr($args['id']) . ']">' . stripslashes($value) . '</textarea>';
745
+		$html .= '<p class="description"> ' . wp_kses_post($args['desc']) . '</p>';
746 746
 	} else {
747
-		$html .= sprintf( esc_html__( 'You must have the %s capability to view/edit this setting', 'google-analytics-for-wordpress' ), '"unfiltered_html"' );
747
+		$html .= sprintf(esc_html__('You must have the %s capability to view/edit this setting', 'google-analytics-for-wordpress'), '"unfiltered_html"');
748 748
 	}
749 749
 
750
-	return apply_filters( 'monsterinsights_after_setting_output', $html, $args );
750
+	return apply_filters('monsterinsights_after_setting_output', $html, $args);
751 751
 }
752 752
 
753 753
 /**
@@ -760,22 +760,22 @@  discard block
 block discarded – undo
760 760
  *
761 761
  * @return void
762 762
  */
763
-function monsterinsights_password_callback( $args ) {
764
-	$monsterinsights_options = monsterinsights_get_option( $args['id'] );
763
+function monsterinsights_password_callback($args) {
764
+	$monsterinsights_options = monsterinsights_get_option($args['id']);
765 765
 
766
-	if ( $monsterinsights_options ) {
766
+	if ($monsterinsights_options) {
767 767
 		$value = $monsterinsights_options;
768 768
 	} else {
769
-		$value = isset( $args['std'] ) ? $args['std'] : '';
769
+		$value = isset($args['std']) ? $args['std'] : '';
770 770
 	}
771 771
 
772
-	$class = monsterinsights_sanitize_html_class( $args['field_class'] );
772
+	$class = monsterinsights_sanitize_html_class($args['field_class']);
773 773
 
774
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
775
-	$html = '<input type="password" class="' . $class . ' ' . sanitize_html_class( $size ) . '-text" id="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . ']" name="monsterinsights_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
776
-	$html .= '<p class="description"> ' . wp_kses_post( $args['desc'] ) . '</p>';
774
+	$size = (isset($args['size']) && ! is_null($args['size'])) ? $args['size'] : 'regular';
775
+	$html = '<input type="password" class="' . $class . ' ' . sanitize_html_class($size) . '-text" id="monsterinsights_settings[' . monsterinsights_sanitize_key($args['id']) . ']" name="monsterinsights_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '"/>';
776
+	$html .= '<p class="description"> ' . wp_kses_post($args['desc']) . '</p>';
777 777
 
778
-	return apply_filters( 'monsterinsights_after_setting_output', $html, $args );
778
+	return apply_filters('monsterinsights_after_setting_output', $html, $args);
779 779
 }
780 780
 
781 781
 /**
@@ -789,43 +789,43 @@  discard block
 block discarded – undo
789 789
  * @return void
790 790
  */
791 791
 function monsterinsights_select_callback($args) {
792
-	$monsterinsights_option = monsterinsights_get_option( $args['id'] );
792
+	$monsterinsights_option = monsterinsights_get_option($args['id']);
793 793
 
794
-	if ( $monsterinsights_option ) {
794
+	if ($monsterinsights_option) {
795 795
 		$value = $monsterinsights_option;
796 796
 	} else {
797
-		$value = isset( $args['std'] ) ? $args['std'] : '';
797
+		$value = isset($args['std']) ? $args['std'] : '';
798 798
 	}
799 799
 
800
-	if ( isset( $args['placeholder'] ) ) {
800
+	if (isset($args['placeholder'])) {
801 801
 		$placeholder = $args['placeholder'];
802 802
 	} else {
803 803
 		$placeholder = '';
804 804
 	}
805 805
 
806
-	$class = monsterinsights_sanitize_html_class( $args['field_class'] );
806
+	$class = monsterinsights_sanitize_html_class($args['field_class']);
807 807
 
808
-	if ( isset( $args['select2'] ) ) {
808
+	if (isset($args['select2'])) {
809 809
 		$class .= ' monsterinsights-select300';
810 810
 	}
811 811
 
812
-	$allowclear   = isset( $args['allowclear'] ) ? (bool) $args['allowclear'] : false;
813
-	$multiple     = isset( $args['multiple'] )   ? (bool) $args['multiple'] : false;
812
+	$allowclear   = isset($args['allowclear']) ? (bool) $args['allowclear'] : false;
813
+	$multiple     = isset($args['multiple']) ? (bool) $args['multiple'] : false;
814 814
 	$multiple     = $multiple ? 'multiple="multiple"' : '';
815 815
 	$multiple_arg = $multiple ? '[]' : '';
816 816
 
817
-	$html = '<select id="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . ']" name="monsterinsights_settings[' . esc_attr( $args['id'] ) . ']' . $multiple_arg .'" class="' . $class . '" data-placeholder="' . esc_html( $placeholder ) . '" data-allow-clear="' . $allowclear . '" ' . $multiple . ' />';
817
+	$html = '<select id="monsterinsights_settings[' . monsterinsights_sanitize_key($args['id']) . ']" name="monsterinsights_settings[' . esc_attr($args['id']) . ']' . $multiple_arg . '" class="' . $class . '" data-placeholder="' . esc_html($placeholder) . '" data-allow-clear="' . $allowclear . '" ' . $multiple . ' />';
818 818
 
819
-	foreach ( $args['options'] as $option => $name ) {
820
-		$selected = ! empty( $value ) && is_array( $value ) ? in_array( $option, $value ) :  $value === $option;
821
-		$selected = selected( true, $selected, false );
822
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
819
+	foreach ($args['options'] as $option => $name) {
820
+		$selected = ! empty($value) && is_array($value) ? in_array($option, $value) : $value === $option;
821
+		$selected = selected(true, $selected, false);
822
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>';
823 823
 	}
824 824
 
825 825
 	$html .= '</select>';
826
-	$html .= '<p class="description"> ' . wp_kses_post( $args['desc'] ) . '</p>';
826
+	$html .= '<p class="description"> ' . wp_kses_post($args['desc']) . '</p>';
827 827
 
828
-	return apply_filters( 'monsterinsights_after_setting_output', $html, $args );
828
+	return apply_filters('monsterinsights_after_setting_output', $html, $args);
829 829
 }
830 830
 
831 831
 /**
@@ -836,30 +836,30 @@  discard block
 block discarded – undo
836 836
  * @since 6.0.0
837 837
  * @param array $args Arguments passed by the setting
838 838
  */
839
-function monsterinsights_rich_editor_callback( $args ) {
840
-	$monsterinsights_option = monsterinsights_get_option( $args['id'] );
839
+function monsterinsights_rich_editor_callback($args) {
840
+	$monsterinsights_option = monsterinsights_get_option($args['id']);
841 841
 
842
-	if ( $monsterinsights_option ) {
842
+	if ($monsterinsights_option) {
843 843
 		$value = $monsterinsights_option;
844 844
 	} else {
845
-		if( ! empty( $args['allow_blank'] ) && empty( $monsterinsights_option ) ) {
845
+		if ( ! empty($args['allow_blank']) && empty($monsterinsights_option)) {
846 846
 			$value = '';
847 847
 		} else {
848
-			$value = isset( $args['std'] ) ? $args['std'] : '';
848
+			$value = isset($args['std']) ? $args['std'] : '';
849 849
 		}
850 850
 	}
851 851
 
852
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
852
+	$rows = isset($args['size']) ? $args['size'] : 20;
853 853
 
854
-	$class = monsterinsights_sanitize_html_class( $args['field_class'] );
854
+	$class = monsterinsights_sanitize_html_class($args['field_class']);
855 855
 
856 856
 	ob_start();
857
-	wp_editor( stripslashes( $value ), 'monsterinsights_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'monsterinsights_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'editor_class' => $class ) );
857
+	wp_editor(stripslashes($value), 'monsterinsights_settings_' . esc_attr($args['id']), array('textarea_name' => 'monsterinsights_settings[' . esc_attr($args['id']) . ']', 'textarea_rows' => absint($rows), 'editor_class' => $class));
858 858
 	$html = ob_get_clean();
859 859
 
860
-	$html .= '<br/><p class="description"> ' . wp_kses_post( $args['desc'] ) . '</p>';
860
+	$html .= '<br/><p class="description"> ' . wp_kses_post($args['desc']) . '</p>';
861 861
 
862
-	return apply_filters( 'monsterinsights_after_setting_output', $html, $args );
862
+	return apply_filters('monsterinsights_after_setting_output', $html, $args);
863 863
 }
864 864
 
865 865
 /**
@@ -871,9 +871,9 @@  discard block
 block discarded – undo
871 871
  * @param array $args Arguments passed by the setting
872 872
  * @return void
873 873
  */
874
-function monsterinsights_descriptive_text_callback( $args ) {
875
-	$html = wp_kses_post( $args['desc'] );
876
-	return apply_filters( 'monsterinsights_after_setting_output', $html, $args );
874
+function monsterinsights_descriptive_text_callback($args) {
875
+	$html = wp_kses_post($args['desc']);
876
+	return apply_filters('monsterinsights_after_setting_output', $html, $args);
877 877
 }
878 878
 
879 879
 /**
@@ -886,9 +886,9 @@  discard block
 block discarded – undo
886 886
  *
887 887
  * @return void
888 888
  */
889
-function monsterinsights_notice_callback( $args ) {
890
-	$html = monsterinsights_get_message( $args['notice_type'], $args['desc'] );
891
-	return apply_filters( 'monsterinsights_after_setting_output', $html, $args );
889
+function monsterinsights_notice_callback($args) {
890
+	$html = monsterinsights_get_message($args['notice_type'], $args['desc']);
891
+	return apply_filters('monsterinsights_after_setting_output', $html, $args);
892 892
 }
893 893
 
894 894
 /**
@@ -901,12 +901,12 @@  discard block
 block discarded – undo
901 901
  *
902 902
  * @return void
903 903
  */
904
-function monsterinsights_upgrade_notice_callback( $args ) {
905
-	$html =   '<div class="monsterinsights-upsell-box"><h2>' . esc_html( $args['name' ] ) . '</h2>'
904
+function monsterinsights_upgrade_notice_callback($args) {
905
+	$html = '<div class="monsterinsights-upsell-box"><h2>' . esc_html($args['name']) . '</h2>'
906 906
 			. '<p class="monsterinsights-upsell-lite-text">' . $args['desc'] . '</p>'
907
-			. '<p class="monsterinsights-upsell-button-par"><a href="https://www.monsterinsights.com/lite/" class="monsterinsights-upsell-box-button button button-primary">' . __( 'Click here to Upgrade', 'google-analytics-for-wordpress' ) . '</a></p>'
907
+			. '<p class="monsterinsights-upsell-button-par"><a href="https://www.monsterinsights.com/lite/" class="monsterinsights-upsell-box-button button button-primary">' . __('Click here to Upgrade', 'google-analytics-for-wordpress') . '</a></p>'
908 908
 			. '</div>';
909
-	return apply_filters( 'monsterinsights_after_setting_output', $html, $args ); 
909
+	return apply_filters('monsterinsights_after_setting_output', $html, $args); 
910 910
 }
911 911
 
912 912
 /**
@@ -918,8 +918,8 @@  discard block
 block discarded – undo
918 918
  * @param array $args Arguments passed by the setting
919 919
  * @return void
920 920
  */
921
-function monsterinsights_hook_callback( $args ) {
922
-	do_action( 'monsterinsights_' . $args['id'], $args );
921
+function monsterinsights_hook_callback($args) {
922
+	do_action('monsterinsights_' . $args['id'], $args);
923 923
 	return '';
924 924
 }
925 925
 
@@ -934,7 +934,7 @@  discard block
 block discarded – undo
934 934
  */
935 935
 function monsterinsights_missing_callback($args) {
936 936
 	return sprintf(
937
-		__( 'The callback function used for the %s setting is missing.', 'google-analytics-for-wordpress' ),
937
+		__('The callback function used for the %s setting is missing.', 'google-analytics-for-wordpress'),
938 938
 		'<strong>' . $args['id'] . '</strong>'
939 939
 	);
940 940
 }
@@ -948,27 +948,27 @@  discard block
 block discarded – undo
948 948
  * @param array $args Arguments passed by the setting
949 949
  * @return void
950 950
  */
951
-function monsterinsights_render_submit_field( $section, $page = 'tracking' ) {
951
+function monsterinsights_render_submit_field($section, $page = 'tracking') {
952 952
 	$html = '';
953 953
 	$settings = monsterinsights_get_registered_settings();
954
-	if ( is_array( $settings ) && ! empty( $settings[$section] ) && is_array( $settings[$section] ) ) {
954
+	if (is_array($settings) && ! empty($settings[$section]) && is_array($settings[$section])) {
955 955
 		$non_setting_types = monsterinsights_get_non_setting_types();
956 956
 		$submit_button     = false;
957
-		foreach ( $settings[$section] as $setting ) {
958
-			if ( ! empty( $non_setting_types ) && ! empty( $setting['type'] ) && ! in_array( $setting['type'], $non_setting_types ) ) {
959
-				if ( empty( $setting['faux'] ) ) {
957
+		foreach ($settings[$section] as $setting) {
958
+			if ( ! empty($non_setting_types) && ! empty($setting['type']) && ! in_array($setting['type'], $non_setting_types)) {
959
+				if (empty($setting['faux'])) {
960 960
 					$submit_button = true;
961 961
 					break;
962 962
 				}
963 963
 			}
964 964
 		}
965
-		if ( $submit_button ) {
966
-			$html .= '<input type="hidden" name="monsterinsights_settings_tab" value="' . esc_attr( $page ). '"/>';
967
-			$html .= '<input type="hidden" name="monsterinsights_settings_sub_tab" value="' .  esc_attr( $section ) . '"/>';
968
-			$html .= wp_nonce_field( 'monsterinsights-settings-nonce', 'monsterinsights-settings-nonce', true, false );
969
-			$html .= get_submit_button( esc_html__( 'Save Changes', 'google-analytics-for-wordpress' ), 'primary', 'monsterinsights-settings-submit', false );
965
+		if ($submit_button) {
966
+			$html .= '<input type="hidden" name="monsterinsights_settings_tab" value="' . esc_attr($page) . '"/>';
967
+			$html .= '<input type="hidden" name="monsterinsights_settings_sub_tab" value="' . esc_attr($section) . '"/>';
968
+			$html .= wp_nonce_field('monsterinsights-settings-nonce', 'monsterinsights-settings-nonce', true, false);
969
+			$html .= get_submit_button(esc_html__('Save Changes', 'google-analytics-for-wordpress'), 'primary', 'monsterinsights-settings-submit', false);
970 970
 		}
971
-		$html      = apply_filters( 'monsterinsights_html_after_submit_field', $html, $page, $section );
971
+		$html = apply_filters('monsterinsights_html_after_submit_field', $html, $page, $section);
972 972
 	}
973 973
 	return $html;
974 974
 }
@@ -976,17 +976,17 @@  discard block
 block discarded – undo
976 976
 /** 
977 977
  * @todo  docbloc
978 978
  */
979
-function monsterinsights_render_field( $args ) {
979
+function monsterinsights_render_field($args) {
980 980
 	$output = '';
981
-	$output .='<tr id="monsterinsights-input-' . monsterinsights_sanitize_key( $args['id'] ) .'">';
982
-		if ( ! empty( $args['name'] ) && empty( $args['no_label'] ) ) {
981
+	$output .= '<tr id="monsterinsights-input-' . monsterinsights_sanitize_key($args['id']) . '">';
982
+		if ( ! empty($args['name']) && empty($args['no_label'])) {
983 983
 			$output .= '<th scope="row">';
984
-				$output .='<label for="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . ']">' . esc_html( $args["name"] ) . '</label>';
984
+				$output .= '<label for="monsterinsights_settings[' . monsterinsights_sanitize_key($args['id']) . ']">' . esc_html($args["name"]) . '</label>';
985 985
 			$output .= '</th>';
986 986
 		}
987 987
 		$output .= '<td>';
988
-			$render  = ! empty( $args['type'] ) && function_exists( 'monsterinsights_' . $args['type'] . '_callback' ) ? 'monsterinsights_' . $args['type'] . '_callback' : 'monsterinsights_missing_callback';
989
-			$output .= call_user_func( $render, $args );
988
+			$render  = ! empty($args['type']) && function_exists('monsterinsights_' . $args['type'] . '_callback') ? 'monsterinsights_' . $args['type'] . '_callback' : 'monsterinsights_missing_callback';
989
+			$output .= call_user_func($render, $args);
990 990
 		$output .= '</td>';
991 991
 	$output .= '</tr>';
992 992
 	return $output;
@@ -995,24 +995,24 @@  discard block
 block discarded – undo
995 995
 /** 
996 996
  * @todo  docbloc
997 997
  */
998
-function monsterinsights_add_setting_tooltip( $html, $args ) { // @todo: enqueue tooltips
998
+function monsterinsights_add_setting_tooltip($html, $args) { // @todo: enqueue tooltips
999 999
 
1000
-	if ( ! empty( $args['tooltip_title'] ) && ! empty( $args['tooltip_desc'] ) ) {
1000
+	if ( ! empty($args['tooltip_title']) && ! empty($args['tooltip_desc'])) {
1001 1001
 		$tooltip = '<span alt="f223" class="monsterinsights-help-tip dashicons dashicons-editor-help" title="<strong>' . $args['tooltip_title'] . '</strong>: ' . $args['tooltip_desc'] . '"></span>';
1002 1002
 		$html .= $tooltip;
1003 1003
 	}
1004 1004
 
1005 1005
 	return $html;
1006 1006
 }
1007
-add_filter( 'monsterinsights_after_setting_output', 'monsterinsights_add_setting_tooltip', 10, 2 );
1007
+add_filter('monsterinsights_after_setting_output', 'monsterinsights_add_setting_tooltip', 10, 2);
1008 1008
 
1009 1009
 /** 
1010 1010
  * @todo  docbloc
1011 1011
  */
1012
-function monsterinsights_get_settings_notices( $delete_on_retrieve = true ) {
1013
-	$notices = get_transient( 'monsterinsights_settings_notices' );
1014
-	if ( $delete_on_retrieve ) {
1015
-		delete_transient( 'monsterinsights_settings_notices' );
1012
+function monsterinsights_get_settings_notices($delete_on_retrieve = true) {
1013
+	$notices = get_transient('monsterinsights_settings_notices');
1014
+	if ($delete_on_retrieve) {
1015
+		delete_transient('monsterinsights_settings_notices');
1016 1016
 	}
1017 1017
 	return $notices;
1018 1018
 }
@@ -1020,30 +1020,30 @@  discard block
 block discarded – undo
1020 1020
 /** 
1021 1021
  * @todo  docbloc
1022 1022
  */
1023
-function monsterinsights_add_settings_notice( $name, $type = 'success', $message = '' ) {
1024
-	$notices = get_transient( 'monsterinsights_settings_notices' );
1025
-	if ( empty( $notices ) ) {
1023
+function monsterinsights_add_settings_notice($name, $type = 'success', $message = '') {
1024
+	$notices = get_transient('monsterinsights_settings_notices');
1025
+	if (empty($notices)) {
1026 1026
 		$notices          = array();
1027
-		$notices[ $name ] = array( "type" => $type, "message" => $message );
1027
+		$notices[$name] = array("type" => $type, "message" => $message);
1028 1028
 	} else {
1029
-		$notices[ $name ] = array( "type" => $type, "message" => $message );
1029
+		$notices[$name] = array("type" => $type, "message" => $message);
1030 1030
 	}
1031
-	set_transient( 'monsterinsights_settings_notices', $notices );
1031
+	set_transient('monsterinsights_settings_notices', $notices);
1032 1032
 }
1033 1033
 
1034 1034
 /** 
1035 1035
  * @todo  docbloc
1036 1036
  */
1037
-function monsterinsights_remove_settings_notice( $name ) {
1038
-	$notices = get_transient( 'monsterinsights_settings_notices' );
1037
+function monsterinsights_remove_settings_notice($name) {
1038
+	$notices = get_transient('monsterinsights_settings_notices');
1039 1039
 	$found   = false;
1040
-	if ( ! empty( $notices ) ) {
1041
-		if ( isset( $notices[ $name] ) ) {
1042
-			unset( $notices[ $name] );
1043
-			set_transient( 'monsterinsights_settings_notices', $notices );
1040
+	if ( ! empty($notices)) {
1041
+		if (isset($notices[$name])) {
1042
+			unset($notices[$name]);
1043
+			set_transient('monsterinsights_settings_notices', $notices);
1044 1044
 			$found = true;
1045 1045
 		} else {
1046
-			set_transient( 'monsterinsights_settings_notices', $notices );
1046
+			set_transient('monsterinsights_settings_notices', $notices);
1047 1047
 		}
1048 1048
 	}
1049 1049
 	return $found;
@@ -1052,6 +1052,6 @@  discard block
 block discarded – undo
1052 1052
 /** 
1053 1053
  * @todo  docbloc
1054 1054
  */
1055
-function monsterinsights_get_non_setting_types(){
1056
-	return apply_filters( 'monsterinsights_non_setting_types', array(  'descriptive_text', 'hook', 'upgrade_notice', 'install_notice', 'notice' ) );
1055
+function monsterinsights_get_non_setting_types() {
1056
+	return apply_filters('monsterinsights_non_setting_types', array('descriptive_text', 'hook', 'upgrade_notice', 'install_notice', 'notice'));
1057 1057
 }
1058 1058
\ No newline at end of file
Please login to merge, or discard this patch.
Indentation   +562 added lines, -562 removed lines patch added patch discarded remove patch
@@ -19,37 +19,37 @@  discard block
 block discarded – undo
19 19
  * @return void
20 20
 */
21 21
 function monsterinsights_get_section_settings( $section, $page = 'tracking' ) {
22
-	$output = '';
23
-	$settings = monsterinsights_get_registered_settings();
24
-	if ( is_array( $settings ) && ! empty( $settings[$section] ) && is_array( $settings[$section] ) ) {
25
-		foreach ( $settings[$section] as $setting ) {
26
-			$args = wp_parse_args( $setting, array(
27
-				'id'            => null,
28
-				'desc'          => '',
29
-				'name'          => '',
30
-				'size'          => null,
31
-				'options'       => '',
32
-				'std'           => '',
33
-				'min'           => null,
34
-				'max'           => null,
35
-				'step'          => null,
36
-				'select2'        => null,
37
-				'placeholder'   => null,
38
-				'allow_blank'   => true,
39
-				'readonly'      => false,
40
-				'faux'          => false,
41
-				'tooltip_title' => false,
42
-				'tooltip_desc'  => false,
43
-				'field_class'   => '',
44
-				'multiple'      => false,
45
-				'allowclear'    => true,
46
-				'notice_type'   => 'info',
47
-				'no_label'      => false,
48
-			) );
49
-			$output .= monsterinsights_render_field( $args );
50
-		}
51
-	}
52
-	return $output;
22
+    $output = '';
23
+    $settings = monsterinsights_get_registered_settings();
24
+    if ( is_array( $settings ) && ! empty( $settings[$section] ) && is_array( $settings[$section] ) ) {
25
+        foreach ( $settings[$section] as $setting ) {
26
+            $args = wp_parse_args( $setting, array(
27
+                'id'            => null,
28
+                'desc'          => '',
29
+                'name'          => '',
30
+                'size'          => null,
31
+                'options'       => '',
32
+                'std'           => '',
33
+                'min'           => null,
34
+                'max'           => null,
35
+                'step'          => null,
36
+                'select2'        => null,
37
+                'placeholder'   => null,
38
+                'allow_blank'   => true,
39
+                'readonly'      => false,
40
+                'faux'          => false,
41
+                'tooltip_title' => false,
42
+                'tooltip_desc'  => false,
43
+                'field_class'   => '',
44
+                'multiple'      => false,
45
+                'allowclear'    => true,
46
+                'notice_type'   => 'info',
47
+                'no_label'      => false,
48
+            ) );
49
+            $output .= monsterinsights_render_field( $args );
50
+        }
51
+    }
52
+    return $output;
53 53
 }
54 54
 
55 55
 /**
@@ -62,104 +62,104 @@  discard block
 block discarded – undo
62 62
  */
63 63
 function monsterinsights_save_settings() {
64 64
 
65
-	// Check if user pressed the 'Update' button and nonce is valid
66
-	if ( ! isset( $_POST['monsterinsights-settings-submit'] ) ) {
67
-		return;
68
-	}
69
-
70
-	if ( ! wp_verify_nonce( $_POST['monsterinsights-settings-nonce'], 'monsterinsights-settings-nonce' ) ) {
71
-		return;
72
-	}
73
-
74
-	if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
75
-		return;
76
-	}
77
-
78
-	if ( empty( $_POST['monsterinsights_settings_tab'] ) || empty( $_POST['monsterinsights_settings_sub_tab'] ) || $_POST['monsterinsights_settings_tab'] !== 'tracking' ) {
79
-		return;
80
-	}
81
-
82
-	// get subtab
83
-	$settings = monsterinsights_get_registered_settings();
84
-	$tab      = $_POST['monsterinsights_settings_sub_tab'];
85
-	if ( empty( $settings ) || !is_array( $settings ) || empty( $settings[ $tab ] ) || ! is_array( $settings[ $tab ] ) ) {
86
-		return;
87
-	}
88
-
89
-	// Okay we're good to sanitize, validate, and save this section's settings
90
-
91
-	// We only care about this sections's settings
92
-	$settings = $settings[ $tab ]; 
93
-
94
-	// Run a general sanitization for the tab for special fields
95
-	$input    = ! empty( $_POST['monsterinsights_settings'] ) ? $_POST['monsterinsights_settings'] : array();
96
-	$input    = apply_filters( 'monsterinsights_settings_' . $tab . '_sanitize', $input );
97
-
98
-	foreach( $settings as $id => $setting ) {
99
-
100
-		// If the value wasn't passed in, set to false, which will delete the option
101
-		$value          = isset( $input[ $id ] ) ? $input[ $id ] : false;
102
-		$previous_value = monsterinsights_get_option( $id, false );
103
-
104
-		// Sanitize/Validate
105
-		if ( empty( $setting['type'] ) ) {
106
-			continue;
107
-		}
108
-
109
-		// Some setting types are not actually settings, just keep moving along here
110
-		$non_setting_types = monsterinsights_get_non_setting_types();
111
-		$type              = $setting['type'];
112
-
113
-		if ( in_array( $type, $non_setting_types ) ) {
114
-			continue;
115
-		}
116
-
117
-		$args = wp_parse_args( $setting, array(
118
-			'id'            => null,
119
-			'desc'          => '',
120
-			'name'          => '',
121
-			'size'          => null,
122
-			'options'       => '',
123
-			'std'           => '',
124
-			'min'           => null,
125
-			'max'           => null,
126
-			'step'          => null,
127
-			'select2'        => null,
128
-			'placeholder'   => null,
129
-			'allow_blank'   => true,
130
-			'readonly'      => false,
131
-			'faux'          => false,
132
-			'tooltip_title' => false,
133
-			'tooltip_desc'  => false,
134
-			'field_class'   => '',
135
-			'multiple'      => false,
136
-			'allowclear'    => true,
137
-			'notice_type'   => 'info',
138
-		) );
139
-
140
-		// Sanitize settings
141
-		$value = apply_filters( 'monsterinsights_settings_sanitize_' . $id  , $value, $id, $args, $previous_value );
142
-		$value = apply_filters( 'monsterinsights_settings_sanitize_' . $type, $value, $id, $args, $previous_value );
143
-		$value = apply_filters( 'monsterinsights_settings_sanitize'         , $value, $id, $args, $previous_value );
144
-
145
-		// Save
146
-		if ( ! has_action( 'monsterinsights_settings_save_' . $args['type'] ) ) {
147
-			monsterinsights_update_option( $id, $value );
148
-		} else {
149
-			do_action( 'monsterinsights_settings_save_' . $args['type'], $value, $id, $args, $previous_value );
150
-		}
151
-	}
152
-	add_action( 'monsterinsights_tracking_' . $tab . '_tab_notice', 'monsterinsights_updated_settings' );
65
+    // Check if user pressed the 'Update' button and nonce is valid
66
+    if ( ! isset( $_POST['monsterinsights-settings-submit'] ) ) {
67
+        return;
68
+    }
69
+
70
+    if ( ! wp_verify_nonce( $_POST['monsterinsights-settings-nonce'], 'monsterinsights-settings-nonce' ) ) {
71
+        return;
72
+    }
73
+
74
+    if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
75
+        return;
76
+    }
77
+
78
+    if ( empty( $_POST['monsterinsights_settings_tab'] ) || empty( $_POST['monsterinsights_settings_sub_tab'] ) || $_POST['monsterinsights_settings_tab'] !== 'tracking' ) {
79
+        return;
80
+    }
81
+
82
+    // get subtab
83
+    $settings = monsterinsights_get_registered_settings();
84
+    $tab      = $_POST['monsterinsights_settings_sub_tab'];
85
+    if ( empty( $settings ) || !is_array( $settings ) || empty( $settings[ $tab ] ) || ! is_array( $settings[ $tab ] ) ) {
86
+        return;
87
+    }
88
+
89
+    // Okay we're good to sanitize, validate, and save this section's settings
90
+
91
+    // We only care about this sections's settings
92
+    $settings = $settings[ $tab ]; 
93
+
94
+    // Run a general sanitization for the tab for special fields
95
+    $input    = ! empty( $_POST['monsterinsights_settings'] ) ? $_POST['monsterinsights_settings'] : array();
96
+    $input    = apply_filters( 'monsterinsights_settings_' . $tab . '_sanitize', $input );
97
+
98
+    foreach( $settings as $id => $setting ) {
99
+
100
+        // If the value wasn't passed in, set to false, which will delete the option
101
+        $value          = isset( $input[ $id ] ) ? $input[ $id ] : false;
102
+        $previous_value = monsterinsights_get_option( $id, false );
103
+
104
+        // Sanitize/Validate
105
+        if ( empty( $setting['type'] ) ) {
106
+            continue;
107
+        }
108
+
109
+        // Some setting types are not actually settings, just keep moving along here
110
+        $non_setting_types = monsterinsights_get_non_setting_types();
111
+        $type              = $setting['type'];
112
+
113
+        if ( in_array( $type, $non_setting_types ) ) {
114
+            continue;
115
+        }
116
+
117
+        $args = wp_parse_args( $setting, array(
118
+            'id'            => null,
119
+            'desc'          => '',
120
+            'name'          => '',
121
+            'size'          => null,
122
+            'options'       => '',
123
+            'std'           => '',
124
+            'min'           => null,
125
+            'max'           => null,
126
+            'step'          => null,
127
+            'select2'        => null,
128
+            'placeholder'   => null,
129
+            'allow_blank'   => true,
130
+            'readonly'      => false,
131
+            'faux'          => false,
132
+            'tooltip_title' => false,
133
+            'tooltip_desc'  => false,
134
+            'field_class'   => '',
135
+            'multiple'      => false,
136
+            'allowclear'    => true,
137
+            'notice_type'   => 'info',
138
+        ) );
139
+
140
+        // Sanitize settings
141
+        $value = apply_filters( 'monsterinsights_settings_sanitize_' . $id  , $value, $id, $args, $previous_value );
142
+        $value = apply_filters( 'monsterinsights_settings_sanitize_' . $type, $value, $id, $args, $previous_value );
143
+        $value = apply_filters( 'monsterinsights_settings_sanitize'         , $value, $id, $args, $previous_value );
144
+
145
+        // Save
146
+        if ( ! has_action( 'monsterinsights_settings_save_' . $args['type'] ) ) {
147
+            monsterinsights_update_option( $id, $value );
148
+        } else {
149
+            do_action( 'monsterinsights_settings_save_' . $args['type'], $value, $id, $args, $previous_value );
150
+        }
151
+    }
152
+    add_action( 'monsterinsights_tracking_' . $tab . '_tab_notice', 'monsterinsights_updated_settings' );
153 153
 }
154 154
 add_action( 'current_screen', 'monsterinsights_save_settings' );
155 155
 
156 156
 function monsterinsights_is_settings_tab( $tab = '' ){
157
-	$tabs = monsterinsights_get_settings_tabs();
158
-	if ( empty( $tab ) || empty( $tabs ) || ! is_string( $tab ) || ! is_array( $tabs ) ) {
159
-		return false;
160
-	}
157
+    $tabs = monsterinsights_get_settings_tabs();
158
+    if ( empty( $tab ) || empty( $tabs ) || ! is_string( $tab ) || ! is_array( $tabs ) ) {
159
+        return false;
160
+    }
161 161
 
162
-	return !empty( $tabs[$tab]);
162
+    return !empty( $tabs[$tab]);
163 163
 }
164 164
 
165 165
 /**
@@ -170,26 +170,26 @@  discard block
 block discarded – undo
170 170
  * @return array Key is the setting ID, value is the type of setting it is registered as
171 171
  */
172 172
 function monsterinsights_get_registered_settings_types( $section = '' ) {
173
-	$settings      = monsterinsights_get_registered_settings();
174
-	$setting_types = array();
175
-	if ( ! empty( $section ) ) {
176
-		if ( ! empty( $settings[$section] ) ) {
177
-			foreach ( $settings[$section] as $setting ) {
178
-				if ( is_array( $setting ) && array_key_exists( 'type', $setting ) ) {
179
-					$setting_types[ $setting['id'] ] = $setting['type'];
180
-				}
181
-			}
182
-		}
183
-	} else {
184
-		foreach ( $settings as $tab ) {
185
-			foreach ( $tab as $setting ) {
186
-				if ( is_array( $setting ) && array_key_exists( 'type', $setting ) ) {
187
-					$setting_types[ $setting['id'] ] = $setting['type'];
188
-				}
189
-			}
190
-		}
191
-	}
192
-	return $setting_types;
173
+    $settings      = monsterinsights_get_registered_settings();
174
+    $setting_types = array();
175
+    if ( ! empty( $section ) ) {
176
+        if ( ! empty( $settings[$section] ) ) {
177
+            foreach ( $settings[$section] as $setting ) {
178
+                if ( is_array( $setting ) && array_key_exists( 'type', $setting ) ) {
179
+                    $setting_types[ $setting['id'] ] = $setting['type'];
180
+                }
181
+            }
182
+        }
183
+    } else {
184
+        foreach ( $settings as $tab ) {
185
+            foreach ( $tab as $setting ) {
186
+                if ( is_array( $setting ) && array_key_exists( 'type', $setting ) ) {
187
+                    $setting_types[ $setting['id'] ] = $setting['type'];
188
+                }
189
+            }
190
+        }
191
+    }
192
+    return $setting_types;
193 193
 }
194 194
 
195 195
 /**
@@ -200,90 +200,90 @@  discard block
 block discarded – undo
200 200
  * @return string $input Sanitizied value
201 201
  */
202 202
 function monsterinsights_sanitize_rich_editor_field( $input ) {
203
-	$tags = array(
204
-		'p' => array(
205
-			'class' => array(),
206
-			'id'    => array(),
207
-		),
208
-		'span' => array(
209
-			'class' => array(),
210
-			'id'    => array(),
211
-		),
212
-		'a' => array(
213
-			'href' => array(),
214
-			'title' => array(),
215
-			'class' => array(),
216
-			'title' => array(),
217
-			'id'    => array(),
218
-		),
219
-		'strong' => array(),
220
-		'em' => array(),
221
-		'br' => array(),
222
-		'img' => array(
223
-			'src'   => array(),
224
-			'title' => array(),
225
-			'alt'   => array(),
226
-			'id'    => array(),
227
-		),
228
-		'div' => array(
229
-			'class' => array(),
230
-			'id'    => array(),
231
-		),
232
-		'ul' => array(
233
-			'class' => array(),
234
-			'id'    => array(),
235
-		),
236
-		'li' => array(
237
-			'class' => array(),
238
-			'id'    => array(),
239
-		)
240
-	);
241
-
242
-	//$allowed_tags = apply_filters( 'monsterinsights_allowed_html_tags', $tags );
243
-
244
-	return trim( wp_kses( $input, $allowed_tags ) );
203
+    $tags = array(
204
+        'p' => array(
205
+            'class' => array(),
206
+            'id'    => array(),
207
+        ),
208
+        'span' => array(
209
+            'class' => array(),
210
+            'id'    => array(),
211
+        ),
212
+        'a' => array(
213
+            'href' => array(),
214
+            'title' => array(),
215
+            'class' => array(),
216
+            'title' => array(),
217
+            'id'    => array(),
218
+        ),
219
+        'strong' => array(),
220
+        'em' => array(),
221
+        'br' => array(),
222
+        'img' => array(
223
+            'src'   => array(),
224
+            'title' => array(),
225
+            'alt'   => array(),
226
+            'id'    => array(),
227
+        ),
228
+        'div' => array(
229
+            'class' => array(),
230
+            'id'    => array(),
231
+        ),
232
+        'ul' => array(
233
+            'class' => array(),
234
+            'id'    => array(),
235
+        ),
236
+        'li' => array(
237
+            'class' => array(),
238
+            'id'    => array(),
239
+        )
240
+    );
241
+
242
+    //$allowed_tags = apply_filters( 'monsterinsights_allowed_html_tags', $tags );
243
+
244
+    return trim( wp_kses( $input, $allowed_tags ) );
245 245
 }
246 246
 add_filter( 'monsterinsights_settings_sanitize_rich_editor', 'monsterinsights_sanitize_rich_editor_field' );
247 247
 
248 248
 if ( ! function_exists( 'sanitize_textarea_field' ) ) {
249
-	function sanitize_textarea_field( $str ) {
250
-		$filtered = _sanitize_text_fields( $str, true );
251
-		return apply_filters( 'sanitize_textarea_field', $filtered, $str );
252
-	}
249
+    function sanitize_textarea_field( $str ) {
250
+        $filtered = _sanitize_text_fields( $str, true );
251
+        return apply_filters( 'sanitize_textarea_field', $filtered, $str );
252
+    }
253 253
 }
254 254
 
255 255
 if ( ! function_exists( 'sanitize_textarea_field' ) ) {
256
-	function _sanitize_text_fields( $str, $keep_newlines = false ) {
257
-		$filtered = wp_check_invalid_utf8( $str );
256
+    function _sanitize_text_fields( $str, $keep_newlines = false ) {
257
+        $filtered = wp_check_invalid_utf8( $str );
258 258
 	 
259
-		if ( strpos($filtered, '<') !== false ) {
260
-			$filtered = wp_pre_kses_less_than( $filtered );
261
-			// This will strip extra whitespace for us.
262
-			$filtered = wp_strip_all_tags( $filtered, false );
259
+        if ( strpos($filtered, '<') !== false ) {
260
+            $filtered = wp_pre_kses_less_than( $filtered );
261
+            // This will strip extra whitespace for us.
262
+            $filtered = wp_strip_all_tags( $filtered, false );
263 263
 	 
264
-			// Use html entities in a special case to make sure no later
265
-			// newline stripping stage could lead to a functional tag
266
-			$filtered = str_replace("<\n", "&lt;\n", $filtered);
267
-		}
264
+            // Use html entities in a special case to make sure no later
265
+            // newline stripping stage could lead to a functional tag
266
+            $filtered = str_replace("<\n", "&lt;\n", $filtered);
267
+        }
268 268
 	 
269
-		if ( ! $keep_newlines ) {
270
-			$filtered = preg_replace( '/[\r\n\t ]+/', ' ', $filtered );
271
-		}
272
-		$filtered = trim( $filtered );
269
+        if ( ! $keep_newlines ) {
270
+            $filtered = preg_replace( '/[\r\n\t ]+/', ' ', $filtered );
271
+        }
272
+        $filtered = trim( $filtered );
273 273
 	 
274
-		$found = false;
275
-		while ( preg_match('/%[a-f0-9]{2}/i', $filtered, $match) ) {
276
-			$filtered = str_replace($match[0], '', $filtered);
277
-			$found = true;
278
-		}
274
+        $found = false;
275
+        while ( preg_match('/%[a-f0-9]{2}/i', $filtered, $match) ) {
276
+            $filtered = str_replace($match[0], '', $filtered);
277
+            $found = true;
278
+        }
279 279
 	 
280
-		if ( $found ) {
281
-			// Strip out the whitespace that may now exist after removing the octets.
282
-			$filtered = trim( preg_replace('/ +/', ' ', $filtered) );
283
-		}
280
+        if ( $found ) {
281
+            // Strip out the whitespace that may now exist after removing the octets.
282
+            $filtered = trim( preg_replace('/ +/', ' ', $filtered) );
283
+        }
284 284
 	 
285
-		return $filtered;
286
-	}
285
+        return $filtered;
286
+    }
287 287
 }
288 288
 
289 289
 /**
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
  * @todo  docbloc
294 294
  */
295 295
 function monsterinsights_sanitize_textarea_field( $value, $id, $setting, $previous_value ) {
296
-	return sanitize_textarea_field( $value );
296
+    return sanitize_textarea_field( $value );
297 297
 }
298 298
 add_filter( 'monsterinsights_settings_sanitize_textarea', 'monsterinsights_sanitize_textarea_field', 10, 4 );
299 299
 
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
  * @todo  docbloc
305 305
  */
306 306
 function monsterinsights_sanitize_checkbox_field( $value, $id, $setting, $previous_value ) {
307
-	return (bool) $value;
307
+    return (bool) $value;
308 308
 }
309 309
 add_filter( 'monsterinsights_settings_sanitize_checkbox', 'monsterinsights_sanitize_checkbox_field', 10, 4 );
310 310
 
@@ -315,15 +315,15 @@  discard block
 block discarded – undo
315 315
  * @todo  docbloc
316 316
  */
317 317
 function monsterinsights_sanitize_multicheck_field( $value, $id, $setting, $previous_value ) {
318
-	$save_value = array();
319
-	if ( ! empty( $value ) && is_array( $value ) ) {
320
-		foreach( $setting['options'] as $key => $option ){
321
-			if ( in_array( $key, $value ) ) {
322
-				$save_value[] = $key;
323
-			}
324
-		}
325
-	}
326
-	return $save_value;
318
+    $save_value = array();
319
+    if ( ! empty( $value ) && is_array( $value ) ) {
320
+        foreach( $setting['options'] as $key => $option ){
321
+            if ( in_array( $key, $value ) ) {
322
+                $save_value[] = $key;
323
+            }
324
+        }
325
+    }
326
+    return $save_value;
327 327
 }
328 328
 add_filter( 'monsterinsights_settings_sanitize_multicheck', 'monsterinsights_sanitize_multicheck_field', 10, 4 );
329 329
 
@@ -334,34 +334,34 @@  discard block
 block discarded – undo
334 334
  * @todo  docbloc
335 335
  */
336 336
 function monsterinsights_sanitize_select_field( $value, $id, $setting, $previous_value ) {
337
-	if ( ! empty( $setting['multiple'] ) && $setting['multiple'] ) {
338
-		$save_value = array();
339
-	} else {
340
-		$save_value = '';
341
-	}
342
-	if ( ! empty( $value ) && is_array( $value ) ) {
343
-		if ( $setting['multiple'] ) {
344
-			foreach ( $value as $vid => $vname ) {
345
-				foreach( $setting['options'] as $key => $option ){
346
-					if ( $key === $vname ) {
347
-						$save_value[] = $key;
348
-						break;
349
-					}
350
-				}
351
-			}
352
-		} else {
353
-			foreach( $setting['options'] as $key => $option ){
354
-				if ( is_array( $value ) && in_array( $key, $value ) ) {
355
-					$save_value = $key;
356
-					break;
357
-				} else if ( is_string( $value ) && $key === $value ){
358
-					$save_value = $key;
359
-					break;
360
-				}
361
-			}
362
-		}
363
-	}
364
-	return $save_value;
337
+    if ( ! empty( $setting['multiple'] ) && $setting['multiple'] ) {
338
+        $save_value = array();
339
+    } else {
340
+        $save_value = '';
341
+    }
342
+    if ( ! empty( $value ) && is_array( $value ) ) {
343
+        if ( $setting['multiple'] ) {
344
+            foreach ( $value as $vid => $vname ) {
345
+                foreach( $setting['options'] as $key => $option ){
346
+                    if ( $key === $vname ) {
347
+                        $save_value[] = $key;
348
+                        break;
349
+                    }
350
+                }
351
+            }
352
+        } else {
353
+            foreach( $setting['options'] as $key => $option ){
354
+                if ( is_array( $value ) && in_array( $key, $value ) ) {
355
+                    $save_value = $key;
356
+                    break;
357
+                } else if ( is_string( $value ) && $key === $value ){
358
+                    $save_value = $key;
359
+                    break;
360
+                }
361
+            }
362
+        }
363
+    }
364
+    return $save_value;
365 365
 }
366 366
 add_filter( 'monsterinsights_settings_sanitize_select', 'monsterinsights_sanitize_select_field', 10, 4 );
367 367
 
@@ -373,15 +373,15 @@  discard block
 block discarded – undo
373 373
  * @todo  docbloc
374 374
  */
375 375
 function monsterinsights_sanitize_radio_field( $value, $id, $setting, $previous_value ) {
376
-	$save_value = '';
377
-	if ( ! empty( $value ) ) {
378
-		foreach( $setting['options'] as $key => $option ){
379
-			if ( $key === $value ) {
380
-				$save_value = $key;
381
-			}
382
-		}
383
-	}
384
-	return $save_value;
376
+    $save_value = '';
377
+    if ( ! empty( $value ) ) {
378
+        foreach( $setting['options'] as $key => $option ){
379
+            if ( $key === $value ) {
380
+                $save_value = $key;
381
+            }
382
+        }
383
+    }
384
+    return $save_value;
385 385
 }
386 386
 add_filter( 'monsterinsights_settings_sanitize_radio', 'monsterinsights_sanitize_radio_field', 10, 4 );
387 387
 
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
  * @todo  docbloc
393 393
  */
394 394
 function monsterinsights_sanitize_text_field( $value, $id, $setting, $previous_value ) {
395
-	return sanitize_text_field( $value );
395
+    return sanitize_text_field( $value );
396 396
 }
397 397
 add_filter( 'monsterinsights_settings_sanitize_text', 'monsterinsights_sanitize_text_field', 10, 4 );
398 398
 
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
  * @todo  docbloc
404 404
  */
405 405
 function monsterinsights_sanitize_password_field( $value, $id, $setting, $previous_value ) {
406
-	return sanitize_text_field( $value );
406
+    return sanitize_text_field( $value );
407 407
 }
408 408
 add_filter( 'monsterinsights_settings_sanitize_password', 'monsterinsights_sanitize_password_field', 10, 4 );
409 409
 
@@ -414,13 +414,13 @@  discard block
 block discarded – undo
414 414
  * @todo  docbloc
415 415
  */
416 416
 function monsterinsights_sanitize_number_field( $value, $id, $setting, $previous_value ) {
417
-	if ( is_int( (int) $value ) ) {
418
-		return $value;
419
-	} else if ( is_int( $previous_value ) ) {
420
-		return $previous_value;
421
-	} else {
422
-		return 0;
423
-	}
417
+    if ( is_int( (int) $value ) ) {
418
+        return $value;
419
+    } else if ( is_int( $previous_value ) ) {
420
+        return $previous_value;
421
+    } else {
422
+        return 0;
423
+    }
424 424
 }
425 425
 add_filter( 'monsterinsights_settings_sanitize_number', 'monsterinsights_sanitize_number_field', 10, 4 );
426 426
 
@@ -431,11 +431,11 @@  discard block
 block discarded – undo
431 431
  * @todo  docbloc
432 432
  */
433 433
 function monsterinsights_sanitize_unfiltered_textarea_field( $value, $id, $setting, $previous_value ) {
434
-	if ( current_user_can( 'unfiltered_html' ) || current_user_can( 'monsterinsights_unfiltered_html' ) ) {
435
-		return $value;
436
-	} else {
437
-		return $previous_value;
438
-	}
434
+    if ( current_user_can( 'unfiltered_html' ) || current_user_can( 'monsterinsights_unfiltered_html' ) ) {
435
+        return $value;
436
+    } else {
437
+        return $previous_value;
438
+    }
439 439
 }
440 440
 add_filter( 'monsterinsights_settings_unfiltered_textarea_number', 'monsterinsights_sanitize_unfiltered_textarea_field', 10, 4 );
441 441
 
@@ -449,16 +449,16 @@  discard block
 block discarded – undo
449 449
  * @return string Sanitized key
450 450
  */
451 451
 function monsterinsights_sanitize_key( $key ) {
452
-	$raw_key = $key;
453
-	$key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key );
454
-	/**
455
-	 * Filter a sanitized key string.
456
-	 *
457
-	 * @since 6.0.0
458
-	 * @param string $key     Sanitized key.
459
-	 * @param string $raw_key The key prior to sanitization.
460
-	 */
461
-	return apply_filters( 'monsterinsights_sanitize_key', $key, $raw_key );
452
+    $raw_key = $key;
453
+    $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key );
454
+    /**
455
+     * Filter a sanitized key string.
456
+     *
457
+     * @since 6.0.0
458
+     * @param string $key     Sanitized key.
459
+     * @param string $raw_key The key prior to sanitization.
460
+     */
461
+    return apply_filters( 'monsterinsights_sanitize_key', $key, $raw_key );
462 462
 }
463 463
 
464 464
 /**
@@ -470,14 +470,14 @@  discard block
 block discarded – undo
470 470
  */
471 471
 function monsterinsights_sanitize_html_class( $class = '' ) {
472 472
 
473
-	if ( is_string( $class ) ) {
474
-		$class = sanitize_html_class( $class );
475
-	} else if ( is_array( $class ) ) {
476
-		$class = array_values( array_map( 'sanitize_html_class', $class ) );
477
-		$class = implode( ' ', array_unique( $class ) );
478
-	}
473
+    if ( is_string( $class ) ) {
474
+        $class = sanitize_html_class( $class );
475
+    } else if ( is_array( $class ) ) {
476
+        $class = array_values( array_map( 'sanitize_html_class', $class ) );
477
+        $class = implode( ' ', array_unique( $class ) );
478
+    }
479 479
 
480
-	return $class;
480
+    return $class;
481 481
 
482 482
 }
483 483
 
@@ -491,19 +491,19 @@  discard block
 block discarded – undo
491 491
  * @return array $pages_options An array of the pages
492 492
  */
493 493
 function monsterinsights_get_pages( $force = false ) {
494
-	$pages_options = array( '' => '' ); // Blank option
495
-	if( ( ! isset( $_GET['page'] ) || 'monsterinsights_settings' != $_GET['page'] ) && ! $force ) {
496
-		return $pages_options;
497
-	}
498
-
499
-	$pages = get_pages();
500
-	if ( $pages ) {
501
-		foreach ( $pages as $page ) {
502
-			$pages_options[ $page->ID ] = $page->post_title;
503
-		}
504
-	}
505
-
506
-	return $pages_options;
494
+    $pages_options = array( '' => '' ); // Blank option
495
+    if( ( ! isset( $_GET['page'] ) || 'monsterinsights_settings' != $_GET['page'] ) && ! $force ) {
496
+        return $pages_options;
497
+    }
498
+
499
+    $pages = get_pages();
500
+    if ( $pages ) {
501
+        foreach ( $pages as $page ) {
502
+            $pages_options[ $page->ID ] = $page->post_title;
503
+        }
504
+    }
505
+
506
+    return $pages_options;
507 507
 }
508 508
 
509 509
 /**
@@ -517,32 +517,32 @@  discard block
 block discarded – undo
517 517
  * @return void
518 518
  */
519 519
 function monsterinsights_checkbox_callback( $args ) {
520
-	$monsterinsights_option = monsterinsights_get_option( $args['id'] );
520
+    $monsterinsights_option = monsterinsights_get_option( $args['id'] );
521 521
 
522
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
523
-		$name = '';
524
-	} else {
525
-		$name = 'name="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . ']"';
526
-	}
522
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
523
+        $name = '';
524
+    } else {
525
+        $name = 'name="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . ']"';
526
+    }
527 527
 
528
-	$class = monsterinsights_sanitize_html_class( $args['field_class'] );
528
+    $class = monsterinsights_sanitize_html_class( $args['field_class'] );
529 529
 
530
-	$checked  = ! empty( $monsterinsights_option ) ? checked( 1, $monsterinsights_option, false ) : '';
530
+    $checked  = ! empty( $monsterinsights_option ) ? checked( 1, $monsterinsights_option, false ) : '';
531 531
 
532
-	$disabled = '';
532
+    $disabled = '';
533 533
 
534
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
535
-		// Disable class
536
-		$disabled = 'disabled="disabled"';
534
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
535
+        // Disable class
536
+        $disabled = 'disabled="disabled"';
537 537
 		
538
-		// Checked
539
-		$checked  = isset( $args['std'] ) && true === $args['std'] ? checked( 1, 1, false ) : '';
540
-	}
538
+        // Checked
539
+        $checked  = isset( $args['std'] ) && true === $args['std'] ? checked( 1, 1, false ) : '';
540
+    }
541 541
 
542
-	$html     = '<input type="checkbox" id="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . ']"' . $name . ' value="1" ' . $checked . ' class="' . $class . '" ' . $disabled . ' />';
543
-	$html    .= '<p class="description">'  . wp_kses_post( $args['desc'] ) . '</p>';
542
+    $html     = '<input type="checkbox" id="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . ']"' . $name . ' value="1" ' . $checked . ' class="' . $class . '" ' . $disabled . ' />';
543
+    $html    .= '<p class="description">'  . wp_kses_post( $args['desc'] ) . '</p>';
544 544
 
545
-	return apply_filters( 'monsterinsights_after_setting_output', $html, $args );
545
+    return apply_filters( 'monsterinsights_after_setting_output', $html, $args );
546 546
 }
547 547
 
548 548
 /**
@@ -556,21 +556,21 @@  discard block
 block discarded – undo
556 556
  * @return void
557 557
  */
558 558
 function monsterinsights_multicheck_callback( $args ) {
559
-	$monsterinsights_option = monsterinsights_get_option( $args['id'] );
559
+    $monsterinsights_option = monsterinsights_get_option( $args['id'] );
560 560
 
561
-	$class = monsterinsights_sanitize_html_class( $args['field_class'] );
561
+    $class = monsterinsights_sanitize_html_class( $args['field_class'] );
562 562
 
563
-	$html = '';
564
-	if ( ! empty( $args['options'] ) ) {
565
-		foreach( $args['options'] as $key => $option ):
566
-			if( isset( $monsterinsights_option[ $key ] ) ) { $enabled = $option; } else { $enabled = NULL; }
567
-			$html .= '<input name="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . '][' . monsterinsights_sanitize_key( $key ) . ']" id="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . '][' . monsterinsights_sanitize_key( $key ) . ']" class="' . $class . '" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked($option, $enabled, false) . '/>&nbsp;';
568
-			$html .= '<label for="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . '][' . monsterinsights_sanitize_key( $key ) . ']">' . wp_kses_post( $option ) . '</label><br/>';
569
-		endforeach;
570
-		$html .= '<p class="description">' . $args['desc'] . '</p>';
571
-	}
563
+    $html = '';
564
+    if ( ! empty( $args['options'] ) ) {
565
+        foreach( $args['options'] as $key => $option ):
566
+            if( isset( $monsterinsights_option[ $key ] ) ) { $enabled = $option; } else { $enabled = NULL; }
567
+            $html .= '<input name="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . '][' . monsterinsights_sanitize_key( $key ) . ']" id="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . '][' . monsterinsights_sanitize_key( $key ) . ']" class="' . $class . '" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked($option, $enabled, false) . '/>&nbsp;';
568
+            $html .= '<label for="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . '][' . monsterinsights_sanitize_key( $key ) . ']">' . wp_kses_post( $option ) . '</label><br/>';
569
+        endforeach;
570
+        $html .= '<p class="description">' . $args['desc'] . '</p>';
571
+    }
572 572
 
573
-	return apply_filters( 'monsterinsights_after_setting_output', $html, $args );
573
+    return apply_filters( 'monsterinsights_after_setting_output', $html, $args );
574 574
 }
575 575
 
576 576
 
@@ -585,29 +585,29 @@  discard block
 block discarded – undo
585 585
  * @return void
586 586
  */
587 587
 function monsterinsights_radio_callback( $args ) {
588
-	$monsterinsights_options = monsterinsights_get_option( $args['id'] );
588
+    $monsterinsights_options = monsterinsights_get_option( $args['id'] );
589 589
 
590
-	$html = '';
590
+    $html = '';
591 591
 
592
-	$class = monsterinsights_sanitize_html_class( $args['field_class'] );
592
+    $class = monsterinsights_sanitize_html_class( $args['field_class'] );
593 593
 
594
-	foreach ( $args['options'] as $key => $option ) :
595
-		$checked = false;
594
+    foreach ( $args['options'] as $key => $option ) :
595
+        $checked = false;
596 596
 
597
-		if ( $monsterinsights_options && $monsterinsights_options == $key ) {
598
-			$checked = true;
599
-		} else if( isset( $args['std'] ) && $args['std'] == $key && ! $monsterinsights_options ) {
600
-			$checked = true;
601
-		}
597
+        if ( $monsterinsights_options && $monsterinsights_options == $key ) {
598
+            $checked = true;
599
+        } else if( isset( $args['std'] ) && $args['std'] == $key && ! $monsterinsights_options ) {
600
+            $checked = true;
601
+        }
602 602
 
603
-		$html .= '<label for="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . '][' . monsterinsights_sanitize_key( $key ) . ']">';
604
-		$html .= '<input name="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . ']" id="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . '][' . monsterinsights_sanitize_key( $key ) . ']" class="' . $class . '" type="radio" value="' . monsterinsights_sanitize_key( $key ) . '" ' . checked(true, $checked, false) . '/>&nbsp;';
605
-		$html .= esc_html( $option ) . '</label>';
606
-	endforeach;
603
+        $html .= '<label for="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . '][' . monsterinsights_sanitize_key( $key ) . ']">';
604
+        $html .= '<input name="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . ']" id="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . '][' . monsterinsights_sanitize_key( $key ) . ']" class="' . $class . '" type="radio" value="' . monsterinsights_sanitize_key( $key ) . '" ' . checked(true, $checked, false) . '/>&nbsp;';
605
+        $html .= esc_html( $option ) . '</label>';
606
+    endforeach;
607 607
 
608
-	$html .= '<p class="description">' . apply_filters( 'monsterinsights_after_setting_output', wp_kses_post( $args['desc'] ), $args ) . '</p>';
608
+    $html .= '<p class="description">' . apply_filters( 'monsterinsights_after_setting_output', wp_kses_post( $args['desc'] ), $args ) . '</p>';
609 609
 
610
-	return $html;
610
+    return $html;
611 611
 }
612 612
 
613 613
 /**
@@ -621,33 +621,33 @@  discard block
 block discarded – undo
621 621
  * @return void
622 622
  */
623 623
 function monsterinsights_text_callback( $args ) {
624
-	$monsterinsights_option = monsterinsights_get_option( $args['id'] );
625
-
626
-	if ( $monsterinsights_option ) {
627
-		$value = $monsterinsights_option;
628
-	} elseif( ! empty( $args['allow_blank'] ) && empty( $monsterinsights_option ) ) {
629
-		$value = '';
630
-	} else {
631
-		$value = isset( $args['std'] ) ? $args['std'] : '';
632
-	}
633
-
634
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
635
-		$args['readonly'] = true;
636
-		$value = isset( $args['std'] ) ? $args['std'] : '';
637
-		$name  = '';
638
-	} else {
639
-		$name = 'name="monsterinsights_settings[' . esc_attr( $args['id'] ) . ']"';
640
-	}
641
-
642
-	$class = monsterinsights_sanitize_html_class( $args['field_class'] );
643
-
644
-	$disabled = ! empty( $args['disabled'] ) ? ' disabled="disabled"' : '';
645
-	$readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
646
-	$size     = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
647
-	$html     = '<input type="text" class="' . $class . ' ' . sanitize_html_class( $size ) . '-text" id="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . $disabled . ' placeholder="' . esc_attr( $args['placeholder'] ) . '"/>';
648
-	$html    .= '<p class="description"> '  . wp_kses_post( $args['desc'] ) . '</p>';
649
-
650
-	return apply_filters( 'monsterinsights_after_setting_output', $html, $args );
624
+    $monsterinsights_option = monsterinsights_get_option( $args['id'] );
625
+
626
+    if ( $monsterinsights_option ) {
627
+        $value = $monsterinsights_option;
628
+    } elseif( ! empty( $args['allow_blank'] ) && empty( $monsterinsights_option ) ) {
629
+        $value = '';
630
+    } else {
631
+        $value = isset( $args['std'] ) ? $args['std'] : '';
632
+    }
633
+
634
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
635
+        $args['readonly'] = true;
636
+        $value = isset( $args['std'] ) ? $args['std'] : '';
637
+        $name  = '';
638
+    } else {
639
+        $name = 'name="monsterinsights_settings[' . esc_attr( $args['id'] ) . ']"';
640
+    }
641
+
642
+    $class = monsterinsights_sanitize_html_class( $args['field_class'] );
643
+
644
+    $disabled = ! empty( $args['disabled'] ) ? ' disabled="disabled"' : '';
645
+    $readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
646
+    $size     = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
647
+    $html     = '<input type="text" class="' . $class . ' ' . sanitize_html_class( $size ) . '-text" id="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . $disabled . ' placeholder="' . esc_attr( $args['placeholder'] ) . '"/>';
648
+    $html    .= '<p class="description"> '  . wp_kses_post( $args['desc'] ) . '</p>';
649
+
650
+    return apply_filters( 'monsterinsights_after_setting_output', $html, $args );
651 651
 }
652 652
 
653 653
 /**
@@ -661,33 +661,33 @@  discard block
 block discarded – undo
661 661
  * @return void
662 662
  */
663 663
 function monsterinsights_number_callback( $args ) {
664
-	$monsterinsights_option = monsterinsights_get_option( $args['id'] );
664
+    $monsterinsights_option = monsterinsights_get_option( $args['id'] );
665 665
 
666
-	if ( $monsterinsights_option ) {
667
-		$value = $monsterinsights_option;
668
-	} else {
669
-		$value = isset( $args['std'] ) ? $args['std'] : '';
670
-	}
666
+    if ( $monsterinsights_option ) {
667
+        $value = $monsterinsights_option;
668
+    } else {
669
+        $value = isset( $args['std'] ) ? $args['std'] : '';
670
+    }
671 671
 
672
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
673
-		$args['readonly'] = true;
674
-		$value = isset( $args['std'] ) ? $args['std'] : '';
675
-		$name  = '';
676
-	} else {
677
-		$name = 'name="monsterinsights_settings[' . esc_attr( $args['id'] ) . ']"';
678
-	}
672
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
673
+        $args['readonly'] = true;
674
+        $value = isset( $args['std'] ) ? $args['std'] : '';
675
+        $name  = '';
676
+    } else {
677
+        $name = 'name="monsterinsights_settings[' . esc_attr( $args['id'] ) . ']"';
678
+    }
679 679
 
680
-	$class = monsterinsights_sanitize_html_class( $args['field_class'] );
680
+    $class = monsterinsights_sanitize_html_class( $args['field_class'] );
681 681
 
682
-	$max  = isset( $args['max'] )  ? $args['max']   : 999999;
683
-	$min  = isset( $args['min'] )  ? $args['min']   : 0;
684
-	$step = isset( $args['step'] ) ? $args['step'] : 1;
682
+    $max  = isset( $args['max'] )  ? $args['max']   : 999999;
683
+    $min  = isset( $args['min'] )  ? $args['min']   : 0;
684
+    $step = isset( $args['step'] ) ? $args['step'] : 1;
685 685
 
686
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
687
-	$html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . $class . ' ' . sanitize_html_class( $size ) . '-text" id="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>';
688
-	$html .= '<p class="description"> '  . wp_kses_post( $args['desc'] ) . '</p>';
686
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
687
+    $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . $class . ' ' . sanitize_html_class( $size ) . '-text" id="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>';
688
+    $html .= '<p class="description"> '  . wp_kses_post( $args['desc'] ) . '</p>';
689 689
 
690
-	return apply_filters( 'monsterinsights_after_setting_output', $html, $args );
690
+    return apply_filters( 'monsterinsights_after_setting_output', $html, $args );
691 691
 }
692 692
 
693 693
 /**
@@ -701,20 +701,20 @@  discard block
 block discarded – undo
701 701
  * @return void
702 702
  */
703 703
 function monsterinsights_textarea_callback( $args ) {
704
-	$monsterinsights_option = monsterinsights_get_option( $args['id'] );
704
+    $monsterinsights_option = monsterinsights_get_option( $args['id'] );
705 705
 
706
-	if ( $monsterinsights_option ) {
707
-		$value = $monsterinsights_option;
708
-	} else {
709
-		$value = isset( $args['std'] ) ? $args['std'] : '';
710
-	}
706
+    if ( $monsterinsights_option ) {
707
+        $value = $monsterinsights_option;
708
+    } else {
709
+        $value = isset( $args['std'] ) ? $args['std'] : '';
710
+    }
711 711
 
712
-	$class = monsterinsights_sanitize_html_class( $args['field_class'] );
712
+    $class = monsterinsights_sanitize_html_class( $args['field_class'] );
713 713
 
714
-	$html = '<textarea class="' . $class . ' large-text" cols="50" rows="5" id="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . ']" name="monsterinsights_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
715
-	$html .= '<p class="description"> '  . wp_kses_post( $args['desc'] ) . '</p>';
714
+    $html = '<textarea class="' . $class . ' large-text" cols="50" rows="5" id="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . ']" name="monsterinsights_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
715
+    $html .= '<p class="description"> '  . wp_kses_post( $args['desc'] ) . '</p>';
716 716
 
717
-	return apply_filters( 'monsterinsights_after_setting_output', $html, $args );
717
+    return apply_filters( 'monsterinsights_after_setting_output', $html, $args );
718 718
 }
719 719
 
720 720
 
@@ -730,24 +730,24 @@  discard block
 block discarded – undo
730 730
  */
731 731
 function monsterinsights_unfiltered_textarea_callback( $args ) {
732 732
 	
733
-	if ( current_user_can( 'unfiltered_html' ) || current_user_can( 'monsterinsights_unfiltered_html' ) ) {
734
-		$monsterinsights_option = monsterinsights_get_option( $args['id'] );
733
+    if ( current_user_can( 'unfiltered_html' ) || current_user_can( 'monsterinsights_unfiltered_html' ) ) {
734
+        $monsterinsights_option = monsterinsights_get_option( $args['id'] );
735 735
 
736
-		if ( $monsterinsights_option ) {
737
-			$value = $monsterinsights_option;
738
-		} else {
739
-			$value = isset( $args['std'] ) ? $args['std'] : '';
740
-		}
736
+        if ( $monsterinsights_option ) {
737
+            $value = $monsterinsights_option;
738
+        } else {
739
+            $value = isset( $args['std'] ) ? $args['std'] : '';
740
+        }
741 741
 
742
-		$class = monsterinsights_sanitize_html_class( $args['field_class'] );
742
+        $class = monsterinsights_sanitize_html_class( $args['field_class'] );
743 743
 
744
-		$html = '<textarea class="' . $class . ' large-text" cols="50" rows="5" id="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . ']" name="monsterinsights_settings[' . esc_attr( $args['id'] ) . ']">' . stripslashes( $value ) . '</textarea>';
745
-		$html .= '<p class="description"> '  . wp_kses_post( $args['desc'] ) . '</p>';
746
-	} else {
747
-		$html .= sprintf( esc_html__( 'You must have the %s capability to view/edit this setting', 'google-analytics-for-wordpress' ), '"unfiltered_html"' );
748
-	}
744
+        $html = '<textarea class="' . $class . ' large-text" cols="50" rows="5" id="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . ']" name="monsterinsights_settings[' . esc_attr( $args['id'] ) . ']">' . stripslashes( $value ) . '</textarea>';
745
+        $html .= '<p class="description"> '  . wp_kses_post( $args['desc'] ) . '</p>';
746
+    } else {
747
+        $html .= sprintf( esc_html__( 'You must have the %s capability to view/edit this setting', 'google-analytics-for-wordpress' ), '"unfiltered_html"' );
748
+    }
749 749
 
750
-	return apply_filters( 'monsterinsights_after_setting_output', $html, $args );
750
+    return apply_filters( 'monsterinsights_after_setting_output', $html, $args );
751 751
 }
752 752
 
753 753
 /**
@@ -761,21 +761,21 @@  discard block
 block discarded – undo
761 761
  * @return void
762 762
  */
763 763
 function monsterinsights_password_callback( $args ) {
764
-	$monsterinsights_options = monsterinsights_get_option( $args['id'] );
764
+    $monsterinsights_options = monsterinsights_get_option( $args['id'] );
765 765
 
766
-	if ( $monsterinsights_options ) {
767
-		$value = $monsterinsights_options;
768
-	} else {
769
-		$value = isset( $args['std'] ) ? $args['std'] : '';
770
-	}
766
+    if ( $monsterinsights_options ) {
767
+        $value = $monsterinsights_options;
768
+    } else {
769
+        $value = isset( $args['std'] ) ? $args['std'] : '';
770
+    }
771 771
 
772
-	$class = monsterinsights_sanitize_html_class( $args['field_class'] );
772
+    $class = monsterinsights_sanitize_html_class( $args['field_class'] );
773 773
 
774
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
775
-	$html = '<input type="password" class="' . $class . ' ' . sanitize_html_class( $size ) . '-text" id="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . ']" name="monsterinsights_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
776
-	$html .= '<p class="description"> ' . wp_kses_post( $args['desc'] ) . '</p>';
774
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
775
+    $html = '<input type="password" class="' . $class . ' ' . sanitize_html_class( $size ) . '-text" id="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . ']" name="monsterinsights_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
776
+    $html .= '<p class="description"> ' . wp_kses_post( $args['desc'] ) . '</p>';
777 777
 
778
-	return apply_filters( 'monsterinsights_after_setting_output', $html, $args );
778
+    return apply_filters( 'monsterinsights_after_setting_output', $html, $args );
779 779
 }
780 780
 
781 781
 /**
@@ -789,43 +789,43 @@  discard block
 block discarded – undo
789 789
  * @return void
790 790
  */
791 791
 function monsterinsights_select_callback($args) {
792
-	$monsterinsights_option = monsterinsights_get_option( $args['id'] );
792
+    $monsterinsights_option = monsterinsights_get_option( $args['id'] );
793 793
 
794
-	if ( $monsterinsights_option ) {
795
-		$value = $monsterinsights_option;
796
-	} else {
797
-		$value = isset( $args['std'] ) ? $args['std'] : '';
798
-	}
794
+    if ( $monsterinsights_option ) {
795
+        $value = $monsterinsights_option;
796
+    } else {
797
+        $value = isset( $args['std'] ) ? $args['std'] : '';
798
+    }
799 799
 
800
-	if ( isset( $args['placeholder'] ) ) {
801
-		$placeholder = $args['placeholder'];
802
-	} else {
803
-		$placeholder = '';
804
-	}
800
+    if ( isset( $args['placeholder'] ) ) {
801
+        $placeholder = $args['placeholder'];
802
+    } else {
803
+        $placeholder = '';
804
+    }
805 805
 
806
-	$class = monsterinsights_sanitize_html_class( $args['field_class'] );
806
+    $class = monsterinsights_sanitize_html_class( $args['field_class'] );
807 807
 
808
-	if ( isset( $args['select2'] ) ) {
809
-		$class .= ' monsterinsights-select300';
810
-	}
808
+    if ( isset( $args['select2'] ) ) {
809
+        $class .= ' monsterinsights-select300';
810
+    }
811 811
 
812
-	$allowclear   = isset( $args['allowclear'] ) ? (bool) $args['allowclear'] : false;
813
-	$multiple     = isset( $args['multiple'] )   ? (bool) $args['multiple'] : false;
814
-	$multiple     = $multiple ? 'multiple="multiple"' : '';
815
-	$multiple_arg = $multiple ? '[]' : '';
812
+    $allowclear   = isset( $args['allowclear'] ) ? (bool) $args['allowclear'] : false;
813
+    $multiple     = isset( $args['multiple'] )   ? (bool) $args['multiple'] : false;
814
+    $multiple     = $multiple ? 'multiple="multiple"' : '';
815
+    $multiple_arg = $multiple ? '[]' : '';
816 816
 
817
-	$html = '<select id="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . ']" name="monsterinsights_settings[' . esc_attr( $args['id'] ) . ']' . $multiple_arg .'" class="' . $class . '" data-placeholder="' . esc_html( $placeholder ) . '" data-allow-clear="' . $allowclear . '" ' . $multiple . ' />';
817
+    $html = '<select id="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . ']" name="monsterinsights_settings[' . esc_attr( $args['id'] ) . ']' . $multiple_arg .'" class="' . $class . '" data-placeholder="' . esc_html( $placeholder ) . '" data-allow-clear="' . $allowclear . '" ' . $multiple . ' />';
818 818
 
819
-	foreach ( $args['options'] as $option => $name ) {
820
-		$selected = ! empty( $value ) && is_array( $value ) ? in_array( $option, $value ) :  $value === $option;
821
-		$selected = selected( true, $selected, false );
822
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
823
-	}
819
+    foreach ( $args['options'] as $option => $name ) {
820
+        $selected = ! empty( $value ) && is_array( $value ) ? in_array( $option, $value ) :  $value === $option;
821
+        $selected = selected( true, $selected, false );
822
+        $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
823
+    }
824 824
 
825
-	$html .= '</select>';
826
-	$html .= '<p class="description"> ' . wp_kses_post( $args['desc'] ) . '</p>';
825
+    $html .= '</select>';
826
+    $html .= '<p class="description"> ' . wp_kses_post( $args['desc'] ) . '</p>';
827 827
 
828
-	return apply_filters( 'monsterinsights_after_setting_output', $html, $args );
828
+    return apply_filters( 'monsterinsights_after_setting_output', $html, $args );
829 829
 }
830 830
 
831 831
 /**
@@ -837,29 +837,29 @@  discard block
 block discarded – undo
837 837
  * @param array $args Arguments passed by the setting
838 838
  */
839 839
 function monsterinsights_rich_editor_callback( $args ) {
840
-	$monsterinsights_option = monsterinsights_get_option( $args['id'] );
840
+    $monsterinsights_option = monsterinsights_get_option( $args['id'] );
841 841
 
842
-	if ( $monsterinsights_option ) {
843
-		$value = $monsterinsights_option;
844
-	} else {
845
-		if( ! empty( $args['allow_blank'] ) && empty( $monsterinsights_option ) ) {
846
-			$value = '';
847
-		} else {
848
-			$value = isset( $args['std'] ) ? $args['std'] : '';
849
-		}
850
-	}
842
+    if ( $monsterinsights_option ) {
843
+        $value = $monsterinsights_option;
844
+    } else {
845
+        if( ! empty( $args['allow_blank'] ) && empty( $monsterinsights_option ) ) {
846
+            $value = '';
847
+        } else {
848
+            $value = isset( $args['std'] ) ? $args['std'] : '';
849
+        }
850
+    }
851 851
 
852
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
852
+    $rows = isset( $args['size'] ) ? $args['size'] : 20;
853 853
 
854
-	$class = monsterinsights_sanitize_html_class( $args['field_class'] );
854
+    $class = monsterinsights_sanitize_html_class( $args['field_class'] );
855 855
 
856
-	ob_start();
857
-	wp_editor( stripslashes( $value ), 'monsterinsights_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'monsterinsights_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'editor_class' => $class ) );
858
-	$html = ob_get_clean();
856
+    ob_start();
857
+    wp_editor( stripslashes( $value ), 'monsterinsights_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'monsterinsights_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'editor_class' => $class ) );
858
+    $html = ob_get_clean();
859 859
 
860
-	$html .= '<br/><p class="description"> ' . wp_kses_post( $args['desc'] ) . '</p>';
860
+    $html .= '<br/><p class="description"> ' . wp_kses_post( $args['desc'] ) . '</p>';
861 861
 
862
-	return apply_filters( 'monsterinsights_after_setting_output', $html, $args );
862
+    return apply_filters( 'monsterinsights_after_setting_output', $html, $args );
863 863
 }
864 864
 
865 865
 /**
@@ -872,8 +872,8 @@  discard block
 block discarded – undo
872 872
  * @return void
873 873
  */
874 874
 function monsterinsights_descriptive_text_callback( $args ) {
875
-	$html = wp_kses_post( $args['desc'] );
876
-	return apply_filters( 'monsterinsights_after_setting_output', $html, $args );
875
+    $html = wp_kses_post( $args['desc'] );
876
+    return apply_filters( 'monsterinsights_after_setting_output', $html, $args );
877 877
 }
878 878
 
879 879
 /**
@@ -887,8 +887,8 @@  discard block
 block discarded – undo
887 887
  * @return void
888 888
  */
889 889
 function monsterinsights_notice_callback( $args ) {
890
-	$html = monsterinsights_get_message( $args['notice_type'], $args['desc'] );
891
-	return apply_filters( 'monsterinsights_after_setting_output', $html, $args );
890
+    $html = monsterinsights_get_message( $args['notice_type'], $args['desc'] );
891
+    return apply_filters( 'monsterinsights_after_setting_output', $html, $args );
892 892
 }
893 893
 
894 894
 /**
@@ -902,11 +902,11 @@  discard block
 block discarded – undo
902 902
  * @return void
903 903
  */
904 904
 function monsterinsights_upgrade_notice_callback( $args ) {
905
-	$html =   '<div class="monsterinsights-upsell-box"><h2>' . esc_html( $args['name' ] ) . '</h2>'
906
-			. '<p class="monsterinsights-upsell-lite-text">' . $args['desc'] . '</p>'
907
-			. '<p class="monsterinsights-upsell-button-par"><a href="https://www.monsterinsights.com/lite/" class="monsterinsights-upsell-box-button button button-primary">' . __( 'Click here to Upgrade', 'google-analytics-for-wordpress' ) . '</a></p>'
908
-			. '</div>';
909
-	return apply_filters( 'monsterinsights_after_setting_output', $html, $args ); 
905
+    $html =   '<div class="monsterinsights-upsell-box"><h2>' . esc_html( $args['name' ] ) . '</h2>'
906
+            . '<p class="monsterinsights-upsell-lite-text">' . $args['desc'] . '</p>'
907
+            . '<p class="monsterinsights-upsell-button-par"><a href="https://www.monsterinsights.com/lite/" class="monsterinsights-upsell-box-button button button-primary">' . __( 'Click here to Upgrade', 'google-analytics-for-wordpress' ) . '</a></p>'
908
+            . '</div>';
909
+    return apply_filters( 'monsterinsights_after_setting_output', $html, $args ); 
910 910
 }
911 911
 
912 912
 /**
@@ -919,8 +919,8 @@  discard block
 block discarded – undo
919 919
  * @return void
920 920
  */
921 921
 function monsterinsights_hook_callback( $args ) {
922
-	do_action( 'monsterinsights_' . $args['id'], $args );
923
-	return '';
922
+    do_action( 'monsterinsights_' . $args['id'], $args );
923
+    return '';
924 924
 }
925 925
 
926 926
 /**
@@ -933,10 +933,10 @@  discard block
 block discarded – undo
933 933
  * @return void
934 934
  */
935 935
 function monsterinsights_missing_callback($args) {
936
-	return sprintf(
937
-		__( 'The callback function used for the %s setting is missing.', 'google-analytics-for-wordpress' ),
938
-		'<strong>' . $args['id'] . '</strong>'
939
-	);
936
+    return sprintf(
937
+        __( 'The callback function used for the %s setting is missing.', 'google-analytics-for-wordpress' ),
938
+        '<strong>' . $args['id'] . '</strong>'
939
+    );
940 940
 }
941 941
 
942 942
 /**
@@ -949,47 +949,47 @@  discard block
 block discarded – undo
949 949
  * @return void
950 950
  */
951 951
 function monsterinsights_render_submit_field( $section, $page = 'tracking' ) {
952
-	$html = '';
953
-	$settings = monsterinsights_get_registered_settings();
954
-	if ( is_array( $settings ) && ! empty( $settings[$section] ) && is_array( $settings[$section] ) ) {
955
-		$non_setting_types = monsterinsights_get_non_setting_types();
956
-		$submit_button     = false;
957
-		foreach ( $settings[$section] as $setting ) {
958
-			if ( ! empty( $non_setting_types ) && ! empty( $setting['type'] ) && ! in_array( $setting['type'], $non_setting_types ) ) {
959
-				if ( empty( $setting['faux'] ) ) {
960
-					$submit_button = true;
961
-					break;
962
-				}
963
-			}
964
-		}
965
-		if ( $submit_button ) {
966
-			$html .= '<input type="hidden" name="monsterinsights_settings_tab" value="' . esc_attr( $page ). '"/>';
967
-			$html .= '<input type="hidden" name="monsterinsights_settings_sub_tab" value="' .  esc_attr( $section ) . '"/>';
968
-			$html .= wp_nonce_field( 'monsterinsights-settings-nonce', 'monsterinsights-settings-nonce', true, false );
969
-			$html .= get_submit_button( esc_html__( 'Save Changes', 'google-analytics-for-wordpress' ), 'primary', 'monsterinsights-settings-submit', false );
970
-		}
971
-		$html      = apply_filters( 'monsterinsights_html_after_submit_field', $html, $page, $section );
972
-	}
973
-	return $html;
952
+    $html = '';
953
+    $settings = monsterinsights_get_registered_settings();
954
+    if ( is_array( $settings ) && ! empty( $settings[$section] ) && is_array( $settings[$section] ) ) {
955
+        $non_setting_types = monsterinsights_get_non_setting_types();
956
+        $submit_button     = false;
957
+        foreach ( $settings[$section] as $setting ) {
958
+            if ( ! empty( $non_setting_types ) && ! empty( $setting['type'] ) && ! in_array( $setting['type'], $non_setting_types ) ) {
959
+                if ( empty( $setting['faux'] ) ) {
960
+                    $submit_button = true;
961
+                    break;
962
+                }
963
+            }
964
+        }
965
+        if ( $submit_button ) {
966
+            $html .= '<input type="hidden" name="monsterinsights_settings_tab" value="' . esc_attr( $page ). '"/>';
967
+            $html .= '<input type="hidden" name="monsterinsights_settings_sub_tab" value="' .  esc_attr( $section ) . '"/>';
968
+            $html .= wp_nonce_field( 'monsterinsights-settings-nonce', 'monsterinsights-settings-nonce', true, false );
969
+            $html .= get_submit_button( esc_html__( 'Save Changes', 'google-analytics-for-wordpress' ), 'primary', 'monsterinsights-settings-submit', false );
970
+        }
971
+        $html      = apply_filters( 'monsterinsights_html_after_submit_field', $html, $page, $section );
972
+    }
973
+    return $html;
974 974
 }
975 975
 
976 976
 /** 
977 977
  * @todo  docbloc
978 978
  */
979 979
 function monsterinsights_render_field( $args ) {
980
-	$output = '';
981
-	$output .='<tr id="monsterinsights-input-' . monsterinsights_sanitize_key( $args['id'] ) .'">';
982
-		if ( ! empty( $args['name'] ) && empty( $args['no_label'] ) ) {
983
-			$output .= '<th scope="row">';
984
-				$output .='<label for="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . ']">' . esc_html( $args["name"] ) . '</label>';
985
-			$output .= '</th>';
986
-		}
987
-		$output .= '<td>';
988
-			$render  = ! empty( $args['type'] ) && function_exists( 'monsterinsights_' . $args['type'] . '_callback' ) ? 'monsterinsights_' . $args['type'] . '_callback' : 'monsterinsights_missing_callback';
989
-			$output .= call_user_func( $render, $args );
990
-		$output .= '</td>';
991
-	$output .= '</tr>';
992
-	return $output;
980
+    $output = '';
981
+    $output .='<tr id="monsterinsights-input-' . monsterinsights_sanitize_key( $args['id'] ) .'">';
982
+        if ( ! empty( $args['name'] ) && empty( $args['no_label'] ) ) {
983
+            $output .= '<th scope="row">';
984
+                $output .='<label for="monsterinsights_settings[' . monsterinsights_sanitize_key( $args['id'] ) . ']">' . esc_html( $args["name"] ) . '</label>';
985
+            $output .= '</th>';
986
+        }
987
+        $output .= '<td>';
988
+            $render  = ! empty( $args['type'] ) && function_exists( 'monsterinsights_' . $args['type'] . '_callback' ) ? 'monsterinsights_' . $args['type'] . '_callback' : 'monsterinsights_missing_callback';
989
+            $output .= call_user_func( $render, $args );
990
+        $output .= '</td>';
991
+    $output .= '</tr>';
992
+    return $output;
993 993
 }
994 994
 
995 995
 /** 
@@ -997,12 +997,12 @@  discard block
 block discarded – undo
997 997
  */
998 998
 function monsterinsights_add_setting_tooltip( $html, $args ) { // @todo: enqueue tooltips
999 999
 
1000
-	if ( ! empty( $args['tooltip_title'] ) && ! empty( $args['tooltip_desc'] ) ) {
1001
-		$tooltip = '<span alt="f223" class="monsterinsights-help-tip dashicons dashicons-editor-help" title="<strong>' . $args['tooltip_title'] . '</strong>: ' . $args['tooltip_desc'] . '"></span>';
1002
-		$html .= $tooltip;
1003
-	}
1000
+    if ( ! empty( $args['tooltip_title'] ) && ! empty( $args['tooltip_desc'] ) ) {
1001
+        $tooltip = '<span alt="f223" class="monsterinsights-help-tip dashicons dashicons-editor-help" title="<strong>' . $args['tooltip_title'] . '</strong>: ' . $args['tooltip_desc'] . '"></span>';
1002
+        $html .= $tooltip;
1003
+    }
1004 1004
 
1005
-	return $html;
1005
+    return $html;
1006 1006
 }
1007 1007
 add_filter( 'monsterinsights_after_setting_output', 'monsterinsights_add_setting_tooltip', 10, 2 );
1008 1008
 
@@ -1010,48 +1010,48 @@  discard block
 block discarded – undo
1010 1010
  * @todo  docbloc
1011 1011
  */
1012 1012
 function monsterinsights_get_settings_notices( $delete_on_retrieve = true ) {
1013
-	$notices = get_transient( 'monsterinsights_settings_notices' );
1014
-	if ( $delete_on_retrieve ) {
1015
-		delete_transient( 'monsterinsights_settings_notices' );
1016
-	}
1017
-	return $notices;
1013
+    $notices = get_transient( 'monsterinsights_settings_notices' );
1014
+    if ( $delete_on_retrieve ) {
1015
+        delete_transient( 'monsterinsights_settings_notices' );
1016
+    }
1017
+    return $notices;
1018 1018
 }
1019 1019
 
1020 1020
 /** 
1021 1021
  * @todo  docbloc
1022 1022
  */
1023 1023
 function monsterinsights_add_settings_notice( $name, $type = 'success', $message = '' ) {
1024
-	$notices = get_transient( 'monsterinsights_settings_notices' );
1025
-	if ( empty( $notices ) ) {
1026
-		$notices          = array();
1027
-		$notices[ $name ] = array( "type" => $type, "message" => $message );
1028
-	} else {
1029
-		$notices[ $name ] = array( "type" => $type, "message" => $message );
1030
-	}
1031
-	set_transient( 'monsterinsights_settings_notices', $notices );
1024
+    $notices = get_transient( 'monsterinsights_settings_notices' );
1025
+    if ( empty( $notices ) ) {
1026
+        $notices          = array();
1027
+        $notices[ $name ] = array( "type" => $type, "message" => $message );
1028
+    } else {
1029
+        $notices[ $name ] = array( "type" => $type, "message" => $message );
1030
+    }
1031
+    set_transient( 'monsterinsights_settings_notices', $notices );
1032 1032
 }
1033 1033
 
1034 1034
 /** 
1035 1035
  * @todo  docbloc
1036 1036
  */
1037 1037
 function monsterinsights_remove_settings_notice( $name ) {
1038
-	$notices = get_transient( 'monsterinsights_settings_notices' );
1039
-	$found   = false;
1040
-	if ( ! empty( $notices ) ) {
1041
-		if ( isset( $notices[ $name] ) ) {
1042
-			unset( $notices[ $name] );
1043
-			set_transient( 'monsterinsights_settings_notices', $notices );
1044
-			$found = true;
1045
-		} else {
1046
-			set_transient( 'monsterinsights_settings_notices', $notices );
1047
-		}
1048
-	}
1049
-	return $found;
1038
+    $notices = get_transient( 'monsterinsights_settings_notices' );
1039
+    $found   = false;
1040
+    if ( ! empty( $notices ) ) {
1041
+        if ( isset( $notices[ $name] ) ) {
1042
+            unset( $notices[ $name] );
1043
+            set_transient( 'monsterinsights_settings_notices', $notices );
1044
+            $found = true;
1045
+        } else {
1046
+            set_transient( 'monsterinsights_settings_notices', $notices );
1047
+        }
1048
+    }
1049
+    return $found;
1050 1050
 }
1051 1051
 
1052 1052
 /** 
1053 1053
  * @todo  docbloc
1054 1054
  */
1055 1055
 function monsterinsights_get_non_setting_types(){
1056
-	return apply_filters( 'monsterinsights_non_setting_types', array(  'descriptive_text', 'hook', 'upgrade_notice', 'install_notice', 'notice' ) );
1056
+    return apply_filters( 'monsterinsights_non_setting_types', array(  'descriptive_text', 'hook', 'upgrade_notice', 'install_notice', 'notice' ) );
1057 1057
 }
1058 1058
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( !defined( 'ABSPATH' ) ) exit;
13
+if ( !defined( 'ABSPATH' ) ) {
14
+    exit;
15
+}
14 16
 
15 17
 /**
16 18
  * Get the settings for a section
Please login to merge, or discard this patch.
includes/admin/settings/tab-general.php 2 patches
Spacing   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
     exit;
15 15
 }
16 16
 
@@ -24,25 +24,25 @@  discard block
 block discarded – undo
24 24
  */
25 25
 function monsterinsights_settings_general_tab() {
26 26
     // Get settings
27
-    $manual_ua_code              = monsterinsights_get_option( 'manual_ua_code', '' );
28
-    $manual_ua_code              = esc_html( $manual_ua_code );
27
+    $manual_ua_code              = monsterinsights_get_option('manual_ua_code', '');
28
+    $manual_ua_code              = esc_html($manual_ua_code);
29 29
 
30 30
     $ua_code                     = monsterinsights_get_ua();
31 31
     $license_key_type            = '';
32 32
 
33
-    $network_license             = get_site_option( 'monsterinsights_license' );
34
-    if ( ! monsterinsights_is_network_active() || ( monsterinsights_is_network_active() && empty ( $network_license ) ) ) {
35
-        $site_license                = get_option( 'monsterinsights_license' );
36
-        $license_key                 = ! empty( $site_license['key'] ) ? esc_attr( $site_license['key'] ) : '';
37
-        $license_key_type            = ! empty( $site_license['type'] ) ? esc_html( $site_license['type'] ) : '';
33
+    $network_license             = get_site_option('monsterinsights_license');
34
+    if ( ! monsterinsights_is_network_active() || (monsterinsights_is_network_active() && empty ($network_license))) {
35
+        $site_license                = get_option('monsterinsights_license');
36
+        $license_key                 = ! empty($site_license['key']) ? esc_attr($site_license['key']) : '';
37
+        $license_key_type            = ! empty($site_license['type']) ? esc_html($site_license['type']) : '';
38 38
     }
39 39
 
40
-    $profile_name                = monsterinsights_get_option( 'analytics_profile_name', '' );
41
-    $profile_id                  = monsterinsights_get_option( 'analytics_profile', '' );
42
-    $tracking_mode               = monsterinsights_get_option( 'tracking_mode', 'analytics' );
43
-    $events_mode                 = monsterinsights_get_option( 'events_mode', 'js' );
44
-    $automatic_updates           = monsterinsights_get_option( 'automatic_updates', false );
45
-    $anon_tracking               = monsterinsights_get_option( 'anonymous_data', false );
40
+    $profile_name                = monsterinsights_get_option('analytics_profile_name', '');
41
+    $profile_id                  = monsterinsights_get_option('analytics_profile', '');
42
+    $tracking_mode               = monsterinsights_get_option('tracking_mode', 'analytics');
43
+    $events_mode                 = monsterinsights_get_option('events_mode', 'js');
44
+    $automatic_updates           = monsterinsights_get_option('automatic_updates', false);
45
+    $anon_tracking               = monsterinsights_get_option('anonymous_data', false);
46 46
     ?>
47 47
     <div id="monsterinsights-settings-general">
48 48
         <div class="monsterinsights-tab-settings-notices">
@@ -55,38 +55,38 @@  discard block
 block discarded – undo
55 55
          * not be used by other developers. This hook's behavior may be modified
56 56
          * or the hook may be removed at any time, without warning.
57 57
          */
58
-        do_action( 'monsterinsights_settings_general_tab_notice' );
58
+        do_action('monsterinsights_settings_general_tab_notice');
59 59
         ?>
60 60
         </div>
61 61
         <table class="form-table">
62 62
             <tbody>
63
-                <?php if ( ( ! monsterinsights_is_network_active() || ( monsterinsights_is_network_active() && empty ( $network_license ) ) ) && monsterinsights_is_pro_version() ) { ?>
63
+                <?php if (( ! monsterinsights_is_network_active() || (monsterinsights_is_network_active() && empty ($network_license))) && monsterinsights_is_pro_version()) { ?>
64 64
                     <tr id="monsterinsights-settings-key-box">
65 65
                         <th scope="row">
66
-                            <label for="monsterinsights-settings-key"><?php esc_html_e( 'License Key', 'google-analytics-for-wordpress' ); ?></label>
66
+                            <label for="monsterinsights-settings-key"><?php esc_html_e('License Key', 'google-analytics-for-wordpress'); ?></label>
67 67
                         </th>
68 68
                         <td>
69 69
                             <form id="monsterinsights-settings-verify-key" method="post">
70 70
                                 <input type="password" name="monsterinsights-license-key" id="monsterinsights-settings-key" value="<?php echo $license_key; ?>" />
71
-                                <?php wp_nonce_field( 'monsterinsights-key-nonce', 'monsterinsights-key-nonce' ); ?>
72
-                                <?php submit_button( esc_html__( 'Verify Key', 'google-analytics-for-wordpress' ), 'button-action', 'monsterinsights-verify-submit', false ); ?>
73
-                                <?php submit_button( esc_html__( 'Deactivate Key', 'google-analytics-for-wordpress' ), 'button-danger', 'monsterinsights-deactivate-submit', false ); ?>
74
-                                <p class="description"><?php esc_html_e( 'License key to enable automatic updates for MonsterInsights Pro & addons. Deactivate your license if you want to use it on another WordPress site.', 'google-analytics-for-wordpress' ); ?></p>
71
+                                <?php wp_nonce_field('monsterinsights-key-nonce', 'monsterinsights-key-nonce'); ?>
72
+                                <?php submit_button(esc_html__('Verify Key', 'google-analytics-for-wordpress'), 'button-action', 'monsterinsights-verify-submit', false); ?>
73
+                                <?php submit_button(esc_html__('Deactivate Key', 'google-analytics-for-wordpress'), 'button-danger', 'monsterinsights-deactivate-submit', false); ?>
74
+                                <p class="description"><?php esc_html_e('License key to enable automatic updates for MonsterInsights Pro & addons. Deactivate your license if you want to use it on another WordPress site.', 'google-analytics-for-wordpress'); ?></p>
75 75
                             </form>
76 76
                         </td>
77 77
                     </tr>
78
-                    <?php if ( ! empty( $license_key_type ) && monsterinsights_is_pro_version() ) : ?>
78
+                    <?php if ( ! empty($license_key_type) && monsterinsights_is_pro_version()) : ?>
79 79
                     <tr id="monsterinsights-settings-key-type-box">
80 80
                         <th scope="row">
81
-                            <label for="monsterinsights-settings-key-type"><?php esc_html_e( 'License Key Type', 'google-analytics-for-wordpress' ); ?></label>
81
+                            <label for="monsterinsights-settings-key-type"><?php esc_html_e('License Key Type', 'google-analytics-for-wordpress'); ?></label>
82 82
                         </th>
83 83
                         <td>
84 84
                             <form id="monsterinsights-settings-key-type" method="post">
85
-                                <span class="monsterinsights-license-type"><?php printf( esc_html__( 'Your license key type for this site is %s.', 'google-analytics-for-wordpress' ), '<strong>' . $license_key_type . '</strong>' ); ?>
85
+                                <span class="monsterinsights-license-type"><?php printf(esc_html__('Your license key type for this site is %s.', 'google-analytics-for-wordpress'), '<strong>' . $license_key_type . '</strong>'); ?>
86 86
                                 <input type="hidden" name="monsterinsights-license-key" value="<?php echo $license_key; ?>" />
87
-                                <?php wp_nonce_field( 'monsterinsights-key-nonce', 'monsterinsights-key-nonce' ); ?>
88
-                                <?php submit_button( esc_html__( 'Refresh Key', 'google-analytics-for-wordpress' ), 'button-action', 'monsterinsights-refresh-submit', false ); ?>
89
-                                <p class="description"><?php esc_html_e( 'Your license key type (handles updates and Addons). Click refresh if your license has been upgraded or the type is incorrect.', 'google-analytics-for-wordpress' ); ?></p>
87
+                                <?php wp_nonce_field('monsterinsights-key-nonce', 'monsterinsights-key-nonce'); ?>
88
+                                <?php submit_button(esc_html__('Refresh Key', 'google-analytics-for-wordpress'), 'button-action', 'monsterinsights-refresh-submit', false); ?>
89
+                                <p class="description"><?php esc_html_e('Your license key type (handles updates and Addons). Click refresh if your license has been upgraded or the type is incorrect.', 'google-analytics-for-wordpress'); ?></p>
90 90
                             </form>
91 91
                         </td>
92 92
                     </tr>
@@ -95,23 +95,23 @@  discard block
 block discarded – undo
95 95
 
96 96
                 <tr id="monsterinsights-google-authenticate-box">
97 97
                     <th scope="row">
98
-                        <?php if ( $profile_name && $ua_code ) { ?>
99
-                            <label for="monsterinsights-google-authenticate"><?php esc_html_e( 'Analytics Profile', 'google-analytics-for-wordpress' ); ?></label>
98
+                        <?php if ($profile_name && $ua_code) { ?>
99
+                            <label for="monsterinsights-google-authenticate"><?php esc_html_e('Analytics Profile', 'google-analytics-for-wordpress'); ?></label>
100 100
                         <?php } else { ?>
101
-                            <label for="monsterinsights-google-authenticate"><?php esc_html_e( 'Google Authentication', 'google-analytics-for-wordpress' ); ?></label>
101
+                            <label for="monsterinsights-google-authenticate"><?php esc_html_e('Google Authentication', 'google-analytics-for-wordpress'); ?></label>
102 102
                         <?php } ?>
103 103
                     </th>
104 104
                     <td>
105 105
                         <form id="monsterinsights-google-authenticate" method="post">
106
-                            <?php if ( $profile_name && $ua_code ) { ?>
107
-                                <p><?php echo esc_html__( 'Profile Active: ', 'google-analytics-for-wordpress' ) . $profile_name; ?></p>
108
-                                <p><?php wp_nonce_field( 'monsterinsights-google-authenticated-nonce', 'monsterinsights-google-authenticated-nonce' ); ?>
109
-                                <?php submit_button( esc_html__( 'Re-Authenticate with your Google account', 'google-analytics-for-wordpress' ), 'button-action', 'monsterinsights-google-reauthenticate-submit', false ); ?>
110
-                                <?php submit_button( esc_html__( 'Deauthenticate', 'google-analytics-for-wordpress' ), 'button-danger', 'monsterinsights-google-deauthenticate-submit', false ); ?></p>
106
+                            <?php if ($profile_name && $ua_code) { ?>
107
+                                <p><?php echo esc_html__('Profile Active: ', 'google-analytics-for-wordpress') . $profile_name; ?></p>
108
+                                <p><?php wp_nonce_field('monsterinsights-google-authenticated-nonce', 'monsterinsights-google-authenticated-nonce'); ?>
109
+                                <?php submit_button(esc_html__('Re-Authenticate with your Google account', 'google-analytics-for-wordpress'), 'button-action', 'monsterinsights-google-reauthenticate-submit', false); ?>
110
+                                <?php submit_button(esc_html__('Deauthenticate', 'google-analytics-for-wordpress'), 'button-danger', 'monsterinsights-google-deauthenticate-submit', false); ?></p>
111 111
                             <?php } else { ?>
112
-                                <?php wp_nonce_field( 'monsterinsights-google-authenticate-nonce', 'monsterinsights-google-authenticate-nonce' ); ?>
113
-                                <?php submit_button( esc_html__( 'Authenticate with your Google account', 'google-analytics-for-wordpress' ), 'button-action', 'monsterinsights-google-authenticate-submit', false ); ?>
114
-                                <p class="description"><?php printf( esc_html__( 'Having issues automatically authenticating? %s Click here to authenticate manually %s.', 'google-analytics-for-wordpress' ), '<a href="javascript:monsterinsights_show_manual()" data-action="show-manual-ua-box">', '</a>' ); ?></p>
112
+                                <?php wp_nonce_field('monsterinsights-google-authenticate-nonce', 'monsterinsights-google-authenticate-nonce'); ?>
113
+                                <?php submit_button(esc_html__('Authenticate with your Google account', 'google-analytics-for-wordpress'), 'button-action', 'monsterinsights-google-authenticate-submit', false); ?>
114
+                                <p class="description"><?php printf(esc_html__('Having issues automatically authenticating? %s Click here to authenticate manually %s.', 'google-analytics-for-wordpress'), '<a href="javascript:monsterinsights_show_manual()" data-action="show-manual-ua-box">', '</a>'); ?></p>
115 115
                             <?php } ?>
116 116
                         </form>
117 117
                     </td>
@@ -125,80 +125,80 @@  discard block
 block discarded – undo
125 125
         <form id="monsterinsights-general-tab" method="post">
126 126
             <table class="form-table">
127 127
                 <tbody>
128
-                    <?php if ( ! $profile_name ) { ?>
128
+                    <?php if ( ! $profile_name) { ?>
129 129
                     <!-- Manual UA -->
130 130
                     <tr id="monsterinsights-google-ua-box" <?php echo ( ! $ua_code ? 'class="monsterinsights-hideme"' : ''); ?> >
131 131
                         <th scope="row">
132
-                            <label for="monsterinsights-google-ua"><?php esc_html_e( 'Manually enter your UA code', 'google-analytics-for-wordpress' ); ?></label>
132
+                            <label for="monsterinsights-google-ua"><?php esc_html_e('Manually enter your UA code', 'google-analytics-for-wordpress'); ?></label>
133 133
                         </th>
134 134
                         <td>
135 135
                             <input type="text" id="monsterinsights-google-ua" name="manual_ua_code" value="<?php echo $manual_ua_code; ?>" />
136
-                            <p class="description"><?php esc_html_e( 'Warning: If you use a manual UA code, you won\'t be able to use the dashboard or reports.', 'google-analytics-for-wordpress' ); ?></p>
136
+                            <p class="description"><?php esc_html_e('Warning: If you use a manual UA code, you won\'t be able to use the dashboard or reports.', 'google-analytics-for-wordpress'); ?></p>
137 137
                         </td>
138 138
                     </tr>
139 139
                     <?php } ?>
140 140
 
141 141
                     <!-- Disable Dashboard -->
142 142
                     <?php
143
-                    $title       = esc_html__( 'Disable Dashboard', 'google-analytics-for-wordpress' );
144
-                    $description = esc_html__( 'Hide the dashboard and reports pages.', 'google-analytics-for-wordpress' );
145
-                    echo monsterinsights_make_checkbox( 'dashboards_disabled', $title, $description );
143
+                    $title       = esc_html__('Disable Dashboard', 'google-analytics-for-wordpress');
144
+                    $description = esc_html__('Hide the dashboard and reports pages.', 'google-analytics-for-wordpress');
145
+                    echo monsterinsights_make_checkbox('dashboards_disabled', $title, $description);
146 146
                     ?>
147 147
 
148
-                    <?php if ( $tracking_mode === 'ga' || monsterinsights_is_debug_mode() ){  ?>
148
+                    <?php if ($tracking_mode === 'ga' || monsterinsights_is_debug_mode()) {  ?>
149 149
                     <tr id="monsterinsights-tracking-mode">
150 150
                         <th scope="row">
151
-                            <label for="monsterinsights-tracking-mode"><?php esc_html_e( 'Pick Tracking Mode', 'google-analytics-for-wordpress' ); ?></label>
151
+                            <label for="monsterinsights-tracking-mode"><?php esc_html_e('Pick Tracking Mode', 'google-analytics-for-wordpress'); ?></label>
152 152
                         </th>
153 153
                         <td>
154 154
                             <?php
155
-                            $url = esc_url( wp_nonce_url( add_query_arg( array( 'monsterinsights-action' => 'switch_to_analyticsjs', 'return' => 'general' ) ), 'monsterinsights-switch-to-analyticsjs-nonce' ) );
155
+                            $url = esc_url(wp_nonce_url(add_query_arg(array('monsterinsights-action' => 'switch_to_analyticsjs', 'return' => 'general')), 'monsterinsights-switch-to-analyticsjs-nonce'));
156 156
                             ?>
157
-                            <label><input type="radio" name="tracking_mode" value="ga" <?php checked( $tracking_mode, 'ga' ); ?> ><?php esc_html_e('GA.js (Deprecated)', 'google-analytics-for-wordpress'); ?> </label>
158
-                            <label><input type="radio" name="tracking_mode" value="analytics" <?php checked( $tracking_mode, 'analytics' ); ?> ><?php esc_html_e( 'Analytics.js (Universal Analytics)', 'google-analytics-for-wordpress'); ?> </label>
159
-                            <?php if ($tracking_mode === 'ga' ) { ?>
160
-                            <?php echo monsterinsights_get_message( 'error', sprintf( esc_html__( 'Warning: You\'re currently using deprecated ga.js tracking. 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.', 'google-analytics-for-wordpress' ), '<a href="' . $url .'">', '</a>' ) );
157
+                            <label><input type="radio" name="tracking_mode" value="ga" <?php checked($tracking_mode, 'ga'); ?> ><?php esc_html_e('GA.js (Deprecated)', 'google-analytics-for-wordpress'); ?> </label>
158
+                            <label><input type="radio" name="tracking_mode" value="analytics" <?php checked($tracking_mode, 'analytics'); ?> ><?php esc_html_e('Analytics.js (Universal Analytics)', 'google-analytics-for-wordpress'); ?> </label>
159
+                            <?php if ($tracking_mode === 'ga') { ?>
160
+                            <?php echo monsterinsights_get_message('error', sprintf(esc_html__('Warning: You\'re currently using deprecated ga.js tracking. 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.', 'google-analytics-for-wordpress'), '<a href="' . $url . '">', '</a>'));
161 161
                             ?>
162 162
                             <?php } ?>
163 163
                         </td>
164 164
                     </tr>
165 165
                     <?php } ?>
166 166
 
167
-                    <?php if ( $tracking_mode !== 'ga' && $events_mode === 'php' ){  ?>
167
+                    <?php if ($tracking_mode !== 'ga' && $events_mode === 'php') {  ?>
168 168
                     <tr id="monsterinsights-tracking-mode">
169 169
                         <th scope="row">
170
-                            <label for="monsterinsights-tracking-mode"><?php esc_html_e( 'Switch to JS events tracking', 'google-analytics-for-wordpress' ); ?></label>
170
+                            <label for="monsterinsights-tracking-mode"><?php esc_html_e('Switch to JS events tracking', 'google-analytics-for-wordpress'); ?></label>
171 171
                         </th>
172 172
                         <td>
173 173
                             <?php
174
-                            $url = esc_url( wp_nonce_url( add_query_arg( array( 'monsterinsights-action' => 'switch_to_jsevents', 'return' => 'general' ) ), 'monsterinsights-switch-to-jsevents-nonce' ) );
174
+                            $url = esc_url(wp_nonce_url(add_query_arg(array('monsterinsights-action' => 'switch_to_jsevents', 'return' => 'general')), 'monsterinsights-switch-to-jsevents-nonce'));
175 175
                             ?>
176
-                            <?php echo monsterinsights_get_message( 'error', sprintf( esc_html__( 'Warning: You\'re currently using deprecated PHP based events tracking. We recommend switching to JS events tracking, as it is significantly more accurate than PHP based events tracking and we will eventually discontinue PHP based events tracking. To switch %1$sclick here%2$s.', 'google-analytics-for-wordpress' ), '<a href="' . $url .'">', '</a>' ) );
176
+                            <?php echo monsterinsights_get_message('error', sprintf(esc_html__('Warning: You\'re currently using deprecated PHP based events tracking. We recommend switching to JS events tracking, as it is significantly more accurate than PHP based events tracking and we will eventually discontinue PHP based events tracking. To switch %1$sclick here%2$s.', 'google-analytics-for-wordpress'), '<a href="' . $url . '">', '</a>'));
177 177
                          ?>
178 178
                         </td>
179 179
                     </tr>
180 180
                     <?php } ?>
181 181
 
182
-                    <?php if ( $automatic_updates !== 'all' && $automatic_updates !== 'minor' ){  ?>
182
+                    <?php if ($automatic_updates !== 'all' && $automatic_updates !== 'minor') {  ?>
183 183
                     <?php $automatic_updates = $automatic_updates ? $automatic_updates : 'none'; ?>
184 184
                     <tr id="monsterinsights-automatic-updates-mode">
185 185
                         <th scope="row">
186
-                            <label for="monsterinsights-tracking-mode"><?php esc_html_e( 'Automatic Updates', 'google-analytics-for-wordpress' ); ?></label>
186
+                            <label for="monsterinsights-tracking-mode"><?php esc_html_e('Automatic Updates', 'google-analytics-for-wordpress'); ?></label>
187 187
                         </th>
188 188
                         <td>
189
-                            <label><input type="radio" name="automatic_updates" value="all" <?php checked( $automatic_updates, 'all' ); ?> ><?php esc_html_e('Yes (Recommended) - Get the latest features, bugfixes, and security updates as they are released.', 'google-analytics-for-wordpress'); ?> </label>
190
-                            <label><input type="radio" name="automatic_updates" value="minor" <?php checked( $automatic_updates, 'minor' ); ?> ><?php esc_html_e( 'Minor Only - Only get bugfixes and security updates, but not major features.', 'google-analytics-for-wordpress'); ?> </label>
191
-                            <label><input type="radio" name="automatic_updates" value="none" <?php checked( $automatic_updates, 'none' ); ?> ><?php esc_html_e( 'None - Manually update everything.', 'google-analytics-for-wordpress'); ?> </label>
189
+                            <label><input type="radio" name="automatic_updates" value="all" <?php checked($automatic_updates, 'all'); ?> ><?php esc_html_e('Yes (Recommended) - Get the latest features, bugfixes, and security updates as they are released.', 'google-analytics-for-wordpress'); ?> </label>
190
+                            <label><input type="radio" name="automatic_updates" value="minor" <?php checked($automatic_updates, 'minor'); ?> ><?php esc_html_e('Minor Only - Only get bugfixes and security updates, but not major features.', 'google-analytics-for-wordpress'); ?> </label>
191
+                            <label><input type="radio" name="automatic_updates" value="none" <?php checked($automatic_updates, 'none'); ?> ><?php esc_html_e('None - Manually update everything.', 'google-analytics-for-wordpress'); ?> </label>
192 192
                         </td>
193 193
                     </tr>
194 194
                     <?php } ?>
195 195
 
196 196
                     <!-- Tracking -->
197 197
                     <?php
198
-                    $title       = esc_html__( 'Allow Usage Tracking', 'google-analytics-for-wordpress' );
199
-                    $description = esc_html__( 'By allowing us to track usage data we can better help you, because we know with which WordPress configurations, themes and plugins we should test.', 'google-analytics-for-wordpress' );
200
-                    if ( ! $anon_tracking || monsterinsights_is_debug_mode() ){
201
-                        echo monsterinsights_make_checkbox( 'anonymous_data', $title, $description );
198
+                    $title       = esc_html__('Allow Usage Tracking', 'google-analytics-for-wordpress');
199
+                    $description = esc_html__('By allowing us to track usage data we can better help you, because we know with which WordPress configurations, themes and plugins we should test.', 'google-analytics-for-wordpress');
200
+                    if ( ! $anon_tracking || monsterinsights_is_debug_mode()) {
201
+                        echo monsterinsights_make_checkbox('anonymous_data', $title, $description);
202 202
                     }
203 203
                     ?>
204 204
 
@@ -210,18 +210,18 @@  discard block
 block discarded – undo
210 210
                      * not be used by other developers. This hook's behavior may be modified
211 211
                      * or the hook may be removed at any time, without warning.
212 212
                      */
213
-                    do_action( 'monsterinsights_settings_general_box' ); 
213
+                    do_action('monsterinsights_settings_general_box'); 
214 214
                     ?>
215 215
                 </tbody>
216 216
             </table>
217 217
             <input type="hidden" name="monsterinsights_settings_tab" value="general"/>
218
-            <?php wp_nonce_field( 'monsterinsights-settings-nonce', 'monsterinsights-settings-nonce' ); ?>
219
-            <?php submit_button( esc_html__( 'Save Changes', 'google-analytics-for-wordpress' ), 'primary', 'monsterinsights-settings-submit', false ); ?>
218
+            <?php wp_nonce_field('monsterinsights-settings-nonce', 'monsterinsights-settings-nonce'); ?>
219
+            <?php submit_button(esc_html__('Save Changes', 'google-analytics-for-wordpress'), 'primary', 'monsterinsights-settings-submit', false); ?>
220 220
         </form>
221 221
     </div>
222 222
     <?php
223 223
 }
224
-add_action( 'monsterinsights_tab_settings_general', 'monsterinsights_settings_general_tab' );
224
+add_action('monsterinsights_tab_settings_general', 'monsterinsights_settings_general_tab');
225 225
 
226 226
 /**
227 227
  * Callback for saving the general settings tab.
@@ -232,27 +232,27 @@  discard block
 block discarded – undo
232 232
  * @return void
233 233
  */
234 234
 function monsterinsights_settings_save_general() {
235
-    $throw_notice    = false;
236
-    $manual_ua_code = isset( $_POST['manual_ua_code'] ) ? $_POST['manual_ua_code'] : '';
237
-    $manual_ua_code = monsterinsights_is_valid_ua( $manual_ua_code ); // also sanitizes the string
235
+    $throw_notice = false;
236
+    $manual_ua_code = isset($_POST['manual_ua_code']) ? $_POST['manual_ua_code'] : '';
237
+    $manual_ua_code = monsterinsights_is_valid_ua($manual_ua_code); // also sanitizes the string
238 238
     
239
-    if ( $manual_ua_code ) {
240
-        monsterinsights_update_option( 'manual_ua_code', $manual_ua_code );
239
+    if ($manual_ua_code) {
240
+        monsterinsights_update_option('manual_ua_code', $manual_ua_code);
241 241
     } else {
242
-        if ( empty ( $manual_ua_code ) && ! empty( $_POST['manual_ua_code'] ) ) {
242
+        if (empty ($manual_ua_code) && ! empty($_POST['manual_ua_code'])) {
243 243
              $throw_notice = true;
244 244
         }
245
-        monsterinsights_update_option( 'manual_ua_code', '' );
245
+        monsterinsights_update_option('manual_ua_code', '');
246 246
     }
247 247
 
248
-    $dashboards_disabled = isset( $_POST['dashboards_disabled'] ) ? 1 : 0;
249
-    monsterinsights_update_option( 'dashboards_disabled', $dashboards_disabled );
248
+    $dashboards_disabled = isset($_POST['dashboards_disabled']) ? 1 : 0;
249
+    monsterinsights_update_option('dashboards_disabled', $dashboards_disabled);
250 250
 
251
-    $old_tracking_mode = monsterinsights_get_option( 'tracking_mode', 'analytics' );
252
-    $tracking_mode     = isset( $_POST['tracking_mode'] ) ? $_POST['tracking_mode'] : 'analytics';
251
+    $old_tracking_mode = monsterinsights_get_option('tracking_mode', 'analytics');
252
+    $tracking_mode     = isset($_POST['tracking_mode']) ? $_POST['tracking_mode'] : 'analytics';
253 253
 
254
-    if ( $old_tracking_mode === 'ga' || monsterinsights_is_debug_mode() ) {
255
-        if ( $tracking_mode !== 'analytics' && $tracking_mode !== 'ga' ) {
254
+    if ($old_tracking_mode === 'ga' || monsterinsights_is_debug_mode()) {
255
+        if ($tracking_mode !== 'analytics' && $tracking_mode !== 'ga') {
256 256
             /** 
257 257
              * Developer Alert:
258 258
              *
@@ -260,11 +260,11 @@  discard block
 block discarded – undo
260 260
              * not be used by other developers. This hook's behavior may be modified
261 261
              * or the hook may be removed at any time, without warning.
262 262
              */
263
-            $tracking_mode = apply_filters( 'monsterinsights_settings_save_general_tracking_mode', 'analytics' );
263
+            $tracking_mode = apply_filters('monsterinsights_settings_save_general_tracking_mode', 'analytics');
264 264
         }
265
-        monsterinsights_update_option( 'tracking_mode', $tracking_mode );
265
+        monsterinsights_update_option('tracking_mode', $tracking_mode);
266 266
     } else {
267
-        if ( $tracking_mode !== 'analytics' ) {
267
+        if ($tracking_mode !== 'analytics') {
268 268
             /** 
269 269
              * Developer Alert:
270 270
              *
@@ -272,19 +272,19 @@  discard block
 block discarded – undo
272 272
              * not be used by other developers. This hook's behavior may be modified
273 273
              * or the hook may be removed at any time, without warning.
274 274
              */
275
-            $tracking_mode = apply_filters( 'monsterinsights_settings_save_general_tracking_mode', 'analytics' );
275
+            $tracking_mode = apply_filters('monsterinsights_settings_save_general_tracking_mode', 'analytics');
276 276
         }
277
-        monsterinsights_update_option( 'tracking_mode', $tracking_mode );
277
+        monsterinsights_update_option('tracking_mode', $tracking_mode);
278 278
     }
279 279
 
280
-    $automatic_updates = isset( $_POST['automatic_updates'] ) && in_array( $_POST['automatic_updates'], array( 'all', 'minor', 'none' ) ) ? $_POST['automatic_updates'] : false;
281
-    if ( $automatic_updates ) {
282
-        monsterinsights_update_option( 'automatic_updates', $automatic_updates );
280
+    $automatic_updates = isset($_POST['automatic_updates']) && in_array($_POST['automatic_updates'], array('all', 'minor', 'none')) ? $_POST['automatic_updates'] : false;
281
+    if ($automatic_updates) {
282
+        monsterinsights_update_option('automatic_updates', $automatic_updates);
283 283
     }
284 284
 
285
-    $anonymous_data = isset( $_POST['anonymous_data'] ) ? 1 : 0;
286
-    if ( $anonymous_data ) {
287
-        monsterinsights_update_option( 'anonymous_data', $anonymous_data );
285
+    $anonymous_data = isset($_POST['anonymous_data']) ? 1 : 0;
286
+    if ($anonymous_data) {
287
+        monsterinsights_update_option('anonymous_data', $anonymous_data);
288 288
     }
289 289
 
290 290
     /** 
@@ -294,13 +294,13 @@  discard block
 block discarded – undo
294 294
      * not be used by other developers. This hook's behavior may be modified
295 295
      * or the hook may be removed at any time, without warning.
296 296
      */
297
-    do_action( 'monsterinsights_settings_save_general_end' );
297
+    do_action('monsterinsights_settings_save_general_end');
298 298
 
299 299
     // Output an admin notice so the user knows what happened
300
-    if ( $throw_notice ) {
301
-        add_action( 'monsterinsights_settings_general_tab_notice', 'monsterinsights_invalid_ua_code' );
300
+    if ($throw_notice) {
301
+        add_action('monsterinsights_settings_general_tab_notice', 'monsterinsights_invalid_ua_code');
302 302
     } else {
303
-        add_action( 'monsterinsights_settings_general_tab_notice', 'monsterinsights_updated_settings' );
303
+        add_action('monsterinsights_settings_general_tab_notice', 'monsterinsights_updated_settings');
304 304
     }
305 305
 }
306
-add_action( 'monsterinsights_settings_save_general', 'monsterinsights_settings_save_general', 11 );
307 306
\ No newline at end of file
307
+add_action('monsterinsights_settings_save_general', 'monsterinsights_settings_save_general', 11);
308 308
\ No newline at end of file
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
                             $url = esc_url( wp_nonce_url( add_query_arg( array( 'monsterinsights-action' => 'switch_to_jsevents', 'return' => 'general' ) ), 'monsterinsights-switch-to-jsevents-nonce' ) );
175 175
                             ?>
176 176
                             <?php echo monsterinsights_get_message( 'error', sprintf( esc_html__( 'Warning: You\'re currently using deprecated PHP based events tracking. We recommend switching to JS events tracking, as it is significantly more accurate than PHP based events tracking and we will eventually discontinue PHP based events tracking. To switch %1$sclick here%2$s.', 'google-analytics-for-wordpress' ), '<a href="' . $url .'">', '</a>' ) );
177
-                         ?>
177
+                            ?>
178 178
                         </td>
179 179
                     </tr>
180 180
                     <?php } ?>
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
         monsterinsights_update_option( 'manual_ua_code', $manual_ua_code );
241 241
     } else {
242 242
         if ( empty ( $manual_ua_code ) && ! empty( $_POST['manual_ua_code'] ) ) {
243
-             $throw_notice = true;
243
+                $throw_notice = true;
244 244
         }
245 245
         monsterinsights_update_option( 'manual_ua_code', '' );
246 246
     }
Please login to merge, or discard this patch.
includes/admin/settings/register-settings.php 2 patches
Spacing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -20,93 +20,93 @@  discard block
 block discarded – undo
20 20
 	// coming soon = true (don't count on this)
21 21
 	$tabs = array(
22 22
 		'engagement' => array( 
23
-			'title' => esc_html__( 'Engagement', 'google-analytics-for-wordpress' ),
23
+			'title' => esc_html__('Engagement', 'google-analytics-for-wordpress'),
24 24
 			'level' => 'lite'
25 25
 		),
26 26
 		'demographics' => array( 
27
-			'title' => esc_html__( 'Demographics', 'google-analytics-for-wordpress' ),
27
+			'title' => esc_html__('Demographics', 'google-analytics-for-wordpress'),
28 28
 			'level' => 'lite'
29 29
 		),
30 30
 		'links' => array( 
31
-			'title' => esc_html__( 'Link Attribution', 'google-analytics-for-wordpress' ),
31
+			'title' => esc_html__('Link Attribution', 'google-analytics-for-wordpress'),
32 32
 			'level' => 'lite'
33 33
 		),
34 34
 		'files' => array( 
35
-			'title' => esc_html__( 'File Downloads', 'google-analytics-for-wordpress' ),
35
+			'title' => esc_html__('File Downloads', 'google-analytics-for-wordpress'),
36 36
 			'level' => 'lite'
37 37
 		),  
38 38
 		'affiliates' => array( 
39
-			'title' => esc_html__( 'Affiliate Links', 'google-analytics-for-wordpress' ),
39
+			'title' => esc_html__('Affiliate Links', 'google-analytics-for-wordpress'),
40 40
 			'level' => 'lite'
41 41
 		),  
42 42
 		'social' => array( 
43
-			'title' => esc_html__( 'Social', 'google-analytics-for-wordpress' ),
43
+			'title' => esc_html__('Social', 'google-analytics-for-wordpress'),
44 44
 			'level' => 'basic',
45 45
 			'comingsoon' => true
46 46
 		),
47 47
 		'ads' => array( 
48
-			'title' => esc_html__( 'Ads', 'google-analytics-for-wordpress' ),
48
+			'title' => esc_html__('Ads', 'google-analytics-for-wordpress'),
49 49
 			'level' => 'plus',
50 50
 		),
51 51
 		'forms' => array( 
52
-			'title' => esc_html__( 'Forms', 'google-analytics-for-wordpress' ),
52
+			'title' => esc_html__('Forms', 'google-analytics-for-wordpress'),
53 53
 			'level' => 'pro',
54 54
 		),
55 55
 		'ecommerce' => array( 
56
-			'title' => esc_html__( 'eCommerce', 'google-analytics-for-wordpress' ),
56
+			'title' => esc_html__('eCommerce', 'google-analytics-for-wordpress'),
57 57
 			'level' => 'pro'
58 58
 		),
59 59
 		'media' => array( 
60
-			'title' => esc_html__( 'Media', 'google-analytics-for-wordpress' ),
60
+			'title' => esc_html__('Media', 'google-analytics-for-wordpress'),
61 61
 			'level' => 'plus',
62 62
 			'comingsoon' => true
63 63
 		),
64 64
 		'memberships' => array( 
65
-			'title' => esc_html__( 'Memberships', 'google-analytics-for-wordpress' ),
65
+			'title' => esc_html__('Memberships', 'google-analytics-for-wordpress'),
66 66
 			'level' => 'plus',
67 67
 			'comingsoon' => true
68 68
 		),
69 69
 		'dimensions' => array( 
70
-			'title' => esc_html__( 'Custom Dimensions', 'google-analytics-for-wordpress' ),
70
+			'title' => esc_html__('Custom Dimensions', 'google-analytics-for-wordpress'),
71 71
 			'level' => 'pro',
72 72
 		),
73 73
 		'performance' => array( 
74
-			'title' => esc_html__( 'Performance', 'google-analytics-for-wordpress' ),
74
+			'title' => esc_html__('Performance', 'google-analytics-for-wordpress'),
75 75
 			'level' => 'plus'
76 76
 		),
77 77
 		'amp' => array( 
78
-			'title' => esc_html__( 'Google AMP', 'google-analytics-for-wordpress' ),
78
+			'title' => esc_html__('Google AMP', 'google-analytics-for-wordpress'),
79 79
 			'level' => 'plus'
80 80
 		),
81 81
 		'goptimize' => array( 
82
-			'title' => esc_html__( 'Google Optimize', 'google-analytics-for-wordpress' ),
82
+			'title' => esc_html__('Google Optimize', 'google-analytics-for-wordpress'),
83 83
 			'level' => 'pro'
84 84
 		),
85 85
 		'fbia' => array( 
86
-			'title' => esc_html__( 'FB Instant Articles', 'google-analytics-for-wordpress' ),
86
+			'title' => esc_html__('FB Instant Articles', 'google-analytics-for-wordpress'),
87 87
 			'level' => 'plus'
88 88
 		),
89 89
 		'bounce' => array( 
90
-			'title' => esc_html__( 'Bounce Reduction', 'google-analytics-for-wordpress' ),
90
+			'title' => esc_html__('Bounce Reduction', 'google-analytics-for-wordpress'),
91 91
 			'level' => 'plus',
92 92
 			'comingsoon' => true
93 93
 		),
94 94
 		'reporting' => array( 
95
-			'title' => esc_html__( 'Additional Reporting', 'google-analytics-for-wordpress' ),
95
+			'title' => esc_html__('Additional Reporting', 'google-analytics-for-wordpress'),
96 96
 			'level' => 'plus',
97 97
 			'comingsoon' => true
98 98
 		),
99 99
 		'notifications' => array( 
100
-			'title' => esc_html__( 'Notifications', 'google-analytics-for-wordpress' ),
100
+			'title' => esc_html__('Notifications', 'google-analytics-for-wordpress'),
101 101
 			'level' => 'basic',
102 102
 			'comingsoon' => true
103 103
 		),
104 104
 		'compatibility' => array( 
105
-			'title' => esc_html__( 'Compatibility', 'google-analytics-for-wordpress' ),
105
+			'title' => esc_html__('Compatibility', 'google-analytics-for-wordpress'),
106 106
 			'level' => 'lite'
107 107
 		),
108 108
 		'permissions' => array( 
109
-			'title' => esc_html__( 'Permissions', 'google-analytics-for-wordpress' ),
109
+			'title' => esc_html__('Permissions', 'google-analytics-for-wordpress'),
110 110
 			'level' => 'lite'
111 111
 		),
112 112
 	);
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	 * versions after 6.0 to ensure we've got the right layout for the long term. 
117 117
 	 * Changes may be done without advance warning or announcement. You've been warned. 
118 118
 	 */
119
-	return apply_filters( 'monsterinsights_settings_tabs', $tabs );
119
+	return apply_filters('monsterinsights_settings_tabs', $tabs);
120 120
 }
121 121
 
122 122
 /**
@@ -146,12 +146,12 @@  discard block
 block discarded – undo
146 146
 	 */
147 147
 	$monsterinsights_settings = array(
148 148
 		/** Engagement Settings */
149
-		'engagement' => apply_filters( 'monsterinsights_settings_engagement',
149
+		'engagement' => apply_filters('monsterinsights_settings_engagement',
150 150
 			array(
151 151
 				'ignore_users' => array(
152 152
 					'id'          => 'ignore_users',
153
-					'name'        => __( 'Ignore these user roles from tracking:', 'google-analytics-for-wordpress' ),
154
-					'desc'        => __( 'Users that have at least one of these roles will not be tracked into Google Analytics.', 'google-analytics-for-wordpress' ),
153
+					'name'        => __('Ignore these user roles from tracking:', 'google-analytics-for-wordpress'),
154
+					'desc'        => __('Users that have at least one of these roles will not be tracked into Google Analytics.', 'google-analytics-for-wordpress'),
155 155
 					'type'        => 'select',
156 156
 					'options'     => monsterinsights_get_roles(),
157 157
 					'select2'     => true,
@@ -160,14 +160,14 @@  discard block
 block discarded – undo
160 160
 				),
161 161
 				'events_mode' => array(
162 162
 					'id'          => 'events_mode',
163
-					'name'        => __( 'Track outbound clicks and download links?', 'google-analytics-for-wordpress' ),
164
-					'desc'        => __( 'We recommend tracking clicks and downloads, so you know where users are exiting your site, and what downloads they are interacting with. ', 'google-analytics-for-wordpress', 'google-analytics-for-wordpress' ),
163
+					'name'        => __('Track outbound clicks and download links?', 'google-analytics-for-wordpress'),
164
+					'desc'        => __('We recommend tracking clicks and downloads, so you know where users are exiting your site, and what downloads they are interacting with. ', 'google-analytics-for-wordpress', 'google-analytics-for-wordpress'),
165 165
 					'type' 		  => 'radio',
166 166
 					'std'  		  => 'js',
167 167
 					'options'     => array(
168
-						'none' => __( 'No', 'google-analytics-for-wordpress' ),
169
-						'php'  => __( 'Yes, using PHP (deprecated)', 'google-analytics-for-wordpress' ),
170
-						'js'   => __( 'Using Javascript (recommended)', 'google-analytics-for-wordpress' ),
168
+						'none' => __('No', 'google-analytics-for-wordpress'),
169
+						'php'  => __('Yes, using PHP (deprecated)', 'google-analytics-for-wordpress'),
170
+						'js'   => __('Using Javascript (recommended)', 'google-analytics-for-wordpress'),
171 171
 					),
172 172
 				),
173 173
 			)
@@ -177,16 +177,16 @@  discard block
 block discarded – undo
177 177
 			array(
178 178
 				'demographics' => array(
179 179
 					'id'          => 'demographics',
180
-					'name'        => __( 'Enable Demographics and Interests Reports for Remarketing and Advertising', 'google-analytics-for-wordpress' ),
181
-					'desc'        => sprintf( esc_html__( 'Check this setting to add the Demographics and Remarketing features to your Google Analytics tracking code. Make sure to enable Demographics and Remarketing in your Google Analaytics account. We have a guide for how to do that in our %1$sknowledge base%2$s. For more information about Remarketing, we refer you to %3$sGoogle\'s documentation%2$s.', 'google-analytics-for-wordpress. Note that usage of this function is affected by privacy and cookie laws around the world. Be sure to follow the laws that affect your target audience.' ), '<a href="https://www.monsterinsights.com/docs/enable-demographics-and-interests-report-in-google-analytics/#utm_medium=kb-link&amp;utm_source=gawp-config&amp;utm_campaign=wpgaplugin" target="_blank" rel="noopener noreferrer" referrer="no-referrer">',
182
-									'</a>','<a href="https://support.google.com/analytics/answer/2444872?hl=' . get_locale() . '" target="_blank" rel="noopener noreferrer" referrer="no-referrer">'
180
+					'name'        => __('Enable Demographics and Interests Reports for Remarketing and Advertising', 'google-analytics-for-wordpress'),
181
+					'desc'        => sprintf(esc_html__('Check this setting to add the Demographics and Remarketing features to your Google Analytics tracking code. Make sure to enable Demographics and Remarketing in your Google Analaytics account. We have a guide for how to do that in our %1$sknowledge base%2$s. For more information about Remarketing, we refer you to %3$sGoogle\'s documentation%2$s.', 'google-analytics-for-wordpress. Note that usage of this function is affected by privacy and cookie laws around the world. Be sure to follow the laws that affect your target audience.'), '<a href="https://www.monsterinsights.com/docs/enable-demographics-and-interests-report-in-google-analytics/#utm_medium=kb-link&amp;utm_source=gawp-config&amp;utm_campaign=wpgaplugin" target="_blank" rel="noopener noreferrer" referrer="no-referrer">',
182
+									'</a>', '<a href="https://support.google.com/analytics/answer/2444872?hl=' . get_locale() . '" target="_blank" rel="noopener noreferrer" referrer="no-referrer">'
183 183
 					),
184 184
 					'type' 		  => 'checkbox',
185 185
 				),
186 186
 				'anonymize_ips' => array(
187 187
 					'id'          => 'anonymize_ips',
188
-					'name'        => __( 'Anonymize IP addresses?', 'google-analytics-for-wordpress' ),
189
-					'desc'        => sprintf( esc_html__( 'This adds %1$s, telling Google Analytics to anonymize the information sent by the tracker objects by removing the last octet of the IP address prior to its storage.', 'google-analytics-for-wordpress' ), '<a href="https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApi_gat?csw=1#_gat._anonymizeIp" target="_blank" rel="noopener noreferrer" referrer="no-referrer"><code>_anonymizeIp</code></a>' ),
188
+					'name'        => __('Anonymize IP addresses?', 'google-analytics-for-wordpress'),
189
+					'desc'        => sprintf(esc_html__('This adds %1$s, telling Google Analytics to anonymize the information sent by the tracker objects by removing the last octet of the IP address prior to its storage.', 'google-analytics-for-wordpress'), '<a href="https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApi_gat?csw=1#_gat._anonymizeIp" target="_blank" rel="noopener noreferrer" referrer="no-referrer"><code>_anonymizeIp</code></a>'),
190 190
 					'type' 		  => 'checkbox',
191 191
 				),
192 192
 			)
@@ -196,32 +196,32 @@  discard block
 block discarded – undo
196 196
 			array(
197 197
 				'enhanced_link_attribution' => array(
198 198
 					'id'          => 'enhanced_link_attribution',
199
-					'name'        => __( 'Enable enhanced link attribution?', 'google-analytics-for-wordpress' ),
200
-					'desc'        => sprintf( esc_html__( 'Add %1$sEnhanced Link Attribution%2$s to your tracking code.', 'google-analytics-for-wordpress' ), '<a href="https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-link-attribution" target="_blank" rel="noopener noreferrer" referrer="no-referrer">', ' </a>' ),
199
+					'name'        => __('Enable enhanced link attribution?', 'google-analytics-for-wordpress'),
200
+					'desc'        => sprintf(esc_html__('Add %1$sEnhanced Link Attribution%2$s to your tracking code.', 'google-analytics-for-wordpress'), '<a href="https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-link-attribution" target="_blank" rel="noopener noreferrer" referrer="no-referrer">', ' </a>'),
201 201
 					'type' 		  => 'checkbox',
202 202
 				),
203 203
 				'hash_tracking' => array(
204 204
 					'id'          => 'hash_tracking',
205
-					'name'        => __( 'Turn on anchor tracking', 'google-analytics-for-wordpress' ),
206
-					'desc'        => esc_html__( 'Many WordPress "1-page" style themes rely on anchor tags for navigation to show virtual pages. The problem is that to Google Analytics, these are all just a single page, and it makes it hard to get meaningful statistics about pages viewed. This feature allows proper tracking in those themes.', 'google-analytics-for-wordpress' ),
205
+					'name'        => __('Turn on anchor tracking', 'google-analytics-for-wordpress'),
206
+					'desc'        => esc_html__('Many WordPress "1-page" style themes rely on anchor tags for navigation to show virtual pages. The problem is that to Google Analytics, these are all just a single page, and it makes it hard to get meaningful statistics about pages viewed. This feature allows proper tracking in those themes.', 'google-analytics-for-wordpress'),
207 207
 					'type' 		  => 'checkbox',
208 208
 				),
209 209
 				'allow_anchor' => array(
210 210
 					'id'          => 'allow_anchor',
211
-					'name'        => __( 'Turn on allowAnchor', 'google-analytics-for-wordpress' ),
212
-					'desc'        => sprintf( esc_html__( 'This adds a %1$s call to your tracking code, and makes RSS link tagging use a %2$s as well.', 'google-analytics-for-wordpress' ), '<a href="https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiCampaignTracking?csw=1#_gat.GA_Tracker_._setAllowAnchor" target="_blank" rel="noopener noreferrer" referrer="no-referrer"><code>_setAllowAnchor</code></a>', '<code>#</code>' ),
211
+					'name'        => __('Turn on allowAnchor', 'google-analytics-for-wordpress'),
212
+					'desc'        => sprintf(esc_html__('This adds a %1$s call to your tracking code, and makes RSS link tagging use a %2$s as well.', 'google-analytics-for-wordpress'), '<a href="https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiCampaignTracking?csw=1#_gat.GA_Tracker_._setAllowAnchor" target="_blank" rel="noopener noreferrer" referrer="no-referrer"><code>_setAllowAnchor</code></a>', '<code>#</code>'),
213 213
 					'type' 		  => 'checkbox',
214 214
 				),
215 215
 				'add_allow_linker' => array(
216 216
 					'id'          => 'add_allow_linker',
217
-					'name'        => __( 'Turn on allowLinker', 'google-analytics-for-wordpress' ),
218
-					'desc'        => sprintf( esc_html__( 'This adds a %1$s call to your tracking code, allowing you to use %2$s and related functions.', 'google-analytics-for-wordpress' ), '<a href="https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiDomainDirectory?csw=1#_gat.GA_Tracker_._setAllowLinker" target="_blank" rel="noopener noreferrer" referrer="no-referrer"><code>_setAllowLinker</code></a>', ' <code>_link</code>' ),
217
+					'name'        => __('Turn on allowLinker', 'google-analytics-for-wordpress'),
218
+					'desc'        => sprintf(esc_html__('This adds a %1$s call to your tracking code, allowing you to use %2$s and related functions.', 'google-analytics-for-wordpress'), '<a href="https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiDomainDirectory?csw=1#_gat.GA_Tracker_._setAllowLinker" target="_blank" rel="noopener noreferrer" referrer="no-referrer"><code>_setAllowLinker</code></a>', ' <code>_link</code>'),
219 219
 					'type' 		  => 'checkbox',
220 220
 				),
221 221
 				'tag_links_in_rss' => array(
222 222
 					'id'          => 'tag_links_in_rss',
223
-					'name'        => __( 'Turn on tag links in RSS', 'google-analytics-for-wordpress' ),
224
-					'desc'        => sprintf( esc_html__( 'Do not use this feature if you use FeedBurner, as FeedBurner can do this automatically and better than this plugin can. Check %1$sthis help page%2$s for info on how to enable this feature in FeedBurner.', 'google-analytics-for-wordpress' ), '<a href="https://support.google.com/feedburner/answer/165769?hl=en&amp;ref_topic=13075" target="_blank" rel="noopener noreferrer" referrer="no-referrer">', '</a>' ),
223
+					'name'        => __('Turn on tag links in RSS', 'google-analytics-for-wordpress'),
224
+					'desc'        => sprintf(esc_html__('Do not use this feature if you use FeedBurner, as FeedBurner can do this automatically and better than this plugin can. Check %1$sthis help page%2$s for info on how to enable this feature in FeedBurner.', 'google-analytics-for-wordpress'), '<a href="https://support.google.com/feedburner/answer/165769?hl=en&amp;ref_topic=13075" target="_blank" rel="noopener noreferrer" referrer="no-referrer">', '</a>'),
225 225
 					'type' 		  => 'checkbox',
226 226
 				),
227 227
 			)
@@ -231,19 +231,19 @@  discard block
 block discarded – undo
231 231
 			array(
232 232
 				'track_download_as' => array(
233 233
 					'id'          => 'track_download_as',
234
-					'name'        => __( 'Track downloads as an:', 'google-analytics-for-wordpress' ),
235
-					'desc'        => __( 'Tracking as pageviews is not recommended, as this would skew your statistics, but it does make it possible to track downloads as goals. This feature requires that event tracking be turned on.', 'google-analytics-for-wordpress' ),
234
+					'name'        => __('Track downloads as an:', 'google-analytics-for-wordpress'),
235
+					'desc'        => __('Tracking as pageviews is not recommended, as this would skew your statistics, but it does make it possible to track downloads as goals. This feature requires that event tracking be turned on.', 'google-analytics-for-wordpress'),
236 236
 					'type' 		  => 'radio',
237 237
 					'std'  		  => 'event',
238 238
 					'options'     => array(
239
-						'event'     => __( 'Event (recommended)', 'google-analytics-for-wordpress' ),
240
-						'pageview'  => __( 'Pageview', 'google-analytics-for-wordpress' )
239
+						'event'     => __('Event (recommended)', 'google-analytics-for-wordpress'),
240
+						'pageview'  => __('Pageview', 'google-analytics-for-wordpress')
241 241
 					),
242 242
 				),
243 243
 				'extensions_of_files' => array( 		/* @todo: Select2 extensions of files */
244 244
 					'id'          => 'extensions_of_files',
245
-					'name'        => __( 'Extensions of files to track as downloads:', 'google-analytics-for-wordpress' ),
246
-					'desc'        => __( 'If you have enabled event tracking, MonsterInsights will send an event/pageview to GA if a link to a local file has one of the above extensions.', 'google-analytics-for-wordpress' ),
245
+					'name'        => __('Extensions of files to track as downloads:', 'google-analytics-for-wordpress'),
246
+					'desc'        => __('If you have enabled event tracking, MonsterInsights will send an event/pageview to GA if a link to a local file has one of the above extensions.', 'google-analytics-for-wordpress'),
247 247
 					'type' 		  => 'text',
248 248
 				),
249 249
 			)
@@ -253,14 +253,14 @@  discard block
 block discarded – undo
253 253
 			array(
254 254
 				'track_internal_as_outbound' => array(
255 255
 					'id'          => 'track_internal_as_outbound',
256
-					'name'        => __( 'Set path for internal links to track as outbound links', 'google-analytics-for-wordpress' ),
257
-					'desc'        => sprintf( esc_html__( 'If you want to track all internal links that begin with %1$s, enter %1$s in the box above. If you have multiple prefixes you can separate them with comma\'s: %2$s', 'google-analytics-for-wordpress' ), '<code>/out/</code>', '<code>/out/,/recommends/</code>' ),
256
+					'name'        => __('Set path for internal links to track as outbound links', 'google-analytics-for-wordpress'),
257
+					'desc'        => sprintf(esc_html__('If you want to track all internal links that begin with %1$s, enter %1$s in the box above. If you have multiple prefixes you can separate them with comma\'s: %2$s', 'google-analytics-for-wordpress'), '<code>/out/</code>', '<code>/out/,/recommends/</code>'),
258 258
 					'type' 		  => 'text',
259 259
 				),
260 260
 				'track_internal_as_label' => array(
261 261
 					'id'          => 'track_internal_as_label',
262
-					'name'        => __( 'Label for those links:', 'google-analytics-for-wordpress' ),
263
-					'desc'        => sprintf( esc_html__( 'The label to use for these links, this will be added to where the click came from, so if the label is %s, the label for a click from the content of an article becomes "outbound-article-aff".', 'google-analytics-for-wordpress' ), '"aff"' ),
262
+					'name'        => __('Label for those links:', 'google-analytics-for-wordpress'),
263
+					'desc'        => sprintf(esc_html__('The label to use for these links, this will be added to where the click came from, so if the label is %s, the label for a click from the content of an article becomes "outbound-article-aff".', 'google-analytics-for-wordpress'), '"aff"'),
264 264
 					'type' 		  => 'text',
265 265
 				),
266 266
 			)
@@ -326,20 +326,20 @@  discard block
 block discarded – undo
326 326
 			array(
327 327
 				'subdomain_tracking' => array(
328 328
 					'id'          => 'subdomain_tracking',
329
-					'name'        => __( 'Domain to track as:', 'google-analytics-for-wordpress' ),
330
-					'desc'        => sprintf( esc_html__( 'This allows you to %1$sset the domain%2$s that\'s used for tracking. Only is used if set to a value, else defaults to automatic determination. It is very rare that you would need to use this setting.', 'google-analytics-for-wordpress' ), '<a href="https://developers.google.com/analytics/devguides/collection/analyticsjs/tracking-snippet-reference" target="_blank" rel="noopener noreferrer" referrer="no-referrer">' ,'</a>' ),
329
+					'name'        => __('Domain to track as:', 'google-analytics-for-wordpress'),
330
+					'desc'        => sprintf(esc_html__('This allows you to %1$sset the domain%2$s that\'s used for tracking. Only is used if set to a value, else defaults to automatic determination. It is very rare that you would need to use this setting.', 'google-analytics-for-wordpress'), '<a href="https://developers.google.com/analytics/devguides/collection/analyticsjs/tracking-snippet-reference" target="_blank" rel="noopener noreferrer" referrer="no-referrer">', '</a>'),
331 331
 					'type' 		  => 'text',
332 332
 				),
333 333
 				'custom_code' => array(
334 334
 					'id'          => 'custom_code',
335
-					'name'        => __( 'Custom code', 'google-analytics-for-wordpress' ),
336
-					'desc'        => sprintf( esc_html__( 'Not for the average user: this allows you to add a line of code, to be added before the %1$s call.', 'google-analytics-for-wordpress' ), '<a href="https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiBasicConfiguration#_gat.GA_Tracker_._trackPageview" target="_blank" rel="noopener noreferrer" referrer="no-referrer"><code>_trackPageview</code></a>' ),
335
+					'name'        => __('Custom code', 'google-analytics-for-wordpress'),
336
+					'desc'        => sprintf(esc_html__('Not for the average user: this allows you to add a line of code, to be added before the %1$s call.', 'google-analytics-for-wordpress'), '<a href="https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiBasicConfiguration#_gat.GA_Tracker_._trackPageview" target="_blank" rel="noopener noreferrer" referrer="no-referrer"><code>_trackPageview</code></a>'),
337 337
 					'type' 		  => 'unfiltered_textarea',
338 338
 				),
339 339
 				'debug_mode' => array(
340 340
 					'id'          => 'debug_mode',
341
-					'name'        => __( 'Enable Debug Mode', 'google-analytics-for-wordpress' ),
342
-					'desc'        => __( 'Turns on debugging in JS events tracking, logging of eCommerce requests and enables debug settings.', 'google-analytics-for-wordpress'),
341
+					'name'        => __('Enable Debug Mode', 'google-analytics-for-wordpress'),
342
+					'desc'        => __('Turns on debugging in JS events tracking, logging of eCommerce requests and enables debug settings.', 'google-analytics-for-wordpress'),
343 343
 					'type' 		  => 'checkbox',
344 344
 				),
345 345
 			)
@@ -349,8 +349,8 @@  discard block
 block discarded – undo
349 349
 			array(
350 350
 				'view_reports' => array(
351 351
 					'id'          => 'view_reports',
352
-					'name'        => __( 'Let these user roles see reports (and the dashboard):', 'google-analytics-for-wordpress' ),
353
-					'desc'        => sprintf( esc_html( 'Users that have at least one of these roles will be able to view the reports and dashboard, along with any user with the %s capability.', 'google-analytics-for-wordpress' ), '<code>manage_options</code>'),
352
+					'name'        => __('Let these user roles see reports (and the dashboard):', 'google-analytics-for-wordpress'),
353
+					'desc'        => sprintf(esc_html('Users that have at least one of these roles will be able to view the reports and dashboard, along with any user with the %s capability.', 'google-analytics-for-wordpress'), '<code>manage_options</code>'),
354 354
 					'type'        => 'select',
355 355
 					'options'     => monsterinsights_get_roles(),
356 356
 					'select2'     => true,
@@ -359,8 +359,8 @@  discard block
 block discarded – undo
359 359
 				),
360 360
 				'save_settings' => array(
361 361
 					'id'          => 'save_settings',
362
-					'name'        => __( 'Let these user roles save settings:', 'google-analytics-for-wordpress' ),
363
-					'desc'        => sprintf( esc_html__( 'Users that have at least one of these roles will be able to view and save the settings panel, along with any user with the %s capability.', 'google-analytics-for-wordpress'), '<code>manage_options</code>' ),
362
+					'name'        => __('Let these user roles save settings:', 'google-analytics-for-wordpress'),
363
+					'desc'        => sprintf(esc_html__('Users that have at least one of these roles will be able to view and save the settings panel, along with any user with the %s capability.', 'google-analytics-for-wordpress'), '<code>manage_options</code>'),
364 364
 					'type'        => 'select',
365 365
 					'options'     => monsterinsights_get_roles(),
366 366
 					'select2'     => true,
@@ -369,23 +369,23 @@  discard block
 block discarded – undo
369 369
 				),
370 370
 				'automatic_updates' => array(
371 371
 					'id'          => 'automatic_updates',
372
-					'name'        => __( 'Automatic Updates', 'google-analytics-for-wordpress' ),
372
+					'name'        => __('Automatic Updates', 'google-analytics-for-wordpress'),
373 373
 					'type' 		  => 'radio',
374 374
 					'std'  		  => 'none',
375 375
 					'options'     => array(
376
-						'all'     => __( 'Yes (Recommended) - Get the latest features, bugfixes, and security updates as they are released.', 'google-analytics-for-wordpress' ),
377
-						'minor'   => __( 'Minor Only - Only get bugfixes and security updates, but not major features.', 'google-analytics-for-wordpress' ),
378
-						'none'    => __( 'None - Manually update everything.', 'google-analytics-for-wordpress' ),
376
+						'all'     => __('Yes (Recommended) - Get the latest features, bugfixes, and security updates as they are released.', 'google-analytics-for-wordpress'),
377
+						'minor'   => __('Minor Only - Only get bugfixes and security updates, but not major features.', 'google-analytics-for-wordpress'),
378
+						'none'    => __('None - Manually update everything.', 'google-analytics-for-wordpress'),
379 379
 					),
380 380
 				),
381 381
 				'anonymous_data' => array(
382 382
 					'id'          => 'anonymous_data',
383
-					'name'        => __( 'Allow Usage Tracking', 'google-analytics-for-wordpress' ),
384
-					'desc'        => __( 'By allowing us to track usage data we can better help you, because we know with which WordPress configurations, themes and plugins we should test.', 'google-analytics-for-wordpress' ),
383
+					'name'        => __('Allow Usage Tracking', 'google-analytics-for-wordpress'),
384
+					'desc'        => __('By allowing us to track usage data we can better help you, because we know with which WordPress configurations, themes and plugins we should test.', 'google-analytics-for-wordpress'),
385 385
 					'type' 		  => 'checkbox',
386 386
 				),
387 387
 			)
388 388
 		),
389 389
 	);
390
-	return apply_filters( 'monsterinsights_registered_settings', $monsterinsights_settings );
390
+	return apply_filters('monsterinsights_registered_settings', $monsterinsights_settings);
391 391
 }
Please login to merge, or discard this patch.
Indentation   +361 added lines, -361 removed lines patch added patch discarded remove patch
@@ -16,107 +16,107 @@  discard block
 block discarded – undo
16 16
  * @return array $tabs
17 17
  */
18 18
 function monsterinsights_get_settings_tabs() {
19
-	// Levels: lite, basic, plus, pro
20
-	// coming soon = true (don't count on this)
21
-	$tabs = array(
22
-		'engagement' => array( 
23
-			'title' => esc_html__( 'Engagement', 'google-analytics-for-wordpress' ),
24
-			'level' => 'lite'
25
-		),
26
-		'demographics' => array( 
27
-			'title' => esc_html__( 'Demographics', 'google-analytics-for-wordpress' ),
28
-			'level' => 'lite'
29
-		),
30
-		'links' => array( 
31
-			'title' => esc_html__( 'Link Attribution', 'google-analytics-for-wordpress' ),
32
-			'level' => 'lite'
33
-		),
34
-		'files' => array( 
35
-			'title' => esc_html__( 'File Downloads', 'google-analytics-for-wordpress' ),
36
-			'level' => 'lite'
37
-		),  
38
-		'affiliates' => array( 
39
-			'title' => esc_html__( 'Affiliate Links', 'google-analytics-for-wordpress' ),
40
-			'level' => 'lite'
41
-		),  
42
-		'social' => array( 
43
-			'title' => esc_html__( 'Social', 'google-analytics-for-wordpress' ),
44
-			'level' => 'basic',
45
-			'comingsoon' => true
46
-		),
47
-		'ads' => array( 
48
-			'title' => esc_html__( 'Ads', 'google-analytics-for-wordpress' ),
49
-			'level' => 'plus',
50
-		),
51
-		'forms' => array( 
52
-			'title' => esc_html__( 'Forms', 'google-analytics-for-wordpress' ),
53
-			'level' => 'pro',
54
-		),
55
-		'ecommerce' => array( 
56
-			'title' => esc_html__( 'eCommerce', 'google-analytics-for-wordpress' ),
57
-			'level' => 'pro'
58
-		),
59
-		'media' => array( 
60
-			'title' => esc_html__( 'Media', 'google-analytics-for-wordpress' ),
61
-			'level' => 'plus',
62
-			'comingsoon' => true
63
-		),
64
-		'memberships' => array( 
65
-			'title' => esc_html__( 'Memberships', 'google-analytics-for-wordpress' ),
66
-			'level' => 'plus',
67
-			'comingsoon' => true
68
-		),
69
-		'dimensions' => array( 
70
-			'title' => esc_html__( 'Custom Dimensions', 'google-analytics-for-wordpress' ),
71
-			'level' => 'pro',
72
-		),
73
-		'performance' => array( 
74
-			'title' => esc_html__( 'Performance', 'google-analytics-for-wordpress' ),
75
-			'level' => 'plus'
76
-		),
77
-		'amp' => array( 
78
-			'title' => esc_html__( 'Google AMP', 'google-analytics-for-wordpress' ),
79
-			'level' => 'plus'
80
-		),
81
-		'goptimize' => array( 
82
-			'title' => esc_html__( 'Google Optimize', 'google-analytics-for-wordpress' ),
83
-			'level' => 'pro'
84
-		),
85
-		'fbia' => array( 
86
-			'title' => esc_html__( 'FB Instant Articles', 'google-analytics-for-wordpress' ),
87
-			'level' => 'plus'
88
-		),
89
-		'bounce' => array( 
90
-			'title' => esc_html__( 'Bounce Reduction', 'google-analytics-for-wordpress' ),
91
-			'level' => 'plus',
92
-			'comingsoon' => true
93
-		),
94
-		'reporting' => array( 
95
-			'title' => esc_html__( 'Additional Reporting', 'google-analytics-for-wordpress' ),
96
-			'level' => 'plus',
97
-			'comingsoon' => true
98
-		),
99
-		'notifications' => array( 
100
-			'title' => esc_html__( 'Notifications', 'google-analytics-for-wordpress' ),
101
-			'level' => 'basic',
102
-			'comingsoon' => true
103
-		),
104
-		'compatibility' => array( 
105
-			'title' => esc_html__( 'Compatibility', 'google-analytics-for-wordpress' ),
106
-			'level' => 'lite'
107
-		),
108
-		'permissions' => array( 
109
-			'title' => esc_html__( 'Permissions', 'google-analytics-for-wordpress' ),
110
-			'level' => 'lite'
111
-		),
112
-	);
113
-	/**
114
-	 * Developers Warning: MonsterInsights does not guarantee backwards compatiblity
115
-	 * of tabs yet. We might add/remove/reorder/edit tabs for the first few major
116
-	 * versions after 6.0 to ensure we've got the right layout for the long term. 
117
-	 * Changes may be done without advance warning or announcement. You've been warned. 
118
-	 */
119
-	return apply_filters( 'monsterinsights_settings_tabs', $tabs );
19
+    // Levels: lite, basic, plus, pro
20
+    // coming soon = true (don't count on this)
21
+    $tabs = array(
22
+        'engagement' => array( 
23
+            'title' => esc_html__( 'Engagement', 'google-analytics-for-wordpress' ),
24
+            'level' => 'lite'
25
+        ),
26
+        'demographics' => array( 
27
+            'title' => esc_html__( 'Demographics', 'google-analytics-for-wordpress' ),
28
+            'level' => 'lite'
29
+        ),
30
+        'links' => array( 
31
+            'title' => esc_html__( 'Link Attribution', 'google-analytics-for-wordpress' ),
32
+            'level' => 'lite'
33
+        ),
34
+        'files' => array( 
35
+            'title' => esc_html__( 'File Downloads', 'google-analytics-for-wordpress' ),
36
+            'level' => 'lite'
37
+        ),  
38
+        'affiliates' => array( 
39
+            'title' => esc_html__( 'Affiliate Links', 'google-analytics-for-wordpress' ),
40
+            'level' => 'lite'
41
+        ),  
42
+        'social' => array( 
43
+            'title' => esc_html__( 'Social', 'google-analytics-for-wordpress' ),
44
+            'level' => 'basic',
45
+            'comingsoon' => true
46
+        ),
47
+        'ads' => array( 
48
+            'title' => esc_html__( 'Ads', 'google-analytics-for-wordpress' ),
49
+            'level' => 'plus',
50
+        ),
51
+        'forms' => array( 
52
+            'title' => esc_html__( 'Forms', 'google-analytics-for-wordpress' ),
53
+            'level' => 'pro',
54
+        ),
55
+        'ecommerce' => array( 
56
+            'title' => esc_html__( 'eCommerce', 'google-analytics-for-wordpress' ),
57
+            'level' => 'pro'
58
+        ),
59
+        'media' => array( 
60
+            'title' => esc_html__( 'Media', 'google-analytics-for-wordpress' ),
61
+            'level' => 'plus',
62
+            'comingsoon' => true
63
+        ),
64
+        'memberships' => array( 
65
+            'title' => esc_html__( 'Memberships', 'google-analytics-for-wordpress' ),
66
+            'level' => 'plus',
67
+            'comingsoon' => true
68
+        ),
69
+        'dimensions' => array( 
70
+            'title' => esc_html__( 'Custom Dimensions', 'google-analytics-for-wordpress' ),
71
+            'level' => 'pro',
72
+        ),
73
+        'performance' => array( 
74
+            'title' => esc_html__( 'Performance', 'google-analytics-for-wordpress' ),
75
+            'level' => 'plus'
76
+        ),
77
+        'amp' => array( 
78
+            'title' => esc_html__( 'Google AMP', 'google-analytics-for-wordpress' ),
79
+            'level' => 'plus'
80
+        ),
81
+        'goptimize' => array( 
82
+            'title' => esc_html__( 'Google Optimize', 'google-analytics-for-wordpress' ),
83
+            'level' => 'pro'
84
+        ),
85
+        'fbia' => array( 
86
+            'title' => esc_html__( 'FB Instant Articles', 'google-analytics-for-wordpress' ),
87
+            'level' => 'plus'
88
+        ),
89
+        'bounce' => array( 
90
+            'title' => esc_html__( 'Bounce Reduction', 'google-analytics-for-wordpress' ),
91
+            'level' => 'plus',
92
+            'comingsoon' => true
93
+        ),
94
+        'reporting' => array( 
95
+            'title' => esc_html__( 'Additional Reporting', 'google-analytics-for-wordpress' ),
96
+            'level' => 'plus',
97
+            'comingsoon' => true
98
+        ),
99
+        'notifications' => array( 
100
+            'title' => esc_html__( 'Notifications', 'google-analytics-for-wordpress' ),
101
+            'level' => 'basic',
102
+            'comingsoon' => true
103
+        ),
104
+        'compatibility' => array( 
105
+            'title' => esc_html__( 'Compatibility', 'google-analytics-for-wordpress' ),
106
+            'level' => 'lite'
107
+        ),
108
+        'permissions' => array( 
109
+            'title' => esc_html__( 'Permissions', 'google-analytics-for-wordpress' ),
110
+            'level' => 'lite'
111
+        ),
112
+    );
113
+    /**
114
+     * Developers Warning: MonsterInsights does not guarantee backwards compatiblity
115
+     * of tabs yet. We might add/remove/reorder/edit tabs for the first few major
116
+     * versions after 6.0 to ensure we've got the right layout for the long term. 
117
+     * Changes may be done without advance warning or announcement. You've been warned. 
118
+     */
119
+    return apply_filters( 'monsterinsights_settings_tabs', $tabs );
120 120
 }
121 121
 
122 122
 /**
@@ -127,265 +127,265 @@  discard block
 block discarded – undo
127 127
 */
128 128
 function monsterinsights_get_registered_settings() {
129 129
 
130
-	/**
131
-	 * 'Whitelisted' MonsterInsights settings, filters are provided for each settings
132
-	 * section to allow extensions and other plugins to add their own settings
133
-	 */
130
+    /**
131
+     * 'Whitelisted' MonsterInsights settings, filters are provided for each settings
132
+     * section to allow extensions and other plugins to add their own settings
133
+     */
134 134
 	
135
-	/**
136
-	 * Developers Warning: MonsterInsights does not guarantee backwards compatiblity
137
-	 * of settings or tabs. We may add/remove settings and/or tabs, or re-arrange the 
138
-	 * settings panel as we need to. We provide these filters here right now for internal use only.
139
-	 * As such the filters below may be removed or altered at any time, without advance
140
-	 * warning or announcement. You've been warned. 
141
-	 *
142
-	 * We will eventually promise backwards compatibility on these filters below but we want to ensure
143
-	 * for the first few major releases after 6.0 we do that the current settings arrangement won't stifle
144
-	 * our development progress. Once we're confident we've made the correct decision on settings layout, 
145
-	 * we'll remove this notice, and only at that point should you rely on the filters below.
146
-	 */
147
-	$monsterinsights_settings = array(
148
-		/** Engagement Settings */
149
-		'engagement' => apply_filters( 'monsterinsights_settings_engagement',
150
-			array(
151
-				'ignore_users' => array(
152
-					'id'          => 'ignore_users',
153
-					'name'        => __( 'Ignore these user roles from tracking:', 'google-analytics-for-wordpress' ),
154
-					'desc'        => __( 'Users that have at least one of these roles will not be tracked into Google Analytics.', 'google-analytics-for-wordpress' ),
155
-					'type'        => 'select',
156
-					'options'     => monsterinsights_get_roles(),
157
-					'select2'     => true,
158
-					'multiple'    => true,
159
-					'allowclear'  => true,
160
-				),
161
-				'events_mode' => array(
162
-					'id'          => 'events_mode',
163
-					'name'        => __( 'Track outbound clicks and download links?', 'google-analytics-for-wordpress' ),
164
-					'desc'        => __( 'We recommend tracking clicks and downloads, so you know where users are exiting your site, and what downloads they are interacting with. ', 'google-analytics-for-wordpress', 'google-analytics-for-wordpress' ),
165
-					'type' 		  => 'radio',
166
-					'std'  		  => 'js',
167
-					'options'     => array(
168
-						'none' => __( 'No', 'google-analytics-for-wordpress' ),
169
-						'php'  => __( 'Yes, using PHP (deprecated)', 'google-analytics-for-wordpress' ),
170
-						'js'   => __( 'Using Javascript (recommended)', 'google-analytics-for-wordpress' ),
171
-					),
172
-				),
173
-			)
174
-		),
175
-		/** Demographics Settings */
176
-		'demographics' => apply_filters('monsterinsights_settings_demographics',
177
-			array(
178
-				'demographics' => array(
179
-					'id'          => 'demographics',
180
-					'name'        => __( 'Enable Demographics and Interests Reports for Remarketing and Advertising', 'google-analytics-for-wordpress' ),
181
-					'desc'        => sprintf( esc_html__( 'Check this setting to add the Demographics and Remarketing features to your Google Analytics tracking code. Make sure to enable Demographics and Remarketing in your Google Analaytics account. We have a guide for how to do that in our %1$sknowledge base%2$s. For more information about Remarketing, we refer you to %3$sGoogle\'s documentation%2$s.', 'google-analytics-for-wordpress. Note that usage of this function is affected by privacy and cookie laws around the world. Be sure to follow the laws that affect your target audience.' ), '<a href="https://www.monsterinsights.com/docs/enable-demographics-and-interests-report-in-google-analytics/#utm_medium=kb-link&amp;utm_source=gawp-config&amp;utm_campaign=wpgaplugin" target="_blank" rel="noopener noreferrer" referrer="no-referrer">',
182
-									'</a>','<a href="https://support.google.com/analytics/answer/2444872?hl=' . get_locale() . '" target="_blank" rel="noopener noreferrer" referrer="no-referrer">'
183
-					),
184
-					'type' 		  => 'checkbox',
185
-				),
186
-				'anonymize_ips' => array(
187
-					'id'          => 'anonymize_ips',
188
-					'name'        => __( 'Anonymize IP addresses?', 'google-analytics-for-wordpress' ),
189
-					'desc'        => sprintf( esc_html__( 'This adds %1$s, telling Google Analytics to anonymize the information sent by the tracker objects by removing the last octet of the IP address prior to its storage.', 'google-analytics-for-wordpress' ), '<a href="https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApi_gat?csw=1#_gat._anonymizeIp" target="_blank" rel="noopener noreferrer" referrer="no-referrer"><code>_anonymizeIp</code></a>' ),
190
-					'type' 		  => 'checkbox',
191
-				),
192
-			)
193
-		),
194
-		/** Enhanced Link Attribution Settings */
195
-		'links' => apply_filters('monsterinsights_settings_links',
196
-			array(
197
-				'enhanced_link_attribution' => array(
198
-					'id'          => 'enhanced_link_attribution',
199
-					'name'        => __( 'Enable enhanced link attribution?', 'google-analytics-for-wordpress' ),
200
-					'desc'        => sprintf( esc_html__( 'Add %1$sEnhanced Link Attribution%2$s to your tracking code.', 'google-analytics-for-wordpress' ), '<a href="https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-link-attribution" target="_blank" rel="noopener noreferrer" referrer="no-referrer">', ' </a>' ),
201
-					'type' 		  => 'checkbox',
202
-				),
203
-				'hash_tracking' => array(
204
-					'id'          => 'hash_tracking',
205
-					'name'        => __( 'Turn on anchor tracking', 'google-analytics-for-wordpress' ),
206
-					'desc'        => esc_html__( 'Many WordPress "1-page" style themes rely on anchor tags for navigation to show virtual pages. The problem is that to Google Analytics, these are all just a single page, and it makes it hard to get meaningful statistics about pages viewed. This feature allows proper tracking in those themes.', 'google-analytics-for-wordpress' ),
207
-					'type' 		  => 'checkbox',
208
-				),
209
-				'allow_anchor' => array(
210
-					'id'          => 'allow_anchor',
211
-					'name'        => __( 'Turn on allowAnchor', 'google-analytics-for-wordpress' ),
212
-					'desc'        => sprintf( esc_html__( 'This adds a %1$s call to your tracking code, and makes RSS link tagging use a %2$s as well.', 'google-analytics-for-wordpress' ), '<a href="https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiCampaignTracking?csw=1#_gat.GA_Tracker_._setAllowAnchor" target="_blank" rel="noopener noreferrer" referrer="no-referrer"><code>_setAllowAnchor</code></a>', '<code>#</code>' ),
213
-					'type' 		  => 'checkbox',
214
-				),
215
-				'add_allow_linker' => array(
216
-					'id'          => 'add_allow_linker',
217
-					'name'        => __( 'Turn on allowLinker', 'google-analytics-for-wordpress' ),
218
-					'desc'        => sprintf( esc_html__( 'This adds a %1$s call to your tracking code, allowing you to use %2$s and related functions.', 'google-analytics-for-wordpress' ), '<a href="https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiDomainDirectory?csw=1#_gat.GA_Tracker_._setAllowLinker" target="_blank" rel="noopener noreferrer" referrer="no-referrer"><code>_setAllowLinker</code></a>', ' <code>_link</code>' ),
219
-					'type' 		  => 'checkbox',
220
-				),
221
-				'tag_links_in_rss' => array(
222
-					'id'          => 'tag_links_in_rss',
223
-					'name'        => __( 'Turn on tag links in RSS', 'google-analytics-for-wordpress' ),
224
-					'desc'        => sprintf( esc_html__( 'Do not use this feature if you use FeedBurner, as FeedBurner can do this automatically and better than this plugin can. Check %1$sthis help page%2$s for info on how to enable this feature in FeedBurner.', 'google-analytics-for-wordpress' ), '<a href="https://support.google.com/feedburner/answer/165769?hl=en&amp;ref_topic=13075" target="_blank" rel="noopener noreferrer" referrer="no-referrer">', '</a>' ),
225
-					'type' 		  => 'checkbox',
226
-				),
227
-			)
228
-		),
229
-		/** File Download Settings */
230
-		'files' => apply_filters('monsterinsights_settings_files',
231
-			array(
232
-				'track_download_as' => array(
233
-					'id'          => 'track_download_as',
234
-					'name'        => __( 'Track downloads as an:', 'google-analytics-for-wordpress' ),
235
-					'desc'        => __( 'Tracking as pageviews is not recommended, as this would skew your statistics, but it does make it possible to track downloads as goals. This feature requires that event tracking be turned on.', 'google-analytics-for-wordpress' ),
236
-					'type' 		  => 'radio',
237
-					'std'  		  => 'event',
238
-					'options'     => array(
239
-						'event'     => __( 'Event (recommended)', 'google-analytics-for-wordpress' ),
240
-						'pageview'  => __( 'Pageview', 'google-analytics-for-wordpress' )
241
-					),
242
-				),
243
-				'extensions_of_files' => array( 		/* @todo: Select2 extensions of files */
244
-					'id'          => 'extensions_of_files',
245
-					'name'        => __( 'Extensions of files to track as downloads:', 'google-analytics-for-wordpress' ),
246
-					'desc'        => __( 'If you have enabled event tracking, MonsterInsights will send an event/pageview to GA if a link to a local file has one of the above extensions.', 'google-analytics-for-wordpress' ),
247
-					'type' 		  => 'text',
248
-				),
249
-			)
250
-		),
251
-		/** Affiliate Tracking Settings */
252
-		'affiliates' => apply_filters('monsterinsights_settings_affiliates',
253
-			array(
254
-				'track_internal_as_outbound' => array(
255
-					'id'          => 'track_internal_as_outbound',
256
-					'name'        => __( 'Set path for internal links to track as outbound links', 'google-analytics-for-wordpress' ),
257
-					'desc'        => sprintf( esc_html__( 'If you want to track all internal links that begin with %1$s, enter %1$s in the box above. If you have multiple prefixes you can separate them with comma\'s: %2$s', 'google-analytics-for-wordpress' ), '<code>/out/</code>', '<code>/out/,/recommends/</code>' ),
258
-					'type' 		  => 'text',
259
-				),
260
-				'track_internal_as_label' => array(
261
-					'id'          => 'track_internal_as_label',
262
-					'name'        => __( 'Label for those links:', 'google-analytics-for-wordpress' ),
263
-					'desc'        => sprintf( esc_html__( 'The label to use for these links, this will be added to where the click came from, so if the label is %s, the label for a click from the content of an article becomes "outbound-article-aff".', 'google-analytics-for-wordpress' ), '"aff"' ),
264
-					'type' 		  => 'text',
265
-				),
266
-			)
267
-		),
268
-		/** Social Tracking Settings */
269
-		'social' => apply_filters('monsterinsights_settings_social',
270
-			array()
271
-		),
272
-		/** Ad Tracking Settings */
273
-		'ads' => apply_filters('monsterinsights_settings_ads',
274
-			array()
275
-		),
276
-		/** Forms Tracking Settings */
277
-		'forms' => apply_filters('monsterinsights_settings_forms',
278
-			array()
279
-		),
280
-		/** eCommerce Tracking Settings */
281
-		'ecommerce' => apply_filters('monsterinsights_settings_ecommerce',
282
-			array()
283
-		),
284
-		/** Media Tracking Settings */
285
-		'media' => apply_filters('monsterinsights_settings_media',
286
-			array()
287
-		),
288
-		/** Members Tracking Settings */
289
-		'memberships' => apply_filters('monsterinsights_settings_memberships',
290
-			array()
291
-		),
292
-		/** Dimensions Tracking Settings */
293
-		'dimensions' => apply_filters('monsterinsights_settings_dimensions',
294
-			array()
295
-		),
296
-		/** Performance Tracking Settings */
297
-		'performance' => apply_filters('monsterinsights_settings_performance',
298
-			array()
299
-		),
300
-		/** AMP Tracking Settings */
301
-		'amp' => apply_filters('monsterinsights_settings_amp',
302
-			array()
303
-		),
304
-		/** Google Optimize Tracking Settings */
305
-		'goptimize' => apply_filters('monsterinsights_settings_goptimize',
306
-			array()
307
-		),
308
-		/** Facebook Instant Articles Tracking Settings */
309
-		'fbia' => apply_filters('monsterinsights_settings_fbia',
310
-			array()
311
-		),
312
-		/** Bounce Reduction Settings */
313
-		'bounce' => apply_filters('monsterinsights_settings_bounce',
314
-			array()
315
-		),
316
-		/** Reporting Tracking Settings */
317
-		'reporting' => apply_filters('monsterinsights_settings_reporting',
318
-			array()
319
-		),
320
-		/** Notifications Tracking Settings */
321
-		'notifications' => apply_filters('monsterinsights_settings_notifications',
322
-			array()
323
-		),
324
-		/** Compatibility Tracking Settings */
325
-		'compatibility' => apply_filters('monsterinsights_settings_compatibility',
326
-			array(
327
-				'subdomain_tracking' => array(
328
-					'id'          => 'subdomain_tracking',
329
-					'name'        => __( 'Domain to track as:', 'google-analytics-for-wordpress' ),
330
-					'desc'        => sprintf( esc_html__( 'This allows you to %1$sset the domain%2$s that\'s used for tracking. Only is used if set to a value, else defaults to automatic determination. It is very rare that you would need to use this setting.', 'google-analytics-for-wordpress' ), '<a href="https://developers.google.com/analytics/devguides/collection/analyticsjs/tracking-snippet-reference" target="_blank" rel="noopener noreferrer" referrer="no-referrer">' ,'</a>' ),
331
-					'type' 		  => 'text',
332
-				),
333
-				'custom_code' => array(
334
-					'id'          => 'custom_code',
335
-					'name'        => __( 'Custom code', 'google-analytics-for-wordpress' ),
336
-					'desc'        => sprintf( esc_html__( 'Not for the average user: this allows you to add a line of code, to be added before the %1$s call.', 'google-analytics-for-wordpress' ), '<a href="https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiBasicConfiguration#_gat.GA_Tracker_._trackPageview" target="_blank" rel="noopener noreferrer" referrer="no-referrer"><code>_trackPageview</code></a>' ),
337
-					'type' 		  => 'unfiltered_textarea',
338
-				),
339
-				'debug_mode' => array(
340
-					'id'          => 'debug_mode',
341
-					'name'        => __( 'Enable Debug Mode', 'google-analytics-for-wordpress' ),
342
-					'desc'        => __( 'Turns on debugging in JS events tracking, logging of eCommerce requests and enables debug settings.', 'google-analytics-for-wordpress'),
343
-					'type' 		  => 'checkbox',
344
-				),
345
-			)
346
-		),
347
-		/** Permissions Tracking Settings */
348
-		'permissions' => apply_filters('monsterinsights_settings_permissions',
349
-			array(
350
-				'view_reports' => array(
351
-					'id'          => 'view_reports',
352
-					'name'        => __( 'Let these user roles see reports (and the dashboard):', 'google-analytics-for-wordpress' ),
353
-					'desc'        => sprintf( esc_html( 'Users that have at least one of these roles will be able to view the reports and dashboard, along with any user with the %s capability.', 'google-analytics-for-wordpress' ), '<code>manage_options</code>'),
354
-					'type'        => 'select',
355
-					'options'     => monsterinsights_get_roles(),
356
-					'select2'     => true,
357
-					'multiple'    => true,
358
-					'allowclear'  => true
359
-				),
360
-				'save_settings' => array(
361
-					'id'          => 'save_settings',
362
-					'name'        => __( 'Let these user roles save settings:', 'google-analytics-for-wordpress' ),
363
-					'desc'        => sprintf( esc_html__( 'Users that have at least one of these roles will be able to view and save the settings panel, along with any user with the %s capability.', 'google-analytics-for-wordpress'), '<code>manage_options</code>' ),
364
-					'type'        => 'select',
365
-					'options'     => monsterinsights_get_roles(),
366
-					'select2'     => true,
367
-					'multiple'    => true,
368
-					'allowclear'  => true
369
-				),
370
-				'automatic_updates' => array(
371
-					'id'          => 'automatic_updates',
372
-					'name'        => __( 'Automatic Updates', 'google-analytics-for-wordpress' ),
373
-					'type' 		  => 'radio',
374
-					'std'  		  => 'none',
375
-					'options'     => array(
376
-						'all'     => __( 'Yes (Recommended) - Get the latest features, bugfixes, and security updates as they are released.', 'google-analytics-for-wordpress' ),
377
-						'minor'   => __( 'Minor Only - Only get bugfixes and security updates, but not major features.', 'google-analytics-for-wordpress' ),
378
-						'none'    => __( 'None - Manually update everything.', 'google-analytics-for-wordpress' ),
379
-					),
380
-				),
381
-				'anonymous_data' => array(
382
-					'id'          => 'anonymous_data',
383
-					'name'        => __( 'Allow Usage Tracking', 'google-analytics-for-wordpress' ),
384
-					'desc'        => __( 'By allowing us to track usage data we can better help you, because we know with which WordPress configurations, themes and plugins we should test.', 'google-analytics-for-wordpress' ),
385
-					'type' 		  => 'checkbox',
386
-				),
387
-			)
388
-		),
389
-	);
390
-	return apply_filters( 'monsterinsights_registered_settings', $monsterinsights_settings );
135
+    /**
136
+     * Developers Warning: MonsterInsights does not guarantee backwards compatiblity
137
+     * of settings or tabs. We may add/remove settings and/or tabs, or re-arrange the 
138
+     * settings panel as we need to. We provide these filters here right now for internal use only.
139
+     * As such the filters below may be removed or altered at any time, without advance
140
+     * warning or announcement. You've been warned. 
141
+     *
142
+     * We will eventually promise backwards compatibility on these filters below but we want to ensure
143
+     * for the first few major releases after 6.0 we do that the current settings arrangement won't stifle
144
+     * our development progress. Once we're confident we've made the correct decision on settings layout, 
145
+     * we'll remove this notice, and only at that point should you rely on the filters below.
146
+     */
147
+    $monsterinsights_settings = array(
148
+        /** Engagement Settings */
149
+        'engagement' => apply_filters( 'monsterinsights_settings_engagement',
150
+            array(
151
+                'ignore_users' => array(
152
+                    'id'          => 'ignore_users',
153
+                    'name'        => __( 'Ignore these user roles from tracking:', 'google-analytics-for-wordpress' ),
154
+                    'desc'        => __( 'Users that have at least one of these roles will not be tracked into Google Analytics.', 'google-analytics-for-wordpress' ),
155
+                    'type'        => 'select',
156
+                    'options'     => monsterinsights_get_roles(),
157
+                    'select2'     => true,
158
+                    'multiple'    => true,
159
+                    'allowclear'  => true,
160
+                ),
161
+                'events_mode' => array(
162
+                    'id'          => 'events_mode',
163
+                    'name'        => __( 'Track outbound clicks and download links?', 'google-analytics-for-wordpress' ),
164
+                    'desc'        => __( 'We recommend tracking clicks and downloads, so you know where users are exiting your site, and what downloads they are interacting with. ', 'google-analytics-for-wordpress', 'google-analytics-for-wordpress' ),
165
+                    'type' 		  => 'radio',
166
+                    'std'  		  => 'js',
167
+                    'options'     => array(
168
+                        'none' => __( 'No', 'google-analytics-for-wordpress' ),
169
+                        'php'  => __( 'Yes, using PHP (deprecated)', 'google-analytics-for-wordpress' ),
170
+                        'js'   => __( 'Using Javascript (recommended)', 'google-analytics-for-wordpress' ),
171
+                    ),
172
+                ),
173
+            )
174
+        ),
175
+        /** Demographics Settings */
176
+        'demographics' => apply_filters('monsterinsights_settings_demographics',
177
+            array(
178
+                'demographics' => array(
179
+                    'id'          => 'demographics',
180
+                    'name'        => __( 'Enable Demographics and Interests Reports for Remarketing and Advertising', 'google-analytics-for-wordpress' ),
181
+                    'desc'        => sprintf( esc_html__( 'Check this setting to add the Demographics and Remarketing features to your Google Analytics tracking code. Make sure to enable Demographics and Remarketing in your Google Analaytics account. We have a guide for how to do that in our %1$sknowledge base%2$s. For more information about Remarketing, we refer you to %3$sGoogle\'s documentation%2$s.', 'google-analytics-for-wordpress. Note that usage of this function is affected by privacy and cookie laws around the world. Be sure to follow the laws that affect your target audience.' ), '<a href="https://www.monsterinsights.com/docs/enable-demographics-and-interests-report-in-google-analytics/#utm_medium=kb-link&amp;utm_source=gawp-config&amp;utm_campaign=wpgaplugin" target="_blank" rel="noopener noreferrer" referrer="no-referrer">',
182
+                                    '</a>','<a href="https://support.google.com/analytics/answer/2444872?hl=' . get_locale() . '" target="_blank" rel="noopener noreferrer" referrer="no-referrer">'
183
+                    ),
184
+                    'type' 		  => 'checkbox',
185
+                ),
186
+                'anonymize_ips' => array(
187
+                    'id'          => 'anonymize_ips',
188
+                    'name'        => __( 'Anonymize IP addresses?', 'google-analytics-for-wordpress' ),
189
+                    'desc'        => sprintf( esc_html__( 'This adds %1$s, telling Google Analytics to anonymize the information sent by the tracker objects by removing the last octet of the IP address prior to its storage.', 'google-analytics-for-wordpress' ), '<a href="https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApi_gat?csw=1#_gat._anonymizeIp" target="_blank" rel="noopener noreferrer" referrer="no-referrer"><code>_anonymizeIp</code></a>' ),
190
+                    'type' 		  => 'checkbox',
191
+                ),
192
+            )
193
+        ),
194
+        /** Enhanced Link Attribution Settings */
195
+        'links' => apply_filters('monsterinsights_settings_links',
196
+            array(
197
+                'enhanced_link_attribution' => array(
198
+                    'id'          => 'enhanced_link_attribution',
199
+                    'name'        => __( 'Enable enhanced link attribution?', 'google-analytics-for-wordpress' ),
200
+                    'desc'        => sprintf( esc_html__( 'Add %1$sEnhanced Link Attribution%2$s to your tracking code.', 'google-analytics-for-wordpress' ), '<a href="https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-link-attribution" target="_blank" rel="noopener noreferrer" referrer="no-referrer">', ' </a>' ),
201
+                    'type' 		  => 'checkbox',
202
+                ),
203
+                'hash_tracking' => array(
204
+                    'id'          => 'hash_tracking',
205
+                    'name'        => __( 'Turn on anchor tracking', 'google-analytics-for-wordpress' ),
206
+                    'desc'        => esc_html__( 'Many WordPress "1-page" style themes rely on anchor tags for navigation to show virtual pages. The problem is that to Google Analytics, these are all just a single page, and it makes it hard to get meaningful statistics about pages viewed. This feature allows proper tracking in those themes.', 'google-analytics-for-wordpress' ),
207
+                    'type' 		  => 'checkbox',
208
+                ),
209
+                'allow_anchor' => array(
210
+                    'id'          => 'allow_anchor',
211
+                    'name'        => __( 'Turn on allowAnchor', 'google-analytics-for-wordpress' ),
212
+                    'desc'        => sprintf( esc_html__( 'This adds a %1$s call to your tracking code, and makes RSS link tagging use a %2$s as well.', 'google-analytics-for-wordpress' ), '<a href="https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiCampaignTracking?csw=1#_gat.GA_Tracker_._setAllowAnchor" target="_blank" rel="noopener noreferrer" referrer="no-referrer"><code>_setAllowAnchor</code></a>', '<code>#</code>' ),
213
+                    'type' 		  => 'checkbox',
214
+                ),
215
+                'add_allow_linker' => array(
216
+                    'id'          => 'add_allow_linker',
217
+                    'name'        => __( 'Turn on allowLinker', 'google-analytics-for-wordpress' ),
218
+                    'desc'        => sprintf( esc_html__( 'This adds a %1$s call to your tracking code, allowing you to use %2$s and related functions.', 'google-analytics-for-wordpress' ), '<a href="https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiDomainDirectory?csw=1#_gat.GA_Tracker_._setAllowLinker" target="_blank" rel="noopener noreferrer" referrer="no-referrer"><code>_setAllowLinker</code></a>', ' <code>_link</code>' ),
219
+                    'type' 		  => 'checkbox',
220
+                ),
221
+                'tag_links_in_rss' => array(
222
+                    'id'          => 'tag_links_in_rss',
223
+                    'name'        => __( 'Turn on tag links in RSS', 'google-analytics-for-wordpress' ),
224
+                    'desc'        => sprintf( esc_html__( 'Do not use this feature if you use FeedBurner, as FeedBurner can do this automatically and better than this plugin can. Check %1$sthis help page%2$s for info on how to enable this feature in FeedBurner.', 'google-analytics-for-wordpress' ), '<a href="https://support.google.com/feedburner/answer/165769?hl=en&amp;ref_topic=13075" target="_blank" rel="noopener noreferrer" referrer="no-referrer">', '</a>' ),
225
+                    'type' 		  => 'checkbox',
226
+                ),
227
+            )
228
+        ),
229
+        /** File Download Settings */
230
+        'files' => apply_filters('monsterinsights_settings_files',
231
+            array(
232
+                'track_download_as' => array(
233
+                    'id'          => 'track_download_as',
234
+                    'name'        => __( 'Track downloads as an:', 'google-analytics-for-wordpress' ),
235
+                    'desc'        => __( 'Tracking as pageviews is not recommended, as this would skew your statistics, but it does make it possible to track downloads as goals. This feature requires that event tracking be turned on.', 'google-analytics-for-wordpress' ),
236
+                    'type' 		  => 'radio',
237
+                    'std'  		  => 'event',
238
+                    'options'     => array(
239
+                        'event'     => __( 'Event (recommended)', 'google-analytics-for-wordpress' ),
240
+                        'pageview'  => __( 'Pageview', 'google-analytics-for-wordpress' )
241
+                    ),
242
+                ),
243
+                'extensions_of_files' => array( 		/* @todo: Select2 extensions of files */
244
+                    'id'          => 'extensions_of_files',
245
+                    'name'        => __( 'Extensions of files to track as downloads:', 'google-analytics-for-wordpress' ),
246
+                    'desc'        => __( 'If you have enabled event tracking, MonsterInsights will send an event/pageview to GA if a link to a local file has one of the above extensions.', 'google-analytics-for-wordpress' ),
247
+                    'type' 		  => 'text',
248
+                ),
249
+            )
250
+        ),
251
+        /** Affiliate Tracking Settings */
252
+        'affiliates' => apply_filters('monsterinsights_settings_affiliates',
253
+            array(
254
+                'track_internal_as_outbound' => array(
255
+                    'id'          => 'track_internal_as_outbound',
256
+                    'name'        => __( 'Set path for internal links to track as outbound links', 'google-analytics-for-wordpress' ),
257
+                    'desc'        => sprintf( esc_html__( 'If you want to track all internal links that begin with %1$s, enter %1$s in the box above. If you have multiple prefixes you can separate them with comma\'s: %2$s', 'google-analytics-for-wordpress' ), '<code>/out/</code>', '<code>/out/,/recommends/</code>' ),
258
+                    'type' 		  => 'text',
259
+                ),
260
+                'track_internal_as_label' => array(
261
+                    'id'          => 'track_internal_as_label',
262
+                    'name'        => __( 'Label for those links:', 'google-analytics-for-wordpress' ),
263
+                    'desc'        => sprintf( esc_html__( 'The label to use for these links, this will be added to where the click came from, so if the label is %s, the label for a click from the content of an article becomes "outbound-article-aff".', 'google-analytics-for-wordpress' ), '"aff"' ),
264
+                    'type' 		  => 'text',
265
+                ),
266
+            )
267
+        ),
268
+        /** Social Tracking Settings */
269
+        'social' => apply_filters('monsterinsights_settings_social',
270
+            array()
271
+        ),
272
+        /** Ad Tracking Settings */
273
+        'ads' => apply_filters('monsterinsights_settings_ads',
274
+            array()
275
+        ),
276
+        /** Forms Tracking Settings */
277
+        'forms' => apply_filters('monsterinsights_settings_forms',
278
+            array()
279
+        ),
280
+        /** eCommerce Tracking Settings */
281
+        'ecommerce' => apply_filters('monsterinsights_settings_ecommerce',
282
+            array()
283
+        ),
284
+        /** Media Tracking Settings */
285
+        'media' => apply_filters('monsterinsights_settings_media',
286
+            array()
287
+        ),
288
+        /** Members Tracking Settings */
289
+        'memberships' => apply_filters('monsterinsights_settings_memberships',
290
+            array()
291
+        ),
292
+        /** Dimensions Tracking Settings */
293
+        'dimensions' => apply_filters('monsterinsights_settings_dimensions',
294
+            array()
295
+        ),
296
+        /** Performance Tracking Settings */
297
+        'performance' => apply_filters('monsterinsights_settings_performance',
298
+            array()
299
+        ),
300
+        /** AMP Tracking Settings */
301
+        'amp' => apply_filters('monsterinsights_settings_amp',
302
+            array()
303
+        ),
304
+        /** Google Optimize Tracking Settings */
305
+        'goptimize' => apply_filters('monsterinsights_settings_goptimize',
306
+            array()
307
+        ),
308
+        /** Facebook Instant Articles Tracking Settings */
309
+        'fbia' => apply_filters('monsterinsights_settings_fbia',
310
+            array()
311
+        ),
312
+        /** Bounce Reduction Settings */
313
+        'bounce' => apply_filters('monsterinsights_settings_bounce',
314
+            array()
315
+        ),
316
+        /** Reporting Tracking Settings */
317
+        'reporting' => apply_filters('monsterinsights_settings_reporting',
318
+            array()
319
+        ),
320
+        /** Notifications Tracking Settings */
321
+        'notifications' => apply_filters('monsterinsights_settings_notifications',
322
+            array()
323
+        ),
324
+        /** Compatibility Tracking Settings */
325
+        'compatibility' => apply_filters('monsterinsights_settings_compatibility',
326
+            array(
327
+                'subdomain_tracking' => array(
328
+                    'id'          => 'subdomain_tracking',
329
+                    'name'        => __( 'Domain to track as:', 'google-analytics-for-wordpress' ),
330
+                    'desc'        => sprintf( esc_html__( 'This allows you to %1$sset the domain%2$s that\'s used for tracking. Only is used if set to a value, else defaults to automatic determination. It is very rare that you would need to use this setting.', 'google-analytics-for-wordpress' ), '<a href="https://developers.google.com/analytics/devguides/collection/analyticsjs/tracking-snippet-reference" target="_blank" rel="noopener noreferrer" referrer="no-referrer">' ,'</a>' ),
331
+                    'type' 		  => 'text',
332
+                ),
333
+                'custom_code' => array(
334
+                    'id'          => 'custom_code',
335
+                    'name'        => __( 'Custom code', 'google-analytics-for-wordpress' ),
336
+                    'desc'        => sprintf( esc_html__( 'Not for the average user: this allows you to add a line of code, to be added before the %1$s call.', 'google-analytics-for-wordpress' ), '<a href="https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiBasicConfiguration#_gat.GA_Tracker_._trackPageview" target="_blank" rel="noopener noreferrer" referrer="no-referrer"><code>_trackPageview</code></a>' ),
337
+                    'type' 		  => 'unfiltered_textarea',
338
+                ),
339
+                'debug_mode' => array(
340
+                    'id'          => 'debug_mode',
341
+                    'name'        => __( 'Enable Debug Mode', 'google-analytics-for-wordpress' ),
342
+                    'desc'        => __( 'Turns on debugging in JS events tracking, logging of eCommerce requests and enables debug settings.', 'google-analytics-for-wordpress'),
343
+                    'type' 		  => 'checkbox',
344
+                ),
345
+            )
346
+        ),
347
+        /** Permissions Tracking Settings */
348
+        'permissions' => apply_filters('monsterinsights_settings_permissions',
349
+            array(
350
+                'view_reports' => array(
351
+                    'id'          => 'view_reports',
352
+                    'name'        => __( 'Let these user roles see reports (and the dashboard):', 'google-analytics-for-wordpress' ),
353
+                    'desc'        => sprintf( esc_html( 'Users that have at least one of these roles will be able to view the reports and dashboard, along with any user with the %s capability.', 'google-analytics-for-wordpress' ), '<code>manage_options</code>'),
354
+                    'type'        => 'select',
355
+                    'options'     => monsterinsights_get_roles(),
356
+                    'select2'     => true,
357
+                    'multiple'    => true,
358
+                    'allowclear'  => true
359
+                ),
360
+                'save_settings' => array(
361
+                    'id'          => 'save_settings',
362
+                    'name'        => __( 'Let these user roles save settings:', 'google-analytics-for-wordpress' ),
363
+                    'desc'        => sprintf( esc_html__( 'Users that have at least one of these roles will be able to view and save the settings panel, along with any user with the %s capability.', 'google-analytics-for-wordpress'), '<code>manage_options</code>' ),
364
+                    'type'        => 'select',
365
+                    'options'     => monsterinsights_get_roles(),
366
+                    'select2'     => true,
367
+                    'multiple'    => true,
368
+                    'allowclear'  => true
369
+                ),
370
+                'automatic_updates' => array(
371
+                    'id'          => 'automatic_updates',
372
+                    'name'        => __( 'Automatic Updates', 'google-analytics-for-wordpress' ),
373
+                    'type' 		  => 'radio',
374
+                    'std'  		  => 'none',
375
+                    'options'     => array(
376
+                        'all'     => __( 'Yes (Recommended) - Get the latest features, bugfixes, and security updates as they are released.', 'google-analytics-for-wordpress' ),
377
+                        'minor'   => __( 'Minor Only - Only get bugfixes and security updates, but not major features.', 'google-analytics-for-wordpress' ),
378
+                        'none'    => __( 'None - Manually update everything.', 'google-analytics-for-wordpress' ),
379
+                    ),
380
+                ),
381
+                'anonymous_data' => array(
382
+                    'id'          => 'anonymous_data',
383
+                    'name'        => __( 'Allow Usage Tracking', 'google-analytics-for-wordpress' ),
384
+                    'desc'        => __( 'By allowing us to track usage data we can better help you, because we know with which WordPress configurations, themes and plugins we should test.', 'google-analytics-for-wordpress' ),
385
+                    'type' 		  => 'checkbox',
386
+                ),
387
+            )
388
+        ),
389
+    );
390
+    return apply_filters( 'monsterinsights_registered_settings', $monsterinsights_settings );
391 391
 }
Please login to merge, or discard this patch.
includes/admin/settings/tab-status.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
     exit;
15 15
 }
16 16
 
@@ -32,21 +32,21 @@  discard block
 block discarded – undo
32 32
     </div>
33 33
     <?php
34 34
 }
35
-add_action( 'monsterinsights_tab_settings_status', 'monsterinsights_settings_status_tab' );
35
+add_action('monsterinsights_tab_settings_status', 'monsterinsights_settings_status_tab');
36 36
 
37 37
 
38 38
 /**
39 39
  * Output System Info file
40 40
  */
41 41
 function monsterinsights_system_info() {
42
-    if ( ! empty( $_REQUEST['monsterinsights-action'] ) && $_REQUEST['monsterinsights-action'] === 'download_sysinfo' ) {
43
-        if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
42
+    if ( ! empty($_REQUEST['monsterinsights-action']) && $_REQUEST['monsterinsights-action'] === 'download_sysinfo') {
43
+        if ( ! current_user_can('monsterinsights_save_settings')) {
44 44
             return;
45 45
         }
46 46
         nocache_headers();
47
-        header( 'Content-Type: text/plain' );
48
-        header( 'Content-Disposition: attachment; filename="monsterinsights-system-info.txt"' );
49
-        echo wp_strip_all_tags( $_POST['monsterinsights-sysinfo'] );
47
+        header('Content-Type: text/plain');
48
+        header('Content-Disposition: attachment; filename="monsterinsights-system-info.txt"');
49
+        echo wp_strip_all_tags($_POST['monsterinsights-sysinfo']);
50 50
         die();
51 51
     }
52 52
 }
Please login to merge, or discard this patch.