diff --git a/wp-admin/edit-comments.php b/wp-admin/edit-comments.php index f06e17631c..47791bcdc9 100644 --- a/wp-admin/edit-comments.php +++ b/wp-admin/edit-comments.php @@ -65,6 +65,8 @@ $mode = ( ! isset($_GET['mode']) || empty($_GET['mode']) ) ? 'detail' : attribut $comment_status = isset($_GET['comment_status']) ? attribute_escape($_GET['comment_status']) : ''; +$post_id = isset($_GET['p']) ? (int) $_GET['p'] : 0; + $search_dirty = ( isset($_GET['s']) ) ? $_GET['s'] : ''; $search = attribute_escape( $search_dirty ); ?> @@ -151,7 +153,7 @@ else $start = $offset = ( $page - 1 ) * $comments_per_page; -list($_comments, $total) = _wp_get_comment_list( $comment_status, $search_dirty, $start, $comments_per_page + 5 ); // Grab a few extra +list($_comments, $total) = _wp_get_comment_list( $comment_status, $search_dirty, $start, $comments_per_page + 5, $post_id ); // Grab a few extra $comments = array_slice($_comments, 0, $comments_per_page); $extra_comments = array_slice($_comments, $comments_per_page); diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index cf249dca88..3b14779b86 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -1529,11 +1529,12 @@ function user_row( $user_object, $style = '', $role = '' ) { return $r; } -function _wp_get_comment_list( $status = '', $s = false, $start, $num ) { +function _wp_get_comment_list( $status = '', $s = false, $start, $num, $post = 0 ) { global $wpdb; $start = abs( (int) $start ); $num = (int) $num; + $post = (int) $post; if ( 'moderated' == $status ) $approved = "comment_approved = '0'"; @@ -1544,6 +1545,11 @@ function _wp_get_comment_list( $status = '', $s = false, $start, $num ) { else $approved = "( comment_approved = '0' OR comment_approved = '1' )"; + if ( $post ) + $post = " AND comment_post_ID = '$post'"; + else + $post = ''; + if ( $s ) { $s = $wpdb->escape($s); $comments = $wpdb->get_results("SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE @@ -1555,7 +1561,7 @@ function _wp_get_comment_list( $status = '', $s = false, $start, $num ) { $approved ORDER BY comment_date_gmt DESC LIMIT $start, $num"); } else { - $comments = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE $approved ORDER BY comment_date_gmt DESC LIMIT $start, $num" ); + $comments = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE $approved $post ORDER BY comment_date_gmt DESC LIMIT $start, $num" ); } update_comment_cache($comments);