11 |
11 |
12 if ( !is_multisite() ) |
12 if ( !is_multisite() ) |
13 wp_die( __( 'Multisite support is not enabled.' ) ); |
13 wp_die( __( 'Multisite support is not enabled.' ) ); |
14 |
14 |
15 if ( ! current_user_can( 'delete_site' ) ) |
15 if ( ! current_user_can( 'delete_site' ) ) |
16 wp_die(__( 'You do not have sufficient permissions to delete this site.')); |
16 wp_die(__( 'Sorry, you are not allowed to delete this site.')); |
17 |
17 |
18 if ( isset( $_GET['h'] ) && $_GET['h'] != '' && get_option( 'delete_blog_hash' ) != false ) { |
18 if ( isset( $_GET['h'] ) && $_GET['h'] != '' && get_option( 'delete_blog_hash' ) != false ) { |
19 if ( get_option( 'delete_blog_hash' ) == $_GET['h'] ) { |
19 if ( hash_equals( get_option( 'delete_blog_hash' ), $_GET['h'] ) ) { |
20 wpmu_delete_blog( $wpdb->blogid ); |
20 wpmu_delete_blog( get_current_blog_id() ); |
21 wp_die( sprintf( __( 'Thank you for using %s, your site has been deleted. Happy trails to you until we meet again.' ), $current_site->site_name ) ); |
21 wp_die( sprintf( __( 'Thank you for using %s, your site has been deleted. Happy trails to you until we meet again.' ), get_network()->site_name ) ); |
22 } else { |
22 } else { |
23 wp_die( __( "I'm sorry, the link you clicked is stale. Please select another option." ) ); |
23 wp_die( __( 'Sorry, the link you clicked is stale. Please select another option.' ) ); |
24 } |
24 } |
25 } |
25 } |
26 |
26 |
27 $blog = get_blog_details(); |
27 $blog = get_site(); |
28 $user = wp_get_current_user(); |
28 $user = wp_get_current_user(); |
29 |
29 |
30 $title = __( 'Delete Site' ); |
30 $title = __( 'Delete Site' ); |
31 $parent_file = 'tools.php'; |
31 $parent_file = 'tools.php'; |
32 require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
32 require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
33 |
33 |
34 echo '<div class="wrap">'; |
34 echo '<div class="wrap">'; |
35 echo '<h2>' . esc_html( $title ) . '</h2>'; |
35 echo '<h1>' . esc_html( $title ) . '</h1>'; |
36 |
36 |
37 if ( isset( $_POST['action'] ) && $_POST['action'] == 'deleteblog' && isset( $_POST['confirmdelete'] ) && $_POST['confirmdelete'] == '1' ) { |
37 if ( isset( $_POST['action'] ) && $_POST['action'] == 'deleteblog' && isset( $_POST['confirmdelete'] ) && $_POST['confirmdelete'] == '1' ) { |
38 check_admin_referer( 'delete-blog' ); |
38 check_admin_referer( 'delete-blog' ); |
39 |
39 |
40 $hash = wp_generate_password( 20, false ); |
40 $hash = wp_generate_password( 20, false ); |
41 update_option( 'delete_blog_hash', $hash ); |
41 update_option( 'delete_blog_hash', $hash ); |
42 |
42 |
43 $url_delete = esc_url( admin_url( 'ms-delete-site.php?h=' . $hash ) ); |
43 $url_delete = esc_url( admin_url( 'ms-delete-site.php?h=' . $hash ) ); |
44 |
44 |
|
45 $switched_locale = switch_to_locale( get_locale() ); |
|
46 |
|
47 /* translators: Do not translate USERNAME, URL_DELETE, SITE_NAME: those are placeholders. */ |
45 $content = __( "Howdy ###USERNAME###, |
48 $content = __( "Howdy ###USERNAME###, |
46 |
49 |
47 You recently clicked the 'Delete Site' link on your site and filled in a |
50 You recently clicked the 'Delete Site' link on your site and filled in a |
48 form on that page. |
51 form on that page. |
49 |
52 |
57 |
60 |
58 Thanks for using the site, |
61 Thanks for using the site, |
59 Webmaster |
62 Webmaster |
60 ###SITE_NAME###" ); |
63 ###SITE_NAME###" ); |
61 /** |
64 /** |
62 * Filter the email content sent when a site in a Multisite network is deleted. |
65 * Filters the email content sent when a site in a Multisite network is deleted. |
63 * |
66 * |
64 * @since 3.0.0 |
67 * @since 3.0.0 |
65 * |
68 * |
66 * @param string $content The email content that will be sent to the user who deleted a site in a Multisite network. |
69 * @param string $content The email content that will be sent to the user who deleted a site in a Multisite network. |
67 */ |
70 */ |
68 $content = apply_filters( 'delete_site_email_content', $content ); |
71 $content = apply_filters( 'delete_site_email_content', $content ); |
69 |
72 |
70 $content = str_replace( '###USERNAME###', $user->user_login, $content ); |
73 $content = str_replace( '###USERNAME###', $user->user_login, $content ); |
71 $content = str_replace( '###URL_DELETE###', $url_delete, $content ); |
74 $content = str_replace( '###URL_DELETE###', $url_delete, $content ); |
72 $content = str_replace( '###SITE_NAME###', $current_site->site_name, $content ); |
75 $content = str_replace( '###SITE_NAME###', get_network()->site_name, $content ); |
73 |
76 |
74 wp_mail( get_option( 'admin_email' ), "[ " . wp_specialchars_decode( get_option( 'blogname' ) ) . " ] ".__( 'Delete My Site' ), $content ); |
77 wp_mail( get_option( 'admin_email' ), "[ " . wp_specialchars_decode( get_option( 'blogname' ) ) . " ] ".__( 'Delete My Site' ), $content ); |
|
78 |
|
79 if ( $switched_locale ) { |
|
80 restore_previous_locale(); |
|
81 } |
75 ?> |
82 ?> |
76 |
83 |
77 <p><?php _e( 'Thank you. Please check your email for a link to confirm your action. Your site will not be deleted until this link is clicked. ') ?></p> |
84 <p><?php _e( 'Thank you. Please check your email for a link to confirm your action. Your site will not be deleted until this link is clicked.' ) ?></p> |
78 |
85 |
79 <?php } else { |
86 <?php } else { |
80 ?> |
87 ?> |
81 <p><?php printf( __( 'If you do not want to use your %s site any more, you can delete it using the form below. When you click <strong>Delete My Site Permanently</strong> you will be sent an email with a link in it. Click on this link to delete your site.'), $current_site->site_name); ?></p> |
88 <p><?php printf( __( 'If you do not want to use your %s site any more, you can delete it using the form below. When you click <strong>Delete My Site Permanently</strong> you will be sent an email with a link in it. Click on this link to delete your site.'), get_network()->site_name); ?></p> |
82 <p><?php _e( 'Remember, once deleted your site cannot be restored.' ) ?></p> |
89 <p><?php _e( 'Remember, once deleted your site cannot be restored.' ) ?></p> |
83 |
90 |
84 <form method="post" name="deletedirect"> |
91 <form method="post" name="deletedirect"> |
85 <?php wp_nonce_field( 'delete-blog' ) ?> |
92 <?php wp_nonce_field( 'delete-blog' ) ?> |
86 <input type="hidden" name="action" value="deleteblog" /> |
93 <input type="hidden" name="action" value="deleteblog" /> |
87 <p><input id="confirmdelete" type="checkbox" name="confirmdelete" value="1" /> <label for="confirmdelete"><strong><?php printf( __( "I'm sure I want to permanently disable my site, and I am aware I can never get it back or use %s again." ), is_subdomain_install() ? $blog->domain : $blog->domain . $blog->path ); ?></strong></label></p> |
94 <p><input id="confirmdelete" type="checkbox" name="confirmdelete" value="1" /> <label for="confirmdelete"><strong><?php |
|
95 printf( |
|
96 /* translators: %s: site address */ |
|
97 __( "I'm sure I want to permanently disable my site, and I am aware I can never get it back or use %s again." ), |
|
98 $blog->domain . $blog->path |
|
99 ); |
|
100 ?></strong></label></p> |
88 <?php submit_button( __( 'Delete My Site Permanently' ) ); ?> |
101 <?php submit_button( __( 'Delete My Site Permanently' ) ); ?> |
89 </form> |
102 </form> |
90 <?php |
103 <?php |
91 } |
104 } |
92 echo '</div>'; |
105 echo '</div>'; |