Update dotclear and textpattern importers to use taxonomy
git-svn-id: https://develop.svn.wordpress.org/trunk@5953 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
48120ed74b
commit
aaa89080a8
|
@ -7,18 +7,6 @@
|
||||||
/**
|
/**
|
||||||
Add These Functions to make our lives easier
|
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'))
|
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'))
|
if(!function_exists('link_exists'))
|
||||||
{
|
{
|
||||||
function link_exists($linkname)
|
function link_exists($linkname)
|
||||||
|
@ -408,7 +387,10 @@ class Dotclear_Import {
|
||||||
|
|
||||||
// Make Post-to-Category associations
|
// Make Post-to-Category associations
|
||||||
$cats = array();
|
$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); }
|
if(!empty($cats)) { wp_set_post_categories($ret_id, $cats); }
|
||||||
}
|
}
|
||||||
|
@ -509,12 +491,11 @@ class Dotclear_Import {
|
||||||
extract($link);
|
extract($link);
|
||||||
|
|
||||||
if ($title != "") {
|
if ($title != "") {
|
||||||
if ($cinfo = link_cat_exists (csc ($title))) {
|
if ($cinfo = is_term(csc ($title), 'link_category')) {
|
||||||
$category = $cinfo;
|
$category = $cinfo['term_id'];
|
||||||
} else {
|
} else {
|
||||||
$wpdb->query ("INSERT INTO $wpdb->linkcategories (cat_name) VALUES ('".
|
$category = wp_insert_term($wpdb->escape (csc ($title)), 'link_category');
|
||||||
$wpdb->escape (csc ($title))."')");
|
$category = $category['term_id'];
|
||||||
$category = $wpdb->insert_id;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$linkname = $wpdb->escape(csc ($label));
|
$linkname = $wpdb->escape(csc ($label));
|
||||||
|
|
|
@ -2,18 +2,6 @@
|
||||||
/**
|
/**
|
||||||
Add These Functions to make our lives easier
|
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'))
|
if(!function_exists('get_comment_count'))
|
||||||
{
|
{
|
||||||
|
@ -338,8 +326,12 @@ class Textpattern_Import {
|
||||||
|
|
||||||
// Make Post-to-Category associations
|
// Make Post-to-Category associations
|
||||||
$cats = array();
|
$cats = array();
|
||||||
if($cat1 = get_catbynicename($Category1)) { $cats[1] = $cat1; }
|
$category1 = get_category_by_slug($Category1);
|
||||||
if($cat2 = get_catbynicename($Category2)) { $cats[2] = $cat2; }
|
$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); }
|
if(!empty($cats)) { wp_set_post_categories($ret_id, $cats); }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue