From a475d0a161b67a79fb86b6a94cf02113c3cd9adc Mon Sep 17 00:00:00 2001 From: Rachel Baker Date: Wed, 29 Jun 2016 01:57:55 +0000 Subject: [PATCH] REST API: Include auto-discovery Link header when serving API requests. The Link header allows clients to verify if a site has made the REST API available, as well as indicating how to access it. Props danielbachhuber. Fixes #35580. Built from https://develop.svn.wordpress.org/trunk@37903 git-svn-id: http://core.svn.wordpress.org/trunk@37844 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/rest-api/class-wp-rest-server.php | 5 +++++ wp-includes/version.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/wp-includes/rest-api/class-wp-rest-server.php b/wp-includes/rest-api/class-wp-rest-server.php index 12e4086bbc..cb19242bf1 100644 --- a/wp-includes/rest-api/class-wp-rest-server.php +++ b/wp-includes/rest-api/class-wp-rest-server.php @@ -228,6 +228,11 @@ class WP_REST_Server { $this->send_header( 'Content-Type', $content_type . '; charset=' . get_option( 'blog_charset' ) ); $this->send_header( 'X-Robots-Tag', 'noindex' ); + $api_root = get_rest_url(); + if ( ! empty( $api_root ) ) { + $this->send_header( 'Link', '<' . esc_url_raw( $api_root ) . '>; rel="https://api.w.org/"' ); + } + /* * Mitigate possible JSONP Flash attacks. * diff --git a/wp-includes/version.php b/wp-includes/version.php index f5ef2cf3c3..dc62f003a3 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.6-alpha-37902'; +$wp_version = '4.6-alpha-37903'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.