| 1 |
<?php |
| 2 |
/** |
| 3 |
* Cron |
| 4 |
* |
| 5 |
* @package AutomatorWP\Cron |
| 6 |
* @author AutomatorWP <contact@automatorwp.com>, Ruben Garcia <rubengcdev@gmail.com> |
| 7 |
* @since 1.0.0 |
| 8 |
*/ |
| 9 |
// Exit if accessed directly |
| 10 |
if( !defined( 'ABSPATH' ) ) exit; |
| 11 |
|
| 12 |
require_once AUTOMATORWP_DIR . 'includes/cron/auto-logs-cleanup.php'; |
| 13 |
require_once AUTOMATORWP_DIR . 'includes/cron/run-scheduled-automations.php'; |
| 14 |
|
| 15 |
/** |
| 16 |
* Register custom cron schedules |
| 17 |
* |
| 18 |
* @since 1.0.0 |
| 19 |
* |
| 20 |
* @param array $schedules |
| 21 |
* |
| 22 |
* @return array |
| 23 |
*/ |
| 24 |
function automatorwp_cron_schedules( $schedules ) { |
| 25 |
|
| 26 |
$schedules['five_minutes'] = array( |
| 27 |
'interval' => 300, |
| 28 |
'display' => __( 'Every five minutes', 'automatorwp' ), |
| 29 |
); |
| 30 |
|
| 31 |
return $schedules; |
| 32 |
|
| 33 |
} |
| 34 |
add_filter( 'cron_schedules', 'automatorwp_cron_schedules' ); |
| 35 |
|
| 36 |
/** |
| 37 |
* Register schedule events |
| 38 |
* |
| 39 |
* @since 1.3.2 |
| 40 |
*/ |
| 41 |
function automatorwp_schedule_events() { |
| 42 |
|
| 43 |
/** |
| 44 |
* Action triggered on activation to schedule events |
| 45 |
* |
| 46 |
* @since 1.3.2 |
| 47 |
*/ |
| 48 |
do_action( 'automatorwp_schedule_events' ); |
| 49 |
|
| 50 |
} |
| 51 |
|
| 52 |
/** |
| 53 |
* Clear scheduled events |
| 54 |
* |
| 55 |
* @since 1.3.2 |
| 56 |
*/ |
| 57 |
function automatorwp_clear_scheduled_events() { |
| 58 |
|
| 59 |
/** |
| 60 |
* Action triggered on deactivation to clear scheduled events |
| 61 |
* |
| 62 |
* @since 1.3.2 |
| 63 |
*/ |
| 64 |
do_action( 'automatorwp_clear_scheduled_events' ); |
| 65 |
|
| 66 |
} |