WP_Comment_Query: Add fields => 'ids' query var.

props mordauk.
fixes #28434.


git-svn-id: https://develop.svn.wordpress.org/trunk@29045 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin
2014-07-09 18:15:42 +00:00
parent 3cda5caafd
commit adbe839132
2 changed files with 34 additions and 1 deletions

View File

@@ -245,6 +245,7 @@ class WP_Comment_Query {
$defaults = array(
'author_email' => '',
'fields' => '',
'ID' => '',
'karma' => '',
'number' => '',
@@ -368,8 +369,16 @@ class WP_Comment_Query {
if ( $this->query_vars['count'] ) {
$fields = 'COUNT(*)';
} else {
$fields = '*';
switch ( strtolower( $this->query_vars['fields'] ) ) {
case 'ids':
$fields = "$wpdb->comments.comment_ID";
break;
default:
$fields = "*";
break;
}
}
$join = '';
$where = $approved;
@@ -460,6 +469,12 @@ class WP_Comment_Query {
if ( $this->query_vars['count'] ) {
return $wpdb->get_var( $query );
}
if ( 'ids' == $this->query_vars['fields'] ) {
$this->comments = $wpdb->get_col( $query );
return array_map( 'intval', $this->comments );
}
$results = $wpdb->get_results( $query );
/**
* Filter the comment query results.