Make WordPress Core

Changeset 43712


Ignore:
Timestamp:
10/11/2018 04:41:39 AM (8 years ago)
Author:
SergeyBiryukov
Message:

Taxonomy: Make sure wp_list_categories() correctly outputs term name of 0.

Props joyously, SergeyBiryukov.
Merges [43605] to the 5.0 branch.
Fixes #44872.

Location:
branches/5.0
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/5.0

  • branches/5.0/src/wp-includes/class-walker-category.php

    r41688 r43712  
    100100
    101101                // Don't generate an element if the category name is empty.
    102                 if ( ! $cat_name ) {
     102                if ( '' === $cat_name ) {
    103103                        return;
    104104                }
  • branches/5.0/tests/phpunit/tests/category/wpListCategories.php

    r39280 r43712  
    8888        }
    8989
     90        public function list_cats_callback( $cat ) {
     91                if ( 'Test Cat 1' === $cat ) {
     92                        return '';
     93                }
     94
     95                return $cat;
     96        }
     97
     98        /**
     99         * @ticket 44872
     100         */
     101        public function test_should_create_element_when_cat_name_is_zero() {
     102                $c = self::factory()->category->create(
     103                        array(
     104                                'name' => '0',
     105                        )
     106                );
     107
     108                $found = wp_list_categories(
     109                        array(
     110                                'hide_empty' => false,
     111                                'echo'       => false,
     112                        )
     113                );
     114
     115                $this->assertContains( "cat-item-$c", $found );
     116                $this->assertContains( '0', $found );
     117        }
     118
    90119        public function test_show_option_all_link_should_go_to_home_page_when_show_on_front_is_false() {
    91120                $cats = self::factory()->category->create_many( 2 );
    … …  
    206235
    207236                $this->assertContains( "<li class='cat-item-all'><a href='" . $url . "'>All</a></li>", $found );
    208         }
    209 
    210         public function list_cats_callback( $cat ) {
    211                 if ( 'Test Cat 1' === $cat ) {
    212                         return '';
    213                 }
    214 
    215                 return $cat;
    216237        }
    217238
Note: See TracChangeset for help on using the changeset viewer.