Changeset 9092

Show
Ignore:
Timestamp:
10/06/08 23:16:26 (2 months ago)
Author:
ryan
Message:

Add arg to comments_template() for requesting separating comments by type. see #7635

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-includes/comment-template.php

    r9037 r9092  
    727727 * 
    728728 * @param string $file Optional, default '/comments.php'. The file to load 
     729 * @param bool $separate_comments Optional, whether to separate the comments by comment type. Default is false.  
    729730 * @return null Returns null if no comments appear 
    730731 */ 
    731 function comments_template( $file = '/comments.php' ) { 
     732function comments_template( $file = '/comments.php', $separate_comments = false ) { 
    732733    global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity; 
    733734 
    734735    if ( ! (is_single() || is_page() || $withcomments) ) 
    735736        return; 
     737 
     738    if ( empty($file) ) 
     739        $file = '/comments.php'; 
    736740 
    737741    $req = get_option('require_name_email'); 
     
    748752    } 
    749753 
    750     // keep $comments for legacy's sake (remember $table*? ;) ) 
     754    // keep $comments for legacy's sake 
    751755    $wp_query->comments = apply_filters( 'comments_array', $comments, $post->ID ); 
    752756    $comments = &$wp_query->comments; 
    753757    $wp_query->comment_count = count($wp_query->comments); 
    754758    update_comment_cache($wp_query->comments); 
     759 
     760    if ( $separate_comments ) { 
     761        $wp_query->comments_by_type = &separate_comments($comments); 
     762        $comments_by_type = &$wp_query->comments_by_type; 
     763    } 
    755764 
    756765    define('COMMENTS_TEMPLATE', true);