1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class EPL_Cron {
public function __construct() {
add_filter( 'cron_schedules', array( $this, 'add_schedules' ) );
add_action( 'wp', array( $this, 'schedule_events' ) );
}
public function add_schedules( $schedules = array() ) {
$schedules['weekly'] = array(
'interval' => 604800,
'display' => __( 'Once Weekly', 'easy-property-listings' ),
);
return $schedules;
}
public function schedule_events() {
$this->weekly_events();
$this->daily_events();
}
private function weekly_events() {
if ( ! wp_next_scheduled( 'epl_weekly_scheduled_events' ) ) {
wp_schedule_event( current_time( 'timestamp' ), 'weekly', 'epl_weekly_scheduled_events' );
}
}
private function daily_events() {
if ( ! wp_next_scheduled( 'epl_daily_scheduled_events' ) ) {
wp_schedule_event( current_time( 'timestamp' ), 'daily', 'epl_daily_scheduled_events' );
}
}
}
$epl_cron = new EPL_Cron();