| @@ -2,26 +2,48 @@ | ||
| 2 | 2 | // If uninstall is not called from WordPress, exit |
| 3 | 3 | if (!defined('WP_UNINSTALL_PLUGIN')) { |
| 4 | 4 | exit(); |
| 5 | 5 | } |
| 6 | -$wp_db_backup_backups_dir = get_option('wp_db_backup_backups_dir'); | |
| 7 | -$wp_db_remove_on_uninstall = get_option('wp_db_remove_on_uninstall',false); | |
| 8 | 6 | |
| 9 | -if($wp_db_remove_on_uninstall){ | |
| 10 | -// Remove options | |
| 11 | - $options_to_remove = array( | |
| 12 | - 'wp_db_backup_destination_SFTP', | |
| 13 | - 'wp_db_backup_destination_FTP', | |
| 14 | - 'wp_db_backup_destination_Email', | |
| 15 | - 'wp_db_backup_destination_s3', | |
| 16 | - 'wp_db_remove_local_backup', | |
| 17 | - 'wp_db_remove_on_uninstall', | |
| 18 | - 'wp_db_backup_backup_type', | |
| 19 | - 'wp_db_backup_exclude_dir', | |
| 20 | - 'wp_db_backup_backups_dir' | |
| 21 | - ); | |
| 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); | |
| 22 | 10 | |
| 23 | - foreach ($options_to_remove as $option) { | |
| 24 | - delete_option($option); | |
| 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 | + | |
| 29 | + ); | |
| 30 | + | |
| 31 | + foreach ($options_to_remove as $option) { | |
| 32 | + delete_option($option); | |
| 33 | + } | |
| 25 | 34 | } |
| 35 | +} | |
| 26 | 36 | |
| 27 | -} | |
| 37 | +if (is_multisite()) { | |
| 38 | + // Get all sites in the network | |
| 39 | + $sites = get_sites(); | |
| 40 | + foreach ($sites as $site) { | |
| 41 | + switch_to_blog($site->blog_id); | |
| 42 | + wp_db_delete_options_for_site(); | |
| 43 | + restore_current_blog(); | |
| 44 | + } | |
| 45 | + | |
| 46 | +} else { | |
| 47 | + // Single site | |
| 48 | + wp_db_delete_options_for_site(); | |
| 49 | +} | |