| @@ -94,16 +94,12 @@ | ||
| 94 | 94 | * @return array |
| 95 | 95 | */ |
| 96 | 96 | public static function get_hellobar_config() { |
| 97 | 97 | return array( |
| 98 | - // Flash sale. | |
| 99 | - 'ultp_helloBar_flash_sale_2026_4' => Xpo::get_transient_without_cache( 'ultp_helloBar_flash_sale_2026_4' ), | |
| 100 | - // Surprise sale. | |
| 101 | - 'ultp_helloBar_surprise_sale_2026_5' => Xpo::get_transient_without_cache( 'ultp_helloBar_surprise_sale_2026_5' ), | |
| 102 | - // Massive sale. | |
| 103 | - 'ultp_helloBar_massive_sale_2026_6' => Xpo::get_transient_without_cache( 'ultp_helloBar_massive_sale_2026_6' ), | |
| 104 | 98 | // Final hours sale. |
| 105 | - 'ultp_helloBar_final_hours_sale_2026_7' => Xpo::get_transient_without_cache( 'ultp_helloBar_final_hours_sale_2026_7' ), | |
| 99 | + 'ultp_helloBar_summer_sale_2026_v1' => Xpo::get_transient_without_cache( 'ultp_helloBar_summer_sale_2026_v1' ), | |
| 100 | + 'ultp_helloBar_summer_sale_2026_v1_2' => Xpo::get_transient_without_cache( 'ultp_helloBar_summer_sale_2026_v1_2' ), | |
| 101 | + 'ultp_helloBar_base_price_2026' => Xpo::get_transient_without_cache( 'ultp_helloBar_base_price_2026' ), | |
| 106 | 102 | ); |
| 107 | 103 | } |
| 108 | 104 | |
| 109 | 105 | /** |
| @@ -116,10 +112,17 @@ | ||
| 116 | 112 | $request_params = $request->get_params(); |
| 117 | 113 | $type = isset( $request_params['type'] ) ? $request_params['type'] : ''; |
| 118 | 114 | $id = isset( $request_params['id'] ) ? $request_params['id'] : ''; |
| 119 | 115 | |
| 120 | - if ( 'hello_bar' === $type && ! empty( $id ) ) { | |
| 121 | - Xpo::set_transient_without_cache( $id, 'hide', 1296000 ); | |
| 116 | + // Guideline 11 — a dismissal must stick. This previously expired after 15 | |
| 117 | + // days (1296000s), so a dismissed sale bar came back on its own. Passing 0 | |
| 118 | + // stores it with no timeout, which Xpo::get_transient_without_cache() reads | |
| 119 | + // back indefinitely. | |
| 120 | + // | |
| 121 | + // $id names the option that gets written, so it is checked against the | |
| 122 | + // known hellobar keys rather than trusted from the request. | |
| 123 | + if ( 'hello_bar' === $type && ! empty( $id ) && array_key_exists( $id, self::get_hellobar_config() ) ) { | |
| 124 | + Xpo::set_transient_without_cache( $id, 'hide', 0 ); | |
| 122 | 125 | } |
| 123 | 126 | |
| 124 | 127 | return new \WP_REST_Response( |
| 125 | 128 | array( |
| @@ -136,9 +139,9 @@ | ||
| 136 | 139 | * @return void |
| 137 | 140 | */ |
| 138 | 141 | public function set_dismiss_notice_callback() { |
| 139 | 142 | |
| 140 | - if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['wpnonce'] ?? '' ) ), 'ultp-nonce' ) ) { | |
| 143 | + if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['wpnonce'] ?? '' ) ), 'ultp-admin-nonce' ) ) { | |
| 141 | 144 | return; |
| 142 | 145 | } |
| 143 | 146 | |
| 144 | 147 | $durbin_key = sanitize_text_field( wp_unslash( $_GET['ultp_durbin_key'] ?? '' ) ); |
| @@ -186,8 +189,10 @@ | ||
| 186 | 189 | public function ultp_dashboard_notice_callback() { |
| 187 | 190 | if ( $this->is_available_for_notice() ) { |
| 188 | 191 | $this->ultp_dashboard_banner_notice(); |
| 189 | 192 | $this->ultp_dashboard_content_notice(); |
| 193 | + $this->ultp_dashboard_image_banner_notice(); | |
| 194 | + | |
| 190 | 195 | } |
| 191 | 196 | } |
| 192 | 197 | |
| 193 | 198 | /** |
| @@ -195,9 +200,9 @@ | ||
| 195 | 200 | * |
| 196 | 201 | * @return void |
| 197 | 202 | */ |
| 198 | 203 | public function ultp_dashboard_banner_notice( $return_bool = false ) { |
| 199 | - $ultp_db_nonce = wp_create_nonce( 'ultp-nonce' ); | |
| 204 | + $ultp_db_nonce = wp_create_nonce( 'ultp-admin-nonce' ); | |
| 200 | 205 | $banner_notices = array( |
| 201 | 206 | // FLash sale. |
| 202 | 207 | array( |
| 203 | 208 | 'key' => 'ultp_banner_flash_sale_2026_1', |
| @@ -420,9 +425,9 @@ | ||
| 420 | 425 | display: flex; |
| 421 | 426 | align-items: center; |
| 422 | 427 | justify-content: center; |
| 423 | 428 | " |
| 424 | - aria-label="<?php esc_html_e( 'Close Banner', 'product-addons' ); ?>" | |
| 429 | + aria-label="<?php esc_html_e( 'Close Banner', 'ultimate-post' ); ?>" | |
| 425 | 430 | href="<?php echo esc_url( add_query_arg( $query_args ) ); ?>"> |
| 426 | 431 | </a> |
| 427 | 432 | |
| 428 | 433 | <a class="ultp-banner-link" target="_blank" href="<?php echo esc_url( $notice['url'] ); ?>"> |
| @@ -564,8 +569,15 @@ | ||
| 564 | 569 | */ |
| 565 | 570 | public function ultp_dashboard_durbin_notice_callback() { |
| 566 | 571 | $durbin_key = 'ultp_durbin_dc1'; |
| 567 | 572 | |
| 573 | + // Guideline 11 — the consent notice is allowed on PostX's own screens and, | |
| 574 | + // as is standard immediately after activation, on plugins.php. Nowhere else. | |
| 575 | + global $pagenow; | |
| 576 | + if ( ! $this->is_postx_screen() && 'plugins.php' !== $pagenow ) { | |
| 577 | + return; | |
| 578 | + } | |
| 579 | + | |
| 568 | 580 | if ( |
| 569 | 581 | isset( $_GET['ultp_durbin_key'] ) || // phpcs:ignore |
| 570 | 582 | 'off' === Xpo::get_transient_without_cache( 'ultp_durbin_notice_' . $durbin_key ) |
| 571 | 583 | ) { |
| @@ -575,9 +587,9 @@ | ||
| 575 | 587 | if ( ! $this->notice_js_css_applied ) { |
| 576 | 588 | $this->notice_js_css_applied = true; |
| 577 | 589 | } |
| 578 | 590 | |
| 579 | - $ultp_db_nonce = wp_create_nonce( 'ultp-nonce' ); | |
| 591 | + $ultp_db_nonce = wp_create_nonce( 'ultp-admin-nonce' ); | |
| 580 | 592 | |
| 581 | 593 | ?> |
| 582 | 594 | <style> |
| 583 | 595 | .ultp-consent-box { |
| @@ -688,175 +700,54 @@ | ||
| 688 | 700 | * @return void |
| 689 | 701 | */ |
| 690 | 702 | public function ultp_dashboard_content_notice( $return_bool = false ) { |
| 691 | 703 | $content_notices = array( |
| 692 | - // Flash sale | |
| 693 | 704 | array( |
| 694 | - 'key' => 'ultp_dashboard_content_notice_flash_sale_brand_logos', | |
| 695 | - 'start' => '2026-05-07 00:00 Asia/Dhaka', | |
| 696 | - 'end' => '2026-05-12 23:59 Asia/Dhaka', | |
| 705 | + 'key' => 'ultp_dashboard_content_notice_summer_sale_2026_vv1', | |
| 706 | + 'start' => '2026-07-06 00:00 Asia/Dhaka', | |
| 707 | + 'end' => '2026-07-12 23:59 Asia/Dhaka', | |
| 697 | 708 | 'url' => Xpo::generate_utm_link( |
| 698 | 709 | array( |
| 699 | - 'utmKey' => 'flash_sale', | |
| 710 | + 'utmKey' => 'summer_db', | |
| 700 | 711 | ) |
| 701 | 712 | ), |
| 702 | 713 | 'visibility' => ! Xpo::is_lc_active(), |
| 703 | - 'content_heading' => __( 'Flash Sale:', 'ultimate-post' ), | |
| 704 | - 'content_subheading' => __( 'Enjoy %s on PostX Pro.', 'ultimate-post' ), | |
| 705 | - 'discount_content' => ' up to 45% Off', | |
| 706 | - 'brand_color' => '#0322ff', | |
| 707 | - 'icon' => ULTP_URL . 'assets/img/dashboard_banner/brand_logo_round.svg', | |
| 708 | - 'button_text' => __( 'Claim Your Discount!', 'ultimate-post' ), | |
| 709 | - 'is_discount_logo' => true, | |
| 714 | + 'content_heading' => __( 'Summer Sale:', 'ultimate-post' ), | |
| 715 | + /* translators: %s: discount percentage */ | |
| 716 | + 'content_subheading' => __( 'Enjoy up to %s on PostX Pro.', 'ultimate-post' ), | |
| 717 | + 'discount_content' => ' 50% OFF', | |
| 710 | 718 | 'border_color' => '#0322ff', |
| 711 | - ), | |
| 712 | - array( | |
| 713 | - 'key' => 'ultp_dashboard_content_notice_flash_sale_discount_logo', | |
| 714 | - 'start' => '2026-05-13 00:00 Asia/Dhaka', | |
| 715 | - 'end' => '2026-05-17 23:59 Asia/Dhaka', | |
| 716 | - 'url' => Xpo::generate_utm_link( | |
| 717 | - array( | |
| 718 | - 'utmKey' => 'flash_sale', | |
| 719 | - ) | |
| 720 | - ), | |
| 721 | - 'visibility' => ! Xpo::is_lc_active(), | |
| 722 | - 'content_heading' => __( 'Flash Sale:', 'ultimate-post' ), | |
| 723 | - 'content_subheading' => __( 'Enjoy %s on PostX Pro.', 'ultimate-post' ), | |
| 724 | - 'discount_content' => ' up to 45% Off', | |
| 725 | - 'brand_color' => '#0322ff', | |
| 726 | - 'icon' => ULTP_URL . 'assets/img/dashboard_banner/flash_sale_45_discount_logo.png', | |
| 719 | + 'icon' => ULTP_URL . 'assets/img/dashboard_banner/brand_logo.svg', | |
| 727 | 720 | 'button_text' => __( 'Upgrade Now!', 'ultimate-post' ), |
| 728 | 721 | 'is_discount_logo' => true, |
| 729 | - 'border_color' => '#0322ff', | |
| 730 | 722 | ), |
| 731 | - | |
| 732 | - // Surprise Sale | |
| 733 | 723 | array( |
| 734 | - 'key' => 'ultp_dashboard_content_notice_surprise_sale_brand_logo', | |
| 735 | - 'start' => '2026-05-22 00:00 Asia/Dhaka', | |
| 736 | - 'end' => '2026-05-25 23:59 Asia/Dhaka', | |
| 724 | + 'key' => 'ultp_dashboard_content_notice_summer_sale_2026_vv3', | |
| 725 | + 'start' => '2026-08-02 00:00 Asia/Dhaka', | |
| 726 | + 'end' => '2026-08-08 23:59 Asia/Dhaka', | |
| 737 | 727 | 'url' => Xpo::generate_utm_link( |
| 738 | 728 | array( |
| 739 | - 'utmKey' => 'surprise_sale', | |
| 729 | + 'utmKey' => 'summer_db', | |
| 740 | 730 | ) |
| 741 | 731 | ), |
| 742 | 732 | 'visibility' => ! Xpo::is_lc_active(), |
| 743 | - 'content_heading' => __( 'Surprise Sale:', 'ultimate-post' ), | |
| 744 | - 'content_subheading' => __( 'Enjoy %s on PostX Pro.', 'ultimate-post' ), | |
| 745 | - 'discount_content' => ' up to 50% Off', | |
| 746 | - 'brand_color' => '#0322ff', | |
| 747 | - 'icon' => ULTP_URL . 'assets/img/dashboard_banner/brand_logo_round.svg', | |
| 748 | - 'button_text' => __( 'Claim Your Discount!', 'ultimate-post' ), | |
| 749 | - 'is_discount_logo' => true, | |
| 733 | + 'content_heading' => __( 'Summer Sale:', 'ultimate-post' ), | |
| 734 | + /* translators: %s: discount percentage */ | |
| 735 | + 'content_subheading' => __( 'Enjoy up to %s on PostX Pro.', 'ultimate-post' ), | |
| 736 | + 'discount_content' => ' 50% OFF', | |
| 750 | 737 | 'border_color' => '#0322ff', |
| 751 | - ), | |
| 752 | - array( | |
| 753 | - 'key' => 'ultp_dashboard_content_notice_surprise_sale_discount_logo', | |
| 754 | - 'start' => '2026-05-26 00:00 Asia/Dhaka', | |
| 755 | - 'end' => '2026-05-28 23:59 Asia/Dhaka', | |
| 756 | - 'url' => Xpo::generate_utm_link( | |
| 757 | - array( | |
| 758 | - 'utmKey' => 'surprise_sale', | |
| 759 | - ) | |
| 760 | - ), | |
| 761 | - 'visibility' => ! Xpo::is_lc_active(), | |
| 762 | - 'content_heading' => __( 'Surprise Sale:', 'ultimate-post' ), | |
| 763 | - 'content_subheading' => __( 'Enjoy %s on PostX Pro.', 'ultimate-post' ), | |
| 764 | - 'discount_content' => ' up to 50% Off', | |
| 765 | - 'brand_color' => '#0322ff', | |
| 766 | 738 | 'icon' => ULTP_URL . 'assets/img/dashboard_banner/flash_sale_50_discount_logo.png', |
| 767 | 739 | 'button_text' => __( 'Upgrade Now!', 'ultimate-post' ), |
| 768 | 740 | 'is_discount_logo' => true, |
| 769 | - 'border_color' => '#0322ff', | |
| 770 | 741 | ), |
| 771 | 742 | |
| 772 | - // Massive Sale | |
| 773 | - array( | |
| 774 | - 'key' => 'ultp_dashboard_content_notice_massive_sale_brand_logo', | |
| 775 | - 'start' => '2026-06-02 00:00 Asia/Dhaka', | |
| 776 | - 'end' => '2026-06-10 23:59 Asia/Dhaka', | |
| 777 | - 'url' => Xpo::generate_utm_link( | |
| 778 | - array( | |
| 779 | - 'utmKey' => 'massive_sale', | |
| 780 | - ) | |
| 781 | - ), | |
| 782 | - 'visibility' => ! Xpo::is_lc_active(), | |
| 783 | - 'content_heading' => __( 'Massive Sale:', 'ultimate-post' ), | |
| 784 | - 'content_subheading' => __( 'Enjoy %s on PostX Pro.', 'ultimate-post' ), | |
| 785 | - 'discount_content' => ' up to 50% Off', | |
| 786 | - 'brand_color' => '#0322ff', | |
| 787 | - 'icon' => ULTP_URL . 'assets/img/dashboard_banner/brand_logo_round.svg', | |
| 788 | - 'button_text' => __( 'Claim Your Discount!', 'ultimate-post' ), | |
| 789 | - 'is_discount_logo' => true, | |
| 790 | - 'border_color' => '#0322ff', | |
| 791 | - ), | |
| 792 | - array( | |
| 793 | - 'key' => 'ultp_dashboard_content_notice_massive_sale_discount_logo', | |
| 794 | - 'start' => '2026-06-11 00:00 Asia/Dhaka', | |
| 795 | - 'end' => '2026-06-16 23:59 Asia/Dhaka', | |
| 796 | - 'url' => Xpo::generate_utm_link( | |
| 797 | - array( | |
| 798 | - 'utmKey' => 'massive_sale', | |
| 799 | - ) | |
| 800 | - ), | |
| 801 | - 'visibility' => ! Xpo::is_lc_active(), | |
| 802 | - 'content_heading' => __( 'Massive Sale:', 'ultimate-post' ), | |
| 803 | - 'content_subheading' => __( 'Enjoy %s on PostX Pro.', 'ultimate-post' ), | |
| 804 | - 'discount_content' => ' up to 50% Off', | |
| 805 | - 'brand_color' => '#0322ff', | |
| 806 | - 'icon' => ULTP_URL . 'assets/img/dashboard_banner/flash_sale_50_discount_logo.png', | |
| 807 | - 'button_text' => __( 'Upgrade Now!', 'ultimate-post' ), | |
| 808 | - 'is_discount_logo' => true, | |
| 809 | - 'border_color' => '#0322ff', | |
| 810 | - ), | |
| 811 | - | |
| 812 | - // Final Hours Sale | |
| 813 | - array( | |
| 814 | - 'key' => 'ultp_dashboard_content_notice_final_hours_sale_brand_logo', | |
| 815 | - 'start' => '2026-06-21 00:00 Asia/Dhaka', | |
| 816 | - 'end' => '2026-06-24 23:59 Asia/Dhaka', | |
| 817 | - 'url' => Xpo::generate_utm_link( | |
| 818 | - array( | |
| 819 | - 'utmKey' => 'final_hour', | |
| 820 | - ) | |
| 821 | - ), | |
| 822 | - 'visibility' => ! Xpo::is_lc_active(), | |
| 823 | - 'content_heading' => __( 'Final Hours Sale:', 'ultimate-post' ), | |
| 824 | - 'content_subheading' => __( 'Enjoy %s on PostX Pro.', 'ultimate-post' ), | |
| 825 | - 'discount_content' => ' up to 50% Off', | |
| 826 | - 'brand_color' => '#0322ff', | |
| 827 | - 'icon' => ULTP_URL . 'assets/img/dashboard_banner/brand_logo_round.svg', | |
| 828 | - 'button_text' => __( 'Claim Your Discount!', 'ultimate-post' ), | |
| 829 | - 'is_discount_logo' => true, | |
| 830 | - 'border_color' => '#0322ff', | |
| 831 | - ), | |
| 832 | - array( | |
| 833 | - 'key' => 'ultp_dashboard_content_notice_final_hours_sale_discount_logo', | |
| 834 | - 'start' => '2026-06-25 00:00 Asia/Dhaka', | |
| 835 | - 'end' => '2026-06-27 23:59 Asia/Dhaka', | |
| 836 | - 'url' => Xpo::generate_utm_link( | |
| 837 | - array( | |
| 838 | - 'utmKey' => 'final_hour', | |
| 839 | - ) | |
| 840 | - ), | |
| 841 | - 'visibility' => ! Xpo::is_lc_active(), | |
| 842 | - 'content_heading' => __( 'Final Hours Sale:', 'ultimate-post' ), | |
| 843 | - 'content_subheading' => __( 'Enjoy %s on PostX Pro.', 'ultimate-post' ), | |
| 844 | - 'discount_content' => ' up to 50% Off', | |
| 845 | - 'brand_color' => '#0322ff', | |
| 846 | - 'icon' => ULTP_URL . 'assets/img/dashboard_banner/flash_sale_50_discount_logo.png', | |
| 847 | - 'button_text' => __( 'Upgrade Now!', 'ultimate-post' ), | |
| 848 | - 'is_discount_logo' => true, | |
| 849 | - 'border_color' => '#0322ff', | |
| 850 | - ), | |
| 851 | - | |
| 852 | 743 | ); |
| 853 | 744 | |
| 854 | - $ultp_db_nonce = wp_create_nonce( 'ultp-nonce' ); | |
| 745 | + $ultp_db_nonce = wp_create_nonce( 'ultp-admin-nonce' ); | |
| 855 | 746 | |
| 856 | 747 | foreach ( $content_notices as $key => $notice ) { |
| 857 | 748 | $notice_key = isset( $notice['key'] ) ? $notice['key'] : $this->notice_version; |
| 858 | - if ( isset( $_GET['ultp_notice'] ) && $notice_key === $_GET['ultp_notice'] ) { | |
| 749 | + if ( isset( $_GET['ultp_notice'] ) && $notice_key === sanitize_text_field( wp_unslash( $_GET['ultp_notice'] ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only; hides the notice on this page view. | |
| 859 | 750 | continue; |
| 860 | 751 | } else { |
| 861 | 752 | $border_color = $notice['border_color']; |
| 862 | 753 | |
| @@ -979,32 +870,32 @@ | ||
| 979 | 870 | </style> |
| 980 | 871 | <div class="ultp-content-notice-wrapper notice data_collection_notice" |
| 981 | 872 | style="border-left: 3px solid <?php echo esc_attr( $border_color ); ?>;" |
| 982 | 873 | > |
| 983 | - <?php | |
| 984 | - if ( $notice['is_discount_logo'] ) { | |
| 985 | - ?> | |
| 874 | + <?php | |
| 875 | + if ( $notice['is_discount_logo'] ) { | |
| 876 | + ?> | |
| 986 | 877 | <div class="ultp-content-notice-discout-icon"> <img src="<?php echo esc_url( $notice['icon'] ); ?>"/> </div> |
| 987 | - <?php | |
| 988 | - } else { | |
| 878 | + <?php | |
| 879 | + } else { | |
| 880 | + ?> | |
| 881 | + <div class="ultp-content-notice-icon"> <img src="<?php echo esc_url( $notice['icon'] ); ?>"/> </div> | |
| 882 | + <?php | |
| 883 | + } | |
| 989 | 884 | ?> |
| 990 | - <div class="ultp-content-notice-icon"> <img src="<?php echo esc_url( $notice['icon'] ); ?>"/> </div> | |
| 991 | - <?php | |
| 992 | - } | |
| 993 | - ?> | |
| 994 | 885 | |
| 995 | 886 | <div class="ultp-notice-content-wrapper"> |
| 996 | 887 | <div class=""> |
| 997 | 888 | <strong><?php printf( esc_html( $notice['content_heading'] ) ); ?> </strong> |
| 998 | - <?php | |
| 999 | - printf( | |
| 1000 | - wp_kses_post( $notice['content_subheading'] ), | |
| 1001 | - '<strong>' . esc_html( $notice['discount_content'] ) . '</strong>' | |
| 1002 | - ); | |
| 1003 | - ?> | |
| 889 | + <?php | |
| 890 | + printf( | |
| 891 | + wp_kses_post( $notice['content_subheading'] ), | |
| 892 | + '<strong>' . esc_html( $notice['discount_content'] ) . '</strong>' | |
| 893 | + ); | |
| 894 | + ?> | |
| 1004 | 895 | </div> |
| 1005 | 896 | <div class="ultp-content-notice-buttons"> |
| 1006 | - <?php if ( isset( $notice['is_discount_logo'] ) && $notice['is_discount_logo'] ) : ?> | |
| 897 | + <?php if ( isset( $notice['is_discount_logo'] ) && $notice['is_discount_logo'] ) : ?> | |
| 1007 | 898 | <a class="ultp-content-discount_btn" href="<?php echo esc_url( $url ); ?>" target="_blank"> |
| 1008 | 899 | <?php echo esc_html( $notice['button_text'] ); ?> |
| 1009 | 900 | </a> |
| 1010 | 901 | <?php else : ?> |
| @@ -1024,9 +915,9 @@ | ||
| 1024 | 915 | ); |
| 1025 | 916 | ?> |
| 1026 | 917 | class="ultp-content-notice-close"><span class="ultp-content-notice-close-icon dashicons dashicons-dismiss"> </span></a> |
| 1027 | 918 | </div> |
| 1028 | - <?php | |
| 919 | + <?php | |
| 1029 | 920 | } |
| 1030 | 921 | } |
| 1031 | 922 | } |
| 1032 | 923 | } |
| @@ -1038,9 +929,9 @@ | ||
| 1038 | 929 | * @param array $active_lists Lists of all active plugin notice. |
| 1039 | 930 | * @return array |
| 1040 | 931 | */ |
| 1041 | 932 | public function handle_xpo_active_notice_lists( $active_lists ) { |
| 1042 | - if ( $this->ultp_dashboard_banner_notice( true ) || $this->ultp_dashboard_content_notice( true ) ) { | |
| 933 | + if ( $this->ultp_dashboard_banner_notice( true ) || $this->ultp_dashboard_content_notice( true ) || $this->ultp_dashboard_image_banner_notice( true ) ) { | |
| 1043 | 934 | $active_lists[ $this->plugin_notice_priority_key ] = $this->plugin_notice_priority; |
| 1044 | 935 | } |
| 1045 | 936 | return $active_lists; |
| 1046 | 937 | } |
| @@ -1049,9 +940,34 @@ | ||
| 1049 | 940 | * Handle Plugin Notice for all plugins |
| 1050 | 941 | * |
| 1051 | 942 | * @return bool |
| 1052 | 943 | */ |
| 944 | + /** | |
| 945 | + * Whether the current admin screen belongs to PostX. | |
| 946 | + * | |
| 947 | + * Guideline 11 limits promotional UI to the plugin's own screens. Every PostX | |
| 948 | + * screen carries `ultp` in its screen id — `toplevel_page_ultp-settings`, | |
| 949 | + * `postx_page_ultp-setup-wizard`, and the `ultp_builder` / `ultp_templates` / | |
| 950 | + * `ultp_custom_font` post-type screens. | |
| 951 | + * | |
| 952 | + * @return BOOL True when the current screen is a PostX screen. | |
| 953 | + */ | |
| 954 | + public function is_postx_screen() { | |
| 955 | + if ( ! function_exists( 'get_current_screen' ) ) { | |
| 956 | + return false; | |
| 957 | + } | |
| 958 | + $screen = get_current_screen(); | |
| 959 | + return $screen && false !== strpos( $screen->id, 'ultp' ); | |
| 960 | + } | |
| 961 | + | |
| 1053 | 962 | public function is_available_for_notice() { |
| 963 | + // Guideline 11 — sale banners and upgrade prompts belong on PostX's own | |
| 964 | + // screens, not on core screens or other plugins' pages. | |
| 965 | + if ( ! $this->is_postx_screen() ) { | |
| 966 | + return false; | |
| 967 | + } | |
| 968 | + | |
| 969 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Shared across WPXPO plugins (ProductX, WholesaleX, …); renaming breaks them. | |
| 1054 | 970 | $active_notices = apply_filters( 'xpo_active_notice_lists', array() ); |
| 1055 | 971 | if ( empty( $active_notices ) ) { |
| 1056 | 972 | return true; |
| 1057 | 973 | } |
| @@ -1056,6 +972,144 @@ | ||
| 1056 | 972 | return true; |
| 1057 | 973 | } |
| 1058 | 974 | asort( $active_notices ); |
| 1059 | 975 | return array_key_first( $active_notices ) === $this->plugin_notice_priority_key; |
| 976 | + } | |
| 977 | + | |
| 978 | + public function ultp_dashboard_image_banner_notice( $return_bool = false ) { | |
| 979 | + $ultp_db_nonce = wp_create_nonce( 'ultp-admin-nonce' ); | |
| 980 | + $banner_notices = array( | |
| 981 | + array( | |
| 982 | + 'key' => 'ultp_summer_sale_2612', | |
| 983 | + 'start' => '2026-07-20 00:00 Asia/Dhaka', // format YY-MM-DD always set time 00:00 and zone Asia/Dhaka | |
| 984 | + 'end' => '2026-08-01 23:59 Asia/Dhaka', // format YY-MM-DD always set time 23:59 and zone Asia/Dhaka | |
| 985 | + 'banner_src' => ULTP_URL . 'assets/img/dashboard_banner/dashboard_banner_summer_sale.png', | |
| 986 | + 'url' => Xpo::generate_utm_link( | |
| 987 | + array( | |
| 988 | + 'utmKey' => 'sub_menu_offer', | |
| 989 | + ) | |
| 990 | + ), | |
| 991 | + 'close_color' => '#000000', | |
| 992 | + 'visibility' => ! Xpo::is_lc_active(), | |
| 993 | + ), | |
| 994 | + array( | |
| 995 | + 'key' => 'ultp_summer_sale_2613', | |
| 996 | + 'start' => '2026-08-09 00:00 Asia/Dhaka', // format YY-MM-DD always set time 00:00 and zone Asia/Dhaka | |
| 997 | + 'end' => '2026-08-16 23:59 Asia/Dhaka', // format YY-MM-DD always set time 23:59 and zone Asia/Dhaka | |
| 998 | + 'banner_src' => ULTP_URL . 'assets/img/dashboard_banner/dashboard_banner_summer_sale.png', | |
| 999 | + 'url' => Xpo::generate_utm_link( | |
| 1000 | + array( | |
| 1001 | + 'utmKey' => 'sub_menu_offer', | |
| 1002 | + ) | |
| 1003 | + ), | |
| 1004 | + 'close_color' => '#000000', | |
| 1005 | + 'visibility' => ! Xpo::is_lc_active(), | |
| 1006 | + ), | |
| 1007 | + array( | |
| 1008 | + 'key' => 'ultp_preco_sale_campaign_262_1', | |
| 1009 | + 'start' => '2026-08-23 00:00 Asia/Dhaka', // format YY-MM-DD always set time 00:00 and zone Asia/Dhaka | |
| 1010 | + 'end' => '2026-08-29 23:59 Asia/Dhaka', // format YY-MM-DD always set time 23:59 and zone Asia/Dhaka | |
| 1011 | + 'banner_src' => ULTP_URL . 'assets/img/dashboard_banner/preco_banner_insider_deal.png', | |
| 1012 | + 'url' => 'https://www.wpxpo.com/product/wowrecommend/?utm_source=db-postx-notice&utm_medium=insider-deal&utm_campaign=postx-dashboard/#pricing', | |
| 1013 | + 'close_color' => '#ffffff', | |
| 1014 | + 'visibility' => ! Xpo::is_lc_active(), | |
| 1015 | + ), | |
| 1016 | + array( | |
| 1017 | + 'key' => 'ultp_preco_sale_campaign_262_2', | |
| 1018 | + 'start' => '2026-08-30 00:00 Asia/Dhaka', // format YY-MM-DD always set time 00:00 and zone Asia/Dhaka. | |
| 1019 | + 'end' => '2026-09-19 23:59 Asia/Dhaka', // format YY-MM-DD always set time 23:59 and zone Asia/Dhaka. | |
| 1020 | + 'banner_src' => ULTP_URL . 'assets/img/dashboard_banner/preco_banner_early_bird.png', | |
| 1021 | + 'url' => 'https://www.wpxpo.com/product/wowrecommend/?utm_source=db-postx-notice&utm_medium=early-bird&utm_campaign=postx-dashboard/#pricing', | |
| 1022 | + 'close_color' => '#ffffff', | |
| 1023 | + 'visibility' => ! Xpo::is_lc_active(), | |
| 1024 | + ), | |
| 1025 | + ); | |
| 1026 | + | |
| 1027 | + foreach ( $banner_notices as $notice ) { | |
| 1028 | + $notice_key = isset( $notice['key'] ) ? $notice['key'] : $this->notice_version; | |
| 1029 | + if ( isset( $_GET['ultp_notice'] ) && $notice_key === sanitize_text_field(wp_unslash($_GET['ultp_notice'])) ) { // phpcs:ignore | |
| 1030 | + continue; | |
| 1031 | + } | |
| 1032 | + | |
| 1033 | + $current_time = gmdate( 'U' ); | |
| 1034 | + $notice_start = gmdate( 'U', strtotime( $notice['start'] ) ); | |
| 1035 | + $notice_end = gmdate( 'U', strtotime( $notice['end'] ) ); | |
| 1036 | + if ( $current_time >= $notice_start && $current_time <= $notice_end && $notice['visibility'] ) { | |
| 1037 | + | |
| 1038 | + $notice_transient = Xpo::get_transient_without_cache( 'ultp_get_pro_notice_' . $notice_key ); | |
| 1039 | + | |
| 1040 | + if ( 'off' === $notice_transient ) { | |
| 1041 | + continue; | |
| 1042 | + } | |
| 1043 | + | |
| 1044 | + if ( $return_bool ) { // Early return for Other plugin notice. | |
| 1045 | + return true; | |
| 1046 | + } | |
| 1047 | + | |
| 1048 | + if ( ! $this->notice_js_css_applied ) { | |
| 1049 | + $this->ultp_banner_notice_js(); | |
| 1050 | + $this->notice_js_css_applied = true; | |
| 1051 | + } | |
| 1052 | + $query_args = array( | |
| 1053 | + 'ultp_notice' => $notice_key, | |
| 1054 | + 'wpnonce' => $ultp_db_nonce, | |
| 1055 | + ); | |
| 1056 | + if ( isset( $notice['repeat_interval'] ) && $notice['repeat_interval'] ) { | |
| 1057 | + $query_args['ultp_interval'] = $notice['repeat_interval']; | |
| 1058 | + } | |
| 1059 | + ?> | |
| 1060 | + <style type="text/css"> | |
| 1061 | + .ultp-notice-wrapper.ultp-image-notice-wrapper { | |
| 1062 | + padding: 0 !important; | |
| 1063 | + position: relative; | |
| 1064 | + box-sizing: border-box; | |
| 1065 | + overflow: hidden; | |
| 1066 | + border-radius: 0px; | |
| 1067 | + border: none !important; | |
| 1068 | + } | |
| 1069 | + .ultp-notice-wrapper.ultp-image-notice-wrapper .ultp-image-banner { | |
| 1070 | + position: relative; | |
| 1071 | + line-height: 0; | |
| 1072 | + } | |
| 1073 | + .ultp-notice-wrapper.ultp-image-notice-wrapper .ultp-btn-image { | |
| 1074 | + display: block; | |
| 1075 | + } | |
| 1076 | + .ultp-notice-wrapper.ultp-image-notice-wrapper .ultp-btn-image img { | |
| 1077 | + display: block; | |
| 1078 | + width: 100%; | |
| 1079 | + height: auto; | |
| 1080 | + border-radius: 0; | |
| 1081 | + } | |
| 1082 | + .ultp-notice-wrapper.ultp-image-notice-wrapper .ultp-content-notice-close { | |
| 1083 | + top: 4px; | |
| 1084 | + right: 4px; | |
| 1085 | + position: absolute; | |
| 1086 | + z-index: 999; | |
| 1087 | + } | |
| 1088 | + @media screen and (max-width: 650px) { | |
| 1089 | + .ultp-image-notice-wrapper { | |
| 1090 | + display: none; | |
| 1091 | + } | |
| 1092 | + } | |
| 1093 | + </style> | |
| 1094 | + <div class="ultp-notice-wrapper ultp-image-notice-wrapper notice wc-install ultp-free-notice"> | |
| 1095 | + <div class="wc-install-body ultp-image-banner"> | |
| 1096 | + <a class="wc-dismiss-notice ultp-content-notice-close" href=" | |
| 1097 | + <?php | |
| 1098 | + echo esc_url( | |
| 1099 | + add_query_arg( | |
| 1100 | + $query_args | |
| 1101 | + ) | |
| 1102 | + ); | |
| 1103 | + ?> | |
| 1104 | + "><span class="ultp-content-notice-close-icon dashicons dashicons-dismiss" style="color: <?php echo esc_attr( $notice['close_color'] ); ?>;"> </span></a> | |
| 1105 | + <a class="ultp-btn-image" target="_blank" href="<?php echo esc_url( $notice['url'] ); ?>"> | |
| 1106 | + <img loading="lazy" src="<?php echo esc_url( $notice['banner_src'] ); ?>" alt="Discount Banner"/> | |
| 1107 | + </a> | |
| 1108 | + </div> | |
| 1109 | + </div> | |
| 1110 | + | |
| 1111 | + <?php | |
| 1112 | + } | |
| 1113 | + } | |
| 1060 | 1114 | } |
| 1061 | 1115 | } |