Ticket #19623: 19623-2.diff
File 19623-2.diff, 3.6 KB (added by , 13 years ago) |
---|
-
wp-includes/comment.php
212 212 'order' => 'DESC', 213 213 'parent' => '', 214 214 'post_ID' => '', 215 'post_id' => 0, 215 'post_id' => '', 216 'post__in' => '', 216 217 'post_author' => '', 217 218 'post_name' => '', 218 219 'post_parent' => '', … … 220 221 'post_type' => '', 221 222 'status' => '', 222 223 'type' => '', 224 'unapproved_author' => '', 225 'unapproved_author_email' => '', 226 'unapproved_user_id' => '', 223 227 'user_id' => '', 224 228 'search' => '', 225 229 'count' => false … … 242 246 return $cache; 243 247 } 244 248 249 if ( empty( $post_id ) && empty( $post__in ) ) 250 $post_id = 0; 251 245 252 $post_id = absint($post_id); 246 253 247 254 if ( 'hold' == $status ) … … 255 262 else 256 263 $approved = "( comment_approved = '0' OR comment_approved = '1' )"; 257 264 265 $where = $approved; 266 267 if ( ( '' != $unapproved_user_id || '' !== $unapproved_author || '' != $unapproved_author_email ) ) { 268 $where = '( ' . $where . ' OR ( comment_approved = 0 '; 269 if ( '' !== $unapproved_author ) 270 $where .= $wpdb->prepare( ' AND comment_author = %s', $unapproved_author ); 271 if ( '' !== $unapproved_author_email ) 272 $where .= $wpdb->prepare( ' AND comment_author_email = %s', $unapproved_author_email ); 273 if ( '' !== $unapproved_user_id ) 274 $where .= $wpdb->prepare( ' AND user_id = %d', $unapproved_user_id ); 275 $where .= ' ) ) '; 276 } 277 258 278 $order = ( 'ASC' == strtoupper($order) ) ? 'ASC' : 'DESC'; 259 279 260 280 if ( ! empty( $orderby ) ) { … … 302 322 $fields = '*'; 303 323 304 324 $join = ''; 305 $where = $approved;306 325 307 326 if ( ! empty($post_id) ) 308 327 $where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id ); 328 if ( '' != $post__in && is_array($post__in) && !empty($post__in) ) { 329 $_post__in = implode(',', array_map( 'absint', $post__in )); 330 $where .= " AND comment_post_ID IN ($_post__in)"; 331 } 309 332 if ( '' !== $author_email ) 310 333 $where .= $wpdb->prepare( ' AND comment_author_email = %s', $author_email ); 311 334 if ( '' !== $karma ) -
wp-includes/comment-template.php
881 881 */ 882 882 $comment_author_url = esc_url($commenter['comment_author_url']); 883 883 884 /** @todo Use API instead of SELECTs. */ 884 $args = array( 885 'order' => 'ASC', 886 'post_id' => $post->ID, 887 'status' => 'approve' 888 ); 885 889 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)); 887 } else if ( empty($comment_author) ) { 888 $comments = get_comments( array('post_id' => $post->ID, 'status' => 'approve', 'order' => 'ASC') ); 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 $args[ 'unapproved_user_id' ] = $user_ID; 891 } else if ( ! empty($comment_author) ) { 892 $args[ 'unapproved_author' ] = wp_specialchars_decode($comment_author,ENT_QUOTES); 893 $args[ 'unapproved_author_email' ] = $comment_author_email; 891 894 } 895 $comments = get_comments( $args ); 892 896 893 897 // keep $comments for legacy's sake 894 898 $wp_query->comments = apply_filters( 'comments_array', $comments, $post->ID );