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

git-svn-id: http://svn.automattic.com/wordpress/trunk@15608 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2010-09-10 23:24:34 +00:00
parent 4850c82d1c
commit ca725961c5
1 changed files with 5 additions and 7 deletions

View File

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