| @@ -1,12 +1,10 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace Better_Payment\Lite; |
| 4 | 4 | |
| 5 | -use Better_Payment\Lite\Admin\Settings; | |
| 6 | 5 | use Better_Payment\Lite\Admin\ReactAdmin; |
| 7 | 6 | use Better_Payment\Lite\Admin\Elementor\Widget; |
| 8 | -use Better_Payment\Lite\Admin\Menu; | |
| 9 | 7 | use Better_Payment\Lite\Classes\Helper; |
| 10 | 8 | use Better_Payment\Lite\Classes\Export; |
| 11 | 9 | use Better_Payment\Lite\Classes\Import; |
| 12 | 10 | use PriyoMukul\WPNotice\Notices; |
| @@ -44,9 +42,8 @@ | ||
| 44 | 42 | public function init(){ |
| 45 | 43 | $this->pro_enabled = apply_filters('better_payment/pro_enabled', false); |
| 46 | 44 | |
| 47 | 45 | new ReactAdmin(); |
| 48 | - // new Settings(); | |
| 49 | 46 | |
| 50 | 47 | // Add plugin action links - works with or without Elementor |
| 51 | 48 | add_filter('plugin_action_links', array($this, 'plugin_actions_links'), 10, 2); |
| 52 | 49 | |
| @@ -51,11 +48,16 @@ | ||
| 51 | 48 | add_filter('plugin_action_links', array($this, 'plugin_actions_links'), 10, 2); |
| 52 | 49 | |
| 53 | 50 | if ( ! $this->pro_enabled ) { |
| 54 | 51 | $this->admin_notice(); |
| 55 | - $this->start_plugin_tracking(); | |
| 56 | 52 | } |
| 57 | 53 | |
| 54 | + // Usage tracking is NOT registered here any more. It is wired from | |
| 55 | + // Better_Payment::init_plugin() for admin *and* cron requests, because | |
| 56 | + // WP-Cron runs as a non-admin request and this gate hid the tracker's | |
| 57 | + // do_tracking() callback from its own scheduled event. See the note | |
| 58 | + // there. The Pro gate now lives in Helper::start_plugin_tracking(). | |
| 59 | + | |
| 58 | 60 | add_action('in_admin_header', array( $this, 'hide_admin_notices' )); |
| 59 | 61 | } |
| 60 | 62 | |
| 61 | 63 | /** |
| @@ -154,119 +156,25 @@ | ||
| 154 | 156 | 'dismissible' => true, |
| 155 | 157 | ] |
| 156 | 158 | ); |
| 157 | 159 | |
| 158 | - /** | |
| 159 | - * Halloween Notice | |
| 160 | - */ | |
| 161 | - // $crown_icon = BETTER_PAYMENT_URL . '/assets/img/crown.svg'; | |
| 162 | - // $halloween_notice_message = "<p>🎃 Manage Payment forms better with Better Payment PRO and grab a <strong>flat 25% OFF</strong> this Halloween.</p><a style='display: inline-flex;column-gap:5px;' class='button button-primary' href='https://betterpayment.co/#pricing-plan' target='_blank'><img style='width:15px;' src='{$crown_icon}'/>Upgrade to PRO</a>"; | |
| 163 | - | |
| 164 | - // $halloween_notice = [ | |
| 165 | - // 'thumbnail' => plugins_url( 'assets/img/logo.svg', BETTER_PAYMENT_BASENAME ), | |
| 166 | - // 'html' => $halloween_notice_message, | |
| 167 | - // ]; | |
| 168 | - | |
| 169 | - // $notices->add( | |
| 170 | - // 'halloween_notice', | |
| 171 | - // $halloween_notice, | |
| 172 | - // [ | |
| 173 | - // 'start' => $notices->time(), | |
| 174 | - // // 'start' => $notices->strtotime( '+7 day' ), | |
| 175 | - // // 'recurrence' => 30, | |
| 176 | - // 'expire' => $notices->strtotime( '+10 days' ), | |
| 177 | - // 'refresh' => BETTER_PAYMENT_VERSION, | |
| 178 | - // 'dismissible' => true, | |
| 179 | - // 'screens' => [ 'dashboard' ], | |
| 180 | - // ] | |
| 181 | - // ); | |
| 182 | - | |
| 183 | - /** | |
| 184 | - * Black Friday Notice | |
| 185 | - */ | |
| 186 | - $purchase_url = 'https://betterpayment.co/bfcm2025-admin-notice'; | |
| 187 | - $black_friday_notice_message = "<p><strong>Black Friday Mega Sale:</strong> Streamline Transactions With Fast, Optimized Payment Forms For Elementor Sites – Now <strong>Up to $200 OFF! 🎁</strong> </p><div class='wpsp-notice-action-button' style='display: inline-flex;column-gap:5px;'><a class='button button-primary' href='{$purchase_url}' target='_blank'>Upgrade To PRO</a> <button class='wpsp-notice-action-dismiss dismiss-btn' data-dismiss='true' target='_blank'>I’ll Grab It Later</button></div>"; | |
| 188 | - | |
| 189 | - $black_friday_notice = [ | |
| 190 | - 'thumbnail' => plugins_url( 'assets/img/logo.svg', BETTER_PAYMENT_BASENAME ), | |
| 191 | - 'html' => $black_friday_notice_message, | |
| 192 | - ]; | |
| 193 | - | |
| 194 | - $notices->add( | |
| 195 | - 'black_friday_notice1', | |
| 196 | - $black_friday_notice, | |
| 197 | - [ | |
| 198 | - 'start' => $notices->time(), | |
| 199 | - 'expire' => strtotime( '11:59:59pm 4th December, 2025' ), | |
| 200 | - 'refresh' => BETTER_PAYMENT_VERSION, | |
| 201 | - 'dismissible' => true, | |
| 202 | - 'screens' => [ 'dashboard' ], | |
| 203 | - ] | |
| 204 | - ); | |
| 205 | - | |
| 206 | 160 | /** |
| 207 | - * Holiday Notice | |
| 161 | + * Summer Offer Notice | |
| 208 | 162 | */ |
| 209 | - $purchase_url = '//betterpayment.co/holiday2025-admin-notice'; | |
| 210 | - $holiday_notice_message = "<p><strong>Season’s Best Deal:</strong> Streamline transactions with fast, optimized payment forms for Elementor sites - <strong>Up to 25% OFF! 💳</strong> </p><div class='wpsp-notice-action-button' style='display: inline-flex;column-gap:5px;'><a class='button button-primary' href='{$purchase_url}' target='_blank'>Upgrade To PRO</a> <button class='wpsp-notice-action-dismiss dismiss-btn' data-dismiss='true' target='_blank'>I’ll Grab It Later</button></div>"; | |
| 211 | - | |
| 212 | - $holiday_notice = [ | |
| 213 | - 'thumbnail' => plugins_url( 'assets/img/logo.svg', BETTER_PAYMENT_BASENAME ), | |
| 214 | - 'html' => $holiday_notice_message, | |
| 215 | - ]; | |
| 163 | + $purchase_url = '//betterpayment.co/summer2026-admin-notice'; | |
| 164 | + $summer_notice_message = "<p>🏖️ <strong>Summer Savings:</strong> Streamline transactions with fast, optimized payment forms on your WordPress sites – now <strong>up to $150 OFF!</strong> </p><div class='wpsp-notice-action-button' style='display: inline-flex;column-gap:5px;'><a class='button button-primary' href='{$purchase_url}' target='_blank'>Upgrade To Pro Now</a> <button class='wpsp-notice-action-dismiss dismiss-btn' data-dismiss='true' target='_blank'>I Don't Want Any Discount</button></div>"; | |
| 216 | 165 | |
| 217 | - $notices->add( | |
| 218 | - 'bp_holiday_notice', | |
| 219 | - $holiday_notice, | |
| 220 | - [ | |
| 221 | - 'start' => strtotime( '12:00:00am 15th December, 2025' ), | |
| 222 | - 'expire' => strtotime( '11:59:59pm 7th January, 2026' ), | |
| 223 | - 'refresh' => BETTER_PAYMENT_VERSION, | |
| 224 | - 'dismissible' => true, | |
| 225 | - 'screens' => [ 'dashboard' ], | |
| 226 | - ] | |
| 227 | - ); | |
| 228 | - | |
| 229 | - /** | |
| 230 | - * February Offer Notice | |
| 231 | - */ | |
| 232 | - $purchase_url = '//betterpayment.co/feb2026-admin-notice'; | |
| 233 | - $february_notice_message = "<p>Streamline transactions with fast, optimized payment forms for Elementor sites - Now <strong>Flat 20% OFF! 🎁</strong> </p><div class='wpsp-notice-action-button' style='display: inline-flex;column-gap:5px;'><a class='button button-primary' href='{$purchase_url}' target='_blank'>Upgrade To PRO</a> <button class='wpsp-notice-action-dismiss dismiss-btn' data-dismiss='true' target='_blank'>I’ll Grab It Later</button></div>"; | |
| 234 | - | |
| 235 | - $friday_notice = [ | |
| 166 | + $summer_notice = [ | |
| 236 | 167 | 'thumbnail' => plugins_url( 'assets/img/logo.svg', BETTER_PAYMENT_BASENAME ), |
| 237 | - 'html' => $february_notice_message, | |
| 168 | + 'html' => $summer_notice_message, | |
| 238 | 169 | ]; |
| 239 | 170 | |
| 240 | 171 | $notices->add( |
| 241 | - 'bp_february_notice', | |
| 242 | - $friday_notice, | |
| 172 | + 'bp_summer_notice', | |
| 173 | + $summer_notice, | |
| 243 | 174 | [ |
| 244 | - 'start' => strtotime( '12:00:00am 10th February, 2026' ), | |
| 245 | - 'expire' => strtotime( '11:59:59pm 7th March, 2026' ), | |
| 246 | - 'refresh' => BETTER_PAYMENT_VERSION, | |
| 247 | - 'dismissible' => true, | |
| 248 | - 'screens' => [ 'dashboard' ], | |
| 249 | - ] | |
| 250 | - ); | |
| 251 | - | |
| 252 | - /** | |
| 253 | - * Spring Offer Notice | |
| 254 | - */ | |
| 255 | - $purchase_url = '//betterpayment.co/spring2026-admin-notice'; | |
| 256 | - $spring_notice_message = "<p>🌸 <strong>Spring Savings:</strong> Streamline transactions with fast, optimized payment forms on your Elementor sites – now <strong>Flat 25% OFF! 💳️</strong> </p><div class='wpsp-notice-action-button' style='display: inline-flex;column-gap:5px;'><a class='button button-primary' href='{$purchase_url}' target='_blank'>Upgrade To Pro Now</a> <button class='wpsp-notice-action-dismiss dismiss-btn' data-dismiss='true' target='_blank'>Maybe Later</button></div>"; | |
| 257 | - | |
| 258 | - $spring_notice = [ | |
| 259 | - 'thumbnail' => plugins_url( 'assets/img/logo.svg', BETTER_PAYMENT_BASENAME ), | |
| 260 | - 'html' => $spring_notice_message, | |
| 261 | - ]; | |
| 262 | - | |
| 263 | - $notices->add( | |
| 264 | - 'bp_spring_notice', | |
| 265 | - $spring_notice, | |
| 266 | - [ | |
| 267 | 175 | 'start' => $notices->time(), |
| 268 | - 'expire' => strtotime( '11:59:59pm 10th May, 2026' ), | |
| 176 | + 'expire' => strtotime( '11:59:59pm 25th June, 2026' ), | |
| 269 | 177 | 'refresh' => BETTER_PAYMENT_VERSION, |
| 270 | 178 | 'dismissible' => true, |
| 271 | 179 | 'screens' => [ 'dashboard' ], |
| 272 | 180 | ] |
| @@ -278,9 +186,9 @@ | ||
| 278 | 186 | |
| 279 | 187 | public function hide_admin_notices(){ |
| 280 | 188 | $current_screen = get_current_screen(); |
| 281 | 189 | |
| 282 | - if ($current_screen && str_contains( $current_screen->id, 'better-payment' ) ) { | |
| 190 | + if ($current_screen && (false !== strpos( $current_screen->id, 'better-payment' ) || false !== strpos( $current_screen->id, 'bp-campaign' )) ) { | |
| 283 | 191 | remove_all_actions('user_admin_notices'); |
| 284 | 192 | remove_all_actions('admin_notices'); |
| 285 | 193 | remove_all_actions('all_admin_notices'); |
| 286 | 194 | remove_all_actions('network_admin_notices'); |
| @@ -298,11 +206,8 @@ | ||
| 298 | 206 | * @return void |
| 299 | 207 | * @since 0.0.1 |
| 300 | 208 | */ |
| 301 | 209 | public static function dispatch_actions( ) { |
| 302 | - $menuObj = new Menu(); | |
| 303 | - $menuObj->init(); | |
| 304 | - | |
| 305 | 210 | $bpElementorWidgetObj = new Widget(); |
| 306 | 211 | |
| 307 | 212 | $bpImportObj = new Import(); |
| 308 | 213 | |