| @@ -70,15 +70,72 @@ | ||
| 70 | 70 | * @param array $links Default plugin action links. |
| 71 | 71 | * @return array Modified plugin action links. |
| 72 | 72 | */ |
| 73 | 73 | public function plugin_action_links_callback( $links ) { |
| 74 | + $offer_config = array( | |
| 75 | + array( | |
| 76 | + 'start' => '2026-07-06 00:00 Asia/Dhaka', | |
| 77 | + 'end' => '2026-08-01 23:59 Asia/Dhaka', | |
| 78 | + 'text' => __( | |
| 79 | + 'Summer Sale - Up to 50% OFF', | |
| 80 | + 'ultimate-post' | |
| 81 | + ), | |
| 82 | + 'utmKey' => 'summer_sale_meta', | |
| 83 | + ), | |
| 84 | + array( | |
| 85 | + 'start' => '2026-09-02 00:00 Asia/Dhaka', | |
| 86 | + 'end' => '2026-10-10 23:59 Asia/Dhaka', | |
| 87 | + 'text' => __( | |
| 88 | + 'Get Pro at $39', | |
| 89 | + 'ultimate-post' | |
| 90 | + ), | |
| 91 | + 'utmKey' => 'base_price_meta', | |
| 92 | + ), | |
| 93 | + ); | |
| 94 | + | |
| 74 | 95 | $setting_link = array( |
| 75 | 96 | 'ultp_options' => '<a href="' . esc_url( admin_url( 'admin.php?page=ultp-settings#startersites' ) ) . '">' . esc_html__( 'Starter Sites', 'ultimate-post' ) . '</a>', |
| 76 | 97 | ); |
| 77 | 98 | |
| 78 | - // The "Upgrade to Pro" / "Renew License" link is added after this by | |
| 79 | - // includes/notice/class-promo-links.php. | |
| 80 | - return array_merge( $setting_link, $links ); | |
| 99 | + $upgrade_link = array(); | |
| 100 | + | |
| 101 | + // Free user or expired license user. | |
| 102 | + if ( ! defined( 'ULTP_PRO_VER' ) || Xpo::is_lc_expired() ) { | |
| 103 | + | |
| 104 | + $license_key = Xpo::get_lc_key() ?? ''; | |
| 105 | + | |
| 106 | + if ( Xpo::is_lc_expired() ) { | |
| 107 | + $text = esc_html__( 'Renew License', 'ultimate-post' ); | |
| 108 | + $url = 'https://account.wpxpo.com/checkout/?edd_license_key=' . $license_key; | |
| 109 | + } else { | |
| 110 | + | |
| 111 | + $text = esc_html__( 'Upgrade to Pro', 'ultimate-post' ); | |
| 112 | + $url = Xpo::generate_utm_link( | |
| 113 | + array( | |
| 114 | + 'utmKey' => 'sub_menu', | |
| 115 | + ) | |
| 116 | + ); | |
| 117 | + | |
| 118 | + foreach ( $offer_config as $offer ) { | |
| 119 | + $current_time = gmdate( 'U' ); | |
| 120 | + $notice_start = gmdate( 'U', strtotime( $offer['start'] ) ); | |
| 121 | + $notice_end = gmdate( 'U', strtotime( $offer['end'] ) ); | |
| 122 | + if ( $current_time >= $notice_start && $current_time <= $notice_end ) { | |
| 123 | + $url = Xpo::generate_utm_link( | |
| 124 | + array( | |
| 125 | + 'utmKey' => $offer['utmKey'], | |
| 126 | + ) | |
| 127 | + ); | |
| 128 | + $text = $offer['text']; | |
| 129 | + break; | |
| 130 | + } | |
| 131 | + } | |
| 132 | + } | |
| 133 | + | |
| 134 | + $upgrade_link['ultp_pro'] = '<a style="color: #0062ff; font-weight: bold;" target="_blank" href="' . esc_url( $url ) . '">' . esc_html( $text ) . '</a>'; | |
| 135 | + } | |
| 136 | + | |
| 137 | + return array_merge( $setting_link, $links, $upgrade_link ); | |
| 81 | 138 | } |
| 82 | 139 | |
| 83 | 140 | |
| 84 | 141 | /** |
| @@ -139,9 +196,51 @@ | ||
| 139 | 196 | 'ultp-setup-wizard', |
| 140 | 197 | array( __CLASS__, 'ultp_wizard_page' ) |
| 141 | 198 | ); |
| 142 | 199 | |
| 143 | - // The "Upgrade to Pro" / "Renew License" item is added last by includes/notice/class-promo-links.php. | |
| 200 | + $pro_link = ''; | |
| 201 | + $pro_link_text = ''; | |
| 202 | + | |
| 203 | + // Check if current date is between November 5th and December 10th | |
| 204 | + $current_date = current_time( 'Y-m-d' ); | |
| 205 | + $start_date = gmdate( 'Y' ) . '-01-01'; // January 1st of current year | |
| 206 | + $end_date = gmdate( 'Y' ) . '-02-15'; // February 15th of current year | |
| 207 | + $menu_pro_text_period = ( $current_date >= $start_date && $current_date <= $end_date ); | |
| 208 | + | |
| 209 | + if ( ! Xpo::is_lc_active() ) { | |
| 210 | + $pro_link = Xpo::generate_utm_link( | |
| 211 | + array( | |
| 212 | + 'utmKey' => 'sub_menu', | |
| 213 | + ) | |
| 214 | + ); | |
| 215 | + $pro_link_text = $menu_pro_text_period ? __( 'New Year Offer!', 'ultimate-post' ) : __( 'Upgrade to Pro', 'ultimate-post' ); | |
| 216 | + } elseif ( Xpo::is_lc_expired() ) { | |
| 217 | + $license_key = Xpo::get_lc_key(); | |
| 218 | + $pro_link = 'https://account.wpxpo.com/checkout/?edd_license_key=' . $license_key; | |
| 219 | + $pro_link_text = __( 'Renew License', 'ultimate-post' ); | |
| 220 | + } | |
| 221 | + | |
| 222 | + if ( ! empty( $pro_link ) ) { | |
| 223 | + ob_start(); | |
| 224 | + ?> | |
| 225 | + <a href="<?php echo esc_url( $pro_link ); ?>" target="_blank" class="ultp-go-pro"> | |
| 226 | + <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"> | |
| 227 | + <path d="M2.86 6.553a.5.5 0 01.823-.482l3.02 2.745c.196.178.506.13.64-.098L9.64 4.779a.417.417 0 01.72 0l2.297 3.939a.417.417 0 00.64.098l3.02-2.745a.5.5 0 01.823.482l-1.99 8.63a.833.833 0 01-.813.646H5.663a.833.833 0 01-.812-.646L2.86 6.553z" stroke="currentColor" stroke-width="1.5"></path> | |
| 228 | + </svg> | |
| 229 | + <span><?php echo esc_html( $pro_link_text ); ?></span> | |
| 230 | + </a> | |
| 231 | + <?php | |
| 232 | + $submenu_content = ob_get_clean(); | |
| 233 | + | |
| 234 | + add_submenu_page( | |
| 235 | + 'ultp-settings', | |
| 236 | + '', | |
| 237 | + $submenu_content, | |
| 238 | + 'manage_options', | |
| 239 | + 'ultp-pro', | |
| 240 | + array( self::class, 'handle_external_redirects' ) | |
| 241 | + ); | |
| 242 | + } | |
| 144 | 243 | |
| 145 | 244 | add_theme_page( |
| 146 | 245 | __( 'Starter Sites', 'ultimate-post' ), |
| 147 | 246 | __( 'Starter Sites', 'ultimate-post' ), |