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
This commit is contained in:
parent
29cfcf3b63
commit
2f0f6ae73e
@ -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 ) ) {
|
||||
|
Loading…
Reference in New Issue
Block a user