Repository navigation
Posts, Post Types: Pass the original array of arguments to hooks that fire within wp_insert_post() - #14796
Conversation
… fire within wp_insert_post()
… by the edit_post_{$field} filter
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Passes the original array of arguments given to
wp_insert_post()($unsanitized_postarr) as a trailing argument to the actions and filters that fire within it, matching whatwp_insert_post_dataandwp_insert_attachment_datahave received since 5.4.1. This lets callbacks see custom keys such astax_input,meta_inputor plugin-specific arguments that are otherwise lost.Hooks updated inside
wp_insert_post()add_trashed_suffix_to_trashed_postspre_post_update,edit_attachment,attachment_updated,add_attachment,edit_post_{$post_type},edit_post,post_updated,save_post_{$post_type},save_post,wp_insert_postOther places these hooks fire
As noted by @johnbillion on the ticket, some of these hooks also fire outside
wp_insert_post(): inwp_publish_post(),WP_Customize_Manager::trash_changeset_post()andwp_update_comment_count_now(). Those call sites now pass an emptyarray(), so a callback registered with the extra argument never hits anArgumentCountError. The docblocks say the array is empty when the hook fires outside ofwp_insert_post().Notes
@sinceversion is set to7.3.0, since 7.2 is past feature freeze. A committer may adjust it.ArgumentCountErrorin callbacks that require it, the same trade-off as when$updatewas added tosave_postin 3.7.0. A dev note may be worthwhile.phpstan.neon.distgets a narrowly scoped ignore: PHPStan conflates theedit_post_{$post_type}action with the unrelatededit_post_{$field}filter insanitize_post_field()because both normalise toedit_post_{...}.Trac ticket: https://core.trac.wordpress.org/ticket/60038
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Sonnet 5.5
Used for: Implementation, tests, and PR description.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.
🤖 Generated with Claude Code