Make WordPress Core


Ignore:
Timestamp:
08/24/2007 02:44:26 PM (17 years ago)
Author:
ryan
Message:

Update WP importer to use taxonomy and query cat based on slug. see #4613

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/import/wordpress.php

    r5870 r5937  
    221221        global $wpdb;
    222222
    223         $cat_names = (array) $wpdb->get_col("SELECT cat_name FROM $wpdb->categories");
     223        $cat_names = (array) get_terms('category', 'fields=names');
    224224
    225225        while ( $c = array_shift($this->categories) ) {
     
    324324                $post_cats = array();
    325325                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;
    327331                    if ($cat_ID == 0) {
     332                        $category = $wpdb->escape($category);
    328333                        $cat_ID = wp_insert_category(array('cat_name' => $category));
    329334                    }
Note: See TracChangeset for help on using the changeset viewer.