Make WordPress Core

Changeset 5953


Ignore:
Timestamp:
08/28/2007 12:08:58 AM (18 years ago)
Author:
ryan
Message:

Update dotclear and textpattern importers to use taxonomy

Location:
trunk/wp-admin/import
Files:
2 edited

Legend:

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

    r5404 r5953  
    88    Add These Functions to make our lives easier
    99**/
    10 if(!function_exists('get_catbynicename'))
    11 {
    12     function get_catbynicename($category_nicename)
    13     {
    14     global $wpdb;
    15 
    16     $cat_id -= 0;   // force numeric
    17     $name = $wpdb->get_var('SELECT cat_ID FROM '.$wpdb->categories.' WHERE category_nicename="'.$category_nicename.'"');
    18 
    19     return $name;
    20     }
    21 }
    2210
    2311if(!function_exists('get_comment_count'))
     
    2715        global $wpdb;
    2816        return $wpdb->get_var('SELECT count(*) FROM '.$wpdb->comments.' WHERE comment_post_ID = '.$post_ID);
    29     }
    30 }
    31 
    32 if(!function_exists('link_cat_exists'))
    33 {
    34     function link_cat_exists($catname)
    35     {
    36         global $wpdb;
    37         return $wpdb->get_var('SELECT cat_id FROM '.$wpdb->linkcategories.' WHERE cat_name = "'.$wpdb->escape($catname).'"');
    3817    }
    3918}
     
    409388                // Make Post-to-Category associations
    410389                $cats = array();
    411                 if($cat1 = get_catbynicename($post_cat_name)) { $cats[1] = $cat1; }
     390                $category1 = get_category_by_slug($post_cat_name);
     391                $category1 = $category1->term_id;
     392
     393                if($cat1 = $category1) { $cats[1] = $cat1; }
    412394
    413395                if(!empty($cats)) { wp_set_post_categories($ret_id, $cats); }
     
    510492
    511493                if ($title != "") {
    512                     if ($cinfo = link_cat_exists (csc ($title))) {
    513                         $category = $cinfo;
     494                    if ($cinfo = is_term(csc ($title), 'link_category')) {
     495                        $category = $cinfo['term_id'];
    514496                    } else {
    515                         $wpdb->query ("INSERT INTO $wpdb->linkcategories (cat_name) VALUES ('".
    516                             $wpdb->escape (csc ($title))."')");
    517                         $category = $wpdb->insert_id;
     497                        $category = wp_insert_term($wpdb->escape (csc ($title)), 'link_category');
     498                        $category = $category['term_id'];
    518499                    }
    519500                } else {
  • trunk/wp-admin/import/textpattern.php

    r5449 r5953  
    33    Add These Functions to make our lives easier
    44**/
    5 if(!function_exists('get_catbynicename'))
    6 {
    7     function get_catbynicename($category_nicename)
    8     {
    9     global $wpdb;
    10 
    11     $cat_id -= 0;   // force numeric
    12     $name = $wpdb->get_var('SELECT cat_ID FROM '.$wpdb->categories.' WHERE category_nicename="'.$category_nicename.'"');
    13 
    14     return $name;
    15     }
    16 }
    175
    186if(!function_exists('get_comment_count'))
     
    339327                // Make Post-to-Category associations
    340328                $cats = array();
    341                 if($cat1 = get_catbynicename($Category1)) { $cats[1] = $cat1; }
    342                 if($cat2 = get_catbynicename($Category2)) { $cats[2] = $cat2; }
     329                $category1 = get_category_by_slug($Category1);
     330                $category1 = $category1->term_id;
     331                $category2 = get_category_by_slug($Category2);
     332                $category2 = $category1->term_id;
     333                if($cat1 = $category1) { $cats[1] = $cat1; }
     334                if($cat2 = $category2) { $cats[2] = $cat2; }
    343335
    344336                if(!empty($cats)) { wp_set_post_categories($ret_id, $cats); }
Note: See TracChangeset for help on using the changeset viewer.