Make WordPress Core

Changeset 22248


Ignore:
Timestamp:
10/16/2012 08:05:40 PM (12 years ago)
Author:
ryan
Message:

Return WP_User objects when querying 'all' fields with WP_User_Query.
Allow passing stdClass or WP_User to the WP_User constructor.

fixes #22057

Location:
trunk/wp-includes
Files:
2 edited

Legend:

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

    r22118 r22248  
    460460     * @access public
    461461     *
    462      * @param int|string $id User's ID
     462     * @param int|string|stdClass|WP_User $id User's ID, a WP_User object, or a user object from the DB.
    463463     * @param string $name Optional. User's username
    464464     * @param int $blog_id Optional Blog ID, defaults to current blog.
     
    476476                $prefix . 'usersettingstime' => $prefix . 'user-settings-time',
    477477            );
     478        }
     479
     480        if ( is_a( $id, 'WP_User' ) ) {
     481            $this->init( $id->data, $blog_id );
     482            return;
     483        } elseif ( is_object( $id ) ) {
     484            $this->init( $id, $blog_id );
     485            return;
    478486        }
    479487
  • trunk/wp-includes/user.php

    r22124 r22248  
    560560
    561561            $this->results = $r;
     562        } elseif ( 'all' == $qv['fields'] ) {
     563            foreach ( $this->results as $key => $user ) {
     564                $this->results[ $key ] = new WP_User( $user );
     565            }
    562566        }
    563567    }
Note: See TracChangeset for help on using the changeset viewer.