Ticket #7635: separate_comments.diff
| File separate_comments.diff, 1.9 KB (added by ryan, 3 years ago) |
|---|
-
wp-includes/comment-template.php
726 726 * @uses $withcomments Will not try to get the comments if the post has none. 727 727 * 728 728 * @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. 729 730 * @return null Returns null if no comments appear 730 731 */ 731 function comments_template( $file = '/comments.php' ) {732 function comments_template( $file = '/comments.php', $separate_comments = false ) { 732 733 global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity; 733 734 734 735 if ( ! (is_single() || is_page() || $withcomments) ) 735 736 return; 736 737 738 if ( empty($file) ) 739 $file = '/comments.php'; 740 737 741 $req = get_option('require_name_email'); 738 742 $commenter = wp_get_current_commenter(); 739 743 extract($commenter, EXTR_SKIP); … … 747 751 $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)); 748 752 } 749 753 750 // keep $comments for legacy's sake (remember $table*? ;) )754 // keep $comments for legacy's sake 751 755 $wp_query->comments = apply_filters( 'comments_array', $comments, $post->ID ); 752 756 $comments = &$wp_query->comments; 753 757 $wp_query->comment_count = count($wp_query->comments); 754 758 update_comment_cache($wp_query->comments); 755 759 760 if ( $separate_comments ) { 761 $wp_query->comments_by_type = &separate_comments($comments); 762 $comments_by_type = &$wp_query->comments_by_type; 763 } 764 756 765 define('COMMENTS_TEMPLATE', true); 757 766 758 767 $include = apply_filters('comments_template', STYLESHEETPATH . $file );
