Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
  • Loading branch information...
commit a8ce9af6d889e770b7de8901af92737b9be4774f 1 parent d65b2ca
@westi westi authored
Showing with 7 additions and 1 deletion.
  1. +7 −1 wp-includes/comment.php
View
8 wp-includes/comment.php
@@ -222,7 +222,9 @@ function query( $query_vars ) {
'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 @@ function query( $query_vars ) {
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 ) ) {
Please sign in to comment.
Something went wrong with that request. Please try again.