From 194e2775b89c7e5f6aeea5b61cddfcfdd01fad81 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Wed, 17 Oct 2012 18:58:09 +0000 Subject: [PATCH] Don't create {$blog_id}_user-settings, {$blog_id}_user-settings-time, and {$blog_id}_dashboard_quick_press_last_post_id user options when a super admin visits a site they aren't a member of. Instead, rely solely on the wp-settings cookie. fixes #22178 git-svn-id: https://develop.svn.wordpress.org/trunk@22256 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/includes/dashboard.php | 9 ++++++--- wp-includes/option.php | 10 ++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php index fb2ecb0005..d44b298e01 100644 --- a/wp-admin/includes/dashboard.php +++ b/wp-admin/includes/dashboard.php @@ -490,13 +490,16 @@ function wp_dashboard_quick_press() { $post = get_post( $last_post_id ); if ( empty( $post ) || $post->post_status != 'auto-draft' ) { // auto-draft doesn't exists anymore $post = get_default_post_to_edit('post', true); - update_user_option( (int) $GLOBALS['current_user']->ID, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID + update_user_option( get_current_user_id(), 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID } else { $post->post_title = ''; // Remove the auto draft title } } else { - $post = get_default_post_to_edit('post', true); - update_user_option( (int) $GLOBALS['current_user']->ID, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID + $post = get_default_post_to_edit( 'post' , true); + $user_id = get_current_user_id(); + // Don't create an option if this is a super admin who does not belong to this site. + if ( ! ( is_super_admin( $user_id ) && ! in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user_id ) ) ) ) ) + update_user_option( $user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID } $post_ID = (int) $post->ID; diff --git a/wp-includes/option.php b/wp-includes/option.php index 446898101a..7f41d15602 100644 --- a/wp-includes/option.php +++ b/wp-includes/option.php @@ -540,6 +540,11 @@ function wp_user_settings() { if ( ! $user = wp_get_current_user() ) return; + if ( is_super_admin( $user->ID ) && + ! in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user->ID ) ) ) + ) + return; + $settings = get_user_option( 'user-settings', $user->ID ); if ( isset( $_COOKIE['wp-settings-' . $user->ID] ) ) { @@ -697,6 +702,11 @@ function wp_set_all_user_settings($all) { if ( ! $user = wp_get_current_user() ) return false; + if ( is_super_admin( $user->ID ) && + ! in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user->ID ) ) ) + ) + return; + $_updated_user_settings = $all; $settings = ''; foreach ( $all as $k => $v ) {