WordPress.org

Make WordPress Core

Changeset 32637


Ignore:
Timestamp:
05/28/2015 03:50:34 PM (6 years ago)
Author:
wonderboymusic
Message:

Add missing doc blocks to user.php.
username_exists() should return false instead of null, just like email_exists() does, which is right under it.

See #32444.

File:
1 edited

Legend:

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

    r32630 r32637  
    1919 *
    2020 * @since 2.5.0
     21 *
     22 * @global string $auth_secure_cookie
    2123 *
    2224 * @param array       $credentials   Optional. User info in order to sign on.
     
    161163 *
    162164 * @since 2.8.0
     165 *
     166 * @global string $auth_secure_cookie
    163167 *
    164168 * @param WP_User|WP_Error|null $user     WP_User or WP_Error object from a previous callback. Default null.
     
    232236 * @param int|bool $user_id The user ID (or false) as received from the
    233237 *                       determine_current_user filter.
    234  * @return int|bool User ID if validated, false otherwise. If a user ID from
    235  *                  an earlier filter callback is received, that value is returned.
     238 * @return int|false User ID if validated, false otherwise. If a user ID from
     239 *                   an earlier filter callback is received, that value is returned.
    236240 */
    237241function wp_validate_logged_in_cookie( $user_id ) {
     
    287291 *
    288292 * @since 3.0.0
     293 *
     294 * @global wpdb $wpdb
    289295 *
    290296 * @param array        $users       Array of user IDs.
     
    517523     *              for `$orderby` parameter.
    518524     * @access public
     525     *
     526     * @global wpdb $wpdb
     527     * @global int  $blog_id
    519528     *
    520529     * @param string|array $query {
     
    902911     * @since 3.1.0
    903912     *
     913     * @global wpdb $wpdb
     914     *
    904915     * @param string $string
    905      * @param array $cols
    906      * @param bool $wild Whether to allow wildcard searches. Default is false for Network Admin, true for
    907      *  single site. Single site allows leading and trailing wildcards, Network Admin only trailing.
     916     * @param array  $cols
     917     * @param bool   $wild   Whether to allow wildcard searches. Default is false for Network Admin, true for single site.
     918     *                      Single site allows leading and trailing wildcards, Network Admin only trailing.
    908919     * @return string
    909920     */
     
    960971     *
    961972     * @param string $orderby Alias for the field to order by.
    962      * @return string|bool Value to used in the ORDER clause, if `$orderby` is valid. False otherwise.
     973     * @return string Value to used in the ORDER clause, if `$orderby` is valid.
    963974     */
    964975    protected function parse_orderby( $orderby ) {
     
    10921103     * @param callable $name      Method to call.
    10931104     * @param array    $arguments Arguments to pass when calling.
    1094      * @return mixed|bool Return value of the callback, false otherwise.
     1105     * @return mixed Return value of the callback, false otherwise.
    10951106     */
    10961107    public function __call( $name, $arguments ) {
     
    12581269 * @link https://codex.wordpress.org/Function_Reference/add_user_meta
    12591270 *
    1260  * @param int $user_id User ID.
    1261  * @param string $meta_key Metadata name.
    1262  * @param mixed $meta_value Metadata value.
    1263  * @param bool $unique Optional, default is false. Whether the same key should not be added.
    1264  * @return int|bool Meta ID on success, false on failure.
     1271 * @param int    $user_id    User ID.
     1272 * @param string $meta_key   Metadata name.
     1273 * @param mixed  $meta_value Metadata value.
     1274 * @param bool   $unique    Optional, default is false. Whether the same key should not be added.
     1275 * @return int|false Meta ID on success, false on failure.
    12651276 */
    12661277function add_user_meta($user_id, $meta_key, $meta_value, $unique = false) {
     
    12781289 * @link https://codex.wordpress.org/Function_Reference/delete_user_meta
    12791290 *
    1280  * @param int $user_id user ID
    1281  * @param string $meta_key Metadata name.
    1282  * @param mixed $meta_value Optional. Metadata value.
     1291 * @param int    $user_id    User ID
     1292 * @param string $meta_key   Metadata name.
     1293 * @param mixed  $meta_value Optional. Metadata value.
    12831294 * @return bool True on success, false on failure.
    12841295 */
     
    12931304 * @link https://codex.wordpress.org/Function_Reference/get_user_meta
    12941305 *
    1295  * @param int $user_id User ID.
    1296  * @param string $key Optional. The meta key to retrieve. By default, returns data for all keys.
    1297  * @param bool $single Whether to return a single value.
    1298  * @return mixed Will be an array if $single is false. Will be value of meta data field if $single
    1299  *  is true.
     1306 * @param int    $user_id User ID.
     1307 * @param string $key     Optional. The meta key to retrieve. By default, returns data for all keys.
     1308 * @param bool   $single  Whether to return a single value.
     1309 * @return mixed Will be an array if $single is false. Will be value of meta data field if $single is true.
    13001310 */
    13011311function get_user_meta($user_id, $key = '', $single = false) {
     
    13141324 * @link https://codex.wordpress.org/Function_Reference/update_user_meta
    13151325 *
    1316  * @param int $user_id User ID.
    1317  * @param string $meta_key Metadata key.
    1318  * @param mixed $meta_value Metadata value.
    1319  * @param mixed $prev_value Optional. Previous value to check before removing.
     1326 * @param int    $user_id    User ID.
     1327 * @param string $meta_key   Metadata key.
     1328 * @param mixed  $meta_value Metadata value.
     1329 * @param mixed  $prev_value Optional. Previous value to check before removing.
    13201330 * @return int|bool Meta ID if the key didn't exist, true on successful update, false on failure.
    13211331 */
     
    13331343 *
    13341344 * @since 3.0.0
     1345 *
     1346 * @global wpdb $wpdb
     1347 *
    13351348 * @param string $strategy 'time' or 'memory'
    13361349 * @return array Includes a grand total and an array of counts indexed by role strings.
     
    14071420 *
    14081421 * @since 2.0.4
    1409  * @global string $userdata User description.
    1410  * @global string $user_login The user username for logging in
    1411  * @global int $user_level The level of the user
    1412  * @global int $user_ID The ID of the user
    1413  * @global string $user_email The email address of the user
    1414  * @global string $user_url The url in the user's profile
     1422 *
     1423 * @global string $user_login    The user username for logging in
     1424 * @global object $userdata      User data.
     1425 * @global int    $user_level    The level of the user
     1426 * @global int    $user_ID       The ID of the user
     1427 * @global string $user_email    The email address of the user
     1428 * @global string $user_url      The url in the user's profile
    14151429 * @global string $user_identity The display name of the user
    14161430 *
     
    14541468 *
    14551469 * @global wpdb $wpdb WordPress database object for queries.
     1470 * @global int  $blog_id
    14561471 *
    14571472 * @param array|string $args {
     
    14931508 *                                                 'authors'. Default empty.
    14941509 * }
    1495  * @return string|null Null on display. String of HTML content on retrieve.
     1510 * @return string String of HTML content.
    14961511 */
    14971512function wp_dropdown_users( $args = '' ) {
     
    15821597 * @since 2.3.0
    15831598 *
    1584  * @param string $field The user Object field name.
    1585  * @param mixed $value The user Object value.
    1586  * @param int $user_id user ID.
     1599 * @param string $field   The user Object field name.
     1600 * @param mixed  $value  The user Object value.
     1601 * @param int    $user_id User ID.
    15871602 * @param string $context How to sanitize user fields. Looks for 'raw', 'edit', 'db', 'display',
    1588  *               'attribute' and 'js'.
     1603 *                        'attribute' and 'js'.
    15891604 * @return mixed Sanitized value.
    15901605 */
     
    17201735 *
    17211736 * @param string $username Username.
    1722  * @return null|int The user's ID on success, and null on failure.
     1737 * @return int|false The user's ID on success, and false on failure.
    17231738 */
    17241739function username_exists( $username ) {
    1725     if ( $user = get_user_by('login', $username ) ) {
     1740    if ( $user = get_user_by( 'login', $username ) ) {
    17261741        return $user->ID;
    1727     } else {
    1728         return null;
    1729     }
     1742    }
     1743    return false;
    17301744}
    17311745
     
    17361750 *
    17371751 * @param string $email Email.
    1738  * @return bool|int The user's ID on success, and false on failure.
     1752 * @return int|false The user's ID on success, and false on failure.
    17391753 */
    17401754function email_exists( $email ) {
    1741     if ( $user = get_user_by('email', $email) )
     1755    if ( $user = get_user_by( 'email', $email) ) {
    17421756        return $user->ID;
    1743 
     1757    }
    17441758    return false;
    17451759}
     
    21492163 * @param string $password The user's password.
    21502164 * @param string $email    Optional. The user's email. Default empty.
    2151  * @return int The new user's ID.
     2165 * @return int|WP_Error The new user's ID.
    21522166 */
    21532167function wp_create_user($username, $password, $email = '') {
     
    22962310 * Handles resetting the user's password.
    22972311 *
    2298  * @param object $user The user
     2312 * @param object $user     The user
    22992313 * @param string $new_pass New password for the user in plaintext
    23002314 */
Note: See TracChangeset for help on using the changeset viewer.