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. Built from https://develop.svn.wordpress.org/trunk@39637 git-svn-id: http://core.svn.wordpress.org/trunk@39577 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
af885f45cf
commit
a3ea7ea2e9
|
@ -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 ) ) {
|
||||
|
||||
$cat_id = wp_insert_term( $cat_name, $taxonomy->name, array( 'parent' => $parent ) );
|
||||
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 ) ) {
|
||||
|
||||
$cat_id = wp_insert_term( $cat_name, 'link_category' );
|
||||
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 );
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.8-alpha-39636';
|
||||
$wp_version = '4.8-alpha-39637';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue