Ticket #19623: 19623.3.diff
File 19623.3.diff, 3.6 KB (added by , 11 years ago) |
---|
-
wp-includes/comment-template.php
1101 1101 */ 1102 1102 $comment_author_url = esc_url($commenter['comment_author_url']); 1103 1103 1104 /** @todo Use API instead of SELECTs. */ 1105 if ( $user_ID) { 1106 $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)); 1107 } else if ( empty($comment_author) ) { 1108 $comments = get_comments( array('post_id' => $post->ID, 'status' => 'approve', 'order' => 'ASC') ); 1109 } else { 1110 $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)); 1104 $args = array( 1105 'order' => 'ASC', 1106 'post_id' => $post->ID, 1107 'status' => 'approve' 1108 ); 1109 if ( $user_ID ) { 1110 $args['unapproved_user_id'] = $user_ID; 1111 } else if ( ! empty( $comment_author ) ) { 1112 $args['unapproved_author'] = wp_specialchars_decode( $comment_author, ENT_QUOTES ); 1113 $args['unapproved_author_email'] = $comment_author_email; 1111 1114 } 1115 $comments = get_comments( $args ); 1112 1116 1113 1117 /** 1114 1118 * Filter the comments array. -
wp-includes/comment.php
241 241 'order' => 'DESC', 242 242 'parent' => '', 243 243 'post_ID' => '', 244 'post_id' => 0, 244 'post_id' => '', 245 'post__in' => '', 245 246 'post_author' => '', 246 247 'post_name' => '', 247 248 'post_parent' => '', … … 249 250 'post_type' => '', 250 251 'status' => '', 251 252 'type' => '', 253 'unapproved_author' => '', 254 'unapproved_author_email' => '', 255 'unapproved_user_id' => '', 252 256 'user_id' => '', 253 257 'search' => '', 254 258 'count' => false, … … 288 292 if ( $cache = wp_cache_get( $cache_key, 'comment' ) ) 289 293 return $cache; 290 294 295 if ( empty( $post_id ) && empty( $post__in ) ) 296 $post_id = 0; 297 291 298 $post_id = absint($post_id); 292 299 293 300 if ( 'hold' == $status ) … … 299 306 else 300 307 $approved = "( comment_approved = '0' OR comment_approved = '1' )"; 301 308 309 $where = $approved; 310 311 if ( ( '' != $unapproved_user_id || '' !== $unapproved_author || '' != $unapproved_author_email ) ) { 312 $where = '( ' . $where . ' OR ( comment_approved = 0 '; 313 if ( '' !== $unapproved_author ) 314 $where .= $wpdb->prepare( ' AND comment_author = %s', $unapproved_author ); 315 if ( '' !== $unapproved_author_email ) 316 $where .= $wpdb->prepare( ' AND comment_author_email = %s', $unapproved_author_email ); 317 if ( '' !== $unapproved_user_id ) 318 $where .= $wpdb->prepare( ' AND user_id = %d', $unapproved_user_id ); 319 $where .= ' ) ) '; 320 } 321 302 322 $order = ( 'ASC' == strtoupper($order) ) ? 'ASC' : 'DESC'; 303 323 304 324 if ( ! empty( $orderby ) ) { … … 356 376 $fields = '*'; 357 377 358 378 $join = ''; 359 $where = $approved;360 379 361 380 if ( ! empty($post_id) ) 362 381 $where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id ); 382 if ( '' != $post__in && is_array( $post__in ) && ! empty( $post__in ) ) { 383 $_post__in = implode( ',', array_map( 'absint', $post__in ) ); 384 $where .= " AND comment_post_ID IN ($_post__in)"; 385 } 363 386 if ( '' !== $author_email ) 364 387 $where .= $wpdb->prepare( ' AND comment_author_email = %s', $author_email ); 365 388 if ( '' !== $karma )