[wp-trac] [WordPress Trac] #60038: Pass original array of arguments to hooks that fire within `wp_insert_post()`

WordPress Trac noreply at wordpress.org
Fri Dec 8 16:55:31 UTC 2023


#60038: Pass original array of arguments to hooks that fire within
`wp_insert_post()`
-------------------------------+----------------------------------------
 Reporter:  johnbillion        |      Owner:  (none)
     Type:  enhancement        |     Status:  new
 Priority:  normal             |  Milestone:  Awaiting Review
Component:  Posts, Post Types  |    Version:
 Severity:  normal             |   Keywords:  needs-patch good-first-bug
  Focuses:                     |
-------------------------------+----------------------------------------
 The `$postarr` value passed to the `wp_insert_post()` function contains
 context that can be useful to callbacks attached to the actions that fire
 within this function, but this value isn't passed to any of them.
 Strangely enough it ''is'' passed to most of the filters there.

 As an example, a plugin of mine needs to perform logic within a callback
 on the `wp_insert_post` action based on a mixture of the `tax_input`
 argument and a custom argument. The `wp_insert_post_data` filter needs to
 be used to access these values.

 The `$postarr` value gets copied to `$unsanitized_postarr`. This is the
 value that should be passed to the actions because it contains the
 original input array, rather than `$postarr` which includes defaults and
 sanitised values. Or both should be passed, as per the filters in the
 function.

 This affects the following actions:

 * `pre_post_update`
 * `edit_attachment`
 * `attachment_updated`
 * `add_attachment`
 * `edit_post_{$post->post_type}`
 * `edit_post`
 * `post_updated`
 * `save_post_{$post->post_type}`
 * `save_post`
 * `wp_insert_post`

 And the following filters:

 * `add_trashed_suffix_to_trashed_posts`

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/60038>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list