Ticket #7147: 7147.diff

File 7147.diff, 2.6 kB (added by DD32, 6 months ago)
  • wp-includes/classes.php

    old new  
    429429                if ( $max_depth == 0 || 
    430430                     ($max_depth != 0 &&  $max_depth > $depth+1 )) { //whether to descend 
    431431 
    432                         for ( $i = 0; $i < sizeof( $children_elements ); $i++ ) { 
     432                        $num_elements = sizeof( $children_elements ); 
     433                        for ( $i = 0; $i < $num_elements; $i++ ) { 
    433434 
    434435                                $child = $children_elements[$i]; 
    435436                                if ( $child->$parent_field == $element->$id_field ) { 
     
    442443                                        } 
    443444 
    444445                                        array_splice( $children_elements, $i, 1 ); 
     446                                        $num_elements--; 
    445447                                        $this->display_element( $child, $children_elements, $max_depth, $depth + 1, $args, $output ); 
    446448                                        $i = -1; 
    447449                                } 
  • wp-includes/taxonomy.php

    old new  
    410410 
    411411        $children = $terms[$term]; 
    412412 
    413         foreach ( $terms[$term] as $child ) { 
     413        foreach ( $terms[$term] as $child ) 
    414414                if ( isset($terms[$child]) ) 
    415415                        $children = array_merge($children, get_term_children($child, $taxonomy)); 
    416         } 
    417416 
    418417        return $children; 
    419418} 
     
    17811780 
    17821781        $children = array(); 
    17831782        $terms = get_terms($taxonomy, 'get=all'); 
    1784         foreach ( $terms as $term ) { 
     1783        foreach ( $terms as $term ) 
    17851784                if ( $term->parent > 0 ) 
    17861785                        $children[$term->parent][] = $term->term_id; 
    1787         } 
    17881786        update_option("{$taxonomy}_children", $children); 
    1789  
    17901787        return $children; 
    17911788} 
    17921789 
     
    18071804 * @return array Empty if $terms is empty else returns full list of child terms. 
    18081805 */ 
    18091806function &_get_term_children($term_id, $terms, $taxonomy) { 
    1810         $empty_array = array(); 
    18111807        if ( empty($terms) ) 
    1812                 return $empty_array
     1808                return array()
    18131809 
    1814         $term_list = array(); 
    18151810        $has_children = _get_term_hierarchy($taxonomy); 
    18161811 
    18171812        if  ( ( 0 != $term_id ) && ! isset($has_children[$term_id]) ) 
    1818                 return $empty_array
     1813                return array()
    18191814 
     1815        $term_list = array(); 
     1816 
    18201817        foreach ( $terms as $term ) { 
    18211818                $use_id = false; 
    18221819                if ( !is_object($term) ) { 
     
    18301827                        continue; 
    18311828 
    18321829                if ( $term->parent == $term_id ) { 
    1833                         if ( $use_id ) 
    1834                                 $term_list[] = $term->term_id; 
    1835                         else 
    1836                                 $term_list[] = $term; 
     1830                        $term_list[] = $use_id ? $term->term_id : $term; 
    18371831 
    18381832                        if ( !isset($has_children[$term->term_id]) ) 
    18391833                                continue; 
    18401834 
    1841                         if ( $children = _get_term_children($term->term_id, $terms, $taxonomy) ) 
     1835                        if ( $children = _get_term_children($term->term_id, &$terms, $taxonomy) ) 
    18421836                                $term_list = array_merge($term_list, $children); 
    18431837                } 
    18441838        }