@@ -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 ( ! is_null( $this->timestamp ) ) { |
|
| 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 ( ! is_null( $this->timestamp ) ) { |
|
| 52 | + $this->scheduled_timestamp = $this->timestamp; |
|
| 53 | + unset( $this->timestamp ); |
|
| 54 | + } |
|
| 55 | + parent::__wakeup(); |
|
| 56 | + } |
|
| 57 | 57 | } |
@@ -5,24 +5,24 @@ |
||
| 5 | 5 | */ |
| 6 | 6 | class ActionScheduler_NullSchedule extends ActionScheduler_SimpleSchedule { |
| 7 | 7 | |
| 8 | - /** |
|
| 9 | - * Make the $date param optional and default to null. |
|
| 10 | - * |
|
| 11 | - * @param null $date The date & time to run the action. |
|
| 12 | - */ |
|
| 13 | - public function __construct( DateTime $date = null ) { |
|
| 14 | - $this->scheduled_date = null; |
|
| 15 | - } |
|
| 8 | + /** |
|
| 9 | + * Make the $date param optional and default to null. |
|
| 10 | + * |
|
| 11 | + * @param null $date The date & time to run the action. |
|
| 12 | + */ |
|
| 13 | + public function __construct( DateTime $date = null ) { |
|
| 14 | + $this->scheduled_date = null; |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * This schedule has no scheduled DateTime, so we need to override the parent __sleep() |
|
| 19 | - * @return array |
|
| 20 | - */ |
|
| 21 | - public function __sleep() { |
|
| 22 | - return array(); |
|
| 23 | - } |
|
| 17 | + /** |
|
| 18 | + * This schedule has no scheduled DateTime, so we need to override the parent __sleep() |
|
| 19 | + * @return array |
|
| 20 | + */ |
|
| 21 | + public function __sleep() { |
|
| 22 | + return array(); |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - public function __wakeup() { |
|
| 26 | - $this->scheduled_date = null; |
|
| 27 | - } |
|
| 25 | + public function __wakeup() { |
|
| 26 | + $this->scheduled_date = null; |
|
| 27 | + } |
|
| 28 | 28 | } |
@@ -5,67 +5,67 @@ |
||
| 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( $sleep_params, array( |
|
| 49 | - 'timestamp', |
|
| 50 | - ) ); |
|
| 51 | - } |
|
| 48 | + return array_merge( $sleep_params, array( |
|
| 49 | + 'timestamp', |
|
| 50 | + ) ); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Unserialize recurring schedules serialized/stored prior to AS 3.0.0 |
|
| 55 | - * |
|
| 56 | - * Prior to Action Scheduler 3.0.0, schedules used different property names to refer |
|
| 57 | - * to equivalent data. For example, ActionScheduler_IntervalSchedule::start_timestamp |
|
| 58 | - * was the same as ActionScheduler_SimpleSchedule::timestamp. Action Scheduler 3.0.0 |
|
| 59 | - * aligned properties and property names for better inheritance. To maintain backward |
|
| 60 | - * compatibility with schedules serialized and stored prior to 3.0, we need to correctly |
|
| 61 | - * map the old property names with matching visibility. |
|
| 62 | - */ |
|
| 63 | - public function __wakeup() { |
|
| 53 | + /** |
|
| 54 | + * Unserialize recurring schedules serialized/stored prior to AS 3.0.0 |
|
| 55 | + * |
|
| 56 | + * Prior to Action Scheduler 3.0.0, schedules used different property names to refer |
|
| 57 | + * to equivalent data. For example, ActionScheduler_IntervalSchedule::start_timestamp |
|
| 58 | + * was the same as ActionScheduler_SimpleSchedule::timestamp. Action Scheduler 3.0.0 |
|
| 59 | + * aligned properties and property names for better inheritance. To maintain backward |
|
| 60 | + * compatibility with schedules serialized and stored prior to 3.0, we need to correctly |
|
| 61 | + * map the old property names with matching visibility. |
|
| 62 | + */ |
|
| 63 | + public function __wakeup() { |
|
| 64 | 64 | |
| 65 | - if ( is_null( $this->scheduled_timestamp ) && ! is_null( $this->timestamp ) ) { |
|
| 66 | - $this->scheduled_timestamp = $this->timestamp; |
|
| 67 | - unset( $this->timestamp ); |
|
| 68 | - } |
|
| 69 | - parent::__wakeup(); |
|
| 70 | - } |
|
| 65 | + if ( is_null( $this->scheduled_timestamp ) && ! is_null( $this->timestamp ) ) { |
|
| 66 | + $this->scheduled_timestamp = $this->timestamp; |
|
| 67 | + unset( $this->timestamp ); |
|
| 68 | + } |
|
| 69 | + parent::__wakeup(); |
|
| 70 | + } |
|
| 71 | 71 | } |
@@ -14,178 +14,178 @@ |
||
| 14 | 14 | |
| 15 | 15 | if ( ! class_exists( 'WP_Async_Request' ) ) { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Abstract WP_Async_Request class. |
|
| 19 | - * |
|
| 20 | - * @abstract |
|
| 21 | - */ |
|
| 22 | - abstract class WP_Async_Request { |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * Prefix |
|
| 26 | - * |
|
| 27 | - * (default value: 'wp') |
|
| 28 | - * |
|
| 29 | - * @var string |
|
| 30 | - * @access protected |
|
| 31 | - */ |
|
| 32 | - protected $prefix = 'wp'; |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * Action |
|
| 36 | - * |
|
| 37 | - * (default value: 'async_request') |
|
| 38 | - * |
|
| 39 | - * @var string |
|
| 40 | - * @access protected |
|
| 41 | - */ |
|
| 42 | - protected $action = 'async_request'; |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * Identifier |
|
| 46 | - * |
|
| 47 | - * @var mixed |
|
| 48 | - * @access protected |
|
| 49 | - */ |
|
| 50 | - protected $identifier; |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * Data |
|
| 54 | - * |
|
| 55 | - * (default value: array()) |
|
| 56 | - * |
|
| 57 | - * @var array |
|
| 58 | - * @access protected |
|
| 59 | - */ |
|
| 60 | - protected $data = array(); |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * Initiate new async request |
|
| 64 | - */ |
|
| 65 | - public function __construct() { |
|
| 66 | - $this->identifier = $this->prefix . '_' . $this->action; |
|
| 67 | - |
|
| 68 | - add_action( 'wp_ajax_' . $this->identifier, array( $this, 'maybe_handle' ) ); |
|
| 69 | - add_action( 'wp_ajax_nopriv_' . $this->identifier, array( $this, 'maybe_handle' ) ); |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * Set data used during the request |
|
| 74 | - * |
|
| 75 | - * @param array $data Data. |
|
| 76 | - * |
|
| 77 | - * @return $this |
|
| 78 | - */ |
|
| 79 | - public function data( $data ) { |
|
| 80 | - $this->data = $data; |
|
| 81 | - |
|
| 82 | - return $this; |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * Dispatch the async request |
|
| 87 | - * |
|
| 88 | - * @return array|WP_Error |
|
| 89 | - */ |
|
| 90 | - public function dispatch() { |
|
| 91 | - $url = add_query_arg( $this->get_query_args(), $this->get_query_url() ); |
|
| 92 | - $args = $this->get_post_args(); |
|
| 93 | - |
|
| 94 | - return wp_remote_post( esc_url_raw( $url ), $args ); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - /** |
|
| 98 | - * Get query args |
|
| 99 | - * |
|
| 100 | - * @return array |
|
| 101 | - */ |
|
| 102 | - protected function get_query_args() { |
|
| 103 | - if ( property_exists( $this, 'query_args' ) ) { |
|
| 104 | - return $this->query_args; |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - $args = array( |
|
| 108 | - 'action' => $this->identifier, |
|
| 109 | - 'nonce' => wp_create_nonce( $this->identifier ), |
|
| 110 | - ); |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * Filters the post arguments used during an async request. |
|
| 114 | - * |
|
| 115 | - * @param array $url |
|
| 116 | - */ |
|
| 117 | - return apply_filters( $this->identifier . '_query_args', $args ); |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * Get query URL |
|
| 122 | - * |
|
| 123 | - * @return string |
|
| 124 | - */ |
|
| 125 | - protected function get_query_url() { |
|
| 126 | - if ( property_exists( $this, 'query_url' ) ) { |
|
| 127 | - return $this->query_url; |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - $url = admin_url( 'admin-ajax.php' ); |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * Filters the post arguments used during an async request. |
|
| 134 | - * |
|
| 135 | - * @param string $url |
|
| 136 | - */ |
|
| 137 | - return apply_filters( $this->identifier . '_query_url', $url ); |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * Get post args |
|
| 142 | - * |
|
| 143 | - * @return array |
|
| 144 | - */ |
|
| 145 | - protected function get_post_args() { |
|
| 146 | - if ( property_exists( $this, 'post_args' ) ) { |
|
| 147 | - return $this->post_args; |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - $args = array( |
|
| 151 | - 'timeout' => 0.01, |
|
| 152 | - 'blocking' => false, |
|
| 153 | - 'body' => $this->data, |
|
| 154 | - 'cookies' => $_COOKIE, |
|
| 155 | - 'sslverify' => apply_filters( 'https_local_ssl_verify', false ), |
|
| 156 | - ); |
|
| 157 | - |
|
| 158 | - /** |
|
| 159 | - * Filters the post arguments used during an async request. |
|
| 160 | - * |
|
| 161 | - * @param array $args |
|
| 162 | - */ |
|
| 163 | - return apply_filters( $this->identifier . '_post_args', $args ); |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - /** |
|
| 167 | - * Maybe handle |
|
| 168 | - * |
|
| 169 | - * Check for correct nonce and pass to handler. |
|
| 170 | - */ |
|
| 171 | - public function maybe_handle() { |
|
| 172 | - // Don't lock up other requests while processing |
|
| 173 | - session_write_close(); |
|
| 174 | - |
|
| 175 | - check_ajax_referer( $this->identifier, 'nonce' ); |
|
| 176 | - |
|
| 177 | - $this->handle(); |
|
| 178 | - |
|
| 179 | - wp_die(); |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - /** |
|
| 183 | - * Handle |
|
| 184 | - * |
|
| 185 | - * Override this method to perform any actions required |
|
| 186 | - * during the async request. |
|
| 187 | - */ |
|
| 188 | - abstract protected function handle(); |
|
| 189 | - |
|
| 190 | - } |
|
| 17 | + /** |
|
| 18 | + * Abstract WP_Async_Request class. |
|
| 19 | + * |
|
| 20 | + * @abstract |
|
| 21 | + */ |
|
| 22 | + abstract class WP_Async_Request { |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * Prefix |
|
| 26 | + * |
|
| 27 | + * (default value: 'wp') |
|
| 28 | + * |
|
| 29 | + * @var string |
|
| 30 | + * @access protected |
|
| 31 | + */ |
|
| 32 | + protected $prefix = 'wp'; |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * Action |
|
| 36 | + * |
|
| 37 | + * (default value: 'async_request') |
|
| 38 | + * |
|
| 39 | + * @var string |
|
| 40 | + * @access protected |
|
| 41 | + */ |
|
| 42 | + protected $action = 'async_request'; |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * Identifier |
|
| 46 | + * |
|
| 47 | + * @var mixed |
|
| 48 | + * @access protected |
|
| 49 | + */ |
|
| 50 | + protected $identifier; |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * Data |
|
| 54 | + * |
|
| 55 | + * (default value: array()) |
|
| 56 | + * |
|
| 57 | + * @var array |
|
| 58 | + * @access protected |
|
| 59 | + */ |
|
| 60 | + protected $data = array(); |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * Initiate new async request |
|
| 64 | + */ |
|
| 65 | + public function __construct() { |
|
| 66 | + $this->identifier = $this->prefix . '_' . $this->action; |
|
| 67 | + |
|
| 68 | + add_action( 'wp_ajax_' . $this->identifier, array( $this, 'maybe_handle' ) ); |
|
| 69 | + add_action( 'wp_ajax_nopriv_' . $this->identifier, array( $this, 'maybe_handle' ) ); |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * Set data used during the request |
|
| 74 | + * |
|
| 75 | + * @param array $data Data. |
|
| 76 | + * |
|
| 77 | + * @return $this |
|
| 78 | + */ |
|
| 79 | + public function data( $data ) { |
|
| 80 | + $this->data = $data; |
|
| 81 | + |
|
| 82 | + return $this; |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * Dispatch the async request |
|
| 87 | + * |
|
| 88 | + * @return array|WP_Error |
|
| 89 | + */ |
|
| 90 | + public function dispatch() { |
|
| 91 | + $url = add_query_arg( $this->get_query_args(), $this->get_query_url() ); |
|
| 92 | + $args = $this->get_post_args(); |
|
| 93 | + |
|
| 94 | + return wp_remote_post( esc_url_raw( $url ), $args ); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + /** |
|
| 98 | + * Get query args |
|
| 99 | + * |
|
| 100 | + * @return array |
|
| 101 | + */ |
|
| 102 | + protected function get_query_args() { |
|
| 103 | + if ( property_exists( $this, 'query_args' ) ) { |
|
| 104 | + return $this->query_args; |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + $args = array( |
|
| 108 | + 'action' => $this->identifier, |
|
| 109 | + 'nonce' => wp_create_nonce( $this->identifier ), |
|
| 110 | + ); |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * Filters the post arguments used during an async request. |
|
| 114 | + * |
|
| 115 | + * @param array $url |
|
| 116 | + */ |
|
| 117 | + return apply_filters( $this->identifier . '_query_args', $args ); |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * Get query URL |
|
| 122 | + * |
|
| 123 | + * @return string |
|
| 124 | + */ |
|
| 125 | + protected function get_query_url() { |
|
| 126 | + if ( property_exists( $this, 'query_url' ) ) { |
|
| 127 | + return $this->query_url; |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + $url = admin_url( 'admin-ajax.php' ); |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * Filters the post arguments used during an async request. |
|
| 134 | + * |
|
| 135 | + * @param string $url |
|
| 136 | + */ |
|
| 137 | + return apply_filters( $this->identifier . '_query_url', $url ); |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + /** |
|
| 141 | + * Get post args |
|
| 142 | + * |
|
| 143 | + * @return array |
|
| 144 | + */ |
|
| 145 | + protected function get_post_args() { |
|
| 146 | + if ( property_exists( $this, 'post_args' ) ) { |
|
| 147 | + return $this->post_args; |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + $args = array( |
|
| 151 | + 'timeout' => 0.01, |
|
| 152 | + 'blocking' => false, |
|
| 153 | + 'body' => $this->data, |
|
| 154 | + 'cookies' => $_COOKIE, |
|
| 155 | + 'sslverify' => apply_filters( 'https_local_ssl_verify', false ), |
|
| 156 | + ); |
|
| 157 | + |
|
| 158 | + /** |
|
| 159 | + * Filters the post arguments used during an async request. |
|
| 160 | + * |
|
| 161 | + * @param array $args |
|
| 162 | + */ |
|
| 163 | + return apply_filters( $this->identifier . '_post_args', $args ); |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + /** |
|
| 167 | + * Maybe handle |
|
| 168 | + * |
|
| 169 | + * Check for correct nonce and pass to handler. |
|
| 170 | + */ |
|
| 171 | + public function maybe_handle() { |
|
| 172 | + // Don't lock up other requests while processing |
|
| 173 | + session_write_close(); |
|
| 174 | + |
|
| 175 | + check_ajax_referer( $this->identifier, 'nonce' ); |
|
| 176 | + |
|
| 177 | + $this->handle(); |
|
| 178 | + |
|
| 179 | + wp_die(); |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + /** |
|
| 183 | + * Handle |
|
| 184 | + * |
|
| 185 | + * Override this method to perform any actions required |
|
| 186 | + * during the async request. |
|
| 187 | + */ |
|
| 188 | + abstract protected function handle(); |
|
| 189 | + |
|
| 190 | + } |
|
| 191 | 191 | } |
@@ -13,10 +13,10 @@ discard block |
||
| 13 | 13 | * @return int The action ID. |
| 14 | 14 | */ |
| 15 | 15 | function as_enqueue_async_action( $hook, $args = array(), $group = '' ) { |
| 16 | - if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) { |
|
| 17 | - return 0; |
|
| 18 | - } |
|
| 19 | - return ActionScheduler::factory()->async( $hook, $args, $group ); |
|
| 16 | + if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) { |
|
| 17 | + return 0; |
|
| 18 | + } |
|
| 19 | + return ActionScheduler::factory()->async( $hook, $args, $group ); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -30,10 +30,10 @@ discard block |
||
| 30 | 30 | * @return int The action ID. |
| 31 | 31 | */ |
| 32 | 32 | function as_schedule_single_action( $timestamp, $hook, $args = array(), $group = '' ) { |
| 33 | - if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) { |
|
| 34 | - return 0; |
|
| 35 | - } |
|
| 36 | - return ActionScheduler::factory()->single( $hook, $args, $timestamp, $group ); |
|
| 33 | + if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) { |
|
| 34 | + return 0; |
|
| 35 | + } |
|
| 36 | + return ActionScheduler::factory()->single( $hook, $args, $timestamp, $group ); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -48,10 +48,10 @@ discard block |
||
| 48 | 48 | * @return int The action ID. |
| 49 | 49 | */ |
| 50 | 50 | function as_schedule_recurring_action( $timestamp, $interval_in_seconds, $hook, $args = array(), $group = '' ) { |
| 51 | - if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) { |
|
| 52 | - return 0; |
|
| 53 | - } |
|
| 54 | - return ActionScheduler::factory()->recurring( $hook, $args, $timestamp, $interval_in_seconds, $group ); |
|
| 51 | + if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) { |
|
| 52 | + return 0; |
|
| 53 | + } |
|
| 54 | + return ActionScheduler::factory()->recurring( $hook, $args, $timestamp, $interval_in_seconds, $group ); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -78,10 +78,10 @@ discard block |
||
| 78 | 78 | * @return int The action ID. |
| 79 | 79 | */ |
| 80 | 80 | function as_schedule_cron_action( $timestamp, $schedule, $hook, $args = array(), $group = '' ) { |
| 81 | - if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) { |
|
| 82 | - return 0; |
|
| 83 | - } |
|
| 84 | - return ActionScheduler::factory()->cron( $hook, $args, $timestamp, $schedule, $group ); |
|
| 81 | + if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) { |
|
| 82 | + return 0; |
|
| 83 | + } |
|
| 84 | + return ActionScheduler::factory()->cron( $hook, $args, $timestamp, $schedule, $group ); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
@@ -101,40 +101,40 @@ discard block |
||
| 101 | 101 | * @return int|null The scheduled action ID if a scheduled action was found, or null if no matching action found. |
| 102 | 102 | */ |
| 103 | 103 | function as_unschedule_action( $hook, $args = array(), $group = '' ) { |
| 104 | - if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) { |
|
| 105 | - return 0; |
|
| 106 | - } |
|
| 107 | - $params = array( |
|
| 108 | - 'hook' => $hook, |
|
| 109 | - 'status' => ActionScheduler_Store::STATUS_PENDING, |
|
| 110 | - 'orderby' => 'date', |
|
| 111 | - 'order' => 'ASC', |
|
| 112 | - 'group' => $group, |
|
| 113 | - ); |
|
| 114 | - if ( is_array( $args ) ) { |
|
| 115 | - $params['args'] = $args; |
|
| 116 | - } |
|
| 104 | + if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) { |
|
| 105 | + return 0; |
|
| 106 | + } |
|
| 107 | + $params = array( |
|
| 108 | + 'hook' => $hook, |
|
| 109 | + 'status' => ActionScheduler_Store::STATUS_PENDING, |
|
| 110 | + 'orderby' => 'date', |
|
| 111 | + 'order' => 'ASC', |
|
| 112 | + 'group' => $group, |
|
| 113 | + ); |
|
| 114 | + if ( is_array( $args ) ) { |
|
| 115 | + $params['args'] = $args; |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | - $action_id = ActionScheduler::store()->query_action( $params ); |
|
| 118 | + $action_id = ActionScheduler::store()->query_action( $params ); |
|
| 119 | 119 | |
| 120 | - if ( $action_id ) { |
|
| 121 | - try { |
|
| 122 | - ActionScheduler::store()->cancel_action( $action_id ); |
|
| 123 | - } catch ( Exception $exception ) { |
|
| 124 | - ActionScheduler::logger()->log( |
|
| 125 | - $action_id, |
|
| 126 | - sprintf( |
|
| 127 | - /* translators: %s is the name of the hook to be cancelled. */ |
|
| 128 | - __( 'Caught exception while cancelling action: %s', 'woocommerce' ), |
|
| 129 | - esc_attr( $hook ) |
|
| 130 | - ) |
|
| 131 | - ); |
|
| 120 | + if ( $action_id ) { |
|
| 121 | + try { |
|
| 122 | + ActionScheduler::store()->cancel_action( $action_id ); |
|
| 123 | + } catch ( Exception $exception ) { |
|
| 124 | + ActionScheduler::logger()->log( |
|
| 125 | + $action_id, |
|
| 126 | + sprintf( |
|
| 127 | + /* translators: %s is the name of the hook to be cancelled. */ |
|
| 128 | + __( 'Caught exception while cancelling action: %s', 'woocommerce' ), |
|
| 129 | + esc_attr( $hook ) |
|
| 130 | + ) |
|
| 131 | + ); |
|
| 132 | 132 | |
| 133 | - $action_id = null; |
|
| 134 | - } |
|
| 135 | - } |
|
| 133 | + $action_id = null; |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | - return $action_id; |
|
| 137 | + return $action_id; |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -145,22 +145,22 @@ discard block |
||
| 145 | 145 | * @param string $group The group the job is assigned to. |
| 146 | 146 | */ |
| 147 | 147 | function as_unschedule_all_actions( $hook, $args = array(), $group = '' ) { |
| 148 | - if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) { |
|
| 149 | - return; |
|
| 150 | - } |
|
| 151 | - if ( empty( $args ) ) { |
|
| 152 | - if ( ! empty( $hook ) && empty( $group ) ) { |
|
| 153 | - ActionScheduler_Store::instance()->cancel_actions_by_hook( $hook ); |
|
| 154 | - return; |
|
| 155 | - } |
|
| 156 | - if ( ! empty( $group ) && empty( $hook ) ) { |
|
| 157 | - ActionScheduler_Store::instance()->cancel_actions_by_group( $group ); |
|
| 158 | - return; |
|
| 159 | - } |
|
| 160 | - } |
|
| 161 | - do { |
|
| 162 | - $unscheduled_action = as_unschedule_action( $hook, $args, $group ); |
|
| 163 | - } while ( ! empty( $unscheduled_action ) ); |
|
| 148 | + if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) { |
|
| 149 | + return; |
|
| 150 | + } |
|
| 151 | + if ( empty( $args ) ) { |
|
| 152 | + if ( ! empty( $hook ) && empty( $group ) ) { |
|
| 153 | + ActionScheduler_Store::instance()->cancel_actions_by_hook( $hook ); |
|
| 154 | + return; |
|
| 155 | + } |
|
| 156 | + if ( ! empty( $group ) && empty( $hook ) ) { |
|
| 157 | + ActionScheduler_Store::instance()->cancel_actions_by_group( $group ); |
|
| 158 | + return; |
|
| 159 | + } |
|
| 160 | + } |
|
| 161 | + do { |
|
| 162 | + $unscheduled_action = as_unschedule_action( $hook, $args, $group ); |
|
| 163 | + } while ( ! empty( $unscheduled_action ) ); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | /** |
@@ -179,42 +179,42 @@ discard block |
||
| 179 | 179 | * @return int|bool The timestamp for the next occurrence of a pending scheduled action, true for an async or in-progress action or false if there is no matching action. |
| 180 | 180 | */ |
| 181 | 181 | function as_next_scheduled_action( $hook, $args = null, $group = '' ) { |
| 182 | - if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) { |
|
| 183 | - return false; |
|
| 184 | - } |
|
| 182 | + if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) { |
|
| 183 | + return false; |
|
| 184 | + } |
|
| 185 | 185 | |
| 186 | - $params = array( |
|
| 187 | - 'hook' => $hook, |
|
| 188 | - 'orderby' => 'date', |
|
| 189 | - 'order' => 'ASC', |
|
| 190 | - 'group' => $group, |
|
| 191 | - ); |
|
| 186 | + $params = array( |
|
| 187 | + 'hook' => $hook, |
|
| 188 | + 'orderby' => 'date', |
|
| 189 | + 'order' => 'ASC', |
|
| 190 | + 'group' => $group, |
|
| 191 | + ); |
|
| 192 | 192 | |
| 193 | - if ( is_array( $args ) ) { |
|
| 194 | - $params['args'] = $args; |
|
| 195 | - } |
|
| 193 | + if ( is_array( $args ) ) { |
|
| 194 | + $params['args'] = $args; |
|
| 195 | + } |
|
| 196 | 196 | |
| 197 | - $params['status'] = ActionScheduler_Store::STATUS_RUNNING; |
|
| 198 | - $action_id = ActionScheduler::store()->query_action( $params ); |
|
| 199 | - if ( $action_id ) { |
|
| 200 | - return true; |
|
| 201 | - } |
|
| 197 | + $params['status'] = ActionScheduler_Store::STATUS_RUNNING; |
|
| 198 | + $action_id = ActionScheduler::store()->query_action( $params ); |
|
| 199 | + if ( $action_id ) { |
|
| 200 | + return true; |
|
| 201 | + } |
|
| 202 | 202 | |
| 203 | - $params['status'] = ActionScheduler_Store::STATUS_PENDING; |
|
| 204 | - $action_id = ActionScheduler::store()->query_action( $params ); |
|
| 205 | - if ( null === $action_id ) { |
|
| 206 | - return false; |
|
| 207 | - } |
|
| 203 | + $params['status'] = ActionScheduler_Store::STATUS_PENDING; |
|
| 204 | + $action_id = ActionScheduler::store()->query_action( $params ); |
|
| 205 | + if ( null === $action_id ) { |
|
| 206 | + return false; |
|
| 207 | + } |
|
| 208 | 208 | |
| 209 | - $action = ActionScheduler::store()->fetch_action( $action_id ); |
|
| 210 | - $scheduled_date = $action->get_schedule()->get_date(); |
|
| 211 | - if ( $scheduled_date ) { |
|
| 212 | - return (int) $scheduled_date->format( 'U' ); |
|
| 213 | - } elseif ( null === $scheduled_date ) { // pending async action with NullSchedule |
|
| 214 | - return true; |
|
| 215 | - } |
|
| 209 | + $action = ActionScheduler::store()->fetch_action( $action_id ); |
|
| 210 | + $scheduled_date = $action->get_schedule()->get_date(); |
|
| 211 | + if ( $scheduled_date ) { |
|
| 212 | + return (int) $scheduled_date->format( 'U' ); |
|
| 213 | + } elseif ( null === $scheduled_date ) { // pending async action with NullSchedule |
|
| 214 | + return true; |
|
| 215 | + } |
|
| 216 | 216 | |
| 217 | - return false; |
|
| 217 | + return false; |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | /** |
@@ -232,24 +232,24 @@ discard block |
||
| 232 | 232 | * @return bool True if a matching action is pending or in-progress, false otherwise. |
| 233 | 233 | */ |
| 234 | 234 | function as_has_scheduled_action( $hook, $args = null, $group = '' ) { |
| 235 | - if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) { |
|
| 236 | - return false; |
|
| 237 | - } |
|
| 235 | + if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) { |
|
| 236 | + return false; |
|
| 237 | + } |
|
| 238 | 238 | |
| 239 | - $query_args = array( |
|
| 240 | - 'hook' => $hook, |
|
| 241 | - 'status' => array( ActionScheduler_Store::STATUS_RUNNING, ActionScheduler_Store::STATUS_PENDING ), |
|
| 242 | - 'group' => $group, |
|
| 243 | - 'orderby' => 'none', |
|
| 244 | - ); |
|
| 239 | + $query_args = array( |
|
| 240 | + 'hook' => $hook, |
|
| 241 | + 'status' => array( ActionScheduler_Store::STATUS_RUNNING, ActionScheduler_Store::STATUS_PENDING ), |
|
| 242 | + 'group' => $group, |
|
| 243 | + 'orderby' => 'none', |
|
| 244 | + ); |
|
| 245 | 245 | |
| 246 | - if ( null !== $args ) { |
|
| 247 | - $query_args['args'] = $args; |
|
| 248 | - } |
|
| 246 | + if ( null !== $args ) { |
|
| 247 | + $query_args['args'] = $args; |
|
| 248 | + } |
|
| 249 | 249 | |
| 250 | - $action_id = ActionScheduler::store()->query_action( $query_args ); |
|
| 250 | + $action_id = ActionScheduler::store()->query_action( $query_args ); |
|
| 251 | 251 | |
| 252 | - return $action_id !== null; |
|
| 252 | + return $action_id !== null; |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | /** |
@@ -275,33 +275,33 @@ discard block |
||
| 275 | 275 | * @return array |
| 276 | 276 | */ |
| 277 | 277 | function as_get_scheduled_actions( $args = array(), $return_format = OBJECT ) { |
| 278 | - if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) { |
|
| 279 | - return array(); |
|
| 280 | - } |
|
| 281 | - $store = ActionScheduler::store(); |
|
| 282 | - foreach ( array('date', 'modified') as $key ) { |
|
| 283 | - if ( isset($args[$key]) ) { |
|
| 284 | - $args[$key] = as_get_datetime_object($args[$key]); |
|
| 285 | - } |
|
| 286 | - } |
|
| 287 | - $ids = $store->query_actions( $args ); |
|
| 278 | + if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) { |
|
| 279 | + return array(); |
|
| 280 | + } |
|
| 281 | + $store = ActionScheduler::store(); |
|
| 282 | + foreach ( array('date', 'modified') as $key ) { |
|
| 283 | + if ( isset($args[$key]) ) { |
|
| 284 | + $args[$key] = as_get_datetime_object($args[$key]); |
|
| 285 | + } |
|
| 286 | + } |
|
| 287 | + $ids = $store->query_actions( $args ); |
|
| 288 | 288 | |
| 289 | - if ( $return_format == 'ids' || $return_format == 'int' ) { |
|
| 290 | - return $ids; |
|
| 291 | - } |
|
| 289 | + if ( $return_format == 'ids' || $return_format == 'int' ) { |
|
| 290 | + return $ids; |
|
| 291 | + } |
|
| 292 | 292 | |
| 293 | - $actions = array(); |
|
| 294 | - foreach ( $ids as $action_id ) { |
|
| 295 | - $actions[$action_id] = $store->fetch_action( $action_id ); |
|
| 296 | - } |
|
| 293 | + $actions = array(); |
|
| 294 | + foreach ( $ids as $action_id ) { |
|
| 295 | + $actions[$action_id] = $store->fetch_action( $action_id ); |
|
| 296 | + } |
|
| 297 | 297 | |
| 298 | - if ( $return_format == ARRAY_A ) { |
|
| 299 | - foreach ( $actions as $action_id => $action_object ) { |
|
| 300 | - $actions[$action_id] = get_object_vars($action_object); |
|
| 301 | - } |
|
| 302 | - } |
|
| 298 | + if ( $return_format == ARRAY_A ) { |
|
| 299 | + foreach ( $actions as $action_id => $action_object ) { |
|
| 300 | + $actions[$action_id] = get_object_vars($action_object); |
|
| 301 | + } |
|
| 302 | + } |
|
| 303 | 303 | |
| 304 | - return $actions; |
|
| 304 | + return $actions; |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | /** |
@@ -322,12 +322,12 @@ discard block |
||
| 322 | 322 | * @return ActionScheduler_DateTime |
| 323 | 323 | */ |
| 324 | 324 | function as_get_datetime_object( $date_string = null, $timezone = 'UTC' ) { |
| 325 | - if ( is_object( $date_string ) && $date_string instanceof DateTime ) { |
|
| 326 | - $date = new ActionScheduler_DateTime( $date_string->format( 'Y-m-d H:i:s' ), new DateTimeZone( $timezone ) ); |
|
| 327 | - } elseif ( is_numeric( $date_string ) ) { |
|
| 328 | - $date = new ActionScheduler_DateTime( '@' . $date_string, new DateTimeZone( $timezone ) ); |
|
| 329 | - } else { |
|
| 330 | - $date = new ActionScheduler_DateTime( null === $date_string ? 'now' : $date_string, new DateTimeZone( $timezone ) ); |
|
| 331 | - } |
|
| 332 | - return $date; |
|
| 325 | + if ( is_object( $date_string ) && $date_string instanceof DateTime ) { |
|
| 326 | + $date = new ActionScheduler_DateTime( $date_string->format( 'Y-m-d H:i:s' ), new DateTimeZone( $timezone ) ); |
|
| 327 | + } elseif ( is_numeric( $date_string ) ) { |
|
| 328 | + $date = new ActionScheduler_DateTime( '@' . $date_string, new DateTimeZone( $timezone ) ); |
|
| 329 | + } else { |
|
| 330 | + $date = new ActionScheduler_DateTime( null === $date_string ? 'now' : $date_string, new DateTimeZone( $timezone ) ); |
|
| 331 | + } |
|
| 332 | + return $date; |
|
| 333 | 333 | } |
@@ -19,8 +19,8 @@ discard block |
||
| 19 | 19 | * @return string The job ID |
| 20 | 20 | */ |
| 21 | 21 | function wc_schedule_single_action( $timestamp, $hook, $args = array(), $group = '' ) { |
| 22 | - _deprecated_function( __FUNCTION__, '2.1.0', 'as_schedule_single_action()' ); |
|
| 23 | - return as_schedule_single_action( $timestamp, $hook, $args, $group ); |
|
| 22 | + _deprecated_function( __FUNCTION__, '2.1.0', 'as_schedule_single_action()' ); |
|
| 23 | + return as_schedule_single_action( $timestamp, $hook, $args, $group ); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
@@ -37,8 +37,8 @@ discard block |
||
| 37 | 37 | * @return string The job ID |
| 38 | 38 | */ |
| 39 | 39 | function wc_schedule_recurring_action( $timestamp, $interval_in_seconds, $hook, $args = array(), $group = '' ) { |
| 40 | - _deprecated_function( __FUNCTION__, '2.1.0', 'as_schedule_recurring_action()' ); |
|
| 41 | - return as_schedule_recurring_action( $timestamp, $interval_in_seconds, $hook, $args, $group ); |
|
| 40 | + _deprecated_function( __FUNCTION__, '2.1.0', 'as_schedule_recurring_action()' ); |
|
| 41 | + return as_schedule_recurring_action( $timestamp, $interval_in_seconds, $hook, $args, $group ); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
@@ -65,8 +65,8 @@ discard block |
||
| 65 | 65 | * @return string The job ID |
| 66 | 66 | */ |
| 67 | 67 | function wc_schedule_cron_action( $timestamp, $schedule, $hook, $args = array(), $group = '' ) { |
| 68 | - _deprecated_function( __FUNCTION__, '2.1.0', 'as_schedule_cron_action()' ); |
|
| 69 | - return as_schedule_cron_action( $timestamp, $schedule, $hook, $args, $group ); |
|
| 68 | + _deprecated_function( __FUNCTION__, '2.1.0', 'as_schedule_cron_action()' ); |
|
| 69 | + return as_schedule_cron_action( $timestamp, $schedule, $hook, $args, $group ); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /** |
@@ -79,8 +79,8 @@ discard block |
||
| 79 | 79 | * @deprecated 2.1.0 |
| 80 | 80 | */ |
| 81 | 81 | function wc_unschedule_action( $hook, $args = array(), $group = '' ) { |
| 82 | - _deprecated_function( __FUNCTION__, '2.1.0', 'as_unschedule_action()' ); |
|
| 83 | - as_unschedule_action( $hook, $args, $group ); |
|
| 82 | + _deprecated_function( __FUNCTION__, '2.1.0', 'as_unschedule_action()' ); |
|
| 83 | + as_unschedule_action( $hook, $args, $group ); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
@@ -93,8 +93,8 @@ discard block |
||
| 93 | 93 | * @return int|bool The timestamp for the next occurrence, or false if nothing was found |
| 94 | 94 | */ |
| 95 | 95 | function wc_next_scheduled_action( $hook, $args = NULL, $group = '' ) { |
| 96 | - _deprecated_function( __FUNCTION__, '2.1.0', 'as_next_scheduled_action()' ); |
|
| 97 | - return as_next_scheduled_action( $hook, $args, $group ); |
|
| 96 | + _deprecated_function( __FUNCTION__, '2.1.0', 'as_next_scheduled_action()' ); |
|
| 97 | + return as_next_scheduled_action( $hook, $args, $group ); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
@@ -121,6 +121,6 @@ discard block |
||
| 121 | 121 | * @return array |
| 122 | 122 | */ |
| 123 | 123 | function wc_get_scheduled_actions( $args = array(), $return_format = OBJECT ) { |
| 124 | - _deprecated_function( __FUNCTION__, '2.1.0', 'as_get_scheduled_actions()' ); |
|
| 125 | - return as_get_scheduled_actions( $args, $return_format ); |
|
| 124 | + _deprecated_function( __FUNCTION__, '2.1.0', 'as_get_scheduled_actions()' ); |
|
| 125 | + return as_get_scheduled_actions( $args, $return_format ); |
|
| 126 | 126 | } |
@@ -5,25 +5,25 @@ |
||
| 5 | 5 | */ |
| 6 | 6 | abstract class ActionScheduler_Schedule_Deprecated implements ActionScheduler_Schedule { |
| 7 | 7 | |
| 8 | - /** |
|
| 9 | - * Get the date & time this schedule was created to run, or calculate when it should be run |
|
| 10 | - * after a given date & time. |
|
| 11 | - * |
|
| 12 | - * @param DateTime $after DateTime to calculate against. |
|
| 13 | - * |
|
| 14 | - * @return DateTime|null |
|
| 15 | - */ |
|
| 16 | - public function next( DateTime $after = null ) { |
|
| 17 | - if ( empty( $after ) ) { |
|
| 18 | - $return_value = $this->get_date(); |
|
| 19 | - $replacement_method = 'get_date()'; |
|
| 20 | - } else { |
|
| 21 | - $return_value = $this->get_next( $after ); |
|
| 22 | - $replacement_method = 'get_next( $after )'; |
|
| 23 | - } |
|
| 8 | + /** |
|
| 9 | + * Get the date & time this schedule was created to run, or calculate when it should be run |
|
| 10 | + * after a given date & time. |
|
| 11 | + * |
|
| 12 | + * @param DateTime $after DateTime to calculate against. |
|
| 13 | + * |
|
| 14 | + * @return DateTime|null |
|
| 15 | + */ |
|
| 16 | + public function next( DateTime $after = null ) { |
|
| 17 | + if ( empty( $after ) ) { |
|
| 18 | + $return_value = $this->get_date(); |
|
| 19 | + $replacement_method = 'get_date()'; |
|
| 20 | + } else { |
|
| 21 | + $return_value = $this->get_next( $after ); |
|
| 22 | + $replacement_method = 'get_next( $after )'; |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - _deprecated_function( __METHOD__, '3.0.0', __CLASS__ . '::' . $replacement_method ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 25 | + _deprecated_function( __METHOD__, '3.0.0', __CLASS__ . '::' . $replacement_method ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 26 | 26 | |
| 27 | - return $return_value; |
|
| 28 | - } |
|
| 27 | + return $return_value; |
|
| 28 | + } |
|
| 29 | 29 | } |
@@ -10,138 +10,138 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | class ActionScheduler_AdminView_Deprecated { |
| 12 | 12 | |
| 13 | - public function action_scheduler_post_type_args( $args ) { |
|
| 14 | - _deprecated_function( __METHOD__, '2.0.0' ); |
|
| 15 | - return $args; |
|
| 16 | - } |
|
| 13 | + public function action_scheduler_post_type_args( $args ) { |
|
| 14 | + _deprecated_function( __METHOD__, '2.0.0' ); |
|
| 15 | + return $args; |
|
| 16 | + } |
|
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Customise the post status related views displayed on the Scheduled Actions administration screen. |
|
| 20 | - * |
|
| 21 | - * @param array $views An associative array of views and view labels which can be used to filter the 'scheduled-action' posts displayed on the Scheduled Actions administration screen. |
|
| 22 | - * @return array $views An associative array of views and view labels which can be used to filter the 'scheduled-action' posts displayed on the Scheduled Actions administration screen. |
|
| 23 | - */ |
|
| 24 | - public function list_table_views( $views ) { |
|
| 25 | - _deprecated_function( __METHOD__, '2.0.0' ); |
|
| 26 | - return $views; |
|
| 27 | - } |
|
| 18 | + /** |
|
| 19 | + * Customise the post status related views displayed on the Scheduled Actions administration screen. |
|
| 20 | + * |
|
| 21 | + * @param array $views An associative array of views and view labels which can be used to filter the 'scheduled-action' posts displayed on the Scheduled Actions administration screen. |
|
| 22 | + * @return array $views An associative array of views and view labels which can be used to filter the 'scheduled-action' posts displayed on the Scheduled Actions administration screen. |
|
| 23 | + */ |
|
| 24 | + public function list_table_views( $views ) { |
|
| 25 | + _deprecated_function( __METHOD__, '2.0.0' ); |
|
| 26 | + return $views; |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Do not include the "Edit" action for the Scheduled Actions administration screen. |
|
| 31 | - * |
|
| 32 | - * Hooked to the 'bulk_actions-edit-action-scheduler' filter. |
|
| 33 | - * |
|
| 34 | - * @param array $actions An associative array of actions which can be performed on the 'scheduled-action' post type. |
|
| 35 | - * @return array $actions An associative array of actions which can be performed on the 'scheduled-action' post type. |
|
| 36 | - */ |
|
| 37 | - public function bulk_actions( $actions ) { |
|
| 38 | - _deprecated_function( __METHOD__, '2.0.0' ); |
|
| 39 | - return $actions; |
|
| 40 | - } |
|
| 29 | + /** |
|
| 30 | + * Do not include the "Edit" action for the Scheduled Actions administration screen. |
|
| 31 | + * |
|
| 32 | + * Hooked to the 'bulk_actions-edit-action-scheduler' filter. |
|
| 33 | + * |
|
| 34 | + * @param array $actions An associative array of actions which can be performed on the 'scheduled-action' post type. |
|
| 35 | + * @return array $actions An associative array of actions which can be performed on the 'scheduled-action' post type. |
|
| 36 | + */ |
|
| 37 | + public function bulk_actions( $actions ) { |
|
| 38 | + _deprecated_function( __METHOD__, '2.0.0' ); |
|
| 39 | + return $actions; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Completely customer the columns displayed on the Scheduled Actions administration screen. |
|
| 44 | - * |
|
| 45 | - * Because we can't filter the content of the default title and date columns, we need to recreate our own |
|
| 46 | - * custom columns for displaying those post fields. For the column content, @see self::list_table_column_content(). |
|
| 47 | - * |
|
| 48 | - * @param array $columns An associative array of columns that are use for the table on the Scheduled Actions administration screen. |
|
| 49 | - * @return array $columns An associative array of columns that are use for the table on the Scheduled Actions administration screen. |
|
| 50 | - */ |
|
| 51 | - public function list_table_columns( $columns ) { |
|
| 52 | - _deprecated_function( __METHOD__, '2.0.0' ); |
|
| 53 | - return $columns; |
|
| 54 | - } |
|
| 42 | + /** |
|
| 43 | + * Completely customer the columns displayed on the Scheduled Actions administration screen. |
|
| 44 | + * |
|
| 45 | + * Because we can't filter the content of the default title and date columns, we need to recreate our own |
|
| 46 | + * custom columns for displaying those post fields. For the column content, @see self::list_table_column_content(). |
|
| 47 | + * |
|
| 48 | + * @param array $columns An associative array of columns that are use for the table on the Scheduled Actions administration screen. |
|
| 49 | + * @return array $columns An associative array of columns that are use for the table on the Scheduled Actions administration screen. |
|
| 50 | + */ |
|
| 51 | + public function list_table_columns( $columns ) { |
|
| 52 | + _deprecated_function( __METHOD__, '2.0.0' ); |
|
| 53 | + return $columns; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * Make our custom title & date columns use defaulting title & date sorting. |
|
| 58 | - * |
|
| 59 | - * @param array $columns An associative array of columns that can be used to sort the table on the Scheduled Actions administration screen. |
|
| 60 | - * @return array $columns An associative array of columns that can be used to sort the table on the Scheduled Actions administration screen. |
|
| 61 | - */ |
|
| 62 | - public static function list_table_sortable_columns( $columns ) { |
|
| 63 | - _deprecated_function( __METHOD__, '2.0.0' ); |
|
| 64 | - return $columns; |
|
| 65 | - } |
|
| 56 | + /** |
|
| 57 | + * Make our custom title & date columns use defaulting title & date sorting. |
|
| 58 | + * |
|
| 59 | + * @param array $columns An associative array of columns that can be used to sort the table on the Scheduled Actions administration screen. |
|
| 60 | + * @return array $columns An associative array of columns that can be used to sort the table on the Scheduled Actions administration screen. |
|
| 61 | + */ |
|
| 62 | + public static function list_table_sortable_columns( $columns ) { |
|
| 63 | + _deprecated_function( __METHOD__, '2.0.0' ); |
|
| 64 | + return $columns; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * Print the content for our custom columns. |
|
| 69 | - * |
|
| 70 | - * @param string $column_name The key for the column for which we should output our content. |
|
| 71 | - * @param int $post_id The ID of the 'scheduled-action' post for which this row relates. |
|
| 72 | - */ |
|
| 73 | - public static function list_table_column_content( $column_name, $post_id ) { |
|
| 74 | - _deprecated_function( __METHOD__, '2.0.0' ); |
|
| 75 | - } |
|
| 67 | + /** |
|
| 68 | + * Print the content for our custom columns. |
|
| 69 | + * |
|
| 70 | + * @param string $column_name The key for the column for which we should output our content. |
|
| 71 | + * @param int $post_id The ID of the 'scheduled-action' post for which this row relates. |
|
| 72 | + */ |
|
| 73 | + public static function list_table_column_content( $column_name, $post_id ) { |
|
| 74 | + _deprecated_function( __METHOD__, '2.0.0' ); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * Hide the inline "Edit" action for all 'scheduled-action' posts. |
|
| 79 | - * |
|
| 80 | - * Hooked to the 'post_row_actions' filter. |
|
| 81 | - * |
|
| 82 | - * @param array $actions An associative array of actions which can be performed on the 'scheduled-action' post type. |
|
| 83 | - * @return array $actions An associative array of actions which can be performed on the 'scheduled-action' post type. |
|
| 84 | - */ |
|
| 85 | - public static function row_actions( $actions, $post ) { |
|
| 86 | - _deprecated_function( __METHOD__, '2.0.0' ); |
|
| 87 | - return $actions; |
|
| 88 | - } |
|
| 77 | + /** |
|
| 78 | + * Hide the inline "Edit" action for all 'scheduled-action' posts. |
|
| 79 | + * |
|
| 80 | + * Hooked to the 'post_row_actions' filter. |
|
| 81 | + * |
|
| 82 | + * @param array $actions An associative array of actions which can be performed on the 'scheduled-action' post type. |
|
| 83 | + * @return array $actions An associative array of actions which can be performed on the 'scheduled-action' post type. |
|
| 84 | + */ |
|
| 85 | + public static function row_actions( $actions, $post ) { |
|
| 86 | + _deprecated_function( __METHOD__, '2.0.0' ); |
|
| 87 | + return $actions; |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - /** |
|
| 91 | - * Run an action when triggered from the Action Scheduler administration screen. |
|
| 92 | - * |
|
| 93 | - * @codeCoverageIgnore |
|
| 94 | - */ |
|
| 95 | - public static function maybe_execute_action() { |
|
| 96 | - _deprecated_function( __METHOD__, '2.0.0' ); |
|
| 97 | - } |
|
| 90 | + /** |
|
| 91 | + * Run an action when triggered from the Action Scheduler administration screen. |
|
| 92 | + * |
|
| 93 | + * @codeCoverageIgnore |
|
| 94 | + */ |
|
| 95 | + public static function maybe_execute_action() { |
|
| 96 | + _deprecated_function( __METHOD__, '2.0.0' ); |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - /** |
|
| 100 | - * Convert an interval of seconds into a two part human friendly string. |
|
| 101 | - * |
|
| 102 | - * The WordPress human_time_diff() function only calculates the time difference to one degree, meaning |
|
| 103 | - * even if an action is 1 day and 11 hours away, it will display "1 day". This funciton goes one step |
|
| 104 | - * further to display two degrees of accuracy. |
|
| 105 | - * |
|
| 106 | - * Based on Crontrol::interval() function by Edward Dale: https://wordpress.org/plugins/wp-crontrol/ |
|
| 107 | - * |
|
| 108 | - * @param int $interval A interval in seconds. |
|
| 109 | - * @return string A human friendly string representation of the interval. |
|
| 110 | - */ |
|
| 111 | - public static function admin_notices() { |
|
| 112 | - _deprecated_function( __METHOD__, '2.0.0' ); |
|
| 113 | - } |
|
| 99 | + /** |
|
| 100 | + * Convert an interval of seconds into a two part human friendly string. |
|
| 101 | + * |
|
| 102 | + * The WordPress human_time_diff() function only calculates the time difference to one degree, meaning |
|
| 103 | + * even if an action is 1 day and 11 hours away, it will display "1 day". This funciton goes one step |
|
| 104 | + * further to display two degrees of accuracy. |
|
| 105 | + * |
|
| 106 | + * Based on Crontrol::interval() function by Edward Dale: https://wordpress.org/plugins/wp-crontrol/ |
|
| 107 | + * |
|
| 108 | + * @param int $interval A interval in seconds. |
|
| 109 | + * @return string A human friendly string representation of the interval. |
|
| 110 | + */ |
|
| 111 | + public static function admin_notices() { |
|
| 112 | + _deprecated_function( __METHOD__, '2.0.0' ); |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | - /** |
|
| 116 | - * Filter search queries to allow searching by Claim ID (i.e. post_password). |
|
| 117 | - * |
|
| 118 | - * @param string $orderby MySQL orderby string. |
|
| 119 | - * @param WP_Query $query Instance of a WP_Query object |
|
| 120 | - * @return string MySQL orderby string. |
|
| 121 | - */ |
|
| 122 | - public function custom_orderby( $orderby, $query ){ |
|
| 123 | - _deprecated_function( __METHOD__, '2.0.0' ); |
|
| 124 | - } |
|
| 115 | + /** |
|
| 116 | + * Filter search queries to allow searching by Claim ID (i.e. post_password). |
|
| 117 | + * |
|
| 118 | + * @param string $orderby MySQL orderby string. |
|
| 119 | + * @param WP_Query $query Instance of a WP_Query object |
|
| 120 | + * @return string MySQL orderby string. |
|
| 121 | + */ |
|
| 122 | + public function custom_orderby( $orderby, $query ){ |
|
| 123 | + _deprecated_function( __METHOD__, '2.0.0' ); |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - /** |
|
| 127 | - * Filter search queries to allow searching by Claim ID (i.e. post_password). |
|
| 128 | - * |
|
| 129 | - * @param string $search MySQL search string. |
|
| 130 | - * @param WP_Query $query Instance of a WP_Query object |
|
| 131 | - * @return string MySQL search string. |
|
| 132 | - */ |
|
| 133 | - public function search_post_password( $search, $query ) { |
|
| 134 | - _deprecated_function( __METHOD__, '2.0.0' ); |
|
| 135 | - } |
|
| 126 | + /** |
|
| 127 | + * Filter search queries to allow searching by Claim ID (i.e. post_password). |
|
| 128 | + * |
|
| 129 | + * @param string $search MySQL search string. |
|
| 130 | + * @param WP_Query $query Instance of a WP_Query object |
|
| 131 | + * @return string MySQL search string. |
|
| 132 | + */ |
|
| 133 | + public function search_post_password( $search, $query ) { |
|
| 134 | + _deprecated_function( __METHOD__, '2.0.0' ); |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | - /** |
|
| 138 | - * Change messages when a scheduled action is updated. |
|
| 139 | - * |
|
| 140 | - * @param array $messages |
|
| 141 | - * @return array |
|
| 142 | - */ |
|
| 143 | - public function post_updated_messages( $messages ) { |
|
| 144 | - _deprecated_function( __METHOD__, '2.0.0' ); |
|
| 145 | - return $messages; |
|
| 146 | - } |
|
| 137 | + /** |
|
| 138 | + * Change messages when a scheduled action is updated. |
|
| 139 | + * |
|
| 140 | + * @param array $messages |
|
| 141 | + * @return array |
|
| 142 | + */ |
|
| 143 | + public function post_updated_messages( $messages ) { |
|
| 144 | + _deprecated_function( __METHOD__, '2.0.0' ); |
|
| 145 | + return $messages; |
|
| 146 | + } |
|
| 147 | 147 | } |
| 148 | 148 | \ No newline at end of file |
@@ -6,44 +6,44 @@ |
||
| 6 | 6 | */ |
| 7 | 7 | abstract class ActionScheduler_Store_Deprecated { |
| 8 | 8 | |
| 9 | - /** |
|
| 10 | - * Mark an action that failed to fetch correctly as failed. |
|
| 11 | - * |
|
| 12 | - * @since 2.2.6 |
|
| 13 | - * |
|
| 14 | - * @param int $action_id The ID of the action. |
|
| 15 | - */ |
|
| 16 | - public function mark_failed_fetch_action( $action_id ) { |
|
| 17 | - _deprecated_function( __METHOD__, '3.0.0', 'ActionScheduler_Store::mark_failure()' ); |
|
| 18 | - self::$store->mark_failure( $action_id ); |
|
| 19 | - } |
|
| 9 | + /** |
|
| 10 | + * Mark an action that failed to fetch correctly as failed. |
|
| 11 | + * |
|
| 12 | + * @since 2.2.6 |
|
| 13 | + * |
|
| 14 | + * @param int $action_id The ID of the action. |
|
| 15 | + */ |
|
| 16 | + public function mark_failed_fetch_action( $action_id ) { |
|
| 17 | + _deprecated_function( __METHOD__, '3.0.0', 'ActionScheduler_Store::mark_failure()' ); |
|
| 18 | + self::$store->mark_failure( $action_id ); |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Add base hooks |
|
| 23 | - * |
|
| 24 | - * @since 2.2.6 |
|
| 25 | - */ |
|
| 26 | - protected static function hook() { |
|
| 27 | - _deprecated_function( __METHOD__, '3.0.0' ); |
|
| 28 | - } |
|
| 21 | + /** |
|
| 22 | + * Add base hooks |
|
| 23 | + * |
|
| 24 | + * @since 2.2.6 |
|
| 25 | + */ |
|
| 26 | + protected static function hook() { |
|
| 27 | + _deprecated_function( __METHOD__, '3.0.0' ); |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * Remove base hooks |
|
| 32 | - * |
|
| 33 | - * @since 2.2.6 |
|
| 34 | - */ |
|
| 35 | - protected static function unhook() { |
|
| 36 | - _deprecated_function( __METHOD__, '3.0.0' ); |
|
| 37 | - } |
|
| 30 | + /** |
|
| 31 | + * Remove base hooks |
|
| 32 | + * |
|
| 33 | + * @since 2.2.6 |
|
| 34 | + */ |
|
| 35 | + protected static function unhook() { |
|
| 36 | + _deprecated_function( __METHOD__, '3.0.0' ); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Get the site's local time. |
|
| 41 | - * |
|
| 42 | - * @deprecated 2.1.0 |
|
| 43 | - * @return DateTimeZone |
|
| 44 | - */ |
|
| 45 | - protected function get_local_timezone() { |
|
| 46 | - _deprecated_function( __FUNCTION__, '2.1.0', 'ActionScheduler_TimezoneHelper::set_local_timezone()' ); |
|
| 47 | - return ActionScheduler_TimezoneHelper::get_local_timezone(); |
|
| 48 | - } |
|
| 39 | + /** |
|
| 40 | + * Get the site's local time. |
|
| 41 | + * |
|
| 42 | + * @deprecated 2.1.0 |
|
| 43 | + * @return DateTimeZone |
|
| 44 | + */ |
|
| 45 | + protected function get_local_timezone() { |
|
| 46 | + _deprecated_function( __FUNCTION__, '2.1.0', 'ActionScheduler_TimezoneHelper::set_local_timezone()' ); |
|
| 47 | + return ActionScheduler_TimezoneHelper::get_local_timezone(); |
|
| 48 | + } |
|
| 49 | 49 | } |