-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.savePost
action, 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 likeisAutosave
andisPreview
and nothing more.This PR fixes that by adding a first argument, and object with the
id
field. The goal is mainly to be forward compatible:post
argument extensible in the future. It's an object that currently contains theid
field, and it the future it can have more fields.The
editor.preSavePost
has a similar API already: first argument isedits
, an object which includes theid
field, 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.