Make WordPress Core


Ignore:
Timestamp:
10/02/2014 01:40:56 AM (11 years ago)
Author:
boonebgorges
Message:

WP_Comment_Query: commentin, commentnot_in, postin, postnot_in.

Props nofearinc, mordauk, boonebgorges

Fixes #25386

File:
1 edited

Legend:

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

    r29788 r29808  
    258258     *
    259259     * @since 3.1.0
     260     * @since 4.1.0 Introduced 'comment__in', 'comment__not_in',
     261     *              'post__in', and 'post__not_in' to $query_vars.
    260262     *
    261263     * @param string|array $query_vars
     
    269271            'fields' => '',
    270272            'ID' => '',
     273            'comment__in' => '',
     274            'comment__not_in' => '',
    271275            'karma' => '',
    272276            'number' => '',
     
    277281            'post_ID' => '',
    278282            'post_id' => 0,
     283            'post__in' => '',
     284            'post__not_in' => '',
    279285            'post_author' => '',
    280286            'post_name' => '',
     
    409415        }
    410416
     417        // Parse comment IDs for an IN clause.
     418        if ( ! empty( $this->query_vars['comment__in'] ) ) {
     419            $where .= ' AND comment_ID IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['comment__in'] ) ) . ' )';
     420        }
     421
     422        // Parse comment IDs for a NOT IN clause.
     423        if ( ! empty( $this->query_vars['comment__not_in'] ) ) {
     424            $where .= ' AND comment_ID NOT IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['comment__not_in'] ) ) . ' )';
     425        }
     426
     427        // Parse comment post IDs for an IN clause.
     428        if ( ! empty( $this->query_vars['post__in'] ) ) {
     429            $where .= ' AND comment_post_ID IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['post__in'] ) ) . ' )';
     430        }
     431
     432        // Parse comment post IDs for a NOT IN clause.
     433        if ( ! empty( $this->query_vars['post__not_in'] ) ) {
     434            $where .= ' AND comment_post_ID NOT IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['post__not_in'] ) ) . ' )';
     435        }
     436
    411437        if ( '' !== $this->query_vars['author_email'] ) {
    412438            $where .= $wpdb->prepare( ' AND comment_author_email = %s', $this->query_vars['author_email'] );
Note: See TracChangeset for help on using the changeset viewer.