Ticket #19009: 19009.3.diff
File 19009.3.diff, 2.5 KB (added by , 14 years ago) |
---|
-
wp-admin/includes/ms.php
53 53 * @return void 54 54 */ 55 55 function wpmu_delete_blog( $blog_id, $drop = false ) { 56 global $wpdb ;56 global $wpdb, $current_site; 57 57 58 58 $switch = false; 59 59 if ( $blog_id != $wpdb->blogid ) { 60 60 $switch = true; 61 61 switch_to_blog( $blog_id ); 62 $blog = get_blog_details( $blog_id ); 63 } else { 64 $blog = $GLOBALS['current_blog']; 62 65 } 63 66 64 $blog_prefix = $wpdb->get_blog_prefix( $blog_id );65 66 67 do_action( 'delete_blog', $blog_id, $drop ); 67 68 68 69 $users = get_users( array( 'blog_id' => $blog_id, 'fields' => 'ids' ) ); … … 70 71 // Remove users from this blog. 71 72 if ( ! empty( $users ) ) { 72 73 foreach ( $users as $user_id ) { 73 remove_user_from_blog( $user_id, $blog_id );74 remove_user_from_blog( $user_id, $blog_id ); 74 75 } 75 76 } 76 77 77 78 update_blog_status( $blog_id, 'deleted', 1 ); 78 79 80 // Don't destroy the initial, main, or root blog. 81 if ( $drop && ( 1 == $blog_id || is_main_site( $blog_id ) || ( $blog->path == $current_site->path && $blog->domain == $current_site->domain ) ) ) 82 $drop = false; 83 79 84 if ( $drop ) { 80 if ( substr( $blog_prefix, -1 ) == '_' )81 $blog_prefix = substr( $blog_prefix, 0, -1 ) . '\_';82 85 83 $drop_tables = $wpdb->get_results( "SHOW TABLES LIKE '{$blog_prefix}%'", ARRAY_A ); 84 $drop_tables = apply_filters( 'wpmu_drop_tables', $drop_tables ); 86 $drop_tables = apply_filters( 'wpmu_drop_tables', $wpdb->tables( 'blog' ) ); 85 87 86 reset( $drop_tables ); 87 foreach ( (array) $drop_tables as $drop_table) { 88 $wpdb->query( "DROP TABLE IF EXISTS ". current( $drop_table ) ."" ); 88 foreach ( (array) $drop_tables as $table ) { 89 $wpdb->query( "DROP TABLE IF EXISTS `$table`" ); 89 90 } 91 90 92 $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->blogs WHERE blog_id = %d", $blog_id ) ); 91 93 $dir = apply_filters( 'wpmu_delete_blog_upload_dir', WP_CONTENT_DIR . "/blogs.dir/{$blog_id}/files/", $blog_id ); 92 94 $dir = rtrim( $dir, DIRECTORY_SEPARATOR ); … … 120 122 } 121 123 } 122 124 123 $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key = '{$blog_prefix}autosave_draft_ids'" );124 $blogs = get_site_option( 'blog_list' );125 if ( is_array( $blogs ) ) {126 foreach ( $blogs as $n => $blog ) {127 if ( $blog['blog_id'] == $blog_id )128 unset( $blogs[$n] );129 }130 update_site_option( 'blog_list', $blogs );131 }132 133 125 if ( $switch === true ) 134 126 restore_current_blog(); 135 127 }