Make WordPress Core

Ticket #29612: 29612_gowp.diff

File 29612_gowp.diff, 1.2 KB (added by karpstrucking, 11 years ago)

add support for array of comment statuses in get_comments()

  • wp-includes/comment.php

    diff --git a/wp-includes/comment.php b/wp-includes/comment.php
    index a4cc7e2..2b41cfd 100644
    a b class WP_Comment_Query { 
    303303                        return $cache;
    304304                }
    305305
    306                 $status = $this->query_vars['status'];
    307                 if ( 'hold' == $status ) {
    308                         $approved = "comment_approved = '0'";
    309                 } elseif ( 'approve' == $status ) {
    310                         $approved = "comment_approved = '1'";
    311                 } elseif ( ! empty( $status ) && 'all' != $status ) {
    312                         $approved = $wpdb->prepare( "comment_approved = %s", $status );
    313                 } else {
     306                $statuses = (array) $this->query_vars['status'];
     307                foreach ( $statuses as $status ) {
     308                        if ( 'hold' == $status ) {
     309                                $approve[] = "comment_approved = '0'";
     310                        } elseif ( 'approve' == $status ) {
     311                                $approve[] = "comment_approved = '1'";
     312                        } elseif ( ! empty( $status ) && 'all' != $status ) {
     313                                $approve[] = $wpdb->prepare( "comment_approved = %s", $status );
     314                        }
     315                }
     316                if ( ! $approve ) {
    314317                        $approved = "( comment_approved = '0' OR comment_approved = '1' )";
     318                } else {
     319                        $approved = "( " . implode( " OR ", $approve ) . " )";
    315320                }
     321
    316322                $order = ( 'ASC' == strtoupper( $this->query_vars['order'] ) ) ? 'ASC' : 'DESC';
    317323
    318324                if ( ! empty( $this->query_vars['orderby'] ) ) {