Rename param added to wp_list_categories()
in [33764] to 'hide_title_if_empty'.
Props vilkatis, DrewAPicture. Fixes #33565. git-svn-id: https://develop.svn.wordpress.org/trunk@33767 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
30eb4853f0
commit
718787cd18
@ -461,7 +461,7 @@ function wp_dropdown_categories( $args = '' ) {
|
|||||||
* Display or retrieve the HTML list of categories.
|
* Display or retrieve the HTML list of categories.
|
||||||
*
|
*
|
||||||
* @since 2.1.0
|
* @since 2.1.0
|
||||||
* @since 4.4.0 Introduced the `hide_title_if_no_cats` argument.
|
* @since 4.4.0 Introduced the `hide_title_if_empty` argument.
|
||||||
*
|
*
|
||||||
* @param string|array $args {
|
* @param string|array $args {
|
||||||
* Array of optional arguments.
|
* Array of optional arguments.
|
||||||
@ -493,7 +493,7 @@ function wp_dropdown_categories( $args = '' ) {
|
|||||||
* See {@link get_terms()}. Default true.
|
* See {@link get_terms()}. Default true.
|
||||||
* @type string $title_li Text to use for the list title `<li>` element. Pass an empty string
|
* @type string $title_li Text to use for the list title `<li>` element. Pass an empty string
|
||||||
* to disable. Default 'Categories'.
|
* to disable. Default 'Categories'.
|
||||||
* @type bool $hide_title_if_no_cats Whether to hide the `$title_li` element if there are no terms in
|
* @type bool $hide_title_if_empty Whether to hide the `$title_li` element if there are no terms in
|
||||||
* the list. Default false (title will always be shown).
|
* the list. Default false (title will always be shown).
|
||||||
* @type int $depth Category depth. Used for tab indentation. Default 0.
|
* @type int $depth Category depth. Used for tab indentation. Default 0.
|
||||||
* @type string $taxonomy Taxonomy name. Default 'category'.
|
* @type string $taxonomy Taxonomy name. Default 'category'.
|
||||||
@ -511,7 +511,7 @@ function wp_list_categories( $args = '' ) {
|
|||||||
'feed_image' => '', 'exclude' => '',
|
'feed_image' => '', 'exclude' => '',
|
||||||
'exclude_tree' => '', 'current_category' => 0,
|
'exclude_tree' => '', 'current_category' => 0,
|
||||||
'hierarchical' => true, 'title_li' => __( 'Categories' ),
|
'hierarchical' => true, 'title_li' => __( 'Categories' ),
|
||||||
'hide_title_if_no_cats' => false,
|
'hide_title_if_empty' => false,
|
||||||
'echo' => 1, 'depth' => 0,
|
'echo' => 1, 'depth' => 0,
|
||||||
'taxonomy' => 'category'
|
'taxonomy' => 'category'
|
||||||
);
|
);
|
||||||
@ -539,7 +539,7 @@ function wp_list_categories( $args = '' ) {
|
|||||||
$categories = get_categories( $r );
|
$categories = get_categories( $r );
|
||||||
|
|
||||||
$output = '';
|
$output = '';
|
||||||
if ( $r['title_li'] && 'list' == $r['style'] && ( ! empty( $categories ) || ! $r['hide_title_if_no_cats'] ) ) {
|
if ( $r['title_li'] && 'list' == $r['style'] && ( ! empty( $categories ) || ! $r['hide_title_if_empty'] ) ) {
|
||||||
$output = '<li class="' . esc_attr( $r['class'] ) . '">' . $r['title_li'] . '<ul>';
|
$output = '<li class="' . esc_attr( $r['class'] ) . '">' . $r['title_li'] . '<ul>';
|
||||||
}
|
}
|
||||||
if ( empty( $categories ) ) {
|
if ( empty( $categories ) ) {
|
||||||
|
@ -212,10 +212,10 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase {
|
|||||||
/**
|
/**
|
||||||
* @ticket 33460
|
* @ticket 33460
|
||||||
*/
|
*/
|
||||||
public function test_hide_title_if_no_cats_should_be_respected_for_empty_lists_when_true() {
|
public function test_hide_title_if_empty_should_be_respected_for_empty_lists_when_true() {
|
||||||
$found = wp_list_categories( array(
|
$found = wp_list_categories( array(
|
||||||
'echo' => false,
|
'echo' => false,
|
||||||
'hide_title_if_no_cats' => true,
|
'hide_title_if_empty' => true,
|
||||||
) );
|
) );
|
||||||
|
|
||||||
$this->assertNotContains( '<li class="categories">Categories', $found );
|
$this->assertNotContains( '<li class="categories">Categories', $found );
|
||||||
@ -224,10 +224,10 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase {
|
|||||||
/**
|
/**
|
||||||
* @ticket 33460
|
* @ticket 33460
|
||||||
*/
|
*/
|
||||||
public function test_hide_title_if_no_cats_should_be_respected_for_empty_lists_when_false() {
|
public function test_hide_title_if_empty_should_be_respected_for_empty_lists_when_false() {
|
||||||
$found = wp_list_categories( array(
|
$found = wp_list_categories( array(
|
||||||
'echo' => false,
|
'echo' => false,
|
||||||
'hide_title_if_no_cats' => false,
|
'hide_title_if_empty' => false,
|
||||||
) );
|
) );
|
||||||
|
|
||||||
$this->assertContains( '<li class="categories">Categories', $found );
|
$this->assertContains( '<li class="categories">Categories', $found );
|
||||||
@ -236,13 +236,13 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase {
|
|||||||
/**
|
/**
|
||||||
* @ticket 33460
|
* @ticket 33460
|
||||||
*/
|
*/
|
||||||
public function test_hide_title_if_no_cats_should_be_ignored_when_category_list_is_not_empty() {
|
public function test_hide_title_if_empty_should_be_ignored_when_category_list_is_not_empty() {
|
||||||
$cat = $this->factory->category->create();
|
$cat = $this->factory->category->create();
|
||||||
|
|
||||||
$found = wp_list_categories( array(
|
$found = wp_list_categories( array(
|
||||||
'echo' => false,
|
'echo' => false,
|
||||||
'hide_empty' => false,
|
'hide_empty' => false,
|
||||||
'hide_title_if_no_cats' => true,
|
'hide_title_if_empty' => true,
|
||||||
) );
|
) );
|
||||||
|
|
||||||
$this->assertContains( '<li class="categories">Categories', $found );
|
$this->assertContains( '<li class="categories">Categories', $found );
|
||||||
|
Loading…
Reference in New Issue
Block a user