mailpoet
/
vendor
/
woocommerce
/
action-scheduler
/
classes
/
schedules
/
ActionScheduler_IntervalSchedule.php
ActionScheduler_CanceledSchedule.php
1 year ago
ActionScheduler_CronSchedule.php
1 year ago
ActionScheduler_IntervalSchedule.php
1 year ago
ActionScheduler_NullSchedule.php
1 year ago
ActionScheduler_Schedule.php
1 year ago
ActionScheduler_SimpleSchedule.php
1 year ago
index.php
3 years ago
ActionScheduler_IntervalSchedule.php
38 lines
| 1 | <?php |
| 2 | if (!defined('ABSPATH')) exit; |
| 3 | class ActionScheduler_IntervalSchedule extends ActionScheduler_Abstract_RecurringSchedule implements ActionScheduler_Schedule { |
| 4 | private $start_timestamp = null; |
| 5 | private $interval_in_seconds = null; |
| 6 | protected function calculate_next( DateTime $after ) { |
| 7 | $after->modify( '+' . (int) $this->get_recurrence() . ' seconds' ); |
| 8 | return $after; |
| 9 | } |
| 10 | public function interval_in_seconds() { |
| 11 | _deprecated_function( __METHOD__, '3.0.0', '(int)ActionScheduler_Abstract_RecurringSchedule::get_recurrence()' ); |
| 12 | return (int) $this->get_recurrence(); |
| 13 | } |
| 14 | public function __sleep() { |
| 15 | $sleep_params = parent::__sleep(); |
| 16 | $this->start_timestamp = $this->scheduled_timestamp; |
| 17 | $this->interval_in_seconds = $this->recurrence; |
| 18 | return array_merge( |
| 19 | $sleep_params, |
| 20 | array( |
| 21 | 'start_timestamp', |
| 22 | 'interval_in_seconds', |
| 23 | ) |
| 24 | ); |
| 25 | } |
| 26 | public function __wakeup() { |
| 27 | if ( is_null( $this->scheduled_timestamp ) && ! is_null( $this->start_timestamp ) ) { |
| 28 | $this->scheduled_timestamp = $this->start_timestamp; |
| 29 | unset( $this->start_timestamp ); |
| 30 | } |
| 31 | if ( is_null( $this->recurrence ) && ! is_null( $this->interval_in_seconds ) ) { |
| 32 | $this->recurrence = $this->interval_in_seconds; |
| 33 | unset( $this->interval_in_seconds ); |
| 34 | } |
| 35 | parent::__wakeup(); |
| 36 | } |
| 37 | } |
| 38 |