diff --git a/wp-includes/rest-api/class-wp-rest-server.php b/wp-includes/rest-api/class-wp-rest-server.php index eae12544a6..1a239a596b 100644 --- a/wp-includes/rest-api/class-wp-rest-server.php +++ b/wp-includes/rest-api/class-wp-rest-server.php @@ -763,6 +763,12 @@ class WP_REST_Server { $path = $request->get_route(); foreach ( $this->get_routes() as $route => $handlers ) { + $match = preg_match( '@^' . $route . '$@i', $path, $args ); + + if ( ! $match ) { + continue; + } + foreach ( $handlers as $handler ) { $callback = $handler['callback']; $response = null; @@ -771,12 +777,6 @@ class WP_REST_Server { continue; } - $match = preg_match( '@^' . $route . '$@i', $path, $args ); - - if ( ! $match ) { - continue; - } - if ( ! is_callable( $callback ) ) { $response = new WP_Error( 'rest_invalid_handler', __( 'The handler for the route is invalid' ), array( 'status' => 500 ) ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index 1a32ef7f84..f5fe45beaa 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-beta2-35513'; +$wp_version = '4.4-beta2-35514'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.