Make WordPress Core

Ticket #15741: 15741.5.diff

File 15741.5.diff, 1.7 KB (added by SergeyBiryukov, 12 years ago)
  • wp-includes/taxonomy.php

     
    20682068        $name = wp_unslash($name);
    20692069        $description = wp_unslash($description);
    20702070
     2071        $slug_provided = $slug;
    20712072        if ( empty($slug) )
    20722073                $slug = sanitize_title($name);
    20732074
     
    20932094                        // Hierarchical, and it matches an existing term, Do not allow same "name" in the same level.
    20942095                        $siblings = get_terms($taxonomy, array('fields' => 'names', 'get' => 'all', 'parent' => (int)$parent) );
    20952096                        if ( in_array($name, $siblings) ) {
    2096                                 return new WP_Error('term_exists', __('A term with the name provided already exists with this parent.'), $exists['term_id']);
     2097                                if ( $slug_provided )
     2098                                        return new WP_Error('term_exists', __('A term with the name and slug provided already exists with this parent.'), $exists['term_id']);
     2099                                else
     2100                                        return new WP_Error('term_exists', __('A term with the name provided already exists with this parent.'), $exists['term_id']);
    20972101                        } else {
    20982102                                $slug = wp_unique_term_slug($slug, (object) $args);
    20992103                                if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) )
     
    21082112                        $term_id = (int) $wpdb->insert_id;
    21092113                } elseif ( $exists = term_exists( (int) $term_id, $taxonomy ) )  {
    21102114                        // Same name, same slug.
    2111                         return new WP_Error('term_exists', __('A term with the name provided already exists.'), $exists['term_id']);
     2115                        return new WP_Error('term_exists', __('A term with the name and slug provided already exists.'), $exists['term_id']);
    21122116                }
    21132117        } else {
    21142118                // This term does not exist at all in the database, Create it.