| @@ -4,9 +4,9 @@ | ||
| 4 | 4 | * Plugin Name: Better Payment |
| 5 | 5 | * Description: Better Payment allows you to automate payment transactions to manage donations, make payments, sell products, and more on your Elementor and Gutenberg website. |
| 6 | 6 | * Plugin URI: https://wpdeveloper.com/ |
| 7 | 7 | * Author: WPDeveloper |
| 8 | - * Version: 2.3.0 | |
| 8 | + * Version: 2.4.1 | |
| 9 | 9 | * Requires at least: 6.0 |
| 10 | 10 | * Requires PHP: 7.4 |
| 11 | 11 | * Author URI: https://wpdeveloper.com/ |
| 12 | 12 | * Text Domain: better-payment |
| @@ -33,9 +33,9 @@ | ||
| 33 | 33 | * |
| 34 | 34 | * @var string |
| 35 | 35 | * @since 0.0.1 |
| 36 | 36 | */ |
| 37 | - const version = '2.3.0'; | |
| 37 | + const version = '2.4.1'; | |
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | 40 | * Class construcotr |
| 41 | 41 | * |
| @@ -124,16 +124,15 @@ | ||
| 124 | 124 | */ |
| 125 | 125 | public function init_plugin() { |
| 126 | 126 | new Better_Payment\Lite\Assets(); |
| 127 | 127 | |
| 128 | - if (defined('DOING_AJAX') && DOING_AJAX) { | |
| 129 | - new Better_Payment\Lite\Ajax(); | |
| 130 | - } | |
| 131 | - | |
| 132 | 128 | if (is_admin()) { |
| 133 | 129 | $adminObj = new Better_Payment\Lite\Admin(); |
| 134 | 130 | $adminObj->init(); |
| 135 | 131 | |
| 132 | + // Warn when the installed Pro predates what this Lite supports. | |
| 133 | + Better_Payment\Lite\Classes\ProCompatibility::register(); | |
| 134 | + | |
| 136 | 135 | if ( !$this->bp_section_dismissed() ) { |
| 137 | 136 | add_action('save_post', array($this, 'bp_widget_usage_on_save'), 10, 1); |
| 138 | 137 | } |
| 139 | 138 | } else { |
| @@ -139,8 +138,31 @@ | ||
| 139 | 138 | } else { |
| 140 | 139 | new Better_Payment\Lite\Frontend(); |
| 141 | 140 | } |
| 142 | 141 | |
| 142 | + /** | |
| 143 | + * Usage tracking must be registered on CRON requests too, not just admin. | |
| 144 | + * | |
| 145 | + * This used to be wired only from Admin::init(), which runs solely under | |
| 146 | + * is_admin(). But WP-Cron executes wp-cron.php as a NON-admin request, so | |
| 147 | + * Plugin_Usage_Tracker::init() never ran there and its do_tracking() | |
| 148 | + * callback was never attached. The daily event was scheduled and fired on | |
| 149 | + * time — into an empty hook. The tracker therefore never sent anything on | |
| 150 | + * its own schedule; the only payloads that ever went out were the forced | |
| 151 | + * ones from the setup wizard's opt-in. Silent, and invisible from the | |
| 152 | + * cron listing, which shows the event as perfectly healthy. | |
| 153 | + * | |
| 154 | + * Not registered on front-end requests: nothing here is needed to render a | |
| 155 | + * page, and this is a payment plugin whose public pages should carry no | |
| 156 | + * avoidable work. Admin + cron is the complete set of contexts the tracker | |
| 157 | + * acts in (notice, action links, AJAX, and the scheduled send). | |
| 158 | + * | |
| 159 | + * @since 2.3.2 | |
| 160 | + */ | |
| 161 | + if ( is_admin() || wp_doing_cron() ) { | |
| 162 | + add_action( 'init', array( $this, 'start_plugin_tracking' ) ); | |
| 163 | + } | |
| 164 | + | |
| 143 | 165 | new Better_Payment\Lite\API(); |
| 144 | 166 | |
| 145 | 167 | // Initialize Gutenberg blocks |
| 146 | 168 | Better_Payment\Lite\Blocks\BlockManager::get_instance(); |
| @@ -170,11 +192,33 @@ | ||
| 170 | 192 | $this->init_campaign_module(); |
| 171 | 193 | |
| 172 | 194 | // ── AI module (AI-native Campaign Builder) ───────────────────── |
| 173 | 195 | $this->init_ai_module(); |
| 196 | + | |
| 197 | + // ── WooCommerce gateway module (Better Payment as a WC gateway) ─ | |
| 198 | + $this->init_woocommerce_module(); | |
| 174 | 199 | } |
| 175 | 200 | |
| 176 | 201 | /** |
| 202 | + * Initialize the WooCommerce integration module. | |
| 203 | + * | |
| 204 | + * Registers the "Better Payment (Stripe)" WooCommerce payment gateway, | |
| 205 | + * which consumes the existing Better Payment payment engine (Stripe | |
| 206 | + * checkout creation, transaction persistence, verification, hooks). | |
| 207 | + * No-op when WooCommerce is not active — none of the module's classes | |
| 208 | + * load, and core never depends on WooCommerce. | |
| 209 | + * | |
| 210 | + * @return void | |
| 211 | + */ | |
| 212 | + private function init_woocommerce_module() { | |
| 213 | + if ( ! class_exists( 'WooCommerce' ) ) { | |
| 214 | + return; | |
| 215 | + } | |
| 216 | + | |
| 217 | + Better_Payment\Lite\WooCommerce\Loader::register(); | |
| 218 | + } | |
| 219 | + | |
| 220 | + /** | |
| 177 | 221 | * Initialize the AI module (providers, operations, REST endpoints). |
| 178 | 222 | * |
| 179 | 223 | * @return void |
| 180 | 224 | */ |
| @@ -286,8 +330,11 @@ | ||
| 286 | 330 | if (get_option('better_payment_version') != BETTER_PAYMENT_VERSION) { |
| 287 | 331 | better_payment_migrator(); |
| 288 | 332 | update_option('better_payment_version', BETTER_PAYMENT_VERSION); |
| 289 | 333 | } |
| 334 | + | |
| 335 | + // Once per site, not per version: WooCommerce rows written in site time → UTC. | |
| 336 | + Better_Payment\Lite\Classes\PaymentDateMigration::maybe_run(); | |
| 290 | 337 | |
| 291 | 338 | $setup_wizard = get_option('better_payment_setup_wizard'); |
| 292 | 339 | |
| 293 | 340 | if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |