Changeset 19038
- Timestamp:
- 10/21/2011 10:04:52 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/ms.php
r18871 r19038 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; … … 60 60 $switch = true; 61 61 switch_to_blog( $blog_id ); 62 } 63 64 $blog_prefix = $wpdb->get_blog_prefix( $blog_id ); 62 $blog = get_blog_details( $blog_id ); 63 } else { 64 $blog = $GLOBALS['current_blog']; 65 } 65 66 66 67 do_action( 'delete_blog', $blog_id, $drop ); … … 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 } … … 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 83 $drop_tables = $wpdb->get_results( "SHOW TABLES LIKE '{$blog_prefix}%'", ARRAY_A ); 84 $drop_tables = apply_filters( 'wpmu_drop_tables', $drop_tables ); 85 86 reset( $drop_tables ); 87 foreach ( (array) $drop_tables as $drop_table) { 88 $wpdb->query( "DROP TABLE IF EXISTS ". current( $drop_table ) ."" ); 89 } 85 86 $drop_tables = apply_filters( 'wpmu_drop_tables', $wpdb->tables( 'blog' ) ); 87 88 foreach ( (array) $drop_tables as $table ) { 89 $wpdb->query( "DROP TABLE IF EXISTS `$table`" ); 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 ); … … 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 if ( $switch === true ) 125 if ( $switch ) 134 126 restore_current_blog(); 135 127 }
Note: See TracChangeset
for help on using the changeset viewer.