diff --git src/wp-includes/pluggable-deprecated.php src/wp-includes/pluggable-deprecated.php
index 39fcd49..77690bf 100644
|
|
function set_current_user($id, $name = '') { |
35 | 35 | } |
36 | 36 | endif; |
37 | 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(); |
| 52 | } |
| 53 | endif; |
| 54 | |
38 | 55 | if ( !function_exists('get_userdatabylogin') ) : |
39 | 56 | /** |
40 | 57 | * Retrieve user info by login name. |
… |
… |
if ( ! class_exists( 'wp_atom_server', false ) ) { |
188 | 205 | _deprecated_function( __CLASS__ . '::' . $name, '3.5', 'the Atom Publishing Protocol plugin' ); |
189 | 206 | } |
190 | 207 | } |
191 | | } |
192 | | No newline at end of file |
| 208 | } |
diff --git src/wp-includes/pluggable.php src/wp-includes/pluggable.php
index 5b441d8..02b3f75 100644
|
|
if ( !function_exists('wp_get_current_user') ) : |
54 | 54 | /** |
55 | 55 | * Retrieve the current user object. |
56 | 56 | * |
57 | | * @since 2.0.3 |
58 | | * |
59 | | * @global WP_User $current_user |
60 | | * |
61 | | * @return WP_User Current user WP_User object |
62 | | */ |
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.71 |
| 61 | * @since 2.0.3 |
81 | 62 | * |
82 | | * @global WP_User $current_user Checks if the current user is set |
| 63 | * @global WP_User $current_user Checks if the current user is set. |
83 | 64 | * |
84 | | * @return false|void False on XML-RPC Request and invalid auth cookie. |
| 65 | * @return bool|WP_User WP_User instance on success, false on XMLRPC Request and invalid auth cookie. |
85 | 66 | */ |
86 | | function get_currentuserinfo() { |
| 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 |
94 | 76 | if ( is_object( $current_user ) && isset( $current_user->ID ) ) { |
95 | 77 | $cur_id = $current_user->ID; |
96 | 78 | $current_user = null; |
97 | 79 | wp_set_current_user( $cur_id ); |
98 | | return; |
| 80 | return $current_user; |
99 | 81 | } |
100 | 82 | |
101 | 83 | // $current_user has a junk value. Force to WP_User with ID 0. |
… |
… |
function get_currentuserinfo() { |
129 | 111 | } |
130 | 112 | |
131 | 113 | wp_set_current_user( $user_id ); |
| 114 | |
| 115 | return $current_user; |
132 | 116 | } |
133 | 117 | endif; |
134 | 118 | |
diff --git tests/phpunit/tests/pluggable.php tests/phpunit/tests/pluggable.php
index a757a60..82c6ab1 100644
|
|
class Tests_Pluggable extends WP_UnitTestCase { |
127 | 127 | // wp-includes/pluggable.php: |
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' ), |
133 | 132 | 'cache_users' => array( 'user_ids' ), |