wpmu_delete_blog example

$updated_action = '';

    switch ( $_GET['action'] ) {

        case 'deleteblog':
            if ( ! current_user_can( 'delete_sites' ) ) {
                wp_die( __( 'Sorry, you are not allowed to access this page.' ), '', array( 'response' => 403 ) );
            }

            $updated_action = 'not_deleted';
            if ( 0 !== $id && ! is_main_site( $id ) && current_user_can( 'delete_site', $id ) ) {
                wpmu_delete_blog( $id, true );
                $updated_action = 'delete';
            }
            break;

        case 'delete_sites':
            check_admin_referer( 'ms-delete-sites' );

            foreach ( (array) $_POST['site_ids'] as $site_id ) {
                $site_id = (int) $site_id;

                if ( is_main_site( $site_id ) ) {
                    
if ( ! is_multisite() ) {
    wp_die( __( 'Multisite support is not enabled.' ) );
}

if ( ! current_user_can( 'delete_site' ) ) {
    wp_die( __( 'Sorry, you are not allowed to delete this site.' ) );
}

if ( isset( $_GET['h'] ) && '' !== $_GET['h'] && false !== get_option( 'delete_blog_hash' ) ) {
    if ( hash_equals( get_option( 'delete_blog_hash' )$_GET['h'] ) ) {
        wpmu_delete_blog( get_current_blog_id() );
        wp_die(
            sprintf(
                /* translators: %s: Network title. */
                __( 'Thank you for using %s, your site has been deleted. Happy trails to you until we meet again.' ),
                get_network()->site_name
            )
        );
    } else {
        wp_die( __( 'Sorry, the link you clicked is stale. Please select another option.' ) );
    }
}

Home | Imprint | This part of the site doesn't use cookies.