X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/699231ae09f7057a4d0000cdf32e50a3df6a04ca..5aa86a9053fb0fa15846bb60aac2fb8fdfff524a:/wp-admin/includes/ms.php diff --git a/wp-admin/includes/ms.php b/wp-admin/includes/ms.php index ae23b7f8..1b2c7e78 100644 --- a/wp-admin/includes/ms.php +++ b/wp-admin/includes/ms.php @@ -53,40 +53,42 @@ add_filter( 'wp_handle_upload_prefilter', 'check_upload_size' ); * @return void */ function wpmu_delete_blog( $blog_id, $drop = false ) { - global $wpdb; + global $wpdb, $current_site; $switch = false; if ( $blog_id != $wpdb->blogid ) { $switch = true; switch_to_blog( $blog_id ); + $blog = get_blog_details( $blog_id ); + } else { + $blog = $GLOBALS['current_blog']; } - $blog_prefix = $wpdb->get_blog_prefix( $blog_id ); - do_action( 'delete_blog', $blog_id, $drop ); - $users = get_users_of_blog( $blog_id ); + $users = get_users( array( 'blog_id' => $blog_id, 'fields' => 'ids' ) ); // Remove users from this blog. if ( ! empty( $users ) ) { - foreach ( $users as $user ) { - remove_user_from_blog( $user->user_id, $blog_id) ; + foreach ( $users as $user_id ) { + remove_user_from_blog( $user_id, $blog_id ); } } update_blog_status( $blog_id, 'deleted', 1 ); + // Don't destroy the initial, main, or root blog. + if ( $drop && ( 1 == $blog_id || is_main_site( $blog_id ) || ( $blog->path == $current_site->path && $blog->domain == $current_site->domain ) ) ) + $drop = false; + if ( $drop ) { - if ( substr( $blog_prefix, -1 ) == '_' ) - $blog_prefix = substr( $blog_prefix, 0, -1 ) . '\_'; - $drop_tables = $wpdb->get_results( "SHOW TABLES LIKE '{$blog_prefix}%'", ARRAY_A ); - $drop_tables = apply_filters( 'wpmu_drop_tables', $drop_tables ); + $drop_tables = apply_filters( 'wpmu_drop_tables', $wpdb->tables( 'blog' ) ); - reset( $drop_tables ); - foreach ( (array) $drop_tables as $drop_table) { - $wpdb->query( "DROP TABLE IF EXISTS ". current( $drop_table ) ."" ); + foreach ( (array) $drop_tables as $table ) { + $wpdb->query( "DROP TABLE IF EXISTS `$table`" ); } + $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->blogs WHERE blog_id = %d", $blog_id ) ); $dir = apply_filters( 'wpmu_delete_blog_upload_dir', WP_CONTENT_DIR . "/blogs.dir/{$blog_id}/files/", $blog_id ); $dir = rtrim( $dir, DIRECTORY_SEPARATOR ); @@ -120,17 +122,7 @@ function wpmu_delete_blog( $blog_id, $drop = false ) { } } - $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key = '{$blog_prefix}autosave_draft_ids'" ); - $blogs = get_site_option( 'blog_list' ); - if ( is_array( $blogs ) ) { - foreach ( $blogs as $n => $blog ) { - if ( $blog['blog_id'] == $blog_id ) - unset( $blogs[$n] ); - } - update_site_option( 'blog_list', $blogs ); - } - - if ( $switch === true ) + if ( $switch ) restore_current_blog(); } @@ -177,72 +169,6 @@ function wpmu_delete_user( $id ) { return true; } -function confirm_delete_users( $users ) { - global $current_user; - if ( !is_array( $users ) ) - return false; - - screen_icon(); - ?> -
- - - id != $_POST['user_id'] ) + if ( $current_user->ID != $_POST['user_id'] ) return false; if ( $current_user->user_email != $_POST['email'] ) { @@ -364,8 +291,7 @@ All at ###SITENAME### add_action( 'personal_options_update', 'send_confirmation_on_profile_email' ); function new_user_email_admin_notice() { - global $current_user; - if ( strpos( $_SERVER['PHP_SELF'], 'profile.php' ) && isset( $_GET['updated'] ) && $email = get_option( $current_user->ID . '_new_email' ) ) + if ( strpos( $_SERVER['PHP_SELF'], 'profile.php' ) && isset( $_GET['updated'] ) && $email = get_option( get_current_user_id() . '_new_email' ) ) echo "%2$sMB' ), esc_url( admin_url( 'upload.php' ) ), $quota ); ?> | -- |
%2$sMB (%3$s%%)' ), esc_url( admin_url( 'upload.php' ) ), $used, $percentused ); ?> | -- |
' . 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.' ) . '
'; + + $output .= '"; + $output .= "{$blog->blogname}"; + $output .= " | "; + $output .= ""; + $output .= "" . __( 'Visit Dashboard' ) . " | " . __( 'View Site' ) . "" ; + $output .= " | "; + $output .= "
" . $content . "" . __( 'Read More' ) . " " . __( 'Dismiss' ) . "
"; - echo "
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;
?>
@@ -783,13 +640,13 @@ function choose_primary_blog() {
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";
}
@@ -807,16 +664,6 @@ 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;
@@ -824,24 +671,13 @@ function ms_deprecated_blogs_file() {
return;
echo ' ' . sprintf( __( 'The ';
}
-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 "%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' ) . '$message |