diff --git a/src/wp-includes/rest-api.php b/src/wp-includes/rest-api.php
index 59e9f7931c..51658ed49c 100644
a
|
b
|
function rest_handle_options_request( $response, $handler, $request ) { |
616 | 616 | $data = []; |
617 | 617 | |
618 | 618 | foreach ( $handler->get_routes() as $route => $endpoints ) { |
619 | | $match = preg_match( '@^' . $route . '$@i', $request->get_route() ); |
| 619 | $match = preg_match( '@^' . $route . '$@i', $request->get_route(), $matches ); |
620 | 620 | |
621 | 621 | if ( ! $match ) { |
622 | 622 | continue; |
623 | 623 | } |
624 | 624 | |
| 625 | $args = []; |
| 626 | foreach ( $matches as $param => $value ) { |
| 627 | if ( ! is_int( $param ) ) { |
| 628 | $args[ $param ] = $value; |
| 629 | } |
| 630 | } |
| 631 | |
| 632 | foreach ( $endpoints as $endpoint ) { |
| 633 | // Remove the redundant preg_match argument. |
| 634 | unset( $args[0] ); |
| 635 | |
| 636 | $request->set_url_params( $args ); |
| 637 | $request->set_attributes( $endpoint ); |
| 638 | } |
| 639 | |
625 | 640 | $data = $handler->get_data_for_route( $route, $endpoints, 'help' ); |
626 | 641 | $response->set_matched_route( $route ); |
627 | 642 | break; |
628 | 643 | } |
629 | 644 | |
630 | | $response->set_data( $data ); |
631 | | |
632 | 645 | $response = rest_send_allow_header( $response, $handler, $request ); |
633 | 646 | |
| 647 | $response->set_data( $data ); |
| 648 | |
634 | 649 | return $response; |
635 | 650 | } |
636 | 651 | |