# wp-database-backup/7.0/uninstall.php

WP Database Backup – Unlimited Database &amp; Files Backup by Backup for WP, version 7.0. 54 lines.

- Page: https://pluginprobe.com/plugins/wp-database-backup/7.0/code/uninstall.php
- Raw: https://pluginprobe.com/plugins/wp-database-backup/7.0/raw/uninstall.php
- Modified: 2024-08-27T10:11:26+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/wp-database-backup/7.0/code/uninstall.php#L10-L20`.

```php
<?php
// If uninstall is not called from WordPress, exit
if (!defined('WP_UNINSTALL_PLUGIN')) {
    exit();
}

// Function to delete options for a specific site
function wp_db_delete_options_for_site() {
    $wp_db_remove_on_uninstall = get_option('wp_db_remove_on_uninstall', false);

    if ($wp_db_remove_on_uninstall) { 
        // Remove options
        $options_to_remove = array(
            'wp_db_backup_destination_SFTP',
            'wp_db_backup_destination_FTP',
            'wp_db_backup_destination_Email',
            'wp_db_backup_destination_s3',
            'wp_db_remove_local_backup',
            'wp_db_remove_on_uninstall',
            'wp_db_backup_backup_type',
            'wp_db_backup_exclude_dir',
            'wp_db_backup_backups_dir',
            'wp_db_backup_sftp_details',
            'wpdb_dest_bb_s3_bucket',
            'wpdb_dest_bb_s3_bucket_key',
            'wpdb_dest_bb_s3_bucket_secret',
            'wpdb_dest_bb_s3_bucket_host',
            'wp_db_backup_destination_bb',
            'wp_db_backup_backups',
            'wp_db_backup_options'
        );

        foreach ($options_to_remove as $option) {
            delete_option($option);
        }
    }
}

if (is_multisite()) {
    // Get all sites in the network
    $sites = get_sites();
    if(!empty($sites) && is_array($sites)) {
        foreach ($sites as $site) {
            switch_to_blog($site->blog_id);
            wp_db_delete_options_for_site();
            restore_current_blog();
        }
    }

} else {
    // Single site
    wp_db_delete_options_for_site();
}

```
