Make WordPress Core


Ignore:
Timestamp:
11/09/2007 06:34:41 PM (16 years ago)
Author:
ryan
Message:

Make term slug unique when moving to another parent.

File:
1 edited

Legend:

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

    r6321 r6326  
    12071207
    12081208    // If we didn't get a unique slug, try appending a number to make it unique.
    1209     if ( $wpdb->get_var( $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s", $slug ) ) ) {
     1209    if ( !empty($args['term_id']) )
     1210        $query = $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s AND term_id != %d", $slug, $args['term_id'] );
     1211    else
     1212        $query = $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s $where", $slug );
     1213
     1214    if ( $wpdb->get_var( $query ) ) {
    12101215        $num = 2;
    12111216        do {
     
    12821287    $id = $wpdb->get_var( $wpdb->prepare( "SELECT term_id FROM $wpdb->terms WHERE slug = %s", $slug ) );
    12831288    if ( $id && ($id != $term_id) ) {
    1284         // If an empty slug was passed, reset the slug to something unique.
     1289        // If an empty slug was passed or the parent changed, reset the slug to something unique.
    12851290        // Otherwise, bail.
    1286         if ( $empty_slug )
     1291        if ( $empty_slug || ( $parent != $term->parent) )
    12871292            $slug = wp_unique_term_slug($slug, (object) $args);
    12881293        else
Note: See TracChangeset for help on using the changeset viewer.