wp/wp-admin/ms-delete-site.php
author ymh <ymh.work@gmail.com>
Tue, 09 Jun 2015 03:35:32 +0200
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 7 cf61fcea0001
permissions -rw-r--r--
upgrade wordpress + plugins
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
 * Multisite delete site panel.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
 * @package WordPress
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
 * @subpackage Multisite
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
require_once( dirname( __FILE__ ) . '/admin.php' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
if ( !is_multisite() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
	wp_die( __( 'Multisite support is not enabled.' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    15
if ( ! current_user_can( 'delete_site' ) )
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
	wp_die(__( 'You do not have sufficient permissions to delete this site.'));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
if ( isset( $_GET['h'] ) && $_GET['h'] != '' && get_option( 'delete_blog_hash' ) != false ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
	if ( get_option( 'delete_blog_hash' ) == $_GET['h'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
		wpmu_delete_blog( $wpdb->blogid );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    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 ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
		wp_die( __( "I'm sorry, the link you clicked is stale. Please select another option." ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
$blog = get_blog_details();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    28
$user = wp_get_current_user();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
$title = __( 'Delete Site' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
$parent_file = 'tools.php';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
require_once( ABSPATH . 'wp-admin/admin-header.php' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
echo '<div class="wrap">';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
echo '<h2>' . esc_html( $title ) . '</h2>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
if ( isset( $_POST['action'] ) && $_POST['action'] == 'deleteblog' && isset( $_POST['confirmdelete'] ) && $_POST['confirmdelete'] == '1' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
	check_admin_referer( 'delete-blog' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
	$hash = wp_generate_password( 20, false );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
	update_option( 'delete_blog_hash', $hash );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
	$url_delete = esc_url( admin_url( 'ms-delete-site.php?h=' . $hash ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    45
	$content = __( "Howdy ###USERNAME###,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    46
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
You recently clicked the 'Delete Site' link on your site and filled in a
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
form on that page.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    49
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
If you really want to delete your site, click the link below. You will not
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
be asked to confirm again so only click this link if you are absolutely certain:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
###URL_DELETE###
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
If you delete your site, please consider opening a new site here
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
some time in the future! (But remember your current site and username
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
are gone forever.)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
Thanks for using the site,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
Webmaster
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    60
###SITE_NAME###" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    62
	 * Filter the email content sent when a site in a Multisite network is deleted.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
	 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
	 * @param string $content The email content that will be sent to the user who deleted a site in a Multisite network.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
	$content = apply_filters( 'delete_site_email_content', $content );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    70
	$content = str_replace( '###USERNAME###', $user->user_login, $content );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
	$content = str_replace( '###URL_DELETE###', $url_delete, $content );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
	$content = str_replace( '###SITE_NAME###', $current_site->site_name, $content );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    74
	wp_mail( get_option( 'admin_email' ), "[ " . wp_specialchars_decode( get_option( 'blogname' ) ) . " ] ".__( 'Delete My Site' ), $content );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
	?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    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>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
<?php } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
	?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    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>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
	<p><?php _e( 'Remember, once deleted your site cannot be restored.' ) ?></p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
	<form method="post" name="deletedirect">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
		<?php wp_nonce_field( 'delete-blog' ) ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    86
		<input type="hidden" name="action" value="deleteblog" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    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>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
		<?php submit_button( __( 'Delete My Site Permanently' ) ); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
	</form>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
 	<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
echo '</div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    93
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    94
include( ABSPATH . 'wp-admin/admin-footer.php' );