Opened 11 years ago
Last modified 7 years ago
#29852 new enhancement
wp_update_term() should use wp_insert_term() internally
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | 2.3 |
| Component: | Taxonomy | Keywords: | needs-patch |
| Focuses: | Cc: |
Description
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.
@boonebgorges want to tackle this?