[wp-trac] [WordPress Trac] #45114: Publish posts and fire related hooks on `rest_after_insert_{$this->post_type}` for rest requests.
WordPress Trac
noreply at wordpress.org
Wed Oct 17 21:12:16 UTC 2018
#45114: Publish posts and fire related hooks on
`rest_after_insert_{$this->post_type}` for rest requests.
---------------------------+-----------------------------
Reporter: peterwilsoncc | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version:
Severity: normal | Keywords:
Focuses: |
---------------------------+-----------------------------
In REST API requests, `wp_insert_post` publishes posts before terms and
post meta has been saved.
This causes a number of hooks to fire before the meta data and terms are
available in the database. As a follow up to [43737] it's possible to
publish posts and fire these hooks after all the data has been saved.
On REST Requests (both via HTTP and internal) it would be good to move the
following to the later action:
* `edit_attachment`
* `attachment_updated`
* `add_attachment`
* `edit_post`
* `post_updated`
* `save_post_{$post->post_type}`
* `save_post`
* `wp_insert_post`
* setting the status to `publish`, `future`, etc
* Related hooks I have missed
To handle both HTTP and internal requests would require a new function
that normally returns `false` but is filtered to return `true` at the
start of a REST request and removing the filter at the end of the request.
This new filter could be added at around the same location as
`rest_pre_dispatch` is fired and removed at the point
`rest_request_after_callbacks` fires.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/45114>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list