When a `term_id` matches in `_get_term_children()`, recurse through its children until there is no more depth in the hierarchy. Since `get_terms()` return terms with a `count` of `0` when their children are not empty, we must return all children so that `get_terms()` can check their count.
In [27108], #26903 was fixed, but only because we were using the example in the ticket, leaving out infinite depth for hierarchical taxonomies. Adds unit tests, including `Tests_Term_getTerms::test_get_terms_seven_levels_deep()`. Fixes #26903. Again. Built from https://develop.svn.wordpress.org/trunk@27125 git-svn-id: http://core.svn.wordpress.org/trunk@26992 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
27097dea2c
commit
75d8688f60
|
@ -3004,12 +3004,17 @@ function _get_term_children($term_id, $terms, $taxonomy) {
|
|||
|
||||
if ( $term->term_id == $term_id ) {
|
||||
if ( isset( $has_children[$term_id] ) ) {
|
||||
foreach ( $has_children[$term_id] as $t_id ) {
|
||||
if ( $use_id ) {
|
||||
$term_list[] = $t_id;
|
||||
} else {
|
||||
$term_list[] = get_term( $t_id, $taxonomy );
|
||||
$current_id = $term_id;
|
||||
while ( $current_id > 0 ) {
|
||||
foreach ( $has_children[$current_id] as $t_id ) {
|
||||
if ( $use_id ) {
|
||||
$term_list[] = $t_id;
|
||||
} else {
|
||||
$term_list[] = get_term( $t_id, $taxonomy );
|
||||
}
|
||||
}
|
||||
|
||||
$current_id = isset( $has_children[$t_id] ) ? $t_id : 0;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
|
|
Loading…
Reference in New Issue