@@ -59,7 +59,7 @@ |
||
59 | 59 | ); |
60 | 60 | add_filter( "monsterinsights_is_autoupdate_setting_html_filtered_" . $plugin_file, '__return_true' ); |
61 | 61 | } elseif ( $has_permission && |
62 | - ( $is_main_free || $is_main_pro || ( $is_addon && $is_pro ) ) |
|
62 | + ( $is_main_free || $is_main_pro || ( $is_addon && $is_pro ) ) |
|
63 | 63 | ) { |
64 | 64 | $text = __( 'Manage auto-updates', 'google-analytics-for-wordpress' ); |
65 | 65 | $html .= '<br>' . sprintf( '<a href="%s"">%s</a>', admin_url( 'admin.php?page=monsterinsights_settings#/advanced' ), $text ); |
@@ -41,7 +41,7 @@ |
||
41 | 41 | public function set_upgrader( &$upgrader ) { |
42 | 42 | |
43 | 43 | if ( is_object( $upgrader ) ) { |
44 | - $this->upgrader =& $upgrader; |
|
44 | + $this->upgrader = & $upgrader; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | } |
@@ -1329,7 +1329,7 @@ |
||
1329 | 1329 | |
1330 | 1330 | $already_added = monsterinsights_get_option('popular_posts_inline_curated', []); |
1331 | 1331 | $exclude = array(); |
1332 | - if( is_array( $already_added ) && !empty( $already_added ) ){ |
|
1332 | + if( is_array( $already_added ) && !empty( $already_added ) ) { |
|
1333 | 1333 | foreach ( $already_added as $key => $value ) { |
1334 | 1334 | $exclude[$value['id']] = $value['id']; |
1335 | 1335 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | return; |
68 | 68 | } |
69 | 69 | |
70 | - $site_license = array( |
|
70 | + $site_license = array( |
|
71 | 71 | 'key' => MonsterInsights()->license->get_site_license_key(), |
72 | 72 | 'type' => MonsterInsights()->license->get_site_license_type(), |
73 | 73 | 'is_disabled' => MonsterInsights()->license->site_license_disabled(), |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | // Array fields are needed even if empty. |
135 | 135 | $array_fields = array( 'view_reports', 'save_settings', 'ignore_users' ); |
136 | 136 | foreach ( $array_fields as $array_field ) { |
137 | - if ( ! isset( $options[ $array_field ] ) ) { |
|
138 | - $options[ $array_field ] = array(); |
|
137 | + if ( ! isset( $options[$array_field] ) ) { |
|
138 | + $options[$array_field] = array(); |
|
139 | 139 | } |
140 | 140 | } |
141 | 141 | |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | } |
266 | 266 | } |
267 | 267 | if ( $empty ) { |
268 | - unset( $value[ $key ] ); |
|
268 | + unset( $value[$key] ); |
|
269 | 269 | } |
270 | 270 | } |
271 | 271 | } |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | } else { |
316 | 316 | $addon = $this->get_addon( $installed_plugins, $addons_type, $addon, $slug ); |
317 | 317 | } |
318 | - $parsed_addons[ $addon->slug ] = $addon; |
|
318 | + $parsed_addons[$addon->slug] = $addon; |
|
319 | 319 | } |
320 | 320 | } |
321 | 321 | |
@@ -363,11 +363,11 @@ discard block |
||
363 | 363 | 'active' => class_exists( 'Charitable' ), |
364 | 364 | 'icon' => plugin_dir_url( MONSTERINSIGHTS_PLUGIN_FILE ) . 'assets/images/plugins/plugin-charitable.png', |
365 | 365 | 'title' => 'Charitable', |
366 | - 'excerpt' => __('Top-rated WordPress donation and fundraising plugin. Over 10,000+ non-profit organizations and website owners use Charitable to create fundraising campaigns and raise more money online.', 'google-analytics-for-wordpress'), |
|
367 | - 'installed' => array_key_exists('charitable/charitable.php', $installed_plugins), |
|
366 | + 'excerpt' => __( 'Top-rated WordPress donation and fundraising plugin. Over 10,000+ non-profit organizations and website owners use Charitable to create fundraising campaigns and raise more money online.', 'google-analytics-for-wordpress' ), |
|
367 | + 'installed' => array_key_exists( 'charitable/charitable.php', $installed_plugins ), |
|
368 | 368 | 'basename' => 'charitable/charitable.php', |
369 | 369 | 'slug' => 'charitable', |
370 | - 'settings' => admin_url('admin.php?page=charitable'), |
|
370 | + 'settings' => admin_url( 'admin.php?page=charitable' ), |
|
371 | 371 | ); |
372 | 372 | |
373 | 373 | // WPCode |
@@ -375,11 +375,11 @@ discard block |
||
375 | 375 | 'active' => function_exists( 'WPCode' ), |
376 | 376 | 'icon' => plugin_dir_url( MONSTERINSIGHTS_PLUGIN_FILE ) . 'assets/images/plugins/plugin-wpcode.png', |
377 | 377 | 'title' => 'WPCode', |
378 | - 'excerpt' => __('Future proof your WordPress customizations with the most popular code snippet management plugin for WordPress. Trusted by over 1,500,000+ websites for easily adding code to WordPress right from the admin area.', 'google-analytics-for-wordpress'), |
|
379 | - 'installed' => array_key_exists('insert-headers-and-footers/ihaf.php', $installed_plugins), |
|
378 | + 'excerpt' => __( 'Future proof your WordPress customizations with the most popular code snippet management plugin for WordPress. Trusted by over 1,500,000+ websites for easily adding code to WordPress right from the admin area.', 'google-analytics-for-wordpress' ), |
|
379 | + 'installed' => array_key_exists( 'insert-headers-and-footers/ihaf.php', $installed_plugins ), |
|
380 | 380 | 'basename' => 'insert-headers-and-footers/ihaf.php', |
381 | 381 | 'slug' => 'insert-headers-and-footers', |
382 | - 'settings' => admin_url('admin.php?page=wpcode-settings'), |
|
382 | + 'settings' => admin_url( 'admin.php?page=wpcode-settings' ), |
|
383 | 383 | ); |
384 | 384 | |
385 | 385 | // Duplicator |
@@ -387,11 +387,11 @@ discard block |
||
387 | 387 | 'active' => defined( 'DUPLICATOR_VERSION' ), |
388 | 388 | 'icon' => plugin_dir_url( MONSTERINSIGHTS_PLUGIN_FILE ) . 'assets/images/plugins/plugin-duplicator.png', |
389 | 389 | 'title' => 'Duplicator', |
390 | - 'excerpt' => __('Leading WordPress backup & site migration plugin. Over 1,500,000+ smart website owners use Duplicator to make reliable and secure WordPress backups to protect their websites. It also makes website migration really easy.', 'google-analytics-for-wordpress'), |
|
391 | - 'installed' => array_key_exists('duplicator/duplicator.php', $installed_plugins), |
|
390 | + 'excerpt' => __( 'Leading WordPress backup & site migration plugin. Over 1,500,000+ smart website owners use Duplicator to make reliable and secure WordPress backups to protect their websites. It also makes website migration really easy.', 'google-analytics-for-wordpress' ), |
|
391 | + 'installed' => array_key_exists( 'duplicator/duplicator.php', $installed_plugins ), |
|
392 | 392 | 'basename' => 'duplicator/duplicator.php', |
393 | 393 | 'slug' => 'duplicator', |
394 | - 'settings' => admin_url('admin.php?page=duplicator-settings'), |
|
394 | + 'settings' => admin_url( 'admin.php?page=duplicator-settings' ), |
|
395 | 395 | ); |
396 | 396 | |
397 | 397 | // WishList Member. |
@@ -433,39 +433,39 @@ discard block |
||
433 | 433 | |
434 | 434 | // AffiliateWP |
435 | 435 | $parsed_addons['affiliate-wp'] = array( |
436 | - 'active' => class_exists('AffiliateWP_Core_Requirements_Check'), |
|
436 | + 'active' => class_exists( 'AffiliateWP_Core_Requirements_Check' ), |
|
437 | 437 | 'icon' => plugin_dir_url( MONSTERINSIGHTS_PLUGIN_FILE ) . 'assets/images/plugins/plugin-affiliate-wp.png', |
438 | 438 | 'title' => 'AffiliateWP', |
439 | - 'excerpt' => __('The #1 affiliate management plugin for WordPress. Easily create an affiliate program for your eCommerce store or membership site within minutes and start growing your sales with the power of referral marketing.', 'google-analytics-for-wordpress'), |
|
440 | - 'installed' => array_key_exists('affiliate-wp/affiliate-wp.php', $installed_plugins), |
|
439 | + 'excerpt' => __( 'The #1 affiliate management plugin for WordPress. Easily create an affiliate program for your eCommerce store or membership site within minutes and start growing your sales with the power of referral marketing.', 'google-analytics-for-wordpress' ), |
|
440 | + 'installed' => array_key_exists( 'affiliate-wp/affiliate-wp.php', $installed_plugins ), |
|
441 | 441 | 'basename' => 'affiliate-wp/affiliate-wp.php', |
442 | 442 | 'slug' => 'affiliate-wp', |
443 | - 'settings' => admin_url('admin.php?page=affiliate-wp-settings'), |
|
443 | + 'settings' => admin_url( 'admin.php?page=affiliate-wp-settings' ), |
|
444 | 444 | 'redirect' => 'https://affiliatewp.com', |
445 | 445 | ); |
446 | 446 | |
447 | 447 | // WP Simple Pay |
448 | 448 | $parsed_addons['wpsimplepay'] = array( |
449 | - 'active' => defined('SIMPLE_PAY_VERSION'), |
|
449 | + 'active' => defined( 'SIMPLE_PAY_VERSION' ), |
|
450 | 450 | 'icon' => plugin_dir_url( MONSTERINSIGHTS_PLUGIN_FILE ) . 'assets/images/plugins/plugin-wp-simple-pay.png', |
451 | 451 | 'title' => 'WP Simple Pay', |
452 | - 'excerpt' => __('The #1 Stripe payments plugin for WordPress. Start accepting one-time and recurring payments on your WordPress site without setting up a shopping cart. No code required.', 'google-analytics-for-wordpress'), |
|
453 | - 'installed' => array_key_exists('stripe/stripe-checkout.php', $installed_plugins), |
|
452 | + 'excerpt' => __( 'The #1 Stripe payments plugin for WordPress. Start accepting one-time and recurring payments on your WordPress site without setting up a shopping cart. No code required.', 'google-analytics-for-wordpress' ), |
|
453 | + 'installed' => array_key_exists( 'stripe/stripe-checkout.php', $installed_plugins ), |
|
454 | 454 | 'basename' => 'stripe/stripe-checkout.php', |
455 | 455 | 'slug' => 'stripe', |
456 | - 'settings' => admin_url('edit.php?post_type=simple-pay&page=simpay_settings'), |
|
456 | + 'settings' => admin_url( 'edit.php?post_type=simple-pay&page=simpay_settings' ), |
|
457 | 457 | ); |
458 | 458 | |
459 | 459 | // Sugar Calendar |
460 | 460 | $parsed_addons['sugarcalendar'] = array( |
461 | - 'active' => class_exists('Sugar_Calendar\\Requirements_Check'), |
|
461 | + 'active' => class_exists( 'Sugar_Calendar\\Requirements_Check' ), |
|
462 | 462 | 'icon' => plugin_dir_url( MONSTERINSIGHTS_PLUGIN_FILE ) . 'assets/images/plugins/plugin-sugar-calendar.png', |
463 | 463 | 'title' => 'Sugar Calendar', |
464 | - 'excerpt' => __('A simple & powerful event calendar plugin for WordPress that comes with all the event management features including payments, scheduling, timezones, ticketing, recurring events, and more.', 'google-analytics-for-wordpress'), |
|
465 | - 'installed' => array_key_exists('sugar-calendar-lite/sugar-calendar-lite.php', $installed_plugins), |
|
464 | + 'excerpt' => __( 'A simple & powerful event calendar plugin for WordPress that comes with all the event management features including payments, scheduling, timezones, ticketing, recurring events, and more.', 'google-analytics-for-wordpress' ), |
|
465 | + 'installed' => array_key_exists( 'sugar-calendar-lite/sugar-calendar-lite.php', $installed_plugins ), |
|
466 | 466 | 'basename' => 'sugar-calendar-lite/sugar-calendar-lite.php', |
467 | 467 | 'slug' => 'sugar-calendar-lite', |
468 | - 'settings' => admin_url('admin.php?page=sugar-calendar'), |
|
468 | + 'settings' => admin_url( 'admin.php?page=sugar-calendar' ), |
|
469 | 469 | ); |
470 | 470 | |
471 | 471 | // WPForms. |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | ); |
554 | 554 | // RafflePress |
555 | 555 | $parsed_addons['rafflepress'] = array( |
556 | - 'active' => defined('RAFFLEPRESS_VERSION'), |
|
556 | + 'active' => defined( 'RAFFLEPRESS_VERSION' ), |
|
557 | 557 | 'icon' => plugin_dir_url( MONSTERINSIGHTS_PLUGIN_FILE ) . 'assets/images/plugins/plugin-rafflepress.png', |
558 | 558 | 'title' => 'RafflePress', |
559 | 559 | 'excerpt' => __( 'Turn your website visitors into brand ambassadors! Easily grow your email list, website traffic, and social media followers with the most powerful giveaways & contests plugin for WordPress.', 'google-analytics-for-wordpress' ), |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | ); |
565 | 565 | // TrustPulse |
566 | 566 | $parsed_addons['trustpulse'] = array( |
567 | - 'active' => defined('TRUSTPULSE_PLUGIN_VERSION'), |
|
567 | + 'active' => defined( 'TRUSTPULSE_PLUGIN_VERSION' ), |
|
568 | 568 | 'icon' => plugin_dir_url( MONSTERINSIGHTS_PLUGIN_FILE ) . 'assets/images/plugins/plugin-trustpulse.png', |
569 | 569 | 'title' => 'TrustPulse', |
570 | 570 | 'excerpt' => __( 'Boost your sales and conversions by up to 15% with real-time social proof notifications. TrustPulse helps you show live user activity and purchases to help convince other users to purchase.', 'google-analytics-for-wordpress' ), |
@@ -577,14 +577,14 @@ discard block |
||
577 | 577 | |
578 | 578 | // SearchWP |
579 | 579 | $parsed_addons['searchwp'] = array( |
580 | - 'active' => defined('SEARCHWP_LIVE_SEARCH_VERSION'), |
|
580 | + 'active' => defined( 'SEARCHWP_LIVE_SEARCH_VERSION' ), |
|
581 | 581 | 'icon' => plugin_dir_url( MONSTERINSIGHTS_PLUGIN_FILE ) . 'assets/images/plugins/plugin-searchwp.png', |
582 | 582 | 'title' => 'SearchWP', |
583 | - 'excerpt' => __('The most advanced WordPress search plugin. Customize your WordPress search algorithm, reorder search results, track search metrics, and everything you need to leverage search to grow your business.', 'google-analytics-for-wordpress'), |
|
584 | - 'installed' => array_key_exists('searchwp-live-ajax-search/searchwp-live-ajax-search.php', $installed_plugins), |
|
583 | + 'excerpt' => __( 'The most advanced WordPress search plugin. Customize your WordPress search algorithm, reorder search results, track search metrics, and everything you need to leverage search to grow your business.', 'google-analytics-for-wordpress' ), |
|
584 | + 'installed' => array_key_exists( 'searchwp-live-ajax-search/searchwp-live-ajax-search.php', $installed_plugins ), |
|
585 | 585 | 'basename' => 'searchwp-live-ajax-search/searchwp-live-ajax-search.php', |
586 | 586 | 'slug' => 'searchwp-live-ajax-search', |
587 | - 'settings' => admin_url('admin.php?page=searchwp-live-search'), |
|
587 | + 'settings' => admin_url( 'admin.php?page=searchwp-live-search' ), |
|
588 | 588 | ); |
589 | 589 | |
590 | 590 | // Smash Balloon (Instagram) |
@@ -617,14 +617,14 @@ discard block |
||
617 | 617 | |
618 | 618 | // Smash Balloon (YouTube) |
619 | 619 | $parsed_addons['smash-balloon-youtube'] = array( |
620 | - 'active' => defined('SBYVER'), |
|
620 | + 'active' => defined( 'SBYVER' ), |
|
621 | 621 | 'icon' => plugin_dir_url( MONSTERINSIGHTS_PLUGIN_FILE ) . 'assets/images/plugins/plugin-sb-youtube.png', |
622 | 622 | 'title' => 'Smash Balloon YouTube Feeds', |
623 | - 'excerpt' => __('Easily display YouTube videos on your WordPress site without writing any code. Comes with multiple layouts, ability to embed live streams, video filtering, ability to combine multiple channel videos, and more.', 'google-analytics-for-wordpress'), |
|
624 | - 'installed' => array_key_exists('feeds-for-youtube/youtube-feed.php', $installed_plugins), |
|
623 | + 'excerpt' => __( 'Easily display YouTube videos on your WordPress site without writing any code. Comes with multiple layouts, ability to embed live streams, video filtering, ability to combine multiple channel videos, and more.', 'google-analytics-for-wordpress' ), |
|
624 | + 'installed' => array_key_exists( 'feeds-for-youtube/youtube-feed.php', $installed_plugins ), |
|
625 | 625 | 'basename' => 'feeds-for-youtube/youtube-feed.php', |
626 | 626 | 'slug' => 'feeds-for-youtube', |
627 | - 'settings' => admin_url('admin.php?page=sby-feed-builder'), |
|
627 | + 'settings' => admin_url( 'admin.php?page=sby-feed-builder' ), |
|
628 | 628 | ); |
629 | 629 | |
630 | 630 | // In Year in Review we need the exact slug for the key in order to make the AJAX activation work. |
@@ -632,14 +632,14 @@ discard block |
||
632 | 632 | |
633 | 633 | // Smash Balloon (Twitter) |
634 | 634 | $parsed_addons['smash-balloon-twitter'] = array( |
635 | - 'active' => defined('CTF_VERSION'), |
|
635 | + 'active' => defined( 'CTF_VERSION' ), |
|
636 | 636 | 'icon' => plugin_dir_url( MONSTERINSIGHTS_PLUGIN_FILE ) . 'assets/images/plugins/plugin-sb-twitter.png', |
637 | 637 | 'title' => 'Smash Balloon Twitter Feeds', |
638 | - 'excerpt' => __('Easily display Twitter content in WordPress without writing any code. Comes with multiple layouts, ability to combine multiple Twitter feeds, Twitter card support, tweet moderation, and more.', 'google-analytics-for-wordpress'), |
|
639 | - 'installed' => array_key_exists('custom-twitter-feeds/custom-twitter-feed.php', $installed_plugins), |
|
638 | + 'excerpt' => __( 'Easily display Twitter content in WordPress without writing any code. Comes with multiple layouts, ability to combine multiple Twitter feeds, Twitter card support, tweet moderation, and more.', 'google-analytics-for-wordpress' ), |
|
639 | + 'installed' => array_key_exists( 'custom-twitter-feeds/custom-twitter-feed.php', $installed_plugins ), |
|
640 | 640 | 'basename' => 'custom-twitter-feeds/custom-twitter-feed.php', |
641 | 641 | 'slug' => 'custom-twitter-feeds', |
642 | - 'settings' => admin_url('admin.php?page=ctf-feed-builder'), |
|
642 | + 'settings' => admin_url( 'admin.php?page=ctf-feed-builder' ), |
|
643 | 643 | ); |
644 | 644 | |
645 | 645 | // We need the key of the addon to be exactly the slug. We should deprecate `smash-balloon-twitter` next version. |
@@ -647,10 +647,10 @@ discard block |
||
647 | 647 | |
648 | 648 | // PushEngage |
649 | 649 | $parsed_addons['pushengage'] = array( |
650 | - 'active' => defined('PUSHENGAGE_VERSION'), |
|
650 | + 'active' => defined( 'PUSHENGAGE_VERSION' ), |
|
651 | 651 | 'icon' => plugin_dir_url( MONSTERINSIGHTS_PLUGIN_FILE ) . 'assets/images/plugins/plugin-pushengage.png', |
652 | 652 | 'title' => 'PushEngage', |
653 | - 'excerpt' => __('Connect with your visitors after they leave your website with the leading web push notification software. Over 10,000+ businesses worldwide use PushEngage to send 15 billion notifications each month.', 'google-analytics-for-wordpress'), |
|
653 | + 'excerpt' => __( 'Connect with your visitors after they leave your website with the leading web push notification software. Over 10,000+ businesses worldwide use PushEngage to send 15 billion notifications each month.', 'google-analytics-for-wordpress' ), |
|
654 | 654 | 'installed' => array_key_exists( 'pushengage/main.php', $installed_plugins ), |
655 | 655 | 'basename' => 'pushengage/main.php', |
656 | 656 | 'slug' => 'pushengage', |
@@ -658,14 +658,14 @@ discard block |
||
658 | 658 | |
659 | 659 | // Uncanny Automator |
660 | 660 | $parsed_addons['uncanny-automator'] = array( |
661 | - 'active' => function_exists('automator_get_recipe_id'), |
|
661 | + 'active' => function_exists( 'automator_get_recipe_id' ), |
|
662 | 662 | 'icon' => plugin_dir_url( MONSTERINSIGHTS_PLUGIN_FILE ) . 'assets/images/plugins/plugin-uncanny-automator.png', |
663 | 663 | 'title' => 'Uncanny Automator', |
664 | - 'excerpt' => __('Automate everything with the #1 no-code Automation tool for WordPress.', 'google-analytics-for-wordpress'), |
|
665 | - 'installed' => array_key_exists('uncanny-automator/uncanny-automator.php', $installed_plugins), |
|
664 | + 'excerpt' => __( 'Automate everything with the #1 no-code Automation tool for WordPress.', 'google-analytics-for-wordpress' ), |
|
665 | + 'installed' => array_key_exists( 'uncanny-automator/uncanny-automator.php', $installed_plugins ), |
|
666 | 666 | 'basename' => 'uncanny-automator/uncanny-automator.php', |
667 | 667 | 'slug' => 'uncanny-automator', |
668 | - 'setup_complete' => class_exists( 'Uncanny_Automator\Api_Server' ) ? !! \Uncanny_Automator\Api_Server::is_automator_connected() : false, |
|
668 | + 'setup_complete' => class_exists( 'Uncanny_Automator\Api_Server' ) ? ! ! \Uncanny_Automator\Api_Server::is_automator_connected() : false, |
|
669 | 669 | 'wizard_url' => admin_url( 'edit.php?post_type=uo-recipe&page=uncanny-automator-setup-wizard' ), |
670 | 670 | 'recipe_url' => admin_url( 'post-new.php?post_type=uo-recipe' ), |
671 | 671 | ); |
@@ -772,7 +772,7 @@ discard block |
||
772 | 772 | 'slug' => 'userfeedback-lite', |
773 | 773 | 'settings' => admin_url( 'admin.php?page=userfeedback_onboarding' ), |
774 | 774 | 'surveys' => admin_url( 'admin.php?page=userfeedback_surveys' ), |
775 | - 'setup_complete' => (get_option('userfeedback_onboarding_complete', 0) == 1), |
|
775 | + 'setup_complete' => ( get_option( 'userfeedback_onboarding_complete', 0 ) == 1 ), |
|
776 | 776 | ); |
777 | 777 | |
778 | 778 | // Gravity Forms. |
@@ -790,7 +790,7 @@ discard block |
||
790 | 790 | ); |
791 | 791 | } |
792 | 792 | |
793 | - $parsed_addons = apply_filters('monsterinsights_parsed_addons', $parsed_addons); |
|
793 | + $parsed_addons = apply_filters( 'monsterinsights_parsed_addons', $parsed_addons ); |
|
794 | 794 | |
795 | 795 | wp_send_json( $parsed_addons ); |
796 | 796 | } |
@@ -807,7 +807,7 @@ discard block |
||
807 | 807 | * @return mixed |
808 | 808 | */ |
809 | 809 | public function get_addon( $installed_plugins, $addons_type, $addon, $slug ) { |
810 | - return monsterinsights_get_addon($installed_plugins, $addons_type, $addon, $slug); |
|
810 | + return monsterinsights_get_addon( $installed_plugins, $addons_type, $addon, $slug ); |
|
811 | 811 | } |
812 | 812 | |
813 | 813 | /** |
@@ -987,14 +987,14 @@ discard block |
||
987 | 987 | unset( $new_settings['site_notes'] ); |
988 | 988 | |
989 | 989 | foreach ( $exclude as $e ) { |
990 | - if ( ! empty( $new_settings[ $e ] ) ) { |
|
991 | - unset( $new_settings[ $e ] ); |
|
990 | + if ( ! empty( $new_settings[$e] ) ) { |
|
991 | + unset( $new_settings[$e] ); |
|
992 | 992 | } |
993 | 993 | } |
994 | 994 | |
995 | 995 | foreach ( $exclude as $e ) { |
996 | - if ( ! empty( $settings[ $e ] ) ) { |
|
997 | - $new_settings = $settings[ $e ]; |
|
996 | + if ( ! empty( $settings[$e] ) ) { |
|
997 | + $new_settings = $settings[$e]; |
|
998 | 998 | } |
999 | 999 | } |
1000 | 1000 | |
@@ -1208,7 +1208,7 @@ discard block |
||
1208 | 1208 | ), |
1209 | 1209 | admin_url( 'admin.php' ) |
1210 | 1210 | ); |
1211 | - $url = esc_url( $url ); |
|
1211 | + $url = esc_url( $url ); |
|
1212 | 1212 | |
1213 | 1213 | ob_start(); |
1214 | 1214 | if ( false === ( $creds = request_filesystem_credentials( $url, $method, false, false, null ) ) ) { |
@@ -1305,15 +1305,15 @@ discard block |
||
1305 | 1305 | |
1306 | 1306 | $post_type = isset( $_POST['post_type'] ) ? sanitize_text_field( wp_unslash( $_POST['post_type'] ) ) : 'any'; |
1307 | 1307 | |
1308 | - $already_added = monsterinsights_get_option('popular_posts_inline_curated', []); |
|
1308 | + $already_added = monsterinsights_get_option( 'popular_posts_inline_curated', [] ); |
|
1309 | 1309 | $exclude = array(); |
1310 | - if( is_array( $already_added ) && !empty( $already_added ) ){ |
|
1310 | + if ( is_array( $already_added ) && ! empty( $already_added ) ) { |
|
1311 | 1311 | foreach ( $already_added as $key => $value ) { |
1312 | 1312 | $exclude[$value['id']] = $value['id']; |
1313 | 1313 | } |
1314 | 1314 | } |
1315 | 1315 | |
1316 | - $exclude = array_unique(array_values($exclude)); |
|
1316 | + $exclude = array_unique( array_values( $exclude ) ); |
|
1317 | 1317 | |
1318 | 1318 | $args = array( |
1319 | 1319 | 's' => isset( $_POST['keyword'] ) ? sanitize_text_field( wp_unslash( $_POST['keyword'] ) ) : '', |
@@ -1331,7 +1331,7 @@ discard block |
||
1331 | 1331 | $homepage = get_option( 'page_on_front' ); |
1332 | 1332 | if ( ! $homepage ) { |
1333 | 1333 | $array[] = array( |
1334 | - 'id' => - 1, |
|
1334 | + 'id' => -1, |
|
1335 | 1335 | 'title' => __( 'Homepage', 'google-analytics-for-wordpress' ), |
1336 | 1336 | ); |
1337 | 1337 | } |
@@ -1405,7 +1405,7 @@ discard block |
||
1405 | 1405 | if ( ! post_type_supports( $post_type->name, 'editor' ) || 'product' === $post_type->name ) { |
1406 | 1406 | continue; |
1407 | 1407 | } |
1408 | - $post_types_parsed[ $post_type->name ] = $post_type->labels->singular_name; |
|
1408 | + $post_types_parsed[$post_type->name] = $post_type->labels->singular_name; |
|
1409 | 1409 | } |
1410 | 1410 | |
1411 | 1411 | $post_types_parsed = apply_filters( 'monsterinsights_vue_post_types_editor', $post_types_parsed ); |
@@ -1574,18 +1574,18 @@ discard block |
||
1574 | 1574 | $value = sanitize_text_field( wp_unslash( $_POST['value'] ) ); // Value of custom style like 12px or #fff. |
1575 | 1575 | $settings = get_option( $settings_key, array() ); |
1576 | 1576 | |
1577 | - if ( ! isset( $settings[ $type ] ) ) { |
|
1578 | - $settings[ $type ] = array(); |
|
1577 | + if ( ! isset( $settings[$type] ) ) { |
|
1578 | + $settings[$type] = array(); |
|
1579 | 1579 | } |
1580 | - if ( ! isset( $settings[ $type ][ $theme ] ) ) { |
|
1581 | - $settings[ $type ][ $theme ] = array(); |
|
1580 | + if ( ! isset( $settings[$type][$theme] ) ) { |
|
1581 | + $settings[$type][$theme] = array(); |
|
1582 | 1582 | } |
1583 | 1583 | |
1584 | - if ( ! isset( $settings[ $type ][ $theme ][ $object ] ) ) { |
|
1585 | - $settings[ $type ][ $theme ][ $object ] = array(); |
|
1584 | + if ( ! isset( $settings[$type][$theme][$object] ) ) { |
|
1585 | + $settings[$type][$theme][$object] = array(); |
|
1586 | 1586 | } |
1587 | 1587 | |
1588 | - $settings[ $type ][ $theme ][ $object ][ $key ] = $value; |
|
1588 | + $settings[$type][$theme][$object][$key] = $value; |
|
1589 | 1589 | |
1590 | 1590 | update_option( $settings_key, $settings ); |
1591 | 1591 |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | */ |
16 | 16 | public static function get_instance() |
17 | 17 | { |
18 | - if (!isset(self::$instance) && !(self::$instance instanceof MonsterInsights_SiteNotes_Controller)) { |
|
18 | + if ( ! isset( self::$instance ) && ! ( self::$instance instanceof MonsterInsights_SiteNotes_Controller ) ) { |
|
19 | 19 | self::$instance = new MonsterInsights_SiteNotes_Controller(); |
20 | 20 | } |
21 | 21 | return self::$instance; |
@@ -35,40 +35,40 @@ discard block |
||
35 | 35 | |
36 | 36 | public function add_hooks() |
37 | 37 | { |
38 | - add_action('init', array($this->db, 'install')); |
|
39 | - add_action('wp_ajax_monsterinsights_vue_get_notes', array($this, 'get_notes')); |
|
40 | - add_action('wp_ajax_monsterinsights_vue_get_note', array($this, 'get_note')); |
|
41 | - add_action('wp_ajax_monsterinsights_vue_get_categories', array($this, 'get_categories')); |
|
42 | - add_action('wp_ajax_monsterinsights_vue_save_note', array($this, 'save_note')); |
|
43 | - add_action('wp_ajax_monsterinsights_vue_save_category', array($this, 'save_category')); |
|
44 | - add_action('wp_ajax_monsterinsights_vue_trash_notes', array($this, 'trash_notes')); |
|
45 | - add_action('wp_ajax_monsterinsights_vue_restore_notes', array($this, 'restore_notes')); |
|
46 | - add_action('wp_ajax_monsterinsights_vue_delete_notes', array($this, 'delete_notes')); |
|
47 | - add_action('wp_ajax_monsterinsights_vue_delete_categories', array($this, 'delete_categories')); |
|
48 | - |
|
49 | - add_action('init', array($this, 'register_meta')); |
|
50 | - |
|
51 | - add_action('wp_after_insert_post', array($this, 'create_note_with_post')); |
|
52 | - |
|
53 | - if (!is_admin()) { |
|
38 | + add_action( 'init', array( $this->db, 'install' ) ); |
|
39 | + add_action( 'wp_ajax_monsterinsights_vue_get_notes', array( $this, 'get_notes' ) ); |
|
40 | + add_action( 'wp_ajax_monsterinsights_vue_get_note', array( $this, 'get_note' ) ); |
|
41 | + add_action( 'wp_ajax_monsterinsights_vue_get_categories', array( $this, 'get_categories' ) ); |
|
42 | + add_action( 'wp_ajax_monsterinsights_vue_save_note', array( $this, 'save_note' ) ); |
|
43 | + add_action( 'wp_ajax_monsterinsights_vue_save_category', array( $this, 'save_category' ) ); |
|
44 | + add_action( 'wp_ajax_monsterinsights_vue_trash_notes', array( $this, 'trash_notes' ) ); |
|
45 | + add_action( 'wp_ajax_monsterinsights_vue_restore_notes', array( $this, 'restore_notes' ) ); |
|
46 | + add_action( 'wp_ajax_monsterinsights_vue_delete_notes', array( $this, 'delete_notes' ) ); |
|
47 | + add_action( 'wp_ajax_monsterinsights_vue_delete_categories', array( $this, 'delete_categories' ) ); |
|
48 | + |
|
49 | + add_action( 'init', array( $this, 'register_meta' ) ); |
|
50 | + |
|
51 | + add_action( 'wp_after_insert_post', array( $this, 'create_note_with_post' ) ); |
|
52 | + |
|
53 | + if ( ! is_admin() ) { |
|
54 | 54 | return; |
55 | 55 | } |
56 | 56 | |
57 | - add_filter('monsterinsights_report_overview_data', array($this, 'prepare_data_overview_chart')); |
|
58 | - add_filter('monsterinsights_report_traffic_sessions_chart_data', array($this, 'prepare_traffic_sessions_chart_data'), 10, 3); |
|
59 | - add_action('save_post', array($this, 'save_custom_fields')); |
|
60 | - add_filter('monsterinsights_gutenberg_tool_vars', array($this, 'add_categories_to_editor')); |
|
61 | - add_action('admin_enqueue_scripts', array($this, 'admin_scripts')); |
|
62 | - add_action('admin_init', array($this->db, 'insert_default_categories')); |
|
63 | - add_action('admin_init', array($this, 'export_notes')); |
|
64 | - add_filter('wp_untrash_post_status', array($this, 'change_restore_note_status'), 10, 3); |
|
65 | - add_action('monsterinsights_after_exclude_metabox', array($this, 'add_metabox_contents'), 11, 2); |
|
66 | - add_action('admin_enqueue_scripts', array($this, 'load_metabox_assets')); |
|
57 | + add_filter( 'monsterinsights_report_overview_data', array( $this, 'prepare_data_overview_chart' ) ); |
|
58 | + add_filter( 'monsterinsights_report_traffic_sessions_chart_data', array( $this, 'prepare_traffic_sessions_chart_data' ), 10, 3 ); |
|
59 | + add_action( 'save_post', array( $this, 'save_custom_fields' ) ); |
|
60 | + add_filter( 'monsterinsights_gutenberg_tool_vars', array( $this, 'add_categories_to_editor' ) ); |
|
61 | + add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) ); |
|
62 | + add_action( 'admin_init', array( $this->db, 'insert_default_categories' ) ); |
|
63 | + add_action( 'admin_init', array( $this, 'export_notes' ) ); |
|
64 | + add_filter( 'wp_untrash_post_status', array( $this, 'change_restore_note_status' ), 10, 3 ); |
|
65 | + add_action( 'monsterinsights_after_exclude_metabox', array( $this, 'add_metabox_contents' ), 11, 2 ); |
|
66 | + add_action( 'admin_enqueue_scripts', array( $this, 'load_metabox_assets' ) ); |
|
67 | 67 | } |
68 | 68 | |
69 | - private function prepare_notes($params) |
|
69 | + private function prepare_notes( $params ) |
|
70 | 70 | { |
71 | - $args = wp_parse_args($params, array( |
|
71 | + $args = wp_parse_args( $params, array( |
|
72 | 72 | 'per_page' => 10, |
73 | 73 | 'page' => 1, |
74 | 74 | 'orderby' => 'id', |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | 'date_range' => null, |
80 | 80 | 'category' => null, |
81 | 81 | ], |
82 | - )); |
|
82 | + ) ); |
|
83 | 83 | |
84 | - switch ($args['orderby']) { |
|
84 | + switch ( $args['orderby'] ) { |
|
85 | 85 | case 'note_date': |
86 | 86 | $args['orderby'] = 'date'; |
87 | 87 | break; |
@@ -90,41 +90,41 @@ discard block |
||
90 | 90 | break; |
91 | 91 | } |
92 | 92 | |
93 | - if ('note_date' === $args['orderby']) { |
|
93 | + if ( 'note_date' === $args['orderby'] ) { |
|
94 | 94 | $args['orderby'] = 'date'; |
95 | 95 | } |
96 | 96 | |
97 | - if ('note_date' === $args['orderby']) { |
|
97 | + if ( 'note_date' === $args['orderby'] ) { |
|
98 | 98 | $args['orderby'] = 'date'; |
99 | 99 | } |
100 | 100 | |
101 | - if (!empty($params['search'])) { |
|
101 | + if ( ! empty( $params['search'] ) ) { |
|
102 | 102 | $args['search'] = $args['search']; |
103 | 103 | } |
104 | 104 | |
105 | - return $this->db->get_items($args); |
|
105 | + return $this->db->get_items( $args ); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | public function get_notes() |
109 | 109 | { |
110 | - check_ajax_referer('mi-admin-nonce', 'nonce'); |
|
110 | + check_ajax_referer( 'mi-admin-nonce', 'nonce' ); |
|
111 | 111 | |
112 | - $params = !empty($_POST['params']) ? json_decode(html_entity_decode(stripslashes($_POST['params'])), true) : []; |
|
112 | + $params = ! empty( $_POST['params'] ) ? json_decode( html_entity_decode( stripslashes( $_POST['params'] ) ), true ) : []; |
|
113 | 113 | |
114 | - $output = $this->prepare_notes($params); |
|
114 | + $output = $this->prepare_notes( $params ); |
|
115 | 115 | |
116 | - $num_posts = wp_count_posts('monsterinsights_note', 'readable'); |
|
116 | + $num_posts = wp_count_posts( 'monsterinsights_note', 'readable' ); |
|
117 | 117 | |
118 | - if ($num_posts) { |
|
118 | + if ( $num_posts ) { |
|
119 | 119 | $output['status_filters'] = array( |
120 | 120 | array( |
121 | 121 | 'status' => 'all', |
122 | - 'count' => array_sum((array) $num_posts) - $num_posts->trash, |
|
122 | + 'count' => array_sum( (array) $num_posts ) - $num_posts->trash, |
|
123 | 123 | ), |
124 | 124 | ); |
125 | 125 | |
126 | - foreach ($num_posts as $status => $count) { |
|
127 | - if (0 >= $count) { |
|
126 | + foreach ( $num_posts as $status => $count ) { |
|
127 | + if ( 0 >= $count ) { |
|
128 | 128 | continue; |
129 | 129 | } |
130 | 130 | |
@@ -135,17 +135,17 @@ discard block |
||
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
138 | - wp_send_json($output); |
|
138 | + wp_send_json( $output ); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | public function get_note() |
142 | 142 | { |
143 | - check_ajax_referer('mi-admin-nonce', 'nonce'); |
|
143 | + check_ajax_referer( 'mi-admin-nonce', 'nonce' ); |
|
144 | 144 | |
145 | - $id = !empty($_POST['id']) ? intval($_POST['id']) : null; |
|
146 | - $item = $this->db->get($id); |
|
145 | + $id = ! empty( $_POST['id'] ) ? intval( $_POST['id'] ) : null; |
|
146 | + $item = $this->db->get( $id ); |
|
147 | 147 | |
148 | - if (is_wp_error($item)) { |
|
148 | + if ( is_wp_error( $item ) ) { |
|
149 | 149 | wp_send_json( |
150 | 150 | array( |
151 | 151 | 'success' => false, |
@@ -154,26 +154,26 @@ discard block |
||
154 | 154 | ); |
155 | 155 | } |
156 | 156 | |
157 | - wp_send_json($item); |
|
157 | + wp_send_json( $item ); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | public function get_categories() |
161 | 161 | { |
162 | - check_ajax_referer('mi-admin-nonce', 'nonce'); |
|
162 | + check_ajax_referer( 'mi-admin-nonce', 'nonce' ); |
|
163 | 163 | |
164 | - $params = !empty($_POST['params']) ? json_decode(html_entity_decode(stripslashes($_POST['params'])), true) : []; |
|
164 | + $params = ! empty( $_POST['params'] ) ? json_decode( html_entity_decode( stripslashes( $_POST['params'] ) ), true ) : []; |
|
165 | 165 | |
166 | - $args = wp_parse_args($params, array( |
|
166 | + $args = wp_parse_args( $params, array( |
|
167 | 167 | 'per_page' => -1, |
168 | 168 | 'page' => 1, |
169 | 169 | 'orderby' => 'name', |
170 | 170 | 'order' => 'asc', |
171 | - )); |
|
171 | + ) ); |
|
172 | 172 | |
173 | - $total = intval($this->db->get_categories($args, true)); |
|
173 | + $total = intval( $this->db->get_categories( $args, true ) ); |
|
174 | 174 | |
175 | - if ($total) { |
|
176 | - $items = $this->db->get_categories($args); |
|
175 | + if ( $total ) { |
|
176 | + $items = $this->db->get_categories( $args ); |
|
177 | 177 | } else { |
178 | 178 | $items = array(); |
179 | 179 | } |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | 'items' => $items, |
184 | 184 | 'pagination' => array( |
185 | 185 | 'total' => $total, |
186 | - 'pages' => ceil($total / $args['per_page']), |
|
186 | + 'pages' => ceil( $total / $args['per_page'] ), |
|
187 | 187 | 'page' => $args['page'], |
188 | 188 | 'per_page' => $args['per_page'], |
189 | 189 | ), |
@@ -193,26 +193,26 @@ discard block |
||
193 | 193 | |
194 | 194 | public function save_note() |
195 | 195 | { |
196 | - check_ajax_referer('mi-admin-nonce', 'nonce'); |
|
196 | + check_ajax_referer( 'mi-admin-nonce', 'nonce' ); |
|
197 | 197 | |
198 | - $note = !empty($_POST['note']) ? json_decode(html_entity_decode(stripslashes($_POST['note']))) : []; |
|
198 | + $note = ! empty( $_POST['note'] ) ? json_decode( html_entity_decode( stripslashes( $_POST['note'] ) ) ) : []; |
|
199 | 199 | |
200 | 200 | $note_details = array( |
201 | - 'note' => sanitize_text_field($note->note_title), |
|
202 | - 'category' => intval(is_object($note->category) && isset($note->category->id) && intval($note->category->id) ? $note->category->id : 0), |
|
201 | + 'note' => sanitize_text_field( $note->note_title ), |
|
202 | + 'category' => intval( is_object( $note->category ) && isset( $note->category->id ) && intval( $note->category->id ) ? $note->category->id : 0 ), |
|
203 | 203 | 'date' => $note->note_date_ymd, |
204 | - 'medias' => !empty($note->medias) ? array_values(array_keys((array) $note->medias)) : [], |
|
205 | - 'important' => isset($note->important) ? $note->important : false, |
|
204 | + 'medias' => ! empty( $note->medias ) ? array_values( array_keys( (array) $note->medias ) ) : [], |
|
205 | + 'important' => isset( $note->important ) ? $note->important : false, |
|
206 | 206 | ); |
207 | 207 | |
208 | - if ($note->id) { |
|
208 | + if ( $note->id ) { |
|
209 | 209 | // Update Site Note. |
210 | 210 | $note_details['id'] = $note->id; |
211 | 211 | } |
212 | 212 | |
213 | - $note_id = $this->db->create($note_details); |
|
213 | + $note_id = $this->db->create( $note_details ); |
|
214 | 214 | |
215 | - if (is_wp_error($note_id)) { |
|
215 | + if ( is_wp_error( $note_id ) ) { |
|
216 | 216 | wp_send_json( |
217 | 217 | array( |
218 | 218 | 'published' => false, |
@@ -232,35 +232,35 @@ discard block |
||
232 | 232 | |
233 | 233 | public function save_category() |
234 | 234 | { |
235 | - check_ajax_referer('mi-admin-nonce', 'nonce'); |
|
235 | + check_ajax_referer( 'mi-admin-nonce', 'nonce' ); |
|
236 | 236 | |
237 | - $category = !empty($_POST['category']) ? json_decode(html_entity_decode(stripslashes($_POST['category']))) : []; |
|
237 | + $category = ! empty( $_POST['category'] ) ? json_decode( html_entity_decode( stripslashes( $_POST['category'] ) ) ) : []; |
|
238 | 238 | |
239 | - if (empty($category->name)) { |
|
239 | + if ( empty( $category->name ) ) { |
|
240 | 240 | wp_send_json( |
241 | 241 | array( |
242 | 242 | 'published' => false, |
243 | - 'message' => __('Please add a category name', 'google-analytics-for-wordpress'), |
|
243 | + 'message' => __( 'Please add a category name', 'google-analytics-for-wordpress' ), |
|
244 | 244 | ) |
245 | 245 | ); |
246 | 246 | } |
247 | 247 | |
248 | - if (200 < mb_strlen($category->name)) { |
|
248 | + if ( 200 < mb_strlen( $category->name ) ) { |
|
249 | 249 | wp_send_json( |
250 | 250 | array( |
251 | 251 | 'published' => false, |
252 | - 'message' => __('You can\'t exceed the 200 characters length for each site note.', 'google-analytics-for-wordpress'), |
|
252 | + 'message' => __( 'You can\'t exceed the 200 characters length for each site note.', 'google-analytics-for-wordpress' ), |
|
253 | 253 | ) |
254 | 254 | ); |
255 | 255 | } |
256 | 256 | |
257 | - $category_id = $this->db->create_category(array( |
|
257 | + $category_id = $this->db->create_category( array( |
|
258 | 258 | 'id' => $category->id, |
259 | 259 | 'name' => $category->name, |
260 | - 'background_color' => sanitize_hex_color($category->background_color), |
|
261 | - )); |
|
260 | + 'background_color' => sanitize_hex_color( $category->background_color ), |
|
261 | + ) ); |
|
262 | 262 | |
263 | - if (is_wp_error($category_id)) { |
|
263 | + if ( is_wp_error( $category_id ) ) { |
|
264 | 264 | wp_send_json( |
265 | 265 | array( |
266 | 266 | 'published' => false, |
@@ -278,9 +278,9 @@ discard block |
||
278 | 278 | ); |
279 | 279 | } |
280 | 280 | |
281 | - public function change_restore_note_status($new_status, $post_id, $previous_status) |
|
281 | + public function change_restore_note_status( $new_status, $post_id, $previous_status ) |
|
282 | 282 | { |
283 | - if ('monsterinsights_note' !== get_post_type($post_id)) { |
|
283 | + if ( 'monsterinsights_note' !== get_post_type( $post_id ) ) { |
|
284 | 284 | return $new_status; |
285 | 285 | } |
286 | 286 | |
@@ -289,21 +289,21 @@ discard block |
||
289 | 289 | |
290 | 290 | public function trash_notes() |
291 | 291 | { |
292 | - check_ajax_referer('mi-admin-nonce', 'nonce'); |
|
292 | + check_ajax_referer( 'mi-admin-nonce', 'nonce' ); |
|
293 | 293 | |
294 | - $ids = !empty($_POST['ids']) ? json_decode(html_entity_decode(stripslashes($_POST['ids']))) : []; |
|
294 | + $ids = ! empty( $_POST['ids'] ) ? json_decode( html_entity_decode( stripslashes( $_POST['ids'] ) ) ) : []; |
|
295 | 295 | |
296 | - if (empty($ids)) { |
|
296 | + if ( empty( $ids ) ) { |
|
297 | 297 | wp_send_json( |
298 | 298 | array( |
299 | 299 | 'success' => false, |
300 | - 'message' => __('Please choose a site note to trash!', 'google-analytics-for-wordpress'), |
|
300 | + 'message' => __( 'Please choose a site note to trash!', 'google-analytics-for-wordpress' ), |
|
301 | 301 | ) |
302 | 302 | ); |
303 | 303 | } |
304 | 304 | |
305 | - foreach ($ids as $id) { |
|
306 | - $this->db->trash_note($id); |
|
305 | + foreach ( $ids as $id ) { |
|
306 | + $this->db->trash_note( $id ); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | wp_send_json( |
@@ -316,21 +316,21 @@ discard block |
||
316 | 316 | |
317 | 317 | public function restore_notes() |
318 | 318 | { |
319 | - check_ajax_referer('mi-admin-nonce', 'nonce'); |
|
319 | + check_ajax_referer( 'mi-admin-nonce', 'nonce' ); |
|
320 | 320 | |
321 | - $ids = !empty($_POST['ids']) ? json_decode(html_entity_decode(stripslashes($_POST['ids']))) : []; |
|
321 | + $ids = ! empty( $_POST['ids'] ) ? json_decode( html_entity_decode( stripslashes( $_POST['ids'] ) ) ) : []; |
|
322 | 322 | |
323 | - if (empty($ids)) { |
|
323 | + if ( empty( $ids ) ) { |
|
324 | 324 | wp_send_json( |
325 | 325 | array( |
326 | 326 | 'success' => false, |
327 | - 'message' => __('Please choose a site note(s) to restore!', 'google-analytics-for-wordpress'), |
|
327 | + 'message' => __( 'Please choose a site note(s) to restore!', 'google-analytics-for-wordpress' ), |
|
328 | 328 | ) |
329 | 329 | ); |
330 | 330 | } |
331 | 331 | |
332 | - foreach ($ids as $id) { |
|
333 | - $this->db->restore_note($id); |
|
332 | + foreach ( $ids as $id ) { |
|
333 | + $this->db->restore_note( $id ); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | wp_send_json( |
@@ -343,21 +343,21 @@ discard block |
||
343 | 343 | |
344 | 344 | public function delete_notes() |
345 | 345 | { |
346 | - check_ajax_referer('mi-admin-nonce', 'nonce'); |
|
346 | + check_ajax_referer( 'mi-admin-nonce', 'nonce' ); |
|
347 | 347 | |
348 | - $ids = !empty($_POST['ids']) ? json_decode(html_entity_decode(stripslashes($_POST['ids']))) : []; |
|
348 | + $ids = ! empty( $_POST['ids'] ) ? json_decode( html_entity_decode( stripslashes( $_POST['ids'] ) ) ) : []; |
|
349 | 349 | |
350 | - if (empty($ids)) { |
|
350 | + if ( empty( $ids ) ) { |
|
351 | 351 | wp_send_json( |
352 | 352 | array( |
353 | 353 | 'success' => false, |
354 | - 'message' => __('Please choose a site note(s) to delete!', 'google-analytics-for-wordpress'), |
|
354 | + 'message' => __( 'Please choose a site note(s) to delete!', 'google-analytics-for-wordpress' ), |
|
355 | 355 | ) |
356 | 356 | ); |
357 | 357 | } |
358 | 358 | |
359 | - foreach ($ids as $id) { |
|
360 | - $this->db->delete_note($id); |
|
359 | + foreach ( $ids as $id ) { |
|
360 | + $this->db->delete_note( $id ); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | wp_send_json( |
@@ -370,21 +370,21 @@ discard block |
||
370 | 370 | |
371 | 371 | public function delete_categories() |
372 | 372 | { |
373 | - check_ajax_referer('mi-admin-nonce', 'nonce'); |
|
373 | + check_ajax_referer( 'mi-admin-nonce', 'nonce' ); |
|
374 | 374 | |
375 | - $ids = !empty($_POST['ids']) ? json_decode(html_entity_decode(stripslashes($_POST['ids']))) : []; |
|
375 | + $ids = ! empty( $_POST['ids'] ) ? json_decode( html_entity_decode( stripslashes( $_POST['ids'] ) ) ) : []; |
|
376 | 376 | |
377 | - if (empty($ids)) { |
|
377 | + if ( empty( $ids ) ) { |
|
378 | 378 | wp_send_json( |
379 | 379 | array( |
380 | 380 | 'success' => false, |
381 | - 'message' => __('Please choose a category to delete!', 'google-analytics-for-wordpress'), |
|
381 | + 'message' => __( 'Please choose a category to delete!', 'google-analytics-for-wordpress' ), |
|
382 | 382 | ) |
383 | 383 | ); |
384 | 384 | } |
385 | 385 | |
386 | - foreach ($ids as $id) { |
|
387 | - $this->db->delete_category($id); |
|
386 | + foreach ( $ids as $id ) { |
|
387 | + $this->db->delete_category( $id ); |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | wp_send_json( |
@@ -397,71 +397,71 @@ discard block |
||
397 | 397 | |
398 | 398 | public function export_notes() |
399 | 399 | { |
400 | - if (!isset($_POST['monsterinsights_action']) || empty($_POST['monsterinsights_action'])) { |
|
400 | + if ( ! isset( $_POST['monsterinsights_action'] ) || empty( $_POST['monsterinsights_action'] ) ) { |
|
401 | 401 | return; |
402 | 402 | } |
403 | 403 | |
404 | - if (!current_user_can('monsterinsights_save_settings')) { |
|
404 | + if ( ! current_user_can( 'monsterinsights_save_settings' ) ) { |
|
405 | 405 | return; |
406 | 406 | } |
407 | 407 | |
408 | - if ('monsterinsights_export_notes' !== $_POST['monsterinsights_action']) { |
|
408 | + if ( 'monsterinsights_export_notes' !== $_POST['monsterinsights_action'] ) { |
|
409 | 409 | return; |
410 | 410 | } |
411 | 411 | |
412 | - check_admin_referer('mi-admin-nonce', 'nonce'); |
|
412 | + check_admin_referer( 'mi-admin-nonce', 'nonce' ); |
|
413 | 413 | |
414 | 414 | //Generate the CSV. |
415 | - ignore_user_abort(true); |
|
415 | + ignore_user_abort( true ); |
|
416 | 416 | |
417 | 417 | nocache_headers(); |
418 | - header('Content-Type: text/csv; charset=utf-8'); |
|
419 | - header('Content-Disposition: attachment; filename=monsterinsights-notes-export-' . wp_date('m-d-Y') . '.csv'); |
|
420 | - header("Expires: 0"); |
|
418 | + header( 'Content-Type: text/csv; charset=utf-8' ); |
|
419 | + header( 'Content-Disposition: attachment; filename=monsterinsights-notes-export-' . wp_date( 'm-d-Y' ) . '.csv' ); |
|
420 | + header( "Expires: 0" ); |
|
421 | 421 | |
422 | 422 | $args = array( |
423 | 423 | 'per_page' => -1, |
424 | 424 | 'status' => ['publish', 'trash'], |
425 | 425 | ); |
426 | 426 | |
427 | - $items = $this->db->get_items($args); |
|
427 | + $items = $this->db->get_items( $args ); |
|
428 | 428 | $headers = array( |
429 | - __('Date', 'google-analytics-for-wordpress'), |
|
430 | - __('Site Note', 'google-analytics-for-wordpress'), |
|
431 | - __('Category', 'google-analytics-for-wordpress'), |
|
432 | - __('Important', 'google-analytics-for-wordpress'), |
|
433 | - __('Media', 'google-analytics-for-wordpress'), |
|
429 | + __( 'Date', 'google-analytics-for-wordpress' ), |
|
430 | + __( 'Site Note', 'google-analytics-for-wordpress' ), |
|
431 | + __( 'Category', 'google-analytics-for-wordpress' ), |
|
432 | + __( 'Important', 'google-analytics-for-wordpress' ), |
|
433 | + __( 'Media', 'google-analytics-for-wordpress' ), |
|
434 | 434 | ); |
435 | 435 | |
436 | - $outstream = fopen("php://output", "wb"); |
|
436 | + $outstream = fopen( "php://output", "wb" ); |
|
437 | 437 | |
438 | 438 | // phpcs:ignore |
439 | - fputcsv($outstream, $headers); |
|
439 | + fputcsv( $outstream, $headers ); |
|
440 | 440 | |
441 | - foreach ($items['items'] as $item) { |
|
442 | - $item_media = __('NA', 'google-analytics-for-wordpress'); |
|
443 | - foreach ($item['medias'] as $media) { |
|
444 | - if (isset($media['url'])) { |
|
441 | + foreach ( $items['items'] as $item ) { |
|
442 | + $item_media = __( 'NA', 'google-analytics-for-wordpress' ); |
|
443 | + foreach ( $item['medias'] as $media ) { |
|
444 | + if ( isset( $media['url'] ) ) { |
|
445 | 445 | $item_media = $media['url']; |
446 | 446 | } |
447 | 447 | } |
448 | 448 | $row = array( |
449 | 449 | $item['note_date'], |
450 | 450 | $item['note_title'], |
451 | - !empty($item['category']) ? $item['category']['name'] : 'N/A', |
|
452 | - intval($item['important']), |
|
451 | + ! empty( $item['category'] ) ? $item['category']['name'] : 'N/A', |
|
452 | + intval( $item['important'] ), |
|
453 | 453 | $item_media |
454 | 454 | ); |
455 | 455 | |
456 | 456 | // phpcs:ignore |
457 | - fputcsv($outstream, $row); |
|
457 | + fputcsv( $outstream, $row ); |
|
458 | 458 | } |
459 | 459 | |
460 | - fclose($outstream); |
|
460 | + fclose( $outstream ); |
|
461 | 461 | exit; |
462 | 462 | } |
463 | 463 | |
464 | - public function add_categories_to_editor($vars) |
|
464 | + public function add_categories_to_editor( $vars ) |
|
465 | 465 | { |
466 | 466 | $args = array( |
467 | 467 | 'per_page' => 0, |
@@ -470,11 +470,11 @@ discard block |
||
470 | 470 | 'order' => 'asc', |
471 | 471 | ); |
472 | 472 | |
473 | - $categories = $this->db->get_categories($args); |
|
473 | + $categories = $this->db->get_categories( $args ); |
|
474 | 474 | $output_categories = array(); |
475 | 475 | |
476 | - if ($categories) { |
|
477 | - foreach ($categories as $category) { |
|
476 | + if ( $categories ) { |
|
477 | + foreach ( $categories as $category ) { |
|
478 | 478 | $output_categories[] = (object) array( |
479 | 479 | 'label' => $category['name'], |
480 | 480 | 'value' => $category['id'], |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | |
489 | 489 | public function register_meta() |
490 | 490 | { |
491 | - if (!function_exists('register_post_meta')) { |
|
491 | + if ( ! function_exists( 'register_post_meta' ) ) { |
|
492 | 492 | return; |
493 | 493 | } |
494 | 494 | |
@@ -529,81 +529,81 @@ discard block |
||
529 | 529 | ); |
530 | 530 | } |
531 | 531 | |
532 | - public function save_custom_fields($current_post_id) |
|
532 | + public function save_custom_fields( $current_post_id ) |
|
533 | 533 | { |
534 | - if (!isset($_POST['monsterinsights_metabox_nonce']) || !wp_verify_nonce($_POST['monsterinsights_metabox_nonce'], 'monsterinsights_metabox')) { |
|
534 | + if ( ! isset( $_POST['monsterinsights_metabox_nonce'] ) || ! wp_verify_nonce( $_POST['monsterinsights_metabox_nonce'], 'monsterinsights_metabox' ) ) { |
|
535 | 535 | return; |
536 | 536 | } |
537 | 537 | |
538 | - if ('monsterinsights_note' === get_post_type($current_post_id) || 'publish' !== get_post_status($current_post_id)) { |
|
538 | + if ( 'monsterinsights_note' === get_post_type( $current_post_id ) || 'publish' !== get_post_status( $current_post_id ) ) { |
|
539 | 539 | return; |
540 | 540 | } |
541 | 541 | |
542 | - $active = intval(isset($_POST['_monsterinsights_sitenote_active']) ? $_POST['_monsterinsights_sitenote_active'] : 0); |
|
543 | - update_post_meta($current_post_id, '_monsterinsights_sitenote_active', $active); |
|
542 | + $active = intval( isset( $_POST['_monsterinsights_sitenote_active'] ) ? $_POST['_monsterinsights_sitenote_active'] : 0 ); |
|
543 | + update_post_meta( $current_post_id, '_monsterinsights_sitenote_active', $active ); |
|
544 | 544 | |
545 | - if (!$active) { |
|
546 | - delete_post_meta($current_post_id, '_monsterinsights_sitenote_note'); |
|
547 | - delete_post_meta($current_post_id, '_monsterinsights_sitenote_category'); |
|
548 | - delete_post_meta($current_post_id, '_monsterinsights_sitenote_id'); |
|
545 | + if ( ! $active ) { |
|
546 | + delete_post_meta( $current_post_id, '_monsterinsights_sitenote_note' ); |
|
547 | + delete_post_meta( $current_post_id, '_monsterinsights_sitenote_category' ); |
|
548 | + delete_post_meta( $current_post_id, '_monsterinsights_sitenote_id' ); |
|
549 | 549 | return; |
550 | 550 | } |
551 | 551 | |
552 | - $note = isset($_POST['_monsterinsights_sitenote_note']) ? esc_html($_POST['_monsterinsights_sitenote_note']) : ''; |
|
553 | - update_post_meta($current_post_id, '_monsterinsights_sitenote_note', $note); |
|
552 | + $note = isset( $_POST['_monsterinsights_sitenote_note'] ) ? esc_html( $_POST['_monsterinsights_sitenote_note'] ) : ''; |
|
553 | + update_post_meta( $current_post_id, '_monsterinsights_sitenote_note', $note ); |
|
554 | 554 | |
555 | - $category = isset($_POST['_monsterinsights_sitenote_category']) ? intval($_POST['_monsterinsights_sitenote_category']) : 0; |
|
556 | - if ($category) { |
|
557 | - update_post_meta($current_post_id, '_monsterinsights_sitenote_category', $category); |
|
555 | + $category = isset( $_POST['_monsterinsights_sitenote_category'] ) ? intval( $_POST['_monsterinsights_sitenote_category'] ) : 0; |
|
556 | + if ( $category ) { |
|
557 | + update_post_meta( $current_post_id, '_monsterinsights_sitenote_category', $category ); |
|
558 | 558 | } |
559 | 559 | } |
560 | 560 | |
561 | - public function create_note_with_post($post_ID) |
|
561 | + public function create_note_with_post( $post_ID ) |
|
562 | 562 | { |
563 | - if ('monsterinsights_note' === get_post_type($post_ID) || 'publish' !== get_post_status($post_ID)) { |
|
563 | + if ( 'monsterinsights_note' === get_post_type( $post_ID ) || 'publish' !== get_post_status( $post_ID ) ) { |
|
564 | 564 | return; |
565 | 565 | } |
566 | 566 | |
567 | - $active = get_post_meta($post_ID, '_monsterinsights_sitenote_active', true); |
|
567 | + $active = get_post_meta( $post_ID, '_monsterinsights_sitenote_active', true ); |
|
568 | 568 | |
569 | - if (!$active) { |
|
570 | - delete_post_meta($post_ID, '_monsterinsights_sitenote_note'); |
|
571 | - delete_post_meta($post_ID, '_monsterinsights_sitenote_category'); |
|
572 | - delete_post_meta($post_ID, '_monsterinsights_sitenote_id'); |
|
569 | + if ( ! $active ) { |
|
570 | + delete_post_meta( $post_ID, '_monsterinsights_sitenote_note' ); |
|
571 | + delete_post_meta( $post_ID, '_monsterinsights_sitenote_category' ); |
|
572 | + delete_post_meta( $post_ID, '_monsterinsights_sitenote_id' ); |
|
573 | 573 | return; |
574 | 574 | } |
575 | 575 | |
576 | - $note = get_post_meta($post_ID, '_monsterinsights_sitenote_note', true); |
|
576 | + $note = get_post_meta( $post_ID, '_monsterinsights_sitenote_note', true ); |
|
577 | 577 | |
578 | - $category = get_post_meta($post_ID, '_monsterinsights_sitenote_category', true); |
|
578 | + $category = get_post_meta( $post_ID, '_monsterinsights_sitenote_category', true ); |
|
579 | 579 | |
580 | - $note_id = get_post_meta($post_ID, '_monsterinsights_sitenote_id', true); |
|
580 | + $note_id = get_post_meta( $post_ID, '_monsterinsights_sitenote_id', true ); |
|
581 | 581 | |
582 | 582 | //create the new note |
583 | 583 | $note_details = array( |
584 | 584 | 'note' => $note, |
585 | - 'category' => intval($category), |
|
586 | - 'date' => wp_date('Y-m-d'), |
|
585 | + 'category' => intval( $category ), |
|
586 | + 'date' => wp_date( 'Y-m-d' ), |
|
587 | 587 | 'medias' => [], |
588 | 588 | 'important' => false, |
589 | 589 | ); |
590 | 590 | |
591 | - if (!empty($note_id)) { |
|
591 | + if ( ! empty( $note_id ) ) { |
|
592 | 592 | // Update Site Note. |
593 | 593 | $note_details['id'] = $note_id; |
594 | 594 | } |
595 | 595 | |
596 | - $created_note_id = $this->db->create($note_details); |
|
597 | - if (is_wp_error($created_note_id) || $note_id === $created_note_id) { |
|
596 | + $created_note_id = $this->db->create( $note_details ); |
|
597 | + if ( is_wp_error( $created_note_id ) || $note_id === $created_note_id ) { |
|
598 | 598 | return; |
599 | 599 | } |
600 | 600 | |
601 | - update_post_meta($post_ID, '_monsterinsights_sitenote_id', $created_note_id); |
|
601 | + update_post_meta( $post_ID, '_monsterinsights_sitenote_id', $created_note_id ); |
|
602 | 602 | } |
603 | 603 | |
604 | 604 | public function admin_scripts() |
605 | 605 | { |
606 | - if (!function_exists('get_current_screen')) { |
|
606 | + if ( ! function_exists( 'get_current_screen' ) ) { |
|
607 | 607 | return; |
608 | 608 | } |
609 | 609 | |
@@ -611,16 +611,16 @@ discard block |
||
611 | 611 | $screen = get_current_screen(); |
612 | 612 | |
613 | 613 | // Bail if we're not on a MonsterInsights screen. |
614 | - if (empty($screen->id) || strpos($screen->id, 'monsterinsights') === false) { |
|
614 | + if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) === false ) { |
|
615 | 615 | return; |
616 | 616 | } |
617 | 617 | |
618 | 618 | wp_enqueue_media(); |
619 | 619 | } |
620 | 620 | |
621 | - public function prepare_data_overview_chart($data) |
|
621 | + public function prepare_data_overview_chart( $data ) |
|
622 | 622 | { |
623 | - if (!isset($data['data']['overviewgraph'])) { |
|
623 | + if ( ! isset( $data['data']['overviewgraph'] ) ) { |
|
624 | 624 | return $data; |
625 | 625 | } |
626 | 626 | |
@@ -633,18 +633,18 @@ discard block |
||
633 | 633 | ), |
634 | 634 | ), |
635 | 635 | ); |
636 | - $notes = $this->prepare_notes($params); |
|
636 | + $notes = $this->prepare_notes( $params ); |
|
637 | 637 | |
638 | 638 | $data['data']['overviewgraph']['notes'] = array(); |
639 | 639 | |
640 | - foreach ($notes['items'] as $note) { |
|
641 | - $date_index = date('j M', strtotime($note['note_date'], current_time('U'))); |
|
642 | - if (!isset($data['data']['overviewgraph']['notes'][$date_index])) { |
|
640 | + foreach ( $notes['items'] as $note ) { |
|
641 | + $date_index = date( 'j M', strtotime( $note['note_date'], current_time( 'U' ) ) ); |
|
642 | + if ( ! isset( $data['data']['overviewgraph']['notes'][$date_index] ) ) { |
|
643 | 643 | $data['data']['overviewgraph']['notes'][$date_index] = array(); |
644 | 644 | } |
645 | 645 | $data['data']['overviewgraph']['notes'][$date_index][] = array( |
646 | 646 | 'title' => $note['note_title'], |
647 | - 'color' => (isset($note['category']) && isset($note['category']['background_color'])) ? str_replace('#', '', $note['category']['background_color']) : null, |
|
647 | + 'color' => ( isset( $note['category'] ) && isset( $note['category']['background_color'] ) ) ? str_replace( '#', '', $note['category']['background_color'] ) : null, |
|
648 | 648 | 'important' => $note['important'], |
649 | 649 | ); |
650 | 650 | } |
@@ -652,11 +652,11 @@ discard block |
||
652 | 652 | return $data; |
653 | 653 | } |
654 | 654 | |
655 | - public function add_metabox_contents($skipped, $post) |
|
655 | + public function add_metabox_contents( $skipped, $post ) |
|
656 | 656 | { |
657 | - $sitenote_active = get_post_meta($post->ID, '_monsterinsights_sitenote_active', true); |
|
658 | - $sitenote_note = get_post_meta($post->ID, '_monsterinsights_sitenote_note', true); |
|
659 | - $sitenote_category = get_post_meta($post->ID, '_monsterinsights_sitenote_category', true); |
|
657 | + $sitenote_active = get_post_meta( $post->ID, '_monsterinsights_sitenote_active', true ); |
|
658 | + $sitenote_note = get_post_meta( $post->ID, '_monsterinsights_sitenote_note', true ); |
|
659 | + $sitenote_category = get_post_meta( $post->ID, '_monsterinsights_sitenote_category', true ); |
|
660 | 660 | |
661 | 661 | $args = array( |
662 | 662 | 'per_page' => 0, |
@@ -665,30 +665,30 @@ discard block |
||
665 | 665 | 'order' => 'asc', |
666 | 666 | ); |
667 | 667 | |
668 | - $categories = $this->db->get_categories($args); |
|
668 | + $categories = $this->db->get_categories( $args ); |
|
669 | 669 | |
670 | 670 | ?> |
671 | 671 | <div class="monsterinsights-metabox" id="monsterinsights-metabox-site-notes"> |
672 | 672 | <div class="monsterinsights-metabox-input monsterinsights-metabox-input-checkbox"> |
673 | 673 | <label class=""> |
674 | - <input type="checkbox" name="_monsterinsights_sitenote_active" value="1" <?php checked($sitenote_active); ?>> |
|
675 | - <span class="monsterinsights-metabox-input-checkbox-label"><?php _e('Add a Site Note', 'google-analytics-for-wordpress'); ?></span> |
|
674 | + <input type="checkbox" name="_monsterinsights_sitenote_active" value="1" <?php checked( $sitenote_active ); ?>> |
|
675 | + <span class="monsterinsights-metabox-input-checkbox-label"><?php _e( 'Add a Site Note', 'google-analytics-for-wordpress' ); ?></span> |
|
676 | 676 | </label> |
677 | 677 | </div> |
678 | 678 | |
679 | - <div id="site-notes-active-container" class="<?php echo (!$sitenote_active ? 'hidden' : ''); ?>"> |
|
679 | + <div id="site-notes-active-container" class="<?php echo ( ! $sitenote_active ? 'hidden' : '' ); ?>"> |
|
680 | 680 | <div class="monsterinsights-metabox-input monsterinsights-metabox-textarea"> |
681 | - <textarea name="_monsterinsights_sitenote_note" rows="3"><?php echo esc_textarea($sitenote_note); ?></textarea> |
|
681 | + <textarea name="_monsterinsights_sitenote_note" rows="3"><?php echo esc_textarea( $sitenote_note ); ?></textarea> |
|
682 | 682 | </div> |
683 | 683 | |
684 | 684 | <div class="monsterinsights-metabox-input monsterinsights-metabox-select"> |
685 | 685 | <label> |
686 | - <?php _e('Category', 'google-analytics-for-wordpress'); ?> |
|
686 | + <?php _e( 'Category', 'google-analytics-for-wordpress' ); ?> |
|
687 | 687 | <select name="_monsterinsights_sitenote_category"> |
688 | - <?php if (!empty($categories)) { |
|
689 | - foreach ($categories as $category) { |
|
688 | + <?php if ( ! empty( $categories ) ) { |
|
689 | + foreach ( $categories as $category ) { |
|
690 | 690 | ?> |
691 | - <option <?php selected($sitenote_category, $category['id']); ?> value="<?php echo esc_attr($category['id']); ?>"><?php echo esc_html($category['name']); ?></option> |
|
691 | + <option <?php selected( $sitenote_category, $category['id'] ); ?> value="<?php echo esc_attr( $category['id'] ); ?>"><?php echo esc_html( $category['name'] ); ?></option> |
|
692 | 692 | <?php |
693 | 693 | } |
694 | 694 | } ?> |
@@ -703,11 +703,11 @@ discard block |
||
703 | 703 | |
704 | 704 | public function load_metabox_assets() |
705 | 705 | { |
706 | - wp_register_style('monsterinsights-admin-metabox-sitenotes-style', plugins_url('assets/css/admin-metabox-sitenotes.css', MONSTERINSIGHTS_PLUGIN_FILE), array(), monsterinsights_get_asset_version()); |
|
707 | - wp_enqueue_style('monsterinsights-admin-metabox-sitenotes-style'); |
|
706 | + wp_register_style( 'monsterinsights-admin-metabox-sitenotes-style', plugins_url( 'assets/css/admin-metabox-sitenotes.css', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version() ); |
|
707 | + wp_enqueue_style( 'monsterinsights-admin-metabox-sitenotes-style' ); |
|
708 | 708 | |
709 | - wp_register_script('monsterinsights-admin-metabox-sitenotes-script', plugins_url('assets/js/admin-metabox-sitenotes.js', MONSTERINSIGHTS_PLUGIN_FILE), array('jquery'), monsterinsights_get_asset_version()); |
|
710 | - wp_enqueue_script('monsterinsights-admin-metabox-sitenotes-script'); |
|
709 | + wp_register_script( 'monsterinsights-admin-metabox-sitenotes-script', plugins_url( 'assets/js/admin-metabox-sitenotes.js', MONSTERINSIGHTS_PLUGIN_FILE ), array( 'jquery' ), monsterinsights_get_asset_version() ); |
|
710 | + wp_enqueue_script( 'monsterinsights-admin-metabox-sitenotes-script' ); |
|
711 | 711 | } |
712 | 712 | |
713 | 713 | /** |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | } |
727 | 727 | |
728 | 728 | $params = array( |
729 | - 'per_page' => - 1, |
|
729 | + 'per_page' => -1, |
|
730 | 730 | 'filter' => array( |
731 | 731 | 'date_range' => array( |
732 | 732 | 'start' => $start_date, |
@@ -742,11 +742,11 @@ discard block |
||
742 | 742 | foreach ( $notes['items'] as $note ) { |
743 | 743 | $date_index = date( 'j M', strtotime( $note['note_date'], current_time( 'U' ) ) ); |
744 | 744 | |
745 | - if ( ! isset( $prepared_notes[ $date_index ] ) ) { |
|
746 | - $prepared_notes[ $date_index ] = array(); |
|
745 | + if ( ! isset( $prepared_notes[$date_index] ) ) { |
|
746 | + $prepared_notes[$date_index] = array(); |
|
747 | 747 | } |
748 | 748 | |
749 | - $prepared_notes[ $date_index ][] = array( |
|
749 | + $prepared_notes[$date_index][] = array( |
|
750 | 750 | 'title' => $note['note_title'], |
751 | 751 | 'color' => ( isset( $note['category'] ) && isset( $note['category']['background_color'] ) ) ? str_replace( '#', '', $note['category']['background_color'] ) : null, |
752 | 752 | 'important' => $note['important'], |
@@ -1,7 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -class MonsterInsights_SiteNotes_Controller |
|
4 | -{ |
|
3 | +class MonsterInsights_SiteNotes_Controller { |
|
5 | 4 | |
6 | 5 | public static $instance; |
7 | 6 | |
@@ -13,28 +12,24 @@ discard block |
||
13 | 12 | /** |
14 | 13 | * @return self |
15 | 14 | */ |
16 | - public static function get_instance() |
|
17 | - { |
|
15 | + public static function get_instance() { |
|
18 | 16 | if (!isset(self::$instance) && !(self::$instance instanceof MonsterInsights_SiteNotes_Controller)) { |
19 | 17 | self::$instance = new MonsterInsights_SiteNotes_Controller(); |
20 | 18 | } |
21 | 19 | return self::$instance; |
22 | 20 | } |
23 | 21 | |
24 | - public function run() |
|
25 | - { |
|
22 | + public function run() { |
|
26 | 23 | $this->load_dependencies(); |
27 | 24 | $this->add_hooks(); |
28 | 25 | } |
29 | 26 | |
30 | - public function load_dependencies() |
|
31 | - { |
|
27 | + public function load_dependencies() { |
|
32 | 28 | require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/site-notes/Database.php'; |
33 | 29 | $this->db = new MonsterInsights_Site_Notes_DB_Base(); |
34 | 30 | } |
35 | 31 | |
36 | - public function add_hooks() |
|
37 | - { |
|
32 | + public function add_hooks() { |
|
38 | 33 | add_action('init', array($this->db, 'install')); |
39 | 34 | add_action('wp_ajax_monsterinsights_vue_get_notes', array($this, 'get_notes')); |
40 | 35 | add_action('wp_ajax_monsterinsights_vue_get_note', array($this, 'get_note')); |
@@ -66,8 +61,7 @@ discard block |
||
66 | 61 | add_action('admin_enqueue_scripts', array($this, 'load_metabox_assets')); |
67 | 62 | } |
68 | 63 | |
69 | - private function prepare_notes($params) |
|
70 | - { |
|
64 | + private function prepare_notes($params) { |
|
71 | 65 | $args = wp_parse_args($params, array( |
72 | 66 | 'per_page' => 10, |
73 | 67 | 'page' => 1, |
@@ -105,8 +99,7 @@ discard block |
||
105 | 99 | return $this->db->get_items($args); |
106 | 100 | } |
107 | 101 | |
108 | - public function get_notes() |
|
109 | - { |
|
102 | + public function get_notes() { |
|
110 | 103 | check_ajax_referer('mi-admin-nonce', 'nonce'); |
111 | 104 | |
112 | 105 | $params = !empty($_POST['params']) ? json_decode(html_entity_decode(stripslashes($_POST['params'])), true) : []; |
@@ -138,8 +131,7 @@ discard block |
||
138 | 131 | wp_send_json($output); |
139 | 132 | } |
140 | 133 | |
141 | - public function get_note() |
|
142 | - { |
|
134 | + public function get_note() { |
|
143 | 135 | check_ajax_referer('mi-admin-nonce', 'nonce'); |
144 | 136 | |
145 | 137 | $id = !empty($_POST['id']) ? intval($_POST['id']) : null; |
@@ -157,8 +149,7 @@ discard block |
||
157 | 149 | wp_send_json($item); |
158 | 150 | } |
159 | 151 | |
160 | - public function get_categories() |
|
161 | - { |
|
152 | + public function get_categories() { |
|
162 | 153 | check_ajax_referer('mi-admin-nonce', 'nonce'); |
163 | 154 | |
164 | 155 | $params = !empty($_POST['params']) ? json_decode(html_entity_decode(stripslashes($_POST['params'])), true) : []; |
@@ -191,8 +182,7 @@ discard block |
||
191 | 182 | ); |
192 | 183 | } |
193 | 184 | |
194 | - public function save_note() |
|
195 | - { |
|
185 | + public function save_note() { |
|
196 | 186 | check_ajax_referer('mi-admin-nonce', 'nonce'); |
197 | 187 | |
198 | 188 | $note = !empty($_POST['note']) ? json_decode(html_entity_decode(stripslashes($_POST['note']))) : []; |
@@ -230,8 +220,7 @@ discard block |
||
230 | 220 | ); |
231 | 221 | } |
232 | 222 | |
233 | - public function save_category() |
|
234 | - { |
|
223 | + public function save_category() { |
|
235 | 224 | check_ajax_referer('mi-admin-nonce', 'nonce'); |
236 | 225 | |
237 | 226 | $category = !empty($_POST['category']) ? json_decode(html_entity_decode(stripslashes($_POST['category']))) : []; |
@@ -278,8 +267,7 @@ discard block |
||
278 | 267 | ); |
279 | 268 | } |
280 | 269 | |
281 | - public function change_restore_note_status($new_status, $post_id, $previous_status) |
|
282 | - { |
|
270 | + public function change_restore_note_status($new_status, $post_id, $previous_status) { |
|
283 | 271 | if ('monsterinsights_note' !== get_post_type($post_id)) { |
284 | 272 | return $new_status; |
285 | 273 | } |
@@ -287,8 +275,7 @@ discard block |
||
287 | 275 | return $previous_status; |
288 | 276 | } |
289 | 277 | |
290 | - public function trash_notes() |
|
291 | - { |
|
278 | + public function trash_notes() { |
|
292 | 279 | check_ajax_referer('mi-admin-nonce', 'nonce'); |
293 | 280 | |
294 | 281 | $ids = !empty($_POST['ids']) ? json_decode(html_entity_decode(stripslashes($_POST['ids']))) : []; |
@@ -314,8 +301,7 @@ discard block |
||
314 | 301 | ); |
315 | 302 | } |
316 | 303 | |
317 | - public function restore_notes() |
|
318 | - { |
|
304 | + public function restore_notes() { |
|
319 | 305 | check_ajax_referer('mi-admin-nonce', 'nonce'); |
320 | 306 | |
321 | 307 | $ids = !empty($_POST['ids']) ? json_decode(html_entity_decode(stripslashes($_POST['ids']))) : []; |
@@ -341,8 +327,7 @@ discard block |
||
341 | 327 | ); |
342 | 328 | } |
343 | 329 | |
344 | - public function delete_notes() |
|
345 | - { |
|
330 | + public function delete_notes() { |
|
346 | 331 | check_ajax_referer('mi-admin-nonce', 'nonce'); |
347 | 332 | |
348 | 333 | $ids = !empty($_POST['ids']) ? json_decode(html_entity_decode(stripslashes($_POST['ids']))) : []; |
@@ -368,8 +353,7 @@ discard block |
||
368 | 353 | ); |
369 | 354 | } |
370 | 355 | |
371 | - public function delete_categories() |
|
372 | - { |
|
356 | + public function delete_categories() { |
|
373 | 357 | check_ajax_referer('mi-admin-nonce', 'nonce'); |
374 | 358 | |
375 | 359 | $ids = !empty($_POST['ids']) ? json_decode(html_entity_decode(stripslashes($_POST['ids']))) : []; |
@@ -395,8 +379,7 @@ discard block |
||
395 | 379 | ); |
396 | 380 | } |
397 | 381 | |
398 | - public function export_notes() |
|
399 | - { |
|
382 | + public function export_notes() { |
|
400 | 383 | if (!isset($_POST['monsterinsights_action']) || empty($_POST['monsterinsights_action'])) { |
401 | 384 | return; |
402 | 385 | } |
@@ -461,8 +444,7 @@ discard block |
||
461 | 444 | exit; |
462 | 445 | } |
463 | 446 | |
464 | - public function add_categories_to_editor($vars) |
|
465 | - { |
|
447 | + public function add_categories_to_editor($vars) { |
|
466 | 448 | $args = array( |
467 | 449 | 'per_page' => 0, |
468 | 450 | 'page' => 1, |
@@ -486,8 +468,7 @@ discard block |
||
486 | 468 | return $vars; |
487 | 469 | } |
488 | 470 | |
489 | - public function register_meta() |
|
490 | - { |
|
471 | + public function register_meta() { |
|
491 | 472 | if (!function_exists('register_post_meta')) { |
492 | 473 | return; |
493 | 474 | } |
@@ -529,8 +510,7 @@ discard block |
||
529 | 510 | ); |
530 | 511 | } |
531 | 512 | |
532 | - public function save_custom_fields($current_post_id) |
|
533 | - { |
|
513 | + public function save_custom_fields($current_post_id) { |
|
534 | 514 | if (!isset($_POST['monsterinsights_metabox_nonce']) || !wp_verify_nonce($_POST['monsterinsights_metabox_nonce'], 'monsterinsights_metabox')) { |
535 | 515 | return; |
536 | 516 | } |
@@ -558,8 +538,7 @@ discard block |
||
558 | 538 | } |
559 | 539 | } |
560 | 540 | |
561 | - public function create_note_with_post($post_ID) |
|
562 | - { |
|
541 | + public function create_note_with_post($post_ID) { |
|
563 | 542 | if ('monsterinsights_note' === get_post_type($post_ID) || 'publish' !== get_post_status($post_ID)) { |
564 | 543 | return; |
565 | 544 | } |
@@ -601,8 +580,7 @@ discard block |
||
601 | 580 | update_post_meta($post_ID, '_monsterinsights_sitenote_id', $created_note_id); |
602 | 581 | } |
603 | 582 | |
604 | - public function admin_scripts() |
|
605 | - { |
|
583 | + public function admin_scripts() { |
|
606 | 584 | if (!function_exists('get_current_screen')) { |
607 | 585 | return; |
608 | 586 | } |
@@ -618,8 +596,7 @@ discard block |
||
618 | 596 | wp_enqueue_media(); |
619 | 597 | } |
620 | 598 | |
621 | - public function prepare_data_overview_chart($data) |
|
622 | - { |
|
599 | + public function prepare_data_overview_chart($data) { |
|
623 | 600 | if (!isset($data['data']['overviewgraph'])) { |
624 | 601 | return $data; |
625 | 602 | } |
@@ -652,8 +629,7 @@ discard block |
||
652 | 629 | return $data; |
653 | 630 | } |
654 | 631 | |
655 | - public function add_metabox_contents($skipped, $post) |
|
656 | - { |
|
632 | + public function add_metabox_contents($skipped, $post) { |
|
657 | 633 | $sitenote_active = get_post_meta($post->ID, '_monsterinsights_sitenote_active', true); |
658 | 634 | $sitenote_note = get_post_meta($post->ID, '_monsterinsights_sitenote_note', true); |
659 | 635 | $sitenote_category = get_post_meta($post->ID, '_monsterinsights_sitenote_category', true); |
@@ -701,8 +677,7 @@ discard block |
||
701 | 677 | <?php |
702 | 678 | } |
703 | 679 | |
704 | - public function load_metabox_assets() |
|
705 | - { |
|
680 | + public function load_metabox_assets() { |
|
706 | 681 | wp_register_style('monsterinsights-admin-metabox-sitenotes-style', plugins_url('assets/css/admin-metabox-sitenotes.css', MONSTERINSIGHTS_PLUGIN_FILE), array(), monsterinsights_get_asset_version()); |
707 | 682 | wp_enqueue_style('monsterinsights-admin-metabox-sitenotes-style'); |
708 | 683 |
@@ -27,10 +27,10 @@ discard block |
||
27 | 27 | 'query_var' => true, |
28 | 28 | 'capability_type' => 'post', |
29 | 29 | 'has_archive' => false, |
30 | - 'supports' => array('title', 'author', 'custom-fields') |
|
30 | + 'supports' => array( 'title', 'author', 'custom-fields' ) |
|
31 | 31 | ); |
32 | 32 | |
33 | - register_post_type('monsterinsights_note', $args); |
|
33 | + register_post_type( 'monsterinsights_note', $args ); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | private function create_taxonomy() |
@@ -42,22 +42,22 @@ discard block |
||
42 | 42 | 'public' => false, |
43 | 43 | ); |
44 | 44 | |
45 | - register_taxonomy('monsterinsights_note_category', array('monsterinsights_note'), $args); |
|
45 | + register_taxonomy( 'monsterinsights_note_category', array( 'monsterinsights_note' ), $args ); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | public function insert_default_categories() |
49 | 49 | { |
50 | - if (get_option('monsterinsights_sitenotes_installed')) { |
|
50 | + if ( get_option( 'monsterinsights_sitenotes_installed' ) ) { |
|
51 | 51 | return; |
52 | 52 | } |
53 | 53 | |
54 | 54 | $categories = array( |
55 | - __('Website Updates', 'google-analytics-for-wordpress'), |
|
56 | - __('Blog Post', 'google-analytics-for-wordpress'), |
|
57 | - __('Promotion', 'google-analytics-for-wordpress'), |
|
55 | + __( 'Website Updates', 'google-analytics-for-wordpress' ), |
|
56 | + __( 'Blog Post', 'google-analytics-for-wordpress' ), |
|
57 | + __( 'Promotion', 'google-analytics-for-wordpress' ), |
|
58 | 58 | ); |
59 | 59 | |
60 | - foreach ($categories as $category) { |
|
60 | + foreach ( $categories as $category ) { |
|
61 | 61 | $this->create_category( |
62 | 62 | array( |
63 | 63 | 'name' => $category, |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | ); |
66 | 66 | } |
67 | 67 | |
68 | - update_option('monsterinsights_sitenotes_installed', time()); |
|
68 | + update_option( 'monsterinsights_sitenotes_installed', time() ); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | public function install() |
@@ -74,10 +74,10 @@ discard block |
||
74 | 74 | $this->create_taxonomy(); |
75 | 75 | } |
76 | 76 | |
77 | - private function get_category_name($id) |
|
77 | + private function get_category_name( $id ) |
|
78 | 78 | { |
79 | - $term = get_term($id, 'monsterinsights_note_category'); |
|
80 | - if (is_wp_error($term)) { |
|
79 | + $term = get_term( $id, 'monsterinsights_note_category' ); |
|
80 | + if ( is_wp_error( $term ) ) { |
|
81 | 81 | return false; |
82 | 82 | } |
83 | 83 | |
@@ -93,43 +93,43 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @return int|WP_Error |
95 | 95 | */ |
96 | - public function create($data) |
|
96 | + public function create( $data ) |
|
97 | 97 | { |
98 | - if (empty($data['note'])) { |
|
99 | - return new WP_Error(400, __('Your Site Note Cannot be Empty', 'google-analytics-for-wordpress')); |
|
98 | + if ( empty( $data['note'] ) ) { |
|
99 | + return new WP_Error( 400, __( 'Your Site Note Cannot be Empty', 'google-analytics-for-wordpress' ) ); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | $note_post = array( |
103 | - 'ID' => isset($data['id']) ? $data['id'] : null, |
|
104 | - 'post_title' => sanitize_text_field($data['note']), |
|
103 | + 'ID' => isset( $data['id'] ) ? $data['id'] : null, |
|
104 | + 'post_title' => sanitize_text_field( $data['note'] ), |
|
105 | 105 | 'post_status' => 'publish', |
106 | 106 | 'post_author' => isset( $data['author_id'] ) ? intval( $data['author_id'] ) : get_current_user_id(), |
107 | - 'post_date' => !empty($data['date']) ? $data['date'] : current_datetime()->format('Y-m-d'), |
|
107 | + 'post_date' => ! empty( $data['date'] ) ? $data['date'] : current_datetime()->format( 'Y-m-d' ), |
|
108 | 108 | 'post_type' => 'monsterinsights_note', |
109 | 109 | ); |
110 | - $post_id = wp_insert_post($note_post, true, false); |
|
110 | + $post_id = wp_insert_post( $note_post, true, false ); |
|
111 | 111 | |
112 | - if (is_wp_error($post_id)) { |
|
112 | + if ( is_wp_error( $post_id ) ) { |
|
113 | 113 | return $post_id; |
114 | 114 | } |
115 | 115 | |
116 | 116 | // Attach the note to the category. |
117 | - if (!empty($data['category'])) { |
|
118 | - if ($category_name = $this->get_category_name($data['category'])) { |
|
119 | - wp_set_object_terms($post_id, $data['category'], 'monsterinsights_note_category'); |
|
120 | - update_post_meta($post_id, '_category', $category_name); |
|
117 | + if ( ! empty( $data['category'] ) ) { |
|
118 | + if ( $category_name = $this->get_category_name( $data['category'] ) ) { |
|
119 | + wp_set_object_terms( $post_id, $data['category'], 'monsterinsights_note_category' ); |
|
120 | + update_post_meta( $post_id, '_category', $category_name ); |
|
121 | 121 | } |
122 | 122 | } else { |
123 | - wp_set_object_terms($post_id, array(), 'monsterinsights_note_category'); |
|
124 | - update_post_meta($post_id, '_category', ''); |
|
123 | + wp_set_object_terms( $post_id, array(), 'monsterinsights_note_category' ); |
|
124 | + update_post_meta( $post_id, '_category', '' ); |
|
125 | 125 | } |
126 | 126 | |
127 | - if (!empty($data['medias'])) { |
|
128 | - update_post_meta($post_id, 'medias', $data['medias']); |
|
127 | + if ( ! empty( $data['medias'] ) ) { |
|
128 | + update_post_meta( $post_id, 'medias', $data['medias'] ); |
|
129 | 129 | } |
130 | 130 | |
131 | - if (isset($data['important'])) { |
|
132 | - update_post_meta($post_id, 'important', $data['important']); |
|
131 | + if ( isset( $data['important'] ) ) { |
|
132 | + update_post_meta( $post_id, 'important', $data['important'] ); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | return $post_id; |
@@ -144,20 +144,20 @@ discard block |
||
144 | 144 | * |
145 | 145 | * @return int|WP_Error |
146 | 146 | */ |
147 | - public function create_category($data) |
|
147 | + public function create_category( $data ) |
|
148 | 148 | { |
149 | - if (isset($data['id'])) { |
|
150 | - $created_term = wp_update_term($data['id'], 'monsterinsights_note_category', array('name' => $data['name'])); |
|
149 | + if ( isset( $data['id'] ) ) { |
|
150 | + $created_term = wp_update_term( $data['id'], 'monsterinsights_note_category', array( 'name' => $data['name'] ) ); |
|
151 | 151 | } else { |
152 | - $created_term = wp_insert_term($data['name'], 'monsterinsights_note_category'); |
|
152 | + $created_term = wp_insert_term( $data['name'], 'monsterinsights_note_category' ); |
|
153 | 153 | } |
154 | 154 | |
155 | - if (is_wp_error($created_term)) { |
|
155 | + if ( is_wp_error( $created_term ) ) { |
|
156 | 156 | return $created_term; |
157 | 157 | } |
158 | 158 | |
159 | - if (!empty($data['background_color'])) { |
|
160 | - update_term_meta($created_term['term_id'], 'background_color', $data['background_color']); |
|
159 | + if ( ! empty( $data['background_color'] ) ) { |
|
160 | + update_term_meta( $created_term['term_id'], 'background_color', $data['background_color'] ); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | return $created_term['term_id']; |
@@ -172,23 +172,23 @@ discard block |
||
172 | 172 | * |
173 | 173 | * @return array|WP_Error |
174 | 174 | */ |
175 | - public function get($post_id) |
|
175 | + public function get( $post_id ) |
|
176 | 176 | { |
177 | - $post = get_post($post_id); |
|
177 | + $post = get_post( $post_id ); |
|
178 | 178 | |
179 | - if (!$post) { |
|
180 | - return new WP_Error(400, __('Note not found', 'google-analytics-for-wordpress')); |
|
179 | + if ( ! $post ) { |
|
180 | + return new WP_Error( 400, __( 'Note not found', 'google-analytics-for-wordpress' ) ); |
|
181 | 181 | } |
182 | 182 | |
183 | - $categories = wp_get_object_terms($post->ID, 'monsterinsights_note_category'); |
|
184 | - $post_title = get_the_title($post); |
|
183 | + $categories = wp_get_object_terms( $post->ID, 'monsterinsights_note_category' ); |
|
184 | + $post_title = get_the_title( $post ); |
|
185 | 185 | $note = array( |
186 | 186 | 'id' => $post->ID, |
187 | - 'note_title' => wp_strip_all_tags(html_entity_decode(htmlspecialchars_decode($post_title), ENT_COMPAT, 'UTF-8')), |
|
188 | - 'note_date' => get_the_date( 'Y-m-d', $post), |
|
187 | + 'note_title' => wp_strip_all_tags( html_entity_decode( htmlspecialchars_decode( $post_title ), ENT_COMPAT, 'UTF-8' ) ), |
|
188 | + 'note_date' => get_the_date( 'Y-m-d', $post ), |
|
189 | 189 | 'note_date_ymd' => get_the_date( 'Y-m-d', $post ), |
190 | - 'status' => get_post_status($post), |
|
191 | - 'important' => (int) get_post_meta($post->ID, 'important', true), |
|
190 | + 'status' => get_post_status( $post ), |
|
191 | + 'important' => (int) get_post_meta( $post->ID, 'important', true ), |
|
192 | 192 | 'medias' => array(), |
193 | 193 | 'category' => array( |
194 | 194 | 'id' => 0, |
@@ -200,15 +200,15 @@ discard block |
||
200 | 200 | && $medias = get_post_meta( $post->ID, 'medias', true ) |
201 | 201 | ) { |
202 | 202 | if ( ! empty( $medias ) ) { |
203 | - foreach ($medias as $media_id) { |
|
204 | - $attachment_url = wp_get_attachment_url($media_id); |
|
205 | - if (!$attachment_url) { |
|
203 | + foreach ( $medias as $media_id ) { |
|
204 | + $attachment_url = wp_get_attachment_url( $media_id ); |
|
205 | + if ( ! $attachment_url ) { |
|
206 | 206 | continue; |
207 | 207 | } |
208 | 208 | |
209 | 209 | $attachment_filename = basename( get_attached_file( $media_id ) ); |
210 | 210 | |
211 | - $note['medias'][ $media_id ] = [ |
|
211 | + $note['medias'][$media_id] = [ |
|
212 | 212 | 'url' => $attachment_url, |
213 | 213 | 'name' => $attachment_filename |
214 | 214 | ]; |
@@ -218,10 +218,10 @@ discard block |
||
218 | 218 | |
219 | 219 | $note['medias'] = (object) $note['medias']; |
220 | 220 | |
221 | - if ($post->post_author) { |
|
222 | - $user = get_userdata($post->post_author); |
|
221 | + if ( $post->post_author ) { |
|
222 | + $user = get_userdata( $post->post_author ); |
|
223 | 223 | |
224 | - if ($user) { |
|
224 | + if ( $user ) { |
|
225 | 225 | $note['author'] = array( |
226 | 226 | 'id' => $user->ID, |
227 | 227 | 'name' => $user->display_name, |
@@ -229,15 +229,15 @@ discard block |
||
229 | 229 | } |
230 | 230 | } |
231 | 231 | |
232 | - if ($categories) { |
|
232 | + if ( $categories ) { |
|
233 | 233 | $note['category'] = array( |
234 | 234 | 'id' => $categories[0]->term_id, |
235 | 235 | 'name' => html_entity_decode( $categories[0]->name ), |
236 | 236 | ); |
237 | 237 | |
238 | - if (monsterinsights_is_pro_version()) { |
|
239 | - $background_color = get_term_meta($categories[0]->term_id, 'background_color', true); |
|
240 | - $note['category']['background_color'] = !empty($background_color) ? $background_color : '#E9AF00'; |
|
238 | + if ( monsterinsights_is_pro_version() ) { |
|
239 | + $background_color = get_term_meta( $categories[0]->term_id, 'background_color', true ); |
|
240 | + $note['category']['background_color'] = ! empty( $background_color ) ? $background_color : '#E9AF00'; |
|
241 | 241 | } |
242 | 242 | } |
243 | 243 | |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | * |
255 | 255 | * @return array|int |
256 | 256 | */ |
257 | - public function get_items($args = array(), $count = false) |
|
257 | + public function get_items( $args = array(), $count = false ) |
|
258 | 258 | { |
259 | 259 | $query_args = array( |
260 | 260 | 'post_type' => 'monsterinsights_note', |
@@ -263,27 +263,27 @@ discard block |
||
263 | 263 | 'fields' => 'ids', |
264 | 264 | 'orderby' => $args['orderby'], |
265 | 265 | 'order' => $args['order'], |
266 | - 'post_status' => (isset($args['filter']) && !empty($args['filter']['status']) && 'all' !== $args['filter']['status']) ? $args['filter']['status'] : ['publish'], |
|
266 | + 'post_status' => ( isset( $args['filter'] ) && ! empty( $args['filter']['status'] ) && 'all' !== $args['filter']['status'] ) ? $args['filter']['status'] : ['publish'], |
|
267 | 267 | ); |
268 | 268 | |
269 | - if (isset($args['search'])) { |
|
269 | + if ( isset( $args['search'] ) ) { |
|
270 | 270 | $query_args['s'] = $args['search']; |
271 | 271 | } |
272 | 272 | |
273 | 273 | $all_notes_query_args = $query_args; |
274 | 274 | $all_notes_query_args['post_status'] = ['publish']; |
275 | 275 | |
276 | - if (isset($args['filter'])) { |
|
277 | - if (isset($args['filter']['important']) && !is_null($args['filter']['important'])) { |
|
276 | + if ( isset( $args['filter'] ) ) { |
|
277 | + if ( isset( $args['filter']['important'] ) && ! is_null( $args['filter']['important'] ) ) { |
|
278 | 278 | $query_args['meta_key'] = 'important'; |
279 | 279 | $query_args['meta_value'] = $args['filter']['important']; |
280 | 280 | } |
281 | - if (isset($args['filter']['category']) && !is_null($args['filter']['category'])) { |
|
281 | + if ( isset( $args['filter']['category'] ) && ! is_null( $args['filter']['category'] ) ) { |
|
282 | 282 | $args['category'] = $args['filter']['category']; |
283 | 283 | } |
284 | 284 | } |
285 | 285 | |
286 | - if (isset($args['filter']) && isset($args['filter']['date_range']) && !is_null($args['filter']['date_range'])) { |
|
286 | + if ( isset( $args['filter'] ) && isset( $args['filter']['date_range'] ) && ! is_null( $args['filter']['date_range'] ) ) { |
|
287 | 287 | $query_args['date_query'] = array( |
288 | 288 | 'after' => $args['filter']['date_range']['start'], |
289 | 289 | 'before' => $args['filter']['date_range']['end'], |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | ); |
297 | 297 | } |
298 | 298 | |
299 | - if (!empty($args['category'])) { |
|
299 | + if ( ! empty( $args['category'] ) ) { |
|
300 | 300 | $query_args['tax_query'] = array( |
301 | 301 | array( |
302 | 302 | 'taxonomy' => 'monsterinsights_note_category', |
@@ -306,26 +306,26 @@ discard block |
||
306 | 306 | ); |
307 | 307 | } |
308 | 308 | |
309 | - if ('category' === $query_args['orderby']) { |
|
309 | + if ( 'category' === $query_args['orderby'] ) { |
|
310 | 310 | $query_args['meta_key'] = '_category'; |
311 | 311 | $query_args['orderby'] = 'meta_value'; |
312 | 312 | } |
313 | 313 | // handle last30days |
314 | 314 | |
315 | - if (isset($query_args['date_query']) && !is_null($query_args['date_query'])) { |
|
316 | - if ($query_args['date_query']['after'] == '' && $query_args['date_query']['before'] == '') { |
|
317 | - $query_args['date_query']['before'] = wp_date('Y-m-d', strtotime('-1 day')); |
|
318 | - $query_args['date_query']['after'] = wp_date('Y-m-d', strtotime('-30 days')); |
|
319 | - $all_notes_query_args['date_query']['before'] = wp_date('Y-m-d', strtotime('-1 day')); |
|
320 | - $all_notes_query_args['date_query']['after'] = wp_date('Y-m-d', strtotime('-30 days')); |
|
315 | + if ( isset( $query_args['date_query'] ) && ! is_null( $query_args['date_query'] ) ) { |
|
316 | + if ( $query_args['date_query']['after'] == '' && $query_args['date_query']['before'] == '' ) { |
|
317 | + $query_args['date_query']['before'] = wp_date( 'Y-m-d', strtotime( '-1 day' ) ); |
|
318 | + $query_args['date_query']['after'] = wp_date( 'Y-m-d', strtotime( '-30 days' ) ); |
|
319 | + $all_notes_query_args['date_query']['before'] = wp_date( 'Y-m-d', strtotime( '-1 day' ) ); |
|
320 | + $all_notes_query_args['date_query']['after'] = wp_date( 'Y-m-d', strtotime( '-30 days' ) ); |
|
321 | 321 | } |
322 | 322 | } |
323 | 323 | |
324 | 324 | $items = array(); |
325 | - $query = new WP_Query($query_args); |
|
326 | - $all_notes_query = new WP_Query($all_notes_query_args); |
|
325 | + $query = new WP_Query( $query_args ); |
|
326 | + $all_notes_query = new WP_Query( $all_notes_query_args ); |
|
327 | 327 | $important_count = 0; |
328 | - if (!$query->have_posts()) { |
|
328 | + if ( ! $query->have_posts() ) { |
|
329 | 329 | return array( |
330 | 330 | 'items' => $items, |
331 | 331 | 'pagination' => array( |
@@ -340,10 +340,10 @@ discard block |
||
340 | 340 | ); |
341 | 341 | } |
342 | 342 | |
343 | - foreach ($query->posts as $post_id) { |
|
344 | - $post = $this->get($post_id); |
|
345 | - $is_important = get_post_meta($post_id, 'important', true); |
|
346 | - if($is_important){ |
|
343 | + foreach ( $query->posts as $post_id ) { |
|
344 | + $post = $this->get( $post_id ); |
|
345 | + $is_important = get_post_meta( $post_id, 'important', true ); |
|
346 | + if ( $is_important ) { |
|
347 | 347 | $important_count++; |
348 | 348 | } |
349 | 349 | $items[] = $post; |
@@ -362,36 +362,36 @@ discard block |
||
362 | 362 | ); |
363 | 363 | } |
364 | 364 | |
365 | - public function get_categories($args = array(), $count = false) |
|
365 | + public function get_categories( $args = array(), $count = false ) |
|
366 | 366 | { |
367 | 367 | $query_args = array( |
368 | 368 | 'taxonomy' => 'monsterinsights_note_category', |
369 | 369 | 'hide_empty' => false, |
370 | 370 | ); |
371 | 371 | |
372 | - if ($count) { |
|
373 | - return wp_count_terms($query_args); |
|
372 | + if ( $count ) { |
|
373 | + return wp_count_terms( $query_args ); |
|
374 | 374 | } |
375 | 375 | |
376 | - $query_args['offset'] = ($args['page'] - 1) * $args['per_page']; |
|
376 | + $query_args['offset'] = ( $args['page'] - 1 ) * $args['per_page']; |
|
377 | 377 | $query_args['fields'] = 'id=>name'; |
378 | 378 | $query_args['order'] = $args['order']; |
379 | 379 | $query_args['orderby'] = $args['orderby']; |
380 | 380 | |
381 | - $items = get_terms($query_args); |
|
382 | - if (!$items) { |
|
381 | + $items = get_terms( $query_args ); |
|
382 | + if ( ! $items ) { |
|
383 | 383 | return false; |
384 | 384 | } |
385 | 385 | |
386 | 386 | $categories = array(); |
387 | 387 | |
388 | - foreach ($items as $term_id => $term_name) { |
|
389 | - $background_color = get_term_meta($term_id, 'background_color', true); |
|
388 | + foreach ( $items as $term_id => $term_name ) { |
|
389 | + $background_color = get_term_meta( $term_id, 'background_color', true ); |
|
390 | 390 | |
391 | 391 | $categories[] = array( |
392 | 392 | 'id' => $term_id, |
393 | 393 | 'name' => html_entity_decode( $term_name ), |
394 | - 'background_color' => !empty($background_color) ? $background_color : '#E9AF00', |
|
394 | + 'background_color' => ! empty( $background_color ) ? $background_color : '#E9AF00', |
|
395 | 395 | ); |
396 | 396 | } |
397 | 397 | |
@@ -407,36 +407,36 @@ discard block |
||
407 | 407 | * |
408 | 408 | * @return WP_Post|false|null |
409 | 409 | */ |
410 | - public function trash_note($note_id = 0) |
|
410 | + public function trash_note( $note_id = 0 ) |
|
411 | 411 | { |
412 | 412 | if ( ! current_user_can( 'monsterinsights_save_settings' ) ) { |
413 | 413 | return; |
414 | 414 | } |
415 | 415 | |
416 | - return wp_trash_post($note_id); |
|
416 | + return wp_trash_post( $note_id ); |
|
417 | 417 | } |
418 | 418 | |
419 | - public function restore_note($note_id = 0) |
|
419 | + public function restore_note( $note_id = 0 ) |
|
420 | 420 | { |
421 | 421 | if ( ! current_user_can( 'monsterinsights_save_settings' ) ) { |
422 | 422 | return; |
423 | 423 | } |
424 | - return wp_untrash_post($note_id); |
|
424 | + return wp_untrash_post( $note_id ); |
|
425 | 425 | } |
426 | 426 | |
427 | - public function delete_note($note_id = 0) |
|
427 | + public function delete_note( $note_id = 0 ) |
|
428 | 428 | { |
429 | 429 | if ( ! current_user_can( 'monsterinsights_save_settings' ) ) { |
430 | 430 | return; |
431 | 431 | } |
432 | - return wp_delete_post($note_id, true); |
|
432 | + return wp_delete_post( $note_id, true ); |
|
433 | 433 | } |
434 | 434 | |
435 | - public function delete_category($id = 0) |
|
435 | + public function delete_category( $id = 0 ) |
|
436 | 436 | { |
437 | 437 | if ( ! current_user_can( 'monsterinsights_save_settings' ) ) { |
438 | 438 | return; |
439 | 439 | } |
440 | - return wp_delete_term($id, 'monsterinsights_note_category'); |
|
440 | + return wp_delete_term( $id, 'monsterinsights_note_category' ); |
|
441 | 441 | } |
442 | 442 | } |
@@ -14,11 +14,9 @@ discard block |
||
14 | 14 | * |
15 | 15 | * @since 1.0.0 |
16 | 16 | */ |
17 | -class MonsterInsights_Site_Notes_DB_Base |
|
18 | -{ |
|
17 | +class MonsterInsights_Site_Notes_DB_Base { |
|
19 | 18 | |
20 | - private function create_post_type() |
|
21 | - { |
|
19 | + private function create_post_type() { |
|
22 | 20 | $args = array( |
23 | 21 | 'public' => false, |
24 | 22 | 'publicly_queryable' => false, |
@@ -33,8 +31,7 @@ discard block |
||
33 | 31 | register_post_type('monsterinsights_note', $args); |
34 | 32 | } |
35 | 33 | |
36 | - private function create_taxonomy() |
|
37 | - { |
|
34 | + private function create_taxonomy() { |
|
38 | 35 | $args = array( |
39 | 36 | 'hierarchical' => false, |
40 | 37 | 'show_ui' => false, |
@@ -45,8 +42,7 @@ discard block |
||
45 | 42 | register_taxonomy('monsterinsights_note_category', array('monsterinsights_note'), $args); |
46 | 43 | } |
47 | 44 | |
48 | - public function insert_default_categories() |
|
49 | - { |
|
45 | + public function insert_default_categories() { |
|
50 | 46 | if (get_option('monsterinsights_sitenotes_installed')) { |
51 | 47 | return; |
52 | 48 | } |
@@ -68,14 +64,12 @@ discard block |
||
68 | 64 | update_option('monsterinsights_sitenotes_installed', time()); |
69 | 65 | } |
70 | 66 | |
71 | - public function install() |
|
72 | - { |
|
67 | + public function install() { |
|
73 | 68 | $this->create_post_type(); |
74 | 69 | $this->create_taxonomy(); |
75 | 70 | } |
76 | 71 | |
77 | - private function get_category_name($id) |
|
78 | - { |
|
72 | + private function get_category_name($id) { |
|
79 | 73 | $term = get_term($id, 'monsterinsights_note_category'); |
80 | 74 | if (is_wp_error($term)) { |
81 | 75 | return false; |
@@ -93,8 +87,7 @@ discard block |
||
93 | 87 | * |
94 | 88 | * @return int|WP_Error |
95 | 89 | */ |
96 | - public function create($data) |
|
97 | - { |
|
90 | + public function create($data) { |
|
98 | 91 | if (empty($data['note'])) { |
99 | 92 | return new WP_Error(400, __('Your Site Note Cannot be Empty', 'google-analytics-for-wordpress')); |
100 | 93 | } |
@@ -144,8 +137,7 @@ discard block |
||
144 | 137 | * |
145 | 138 | * @return int|WP_Error |
146 | 139 | */ |
147 | - public function create_category($data) |
|
148 | - { |
|
140 | + public function create_category($data) { |
|
149 | 141 | if (isset($data['id'])) { |
150 | 142 | $created_term = wp_update_term($data['id'], 'monsterinsights_note_category', array('name' => $data['name'])); |
151 | 143 | } else { |
@@ -172,8 +164,7 @@ discard block |
||
172 | 164 | * |
173 | 165 | * @return array|WP_Error |
174 | 166 | */ |
175 | - public function get($post_id) |
|
176 | - { |
|
167 | + public function get($post_id) { |
|
177 | 168 | $post = get_post($post_id); |
178 | 169 | |
179 | 170 | if (!$post) { |
@@ -254,8 +245,7 @@ discard block |
||
254 | 245 | * |
255 | 246 | * @return array|int |
256 | 247 | */ |
257 | - public function get_items($args = array(), $count = false) |
|
258 | - { |
|
248 | + public function get_items($args = array(), $count = false) { |
|
259 | 249 | $query_args = array( |
260 | 250 | 'post_type' => 'monsterinsights_note', |
261 | 251 | 'posts_per_page' => $args['per_page'], |
@@ -343,7 +333,7 @@ discard block |
||
343 | 333 | foreach ($query->posts as $post_id) { |
344 | 334 | $post = $this->get($post_id); |
345 | 335 | $is_important = get_post_meta($post_id, 'important', true); |
346 | - if($is_important){ |
|
336 | + if($is_important) { |
|
347 | 337 | $important_count++; |
348 | 338 | } |
349 | 339 | $items[] = $post; |
@@ -362,8 +352,7 @@ discard block |
||
362 | 352 | ); |
363 | 353 | } |
364 | 354 | |
365 | - public function get_categories($args = array(), $count = false) |
|
366 | - { |
|
355 | + public function get_categories($args = array(), $count = false) { |
|
367 | 356 | $query_args = array( |
368 | 357 | 'taxonomy' => 'monsterinsights_note_category', |
369 | 358 | 'hide_empty' => false, |
@@ -407,8 +396,7 @@ discard block |
||
407 | 396 | * |
408 | 397 | * @return WP_Post|false|null |
409 | 398 | */ |
410 | - public function trash_note($note_id = 0) |
|
411 | - { |
|
399 | + public function trash_note($note_id = 0) { |
|
412 | 400 | if ( ! current_user_can( 'monsterinsights_save_settings' ) ) { |
413 | 401 | return; |
414 | 402 | } |
@@ -416,24 +404,21 @@ discard block |
||
416 | 404 | return wp_trash_post($note_id); |
417 | 405 | } |
418 | 406 | |
419 | - public function restore_note($note_id = 0) |
|
420 | - { |
|
407 | + public function restore_note($note_id = 0) { |
|
421 | 408 | if ( ! current_user_can( 'monsterinsights_save_settings' ) ) { |
422 | 409 | return; |
423 | 410 | } |
424 | 411 | return wp_untrash_post($note_id); |
425 | 412 | } |
426 | 413 | |
427 | - public function delete_note($note_id = 0) |
|
428 | - { |
|
414 | + public function delete_note($note_id = 0) { |
|
429 | 415 | if ( ! current_user_can( 'monsterinsights_save_settings' ) ) { |
430 | 416 | return; |
431 | 417 | } |
432 | 418 | return wp_delete_post($note_id, true); |
433 | 419 | } |
434 | 420 | |
435 | - public function delete_category($id = 0) |
|
436 | - { |
|
421 | + public function delete_category($id = 0) { |
|
437 | 422 | if ( ! current_user_can( 'monsterinsights_save_settings' ) ) { |
438 | 423 | return; |
439 | 424 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $time = time(); |
92 | 92 | } |
93 | 93 | |
94 | - $this->last_run[ $notification_id ] = $time; |
|
94 | + $this->last_run[$notification_id] = $time; |
|
95 | 95 | $this->changed = true; |
96 | 96 | } |
97 | 97 | |
@@ -126,17 +126,17 @@ discard block |
||
126 | 126 | * |
127 | 127 | * @var MonsterInsights_Notification_Event $notification |
128 | 128 | */ |
129 | - if ( empty( $last_runs[ $notification->notification_id ] ) ) { |
|
129 | + if ( empty( $last_runs[$notification->notification_id] ) ) { |
|
130 | 130 | // If the notification never ran, save current time to show it after the interval. |
131 | 131 | $this->update_last_run( $notification->notification_id ); |
132 | 132 | } else { |
133 | 133 | // Has run before so let's check if enough days passed since the last run. |
134 | - $time_since = $last_runs[ $notification->notification_id ] + $notification->notification_interval * DAY_IN_SECONDS; |
|
134 | + $time_since = $last_runs[$notification->notification_id] + $notification->notification_interval * DAY_IN_SECONDS; |
|
135 | 135 | $time_now = time(); |
136 | 136 | if ( $time_since < $time_now ) { |
137 | 137 | // Interval passed since it ran so let's add this one. |
138 | 138 | |
139 | - $current_runs ++; |
|
139 | + $current_runs++; |
|
140 | 140 | $added_notification = $notification->add_notification(); |
141 | 141 | |
142 | 142 | // Update the last run date as right now. |
@@ -175,8 +175,8 @@ discard block |
||
175 | 175 | public function register_notification( $notification ) { |
176 | 176 | |
177 | 177 | $notification_id = isset( $notification->notification_id ) ? $notification->notification_id : false; |
178 | - if ( ! empty( $notification_id ) && ! isset( self::$notifications[ $notification_id ] ) ) { |
|
179 | - self::$notifications[ $notification_id ] = $notification; |
|
178 | + if ( ! empty( $notification_id ) && ! isset( self::$notifications[$notification_id] ) ) { |
|
179 | + self::$notifications[$notification_id] = $notification; |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | } |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | return; |
161 | 161 | } |
162 | 162 | |
163 | - $session_id = monsterinsights_get_browser_session_id( $this->measurement_id ); |
|
163 | + $session_id = monsterinsights_get_browser_session_id( $this->measurement_id ); |
|
164 | 164 | |
165 | 165 | $defaults = array( |
166 | 166 | 'client_id' => $this->get_client_id( $args ), |
@@ -169,17 +169,17 @@ discard block |
||
169 | 169 | |
170 | 170 | $body = $this->validate_args( $args, $defaults ); |
171 | 171 | |
172 | - foreach ( $body['events'] as $index => $event ) { |
|
172 | + foreach ( $body['events'] as $index => $event ) { |
|
173 | 173 | |
174 | - // Provide a default session id if not set already. |
|
175 | - if ( !empty( $session_id ) && empty( $body['events'][$index]['params']['session_id'] ) ) { |
|
176 | - $body['events'][$index]['params']['session_id'] = $session_id; |
|
177 | - } |
|
174 | + // Provide a default session id if not set already. |
|
175 | + if ( !empty( $session_id ) && empty( $body['events'][$index]['params']['session_id'] ) ) { |
|
176 | + $body['events'][$index]['params']['session_id'] = $session_id; |
|
177 | + } |
|
178 | 178 | |
179 | - if ( $this->is_debug ) { |
|
180 | - $body['events'][ $index ]['params']['debug_mode'] = true; |
|
181 | - } |
|
182 | - } |
|
179 | + if ( $this->is_debug ) { |
|
180 | + $body['events'][ $index ]['params']['debug_mode'] = true; |
|
181 | + } |
|
182 | + } |
|
183 | 183 | |
184 | 184 | $body = apply_filters( 'monsterinsights_mp_v4_api_call', $body ); |
185 | 185 |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | |
66 | 66 | return add_query_arg( |
67 | 67 | array( |
68 | - 'api_secret' => apply_filters('monsterinsights_get_mp_call_secret', $api_secret), |
|
68 | + 'api_secret' => apply_filters( 'monsterinsights_get_mp_call_secret', $api_secret ), |
|
69 | 69 | 'measurement_id' => $this->measurement_id, |
70 | 70 | ), |
71 | 71 | $this->get_base_url() |
@@ -90,35 +90,35 @@ discard block |
||
90 | 90 | |
91 | 91 | foreach ( $params as $key => $value ) { |
92 | 92 | if ( ! array_key_exists( $key, $schema ) || |
93 | - ( ! is_array( $value ) && gettype( $value ) === $schema[ $key ] ) |
|
93 | + ( ! is_array( $value ) && gettype( $value ) === $schema[$key] ) |
|
94 | 94 | ) { |
95 | - $sanitized_params[ $key ] = $value; |
|
95 | + $sanitized_params[$key] = $value; |
|
96 | 96 | continue; |
97 | 97 | } |
98 | 98 | |
99 | - if ( is_array( $value ) && is_array( $schema[ $key ] ) ) { |
|
100 | - $sanitized_params[ $key ] = array(); |
|
99 | + if ( is_array( $value ) && is_array( $schema[$key] ) ) { |
|
100 | + $sanitized_params[$key] = array(); |
|
101 | 101 | foreach ( $value as $item_index => $item ) { |
102 | - $sanitized_params[ $key ][ $item_index ] = $this->sanitize_event( $item, $schema[ $key ] ); |
|
102 | + $sanitized_params[$key][$item_index] = $this->sanitize_event( $item, $schema[$key] ); |
|
103 | 103 | } |
104 | 104 | continue; |
105 | 105 | } |
106 | 106 | |
107 | - switch ( $schema[ $key ] ) { |
|
107 | + switch ( $schema[$key] ) { |
|
108 | 108 | case 'string': |
109 | - $sanitized_params[ $key ] = (string) $value; |
|
109 | + $sanitized_params[$key] = (string) $value; |
|
110 | 110 | break; |
111 | 111 | |
112 | 112 | case 'double': |
113 | - $sanitized_params[ $key ] = (float) $value; |
|
113 | + $sanitized_params[$key] = (float) $value; |
|
114 | 114 | break; |
115 | 115 | |
116 | 116 | case 'integer': |
117 | - $sanitized_params[ $key ] = (int) $value; |
|
117 | + $sanitized_params[$key] = (int) $value; |
|
118 | 118 | break; |
119 | 119 | |
120 | 120 | case 'money': |
121 | - $sanitized_params[ $key ] = MonsterInsights_eCommerce_Helper::round_price( $value ); |
|
121 | + $sanitized_params[$key] = MonsterInsights_eCommerce_Helper::round_price( $value ); |
|
122 | 122 | break; |
123 | 123 | } |
124 | 124 | } |
@@ -131,9 +131,9 @@ discard block |
||
131 | 131 | |
132 | 132 | foreach ( $defaults as $key => $default ) { |
133 | 133 | if ( array_key_exists( $key, $args ) ) { |
134 | - $out[ $key ] = $args[ $key ]; |
|
134 | + $out[$key] = $args[$key]; |
|
135 | 135 | } else { |
136 | - $out[ $key ] = $default; |
|
136 | + $out[$key] = $default; |
|
137 | 137 | } |
138 | 138 | } |
139 | 139 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | $sanitized_event['params'] = $this->sanitize_event( $event['params'], $this->schema ); |
150 | 150 | } |
151 | 151 | |
152 | - $out['events'][ $event_index ] = $sanitized_event; |
|
152 | + $out['events'][$event_index] = $sanitized_event; |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | return $out; |
@@ -172,12 +172,12 @@ discard block |
||
172 | 172 | foreach ( $body['events'] as $index => $event ) { |
173 | 173 | |
174 | 174 | // Provide a default session id if not set already. |
175 | - if ( !empty( $session_id ) && empty( $body['events'][$index]['params']['session_id'] ) ) { |
|
175 | + if ( ! empty( $session_id ) && empty( $body['events'][$index]['params']['session_id'] ) ) { |
|
176 | 176 | $body['events'][$index]['params']['session_id'] = $session_id; |
177 | 177 | } |
178 | 178 | |
179 | 179 | if ( $this->is_debug ) { |
180 | - $body['events'][ $index ]['params']['debug_mode'] = true; |
|
180 | + $body['events'][$index]['params']['debug_mode'] = true; |
|
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
@@ -196,8 +196,8 @@ discard block |
||
196 | 196 | |
197 | 197 | public function collect( $args ) { |
198 | 198 | // Detect if browser request is a prefetch |
199 | - if ( ( isset( $_SERVER["HTTP_X_PURPOSE"] ) && ( 'prefetch' === strtolower( sanitize_text_field($_SERVER["HTTP_X_PURPOSE"]) ) ) ) || |
|
200 | - ( isset( $_SERVER["HTTP_X_MOZ"] ) && ( 'prefetch' === strtolower( sanitize_text_field($_SERVER["HTTP_X_MOZ"]) ) ) ) ) { |
|
199 | + if ( ( isset( $_SERVER["HTTP_X_PURPOSE"] ) && ( 'prefetch' === strtolower( sanitize_text_field( $_SERVER["HTTP_X_PURPOSE"] ) ) ) ) || |
|
200 | + ( isset( $_SERVER["HTTP_X_MOZ"] ) && ( 'prefetch' === strtolower( sanitize_text_field( $_SERVER["HTTP_X_MOZ"] ) ) ) ) ) { |
|
201 | 201 | return; |
202 | 202 | } |
203 | 203 |
@@ -289,7 +289,7 @@ |
||
289 | 289 | // This filter will be removed in the future. |
290 | 290 | $body = apply_filters( 'monsterinsights_api_request_body', $body ); |
291 | 291 | |
292 | - $body = array_merge($body, $extra_params); |
|
292 | + $body = array_merge($body, $extra_params); |
|
293 | 293 | |
294 | 294 | $string = http_build_query( $body, '', '&' ); |
295 | 295 |
@@ -299,12 +299,12 @@ discard block |
||
299 | 299 | |
300 | 300 | $body['network'] = $this->network ? 'network' : 'site'; |
301 | 301 | |
302 | - $body['ip'] = ! empty( $_SERVER['SERVER_ADDR'] ) ? sanitize_text_field(wp_unslash($_SERVER['SERVER_ADDR'])) : ''; |
|
302 | + $body['ip'] = ! empty( $_SERVER['SERVER_ADDR'] ) ? sanitize_text_field( wp_unslash( $_SERVER['SERVER_ADDR'] ) ) : ''; |
|
303 | 303 | |
304 | 304 | // This filter will be removed in the future. |
305 | 305 | $body = apply_filters( 'monsterinsights_api_request_body', $body ); |
306 | 306 | |
307 | - $body = array_merge($body, $extra_params); |
|
307 | + $body = array_merge( $body, $extra_params ); |
|
308 | 308 | |
309 | 309 | $string = http_build_query( $body, '', '&' ); |
310 | 310 | |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | } |
351 | 351 | |
352 | 352 | // If not a 200 status header, send back error. |
353 | - if ( 200 != $response_code && 204 != $response_code) { |
|
353 | + if ( 200 != $response_code && 204 != $response_code ) { |
|
354 | 354 | $type = ! empty( $response_body['type'] ) ? $response_body['type'] : 'api-error'; |
355 | 355 | |
356 | 356 | if ( empty( $response_code ) ) { |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | if ( $on_blacklist ) { |
495 | 495 | return new WP_Error( 'api-error', __( 'Reason: The API was unreachable because the API url is on the WP HTTP blocklist.', 'google-analytics-for-wordpress' ) ); |
496 | 496 | } else { |
497 | - $params = array( |
|
497 | + $params = array( |
|
498 | 498 | 'sslverify' => false, |
499 | 499 | 'timeout' => 2, |
500 | 500 | 'user-agent' => 'MonsterInsights/' . MONSTERINSIGHTS_VERSION, |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | return new WP_Error( 'api-error', __( 'Reason: The API was unreachable because no external hosts are allowed on this site.', 'google-analytics-for-wordpress' ) ); |
516 | 516 | } |
517 | 517 | } else { |
518 | - $params = array( |
|
518 | + $params = array( |
|
519 | 519 | 'sslverify' => false, |
520 | 520 | 'timeout' => 2, |
521 | 521 | 'user-agent' => 'MonsterInsights/' . MONSTERINSIGHTS_VERSION, |
@@ -161,12 +161,12 @@ discard block |
||
161 | 161 | } |
162 | 162 | |
163 | 163 | // Avoid loading scripts on pages that don't have admin bar such as WPBakery Page Builder. |
164 | - if (isset($_GET['vc_editable']) && isset($_GET['vc_post_id']) && $_GET['vc_editable'] === 'true') { |
|
164 | + if ( isset( $_GET['vc_editable'] ) && isset( $_GET['vc_post_id'] ) && $_GET['vc_editable'] === 'true' ) { |
|
165 | 165 | return; |
166 | 166 | } |
167 | 167 | |
168 | 168 | // Avoid adding admin bar scripts in Elementor's preview which is done via admin-ajax(where $pagenow = 'index.php') |
169 | - if ($pagenow === 'index.php' && isset($_GET['elementor-preview'])) { |
|
169 | + if ( $pagenow === 'index.php' && isset( $_GET['elementor-preview'] ) ) { |
|
170 | 170 | return; |
171 | 171 | } |
172 | 172 | |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | 'wizard_url' => is_network_admin() ? network_admin_url( 'index.php?page=monsterinsights-onboarding' ) : admin_url( 'index.php?page=monsterinsights-onboarding' ), |
214 | 214 | 'roles_manage_options' => monsterinsights_get_manage_options_roles(), |
215 | 215 | 'user_roles' => $current_user->roles, |
216 | - 'roles_view_reports' => monsterinsights_get_option('view_reports'), |
|
216 | + 'roles_view_reports' => monsterinsights_get_option( 'view_reports' ), |
|
217 | 217 | ) |
218 | 218 | ); |
219 | 219 | } |