diff --git a/wp-includes/rest-api.php b/wp-includes/rest-api.php index a2e3363951..1c73b97824 100644 --- a/wp-includes/rest-api.php +++ b/wp-includes/rest-api.php @@ -615,12 +615,27 @@ function rest_handle_options_request( $response, $handler, $request ) { $data = array(); foreach ( $handler->get_routes() as $route => $endpoints ) { - $match = preg_match( '@^' . $route . '$@i', $request->get_route() ); + $match = preg_match( '@^' . $route . '$@i', $request->get_route(), $matches ); if ( ! $match ) { continue; } + $args = array(); + foreach ( $matches as $param => $value ) { + if ( ! is_int( $param ) ) { + $args[ $param ] = $value; + } + } + + foreach ( $endpoints as $endpoint ) { + // Remove the redundant preg_match argument. + unset( $args[0] ); + + $request->set_url_params( $args ); + $request->set_attributes( $endpoint ); + } + $data = $handler->get_data_for_route( $route, $endpoints, 'help' ); $response->set_matched_route( $route ); break; diff --git a/wp-includes/version.php b/wp-includes/version.php index e113c48c99..e65cae7136 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.2-alpha-44932'; +$wp_version = '5.2-alpha-44933'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.