Make WordPress Core


Ignore:
Timestamp:
07/09/2014 06:15:42 PM (12 years ago)
Author:
nacin
Message:

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

props mordauk.
fixes #28434.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/comment.php

    r28922 r29045  
    246246                $defaults = array(
    247247                        'author_email' => '',
     248                        'fields' => '',
    248249                        'ID' => '',
    249250                        'karma' => '',
    … …  
    369370                        $fields = 'COUNT(*)';
    370371                } else {
    371                         $fields = '*';
    372                 }
     372                        switch ( strtolower( $this->query_vars['fields'] ) ) {
     373                                case 'ids':
     374                                        $fields = "$wpdb->comments.comment_ID";
     375                                        break;
     376                                default:
     377                                        $fields = "*";
     378                                        break;
     379                        }
     380                }
     381
    373382                $join = '';
    374383                $where = $approved;
    … …  
    461470                        return $wpdb->get_var( $query );
    462471                }
     472
     473                if ( 'ids' == $this->query_vars['fields'] ) {
     474                        $this->comments = $wpdb->get_col( $query );
     475                        return array_map( 'intval', $this->comments );
     476                }
     477
    463478                $results = $wpdb->get_results( $query );
    464479                /**
Note: See TracChangeset for help on using the changeset viewer.