| 1 |
<?php |
| 2 |
/** |
| 3 |
* Cron controller |
| 4 |
* |
| 5 |
* @since 6.3.2 |
| 6 |
*/ |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) { |
| 9 |
die( 'You are not allowed to call this page directly.' ); |
| 10 |
} |
| 11 |
|
| 12 |
/** |
| 13 |
* Class FrmCronController |
| 14 |
*/ |
| 15 |
class FrmCronController { |
| 16 |
|
| 17 |
/** |
| 18 |
* Gets all cron events. |
| 19 |
* |
| 20 |
* @since 6.3.2 |
| 21 |
* |
| 22 |
* @return string[] |
| 23 |
*/ |
| 24 |
private static function get_events() { |
| 25 |
return array( |
| 26 |
'formidable_send_usage' => 'weekly', |
| 27 |
'frm_payment_cron' => 'daily', |
| 28 |
); |
| 29 |
} |
| 30 |
|
| 31 |
/** |
| 32 |
* Removes all cron events. |
| 33 |
* |
| 34 |
* @since 6.3.2 |
| 35 |
* |
| 36 |
* @return void |
| 37 |
*/ |
| 38 |
public static function remove_crons() { |
| 39 |
$events = self::get_events(); |
| 40 |
|
| 41 |
foreach ( $events as $event => $recurrence ) { |
| 42 |
$timestamp = wp_next_scheduled( $event ); |
| 43 |
if ( false !== $timestamp ) { |
| 44 |
wp_unschedule_event( $timestamp, $event ); |
| 45 |
} |
| 46 |
} |
| 47 |
} |
| 48 |
} |
| 49 |
|