REST API: Allow explicit HEAD callbacks.

HEAD callbacks can now be registered independently, with the GET
callback still used as a fallback.

Fixes #34841.

Built from https://develop.svn.wordpress.org/trunk@36535


git-svn-id: http://core.svn.wordpress.org/trunk@36502 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Ryan McCue 2016-02-16 05:51:26 +00:00
parent 0438795671
commit 03ba67a0b7
2 changed files with 6 additions and 2 deletions

View File

@ -820,7 +820,11 @@ class WP_REST_Server {
$callback = $handler['callback'];
$response = null;
$checked_method = 'HEAD' === $method ? 'GET' : $method;
// Fallback to GET method if no HEAD method is registered.
$checked_method = $method;
if ( 'HEAD' === $method && empty( $handler['methods']['HEAD'] ) ) {
$checked_method = 'GET';
}
if ( empty( $handler['methods'][ $checked_method ] ) ) {
continue;
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.5-alpha-36534';
$wp_version = '4.5-alpha-36535';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.