PluginProbe ʕ •ᴥ•ʔ
Duplicator – Backups & Migration Plugin – Cloud Backups, Scheduled Backups, & More / 1.5.13
Duplicator – Backups & Migration Plugin – Cloud Backups, Scheduled Backups, & More v1.5.13
1.5.16.1 1.2.48 1.2.50 1.2.52 1.2.6 1.2.8 1.3.0 1.3.10 1.3.12 1.3.14 1.3.16 1.3.18 1.3.2 1.3.20 1.3.22 1.3.24 1.3.26 1.3.28 1.3.30 1.3.32 1.3.34 1.3.36 1.3.38 1.3.4 1.3.40 1.3.40.1 1.3.6 1.3.8 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.7.1 1.4.7.2 1.5.0 1.5.1 1.5.10 1.5.10.1 1.5.10.2 1.5.11 1.5.11.1 1.5.11.2 1.5.12 1.5.13 1.5.13.1 1.5.13.2 1.5.13.3 1.5.14 1.5.15 1.5.16 1.5.2 1.5.2.1 1.5.3 1.5.3.1 1.5.4 1.5.5 1.5.5.1 1.5.6 1.5.6.1 1.5.7 1.5.7.1 1.5.8 1.5.8.1 1.5.9 trunk 0.4.6 0.5.0 0.5.1 0.5.10 0.5.12 0.5.14 0.5.16 0.5.18 0.5.2 0.5.20 0.5.22 0.5.24 0.5.26 0.5.28 0.5.30 0.5.32 0.5.34 0.5.4 0.5.6 0.5.8 1.1.0 1.1.10 1.1.12 1.1.14 1.1.16 1.1.18 1.1.2 1.1.20 1.1.22 1.1.24 1.1.26 1.1.28 1.1.30 1.1.32 1.1.34 1.1.4 1.1.6 1.1.8 1.2.0 1.2.10 1.2.12 1.2.14 1.2.16 1.2.18 1.2.2 1.2.20 1.2.22 1.2.24 1.2.26 1.2.28 1.2.30 1.2.32 1.2.34 1.2.36 1.2.38 1.2.4 1.2.40 1.2.42 1.2.44 1.2.46
duplicator / uninstall.php
duplicator Last commit date
assets 10 months ago classes 10 months ago ctrls 10 months ago installer 10 months ago languages 10 months ago lib 10 months ago src 10 months ago template 10 months ago vendor 10 months ago views 10 months ago deactivation.php 10 months ago define.php 10 months ago duplicator-main.php 10 months ago duplicator.php 10 months ago helper.php 10 months ago readme.txt 10 months ago uninstall.php 10 months ago
uninstall.php
168 lines
1 <?php
2
3 /**
4 * Fired when the plugin is uninstalled.
5 *
6 * Maintain PHP 5.2 compatibility, don't use namespace and don't include Duplicator Libs
7 */
8
9 // If uninstall not called from WordPress, then exit
10 if (!defined('WP_UNINSTALL_PLUGIN')) {
11 exit;
12 }
13
14 /**
15 * Uninstall class
16 * Maintain PHP 5.2 compatibility, don't use namespace and don't include Duplicator Libs.
17 * This is a standalone class.
18 */
19 class DuplicatorLiteUninstall // phpcs:ignore
20 {
21 const PACKAGES_TABLE_NAME = 'duplicator_packages';
22 const VERSION_OPTION_KEY = 'duplicator_version_plugin';
23 const UNINSTALL_PACKAGE_OPTION_KEY = 'duplicator_uninstall_package';
24 const UNINSTALL_SETTINGS_OPTION_KEY = 'duplicator_uninstall_settings';
25 const SSDIR_NAME_LEGACY = 'wp-snapshots';
26 const SSDIR_NAME_NEW = 'backups-dup-lite';
27
28 /**
29 * Uninstall plugin
30 *
31 * @return void
32 */
33 public static function uninstall()
34 {
35 try {
36 do_action('duplicator_unistall');
37 self::removePackages();
38 self::removeSettings();
39 self::removePluginVersion();
40 } catch (Exception $e) {
41 // Prevent error on uninstall
42 } catch (Error $e) {
43 // Prevent error on uninstall
44 }
45 }
46
47 /**
48 * Remove plugin option version
49 *
50 * @return void
51 */
52 private static function removePluginVersion()
53 {
54 delete_option(self::VERSION_OPTION_KEY);
55 }
56
57 /**
58 * Return duplicator PRO backup path legacy
59 *
60 * @return string
61 */
62 private static function getSsdirPathLegacy()
63 {
64 return trailingslashit(wp_normalize_path(realpath(ABSPATH))) . self::SSDIR_NAME_LEGACY;
65 }
66
67 /**
68 * Return duplicator PRO backup path
69 *
70 * @return string
71 */
72 private static function getSsdirPathWpCont()
73 {
74 return trailingslashit(wp_normalize_path(realpath(WP_CONTENT_DIR))) . self::SSDIR_NAME_NEW;
75 }
76
77 /**
78 * Remove all packages
79 *
80 * @return void
81 */
82 private static function removePackages()
83 {
84 global $wpdb;
85
86 if (get_option(self::UNINSTALL_PACKAGE_OPTION_KEY) != true) {
87 return;
88 }
89
90 $tableName = esc_sql($wpdb->base_prefix . self::PACKAGES_TABLE_NAME);
91 $wpdb->query("DROP TABLE IF EXISTS {$tableName}");
92
93 $fsystem = new WP_Filesystem_Direct(true);
94 $fsystem->rmdir(self::getSsdirPathWpCont(), true);
95 $fsystem->rmdir(self::getSsdirPathLegacy(), true);
96 }
97
98 /**
99 * Remove plugins settings
100 *
101 * @return void
102 */
103 private static function removeSettings()
104 {
105 if (get_option(self::UNINSTALL_SETTINGS_OPTION_KEY) != true) {
106 return;
107 }
108
109 self::deleteUserMetaKeys();
110 self::deleteOptions();
111 self::deleteTransients();
112 }
113
114 /**
115 * Delete all users meta key
116 *
117 * @return void
118 */
119 private static function deleteUserMetaKeys()
120 {
121 /** @var wpdb */
122 global $wpdb;
123
124 $wpdb->query("DELETE FROM `{$wpdb->usermeta}` WHERE meta_key REGEXP '^duplicator_(?!pro_)'");
125 }
126
127 /**
128 * Delete all options
129 *
130 * @return void
131 */
132 private static function deleteOptions()
133 {
134 /** @var wpdb */
135 global $wpdb;
136
137 $optionsTableName = esc_sql($wpdb->base_prefix . "options");
138 $dupOptionNames = $wpdb->get_col(
139 "SELECT `option_name` FROM `{$optionsTableName}` WHERE `option_name` REGEXP '^duplicator_(?!pro_)'"
140 );
141
142 foreach ($dupOptionNames as $dupOptionName) {
143 delete_option($dupOptionName);
144 }
145 }
146
147 /**
148 * Delete all transients
149 *
150 * @return void
151 */
152 private static function deleteTransients()
153 {
154 global $wpdb;
155
156 $optionsTableName = esc_sql($wpdb->base_prefix . "options");
157 $dupOptionTransientNames = $wpdb->get_col(
158 "SELECT `option_name` FROM `{$optionsTableName}` WHERE `option_name` REGEXP '^_transient_duplicator_(?!pro_)'"
159 );
160
161 foreach ($dupOptionTransientNames as $dupOptionTransientName) {
162 delete_transient(str_replace("_transient_", "", $dupOptionTransientName));
163 }
164 }
165 }
166
167 DuplicatorLiteUninstall::uninstall();
168