Ticket #19623: 19623-1.diff
File 19623-1.diff, 4.3 KB (added by , 14 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 'count' => false 229 'count' => false, 226 230 ); 227 231 228 232 $this->query_vars = wp_parse_args( $query_vars, $defaults ); … … 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 254 $where = ''; 255 256 $show_unapproved = ( '' != $unapproved_user_id || '' !== $unapproved_author || '' != $unapproved_author_email ); 257 258 if ( $show_unapproved ) { 259 $where .= ' ( '; 260 } 261 247 262 if ( 'hold' == $status ) 248 $ approved= "comment_approved = '0'";263 $where .= "comment_approved = '0'"; 249 264 elseif ( 'approve' == $status ) 250 $ approved= "comment_approved = '1'";265 $where .= "comment_approved = '1'"; 251 266 elseif ( 'spam' == $status ) 252 $ approved= "comment_approved = 'spam'";267 $where .= "comment_approved = 'spam'"; 253 268 elseif ( 'trash' == $status ) 254 $ approved= "comment_approved = 'trash'";269 $where .= "comment_approved = 'trash'"; 255 270 else 256 $ approved= "( comment_approved = '0' OR comment_approved = '1' )";271 $where .= "( comment_approved = '0' OR comment_approved = '1' )"; 257 272 273 if ( $show_unapproved ) { 274 $where .= ' OR ( comment_approved = 0 '; 275 if ( '' !== $unapproved_author ) 276 $where .= $wpdb->prepare( ' AND comment_author = %s', $unapproved_author ); 277 if ( '' !== $unapproved_author_email ) 278 $where .= $wpdb->prepare( ' AND comment_author_email = %s', $unapproved_author_email ); 279 if ( '' !== $unapproved_user_id ) 280 $where .= $wpdb->prepare( ' AND user_id = %d', $unapproved_user_id ); 281 $where .= ' ) ) '; 282 } 283 258 284 $order = ( 'ASC' == strtoupper($order) ) ? 'ASC' : 'DESC'; 259 285 260 286 if ( ! empty( $orderby ) ) { … … 302 328 $fields = '*'; 303 329 304 330 $join = ''; 305 $where = $approved;306 331 307 332 if ( ! empty($post_id) ) 308 333 $where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id ); 334 if ( '' != $post__in ) { 335 $_post__in = implode(',', array_map( 'absint', $post__in )); 336 $where .= " AND comment_post_ID IN ($_post__in)"; 337 } 309 338 if ( '' !== $author_email ) 310 339 $where .= $wpdb->prepare( ' AND comment_author_email = %s', $author_email ); 311 340 if ( '' !== $karma ) -
wp-includes/comment-template.php
879 879 */ 880 880 $comment_author_url = esc_url($commenter['comment_author_url']); 881 881 882 /** @todo Use API instead of SELECTs. */ 882 $query = new WP_Comment_Query; 883 $args = array( 884 'order' => 'ASC', 885 'post_id' => $post->ID, 886 'status' => 'approve', 887 ); 883 888 if ( $user_ID) { 884 $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)); 885 } else if ( empty($comment_author) ) { 886 $comments = get_comments( array('post_id' => $post->ID, 'status' => 'approve', 'order' => 'ASC') ); 887 } else { 888 $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)); 889 $args[ 'unapproved_user_id' ] = $user_ID; 890 } else if ( ! empty($comment_author) ) { 891 $args[ 'unapproved_author' ] = wp_specialchars_decode($comment_author,ENT_QUOTES); 892 $args[ 'unapproved_author_email' ] = $comment_author_email; 889 893 } 894 $args = apply_filters( 'comments_template_args', $args ); 895 $comments = $query->query( $args ); 890 896 891 897 // keep $comments for legacy's sake 892 898 $wp_query->comments = apply_filters( 'comments_array', $comments, $post->ID );