Changeset 5553
- Timestamp:
- 05/26/2007 06:54:16 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/import/wp-cat2tag.php
r5390 r5553 17 17 global $wpdb; 18 18 19 $this->all_categories = $wpdb->get_results("SELECT * FROM $wpdb->categories WHERE (type & ~ " . TAXONOMY_TAG . ") != 0 AND category_count > 0 ORDER BY cat_name ASC");19 $this->all_categories = get_categories('get=all'); 20 20 } 21 21 … … 41 41 print '<ul style="list-style:none">'; 42 42 43 $hier = _get_ category_hierarchy();43 $hier = _get_term_hierarchy('category'); 44 44 45 45 foreach ($this->all_categories as $category) { 46 if ((int) $category-> category_parent == 0) {47 print '<li><label><input type="checkbox" name="cats_to_convert[]" value="' . intval($category-> cat_ID) . '" /> ' . $category->cat_name . ' (' . $category->category_count . ')</label>';48 49 if (isset($hier[$category-> cat_ID])) {46 if ((int) $category->parent == 0) { 47 print '<li><label><input type="checkbox" name="cats_to_convert[]" value="' . intval($category->term_id) . '" /> ' . $category->name . ' (' . $category->count . ')</label>'; 48 49 if (isset($hier[$category->term_id])) { 50 50 $this->_category_children($category, $hier); 51 51 } … … 64 64 print '<ul style="list-style:none">'; 65 65 66 foreach ($hier[$parent-> cat_ID] as $child_id) {66 foreach ($hier[$parent->term_id] as $child_id) { 67 67 $child =& get_category($child_id); 68 68 69 print '<li><label><input type="checkbox" name="cats_to_convert[]" value="' . intval($child-> cat_ID) . '" /> ' . $child->cat_name . ' (' . $child->category_count . ')</label>';70 71 if (isset($hier[$child-> cat_ID])) {69 print '<li><label><input type="checkbox" name="cats_to_convert[]" value="' . intval($child->term_id) . '" /> ' . $child->name . ' (' . $child->count . ')</label>'; 70 71 if (isset($hier[$child->term_id])) { 72 72 $this->_category_children($child, $hier); 73 73 } … … 84 84 $cat_id = (int) $cat_id; 85 85 86 $maybe_exists = $wpdb->get_results("SELECT cat_ID from $wpdb->categories WHERE cat_ID = '$cat_id'");87 88 if ( count($maybe_exists) > 0) {86 $maybe_exists = category_exists($cat_id); 87 88 if ( $maybe_exists ) { 89 89 return true; 90 90 } else { … … 102 102 } 103 103 104 $this->categories_to_convert = $_POST['cats_to_convert']; 105 $hier = _get_category_hierarchy(); 104 105 if ( empty($this->categories_to_convert) ) 106 $this->categories_to_convert = $_POST['cats_to_convert']; 107 $hier = _get_term_hierarchy('category'); 106 108 107 109 print '<ul>'; … … 117 119 $category =& get_category($cat_id); 118 120 119 if ($category->link_count > 0) {120 $type = $category->type | TAXONOMY_TAG;121 } else {122 $type = TAXONOMY_TAG;123 }124 125 121 // Set the category itself to $type from above 126 $wpdb->query("UPDATE $wpdb->categories SET type = '$type' WHERE cat_ID = '{$category->cat_ID}'"); 127 128 // Set relationships in post2cat to 'tag', category_count becomes tag_count 129 $wpdb->query("UPDATE $wpdb->post2cat SET rel_type = 'tag' WHERE category_ID = '{$category->cat_ID}'"); 130 $wpdb->query("UPDATE $wpdb->categories SET tag_count = '{$category->category_count}', category_count = '0' WHERE cat_ID = '{$category->cat_ID}'"); 122 $wpdb->query("UPDATE $wpdb->term_taxonomy SET taxonomy = '$type' WHERE term_id = '{$category->term_id}' AND taxonomy = 'category'"); 131 123 132 124 // Set all parents to 0 (root-level) if their parent was the converted tag 133 $wpdb->query("UPDATE $wpdb-> categories SET category_parent = 0 WHERE category_parent = '{$category->cat_ID}'");125 $wpdb->query("UPDATE $wpdb->term_taxonomy SET parent = 0 WHERE parent = '{$category->term_id}' AND taxonomy = 'category'"); 134 126 135 127 // Clean the cache 136 clean_category_cache($category-> cat_ID);128 clean_category_cache($category->term_id); 137 129 138 130 _e('Converted successfully.'); … … 161 153 function convert_all() { 162 154 global $wpdb; 163 164 $cats = $wpdb->get_results("SELECT * FROM $wpdb->categories WHERE (type & ~ " . TAXONOMY_TAG . ") != 0 AND category_count > 0"); 165 166 $_POST['cats_to_convert'] = array(); 167 168 foreach ($cats as $cat) { 169 $_POST['cats_to_convert'][] = $cat->cat_ID; 170 } 171 172 $this->convert_them(); 155 156 $wpdb->query("UPDATE $wpdb->term_taxonomy SET taxonomy = '$type', parent = 0 WHERE taxonomy = 'category'"); 157 clean_category_cache($category->term_id); 173 158 } 174 159 -
trunk/wp-admin/includes/template.php
r5543 r5553 99 99 } 100 100 101 $cats = get_categories("child_of=$parent&hide_empty=0& get=ids");101 $cats = get_categories("child_of=$parent&hide_empty=0&fields=ids"); 102 102 $result = array (); 103 103 -
trunk/wp-includes/category.php
r5534 r5553 5 5 6 6 if ( ! $cat_ids = wp_cache_get('all_category_ids', 'category') ) { 7 $cat_ids = get_terms('category', ' get=ids&hierarchical=0&hide_empty=0');7 $cat_ids = get_terms('category', 'fields=ids&get=all'); 8 8 wp_cache_add('all_category_ids', $cat_ids, 'category'); 9 9 } -
trunk/wp-includes/post.php
r5529 r5553 448 448 $post_id = (int) $post_id; 449 449 450 $cats = get_object_terms($post_id, 'category', 'get= ids');450 $cats = get_object_terms($post_id, 'category', 'get=fields'); 451 451 return $cats; 452 452 } -
trunk/wp-includes/taxonomy.php
r5552 r5553 137 137 138 138 foreach ( (array) $objects as $object ) { 139 $terms = get_object_terms($object, $taxonomy, ' get=ids');139 $terms = get_object_terms($object, $taxonomy, 'fields=ids'); 140 140 if ( 1 == count($terms) && isset($default) ) 141 141 $terms = array($default); … … 320 320 $object_ids = ($single_object = !is_array($object_id)) ? array($object_id) : $object_id; 321 321 322 $defaults = array('orderby' => 'name', 'order' => 'ASC', ' get' => 'everything');322 $defaults = array('orderby' => 'name', 'order' => 'ASC', 'fields' => 'all'); 323 323 $args = wp_parse_args( $args, $defaults ); 324 324 extract($args); … … 332 332 $object_ids = implode(', ', $object_ids); 333 333 334 if ( ' everything' == $get)334 if ( 'all' == $fields ) 335 335 $select_this = 't.*'; 336 else if ( 'ids' == $ get)336 else if ( 'ids' == $fields ) 337 337 $select_this = 't.term_id'; 338 338 339 339 $query = "SELECT $select_this FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN $wpdb->term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ($taxonomies) AND tr.object_id IN ($object_ids) ORDER BY $orderby $order"; 340 340 341 if ( ' everything' == $get)341 if ( 'all' == $fields ) 342 342 $taxonomy_data = $wpdb->get_results($query); 343 else if ( 'ids' == $ get)343 else if ( 'ids' == $fields ) 344 344 $taxonomy_data = $wpdb->get_col($query); 345 345 … … 380 380 $defaults = array('orderby' => 'name', 'order' => 'ASC', 381 381 'hide_empty' => true, 'exclude' => '', 'include' => '', 382 'number' => '', ' get' => 'everything', 'slug' => '', 'parent' => '',383 'hierarchical' => true, 'child_of' => 0 );382 'number' => '', 'fields' => 'all', 'slug' => '', 'parent' => '', 383 'hierarchical' => true, 'child_of' => 0, 'get' => ''); 384 384 $args = wp_parse_args( $args, $defaults ); 385 385 $args['number'] = (int) $args['number']; … … 387 387 $args['child_of'] = 0; 388 388 $args['hierarchical'] = false; 389 } else { 390 $tax = get_taxonomy($taxonomy); 391 if ( !$tax['hierarchical'] ) { 392 $args['child_of'] = 0; 393 $args['hierarchical'] = false; 394 } 389 } else if ( !is_taxonomy_hierarchical($taxonomies[0]) ) { 390 $args['child_of'] = 0; 391 $args['hierarchical'] = false; 392 } 393 if ( 'all' == $args['get'] ) { 394 $args['child_of'] = 0; 395 $args['hide_empty'] = 0; 396 $args['hierarchical'] = false; 395 397 } 396 398 extract($args); … … 464 466 $number = ''; 465 467 466 if ( ' everything' == $get)468 if ( 'all' == $fields ) 467 469 $select_this = 't.*, tt.*'; 468 else if ( 'ids' == $ get)470 else if ( 'ids' == $fields ) 469 471 $select_this = 't.term_id'; 470 472 471 473 $query = "SELECT $select_this FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ($in_taxonomies) $where ORDER BY $orderby $order $number"; 472 474 473 if ( ' everything' == $get)475 if ( 'all' == $fields ) 474 476 $terms = $wpdb->get_results($query); 475 else if ( 'ids' == $ get)477 else if ( 'ids' == $fields ) 476 478 $terms = $wpdb->get_col($query); 477 479
Note: See TracChangeset
for help on using the changeset viewer.