PluginProbe
Yatra – Travel Booking & Tour Operator Software / 2.1.16
Yatra – Travel Booking & Tour Operator Software v2.1.16
3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 2.0.1 2.0.10 2.0.11 All 82 releases
yatra / core / Cron.php

Cron.php in Yatra – Travel Booking & Tour Operator Software 2.1.16, at core/Cron.php

81 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Yatra\Core;
4
5 class Cron
6 {
7
8 /**
9 * Init WordPress hook
10 *
11 * @since 2.1.12
12 * @see Cron::weekly_events()
13 */
14 public static function init()
15 {
16 $self = new self;
17 add_filter('cron_schedules', array($self, 'add_schedules'));
18 add_action('wp', array($self, 'schedule_events'));
19 }
20
21 /**
22 * Registers new cron schedules
23 *
24 * @param array $schedules
25 * @return array
26 * @since 2.1.12
27 *
28 */
29 public function add_schedules($schedules = array())
30 {
31 /*Adds once weekly to the existing schedules*/
32 $schedules['weekly'] = array(
33 'interval' => 604800,
34 'display' => __('Once Weekly', 'yatra'),
35 );
36
37 return $schedules;
38 }
39
40 /**
41 * Schedules our events
42 *
43 * @return void
44 * @since 2.1.12
45 */
46 public function schedule_events()
47 {
48 $this->weekly_events();
49 $this->daily_events();
50 }
51
52 /**
53 * Schedule weekly events
54 *
55 * @access private
56 * @return void
57 * @since 2.1.12
58 */
59 private function weekly_events()
60 {
61 if (!wp_next_scheduled('yatra_weekly_scheduled_events')) {
62 wp_schedule_event(time(), 'weekly', 'yatra_weekly_scheduled_events');
63 }
64 }
65
66 /**
67 * Schedule daily events
68 *
69 * @access private
70 * @return void
71 * @since 2.1.12
72 */
73 private function daily_events()
74 {
75 if (!wp_next_scheduled('yatra_daily_scheduled_events')) {
76 wp_schedule_event(time(), 'daily', 'yatra_daily_scheduled_events');
77 }
78 }
79
80 }
81