From aaa89080a8f45707ebed33eb411efdeb7512a706 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Tue, 28 Aug 2007 00:08:58 +0000 Subject: [PATCH] Update dotclear and textpattern importers to use taxonomy git-svn-id: https://develop.svn.wordpress.org/trunk@5953 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/import/dotclear.php | 35 ++++++++------------------------- wp-admin/import/textpattern.php | 20 ++++++------------- 2 files changed, 14 insertions(+), 41 deletions(-) diff --git a/wp-admin/import/dotclear.php b/wp-admin/import/dotclear.php index 661e1a07ba..d63ffdb095 100644 --- a/wp-admin/import/dotclear.php +++ b/wp-admin/import/dotclear.php @@ -7,18 +7,6 @@ /** Add These Functions to make our lives easier **/ -if(!function_exists('get_catbynicename')) -{ - function get_catbynicename($category_nicename) - { - global $wpdb; - - $cat_id -= 0; // force numeric - $name = $wpdb->get_var('SELECT cat_ID FROM '.$wpdb->categories.' WHERE category_nicename="'.$category_nicename.'"'); - - return $name; - } -} if(!function_exists('get_comment_count')) { @@ -29,15 +17,6 @@ if(!function_exists('get_comment_count')) } } -if(!function_exists('link_cat_exists')) -{ - function link_cat_exists($catname) - { - global $wpdb; - return $wpdb->get_var('SELECT cat_id FROM '.$wpdb->linkcategories.' WHERE cat_name = "'.$wpdb->escape($catname).'"'); - } -} - if(!function_exists('link_exists')) { function link_exists($linkname) @@ -408,7 +387,10 @@ class Dotclear_Import { // Make Post-to-Category associations $cats = array(); - if($cat1 = get_catbynicename($post_cat_name)) { $cats[1] = $cat1; } + $category1 = get_category_by_slug($post_cat_name); + $category1 = $category1->term_id; + + if($cat1 = $category1) { $cats[1] = $cat1; } if(!empty($cats)) { wp_set_post_categories($ret_id, $cats); } } @@ -509,12 +491,11 @@ class Dotclear_Import { extract($link); if ($title != "") { - if ($cinfo = link_cat_exists (csc ($title))) { - $category = $cinfo; + if ($cinfo = is_term(csc ($title), 'link_category')) { + $category = $cinfo['term_id']; } else { - $wpdb->query ("INSERT INTO $wpdb->linkcategories (cat_name) VALUES ('". - $wpdb->escape (csc ($title))."')"); - $category = $wpdb->insert_id; + $category = wp_insert_term($wpdb->escape (csc ($title)), 'link_category'); + $category = $category['term_id']; } } else { $linkname = $wpdb->escape(csc ($label)); diff --git a/wp-admin/import/textpattern.php b/wp-admin/import/textpattern.php index 286d74a234..46e3420b14 100644 --- a/wp-admin/import/textpattern.php +++ b/wp-admin/import/textpattern.php @@ -2,18 +2,6 @@ /** Add These Functions to make our lives easier **/ -if(!function_exists('get_catbynicename')) -{ - function get_catbynicename($category_nicename) - { - global $wpdb; - - $cat_id -= 0; // force numeric - $name = $wpdb->get_var('SELECT cat_ID FROM '.$wpdb->categories.' WHERE category_nicename="'.$category_nicename.'"'); - - return $name; - } -} if(!function_exists('get_comment_count')) { @@ -338,8 +326,12 @@ class Textpattern_Import { // Make Post-to-Category associations $cats = array(); - if($cat1 = get_catbynicename($Category1)) { $cats[1] = $cat1; } - if($cat2 = get_catbynicename($Category2)) { $cats[2] = $cat2; } + $category1 = get_category_by_slug($Category1); + $category1 = $category1->term_id; + $category2 = get_category_by_slug($Category2); + $category2 = $category1->term_id; + if($cat1 = $category1) { $cats[1] = $cat1; } + if($cat2 = $category2) { $cats[2] = $cat2; } if(!empty($cats)) { wp_set_post_categories($ret_id, $cats); } }