WordPress.org

Make WordPress Core

Changeset 14783


Ignore:
Timestamp:
05/21/2010 04:03:35 PM (10 years ago)
Author:
ryan
Message:

Check for siblings only if term already exists in the same taxonomy. see #13119

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/taxonomy.php

    r14619 r14783  
    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 ) {
    1613             // Heirarchical, and it matches an existing term, Do not allow same "name" in the same level.
     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 ) ) {
     1613            // Hierarchical, 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) ) {
     
    16221622            }
    16231623        } elseif ( $existing_term['name'] != $name ) {
    1624             // We've got an existing term, with a different name, Creat ethe new term.
     1624            // We've got an existing term, with a different name, Create the new term.
    16251625            $slug = wp_unique_term_slug($slug, (object) $args);
    16261626            if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) )
Note: See TracChangeset for help on using the changeset viewer.