Ensure that 'hierarchical' is respected in `get_terms()` when multiple taxonomies are passed.
Previously, attempts to descend the family tree of each term were done using the first taxonomy in the `$taxonomies` array, with the result that terms not belonging to that taxonomy were not found and their children not properly parsed. We fix this bug by fetching each term's taxonomy with the SQL query, and then using that taxonomy to get the correct children for each term. Fixes #31118. Built from https://develop.svn.wordpress.org/trunk@31285 git-svn-id: http://core.svn.wordpress.org/trunk@31266 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
af6e0f5c55
commit
e199d2420f
|
@ -1887,10 +1887,10 @@ function get_terms( $taxonomies, $args = '' ) {
|
|||
break;
|
||||
case 'ids':
|
||||
case 'id=>parent':
|
||||
$selects = array( 't.term_id', 'tt.parent', 'tt.count' );
|
||||
$selects = array( 't.term_id', 'tt.parent', 'tt.count', 'tt.taxonomy' );
|
||||
break;
|
||||
case 'names':
|
||||
$selects = array( 't.term_id', 'tt.parent', 'tt.count', 't.name' );
|
||||
$selects = array( 't.term_id', 'tt.parent', 'tt.count', 't.name', 'tt.taxonomy' );
|
||||
break;
|
||||
case 'count':
|
||||
$orderby = '';
|
||||
|
@ -1898,10 +1898,10 @@ function get_terms( $taxonomies, $args = '' ) {
|
|||
$selects = array( 'COUNT(*)' );
|
||||
break;
|
||||
case 'id=>name':
|
||||
$selects = array( 't.term_id', 't.name', 'tt.count' );
|
||||
$selects = array( 't.term_id', 't.name', 'tt.count', 'tt.taxonomy' );
|
||||
break;
|
||||
case 'id=>slug':
|
||||
$selects = array( 't.term_id', 't.slug', 'tt.count' );
|
||||
$selects = array( 't.term_id', 't.slug', 'tt.count', 'tt.taxonomy' );
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1974,14 +1974,15 @@ function get_terms( $taxonomies, $args = '' ) {
|
|||
_pad_term_counts( $terms, $_tax );
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure we show empty categories that have children.
|
||||
if ( $hierarchical && $args['hide_empty'] && is_array( $terms ) ) {
|
||||
foreach ( $terms as $k => $term ) {
|
||||
if ( ! $term->count ) {
|
||||
$children = get_term_children( $term->term_id, reset( $taxonomies ) );
|
||||
$children = get_term_children( $term->term_id, $term->taxonomy );
|
||||
if ( is_array( $children ) ) {
|
||||
foreach ( $children as $child_id ) {
|
||||
$child = get_term( $child_id, reset( $taxonomies ) );
|
||||
$child = get_term( $child_id, $term->taxonomy );
|
||||
if ( $child->count ) {
|
||||
continue 2;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.2-alpha-31284';
|
||||
$wp_version = '4.2-alpha-31285';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue