mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@31027 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
3da394f499
commit
8d990ce6f8
@ -1053,16 +1053,36 @@ class Walker_Category extends Walker {
|
||||
}
|
||||
if ( 'list' == $args['style'] ) {
|
||||
$output .= "\t<li";
|
||||
$class = 'cat-item cat-item-' . $category->term_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<br />\n";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user