| @@ -1,14 +1,13 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace Better_Payment\Lite; |
| 4 | 4 | |
| 5 | -use Better_Payment\Lite\Admin\Better_Payment_Settings; | |
| 6 | -use Better_Payment\Lite\Admin\Elementor\Better_Payment_Widget; | |
| 5 | +use Better_Payment\Lite\Admin\ReactAdmin; | |
| 7 | 6 | use Better_Payment\Lite\Admin\Elementor\Widget; |
| 8 | -use Better_Payment\Lite\Admin\Menu; | |
| 9 | -use Better_Payment\Lite\Classes\Better_Payment_Helper; | |
| 7 | +use Better_Payment\Lite\Classes\Helper; | |
| 10 | 8 | use Better_Payment\Lite\Classes\Export; |
| 9 | +use Better_Payment\Lite\Classes\Import; | |
| 11 | 10 | use PriyoMukul\WPNotice\Notices; |
| 12 | 11 | use PriyoMukul\WPNotice\Utils\CacheBank; |
| 13 | 12 | use PriyoMukul\WPNotice\Utils\NoticeRemover; |
| 14 | 13 | |
| @@ -42,24 +41,24 @@ | ||
| 42 | 41 | |
| 43 | 42 | public function init(){ |
| 44 | 43 | $this->pro_enabled = apply_filters('better_payment/pro_enabled', false); |
| 45 | 44 | |
| 46 | - if ( defined( 'ELEMENTOR_VERSION' ) ) { | |
| 47 | - new Better_Payment_Settings(); | |
| 48 | - } | |
| 45 | + new ReactAdmin(); | |
| 49 | 46 | |
| 50 | - if (!did_action('elementor/loaded')) { | |
| 51 | - $notice = new Better_Payment_Helper(); | |
| 52 | - $notice->elementor_not_loaded(); | |
| 53 | - } | |
| 47 | + // Add plugin action links - works with or without Elementor | |
| 48 | + add_filter('plugin_action_links', array($this, 'plugin_actions_links'), 10, 2); | |
| 54 | 49 | |
| 55 | - if (did_action('elementor/loaded')) { | |
| 56 | - add_filter('plugin_action_links', array($this, 'plugin_actions_links'), 10, 2); | |
| 57 | - } | |
| 58 | - | |
| 59 | 50 | if ( ! $this->pro_enabled ) { |
| 60 | 51 | $this->admin_notice(); |
| 61 | 52 | } |
| 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 | + | |
| 60 | + add_action('in_admin_header', array( $this, 'hide_admin_notices' )); | |
| 62 | 61 | } |
| 63 | 62 | |
| 64 | 63 | /** |
| 65 | 64 | * Add settings page link on plugins page |
| @@ -73,9 +72,9 @@ | ||
| 73 | 72 | public function plugin_actions_links($links, $file) { |
| 74 | 73 | $better_payment_plugin = plugin_basename(BETTER_PAYMENT_FILE); |
| 75 | 74 | |
| 76 | 75 | if ($file == $better_payment_plugin && current_user_can('manage_options')) { |
| 77 | - $links[] = sprintf('<a href="%s">%s</a>', admin_url("admin.php?page=better-payment-settings"), __('Settings', 'better-payment')); | |
| 76 | + $links[] = sprintf('<a href="%s">%s</a>', admin_url("admin.php?page=better-payment-admin&tab=settings"), __('Settings', 'better-payment')); | |
| 78 | 77 | |
| 79 | 78 | if ( ! $this->pro_enabled ) { |
| 80 | 79 | $links[] = sprintf('<a href="https://wpdeveloper.com/in/upgrade-better-payment-pro" target="_blank" style="color: #7561F8; font-weight: bold;">' . __('Go Pro', 'better-payment') . '</a>'); |
| 81 | 80 | } |
| @@ -100,9 +99,9 @@ | ||
| 100 | 99 | 'styles' => esc_url_raw( BETTER_PAYMENT_URL . '/assets/css/admin.min.css' ), |
| 101 | 100 | 'priority' => 9 |
| 102 | 101 | ] ); |
| 103 | 102 | |
| 104 | - $review_notice = __( 'We hope you\'re enjoying Better Payment! Could you please do us a BIG favor and give it a 5-star rating on WordPress to help us spread the word and boost our motivation?', 'better-payment' ); | |
| 103 | + $review_notice = 'We hope you\'re enjoying Better Payment! Could you please do us a BIG favor and give it a 5-star rating on WordPress to help us spread the word and boost our motivation?'; | |
| 105 | 104 | $_review_notice = [ |
| 106 | 105 | 'thumbnail' => plugins_url( 'assets/img/logo.svg', BETTER_PAYMENT_BASENAME ), |
| 107 | 106 | 'html' => '<p>' . $review_notice . '</p>', |
| 108 | 107 | 'links' => [ |
| @@ -108,9 +107,9 @@ | ||
| 108 | 107 | 'links' => [ |
| 109 | 108 | 'later' => array( |
| 110 | 109 | 'link' => '//wordpress.org/support/plugin/better-payment/reviews/#new-post', |
| 111 | 110 | 'target' => '_blank', |
| 112 | - 'label' => __( 'Ok, you deserve it!', 'better-payment' ), | |
| 111 | + 'label' => 'Ok, you deserve it!', | |
| 113 | 112 | 'icon_class' => 'dashicons dashicons-external', |
| 114 | 113 | 'attributes' => [ |
| 115 | 114 | 'target' => '_blank', |
| 116 | 115 | ], |
| @@ -115,9 +114,9 @@ | ||
| 115 | 114 | 'target' => '_blank', |
| 116 | 115 | ], |
| 117 | 116 | ), |
| 118 | 117 | 'allready' => array( |
| 119 | - 'label' => __( 'I already did', 'better-payment' ), | |
| 118 | + 'label' => 'I already did', | |
| 120 | 119 | 'icon_class' => 'dashicons dashicons-smiley', |
| 121 | 120 | 'attributes' => [ |
| 122 | 121 | 'data-dismiss' => true |
| 123 | 122 | ], |
| @@ -122,9 +121,9 @@ | ||
| 122 | 121 | 'data-dismiss' => true |
| 123 | 122 | ], |
| 124 | 123 | ), |
| 125 | 124 | 'maybe_later' => array( |
| 126 | - 'label' => __( 'Maybe Later', 'better-payment' ), | |
| 125 | + 'label' => 'Maybe Later', | |
| 127 | 126 | 'icon_class' => 'dashicons dashicons-calendar-alt', |
| 128 | 127 | 'attributes' => [ |
| 129 | 128 | 'data-later' => true |
| 130 | 129 | ], |
| @@ -130,9 +129,9 @@ | ||
| 130 | 129 | ], |
| 131 | 130 | ), |
| 132 | 131 | 'support' => array( |
| 133 | 132 | 'link' => 'https://wpdeveloper.com/support', |
| 134 | - 'label' => __( 'I need help', 'better-payment' ), | |
| 133 | + 'label' => 'I need help', | |
| 135 | 134 | 'icon_class' => 'dashicons dashicons-sos', |
| 136 | 135 | 'attributes' => [ |
| 137 | 136 | 'target' => '_blank', |
| 138 | 137 | ], |
| @@ -137,9 +136,9 @@ | ||
| 137 | 136 | 'target' => '_blank', |
| 138 | 137 | ], |
| 139 | 138 | ), |
| 140 | 139 | 'never_show_again' => array( |
| 141 | - 'label' => __( 'Never show again', 'better-payment' ), | |
| 140 | + 'label' => 'Never show again', | |
| 142 | 141 | 'icon_class' => 'dashicons dashicons-dismiss', |
| 143 | 142 | 'attributes' => [ |
| 144 | 143 | 'data-dismiss' => true |
| 145 | 144 | ], |
| @@ -157,12 +156,51 @@ | ||
| 157 | 156 | 'dismissible' => true, |
| 158 | 157 | ] |
| 159 | 158 | ); |
| 160 | 159 | |
| 160 | + /** | |
| 161 | + * Summer Offer Notice | |
| 162 | + */ | |
| 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>"; | |
| 165 | + | |
| 166 | + $summer_notice = [ | |
| 167 | + 'thumbnail' => plugins_url( 'assets/img/logo.svg', BETTER_PAYMENT_BASENAME ), | |
| 168 | + 'html' => $summer_notice_message, | |
| 169 | + ]; | |
| 170 | + | |
| 171 | + $notices->add( | |
| 172 | + 'bp_summer_notice', | |
| 173 | + $summer_notice, | |
| 174 | + [ | |
| 175 | + 'start' => $notices->time(), | |
| 176 | + 'expire' => strtotime( '11:59:59pm 25th June, 2026' ), | |
| 177 | + 'refresh' => BETTER_PAYMENT_VERSION, | |
| 178 | + 'dismissible' => true, | |
| 179 | + 'screens' => [ 'dashboard' ], | |
| 180 | + ] | |
| 181 | + ); | |
| 182 | + | |
| 161 | 183 | self::$cache_bank->create_account( $notices ); |
| 162 | 184 | self::$cache_bank->calculate_deposits( $notices ); |
| 163 | 185 | } |
| 164 | 186 | |
| 187 | + public function hide_admin_notices(){ | |
| 188 | + $current_screen = get_current_screen(); | |
| 189 | + | |
| 190 | + if ($current_screen && (false !== strpos( $current_screen->id, 'better-payment' ) || false !== strpos( $current_screen->id, 'bp-campaign' )) ) { | |
| 191 | + remove_all_actions('user_admin_notices'); | |
| 192 | + remove_all_actions('admin_notices'); | |
| 193 | + remove_all_actions('all_admin_notices'); | |
| 194 | + remove_all_actions('network_admin_notices'); | |
| 195 | + | |
| 196 | + // To show notice in better payment settings page we have to use 'better_payment_admin_notices' action hook | |
| 197 | + add_action( 'admin_notices', function () { | |
| 198 | + do_action( 'better_payment_admin_notices' ); | |
| 199 | + } ); | |
| 200 | + } | |
| 201 | + } | |
| 202 | + | |
| 165 | 203 | /** |
| 166 | 204 | * Dispatch and bind actions |
| 167 | 205 | * |
| 168 | 206 | * @return void |
| @@ -168,15 +206,16 @@ | ||
| 168 | 206 | * @return void |
| 169 | 207 | * @since 0.0.1 |
| 170 | 208 | */ |
| 171 | 209 | public static function dispatch_actions( ) { |
| 172 | - $menuObj = new Menu(); | |
| 173 | - $menuObj->init(); | |
| 174 | - | |
| 175 | 210 | $bpElementorWidgetObj = new Widget(); |
| 176 | 211 | |
| 212 | + $bpImportObj = new Import(); | |
| 213 | + | |
| 177 | 214 | $bpExportObj = new Export(); |
| 178 | 215 | |
| 216 | + $helperObj = new Helper(); | |
| 217 | + | |
| 179 | 218 | // Handle select2 ajax search |
| 180 | 219 | add_action('wp_ajax_better_payment_select2_search_post', [$bpElementorWidgetObj, 'select2_ajax_posts_filter_autocomplete']); |
| 181 | 220 | |
| 182 | 221 | add_action('wp_ajax_better_payment_select2_get_title', [$bpElementorWidgetObj, 'select2_ajax_get_posts_value_titles']); |
| @@ -184,7 +223,11 @@ | ||
| 184 | 223 | // Elements |
| 185 | 224 | add_action('elementor/controls/controls_registered',[$bpElementorWidgetObj, 'register_controls']); |
| 186 | 225 | |
| 187 | 226 | //Page: Transactions |
| 227 | + add_action('admin_post_better-payment-transactions-import',[$bpImportObj, 'import_transactions']); | |
| 188 | 228 | add_action('wp_ajax_better-payment-transactions-export',[$bpExportObj, 'export_transactions']); |
| 229 | + | |
| 230 | + // Elementor categories | |
| 231 | + add_action('elementor/elements/categories_registered', [$helperObj, 'register_widget_categories']); | |
| 189 | 232 | } |
| 190 | 233 | } |