WordPress.org

Making WordPress.org

Changeset 5202


Ignore:
Timestamp:
03/29/2017 11:44:41 PM (2 years ago)
Author:
iandunn
Message:

WordCamp JSON API: Route root API URL to v2 handler

All V1 endpoints were deprecated in r5164, so the v2 handler should be the default now.

File:
1 edited

Legend:

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

    r5164 r5202  
    342342    // Determine if it's a v2 request
    343343    $is_route_v2 = false;
    344     foreach ( rest_get_server()->get_namespaces() as $namespace ) {
    345         if ( 0 === strpos( $_SERVER[ 'REQUEST_URI' ], "/$rest_prefix/$namespace" ) ) {
    346             $is_route_v2 = true;
    347             break;
     344
     345    if ( rest_get_url_prefix() === trim( $_SERVER['REQUEST_URI'], '/' ) ) {
     346        $is_route_v2 = true;
     347    }
     348
     349    if ( ! $is_route_v2 ) {
     350        foreach ( rest_get_server()->get_namespaces() as $namespace ) {
     351            if ( 0 === strpos( $_SERVER['REQUEST_URI'], "/$rest_prefix/$namespace" ) ) {
     352                $is_route_v2 = true;
     353                break;
     354            }
    348355        }
    349356    }
Note: See TracChangeset for help on using the changeset viewer.