Make WordPress Core

Ticket #29885: 29885.diff

File 29885.diff, 1.1 KB (added by nofearinc, 11 years ago)

Add authorin and authornot_in for WP_Comment_Query

  • wp-includes/comment.php

     
    475475                        foreach( $post_fields as $field_name => $field_value )
    476476                                $where .= $wpdb->prepare( " AND {$wpdb->posts}.{$field_name} = %s", $field_value );
    477477                }
     478               
     479                if ( ! empty( $this->query_vars['author__in'] ) ) {
     480                        if ( empty( $join ) ) {
     481                                $join = "JOIN $wpdb->posts ON $wpdb->posts.ID = $wpdb->comments.comment_post_ID";
     482                        }
     483                        $where .= ' AND post_author IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['author__in'] ) ) . ' )';
     484                }
    478485
     486                if ( ! empty( $this->query_vars['author__not_in'] ) ) {
     487                        if ( empty( $join ) ) {
     488                                $join = "JOIN $wpdb->posts ON $wpdb->posts.ID = $wpdb->comments.comment_post_ID";
     489                        }
     490                        $where .= ' AND post_author NOT IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['author__not_in'] ) ) . ' )';
     491                }
     492
    479493                if ( ! empty( $this->meta_query->queries ) ) {
    480494                        $clauses = $this->meta_query->get_sql( 'comment', $wpdb->comments, 'comment_ID', $this );
    481495                        $join .= $clauses['join'];