diff --git a/wp-includes/comment.php b/wp-includes/comment.php index 998fbec69e..9215e1eb3e 100644 --- a/wp-includes/comment.php +++ b/wp-includes/comment.php @@ -222,7 +222,9 @@ class WP_Comment_Query { 'type' => '', 'user_id' => '', 'search' => '', - 'count' => false + 'count' => false, + // lets us override the status query var by explicitly setting a value for comment_approved + 'comment_approved' => false, ); $this->query_vars = wp_parse_args( $query_vars, $defaults ); @@ -255,6 +257,10 @@ class WP_Comment_Query { else $approved = "( comment_approved = '0' OR comment_approved = '1' )"; + if ( false !== $comment_approved ) { + $approved = $wpdb->prepare( 'comment_approved = %s', $comment_approved ); + } + $order = ( 'ASC' == strtoupper($order) ) ? 'ASC' : 'DESC'; if ( ! empty( $orderby ) ) {