| 1 |
<?php |
| 2 |
// If uninstall is not called from WordPress, exit |
| 3 |
if (!defined('WP_UNINSTALL_PLUGIN')) { |
| 4 |
exit(); |
| 5 |
} |
| 6 |
|
| 7 |
// Function to delete options for a specific site |
| 8 |
function wp_db_delete_options_for_site() { |
| 9 |
$wp_db_remove_on_uninstall = get_option('wp_db_remove_on_uninstall', false); |
| 10 |
|
| 11 |
if ($wp_db_remove_on_uninstall) { |
| 12 |
// Remove options |
| 13 |
$options_to_remove = array( |
| 14 |
'wp_db_backup_destination_SFTP', |
| 15 |
'wp_db_backup_destination_FTP', |
| 16 |
'wp_db_backup_destination_Email', |
| 17 |
'wp_db_backup_destination_s3', |
| 18 |
'wp_db_remove_local_backup', |
| 19 |
'wp_db_remove_on_uninstall', |
| 20 |
'wp_db_backup_backup_type', |
| 21 |
'wp_db_backup_exclude_dir', |
| 22 |
'wp_db_backup_backups_dir', |
| 23 |
'wp_db_backup_sftp_details', |
| 24 |
'wpdb_dest_bb_s3_bucket', |
| 25 |
'wpdb_dest_bb_s3_bucket_key', |
| 26 |
'wpdb_dest_bb_s3_bucket_secret', |
| 27 |
'wpdb_dest_bb_s3_bucket_host', |
| 28 |
'wp_db_backup_destination_bb', |
| 29 |
'wp_db_backup_backups', |
| 30 |
'wp_db_backup_options' |
| 31 |
); |
| 32 |
|
| 33 |
foreach ($options_to_remove as $option) { |
| 34 |
delete_option($option); |
| 35 |
} |
| 36 |
} |
| 37 |
} |
| 38 |
|
| 39 |
if (is_multisite()) { |
| 40 |
// Get all sites in the network |
| 41 |
$sites = get_sites(); |
| 42 |
if(!empty($sites) && is_array($sites)) { |
| 43 |
foreach ($sites as $site) { |
| 44 |
switch_to_blog($site->blog_id); |
| 45 |
wp_db_delete_options_for_site(); |
| 46 |
restore_current_blog(); |
| 47 |
} |
| 48 |
} |
| 49 |
|
| 50 |
} else { |
| 51 |
// Single site |
| 52 |
wp_db_delete_options_for_site(); |
| 53 |
} |
| 54 |
|