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: http://core.svn.wordpress.org/trunk@21570 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Peter Westwood
2012-08-21 09:56:16 +00:00
parent d65b2caac9
commit a8ce9af6d8

View File

@@ -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 ) ) {