, 'display' => '') * * @return array|null */ public function get_custom_interval_args() { return null; } /** * UTC timestamp for the first occurrence of this event. * * Defaults to one minute from the current time, giving WordPress a chance * to finish its current request before the first execution. * * @return int Unix timestamp */ public function get_schedule_start() { return time() + MINUTE_IN_SECONDS; } // ── Final infrastructure methods ─────────────────────────────────────────── /** * Bind this task's run() method to its WP action hook. * Called once per request by TaskManager::boot(). * * @return void */ final public function register() { add_action($this->get_hook(), array($this, 'run')); } /** * Schedule the recurring event unless it is already queued. * Silently no-ops when the event is already scheduled. * * @return void */ final public function schedule() { if (!$this->is_scheduled()) { wp_schedule_event( $this->get_schedule_start(), $this->get_interval(), $this->get_hook() ); } } /** * Remove every pending occurrence of this event from the cron queue. * * @return void */ final public function unschedule() { $timestamp = wp_next_scheduled($this->get_hook()); if ($timestamp !== false) { wp_unschedule_event($timestamp, $this->get_hook()); } wp_clear_scheduled_hook($this->get_hook()); } /** * Return true when at least one occurrence of this event is queued. * * @return bool */ final public function is_scheduled() { return (bool) wp_next_scheduled($this->get_hook()); } }