Making WordPress.org

Changeset 8819


Ignore:
Timestamp:
05/20/2019 11:52:28 AM (5 years ago)
Author:
vedjain
Message:

WC Docker: Prevent overwriting rest_route if json_route is null

JSON REST API plugin is depreciated and will not be there for new installations. This patch adds a conditional check so that in cases json_route is not present, core's API handlers will handle the requests.
Request with json_route will anyways fail when JSON REST API plugin is not installed, although this should be rare because it should be hardcoded only in some old posts.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/wcorg-json-api.php

    r5202 r8819  
    362362
    363363    // Route v2 requests to Core handler
    364     $request->query_vars['rest_route'] = $request->query_vars['json_route'];
    365     unset( $request->query_vars['json_route'] );
    366     $request->matched_query = preg_replace( '#^json_route=(.+)$#', 'rest_route=$1', $request->matched_query );
     364    if ( isset( $request->query_vars['json_route'] ) ) {
     365        $request->query_vars['rest_route'] = $request->query_vars['json_route'];
     366        unset( $request->query_vars['json_route'] );
     367        $request->matched_query = preg_replace( '#^json_route=(.+)$#', 'rest_route=$1', $request->matched_query );
     368    }
    367369
    368370    return;
Note: See TracChangeset for help on using the changeset viewer.