| @@ -30,8 +30,9 @@ | ||
| 30 | 30 | */ |
| 31 | 31 | public function __construct() { |
| 32 | 32 | add_action( 'admin_init', array( $this, 'handle_external_redirects' ) ); |
| 33 | 33 | add_action( 'admin_menu', array( $this, 'menu_page_callback' ) ); |
| 34 | + add_action( 'admin_footer', array( $this, 'sync_addon_submenu_visibility' ) ); | |
| 34 | 35 | add_action( 'in_admin_header', array( $this, 'remove_all_notices' ) ); |
| 35 | 36 | add_filter( 'plugin_row_meta', array( $this, 'plugin_settings_meta' ), 10, 2 ); |
| 36 | 37 | add_filter( 'plugin_action_links_' . ULTP_BASE, array( $this, 'plugin_action_links_callback' ) ); |
| 37 | 38 | } |
| @@ -70,51 +71,26 @@ | ||
| 70 | 71 | * @return array Modified plugin action links. |
| 71 | 72 | */ |
| 72 | 73 | public function plugin_action_links_callback( $links ) { |
| 73 | 74 | $offer_config = array( |
| 74 | - // Flash sale | |
| 75 | 75 | array( |
| 76 | - 'start' => '2026-05-07 00:00 Asia/Dhaka', | |
| 77 | - 'end' => '2026-05-21 23:59 Asia/Dhaka', | |
| 76 | + 'start' => '2026-07-06 00:00 Asia/Dhaka', | |
| 77 | + 'end' => '2026-08-01 23:59 Asia/Dhaka', | |
| 78 | 78 | 'text' => __( |
| 79 | - 'Flash Sale - Up to 45% OFF', | |
| 79 | + 'Summer Sale - Up to 50% OFF', | |
| 80 | 80 | 'ultimate-post' |
| 81 | 81 | ), |
| 82 | - 'utmKey' => 'flash_sale_meta', | |
| 82 | + 'utmKey' => 'summer_sale_meta', | |
| 83 | 83 | ), |
| 84 | - | |
| 85 | - // Surprise Sale | |
| 86 | 84 | array( |
| 87 | - 'start' => '2026-05-22 00:00 Asia/Dhaka', | |
| 88 | - 'end' => '2026-06-01 23:59 Asia/Dhaka', | |
| 85 | + 'start' => '2026-09-02 00:00 Asia/Dhaka', | |
| 86 | + 'end' => '2026-10-10 23:59 Asia/Dhaka', | |
| 89 | 87 | 'text' => __( |
| 90 | - 'Surprise Sale - Up to 50% OFF', | |
| 88 | + 'Get Pro at $39', | |
| 91 | 89 | 'ultimate-post' |
| 92 | 90 | ), |
| 93 | - 'utmKey' => 'surprise_sale_meta', | |
| 91 | + 'utmKey' => 'base_price_meta', | |
| 94 | 92 | ), |
| 95 | - | |
| 96 | - // Massive Sale | |
| 97 | - array( | |
| 98 | - 'start' => '2026-06-02 00:00 Asia/Dhaka', | |
| 99 | - 'end' => '2026-06-20 23:59 Asia/Dhaka', | |
| 100 | - 'text' => __( | |
| 101 | - 'Massive Sale - Up to 50% OFF', | |
| 102 | - 'ultimate-post' | |
| 103 | - ), | |
| 104 | - 'utmKey' => 'massive_sale_meta', | |
| 105 | - ), | |
| 106 | - | |
| 107 | - // Final hours sale | |
| 108 | - array( | |
| 109 | - 'start' => '2026-06-21 00:00 Asia/Dhaka', | |
| 110 | - 'end' => '2026-06-30 23:59 Asia/Dhaka', | |
| 111 | - 'text' => __( | |
| 112 | - 'Final Hours Sale - Up to 50% OFF', | |
| 113 | - 'ultimate-post' | |
| 114 | - ), | |
| 115 | - 'utmKey' => 'final_hour_meta', | |
| 116 | - ), | |
| 117 | 93 | ); |
| 118 | 94 | |
| 119 | 95 | $setting_link = array( |
| 120 | 96 | 'ultp_options' => '<a href="' . esc_url( admin_url( 'admin.php?page=ultp-settings#startersites' ) ) . '">' . esc_html__( 'Starter Sites', 'ultimate-post' ) . '</a>', |
| @@ -132,9 +108,13 @@ | ||
| 132 | 108 | $url = 'https://account.wpxpo.com/checkout/?edd_license_key=' . $license_key; |
| 133 | 109 | } else { |
| 134 | 110 | |
| 135 | 111 | $text = esc_html__( 'Upgrade to Pro', 'ultimate-post' ); |
| 136 | - $url = Xpo::generate_utm_link(); | |
| 112 | + $url = Xpo::generate_utm_link( | |
| 113 | + array( | |
| 114 | + 'utmKey' => 'sub_menu', | |
| 115 | + ) | |
| 116 | + ); | |
| 137 | 117 | |
| 138 | 118 | foreach ( $offer_config as $offer ) { |
| 139 | 119 | $current_time = gmdate( 'U' ); |
| 140 | 120 | $notice_start = gmdate( 'U', strtotime( $offer['start'] ) ); |
| @@ -221,10 +201,10 @@ | ||
| 221 | 201 | $pro_link_text = ''; |
| 222 | 202 | |
| 223 | 203 | // Check if current date is between November 5th and December 10th |
| 224 | 204 | $current_date = current_time( 'Y-m-d' ); |
| 225 | - $start_date = date( 'Y' ) . '-01-01'; // January 1st of current year | |
| 226 | - $end_date = date( 'Y' ) . '-02-15'; // February 15th of current year | |
| 205 | + $start_date = gmdate( 'Y' ) . '-01-01'; // January 1st of current year | |
| 206 | + $end_date = gmdate( 'Y' ) . '-02-15'; // February 15th of current year | |
| 227 | 207 | $menu_pro_text_period = ( $current_date >= $start_date && $current_date <= $end_date ); |
| 228 | 208 | |
| 229 | 209 | if ( ! Xpo::is_lc_active() ) { |
| 230 | 210 | $pro_link = Xpo::generate_utm_link( |
| @@ -270,8 +250,46 @@ | ||
| 270 | 250 | ); |
| 271 | 251 | } |
| 272 | 252 | |
| 273 | 253 | /** |
| 254 | + * Sync addon-backed WordPress submenu items with addon enabled status. | |
| 255 | + * | |
| 256 | + * @since v.4.1.7 | |
| 257 | + * @return void No return value. | |
| 258 | + */ | |
| 259 | + public function sync_addon_submenu_visibility() { | |
| 260 | + $settings = ultimate_post()->get_setting(); | |
| 261 | + $submenus = array( | |
| 262 | + 'builder' => 'ultp_builder', | |
| 263 | + 'saved-templates' => 'ultp_templates', | |
| 264 | + 'custom-font' => 'ultp_custom_font', | |
| 265 | + ); | |
| 266 | + | |
| 267 | + foreach ( $submenus as $slug => $setting_key ) { | |
| 268 | + $submenus[ $slug ] = isset( $settings[ $setting_key ] ) && $settings[ $setting_key ] !== 'false'; | |
| 269 | + } | |
| 270 | + ?> | |
| 271 | + <script> | |
| 272 | + ( function() { | |
| 273 | + const postxAddonSubmenus = <?php echo wp_json_encode( $submenus ); ?>; | |
| 274 | + | |
| 275 | + Object.keys( postxAddonSubmenus ).forEach( function( slug ) { | |
| 276 | + const link = document.querySelector( '#adminmenu a[href*="page=ultp-settings#' + slug + '"]' ); | |
| 277 | + const item = link ? link.closest( 'li' ) : null; | |
| 278 | + | |
| 279 | + if ( ! item ) { | |
| 280 | + return; | |
| 281 | + } | |
| 282 | + | |
| 283 | + item.id = 'postx-submenu-' + slug; | |
| 284 | + item.style.display = postxAddonSubmenus[ slug ] ? '' : 'none'; | |
| 285 | + } ); | |
| 286 | + }() ); | |
| 287 | + </script> | |
| 288 | + <?php | |
| 289 | + } | |
| 290 | + | |
| 291 | + /** | |
| 274 | 292 | * Handle external redirects for menu and pro links. |
| 275 | 293 | * |
| 276 | 294 | * @since v.1.0.0 |
| 277 | 295 | * @return void No return value. |
| @@ -279,13 +297,14 @@ | ||
| 279 | 297 | public function handle_external_redirects() { |
| 280 | 298 | if (empty($_GET['page'])) { // @codingStandardsIgnoreLine |
| 281 | 299 | return; |
| 282 | 300 | } |
| 283 | - $_page = sanitize_key( $_GET['page'] ); | |
| 301 | + $_page = sanitize_key( $_GET['page'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only admin page slug. | |
| 284 | 302 | if ('ultp-startersites' === $_page) { // @codingStandardsIgnoreLine |
| 285 | - exit( wp_safe_redirect( admin_url( 'admin.php?page=ultp-settings#startersites' ) ) ); | |
| 303 | + wp_safe_redirect( admin_url( 'admin.php?page=ultp-settings#startersites' ) ); | |
| 304 | + exit; | |
| 286 | 305 | } else if ('go_postx_pro' === $_page) { // @codingStandardsIgnoreLine |
| 287 | - wp_redirect( | |
| 306 | + wp_redirect( // phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect -- Intentional redirect to the fixed wpxpo.com pricing URL. | |
| 288 | 307 | Xpo::generate_utm_link( |
| 289 | 308 | array( |
| 290 | 309 | 'utmKey' => 'dashboard_go_pro', |
| 291 | 310 | ) |