Fix the exclude_tree argument in get_terms(), which fixes the exclude argument in wp_list_categories().

This was a 3.7 regression caused by [25162].

props dd32.
see #25710 for trunk.


git-svn-id: https://develop.svn.wordpress.org/trunk@25933 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2013-10-26 15:03:10 +00:00
parent 287e4db6f6
commit 90b55d0279
2 changed files with 33 additions and 1 deletions

View File

@ -1362,7 +1362,7 @@ function get_terms($taxonomies, $args = '') {
$exclusions = '';
if ( ! empty( $exclude_tree ) ) {
$exclude_tree = wp_parse_id_list( $exclude_tree );
$excluded_children = array();
$excluded_children = $exclude_tree;
foreach ( $exclude_tree as $extrunk ) {
$excluded_children = array_merge(
$excluded_children,

View File

@ -151,6 +151,38 @@ class Tests_Term_getTerms extends WP_UnitTestCase {
$this->assertEmpty( $wpdb->last_error );
}
/**
* @ticket 25710
*/
function test_get_terms_exclude_tree() {
$term_id_uncategorized = get_option( 'default_category' );
$term_id1 = $this->factory->category->create();
$term_id11 = $this->factory->category->create( array( 'parent' => $term_id1 ) );
$term_id2 = $this->factory->category->create();
$term_id22 = $this->factory->category->create( array( 'parent' => $term_id2 ) );
// There's something else broken in the cache cleaning routines that leads to this having to be done manually
delete_option( 'category_children' );
$terms = get_terms( 'category', array(
'exclude' => $term_id_uncategorized,
'fields' => 'ids',
'hide_empty' => false,
) );
$this->assertEquals( array( $term_id1, $term_id11, $term_id2, $term_id22 ), $terms );
$terms = get_terms( 'category', array(
'fields' => 'ids',
'exclude_tree' => "$term_id1,$term_id_uncategorized",
'hide_empty' => false,
) );
$this->assertEquals( array( $term_id2, $term_id22 ), $terms );
}
/**
* @ticket 13992
*/