mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-22 23:41:38 +01:00
In get_terms()
, do not override 'hierarchical' and 'pad_counts' when 'parent' is present.
The previous behavior resulted in descendant terms being improperly excluded from the results when passing a 'parent', even when 'hierarchical' had been set to true. The patch also adds unit tests that demonstrate the various interactions between the 'child_of', 'parent', and 'hierarchical' parameters of `get_terms()`. Props landakram. Fixes #29815. Built from https://develop.svn.wordpress.org/trunk@30107 git-svn-id: http://core.svn.wordpress.org/trunk@30107 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
3dcf418545
commit
47742eae12
@ -1628,13 +1628,19 @@ function get_terms( $taxonomies, $args = '' ) {
|
|||||||
$args = wp_parse_args( $args, $defaults );
|
$args = wp_parse_args( $args, $defaults );
|
||||||
$args['number'] = absint( $args['number'] );
|
$args['number'] = absint( $args['number'] );
|
||||||
$args['offset'] = absint( $args['offset'] );
|
$args['offset'] = absint( $args['offset'] );
|
||||||
if ( !$single_taxonomy || ! is_taxonomy_hierarchical( reset( $taxonomies ) ) ||
|
|
||||||
( '' !== $args['parent'] && 0 !== $args['parent'] ) ) {
|
// Save queries by not crawling the tree in the case of multiple taxes or a flat tax.
|
||||||
$args['child_of'] = 0;
|
if ( ! $single_taxonomy || ! is_taxonomy_hierarchical( reset( $taxonomies ) ) ) {
|
||||||
|
$args['child_of'] = false;
|
||||||
$args['hierarchical'] = false;
|
$args['hierarchical'] = false;
|
||||||
$args['pad_counts'] = false;
|
$args['pad_counts'] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 'parent' overrides 'child_of'.
|
||||||
|
if ( 0 < intval( $args['parent'] ) ) {
|
||||||
|
$args['child_of'] = false;
|
||||||
|
}
|
||||||
|
|
||||||
if ( 'all' == $args['get'] ) {
|
if ( 'all' == $args['get'] ) {
|
||||||
$args['child_of'] = 0;
|
$args['child_of'] = 0;
|
||||||
$args['hide_empty'] = 0;
|
$args['hide_empty'] = 0;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.1-alpha-30106';
|
$wp_version = '4.1-alpha-30107';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user