Use get_current_user() and get_current_user_id() instead of global . Props filofo. see #13934 for trunk

git-svn-id: https://develop.svn.wordpress.org/trunk@15315 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren
2010-06-24 15:01:29 +00:00
parent 3cd056320a
commit 494ee995b5
11 changed files with 56 additions and 62 deletions

View File

@@ -371,7 +371,7 @@ function update_blog_option( $id, $key, $value, $refresh = true ) {
}
function switch_to_blog( $new_blog, $validate = false ) {
global $wpdb, $table_prefix, $blog_id, $switched, $switched_stack, $wp_roles, $current_user, $wp_object_cache;
global $wpdb, $table_prefix, $blog_id, $switched, $switched_stack, $wp_roles, $wp_object_cache;
if ( empty($new_blog) )
$new_blog = $blog_id;
@@ -406,7 +406,8 @@ function switch_to_blog( $new_blog, $validate = false ) {
$wp_roles->__construct();
$wpdb->suppress_errors( false );
}
$current_user = wp_get_current_user();
if ( is_object( $current_user ) )
$current_user->for_blog( $blog_id );
@@ -430,7 +431,7 @@ function switch_to_blog( $new_blog, $validate = false ) {
}
function restore_current_blog() {
global $table_prefix, $wpdb, $blog_id, $switched, $switched_stack, $wp_roles, $current_user, $wp_object_cache;
global $table_prefix, $wpdb, $blog_id, $switched, $switched_stack, $wp_roles, $wp_object_cache;
if ( !$switched )
return false;
@@ -460,6 +461,7 @@ function restore_current_blog() {
$wpdb->suppress_errors( false );
}
$current_user = wp_get_current_user();
if ( is_object( $current_user ) )
$current_user->for_blog( $blog_id );

View File

@@ -372,8 +372,9 @@ function wpmu_admin_redirect_add_updated_param( $url = '' ) {
}
function is_blog_user( $blog_id = 0 ) {
global $current_user, $wpdb;
global $wpdb;
$current_user = wp_get_current_user();
if ( !$blog_id )
$blog_id = $wpdb->blogid;
@@ -1319,8 +1320,7 @@ function fix_phpmailer_messageid( $phpmailer ) {
function is_user_spammy( $username = 0 ) {
if ( $username == 0 ) {
global $current_user;
$user_id = $current_user->ID;
$user_id = get_current_user_id();
} else {
$user_id = get_user_id_from_string( $username );
}
@@ -1360,8 +1360,9 @@ function get_dashboard_blog() {
}
function is_user_option_local( $key, $user_id = 0, $blog_id = 0 ) {
global $current_user, $wpdb;
global $wpdb;
$current_user = wp_get_current_user();
if ( $user_id == 0 )
$user_id = $current_user->ID;
if ( $blog_id == 0 )