Make WordPress Core

Changeset 31027


Ignore:
Timestamp:
01/03/2015 02:30:14 AM (12 years ago)
Author:
boonebgorges
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/category-template.php

    r31025 r31027  
    10541054                if ( 'list' == $args['style'] ) {
    10551055                        $output .= "\t<li";
    1056                         $class = 'cat-item cat-item-' . $category->term_id;
     1056                        $css_classes = array(
     1057                                'cat-item',
     1058                                'cat-item-' . $category->term_id,
     1059                        );
     1060
    10571061                        if ( ! empty( $args['current_category'] ) ) {
    10581062                                $_current_category = get_term( $args['current_category'], $category->taxonomy );
    10591063                                if ( $category->term_id == $args['current_category'] ) {
    1060                                         $class .=  ' current-cat';
     1064                                        $css_classes[] = 'current-cat';
    10611065                                } elseif ( $category->term_id == $_current_category->parent ) {
    1062                                         $class .=  ' current-cat-parent';
     1066                                        $css_classes[] = 'current-cat-parent';
    10631067                                }
    10641068                        }
    1065                         $output .=  ' class="' . $class . '"';
     1069
     1070                        /**
     1071                         * Filter the list of CSS classes to include with each category in the list.
     1072                         *
     1073                         * @since 4.2.0
     1074                         *
     1075                         * @see wp_list_categories()
     1076                         *
     1077                         * @param array  $css_classes    An array of CSS classes to be applied
     1078                         *                               to each list item.
     1079                         * @param object $category       Category data object.
     1080                         * @param int    $depth          Depth of page, used for padding.
     1081                         * @param array  $args           An array of arguments.
     1082                         */
     1083                        $css_classes = implode( ' ', apply_filters( 'category_css_class', $css_classes, $category, $depth, $args ) );
     1084
     1085                        $output .=  ' class="' . $css_classes . '"';
    10661086                        $output .= ">$link\n";
    10671087                } else {
Note: See TracChangeset for help on using the changeset viewer.