Ticket #19623: comment-template-api.diff
File comment-template-api.diff, 2.9 KB (added by , 13 years ago) |
---|
-
wp-includes/comment-template.php
883 883 884 884 /** @todo Use API instead of SELECTs. */ 885 885 if ( $user_ID) { 886 $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND (comment_approved = '1' OR ( user_id = %d AND comment_approved = '0' ) ) ORDER BY comment_date_gmt", $post->ID, $user_ID));886 $comments = get_comments( array('post_id' => $post->ID, 'unapproved_comment_author_user_id' => $user_ID, 'order' => 'ASC') ); 887 887 } else if ( empty($comment_author) ) { 888 888 $comments = get_comments( array('post_id' => $post->ID, 'status' => 'approve', 'order' => 'ASC') ); 889 889 } else { 890 $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_gmt", $post->ID, wp_specialchars_decode($comment_author,ENT_QUOTES), $comment_author_email));890 $comments = get_comments( array('post_id' => $post->ID, 'unapproved_comment_author_data' => array( 'comment_author' => wp_specialchars_decode($comment_author,ENT_QUOTES), 'comment_author_email' => $comment_author_email ), 'order' => 'ASC') ); 891 891 } 892 892 893 893 // keep $comments for legacy's sake -
wp-includes/comment.php
252 252 $approved = "comment_approved = 'spam'"; 253 253 elseif ( 'trash' == $status ) 254 254 $approved = "comment_approved = 'trash'"; 255 elseif ( 0 < $unapproved_comment_author_user_id ) //show unapproved comments to the current user if they're the author 256 $approved = sprintf( "( ( user_id = %d AND comment_approved = '0' ) OR comment_approved = '1' )", $unapproved_comment_author_user_id ); 257 elseif ( is_array($unapproved_comment_author_data) && ! empty($unapproved_comment_author_data) && ! empty( $unapproved_comment_author_data['comment_author'] ) && ! empty( $unapproved_comment_author_data['comment_author_email'] ) ) //use the cookie system for current commenter 258 $approved = sprintf( "( ( comment_author = '%1s' AND comment_author_email = '%2s' AND comment_approved = '0' ) OR comment_approved = '1' )", $unapproved_comment_author_data['comment_author'], $unapproved_comment_author_data['comment_author_email'] ); 255 259 else 256 260 $approved = "( comment_approved = '0' OR comment_approved = '1' )";