[wp-trac] [WordPress Trac] #55441: In wp_insert_term, pass $args as an additional parameter to after-insert actions (create_term, created_term, et al)
WordPress Trac
noreply at wordpress.org
Tue Mar 22 20:47:07 UTC 2022
#55441: In wp_insert_term, pass $args as an additional parameter to after-insert
actions (create_term, created_term, et al)
-------------------------+-----------------------------
Reporter: mboynes | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Taxonomy | Version:
Severity: normal | Keywords:
Focuses: |
-------------------------+-----------------------------
@johnbillion [https://github.com/alleyinteractive/wordpress-
fieldmanager/issues/831 reported an issue to Fieldmanager] where it would
save term meta to additional terms if any were added or updated as a side
effect of adding/updating a term in the WordPress admin. Guarding against
this when editing a term is simple since there's a term ID to check
against, but I've had to [https://github.com/alleyinteractive/wordpress-
fieldmanager/pull/832/files#diff-
683aac44c2d38dd2ea1f9084f864fafb04cd37323f494a39602be25db008bc38 jump
through a few hoops to guard against this when creating new terms].
Through this process I've come to realize that there's an opportunity for
improvement to core. As it currently stands, when
[https://github.com/WordPress/WordPress/blob/6f39380c34c5665e4b78e0733d25c39043d7ac94
/wp-includes/taxonomy.php#L2577-L2685 all of the actions fire in
wp_insert_term() after the term is inserted], there's no way to guarantee
that the action firing relates to a specific call of `wp_insert_term()`.
If the actions included the `$args` array passed to that function, then a
developer could use that information to target a specific call to
`wp_insert_term()`, especially when core calls it to insert a term from
the canonical form in the WordPress admin (since it passes `$_POST`
wholesale as the `$args` argument).
This would entail adding the argument to the following actions:
* `create_term`
* `create_{$taxonomy}`
* `created_term`
* `created_{$taxonomy}`
* `saved_term`
* `saved_{$taxonomy}`
If there's appetite for this update, I'm happy to submit a patch.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/55441>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list