WordPress.org

Make WordPress Core

Ticket #13119: 13119.diff

File 13119.diff, 999 bytes (added by ryan, 4 years ago)

Look for siblings only if existing term is in the same taxonomy

  • wp-includes/taxonomy.php

     
    16081608 
    16091609        if ( $term_id = is_term($slug) ) { 
    16101610                $existing_term = $wpdb->get_row( $wpdb->prepare( "SELECT name FROM $wpdb->terms WHERE term_id = %d", $term_id), ARRAY_A ); 
    1611                 // We've got an existing term, which matches the name of the new term: 
    1612                 if ( is_taxonomy_hierarchical($taxonomy) && $existing_term['name'] == $name ) { 
     1611                // We've got an existing term in the same taxonomy, which matches the name of the new term: 
     1612                if ( is_taxonomy_hierarchical($taxonomy) && $existing_term['name'] == $name && is_term( (int) $term_id, $taxonomy ) ) { 
    16131613                        // Heirarchical, and it matches an existing term, Do not allow same "name" in the same level. 
    16141614                        $siblings = get_terms($taxonomy, array('fields' => 'names', 'get' => 'all', 'parent' => (int)$parent) ); 
    16151615                        if ( in_array($name, $siblings) ) {