WordPress.org

Make WordPress Core

Ticket #41555: 41555.diff

File 41555.diff, 2.9 KB (added by jnylen0, 4 years ago)
  • src/wp-includes/rest-api.php

    diff --git a/src/wp-includes/rest-api.php b/src/wp-includes/rest-api.php
    index 3b158ea..06bb9f9 100644
    a b define( 'REST_API_VERSION', '2.0' ); 
    1919 *
    2020 * @since 4.4.0
    2121 *
    22  * @global WP_REST_Server $wp_rest_server ResponseHandler instance (usually WP_REST_Server).
    23  *
    2422 * @param string $namespace The first URL segment after core prefix. Should be unique to your package/plugin.
    2523 * @param string $route     The base URL for route you are adding.
    2624 * @param array  $args      Optional. Either an array of options for the endpoint, or an array of arrays for
    define( 'REST_API_VERSION', '2.0' ); 
    3028 * @return bool True on success, false on error.
    3129 */
    3230function register_rest_route( $namespace, $route, $args = array(), $override = false ) {
    33         /** @var WP_REST_Server $wp_rest_server */
    34         global $wp_rest_server;
    35 
    3631        if ( empty( $namespace ) ) {
    3732                /*
    3833                 * Non-namespaced routes are not allowed, with the exception of the main
    function register_rest_route( $namespace, $route, $args = array(), $override = f 
    7469        }
    7570
    7671        $full_route = '/' . trim( $namespace, '/' ) . '/' . trim( $route, '/' );
    77         $wp_rest_server->register_route( $namespace, $full_route, $args, $override );
     72        rest_get_server()->register_route( $namespace, $full_route, $args, $override );
    7873        return true;
    7974}
    8075
    function create_initial_rest_routes() { 
    245240 * @since 4.4.0
    246241 *
    247242 * @global WP             $wp             Current WordPress environment instance.
    248  * @global WP_REST_Server $wp_rest_server ResponseHandler instance (usually WP_REST_Server).
    249243 */
    250244function rest_api_loaded() {
    251245        if ( empty( $GLOBALS['wp']->query_vars['rest_route'] ) ) {
    function rest_url( $path = '', $scheme = 'json' ) { 
    387381 *
    388382 * @since 4.4.0
    389383 *
    390  * @global WP_REST_Server $wp_rest_server ResponseHandler instance (usually WP_REST_Server).
    391  *
    392384 * @param WP_REST_Request|string $request Request.
    393385 * @return WP_REST_Response REST response.
    394386 */
    function rest_output_link_header() { 
    704696 * @since 4.4.0
    705697 *
    706698 * @global mixed          $wp_rest_auth_cookie
    707  * @global WP_REST_Server $wp_rest_server      REST server instance.
    708699 *
    709700 * @param WP_Error|mixed $result Error from another authentication handler,
    710701 *                               null if we should handle it, or another value
    function rest_cookie_check_errors( $result ) { 
    716707                return $result;
    717708        }
    718709
    719         global $wp_rest_auth_cookie, $wp_rest_server;
     710        global $wp_rest_auth_cookie;
    720711
    721712        /*
    722713         * Is cookie authentication being used? (If we get an auth
    function rest_cookie_check_errors( $result ) { 
    750741        }
    751742
    752743        // Send a refreshed nonce in header.
    753         $wp_rest_server->send_header( 'X-WP-Nonce', wp_create_nonce( 'wp_rest' ) );
     744        rest_get_server()->send_header( 'X-WP-Nonce', wp_create_nonce( 'wp_rest' ) );
    754745
    755746        return true;
    756747}