Make WordPress Core


Ignore:
Timestamp:
02/16/2016 05:50:21 AM (6 years ago)
Author:
rmccue
Message:

REST API: Allow explicit HEAD callbacks.

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

Fixes #34841.

File:
1 edited

Legend:

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

    r36534 r36535  
    821821                $response = null;
    822822
    823                 $checked_method = 'HEAD' === $method ? 'GET' : $method;
     823                // Fallback to GET method if no HEAD method is registered.
     824                $checked_method = $method;
     825                if ( 'HEAD' === $method && empty( $handler['methods']['HEAD'] ) ) {
     826                    $checked_method = 'GET';
     827                }
    824828                if ( empty( $handler['methods'][ $checked_method ] ) ) {
    825829                    continue;
Note: See TracChangeset for help on using the changeset viewer.