Make WordPress Core

Changeset 26544


Ignore:
Timestamp:
12/02/2013 11:05:49 PM (12 years ago)
Author:
nacin
Message:

Be specific in term_exists error messages in wp_insert_term() as to what already exists (name, or name and slug).

props ericmann, SergeyBiryukov.
fixes #15741.

File:
1 edited

Legend:

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

    r26510 r26544  
    21442144    $description = wp_unslash($description);
    21452145
    2146     if ( empty($slug) )
     2146    $slug_provided = ! empty( $slug );
     2147    if ( ! $slug_provided ) {
    21472148        $slug = sanitize_title($name);
     2149    }
    21482150
    21492151    $term_group = 0;
     
    21692171            $siblings = get_terms($taxonomy, array('fields' => 'names', 'get' => 'all', 'parent' => (int)$parent) );
    21702172            if ( in_array($name, $siblings) ) {
    2171                 return new WP_Error('term_exists', __('A term with the name provided already exists with this parent.'), $exists['term_id']);
     2173                if ( $slug_provided ) {
     2174                    return new WP_Error( 'term_exists', __( 'A term with the name and slug provided already exists with this parent.' ), $exists['term_id'] );
     2175                } else {
     2176                    return new WP_Error( 'term_exists', __( 'A term with the name provided already exists with this parent.' ), $exists['term_id'] );
     2177                }
    21722178            } else {
    21732179                $slug = wp_unique_term_slug($slug, (object) $args);
     
    21842190        } elseif ( $exists = term_exists( (int) $term_id, $taxonomy ) )  {
    21852191            // Same name, same slug.
    2186             return new WP_Error('term_exists', __('A term with the name provided already exists.'), $exists['term_id']);
     2192            return new WP_Error( 'term_exists', __( 'A term with the name and slug provided already exists.' ), $exists['term_id'] );
    21872193        }
    21882194    } else {
Note: See TracChangeset for help on using the changeset viewer.