Make WordPress Core

Ticket #5844: 5844_walker_ul.diff

File 5844_walker_ul.diff, 2.5 KB (added by hailin, 17 years ago)

new patch

  • C:/xampp/htdocs/wordpress_trunk/wp-includes/classes.php

     
    409409                if ( !$element)
    410410                        return $output;
    411411
    412                 if ( $max_depth != 0 ) {
    413                         if ($depth >= $max_depth)
    414                                 return $output;
    415                 }
    416 
    417412                $id_field = $this->db_fields['id'];
    418413                $parent_field = $this->db_fields['parent'];
    419414
    420                 if ($depth > 0) {
    421                         //start the child delimiter
    422                         $cb_args = array_merge( array($output, $depth), $args);
    423                         $output = call_user_func_array(array(&$this, 'start_lvl'), $cb_args);
    424                 }
    425 
    426415                //display this element
    427416                $cb_args = array_merge( array($output, $element, $depth), $args);
    428417                $output = call_user_func_array(array(&$this, 'start_el'), $cb_args);
    429418
    430                 for ( $i = 0; $i < sizeof( $children_elements ); $i++ ) {
     419                if ( $max_depth == 0 ||
     420                     ($max_depth != 0 &&  $max_depth > $depth+1 )) { //whether to descend
     421               
     422                        for ( $i = 0; $i < sizeof( $children_elements ); $i++ ) {
     423                               
     424                                $child = $children_elements[$i];
     425                                if ( $child->$parent_field == $element->$id_field ) {
    431426
    432                         $child = $children_elements[$i];
    433                         if ( $child->$parent_field == $element->$id_field ) {
    434 
    435                                 array_splice( $children_elements, $i, 1 );
    436                                 $output = $this->display_element( $child, $children_elements, $max_depth, $depth + 1, $args, $output );
    437                                 $i = -1;
     427                                        if ( !isset($newlevel) ) {
     428                                                $newlevel = true;
     429                                                //start the child delimiter
     430                                                $cb_args = array_merge( array($output, $depth), $args);
     431                                                $output = call_user_func_array(array(&$this, 'start_lvl'), $cb_args);
     432                                        }
     433                               
     434                                        array_splice( $children_elements, $i, 1 );
     435                                        $output = $this->display_element( $child, $children_elements, $max_depth, $depth + 1, $args, $output );
     436                                        $i = -1;
     437                                }
    438438                        }
    439439                }
    440 
    441                 //end this element
    442                 $cb_args = array_merge( array($output, $element, $depth), $args);
    443                 $output = call_user_func_array(array(&$this, 'end_el'), $cb_args);
    444 
    445                 if ($depth > 0) {
     440               
     441                if ( isset($newlevel) && $newlevel ){
    446442                        //end the child delimiter
    447443                        $cb_args = array_merge( array($output, $depth), $args);
    448444                        $output = call_user_func_array(array(&$this, 'end_lvl'), $cb_args);
    449445                }
     446               
     447                //end this element
     448                $cb_args = array_merge( array($output, $element, $depth), $args);
     449                $output = call_user_func_array(array(&$this, 'end_el'), $cb_args);
    450450
    451451                return $output;
    452452        }