get_event_name(), [ $this, 'process' ] ); } /** * Schedule the event. * * @param mixed[] ...$args Arguments passed to the function from the action hook, which here is empty always since add_action(). */ final public function schedule_event( ...$args ) { if ( ! is_user_logged_in() ) { return; } $event_name = $this->get_event_name(); $recurrence = $this->get_interval(); $scheduled_event = $this->get_scheduled_event( $event_name, $args ); // Unschedule any existing event which had a differing recurrence. if ( $scheduled_event && $scheduled_event->schedule !== $recurrence ) { wp_unschedule_event( $scheduled_event->timestamp, $event_name, $args ); $scheduled_event = null; } if ( ! $scheduled_event ) { wp_schedule_event( time(), $recurrence, $event_name, $args ); } } /** * Retrieve a scheduled event. * * This uses a copied implementation from WordPress core if `wp_get_scheduled_event()` does not exist, as it was * introduced in WordPress 5.1. * * @link https://github.com/WordPress/wordpress-develop/blob/ba943e113d3b31b121f7/src/wp-includes/cron.php#L753-L793 * @see \wp_get_scheduled_event() * @codeCoverageIgnore * * @param string $hook Action hook of the event. * @param array $args Optional. Array containing each separate argument to pass to the hook's callback function. * Although not passed to a callback, these arguments are used to uniquely identify the * event, so they should be the same as those used when originally scheduling the event. * Default empty array. * @param mixed $timestamp Optional. Unix timestamp (UTC) of the event. If not