Ticket #6796: 6796.diff

File 6796.diff, 8.9 kB (added by mdawaffe, 7 months ago)
  • wp-includes/classes.php

    old new  
    395395        var $db_fields; 
    396396 
    397397        //abstract callbacks 
    398         function start_lvl($output) { return $output;
    399         function end_lvl($output)   { return $output;
    400         function start_el($output)  { return $output;
    401         function end_el($output)    { return $output;
     398        function start_lvl(&$output) {
     399        function end_lvl(&$output)   {
     400        function start_el(&$output)  {
     401        function end_el(&$output)    {
    402402 
    403403        /* 
    404404         * display one element if the element doesn't have any children 
    405405         * otherwise, display the element and its children 
    406406         */ 
    407         function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, $output ) { 
     407        function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, &$output ) { 
    408408 
    409                 if ( !$element
    410                         return $output
     409                if ( !$element 
     410                        return
    411411 
    412412                $id_field = $this->db_fields['id']; 
    413413                $parent_field = $this->db_fields['parent']; 
    414414 
    415415                //display this element 
    416                 $cb_args = array_merge( array($output, $element, $depth), $args); 
    417                 $output = call_user_func_array(array(&$this, 'start_el'), $cb_args); 
     416                $cb_args = array_merge( array(&$output, $element, $depth), $args); 
     417                call_user_func_array(array(&$this, 'start_el'), $cb_args); 
    418418 
    419419                if ( $max_depth == 0 || 
    420420                     ($max_depth != 0 &&  $max_depth > $depth+1 )) { //whether to descend 
     
    427427                                        if ( !isset($newlevel) ) { 
    428428                                                $newlevel = true; 
    429429                                                //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); 
     430                                                $cb_args = array_merge( array(&$output, $depth), $args); 
     431                                                call_user_func_array(array(&$this, 'start_lvl'), $cb_args); 
    432432                                        } 
    433433 
    434434                                        array_splice( $children_elements, $i, 1 ); 
    435                                         $output = $this->display_element( $child, $children_elements, $max_depth, $depth + 1, $args, $output ); 
     435                                        $this->display_element( $child, $children_elements, $max_depth, $depth + 1, $args, $output ); 
    436436                                        $i = -1; 
    437437                                } 
    438438                        } 
     
    440440 
    441441                if ( isset($newlevel) && $newlevel ){ 
    442442                        //end the child delimiter 
    443                         $cb_args = array_merge( array($output, $depth), $args); 
    444                         $output = call_user_func_array(array(&$this, 'end_lvl'), $cb_args); 
     443                        $cb_args = array_merge( array(&$output, $depth), $args); 
     444                        call_user_func_array(array(&$this, 'end_lvl'), $cb_args); 
    445445                } 
    446446 
    447447                //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); 
    450  
    451                 return $output; 
     448                $cb_args = array_merge( array(&$output, $element, $depth), $args); 
     449                call_user_func_array(array(&$this, 'end_el'), $cb_args); 
    452450        } 
    453451 
    454452        /* 
     
    476474                if ( -1 == $max_depth ) { 
    477475                        $empty_array = array(); 
    478476                        foreach ( $elements as $e ) 
    479                                 $output = $this->display_element( $e, $empty_array, 1, 0, $args, $output ); 
     477                                $this->display_element( $e, $empty_array, 1, 0, $args, $output ); 
    480478                        return $output; 
    481479                } 
    482480 
     
    512510                } 
    513511 
    514512                foreach ( $top_level_elements as $e ) 
    515                         $output = $this->display_element( $e, $children_elements, $max_depth, 0, $args, $output ); 
     513                        $this->display_element( $e, $children_elements, $max_depth, 0, $args, $output ); 
    516514 
    517515                /* 
    518516                * if we are displaying all levels, and remaining children_elements is not empty, 
     
    521519                if ( ( $max_depth == 0 ) && sizeof( $children_elements ) > 0 ) { 
    522520                        $empty_array = array(); 
    523521                        foreach ( $children_elements as $orphan_e ) 
    524                                 $output = $this->display_element( $orphan_e, $empty_array, 1, 0, $args, $output ); 
     522                                $this->display_element( $orphan_e, $empty_array, 1, 0, $args, $output ); 
    525523                 } 
    526524                 return $output; 
    527525        } 
     
    531529        var $tree_type = 'page'; 
    532530        var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID'); //TODO: decouple this 
    533531 
    534         function start_lvl($output, $depth) { 
     532        function start_lvl(&$output, $depth) { 
    535533                $indent = str_repeat("\t", $depth); 
    536534                $output .= "\n$indent<ul>\n"; 
    537                 return $output; 
    538535        } 
    539536 
    540         function end_lvl($output, $depth) { 
     537        function end_lvl(&$output, $depth) { 
    541538                $indent = str_repeat("\t", $depth); 
    542539                $output .= "$indent</ul>\n"; 
    543                 return $output; 
    544540        } 
    545541 
    546         function start_el($output, $page, $depth, $current_page, $args) { 
     542        function start_el(&$output, $page, $depth, $current_page, $args) { 
    547543                if ( $depth ) 
    548544                        $indent = str_repeat("\t", $depth); 
    549545                else 
     
    571567 
    572568                        $output .= " " . mysql2date($date_format, $time); 
    573569                } 
    574  
    575                 return $output; 
    576570        } 
    577571 
    578         function end_el($output, $page, $depth) { 
     572        function end_el(&$output, $page, $depth) { 
    579573                $output .= "</li>\n"; 
    580  
    581                 return $output; 
    582574        } 
    583575 
    584576} 
     
    587579        var $tree_type = 'page'; 
    588580        var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID'); //TODO: decouple this 
    589581 
    590         function start_el($output, $page, $depth, $args) { 
    591                                $pad = str_repeat('&nbsp;', $depth * 3); 
     582        function start_el(&$output, $page, $depth, $args) { 
     583                $pad = str_repeat('&nbsp;', $depth * 3); 
    592584 
    593                                 $output .= "\t<option value=\"$page->ID\""; 
    594                                 if ( $page->ID == $args['selected'] ) 
    595                                                                 $output .= ' selected="selected"'; 
    596                                 $output .= '>'; 
    597                                 $title = wp_specialchars($page->post_title); 
    598                                 $output .= "$pad$title"; 
    599                                 $output .= "</option>\n"; 
    600  
    601                                 return $output; 
     585                $output .= "\t<option value=\"$page->ID\""; 
     586                if ( $page->ID == $args['selected'] ) 
     587                        $output .= ' selected="selected"'; 
     588                $output .= '>'; 
     589                $title = wp_specialchars($page->post_title); 
     590                $output .= "$pad$title"; 
     591                $output .= "</option>\n"; 
    602592        } 
    603593} 
    604594 
     
    606596        var $tree_type = 'category'; 
    607597        var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this 
    608598 
    609         function start_lvl($output, $depth, $args) { 
     599        function start_lvl(&$output, $depth, $args) { 
    610600                if ( 'list' != $args['style'] ) 
    611                         return $output
     601                        return
    612602 
    613603                $indent = str_repeat("\t", $depth); 
    614604                $output .= "$indent<ul class='children'>\n"; 
    615                 return $output; 
    616605        } 
    617606 
    618         function end_lvl($output, $depth, $args) { 
     607        function end_lvl(&$output, $depth, $args) { 
    619608                if ( 'list' != $args['style'] ) 
    620                         return $output
     609                        return
    621610 
    622611                $indent = str_repeat("\t", $depth); 
    623612                $output .= "$indent</ul>\n"; 
    624                 return $output; 
    625613        } 
    626614 
    627         function start_el($output, $category, $depth, $args) { 
     615        function start_el(&$output, $category, $depth, $args) { 
    628616                extract($args); 
    629617 
    630618                $cat_name = attribute_escape( $category->name); 
     
    687675                } else { 
    688676                        $output .= "\t$link<br />\n"; 
    689677                } 
    690  
    691                 return $output; 
    692678        } 
    693679 
    694         function end_el($output, $page, $depth, $args) { 
     680        function end_el(&$output, $page, $depth, $args) { 
    695681                if ( 'list' != $args['style'] ) 
    696                         return $output
     682                        return
    697683 
    698684                $output .= "</li>\n"; 
    699                 return $output; 
    700685        } 
    701686 
    702687} 
     
    705690        var $tree_type = 'category'; 
    706691        var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this 
    707692 
    708         function start_el($output, $category, $depth, $args) { 
     693        function start_el(&$output, $category, $depth, $args) { 
    709694                $pad = str_repeat('&nbsp;', $depth * 3); 
    710695 
    711696                $cat_name = apply_filters('list_cats', $category->name, $category); 
     
    721706                        $output .= '&nbsp;&nbsp;' . gmdate($format, $category->last_update_timestamp); 
    722707                } 
    723708                $output .= "</option>\n"; 
    724  
    725                 return $output; 
    726709        } 
    727710} 
    728711 
  • wp-admin/includes/template.php

    old new  
    126126        var $tree_type = 'category'; 
    127127        var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this 
    128128 
    129         function start_lvl($output, $depth, $args) { 
     129        function start_lvl(&$output, $depth, $args) { 
    130130                $indent = str_repeat("\t", $depth); 
    131131                $output .= "$indent<ul class='children'>\n"; 
    132                 return $output; 
    133132        } 
    134133 
    135         function end_lvl($output, $depth, $args) { 
     134        function end_lvl(&$output, $depth, $args) { 
    136135                $indent = str_repeat("\t", $depth); 
    137136                $output .= "$indent</ul>\n"; 
    138                 return $output; 
    139137        } 
    140138 
    141         function start_el($output, $category, $depth, $args) { 
     139        function start_el(&$output, $category, $depth, $args) { 
    142140                extract($args); 
    143141 
    144142                $class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : ''; 
    145143                $output .= "\n<li id='category-$category->term_id'$class>" . '<label for="in-category-' . $category->term_id . '" class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="post_category[]" id="in-category-' . $category->term_id . '"' . (in_array( $category->term_id, $selected_cats ) ? ' checked="checked"' : "" ) . '/> ' . wp_specialchars( apply_filters('the_category', $category->name )) . '</label>'; 
    146  
    147                 return $output; 
    148144        } 
    149145 
    150         function end_el($output, $category, $depth, $args) { 
    151                 if ( 'list' != $args['style'] ) 
    152                         return $output; 
    153  
     146        function end_el(&$output, $category, $depth, $args) { 
    154147                $output .= "</li>\n"; 
    155                 return $output; 
    156148        } 
    157149} 
    158150