[wp-trac] [WordPress Trac] #38964: Add filter to allow modifying response *after* embedded data is adde

WordPress Trac noreply at wordpress.org
Mon Nov 28 02:08:48 UTC 2016


#38964: Add filter to allow modifying response *after* embedded data is adde
-------------------------+-----------------------------
 Reporter:  loboyle      |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  REST API     |    Version:  trunk
 Severity:  normal       |   Keywords:
  Focuses:               |
-------------------------+-----------------------------
 The `rest_post_dispatch` is intended to be used for modifying responses,
 but the `_embedded` data is not yet available which limits the
 manipulations that can be done.  It would be useful to have another filter
 that allows us to modify the final result being sent back, immediately
 before it's encoded and echoed.

 For context, this is a problem for me in my `wp-rest-jmespath` plugin,
 which allows applying a JMESPath transform to a response to limit/rewrite
 the fields (see https://github.com/elyobo/wp-rest-jmespath/issues/1).  It
 is possible to work around this limitation by adding a handler for
 `rest_pre_serve_request` and copying the logic that would embed the data
 (e.g.https://github.com/elyobo/wp-rest-
 jmespath/commit/887a638cc00c0d80a9425346e5e6d9439a096ee3) but this is a
 fragile workaround - any changes to the logic for processing and sending
 after `rest_pre_serve_request` would not be picked up by the plugin and so
 responses may end up differing unexpectedly.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/38964>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list