backup-backup
Last commit date
admin
2 years ago
analyst
2 years ago
includes
2 years ago
modules
2 years ago
backup-backup.php
2 years ago
readme.txt
2 years ago
uninstall.php
2 years ago
uninstall.php
71 lines
| 1 | <?php |
| 2 | |
| 3 | // Namespace |
| 4 | namespace BMI\Plugin\Uninstaller; |
| 5 | |
| 6 | // Exit on direct access |
| 7 | if (!defined('ABSPATH')) exit; |
| 8 | |
| 9 | // Get config |
| 10 | $dir = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'backup-migration' . DIRECTORY_SEPARATOR; |
| 11 | $config = $dir . 'config.json'; |
| 12 | if (file_exists($config)) { |
| 13 | $config = json_decode(file_get_contents($config)); |
| 14 | if (json_last_error() == JSON_ERROR_NONE) { |
| 15 | |
| 16 | if (isset($config->{'OTHER:UNINSTALL:BACKUPS'})) { |
| 17 | if ($config->{'OTHER:UNINSTALL:BACKUPS'} === 'true' || $config->{'OTHER:UNINSTALL:BACKUPS'} === true) { |
| 18 | if (isset($config->{'STORAGE::LOCAL::PATH'})) { |
| 19 | if ($config->{'STORAGE::LOCAL::PATH'} == 'default') { |
| 20 | $backups = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'backup-migration' . DIRECTORY_SEPARATOR . 'backups'; |
| 21 | } else { |
| 22 | $backups = $config->{'STORAGE::LOCAL::PATH'} . DIRECTORY_SEPARATOR . 'backups'; |
| 23 | } |
| 24 | |
| 25 | if (file_exists($backups) && is_dir($backups)) { |
| 26 | |
| 27 | $files = scandir($backups); |
| 28 | for ($i = 0; $i < sizeof($files); ++$i) { |
| 29 | |
| 30 | $file = $backups . DIRECTORY_SEPARATOR . $files[$i]; |
| 31 | if (is_file($file) && !in_array($files[$i], ['.', '..'])) { |
| 32 | @unlink($file); |
| 33 | } |
| 34 | |
| 35 | } |
| 36 | |
| 37 | $files = scandir($backups); |
| 38 | if (sizeof($files) <= 2) rmdir($backups); |
| 39 | |
| 40 | } |
| 41 | } |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | if (isset($config->{'OTHER:UNINSTALL:CONFIGS'})) { |
| 46 | if ($config->{'OTHER:UNINSTALL:CONFIGS'} === 'true' || $config->{'OTHER:UNINSTALL:CONFIGS'} === true) { |
| 47 | |
| 48 | $files = scandir($dir); |
| 49 | for ($i = 0; $i < sizeof($files); ++$i) { |
| 50 | |
| 51 | $file = $dir . DIRECTORY_SEPARATOR . $files[$i]; |
| 52 | if (is_file($file) && !in_array($files[$i], ['.', '..'])) { |
| 53 | @unlink($file); |
| 54 | } |
| 55 | |
| 56 | } |
| 57 | |
| 58 | $files = scandir($dir); |
| 59 | if (sizeof($files) <= 2) rmdir($dir); |
| 60 | |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | } |
| 65 | |
| 66 | if (function_exists('delete_option')) { |
| 67 | delete_option('bmi_pro_gd_client_id'); |
| 68 | delete_option('bmi_pro_gd_token'); |
| 69 | } |
| 70 | } |
| 71 |