From cd56aef4f90cdd44c9edf207b60790974408e11e Mon Sep 17 00:00:00 2001 From: Pablo Amato Date: Fri, 19 May 2017 21:32:58 -0300 Subject: [PATCH] Fix for multiple values on "Link" header MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sample header value with page as front page ( added by wp_shortlink_header() ): link →; rel="http://api.w.org/", ; rel=shortlink Sample header value with posts as front page: Link →; rel="https://api.w.org/" --- lib/namespace.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/namespace.php b/lib/namespace.php index f5da48d..24a849c 100644 --- a/lib/namespace.php +++ b/lib/namespace.php @@ -36,7 +36,8 @@ function discover_api_root( $uri, $legacy = false ) { $response = Requests::head( $uri ); $response->throw_for_status(); - $links = $response->headers->getValues( 'Link' ); + $header_value = $response->headers->getValues( 'Link' ); + $links = explode( ',', $header_value[0] ); // Find the correct link by relation foreach ( $links as $link ) {