More efficient is_super_admin(). Don't call new WP_User on the current user. props mdawaffe, fixes #14842.

git-svn-id: https://develop.svn.wordpress.org/trunk@15608 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2010-09-10 23:24:34 +00:00
parent be0b363c5c
commit fc00e5842f

View File

@ -1213,16 +1213,14 @@ function get_super_admins() {
* @return bool True if the user is a site admin.
*/
function is_super_admin( $user_id = false ) {
if ( ! $user_id ) {
$current_user = wp_get_current_user();
$user_id = ! empty($current_user) ? $current_user->id : 0;
}
if ( $user_id )
$user = new WP_User( $user_id );
else
$user = wp_get_current_user();
if ( ! $user_id )
if ( empty( $user->id ) )
return false;
$user = new WP_User($user_id);
if ( is_multisite() ) {
$super_admins = get_super_admins();
if ( is_array( $super_admins ) && in_array( $user->user_login, $super_admins ) )