From 5a945adeed812fc6da6c37de08daf1691f91e95b Mon Sep 17 00:00:00 2001 From: rmccue Date: Tue, 16 Feb 2016 06:05:02 +0000 Subject: [PATCH] REST API: Apply rest_post_dispatch to embedded responses. Fixes #35628. Props @danielbachhuber. git-svn-id: https://develop.svn.wordpress.org/trunk@36536 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/rest-api/class-wp-rest-server.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/wp-includes/rest-api/class-wp-rest-server.php b/src/wp-includes/rest-api/class-wp-rest-server.php index cc9fda7014..93abf87e1b 100644 --- a/src/wp-includes/rest-api/class-wp-rest-server.php +++ b/src/wp-includes/rest-api/class-wp-rest-server.php @@ -340,6 +340,7 @@ class WP_REST_Server { * Allows modification of the response before returning. * * @since 4.4.0 + * @since 4.5.0 Applied to embedded responses. * * @param WP_HTTP_Response $result Result to send to the client. Usually a WP_REST_Response. * @param WP_REST_Server $this Server instance. @@ -567,6 +568,9 @@ class WP_REST_Server { $request->set_query_params( $query_params ); $response = $this->dispatch( $request ); + /** This filter is documented in wp-includes/rest-api/class-wp-rest-server.php */ + $response = apply_filters( 'rest_post_dispatch', rest_ensure_response( $response ), $this, $request ); + $embeds[] = $this->response_to_data( $response, false ); }