WordPress.org

Make WordPress Core

Ticket #19615: 19615.2.diff

File 19615.2.diff, 2.6 KB (added by scribu, 4 years ago)
  • wp-includes/pluggable-deprecated.php

    diff --git wp-includes/pluggable-deprecated.php wp-includes/pluggable-deprecated.php
    index 2a202ac..a3983c0 100644
    function set_current_user($id, $name = '') { 
    3636} 
    3737endif; 
    3838 
     39if ( !function_exists('get_currentuserinfo') ) : 
     40/** 
     41 * Populate global variables with information about the currently logged in user. 
     42 * 
     43 * @since 0.71 
     44 * 
     45 * @return bool|WP_User False on XMLRPC Request and invalid auth cookie, WP_User instance otherwise. 
     46 */ 
     47function get_currentuserinfo() { 
     48        _deprecated_function( __FUNCTION__, '3.4', 'wp_get_current_user()' ); 
     49 
     50        return wp_get_current_user(); 
     51} 
     52endif; 
     53 
    3954if ( !function_exists('get_userdatabylogin') ) : 
    4055/** 
    4156 * Retrieve user info by login name. 
  • wp-includes/pluggable.php

    diff --git wp-includes/pluggable.php wp-includes/pluggable.php
    index 7855004..b503421 100644
    if ( !function_exists('wp_get_current_user') ) : 
    4444/** 
    4545 * Retrieve the current user object. 
    4646 * 
    47  * @since 2.0.3 
    48  * 
    49  * @return WP_User Current user WP_User object 
    50  */ 
    51 function wp_get_current_user() { 
    52         global $current_user; 
    53  
    54         get_currentuserinfo(); 
    55  
    56         return $current_user; 
    57 } 
    58 endif; 
    59  
    60 if ( !function_exists('get_currentuserinfo') ) : 
    61 /** 
    62  * Populate global variables with information about the currently logged in user. 
    63  * 
    6447 * Will set the current user, if the current user is not set. The current user 
    6548 * will be set to the logged in person. If no user is logged in, then it will 
    6649 * set the current user to 0, which is invalid and won't have any permissions. 
    6750 * 
    68  * @since 0.71 
    69  * @uses $current_user Checks if the current user is set 
     51 * @since 2.0.3 
     52 * 
    7053 * @uses wp_validate_auth_cookie() Retrieves current logged in user. 
    7154 * 
    72  * @return bool|null False on XMLRPC Request and invalid auth cookie. Null when current user set 
     55 * @return bool|WP_User False on XMLRPC Request and invalid auth cookie, WP_User instance otherwise. 
    7356 */ 
    74 function get_currentuserinfo() { 
     57function wp_get_current_user() { 
    7558        global $current_user; 
    7659 
    7760        if ( defined('XMLRPC_REQUEST') && XMLRPC_REQUEST ) 
    7861                return false; 
    7962 
    80         if ( ! empty($current_user) ) 
    81                 return; 
     63        if ( ! empty( $current_user ) ) 
     64                return $current_user; 
    8265 
    8366        if ( ! $user = wp_validate_auth_cookie() ) { 
    8467                 if ( is_blog_admin() || is_network_admin() || empty($_COOKIE[LOGGED_IN_COOKIE]) || !$user = wp_validate_auth_cookie($_COOKIE[LOGGED_IN_COOKIE], 'logged_in') ) { 
    function get_currentuserinfo() { 
    8871        } 
    8972 
    9073        wp_set_current_user($user); 
     74 
     75        return $current_user; 
    9176} 
    9277endif; 
    9378