Changeset 36674
- Timestamp:
- 02/24/2016 04:19:44 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/class-wp-rest-server.php
r36576 r36674 533 533 foreach ( $links as $item ) { 534 534 // Determine if the link is embeddable. 535 if ( empty( $item['embeddable'] ) || strpos( $item['href'], $api_root ) !== 0) {535 if ( empty( $item['embeddable'] ) ) { 536 536 // Ensure we keep the same order. 537 537 $embeds[] = array(); … … 540 540 541 541 // Run through our internal routing and serve. 542 $route = substr( $item['href'], strlen( untrailingslashit( $api_root ) ) ); 543 $query_params = array(); 544 545 // Parse out URL query parameters. 546 $parsed = parse_url( $route ); 547 if ( empty( $parsed['path'] ) ) { 542 $request = WP_REST_Request::from_url( $item['href'] ); 543 if ( ! $request ) { 548 544 $embeds[] = array(); 549 545 continue; 550 546 } 551 547 552 if ( ! empty( $parsed['query'] ) ) {553 parse_str( $parsed['query'], $query_params );554 555 // Ensure magic quotes are stripped.556 if ( get_magic_quotes_gpc() ) {557 $query_params = stripslashes_deep( $query_params );558 }559 }560 561 548 // Embedded resources get passed context=embed. 562 if ( empty( $query_params['context'] ) ) { 563 $query_params['context'] = 'embed'; 564 } 565 566 $request = new WP_REST_Request( 'GET', $parsed['path'] ); 567 568 $request->set_query_params( $query_params ); 549 if ( empty( $request['context'] ) ) { 550 $request['context'] = 'embed'; 551 } 552 569 553 $response = $this->dispatch( $request ); 570 554 -
trunk/tests/phpunit/tests/rest-api/rest-server.php
r36535 r36674 493 493 494 494 $response = new WP_REST_Response(); 495 $response->add_link( 'alternate', rest_url( '/test/embeddable?parsed_params=yes' ), array( 'embeddable' => true ) ); 495 $url = rest_url( '/test/embeddable' ); 496 $url = add_query_arg( 'parsed_params', 'yes', $url ); 497 $response->add_link( 'alternate', $url, array( 'embeddable' => true ) ); 496 498 497 499 $data = $this->server->response_to_data( $response, true ); … … 515 517 516 518 $response = new WP_REST_Response(); 517 $response->add_link( 'up', rest_url( '/test/embeddable?error=1' ), array( 'embeddable' => true ) ); 519 $url = rest_url( '/test/embeddable' ); 520 $url = add_query_arg( 'error', '1', $url ); 521 $response->add_link( 'up', $url, array( 'embeddable' => true ) ); 518 522 519 523 $data = $this->server->response_to_data( $response, true );
Note: See TracChangeset
for help on using the changeset viewer.