Ticket #2608: 2608.diff
| File 2608.diff, 3.7 KB (added by , 21 years ago) |
|---|
-
wp-includes/template-functions-post.php
427 427 428 428 global $wp_query; 429 429 $current_page = $wp_query->get_queried_object_id(); 430 $output .= walk_page_tree($pages, $ depth, '_page_list_element_start', '_page_list_element_end', '_page_list_level_start', '_page_list_level_end', $current_page, $r['show_date'], $r['date_format']);430 $output .= walk_page_tree($pages, $r['depth'], '_page_list_element_start', '_page_list_element_end', '_page_list_level_start', '_page_list_level_end', $current_page, $r['show_date'], $r['date_format']); 431 431 432 432 if ( $r['title_li'] ) 433 433 $output .= '</ul></li>'; -
wp-includes/functions.php
708 708 function walk_tree($tree_type, $elements, $to_depth, $start_element_callback, $end_element_callback = '', $start_level_callback = '', $end_level_callback = '') { 709 709 $args = array_slice(func_get_args(), 7); 710 710 $parents = array(); 711 $depth = 0;711 $depth = 1; //1 is top level 712 712 $previous_element = ''; 713 713 $output = ''; 714 714 … … 749 749 // Walk the tree. 750 750 if ( !empty($previous_element) && ($element->$parent_field == $previous_element->$id_field) ) { 751 751 // Previous element is my parent. Descend a level. 752 $depth++; //always do this so when we start the element further down, we know where we are 752 753 array_unshift($parents, $previous_element); 753 $depth++; 754 if ( !$to_depth || ($depth < $to_depth) ) 754 if ( !$to_depth || ($depth < $to_depth) ) { //only descend if we're below $to_depth 755 755 if ( !empty($start_level_callback) ) { 756 756 $cb_args = array_merge( array($output, $depth), $args); 757 757 $output = call_user_func_array($start_level_callback, $cb_args); 758 758 } 759 } else if ( $depth && ($element->$parent_field == $previous_element->$parent_field) ) { 760 // On the same level as previous element. 761 if ( !$to_depth || ($depth < $to_depth) ) { 759 } 760 } else if ( $element->$parent_field == $previous_element->$parent_field ) { 761 // On the same level as previous element, so close the previous 762 if ( !$to_depth || ($depth <= $to_depth) ) { 762 763 if ( !empty($end_element_callback) ) { 763 764 $cb_args = array_merge( array($output, $previous_element, $depth), $args); 764 765 $output = call_user_func_array($end_element_callback, $cb_args); 765 766 } 766 767 } 767 } else if ( $depth ) {768 } else if ( $depth > 1 ) { 768 769 // Ascend one or more levels. 769 if ( !$to_depth || ($depth < $to_depth) ) {770 if ( !$to_depth || ($depth <= $to_depth) ) { 770 771 if ( !empty($end_element_callback) ) { 771 772 $cb_args = array_merge( array($output, $previous_element, $depth), $args); 772 773 $output = call_user_func_array($end_element_callback, $cb_args); … … 791 792 } 792 793 } else if ( !empty($previous_element) ) { 793 794 // Close off previous element. 794 if ( !$to_depth || ($depth < $to_depth) ) {795 if ( !$to_depth || ($depth <= $to_depth) ) { 795 796 if ( !empty($end_element_callback) ) { 796 797 $cb_args = array_merge( array($output, $previous_element, $depth), $args); 797 798 $output = call_user_func_array($end_element_callback, $cb_args); … … 800 801 } 801 802 802 803 // Start the element. 803 if ( !$to_depth || ($depth < $to_depth) ) {804 if ( !$to_depth || ($depth <= $to_depth) ) { 804 805 if ( !empty($start_element_callback) && ($element->$id_field != 0) ) { 805 806 $cb_args = array_merge( array($output, $element, $depth), $args); 806 807 $output = call_user_func_array($start_element_callback, $cb_args);
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)