diff --git src/wp-includes/category-template.php src/wp-includes/category-template.php
index 797d07a..3daecb2 100644
|
|
class Walker_Category extends Walker { |
1121 | 1121 | ); |
1122 | 1122 | |
1123 | 1123 | if ( ! empty( $args['current_category'] ) ) { |
1124 | | $_current_category = get_term( $args['current_category'], $category->taxonomy ); |
1125 | | if ( $category->term_id == $args['current_category'] ) { |
1126 | | $css_classes[] = 'current-cat'; |
1127 | | } elseif ( $category->term_id == $_current_category->parent ) { |
1128 | | $css_classes[] = 'current-cat-parent'; |
| 1124 | // 'current_category' can be an array, so we use `get_terms()`. |
| 1125 | $_current_terms = get_terms( $category->taxonomy, array( |
| 1126 | 'include' => $args['current_category'], |
| 1127 | 'hide_empty' => false, |
| 1128 | ) ); |
| 1129 | |
| 1130 | foreach ( $_current_terms as $_current_term ) { |
| 1131 | if ( $category->term_id == $_current_term->term_id ) { |
| 1132 | $css_classes[] = 'current-cat'; |
| 1133 | } elseif ( $category->term_id == $_current_term->parent ) { |
| 1134 | $css_classes[] = 'current-cat-parent'; |
| 1135 | } |
1129 | 1136 | } |
1130 | 1137 | } |
1131 | 1138 | |
diff --git tests/phpunit/tests/category/wpListCategories.php tests/phpunit/tests/category/wpListCategories.php
index 92284f8..56ae395 100644
|
|
class Tests_Category_WpListCategories extends WP_UnitTestCase { |
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
| 49 | * @ticket 33565 |
| 50 | */ |
| 51 | public function test_current_category_should_accept_an_array_of_ids() { |
| 52 | $cats = $this->factory->category->create_many( 3 ); |
| 53 | |
| 54 | $found = wp_list_categories( array( |
| 55 | 'echo' => false, |
| 56 | 'hide_empty' => false, |
| 57 | 'current_category' => array( $cats[0], $cats[2] ), |
| 58 | ) ); |
| 59 | |
| 60 | $this->assertRegExp( '/class="[^"]*cat-item-' . $cats[0] . '[^"]*current-cat[^"]*"/', $found ); |
| 61 | $this->assertNotRegExp( '/class="[^"]*cat-item-' . $cats[1] . '[^"]*current[^"]*"/', $found ); |
| 62 | $this->assertRegExp( '/class="[^"]*cat-item-' . $cats[2] . '[^"]*current-cat[^"]*"/', $found ); |
| 63 | } |
| 64 | |
| 65 | /** |
49 | 66 | * @ticket 16792 |
50 | 67 | */ |
51 | 68 | public function test_should_not_create_element_when_cat_name_is_filtered_to_empty_string() { |