From a374f9f092585988d1d7bbfe247f8b015fe97027 Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Sat, 3 Jan 2015 02:31:22 +0000 Subject: [PATCH] Introduce 'category_css_classes' filter. Paralleling the 'page_css_classes' filter, this allows developers to modify the list of CSS classes used when creating category list markup via `Walker_Category`. Props sivel. Fixes #16497. Built from https://develop.svn.wordpress.org/trunk@31027 git-svn-id: http://core.svn.wordpress.org/trunk@31008 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/category-template.php | 28 ++++++++++++++++++++++++---- wp-includes/version.php | 2 +- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/wp-includes/category-template.php b/wp-includes/category-template.php index ad66987f7b..264a0d6355 100644 --- a/wp-includes/category-template.php +++ b/wp-includes/category-template.php @@ -1053,16 +1053,36 @@ class Walker_Category extends Walker { } if ( 'list' == $args['style'] ) { $output .= "\tterm_id; + $css_classes = array( + 'cat-item', + 'cat-item-' . $category->term_id, + ); + if ( ! empty( $args['current_category'] ) ) { $_current_category = get_term( $args['current_category'], $category->taxonomy ); if ( $category->term_id == $args['current_category'] ) { - $class .= ' current-cat'; + $css_classes[] = 'current-cat'; } elseif ( $category->term_id == $_current_category->parent ) { - $class .= ' current-cat-parent'; + $css_classes[] = 'current-cat-parent'; } } - $output .= ' class="' . $class . '"'; + + /** + * Filter the list of CSS classes to include with each category in the list. + * + * @since 4.2.0 + * + * @see wp_list_categories() + * + * @param array $css_classes An array of CSS classes to be applied + * to each list item. + * @param object $category Category data object. + * @param int $depth Depth of page, used for padding. + * @param array $args An array of arguments. + */ + $css_classes = implode( ' ', apply_filters( 'category_css_class', $css_classes, $category, $depth, $args ) ); + + $output .= ' class="' . $css_classes . '"'; $output .= ">$link\n"; } else { $output .= "\t$link
\n"; diff --git a/wp-includes/version.php b/wp-includes/version.php index 20efe381e2..8ca19fc381 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.2-alpha-31026'; +$wp_version = '4.2-alpha-31027'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.