author | ymh <ymh.work@gmail.com> |
Mon, 14 Oct 2019 18:28:13 +0200 | |
changeset 9 | 177826044cd9 |
parent 7 | cf61fcea0001 |
child 16 | a86126ab1dd4 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
3 |
* Multisite delete site panel. |
|
4 |
* |
|
5 |
* @package WordPress |
|
6 |
* @subpackage Multisite |
|
7 |
* @since 3.0.0 |
|
8 |
*/ |
|
9 |
||
10 |
require_once( dirname( __FILE__ ) . '/admin.php' ); |
|
11 |
||
9 | 12 |
if ( ! is_multisite() ) { |
0 | 13 |
wp_die( __( 'Multisite support is not enabled.' ) ); |
9 | 14 |
} |
0 | 15 |
|
9 | 16 |
if ( ! current_user_can( 'delete_site' ) ) { |
17 |
wp_die( __( 'Sorry, you are not allowed to delete this site.' ) ); |
|
18 |
} |
|
0 | 19 |
|
20 |
if ( isset( $_GET['h'] ) && $_GET['h'] != '' && get_option( 'delete_blog_hash' ) != false ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
21 |
if ( hash_equals( get_option( 'delete_blog_hash' ), $_GET['h'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
22 |
wpmu_delete_blog( get_current_blog_id() ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
23 |
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 ) ); |
0 | 24 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
25 |
wp_die( __( 'Sorry, the link you clicked is stale. Please select another option.' ) ); |
0 | 26 |
} |
27 |
} |
|
28 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
29 |
$blog = get_site(); |
5 | 30 |
$user = wp_get_current_user(); |
0 | 31 |
|
9 | 32 |
$title = __( 'Delete Site' ); |
0 | 33 |
$parent_file = 'tools.php'; |
34 |
require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
|
35 |
||
36 |
echo '<div class="wrap">'; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
37 |
echo '<h1>' . esc_html( $title ) . '</h1>'; |
0 | 38 |
|
39 |
if ( isset( $_POST['action'] ) && $_POST['action'] == 'deleteblog' && isset( $_POST['confirmdelete'] ) && $_POST['confirmdelete'] == '1' ) { |
|
40 |
check_admin_referer( 'delete-blog' ); |
|
41 |
||
42 |
$hash = wp_generate_password( 20, false ); |
|
43 |
update_option( 'delete_blog_hash', $hash ); |
|
44 |
||
45 |
$url_delete = esc_url( admin_url( 'ms-delete-site.php?h=' . $hash ) ); |
|
46 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
47 |
$switched_locale = switch_to_locale( get_locale() ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
48 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
49 |
/* translators: Do not translate USERNAME, URL_DELETE, SITE_NAME: those are placeholders. */ |
9 | 50 |
$content = __( |
51 |
"Howdy ###USERNAME###, |
|
5 | 52 |
|
0 | 53 |
You recently clicked the 'Delete Site' link on your site and filled in a |
54 |
form on that page. |
|
5 | 55 |
|
0 | 56 |
If you really want to delete your site, click the link below. You will not |
57 |
be asked to confirm again so only click this link if you are absolutely certain: |
|
58 |
###URL_DELETE### |
|
59 |
||
60 |
If you delete your site, please consider opening a new site here |
|
61 |
some time in the future! (But remember your current site and username |
|
62 |
are gone forever.) |
|
63 |
||
64 |
Thanks for using the site, |
|
65 |
Webmaster |
|
9 | 66 |
###SITE_NAME###" |
67 |
); |
|
0 | 68 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
69 |
* Filters the email content sent when a site in a Multisite network is deleted. |
0 | 70 |
* |
71 |
* @since 3.0.0 |
|
72 |
* |
|
73 |
* @param string $content The email content that will be sent to the user who deleted a site in a Multisite network. |
|
74 |
*/ |
|
75 |
$content = apply_filters( 'delete_site_email_content', $content ); |
|
76 |
||
5 | 77 |
$content = str_replace( '###USERNAME###', $user->user_login, $content ); |
0 | 78 |
$content = str_replace( '###URL_DELETE###', $url_delete, $content ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
79 |
$content = str_replace( '###SITE_NAME###', get_network()->site_name, $content ); |
0 | 80 |
|
9 | 81 |
wp_mail( get_option( 'admin_email' ), '[ ' . wp_specialchars_decode( get_option( 'blogname' ) ) . ' ] ' . __( 'Delete My Site' ), $content ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
82 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
83 |
if ( $switched_locale ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
84 |
restore_previous_locale(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
85 |
} |
0 | 86 |
?> |
87 |
||
9 | 88 |
<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> |
0 | 89 |
|
9 | 90 |
<?php |
91 |
} else { |
|
0 | 92 |
?> |
9 | 93 |
<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> |
94 |
<p><?php _e( 'Remember, once deleted your site cannot be restored.' ); ?></p> |
|
0 | 95 |
|
96 |
<form method="post" name="deletedirect"> |
|
9 | 97 |
<?php wp_nonce_field( 'delete-blog' ); ?> |
0 | 98 |
<input type="hidden" name="action" value="deleteblog" /> |
9 | 99 |
<p><input id="confirmdelete" type="checkbox" name="confirmdelete" value="1" /> <label for="confirmdelete"><strong> |
100 |
<?php |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
101 |
printf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
102 |
/* translators: %s: site address */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
103 |
__( "I'm sure I want to permanently disable my site, and I am aware I can never get it back or use %s again." ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
104 |
$blog->domain . $blog->path |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
105 |
); |
9 | 106 |
?> |
107 |
</strong></label></p> |
|
0 | 108 |
<?php submit_button( __( 'Delete My Site Permanently' ) ); ?> |
109 |
</form> |
|
9 | 110 |
<?php |
0 | 111 |
} |
112 |
echo '</div>'; |
|
113 |
||
114 |
include( ABSPATH . 'wp-admin/admin-footer.php' ); |