[wp-trac] [WordPress Trac] #29852: wp_update_term() should use wp_insert_term() internally
WordPress Trac
noreply at wordpress.org
Fri Oct 3 16:59:40 UTC 2014
#29852: wp_update_term() should use wp_insert_term() internally
--------------------------+----------------------------
Reporter: boonebgorges | Owner:
Type: enhancement | Status: new
Priority: low | Milestone: Future Release
Component: Taxonomy | Version: 2.3
Severity: normal | Keywords: needs-patch
Focuses: |
--------------------------+----------------------------
`wp_update_term()` and `wp_insert_term()` have a large amount of
overlapping functionality. Things like argument sanitization,
`term_exists()` checks, parent and alias_of validation, and even some hook
names are shared between the two. Having the logic separate means twice
the unit tests and twice the bug fixes for shared functionality. (See
#29848 for an example.) This, in turn, has the potential to hold up future
refactoring (#5809).
As much as possible, the duplicate logic should be pulled out of
`wp_update_term()`. Update-specific validation should take place there,
and then call `wp_insert_term()` with a `term_id` or `term_taxonomy_id`
param. (Suggestions for syntax are welcome.) In `wp_insert_term()`, break
out the logic specific to the creation of new terms, and only run it when
no existing term ID is passed to the function. Then, choose whether to run
`$wpdb->update()` or `$wpdb->insert()` as appropriate.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/29852>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list