Make WordPress Core

Changeset 31795


Ignore:
Timestamp:
03/16/2015 08:17:35 PM (10 years ago)
Author:
DrewAPicture
Message:

Move the default arguments hash notation for WP_Comment_Query to the new constructor, where the argument definitions were moved in [31793].

Core style dictates that the default arguments should be documented in the same function or method where they are defined.

See [31793].
Fixes #24826.

File:
1 edited

Legend:

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

    r31793 r31795  
    233233 * WordPress Comment Query class.
    234234 *
    235  * See {@see WP_Comment_Query::query()} for accepted arguments.
     235 * See WP_Comment_Query::__construct() for accepted arguments.
    236236 *
    237237 * @since 3.1.0
     
    317317     * @access public
    318318     *
    319      * @param string $query URL query string.
    320      * @return WP_Comment_Query
    321      */
    322     public function __construct( $query = '' ) {
    323         $this->query_var_defaults = array(
    324             'author_email' => '',
    325             'author__in' => '',
    326             'author__not_in' => '',
    327             'include_unapproved' => '',
    328             'fields' => '',
    329             'ID' => '',
    330             'comment__in' => '',
    331             'comment__not_in' => '',
    332             'karma' => '',
    333             'number' => '',
    334             'offset' => '',
    335             'orderby' => '',
    336             'order' => 'DESC',
    337             'parent' => '',
    338             'post_author__in' => '',
    339             'post_author__not_in' => '',
    340             'post_ID' => '',
    341             'post_id' => 0,
    342             'post__in' => '',
    343             'post__not_in' => '',
    344             'post_author' => '',
    345             'post_name' => '',
    346             'post_parent' => '',
    347             'post_status' => '',
    348             'post_type' => '',
    349             'status' => 'all',
    350             'type' => '',
    351             'type__in' => '',
    352             'type__not_in' => '',
    353             'user_id' => '',
    354             'search' => '',
    355             'count' => false,
    356             'meta_key' => '',
    357             'meta_value' => '',
    358             'meta_query' => '',
    359             'date_query' => null, // See WP_Date_Query
    360         );
    361 
    362         if ( ! empty( $query ) ) {
    363             $this->query( $query );
    364         }
    365     }
    366 
    367     /**
    368      * Parse arguments passed to the comment query with default query parameters.
    369      *
    370      * @since  4.2.0 Extracted from {@link WP_Comment_Query::query()}.
    371      * @access public
    372      *
    373319     * @param string|array $query {
    374      *     Optional. Array or query string of comment query parameters.
     320     *     Optional. Array or query string of comment query parameters. Default empty.
    375321     *
    376322     *     @type string       $author_email        Comment author email address. Default empty.
     
    381327     *     @type bool         $count               Whether to return a comment count (true) or array of comment
    382328     *                                             objects (false). Default false.
    383      *     @type array        $date_query          Date query clauses to limit comments by. See {@see WP_Date_Query}.
     329     *     @type array        $date_query          Date query clauses to limit comments by. See WP_Date_Query.
    384330     *                                             Default null.
    385331     *     @type string       $fields              Comment fields to return. Accepts 'ids' for comment IDs only or
     
    393339     *                                             `$meta_key` to be set. Default empty.
    394340     *     @type array        $meta_query          Meta query clauses to limit retrieved comments by.
    395      *                                             See {@see WP_Meta_Query}. Default empty.
     341     *                                             See WP_Meta_Query. Default empty.
    396342     *     @type int          $number              Maximum number of comments to retrieve. Default null (no limit).
    397343     *     @type int          $offset              Number of comments to offset the query. Used to build LIMIT clause.
     
    434380     *     @type int          $user_id             Include comments for a specific user ID. Default empty.
    435381     * }
     382     * @return WP_Comment_Query WP_Comment_Query instance.
     383     */
     384    public function __construct( $query = '' ) {
     385        $this->query_var_defaults = array(
     386            'author_email' => '',
     387            'author__in' => '',
     388            'author__not_in' => '',
     389            'include_unapproved' => '',
     390            'fields' => '',
     391            'ID' => '',
     392            'comment__in' => '',
     393            'comment__not_in' => '',
     394            'karma' => '',
     395            'number' => '',
     396            'offset' => '',
     397            'orderby' => '',
     398            'order' => 'DESC',
     399            'parent' => '',
     400            'post_author__in' => '',
     401            'post_author__not_in' => '',
     402            'post_ID' => '',
     403            'post_id' => 0,
     404            'post__in' => '',
     405            'post__not_in' => '',
     406            'post_author' => '',
     407            'post_name' => '',
     408            'post_parent' => '',
     409            'post_status' => '',
     410            'post_type' => '',
     411            'status' => 'all',
     412            'type' => '',
     413            'type__in' => '',
     414            'type__not_in' => '',
     415            'user_id' => '',
     416            'search' => '',
     417            'count' => false,
     418            'meta_key' => '',
     419            'meta_value' => '',
     420            'meta_query' => '',
     421            'date_query' => null, // See WP_Date_Query
     422        );
     423
     424        if ( ! empty( $query ) ) {
     425            $this->query( $query );
     426        }
     427    }
     428
     429    /**
     430     * Parse arguments passed to the comment query with default query parameters.
     431     *
     432     * @since  4.2.0 Extracted from WP_Comment_Query::query().
     433     *
     434     * @access public
     435     *
     436     * @param string|array $query WP_Comment_Query arguments. See WP_Comment_Query::__construct()
    436437     */
    437438    public function parse_query( $query = '' ) {
Note: See TracChangeset for help on using the changeset viewer.