summaryrefslogtreecommitdiffstats
path: root/wp-includes/category.php
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-08-17 12:36:23 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-08-17 12:36:23 +0000
commite9261c6491959b5b0efe1036ec37ff9e850bd62e (patch)
treeb0ca05cf207206ab1ec85216c0d7abc4c16eca5b /wp-includes/category.php
parent62a85df302a839177400100c6a09813161440ce0 (diff)
downloadwordpress-mu-e9261c6491959b5b0efe1036ec37ff9e850bd62e.tar.gz
wordpress-mu-e9261c6491959b5b0efe1036ec37ff9e850bd62e.tar.xz
wordpress-mu-e9261c6491959b5b0efe1036ec37ff9e850bd62e.zip
WP Merge to rev 4104
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@723 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-includes/category.php')
-rw-r--r--wp-includes/category.php18
1 files changed, 17 insertions, 1 deletions
diff --git a/wp-includes/category.php b/wp-includes/category.php
index 3127482..648ef4f 100644
--- a/wp-includes/category.php
+++ b/wp-includes/category.php
@@ -67,7 +67,7 @@ function &get_categories($args = '') {
$exclusions = apply_filters('list_cats_exclusions', $exclusions, $r );
$where .= $exclusions;
- if ( $hide_empty ) {
+ if ( $hide_empty && !$hierarchical ) {
if ( 'link' == $type )
$where .= ' AND link_count > 0';
else
@@ -103,6 +103,22 @@ function &get_categories($args = '') {
if ( $child_of || $hierarchical )
$categories = & _get_cat_children($child_of, $categories);
+ // Update category counts to include children.
+ if ( $hierarchical ) {
+ foreach ( $categories as $k => $category ) {
+ $progeny = $category->category_count;
+ if ( $children = _get_cat_children($category->cat_ID, $categories) ) {
+ foreach ( $children as $child )
+ $progeny += $child->category_count;
+ }
+ if ( !$progeny && $hide_empty )
+ unset($categories[$k]);
+ else
+ $categories[$k]->category_count = $progeny;
+ }
+ }
+ reset ( $categories );
+
return apply_filters('get_categories', $categories, $r);
}