@@ -5,53 +5,53 @@ |
||
5 | 5 | */ |
6 | 6 | class ActionScheduler_CanceledSchedule extends ActionScheduler_SimpleSchedule { |
7 | 7 | |
8 | - /** |
|
9 | - * Deprecated property @see $this->__wakeup() for details. |
|
10 | - **/ |
|
11 | - private $timestamp = null; |
|
8 | + /** |
|
9 | + * Deprecated property @see $this->__wakeup() for details. |
|
10 | + **/ |
|
11 | + private $timestamp = null; |
|
12 | 12 | |
13 | - /** |
|
14 | - * @param DateTime $after |
|
15 | - * |
|
16 | - * @return DateTime|null |
|
17 | - */ |
|
18 | - public function calculate_next( DateTime $after ) { |
|
19 | - return null; |
|
20 | - } |
|
13 | + /** |
|
14 | + * @param DateTime $after |
|
15 | + * |
|
16 | + * @return DateTime|null |
|
17 | + */ |
|
18 | + public function calculate_next( DateTime $after ) { |
|
19 | + return null; |
|
20 | + } |
|
21 | 21 | |
22 | - /** |
|
23 | - * Cancelled actions should never have a next schedule, even if get_next() |
|
24 | - * is called with $after < $this->scheduled_date. |
|
25 | - * |
|
26 | - * @param DateTime $after |
|
27 | - * @return DateTime|null |
|
28 | - */ |
|
29 | - public function get_next( DateTime $after ) { |
|
30 | - return null; |
|
31 | - } |
|
22 | + /** |
|
23 | + * Cancelled actions should never have a next schedule, even if get_next() |
|
24 | + * is called with $after < $this->scheduled_date. |
|
25 | + * |
|
26 | + * @param DateTime $after |
|
27 | + * @return DateTime|null |
|
28 | + */ |
|
29 | + public function get_next( DateTime $after ) { |
|
30 | + return null; |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * @return bool |
|
35 | - */ |
|
36 | - public function is_recurring() { |
|
37 | - return false; |
|
38 | - } |
|
33 | + /** |
|
34 | + * @return bool |
|
35 | + */ |
|
36 | + public function is_recurring() { |
|
37 | + return false; |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * Unserialize recurring schedules serialized/stored prior to AS 3.0.0 |
|
42 | - * |
|
43 | - * Prior to Action Scheduler 3.0.0, schedules used different property names to refer |
|
44 | - * to equivalent data. For example, ActionScheduler_IntervalSchedule::start_timestamp |
|
45 | - * was the same as ActionScheduler_SimpleSchedule::timestamp. Action Scheduler 3.0.0 |
|
46 | - * aligned properties and property names for better inheritance. To maintain backward |
|
47 | - * compatibility with schedules serialized and stored prior to 3.0, we need to correctly |
|
48 | - * map the old property names with matching visibility. |
|
49 | - */ |
|
50 | - public function __wakeup() { |
|
51 | - if ( $this->timestamp !== null ) { |
|
52 | - $this->scheduled_timestamp = $this->timestamp; |
|
53 | - unset( $this->timestamp ); |
|
54 | - } |
|
55 | - parent::__wakeup(); |
|
56 | - } |
|
40 | + /** |
|
41 | + * Unserialize recurring schedules serialized/stored prior to AS 3.0.0 |
|
42 | + * |
|
43 | + * Prior to Action Scheduler 3.0.0, schedules used different property names to refer |
|
44 | + * to equivalent data. For example, ActionScheduler_IntervalSchedule::start_timestamp |
|
45 | + * was the same as ActionScheduler_SimpleSchedule::timestamp. Action Scheduler 3.0.0 |
|
46 | + * aligned properties and property names for better inheritance. To maintain backward |
|
47 | + * compatibility with schedules serialized and stored prior to 3.0, we need to correctly |
|
48 | + * map the old property names with matching visibility. |
|
49 | + */ |
|
50 | + public function __wakeup() { |
|
51 | + if ( $this->timestamp !== null ) { |
|
52 | + $this->scheduled_timestamp = $this->timestamp; |
|
53 | + unset( $this->timestamp ); |
|
54 | + } |
|
55 | + parent::__wakeup(); |
|
56 | + } |
|
57 | 57 | } |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * |
16 | 16 | * @return DateTime|null |
17 | 17 | */ |
18 | - public function calculate_next( DateTime $after ) { |
|
18 | + public function calculate_next(DateTime $after) { |
|
19 | 19 | return null; |
20 | 20 | } |
21 | 21 | |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * @param DateTime $after |
27 | 27 | * @return DateTime|null |
28 | 28 | */ |
29 | - public function get_next( DateTime $after ) { |
|
29 | + public function get_next(DateTime $after) { |
|
30 | 30 | return null; |
31 | 31 | } |
32 | 32 | |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | * map the old property names with matching visibility. |
49 | 49 | */ |
50 | 50 | public function __wakeup() { |
51 | - if ( $this->timestamp !== null ) { |
|
51 | + if ($this->timestamp !== null) { |
|
52 | 52 | $this->scheduled_timestamp = $this->timestamp; |
53 | - unset( $this->timestamp ); |
|
53 | + unset($this->timestamp); |
|
54 | 54 | } |
55 | 55 | parent::__wakeup(); |
56 | 56 | } |
@@ -4,15 +4,15 @@ |
||
4 | 4 | * Class ActionScheduler_Schedule |
5 | 5 | */ |
6 | 6 | interface ActionScheduler_Schedule { |
7 | - /** |
|
8 | - * @param DateTime $after |
|
9 | - * @return DateTime|null |
|
10 | - */ |
|
11 | - public function next( DateTime $after = null ); |
|
7 | + /** |
|
8 | + * @param DateTime $after |
|
9 | + * @return DateTime|null |
|
10 | + */ |
|
11 | + public function next( DateTime $after = null ); |
|
12 | 12 | |
13 | - /** |
|
14 | - * @return bool |
|
15 | - */ |
|
16 | - public function is_recurring(); |
|
13 | + /** |
|
14 | + * @return bool |
|
15 | + */ |
|
16 | + public function is_recurring(); |
|
17 | 17 | } |
18 | 18 |
@@ -8,7 +8,7 @@ |
||
8 | 8 | * @param DateTime $after |
9 | 9 | * @return DateTime|null |
10 | 10 | */ |
11 | - public function next( DateTime $after = null ); |
|
11 | + public function next(DateTime $after = null); |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * @return bool |
@@ -5,80 +5,80 @@ |
||
5 | 5 | */ |
6 | 6 | class ActionScheduler_IntervalSchedule extends ActionScheduler_Abstract_RecurringSchedule implements ActionScheduler_Schedule { |
7 | 7 | |
8 | - /** |
|
9 | - * Deprecated property @see $this->__wakeup() for details. |
|
10 | - **/ |
|
11 | - private $start_timestamp = null; |
|
8 | + /** |
|
9 | + * Deprecated property @see $this->__wakeup() for details. |
|
10 | + **/ |
|
11 | + private $start_timestamp = null; |
|
12 | 12 | |
13 | - /** |
|
14 | - * Deprecated property @see $this->__wakeup() for details. |
|
15 | - **/ |
|
16 | - private $interval_in_seconds = null; |
|
13 | + /** |
|
14 | + * Deprecated property @see $this->__wakeup() for details. |
|
15 | + **/ |
|
16 | + private $interval_in_seconds = null; |
|
17 | 17 | |
18 | - /** |
|
19 | - * Calculate when this schedule should start after a given date & time using |
|
20 | - * the number of seconds between recurrences. |
|
21 | - * |
|
22 | - * @param DateTime $after |
|
23 | - * @return DateTime |
|
24 | - */ |
|
25 | - protected function calculate_next( DateTime $after ) { |
|
26 | - $after->modify( '+' . (int) $this->get_recurrence() . ' seconds' ); |
|
27 | - return $after; |
|
28 | - } |
|
18 | + /** |
|
19 | + * Calculate when this schedule should start after a given date & time using |
|
20 | + * the number of seconds between recurrences. |
|
21 | + * |
|
22 | + * @param DateTime $after |
|
23 | + * @return DateTime |
|
24 | + */ |
|
25 | + protected function calculate_next( DateTime $after ) { |
|
26 | + $after->modify( '+' . (int) $this->get_recurrence() . ' seconds' ); |
|
27 | + return $after; |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
31 | - * @return int |
|
32 | - */ |
|
33 | - public function interval_in_seconds() { |
|
34 | - _deprecated_function( __METHOD__, '3.0.0', '(int)ActionScheduler_Abstract_RecurringSchedule::get_recurrence()' ); |
|
35 | - return (int) $this->get_recurrence(); |
|
36 | - } |
|
30 | + /** |
|
31 | + * @return int |
|
32 | + */ |
|
33 | + public function interval_in_seconds() { |
|
34 | + _deprecated_function( __METHOD__, '3.0.0', '(int)ActionScheduler_Abstract_RecurringSchedule::get_recurrence()' ); |
|
35 | + return (int) $this->get_recurrence(); |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * Serialize interval schedules with data required prior to AS 3.0.0 |
|
40 | - * |
|
41 | - * Prior to Action Scheduler 3.0.0, reccuring schedules used different property names to |
|
42 | - * refer to equivalent data. For example, ActionScheduler_IntervalSchedule::start_timestamp |
|
43 | - * was the same as ActionScheduler_SimpleSchedule::timestamp. Action Scheduler 3.0.0 |
|
44 | - * aligned properties and property names for better inheritance. To guard against the |
|
45 | - * possibility of infinite loops if downgrading to Action Scheduler < 3.0.0, we need to |
|
46 | - * also store the data with the old property names so if it's unserialized in AS < 3.0, |
|
47 | - * the schedule doesn't end up with a null/false/0 recurrence. |
|
48 | - * |
|
49 | - * @return array |
|
50 | - */ |
|
51 | - public function __sleep() { |
|
38 | + /** |
|
39 | + * Serialize interval schedules with data required prior to AS 3.0.0 |
|
40 | + * |
|
41 | + * Prior to Action Scheduler 3.0.0, reccuring schedules used different property names to |
|
42 | + * refer to equivalent data. For example, ActionScheduler_IntervalSchedule::start_timestamp |
|
43 | + * was the same as ActionScheduler_SimpleSchedule::timestamp. Action Scheduler 3.0.0 |
|
44 | + * aligned properties and property names for better inheritance. To guard against the |
|
45 | + * possibility of infinite loops if downgrading to Action Scheduler < 3.0.0, we need to |
|
46 | + * also store the data with the old property names so if it's unserialized in AS < 3.0, |
|
47 | + * the schedule doesn't end up with a null/false/0 recurrence. |
|
48 | + * |
|
49 | + * @return array |
|
50 | + */ |
|
51 | + public function __sleep() { |
|
52 | 52 | |
53 | - $sleep_params = parent::__sleep(); |
|
53 | + $sleep_params = parent::__sleep(); |
|
54 | 54 | |
55 | - $this->start_timestamp = $this->scheduled_timestamp; |
|
56 | - $this->interval_in_seconds = $this->recurrence; |
|
55 | + $this->start_timestamp = $this->scheduled_timestamp; |
|
56 | + $this->interval_in_seconds = $this->recurrence; |
|
57 | 57 | |
58 | - return array_merge( |
|
59 | - $sleep_params, |
|
60 | - array( |
|
61 | - 'start_timestamp', |
|
62 | - 'interval_in_seconds', |
|
63 | - ) |
|
64 | - ); |
|
65 | - } |
|
58 | + return array_merge( |
|
59 | + $sleep_params, |
|
60 | + array( |
|
61 | + 'start_timestamp', |
|
62 | + 'interval_in_seconds', |
|
63 | + ) |
|
64 | + ); |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * Unserialize interval schedules serialized/stored prior to AS 3.0.0 |
|
69 | - * |
|
70 | - * For more background, @see ActionScheduler_Abstract_RecurringSchedule::__wakeup(). |
|
71 | - */ |
|
72 | - public function __wakeup() { |
|
73 | - if ( $this->scheduled_timestamp === null && $this->start_timestamp !== null ) { |
|
74 | - $this->scheduled_timestamp = $this->start_timestamp; |
|
75 | - unset( $this->start_timestamp ); |
|
76 | - } |
|
67 | + /** |
|
68 | + * Unserialize interval schedules serialized/stored prior to AS 3.0.0 |
|
69 | + * |
|
70 | + * For more background, @see ActionScheduler_Abstract_RecurringSchedule::__wakeup(). |
|
71 | + */ |
|
72 | + public function __wakeup() { |
|
73 | + if ( $this->scheduled_timestamp === null && $this->start_timestamp !== null ) { |
|
74 | + $this->scheduled_timestamp = $this->start_timestamp; |
|
75 | + unset( $this->start_timestamp ); |
|
76 | + } |
|
77 | 77 | |
78 | - if ( $this->recurrence === null && $this->interval_in_seconds !== null ) { |
|
79 | - $this->recurrence = $this->interval_in_seconds; |
|
80 | - unset( $this->interval_in_seconds ); |
|
81 | - } |
|
82 | - parent::__wakeup(); |
|
83 | - } |
|
78 | + if ( $this->recurrence === null && $this->interval_in_seconds !== null ) { |
|
79 | + $this->recurrence = $this->interval_in_seconds; |
|
80 | + unset( $this->interval_in_seconds ); |
|
81 | + } |
|
82 | + parent::__wakeup(); |
|
83 | + } |
|
84 | 84 | } |
@@ -22,8 +22,8 @@ discard block |
||
22 | 22 | * @param DateTime $after |
23 | 23 | * @return DateTime |
24 | 24 | */ |
25 | - protected function calculate_next( DateTime $after ) { |
|
26 | - $after->modify( '+' . (int) $this->get_recurrence() . ' seconds' ); |
|
25 | + protected function calculate_next(DateTime $after) { |
|
26 | + $after->modify('+'.(int) $this->get_recurrence().' seconds'); |
|
27 | 27 | return $after; |
28 | 28 | } |
29 | 29 | |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @return int |
32 | 32 | */ |
33 | 33 | public function interval_in_seconds() { |
34 | - _deprecated_function( __METHOD__, '3.0.0', '(int)ActionScheduler_Abstract_RecurringSchedule::get_recurrence()' ); |
|
34 | + _deprecated_function(__METHOD__, '3.0.0', '(int)ActionScheduler_Abstract_RecurringSchedule::get_recurrence()'); |
|
35 | 35 | return (int) $this->get_recurrence(); |
36 | 36 | } |
37 | 37 | |
@@ -70,14 +70,14 @@ discard block |
||
70 | 70 | * For more background, @see ActionScheduler_Abstract_RecurringSchedule::__wakeup(). |
71 | 71 | */ |
72 | 72 | public function __wakeup() { |
73 | - if ( $this->scheduled_timestamp === null && $this->start_timestamp !== null ) { |
|
73 | + if ($this->scheduled_timestamp === null && $this->start_timestamp !== null) { |
|
74 | 74 | $this->scheduled_timestamp = $this->start_timestamp; |
75 | - unset( $this->start_timestamp ); |
|
75 | + unset($this->start_timestamp); |
|
76 | 76 | } |
77 | 77 | |
78 | - if ( $this->recurrence === null && $this->interval_in_seconds !== null ) { |
|
78 | + if ($this->recurrence === null && $this->interval_in_seconds !== null) { |
|
79 | 79 | $this->recurrence = $this->interval_in_seconds; |
80 | - unset( $this->interval_in_seconds ); |
|
80 | + unset($this->interval_in_seconds); |
|
81 | 81 | } |
82 | 82 | parent::__wakeup(); |
83 | 83 | } |
@@ -5,101 +5,101 @@ |
||
5 | 5 | */ |
6 | 6 | class ActionScheduler_CronSchedule extends ActionScheduler_Abstract_RecurringSchedule implements ActionScheduler_Schedule { |
7 | 7 | |
8 | - /** |
|
9 | - * Deprecated property @see $this->__wakeup() for details. |
|
10 | - **/ |
|
11 | - private $start_timestamp = null; |
|
12 | - |
|
13 | - /** |
|
14 | - * Deprecated property @see $this->__wakeup() for details. |
|
15 | - **/ |
|
16 | - private $cron = null; |
|
17 | - |
|
18 | - /** |
|
19 | - * Wrapper for parent constructor to accept a cron expression string and map it to a CronExpression for this |
|
20 | - * objects $recurrence property. |
|
21 | - * |
|
22 | - * @param DateTime $start The date & time to run the action at or after. If $start aligns with the CronSchedule passed via $recurrence, it will be used. If it does not align, the first matching date after it will be used. |
|
23 | - * @param CronExpression|string $recurrence The CronExpression used to calculate the schedule's next instance. |
|
24 | - * @param DateTime|null $first (Optional) The date & time the first instance of this interval schedule ran. Default null, meaning this is the first instance. |
|
25 | - */ |
|
26 | - public function __construct( DateTime $start, $recurrence, DateTime $first = null ) { |
|
27 | - if ( ! is_a( $recurrence, 'CronExpression' ) ) { |
|
28 | - $recurrence = CronExpression::factory( $recurrence ); |
|
29 | - } |
|
30 | - |
|
31 | - // For backward compatibility, we need to make sure the date is set to the first matching cron date, not whatever date is passed in. Importantly, by passing true as the 3rd param, if $start matches the cron expression, then it will be used. This was previously handled in the now deprecated next() method. |
|
32 | - $date = $recurrence->getNextRunDate( $start, 0, true ); |
|
33 | - |
|
34 | - // parent::__construct() will set this to $date by default, but that may be different to $start now. |
|
35 | - $first = empty( $first ) ? $start : $first; |
|
36 | - |
|
37 | - parent::__construct( $date, $recurrence, $first ); |
|
38 | - } |
|
39 | - |
|
40 | - /** |
|
41 | - * Calculate when an instance of this schedule would start based on a given |
|
42 | - * date & time using its the CronExpression. |
|
43 | - * |
|
44 | - * @param DateTime $after |
|
45 | - * @return DateTime |
|
46 | - */ |
|
47 | - protected function calculate_next( DateTime $after ) { |
|
48 | - return $this->recurrence->getNextRunDate( $after, 0, false ); |
|
49 | - } |
|
50 | - |
|
51 | - /** |
|
52 | - * @return string |
|
53 | - */ |
|
54 | - public function get_recurrence() { |
|
55 | - return strval( $this->recurrence ); |
|
56 | - } |
|
57 | - |
|
58 | - /** |
|
59 | - * Serialize cron schedules with data required prior to AS 3.0.0 |
|
60 | - * |
|
61 | - * Prior to Action Scheduler 3.0.0, reccuring schedules used different property names to |
|
62 | - * refer to equivalent data. For example, ActionScheduler_IntervalSchedule::start_timestamp |
|
63 | - * was the same as ActionScheduler_SimpleSchedule::timestamp. Action Scheduler 3.0.0 |
|
64 | - * aligned properties and property names for better inheritance. To guard against the |
|
65 | - * possibility of infinite loops if downgrading to Action Scheduler < 3.0.0, we need to |
|
66 | - * also store the data with the old property names so if it's unserialized in AS < 3.0, |
|
67 | - * the schedule doesn't end up with a null recurrence. |
|
68 | - * |
|
69 | - * @return array |
|
70 | - */ |
|
71 | - public function __sleep() { |
|
72 | - |
|
73 | - $sleep_params = parent::__sleep(); |
|
74 | - |
|
75 | - $this->start_timestamp = $this->scheduled_timestamp; |
|
76 | - $this->cron = $this->recurrence; |
|
77 | - |
|
78 | - return array_merge( |
|
79 | - $sleep_params, |
|
80 | - array( |
|
81 | - 'start_timestamp', |
|
82 | - 'cron', |
|
83 | - ) |
|
84 | - ); |
|
85 | - } |
|
86 | - |
|
87 | - /** |
|
88 | - * Unserialize cron schedules serialized/stored prior to AS 3.0.0 |
|
89 | - * |
|
90 | - * For more background, @see ActionScheduler_Abstract_RecurringSchedule::__wakeup(). |
|
91 | - */ |
|
92 | - public function __wakeup() { |
|
93 | - if ( $this->scheduled_timestamp === null && $this->start_timestamp !== null ) { |
|
94 | - $this->scheduled_timestamp = $this->start_timestamp; |
|
95 | - unset( $this->start_timestamp ); |
|
96 | - } |
|
97 | - |
|
98 | - if ( $this->recurrence === null && $this->cron !== null ) { |
|
99 | - $this->recurrence = $this->cron; |
|
100 | - unset( $this->cron ); |
|
101 | - } |
|
102 | - parent::__wakeup(); |
|
103 | - } |
|
8 | + /** |
|
9 | + * Deprecated property @see $this->__wakeup() for details. |
|
10 | + **/ |
|
11 | + private $start_timestamp = null; |
|
12 | + |
|
13 | + /** |
|
14 | + * Deprecated property @see $this->__wakeup() for details. |
|
15 | + **/ |
|
16 | + private $cron = null; |
|
17 | + |
|
18 | + /** |
|
19 | + * Wrapper for parent constructor to accept a cron expression string and map it to a CronExpression for this |
|
20 | + * objects $recurrence property. |
|
21 | + * |
|
22 | + * @param DateTime $start The date & time to run the action at or after. If $start aligns with the CronSchedule passed via $recurrence, it will be used. If it does not align, the first matching date after it will be used. |
|
23 | + * @param CronExpression|string $recurrence The CronExpression used to calculate the schedule's next instance. |
|
24 | + * @param DateTime|null $first (Optional) The date & time the first instance of this interval schedule ran. Default null, meaning this is the first instance. |
|
25 | + */ |
|
26 | + public function __construct( DateTime $start, $recurrence, DateTime $first = null ) { |
|
27 | + if ( ! is_a( $recurrence, 'CronExpression' ) ) { |
|
28 | + $recurrence = CronExpression::factory( $recurrence ); |
|
29 | + } |
|
30 | + |
|
31 | + // For backward compatibility, we need to make sure the date is set to the first matching cron date, not whatever date is passed in. Importantly, by passing true as the 3rd param, if $start matches the cron expression, then it will be used. This was previously handled in the now deprecated next() method. |
|
32 | + $date = $recurrence->getNextRunDate( $start, 0, true ); |
|
33 | + |
|
34 | + // parent::__construct() will set this to $date by default, but that may be different to $start now. |
|
35 | + $first = empty( $first ) ? $start : $first; |
|
36 | + |
|
37 | + parent::__construct( $date, $recurrence, $first ); |
|
38 | + } |
|
39 | + |
|
40 | + /** |
|
41 | + * Calculate when an instance of this schedule would start based on a given |
|
42 | + * date & time using its the CronExpression. |
|
43 | + * |
|
44 | + * @param DateTime $after |
|
45 | + * @return DateTime |
|
46 | + */ |
|
47 | + protected function calculate_next( DateTime $after ) { |
|
48 | + return $this->recurrence->getNextRunDate( $after, 0, false ); |
|
49 | + } |
|
50 | + |
|
51 | + /** |
|
52 | + * @return string |
|
53 | + */ |
|
54 | + public function get_recurrence() { |
|
55 | + return strval( $this->recurrence ); |
|
56 | + } |
|
57 | + |
|
58 | + /** |
|
59 | + * Serialize cron schedules with data required prior to AS 3.0.0 |
|
60 | + * |
|
61 | + * Prior to Action Scheduler 3.0.0, reccuring schedules used different property names to |
|
62 | + * refer to equivalent data. For example, ActionScheduler_IntervalSchedule::start_timestamp |
|
63 | + * was the same as ActionScheduler_SimpleSchedule::timestamp. Action Scheduler 3.0.0 |
|
64 | + * aligned properties and property names for better inheritance. To guard against the |
|
65 | + * possibility of infinite loops if downgrading to Action Scheduler < 3.0.0, we need to |
|
66 | + * also store the data with the old property names so if it's unserialized in AS < 3.0, |
|
67 | + * the schedule doesn't end up with a null recurrence. |
|
68 | + * |
|
69 | + * @return array |
|
70 | + */ |
|
71 | + public function __sleep() { |
|
72 | + |
|
73 | + $sleep_params = parent::__sleep(); |
|
74 | + |
|
75 | + $this->start_timestamp = $this->scheduled_timestamp; |
|
76 | + $this->cron = $this->recurrence; |
|
77 | + |
|
78 | + return array_merge( |
|
79 | + $sleep_params, |
|
80 | + array( |
|
81 | + 'start_timestamp', |
|
82 | + 'cron', |
|
83 | + ) |
|
84 | + ); |
|
85 | + } |
|
86 | + |
|
87 | + /** |
|
88 | + * Unserialize cron schedules serialized/stored prior to AS 3.0.0 |
|
89 | + * |
|
90 | + * For more background, @see ActionScheduler_Abstract_RecurringSchedule::__wakeup(). |
|
91 | + */ |
|
92 | + public function __wakeup() { |
|
93 | + if ( $this->scheduled_timestamp === null && $this->start_timestamp !== null ) { |
|
94 | + $this->scheduled_timestamp = $this->start_timestamp; |
|
95 | + unset( $this->start_timestamp ); |
|
96 | + } |
|
97 | + |
|
98 | + if ( $this->recurrence === null && $this->cron !== null ) { |
|
99 | + $this->recurrence = $this->cron; |
|
100 | + unset( $this->cron ); |
|
101 | + } |
|
102 | + parent::__wakeup(); |
|
103 | + } |
|
104 | 104 | } |
105 | 105 |
@@ -23,18 +23,18 @@ discard block |
||
23 | 23 | * @param CronExpression|string $recurrence The CronExpression used to calculate the schedule's next instance. |
24 | 24 | * @param DateTime|null $first (Optional) The date & time the first instance of this interval schedule ran. Default null, meaning this is the first instance. |
25 | 25 | */ |
26 | - public function __construct( DateTime $start, $recurrence, DateTime $first = null ) { |
|
27 | - if ( ! is_a( $recurrence, 'CronExpression' ) ) { |
|
28 | - $recurrence = CronExpression::factory( $recurrence ); |
|
26 | + public function __construct(DateTime $start, $recurrence, DateTime $first = null) { |
|
27 | + if ( ! is_a($recurrence, 'CronExpression')) { |
|
28 | + $recurrence = CronExpression::factory($recurrence); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | // For backward compatibility, we need to make sure the date is set to the first matching cron date, not whatever date is passed in. Importantly, by passing true as the 3rd param, if $start matches the cron expression, then it will be used. This was previously handled in the now deprecated next() method. |
32 | - $date = $recurrence->getNextRunDate( $start, 0, true ); |
|
32 | + $date = $recurrence->getNextRunDate($start, 0, true); |
|
33 | 33 | |
34 | 34 | // parent::__construct() will set this to $date by default, but that may be different to $start now. |
35 | - $first = empty( $first ) ? $start : $first; |
|
35 | + $first = empty($first) ? $start : $first; |
|
36 | 36 | |
37 | - parent::__construct( $date, $recurrence, $first ); |
|
37 | + parent::__construct($date, $recurrence, $first); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -44,15 +44,15 @@ discard block |
||
44 | 44 | * @param DateTime $after |
45 | 45 | * @return DateTime |
46 | 46 | */ |
47 | - protected function calculate_next( DateTime $after ) { |
|
48 | - return $this->recurrence->getNextRunDate( $after, 0, false ); |
|
47 | + protected function calculate_next(DateTime $after) { |
|
48 | + return $this->recurrence->getNextRunDate($after, 0, false); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
52 | 52 | * @return string |
53 | 53 | */ |
54 | 54 | public function get_recurrence() { |
55 | - return strval( $this->recurrence ); |
|
55 | + return strval($this->recurrence); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -90,14 +90,14 @@ discard block |
||
90 | 90 | * For more background, @see ActionScheduler_Abstract_RecurringSchedule::__wakeup(). |
91 | 91 | */ |
92 | 92 | public function __wakeup() { |
93 | - if ( $this->scheduled_timestamp === null && $this->start_timestamp !== null ) { |
|
93 | + if ($this->scheduled_timestamp === null && $this->start_timestamp !== null) { |
|
94 | 94 | $this->scheduled_timestamp = $this->start_timestamp; |
95 | - unset( $this->start_timestamp ); |
|
95 | + unset($this->start_timestamp); |
|
96 | 96 | } |
97 | 97 | |
98 | - if ( $this->recurrence === null && $this->cron !== null ) { |
|
98 | + if ($this->recurrence === null && $this->cron !== null) { |
|
99 | 99 | $this->recurrence = $this->cron; |
100 | - unset( $this->cron ); |
|
100 | + unset($this->cron); |
|
101 | 101 | } |
102 | 102 | parent::__wakeup(); |
103 | 103 | } |
@@ -5,70 +5,70 @@ |
||
5 | 5 | */ |
6 | 6 | class ActionScheduler_SimpleSchedule extends ActionScheduler_Abstract_Schedule { |
7 | 7 | |
8 | - /** |
|
9 | - * Deprecated property @see $this->__wakeup() for details. |
|
10 | - **/ |
|
11 | - private $timestamp = null; |
|
8 | + /** |
|
9 | + * Deprecated property @see $this->__wakeup() for details. |
|
10 | + **/ |
|
11 | + private $timestamp = null; |
|
12 | 12 | |
13 | - /** |
|
14 | - * @param DateTime $after |
|
15 | - * |
|
16 | - * @return DateTime|null |
|
17 | - */ |
|
18 | - public function calculate_next( DateTime $after ) { |
|
19 | - return null; |
|
20 | - } |
|
13 | + /** |
|
14 | + * @param DateTime $after |
|
15 | + * |
|
16 | + * @return DateTime|null |
|
17 | + */ |
|
18 | + public function calculate_next( DateTime $after ) { |
|
19 | + return null; |
|
20 | + } |
|
21 | 21 | |
22 | - /** |
|
23 | - * @return bool |
|
24 | - */ |
|
25 | - public function is_recurring() { |
|
26 | - return false; |
|
27 | - } |
|
22 | + /** |
|
23 | + * @return bool |
|
24 | + */ |
|
25 | + public function is_recurring() { |
|
26 | + return false; |
|
27 | + } |
|
28 | 28 | |
29 | - /** |
|
30 | - * Serialize schedule with data required prior to AS 3.0.0 |
|
31 | - * |
|
32 | - * Prior to Action Scheduler 3.0.0, schedules used different property names to refer |
|
33 | - * to equivalent data. For example, ActionScheduler_IntervalSchedule::start_timestamp |
|
34 | - * was the same as ActionScheduler_SimpleSchedule::timestamp. Action Scheduler 3.0.0 |
|
35 | - * aligned properties and property names for better inheritance. To guard against the |
|
36 | - * scheduled date for single actions always being seen as "now" if downgrading to |
|
37 | - * Action Scheduler < 3.0.0, we need to also store the data with the old property names |
|
38 | - * so if it's unserialized in AS < 3.0, the schedule doesn't end up with a null recurrence. |
|
39 | - * |
|
40 | - * @return array |
|
41 | - */ |
|
42 | - public function __sleep() { |
|
29 | + /** |
|
30 | + * Serialize schedule with data required prior to AS 3.0.0 |
|
31 | + * |
|
32 | + * Prior to Action Scheduler 3.0.0, schedules used different property names to refer |
|
33 | + * to equivalent data. For example, ActionScheduler_IntervalSchedule::start_timestamp |
|
34 | + * was the same as ActionScheduler_SimpleSchedule::timestamp. Action Scheduler 3.0.0 |
|
35 | + * aligned properties and property names for better inheritance. To guard against the |
|
36 | + * scheduled date for single actions always being seen as "now" if downgrading to |
|
37 | + * Action Scheduler < 3.0.0, we need to also store the data with the old property names |
|
38 | + * so if it's unserialized in AS < 3.0, the schedule doesn't end up with a null recurrence. |
|
39 | + * |
|
40 | + * @return array |
|
41 | + */ |
|
42 | + public function __sleep() { |
|
43 | 43 | |
44 | - $sleep_params = parent::__sleep(); |
|
44 | + $sleep_params = parent::__sleep(); |
|
45 | 45 | |
46 | - $this->timestamp = $this->scheduled_timestamp; |
|
46 | + $this->timestamp = $this->scheduled_timestamp; |
|
47 | 47 | |
48 | - return array_merge( |
|
49 | - $sleep_params, |
|
50 | - array( |
|
51 | - 'timestamp', |
|
52 | - ) |
|
53 | - ); |
|
54 | - } |
|
48 | + return array_merge( |
|
49 | + $sleep_params, |
|
50 | + array( |
|
51 | + 'timestamp', |
|
52 | + ) |
|
53 | + ); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * Unserialize recurring schedules serialized/stored prior to AS 3.0.0 |
|
58 | - * |
|
59 | - * Prior to Action Scheduler 3.0.0, schedules used different property names to refer |
|
60 | - * to equivalent data. For example, ActionScheduler_IntervalSchedule::start_timestamp |
|
61 | - * was the same as ActionScheduler_SimpleSchedule::timestamp. Action Scheduler 3.0.0 |
|
62 | - * aligned properties and property names for better inheritance. To maintain backward |
|
63 | - * compatibility with schedules serialized and stored prior to 3.0, we need to correctly |
|
64 | - * map the old property names with matching visibility. |
|
65 | - */ |
|
66 | - public function __wakeup() { |
|
56 | + /** |
|
57 | + * Unserialize recurring schedules serialized/stored prior to AS 3.0.0 |
|
58 | + * |
|
59 | + * Prior to Action Scheduler 3.0.0, schedules used different property names to refer |
|
60 | + * to equivalent data. For example, ActionScheduler_IntervalSchedule::start_timestamp |
|
61 | + * was the same as ActionScheduler_SimpleSchedule::timestamp. Action Scheduler 3.0.0 |
|
62 | + * aligned properties and property names for better inheritance. To maintain backward |
|
63 | + * compatibility with schedules serialized and stored prior to 3.0, we need to correctly |
|
64 | + * map the old property names with matching visibility. |
|
65 | + */ |
|
66 | + public function __wakeup() { |
|
67 | 67 | |
68 | - if ( $this->scheduled_timestamp === null && $this->timestamp !== null ) { |
|
69 | - $this->scheduled_timestamp = $this->timestamp; |
|
70 | - unset( $this->timestamp ); |
|
71 | - } |
|
72 | - parent::__wakeup(); |
|
73 | - } |
|
68 | + if ( $this->scheduled_timestamp === null && $this->timestamp !== null ) { |
|
69 | + $this->scheduled_timestamp = $this->timestamp; |
|
70 | + unset( $this->timestamp ); |
|
71 | + } |
|
72 | + parent::__wakeup(); |
|
73 | + } |
|
74 | 74 | } |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * |
16 | 16 | * @return DateTime|null |
17 | 17 | */ |
18 | - public function calculate_next( DateTime $after ) { |
|
18 | + public function calculate_next(DateTime $after) { |
|
19 | 19 | return null; |
20 | 20 | } |
21 | 21 | |
@@ -65,9 +65,9 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public function __wakeup() { |
67 | 67 | |
68 | - if ( $this->scheduled_timestamp === null && $this->timestamp !== null ) { |
|
68 | + if ($this->scheduled_timestamp === null && $this->timestamp !== null) { |
|
69 | 69 | $this->scheduled_timestamp = $this->timestamp; |
70 | - unset( $this->timestamp ); |
|
70 | + unset($this->timestamp); |
|
71 | 71 | } |
72 | 72 | parent::__wakeup(); |
73 | 73 | } |
@@ -5,63 +5,63 @@ |
||
5 | 5 | */ |
6 | 6 | class ActionScheduler_LogEntry { |
7 | 7 | |
8 | - /** |
|
9 | - * @var int $action_id |
|
10 | - */ |
|
11 | - protected $action_id = ''; |
|
8 | + /** |
|
9 | + * @var int $action_id |
|
10 | + */ |
|
11 | + protected $action_id = ''; |
|
12 | 12 | |
13 | - /** |
|
14 | - * @var string $message |
|
15 | - */ |
|
16 | - protected $message = ''; |
|
13 | + /** |
|
14 | + * @var string $message |
|
15 | + */ |
|
16 | + protected $message = ''; |
|
17 | 17 | |
18 | - /** |
|
19 | - * @var Datetime $date |
|
20 | - */ |
|
21 | - protected $date; |
|
18 | + /** |
|
19 | + * @var Datetime $date |
|
20 | + */ |
|
21 | + protected $date; |
|
22 | 22 | |
23 | - /** |
|
24 | - * Constructor |
|
25 | - * |
|
26 | - * @param mixed $action_id Action ID |
|
27 | - * @param string $message Message |
|
28 | - * @param Datetime $date Datetime object with the time when this log entry was created. If this parameter is |
|
29 | - * not provided a new Datetime object (with current time) will be created. |
|
30 | - */ |
|
31 | - public function __construct( $action_id, $message, $date = null ) { |
|
23 | + /** |
|
24 | + * Constructor |
|
25 | + * |
|
26 | + * @param mixed $action_id Action ID |
|
27 | + * @param string $message Message |
|
28 | + * @param Datetime $date Datetime object with the time when this log entry was created. If this parameter is |
|
29 | + * not provided a new Datetime object (with current time) will be created. |
|
30 | + */ |
|
31 | + public function __construct( $action_id, $message, $date = null ) { |
|
32 | 32 | |
33 | - /* |
|
33 | + /* |
|
34 | 34 | * ActionScheduler_wpCommentLogger::get_entry() previously passed a 3rd param of $comment->comment_type |
35 | 35 | * to ActionScheduler_LogEntry::__construct(), goodness knows why, and the Follow-up Emails plugin |
36 | 36 | * hard-codes loading its own version of ActionScheduler_wpCommentLogger with that out-dated method, |
37 | 37 | * goodness knows why, so we need to guard against that here instead of using a DateTime type declaration |
38 | 38 | * for the constructor's 3rd param of $date and causing a fatal error with older versions of FUE. |
39 | 39 | */ |
40 | - if ( null !== $date && ! is_a( $date, 'DateTime' ) ) { |
|
41 | - _doing_it_wrong( __METHOD__, 'The third parameter must be a valid DateTime instance, or null.', '2.0.0' ); |
|
42 | - $date = null; |
|
43 | - } |
|
40 | + if ( null !== $date && ! is_a( $date, 'DateTime' ) ) { |
|
41 | + _doing_it_wrong( __METHOD__, 'The third parameter must be a valid DateTime instance, or null.', '2.0.0' ); |
|
42 | + $date = null; |
|
43 | + } |
|
44 | 44 | |
45 | - $this->action_id = $action_id; |
|
46 | - $this->message = $message; |
|
47 | - $this->date = $date ? $date : new Datetime(); |
|
48 | - } |
|
45 | + $this->action_id = $action_id; |
|
46 | + $this->message = $message; |
|
47 | + $this->date = $date ? $date : new Datetime(); |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * Returns the date when this log entry was created |
|
52 | - * |
|
53 | - * @return Datetime |
|
54 | - */ |
|
55 | - public function get_date() { |
|
56 | - return $this->date; |
|
57 | - } |
|
50 | + /** |
|
51 | + * Returns the date when this log entry was created |
|
52 | + * |
|
53 | + * @return Datetime |
|
54 | + */ |
|
55 | + public function get_date() { |
|
56 | + return $this->date; |
|
57 | + } |
|
58 | 58 | |
59 | - public function get_action_id() { |
|
60 | - return $this->action_id; |
|
61 | - } |
|
59 | + public function get_action_id() { |
|
60 | + return $this->action_id; |
|
61 | + } |
|
62 | 62 | |
63 | - public function get_message() { |
|
64 | - return $this->message; |
|
65 | - } |
|
63 | + public function get_message() { |
|
64 | + return $this->message; |
|
65 | + } |
|
66 | 66 | } |
67 | 67 |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * @param Datetime $date Datetime object with the time when this log entry was created. If this parameter is |
29 | 29 | * not provided a new Datetime object (with current time) will be created. |
30 | 30 | */ |
31 | - public function __construct( $action_id, $message, $date = null ) { |
|
31 | + public function __construct($action_id, $message, $date = null) { |
|
32 | 32 | |
33 | 33 | /* |
34 | 34 | * ActionScheduler_wpCommentLogger::get_entry() previously passed a 3rd param of $comment->comment_type |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | * goodness knows why, so we need to guard against that here instead of using a DateTime type declaration |
38 | 38 | * for the constructor's 3rd param of $date and causing a fatal error with older versions of FUE. |
39 | 39 | */ |
40 | - if ( null !== $date && ! is_a( $date, 'DateTime' ) ) { |
|
41 | - _doing_it_wrong( __METHOD__, 'The third parameter must be a valid DateTime instance, or null.', '2.0.0' ); |
|
40 | + if (null !== $date && ! is_a($date, 'DateTime')) { |
|
41 | + _doing_it_wrong(__METHOD__, 'The third parameter must be a valid DateTime instance, or null.', '2.0.0'); |
|
42 | 42 | $date = null; |
43 | 43 | } |
44 | 44 |
@@ -4,93 +4,93 @@ |
||
4 | 4 | * Class ActionScheduler_Action |
5 | 5 | */ |
6 | 6 | class ActionScheduler_Action { |
7 | - protected $hook = ''; |
|
8 | - protected $args = array(); |
|
9 | - /** @var ActionScheduler_Schedule */ |
|
10 | - protected $schedule = null; |
|
11 | - protected $group = ''; |
|
7 | + protected $hook = ''; |
|
8 | + protected $args = array(); |
|
9 | + /** @var ActionScheduler_Schedule */ |
|
10 | + protected $schedule = null; |
|
11 | + protected $group = ''; |
|
12 | 12 | |
13 | - public function __construct( $hook, array $args = array(), ActionScheduler_Schedule $schedule = null, $group = '' ) { |
|
14 | - $schedule = empty( $schedule ) ? new ActionScheduler_NullSchedule() : $schedule; |
|
15 | - $this->set_hook( $hook ); |
|
16 | - $this->set_schedule( $schedule ); |
|
17 | - $this->set_args( $args ); |
|
18 | - $this->set_group( $group ); |
|
19 | - } |
|
13 | + public function __construct( $hook, array $args = array(), ActionScheduler_Schedule $schedule = null, $group = '' ) { |
|
14 | + $schedule = empty( $schedule ) ? new ActionScheduler_NullSchedule() : $schedule; |
|
15 | + $this->set_hook( $hook ); |
|
16 | + $this->set_schedule( $schedule ); |
|
17 | + $this->set_args( $args ); |
|
18 | + $this->set_group( $group ); |
|
19 | + } |
|
20 | 20 | |
21 | - /** |
|
22 | - * Executes the action. |
|
23 | - * |
|
24 | - * If no callbacks are registered, an exception will be thrown and the action will not be |
|
25 | - * fired. This is useful to help detect cases where the code responsible for setting up |
|
26 | - * a scheduled action no longer exists. |
|
27 | - * |
|
28 | - * @throws Exception If no callbacks are registered for this action. |
|
29 | - */ |
|
30 | - public function execute() { |
|
31 | - $hook = $this->get_hook(); |
|
21 | + /** |
|
22 | + * Executes the action. |
|
23 | + * |
|
24 | + * If no callbacks are registered, an exception will be thrown and the action will not be |
|
25 | + * fired. This is useful to help detect cases where the code responsible for setting up |
|
26 | + * a scheduled action no longer exists. |
|
27 | + * |
|
28 | + * @throws Exception If no callbacks are registered for this action. |
|
29 | + */ |
|
30 | + public function execute() { |
|
31 | + $hook = $this->get_hook(); |
|
32 | 32 | |
33 | - if ( ! has_action( $hook ) ) { |
|
34 | - throw new Exception( |
|
35 | - sprintf( |
|
36 | - /* translators: 1: action hook. */ |
|
37 | - __( 'Scheduled action for %1$s will not be executed as no callbacks are registered.', 'action-scheduler' ), |
|
38 | - $hook |
|
39 | - ) |
|
40 | - ); |
|
41 | - } |
|
33 | + if ( ! has_action( $hook ) ) { |
|
34 | + throw new Exception( |
|
35 | + sprintf( |
|
36 | + /* translators: 1: action hook. */ |
|
37 | + __( 'Scheduled action for %1$s will not be executed as no callbacks are registered.', 'action-scheduler' ), |
|
38 | + $hook |
|
39 | + ) |
|
40 | + ); |
|
41 | + } |
|
42 | 42 | |
43 | - do_action_ref_array( $hook, array_values( $this->get_args() ) ); |
|
44 | - } |
|
43 | + do_action_ref_array( $hook, array_values( $this->get_args() ) ); |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * @param string $hook |
|
48 | - */ |
|
49 | - protected function set_hook( $hook ) { |
|
50 | - $this->hook = $hook; |
|
51 | - } |
|
46 | + /** |
|
47 | + * @param string $hook |
|
48 | + */ |
|
49 | + protected function set_hook( $hook ) { |
|
50 | + $this->hook = $hook; |
|
51 | + } |
|
52 | 52 | |
53 | - public function get_hook() { |
|
54 | - return $this->hook; |
|
55 | - } |
|
53 | + public function get_hook() { |
|
54 | + return $this->hook; |
|
55 | + } |
|
56 | 56 | |
57 | - protected function set_schedule( ActionScheduler_Schedule $schedule ) { |
|
58 | - $this->schedule = $schedule; |
|
59 | - } |
|
57 | + protected function set_schedule( ActionScheduler_Schedule $schedule ) { |
|
58 | + $this->schedule = $schedule; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * @return ActionScheduler_Schedule |
|
63 | - */ |
|
64 | - public function get_schedule() { |
|
65 | - return $this->schedule; |
|
66 | - } |
|
61 | + /** |
|
62 | + * @return ActionScheduler_Schedule |
|
63 | + */ |
|
64 | + public function get_schedule() { |
|
65 | + return $this->schedule; |
|
66 | + } |
|
67 | 67 | |
68 | - protected function set_args( array $args ) { |
|
69 | - $this->args = $args; |
|
70 | - } |
|
68 | + protected function set_args( array $args ) { |
|
69 | + $this->args = $args; |
|
70 | + } |
|
71 | 71 | |
72 | - public function get_args() { |
|
73 | - return $this->args; |
|
74 | - } |
|
72 | + public function get_args() { |
|
73 | + return $this->args; |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * @param string $group |
|
78 | - */ |
|
79 | - protected function set_group( $group ) { |
|
80 | - $this->group = $group; |
|
81 | - } |
|
76 | + /** |
|
77 | + * @param string $group |
|
78 | + */ |
|
79 | + protected function set_group( $group ) { |
|
80 | + $this->group = $group; |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * @return string |
|
85 | - */ |
|
86 | - public function get_group() { |
|
87 | - return $this->group; |
|
88 | - } |
|
83 | + /** |
|
84 | + * @return string |
|
85 | + */ |
|
86 | + public function get_group() { |
|
87 | + return $this->group; |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * @return bool If the action has been finished |
|
92 | - */ |
|
93 | - public function is_finished() { |
|
94 | - return false; |
|
95 | - } |
|
90 | + /** |
|
91 | + * @return bool If the action has been finished |
|
92 | + */ |
|
93 | + public function is_finished() { |
|
94 | + return false; |
|
95 | + } |
|
96 | 96 | } |
@@ -10,12 +10,12 @@ discard block |
||
10 | 10 | protected $schedule = null; |
11 | 11 | protected $group = ''; |
12 | 12 | |
13 | - public function __construct( $hook, array $args = array(), ActionScheduler_Schedule $schedule = null, $group = '' ) { |
|
14 | - $schedule = empty( $schedule ) ? new ActionScheduler_NullSchedule() : $schedule; |
|
15 | - $this->set_hook( $hook ); |
|
16 | - $this->set_schedule( $schedule ); |
|
17 | - $this->set_args( $args ); |
|
18 | - $this->set_group( $group ); |
|
13 | + public function __construct($hook, array $args = array(), ActionScheduler_Schedule $schedule = null, $group = '') { |
|
14 | + $schedule = empty($schedule) ? new ActionScheduler_NullSchedule() : $schedule; |
|
15 | + $this->set_hook($hook); |
|
16 | + $this->set_schedule($schedule); |
|
17 | + $this->set_args($args); |
|
18 | + $this->set_group($group); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -30,23 +30,23 @@ discard block |
||
30 | 30 | public function execute() { |
31 | 31 | $hook = $this->get_hook(); |
32 | 32 | |
33 | - if ( ! has_action( $hook ) ) { |
|
33 | + if ( ! has_action($hook)) { |
|
34 | 34 | throw new Exception( |
35 | 35 | sprintf( |
36 | 36 | /* translators: 1: action hook. */ |
37 | - __( 'Scheduled action for %1$s will not be executed as no callbacks are registered.', 'action-scheduler' ), |
|
37 | + __('Scheduled action for %1$s will not be executed as no callbacks are registered.', 'action-scheduler'), |
|
38 | 38 | $hook |
39 | 39 | ) |
40 | 40 | ); |
41 | 41 | } |
42 | 42 | |
43 | - do_action_ref_array( $hook, array_values( $this->get_args() ) ); |
|
43 | + do_action_ref_array($hook, array_values($this->get_args())); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
47 | 47 | * @param string $hook |
48 | 48 | */ |
49 | - protected function set_hook( $hook ) { |
|
49 | + protected function set_hook($hook) { |
|
50 | 50 | $this->hook = $hook; |
51 | 51 | } |
52 | 52 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | return $this->hook; |
55 | 55 | } |
56 | 56 | |
57 | - protected function set_schedule( ActionScheduler_Schedule $schedule ) { |
|
57 | + protected function set_schedule(ActionScheduler_Schedule $schedule) { |
|
58 | 58 | $this->schedule = $schedule; |
59 | 59 | } |
60 | 60 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | return $this->schedule; |
66 | 66 | } |
67 | 67 | |
68 | - protected function set_args( array $args ) { |
|
68 | + protected function set_args(array $args) { |
|
69 | 69 | $this->args = $args; |
70 | 70 | } |
71 | 71 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | /** |
77 | 77 | * @param string $group |
78 | 78 | */ |
79 | - protected function set_group( $group ) { |
|
79 | + protected function set_group($group) { |
|
80 | 80 | $this->group = $group; |
81 | 81 | } |
82 | 82 |
@@ -5,12 +5,12 @@ |
||
5 | 5 | */ |
6 | 6 | class ActionScheduler_FinishedAction extends ActionScheduler_Action { |
7 | 7 | |
8 | - public function execute() { |
|
9 | - // don't execute |
|
10 | - } |
|
8 | + public function execute() { |
|
9 | + // don't execute |
|
10 | + } |
|
11 | 11 | |
12 | - public function is_finished() { |
|
13 | - return true; |
|
14 | - } |
|
12 | + public function is_finished() { |
|
13 | + return true; |
|
14 | + } |
|
15 | 15 | } |
16 | 16 |
@@ -5,12 +5,12 @@ |
||
5 | 5 | */ |
6 | 6 | class ActionScheduler_NullAction extends ActionScheduler_Action { |
7 | 7 | |
8 | - public function __construct( $hook = '', array $args = array(), ActionScheduler_Schedule $schedule = null ) { |
|
9 | - $this->set_schedule( new ActionScheduler_NullSchedule() ); |
|
10 | - } |
|
8 | + public function __construct( $hook = '', array $args = array(), ActionScheduler_Schedule $schedule = null ) { |
|
9 | + $this->set_schedule( new ActionScheduler_NullSchedule() ); |
|
10 | + } |
|
11 | 11 | |
12 | - public function execute() { |
|
13 | - // don't execute |
|
14 | - } |
|
12 | + public function execute() { |
|
13 | + // don't execute |
|
14 | + } |
|
15 | 15 | } |
16 | 16 |
@@ -5,8 +5,8 @@ |
||
5 | 5 | */ |
6 | 6 | class ActionScheduler_NullAction extends ActionScheduler_Action { |
7 | 7 | |
8 | - public function __construct( $hook = '', array $args = array(), ActionScheduler_Schedule $schedule = null ) { |
|
9 | - $this->set_schedule( new ActionScheduler_NullSchedule() ); |
|
8 | + public function __construct($hook = '', array $args = array(), ActionScheduler_Schedule $schedule = null) { |
|
9 | + $this->set_schedule(new ActionScheduler_NullSchedule()); |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | public function execute() { |