Fix the exclude_tree argument in get_terms(), which fixes the exclude argument in wp_list_categories().
Merges [25933] to the 3.7 branch. This was a 3.7 regression caused by [25162]. props dd32. fixes #25710. git-svn-id: https://develop.svn.wordpress.org/branches/3.7@25936 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
47786de986
commit
03f3c454ca
@ -1362,7 +1362,7 @@ function get_terms($taxonomies, $args = '') {
|
|||||||
$exclusions = '';
|
$exclusions = '';
|
||||||
if ( ! empty( $exclude_tree ) ) {
|
if ( ! empty( $exclude_tree ) ) {
|
||||||
$exclude_tree = wp_parse_id_list( $exclude_tree );
|
$exclude_tree = wp_parse_id_list( $exclude_tree );
|
||||||
$excluded_children = array();
|
$excluded_children = $exclude_tree;
|
||||||
foreach ( $exclude_tree as $extrunk ) {
|
foreach ( $exclude_tree as $extrunk ) {
|
||||||
$excluded_children = array_merge(
|
$excluded_children = array_merge(
|
||||||
$excluded_children,
|
$excluded_children,
|
||||||
|
@ -151,6 +151,38 @@ class Tests_Term_getTerms extends WP_UnitTestCase {
|
|||||||
$this->assertEmpty( $wpdb->last_error );
|
$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
|
* @ticket 13992
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user