$obstacle], 5 * MINUTE_IN_SECONDS); return $obstacle; } /** * @param string $url - The endpoint as a client would see it. * @return string|null */ private static function ask($url) { $response = \wp_remote_post($url, [ 'timeout' => 5, 'sslverify' => false, 'headers' => ['Content-Type' => 'application/json', 'Accept' => 'application/json'], 'body' => \wp_json_encode(['jsonrpc' => '2.0', 'id' => 1, 'method' => 'initialize']), ]); $raw = \is_wp_error($response) ? '' : \wp_remote_retrieve_body($response); if (trim($raw) === '') { return null; } $body = json_decode($raw, true); if (($body['code'] ?? '') === 'extendify_mcp_unauthorized') { return null; } $challenged = \wp_remote_retrieve_response_code($response) === 401 && \wp_remote_retrieve_header($response, 'www-authenticate'); return $challenged ? 'auth' : 'blocked'; } }