Ticket #3985: 3985.diff
File 3985.diff, 2.0 KB (added by , 17 years ago) |
---|
-
wp-includes/category.php
109 109 unset($cat_stamps); 110 110 } 111 111 112 if ( $child_of || $hierarchical ) 113 $categories = & _get_cat_children($child_of, $categories); 112 if ( $child_of || $hierarchical ) { 113 $children = _get_category_hierarchy(); 114 if ( ! empty($children) ) 115 $categories = & _get_cat_children($child_of, $categories); 116 } 114 117 115 118 // Update category counts to include children. 116 119 if ( $pad_counts ) … … 260 263 return array(); 261 264 262 265 $category_list = array(); 266 $children = _get_category_hierarchy(); 263 267 foreach ( $categories as $category ) { 264 268 if ( $category->cat_ID == $category_id ) 265 269 continue; 266 270 267 271 if ( $category->category_parent == $category_id ) { 268 272 $category_list[] = $category; 273 if ( !isset($children[$category->cat_ID]) ) 274 continue; 275 269 276 if ( $children = _get_cat_children($category->cat_ID, $categories) ) 270 277 $category_list = array_merge($category_list, $children); 271 278 } … … 313 320 $cats[$id]->{'link' == $type ? 'link_count' : 'category_count'} = count($items); 314 321 } 315 322 323 function _get_category_hierarchy() { 324 $children = get_option('category_children'); 325 if ( is_array($children) ) 326 return $children; 327 328 $children = array(); 329 $categories = get_categories('hide_empty=0&hierarchical=0'); 330 foreach ( $categories as $cat ) { 331 if ( $cat->category_parent > 0 ) 332 $children[$cat->category_parent][] = $cat->ID; 333 } 334 update_option('category_children', $children); 335 336 return $children; 337 } 316 338 ?> -
wp-includes/functions.php
749 749 wp_cache_delete($id, 'category'); 750 750 wp_cache_delete('all_category_ids', 'category'); 751 751 wp_cache_delete('get_categories', 'category'); 752 delete_option('category_children'); 752 753 } 753 754 754 755 /*