From 0c56811154cbec22f2f676796dcc6d9df9c87258 Mon Sep 17 00:00:00 2001 From: dd32 Date: Tue, 19 Oct 2010 10:10:11 +0000 Subject: [PATCH] Fix current-cat & current-cat-parent classes for Category listings for non-category taxonomies. General cleanup of wp_list_categories() sanity checking. Props TheDeadMedic for the initial taxonomy patch. Fixes #15143 git-svn-id: http://svn.automattic.com/wordpress/trunk@15847 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/classes.php | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/wp-includes/classes.php b/wp-includes/classes.php index da54a1c64..5cbcd8878 100644 --- a/wp-includes/classes.php +++ b/wp-includes/classes.php @@ -1556,7 +1556,7 @@ class Walker_Category extends Walker { $link .= '>'; $link .= $cat_name . ''; - if ( (! empty($feed_image)) || (! empty($feed)) ) { + if ( !empty($feed_image) || !empty($feed) ) { $link .= ' '; if ( empty($feed_image) ) @@ -1564,9 +1564,9 @@ class Walker_Category extends Walker { $link .= ''; + $link .= ''; + if ( empty($feed_image) ) $link .= ')'; } - if ( isset($show_count) && $show_count ) + if ( !empty($show_count) ) $link .= ' (' . intval($category->count) . ')'; - if ( isset($show_date) && $show_date ) { + if ( !empty($show_date) ) $link .= ' ' . gmdate('Y-m-d', $category->last_update_timestamp); - } - - if ( isset($current_category) && $current_category ) - $_current_category = get_category( $current_category ); if ( 'list' == $args['style'] ) { $output .= "\tterm_id; - if ( isset($current_category) && $current_category && ($category->term_id == $current_category) ) - $class .= ' current-cat'; - elseif ( isset($_current_category) && $_current_category && ($category->term_id == $_current_category->parent) ) - $class .= ' current-cat-parent'; - $output .= ' class="'.$class.'"'; + $class = 'cat-item cat-item-' . $category->term_id; + if ( !empty($current_category) ) { + $_current_category = get_term( $current_category, $category->taxonomy ); + if ( $category->term_id == $current_category ) + $class .= ' current-cat'; + elseif ( $category->term_id == $_current_category->parent ) + $class .= ' current-cat-parent'; + } + $output .= ' class="' . $class . '"'; $output .= ">$link\n"; } else { $output .= "\t$link
\n";