[wp-trac] [WordPress Trac] #45114: Fire publishing related hooks after all data is saved via the REST API.
WordPress Trac
noreply at wordpress.org
Thu Jan 30 21:45:38 UTC 2020
#45114: Fire publishing related hooks after all data is saved via the REST API.
---------------------------+------------------------------
Reporter: peterwilsoncc | Owner: (none)
Type: defect (bug) | Status: reopened
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version:
Severity: normal | Resolution:
Keywords: dev-feedback | Focuses:
---------------------------+------------------------------
Changes (by kraftbj):
* keywords: => dev-feedback
Comment:
For the sake of conversation, 45114-alt.diff only modifies the REST
controller.
For a new post, I'm somewhat mocking what `wp_insert_post` does in a
similar case by setting a "new" post status. To keep intent, I'm storing
the passed status and then `wp_update_post` at the end with the intended
status.
wp_insert_post hooks will still fire early, but with a more "expected"
status. `wp_update_post` at the conclusion of the method will fire the
hooks again, but things like transitioning post status to `publish` will
be accurate.
For the update, I just moved the call to `wp_update_post` to the end. Same
thing in that now hooks that are firing on `publish` will have fully
fleshed data available.
I don't expect this to be a complete solution and haven't audited the list
of hooks mentioned in the OP to ensure this hits all those cases. Posting
early to see if this direction seems feasible.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/45114#comment:23>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list