$agent_id, 'task' => $task->to_array(), ); if ( ! $this->supports_unique_args() && as_has_scheduled_action( self::HOOK, $args, $group ) ) { return false; } if ( $delay > 0 ) { return 0 !== as_schedule_single_action( time() + $delay, self::HOOK, $args, $group, true ); } return 0 !== as_enqueue_async_action( self::HOOK, $args, $group, true ); } /** * Whether the elected Action Scheduler honors arg-inclusive uniqueness * (4.0+). Older 3.x copies dedupe on hook+group only. */ private function supports_unique_args(): bool { if ( ! class_exists( '\ActionScheduler_Versions' ) ) { return false; } try { $version = (string) \ActionScheduler_Versions::instance()->latest_version(); return version_compare( $version, '4.0.0', '>=' ); } catch ( \Throwable $e ) { return false; } } }