[wp-trac] [WordPress Trac] #35590: Add filters to allow creating REST API middleware plugins

WordPress Trac noreply at wordpress.org
Fri Feb 19 18:53:33 UTC 2016

#35590: Add filters to allow creating REST API middleware plugins
 Reporter:  jnylen0      |       Owner:  rmccue
     Type:  enhancement  |      Status:  assigned
 Priority:  normal       |   Milestone:  4.5
Component:  REST API     |     Version:  trunk
 Severity:  normal       |  Resolution:
 Keywords:               |     Focuses:

Comment (by jnylen0):

 We're using these filters heavily for our auth and multisite handling
 (switch to the right blog, validate tokens/cookies against the blog,
 restore the previous blog after the request, etc.)

 There was some Slack discussion about the `$did_run_before_callbacks` in
 particular.  This is there because if we call `before_callbacks` then we
 ​'''always''' need to call `after_callbacks` so that it can clean up (even
 if `before_callbacks` or the endpoint callbacks themselves error).  But,
 if an earlier piece of logic returns an error
 (`rest_authentication_errors`, for example), then we don't need to call
 either one of these two new filters.

 I've been meaning to add some tests but haven't had a chance yet.

 Getting this patch merged would enable other plugins to do similar things
 with the API and allow us to run with one less core hack.

Ticket URL: <https://core.trac.wordpress.org/ticket/35590#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list