update( $wpdb->users, array( $pref => $value ), array( 'ID' => $id ) );
- if ( $refresh == 1 )
- refresh_user_details( $id );
+ $user = new WP_User( $id );
+ clean_user_cache( $user );
if ( $pref == 'spam' ) {
if ( $value == 1 )
@@ -562,7 +389,7 @@ function refresh_user_details( $id ) {
if ( !$user = get_userdata( $id ) )
return false;
- clean_user_cache( $id );
+ clean_user_cache( $user );
return $id;
}
@@ -597,44 +424,41 @@ function sync_category_tag_slugs( $term, $taxonomy ) {
}
add_filter( 'get_term', 'sync_category_tag_slugs', 10, 2 );
-function redirect_user_to_blog() {
- global $current_user;
- $c = 0;
- if ( isset( $_GET['c'] ) )
- $c = (int) $_GET['c'];
+function _access_denied_splash() {
+ if ( ! is_user_logged_in() || is_network_admin() )
+ return;
- if ( $c >= 5 ) {
- wp_die( __( "You don’t have permission to view this site. Please contact the system administrator." ) );
- }
- $c ++;
+ $blogs = get_blogs_of_user( get_current_user_id() );
- $blog = get_active_blog_for_user( $current_user->ID );
- $dashboard_blog = get_dashboard_blog();
- if ( is_object( $blog ) ) {
- wp_redirect( get_admin_url( $blog->blog_id, '?c=' . $c ) ); // redirect and count to 5, "just in case"
- exit;
- }
+ if ( wp_list_filter( $blogs, array( 'userblog_id' => get_current_blog_id() ) ) )
+ return;
- /*
- If the user is a member of only 1 blog and the user's primary_blog isn't set to that blog,
- then update the primary_blog record to match the user's blog
- */
- $blogs = get_blogs_of_user( $current_user->ID );
-
- if ( !empty( $blogs ) ) {
- foreach( $blogs as $blogid => $blog ) {
- if ( $blogid != $dashboard_blog->blog_id && get_user_meta( $current_user->ID , 'primary_blog', true ) == $dashboard_blog->blog_id ) {
- update_user_meta( $current_user->ID, 'primary_blog', $blogid );
- continue;
- }
- }
- $blog = get_blog_details( get_user_meta( $current_user->ID, 'primary_blog', true ) );
- wp_redirect( get_admin_url( $blog->blog_id, '?c=' . $c ) );
- exit;
+ $blog_name = get_bloginfo( 'name' );
+
+ if ( empty( $blogs ) )
+ wp_die( sprintf( __( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ), $blog_name ) );
+
+ $output = '
' . sprintf( __( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ), $blog_name ) . '
';
+ $output .= '
' . __( 'If you reached this screen by accident and meant to visit one of your own sites, here are some shortcuts to help you find your way.' ) . '
', esc_html( $url ) );
- }
-}
-add_action( 'admin_notices', 'admin_notice_feed' );
+add_action( 'network_admin_notices', 'secret_salt_warning' );
function site_admin_notice() {
- global $current_user, $wp_db_version;
+ global $wp_db_version;
if ( !is_super_admin() )
return false;
if ( get_site_option( 'wpmu_upgrade_site' ) != $wp_db_version )
- echo "
" . sprintf( __( 'Thank you for Updating! Please visit the Update Network page to update all your sites.' ), esc_url( admin_url( 'ms-upgrade-network.php' ) ) ) . "
";
+ echo "
" . sprintf( __( 'Thank you for Updating! Please visit the Update Network page to update all your sites.' ), esc_url( network_admin_url( 'upgrade.php' ) ) ) . "
";
}
add_action( 'admin_notices', 'site_admin_notice' );
+add_action( 'network_admin_notices', 'site_admin_notice' );
function avoid_blog_page_permalink_collision( $data, $postarr ) {
if ( is_subdomain_install() )
@@ -760,7 +554,6 @@ function avoid_blog_page_permalink_collision( $data, $postarr ) {
add_filter( 'wp_insert_post_data', 'avoid_blog_page_permalink_collision', 10, 2 );
function choose_primary_blog() {
- global $current_user;
?>
@@ -768,8 +561,8 @@ function choose_primary_blog() {
ID );
- $primary_blog = get_user_meta( $current_user->ID, 'primary_blog', true );
+ $all_blogs = get_blogs_of_user( get_current_user_id() );
+ $primary_blog = get_user_meta( get_current_user_id(), 'primary_blog', true );
if ( count( $all_blogs ) > 1 ) {
$found = false;
?>
@@ -777,19 +570,19 @@ function choose_primary_blog() {
userblog_id )
$found = true;
- ?>
ID, 'primary_blog', $blog->userblog_id );
+ update_user_meta( get_current_user_id(), 'primary_blog', $blog->userblog_id );
}
} elseif ( count( $all_blogs ) == 1 ) {
$blog = array_shift( $all_blogs );
echo $blog->domain;
if ( $primary_blog != $blog->userblog_id ) // Set the primary blog again if it's out of sync with blog list.
- update_user_meta( $current_user->ID, 'primary_blog', $blog->userblog_id );
+ update_user_meta( get_current_user_id(), 'primary_blog', $blog->userblog_id );
} else {
echo "N/A";
}
@@ -799,7 +592,7 @@ function choose_primary_blog() {
-
+
@@ -807,41 +600,11 @@ function choose_primary_blog() {
" . sprintf( __( "Warning! The current theme supports Featured Images. You must enable image uploads on the options page for it to work." ), esc_url( admin_url( 'ms-options.php' ) ) ) . "";
- }
-}
-add_action( 'admin_notices', 'show_post_thumbnail_warning' );
-
-function ms_deprecated_blogs_file() {
- if ( ! is_super_admin() )
- return;
- if ( ! file_exists( WP_CONTENT_DIR . '/blogs.php' ) )
- return;
- echo '
' . sprintf( __( 'The %1$s file is deprecated. Please remove it and update your server rewrite rules to use %2$s instead.' ), 'wp-content/blogs.php', 'wp-includes/ms-files.php' ) . '
';
-}
-add_action( 'admin_notices', 'ms_deprecated_blogs_file' );
-
-/**
- * Outputs the notice message for multisite regarding activation of plugin page.
- *
- * @since 3.0.0
- * @return none
- */
-function _admin_notice_multisite_activate_plugins_page() {
- $message = sprintf( __( 'The plugins page is not visible to normal users. It must be activated first. %s' ), '' . __( 'Activate' ) . '' );
- echo "
$message
";
-}
-
/**
* Grants super admin privileges.
*
* @since 3.0.0
- * @param $user_id
+ * @param int $user_id
*/
function grant_super_admin( $user_id ) {
global $super_admins;
@@ -855,8 +618,8 @@ function grant_super_admin( $user_id ) {
// Directly fetch site_admins instead of using get_super_admins()
$super_admins = get_site_option( 'site_admins', array( 'admin' ) );
- $user = new WP_User( $user_id );
- if ( ! in_array( $user->user_login, $super_admins ) ) {
+ $user = get_userdata( $user_id );
+ if ( $user && ! in_array( $user->user_login, $super_admins ) ) {
$super_admins[] = $user->user_login;
update_site_option( 'site_admins' , $super_admins );
do_action( 'granted_super_admin', $user_id );
@@ -869,7 +632,7 @@ function grant_super_admin( $user_id ) {
* Revokes super admin privileges.
*
* @since 3.0.0
- * @param $user_id
+ * @param int $user_id
*/
function revoke_super_admin( $user_id ) {
global $super_admins;
@@ -883,8 +646,8 @@ function revoke_super_admin( $user_id ) {
// Directly fetch site_admins instead of using get_super_admins()
$super_admins = get_site_option( 'site_admins', array( 'admin' ) );
- $user = new WP_User( $user_id );
- if ( $user->user_email != get_site_option( 'admin_email' ) ) {
+ $user = get_userdata( $user_id );
+ if ( $user && $user->user_email != get_site_option( 'admin_email' ) ) {
if ( false !== ( $key = array_search( $user->user_login, $super_admins ) ) ) {
unset( $super_admins[$key] );
update_site_option( 'site_admins', $super_admins );
@@ -894,4 +657,58 @@ function revoke_super_admin( $user_id ) {
}
return false;
}
+
+/**
+ * Whether or not we can edit this network from this page
+ *
+ * By default editing of network is restricted to the Network Admin for that site_id this allows for this to be overridden
+ *
+ * @since 3.1.0
+ * @param integer $site_id The network/site id to check.
+ */
+function can_edit_network( $site_id ) {
+ global $wpdb;
+
+ if ($site_id == $wpdb->siteid )
+ $result = true;
+ else
+ $result = false;
+
+ return apply_filters( 'can_edit_network', $result, $site_id );
+}
+
+/**
+ * Thickbox image paths for Network Admin.
+ *
+ * @since 3.1.0
+ * @access private
+ */
+function _thickbox_path_admin_subfolder() {
?>
+
+ 10000, 'users', $count );
+ }
+
+ $count = get_blog_count();
+ return apply_filters( 'wp_is_large_network', $count > 10000, 'sites', $count );
+}