@@ -1,4 +1,4 @@ |
||
1 | 1 | <?php |
2 | 2 | //Nothing to see here |
3 | 3 | |
4 | -header( 'HTTP/1.0 403 Forbidden' ); |
|
5 | 4 | \ No newline at end of file |
5 | +header('HTTP/1.0 403 Forbidden'); |
|
6 | 6 | \ No newline at end of file |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | |
40 | 40 | // Exit if accessed directly. |
41 | -if ( ! defined( 'ABSPATH' ) ) { |
|
41 | +if ( ! defined('ABSPATH')) { |
|
42 | 42 | exit; |
43 | 43 | } |
44 | 44 | |
@@ -145,25 +145,25 @@ discard block |
||
145 | 145 | */ |
146 | 146 | public static function get_instance() { |
147 | 147 | |
148 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof MonsterInsights_Lite ) ) { |
|
148 | + if ( ! isset(self::$instance) && ! (self::$instance instanceof MonsterInsights_Lite)) { |
|
149 | 149 | self::$instance = new MonsterInsights_Lite(); |
150 | 150 | |
151 | 151 | global $wp_version; |
152 | 152 | |
153 | 153 | // Detect non-supported WordPress version and return early |
154 | - if ( version_compare( $wp_version, '3.8', '<' ) && ( ! defined( 'MONSTERINSIGHTS_FORCE_ACTIVATION' ) || ! MONSTERINSIGHTS_FORCE_ACTIVATION ) ) { |
|
155 | - add_action( 'admin_notices', array( self::$instance, 'monsterinsights_wp_notice' ) ); |
|
154 | + if (version_compare($wp_version, '3.8', '<') && ( ! defined('MONSTERINSIGHTS_FORCE_ACTIVATION') || ! MONSTERINSIGHTS_FORCE_ACTIVATION)) { |
|
155 | + add_action('admin_notices', array(self::$instance, 'monsterinsights_wp_notice')); |
|
156 | 156 | return; |
157 | 157 | } |
158 | 158 | |
159 | 159 | // Detect Pro version and return early |
160 | - if ( class_exists( 'MonsterInsights' ) && defined( 'GAWP_VERSION' ) ) { |
|
161 | - add_action( 'admin_notices', array( self::$instance, 'monsterinsights_pro_notice' ) ); |
|
160 | + if (class_exists('MonsterInsights') && defined('GAWP_VERSION')) { |
|
161 | + add_action('admin_notices', array(self::$instance, 'monsterinsights_pro_notice')); |
|
162 | 162 | return; |
163 | 163 | } |
164 | 164 | |
165 | - if ( defined( 'GAWP_ECOMMERCE_PATH' ) ) { |
|
166 | - add_action( 'admin_notices', array( self::$instance, 'monsterinsights_old_ecommerce' ) ); |
|
165 | + if (defined('GAWP_ECOMMERCE_PATH')) { |
|
166 | + add_action('admin_notices', array(self::$instance, 'monsterinsights_old_ecommerce')); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | // Define constants |
@@ -176,38 +176,38 @@ discard block |
||
176 | 176 | self::$instance->require_files(); |
177 | 177 | |
178 | 178 | // This does the version to version background upgrade routines and initial install |
179 | - $mi_version = get_option( 'monsterinsights_current_version', '5.5.3' ); |
|
180 | - if ( version_compare( $mi_version, '6.0.11', '<' ) ) { |
|
179 | + $mi_version = get_option('monsterinsights_current_version', '5.5.3'); |
|
180 | + if (version_compare($mi_version, '6.0.11', '<')) { |
|
181 | 181 | monsterinsights_lite_call_install_and_upgrade(); |
182 | 182 | } |
183 | 183 | |
184 | - if ( is_admin() ) { |
|
185 | - new AM_Notification( 'mi-lite', self::$instance->version ); |
|
186 | - new AM_Deactivation_Survey( 'MonsterInsights', basename( __DIR__ ) ); |
|
184 | + if (is_admin()) { |
|
185 | + new AM_Notification('mi-lite', self::$instance->version); |
|
186 | + new AM_Deactivation_Survey('MonsterInsights', basename(__DIR__)); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | // Load the plugin textdomain. |
190 | - add_action( 'plugins_loaded', array( self::$instance, 'load_plugin_textdomain' ) ); |
|
190 | + add_action('plugins_loaded', array(self::$instance, 'load_plugin_textdomain')); |
|
191 | 191 | |
192 | 192 | // Load GA for admin, lazyload for frontend |
193 | - if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) { |
|
194 | - self::$instance->ga = new MonsterInsights_GA(); |
|
193 | + if (is_admin() || (defined('DOING_CRON') && DOING_CRON)) { |
|
194 | + self::$instance->ga = new MonsterInsights_GA(); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | // Load admin only components. |
198 | - if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) { |
|
198 | + if (is_admin() || (defined('DOING_CRON') && DOING_CRON)) { |
|
199 | 199 | self::$instance->notices = new MonsterInsights_Notice_Admin(); |
200 | 200 | self::$instance->license = new MonsterInsights_License(); |
201 | - self::$instance->reports = new MonsterInsights_Reporting(); |
|
202 | - if ( defined( 'DOING_CRON' ) && DOING_CRON ) { |
|
201 | + self::$instance->reports = new MonsterInsights_Reporting(); |
|
202 | + if (defined('DOING_CRON') && DOING_CRON) { |
|
203 | 203 | self::$instance->require_updater(); |
204 | 204 | } else { |
205 | - add_action( 'admin_init', array( self::$instance, 'require_updater' ) ); |
|
205 | + add_action('admin_init', array(self::$instance, 'require_updater')); |
|
206 | 206 | } |
207 | 207 | } |
208 | 208 | |
209 | 209 | // Run hook to load MonsterInsights addons. |
210 | - do_action( 'monsterinsights_load_plugins' ); // the updater class for each addon needs to be instantiated via `monsterinsights_updater` |
|
210 | + do_action('monsterinsights_load_plugins'); // the updater class for each addon needs to be instantiated via `monsterinsights_updater` |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | return self::$instance; |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | * @return void |
227 | 227 | */ |
228 | 228 | public function __clone() { |
229 | - _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ huh?', 'google-analytics-for-wordpress' ), '6.0.0' ); |
|
229 | + _doing_it_wrong(__FUNCTION__, esc_html__('Cheatin’ huh?', 'google-analytics-for-wordpress'), '6.0.0'); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * @return void |
241 | 241 | */ |
242 | 242 | public function __wakeup() { |
243 | - _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ huh?', 'google-analytics-for-wordpress' ), '6.0.0' ); |
|
243 | + _doing_it_wrong(__FUNCTION__, esc_html__('Cheatin’ huh?', 'google-analytics-for-wordpress'), '6.0.0'); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |
@@ -255,9 +255,9 @@ discard block |
||
255 | 255 | * |
256 | 256 | * @return void |
257 | 257 | */ |
258 | - public function __get( $key ) { |
|
259 | - if ( $key === 'ga' ) { |
|
260 | - if ( empty( self::$instance->ga ) ) { |
|
258 | + public function __get($key) { |
|
259 | + if ($key === 'ga') { |
|
260 | + if (empty(self::$instance->ga)) { |
|
261 | 261 | // LazyLoad GA for Frontend |
262 | 262 | require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/google.php'; |
263 | 263 | self::$instance->ga = new MonsterInsights_GA(); |
@@ -280,48 +280,48 @@ discard block |
||
280 | 280 | */ |
281 | 281 | public function define_globals() { |
282 | 282 | |
283 | - if ( ! defined( 'MONSTERINSIGHTS_VERSION' ) ) { |
|
284 | - define( 'MONSTERINSIGHTS_VERSION', $this->version ); |
|
283 | + if ( ! defined('MONSTERINSIGHTS_VERSION')) { |
|
284 | + define('MONSTERINSIGHTS_VERSION', $this->version); |
|
285 | 285 | } |
286 | 286 | |
287 | - if ( ! defined( 'MONSTERINSIGHTS_LITE_VERSION' ) ) { |
|
288 | - define( 'MONSTERINSIGHTS_LITE_VERSION', MONSTERINSIGHTS_VERSION ); |
|
287 | + if ( ! defined('MONSTERINSIGHTS_LITE_VERSION')) { |
|
288 | + define('MONSTERINSIGHTS_LITE_VERSION', MONSTERINSIGHTS_VERSION); |
|
289 | 289 | } |
290 | 290 | |
291 | - if ( ! defined( 'GAWP_VERSION' ) ) { |
|
292 | - define( 'GAWP_VERSION', MONSTERINSIGHTS_VERSION ); |
|
291 | + if ( ! defined('GAWP_VERSION')) { |
|
292 | + define('GAWP_VERSION', MONSTERINSIGHTS_VERSION); |
|
293 | 293 | } |
294 | 294 | |
295 | - if ( ! defined( 'MONSTERINSIGHTS_PLUGIN_NAME' ) ) { |
|
296 | - define( 'MONSTERINSIGHTS_PLUGIN_NAME', $this->plugin_name ); |
|
295 | + if ( ! defined('MONSTERINSIGHTS_PLUGIN_NAME')) { |
|
296 | + define('MONSTERINSIGHTS_PLUGIN_NAME', $this->plugin_name); |
|
297 | 297 | } |
298 | 298 | |
299 | - if ( ! defined( 'MONSTERINSIGHTS_PLUGIN_SLUG' ) ) { |
|
300 | - define( 'MONSTERINSIGHTS_PLUGIN_SLUG', $this->plugin_slug ); |
|
299 | + if ( ! defined('MONSTERINSIGHTS_PLUGIN_SLUG')) { |
|
300 | + define('MONSTERINSIGHTS_PLUGIN_SLUG', $this->plugin_slug); |
|
301 | 301 | } |
302 | 302 | |
303 | - if ( ! defined( 'MONSTERINSIGHTS_PLUGIN_FILE' ) ) { |
|
304 | - define( 'MONSTERINSIGHTS_PLUGIN_FILE', $this->file ); |
|
303 | + if ( ! defined('MONSTERINSIGHTS_PLUGIN_FILE')) { |
|
304 | + define('MONSTERINSIGHTS_PLUGIN_FILE', $this->file); |
|
305 | 305 | } |
306 | 306 | |
307 | - if ( ! defined( 'GAWP_FILE' ) ) { |
|
308 | - define( 'GAWP_FILE', MONSTERINSIGHTS_PLUGIN_FILE ); |
|
307 | + if ( ! defined('GAWP_FILE')) { |
|
308 | + define('GAWP_FILE', MONSTERINSIGHTS_PLUGIN_FILE); |
|
309 | 309 | } |
310 | 310 | |
311 | - if ( ! defined( 'MONSTERINSIGHTS_PLUGIN_DIR' ) ) { |
|
312 | - define( 'MONSTERINSIGHTS_PLUGIN_DIR', plugin_dir_path( $this->file ) ); |
|
311 | + if ( ! defined('MONSTERINSIGHTS_PLUGIN_DIR')) { |
|
312 | + define('MONSTERINSIGHTS_PLUGIN_DIR', plugin_dir_path($this->file)); |
|
313 | 313 | } |
314 | 314 | |
315 | - if ( ! defined( 'GAWP_PATH' ) ) { |
|
316 | - define( 'GAWP_PATH', MONSTERINSIGHTS_PLUGIN_FILE ); |
|
315 | + if ( ! defined('GAWP_PATH')) { |
|
316 | + define('GAWP_PATH', MONSTERINSIGHTS_PLUGIN_FILE); |
|
317 | 317 | } |
318 | 318 | |
319 | - if ( ! defined( 'MONSTERINSIGHTS_PLUGIN_URL' ) ) { |
|
320 | - define( 'MONSTERINSIGHTS_PLUGIN_URL', plugin_dir_url( $this->file ) ); |
|
319 | + if ( ! defined('MONSTERINSIGHTS_PLUGIN_URL')) { |
|
320 | + define('MONSTERINSIGHTS_PLUGIN_URL', plugin_dir_url($this->file)); |
|
321 | 321 | } |
322 | 322 | |
323 | - if ( ! defined( 'GAWP_URL' ) ) { |
|
324 | - define( 'GAWP_URL', MONSTERINSIGHTS_PLUGIN_URL ); |
|
323 | + if ( ! defined('GAWP_URL')) { |
|
324 | + define('GAWP_URL', MONSTERINSIGHTS_PLUGIN_URL); |
|
325 | 325 | } |
326 | 326 | } |
327 | 327 | |
@@ -336,13 +336,13 @@ discard block |
||
336 | 336 | public function load_plugin_textdomain() { |
337 | 337 | |
338 | 338 | $mi_locale = get_locale(); |
339 | - if ( function_exists( 'get_user_locale' ) ) { |
|
339 | + if (function_exists('get_user_locale')) { |
|
340 | 340 | $mi_locale = get_user_locale(); |
341 | 341 | } |
342 | 342 | |
343 | 343 | // Traditional WordPress plugin locale filter. |
344 | - $mi_locale = apply_filters( 'plugin_locale', $mi_locale, 'google-analytics-for-wordpress' ); |
|
345 | - $mi_mofile = sprintf( '%1$s-%2$s.mo', 'google-analytics-for-wordpress', $mi_locale ); |
|
344 | + $mi_locale = apply_filters('plugin_locale', $mi_locale, 'google-analytics-for-wordpress'); |
|
345 | + $mi_mofile = sprintf('%1$s-%2$s.mo', 'google-analytics-for-wordpress', $mi_locale); |
|
346 | 346 | |
347 | 347 | // Look for wp-content/languages/google-analytics-for-wordpress/google-analytics-for-wordpress-{lang}_{country}.mo |
348 | 348 | $mi_mofile1 = WP_LANG_DIR . '/google-analytics-for-wordpress/' . $mi_mofile; |
@@ -354,17 +354,17 @@ discard block |
||
354 | 354 | $mi_mofile3 = WP_LANG_DIR . '/plugins/' . $mi_mofile; |
355 | 355 | |
356 | 356 | // Look in wp-content/plugins/google-analytics-for-wordpress/languages/google-analytics-for-wordpress-{lang}_{country}.mo |
357 | - $mi_mofile4 = dirname( plugin_basename( MONSTERINSIGHTS_PLUGIN_FILE ) ) . '/languages/'; |
|
358 | - $mi_mofile4 = apply_filters( 'monsterinsights_lite_languages_directory', $mi_mofile4 ); |
|
359 | - |
|
360 | - if ( file_exists( $mi_mofile1 ) ) { |
|
361 | - load_textdomain( 'google-analytics-for-wordpress', $mi_mofile1 ); |
|
362 | - } elseif ( file_exists( $mi_mofile2 ) ) { |
|
363 | - load_textdomain( 'google-analytics-for-wordpress', $mi_mofile2 ); |
|
364 | - } elseif ( file_exists( $mi_mofile3 ) ) { |
|
365 | - load_textdomain( 'google-analytics-for-wordpress', $mi_mofile3 ); |
|
357 | + $mi_mofile4 = dirname(plugin_basename(MONSTERINSIGHTS_PLUGIN_FILE)) . '/languages/'; |
|
358 | + $mi_mofile4 = apply_filters('monsterinsights_lite_languages_directory', $mi_mofile4); |
|
359 | + |
|
360 | + if (file_exists($mi_mofile1)) { |
|
361 | + load_textdomain('google-analytics-for-wordpress', $mi_mofile1); |
|
362 | + } elseif (file_exists($mi_mofile2)) { |
|
363 | + load_textdomain('google-analytics-for-wordpress', $mi_mofile2); |
|
364 | + } elseif (file_exists($mi_mofile3)) { |
|
365 | + load_textdomain('google-analytics-for-wordpress', $mi_mofile3); |
|
366 | 366 | } else { |
367 | - load_plugin_textdomain( 'google-analytics-for-wordpress', false, $mi_mofile4 ); |
|
367 | + load_plugin_textdomain('google-analytics-for-wordpress', false, $mi_mofile4); |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | } |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | public function monsterinsights_old_ecommerce() { |
382 | 382 | ?> |
383 | 383 | <div class="error"> |
384 | - <p><?php echo __( 'The version of MonsterInsights eCommerce addon you have is not compatible with the version of MonsterInsights installed. Please update the eCommerce addon as soon as possible', 'ga-premium' ); ?></p> |
|
384 | + <p><?php echo __('The version of MonsterInsights eCommerce addon you have is not compatible with the version of MonsterInsights installed. Please update the eCommerce addon as soon as possible', 'ga-premium'); ?></p> |
|
385 | 385 | </div> |
386 | 386 | <?php |
387 | 387 | |
@@ -396,14 +396,14 @@ discard block |
||
396 | 396 | * @return void |
397 | 397 | */ |
398 | 398 | public function monsterinsights_wp_notice() { |
399 | - $url = admin_url( 'plugins.php' ); |
|
399 | + $url = admin_url('plugins.php'); |
|
400 | 400 | // Check for MS dashboard |
401 | - if( is_network_admin() ) { |
|
402 | - $url = network_admin_url( 'plugins.php' ); |
|
401 | + if (is_network_admin()) { |
|
402 | + $url = network_admin_url('plugins.php'); |
|
403 | 403 | } |
404 | 404 | ?> |
405 | 405 | <div class="error"> |
406 | - <p><?php echo sprintf( esc_html__( 'Sorry, but your version of WordPress does not meet MonsterInsights\'s required version of %1$s3.8%2$s to run properly. The plugin not been activated. %3$sClick here to return to the Dashboard%4$s.', 'google-analytics-for-wordpress' ), '<strong>', '</strong>', '<a href="' . $url . '">', '</a>' ); ?></p> |
|
406 | + <p><?php echo sprintf(esc_html__('Sorry, but your version of WordPress does not meet MonsterInsights\'s required version of %1$s3.8%2$s to run properly. The plugin not been activated. %3$sClick here to return to the Dashboard%4$s.', 'google-analytics-for-wordpress'), '<strong>', '</strong>', '<a href="' . $url . '">', '</a>'); ?></p> |
|
407 | 407 | </div> |
408 | 408 | <?php |
409 | 409 | } |
@@ -417,14 +417,14 @@ discard block |
||
417 | 417 | * @return void |
418 | 418 | */ |
419 | 419 | public function monsterinsights_pro_notice() { |
420 | - $url = admin_url( 'plugins.php' ); |
|
420 | + $url = admin_url('plugins.php'); |
|
421 | 421 | // Check for MS dashboard |
422 | - if( is_network_admin() ) { |
|
423 | - $url = network_admin_url( 'plugins.php' ); |
|
422 | + if (is_network_admin()) { |
|
423 | + $url = network_admin_url('plugins.php'); |
|
424 | 424 | } |
425 | 425 | ?> |
426 | 426 | <div class="error"> |
427 | - <p><?php echo sprintf( esc_html__( 'Please %1$uninstall%2$s the MonsterInsights Lite Plugin. Your Pro version of MonsterInsights may not work as expected until the Lite version is uninstalled.', 'google-analytics-for-wordpress' ), '<a href="' . $url . '">', '</a>' ); ?></p> |
|
427 | + <p><?php echo sprintf(esc_html__('Please %1$uninstall%2$s the MonsterInsights Lite Plugin. Your Pro version of MonsterInsights may not work as expected until the Lite version is uninstalled.', 'google-analytics-for-wordpress'), '<a href="' . $url . '">', '</a>'); ?></p> |
|
428 | 428 | </div> |
429 | 429 | <?php |
430 | 430 | |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/options.php'; |
446 | 446 | require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/helpers.php'; |
447 | 447 | require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/deprecated.php'; |
448 | - $monsterinsights_settings = monsterinsights_get_options(); |
|
448 | + $monsterinsights_settings = monsterinsights_get_options(); |
|
449 | 449 | } |
450 | 450 | |
451 | 451 | /** |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | */ |
459 | 459 | public function require_files() { |
460 | 460 | |
461 | - if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) { |
|
461 | + if (is_admin() || (defined('DOING_CRON') && DOING_CRON)) { |
|
462 | 462 | |
463 | 463 | // Lite and Pro files |
464 | 464 | require_once MONSTERINSIGHTS_PLUGIN_DIR . 'assets/lib/pandora/class-am-notification.php'; |
@@ -502,11 +502,11 @@ discard block |
||
502 | 502 | require_once MONSTERINSIGHTS_PLUGIN_DIR . 'lite/includes/google.php'; |
503 | 503 | |
504 | 504 | // Lazy Load for Frontend. Load for Admin. |
505 | - if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) { |
|
505 | + if (is_admin() || (defined('DOING_CRON') && DOING_CRON)) { |
|
506 | 506 | require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/google.php'; |
507 | 507 | } |
508 | 508 | |
509 | - if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) { |
|
509 | + if (is_admin() || (defined('DOING_CRON') && DOING_CRON)) { |
|
510 | 510 | require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/googleauth.php'; |
511 | 511 | require_once MONSTERINSIGHTS_PLUGIN_DIR . 'lite/includes/admin/addons.php'; |
512 | 512 | require_once MONSTERINSIGHTS_PLUGIN_DIR . 'lite/includes/admin/tools.php'; |
@@ -533,12 +533,12 @@ discard block |
||
533 | 533 | |
534 | 534 | // Retrieve the license key. If it is not set, return early. |
535 | 535 | $key = monsterinsights_get_license_key(); |
536 | - if ( ! $key ) { |
|
536 | + if ( ! $key) { |
|
537 | 537 | return; |
538 | 538 | } |
539 | 539 | |
540 | 540 | // If there are any errors with the key itself, return early. |
541 | - if ( monsterinsights_get_license_key_errors() ) { |
|
541 | + if (monsterinsights_get_license_key_errors()) { |
|
542 | 542 | return; |
543 | 543 | } |
544 | 544 | |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/licensing/updater.php'; |
547 | 547 | |
548 | 548 | // Fire a hook for Addons to register their updater since we know the key is present. |
549 | - do_action( 'monsterinsights_updater', $key ); |
|
549 | + do_action('monsterinsights_updater', $key); |
|
550 | 550 | } |
551 | 551 | } |
552 | 552 | |
@@ -562,27 +562,27 @@ discard block |
||
562 | 562 | * |
563 | 563 | * @return void |
564 | 564 | */ |
565 | -function monsterinsights_lite_activation_hook( $network_wide ) { |
|
565 | +function monsterinsights_lite_activation_hook($network_wide) { |
|
566 | 566 | |
567 | 567 | global $wp_version; |
568 | 568 | |
569 | - $url = admin_url( 'plugins.php' ); |
|
569 | + $url = admin_url('plugins.php'); |
|
570 | 570 | // Check for MS dashboard |
571 | - if ( is_network_admin() ) { |
|
572 | - $url = network_admin_url( 'plugins.php' ); |
|
571 | + if (is_network_admin()) { |
|
572 | + $url = network_admin_url('plugins.php'); |
|
573 | 573 | } |
574 | 574 | |
575 | - if ( version_compare( $wp_version, '3.8', '<' ) && ( ! defined( 'MONSTERINSIGHTS_FORCE_ACTIVATION' ) || ! MONSTERINSIGHTS_FORCE_ACTIVATION ) ) { |
|
576 | - deactivate_plugins( plugin_basename( __FILE__ ) ); |
|
577 | - wp_die( sprintf( esc_html__( 'Sorry, but your version of WordPress does not meet MonsterInsight\'s required version of %1$s3.8%2$s to run properly. The plugin not been activated. %3$sClick here to return to the Dashboard%4$s.', 'google-analytics-by-wordpress' ), '<strong>', '</strong>', '<a href="' . $url . '">', '</a>' ) ); |
|
575 | + if (version_compare($wp_version, '3.8', '<') && ( ! defined('MONSTERINSIGHTS_FORCE_ACTIVATION') || ! MONSTERINSIGHTS_FORCE_ACTIVATION)) { |
|
576 | + deactivate_plugins(plugin_basename(__FILE__)); |
|
577 | + wp_die(sprintf(esc_html__('Sorry, but your version of WordPress does not meet MonsterInsight\'s required version of %1$s3.8%2$s to run properly. The plugin not been activated. %3$sClick here to return to the Dashboard%4$s.', 'google-analytics-by-wordpress'), '<strong>', '</strong>', '<a href="' . $url . '">', '</a>')); |
|
578 | 578 | } |
579 | 579 | |
580 | - if ( class_exists( 'MonsterInsights' ) ) { |
|
581 | - deactivate_plugins( plugin_basename( __FILE__ ) ); |
|
582 | - wp_die( sprintf( esc_html__( 'Please uninstall and remove MonsterInsights Pro before activating MonsterInsights Lite. The Lite version has not been activated. %1$sClick here to return to the Dashboard%2$s.', 'google-analytics-by-wordpress' ), '<a href="' . $url . '">', '</a>' ) ); |
|
580 | + if (class_exists('MonsterInsights')) { |
|
581 | + deactivate_plugins(plugin_basename(__FILE__)); |
|
582 | + wp_die(sprintf(esc_html__('Please uninstall and remove MonsterInsights Pro before activating MonsterInsights Lite. The Lite version has not been activated. %1$sClick here to return to the Dashboard%2$s.', 'google-analytics-by-wordpress'), '<a href="' . $url . '">', '</a>')); |
|
583 | 583 | } |
584 | 584 | } |
585 | -register_activation_hook( __FILE__, 'monsterinsights_lite_activation_hook' ); |
|
585 | +register_activation_hook(__FILE__, 'monsterinsights_lite_activation_hook'); |
|
586 | 586 | |
587 | 587 | /** |
588 | 588 | * Fired when the plugin is deactivation. |
@@ -592,23 +592,23 @@ discard block |
||
592 | 592 | * |
593 | 593 | * @return void |
594 | 594 | */ |
595 | -function monsterinsights_lite_deactivation_hook( $network_wide ) { |
|
595 | +function monsterinsights_lite_deactivation_hook($network_wide) { |
|
596 | 596 | // Note, if both MI Pro and Lite are active, this is an MI Pro instance |
597 | 597 | // Therefore MI Lite can only use functions of the instance common to |
598 | 598 | // both plugins. If it needs to be pro specific, then include a file that |
599 | 599 | // has that method. |
600 | 600 | $instance = MonsterInsights(); |
601 | 601 | |
602 | - if ( is_multisite() && $network_wide ) { |
|
602 | + if (is_multisite() && $network_wide) { |
|
603 | 603 | $site_list = get_sites(); |
604 | 604 | $options = array( |
605 | 605 | 'cron_failed', |
606 | 606 | 'cron_last_run', |
607 | 607 | ); |
608 | 608 | |
609 | - foreach ( (array) $site_list as $site ) { |
|
610 | - switch_to_blog( $site->blog_id ); |
|
611 | - monsterinsights_delete_options( $options ); |
|
609 | + foreach ((array) $site_list as $site) { |
|
610 | + switch_to_blog($site->blog_id); |
|
611 | + monsterinsights_delete_options($options); |
|
612 | 612 | restore_current_blog(); |
613 | 613 | } |
614 | 614 | } else { |
@@ -616,10 +616,10 @@ discard block |
||
616 | 616 | 'cron_failed', |
617 | 617 | 'cron_last_run', |
618 | 618 | ); |
619 | - monsterinsights_delete_options( $options ); |
|
619 | + monsterinsights_delete_options($options); |
|
620 | 620 | } |
621 | 621 | } |
622 | -register_deactivation_hook( __FILE__, 'monsterinsights_lite_deactivation_hook' ); |
|
622 | +register_deactivation_hook(__FILE__, 'monsterinsights_lite_deactivation_hook'); |
|
623 | 623 | |
624 | 624 | /** |
625 | 625 | * Fired when the plugin is uninstalled. |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | * |
630 | 630 | * @return void |
631 | 631 | */ |
632 | -function monsterinsights_lite_uninstall_hook( $network_wide ) { |
|
632 | +function monsterinsights_lite_uninstall_hook($network_wide) { |
|
633 | 633 | wp_cache_flush(); |
634 | 634 | $instance = MonsterInsights(); |
635 | 635 | |
@@ -637,7 +637,7 @@ discard block |
||
637 | 637 | // Therefore MI Lite can only use functions of the instance common to |
638 | 638 | // both plugins. If it needs to be pro specific, then include a file that |
639 | 639 | // has that method. |
640 | - if ( is_multisite() && $network_wide ) { |
|
640 | + if (is_multisite() && $network_wide) { |
|
641 | 641 | $site_list = get_sites(); |
642 | 642 | |
643 | 643 | $options = array( |
@@ -650,11 +650,11 @@ discard block |
||
650 | 650 | 'cron_last_run', |
651 | 651 | ); |
652 | 652 | |
653 | - foreach ( (array) $site_list as $site ) { |
|
654 | - switch_to_blog( $site->blog_id ); |
|
655 | - monsterinsights_delete_options( $options ); |
|
656 | - delete_option( 'monsterinsights_lite_access_token' ); |
|
657 | - delete_option( 'monsterinsights_lite_refresh_token' ); |
|
653 | + foreach ((array) $site_list as $site) { |
|
654 | + switch_to_blog($site->blog_id); |
|
655 | + monsterinsights_delete_options($options); |
|
656 | + delete_option('monsterinsights_lite_access_token'); |
|
657 | + delete_option('monsterinsights_lite_refresh_token'); |
|
658 | 658 | |
659 | 659 | // Destroy the data |
660 | 660 | $instance->reports->delete_aggregate_data(); |
@@ -670,18 +670,18 @@ discard block |
||
670 | 670 | 'cron_failed', |
671 | 671 | 'cron_last_run', |
672 | 672 | ); |
673 | - monsterinsights_delete_options( $options ); |
|
674 | - delete_option( 'monsterinsights_lite_access_token' ); |
|
675 | - delete_option( 'monsterinsights_lite_refresh_token' ); |
|
673 | + monsterinsights_delete_options($options); |
|
674 | + delete_option('monsterinsights_lite_access_token'); |
|
675 | + delete_option('monsterinsights_lite_refresh_token'); |
|
676 | 676 | |
677 | 677 | // Destroy the data |
678 | - if ( isset( $instance->reports ) && method_exists( $instance->reports,'delete_aggregate_data' ) ) { |
|
678 | + if (isset($instance->reports) && method_exists($instance->reports, 'delete_aggregate_data')) { |
|
679 | 679 | $instance->reports->delete_aggregate_data(); |
680 | 680 | } |
681 | 681 | } |
682 | 682 | |
683 | 683 | } |
684 | -register_uninstall_hook( __FILE__, 'monsterinsights_lite_uninstall_hook' ); |
|
684 | +register_uninstall_hook(__FILE__, 'monsterinsights_lite_uninstall_hook'); |
|
685 | 685 | |
686 | 686 | /** |
687 | 687 | * The main function responsible for returning the one true MonsterInsights_Lite |
@@ -722,15 +722,15 @@ discard block |
||
722 | 722 | global $wp_version; |
723 | 723 | |
724 | 724 | // If the WordPress site doesn't meet the correct WP version requirements, don't activate MonsterInsights |
725 | - if ( version_compare( $wp_version, '3.8', '<' ) ) { |
|
726 | - if ( is_plugin_active( plugin_basename( __FILE__ ) ) ) { |
|
725 | + if (version_compare($wp_version, '3.8', '<')) { |
|
726 | + if (is_plugin_active(plugin_basename(__FILE__))) { |
|
727 | 727 | return; |
728 | 728 | } |
729 | 729 | } |
730 | 730 | |
731 | 731 | // Don't run if MI Pro is installed |
732 | - if ( class_exists( 'MonsterInsights' ) ) { |
|
733 | - if ( is_plugin_active( plugin_basename( __FILE__ ) ) ) { |
|
732 | + if (class_exists('MonsterInsights')) { |
|
733 | + if (is_plugin_active(plugin_basename(__FILE__))) { |
|
734 | 734 | return; |
735 | 735 | } |
736 | 736 | } |
@@ -763,8 +763,8 @@ discard block |
||
763 | 763 | * |
764 | 764 | * @return void |
765 | 765 | */ |
766 | -function monsterinsights_lite_call_install_and_upgrade(){ |
|
767 | - add_action( 'wp_loaded', 'monsterinsights_lite_install_and_upgrade' ); |
|
766 | +function monsterinsights_lite_call_install_and_upgrade() { |
|
767 | + add_action('wp_loaded', 'monsterinsights_lite_install_and_upgrade'); |
|
768 | 768 | } |
769 | 769 | |
770 | 770 | /** |
@@ -790,9 +790,9 @@ discard block |
||
790 | 790 | * |
791 | 791 | * @return MonsterInsights The singleton MonsterInsights instance. |
792 | 792 | */ |
793 | -if ( ! function_exists( 'MonsterInsights' ) ) { |
|
793 | +if ( ! function_exists('MonsterInsights')) { |
|
794 | 794 | function MonsterInsights() { |
795 | - return ( class_exists( 'MonsterInsights' ) ? MonsterInsights_Pro() : MonsterInsights_Lite() ); |
|
795 | + return (class_exists('MonsterInsights') ? MonsterInsights_Pro() : MonsterInsights_Lite()); |
|
796 | 796 | } |
797 | - add_action( 'plugins_loaded', 'MonsterInsights' ); |
|
797 | + add_action('plugins_loaded', 'MonsterInsights'); |
|
798 | 798 | } |
799 | 799 | \ No newline at end of file |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | |
40 | 40 | // Exit if accessed directly. |
41 | 41 | if ( ! defined( 'ABSPATH' ) ) { |
42 | - exit; |
|
42 | + exit; |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -53,501 +53,501 @@ discard block |
||
53 | 53 | */ |
54 | 54 | final class MonsterInsights_Lite { |
55 | 55 | |
56 | - /** |
|
57 | - * Holds the class object. |
|
58 | - * |
|
59 | - * @since 6.0.0 |
|
60 | - * @access public |
|
61 | - * @var object Instance of instantiated MonsterInsights class. |
|
62 | - */ |
|
63 | - public static $instance; |
|
64 | - |
|
65 | - /** |
|
66 | - * Plugin version, used for cache-busting of style and script file references. |
|
67 | - * |
|
68 | - * @since 6.0.0 |
|
69 | - * @access public |
|
70 | - * @var string $version Plugin version. |
|
71 | - */ |
|
72 | - public $version = '6.2.3'; |
|
73 | - |
|
74 | - /** |
|
75 | - * Plugin file. |
|
76 | - * |
|
77 | - * @since 6.0.0 |
|
78 | - * @access public |
|
79 | - * @var string $file PHP File constant for main file. |
|
80 | - */ |
|
81 | - public $file = __FILE__; |
|
82 | - |
|
83 | - /** |
|
84 | - * The name of the plugin. |
|
85 | - * |
|
86 | - * @since 6.0.0 |
|
87 | - * @access public |
|
88 | - * @var string $plugin_name Plugin name. |
|
89 | - */ |
|
90 | - public $plugin_name = 'MonsterInsights Lite'; |
|
91 | - |
|
92 | - /** |
|
93 | - * Unique plugin slug identifier. |
|
94 | - * |
|
95 | - * @since 6.0.0 |
|
96 | - * @access public |
|
97 | - * @var string $plugin_slug Plugin slug. |
|
98 | - */ |
|
99 | - public $plugin_slug = 'monsterinsights-lite'; |
|
100 | - |
|
101 | - /** |
|
102 | - * Holds instance of MonsterInsights Admin Notice class. |
|
103 | - * |
|
104 | - * @since 6.0.0 |
|
105 | - * @access public |
|
106 | - * @var MonsterInsights_Admin_Notice $notices Instance of Admin Notice class. |
|
107 | - */ |
|
108 | - public $notices; |
|
109 | - |
|
110 | - /** |
|
111 | - * Holds instance of MonsterInsights License class. |
|
112 | - * |
|
113 | - * @since 6.0.0 |
|
114 | - * @access public |
|
115 | - * @var MonsterInsights_License $license Instance of License class. |
|
116 | - */ |
|
117 | - public $license; |
|
118 | - |
|
119 | - /** |
|
120 | - * Holds instance of MonsterInsights GA class. |
|
121 | - * |
|
122 | - * @since 6.0.0 |
|
123 | - * @access public |
|
124 | - * @var MonsterInsights_GA $ga Instance of GA class. |
|
125 | - */ |
|
126 | - protected $ga; |
|
127 | - |
|
128 | - /** |
|
129 | - * Primary class constructor. |
|
130 | - * |
|
131 | - * @since 6.0.0 |
|
132 | - * @access public |
|
133 | - */ |
|
134 | - public function __construct() { |
|
135 | - // We don't use this |
|
136 | - } |
|
137 | - |
|
138 | - /** |
|
139 | - * Returns the singleton instance of the class. |
|
140 | - * |
|
141 | - * @access public |
|
142 | - * @since 6.0.0 |
|
143 | - * |
|
144 | - * @return object The MonsterInsights_Lite object. |
|
145 | - */ |
|
146 | - public static function get_instance() { |
|
147 | - |
|
148 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof MonsterInsights_Lite ) ) { |
|
149 | - self::$instance = new MonsterInsights_Lite(); |
|
150 | - |
|
151 | - global $wp_version; |
|
152 | - |
|
153 | - // Detect non-supported WordPress version and return early |
|
154 | - if ( version_compare( $wp_version, '3.8', '<' ) && ( ! defined( 'MONSTERINSIGHTS_FORCE_ACTIVATION' ) || ! MONSTERINSIGHTS_FORCE_ACTIVATION ) ) { |
|
155 | - add_action( 'admin_notices', array( self::$instance, 'monsterinsights_wp_notice' ) ); |
|
156 | - return; |
|
157 | - } |
|
56 | + /** |
|
57 | + * Holds the class object. |
|
58 | + * |
|
59 | + * @since 6.0.0 |
|
60 | + * @access public |
|
61 | + * @var object Instance of instantiated MonsterInsights class. |
|
62 | + */ |
|
63 | + public static $instance; |
|
64 | + |
|
65 | + /** |
|
66 | + * Plugin version, used for cache-busting of style and script file references. |
|
67 | + * |
|
68 | + * @since 6.0.0 |
|
69 | + * @access public |
|
70 | + * @var string $version Plugin version. |
|
71 | + */ |
|
72 | + public $version = '6.2.3'; |
|
73 | + |
|
74 | + /** |
|
75 | + * Plugin file. |
|
76 | + * |
|
77 | + * @since 6.0.0 |
|
78 | + * @access public |
|
79 | + * @var string $file PHP File constant for main file. |
|
80 | + */ |
|
81 | + public $file = __FILE__; |
|
82 | + |
|
83 | + /** |
|
84 | + * The name of the plugin. |
|
85 | + * |
|
86 | + * @since 6.0.0 |
|
87 | + * @access public |
|
88 | + * @var string $plugin_name Plugin name. |
|
89 | + */ |
|
90 | + public $plugin_name = 'MonsterInsights Lite'; |
|
91 | + |
|
92 | + /** |
|
93 | + * Unique plugin slug identifier. |
|
94 | + * |
|
95 | + * @since 6.0.0 |
|
96 | + * @access public |
|
97 | + * @var string $plugin_slug Plugin slug. |
|
98 | + */ |
|
99 | + public $plugin_slug = 'monsterinsights-lite'; |
|
100 | + |
|
101 | + /** |
|
102 | + * Holds instance of MonsterInsights Admin Notice class. |
|
103 | + * |
|
104 | + * @since 6.0.0 |
|
105 | + * @access public |
|
106 | + * @var MonsterInsights_Admin_Notice $notices Instance of Admin Notice class. |
|
107 | + */ |
|
108 | + public $notices; |
|
109 | + |
|
110 | + /** |
|
111 | + * Holds instance of MonsterInsights License class. |
|
112 | + * |
|
113 | + * @since 6.0.0 |
|
114 | + * @access public |
|
115 | + * @var MonsterInsights_License $license Instance of License class. |
|
116 | + */ |
|
117 | + public $license; |
|
118 | + |
|
119 | + /** |
|
120 | + * Holds instance of MonsterInsights GA class. |
|
121 | + * |
|
122 | + * @since 6.0.0 |
|
123 | + * @access public |
|
124 | + * @var MonsterInsights_GA $ga Instance of GA class. |
|
125 | + */ |
|
126 | + protected $ga; |
|
127 | + |
|
128 | + /** |
|
129 | + * Primary class constructor. |
|
130 | + * |
|
131 | + * @since 6.0.0 |
|
132 | + * @access public |
|
133 | + */ |
|
134 | + public function __construct() { |
|
135 | + // We don't use this |
|
136 | + } |
|
137 | + |
|
138 | + /** |
|
139 | + * Returns the singleton instance of the class. |
|
140 | + * |
|
141 | + * @access public |
|
142 | + * @since 6.0.0 |
|
143 | + * |
|
144 | + * @return object The MonsterInsights_Lite object. |
|
145 | + */ |
|
146 | + public static function get_instance() { |
|
147 | + |
|
148 | + if ( ! isset( self::$instance ) && ! ( self::$instance instanceof MonsterInsights_Lite ) ) { |
|
149 | + self::$instance = new MonsterInsights_Lite(); |
|
150 | + |
|
151 | + global $wp_version; |
|
152 | + |
|
153 | + // Detect non-supported WordPress version and return early |
|
154 | + if ( version_compare( $wp_version, '3.8', '<' ) && ( ! defined( 'MONSTERINSIGHTS_FORCE_ACTIVATION' ) || ! MONSTERINSIGHTS_FORCE_ACTIVATION ) ) { |
|
155 | + add_action( 'admin_notices', array( self::$instance, 'monsterinsights_wp_notice' ) ); |
|
156 | + return; |
|
157 | + } |
|
158 | 158 | |
159 | - // Detect Pro version and return early |
|
160 | - if ( class_exists( 'MonsterInsights' ) && defined( 'GAWP_VERSION' ) ) { |
|
161 | - add_action( 'admin_notices', array( self::$instance, 'monsterinsights_pro_notice' ) ); |
|
162 | - return; |
|
163 | - } |
|
164 | - |
|
165 | - if ( defined( 'GAWP_ECOMMERCE_PATH' ) ) { |
|
166 | - add_action( 'admin_notices', array( self::$instance, 'monsterinsights_old_ecommerce' ) ); |
|
167 | - } |
|
159 | + // Detect Pro version and return early |
|
160 | + if ( class_exists( 'MonsterInsights' ) && defined( 'GAWP_VERSION' ) ) { |
|
161 | + add_action( 'admin_notices', array( self::$instance, 'monsterinsights_pro_notice' ) ); |
|
162 | + return; |
|
163 | + } |
|
164 | + |
|
165 | + if ( defined( 'GAWP_ECOMMERCE_PATH' ) ) { |
|
166 | + add_action( 'admin_notices', array( self::$instance, 'monsterinsights_old_ecommerce' ) ); |
|
167 | + } |
|
168 | 168 | |
169 | - // Define constants |
|
170 | - self::$instance->define_globals(); |
|
171 | - |
|
172 | - // Load in settings |
|
173 | - self::$instance->load_settings(); |
|
174 | - |
|
175 | - // Load files |
|
176 | - self::$instance->require_files(); |
|
177 | - |
|
178 | - // This does the version to version background upgrade routines and initial install |
|
179 | - $mi_version = get_option( 'monsterinsights_current_version', '5.5.3' ); |
|
180 | - if ( version_compare( $mi_version, '6.0.11', '<' ) ) { |
|
181 | - monsterinsights_lite_call_install_and_upgrade(); |
|
182 | - } |
|
183 | - |
|
184 | - if ( is_admin() ) { |
|
185 | - new AM_Notification( 'mi-lite', self::$instance->version ); |
|
186 | - new AM_Deactivation_Survey( 'MonsterInsights', basename( __DIR__ ) ); |
|
187 | - } |
|
188 | - |
|
189 | - // Load the plugin textdomain. |
|
190 | - add_action( 'plugins_loaded', array( self::$instance, 'load_plugin_textdomain' ) ); |
|
191 | - |
|
192 | - // Load GA for admin, lazyload for frontend |
|
193 | - if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) { |
|
194 | - self::$instance->ga = new MonsterInsights_GA(); |
|
195 | - } |
|
196 | - |
|
197 | - // Load admin only components. |
|
198 | - if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) { |
|
199 | - self::$instance->notices = new MonsterInsights_Notice_Admin(); |
|
200 | - self::$instance->license = new MonsterInsights_License(); |
|
201 | - self::$instance->reports = new MonsterInsights_Reporting(); |
|
202 | - if ( defined( 'DOING_CRON' ) && DOING_CRON ) { |
|
203 | - self::$instance->require_updater(); |
|
204 | - } else { |
|
205 | - add_action( 'admin_init', array( self::$instance, 'require_updater' ) ); |
|
206 | - } |
|
207 | - } |
|
208 | - |
|
209 | - // Run hook to load MonsterInsights addons. |
|
210 | - do_action( 'monsterinsights_load_plugins' ); // the updater class for each addon needs to be instantiated via `monsterinsights_updater` |
|
211 | - } |
|
212 | - |
|
213 | - return self::$instance; |
|
214 | - |
|
215 | - } |
|
216 | - |
|
217 | - /** |
|
218 | - * Throw error on object clone |
|
219 | - * |
|
220 | - * The whole idea of the singleton design pattern is that there is a single |
|
221 | - * object therefore, we don't want the object to be cloned. |
|
222 | - * |
|
223 | - * @since 6.0.0 |
|
224 | - * @access public |
|
225 | - * |
|
226 | - * @return void |
|
227 | - */ |
|
228 | - public function __clone() { |
|
229 | - _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ huh?', 'google-analytics-for-wordpress' ), '6.0.0' ); |
|
230 | - } |
|
231 | - |
|
232 | - /** |
|
233 | - * Disable unserializing of the class |
|
234 | - * |
|
235 | - * Attempting to wakeup an MonsterInsights instance will throw a doing it wrong notice. |
|
236 | - * |
|
237 | - * @since 6.0.0 |
|
238 | - * @access public |
|
239 | - * |
|
240 | - * @return void |
|
241 | - */ |
|
242 | - public function __wakeup() { |
|
243 | - _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ huh?', 'google-analytics-for-wordpress' ), '6.0.0' ); |
|
244 | - } |
|
245 | - |
|
246 | - /** |
|
247 | - * Magic get function. |
|
248 | - * |
|
249 | - * We use this to lazy load certain functionality. Right now used to lazyload |
|
250 | - * the Google Object for frontend, so it's only loaded if user is using a plugin |
|
251 | - * that requires it. |
|
252 | - * |
|
253 | - * @since 6.0.10 |
|
254 | - * @access public |
|
255 | - * |
|
256 | - * @return void |
|
257 | - */ |
|
258 | - public function __get( $key ) { |
|
259 | - if ( $key === 'ga' ) { |
|
260 | - if ( empty( self::$instance->ga ) ) { |
|
261 | - // LazyLoad GA for Frontend |
|
262 | - require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/google.php'; |
|
263 | - self::$instance->ga = new MonsterInsights_GA(); |
|
264 | - } |
|
265 | - return self::$instance->$key; |
|
266 | - } else { |
|
267 | - return self::$instance->$key; |
|
268 | - } |
|
269 | - } |
|
270 | - |
|
271 | - /** |
|
272 | - * Define MonsterInsights constants. |
|
273 | - * |
|
274 | - * This function defines all of the MonsterInsights PHP constants. |
|
275 | - * |
|
276 | - * @since 6.0.0 |
|
277 | - * @access public |
|
278 | - * |
|
279 | - * @return void |
|
280 | - */ |
|
281 | - public function define_globals() { |
|
282 | - |
|
283 | - if ( ! defined( 'MONSTERINSIGHTS_VERSION' ) ) { |
|
284 | - define( 'MONSTERINSIGHTS_VERSION', $this->version ); |
|
285 | - } |
|
286 | - |
|
287 | - if ( ! defined( 'MONSTERINSIGHTS_LITE_VERSION' ) ) { |
|
288 | - define( 'MONSTERINSIGHTS_LITE_VERSION', MONSTERINSIGHTS_VERSION ); |
|
289 | - } |
|
290 | - |
|
291 | - if ( ! defined( 'GAWP_VERSION' ) ) { |
|
292 | - define( 'GAWP_VERSION', MONSTERINSIGHTS_VERSION ); |
|
293 | - } |
|
294 | - |
|
295 | - if ( ! defined( 'MONSTERINSIGHTS_PLUGIN_NAME' ) ) { |
|
296 | - define( 'MONSTERINSIGHTS_PLUGIN_NAME', $this->plugin_name ); |
|
297 | - } |
|
298 | - |
|
299 | - if ( ! defined( 'MONSTERINSIGHTS_PLUGIN_SLUG' ) ) { |
|
300 | - define( 'MONSTERINSIGHTS_PLUGIN_SLUG', $this->plugin_slug ); |
|
301 | - } |
|
302 | - |
|
303 | - if ( ! defined( 'MONSTERINSIGHTS_PLUGIN_FILE' ) ) { |
|
304 | - define( 'MONSTERINSIGHTS_PLUGIN_FILE', $this->file ); |
|
305 | - } |
|
306 | - |
|
307 | - if ( ! defined( 'GAWP_FILE' ) ) { |
|
308 | - define( 'GAWP_FILE', MONSTERINSIGHTS_PLUGIN_FILE ); |
|
309 | - } |
|
310 | - |
|
311 | - if ( ! defined( 'MONSTERINSIGHTS_PLUGIN_DIR' ) ) { |
|
312 | - define( 'MONSTERINSIGHTS_PLUGIN_DIR', plugin_dir_path( $this->file ) ); |
|
313 | - } |
|
314 | - |
|
315 | - if ( ! defined( 'GAWP_PATH' ) ) { |
|
316 | - define( 'GAWP_PATH', MONSTERINSIGHTS_PLUGIN_FILE ); |
|
317 | - } |
|
318 | - |
|
319 | - if ( ! defined( 'MONSTERINSIGHTS_PLUGIN_URL' ) ) { |
|
320 | - define( 'MONSTERINSIGHTS_PLUGIN_URL', plugin_dir_url( $this->file ) ); |
|
321 | - } |
|
322 | - |
|
323 | - if ( ! defined( 'GAWP_URL' ) ) { |
|
324 | - define( 'GAWP_URL', MONSTERINSIGHTS_PLUGIN_URL ); |
|
325 | - } |
|
326 | - } |
|
327 | - |
|
328 | - /** |
|
329 | - * Loads the plugin textdomain for translation. |
|
330 | - * |
|
331 | - * @access public |
|
332 | - * @since 6.0.0 |
|
333 | - * |
|
334 | - * @return void |
|
335 | - */ |
|
336 | - public function load_plugin_textdomain() { |
|
337 | - |
|
338 | - $mi_locale = get_locale(); |
|
339 | - if ( function_exists( 'get_user_locale' ) ) { |
|
340 | - $mi_locale = get_user_locale(); |
|
341 | - } |
|
342 | - |
|
343 | - // Traditional WordPress plugin locale filter. |
|
344 | - $mi_locale = apply_filters( 'plugin_locale', $mi_locale, 'google-analytics-for-wordpress' ); |
|
345 | - $mi_mofile = sprintf( '%1$s-%2$s.mo', 'google-analytics-for-wordpress', $mi_locale ); |
|
169 | + // Define constants |
|
170 | + self::$instance->define_globals(); |
|
171 | + |
|
172 | + // Load in settings |
|
173 | + self::$instance->load_settings(); |
|
174 | + |
|
175 | + // Load files |
|
176 | + self::$instance->require_files(); |
|
177 | + |
|
178 | + // This does the version to version background upgrade routines and initial install |
|
179 | + $mi_version = get_option( 'monsterinsights_current_version', '5.5.3' ); |
|
180 | + if ( version_compare( $mi_version, '6.0.11', '<' ) ) { |
|
181 | + monsterinsights_lite_call_install_and_upgrade(); |
|
182 | + } |
|
183 | + |
|
184 | + if ( is_admin() ) { |
|
185 | + new AM_Notification( 'mi-lite', self::$instance->version ); |
|
186 | + new AM_Deactivation_Survey( 'MonsterInsights', basename( __DIR__ ) ); |
|
187 | + } |
|
188 | + |
|
189 | + // Load the plugin textdomain. |
|
190 | + add_action( 'plugins_loaded', array( self::$instance, 'load_plugin_textdomain' ) ); |
|
191 | + |
|
192 | + // Load GA for admin, lazyload for frontend |
|
193 | + if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) { |
|
194 | + self::$instance->ga = new MonsterInsights_GA(); |
|
195 | + } |
|
196 | + |
|
197 | + // Load admin only components. |
|
198 | + if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) { |
|
199 | + self::$instance->notices = new MonsterInsights_Notice_Admin(); |
|
200 | + self::$instance->license = new MonsterInsights_License(); |
|
201 | + self::$instance->reports = new MonsterInsights_Reporting(); |
|
202 | + if ( defined( 'DOING_CRON' ) && DOING_CRON ) { |
|
203 | + self::$instance->require_updater(); |
|
204 | + } else { |
|
205 | + add_action( 'admin_init', array( self::$instance, 'require_updater' ) ); |
|
206 | + } |
|
207 | + } |
|
208 | + |
|
209 | + // Run hook to load MonsterInsights addons. |
|
210 | + do_action( 'monsterinsights_load_plugins' ); // the updater class for each addon needs to be instantiated via `monsterinsights_updater` |
|
211 | + } |
|
212 | + |
|
213 | + return self::$instance; |
|
214 | + |
|
215 | + } |
|
216 | + |
|
217 | + /** |
|
218 | + * Throw error on object clone |
|
219 | + * |
|
220 | + * The whole idea of the singleton design pattern is that there is a single |
|
221 | + * object therefore, we don't want the object to be cloned. |
|
222 | + * |
|
223 | + * @since 6.0.0 |
|
224 | + * @access public |
|
225 | + * |
|
226 | + * @return void |
|
227 | + */ |
|
228 | + public function __clone() { |
|
229 | + _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ huh?', 'google-analytics-for-wordpress' ), '6.0.0' ); |
|
230 | + } |
|
231 | + |
|
232 | + /** |
|
233 | + * Disable unserializing of the class |
|
234 | + * |
|
235 | + * Attempting to wakeup an MonsterInsights instance will throw a doing it wrong notice. |
|
236 | + * |
|
237 | + * @since 6.0.0 |
|
238 | + * @access public |
|
239 | + * |
|
240 | + * @return void |
|
241 | + */ |
|
242 | + public function __wakeup() { |
|
243 | + _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ huh?', 'google-analytics-for-wordpress' ), '6.0.0' ); |
|
244 | + } |
|
245 | + |
|
246 | + /** |
|
247 | + * Magic get function. |
|
248 | + * |
|
249 | + * We use this to lazy load certain functionality. Right now used to lazyload |
|
250 | + * the Google Object for frontend, so it's only loaded if user is using a plugin |
|
251 | + * that requires it. |
|
252 | + * |
|
253 | + * @since 6.0.10 |
|
254 | + * @access public |
|
255 | + * |
|
256 | + * @return void |
|
257 | + */ |
|
258 | + public function __get( $key ) { |
|
259 | + if ( $key === 'ga' ) { |
|
260 | + if ( empty( self::$instance->ga ) ) { |
|
261 | + // LazyLoad GA for Frontend |
|
262 | + require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/google.php'; |
|
263 | + self::$instance->ga = new MonsterInsights_GA(); |
|
264 | + } |
|
265 | + return self::$instance->$key; |
|
266 | + } else { |
|
267 | + return self::$instance->$key; |
|
268 | + } |
|
269 | + } |
|
270 | + |
|
271 | + /** |
|
272 | + * Define MonsterInsights constants. |
|
273 | + * |
|
274 | + * This function defines all of the MonsterInsights PHP constants. |
|
275 | + * |
|
276 | + * @since 6.0.0 |
|
277 | + * @access public |
|
278 | + * |
|
279 | + * @return void |
|
280 | + */ |
|
281 | + public function define_globals() { |
|
282 | + |
|
283 | + if ( ! defined( 'MONSTERINSIGHTS_VERSION' ) ) { |
|
284 | + define( 'MONSTERINSIGHTS_VERSION', $this->version ); |
|
285 | + } |
|
286 | + |
|
287 | + if ( ! defined( 'MONSTERINSIGHTS_LITE_VERSION' ) ) { |
|
288 | + define( 'MONSTERINSIGHTS_LITE_VERSION', MONSTERINSIGHTS_VERSION ); |
|
289 | + } |
|
290 | + |
|
291 | + if ( ! defined( 'GAWP_VERSION' ) ) { |
|
292 | + define( 'GAWP_VERSION', MONSTERINSIGHTS_VERSION ); |
|
293 | + } |
|
294 | + |
|
295 | + if ( ! defined( 'MONSTERINSIGHTS_PLUGIN_NAME' ) ) { |
|
296 | + define( 'MONSTERINSIGHTS_PLUGIN_NAME', $this->plugin_name ); |
|
297 | + } |
|
298 | + |
|
299 | + if ( ! defined( 'MONSTERINSIGHTS_PLUGIN_SLUG' ) ) { |
|
300 | + define( 'MONSTERINSIGHTS_PLUGIN_SLUG', $this->plugin_slug ); |
|
301 | + } |
|
302 | + |
|
303 | + if ( ! defined( 'MONSTERINSIGHTS_PLUGIN_FILE' ) ) { |
|
304 | + define( 'MONSTERINSIGHTS_PLUGIN_FILE', $this->file ); |
|
305 | + } |
|
306 | + |
|
307 | + if ( ! defined( 'GAWP_FILE' ) ) { |
|
308 | + define( 'GAWP_FILE', MONSTERINSIGHTS_PLUGIN_FILE ); |
|
309 | + } |
|
310 | + |
|
311 | + if ( ! defined( 'MONSTERINSIGHTS_PLUGIN_DIR' ) ) { |
|
312 | + define( 'MONSTERINSIGHTS_PLUGIN_DIR', plugin_dir_path( $this->file ) ); |
|
313 | + } |
|
314 | + |
|
315 | + if ( ! defined( 'GAWP_PATH' ) ) { |
|
316 | + define( 'GAWP_PATH', MONSTERINSIGHTS_PLUGIN_FILE ); |
|
317 | + } |
|
318 | + |
|
319 | + if ( ! defined( 'MONSTERINSIGHTS_PLUGIN_URL' ) ) { |
|
320 | + define( 'MONSTERINSIGHTS_PLUGIN_URL', plugin_dir_url( $this->file ) ); |
|
321 | + } |
|
322 | + |
|
323 | + if ( ! defined( 'GAWP_URL' ) ) { |
|
324 | + define( 'GAWP_URL', MONSTERINSIGHTS_PLUGIN_URL ); |
|
325 | + } |
|
326 | + } |
|
327 | + |
|
328 | + /** |
|
329 | + * Loads the plugin textdomain for translation. |
|
330 | + * |
|
331 | + * @access public |
|
332 | + * @since 6.0.0 |
|
333 | + * |
|
334 | + * @return void |
|
335 | + */ |
|
336 | + public function load_plugin_textdomain() { |
|
337 | + |
|
338 | + $mi_locale = get_locale(); |
|
339 | + if ( function_exists( 'get_user_locale' ) ) { |
|
340 | + $mi_locale = get_user_locale(); |
|
341 | + } |
|
342 | + |
|
343 | + // Traditional WordPress plugin locale filter. |
|
344 | + $mi_locale = apply_filters( 'plugin_locale', $mi_locale, 'google-analytics-for-wordpress' ); |
|
345 | + $mi_mofile = sprintf( '%1$s-%2$s.mo', 'google-analytics-for-wordpress', $mi_locale ); |
|
346 | 346 | |
347 | - // Look for wp-content/languages/google-analytics-for-wordpress/google-analytics-for-wordpress-{lang}_{country}.mo |
|
348 | - $mi_mofile1 = WP_LANG_DIR . '/google-analytics-for-wordpress/' . $mi_mofile; |
|
349 | - |
|
350 | - // Look in wp-content/languages/plugins/google-analytics-for-wordpress/google-analytics-for-wordpress-{lang}_{country}.mo |
|
351 | - $mi_mofile2 = WP_LANG_DIR . '/plugins/google-analytics-for-wordpress/' . $mi_mofile; |
|
352 | - |
|
353 | - // Look in wp-content/languages/plugins/google-analytics-for-wordpress-{lang}_{country}.mo |
|
354 | - $mi_mofile3 = WP_LANG_DIR . '/plugins/' . $mi_mofile; |
|
355 | - |
|
356 | - // Look in wp-content/plugins/google-analytics-for-wordpress/languages/google-analytics-for-wordpress-{lang}_{country}.mo |
|
357 | - $mi_mofile4 = dirname( plugin_basename( MONSTERINSIGHTS_PLUGIN_FILE ) ) . '/languages/'; |
|
358 | - $mi_mofile4 = apply_filters( 'monsterinsights_lite_languages_directory', $mi_mofile4 ); |
|
359 | - |
|
360 | - if ( file_exists( $mi_mofile1 ) ) { |
|
361 | - load_textdomain( 'google-analytics-for-wordpress', $mi_mofile1 ); |
|
362 | - } elseif ( file_exists( $mi_mofile2 ) ) { |
|
363 | - load_textdomain( 'google-analytics-for-wordpress', $mi_mofile2 ); |
|
364 | - } elseif ( file_exists( $mi_mofile3 ) ) { |
|
365 | - load_textdomain( 'google-analytics-for-wordpress', $mi_mofile3 ); |
|
366 | - } else { |
|
367 | - load_plugin_textdomain( 'google-analytics-for-wordpress', false, $mi_mofile4 ); |
|
368 | - } |
|
369 | - |
|
370 | - } |
|
371 | - |
|
372 | - |
|
373 | - /** |
|
374 | - * Output notice to update eCommerce |
|
375 | - * |
|
376 | - * @access public |
|
377 | - * @since 6.0.0 |
|
378 | - * |
|
379 | - * @return void |
|
380 | - */ |
|
381 | - public function monsterinsights_old_ecommerce() { |
|
382 | - ?> |
|
347 | + // Look for wp-content/languages/google-analytics-for-wordpress/google-analytics-for-wordpress-{lang}_{country}.mo |
|
348 | + $mi_mofile1 = WP_LANG_DIR . '/google-analytics-for-wordpress/' . $mi_mofile; |
|
349 | + |
|
350 | + // Look in wp-content/languages/plugins/google-analytics-for-wordpress/google-analytics-for-wordpress-{lang}_{country}.mo |
|
351 | + $mi_mofile2 = WP_LANG_DIR . '/plugins/google-analytics-for-wordpress/' . $mi_mofile; |
|
352 | + |
|
353 | + // Look in wp-content/languages/plugins/google-analytics-for-wordpress-{lang}_{country}.mo |
|
354 | + $mi_mofile3 = WP_LANG_DIR . '/plugins/' . $mi_mofile; |
|
355 | + |
|
356 | + // Look in wp-content/plugins/google-analytics-for-wordpress/languages/google-analytics-for-wordpress-{lang}_{country}.mo |
|
357 | + $mi_mofile4 = dirname( plugin_basename( MONSTERINSIGHTS_PLUGIN_FILE ) ) . '/languages/'; |
|
358 | + $mi_mofile4 = apply_filters( 'monsterinsights_lite_languages_directory', $mi_mofile4 ); |
|
359 | + |
|
360 | + if ( file_exists( $mi_mofile1 ) ) { |
|
361 | + load_textdomain( 'google-analytics-for-wordpress', $mi_mofile1 ); |
|
362 | + } elseif ( file_exists( $mi_mofile2 ) ) { |
|
363 | + load_textdomain( 'google-analytics-for-wordpress', $mi_mofile2 ); |
|
364 | + } elseif ( file_exists( $mi_mofile3 ) ) { |
|
365 | + load_textdomain( 'google-analytics-for-wordpress', $mi_mofile3 ); |
|
366 | + } else { |
|
367 | + load_plugin_textdomain( 'google-analytics-for-wordpress', false, $mi_mofile4 ); |
|
368 | + } |
|
369 | + |
|
370 | + } |
|
371 | + |
|
372 | + |
|
373 | + /** |
|
374 | + * Output notice to update eCommerce |
|
375 | + * |
|
376 | + * @access public |
|
377 | + * @since 6.0.0 |
|
378 | + * |
|
379 | + * @return void |
|
380 | + */ |
|
381 | + public function monsterinsights_old_ecommerce() { |
|
382 | + ?> |
|
383 | 383 | <div class="error"> |
384 | 384 | <p><?php echo __( 'The version of MonsterInsights eCommerce addon you have is not compatible with the version of MonsterInsights installed. Please update the eCommerce addon as soon as possible', 'ga-premium' ); ?></p> |
385 | 385 | </div> |
386 | 386 | <?php |
387 | 387 | |
388 | - } |
|
389 | - |
|
390 | - /** |
|
391 | - * Output a nag notice if the user has an out of date WP version installed |
|
392 | - * |
|
393 | - * @access public |
|
394 | - * @since 6.0.0 |
|
395 | - * |
|
396 | - * @return void |
|
397 | - */ |
|
398 | - public function monsterinsights_wp_notice() { |
|
399 | - $url = admin_url( 'plugins.php' ); |
|
400 | - // Check for MS dashboard |
|
401 | - if( is_network_admin() ) { |
|
402 | - $url = network_admin_url( 'plugins.php' ); |
|
403 | - } |
|
404 | - ?> |
|
388 | + } |
|
389 | + |
|
390 | + /** |
|
391 | + * Output a nag notice if the user has an out of date WP version installed |
|
392 | + * |
|
393 | + * @access public |
|
394 | + * @since 6.0.0 |
|
395 | + * |
|
396 | + * @return void |
|
397 | + */ |
|
398 | + public function monsterinsights_wp_notice() { |
|
399 | + $url = admin_url( 'plugins.php' ); |
|
400 | + // Check for MS dashboard |
|
401 | + if( is_network_admin() ) { |
|
402 | + $url = network_admin_url( 'plugins.php' ); |
|
403 | + } |
|
404 | + ?> |
|
405 | 405 | <div class="error"> |
406 | 406 | <p><?php echo sprintf( esc_html__( 'Sorry, but your version of WordPress does not meet MonsterInsights\'s required version of %1$s3.8%2$s to run properly. The plugin not been activated. %3$sClick here to return to the Dashboard%4$s.', 'google-analytics-for-wordpress' ), '<strong>', '</strong>', '<a href="' . $url . '">', '</a>' ); ?></p> |
407 | 407 | </div> |
408 | 408 | <?php |
409 | - } |
|
409 | + } |
|
410 | 410 | |
411 | - /** |
|
412 | - * Output a nag notice if the user has both Lite and Pro activated |
|
413 | - * |
|
414 | - * @access public |
|
415 | - * @since 6.0.0 |
|
416 | - * |
|
417 | - * @return void |
|
418 | - */ |
|
419 | - public function monsterinsights_pro_notice() { |
|
420 | - $url = admin_url( 'plugins.php' ); |
|
421 | - // Check for MS dashboard |
|
422 | - if( is_network_admin() ) { |
|
423 | - $url = network_admin_url( 'plugins.php' ); |
|
424 | - } |
|
425 | - ?> |
|
411 | + /** |
|
412 | + * Output a nag notice if the user has both Lite and Pro activated |
|
413 | + * |
|
414 | + * @access public |
|
415 | + * @since 6.0.0 |
|
416 | + * |
|
417 | + * @return void |
|
418 | + */ |
|
419 | + public function monsterinsights_pro_notice() { |
|
420 | + $url = admin_url( 'plugins.php' ); |
|
421 | + // Check for MS dashboard |
|
422 | + if( is_network_admin() ) { |
|
423 | + $url = network_admin_url( 'plugins.php' ); |
|
424 | + } |
|
425 | + ?> |
|
426 | 426 | <div class="error"> |
427 | 427 | <p><?php echo sprintf( esc_html__( 'Please %1$uninstall%2$s the MonsterInsights Lite Plugin. Your Pro version of MonsterInsights may not work as expected until the Lite version is uninstalled.', 'google-analytics-for-wordpress' ), '<a href="' . $url . '">', '</a>' ); ?></p> |
428 | 428 | </div> |
429 | 429 | <?php |
430 | 430 | |
431 | - } |
|
432 | - |
|
433 | - /** |
|
434 | - * Loads MonsterInsights settings |
|
435 | - * |
|
436 | - * Adds the items to the base object, and adds the helper functions. |
|
437 | - * |
|
438 | - * @since 6.0.0 |
|
439 | - * @access public |
|
440 | - * |
|
441 | - * @return void |
|
442 | - */ |
|
443 | - public function load_settings() { |
|
444 | - global $monsterinsights_settings; |
|
445 | - require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/options.php'; |
|
446 | - require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/helpers.php'; |
|
447 | - require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/deprecated.php'; |
|
448 | - $monsterinsights_settings = monsterinsights_get_options(); |
|
449 | - } |
|
450 | - |
|
451 | - /** |
|
452 | - * Loads all files into scope. |
|
453 | - * |
|
454 | - * @access public |
|
455 | - * @since 6.0.0 |
|
456 | - * |
|
457 | - * @return void |
|
458 | - */ |
|
459 | - public function require_files() { |
|
460 | - |
|
461 | - if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) { |
|
462 | - |
|
463 | - // Lite and Pro files |
|
464 | - require_once MONSTERINSIGHTS_PLUGIN_DIR . 'assets/lib/pandora/class-am-notification.php'; |
|
465 | - require_once MONSTERINSIGHTS_PLUGIN_DIR . 'assets/lib/pandora/class-am-deactivation-survey.php'; |
|
466 | - require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/ajax.php'; |
|
467 | - require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/admin.php'; |
|
468 | - require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/common.php'; |
|
469 | - require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/notice.php'; |
|
470 | - require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/capabilities.php'; |
|
471 | - require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/licensing/license.php'; |
|
472 | - require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/licensing/autoupdate.php'; |
|
473 | - |
|
474 | - // Pages |
|
475 | - // Multisite |
|
476 | - require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/pages/network-settings.php'; |
|
477 | - |
|
478 | - // Single Site |
|
479 | - require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/pages/dashboard.php'; |
|
480 | - require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/pages/settings.php'; |
|
481 | - require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/pages/tools.php'; |
|
482 | - require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/pages/reports.php'; |
|
431 | + } |
|
432 | + |
|
433 | + /** |
|
434 | + * Loads MonsterInsights settings |
|
435 | + * |
|
436 | + * Adds the items to the base object, and adds the helper functions. |
|
437 | + * |
|
438 | + * @since 6.0.0 |
|
439 | + * @access public |
|
440 | + * |
|
441 | + * @return void |
|
442 | + */ |
|
443 | + public function load_settings() { |
|
444 | + global $monsterinsights_settings; |
|
445 | + require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/options.php'; |
|
446 | + require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/helpers.php'; |
|
447 | + require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/deprecated.php'; |
|
448 | + $monsterinsights_settings = monsterinsights_get_options(); |
|
449 | + } |
|
450 | + |
|
451 | + /** |
|
452 | + * Loads all files into scope. |
|
453 | + * |
|
454 | + * @access public |
|
455 | + * @since 6.0.0 |
|
456 | + * |
|
457 | + * @return void |
|
458 | + */ |
|
459 | + public function require_files() { |
|
460 | + |
|
461 | + if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) { |
|
462 | + |
|
463 | + // Lite and Pro files |
|
464 | + require_once MONSTERINSIGHTS_PLUGIN_DIR . 'assets/lib/pandora/class-am-notification.php'; |
|
465 | + require_once MONSTERINSIGHTS_PLUGIN_DIR . 'assets/lib/pandora/class-am-deactivation-survey.php'; |
|
466 | + require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/ajax.php'; |
|
467 | + require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/admin.php'; |
|
468 | + require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/common.php'; |
|
469 | + require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/notice.php'; |
|
470 | + require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/capabilities.php'; |
|
471 | + require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/licensing/license.php'; |
|
472 | + require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/licensing/autoupdate.php'; |
|
473 | + |
|
474 | + // Pages |
|
475 | + // Multisite |
|
476 | + require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/pages/network-settings.php'; |
|
477 | + |
|
478 | + // Single Site |
|
479 | + require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/pages/dashboard.php'; |
|
480 | + require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/pages/settings.php'; |
|
481 | + require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/pages/tools.php'; |
|
482 | + require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/pages/reports.php'; |
|
483 | 483 | |
484 | - // Both |
|
485 | - require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/pages/addons.php'; |
|
486 | - |
|
487 | - // Settings Tabs |
|
488 | - require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/settings/tab-general.php'; |
|
489 | - require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/settings/tab-tracking.php'; |
|
490 | - require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/settings/tab-status.php'; |
|
491 | - require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/settings/tab-support.php'; |
|
484 | + // Both |
|
485 | + require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/pages/addons.php'; |
|
486 | + |
|
487 | + // Settings Tabs |
|
488 | + require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/settings/tab-general.php'; |
|
489 | + require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/settings/tab-tracking.php'; |
|
490 | + require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/settings/tab-status.php'; |
|
491 | + require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/settings/tab-support.php'; |
|
492 | 492 | |
493 | - // Register Settings + Settings API |
|
494 | - require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/settings/settings-api.php'; |
|
495 | - require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/settings/register-settings.php'; |
|
496 | - |
|
497 | - require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/reporting.php'; |
|
498 | - require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/abstract-report.php'; |
|
499 | - } |
|
500 | - |
|
501 | - // Load Google Config |
|
502 | - require_once MONSTERINSIGHTS_PLUGIN_DIR . 'lite/includes/google.php'; |
|
503 | - |
|
504 | - // Lazy Load for Frontend. Load for Admin. |
|
505 | - if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) { |
|
506 | - require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/google.php'; |
|
507 | - } |
|
508 | - |
|
509 | - if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) { |
|
510 | - require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/googleauth.php'; |
|
511 | - require_once MONSTERINSIGHTS_PLUGIN_DIR . 'lite/includes/admin/addons.php'; |
|
512 | - require_once MONSTERINSIGHTS_PLUGIN_DIR . 'lite/includes/admin/tools.php'; |
|
513 | - //require_once MONSTERINSIGHTS_PLUGIN_DIR . 'lite/includes/admin/tab-support.php'; |
|
493 | + // Register Settings + Settings API |
|
494 | + require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/settings/settings-api.php'; |
|
495 | + require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/settings/register-settings.php'; |
|
496 | + |
|
497 | + require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/reporting.php'; |
|
498 | + require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/abstract-report.php'; |
|
499 | + } |
|
500 | + |
|
501 | + // Load Google Config |
|
502 | + require_once MONSTERINSIGHTS_PLUGIN_DIR . 'lite/includes/google.php'; |
|
503 | + |
|
504 | + // Lazy Load for Frontend. Load for Admin. |
|
505 | + if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) { |
|
506 | + require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/google.php'; |
|
507 | + } |
|
508 | + |
|
509 | + if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) { |
|
510 | + require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/googleauth.php'; |
|
511 | + require_once MONSTERINSIGHTS_PLUGIN_DIR . 'lite/includes/admin/addons.php'; |
|
512 | + require_once MONSTERINSIGHTS_PLUGIN_DIR . 'lite/includes/admin/tools.php'; |
|
513 | + //require_once MONSTERINSIGHTS_PLUGIN_DIR . 'lite/includes/admin/tab-support.php'; |
|
514 | 514 | |
515 | - // Late loading classes (self instantiating) |
|
516 | - require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/reports/overview.php'; |
|
517 | - require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/tracking.php'; |
|
518 | - } |
|
519 | - |
|
520 | - require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/frontend/frontend.php'; |
|
521 | - require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/measurement-protocol.php'; |
|
522 | - } |
|
523 | - |
|
524 | - /** |
|
525 | - * Loads all updater related files and functions into scope. |
|
526 | - * |
|
527 | - * @access public |
|
528 | - * @since 6.0.0 |
|
529 | - * |
|
530 | - * @return null Return early if the license key is not set or there are key errors. |
|
531 | - */ |
|
532 | - public function require_updater() { |
|
533 | - |
|
534 | - // Retrieve the license key. If it is not set, return early. |
|
535 | - $key = monsterinsights_get_license_key(); |
|
536 | - if ( ! $key ) { |
|
537 | - return; |
|
538 | - } |
|
539 | - |
|
540 | - // If there are any errors with the key itself, return early. |
|
541 | - if ( monsterinsights_get_license_key_errors() ) { |
|
542 | - return; |
|
543 | - } |
|
544 | - |
|
545 | - // Load the updater class. |
|
546 | - require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/licensing/updater.php'; |
|
547 | - |
|
548 | - // Fire a hook for Addons to register their updater since we know the key is present. |
|
549 | - do_action( 'monsterinsights_updater', $key ); |
|
550 | - } |
|
515 | + // Late loading classes (self instantiating) |
|
516 | + require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/reports/overview.php'; |
|
517 | + require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/tracking.php'; |
|
518 | + } |
|
519 | + |
|
520 | + require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/frontend/frontend.php'; |
|
521 | + require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/measurement-protocol.php'; |
|
522 | + } |
|
523 | + |
|
524 | + /** |
|
525 | + * Loads all updater related files and functions into scope. |
|
526 | + * |
|
527 | + * @access public |
|
528 | + * @since 6.0.0 |
|
529 | + * |
|
530 | + * @return null Return early if the license key is not set or there are key errors. |
|
531 | + */ |
|
532 | + public function require_updater() { |
|
533 | + |
|
534 | + // Retrieve the license key. If it is not set, return early. |
|
535 | + $key = monsterinsights_get_license_key(); |
|
536 | + if ( ! $key ) { |
|
537 | + return; |
|
538 | + } |
|
539 | + |
|
540 | + // If there are any errors with the key itself, return early. |
|
541 | + if ( monsterinsights_get_license_key_errors() ) { |
|
542 | + return; |
|
543 | + } |
|
544 | + |
|
545 | + // Load the updater class. |
|
546 | + require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/licensing/updater.php'; |
|
547 | + |
|
548 | + // Fire a hook for Addons to register their updater since we know the key is present. |
|
549 | + do_action( 'monsterinsights_updater', $key ); |
|
550 | + } |
|
551 | 551 | } |
552 | 552 | |
553 | 553 | /** |
@@ -564,23 +564,23 @@ discard block |
||
564 | 564 | */ |
565 | 565 | function monsterinsights_lite_activation_hook( $network_wide ) { |
566 | 566 | |
567 | - global $wp_version; |
|
567 | + global $wp_version; |
|
568 | 568 | |
569 | - $url = admin_url( 'plugins.php' ); |
|
570 | - // Check for MS dashboard |
|
571 | - if ( is_network_admin() ) { |
|
572 | - $url = network_admin_url( 'plugins.php' ); |
|
573 | - } |
|
569 | + $url = admin_url( 'plugins.php' ); |
|
570 | + // Check for MS dashboard |
|
571 | + if ( is_network_admin() ) { |
|
572 | + $url = network_admin_url( 'plugins.php' ); |
|
573 | + } |
|
574 | 574 | |
575 | - if ( version_compare( $wp_version, '3.8', '<' ) && ( ! defined( 'MONSTERINSIGHTS_FORCE_ACTIVATION' ) || ! MONSTERINSIGHTS_FORCE_ACTIVATION ) ) { |
|
576 | - deactivate_plugins( plugin_basename( __FILE__ ) ); |
|
577 | - wp_die( sprintf( esc_html__( 'Sorry, but your version of WordPress does not meet MonsterInsight\'s required version of %1$s3.8%2$s to run properly. The plugin not been activated. %3$sClick here to return to the Dashboard%4$s.', 'google-analytics-by-wordpress' ), '<strong>', '</strong>', '<a href="' . $url . '">', '</a>' ) ); |
|
578 | - } |
|
575 | + if ( version_compare( $wp_version, '3.8', '<' ) && ( ! defined( 'MONSTERINSIGHTS_FORCE_ACTIVATION' ) || ! MONSTERINSIGHTS_FORCE_ACTIVATION ) ) { |
|
576 | + deactivate_plugins( plugin_basename( __FILE__ ) ); |
|
577 | + wp_die( sprintf( esc_html__( 'Sorry, but your version of WordPress does not meet MonsterInsight\'s required version of %1$s3.8%2$s to run properly. The plugin not been activated. %3$sClick here to return to the Dashboard%4$s.', 'google-analytics-by-wordpress' ), '<strong>', '</strong>', '<a href="' . $url . '">', '</a>' ) ); |
|
578 | + } |
|
579 | 579 | |
580 | - if ( class_exists( 'MonsterInsights' ) ) { |
|
581 | - deactivate_plugins( plugin_basename( __FILE__ ) ); |
|
582 | - wp_die( sprintf( esc_html__( 'Please uninstall and remove MonsterInsights Pro before activating MonsterInsights Lite. The Lite version has not been activated. %1$sClick here to return to the Dashboard%2$s.', 'google-analytics-by-wordpress' ), '<a href="' . $url . '">', '</a>' ) ); |
|
583 | - } |
|
580 | + if ( class_exists( 'MonsterInsights' ) ) { |
|
581 | + deactivate_plugins( plugin_basename( __FILE__ ) ); |
|
582 | + wp_die( sprintf( esc_html__( 'Please uninstall and remove MonsterInsights Pro before activating MonsterInsights Lite. The Lite version has not been activated. %1$sClick here to return to the Dashboard%2$s.', 'google-analytics-by-wordpress' ), '<a href="' . $url . '">', '</a>' ) ); |
|
583 | + } |
|
584 | 584 | } |
585 | 585 | register_activation_hook( __FILE__, 'monsterinsights_lite_activation_hook' ); |
586 | 586 | |
@@ -593,31 +593,31 @@ discard block |
||
593 | 593 | * @return void |
594 | 594 | */ |
595 | 595 | function monsterinsights_lite_deactivation_hook( $network_wide ) { |
596 | - // Note, if both MI Pro and Lite are active, this is an MI Pro instance |
|
597 | - // Therefore MI Lite can only use functions of the instance common to |
|
598 | - // both plugins. If it needs to be pro specific, then include a file that |
|
599 | - // has that method. |
|
600 | - $instance = MonsterInsights(); |
|
596 | + // Note, if both MI Pro and Lite are active, this is an MI Pro instance |
|
597 | + // Therefore MI Lite can only use functions of the instance common to |
|
598 | + // both plugins. If it needs to be pro specific, then include a file that |
|
599 | + // has that method. |
|
600 | + $instance = MonsterInsights(); |
|
601 | 601 | |
602 | - if ( is_multisite() && $network_wide ) { |
|
603 | - $site_list = get_sites(); |
|
604 | - $options = array( |
|
605 | - 'cron_failed', |
|
606 | - 'cron_last_run', |
|
607 | - ); |
|
608 | - |
|
609 | - foreach ( (array) $site_list as $site ) { |
|
610 | - switch_to_blog( $site->blog_id ); |
|
611 | - monsterinsights_delete_options( $options ); |
|
612 | - restore_current_blog(); |
|
613 | - } |
|
614 | - } else { |
|
615 | - $options = array( |
|
616 | - 'cron_failed', |
|
617 | - 'cron_last_run', |
|
618 | - ); |
|
619 | - monsterinsights_delete_options( $options ); |
|
620 | - } |
|
602 | + if ( is_multisite() && $network_wide ) { |
|
603 | + $site_list = get_sites(); |
|
604 | + $options = array( |
|
605 | + 'cron_failed', |
|
606 | + 'cron_last_run', |
|
607 | + ); |
|
608 | + |
|
609 | + foreach ( (array) $site_list as $site ) { |
|
610 | + switch_to_blog( $site->blog_id ); |
|
611 | + monsterinsights_delete_options( $options ); |
|
612 | + restore_current_blog(); |
|
613 | + } |
|
614 | + } else { |
|
615 | + $options = array( |
|
616 | + 'cron_failed', |
|
617 | + 'cron_last_run', |
|
618 | + ); |
|
619 | + monsterinsights_delete_options( $options ); |
|
620 | + } |
|
621 | 621 | } |
622 | 622 | register_deactivation_hook( __FILE__, 'monsterinsights_lite_deactivation_hook' ); |
623 | 623 | |
@@ -630,55 +630,55 @@ discard block |
||
630 | 630 | * @return void |
631 | 631 | */ |
632 | 632 | function monsterinsights_lite_uninstall_hook( $network_wide ) { |
633 | - wp_cache_flush(); |
|
634 | - $instance = MonsterInsights(); |
|
635 | - |
|
636 | - // Note, if both MI Pro and Lite are active, this is an MI Pro instance |
|
637 | - // Therefore MI Lite can only use functions of the instance common to |
|
638 | - // both plugins. If it needs to be pro specific, then include a file that |
|
639 | - // has that method. |
|
640 | - if ( is_multisite() && $network_wide ) { |
|
641 | - $site_list = get_sites(); |
|
642 | - |
|
643 | - $options = array( |
|
644 | - 'analytics_profile_code', |
|
645 | - 'analytics_profile', |
|
646 | - 'analytics_profile_name', |
|
647 | - 'analytics_name', |
|
648 | - 'oauth_version', |
|
649 | - 'cron_failed', |
|
650 | - 'cron_last_run', |
|
651 | - ); |
|
652 | - |
|
653 | - foreach ( (array) $site_list as $site ) { |
|
654 | - switch_to_blog( $site->blog_id ); |
|
655 | - monsterinsights_delete_options( $options ); |
|
656 | - delete_option( 'monsterinsights_lite_access_token' ); |
|
657 | - delete_option( 'monsterinsights_lite_refresh_token' ); |
|
658 | - |
|
659 | - // Destroy the data |
|
660 | - $instance->reports->delete_aggregate_data(); |
|
661 | - restore_current_blog(); |
|
662 | - } |
|
663 | - } else { |
|
664 | - $options = array( |
|
665 | - 'analytics_profile_code', |
|
666 | - 'analytics_profile', |
|
667 | - 'analytics_profile_name', |
|
668 | - 'analytics_name', |
|
669 | - 'oauth_version', |
|
670 | - 'cron_failed', |
|
671 | - 'cron_last_run', |
|
672 | - ); |
|
673 | - monsterinsights_delete_options( $options ); |
|
674 | - delete_option( 'monsterinsights_lite_access_token' ); |
|
675 | - delete_option( 'monsterinsights_lite_refresh_token' ); |
|
676 | - |
|
677 | - // Destroy the data |
|
678 | - if ( isset( $instance->reports ) && method_exists( $instance->reports,'delete_aggregate_data' ) ) { |
|
679 | - $instance->reports->delete_aggregate_data(); |
|
680 | - } |
|
681 | - } |
|
633 | + wp_cache_flush(); |
|
634 | + $instance = MonsterInsights(); |
|
635 | + |
|
636 | + // Note, if both MI Pro and Lite are active, this is an MI Pro instance |
|
637 | + // Therefore MI Lite can only use functions of the instance common to |
|
638 | + // both plugins. If it needs to be pro specific, then include a file that |
|
639 | + // has that method. |
|
640 | + if ( is_multisite() && $network_wide ) { |
|
641 | + $site_list = get_sites(); |
|
642 | + |
|
643 | + $options = array( |
|
644 | + 'analytics_profile_code', |
|
645 | + 'analytics_profile', |
|
646 | + 'analytics_profile_name', |
|
647 | + 'analytics_name', |
|
648 | + 'oauth_version', |
|
649 | + 'cron_failed', |
|
650 | + 'cron_last_run', |
|
651 | + ); |
|
652 | + |
|
653 | + foreach ( (array) $site_list as $site ) { |
|
654 | + switch_to_blog( $site->blog_id ); |
|
655 | + monsterinsights_delete_options( $options ); |
|
656 | + delete_option( 'monsterinsights_lite_access_token' ); |
|
657 | + delete_option( 'monsterinsights_lite_refresh_token' ); |
|
658 | + |
|
659 | + // Destroy the data |
|
660 | + $instance->reports->delete_aggregate_data(); |
|
661 | + restore_current_blog(); |
|
662 | + } |
|
663 | + } else { |
|
664 | + $options = array( |
|
665 | + 'analytics_profile_code', |
|
666 | + 'analytics_profile', |
|
667 | + 'analytics_profile_name', |
|
668 | + 'analytics_name', |
|
669 | + 'oauth_version', |
|
670 | + 'cron_failed', |
|
671 | + 'cron_last_run', |
|
672 | + ); |
|
673 | + monsterinsights_delete_options( $options ); |
|
674 | + delete_option( 'monsterinsights_lite_access_token' ); |
|
675 | + delete_option( 'monsterinsights_lite_refresh_token' ); |
|
676 | + |
|
677 | + // Destroy the data |
|
678 | + if ( isset( $instance->reports ) && method_exists( $instance->reports,'delete_aggregate_data' ) ) { |
|
679 | + $instance->reports->delete_aggregate_data(); |
|
680 | + } |
|
681 | + } |
|
682 | 682 | |
683 | 683 | } |
684 | 684 | register_uninstall_hook( __FILE__, 'monsterinsights_lite_uninstall_hook' ); |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | * @return MonsterInsights_Lite The singleton MonsterInsights_Lite instance. |
700 | 700 | */ |
701 | 701 | function MonsterInsights_Lite() { |
702 | - return MonsterInsights_Lite::get_instance(); |
|
702 | + return MonsterInsights_Lite::get_instance(); |
|
703 | 703 | } |
704 | 704 | |
705 | 705 | /** |
@@ -719,34 +719,34 @@ discard block |
||
719 | 719 | * @return void |
720 | 720 | */ |
721 | 721 | function monsterinsights_lite_install_and_upgrade() { |
722 | - global $wp_version; |
|
723 | - |
|
724 | - // If the WordPress site doesn't meet the correct WP version requirements, don't activate MonsterInsights |
|
725 | - if ( version_compare( $wp_version, '3.8', '<' ) ) { |
|
726 | - if ( is_plugin_active( plugin_basename( __FILE__ ) ) ) { |
|
727 | - return; |
|
728 | - } |
|
729 | - } |
|
730 | - |
|
731 | - // Don't run if MI Pro is installed |
|
732 | - if ( class_exists( 'MonsterInsights' ) ) { |
|
733 | - if ( is_plugin_active( plugin_basename( __FILE__ ) ) ) { |
|
734 | - return; |
|
735 | - } |
|
736 | - } |
|
737 | - |
|
738 | - |
|
739 | - // Load settings and globals (so we can use/set them during the upgrade process) |
|
740 | - MonsterInsights_Lite()->define_globals(); |
|
741 | - MonsterInsights_Lite()->load_settings(); |
|
742 | - |
|
743 | - // Load upgrade file |
|
744 | - require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/install.php'; |
|
745 | - require_once MONSTERINSIGHTS_PLUGIN_DIR . 'lite/includes/install.php'; // Lite only install stuff |
|
746 | - |
|
747 | - // Run the MonsterInsights upgrade routines |
|
748 | - $updates = new MonsterInsights_Install(); |
|
749 | - $updates->init(); |
|
722 | + global $wp_version; |
|
723 | + |
|
724 | + // If the WordPress site doesn't meet the correct WP version requirements, don't activate MonsterInsights |
|
725 | + if ( version_compare( $wp_version, '3.8', '<' ) ) { |
|
726 | + if ( is_plugin_active( plugin_basename( __FILE__ ) ) ) { |
|
727 | + return; |
|
728 | + } |
|
729 | + } |
|
730 | + |
|
731 | + // Don't run if MI Pro is installed |
|
732 | + if ( class_exists( 'MonsterInsights' ) ) { |
|
733 | + if ( is_plugin_active( plugin_basename( __FILE__ ) ) ) { |
|
734 | + return; |
|
735 | + } |
|
736 | + } |
|
737 | + |
|
738 | + |
|
739 | + // Load settings and globals (so we can use/set them during the upgrade process) |
|
740 | + MonsterInsights_Lite()->define_globals(); |
|
741 | + MonsterInsights_Lite()->load_settings(); |
|
742 | + |
|
743 | + // Load upgrade file |
|
744 | + require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/install.php'; |
|
745 | + require_once MONSTERINSIGHTS_PLUGIN_DIR . 'lite/includes/install.php'; // Lite only install stuff |
|
746 | + |
|
747 | + // Run the MonsterInsights upgrade routines |
|
748 | + $updates = new MonsterInsights_Install(); |
|
749 | + $updates->init(); |
|
750 | 750 | } |
751 | 751 | |
752 | 752 | /** |
@@ -764,7 +764,7 @@ discard block |
||
764 | 764 | * @return void |
765 | 765 | */ |
766 | 766 | function monsterinsights_lite_call_install_and_upgrade(){ |
767 | - add_action( 'wp_loaded', 'monsterinsights_lite_install_and_upgrade' ); |
|
767 | + add_action( 'wp_loaded', 'monsterinsights_lite_install_and_upgrade' ); |
|
768 | 768 | } |
769 | 769 | |
770 | 770 | /** |
@@ -791,8 +791,8 @@ discard block |
||
791 | 791 | * @return MonsterInsights The singleton MonsterInsights instance. |
792 | 792 | */ |
793 | 793 | if ( ! function_exists( 'MonsterInsights' ) ) { |
794 | - function MonsterInsights() { |
|
795 | - return ( class_exists( 'MonsterInsights' ) ? MonsterInsights_Pro() : MonsterInsights_Lite() ); |
|
796 | - } |
|
797 | - add_action( 'plugins_loaded', 'MonsterInsights' ); |
|
794 | + function MonsterInsights() { |
|
795 | + return ( class_exists( 'MonsterInsights' ) ? MonsterInsights_Pro() : MonsterInsights_Lite() ); |
|
796 | + } |
|
797 | + add_action( 'plugins_loaded', 'MonsterInsights' ); |
|
798 | 798 | } |
799 | 799 | \ No newline at end of file |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | */ |
15 | 15 | |
16 | 16 | // Exit if accessed directly |
17 | -if ( ! defined( 'ABSPATH' ) ) { |
|
17 | +if ( ! defined('ABSPATH')) { |
|
18 | 18 | exit; |
19 | 19 | } |
20 | 20 | |
@@ -38,14 +38,14 @@ discard block |
||
38 | 38 | * @param string $version The version of WordPress that deprecated the hook. |
39 | 39 | * @param string $message Optional. A message regarding the change. Default null. |
40 | 40 | */ |
41 | -function _monsterinsights_apply_filters_deprecated( $tag, $args, $version, $message = null ) { |
|
42 | - if ( ! has_filter( $tag ) ) { |
|
41 | +function _monsterinsights_apply_filters_deprecated($tag, $args, $version, $message = null) { |
|
42 | + if ( ! has_filter($tag)) { |
|
43 | 43 | return $args[0]; |
44 | 44 | } |
45 | 45 | |
46 | - _monsterinsights_deprecated_hook( $tag, $version, $message ); |
|
46 | + _monsterinsights_deprecated_hook($tag, $version, $message); |
|
47 | 47 | |
48 | - return apply_filters_ref_array( $tag, $args ); |
|
48 | + return apply_filters_ref_array($tag, $args); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -68,14 +68,14 @@ discard block |
||
68 | 68 | * @param string $version The version of WordPress that deprecated the hook. |
69 | 69 | * @param string $message Optional. A message regarding the change. |
70 | 70 | */ |
71 | -function _monsterinsights_do_action_deprecated( $tag, $args, $version, $message = null ) { |
|
72 | - if ( ! has_action( $tag ) ) { |
|
71 | +function _monsterinsights_do_action_deprecated($tag, $args, $version, $message = null) { |
|
72 | + if ( ! has_action($tag)) { |
|
73 | 73 | return; |
74 | 74 | } |
75 | 75 | |
76 | - _monsterinsights_deprecated_hook( $tag, $version, $message ); |
|
76 | + _monsterinsights_deprecated_hook($tag, $version, $message); |
|
77 | 77 | |
78 | - do_action_ref_array( $tag, $args ); |
|
78 | + do_action_ref_array($tag, $args); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * @param string $version The version of WordPress that deprecated the hook. |
102 | 102 | * @param string $message Optional. A message regarding the change. |
103 | 103 | */ |
104 | -function _monsterinsights_deprecated_hook( $hook, $version, $message = null ) { |
|
104 | +function _monsterinsights_deprecated_hook($hook, $version, $message = null) { |
|
105 | 105 | /** |
106 | 106 | * Fires when a deprecated hook is called. |
107 | 107 | * |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * @param string $version The version of MonsterInsights that deprecated the hook used. |
112 | 112 | * @param string $message A message regarding the change. |
113 | 113 | */ |
114 | - do_action( 'deprecated_hook_run', $hook, $version, $message ); |
|
114 | + do_action('deprecated_hook_run', $hook, $version, $message); |
|
115 | 115 | |
116 | 116 | /** |
117 | 117 | * Filters whether to trigger deprecated hook errors. |
@@ -121,9 +121,9 @@ discard block |
||
121 | 121 | * @param bool $trigger Whether to trigger deprecated hook errors. Requires |
122 | 122 | * `WP_DEBUG` to be defined true. |
123 | 123 | */ |
124 | - if ( ( WP_DEBUG && apply_filters( 'deprecated_hook_trigger_error', true ) ) || monsterinsights_is_debug_mode() ) { |
|
125 | - $message = empty( $message ) ? '' : ' ' . $message; |
|
126 | - trigger_error( sprintf( esc_html__( '%1$s is %3$sdeprecated%4$s since MonsterInsights version %2$s!', 'google-analytics-for-wordpress' ), $hook, $version, '<strong>', '</strong>' ) . esc_html ( $message ) ); |
|
124 | + if ((WP_DEBUG && apply_filters('deprecated_hook_trigger_error', true)) || monsterinsights_is_debug_mode()) { |
|
125 | + $message = empty($message) ? '' : ' ' . $message; |
|
126 | + trigger_error(sprintf(esc_html__('%1$s is %3$sdeprecated%4$s since MonsterInsights version %2$s!', 'google-analytics-for-wordpress'), $hook, $version, '<strong>', '</strong>') . esc_html($message)); |
|
127 | 127 | } |
128 | 128 | } |
129 | 129 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * @param array $backtrace Optional. Contains stack backtrace of deprecated function |
152 | 152 | * @return void |
153 | 153 | */ |
154 | -function _monsterinsights_deprecated_function( $function, $version, $backtrace = null ) { |
|
154 | +function _monsterinsights_deprecated_function($function, $version, $backtrace = null) { |
|
155 | 155 | |
156 | 156 | /** |
157 | 157 | * Deprecated Function Action. |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * @param string $version The version of WordPress that deprecated the function. |
167 | 167 | * @param array $backtrace Optional. Contains stack backtrace of deprecated function. |
168 | 168 | */ |
169 | - do_action( 'deprecated_function_run', $function, $version, $backtrace ); |
|
169 | + do_action('deprecated_function_run', $function, $version, $backtrace); |
|
170 | 170 | |
171 | 171 | /** |
172 | 172 | * Filters whether to trigger an error for deprecated functions. |
@@ -175,9 +175,9 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @param bool $trigger Whether to trigger the error for deprecated functions. Default true. |
177 | 177 | */ |
178 | - if ( ( WP_DEBUG && apply_filters( 'deprecated_function_trigger_error', true ) ) || monsterinsights_is_debug_mode() ) { |
|
179 | - trigger_error( sprintf( esc_html__( '%1$s is %3$sdeprecated%4$s since MonsterInsights version %2$s.', 'google-analytics-for-wordpress' ), $function, $version, '<strong>', '</strong>' ) ); |
|
180 | - trigger_error( print_r( $backtrace, 1 ) );// Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
178 | + if ((WP_DEBUG && apply_filters('deprecated_function_trigger_error', true)) || monsterinsights_is_debug_mode()) { |
|
179 | + trigger_error(sprintf(esc_html__('%1$s is %3$sdeprecated%4$s since MonsterInsights version %2$s.', 'google-analytics-for-wordpress'), $function, $version, '<strong>', '</strong>')); |
|
180 | + trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
181 | 181 | // Alternatively we could dump this to a file. |
182 | 182 | } |
183 | 183 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * @param string $message Deprecation message shown. |
197 | 197 | * @return void |
198 | 198 | */ |
199 | -function _monsterinsights_deprecated( $message ) { |
|
199 | +function _monsterinsights_deprecated($message) { |
|
200 | 200 | |
201 | 201 | /** |
202 | 202 | * Deprecated Message Filter. |
@@ -207,9 +207,9 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @param string $message Error message. |
209 | 209 | */ |
210 | - do_action( 'monsterinsights_deprecated_run', $message ); |
|
210 | + do_action('monsterinsights_deprecated_run', $message); |
|
211 | 211 | |
212 | - $show_errors = current_user_can( 'manage_options' ); |
|
212 | + $show_errors = current_user_can('manage_options'); |
|
213 | 213 | |
214 | 214 | /** |
215 | 215 | * Deprecated Error Trigger. |
@@ -220,9 +220,9 @@ discard block |
||
220 | 220 | * |
221 | 221 | * @param bool $show_errors Whether to show errors. |
222 | 222 | */ |
223 | - $show_errors = apply_filters( 'monsterinsights_deprecated_trigger_error', $show_errors ); |
|
224 | - if ( ( WP_DEBUG && $show_errors ) || monsterinsights_is_debug_mode() ) { |
|
225 | - trigger_error( esc_html( $message ) ); |
|
223 | + $show_errors = apply_filters('monsterinsights_deprecated_trigger_error', $show_errors); |
|
224 | + if ((WP_DEBUG && $show_errors) || monsterinsights_is_debug_mode()) { |
|
225 | + trigger_error(esc_html($message)); |
|
226 | 226 | } |
227 | 227 | } |
228 | 228 | |
@@ -243,11 +243,11 @@ discard block |
||
243 | 243 | * @param int $limit Number of rows to request at most in API calls. Default 300. |
244 | 244 | * @return int Number of rows to request at most in API calls. |
245 | 245 | */ |
246 | -function monsterinsights_yst_ga_filter_api_limit( $limit ) { |
|
247 | - $message = sprintf( __( 'Use %s instead.', 'google-analytics-for-wordpress' ), '<code>monsterinsights_reporting_get_max_api_limit</code>' ); |
|
248 | - return _monsterinsights_apply_filters_deprecated( 'yst-ga-filter-api-limit', array( $limit ), '6.0.0', $message ); |
|
246 | +function monsterinsights_yst_ga_filter_api_limit($limit) { |
|
247 | + $message = sprintf(__('Use %s instead.', 'google-analytics-for-wordpress'), '<code>monsterinsights_reporting_get_max_api_limit</code>'); |
|
248 | + return _monsterinsights_apply_filters_deprecated('yst-ga-filter-api-limit', array($limit), '6.0.0', $message); |
|
249 | 249 | } |
250 | -add_filter( 'monsterinsights_reporting_get_max_api_limit', 'monsterinsights_yst_ga_filter_api_limit' ); |
|
250 | +add_filter('monsterinsights_reporting_get_max_api_limit', 'monsterinsights_yst_ga_filter_api_limit'); |
|
251 | 251 | |
252 | 252 | /** |
253 | 253 | * Deprecated Filter: 'yst_ga_track_super_admin'. |
@@ -257,12 +257,12 @@ discard block |
||
257 | 257 | * @param bool $track Whether to track super admins. Default false. |
258 | 258 | * @return bool Whether to track super admins. Default false. |
259 | 259 | */ |
260 | -function monsterinsights_yst_ga_track_super_admin( $track ) { |
|
260 | +function monsterinsights_yst_ga_track_super_admin($track) { |
|
261 | 261 | $track = ! $track; // invert track as in Yoast it defaulted to track super admins |
262 | - $message = sprintf( __( 'Use %s instead.', 'google-analytics-for-wordpress' ), '<code>monsterinsights_track_super_admins</code>' ); |
|
263 | - return _monsterinsights_apply_filters_deprecated( 'yst_ga_track_super_admin', array( $track ), '6.0.0', $message ); |
|
262 | + $message = sprintf(__('Use %s instead.', 'google-analytics-for-wordpress'), '<code>monsterinsights_track_super_admins</code>'); |
|
263 | + return _monsterinsights_apply_filters_deprecated('yst_ga_track_super_admin', array($track), '6.0.0', $message); |
|
264 | 264 | } |
265 | -add_filter( 'monsterinsights_track_super_admins', 'monsterinsights_yst_ga_track_super_admin' ); |
|
265 | +add_filter('monsterinsights_track_super_admins', 'monsterinsights_yst_ga_track_super_admin'); |
|
266 | 266 | |
267 | 267 | |
268 | 268 | /** |
@@ -271,11 +271,11 @@ discard block |
||
271 | 271 | * Allows output before the analytics and ga.js tracking output. |
272 | 272 | */ |
273 | 273 | function monsterinsights_yst_tracking() { |
274 | - $message = sprintf( __( 'Use %s instead.', 'google-analytics-for-wordpress' ), '<code>monsterinsights_tracking_before{_$mode}</code>' ); |
|
275 | - _monsterinsights_do_action_deprecated( 'yst_tracking', array(), '6.0.0', $message ); |
|
274 | + $message = sprintf(__('Use %s instead.', 'google-analytics-for-wordpress'), '<code>monsterinsights_tracking_before{_$mode}</code>'); |
|
275 | + _monsterinsights_do_action_deprecated('yst_tracking', array(), '6.0.0', $message); |
|
276 | 276 | } |
277 | -add_action( 'monsterinsights_tracking_before_ga', 'monsterinsights_yst_tracking' ); |
|
278 | -add_action( 'monsterinsights_tracking_before_analytics', 'monsterinsights_yst_tracking' ); |
|
277 | +add_action('monsterinsights_tracking_before_ga', 'monsterinsights_yst_tracking'); |
|
278 | +add_action('monsterinsights_tracking_before_analytics', 'monsterinsights_yst_tracking'); |
|
279 | 279 | |
280 | 280 | /** |
281 | 281 | * Deprecated Filter: 'yoast-ga-push-array-ga-js'. |
@@ -285,11 +285,11 @@ discard block |
||
285 | 285 | * @param array $options GA.js options. |
286 | 286 | * @return array GA.js options. |
287 | 287 | */ |
288 | -function monsterinsights_yoast_ga_push_array_ga_js( $options ) { |
|
289 | - $message = sprintf( __( 'Use %s instead.', 'google-analytics-for-wordpress' ), '<code>monsterinsights_frontend_tracking_options_analytics_end</code>' ); |
|
290 | - return _monsterinsights_apply_filters_deprecated( 'yoast-ga-push-array-ga-js', array( $options ), '6.0.0', $message ); |
|
288 | +function monsterinsights_yoast_ga_push_array_ga_js($options) { |
|
289 | + $message = sprintf(__('Use %s instead.', 'google-analytics-for-wordpress'), '<code>monsterinsights_frontend_tracking_options_analytics_end</code>'); |
|
290 | + return _monsterinsights_apply_filters_deprecated('yoast-ga-push-array-ga-js', array($options), '6.0.0', $message); |
|
291 | 291 | } |
292 | -add_filter( 'monsterinsights_frontend_tracking_options_ga_end', 'monsterinsights_yoast_ga_push_array_ga_js' ); |
|
292 | +add_filter('monsterinsights_frontend_tracking_options_ga_end', 'monsterinsights_yoast_ga_push_array_ga_js'); |
|
293 | 293 | |
294 | 294 | /** |
295 | 295 | * Deprecated Filter: 'yoast-ga-push-array-universal'. |
@@ -299,11 +299,11 @@ discard block |
||
299 | 299 | * @param array $options analytics.js options. |
300 | 300 | * @return array Analytics.js options. |
301 | 301 | */ |
302 | -function monsterinsights_yoast_ga_push_array_universal( $options ) { |
|
303 | - $message = sprintf( __( 'Use %s instead.', 'google-analytics-for-wordpress' ), '<code>monsterinsights_frontend_tracking_options_analytics_end</code>' ); |
|
304 | - return _monsterinsights_apply_filters_deprecated( 'yoast-ga-push-array-universal', array( $options ), '6.0.0', $message ); |
|
302 | +function monsterinsights_yoast_ga_push_array_universal($options) { |
|
303 | + $message = sprintf(__('Use %s instead.', 'google-analytics-for-wordpress'), '<code>monsterinsights_frontend_tracking_options_analytics_end</code>'); |
|
304 | + return _monsterinsights_apply_filters_deprecated('yoast-ga-push-array-universal', array($options), '6.0.0', $message); |
|
305 | 305 | } |
306 | -add_filter( 'monsterinsights_frontend_tracking_options_analytics_end', 'monsterinsights_yoast_ga_push_array_universal' ); |
|
306 | +add_filter('monsterinsights_frontend_tracking_options_analytics_end', 'monsterinsights_yoast_ga_push_array_universal'); |
|
307 | 307 | |
308 | 308 | /** |
309 | 309 | * Deprecated Filter: 'yst_ga_filter_push_vars'. |
@@ -313,17 +313,17 @@ discard block |
||
313 | 313 | * @param array $options analytics.js options. |
314 | 314 | * @return array Analytics.js options. |
315 | 315 | */ |
316 | -function monsterinsights_yst_ga_filter_push_vars( $options ) { |
|
317 | - if ( ! has_filter('yst_ga_filter_push_vars' ) ) { |
|
316 | +function monsterinsights_yst_ga_filter_push_vars($options) { |
|
317 | + if ( ! has_filter('yst_ga_filter_push_vars')) { |
|
318 | 318 | return $options; |
319 | 319 | } else { |
320 | - $message = sprintf( __( 'Use %s instead.', 'google-analytics-for-wordpress' ), '<code>monsterinsights_frontend_tracking_options_analytics_before_scripts</code>' ); |
|
321 | - _monsterinsights_deprecated_hook( 'yst_ga_filter_push_vars', '6.0.0', $message ); |
|
320 | + $message = sprintf(__('Use %s instead.', 'google-analytics-for-wordpress'), '<code>monsterinsights_frontend_tracking_options_analytics_before_scripts</code>'); |
|
321 | + _monsterinsights_deprecated_hook('yst_ga_filter_push_vars', '6.0.0', $message); |
|
322 | 322 | |
323 | 323 | $i = 0; |
324 | - while ( true ) { |
|
325 | - if ( empty( $options[ 'yst_ga_filter_push_vars_' . $i ] ) ) { |
|
326 | - $options[ 'yst_ga_filter_push_vars_' . $i ] = apply_filters( 'yst_ga_filter_push_vars', $options ); |
|
324 | + while (true) { |
|
325 | + if (empty($options['yst_ga_filter_push_vars_' . $i])) { |
|
326 | + $options['yst_ga_filter_push_vars_' . $i] = apply_filters('yst_ga_filter_push_vars', $options); |
|
327 | 327 | break; |
328 | 328 | } else { |
329 | 329 | $i++; |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | return $options; |
333 | 333 | } |
334 | 334 | } |
335 | -add_filter( 'monsterinsights_frontend_tracking_options_analytics_before_scripts', 'monsterinsights_yst_ga_filter_push_vars' ); |
|
335 | +add_filter('monsterinsights_frontend_tracking_options_analytics_before_scripts', 'monsterinsights_yst_ga_filter_push_vars'); |
|
336 | 336 | |
337 | 337 | |
338 | 338 | /** |
@@ -343,13 +343,13 @@ discard block |
||
343 | 343 | * @param array $config GA App config. |
344 | 344 | * @return array GA App config. |
345 | 345 | */ |
346 | -function monsterinsights_yst_ga_filter_ga_config( $config ) { |
|
347 | - $message = sprintf( __( 'Use %s instead.', 'google-analytics-for-wordpress' ), '<code>monsterinsights_{lite/pro}_google_app_config</code>' ); |
|
348 | - return _monsterinsights_apply_filters_deprecated( 'yst-ga-filter-ga-config', array( $config ), '6.0.0', $message ); |
|
346 | +function monsterinsights_yst_ga_filter_ga_config($config) { |
|
347 | + $message = sprintf(__('Use %s instead.', 'google-analytics-for-wordpress'), '<code>monsterinsights_{lite/pro}_google_app_config</code>'); |
|
348 | + return _monsterinsights_apply_filters_deprecated('yst-ga-filter-ga-config', array($config), '6.0.0', $message); |
|
349 | 349 | } |
350 | -add_filter( 'monsterinsights_lite_google_app_config', 'monsterinsights_yst_ga_filter_ga_config' ); |
|
351 | -add_filter( 'monsterinsights_pro_google_app_config', 'monsterinsights_yst_ga_filter_ga_config' ); |
|
350 | +add_filter('monsterinsights_lite_google_app_config', 'monsterinsights_yst_ga_filter_ga_config'); |
|
351 | +add_filter('monsterinsights_pro_google_app_config', 'monsterinsights_yst_ga_filter_ga_config'); |
|
352 | 352 | |
353 | -function monsterinsights_disabled_user_group(){ |
|
353 | +function monsterinsights_disabled_user_group() { |
|
354 | 354 | return ! monsterinsights_track_user(); |
355 | 355 | } |
356 | 356 | \ No newline at end of file |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | // Exit if accessed directly |
17 | 17 | if ( ! defined( 'ABSPATH' ) ) { |
18 | - exit; |
|
18 | + exit; |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | * @param string $message Optional. A message regarding the change. Default null. |
40 | 40 | */ |
41 | 41 | function _monsterinsights_apply_filters_deprecated( $tag, $args, $version, $message = null ) { |
42 | - if ( ! has_filter( $tag ) ) { |
|
43 | - return $args[0]; |
|
44 | - } |
|
42 | + if ( ! has_filter( $tag ) ) { |
|
43 | + return $args[0]; |
|
44 | + } |
|
45 | 45 | |
46 | - _monsterinsights_deprecated_hook( $tag, $version, $message ); |
|
46 | + _monsterinsights_deprecated_hook( $tag, $version, $message ); |
|
47 | 47 | |
48 | - return apply_filters_ref_array( $tag, $args ); |
|
48 | + return apply_filters_ref_array( $tag, $args ); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -69,13 +69,13 @@ discard block |
||
69 | 69 | * @param string $message Optional. A message regarding the change. |
70 | 70 | */ |
71 | 71 | function _monsterinsights_do_action_deprecated( $tag, $args, $version, $message = null ) { |
72 | - if ( ! has_action( $tag ) ) { |
|
73 | - return; |
|
74 | - } |
|
72 | + if ( ! has_action( $tag ) ) { |
|
73 | + return; |
|
74 | + } |
|
75 | 75 | |
76 | - _monsterinsights_deprecated_hook( $tag, $version, $message ); |
|
76 | + _monsterinsights_deprecated_hook( $tag, $version, $message ); |
|
77 | 77 | |
78 | - do_action_ref_array( $tag, $args ); |
|
78 | + do_action_ref_array( $tag, $args ); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -102,29 +102,29 @@ discard block |
||
102 | 102 | * @param string $message Optional. A message regarding the change. |
103 | 103 | */ |
104 | 104 | function _monsterinsights_deprecated_hook( $hook, $version, $message = null ) { |
105 | - /** |
|
106 | - * Fires when a deprecated hook is called. |
|
107 | - * |
|
108 | - * @since 6.0.0 |
|
109 | - * |
|
110 | - * @param string $hook The hook that was called. |
|
111 | - * @param string $version The version of MonsterInsights that deprecated the hook used. |
|
112 | - * @param string $message A message regarding the change. |
|
113 | - */ |
|
114 | - do_action( 'deprecated_hook_run', $hook, $version, $message ); |
|
105 | + /** |
|
106 | + * Fires when a deprecated hook is called. |
|
107 | + * |
|
108 | + * @since 6.0.0 |
|
109 | + * |
|
110 | + * @param string $hook The hook that was called. |
|
111 | + * @param string $version The version of MonsterInsights that deprecated the hook used. |
|
112 | + * @param string $message A message regarding the change. |
|
113 | + */ |
|
114 | + do_action( 'deprecated_hook_run', $hook, $version, $message ); |
|
115 | 115 | |
116 | - /** |
|
117 | - * Filters whether to trigger deprecated hook errors. |
|
118 | - * |
|
119 | - * @since 6.0.0 |
|
120 | - * |
|
121 | - * @param bool $trigger Whether to trigger deprecated hook errors. Requires |
|
122 | - * `WP_DEBUG` to be defined true. |
|
123 | - */ |
|
124 | - if ( ( WP_DEBUG && apply_filters( 'deprecated_hook_trigger_error', true ) ) || monsterinsights_is_debug_mode() ) { |
|
125 | - $message = empty( $message ) ? '' : ' ' . $message; |
|
126 | - trigger_error( sprintf( esc_html__( '%1$s is %3$sdeprecated%4$s since MonsterInsights version %2$s!', 'google-analytics-for-wordpress' ), $hook, $version, '<strong>', '</strong>' ) . esc_html ( $message ) ); |
|
127 | - } |
|
116 | + /** |
|
117 | + * Filters whether to trigger deprecated hook errors. |
|
118 | + * |
|
119 | + * @since 6.0.0 |
|
120 | + * |
|
121 | + * @param bool $trigger Whether to trigger deprecated hook errors. Requires |
|
122 | + * `WP_DEBUG` to be defined true. |
|
123 | + */ |
|
124 | + if ( ( WP_DEBUG && apply_filters( 'deprecated_hook_trigger_error', true ) ) || monsterinsights_is_debug_mode() ) { |
|
125 | + $message = empty( $message ) ? '' : ' ' . $message; |
|
126 | + trigger_error( sprintf( esc_html__( '%1$s is %3$sdeprecated%4$s since MonsterInsights version %2$s!', 'google-analytics-for-wordpress' ), $hook, $version, '<strong>', '</strong>' ) . esc_html ( $message ) ); |
|
127 | + } |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -153,33 +153,33 @@ discard block |
||
153 | 153 | */ |
154 | 154 | function _monsterinsights_deprecated_function( $function, $version, $backtrace = null ) { |
155 | 155 | |
156 | - /** |
|
157 | - * Deprecated Function Action. |
|
158 | - * |
|
159 | - * Allow plugin run an action on the use of a |
|
160 | - * deprecated function. This could be used to |
|
161 | - * feed into an error logging program or file. |
|
162 | - * |
|
163 | - * @since 6.0.0 |
|
164 | - * |
|
165 | - * @param string $function The function that was called. |
|
166 | - * @param string $version The version of WordPress that deprecated the function. |
|
167 | - * @param array $backtrace Optional. Contains stack backtrace of deprecated function. |
|
168 | - */ |
|
169 | - do_action( 'deprecated_function_run', $function, $version, $backtrace ); |
|
156 | + /** |
|
157 | + * Deprecated Function Action. |
|
158 | + * |
|
159 | + * Allow plugin run an action on the use of a |
|
160 | + * deprecated function. This could be used to |
|
161 | + * feed into an error logging program or file. |
|
162 | + * |
|
163 | + * @since 6.0.0 |
|
164 | + * |
|
165 | + * @param string $function The function that was called. |
|
166 | + * @param string $version The version of WordPress that deprecated the function. |
|
167 | + * @param array $backtrace Optional. Contains stack backtrace of deprecated function. |
|
168 | + */ |
|
169 | + do_action( 'deprecated_function_run', $function, $version, $backtrace ); |
|
170 | 170 | |
171 | - /** |
|
172 | - * Filters whether to trigger an error for deprecated functions. |
|
173 | - * |
|
174 | - * @since 6.0.0 |
|
175 | - * |
|
176 | - * @param bool $trigger Whether to trigger the error for deprecated functions. Default true. |
|
177 | - */ |
|
178 | - if ( ( WP_DEBUG && apply_filters( 'deprecated_function_trigger_error', true ) ) || monsterinsights_is_debug_mode() ) { |
|
179 | - trigger_error( sprintf( esc_html__( '%1$s is %3$sdeprecated%4$s since MonsterInsights version %2$s.', 'google-analytics-for-wordpress' ), $function, $version, '<strong>', '</strong>' ) ); |
|
180 | - trigger_error( print_r( $backtrace, 1 ) );// Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
181 | - // Alternatively we could dump this to a file. |
|
182 | - } |
|
171 | + /** |
|
172 | + * Filters whether to trigger an error for deprecated functions. |
|
173 | + * |
|
174 | + * @since 6.0.0 |
|
175 | + * |
|
176 | + * @param bool $trigger Whether to trigger the error for deprecated functions. Default true. |
|
177 | + */ |
|
178 | + if ( ( WP_DEBUG && apply_filters( 'deprecated_function_trigger_error', true ) ) || monsterinsights_is_debug_mode() ) { |
|
179 | + trigger_error( sprintf( esc_html__( '%1$s is %3$sdeprecated%4$s since MonsterInsights version %2$s.', 'google-analytics-for-wordpress' ), $function, $version, '<strong>', '</strong>' ) ); |
|
180 | + trigger_error( print_r( $backtrace, 1 ) );// Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
181 | + // Alternatively we could dump this to a file. |
|
182 | + } |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | /** |
@@ -198,32 +198,32 @@ discard block |
||
198 | 198 | */ |
199 | 199 | function _monsterinsights_deprecated( $message ) { |
200 | 200 | |
201 | - /** |
|
202 | - * Deprecated Message Filter. |
|
203 | - * |
|
204 | - * Allow plugin to filter the deprecated message. |
|
205 | - * |
|
206 | - * @since 6.0.0 |
|
207 | - * |
|
208 | - * @param string $message Error message. |
|
209 | - */ |
|
210 | - do_action( 'monsterinsights_deprecated_run', $message ); |
|
201 | + /** |
|
202 | + * Deprecated Message Filter. |
|
203 | + * |
|
204 | + * Allow plugin to filter the deprecated message. |
|
205 | + * |
|
206 | + * @since 6.0.0 |
|
207 | + * |
|
208 | + * @param string $message Error message. |
|
209 | + */ |
|
210 | + do_action( 'monsterinsights_deprecated_run', $message ); |
|
211 | 211 | |
212 | - $show_errors = current_user_can( 'manage_options' ); |
|
212 | + $show_errors = current_user_can( 'manage_options' ); |
|
213 | 213 | |
214 | - /** |
|
215 | - * Deprecated Error Trigger. |
|
216 | - * |
|
217 | - * Allow plugin to filter the output error trigger. |
|
218 | - * |
|
219 | - * @since 6.0.0 |
|
220 | - * |
|
221 | - * @param bool $show_errors Whether to show errors. |
|
222 | - */ |
|
223 | - $show_errors = apply_filters( 'monsterinsights_deprecated_trigger_error', $show_errors ); |
|
224 | - if ( ( WP_DEBUG && $show_errors ) || monsterinsights_is_debug_mode() ) { |
|
225 | - trigger_error( esc_html( $message ) ); |
|
226 | - } |
|
214 | + /** |
|
215 | + * Deprecated Error Trigger. |
|
216 | + * |
|
217 | + * Allow plugin to filter the output error trigger. |
|
218 | + * |
|
219 | + * @since 6.0.0 |
|
220 | + * |
|
221 | + * @param bool $show_errors Whether to show errors. |
|
222 | + */ |
|
223 | + $show_errors = apply_filters( 'monsterinsights_deprecated_trigger_error', $show_errors ); |
|
224 | + if ( ( WP_DEBUG && $show_errors ) || monsterinsights_is_debug_mode() ) { |
|
225 | + trigger_error( esc_html( $message ) ); |
|
226 | + } |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | |
@@ -244,8 +244,8 @@ discard block |
||
244 | 244 | * @return int Number of rows to request at most in API calls. |
245 | 245 | */ |
246 | 246 | function monsterinsights_yst_ga_filter_api_limit( $limit ) { |
247 | - $message = sprintf( __( 'Use %s instead.', 'google-analytics-for-wordpress' ), '<code>monsterinsights_reporting_get_max_api_limit</code>' ); |
|
248 | - return _monsterinsights_apply_filters_deprecated( 'yst-ga-filter-api-limit', array( $limit ), '6.0.0', $message ); |
|
247 | + $message = sprintf( __( 'Use %s instead.', 'google-analytics-for-wordpress' ), '<code>monsterinsights_reporting_get_max_api_limit</code>' ); |
|
248 | + return _monsterinsights_apply_filters_deprecated( 'yst-ga-filter-api-limit', array( $limit ), '6.0.0', $message ); |
|
249 | 249 | } |
250 | 250 | add_filter( 'monsterinsights_reporting_get_max_api_limit', 'monsterinsights_yst_ga_filter_api_limit' ); |
251 | 251 | |
@@ -258,9 +258,9 @@ discard block |
||
258 | 258 | * @return bool Whether to track super admins. Default false. |
259 | 259 | */ |
260 | 260 | function monsterinsights_yst_ga_track_super_admin( $track ) { |
261 | - $track = ! $track; // invert track as in Yoast it defaulted to track super admins |
|
262 | - $message = sprintf( __( 'Use %s instead.', 'google-analytics-for-wordpress' ), '<code>monsterinsights_track_super_admins</code>' ); |
|
263 | - return _monsterinsights_apply_filters_deprecated( 'yst_ga_track_super_admin', array( $track ), '6.0.0', $message ); |
|
261 | + $track = ! $track; // invert track as in Yoast it defaulted to track super admins |
|
262 | + $message = sprintf( __( 'Use %s instead.', 'google-analytics-for-wordpress' ), '<code>monsterinsights_track_super_admins</code>' ); |
|
263 | + return _monsterinsights_apply_filters_deprecated( 'yst_ga_track_super_admin', array( $track ), '6.0.0', $message ); |
|
264 | 264 | } |
265 | 265 | add_filter( 'monsterinsights_track_super_admins', 'monsterinsights_yst_ga_track_super_admin' ); |
266 | 266 | |
@@ -271,8 +271,8 @@ discard block |
||
271 | 271 | * Allows output before the analytics and ga.js tracking output. |
272 | 272 | */ |
273 | 273 | function monsterinsights_yst_tracking() { |
274 | - $message = sprintf( __( 'Use %s instead.', 'google-analytics-for-wordpress' ), '<code>monsterinsights_tracking_before{_$mode}</code>' ); |
|
275 | - _monsterinsights_do_action_deprecated( 'yst_tracking', array(), '6.0.0', $message ); |
|
274 | + $message = sprintf( __( 'Use %s instead.', 'google-analytics-for-wordpress' ), '<code>monsterinsights_tracking_before{_$mode}</code>' ); |
|
275 | + _monsterinsights_do_action_deprecated( 'yst_tracking', array(), '6.0.0', $message ); |
|
276 | 276 | } |
277 | 277 | add_action( 'monsterinsights_tracking_before_ga', 'monsterinsights_yst_tracking' ); |
278 | 278 | add_action( 'monsterinsights_tracking_before_analytics', 'monsterinsights_yst_tracking' ); |
@@ -286,8 +286,8 @@ discard block |
||
286 | 286 | * @return array GA.js options. |
287 | 287 | */ |
288 | 288 | function monsterinsights_yoast_ga_push_array_ga_js( $options ) { |
289 | - $message = sprintf( __( 'Use %s instead.', 'google-analytics-for-wordpress' ), '<code>monsterinsights_frontend_tracking_options_analytics_end</code>' ); |
|
290 | - return _monsterinsights_apply_filters_deprecated( 'yoast-ga-push-array-ga-js', array( $options ), '6.0.0', $message ); |
|
289 | + $message = sprintf( __( 'Use %s instead.', 'google-analytics-for-wordpress' ), '<code>monsterinsights_frontend_tracking_options_analytics_end</code>' ); |
|
290 | + return _monsterinsights_apply_filters_deprecated( 'yoast-ga-push-array-ga-js', array( $options ), '6.0.0', $message ); |
|
291 | 291 | } |
292 | 292 | add_filter( 'monsterinsights_frontend_tracking_options_ga_end', 'monsterinsights_yoast_ga_push_array_ga_js' ); |
293 | 293 | |
@@ -300,8 +300,8 @@ discard block |
||
300 | 300 | * @return array Analytics.js options. |
301 | 301 | */ |
302 | 302 | function monsterinsights_yoast_ga_push_array_universal( $options ) { |
303 | - $message = sprintf( __( 'Use %s instead.', 'google-analytics-for-wordpress' ), '<code>monsterinsights_frontend_tracking_options_analytics_end</code>' ); |
|
304 | - return _monsterinsights_apply_filters_deprecated( 'yoast-ga-push-array-universal', array( $options ), '6.0.0', $message ); |
|
303 | + $message = sprintf( __( 'Use %s instead.', 'google-analytics-for-wordpress' ), '<code>monsterinsights_frontend_tracking_options_analytics_end</code>' ); |
|
304 | + return _monsterinsights_apply_filters_deprecated( 'yoast-ga-push-array-universal', array( $options ), '6.0.0', $message ); |
|
305 | 305 | } |
306 | 306 | add_filter( 'monsterinsights_frontend_tracking_options_analytics_end', 'monsterinsights_yoast_ga_push_array_universal' ); |
307 | 307 | |
@@ -314,23 +314,23 @@ discard block |
||
314 | 314 | * @return array Analytics.js options. |
315 | 315 | */ |
316 | 316 | function monsterinsights_yst_ga_filter_push_vars( $options ) { |
317 | - if ( ! has_filter('yst_ga_filter_push_vars' ) ) { |
|
318 | - return $options; |
|
319 | - } else { |
|
320 | - $message = sprintf( __( 'Use %s instead.', 'google-analytics-for-wordpress' ), '<code>monsterinsights_frontend_tracking_options_analytics_before_scripts</code>' ); |
|
321 | - _monsterinsights_deprecated_hook( 'yst_ga_filter_push_vars', '6.0.0', $message ); |
|
317 | + if ( ! has_filter('yst_ga_filter_push_vars' ) ) { |
|
318 | + return $options; |
|
319 | + } else { |
|
320 | + $message = sprintf( __( 'Use %s instead.', 'google-analytics-for-wordpress' ), '<code>monsterinsights_frontend_tracking_options_analytics_before_scripts</code>' ); |
|
321 | + _monsterinsights_deprecated_hook( 'yst_ga_filter_push_vars', '6.0.0', $message ); |
|
322 | 322 | |
323 | - $i = 0; |
|
324 | - while ( true ) { |
|
325 | - if ( empty( $options[ 'yst_ga_filter_push_vars_' . $i ] ) ) { |
|
326 | - $options[ 'yst_ga_filter_push_vars_' . $i ] = apply_filters( 'yst_ga_filter_push_vars', $options ); |
|
327 | - break; |
|
328 | - } else { |
|
329 | - $i++; |
|
330 | - } |
|
331 | - } |
|
332 | - return $options; |
|
333 | - } |
|
323 | + $i = 0; |
|
324 | + while ( true ) { |
|
325 | + if ( empty( $options[ 'yst_ga_filter_push_vars_' . $i ] ) ) { |
|
326 | + $options[ 'yst_ga_filter_push_vars_' . $i ] = apply_filters( 'yst_ga_filter_push_vars', $options ); |
|
327 | + break; |
|
328 | + } else { |
|
329 | + $i++; |
|
330 | + } |
|
331 | + } |
|
332 | + return $options; |
|
333 | + } |
|
334 | 334 | } |
335 | 335 | add_filter( 'monsterinsights_frontend_tracking_options_analytics_before_scripts', 'monsterinsights_yst_ga_filter_push_vars' ); |
336 | 336 | |
@@ -344,12 +344,12 @@ discard block |
||
344 | 344 | * @return array GA App config. |
345 | 345 | */ |
346 | 346 | function monsterinsights_yst_ga_filter_ga_config( $config ) { |
347 | - $message = sprintf( __( 'Use %s instead.', 'google-analytics-for-wordpress' ), '<code>monsterinsights_{lite/pro}_google_app_config</code>' ); |
|
348 | - return _monsterinsights_apply_filters_deprecated( 'yst-ga-filter-ga-config', array( $config ), '6.0.0', $message ); |
|
347 | + $message = sprintf( __( 'Use %s instead.', 'google-analytics-for-wordpress' ), '<code>monsterinsights_{lite/pro}_google_app_config</code>' ); |
|
348 | + return _monsterinsights_apply_filters_deprecated( 'yst-ga-filter-ga-config', array( $config ), '6.0.0', $message ); |
|
349 | 349 | } |
350 | 350 | add_filter( 'monsterinsights_lite_google_app_config', 'monsterinsights_yst_ga_filter_ga_config' ); |
351 | 351 | add_filter( 'monsterinsights_pro_google_app_config', 'monsterinsights_yst_ga_filter_ga_config' ); |
352 | 352 | |
353 | 353 | function monsterinsights_disabled_user_group(){ |
354 | - return ! monsterinsights_track_user(); |
|
354 | + return ! monsterinsights_track_user(); |
|
355 | 355 | } |
356 | 356 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
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 | |
@@ -23,21 +23,21 @@ discard block |
||
23 | 23 | function monsterinsights_ajax_set_user_setting() { |
24 | 24 | |
25 | 25 | // Run a security check first. |
26 | - check_ajax_referer( 'monsterinsights-set-user-setting', 'nonce' ); |
|
26 | + check_ajax_referer('monsterinsights-set-user-setting', 'nonce'); |
|
27 | 27 | |
28 | 28 | // Prepare variables. |
29 | - $name = stripslashes( $_POST['name'] ); |
|
30 | - $value = stripslashes( $_POST['value'] ); |
|
29 | + $name = stripslashes($_POST['name']); |
|
30 | + $value = stripslashes($_POST['value']); |
|
31 | 31 | |
32 | 32 | // Set user setting. |
33 | - set_user_setting( $name, $value ); |
|
33 | + set_user_setting($name, $value); |
|
34 | 34 | |
35 | 35 | // Send back the response. |
36 | 36 | wp_send_json_success(); |
37 | 37 | wp_die(); |
38 | 38 | |
39 | 39 | } |
40 | -add_action( 'wp_ajax_monsterinsights_install_addon', 'monsterinsights_ajax_install_addon' ); |
|
40 | +add_action('wp_ajax_monsterinsights_install_addon', 'monsterinsights_ajax_install_addon'); |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * Installs a MonsterInsights addon. |
@@ -48,14 +48,14 @@ discard block |
||
48 | 48 | function monsterinsights_ajax_install_addon() { |
49 | 49 | |
50 | 50 | // Run a security check first. |
51 | - check_ajax_referer( 'monsterinsights-install', 'nonce' ); |
|
51 | + check_ajax_referer('monsterinsights-install', 'nonce'); |
|
52 | 52 | |
53 | - if ( ! current_user_can( 'install_plugins' ) ) { |
|
54 | - echo json_encode( true ); |
|
53 | + if ( ! current_user_can('install_plugins')) { |
|
54 | + echo json_encode(true); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | // Install the addon. |
58 | - if ( isset( $_POST['plugin'] ) ) { |
|
58 | + if (isset($_POST['plugin'])) { |
|
59 | 59 | $download_url = $_POST['plugin']; |
60 | 60 | global $hook_suffix; |
61 | 61 | |
@@ -68,52 +68,52 @@ discard block |
||
68 | 68 | array( |
69 | 69 | 'page' => 'monsterinsights-settings' |
70 | 70 | ), |
71 | - admin_url( 'admin.php' ) |
|
71 | + admin_url('admin.php') |
|
72 | 72 | ); |
73 | - $url = esc_url( $url ); |
|
73 | + $url = esc_url($url); |
|
74 | 74 | |
75 | 75 | // Start output bufferring to catch the filesystem form if credentials are needed. |
76 | 76 | ob_start(); |
77 | - if ( false === ( $creds = request_filesystem_credentials( $url, $method, false, false, null ) ) ) { |
|
77 | + if (false === ($creds = request_filesystem_credentials($url, $method, false, false, null))) { |
|
78 | 78 | $form = ob_get_clean(); |
79 | - echo json_encode( array( 'form' => $form ) ); |
|
79 | + echo json_encode(array('form' => $form)); |
|
80 | 80 | wp_die(); |
81 | 81 | } |
82 | 82 | |
83 | 83 | // If we are not authenticated, make it happen now. |
84 | - if ( ! WP_Filesystem( $creds ) ) { |
|
84 | + if ( ! WP_Filesystem($creds)) { |
|
85 | 85 | ob_start(); |
86 | - request_filesystem_credentials( $url, $method, true, false, null ); |
|
86 | + request_filesystem_credentials($url, $method, true, false, null); |
|
87 | 87 | $form = ob_get_clean(); |
88 | - echo json_encode( array( 'form' => $form ) ); |
|
88 | + echo json_encode(array('form' => $form)); |
|
89 | 89 | wp_die(); |
90 | 90 | } |
91 | 91 | |
92 | 92 | // We do not need any extra credentials if we have gotten this far, so let's install the plugin. |
93 | 93 | require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
94 | 94 | $base = MonsterInsights(); |
95 | - require_once plugin_dir_path( $base->file ) . '/includes/admin/licensing/skin.php'; |
|
95 | + require_once plugin_dir_path($base->file) . '/includes/admin/licensing/skin.php'; |
|
96 | 96 | |
97 | 97 | // Create the plugin upgrader with our custom skin. |
98 | - $installer = new Plugin_Upgrader( $skin = new MonsterInsights_Skin() ); |
|
99 | - $installer->install( $download_url ); |
|
98 | + $installer = new Plugin_Upgrader($skin = new MonsterInsights_Skin()); |
|
99 | + $installer->install($download_url); |
|
100 | 100 | |
101 | 101 | // Flush the cache and return the newly installed plugin basename. |
102 | 102 | wp_cache_flush(); |
103 | - if ( $installer->plugin_info() ) { |
|
103 | + if ($installer->plugin_info()) { |
|
104 | 104 | $plugin_basename = $installer->plugin_info(); |
105 | - echo json_encode( array( 'plugin' => $plugin_basename ) ); |
|
105 | + echo json_encode(array('plugin' => $plugin_basename)); |
|
106 | 106 | wp_die(); |
107 | 107 | } |
108 | 108 | } |
109 | 109 | |
110 | 110 | // Send back a response. |
111 | - echo json_encode( true ); |
|
111 | + echo json_encode(true); |
|
112 | 112 | wp_die(); |
113 | 113 | |
114 | 114 | } |
115 | 115 | |
116 | -add_action( 'wp_ajax_monsterinsights_activate_addon', 'monsterinsights_ajax_activate_addon' ); |
|
116 | +add_action('wp_ajax_monsterinsights_activate_addon', 'monsterinsights_ajax_activate_addon'); |
|
117 | 117 | /** |
118 | 118 | * Activates a MonsterInsights addon. |
119 | 119 | * |
@@ -123,32 +123,32 @@ discard block |
||
123 | 123 | function monsterinsights_ajax_activate_addon() { |
124 | 124 | |
125 | 125 | // Run a security check first. |
126 | - check_ajax_referer( 'monsterinsights-activate', 'nonce' ); |
|
126 | + check_ajax_referer('monsterinsights-activate', 'nonce'); |
|
127 | 127 | |
128 | - if ( ! current_user_can( 'activate_plugins' ) ) { |
|
129 | - echo json_encode( true ); |
|
128 | + if ( ! current_user_can('activate_plugins')) { |
|
129 | + echo json_encode(true); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | // Activate the addon. |
133 | - if ( isset( $_POST['plugin'] ) ) { |
|
134 | - if ( isset( $_POST['isnetwork'] ) && $_POST['isnetwork'] ) { |
|
135 | - $activate = activate_plugin( $_POST['plugin'], NULL, true ); |
|
133 | + if (isset($_POST['plugin'])) { |
|
134 | + if (isset($_POST['isnetwork']) && $_POST['isnetwork']) { |
|
135 | + $activate = activate_plugin($_POST['plugin'], NULL, true); |
|
136 | 136 | } else { |
137 | - $activate = activate_plugin( $_POST['plugin'] ); |
|
137 | + $activate = activate_plugin($_POST['plugin']); |
|
138 | 138 | } |
139 | 139 | |
140 | - if ( is_wp_error( $activate ) ) { |
|
141 | - echo json_encode( array( 'error' => $activate->get_error_message() ) ); |
|
140 | + if (is_wp_error($activate)) { |
|
141 | + echo json_encode(array('error' => $activate->get_error_message())); |
|
142 | 142 | wp_die(); |
143 | 143 | } |
144 | 144 | } |
145 | 145 | |
146 | - echo json_encode( true ); |
|
146 | + echo json_encode(true); |
|
147 | 147 | wp_die(); |
148 | 148 | |
149 | 149 | } |
150 | 150 | |
151 | -add_action( 'wp_ajax_monsterinsights_deactivate_addon', 'monsterinsights_ajax_deactivate_addon' ); |
|
151 | +add_action('wp_ajax_monsterinsights_deactivate_addon', 'monsterinsights_ajax_deactivate_addon'); |
|
152 | 152 | /** |
153 | 153 | * Deactivates a MonsterInsights addon. |
154 | 154 | * |
@@ -158,22 +158,22 @@ discard block |
||
158 | 158 | function monsterinsights_ajax_deactivate_addon() { |
159 | 159 | |
160 | 160 | // Run a security check first. |
161 | - check_ajax_referer( 'monsterinsights-deactivate', 'nonce' ); |
|
161 | + check_ajax_referer('monsterinsights-deactivate', 'nonce'); |
|
162 | 162 | |
163 | - if ( ! current_user_can( 'activate_plugins' ) ) { |
|
164 | - echo json_encode( true ); |
|
163 | + if ( ! current_user_can('activate_plugins')) { |
|
164 | + echo json_encode(true); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | // Deactivate the addon. |
168 | - if ( isset( $_POST['plugin'] ) ) { |
|
169 | - if ( isset( $_POST['isnetwork'] ) && $_POST['isnetwork'] ) { |
|
170 | - $deactivate = deactivate_plugins( $_POST['plugin'], false, true ); |
|
168 | + if (isset($_POST['plugin'])) { |
|
169 | + if (isset($_POST['isnetwork']) && $_POST['isnetwork']) { |
|
170 | + $deactivate = deactivate_plugins($_POST['plugin'], false, true); |
|
171 | 171 | } else { |
172 | - $deactivate = deactivate_plugins( $_POST['plugin'] ); |
|
172 | + $deactivate = deactivate_plugins($_POST['plugin']); |
|
173 | 173 | } |
174 | 174 | } |
175 | 175 | |
176 | - echo json_encode( true ); |
|
176 | + echo json_encode(true); |
|
177 | 177 | wp_die(); |
178 | 178 | } |
179 | 179 | |
@@ -189,46 +189,46 @@ discard block |
||
189 | 189 | function monsterinsights_ajax_dismiss_notice() { |
190 | 190 | |
191 | 191 | // Run a security check first. |
192 | - check_ajax_referer( 'monsterinsights-dismiss-notice', 'nonce' ); |
|
192 | + check_ajax_referer('monsterinsights-dismiss-notice', 'nonce'); |
|
193 | 193 | |
194 | 194 | // Deactivate the notice |
195 | - if ( isset( $_POST['notice'] ) ) { |
|
195 | + if (isset($_POST['notice'])) { |
|
196 | 196 | // Init the notice class and mark notice as deactivated |
197 | - MonsterInsights()->notices->dismiss( $_POST['notice'] ); |
|
197 | + MonsterInsights()->notices->dismiss($_POST['notice']); |
|
198 | 198 | |
199 | 199 | // Return true |
200 | - echo json_encode( true ); |
|
200 | + echo json_encode(true); |
|
201 | 201 | wp_die(); |
202 | 202 | } |
203 | 203 | |
204 | 204 | // If here, an error occured |
205 | - echo json_encode( false ); |
|
205 | + echo json_encode(false); |
|
206 | 206 | wp_die(); |
207 | 207 | |
208 | 208 | } |
209 | -add_action( 'wp_ajax_monsterinsights_ajax_dismiss_notice', 'monsterinsights_ajax_dismiss_notice' ); |
|
209 | +add_action('wp_ajax_monsterinsights_ajax_dismiss_notice', 'monsterinsights_ajax_dismiss_notice'); |
|
210 | 210 | |
211 | 211 | |
212 | 212 | function monsterinsights_get_shortlink() { |
213 | 213 | // Run a security check first. |
214 | - check_ajax_referer( 'mi-admin-nonce', 'nonce' ); |
|
214 | + check_ajax_referer('mi-admin-nonce', 'nonce'); |
|
215 | 215 | |
216 | - $shorten = ! empty( $_POST['url'] ) ? esc_url_raw( $_POST['url'] ) : ''; |
|
217 | - if ( ! current_user_can( 'monsterinsights_view_dashboard' ) ) { |
|
216 | + $shorten = ! empty($_POST['url']) ? esc_url_raw($_POST['url']) : ''; |
|
217 | + if ( ! current_user_can('monsterinsights_view_dashboard')) { |
|
218 | 218 | echo $shorten; |
219 | 219 | wp_die(); |
220 | 220 | } |
221 | 221 | |
222 | - $url = 'https://www.googleapis.com/urlshortener/v1/url'; |
|
222 | + $url = 'https://www.googleapis.com/urlshortener/v1/url'; |
|
223 | 223 | |
224 | 224 | // If no url passed die |
225 | - if ( ! $shorten ) { |
|
225 | + if ( ! $shorten) { |
|
226 | 226 | echo $shorten; |
227 | 227 | wp_die(); |
228 | 228 | } |
229 | 229 | |
230 | 230 | // if the url is already shortened, don't re-run |
231 | - if ( strpos( $shorten, 'goo.g') !== false ) { |
|
231 | + if (strpos($shorten, 'goo.g') !== false) { |
|
232 | 232 | echo $shorten; |
233 | 233 | wp_die(); |
234 | 234 | } |
@@ -240,18 +240,18 @@ discard block |
||
240 | 240 | 'https://www.googleapis.com/urlshortener/v1/url' |
241 | 241 | ), |
242 | 242 | array( |
243 | - 'body' => json_encode( array('longUrl' => esc_url_raw( $shorten ) ) ), |
|
244 | - 'headers' => array( 'Content-Type' => 'application/json') |
|
243 | + 'body' => json_encode(array('longUrl' => esc_url_raw($shorten))), |
|
244 | + 'headers' => array('Content-Type' => 'application/json') |
|
245 | 245 | ) |
246 | 246 | ); |
247 | 247 | |
248 | - if ( is_wp_error( $result ) ) { |
|
248 | + if (is_wp_error($result)) { |
|
249 | 249 | echo $shorten; |
250 | 250 | wp_die(); |
251 | 251 | } |
252 | - $result = json_decode( $result['body'] ); |
|
252 | + $result = json_decode($result['body']); |
|
253 | 253 | $shortlink = $result->id; |
254 | 254 | echo $shortlink; |
255 | 255 | wp_die(); |
256 | 256 | } |
257 | -add_action( 'wp_ajax_monsterinsights_get_shortlink', 'monsterinsights_get_shortlink' ); |
|
258 | 257 | \ No newline at end of file |
258 | +add_action('wp_ajax_monsterinsights_get_shortlink', 'monsterinsights_get_shortlink'); |
|
259 | 259 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
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 | |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @param array $args Empty array of args (we will use defaults). |
25 | 25 | */ |
26 | - public function __construct( $args = array() ) { |
|
26 | + public function __construct($args = array()) { |
|
27 | 27 | |
28 | 28 | parent::__construct(); |
29 | 29 | |
@@ -36,10 +36,10 @@ discard block |
||
36 | 36 | * |
37 | 37 | * @param object $upgrader The upgrader object (passed by reference). |
38 | 38 | */ |
39 | - public function set_upgrader( &$upgrader ) { |
|
39 | + public function set_upgrader(&$upgrader) { |
|
40 | 40 | |
41 | - if ( is_object( $upgrader ) ) { |
|
42 | - $this->upgrader =& $upgrader; |
|
41 | + if (is_object($upgrader)) { |
|
42 | + $this->upgrader = & $upgrader; |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * |
52 | 52 | * @param object $result The result of the install process. |
53 | 53 | */ |
54 | - public function set_result( $result ) { |
|
54 | + public function set_result($result) { |
|
55 | 55 | |
56 | 56 | $this->result = $result; |
57 | 57 | |
@@ -80,10 +80,10 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @param array $errors Array of errors with the install process. |
82 | 82 | */ |
83 | - function error( $errors ) { |
|
83 | + function error($errors) { |
|
84 | 84 | |
85 | - if ( ! empty( $errors ) ) { |
|
86 | - echo json_encode( array( 'error' => esc_html__( 'There was an error installing the addon. Please try again.', 'google-analytics-for-wordpress' ) ) ); |
|
85 | + if ( ! empty($errors)) { |
|
86 | + echo json_encode(array('error' => esc_html__('There was an error installing the addon. Please try again.', 'google-analytics-for-wordpress'))); |
|
87 | 87 | die; |
88 | 88 | } |
89 | 89 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * |
98 | 98 | * @param string $string The feedback string. |
99 | 99 | */ |
100 | - function feedback( $string ) { |
|
100 | + function feedback($string) { |
|
101 | 101 | |
102 | 102 | } |
103 | 103 |
@@ -10,7 +10,7 @@ discard block |
||
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 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @param array $config Array of updater config args. |
115 | 115 | */ |
116 | - public function __construct( array $config ) { |
|
116 | + public function __construct(array $config) { |
|
117 | 117 | |
118 | 118 | // Load the base class object. |
119 | 119 | $this->base = MonsterInsights(); |
@@ -128,20 +128,20 @@ discard block |
||
128 | 128 | 'version', |
129 | 129 | 'key' |
130 | 130 | ); |
131 | - foreach ( $accepted_args as $arg ) { |
|
131 | + foreach ($accepted_args as $arg) { |
|
132 | 132 | $this->$arg = $config[$arg]; |
133 | 133 | } |
134 | 134 | |
135 | 135 | // If the user cannot update plugins, stop processing here. |
136 | - if ( ! current_user_can( 'update_plugins' ) && ( ! defined( 'DOING_CRON' ) || ! DOING_CRON ) ) { |
|
136 | + if ( ! current_user_can('update_plugins') && ( ! defined('DOING_CRON') || ! DOING_CRON)) { |
|
137 | 137 | return; |
138 | 138 | } |
139 | 139 | |
140 | 140 | // Load the updater hooks and filters. |
141 | - add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'update_plugins_filter' ) ); |
|
141 | + add_filter('pre_set_site_transient_update_plugins', array($this, 'update_plugins_filter')); |
|
142 | 142 | |
143 | - add_filter( 'http_request_args', array( $this, 'http_request_args' ), 10, 2 ); |
|
144 | - add_filter( 'plugins_api', array( $this, 'plugins_api' ), 10, 3 ); |
|
143 | + add_filter('http_request_args', array($this, 'http_request_args'), 10, 2); |
|
144 | + add_filter('plugins_api', array($this, 'plugins_api'), 10, 3); |
|
145 | 145 | |
146 | 146 | // ManageWP premium update filters |
147 | 147 | //add_filter( 'mwp_premium_update_notification', array( $this, 'premium_update_push' ) ); |
@@ -156,24 +156,24 @@ discard block |
||
156 | 156 | * @param object $value The WordPress update object. |
157 | 157 | * @return object $value Amended WordPress update object on success, default if object is empty. |
158 | 158 | */ |
159 | - public function update_plugins_filter( $value ) { |
|
159 | + public function update_plugins_filter($value) { |
|
160 | 160 | |
161 | 161 | // If no update object exists, return early. |
162 | - if ( empty( $value ) ) { |
|
162 | + if (empty($value)) { |
|
163 | 163 | return $value; |
164 | 164 | } |
165 | 165 | |
166 | 166 | // Run update check by pinging the external API. If it fails, return the default update object. |
167 | - if ( ! $this->update ) { |
|
168 | - $this->update = $this->perform_remote_request( 'get-plugin-update', array( 'tgm-updater-plugin' => $this->plugin_slug ) ); |
|
169 | - if ( ! $this->update || ! empty( $this->update->error ) ) { |
|
167 | + if ( ! $this->update) { |
|
168 | + $this->update = $this->perform_remote_request('get-plugin-update', array('tgm-updater-plugin' => $this->plugin_slug)); |
|
169 | + if ( ! $this->update || ! empty($this->update->error)) { |
|
170 | 170 | $this->update = false; |
171 | 171 | return $value; |
172 | 172 | } |
173 | 173 | } |
174 | 174 | |
175 | 175 | // Infuse the update object with our data if the version from the remote API is newer. |
176 | - if ( isset( $this->update->new_version ) && version_compare( $this->version, $this->update->new_version, '<' ) ) { |
|
176 | + if (isset($this->update->new_version) && version_compare($this->version, $this->update->new_version, '<')) { |
|
177 | 177 | // The $plugin_update object contains new_version, package, slug and last_update keys. |
178 | 178 | //$this->update->full_slug = $this->plugin_slug; |
179 | 179 | //$this->update->name = $this->plugin_name; |
@@ -197,10 +197,10 @@ discard block |
||
197 | 197 | * @param string $url The URL to be pinged. |
198 | 198 | * @return array $args Amended array of request args. |
199 | 199 | */ |
200 | - public function http_request_args( $args, $url ) { |
|
200 | + public function http_request_args($args, $url) { |
|
201 | 201 | |
202 | 202 | // If this is an SSL request and we are performing an upgrade routine, disable SSL verification. |
203 | - if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'tgm-updater-action=get-plugin-update' ) ) { |
|
203 | + if (strpos($url, 'https://') !== false && strpos($url, 'tgm-updater-action=get-plugin-update')) { |
|
204 | 204 | $args['sslverify'] = false; |
205 | 205 | } |
206 | 206 | |
@@ -219,13 +219,13 @@ discard block |
||
219 | 219 | * @param array $args Additional args to send to plugins_api. |
220 | 220 | * @return object $api New stdClass with plugin information on success, default response on failure. |
221 | 221 | */ |
222 | - public function plugins_api( $api, $action = '', $args = null ) { |
|
222 | + public function plugins_api($api, $action = '', $args = null) { |
|
223 | 223 | |
224 | - $plugin = ( 'plugin_information' == $action ) && isset( $args->slug ) && ( $this->plugin_slug == $args->slug ); |
|
224 | + $plugin = ('plugin_information' == $action) && isset($args->slug) && ($this->plugin_slug == $args->slug); |
|
225 | 225 | |
226 | 226 | // If our plugin matches the request, set our own plugin data, else return the default response. |
227 | - if ( $plugin ) { |
|
228 | - return $this->set_plugins_api( $api ); |
|
227 | + if ($plugin) { |
|
228 | + return $this->set_plugins_api($api); |
|
229 | 229 | } else { |
230 | 230 | return $api; |
231 | 231 | } |
@@ -240,12 +240,12 @@ discard block |
||
240 | 240 | * @param object $default_api The default API object. |
241 | 241 | * @return object $api Return custom plugin information to plugins_api. |
242 | 242 | */ |
243 | - public function set_plugins_api( $default_api ) { |
|
243 | + public function set_plugins_api($default_api) { |
|
244 | 244 | |
245 | 245 | // Perform the remote request to retrieve our plugin information. If it fails, return the default object. |
246 | - if ( ! $this->info ) { |
|
247 | - $this->info = $this->perform_remote_request( 'get-plugin-info', array( 'tgm-updater-plugin' => $this->plugin_slug ) ); |
|
248 | - if ( ! $this->info || ! empty( $this->info->error ) ) { |
|
246 | + if ( ! $this->info) { |
|
247 | + $this->info = $this->perform_remote_request('get-plugin-info', array('tgm-updater-plugin' => $this->plugin_slug)); |
|
248 | + if ( ! $this->info || ! empty($this->info->error)) { |
|
249 | 249 | $this->info = false; |
250 | 250 | return $default_api; |
251 | 251 | } |
@@ -253,33 +253,33 @@ discard block |
||
253 | 253 | |
254 | 254 | // Create a new stdClass object and populate it with our plugin information. |
255 | 255 | $api = new stdClass; |
256 | - $api->name = isset( $this->info->name ) ? $this->info->name : ''; |
|
257 | - $api->slug = isset( $this->info->slug ) ? $this->info->slug : ''; |
|
258 | - $api->version = isset( $this->info->version ) ? $this->info->version : ''; |
|
259 | - $api->author = isset( $this->info->author ) ? $this->info->author : ''; |
|
260 | - $api->author_profile = isset( $this->info->author_profile ) ? $this->info->author_profile : ''; |
|
261 | - $api->requires = isset( $this->info->requires ) ? $this->info->requires : ''; |
|
262 | - $api->tested = isset( $this->info->tested ) ? $this->info->tested : ''; |
|
263 | - $api->last_updated = isset( $this->info->last_updated ) ? $this->info->last_updated : ''; |
|
264 | - $api->homepage = isset( $this->info->homepage ) ? $this->info->homepage : ''; |
|
265 | - |
|
266 | - $changelog = isset( $this->info->changelog ) ? $this->info->changelog : ''; |
|
267 | - $description = isset( $this->info->description ) ? $this->info->description : ''; |
|
268 | - |
|
269 | - if ( ! empty( $changelog ) ) { |
|
270 | - if ( ! empty( $description ) ) { |
|
256 | + $api->name = isset($this->info->name) ? $this->info->name : ''; |
|
257 | + $api->slug = isset($this->info->slug) ? $this->info->slug : ''; |
|
258 | + $api->version = isset($this->info->version) ? $this->info->version : ''; |
|
259 | + $api->author = isset($this->info->author) ? $this->info->author : ''; |
|
260 | + $api->author_profile = isset($this->info->author_profile) ? $this->info->author_profile : ''; |
|
261 | + $api->requires = isset($this->info->requires) ? $this->info->requires : ''; |
|
262 | + $api->tested = isset($this->info->tested) ? $this->info->tested : ''; |
|
263 | + $api->last_updated = isset($this->info->last_updated) ? $this->info->last_updated : ''; |
|
264 | + $api->homepage = isset($this->info->homepage) ? $this->info->homepage : ''; |
|
265 | + |
|
266 | + $changelog = isset($this->info->changelog) ? $this->info->changelog : ''; |
|
267 | + $description = isset($this->info->description) ? $this->info->description : ''; |
|
268 | + |
|
269 | + if ( ! empty($changelog)) { |
|
270 | + if ( ! empty($description)) { |
|
271 | 271 | $api->sections['description'] = $description; |
272 | 272 | $api->sections['changelog'] = $changelog; |
273 | 273 | } else { |
274 | 274 | $api->sections['changelog'] = $changelog; |
275 | 275 | } |
276 | - } else if ( ! empty( $description ) ) { |
|
276 | + } else if ( ! empty($description)) { |
|
277 | 277 | $api->sections['description'] = $description; |
278 | 278 | } else { |
279 | 279 | $api->sections = array(); |
280 | 280 | } |
281 | 281 | |
282 | - $api->download_link = isset( $this->info->download_link ) ? $this->info->download_link : ''; |
|
282 | + $api->download_link = isset($this->info->download_link) ? $this->info->download_link : ''; |
|
283 | 283 | |
284 | 284 | // Return the new API object with our custom data. |
285 | 285 | return $api; |
@@ -287,14 +287,14 @@ discard block |
||
287 | 287 | } |
288 | 288 | |
289 | 289 | // Integration with ManageWP |
290 | - public function premium_update_push( $premium_update ) { |
|
291 | - if ( ! function_exists( 'get_plugin_data' ) ) { |
|
292 | - include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
290 | + public function premium_update_push($premium_update) { |
|
291 | + if ( ! function_exists('get_plugin_data')) { |
|
292 | + include_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
293 | 293 | } |
294 | 294 | |
295 | - $update = $this->set_plugins_api( array() ); |
|
296 | - if ( ! empty( $update ) && version_compare( MONSTERINSIGHTS_VERSION, $update->version, '<' ) ) { |
|
297 | - $plugin_data = get_plugin_data( $update->slug ); |
|
295 | + $update = $this->set_plugins_api(array()); |
|
296 | + if ( ! empty($update) && version_compare(MONSTERINSIGHTS_VERSION, $update->version, '<')) { |
|
297 | + $plugin_data = get_plugin_data($update->slug); |
|
298 | 298 | $plugin_data['type'] = 'plugin'; |
299 | 299 | $plugin_data['slug'] = $update->slug; |
300 | 300 | $plugin_data['new_version'] = $update->version; |
@@ -304,18 +304,18 @@ discard block |
||
304 | 304 | } |
305 | 305 | |
306 | 306 | // Integration with ManageWP |
307 | - public function premium_update( $premium_update ) { |
|
308 | - if ( ! function_exists( 'get_plugin_data' ) ) { |
|
309 | - include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
307 | + public function premium_update($premium_update) { |
|
308 | + if ( ! function_exists('get_plugin_data')) { |
|
309 | + include_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
310 | 310 | } |
311 | 311 | |
312 | - $update = $this->set_plugins_api( array() ); |
|
313 | - if ( ! empty( $update ) && version_compare( MONSTERINSIGHTS_VERSION, $update->version, '<' ) ) { |
|
314 | - $plugin_data = get_plugin_data( $update->slug ); |
|
312 | + $update = $this->set_plugins_api(array()); |
|
313 | + if ( ! empty($update) && version_compare(MONSTERINSIGHTS_VERSION, $update->version, '<')) { |
|
314 | + $plugin_data = get_plugin_data($update->slug); |
|
315 | 315 | $plugin_data['type'] = 'plugin'; |
316 | 316 | $plugin_data['slug'] = $update->slug; |
317 | 317 | $plugin_data['url'] = $update->download_link; // OR provide your own callback function for managing the update |
318 | - array_push( $premium_update, $plugin_data ); |
|
318 | + array_push($premium_update, $plugin_data); |
|
319 | 319 | } |
320 | 320 | return $premium_update; |
321 | 321 | } |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | * @param string $return_format The format for returning content from the remote URL. |
332 | 332 | * @return string|bool Json decoded response on success, false on failure. |
333 | 333 | */ |
334 | - public function perform_remote_request( $action, $body = array(), $headers = array(), $return_format = 'json' ) { |
|
334 | + public function perform_remote_request($action, $body = array(), $headers = array(), $return_format = 'json') { |
|
335 | 335 | |
336 | 336 | // Build the body of the request. |
337 | 337 | $body = wp_parse_args( |
@@ -339,20 +339,20 @@ discard block |
||
339 | 339 | array( |
340 | 340 | 'tgm-updater-action' => $action, |
341 | 341 | 'tgm-updater-key' => $this->key, |
342 | - 'tgm-updater-wp-version' => get_bloginfo( 'version' ), |
|
342 | + 'tgm-updater-wp-version' => get_bloginfo('version'), |
|
343 | 343 | 'tgm-updater-referer' => site_url(), |
344 | 344 | 'tgm-updater-mi-version' => MONSTERINSIGHTS_VERSION, |
345 | 345 | 'tgm-updater-is-pro' => monsterinsights_is_pro_version(), |
346 | 346 | ) |
347 | 347 | ); |
348 | - $body = http_build_query( $body, '', '&' ); |
|
348 | + $body = http_build_query($body, '', '&'); |
|
349 | 349 | |
350 | 350 | // Build the headers of the request. |
351 | 351 | $headers = wp_parse_args( |
352 | 352 | $headers, |
353 | 353 | array( |
354 | 354 | 'Content-Type' => 'application/x-www-form-urlencoded', |
355 | - 'Content-Length' => strlen( $body ) |
|
355 | + 'Content-Length' => strlen($body) |
|
356 | 356 | ) |
357 | 357 | ); |
358 | 358 | |
@@ -363,17 +363,17 @@ discard block |
||
363 | 363 | ); |
364 | 364 | |
365 | 365 | // Perform the query and retrieve the response. |
366 | - $response = wp_remote_post( esc_url_raw( $this->remote_url ), $post ); |
|
367 | - $response_code = wp_remote_retrieve_response_code( $response ); |
|
368 | - $response_body = wp_remote_retrieve_body( $response ); |
|
366 | + $response = wp_remote_post(esc_url_raw($this->remote_url), $post); |
|
367 | + $response_code = wp_remote_retrieve_response_code($response); |
|
368 | + $response_body = wp_remote_retrieve_body($response); |
|
369 | 369 | |
370 | 370 | // Bail out early if there are any errors. |
371 | - if ( 200 != $response_code || is_wp_error( $response_body ) ) { |
|
371 | + if (200 != $response_code || is_wp_error($response_body)) { |
|
372 | 372 | return false; |
373 | 373 | } |
374 | 374 | |
375 | 375 | // Return the json decoded content. |
376 | - return json_decode( $response_body ); |
|
376 | + return json_decode($response_body); |
|
377 | 377 | |
378 | 378 | } |
379 | 379 | } |
380 | 380 | \ No newline at end of file |
@@ -267,12 +267,12 @@ |
||
267 | 267 | $description = isset( $this->info->description ) ? $this->info->description : ''; |
268 | 268 | |
269 | 269 | if ( ! empty( $changelog ) ) { |
270 | - if ( ! empty( $description ) ) { |
|
270 | + if ( ! empty( $description ) ) { |
|
271 | 271 | $api->sections['description'] = $description; |
272 | 272 | $api->sections['changelog'] = $changelog; |
273 | - } else { |
|
273 | + } else { |
|
274 | 274 | $api->sections['changelog'] = $changelog; |
275 | - } |
|
275 | + } |
|
276 | 276 | } else if ( ! empty( $description ) ) { |
277 | 277 | $api->sections['description'] = $description; |
278 | 278 | } else { |
@@ -9,34 +9,34 @@ discard block |
||
9 | 9 | * @param array $item Update data about a specific plugin. |
10 | 10 | * @return bool $update The new update state. |
11 | 11 | */ |
12 | -function monsterinsights_automatic_updates( $update, $item ) { |
|
12 | +function monsterinsights_automatic_updates($update, $item) { |
|
13 | 13 | |
14 | 14 | // If this is multisite and is not on the main site, return early. |
15 | - if ( is_multisite() && ! is_main_site() ) { |
|
15 | + if (is_multisite() && ! is_main_site()) { |
|
16 | 16 | return $update; |
17 | 17 | } |
18 | 18 | |
19 | 19 | // If we don't have everything we need, return early. |
20 | 20 | $item = (array) $item; |
21 | - if ( ! isset( $item['new_version'] ) || ! isset( $item['slug'] ) ) { |
|
21 | + if ( ! isset($item['new_version']) || ! isset($item['slug'])) { |
|
22 | 22 | return $update; |
23 | 23 | } |
24 | 24 | |
25 | 25 | // If the plugin isn't ours, return early. |
26 | 26 | $is_free = 'google-analytics-for-wordpress' === $item['slug']; |
27 | - $is_paid = isset( $item['monsterinsights_plugin'] ); // see updater class |
|
28 | - if ( ! $is_free && ! $is_paid ) { |
|
27 | + $is_paid = isset($item['monsterinsights_plugin']); // see updater class |
|
28 | + if ( ! $is_free && ! $is_paid) { |
|
29 | 29 | return $update; |
30 | 30 | } |
31 | 31 | |
32 | 32 | $version = $is_free ? MONSTERINSIGHTS_LITE_VERSION : $item['old_version']; |
33 | - $automatic_updates = monsterinsights_get_option( 'automatic_updates', false ); |
|
34 | - $current_major = monsterinsights_get_major_version( $version ); |
|
35 | - $new_major = monsterinsights_get_major_version( $item['new_version'] ); |
|
33 | + $automatic_updates = monsterinsights_get_option('automatic_updates', false); |
|
34 | + $current_major = monsterinsights_get_major_version($version); |
|
35 | + $new_major = monsterinsights_get_major_version($item['new_version']); |
|
36 | 36 | |
37 | 37 | // If the opt in update allows major updates but there is no major version update, return early. |
38 | - if ( $current_major < $new_major ) { |
|
39 | - if ( $automatic_updates === 'all' ) { |
|
38 | + if ($current_major < $new_major) { |
|
39 | + if ($automatic_updates === 'all') { |
|
40 | 40 | return true; |
41 | 41 | } else { |
42 | 42 | return $update; |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | } |
45 | 45 | |
46 | 46 | // If the opt in update allows minor updates but there is no minor version update, return early. |
47 | - if ( $current_major == $new_major ) { |
|
48 | - if ( $automatic_updates === 'all' || $automatic_updates === 'minor' ) { |
|
47 | + if ($current_major == $new_major) { |
|
48 | + if ($automatic_updates === 'all' || $automatic_updates === 'minor') { |
|
49 | 49 | return true; |
50 | 50 | } else { |
51 | 51 | return $update; |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | return true; |
57 | 57 | } |
58 | 58 | |
59 | -add_filter( 'auto_update_plugin', 'monsterinsights_automatic_updates', 10, 2 ); |
|
59 | +add_filter('auto_update_plugin', 'monsterinsights_automatic_updates', 10, 2); |
|
60 | 60 | /** |
61 | 61 | * Notes about autoupdater: |
62 | 62 | * This runs on the normal WordPress auto-update sequence: |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | */ |
85 | 85 | |
86 | 86 | |
87 | -function monsterinsights_get_major_version( $version ) { |
|
88 | - $exploded_version = explode( '.', $version ); |
|
89 | - if ( isset( $exploded_version[2] ) ) { |
|
87 | +function monsterinsights_get_major_version($version) { |
|
88 | + $exploded_version = explode('.', $version); |
|
89 | + if (isset($exploded_version[2])) { |
|
90 | 90 | return $exploded_version[0] . '.' . $exploded_version[1] . '.' . $exploded_version[2]; |
91 | 91 | } else { |
92 | 92 | return $exploded_version[0] . '.' . $exploded_version[1] . '.0'; |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | */ |
10 | 10 | |
11 | 11 | // Exit if accessed directly |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | public function __construct() { |
60 | 60 | // Load the base class object. |
61 | 61 | $this->base = MonsterInsights(); |
62 | - add_action( 'admin_init', array( $this, 'admin_init' ) ); |
|
62 | + add_action('admin_init', array($this, 'admin_init')); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | public function admin_init() { |
@@ -67,12 +67,12 @@ discard block |
||
67 | 67 | $this->maybe_verify_key(); |
68 | 68 | |
69 | 69 | // Add potential admin notices for actions around the admin. |
70 | - add_action( 'admin_notices', array( $this, 'monsterinsights_notices' ) ); |
|
71 | - add_action( 'network_admin_notices', array( $this, 'monsterinsights_notices' ) ); |
|
70 | + add_action('admin_notices', array($this, 'monsterinsights_notices')); |
|
71 | + add_action('network_admin_notices', array($this, 'monsterinsights_notices')); |
|
72 | 72 | |
73 | 73 | // Grab the license key. If it is not set (even after verification), return early. |
74 | 74 | $this->key = monsterinsights_get_license_key(); |
75 | - if ( ! $this->key ) { |
|
75 | + if ( ! $this->key) { |
|
76 | 76 | return; |
77 | 77 | } |
78 | 78 | |
@@ -91,11 +91,11 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function maybe_verify_key() { |
93 | 93 | |
94 | - if ( ! $this->is_verifying_key() ) { |
|
94 | + if ( ! $this->is_verifying_key()) { |
|
95 | 95 | return; |
96 | 96 | } |
97 | 97 | |
98 | - if ( ! $this->verify_key_action() ) { |
|
98 | + if ( ! $this->verify_key_action()) { |
|
99 | 99 | return; |
100 | 100 | } |
101 | 101 | |
@@ -111,39 +111,39 @@ discard block |
||
111 | 111 | public function verify_key() { |
112 | 112 | |
113 | 113 | // Perform a request to verify the key. |
114 | - $verify = $this->perform_remote_request( 'verify-key', array( 'tgm-updater-key' => trim( $_POST['monsterinsights-license-key'] ) ) ); |
|
114 | + $verify = $this->perform_remote_request('verify-key', array('tgm-updater-key' => trim($_POST['monsterinsights-license-key']))); |
|
115 | 115 | |
116 | 116 | // If it returns false, send back a generic error message and return. |
117 | - if ( ! $verify ) { |
|
118 | - $this->errors[] = esc_html__( 'There was an error connecting to the remote key API. Please try again later.', 'google-analytics-for-wordpress' ); |
|
117 | + if ( ! $verify) { |
|
118 | + $this->errors[] = esc_html__('There was an error connecting to the remote key API. Please try again later.', 'google-analytics-for-wordpress'); |
|
119 | 119 | return; |
120 | 120 | } |
121 | 121 | |
122 | 122 | // If an error is returned, set the error and return. |
123 | - if ( ! empty( $verify->error ) ) { |
|
123 | + if ( ! empty($verify->error)) { |
|
124 | 124 | $this->errors[] = $verify->error; |
125 | 125 | return; |
126 | 126 | } |
127 | 127 | |
128 | 128 | // Otherwise, our request has been done successfully. Update the option and set the success message. |
129 | - if ( is_multisite() && is_network_admin() ) { |
|
130 | - $option = get_site_option( 'monsterinsights_license' ); |
|
131 | - $option['key'] = trim( $_POST['monsterinsights-license-key'] ); |
|
132 | - $option['type'] = isset( $verify->type ) ? $verify->type : $option['type']; |
|
129 | + if (is_multisite() && is_network_admin()) { |
|
130 | + $option = get_site_option('monsterinsights_license'); |
|
131 | + $option['key'] = trim($_POST['monsterinsights-license-key']); |
|
132 | + $option['type'] = isset($verify->type) ? $verify->type : $option['type']; |
|
133 | 133 | $option['is_expired'] = false; |
134 | 134 | $option['is_disabled'] = false; |
135 | 135 | $option['is_invalid'] = false; |
136 | - $this->success[] = isset( $verify->success ) ? $verify->success : esc_html__( 'Congratulations! This site is now receiving automatic updates.', 'google-analytics-for-wordpress' ); |
|
137 | - update_site_option( 'monsterinsights_license', $option ); |
|
136 | + $this->success[] = isset($verify->success) ? $verify->success : esc_html__('Congratulations! This site is now receiving automatic updates.', 'google-analytics-for-wordpress'); |
|
137 | + update_site_option('monsterinsights_license', $option); |
|
138 | 138 | } else { |
139 | - $option = get_option( 'monsterinsights_license' ); |
|
140 | - $option['key'] = trim( $_POST['monsterinsights-license-key'] ); |
|
141 | - $option['type'] = isset( $verify->type ) ? $verify->type : $option['type']; |
|
139 | + $option = get_option('monsterinsights_license'); |
|
140 | + $option['key'] = trim($_POST['monsterinsights-license-key']); |
|
141 | + $option['type'] = isset($verify->type) ? $verify->type : $option['type']; |
|
142 | 142 | $option['is_expired'] = false; |
143 | 143 | $option['is_disabled'] = false; |
144 | 144 | $option['is_invalid'] = false; |
145 | - $this->success[] = isset( $verify->success ) ? $verify->success : esc_html__( 'Congratulations! This site is now receiving automatic updates.', 'google-analytics-for-wordpress' ); |
|
146 | - update_option( 'monsterinsights_license', $option ); |
|
145 | + $this->success[] = isset($verify->success) ? $verify->success : esc_html__('Congratulations! This site is now receiving automatic updates.', 'google-analytics-for-wordpress'); |
|
146 | + update_option('monsterinsights_license', $option); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | } |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | */ |
158 | 158 | public function is_verifying_key() { |
159 | 159 | |
160 | - return isset( $_POST['monsterinsights-license-key'] ) && isset( $_POST['monsterinsights-verify-submit'] ); |
|
160 | + return isset($_POST['monsterinsights-license-key']) && isset($_POST['monsterinsights-verify-submit']); |
|
161 | 161 | |
162 | 162 | } |
163 | 163 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | */ |
171 | 171 | public function verify_key_action() { |
172 | 172 | |
173 | - return isset( $_POST['monsterinsights-verify-submit'] ) && wp_verify_nonce( $_POST['monsterinsights-key-nonce'], 'monsterinsights-key-nonce' ); |
|
173 | + return isset($_POST['monsterinsights-verify-submit']) && wp_verify_nonce($_POST['monsterinsights-key-nonce'], 'monsterinsights-key-nonce'); |
|
174 | 174 | |
175 | 175 | } |
176 | 176 | |
@@ -184,17 +184,17 @@ discard block |
||
184 | 184 | public function maybe_validate_key() { |
185 | 185 | |
186 | 186 | // Only run every 12 hours. |
187 | - $timestamp = get_option( 'monsterinsights_license_updates' ); |
|
188 | - if ( ! $timestamp ) { |
|
189 | - $timestamp = strtotime( '+8 hours' ); |
|
190 | - update_option( 'monsterinsights_license_updates', $timestamp ); |
|
187 | + $timestamp = get_option('monsterinsights_license_updates'); |
|
188 | + if ( ! $timestamp) { |
|
189 | + $timestamp = strtotime('+8 hours'); |
|
190 | + update_option('monsterinsights_license_updates', $timestamp); |
|
191 | 191 | $this->validate_key(); |
192 | 192 | } else { |
193 | 193 | $current_timestamp = time(); |
194 | - if ( $current_timestamp < $timestamp ) { |
|
194 | + if ($current_timestamp < $timestamp) { |
|
195 | 195 | return; |
196 | 196 | } else { |
197 | - update_option( 'monsterinsights_license_updates', strtotime( '+8 hours' ) ); |
|
197 | + update_option('monsterinsights_license_updates', strtotime('+8 hours')); |
|
198 | 198 | $this->validate_key(); |
199 | 199 | } |
200 | 200 | } |
@@ -207,104 +207,104 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @param bool $forced Force to set contextual messages (false by default). |
209 | 209 | */ |
210 | - public function validate_key( $forced = false ) { |
|
210 | + public function validate_key($forced = false) { |
|
211 | 211 | |
212 | - $validate = $this->perform_remote_request( 'validate-key', array( 'tgm-updater-key' => $this->key ) ); |
|
212 | + $validate = $this->perform_remote_request('validate-key', array('tgm-updater-key' => $this->key)); |
|
213 | 213 | |
214 | 214 | // If there was a basic API error in validation, only set the transient for 10 minutes before retrying. |
215 | - if ( ! $validate ) { |
|
215 | + if ( ! $validate) { |
|
216 | 216 | // If forced, set contextual success message. |
217 | - if ( $forced ) { |
|
218 | - $this->errors[] = esc_html__( 'There was an error connecting to the remote key API. Please try again later.', 'google-analytics-for-wordpress' ); |
|
217 | + if ($forced) { |
|
218 | + $this->errors[] = esc_html__('There was an error connecting to the remote key API. Please try again later.', 'google-analytics-for-wordpress'); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | return; |
222 | 222 | } |
223 | 223 | |
224 | 224 | // If a key or author error is returned, the license no longer exists or the user has been deleted, so reset license. |
225 | - if ( isset( $validate->key ) || isset( $validate->author ) ) { |
|
225 | + if (isset($validate->key) || isset($validate->author)) { |
|
226 | 226 | $option = array(); |
227 | - if ( is_multisite() && is_network_admin() ) { |
|
228 | - $option = get_site_option( 'monsterinsights_license' ); |
|
227 | + if (is_multisite() && is_network_admin()) { |
|
228 | + $option = get_site_option('monsterinsights_license'); |
|
229 | 229 | } else { |
230 | - $option = get_option( 'monsterinsights_license' ); |
|
230 | + $option = get_option('monsterinsights_license'); |
|
231 | 231 | } |
232 | 232 | $option['is_expired'] = false; |
233 | 233 | $option['is_disabled'] = false; |
234 | 234 | $option['is_invalid'] = true; |
235 | - if ( is_multisite() && is_network_admin() ) { |
|
236 | - update_site_option( 'monsterinsights_license', $option ); |
|
235 | + if (is_multisite() && is_network_admin()) { |
|
236 | + update_site_option('monsterinsights_license', $option); |
|
237 | 237 | } else { |
238 | - update_option( 'monsterinsights_license', $option ); |
|
238 | + update_option('monsterinsights_license', $option); |
|
239 | 239 | } |
240 | 240 | return; |
241 | 241 | } |
242 | 242 | |
243 | 243 | // If the license has expired, set the transient and expired flag and return. |
244 | - if ( isset( $validate->expired ) ) { |
|
244 | + if (isset($validate->expired)) { |
|
245 | 245 | $option = array(); |
246 | - if ( is_multisite() && is_network_admin() ) { |
|
247 | - $option = get_site_option( 'monsterinsights_license' ); |
|
246 | + if (is_multisite() && is_network_admin()) { |
|
247 | + $option = get_site_option('monsterinsights_license'); |
|
248 | 248 | } else { |
249 | - $option = get_option( 'monsterinsights_license' ); |
|
249 | + $option = get_option('monsterinsights_license'); |
|
250 | 250 | } |
251 | 251 | $option['is_expired'] = true; |
252 | 252 | $option['is_disabled'] = false; |
253 | 253 | $option['is_invalid'] = false; |
254 | - if ( is_multisite() && is_network_admin() ) { |
|
255 | - update_site_option( 'monsterinsights_license', $option ); |
|
254 | + if (is_multisite() && is_network_admin()) { |
|
255 | + update_site_option('monsterinsights_license', $option); |
|
256 | 256 | } else { |
257 | - update_option( 'monsterinsights_license', $option ); |
|
257 | + update_option('monsterinsights_license', $option); |
|
258 | 258 | } |
259 | 259 | return; |
260 | 260 | } |
261 | 261 | |
262 | 262 | // If the license is disabled, set the transient and disabled flag and return. |
263 | - if ( isset( $validate->disabled ) ) { |
|
263 | + if (isset($validate->disabled)) { |
|
264 | 264 | $option = array(); |
265 | - if ( is_multisite() && is_network_admin() ) { |
|
266 | - $option = get_site_option( 'monsterinsights_license' ); |
|
265 | + if (is_multisite() && is_network_admin()) { |
|
266 | + $option = get_site_option('monsterinsights_license'); |
|
267 | 267 | } else { |
268 | - $option = get_option( 'monsterinsights_license' ); |
|
268 | + $option = get_option('monsterinsights_license'); |
|
269 | 269 | } |
270 | 270 | $option['is_expired'] = false; |
271 | 271 | $option['is_disabled'] = true; |
272 | 272 | $option['is_invalid'] = false; |
273 | - if ( is_multisite() && is_network_admin() ) { |
|
274 | - update_site_option( 'monsterinsights_license', $option ); |
|
273 | + if (is_multisite() && is_network_admin()) { |
|
274 | + update_site_option('monsterinsights_license', $option); |
|
275 | 275 | } else { |
276 | - update_option( 'monsterinsights_license', $option ); |
|
276 | + update_option('monsterinsights_license', $option); |
|
277 | 277 | } |
278 | 278 | return; |
279 | 279 | } |
280 | 280 | |
281 | 281 | // If forced, set contextual success message. |
282 | - if ( ( ! empty( $validate->key ) || ! empty( $this->key ) ) && $forced ) { |
|
282 | + if (( ! empty($validate->key) || ! empty($this->key)) && $forced) { |
|
283 | 283 | $key = ''; |
284 | - if ( ! empty( $validate->key ) ) { |
|
284 | + if ( ! empty($validate->key)) { |
|
285 | 285 | $key = $validate->key; |
286 | 286 | } else { |
287 | 287 | $key = $this->key; |
288 | 288 | } |
289 | - delete_transient( '_monsterinsights_addons' ); |
|
290 | - monsterinsights_get_addons_data( $key ); |
|
291 | - $this->success[] = esc_html__( 'Congratulations! Your key has been refreshed successfully.', 'google-analytics-for-wordpress' ); |
|
289 | + delete_transient('_monsterinsights_addons'); |
|
290 | + monsterinsights_get_addons_data($key); |
|
291 | + $this->success[] = esc_html__('Congratulations! Your key has been refreshed successfully.', 'google-analytics-for-wordpress'); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | $option = array(); |
295 | - if ( is_multisite() && is_network_admin() ) { |
|
296 | - $option = get_site_option( 'monsterinsights_license' ); |
|
295 | + if (is_multisite() && is_network_admin()) { |
|
296 | + $option = get_site_option('monsterinsights_license'); |
|
297 | 297 | } else { |
298 | - $option = get_option( 'monsterinsights_license' ); |
|
298 | + $option = get_option('monsterinsights_license'); |
|
299 | 299 | } |
300 | - $option['type'] = isset( $validate->type ) ? $validate->type : $option['type']; |
|
300 | + $option['type'] = isset($validate->type) ? $validate->type : $option['type']; |
|
301 | 301 | $option['is_expired'] = false; |
302 | 302 | $option['is_disabled'] = false; |
303 | 303 | $option['is_invalid'] = false; |
304 | - if ( is_multisite() && is_network_admin() ) { |
|
305 | - update_site_option( 'monsterinsights_license', $option ); |
|
304 | + if (is_multisite() && is_network_admin()) { |
|
305 | + update_site_option('monsterinsights_license', $option); |
|
306 | 306 | } else { |
307 | - update_option( 'monsterinsights_license', $option ); |
|
307 | + update_option('monsterinsights_license', $option); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | } |
@@ -318,11 +318,11 @@ discard block |
||
318 | 318 | */ |
319 | 319 | public function maybe_deactivate_key() { |
320 | 320 | |
321 | - if ( ! $this->is_deactivating_key() ) { |
|
321 | + if ( ! $this->is_deactivating_key()) { |
|
322 | 322 | return; |
323 | 323 | } |
324 | 324 | |
325 | - if ( ! $this->deactivate_key_action() ) { |
|
325 | + if ( ! $this->deactivate_key_action()) { |
|
326 | 326 | return; |
327 | 327 | } |
328 | 328 | |
@@ -338,27 +338,27 @@ discard block |
||
338 | 338 | public function deactivate_key() { |
339 | 339 | |
340 | 340 | // Perform a request to deactivate the key. |
341 | - $deactivate = $this->perform_remote_request( 'deactivate-key', array( 'tgm-updater-key' => $_POST['monsterinsights-license-key'] ) ); |
|
341 | + $deactivate = $this->perform_remote_request('deactivate-key', array('tgm-updater-key' => $_POST['monsterinsights-license-key'])); |
|
342 | 342 | |
343 | 343 | // If it returns false, send back a generic error message and return. |
344 | - if ( ! $deactivate ) { |
|
345 | - $this->errors[] = esc_html__( 'There was an error connecting to the remote key API. Please try again later.', 'google-analytics-for-wordpress' ); |
|
344 | + if ( ! $deactivate) { |
|
345 | + $this->errors[] = esc_html__('There was an error connecting to the remote key API. Please try again later.', 'google-analytics-for-wordpress'); |
|
346 | 346 | return; |
347 | 347 | } |
348 | 348 | |
349 | 349 | // If an error is returned, set the error and return. |
350 | - if ( ! empty( $deactivate->error ) && ! monsterinsights_is_debug_mode() ) { |
|
350 | + if ( ! empty($deactivate->error) && ! monsterinsights_is_debug_mode()) { |
|
351 | 351 | $this->errors[] = $deactivate->error; |
352 | 352 | return; |
353 | 353 | } |
354 | 354 | |
355 | 355 | // Otherwise, our request has been done successfully. Reset the option and set the success message. |
356 | - $this->success[] = isset( $deactivate->success ) ? $deactivate->success : esc_html__( 'Congratulations! You have deactivated the key from this site successfully.', 'google-analytics-for-wordpress' ); |
|
357 | - update_option( 'monsterinsights_license', array() ); |
|
358 | - if ( is_multisite() && is_network_admin() ) { |
|
359 | - update_site_option( 'monsterinsights_license', array() ); |
|
356 | + $this->success[] = isset($deactivate->success) ? $deactivate->success : esc_html__('Congratulations! You have deactivated the key from this site successfully.', 'google-analytics-for-wordpress'); |
|
357 | + update_option('monsterinsights_license', array()); |
|
358 | + if (is_multisite() && is_network_admin()) { |
|
359 | + update_site_option('monsterinsights_license', array()); |
|
360 | 360 | } else { |
361 | - update_option( 'monsterinsights_license', array() ); |
|
361 | + update_option('monsterinsights_license', array()); |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | } |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | */ |
373 | 373 | public function is_deactivating_key() { |
374 | 374 | |
375 | - return isset( $_POST['monsterinsights-license-key'] ) && isset( $_POST['monsterinsights-deactivate-submit'] ); |
|
375 | + return isset($_POST['monsterinsights-license-key']) && isset($_POST['monsterinsights-deactivate-submit']); |
|
376 | 376 | |
377 | 377 | } |
378 | 378 | |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | */ |
386 | 386 | public function deactivate_key_action() { |
387 | 387 | |
388 | - return isset( $_POST['monsterinsights-deactivate-submit'] ) && wp_verify_nonce( $_POST['monsterinsights-key-nonce'], 'monsterinsights-key-nonce' ); |
|
388 | + return isset($_POST['monsterinsights-deactivate-submit']) && wp_verify_nonce($_POST['monsterinsights-key-nonce'], 'monsterinsights-key-nonce'); |
|
389 | 389 | |
390 | 390 | } |
391 | 391 | |
@@ -398,16 +398,16 @@ discard block |
||
398 | 398 | */ |
399 | 399 | public function maybe_refresh_key() { |
400 | 400 | |
401 | - if ( ! $this->is_refreshing_key() ) { |
|
401 | + if ( ! $this->is_refreshing_key()) { |
|
402 | 402 | return; |
403 | 403 | } |
404 | 404 | |
405 | - if ( ! $this->refresh_key_action() ) { |
|
405 | + if ( ! $this->refresh_key_action()) { |
|
406 | 406 | return; |
407 | 407 | } |
408 | 408 | |
409 | 409 | // Refreshing is simply a word alias for validating a key. Force true to set contextual messages. |
410 | - $this->validate_key( true ); |
|
410 | + $this->validate_key(true); |
|
411 | 411 | |
412 | 412 | } |
413 | 413 | |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | */ |
421 | 421 | public function is_refreshing_key() { |
422 | 422 | |
423 | - return isset( $_POST['monsterinsights-license-key'] ) && isset( $_POST['monsterinsights-refresh-submit'] ); |
|
423 | + return isset($_POST['monsterinsights-license-key']) && isset($_POST['monsterinsights-refresh-submit']); |
|
424 | 424 | |
425 | 425 | } |
426 | 426 | |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | */ |
434 | 434 | public function refresh_key_action() { |
435 | 435 | |
436 | - return isset( $_POST['monsterinsights-refresh-submit'] ) && wp_verify_nonce( $_POST['monsterinsights-key-nonce'], 'monsterinsights-key-nonce' ); |
|
436 | + return isset($_POST['monsterinsights-refresh-submit']) && wp_verify_nonce($_POST['monsterinsights-key-nonce'], 'monsterinsights-key-nonce'); |
|
437 | 437 | |
438 | 438 | } |
439 | 439 | |
@@ -448,119 +448,119 @@ discard block |
||
448 | 448 | $key = monsterinsights_get_license_key(); |
449 | 449 | |
450 | 450 | $option = array(); |
451 | - if ( is_multisite() && is_network_admin() ) { |
|
452 | - $option = get_site_option( 'monsterinsights_license' ); |
|
451 | + if (is_multisite() && is_network_admin()) { |
|
452 | + $option = get_site_option('monsterinsights_license'); |
|
453 | 453 | } else { |
454 | - $option = get_option( 'monsterinsights_license' ); |
|
454 | + $option = get_option('monsterinsights_license'); |
|
455 | 455 | } |
456 | 456 | |
457 | - if ( ! monsterinsights_is_pro_version() ) { |
|
457 | + if ( ! monsterinsights_is_pro_version()) { |
|
458 | 458 | return; |
459 | 459 | } |
460 | 460 | |
461 | - if ( is_multisite() && is_network_admin() ) { |
|
461 | + if (is_multisite() && is_network_admin()) { |
|
462 | 462 | // If a key has expired, output nag about renewing the key. |
463 | - if ( isset( $option['is_expired'] ) && $option['is_expired'] ) : |
|
463 | + if (isset($option['is_expired']) && $option['is_expired']) : |
|
464 | 464 | ?> |
465 | 465 | <div class="error"> |
466 | - <p><?php printf( esc_html__( 'Your license key for MonsterInsights has expired. %1$sPlease click here to renew your license key and continue receiving automatic updates.%2$s', 'google-analytics-for-wordpress' ), '<a href="https://www.monsterinsights.com/login/" target="_blank" rel="noopener noreferrer" referrer="no-referrer">', '</a>' ); ?></p> |
|
466 | + <p><?php printf(esc_html__('Your license key for MonsterInsights has expired. %1$sPlease click here to renew your license key and continue receiving automatic updates.%2$s', 'google-analytics-for-wordpress'), '<a href="https://www.monsterinsights.com/login/" target="_blank" rel="noopener noreferrer" referrer="no-referrer">', '</a>'); ?></p> |
|
467 | 467 | </div> |
468 | 468 | <?php |
469 | 469 | endif; |
470 | 470 | |
471 | 471 | // If a key has been disabled, output nag about using another key. |
472 | - if ( isset( $option['is_disabled'] ) && $option['is_disabled'] ) : |
|
472 | + if (isset($option['is_disabled']) && $option['is_disabled']) : |
|
473 | 473 | ?> |
474 | 474 | <div class="error"> |
475 | - <p><?php esc_html_e( 'Your license key for MonsterInsights has been disabled. Please use a different key to continue receiving automatic updates.', 'google-analytics-for-wordpress' ); ?></p> |
|
475 | + <p><?php esc_html_e('Your license key for MonsterInsights has been disabled. Please use a different key to continue receiving automatic updates.', 'google-analytics-for-wordpress'); ?></p> |
|
476 | 476 | </div> |
477 | 477 | <?php |
478 | 478 | endif; |
479 | 479 | |
480 | 480 | // If a key is invalid, output nag about using another key. |
481 | - if ( isset( $option['is_invalid'] ) && $option['is_invalid'] ) : |
|
481 | + if (isset($option['is_invalid']) && $option['is_invalid']) : |
|
482 | 482 | ?> |
483 | 483 | <div class="error"> |
484 | - <p><?php esc_html_e( 'Your license key for MonsterInsights is invalid. The key no longer exists or the user associated with the key has been deleted. Please use a different key to continue receiving automatic updates.', 'google-analytics-for-wordpress' ); ?></p> |
|
484 | + <p><?php esc_html_e('Your license key for MonsterInsights is invalid. The key no longer exists or the user associated with the key has been deleted. Please use a different key to continue receiving automatic updates.', 'google-analytics-for-wordpress'); ?></p> |
|
485 | 485 | </div> |
486 | 486 | <?php |
487 | 487 | endif; |
488 | 488 | |
489 | 489 | // If there are any license errors, output them now. |
490 | - if ( ! empty( $this->errors ) ) : |
|
490 | + if ( ! empty($this->errors)) : |
|
491 | 491 | ?> |
492 | 492 | <div class="error"> |
493 | - <p><?php echo implode( '<br>', $this->errors ); ?></p> |
|
493 | + <p><?php echo implode('<br>', $this->errors); ?></p> |
|
494 | 494 | </div> |
495 | 495 | <?php |
496 | 496 | endif; |
497 | 497 | |
498 | 498 | // If there are any success messages, output them now. |
499 | - if ( ! empty( $this->success ) ) : |
|
499 | + if ( ! empty($this->success)) : |
|
500 | 500 | ?> |
501 | 501 | <div class="updated"> |
502 | - <p><?php echo implode( '<br>', $this->success ); ?></p> |
|
502 | + <p><?php echo implode('<br>', $this->success); ?></p> |
|
503 | 503 | </div> |
504 | 504 | <?php |
505 | 505 | endif; |
506 | 506 | } else { |
507 | 507 | // If there is no license key, output nag about ensuring key is set for automatic updates. |
508 | - if ( ! $key ) : |
|
509 | - if ( ! monsterinsights_is_pro_version() ) { |
|
508 | + if ( ! $key) : |
|
509 | + if ( ! monsterinsights_is_pro_version()) { |
|
510 | 510 | return; |
511 | 511 | } |
512 | 512 | $screen = get_current_screen(); |
513 | - if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) !== false ) { |
|
513 | + if (empty($screen->id) || strpos($screen->id, 'monsterinsights') !== false) { |
|
514 | 514 | return; |
515 | 515 | } |
516 | 516 | ?> |
517 | 517 | <div class="error"> |
518 | - <p><?php printf( esc_html__( 'No valid license key has been entered, so automatic updates for MonsterInsights have been turned off. %1$sPlease click here to enter your license key and begin receiving automatic updates.%2$s', 'google-analytics-for-wordpress' ), '<a href="'. esc_url( add_query_arg( array( 'page' => 'monsterinsights_settings' ), admin_url( 'admin.php' ) ) ) . '" target="_blank" rel="noopener noreferrer">', '</a>' ); ?></p> |
|
518 | + <p><?php printf(esc_html__('No valid license key has been entered, so automatic updates for MonsterInsights have been turned off. %1$sPlease click here to enter your license key and begin receiving automatic updates.%2$s', 'google-analytics-for-wordpress'), '<a href="' . esc_url(add_query_arg(array('page' => 'monsterinsights_settings'), admin_url('admin.php'))) . '" target="_blank" rel="noopener noreferrer">', '</a>'); ?></p> |
|
519 | 519 | </div> |
520 | 520 | <?php |
521 | 521 | endif; |
522 | 522 | |
523 | 523 | // If a key has expired, output nag about renewing the key. |
524 | - if ( isset( $option['is_expired'] ) && $option['is_expired'] ) : |
|
524 | + if (isset($option['is_expired']) && $option['is_expired']) : |
|
525 | 525 | ?> |
526 | 526 | <div class="error"> |
527 | - <p><?php printf( esc_html__( 'Your license key for MonsterInsights has expired. %1$sPlease click here to renew your license key and continue receiving automatic updates.%2$s', 'google-analytics-for-wordpress' ), '<a href="https://www.monsterinsights.com/login/" target="_blank" rel="noopener noreferrer">', '</a>' ); ?></p> |
|
527 | + <p><?php printf(esc_html__('Your license key for MonsterInsights has expired. %1$sPlease click here to renew your license key and continue receiving automatic updates.%2$s', 'google-analytics-for-wordpress'), '<a href="https://www.monsterinsights.com/login/" target="_blank" rel="noopener noreferrer">', '</a>'); ?></p> |
|
528 | 528 | </div> |
529 | 529 | <?php |
530 | 530 | endif; |
531 | 531 | |
532 | 532 | // If a key has been disabled, output nag about using another key. |
533 | - if ( isset( $option['is_disabled'] ) && $option['is_disabled'] ) : |
|
533 | + if (isset($option['is_disabled']) && $option['is_disabled']) : |
|
534 | 534 | ?> |
535 | 535 | <div class="error"> |
536 | - <p><?php esc_html_e( 'Your license key for MonsterInsights has been disabled. Please use a different key to continue receiving automatic updates.', 'google-analytics-for-wordpress' ); ?></p> |
|
536 | + <p><?php esc_html_e('Your license key for MonsterInsights has been disabled. Please use a different key to continue receiving automatic updates.', 'google-analytics-for-wordpress'); ?></p> |
|
537 | 537 | </div> |
538 | 538 | <?php |
539 | 539 | endif; |
540 | 540 | |
541 | 541 | // If a key is invalid, output nag about using another key. |
542 | - if ( isset( $option['is_invalid'] ) && $option['is_invalid'] ) : |
|
542 | + if (isset($option['is_invalid']) && $option['is_invalid']) : |
|
543 | 543 | ?> |
544 | 544 | <div class="error"> |
545 | - <p><?php esc_html_e( 'Your license key for MonsterInsights is invalid. The key no longer exists or the user associated with the key has been deleted. Please use a different key to continue receiving automatic updates.', 'google-analytics-for-wordpress' ); ?></p> |
|
545 | + <p><?php esc_html_e('Your license key for MonsterInsights is invalid. The key no longer exists or the user associated with the key has been deleted. Please use a different key to continue receiving automatic updates.', 'google-analytics-for-wordpress'); ?></p> |
|
546 | 546 | </div> |
547 | 547 | <?php |
548 | 548 | endif; |
549 | 549 | |
550 | 550 | // If there are any license errors, output them now. |
551 | - if ( ! empty( $this->errors ) ) : |
|
551 | + if ( ! empty($this->errors)) : |
|
552 | 552 | ?> |
553 | 553 | <div class="error"> |
554 | - <p><?php echo implode( '<br>', $this->errors ); ?></p> |
|
554 | + <p><?php echo implode('<br>', $this->errors); ?></p> |
|
555 | 555 | </div> |
556 | 556 | <?php |
557 | 557 | endif; |
558 | 558 | |
559 | 559 | // If there are any success messages, output them now. |
560 | - if ( ! empty( $this->success ) ) : |
|
560 | + if ( ! empty($this->success)) : |
|
561 | 561 | ?> |
562 | 562 | <div class="updated"> |
563 | - <p><?php echo implode( '<br>', $this->success ); ?></p> |
|
563 | + <p><?php echo implode('<br>', $this->success); ?></p> |
|
564 | 564 | </div> |
565 | 565 | <?php |
566 | 566 | endif; |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | * @param string $return_format The format for returning content from the remote URL. |
579 | 579 | * @return string|bool Json decoded response on success, false on failure. |
580 | 580 | */ |
581 | - public function perform_remote_request( $action, $body = array(), $headers = array(), $return_format = 'json' ) { |
|
581 | + public function perform_remote_request($action, $body = array(), $headers = array(), $return_format = 'json') { |
|
582 | 582 | |
583 | 583 | // Build the body of the request. |
584 | 584 | $body = wp_parse_args( |
@@ -586,20 +586,20 @@ discard block |
||
586 | 586 | array( |
587 | 587 | 'tgm-updater-action' => $action, |
588 | 588 | 'tgm-updater-key' => $this->key, |
589 | - 'tgm-updater-wp-version' => get_bloginfo( 'version' ), |
|
589 | + 'tgm-updater-wp-version' => get_bloginfo('version'), |
|
590 | 590 | 'tgm-updater-referer' => site_url(), |
591 | 591 | 'tgm-updater-mi-version' => MONSTERINSIGHTS_VERSION, |
592 | 592 | 'tgm-updater-is-pro' => monsterinsights_is_pro_version(), |
593 | 593 | ) |
594 | 594 | ); |
595 | - $body = http_build_query( $body, '', '&' ); |
|
595 | + $body = http_build_query($body, '', '&'); |
|
596 | 596 | |
597 | 597 | // Build the headers of the request. |
598 | 598 | $headers = wp_parse_args( |
599 | 599 | $headers, |
600 | 600 | array( |
601 | 601 | 'Content-Type' => 'application/x-www-form-urlencoded', |
602 | - 'Content-Length' => strlen( $body ) |
|
602 | + 'Content-Length' => strlen($body) |
|
603 | 603 | ) |
604 | 604 | ); |
605 | 605 | |
@@ -610,17 +610,17 @@ discard block |
||
610 | 610 | ); |
611 | 611 | |
612 | 612 | // Perform the query and retrieve the response. |
613 | - $response = wp_remote_post( 'https://www.monsterinsights.com', $post ); |
|
614 | - $response_code = wp_remote_retrieve_response_code( $response ); |
|
615 | - $response_body = wp_remote_retrieve_body( $response ); |
|
613 | + $response = wp_remote_post('https://www.monsterinsights.com', $post); |
|
614 | + $response_code = wp_remote_retrieve_response_code($response); |
|
615 | + $response_body = wp_remote_retrieve_body($response); |
|
616 | 616 | |
617 | 617 | // Bail out early if there are any errors. |
618 | - if ( 200 != $response_code || is_wp_error( $response_body ) ) { |
|
618 | + if (200 != $response_code || is_wp_error($response_body)) { |
|
619 | 619 | return false; |
620 | 620 | } |
621 | 621 | |
622 | 622 | // Return the json decoded content. |
623 | - return json_decode( $response_body ); |
|
623 | + return json_decode($response_body); |
|
624 | 624 | |
625 | 625 | } |
626 | 626 | } |
627 | 627 | \ No newline at end of file |
@@ -186,9 +186,9 @@ |
||
186 | 186 | // Only run every 12 hours. |
187 | 187 | $timestamp = get_option( 'monsterinsights_license_updates' ); |
188 | 188 | if ( ! $timestamp ) { |
189 | - $timestamp = strtotime( '+8 hours' ); |
|
190 | - update_option( 'monsterinsights_license_updates', $timestamp ); |
|
191 | - $this->validate_key(); |
|
189 | + $timestamp = strtotime( '+8 hours' ); |
|
190 | + update_option( 'monsterinsights_license_updates', $timestamp ); |
|
191 | + $this->validate_key(); |
|
192 | 192 | } else { |
193 | 193 | $current_timestamp = time(); |
194 | 194 | if ( $current_timestamp < $timestamp ) { |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -32,52 +32,52 @@ discard block |
||
32 | 32 | * @param array $args Extra parameters. Unused. |
33 | 33 | * @return array Array of caps needed to have this meta cap. If returned array is empty, user has the capability. |
34 | 34 | */ |
35 | -function monsterinsights_add_capabilities( $caps, $cap, $user_id, $args ) { |
|
36 | - switch( $cap ) { |
|
35 | +function monsterinsights_add_capabilities($caps, $cap, $user_id, $args) { |
|
36 | + switch ($cap) { |
|
37 | 37 | case 'monsterinsights_view_dashboard' : |
38 | - $roles = monsterinsights_get_option( 'view_reports', array() ); |
|
38 | + $roles = monsterinsights_get_option('view_reports', array()); |
|
39 | 39 | |
40 | 40 | $user_can_via_settings = false; |
41 | - if ( ! empty( $roles ) && is_array( $roles ) ) { |
|
42 | - foreach ( $roles as $role ) { |
|
43 | - if ( is_string( $role ) ) { |
|
44 | - if ( user_can( $user_id, $role ) ) { |
|
41 | + if ( ! empty($roles) && is_array($roles)) { |
|
42 | + foreach ($roles as $role) { |
|
43 | + if (is_string($role)) { |
|
44 | + if (user_can($user_id, $role)) { |
|
45 | 45 | $user_can_via_settings = true; |
46 | 46 | break; |
47 | 47 | } |
48 | 48 | } |
49 | 49 | } |
50 | - } else if ( ! empty( $roles ) && is_string( $roles ) ) { |
|
51 | - if ( user_can( $user_id, $roles ) ) { |
|
50 | + } else if ( ! empty($roles) && is_string($roles)) { |
|
51 | + if (user_can($user_id, $roles)) { |
|
52 | 52 | $user_can_via_settings = true; |
53 | 53 | } |
54 | 54 | } |
55 | 55 | |
56 | - if ( user_can( $user_id, 'manage_options' ) || $user_can_via_settings ) { |
|
56 | + if (user_can($user_id, 'manage_options') || $user_can_via_settings) { |
|
57 | 57 | $caps = array(); |
58 | 58 | } |
59 | 59 | |
60 | 60 | break; |
61 | 61 | case 'monsterinsights_save_settings' : |
62 | - $roles = monsterinsights_get_option( 'save_settings', array() ); |
|
62 | + $roles = monsterinsights_get_option('save_settings', array()); |
|
63 | 63 | |
64 | 64 | $user_can_via_settings = false; |
65 | - if ( ! empty( $roles ) && is_array( $roles ) ) { |
|
66 | - foreach ( $roles as $role ) { |
|
67 | - if ( is_string( $role ) ) { |
|
68 | - if ( user_can( $user_id, $role ) ) { |
|
65 | + if ( ! empty($roles) && is_array($roles)) { |
|
66 | + foreach ($roles as $role) { |
|
67 | + if (is_string($role)) { |
|
68 | + if (user_can($user_id, $role)) { |
|
69 | 69 | $user_can_via_settings = true; |
70 | 70 | break; |
71 | 71 | } |
72 | 72 | } |
73 | 73 | } |
74 | - } else if ( ! empty( $roles ) && is_string( $roles ) ) { |
|
75 | - if ( user_can( $user_id, $roles ) ) { |
|
74 | + } else if ( ! empty($roles) && is_string($roles)) { |
|
75 | + if (user_can($user_id, $roles)) { |
|
76 | 76 | $user_can_via_settings = true; |
77 | 77 | } |
78 | 78 | } |
79 | 79 | |
80 | - if ( user_can( $user_id, 'manage_options' ) || $user_can_via_settings ) { |
|
80 | + if (user_can($user_id, 'manage_options') || $user_can_via_settings) { |
|
81 | 81 | $caps = array(); |
82 | 82 | } |
83 | 83 | |
@@ -85,4 +85,4 @@ discard block |
||
85 | 85 | } |
86 | 86 | return $caps; |
87 | 87 | } |
88 | -add_filter( 'map_meta_cap','monsterinsights_add_capabilities', 10, 4 ); |
|
89 | 88 | \ No newline at end of file |
89 | +add_filter('map_meta_cap', 'monsterinsights_add_capabilities', 10, 4); |
|
90 | 90 | \ No newline at end of file |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | } |
59 | 59 | |
60 | 60 | break; |
61 | - case 'monsterinsights_save_settings' : |
|
61 | + case 'monsterinsights_save_settings' : |
|
62 | 62 | $roles = monsterinsights_get_option( 'save_settings', array() ); |
63 | 63 | |
64 | 64 | $user_can_via_settings = false; |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | } |
73 | 73 | } |
74 | 74 | } else if ( ! empty( $roles ) && is_string( $roles ) ) { |
75 | - if ( user_can( $user_id, $roles ) ) { |
|
75 | + if ( user_can( $user_id, $roles ) ) { |
|
76 | 76 | $user_can_via_settings = true; |
77 | 77 | } |
78 | 78 | } |