wp/wp-admin/ms-delete-site.php
author ymh <ymh.work@gmail.com>
Thu, 07 Nov 2013 00:08:07 +0000
changeset 1 f6eb5a861d2f
parent 0 d970ebf37754
child 5 5e2f62d02dcd
permissions -rw-r--r--
remove unnessary files. Make timthumb work
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
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
// @todo Create a delete blog cap.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
if ( ! current_user_can( 'manage_options' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
	wp_die(__( 'You do not have sufficient permissions to delete this site.'));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
if ( isset( $_GET['h'] ) && $_GET['h'] != '' && get_option( 'delete_blog_hash' ) != false ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
	if ( get_option( 'delete_blog_hash' ) == $_GET['h'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
		wpmu_delete_blog( $wpdb->blogid );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
		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
    23
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
		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
    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
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
$blog = get_blog_details();
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
screen_icon();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
echo '<h2>' . esc_html( $title ) . '</h2>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
if ( isset( $_POST['action'] ) && $_POST['action'] == 'deleteblog' && isset( $_POST['confirmdelete'] ) && $_POST['confirmdelete'] == '1' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
	check_admin_referer( 'delete-blog' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
	$hash = wp_generate_password( 20, false );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
	update_option( 'delete_blog_hash', $hash );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
	$url_delete = esc_url( admin_url( 'ms-delete-site.php?h=' . $hash ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
	$content = __( "Dear User,
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.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
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
    50
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
    51
###URL_DELETE###
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
If you delete your site, please consider opening a new site here
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
some time in the future! (But remember your current site and username
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
are gone forever.)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
Thanks for using the site,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
Webmaster
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
###SITE_NAME###" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    60
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
	 * 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
    62
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
	 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
	 * @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
    66
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
	$content = apply_filters( 'delete_site_email_content', $content );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
	$content = str_replace( '###URL_DELETE###', $url_delete, $content );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
	$content = str_replace( '###SITE_NAME###', $current_site->site_name, $content );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
	wp_mail( get_option( 'admin_email' ), "[ " . get_option( 'blogname' ) . " ] ".__( 'Delete My Site' ), $content );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
	?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
	<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
    76
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
<?php } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
	?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
	<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
    80
	<p><?php _e( 'Remember, once deleted your site cannot be restored.' ) ?></p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
	<form method="post" name="deletedirect">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
		<?php wp_nonce_field( 'delete-blog' ) ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
		<input type="hidden" name="action" value="deleteblog" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
		<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
    86
		<?php submit_button( __( 'Delete My Site Permanently' ) ); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
	</form>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
 	<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
echo '</div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
include( ABSPATH . 'wp-admin/admin-footer.php' );