PluginProbe ʕ •ᴥ•ʔ
Backup Migration / 1.4.9
Backup Migration v1.4.9
2.1.6 2.1.5.2 trunk 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.6.1 1.4.7 1.4.8 1.4.9 1.4.9.1 2.0.0 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.5.1
backup-backup / uninstall.php
backup-backup Last commit date
admin 11 months ago analyst 11 months ago includes 11 months ago modules 11 months ago backup-backup.php 11 months ago readme.txt 11 months ago uninstall.php 11 months ago
uninstall.php
62 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 file
10 $configFile = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'backup-migration-config.php';
11
12 if (!file_exists($configFile)) {
13 return;
14 }
15
16 $config = file_get_contents($configFile);
17 $config = json_decode(substr($config, 8), true);
18
19
20 $deleteBackups = $config['OTHER:UNINSTALL:BACKUPS'];
21 $deleteConfigs = $config['OTHER:UNINSTALL:CONFIGS'];
22
23
24 if ($deleteBackups === 'true' || $deleteBackups === true) {
25 $backupsPath = $config['STORAGE::LOCAL::PATH'];
26 $backupsPath = $backupsPath . DIRECTORY_SEPARATOR . 'backups';
27
28 if (file_exists($backupsPath) && is_dir($backupsPath)) {
29
30 $files = scandir($backupsPath);
31 for ($i = 0; $i < sizeof($files); ++$i) {
32
33 $file = $backupsPath . DIRECTORY_SEPARATOR . $files[$i];
34 if (is_file($file) && !in_array($files[$i], ['.', '..'])) {
35 @unlink($file);
36 }
37
38 }
39
40 $files = scandir($backupsPath);
41 if (sizeof($files) <= 2) rmdir($backupsPath);
42
43 }
44 }
45
46 if ($deleteConfigs === 'true' || $deleteConfigs === true) {
47 $configFile = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'backup-migration-config.php';
48
49 if (file_exists($configFile)) {
50 @unlink($configFile);
51 }
52
53 global $wpdb;
54
55
56 $free_options = $wpdb->get_results( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE 'bmi_%'" );
57
58 foreach( $free_options as $option ) {
59 delete_option( $option->option_name );
60 }
61
62 }