Add argument with post ID to the editor.savePost hook#66165
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Size Change: +4 B (0%) Total Size: 1.77 MB
ℹ️ View Unchanged
|
|
Flaky tests detected in 4d00f18. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/11363399213
|
tyxla
left a comment
There was a problem hiding this comment.
Makes sense, thanks! 👍
Good timing 😅 a few more weeks and it would have been too late.
Co-authored-by: jsnajdr <jsnajdr@git.wordpress.org> Co-authored-by: tyxla <tyxla@git.wordpress.org>
|
I just cherry-picked this PR to the wp/6.7 branch to get it included in the next release: b59bac3 |
Co-authored-by: jsnajdr <jsnajdr@git.wordpress.org> Co-authored-by: tyxla <tyxla@git.wordpress.org>
When writing the dev note for the
editor.savePostaction, I noticed it has a serious problem: the identity of the saved post (the ID and optionally other fields) is not passed to the action at all. The handler doesn't know anything about the post it's dealing with. It gets only theoptions, which contain flags likeisAutosaveandisPreviewand nothing more.This PR fixes that by adding a first argument, and object with the
idfield. The goal is mainly to be forward compatible:postargument extensible in the future. It's an object that currently contains theidfield, and it the future it can have more fields.The
editor.preSavePosthas a similar API already: first argument isedits, an object which includes theidfield, and the second argument is theoptions.We got to this situation because originally the hook was motivated by the "save metaboxes" action. And accidentally, the "save metaboxes" doesn't need to know the post ID, because it can read it from the metabox forms inside the page HTML. But other users of the hook are likely to run into big trouble very soon.