$args Arguments for the hook's callbacks. */ public static function schedule( int $timestamp, string $hook, array $args ): void { $schedule = static function () use ( $timestamp, $hook, $args ): void { as_schedule_single_action( $timestamp, $hook, $args, self::GROUP ); }; // Action Scheduler is ready from init on. Work that is handed over earlier waits for it. if ( did_action( 'action_scheduler_init' ) ) { $schedule(); } else { add_action( 'action_scheduler_init', $schedule ); } } /** * Cancels everything this plugin has waiting. Does nothing when Action Scheduler is not running. */ public static function cancel_all(): void { if ( function_exists( 'as_unschedule_all_actions' ) && did_action( 'action_scheduler_init' ) ) { as_unschedule_all_actions( '', [], self::GROUP ); } } }