Optimize get_user_by( 'id', $id ) to return wp_get_current_user() when the current user ID is requested.
Provides for a major performance improvement by preventing repeated instantiations of WP_User in the capabilities API. see #21120. git-svn-id: https://develop.svn.wordpress.org/trunk@21376 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
cd7e3f097d
commit
2c058d3b3a
@ -133,6 +133,9 @@ if ( !function_exists('get_user_by') ) :
|
|||||||
* @return bool|object False on failure, WP_User object on success
|
* @return bool|object False on failure, WP_User object on success
|
||||||
*/
|
*/
|
||||||
function get_user_by( $field, $value ) {
|
function get_user_by( $field, $value ) {
|
||||||
|
if ( 'id' === $field && (int) $value && get_current_user_id() === (int) $value )
|
||||||
|
return wp_get_current_user();
|
||||||
|
|
||||||
$userdata = WP_User::get_data_by( $field, $value );
|
$userdata = WP_User::get_data_by( $field, $value );
|
||||||
|
|
||||||
if ( !$userdata )
|
if ( !$userdata )
|
||||||
|
Loading…
Reference in New Issue
Block a user