*/ private const CORE = ['allowed_http_request_hosts' => 10, 'ms_allowed_http_request_hosts' => 20]; /** * AddressPin::resolve() for an MCP server's host, with core's own-host and network opt-ins * removed while it runs. * * @param null|\Closure(string): list $lookup passed to AddressPin::resolve(); the system resolver by default * @return list every checked address * @throws \AlpacaBot\Toolkit\AddressRefused as AddressPin::resolve() does */ public static function resolve(string $host, string $url = '', ?\Closure $lookup = null): array { global $wp_filter; $saved = isset($wp_filter[self::FILTER]) && $wp_filter[self::FILTER] instanceof \WP_Hook ? clone $wp_filter[self::FILTER] : null; foreach (self::CORE as $callback => $priority) { remove_filter(self::FILTER, $callback, $priority); } try { return AddressPin::resolve($host, $url, $lookup); } finally { if ($saved !== null) { // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- Puts back the WP_Hook this method copied a moment ago; the class docblock says why a copy rather than add_filter(). $wp_filter[self::FILTER] = $saved; } } } }