$args Arguments passed to the hook. * @param int $delay Seconds from now (default 0 = immediate). * * @return int|null Action Scheduler action ID, or null if unavailable. */ public static function schedule_single( string $hook, array $args = array(), int $delay = 0 ): ?int { if ( ! self::is_available() ) { return null; } return as_schedule_single_action( time() + $delay, $hook, $args, self::GROUP ); } /** * Returns true if a pending (not-yet-run) action exists for this hook. * * @param string $hook Action hook name. * @param array $args Arguments to match. * * @return bool */ public static function has_pending( string $hook, array $args = array() ): bool { if ( ! self::is_available() ) { return false; } return as_has_scheduled_action( $hook, $args, self::GROUP ); } /** * Cancels all pending plugin actions across all hooks. * * Called on plugin deactivation. * * @return void */ public static function cancel_all(): void { if ( ! self::is_available() ) { return; } as_unschedule_all_actions( '', array(), self::GROUP ); } }