Make WordPress Core

Changeset 15543


Ignore:
Timestamp:
08/27/2010 03:41:32 PM (14 years ago)
Author:
scribu
Message:

WP_User_Query constructor improvements. Props filosofo. Fixes #14709

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/user.php

    r15539 r15543  
    334334
    335335    /**
    336      * {@internal Missing Description}}
     336     * List of found user ids
    337337     *
    338338     * @since 3.1.0
     
    343343
    344344    /**
    345      * The total number of users for the current query
     345     * Total number of found users for the current query
    346346     *
    347347     * @since 3.1.0
     
    351351    var $total_users = 0;
    352352
     353    // SQL pieces
    353354    var $query_from;
    354355    var $query_where;
     
    357358
    358359    /**
    359      * Sets up the object properties.
     360     * PHP4 constructor
     361     */
     362    function WP_User_Query( $query = null ) {
     363        $this->__construct( $query );
     364    }
     365
     366    /**
     367     * PHP5 constructor
    360368     *
    361369     * @since 3.1.0
     
    364372     * @return WP_User_Query
    365373     */
    366     function WP_User_Query( $query ) {
    367         $this->query_vars = wp_parse_args( $query, array(
    368             'search' => '', 'role' => '',
    369             'offset' => '', 'number' => '', 'count_total' => true,
    370             'orderby' => 'login', 'order' => 'ASC',
    371             'meta_key' => '', 'meta_value' => '',
    372             'include' => array(), 'exclude' => array(),
    373             'fields' => 'all'
    374         ) );
    375 
    376         $this->prepare_query();
    377         $this->query();
     374    function __construct( $query = null ) {
     375        if ( !empty( $query ) ) {
     376            $this->query_vars = wp_parse_args( $query, array(
     377                'search' => '', 'role' => '',
     378                'offset' => '', 'number' => '', 'count_total' => true,
     379                'orderby' => 'login', 'order' => 'ASC',
     380                'meta_key' => '', 'meta_value' => '',
     381                'include' => array(), 'exclude' => array(),
     382                'fields' => 'all'
     383            ) );
     384
     385            $this->prepare_query();
     386            $this->query();
     387        }
    378388    }
    379389
Note: See TracChangeset for help on using the changeset viewer.