wp/wp-admin/ms-delete-site.php
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 7 cf61fcea0001
equal deleted inserted replaced
4:346c88efed21 5:5e2f62d02dcd
    10 require_once( dirname( __FILE__ ) . '/admin.php' );
    10 require_once( dirname( __FILE__ ) . '/admin.php' );
    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 // @todo Create a delete blog cap.
    15 if ( ! current_user_can( 'delete_site' ) )
    16 if ( ! current_user_can( 'manage_options' ) )
       
    17 	wp_die(__( 'You do not have sufficient permissions to delete this site.'));
    16 	wp_die(__( 'You do not have sufficient permissions to delete this site.'));
    18 
    17 
    19 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 ) {
    20 	if ( get_option( 'delete_blog_hash' ) == $_GET['h'] ) {
    19 	if ( get_option( 'delete_blog_hash' ) == $_GET['h'] ) {
    21 		wpmu_delete_blog( $wpdb->blogid );
    20 		wpmu_delete_blog( $wpdb->blogid );
    24 		wp_die( __( "I'm sorry, the link you clicked is stale. Please select another option." ) );
    23 		wp_die( __( "I'm sorry, the link you clicked is stale. Please select another option." ) );
    25 	}
    24 	}
    26 }
    25 }
    27 
    26 
    28 $blog = get_blog_details();
    27 $blog = get_blog_details();
       
    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 screen_icon();
       
    36 echo '<h2>' . esc_html( $title ) . '</h2>';
    35 echo '<h2>' . esc_html( $title ) . '</h2>';
    37 
    36 
    38 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' ) {
    39 	check_admin_referer( 'delete-blog' );
    38 	check_admin_referer( 'delete-blog' );
    40 
    39 
    41 	$hash = wp_generate_password( 20, false );
    40 	$hash = wp_generate_password( 20, false );
    42 	update_option( 'delete_blog_hash', $hash );
    41 	update_option( 'delete_blog_hash', $hash );
    43 
    42 
    44 	$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 ) );
    45 
    44 
    46 	$content = __( "Dear User,
    45 	$content = __( "Howdy ###USERNAME###,
       
    46 
    47 You recently clicked the 'Delete Site' link on your site and filled in a
    47 You recently clicked the 'Delete Site' link on your site and filled in a
    48 form on that page.
    48 form on that page.
       
    49 
    49 If you really want to delete your site, click the link below. You will not
    50 If you really want to delete your site, click the link below. You will not
    50 be asked to confirm again so only click this link if you are absolutely certain:
    51 be asked to confirm again so only click this link if you are absolutely certain:
    51 ###URL_DELETE###
    52 ###URL_DELETE###
    52 
    53 
    53 If you delete your site, please consider opening a new site here
    54 If you delete your site, please consider opening a new site here
    64 	 *
    65 	 *
    65 	 * @param string $content The email content that will be sent to the user who deleted a site in a Multisite network.
    66 	 * @param string $content The email content that will be sent to the user who deleted a site in a Multisite network.
    66 	 */
    67 	 */
    67 	$content = apply_filters( 'delete_site_email_content', $content );
    68 	$content = apply_filters( 'delete_site_email_content', $content );
    68 
    69 
       
    70 	$content = str_replace( '###USERNAME###', $user->user_login, $content );
    69 	$content = str_replace( '###URL_DELETE###', $url_delete, $content );
    71 	$content = str_replace( '###URL_DELETE###', $url_delete, $content );
    70 	$content = str_replace( '###SITE_NAME###', $current_site->site_name, $content );
    72 	$content = str_replace( '###SITE_NAME###', $current_site->site_name, $content );
    71 
    73 
    72 	wp_mail( get_option( 'admin_email' ), "[ " . get_option( 'blogname' ) . " ] ".__( 'Delete My Site' ), $content );
    74 	wp_mail( get_option( 'admin_email' ), "[ " . wp_specialchars_decode( get_option( 'blogname' ) ) . " ] ".__( 'Delete My Site' ), $content );
    73 	?>
    75 	?>
    74 
    76 
    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>
    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>
    76 
    78 
    77 <?php } else {
    79 <?php } else {