Make WordPress Core

Ticket #14041: has_children.diff

File has_children.diff, 2.1 KB (added by scribu, 13 years ago)

Set flag on Walker object

  • wp-includes/comment-template.php

     
    13201320                        $add_below = 'div-comment';
    13211321                }
    13221322?>
    1323                 <<?php echo $tag ?> <?php comment_class(empty( $args['has_children'] ) ? '' : 'parent') ?> id="comment-<?php comment_ID() ?>">
     1323                <<?php echo $tag ?> <?php comment_class( $this->has_children ? '' : 'parent' ) ?> id="comment-<?php comment_ID() ?>">
    13241324                <?php if ( 'div' != $args['style'] ) : ?>
    13251325                <div id="div-comment-<?php comment_ID() ?>" class="comment-body">
    13261326                <?php endif; ?>
  • wp-includes/classes.php

     
    768768        var $max_pages = 1;
    769769
    770770        /**
     771         * Wether the current element has children or not. To be used in start_el()
     772         *
     773         * @since 3.1.0
     774         * @var bool
     775         * @access protected
     776         */
     777        var $has_children;
     778
     779        /**
    771780         * Starts the list before the elements are added.
    772781         *
    773782         * Additional parameters are used in child classes. The args parameter holds
     
    849858
    850859                $id_field = $this->db_fields['id'];
    851860
     861                $id = $element->$id_field;
     862
    852863                //display this element
     864                $this->has_children = !empty( $children_elements[ $id ] );
    853865                if ( is_array( $args[0] ) )
    854                         $args[0]['has_children'] = ! empty( $children_elements[$element->$id_field] );
     866                        $args[0]['has_children'] = $this->has_children; // backwards compatibility
     867
    855868                $cb_args = array_merge( array(&$output, $element, $depth), $args);
    856869                call_user_func_array(array(&$this, 'start_el'), $cb_args);
    857870
    858                 $id = $element->$id_field;
    859 
    860871                // descend only when the depth is right and there are childrens for this element
    861                 if ( ($max_depth == 0 || $max_depth > $depth+1 ) && isset( $children_elements[$id]) ) {
     872                if ( ( $max_depth == 0 || $max_depth > $depth+1 ) && $this->has_children ) {
    862873
    863                         foreach( $children_elements[ $id ] as $child ){
     874                        foreach ( $children_elements[ $id ] as $child ) {
    864875
    865876                                if ( !isset($newlevel) ) {
    866877                                        $newlevel = true;