From ca725961c59b82b0f6e778ed6d7b6699ee26726e Mon Sep 17 00:00:00 2001 From: nacin Date: Fri, 10 Sep 2010 23:24:34 +0000 Subject: [PATCH] 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 --- wp-includes/capabilities.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/wp-includes/capabilities.php b/wp-includes/capabilities.php index 1474b82053..a1b3dc75b1 100644 --- a/wp-includes/capabilities.php +++ b/wp-includes/capabilities.php @@ -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 ) )