Page walker fixes from hailin. fixes #5498
git-svn-id: https://develop.svn.wordpress.org/trunk@6456 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
f198d41f1b
commit
5ff262b3da
|
@ -465,33 +465,51 @@ class Walker {
|
|||
|
||||
if ($max_depth < -1) //invalid parameter
|
||||
return $output;
|
||||
|
||||
|
||||
if (empty($elements)) //nothing to walk
|
||||
return $output;
|
||||
|
||||
$id_field = $this->db_fields['id'];
|
||||
$parent_field = $this->db_fields['parent'];
|
||||
|
||||
$flat = ($max_depth == -1) ? true : false;
|
||||
if ( $flat ) {
|
||||
|
||||
// flat display
|
||||
if ( -1 == $max_depth ) {
|
||||
$empty_array = array();
|
||||
foreach ( $elements as $e )
|
||||
$output = $this->display_element( $e, $empty_array, 1, 0, $args, $output );
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* need to display in hierarchical order
|
||||
* splice elements into two buckets: those without parent and those with parent
|
||||
*/
|
||||
|
||||
$top_level_elements = array();
|
||||
$children_elements = array();
|
||||
|
||||
foreach ( $elements as $e) {
|
||||
if ( 0 == $e->$parent_field )
|
||||
$top_level_elements[] = $e;
|
||||
else
|
||||
$children_elements[] = $e;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* none of the elements is top level
|
||||
* the first one must be root of the sub elements
|
||||
*/
|
||||
if ( !$top_level_elements ) {
|
||||
|
||||
$root = $children_elements[0];
|
||||
for ( $i = 0; $i < sizeof( $children_elements ); $i++ ) {
|
||||
|
||||
$child = $children_elements[$i];
|
||||
if ($root->$parent_field == $child->$parent_field )
|
||||
$top_level_elements[] = $child;
|
||||
array_splice( $children_elements, $i, 1 );
|
||||
$i--;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( $top_level_elements as $e )
|
||||
$output = $this->display_element( $e, $children_elements, $max_depth, 0, $args, $output );
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -77,7 +77,7 @@ class WP_Scripts {
|
|||
|
||||
$this->add( 'cropper', '/wp-includes/js/crop/cropper.js', array('scriptaculous-dragdrop'), '20070118');
|
||||
|
||||
$this->add( 'jquery', '/wp-includes/js/jquery/jquery.js', false, '1.1.4');
|
||||
$this->add( 'jquery', '/wp-includes/js/jquery/jquery.js', false, '1.2.2b');
|
||||
$this->add( 'jquery-form', '/wp-includes/js/jquery/jquery.form.js', array('jquery'), '1.0.3');
|
||||
$this->add( 'interface', '/wp-includes/js/jquery/interface.js', array('jquery'), '1.2');
|
||||
|
||||
|
|
Loading…
Reference in New Issue