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