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

git-svn-id: http://svn.automattic.com/wordpress/trunk@9092 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-10-06 23:16:26 +00:00
parent c75149c03d
commit 69f373ec0c
1 changed files with 11 additions and 2 deletions

View File

@ -726,14 +726,18 @@ function wp_comment_form_unfiltered_html_nonce() {
* @uses $withcomments Will not try to get the comments if the post has none.
*
* @param string $file Optional, default '/comments.php'. The file to load
* @param bool $separate_comments Optional, whether to separate the comments by comment type. Default is false.
* @return null Returns null if no comments appear
*/
function comments_template( $file = '/comments.php' ) {
function comments_template( $file = '/comments.php', $separate_comments = false ) {
global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity;
if ( ! (is_single() || is_page() || $withcomments) )
return;
if ( empty($file) )
$file = '/comments.php';
$req = get_option('require_name_email');
$commenter = wp_get_current_commenter();
extract($commenter, EXTR_SKIP);
@ -747,12 +751,17 @@ function comments_template( $file = '/comments.php' ) {
$comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND ( comment_approved = '1' OR ( comment_author = %s AND comment_author_email = %s AND comment_approved = '0' ) ) ORDER BY comment_date", $post->ID, $comment_author, $comment_author_email));
}
// keep $comments for legacy's sake (remember $table*? ;) )
// keep $comments for legacy's sake
$wp_query->comments = apply_filters( 'comments_array', $comments, $post->ID );
$comments = &$wp_query->comments;
$wp_query->comment_count = count($wp_query->comments);
update_comment_cache($wp_query->comments);
if ( $separate_comments ) {
$wp_query->comments_by_type = &separate_comments($comments);
$comments_by_type = &$wp_query->comments_by_type;
}
define('COMMENTS_TEMPLATE', true);
$include = apply_filters('comments_template', STYLESHEETPATH . $file );