Make WordPress Core

Changeset 26353


Ignore:
Timestamp:
11/24/2013 02:58:48 PM (10 years ago)
Author:
nacin
Message:

Add echo arguments to wp_list_comments() and Walker_Comment, allowing non-echo usage.

props mikelittle.
fixes #10948.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/comment-template.php

    r25991 r26353  
    15181518                break;
    15191519            case 'ol':
    1520                 echo '<ol class="children">' . "\n";
     1520                $output .= '<ol class="children">' . "\n";
    15211521                break;
    15221522            default:
    15231523            case 'ul':
    1524                 echo '<ul class="children">' . "\n";
     1524                $output .= '<ul class="children">' . "\n";
    15251525                break;
    15261526        }
     
    15451545                break;
    15461546            case 'ol':
    1547                 echo "</ol><!-- .children -->\n";
     1547                $output .= "</ol><!-- .children -->\n";
    15481548                break;
    15491549            default:
    15501550            case 'ul':
    1551                 echo "</ul><!-- .children -->\n";
     1551                $output .= "</ul><!-- .children -->\n";
    15521552                break;
    15531553        }
     
    16241624
    16251625        if ( !empty( $args['callback'] ) ) {
     1626            ob_start();
    16261627            call_user_func( $args['callback'], $comment, $args, $depth );
     1628            $output .= ob_get_clean();
    16271629            return;
    16281630        }
    16291631
    16301632        if ( ( 'pingback' == $comment->comment_type || 'trackback' == $comment->comment_type ) && $args['short_ping'] ) {
     1633            ob_start();
    16311634            $this->ping( $comment, $depth, $args );
     1635            $output .= ob_get_clean();
    16321636        } elseif ( 'html5' === $args['format'] ) {
     1637            ob_start();
    16331638            $this->html5_comment( $comment, $depth, $args );
     1639            $output .= ob_get_clean();
    16341640        } else {
     1641            ob_start();
    16351642            $this->comment( $comment, $depth, $args );
     1643            $output .= ob_get_clean();
    16361644        }
    16371645    }
     
    16511659    function end_el( &$output, $comment, $depth = 0, $args = array() ) {
    16521660        if ( !empty( $args['end-callback'] ) ) {
     1661            ob_start();
    16531662            call_user_func( $args['end-callback'], $comment, $args, $depth );
     1663            $output .= ob_get_clean();
    16541664            return;
    16551665        }
    16561666        if ( 'div' == $args['style'] )
    1657             echo "</div><!-- #comment-## -->\n";
     1667            $output .= "</div><!-- #comment-## -->\n";
    16581668        else
    1659             echo "</li><!-- #comment-## -->\n";
     1669            $output .= "</li><!-- #comment-## -->\n";
    16601670    }
    16611671
     
    18021812 *                                      Default 'html5' if the theme supports it. Accepts 'html5', 'xhtml'.
    18031813 *     @type bool   'short_ping'        Whether to output short pings. Default false.
     1814 *     @type bool   'echo'              Whether to echo the output or return it. Default true.
    18041815 * }
    18051816 * @param array $comments Optional. Array of comment objects. @see WP_Query->comments
     
    18271838        'format'            => current_theme_supports( 'html5', 'comment-list' ) ? 'html5' : 'xhtml',
    18281839        'short_ping'        => false,
     1840        'echo'              => true,
    18291841    );
    18301842
     
    18951907        $walker = new Walker_Comment;
    18961908
    1897     $walker->paged_walk($_comments, $max_depth, $page, $per_page, $r);
     1909    $output = $walker->paged_walk($_comments, $max_depth, $page, $per_page, $r);
    18981910    $wp_query->max_num_comment_pages = $walker->max_pages;
    18991911
    19001912    $in_comment_loop = false;
     1913
     1914    if ( $r['echo'] )
     1915        echo $output;
     1916    else
     1917        return $output;
    19011918}
    19021919
Note: See TracChangeset for help on using the changeset viewer.