Ticket #14842: 14842.next-iteration.patch
File 14842.next-iteration.patch, 1.6 KB (added by , 14 years ago) |
---|
-
wp-includes/capabilities.php
206 206 * @access public 207 207 * 208 208 * @param string $role Role name. 209 * @return object|null Null, if role does not exist. WP_Role object, if found.209 * @return WP_Role|null Null, if role does not exist. WP_Role object, if found. 210 210 */ 211 211 function &get_role( $role ) { 212 212 if ( isset( $this->role_objects[$role] ) ) … … 1137 1137 * @since 2.0.0 1138 1138 * 1139 1139 * @param string $role Role name. 1140 * @return object1140 * @return WP_Role|null Null, if role does not exist. WP_Role object, if found. 1141 1141 */ 1142 1142 function get_role( $role ) { 1143 1143 global $wp_roles; … … 1213 1213 * @return bool True if the user is a site admin. 1214 1214 */ 1215 1215 function is_super_admin( $user_id = false ) { 1216 if ( $user_id ) 1217 $user = new WP_User( $user_id ); 1218 else 1219 $user = wp_get_current_user(); 1216 $user = $user_id 1217 ? new WP_User( $user_id ) 1218 : wp_get_current_user(); 1220 1219 1221 if ( empty( $user->id ) ) 1220 // invalid users are never superadmins 1221 if ( empty ( $user->id ) ) 1222 1222 return false; 1223 1223 1224 if ( is_multisite() ) { 1225 $super_admins = get_super_admins(); 1226 if ( is_array( $super_admins ) && in_array( $user->user_login, $super_admins ) ) 1227 return true; 1228 } else { 1229 if ( $user->has_cap('delete_users') ) 1230 return true; 1231 } 1224 // multisite 1225 if ( is_multisite() ) 1226 return ( $super_admins = array_flip( get_super_admins() ) ) 1227 && isset ( $super_admins[ $user->user_login ] ); 1232 1228 1233 return false; 1229 // singlesite 1230 return $user->has_cap('delete_users'); 1234 1231 } 1235 1232 1236 1233 ?>