Walker fix ups. fixes #3080

git-svn-id: https://develop.svn.wordpress.org/trunk@4779 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2007-01-22 07:05:48 +00:00
parent e8e964482d
commit 81ccfa17f6

View File

@ -428,14 +428,14 @@ class Walker {
if ( !empty($previous_element) && ($element->$parent_field == $previous_element->$id_field) ) { if ( !empty($previous_element) && ($element->$parent_field == $previous_element->$id_field) ) {
// Previous element is my parent. Descend a level. // Previous element is my parent. Descend a level.
array_unshift($parents, $previous_element); array_unshift($parents, $previous_element);
$depth++; //always do this so when we start the element further down, we know where we are
if ( !$to_depth || ($depth < $to_depth) ) { //only descend if we're below $to_depth if ( !$to_depth || ($depth < $to_depth) ) { //only descend if we're below $to_depth
$cb_args = array_merge( array($output, $depth - 1), $args); $cb_args = array_merge( array($output, $depth), $args);
$output = call_user_func_array(array(&$this, 'start_lvl'), $cb_args); $output = call_user_func_array(array(&$this, 'start_lvl'), $cb_args);
} else { // If we've reached depth, end the previous element. } else if ( $to_depth && $depth == $to_depth ) { // If we've reached depth, end the previous element.
$cb_args = array_merge( array($output, $previous_element, $depth - 1), $args); $cb_args = array_merge( array($output, $previous_element, $depth), $args);
$output = call_user_func_array(array(&$this, 'end_el'), $cb_args); $output = call_user_func_array(array(&$this, 'end_el'), $cb_args);
} }
$depth++; //always do this so when we start the element further down, we know where we are
} else if ( $element->$parent_field == $previous_element->$parent_field) { } else if ( $element->$parent_field == $previous_element->$parent_field) {
// On the same level as previous element. // On the same level as previous element.
if ( !$to_depth || ($depth <= $to_depth) ) { if ( !$to_depth || ($depth <= $to_depth) ) {
@ -452,7 +452,7 @@ class Walker {
while ( $parent = array_shift($parents) ) { while ( $parent = array_shift($parents) ) {
$depth--; $depth--;
if ( !$to_depth || ($depth < $to_depth) ) { if ( !$to_depth || ($depth < $to_depth) ) {
$cb_args = array_merge( array($output, $depth - 1), $args); $cb_args = array_merge( array($output, $depth), $args);
$output = call_user_func_array(array(&$this, 'end_lvl'), $cb_args); $output = call_user_func_array(array(&$this, 'end_lvl'), $cb_args);
$cb_args = array_merge( array($output, $parent, $depth - 1), $args); $cb_args = array_merge( array($output, $parent, $depth - 1), $args);
$output = call_user_func_array(array(&$this, 'end_el'), $cb_args); $output = call_user_func_array(array(&$this, 'end_el'), $cb_args);
@ -490,7 +490,7 @@ class Walker_Page extends Walker {
function start_lvl($output, $depth) { function start_lvl($output, $depth) {
$indent = str_repeat("\t", $depth); $indent = str_repeat("\t", $depth);
$output .= "$indent<ul>\n"; $output .= "\n$indent<ul>\n";
return $output; return $output;
} }