WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/12/2019 09:46:41 PM (2 years ago)
Author:
kadamwhite
Message:

REST API: Accept string path in rest_ensure_request.

Update rest_ensure_request() to accept a string path, permitting a string path to be passed to rest_do_request() as is indicated (previously inaccurately) in that method's PHPDoc.

Props TimothyBlynJacobs, kadamwhite.
Fixes #40614.

File:
1 edited

Legend:

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

    r45932 r46099  
    483483 *
    484484 * @since 4.4.0
    485  *
    486  * @param array|WP_REST_Request $request Request to check.
     485 * @since 5.3.0 Accept string argument for the request path.
     486 *
     487 * @param array|string|WP_REST_Request $request Request to check.
    487488 * @return WP_REST_Request REST request instance.
    488489 */
     
    490491    if ( $request instanceof WP_REST_Request ) {
    491492        return $request;
     493    }
     494
     495    if ( is_string( $request ) ) {
     496        return new WP_REST_Request( 'GET', $request );
    492497    }
    493498
Note: See TracChangeset for help on using the changeset viewer.