- Timestamp:
- 01/22/2016 07:02:40 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
r2246 r2358 20 20 add_action( 'wp_json_server_before_serve', 'wcorg_json_avoid_nested_callback_conflicts', 11 ); // after the default endpoints are added in `json_api_default_filters()` 21 21 add_filter( 'wp_cache_eof_tags', 'wcorg_json_cache_requests' ); 22 23 // Allow some routes to skip the JSON REST API v1 plugin. 24 add_action( 'parse_request', 'wcorg_json_v2_compat', 9 ); 22 25 23 26 /** … … 333 336 return $eof_pattern; 334 337 } 338 339 /** 340 * JSON REST API v1 and Core/v2 compatibility. 341 * 342 * All routes in $v2_routes are routed to the core handler. 343 * 344 * @param WP $request 345 */ 346 function wcorg_json_v2_compat( $request ) { 347 $v2_routes = array( 348 '/wp-json/wordcamp-qbo', 349 '/wp-json/wordcamp-letsencrypt', 350 ); 351 352 if ( strpos( $_SERVER['REQUEST_URI'], '/wp-json' ) !== 0 ) { 353 return; 354 } 355 356 $is_route_v2 = false; 357 foreach ( $v2_routes as $route ) { 358 if ( strpos( $_SERVER['REQUEST_URI'], $route ) === 0 ) { 359 $is_route_v2 = true; 360 break; 361 } 362 } 363 364 if ( ! $is_route_v2 ) { 365 return; 366 } 367 368 $request->query_vars['rest_route'] = $request->query_vars['json_route']; 369 unset( $request->query_vars['json_route'] ); 370 $request->matched_query = preg_replace( '#^json_route=(.+)$#', 'rest_route=$1', $request->matched_query ); 371 372 return; 373 }
Note: See TracChangeset
for help on using the changeset viewer.