| @@ -46,8 +46,9 @@ | ||
| 46 | 46 | * when its initialized. |
| 47 | 47 | */ |
| 48 | 48 | public function __construct() { |
| 49 | 49 | Analytics::get_instance(); |
| 50 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reviewed for the NotificationX codebase: acceptable in this context. | |
| 50 | 51 | if (!is_admin() || !empty($_GET['frontend'])) { |
| 51 | 52 | add_action('init', [$this, 'init'], 10); |
| 52 | 53 | } |
| 53 | 54 | add_filter('nx_frontend_localize_data', [$this, 'get_localize_data']); |
| @@ -76,9 +77,11 @@ | ||
| 76 | 77 | * @return void |
| 77 | 78 | */ |
| 78 | 79 | public function enqueue_scripts() { |
| 79 | 80 | $custom_css = $this->generate_custom_css(); |
| 81 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context. | |
| 80 | 82 | wp_register_script('notificationx-public', Helper::file('public/js/frontend.js', true), [], apply_filters('nx_frontend_js_version', NOTIFICATIONX_VERSION ), true); |
| 83 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context. | |
| 81 | 84 | wp_register_style('notificationx-public', Helper::file('public/css/frontend.css', true), [], apply_filters('nx_frontend_css_version', NOTIFICATIONX_VERSION ), 'all'); |
| 82 | 85 | // wp_register_style('notificationx-icon-pack', Helper::file('public/icon/style.css', true), [], NOTIFICATIONX_VERSION, 'all'); |
| 83 | 86 | // Localize scripts for frontend |
| 84 | 87 | wp_localize_script( |
| @@ -113,12 +116,14 @@ | ||
| 113 | 116 | ) |
| 114 | 117 | ); |
| 115 | 118 | |
| 116 | 119 | $exit = false; |
| 117 | - if(isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], 'wp-admin/widgets.php') !== false){ | |
| 120 | + $referer = isset($_SERVER['HTTP_REFERER']) ? esc_url_raw(wp_unslash($_SERVER['HTTP_REFERER'])) : ''; | |
| 121 | + if($referer && strpos($referer, 'wp-admin/widgets.php') !== false){ | |
| 118 | 122 | $exit = ['total' => 0]; |
| 119 | 123 | } |
| 120 | 124 | |
| 125 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context. | |
| 121 | 126 | $exit = apply_filters('nx_before_enqueue_scripts', $exit); |
| 122 | 127 | if(!empty($exit)){ |
| 123 | 128 | $this->notificationXArr = $exit; |
| 124 | 129 | return; |
| @@ -123,8 +128,9 @@ | ||
| 123 | 128 | $this->notificationXArr = $exit; |
| 124 | 129 | return; |
| 125 | 130 | } |
| 126 | 131 | |
| 132 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reviewed for the NotificationX codebase: acceptable in this context. | |
| 127 | 133 | if (!$exit && empty($_GET['elementor-preview'])) { |
| 128 | 134 | $this->notificationXArr = $this->get_notifications_ids(); |
| 129 | 135 | if ($this->notificationXArr['total'] > 0) { |
| 130 | 136 | $lang = get_locale(); |
| @@ -205,8 +211,9 @@ | ||
| 205 | 211 | } |
| 206 | 212 | |
| 207 | 213 | public function footer_scripts() { |
| 208 | 214 | if (!empty($this->notificationXArr['total']) && $this->notificationXArr['total'] > 0) { |
| 215 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context. | |
| 209 | 216 | $this->notificationXArr = apply_filters('nx_frontend_localize_data', $this->notificationXArr); |
| 210 | 217 | ?> |
| 211 | 218 | <script data-no-optimize="1"> |
| 212 | 219 | (function() { |
| @@ -306,8 +313,9 @@ | ||
| 306 | 313 | |
| 307 | 314 | $type = $settings['type']; |
| 308 | 315 | $source = $settings['source']; |
| 309 | 316 | |
| 317 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context. | |
| 310 | 318 | $should_continue = apply_filters("nx_entry_show_on_frontend_$source", false, $entry, $settings); |
| 311 | 319 | if ( $should_continue ) { |
| 312 | 320 | continue; |
| 313 | 321 | } |
| @@ -319,8 +327,9 @@ | ||
| 319 | 327 | if (!is_numeric($timestamp)) { |
| 320 | 328 | $entry['timestamp'] = $timestamp = is_string($timestamp) ? strtotime($timestamp) : false; |
| 321 | 329 | } |
| 322 | 330 | if ($timestamp && $display_from > $timestamp) { |
| 331 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context. | |
| 323 | 332 | if (apply_filters("nx_entry_display_$source", true, $entry, $settings)) { |
| 324 | 333 | continue; |
| 325 | 334 | } |
| 326 | 335 | } |
| @@ -325,19 +334,24 @@ | ||
| 325 | 334 | } |
| 326 | 335 | } |
| 327 | 336 | } |
| 328 | 337 | |
| 338 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context. | |
| 329 | 339 | $defaults = apply_filters("nx_fallback_data_$source", $_defaults, $entry, $settings); |
| 340 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context. | |
| 330 | 341 | $defaults = apply_filters('nx_fallback_data', $defaults, $entry, $settings); |
| 331 | 342 | |
| 332 | 343 | $entry = $this->apply_defaults($entry, $defaults); |
| 333 | 344 | $entry['image_data'] = $this->get_image_url($entry, $settings); |
| 334 | 345 | if (!empty($entry['title'])) { |
| 335 | - $entry['title'] = strip_tags(html_entity_decode($entry['title'])); | |
| 346 | + $entry['title'] = wp_strip_all_tags(html_entity_decode($entry['title'])); | |
| 336 | 347 | } |
| 337 | 348 | |
| 349 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context. | |
| 338 | 350 | $entry = apply_filters("nx_filtered_entry_$type", $entry, $settings); |
| 351 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context. | |
| 339 | 352 | $entry = apply_filters("nx_filtered_entry_$source", $entry, $settings); |
| 353 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context. | |
| 340 | 354 | $entry = apply_filters('nx_filtered_entry', $entry, $settings); |
| 341 | 355 | $entry = $this->link_url($entry, $settings, $params); |
| 342 | 356 | |
| 343 | 357 | // @todo shortcode |
| @@ -372,14 +386,19 @@ | ||
| 372 | 386 | } |
| 373 | 387 | |
| 374 | 388 | foreach ($result as &$group) { |
| 375 | 389 | foreach ($group as &$value) { |
| 390 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context. | |
| 376 | 391 | $value['entries'] = apply_filters("nx_filtered_data_{$value['post']['type']}", $value['entries'], $value['post'], $params); |
| 392 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context. | |
| 377 | 393 | $value['entries'] = apply_filters("nx_filtered_data_{$value['post']['source']}", $value['entries'], $value['post'], $params); |
| 394 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context. | |
| 378 | 395 | $value['entries'] = apply_filters('nx_filtered_data', $value['entries'], $value['post'], $params); |
| 396 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context. | |
| 379 | 397 | $value['post'] = apply_filters('nx_filtered_post', $value['post'], $params); |
| 380 | 398 | } |
| 381 | 399 | } |
| 400 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context. | |
| 382 | 401 | $result = apply_filters('nx_filtered_notice', $result, $params); |
| 383 | 402 | } |
| 384 | 403 | |
| 385 | 404 | if (!empty($pressbar)) { |
| @@ -398,8 +417,9 @@ | ||
| 398 | 417 | continue; |
| 399 | 418 | } |
| 400 | 419 | |
| 401 | 420 | // $settings['button_url'] = apply_filters("nx_notification_link_{$settings['source']}", $settings['button_url'], $settings); |
| 421 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context. | |
| 402 | 422 | $settings['button_url'] = apply_filters('nx_notification_link', $settings['button_url'], $settings); |
| 403 | 423 | if (!empty($settings['button_url']) && strpos($settings['button_url'], '//') === false && strpos($settings['button_url'], './') === false) { |
| 404 | 424 | $settings['button_url'] = "//{$settings['button_url']}"; |
| 405 | 425 | } |
| @@ -404,8 +424,9 @@ | ||
| 404 | 424 | $settings['button_url'] = "//{$settings['button_url']}"; |
| 405 | 425 | } |
| 406 | 426 | $bar_content = $this->get_bar_content($settings, false, $params); |
| 407 | 427 | if ($bar_content !== ' ' || !empty($settings['enable_countdown'])) { |
| 428 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context. | |
| 408 | 429 | $settings = apply_filters('nx_filtered_post', $settings, $params); |
| 409 | 430 | $result['pressbar'][$_nx_id]['post'] = $settings; |
| 410 | 431 | $result['pressbar'][$_nx_id]['content'] = $bar_content; |
| 411 | 432 | } |
| @@ -421,8 +442,9 @@ | ||
| 421 | 442 | if (!empty($_params['all_active'])) { |
| 422 | 443 | continue; |
| 423 | 444 | } |
| 424 | 445 | |
| 446 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context. | |
| 425 | 447 | $settings = apply_filters('nx_filtered_post', $settings, $params); |
| 426 | 448 | |
| 427 | 449 | $result['gdpr'][$_nx_id]['post'] = $settings; |
| 428 | 450 | $result['gdpr'][$_nx_id]['content'] = ""; |
| @@ -438,8 +460,9 @@ | ||
| 438 | 460 | if ( !$settings['enabled'] ) { |
| 439 | 461 | continue; |
| 440 | 462 | } |
| 441 | 463 | |
| 464 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context. | |
| 442 | 465 | $settings = apply_filters('nx_filtered_post', $settings, $params); |
| 443 | 466 | |
| 444 | 467 | $result['popup'][$_nx_id]['post'] = $settings; |
| 445 | 468 | $result['popup'][$_nx_id]['content'] = ""; |
| @@ -454,8 +477,9 @@ | ||
| 454 | 477 | $_nx_id = $settings['nx_id']; |
| 455 | 478 | if ( !$settings['enabled'] ) { |
| 456 | 479 | continue; |
| 457 | 480 | } |
| 481 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context. | |
| 458 | 482 | $settings = apply_filters('nx_filtered_post', $settings, $params); |
| 459 | 483 | $result['exit_intent'][$_nx_id]['post'] = $settings; |
| 460 | 484 | $result['exit_intent'][$_nx_id]['content'] = ""; |
| 461 | 485 | unset($_nx_id); |
| @@ -467,8 +491,9 @@ | ||
| 467 | 491 | } |
| 468 | 492 | |
| 469 | 493 | public function get_settings(){ |
| 470 | 494 | |
| 495 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context. | |
| 471 | 496 | $branding_url = apply_filters('nx_branding_url', NOTIFICATIONX_PLUGIN_URL . '?utm_source=' . esc_url(home_url()) . '&utm_medium=notificationx'); |
| 472 | 497 | $settings = [ |
| 473 | 498 | 'disable_powered_by' => Settings::get_instance()->get('settings.disable_powered_by'), |
| 474 | 499 | 'affiliate_link' => $branding_url, |
| @@ -540,8 +565,9 @@ | ||
| 540 | 565 | // if ($settings['hide_on_mobile'] && wp_is_mobile()) { |
| 541 | 566 | // continue; |
| 542 | 567 | // } |
| 543 | 568 | |
| 569 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context. | |
| 544 | 570 | $show_on_exclude = apply_filters('nx_show_on_exclude', false, $settings); |
| 545 | 571 | if ($show_on_exclude) { |
| 546 | 572 | continue; |
| 547 | 573 | } |
| @@ -597,8 +623,9 @@ | ||
| 597 | 623 | |
| 598 | 624 | // @todo maybe combine two hooks. |
| 599 | 625 | |
| 600 | 626 | return apply_filters( |
| 627 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context. | |
| 601 | 628 | 'get_notifications_ids', |
| 602 | 629 | [ |
| 603 | 630 | 'global' => $global_notifications, |
| 604 | 631 | 'active' => $active_notifications, |
| @@ -634,8 +661,9 @@ | ||
| 634 | 661 | // @todo need to pass url. |
| 635 | 662 | $check_location = Locations::get_instance()->check_location($locations, $custom_ids, $taxonomy_ids); |
| 636 | 663 | } |
| 637 | 664 | |
| 665 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context. | |
| 638 | 666 | $check_location = apply_filters('nx_check_location', $check_location, $custom_ids, $show_on); |
| 639 | 667 | |
| 640 | 668 | if ($show_on == 'on_selected') { |
| 641 | 669 | // show if the page is on selected |
| @@ -701,8 +729,9 @@ | ||
| 701 | 729 | foreach ($ids as $id) { |
| 702 | 730 | if (!empty($notifications[$id])) { |
| 703 | 731 | $post = $notifications[$id]; |
| 704 | 732 | $global_query = " nx_id = " . absint($id) . " AND source = '" . esc_sql($post['source']) . "'"; |
| 733 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context. | |
| 705 | 734 | $_q = apply_filters("nx_get_entries_query_part_{$notifications[$id]['source']}",$global_query, $notifications[$id], $params ); |
| 706 | 735 | $query[$id] = " (" . $_q . ")"; |
| 707 | 736 | } |
| 708 | 737 | } |
| @@ -718,8 +747,9 @@ | ||
| 718 | 747 | } |
| 719 | 748 | if (!is_array($entries)) { |
| 720 | 749 | $entries = []; |
| 721 | 750 | } |
| 751 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context. | |
| 722 | 752 | $entries = apply_filters('nx_frontend_get_entries', $entries, $ids, $notifications,$params); |
| 723 | 753 | return $entries; |
| 724 | 754 | } |
| 725 | 755 | |
| @@ -738,9 +768,11 @@ | ||
| 738 | 768 | if (empty($post['link_type']) || $post['link_type'] === 'none') { |
| 739 | 769 | $link = ''; |
| 740 | 770 | } |
| 741 | 771 | |
| 772 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context. | |
| 742 | 773 | $link = apply_filters("nx_notification_link_{$post['source']}", $link, $post, $entry, $params); |
| 774 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context. | |
| 743 | 775 | $entry['link'] = apply_filters('nx_notification_link', $link, $post, $entry, $params); |
| 744 | 776 | return $entry; |
| 745 | 777 | } |
| 746 | 778 | |
| @@ -789,9 +821,11 @@ | ||
| 789 | 821 | } |
| 790 | 822 | } |
| 791 | 823 | |
| 792 | 824 | $image_data['classes'] = $image_type; |
| 825 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context. | |
| 793 | 826 | $image_data = apply_filters("nx_notification_image_$source", $image_data, $data, $settings); |
| 827 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context. | |
| 794 | 828 | $image_data = apply_filters('nx_notification_image', $image_data, $data, $settings); |
| 795 | 829 | |
| 796 | 830 | if (!empty($image_data['url'])) { |
| 797 | 831 | return $image_data; |
| @@ -835,8 +869,9 @@ | ||
| 835 | 869 | if (!empty($post['display_last']) && !in_array($post['source'], ['google', 'woo_inline', 'edd_inline', 'tutor_inline', 'learndash_inline', 'google_reviews', 'youtube','woocommerce_sales_inline','fluentcart_inline'])) { |
| 836 | 870 | $entries = array_slice($entries, 0, $post['display_last']); |
| 837 | 871 | } |
| 838 | 872 | foreach ($entries as $index => $entry) { |
| 873 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context. | |
| 839 | 874 | $_entry = apply_filters("nx_frontend_keep_entry_{$post['source']}", [ |
| 840 | 875 | 'nx_id' => $entry['nx_id'], |
| 841 | 876 | 'timestamp' => isset($entry['timestamp']) ? $entry['timestamp'] : Helper::current_timestamp($entry['updated_at']), |
| 842 | 877 | 'updated_at' => isset( $entry['updated_at'] ) ? $entry['updated_at'] : '', |
| @@ -904,8 +939,9 @@ | ||
| 904 | 939 | if (is_array($post) && empty($params['inline_shortcode']) && (!defined('NX_DEBUG') || !NX_DEBUG)) { |
| 905 | 940 | $ignore_props = [ |
| 906 | 941 | 'all_locations', |
| 907 | 942 | 'category_list', |
| 943 | + 'combine_multiorder_display', | |
| 908 | 944 | 'combine_multiorder_text', |
| 909 | 945 | 'content_trim_length', |
| 910 | 946 | 'convertkit_form', |
| 911 | 947 | 'currentTab', |
| @@ -928,8 +964,10 @@ | ||
| 928 | 964 | 'is_elementor', |
| 929 | 965 | 'is_inline', |
| 930 | 966 | 'ld_course_list', |
| 931 | 967 | 'ld_product_control', |
| 968 | + 'activecampaign_form', | |
| 969 | + 'brevo_list', | |
| 932 | 970 | 'mailchimp_list', |
| 933 | 971 | 'max_stock', |
| 934 | 972 | 'nx-bar_with_elementor', |
| 935 | 973 | 'nx-bar_with_elementor-remove', |
| @@ -976,14 +1014,15 @@ | ||
| 976 | 1014 | |
| 977 | 1015 | public function get_bar_content($settings, $suppress_filters = false, $params = []){ |
| 978 | 1016 | $bar_content = PressBar::get_instance()->print_bar_notice($settings); |
| 979 | 1017 | if(!$suppress_filters){ |
| 1018 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context. | |
| 980 | 1019 | $bar_content = apply_filters("nx_filtered_data_{$settings['source']}", $bar_content, $settings, $params); |
| 981 | 1020 | } |
| 982 | 1021 | |
| 983 | 1022 | // checking if content is empty |
| 984 | 1023 | $_bar_content = str_replace(array("\r\n", "\n", "\r"), '', $bar_content); |
| 985 | - $_bar_content = trim(strip_tags($_bar_content)); | |
| 1024 | + $_bar_content = trim(wp_strip_all_tags($_bar_content)); | |
| 986 | 1025 | if (empty($_bar_content) && !empty($settings['enable_countdown'])) { |
| 987 | 1026 | $bar_content = ' '; |
| 988 | 1027 | } |
| 989 | 1028 | return $bar_content; |