mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-11 02:49:04 +01:00
Fix depth = 1 page traversal. Props hailin. fixes #5469
git-svn-id: http://svn.automattic.com/wordpress/trunk@6388 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
29ef8b6f5f
commit
28f0d5bf06
@ -417,41 +417,43 @@ class Walker {
|
|||||||
$id_field = $this->db_fields['id'];
|
$id_field = $this->db_fields['id'];
|
||||||
$parent_field = $this->db_fields['parent'];
|
$parent_field = $this->db_fields['parent'];
|
||||||
|
|
||||||
|
if ($depth > 0) {
|
||||||
|
//start the child delimiter
|
||||||
|
$cb_args = array_merge( array($output, $depth), $args);
|
||||||
|
$output = call_user_func_array(array(&$this, 'start_lvl'), $cb_args);
|
||||||
|
}
|
||||||
|
|
||||||
//display this element
|
//display this element
|
||||||
$cb_args = array_merge( array($output, $element, $depth), $args);
|
$cb_args = array_merge( array($output, $element, $depth), $args);
|
||||||
$output = call_user_func_array(array(&$this, 'start_el'), $cb_args);
|
$output = call_user_func_array(array(&$this, 'start_el'), $cb_args);
|
||||||
|
|
||||||
if ( !$children_elements ) {
|
|
||||||
//close off this element
|
|
||||||
$cb_args = array_merge( array($output, $element, $depth), $args);
|
|
||||||
$output = call_user_func_array(array(&$this, 'end_el'), $cb_args);
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
|
|
||||||
for ( $i = 0; $i < sizeof( $children_elements ); $i++ ) {
|
for ( $i = 0; $i < sizeof( $children_elements ); $i++ ) {
|
||||||
$child = $children_elements[$i];
|
|
||||||
|
|
||||||
|
$child = $children_elements[$i];
|
||||||
if ( $child->$parent_field == $element->$id_field ) {
|
if ( $child->$parent_field == $element->$id_field ) {
|
||||||
|
|
||||||
array_splice( $children_elements, $i, 1 );
|
array_splice( $children_elements, $i, 1 );
|
||||||
|
|
||||||
//start the child delimiter
|
|
||||||
$cb_args = array_merge( array($output, $depth), $args);
|
|
||||||
$output = call_user_func_array(array(&$this, 'start_lvl'), $cb_args);
|
|
||||||
|
|
||||||
$output = $this->display_element( $child, $children_elements, $max_depth, $depth + 1, $args, $output );
|
$output = $this->display_element( $child, $children_elements, $max_depth, $depth + 1, $args, $output );
|
||||||
|
|
||||||
//end the child delimiter
|
|
||||||
$cb_args = array_merge( array($output, $depth), $args);
|
|
||||||
$output = call_user_func_array(array(&$this, 'end_lvl'), $cb_args);
|
|
||||||
$i--;
|
$i--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//end this element
|
||||||
|
$cb_args = array_merge( array($output, $element, $depth), $args);
|
||||||
|
$output = call_user_func_array(array(&$this, 'end_el'), $cb_args);
|
||||||
|
|
||||||
|
if ($depth > 0) {
|
||||||
|
//end the child delimiter
|
||||||
|
$cb_args = array_merge( array($output, $depth), $args);
|
||||||
|
$output = call_user_func_array(array(&$this, 'end_lvl'), $cb_args);
|
||||||
|
}
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* displays array of elements hierarchically
|
* displays array of elements hierarchically
|
||||||
|
* it is a generic function which does not assume any existing order of elements
|
||||||
* max_depth = -1 means flatly display every element
|
* max_depth = -1 means flatly display every element
|
||||||
* max_depth = 0 means display all levels
|
* max_depth = 0 means display all levels
|
||||||
* max_depth > 0 specifies the number of display levels.
|
* max_depth > 0 specifies the number of display levels.
|
||||||
@ -461,6 +463,9 @@ class Walker {
|
|||||||
$args = array_slice(func_get_args(), 2);
|
$args = array_slice(func_get_args(), 2);
|
||||||
$output = '';
|
$output = '';
|
||||||
|
|
||||||
|
if ($max_depth < -1) //invalid parameter
|
||||||
|
return $output;
|
||||||
|
|
||||||
$id_field = $this->db_fields['id'];
|
$id_field = $this->db_fields['id'];
|
||||||
$parent_field = $this->db_fields['parent'];
|
$parent_field = $this->db_fields['parent'];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user