Changeset 36311
- Timestamp:
- 01/15/2016 10:15:21 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/pluggable-deprecated.php
r34348 r36311 33 33 _deprecated_function( __FUNCTION__, '3.0', 'wp_set_current_user()' ); 34 34 return wp_set_current_user($id, $name); 35 } 36 endif; 37 38 if ( !function_exists('get_currentuserinfo') ) : 39 /** 40 * Populate global variables with information about the currently logged in user. 41 * 42 * @since 0.71 43 * @deprecated 4.5.0 Use wp_get_current_user() 44 * @see wp_get_current_user() 45 * 46 * @return bool|WP_User False on XMLRPC Request and invalid auth cookie, WP_User instance otherwise. 47 */ 48 function get_currentuserinfo() { 49 _deprecated_function( __FUNCTION__, '4.5', 'wp_get_current_user()' ); 50 51 return wp_get_current_user(); 35 52 } 36 53 endif; -
trunk/src/wp-includes/pluggable.php
r36246 r36311 55 55 * Retrieve the current user object. 56 56 * 57 * @since 2.0.358 *59 * @global WP_User $current_user60 *61 * @return WP_User Current user WP_User object62 */63 function wp_get_current_user() {64 global $current_user;65 66 get_currentuserinfo();67 68 return $current_user;69 }70 endif;71 72 if ( !function_exists('get_currentuserinfo') ) :73 /**74 * Populate global variables with information about the currently logged in user.75 *76 57 * Will set the current user, if the current user is not set. The current user 77 58 * will be set to the logged-in person. If no user is logged-in, then it will 78 59 * set the current user to 0, which is invalid and won't have any permissions. 79 60 * 80 * @since 0.7181 * 82 * @global WP_User $current_user Checks if the current user is set 83 * 84 * @return false|void False on XML-RPC Request and invalid auth cookie.85 */ 86 function get_currentuserinfo() {61 * @since 2.0.3 62 * 63 * @global WP_User $current_user Checks if the current user is set. 64 * 65 * @return bool|WP_User WP_User instance on success, false on XMLRPC Request and invalid auth cookie. 66 */ 67 function wp_get_current_user() { 87 68 global $current_user; 88 69 89 70 if ( ! empty( $current_user ) ) { 90 if ( $current_user instanceof WP_User ) 91 return; 71 if ( $current_user instanceof WP_User ) { 72 return $current_user; 73 } 92 74 93 75 // Upgrade stdClass to WP_User … … 96 78 $current_user = null; 97 79 wp_set_current_user( $cur_id ); 98 return ;80 return $current_user; 99 81 } 100 82 … … 130 112 131 113 wp_set_current_user( $user_id ); 114 115 return $current_user; 132 116 } 133 117 endif; -
trunk/tests/phpunit/tests/pluggable.php
r35148 r36311 128 128 'wp_set_current_user' => array( 'id', 'name' => '' ), 129 129 'wp_get_current_user' => array(), 130 'get_currentuserinfo' => array(),131 130 'get_userdata' => array( 'user_id' ), 132 131 'get_user_by' => array( 'field', 'value' ),
Note: See TracChangeset
for help on using the changeset viewer.