Make current_user_can_for_blog() safe to run single site.

Props nacin, MarkJaquith
fixes #22803


git-svn-id: http://core.svn.wordpress.org/trunk@23117 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Ryan Boren 2012-12-07 09:53:27 +00:00
parent 4e22d6fbab
commit 54ac1d939b
2 changed files with 5 additions and 3 deletions

View File

@ -1299,7 +1299,8 @@ function current_user_can( $capability ) {
* @return bool
*/
function current_user_can_for_blog( $blog_id, $capability ) {
switch_to_blog( $blog_id );
if ( is_multisite() )
switch_to_blog( $blog_id );
$current_user = wp_get_current_user();
@ -1311,7 +1312,8 @@ function current_user_can_for_blog( $blog_id, $capability ) {
$can = call_user_func_array( array( $current_user, 'has_cap' ), $args );
restore_current_blog();
if ( is_multisite() )
restore_current_blog();
return $can;
}

View File

@ -1104,7 +1104,7 @@ final class WP_Theme implements ArrayAccess {
public static function get_allowed_on_site( $blog_id = null ) {
static $allowed_themes = array();
if ( ! $blog_id )
if ( ! $blog_id || ! is_multisite() )
$blog_id = get_current_blog_id();
if ( isset( $allowed_themes[ $blog_id ] ) )