Changeset 5937
- Timestamp:
- 08/24/2007 02:44:26 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/import/wordpress.php
r5870 r5937 221 221 global $wpdb; 222 222 223 $cat_names = (array) $wpdb->get_col("SELECT cat_name FROM $wpdb->categories");223 $cat_names = (array) get_terms('category', 'fields=names'); 224 224 225 225 while ( $c = array_shift($this->categories) ) { … … 324 324 $post_cats = array(); 325 325 foreach ($categories as $category) { 326 $cat_ID = (int) $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name = '$category'"); 326 $slug = sanitize_term_field('slug', $category, 0, 'category', 'db'); 327 $cat = get_term_by('slug', $slug, 'category'); 328 $cat_ID = 0; 329 if ( ! empty($cat) ) 330 $cat_ID = $cat->term_id; 327 331 if ($cat_ID == 0) { 332 $category = $wpdb->escape($category); 328 333 $cat_ID = wp_insert_category(array('cat_name' => $category)); 329 334 } -
trunk/wp-includes/default-filters.php
r5906 r5937 34 34 add_filter($filter, 'clean_url'); 35 35 add_filter($filter, 'wp_filter_kses'); 36 } 37 38 // Slugs 39 $filters = array('pre_term_slug'); 40 foreach ( $filters as $filter ) { 41 add_filter($filter, 'sanitize_title'); 36 42 } 37 43 -
trunk/wp-includes/taxonomy.php
r5906 r5937 283 283 * might be inaccurate or wrong. 284 284 */ 285 function get_term_by($field, $value, $taxonomy, $output = OBJECT ) {285 function get_term_by($field, $value, $taxonomy, $output = OBJECT, $filter = 'raw') { 286 286 global $wpdb; 287 287 … … 307 307 308 308 wp_cache_add($term->term_id, $term, $taxonomy); 309 310 $term = sanitize_term($term, $taxonomy, $filter); 309 311 310 312 if ( $output == OBJECT ) { … … 488 490 else if ( 'ids' == $fields ) 489 491 $select_this = 't.term_id'; 492 else if ( 'names' == $fields ) 493 $select_this == 't.name'; 490 494 491 495 $query = "SELECT $select_this FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ($in_taxonomies) $where ORDER BY $orderby $order $number"; … … 772 776 if ( empty($slug) ) 773 777 $slug = sanitize_title($name); 774 else775 $slug = sanitize_title($slug);776 778 777 779 $term_group = 0;
Note: See TracChangeset
for help on using the changeset viewer.