$hook, 'status' => \ActionScheduler_Store::STATUS_PENDING, 'per_page' => 1, ), 'ids' ); } /** * Queue a single job (no arguments) unless one of this hook is already waiting. * * @since 1.0.0 * @param string $hook Hook. * @param int $delay Seconds from now; 0 queues an async job (as soon as possible). * @param string $group Action Scheduler group. * @return bool Whether a job was queued. */ public static function queue_once( string $hook, int $delay, string $group ): bool { if ( '' === $hook || ! function_exists( 'as_schedule_single_action' ) || self::pending( $hook ) ) { return false; } $id = $delay > 0 ? as_schedule_single_action( time() + $delay, $hook, array(), $group ) : as_enqueue_async_action( $hook, array(), $group ); return (bool) $id; } }