Changeset 14229
- Timestamp:
- 04/25/2010 07:35:16 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-ajax.php
r14214 r14229 573 573 $level++; 574 574 } 575 }576 if ( is_taxonomy_hierarchical($taxonomy) )577 575 $noparents = _tag_row( $tag, $level, $taxonomy ); 576 } 578 577 $tag->name = $tag_full_name; 579 578 $parents = _tag_row( $tag, 0, $taxonomy); -
trunk/wp-includes/taxonomy.php
r14108 r14229 1524 1524 if ( empty($slug) ) 1525 1525 $slug = sanitize_title($name); 1526 elseif ( is_term($slug , $taxonomy) ) // Provided slug issue.1527 return new WP_Error('term_slug_exists', __('A Term with the slug provided already exists.'));1526 elseif ( is_term($slug) ) 1527 return new WP_Error('term_slug_exists', __('A term with the slug provided already exists.')); 1528 1528 1529 1529 $term_group = 0; … … 1542 1542 } 1543 1543 1544 if ( ! $term_id = is_term($slug, $taxonomy) ) { 1545 // Make sure the slug is unique accross all taxonomies. 1544 if ( $term_id = is_term($slug) ) { 1545 $existing_term = $wpdb->get_row( $wpdb->prepare( "SELECT name FROM $wpdb->terms WHERE term_id = %d", $term_id), ARRAY_A ); 1546 // We've got an existing term, which matches the name of the new term: 1547 if ( is_taxonomy_hierarchical($taxonomy) && $existing_term['name'] == $name ) { 1548 // Heirarchical, and it matches an existing term, Do not allow same "name" in the same level. 1549 $siblings = get_terms($taxonomy, array('fields' => 'names', 'get' => 'all', 'parent' => (int)$parent) ); 1550 if ( in_array($name, $siblings) ) { 1551 return new WP_Error('term_exists', __('A term with the name provided already exists with this parent.')); 1552 } else { 1553 $slug = wp_unique_term_slug($slug, (object) $args); 1554 if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) ) 1555 return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error); 1556 $term_id = (int) $wpdb->insert_id; 1557 } 1558 } elseif ( $existing_term['name'] != $name ) { 1559 // We've got an existing term, with a different name, Creat ethe new term. 1560 $slug = wp_unique_term_slug($slug, (object) $args); 1561 if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) ) 1562 return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error); 1563 $term_id = (int) $wpdb->insert_id; 1564 } 1565 } else { 1566 // This term does not exist at all in the database, Create it. 1546 1567 $slug = wp_unique_term_slug($slug, (object) $args); 1547 1568 if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) ) 1548 1569 return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error); 1549 1570 $term_id = (int) $wpdb->insert_id; 1550 } else if ( is_taxonomy_hierarchical($taxonomy) && !empty($parent) ) { 1551 // If the taxonomy supports hierarchy and the term has a parent, make the slug unique 1552 // by incorporating parent slugs. 1553 $slug = wp_unique_term_slug($slug, (object) $args); 1554 if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) ) 1555 return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error); 1556 $term_id = (int) $wpdb->insert_id; 1557 } 1558 1559 if ( empty($slug) ) { 1571 } 1572 1573 // Seems unreachable, However, Is used in the case that a term name is provided, which sanitizes to an empty string. 1574 if ( empty($slug) ) { 1560 1575 $slug = sanitize_title($slug, $term_id); 1561 1576 do_action( 'edit_terms', $term_id );
Note: See TracChangeset
for help on using the changeset viewer.