Make WordPress Core

Ticket #12981: 12981.2.diff

File 12981.2.diff, 1.5 KB (added by MikeHansenMe, 9 years ago)
  • src/wp-includes/category-template.php

     
    536536        if ( !isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] )
    537537                $r['pad_counts'] = true;
    538538
    539         if ( true == $r['hierarchical'] ) {
     539        if ( true == $r['hierarchical'] && empty( $r['exclude_tree'] ) ) {
    540540                $r['exclude_tree'] = $r['exclude'];
    541541                $r['exclude'] = '';
    542542        }
  • tests/phpunit/tests/category/wpListCategories.php

     
    264264
    265265                $this->assertContains( '<li class="categories">Categories', $found );
    266266        }
     267
     268        public function test_wp_list_categories_exclude_tree() {
     269                $parent = $this->factory->category->create( array( 'name' => 'Parent', 'slug' => 'parent' ) );
     270                $child = $this->factory->category->create( array( 'name' => 'Child', 'slug' => 'child', 'parent' => $parent ) );
     271
     272                $args = array( 'echo' => 0, 'hide_empty' => 0, 'exclude_tree' => $parent );
     273
     274                $actual = wp_list_categories( $args );
     275
     276                $this->assertNotContains( '<li class="cat-item cat-item-' . $parent . '">', $actual );
     277
     278                $this->assertNotContains( '<li class="cat-item cat-item-' . $child . '">', $actual );
     279        }
    267280}