Ticket #7147: 7147.diff
File 7147.diff, 2.6 KB (added by , 16 years ago) |
---|
-
wp-includes/classes.php
429 429 if ( $max_depth == 0 || 430 430 ($max_depth != 0 && $max_depth > $depth+1 )) { //whether to descend 431 431 432 for ( $i = 0; $i < sizeof( $children_elements ); $i++ ) { 432 $num_elements = sizeof( $children_elements ); 433 for ( $i = 0; $i < $num_elements; $i++ ) { 433 434 434 435 $child = $children_elements[$i]; 435 436 if ( $child->$parent_field == $element->$id_field ) { … … 442 443 } 443 444 444 445 array_splice( $children_elements, $i, 1 ); 446 $num_elements--; 445 447 $this->display_element( $child, $children_elements, $max_depth, $depth + 1, $args, $output ); 446 448 $i = -1; 447 449 } -
wp-includes/taxonomy.php
410 410 411 411 $children = $terms[$term]; 412 412 413 foreach ( $terms[$term] as $child ) {413 foreach ( $terms[$term] as $child ) 414 414 if ( isset($terms[$child]) ) 415 415 $children = array_merge($children, get_term_children($child, $taxonomy)); 416 }417 416 418 417 return $children; 419 418 } … … 1781 1780 1782 1781 $children = array(); 1783 1782 $terms = get_terms($taxonomy, 'get=all'); 1784 foreach ( $terms as $term ) {1783 foreach ( $terms as $term ) 1785 1784 if ( $term->parent > 0 ) 1786 1785 $children[$term->parent][] = $term->term_id; 1787 }1788 1786 update_option("{$taxonomy}_children", $children); 1789 1790 1787 return $children; 1791 1788 } 1792 1789 … … 1807 1804 * @return array Empty if $terms is empty else returns full list of child terms. 1808 1805 */ 1809 1806 function &_get_term_children($term_id, $terms, $taxonomy) { 1810 $empty_array = array();1811 1807 if ( empty($terms) ) 1812 return $empty_array;1808 return array(); 1813 1809 1814 $term_list = array();1815 1810 $has_children = _get_term_hierarchy($taxonomy); 1816 1811 1817 1812 if ( ( 0 != $term_id ) && ! isset($has_children[$term_id]) ) 1818 return $empty_array;1813 return array(); 1819 1814 1815 $term_list = array(); 1816 1820 1817 foreach ( $terms as $term ) { 1821 1818 $use_id = false; 1822 1819 if ( !is_object($term) ) { … … 1830 1827 continue; 1831 1828 1832 1829 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; 1837 1831 1838 1832 if ( !isset($has_children[$term->term_id]) ) 1839 1833 continue; 1840 1834 1841 if ( $children = _get_term_children($term->term_id, $terms, $taxonomy) )1835 if ( $children = _get_term_children($term->term_id, &$terms, $taxonomy) ) 1842 1836 $term_list = array_merge($term_list, $children); 1843 1837 } 1844 1838 }