| @@ -44,14 +44,25 @@ | ||
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | - * Remove the cron when the plugin is deactivated. | |
| 48 | + * Remove the payment cron when all gateways are disconnected. | |
| 49 | 49 | * |
| 50 | + * @since 6.32.1 | |
| 51 | + * | |
| 52 | + * @param string $gateway 'stripe', 'square', or 'paypal'. | |
| 53 | + * @param string $mode 'test' or 'live'. | |
| 54 | + * | |
| 50 | 55 | * @return void |
| 51 | 56 | */ |
| 52 | - public static function remove_cron() { | |
| 53 | - wp_clear_scheduled_hook( 'frm_payment_cron' ); | |
| 57 | + public static function maybe_remove_payment_cron( $gateway, $mode ) { | |
| 58 | + $stripe_connected = FrmStrpLiteConnectHelper::at_least_one_mode_is_setup(); | |
| 59 | + $square_connected = FrmSquareLiteConnectHelper::at_least_one_mode_is_setup(); | |
| 60 | + $paypal_connected = FrmPayPalLiteConnectHelper::at_least_one_mode_is_setup(); | |
| 61 | + | |
| 62 | + if ( ! $stripe_connected && ! $square_connected && ! $paypal_connected ) { | |
| 63 | + wp_clear_scheduled_hook( 'frm_payment_cron' ); | |
| 64 | + } | |
| 54 | 65 | } |
| 55 | 66 | |
| 56 | 67 | /** |
| 57 | 68 | * Process overdue subscriptions. |
| @@ -229,6 +240,18 @@ | ||
| 229 | 240 | #frm_builder_page li[data-ftype="gateway"] { display: none; } |
| 230 | 241 | .frm_field_box:has(li[data-ftype="gateway"]:only-child) { display: none; } |
| 231 | 242 | ' |
| 232 | 243 | ); |
| 244 | + } | |
| 245 | + | |
| 246 | + /** | |
| 247 | + * Remove the cron when the plugin is deactivated. | |
| 248 | + * | |
| 249 | + * @deprecated 6.32.1 | |
| 250 | + * | |
| 251 | + * @return void | |
| 252 | + */ | |
| 253 | + public static function remove_cron() { | |
| 254 | + _deprecated_function( __METHOD__, '6.32.1' ); | |
| 255 | + wp_clear_scheduled_hook( 'frm_payment_cron' ); | |
| 233 | 256 | } |
| 234 | 257 | } |