[wp-trac] [WordPress Trac] #40600: get_item filter for hijacking single post request

WordPress Trac noreply at wordpress.org
Fri Apr 28 21:06:39 UTC 2017


#40600: get_item filter for hijacking single post request
-----------------------------+-----------------------------
 Reporter:  ruud@…           |      Owner:
     Type:  feature request  |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  REST API         |    Version:  4.7
 Severity:  normal           |   Keywords:
  Focuses:                   |
-----------------------------+-----------------------------
 Hi,

 I want to propose a filter in the get_item() method.

 The use case is as follows;
 - Content from a WP REST API enabled repository is being shown on a site
 through a 'virtual' post mechanism.
 - The managers of the repository site use a custom way of setting whether
 or not a item is active, e.g via a metakey.
 - Once an end-user bookmarks this 'virtual' post URL, or if the 'virtual'
 post is accessed via menu's or internal links, it will try to retrieve the
 content from the repository.
 - If the managers of the repository site change the active property via
 its metakey value, the content should not come up anymore with a REST
 request.

 The method I have in place right now has its own drawbacks, see: #40580,
 and from a performance standpoint it may not be very nice to first build
 the entire post object and then destroy in the end. Also using the
 rest_prepare_{$this->post_type} filter in this way isn't following its
 return policy as well (should be an WP_REST_Request not an WP_Error
 object)

 With this filter one can now create a way for this to work.

 I will add the patch and an unit test for this new filter.

 Like to hear your thoughts.

 Thanks,
 Ruud

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


More information about the wp-trac mailing list