Make WordPress Core

Ticket #29885: 29885.3.patch

File 29885.3.patch, 2.1 KB (added by chriscct7, 10 years ago)

First attempt at patch that implements all 4 parameters

  • wp-includes/comment.php

     
    258258         *
    259259         * @since 3.1.0
    260260         * @since 4.1.0 Introduced 'comment__in', 'comment__not_in',
     261         *              'post_author__in', 'post_author__not_in',
     262         *              'author__in', 'author__not_in', 
    261263         *              'post__in', and 'post__not_in' to $query_vars.
    262264         *
    263265         * @param string|array $query_vars
     
    268270
    269271                $defaults = array(
    270272                        'author_email' => '',
     273                        'author__in' => '',
     274                        'author__not_in' => '',
    271275                        'fields' => '',
    272276                        'ID' => '',
    273277                        'comment__in' => '',
     
    278282                        'orderby' => '',
    279283                        'order' => 'DESC',
    280284                        'parent' => '',
     285                        'post_author__in' => '',
     286                        'post_author__not_in' => '',
    281287                        'post_ID' => '',
    282288                        'post_id' => 0,
    283289                        'post__in' => '',
     
    476482                                $where .= $wpdb->prepare( " AND {$wpdb->posts}.{$field_name} = %s", $field_value );
    477483                }
    478484
     485                if ( ! empty( $this->query_vars['author__in'] ) ) {
     486                        $where .= ' AND user_id IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['author__in'] ) ) . ' )';
     487                }
     488
     489                if ( ! empty( $this->query_vars['author__not_in'] ) ) {
     490                        $where .= ' AND user_id NOT IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['author__not_in'] ) ) . ' )';
     491                }
     492               
     493                if ( ! empty( $this->query_vars['post_author__in'] ) ) {
     494                        if ( empty( $join ) ) {
     495                                $join = "JOIN $wpdb->posts ON $wpdb->posts.ID = $wpdb->comments.comment_post_ID";
     496                        }
     497                        $where .= ' AND post_author IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['post_author__in'] ) ) . ' )';
     498                }
     499
     500                if ( ! empty( $this->query_vars['post_author__not_in'] ) ) {
     501                        if ( empty( $join ) ) {
     502                                $join = "JOIN $wpdb->posts ON $wpdb->posts.ID = $wpdb->comments.comment_post_ID";
     503                        }
     504                        $where .= ' AND post_author NOT IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['post_author__not_in'] ) ) . ' )';
     505                }
     506
    479507                if ( ! empty( $this->meta_query->queries ) ) {
    480508                        $clauses = $this->meta_query->get_sql( 'comment', $wpdb->comments, 'comment_ID', $this );
    481509                        $join .= $clauses['join'];