Changeset 5953
- Timestamp:
- 08/28/2007 12:08:58 AM (18 years ago)
- Location:
- trunk/wp-admin/import
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/import/dotclear.php
r5404 r5953 8 8 Add These Functions to make our lives easier 9 9 **/ 10 if(!function_exists('get_catbynicename'))11 {12 function get_catbynicename($category_nicename)13 {14 global $wpdb;15 16 $cat_id -= 0; // force numeric17 $name = $wpdb->get_var('SELECT cat_ID FROM '.$wpdb->categories.' WHERE category_nicename="'.$category_nicename.'"');18 19 return $name;20 }21 }22 10 23 11 if(!function_exists('get_comment_count')) … … 27 15 global $wpdb; 28 16 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).'"');38 17 } 39 18 } … … 409 388 // Make Post-to-Category associations 410 389 $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; } 412 394 413 395 if(!empty($cats)) { wp_set_post_categories($ret_id, $cats); } … … 510 492 511 493 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']; 514 496 } 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']; 518 499 } 519 500 } else { -
trunk/wp-admin/import/textpattern.php
r5449 r5953 3 3 Add These Functions to make our lives easier 4 4 **/ 5 if(!function_exists('get_catbynicename'))6 {7 function get_catbynicename($category_nicename)8 {9 global $wpdb;10 11 $cat_id -= 0; // force numeric12 $name = $wpdb->get_var('SELECT cat_ID FROM '.$wpdb->categories.' WHERE category_nicename="'.$category_nicename.'"');13 14 return $name;15 }16 }17 5 18 6 if(!function_exists('get_comment_count')) … … 339 327 // Make Post-to-Category associations 340 328 $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; } 343 335 344 336 if(!empty($cats)) { wp_set_post_categories($ret_id, $cats); }
Note: See TracChangeset
for help on using the changeset viewer.