diff --git src/wp-includes/taxonomy.php src/wp-includes/taxonomy.php
index 7ce4093..619eb57 100644
|
|
function _get_term_hierarchy($taxonomy) { |
3926 | 3926 | * @param string $taxonomy The taxonomy which determines the hierarchy of the terms. |
3927 | 3927 | * @param array $ancestors Term ancestors that have already been identified. Passed by reference, to keep track of |
3928 | 3928 | * found terms when recursing the hierarchy. The array of located ancestors is used to prevent |
3929 | | * infinite recursion loops. |
| 3929 | * infinite recursion loops. For performance, term_ids are used as array keys, with 1 as value. |
3930 | 3930 | * @return array The subset of $terms that are descendants of $term_id. |
3931 | 3931 | */ |
3932 | 3932 | function _get_term_children( $term_id, $terms, $taxonomy, &$ancestors = array() ) { |
… |
… |
function _get_term_children( $term_id, $terms, $taxonomy, &$ancestors = array() |
3942 | 3942 | |
3943 | 3943 | // Include the term itself in the ancestors array, so we can properly detect when a loop has occurred. |
3944 | 3944 | if ( empty( $ancestors ) ) { |
3945 | | $ancestors[] = $term_id; |
| 3945 | $ancestors[ $term_id ] = 1; |
3946 | 3946 | } |
3947 | 3947 | |
3948 | 3948 | foreach ( (array) $terms as $term ) { |
… |
… |
function _get_term_children( $term_id, $terms, $taxonomy, &$ancestors = array() |
3955 | 3955 | } |
3956 | 3956 | |
3957 | 3957 | // Don't recurse if we've already identified the term as a child - this indicates a loop. |
3958 | | if ( in_array( $term->term_id, $ancestors ) ) { |
| 3958 | if ( isset( $ancestors[ $term->term_id ] ) ) { |
3959 | 3959 | continue; |
3960 | 3960 | } |
3961 | 3961 | |
… |
… |
function _get_term_children( $term_id, $terms, $taxonomy, &$ancestors = array() |
3968 | 3968 | if ( !isset($has_children[$term->term_id]) ) |
3969 | 3969 | continue; |
3970 | 3970 | |
3971 | | if ( $use_id ) { |
3972 | | $ancestors = array_merge( $ancestors, $term_list ); |
3973 | | } else { |
3974 | | $ancestors = array_merge( $ancestors, wp_list_pluck( $term_list, 'term_id' ) ); |
3975 | | } |
| 3971 | $ancestors[ $term->term_id ] = 1;; |
3976 | 3972 | |
3977 | 3973 | if ( $children = _get_term_children( $term->term_id, $terms, $taxonomy, $ancestors) ) |
3978 | 3974 | $term_list = array_merge($term_list, $children); |