| @@ -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.2.1 | |
| 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.2.1'; | |
| 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(); |
| @@ -148,8 +170,17 @@ | ||
| 148 | 170 | |
| 149 | 171 | // Initialize Block Actions for payment processing (runs before Elementor Actions) |
| 150 | 172 | new Better_Payment\Lite\Blocks\BlockActions(); |
| 151 | 173 | |
| 174 | + // Always register PayPal IPN listener + verification poll. These must run even | |
| 175 | + // when Elementor is inactive, because PayPal payments also flow through the | |
| 176 | + // block/campaign path. (Previously registered only inside the Elementor gate | |
| 177 | + // via Classes\Actions, so non-Elementor sites never confirmed PayPal payments.) | |
| 178 | + add_action( 'admin_post_better_payment_paypal_ipn', [ 'Better_Payment\Lite\Classes\Handler', 'handle_paypal_ipn' ] ); | |
| 179 | + add_action( 'admin_post_nopriv_better_payment_paypal_ipn', [ 'Better_Payment\Lite\Classes\Handler', 'handle_paypal_ipn' ] ); | |
| 180 | + add_action( 'wp_ajax_better_payment_check_paypal_status', [ 'Better_Payment\Lite\Classes\Handler', 'check_paypal_status' ] ); | |
| 181 | + add_action( 'wp_ajax_nopriv_better_payment_check_paypal_status', [ 'Better_Payment\Lite\Classes\Handler', 'check_paypal_status' ] ); | |
| 182 | + | |
| 152 | 183 | if (defined('ELEMENTOR_VERSION')) { |
| 153 | 184 | new Better_Payment\Lite\Classes\Actions(); |
| 154 | 185 | $el_integration = new Better_Payment\Lite\Admin\Elementor\EL_Integration(); |
| 155 | 186 | $el_integration->init(); |
| @@ -158,11 +189,49 @@ | ||
| 158 | 189 | } |
| 159 | 190 | |
| 160 | 191 | // ── Campaign Builder module ──────────────────────────────────── |
| 161 | 192 | $this->init_campaign_module(); |
| 193 | + | |
| 194 | + // ── AI module (AI-native Campaign Builder) ───────────────────── | |
| 195 | + $this->init_ai_module(); | |
| 196 | + | |
| 197 | + // ── WooCommerce gateway module (Better Payment as a WC gateway) ─ | |
| 198 | + $this->init_woocommerce_module(); | |
| 162 | 199 | } |
| 163 | 200 | |
| 164 | 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 | + /** | |
| 221 | + * Initialize the AI module (providers, operations, REST endpoints). | |
| 222 | + * | |
| 223 | + * @return void | |
| 224 | + */ | |
| 225 | + private function init_ai_module() { | |
| 226 | + // Register providers + resolve settings-driven config. | |
| 227 | + ( new Better_Payment\Lite\AI\AIManager() )->init(); | |
| 228 | + | |
| 229 | + // REST API for AI (chat/generate/analyze/image/conversations/config). | |
| 230 | + new Better_Payment\Lite\API\AIAPI(); | |
| 231 | + } | |
| 232 | + | |
| 233 | + /** | |
| 165 | 234 | * Initialize the Campaign Builder module. |
| 166 | 235 | * |
| 167 | 236 | * @return void |
| 168 | 237 | */ |
| @@ -261,8 +330,11 @@ | ||
| 261 | 330 | if (get_option('better_payment_version') != BETTER_PAYMENT_VERSION) { |
| 262 | 331 | better_payment_migrator(); |
| 263 | 332 | update_option('better_payment_version', BETTER_PAYMENT_VERSION); |
| 264 | 333 | } |
| 334 | + | |
| 335 | + // Once per site, not per version: WooCommerce rows written in site time → UTC. | |
| 336 | + Better_Payment\Lite\Classes\PaymentDateMigration::maybe_run(); | |
| 265 | 337 | |
| 266 | 338 | $setup_wizard = get_option('better_payment_setup_wizard'); |
| 267 | 339 | |
| 268 | 340 | if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |