Taxonomy: Eliminate redundant and inaccurate dupe check when creating categories from post.php.
The `term_exists()` check is not needed because of existing dupe checks in `wp_insert_term()`. Furthermore, `term_exists()` conflates term names and sanitized slugs, so incorrectly marks terms like 'C' and 'C+' as duplicates of one another. Props garyc40, SergeyBiryukov, kovshenin, MikeHansenMe. Fixes #16567. git-svn-id: https://develop.svn.wordpress.org/trunk@39637 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
ef91d166d5
commit
35ccbc8368
@ -472,11 +472,11 @@ function _wp_ajax_add_hierarchical_term() {
|
||||
$category_nicename = sanitize_title($cat_name);
|
||||
if ( '' === $category_nicename )
|
||||
continue;
|
||||
if ( !$cat_id = term_exists( $cat_name, $taxonomy->name, $parent ) )
|
||||
|
||||
$cat_id = wp_insert_term( $cat_name, $taxonomy->name, array( 'parent' => $parent ) );
|
||||
if ( is_wp_error( $cat_id ) ) {
|
||||
if ( ! $cat_id || is_wp_error( $cat_id ) ) {
|
||||
continue;
|
||||
} elseif ( is_array( $cat_id ) ) {
|
||||
} else {
|
||||
$cat_id = $cat_id['term_id'];
|
||||
}
|
||||
$checked_categories[] = $cat_id;
|
||||
@ -806,11 +806,11 @@ function wp_ajax_add_link_category( $action ) {
|
||||
$slug = sanitize_title($cat_name);
|
||||
if ( '' === $slug )
|
||||
continue;
|
||||
if ( !$cat_id = term_exists( $cat_name, 'link_category' ) )
|
||||
|
||||
$cat_id = wp_insert_term( $cat_name, 'link_category' );
|
||||
if ( is_wp_error( $cat_id ) ) {
|
||||
if ( ! $cat_id || is_wp_error( $cat_id ) ) {
|
||||
continue;
|
||||
} elseif ( is_array( $cat_id ) ) {
|
||||
} else {
|
||||
$cat_id = $cat_id['term_id'];
|
||||
}
|
||||
$cat_name = esc_html( $cat_name );
|
||||
|
Loading…
Reference in New Issue
Block a user