WordPress.org

Make WordPress Core


Ignore:
Timestamp:
06/29/2016 01:56:32 AM (4 years ago)
Author:
rachelbaker
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/class-wp-rest-server.php

    r37726 r37903  
    228228        $this->send_header( 'Content-Type', $content_type . '; charset=' . get_option( 'blog_charset' ) );
    229229        $this->send_header( 'X-Robots-Tag', 'noindex' );
     230
     231        $api_root = get_rest_url();
     232        if ( ! empty( $api_root ) ) {
     233            $this->send_header( 'Link', '<' . esc_url_raw( $api_root ) . '>; rel="https://api.w.org/"' );
     234        }
    230235
    231236        /*
Note: See TracChangeset for help on using the changeset viewer.