WordPress.org

Make WordPress Core

Changeset 39280


Ignore:
Timestamp:
11/17/16 18:01:13 (8 months ago)
Author:
SergeyBiryukov
Message:

Taxonomy: Prevent wp_list_categories() from producing not well-nested output if hide_title_if_empty is true.

Props chesio.
Fixes #38839. See #33460.

Location:
trunk
Files:
2 edited

Legend:

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

    r38928 r39280  
    625625    } 
    626626 
    627     if ( $r['title_li'] && 'list' == $r['style'] ) 
     627    if ( $r['title_li'] && 'list' == $r['style'] && ( ! empty( $categories ) || ! $r['hide_title_if_empty'] ) ) { 
    628628        $output .= '</ul></li>'; 
     629    } 
    629630 
    630631    /** 
  • trunk/tests/phpunit/tests/category/wpListCategories.php

    r36008 r39280  
    264264 
    265265        $this->assertContains( '<li class="categories">Categories', $found ); 
     266    } 
     267 
     268    /** 
     269     * @ticket 38839 
     270     */ 
     271    public function test_hide_title_if_empty_should_not_output_stray_closing_tags() { 
     272        $cat = self::factory()->category->create(); 
     273 
     274        $found = wp_list_categories( array( 
     275            'echo' => false, 
     276            'show_option_none' => '', 
     277            'child_of' => 1, 
     278            'hide_title_if_empty' => true, 
     279        ) ); 
     280 
     281        $this->assertNotContains( '</ul></li>', $found ); 
    266282    } 
    267283 
Note: See TracChangeset for help on using the changeset viewer.