| @@ -2,8 +2,10 @@ | ||
| 2 | 2 | /** |
| 3 | 3 | * Cron controller |
| 4 | 4 | * |
| 5 | 5 | * @since 6.3.2 |
| 6 | + * | |
| 7 | + * @package Formidable | |
| 6 | 8 | */ |
| 7 | 9 | |
| 8 | 10 | if ( ! defined( 'ABSPATH' ) ) { |
| 9 | 11 | die( 'You are not allowed to call this page directly.' ); |
| @@ -23,16 +25,38 @@ | ||
| 23 | 25 | */ |
| 24 | 26 | private static function get_events() { |
| 25 | 27 | return array( |
| 26 | 28 | 'formidable_send_usage' => 'weekly', |
| 29 | + 'frm_daily_event' => 'daily', | |
| 30 | + 'frm_payment_cron' => 'daily', | |
| 27 | 31 | ); |
| 28 | 32 | } |
| 29 | 33 | |
| 34 | + /** | |
| 35 | + * Schedules cron events. | |
| 36 | + * | |
| 37 | + * @since 6.7 | |
| 38 | + */ | |
| 39 | + public static function schedule_events() { | |
| 40 | + $events = self::get_events(); | |
| 30 | 41 | |
| 42 | + // These are scheduled in another place. | |
| 43 | + unset( $events['formidable_send_usage'] ); | |
| 44 | + unset( $events['frm_payment_cron'] ); | |
| 45 | + | |
| 46 | + foreach ( $events as $event => $recurrence ) { | |
| 47 | + if ( ! wp_next_scheduled( $event ) ) { | |
| 48 | + wp_schedule_event( time(), $recurrence, $event ); | |
| 49 | + } | |
| 50 | + } | |
| 51 | + } | |
| 52 | + | |
| 31 | 53 | /** |
| 32 | 54 | * Removes all cron events. |
| 33 | 55 | * |
| 34 | 56 | * @since 6.3.2 |
| 57 | + * | |
| 58 | + * @return void | |
| 35 | 59 | */ |
| 36 | 60 | public static function remove_crons() { |
| 37 | 61 | $events = self::get_events(); |
| 38 | 62 | |