From 2f0f6ae73e6ca4abcd7572a705f0309dd149fbfa Mon Sep 17 00:00:00 2001 From: Peter Westwood Date: Tue, 21 Aug 2012 09:56:16 +0000 Subject: [PATCH] Comments: Allow the caller of get_comments() to request comments with a specific comment_approved value. This allows for a custom comment status to be queried directly overriding the status argument. See #21101 props nbachiyski. git-svn-id: https://develop.svn.wordpress.org/trunk@21570 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/comment.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 ) ) {