! function_exists( 'as_enqueue_async_action' ) ) { return null; } return as_enqueue_async_action( $this->action, [ 'tasks_meta_id' => $this->meta_id ], Tasks::GROUP ); } /** * Register the recurring task. * * @since 1.5.9 * * @return null|string Action ID. */ protected function register_recurring() { if ( ! function_exists( 'as_schedule_recurring_action' ) ) { return null; } return as_schedule_recurring_action( $this->timestamp, $this->interval, $this->action, [ 'tasks_meta_id' => $this->meta_id ], Tasks::GROUP ); } /** * Register the one-time task. * * @since 1.5.9 * * @return null|string Action ID. */ protected function register_once() { if ( ! function_exists( 'as_schedule_single_action' ) ) { return null; } return as_schedule_single_action( $this->timestamp, $this->action, [ 'tasks_meta_id' => $this->meta_id ], Tasks::GROUP ); } /** * Cancel all occurrences of this task. * * @since 1.6.1 * * @return null|bool|string Null if no matching action found, * false if AS library is missing, * true if scheduled task has no params, * string of the scheduled action ID if a scheduled action was found and unscheduled. */ public function cancel() { if ( ! function_exists( 'as_unschedule_all_actions' ) ) { return false; } if ( $this->params === null ) { as_unschedule_all_actions( $this->action ); return true; } $this->meta_id = $this->meta->get_meta_id( $this->action, $this->params ); if ( $this->meta_id === null ) { return null; } return as_unschedule_action( $this->action, [ 'tasks_meta_id' => $this->meta_id ], Tasks::GROUP ); } }