Changeset 3104
- Timestamp:
- 05/09/2016 09:29:51 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/wcorg-json-api.php
r3101 r3104 349 349 * JSON REST API v1 and Core/v2 compatibility. 350 350 * 351 * All routes in $v2_routes are routed to the core handler.351 * All v2 routes are routed to the Core handler, instead of the json-rest-api plugin. 352 352 * 353 353 * @param WP $request 354 354 */ 355 355 function wcorg_json_v2_compat( $request ) { 356 $v2_routes = array( 357 '/wp-json/wordcamp-qbo', 358 '/wp-json/wordcamp-letsencrypt', 359 ); 360 361 if ( strpos( $_SERVER['REQUEST_URI'], '/wp-json' ) !== 0 ) { 356 $rest_prefix = rest_get_url_prefix(); 357 358 // Skip non-API requests 359 if ( 0 !== strpos( $_SERVER[ 'REQUEST_URI' ], "/$rest_prefix" ) ) { 362 360 return; 363 361 } 364 362 363 // Determine if it's a v2 request 365 364 $is_route_v2 = false; 366 foreach ( $v2_routes as $route ) {367 if ( strpos( $_SERVER['REQUEST_URI'], $route ) === 0) {365 foreach ( rest_get_server()->get_namespaces() as $namespace ) { 366 if ( 0 === strpos( $_SERVER[ 'REQUEST_URI' ], "/$rest_prefix/$namespace" ) ) { 368 367 $is_route_v2 = true; 369 368 break; … … 371 370 } 372 371 372 // Skip API v1 requests 373 373 if ( ! $is_route_v2 ) { 374 374 return; 375 375 } 376 376 377 // Route v2 requests to Core handler 377 378 $request->query_vars['rest_route'] = $request->query_vars['json_route']; 378 379 unset( $request->query_vars['json_route'] );
Note: See TracChangeset
for help on using the changeset viewer.