rest_output_link_header() WordPress Function

The rest_output_link_header() function is used to output the Link header for a REST request. This function should be called after the rest_pre_dispatch() function.

rest_output_link_header() #

Sends a Link header for the REST API.


Source

File: wp-includes/rest-api.php

function rest_output_link_header() {
	if ( headers_sent() ) {
		return;
	}

	$api_root = get_rest_url();

	if ( empty( $api_root ) ) {
		return;
	}

	header( sprintf( 'Link: <%s>; rel="https://api.w.org/"', esc_url_raw( $api_root ) ), false );

	$resource = rest_get_queried_resource_route();

	if ( $resource ) {
		header( sprintf( 'Link: <%s>; rel="alternate"; type="application/json"', esc_url_raw( rest_url( $resource ) ) ), false );
	}
}


Top ↑

Changelog

Changelog
VersionDescription
4.4.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More