WordPress.org

Make WordPress Core

Changeset 13087


Ignore:
Timestamp:
02/13/10 05:52:27 (8 years ago)
Author:
dd32
Message:

Prevent Terms from being created in multiple taxonomies. If a slug is provided by the user, error out if it exists, else make the auto slug unique. See #11838

File:
1 edited

Legend:

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

    r13083 r13087  
    14371437    if ( empty($slug) ) 
    14381438        $slug = sanitize_title($name); 
     1439    elseif ( is_term($slug) ) // Provided slug issue. 
     1440        return new WP_Error('term_slug_exists', __('A Term with the slug provided already exists.')); 
    14391441 
    14401442    $term_group = 0; 
     
    14531455    } 
    14541456 
    1455     if ( ! $term_id = is_term($slug) ) { 
     1457    if ( ! $term_id = is_term($slug, $taxonomy) ) { 
     1458        // Make sure the slug is unique accross all taxonomies. 
     1459        $slug = wp_unique_term_slug($slug, (object) $args); 
    14561460        if ( !is_multisite() ) { 
    14571461            if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) ) 
Note: See TracChangeset for help on using the changeset viewer.