Make WordPress Core


Ignore:
Timestamp:
09/15/2015 04:22:34 PM (9 years ago)
Author:
wonderboymusic
Message:

Add parent__in and parent__not_in query vars to WP_Comment_Query.

Adds unit tests.

Fixes #33882.

File:
1 edited

Legend:

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

    r33898 r34205  
    9393     * Sets up the comment query, based on the query vars passed.
    9494     *
    95      * @since  4.2.0
     95     * @since 4.2.0
     96     * @since 4.4.0 `$parent__in` and `$parent__not_in` were added.
    9697     * @access public
    9798     *
     
    137138     *                                             Default: 'DESC'.
    138139     *     @type int          $parent              Parent ID of comment to retrieve children of. Default empty.
     140     *     @type array        $parent__in          Array of parent IDs of comments to retrieve children for. Default empty.
     141     *     @type array        $parent__not_in      Array of parent IDs of comments *not* to retrieve children for. Default empty.
    139142     *     @type array        $post_author__in     Array of author IDs to retrieve comments for. Default empty.
    140143     *     @type array        $post_author__not_in Array of author IDs *not* to retrieve comments for. Default empty.
     
    487490        }
    488491
     492        // Parse comment parent IDs for an IN clause.
     493        if ( ! empty( $this->query_vars['parent__in'] ) ) {
     494            $where[] = 'comment_parent IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['parent__in'] ) ) . ' )';
     495        }
     496
     497        // Parse comment parent IDs for a NOT IN clause.
     498        if ( ! empty( $this->query_vars['parent__not_in'] ) ) {
     499            $where[] = 'comment_parent NOT IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['parent__not_in'] ) ) . ' )';
     500        }
     501
    489502        // Parse comment post IDs for an IN clause.
    490503        if ( ! empty( $this->query_vars['post__in'] ) ) {
Note: See TracChangeset for help on using the changeset viewer.