mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 12:20:22 +00:00
Fix 'exclude_tree' in wp_list_categories().
The 'exclude_tree' parameter must be compatible with 'hierarchical'; previously, 'hierarchical' canceled it out. This changeset also makes it so that 'exclude_tree' is compatible with 'exclude'. When both are passed, and 'hierarchical' is true, the descendant trees of terms in both parameters will be excluded from matched terms. Props tott, webord, MikeHansenMe. Fixes #12981. git-svn-id: https://develop.svn.wordpress.org/trunk@34696 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -264,4 +264,47 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase {
|
||||
|
||||
$this->assertContains( '<li class="categories">Categories', $found );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 12981
|
||||
*/
|
||||
public function test_exclude_tree_should_be_respected() {
|
||||
$c = $this->factory->category->create();
|
||||
$parent = $this->factory->category->create( array( 'name' => 'Parent', 'slug' => 'parent' ) );
|
||||
$child = $this->factory->category->create( array( 'name' => 'Child', 'slug' => 'child', 'parent' => $parent ) );
|
||||
|
||||
$args = array( 'echo' => 0, 'hide_empty' => 0, 'exclude_tree' => $parent );
|
||||
|
||||
$actual = wp_list_categories( $args );
|
||||
|
||||
$this->assertNotContains( '<li class="cat-item cat-item-' . $parent . '">', $actual );
|
||||
|
||||
$this->assertNotContains( '<li class="cat-item cat-item-' . $child . '">', $actual );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 12981
|
||||
*/
|
||||
public function test_exclude_tree_should_be_merged_with_exclude() {
|
||||
$c = $this->factory->category->create();
|
||||
$parent = $this->factory->category->create( array( 'name' => 'Parent', 'slug' => 'parent' ) );
|
||||
$child = $this->factory->category->create( array( 'name' => 'Child', 'slug' => 'child', 'parent' => $parent ) );
|
||||
$parent2 = $this->factory->category->create( array( 'name' => 'Parent', 'slug' => 'parent2' ) );
|
||||
$child2 = $this->factory->category->create( array( 'name' => 'Child', 'slug' => 'child2', 'parent' => $parent2 ) );
|
||||
|
||||
$args = array( 'echo' => 0, 'hide_empty' => 0, 'exclude_tree' => $parent );
|
||||
|
||||
$actual = wp_list_categories( array(
|
||||
'echo' => 0,
|
||||
'hide_empty' => 0,
|
||||
'exclude' => $parent,
|
||||
'exclude_tree' => $parent2,
|
||||
) );
|
||||
|
||||
$this->assertNotContains( '<li class="cat-item cat-item-' . $parent . '">', $actual );
|
||||
$this->assertNotContains( '<li class="cat-item cat-item-' . $parent2 . '">', $actual );
|
||||
$this->assertNotContains( '<li class="cat-item cat-item-' . $child . '">', $actual );
|
||||
|
||||
$this->assertNotContains( '<li class="cat-item cat-item-' . $child2 . '">', $actual );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user