Changeset 13925 for trunk/wp-includes/taxonomy.php
- Timestamp:
- 04/02/2010 01:26:44 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/taxonomy.php
r13924 r13925 1546 1546 // Make sure the slug is unique accross all taxonomies. 1547 1547 $slug = wp_unique_term_slug($slug, (object) $args); 1548 if ( !is_multisite() ) { 1549 if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) ) 1550 return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error); 1551 $term_id = (int) $wpdb->insert_id; 1552 } else { 1553 $maxterm = $wpdb->get_var( "SELECT max(term_id) FROM {$wpdb->terms}" ); 1554 $term_id = mt_rand( $maxterm+100, $maxterm+4000 ); 1555 if ( false === $wpdb->insert( $wpdb->terms, compact( 'term_id', 'name', 'slug', 'term_group' ) ) ) 1556 return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error); 1557 } 1548 if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) ) 1549 return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error); 1550 $term_id = (int) $wpdb->insert_id; 1558 1551 } else if ( is_taxonomy_hierarchical($taxonomy) && !empty($parent) ) { 1559 1552 // If the taxonomy supports hierarchy and the term has a parent, make the slug unique 1560 1553 // by incorporating parent slugs. 1561 1554 $slug = wp_unique_term_slug($slug, (object) $args); 1562 if ( !is_multisite() ) { 1563 if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) ) 1564 return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error); 1565 $term_id = (int) $wpdb->insert_id; 1566 } else { 1567 $maxterm = $wpdb->get_var( "SELECT max(term_id) FROM {$wpdb->terms}" ); 1568 $term_id = mt_rand( $maxterm+100, $maxterm+4000 ); 1569 if ( false === $wpdb->insert( $wpdb->terms, compact( 'term_id','name', 'slug', 'term_group' ) ) ) 1570 return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error); 1571 } 1555 if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) ) 1556 return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error); 1557 $term_id = (int) $wpdb->insert_id; 1572 1558 } 1573 1559
Note: See TracChangeset
for help on using the changeset viewer.