PluginProbe
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript / 4.0.16
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript v4.0.16
4.1.16 4.1.15 4.1.14 4.1.13 4.1.12 4.1.11 4.1.10 4.0.30 4.0.29 4.0.28 4.0.27 4.0.26 4.0.24 4.0.25 4.0.23 4.0.22 4.0.21 4.0.19 4.0.18 4.0.17 4.0.16 1.9.3 1.9.4 1.9.5 1.9.6 All 170 releases
searchpro / uninstall.php

uninstall.php in BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript 4.0.16, at uninstall.php

162 lines 4.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // if uninstall.php is not called by WordPress, die
4 if (!defined('WP_UNINSTALL_PLUGIN')) {
5 die;
6 }
7
8 if (!defined('optifer_PATH')) {
9 define('optifer_PATH', plugin_dir_path(__FILE__));
10 }
11
12 if (!defined('optifer_URL')) {
13 define('optifer_URL', plugin_dir_url(__FILE__));
14 }
15
16 if (!defined('optifer_cache')) {
17 define('optifer_cache', WP_CONTENT_DIR . '/cache/berqwp/');
18 }
19
20 use BerqWP\BerqWP;
21
22 // Initialize BerqWP SDK
23 require_once optifer_PATH . '/BerqWP/vendor/autoload.php';
24
25 // Load functions
26 require_once optifer_PATH . '/inc/helper-functions.php';
27
28 /**
29 * Clean up per-site options (used for both single-site and per-site in multisite).
30 */
31 function berqwp_uninstall_delete_site_options() {
32 delete_option('berqwp_enable_sandbox');
33 delete_option('berqwp_webp_max_width');
34 delete_option('berqwp_webp_quality');
35 delete_option('berqwp_image_lazyloading');
36 delete_option('berqwp_disable_webp');
37 delete_option('berqwp_enable_cdn');
38 delete_option('berqwp_preload_fontfaces');
39 delete_option('berqwp_disable_emojis');
40 delete_option('berqwp_lazyload_youtube_embed');
41 delete_option('berqwp_javascript_execution_mode');
42 delete_option('berqwp_interaction_delay');
43 delete_option('berq_opt_mode');
44 delete_option('berq_ignore_urls_params');
45 delete_option('berq_exclude_urls');
46 delete_option('berqwp_site_url');
47 delete_option('berqwp_post_type_names');
48 delete_option('berqwp_optimize_post_types');
49 delete_option('berqwp_optimize_taxonomies');
50 delete_option('berqwp_enable_cwv');
51 delete_option('berq_exclude_js_css');
52 delete_option('berqwp_fluid_images');
53 delete_option('berqwp_cache_rules');
54 delete_option('berqwp_sync_addons');
55 delete_option('berqwp_can_use_fluid_images');
56 delete_option('berqwp_preload_yt_poster');
57 delete_option('berqwp_enable_critical_css');
58 delete_option('berqwp_async_excluded_styles');
59 delete_option('berqwp_delay_third_party_scripts');
60 delete_option('berqwp_lazy_render');
61 delete_option('berqwp_enable_webp');
62 delete_option('berqwp_lazy_load_videos');
63 delete_option('berqwp_force_include_critical_css');
64 delete_option('berqwp_exclude_lazy_load_images');
65 delete_option('berqwp_exclude_third_party_js');
66 delete_option('berqwp_exclude_js');
67 delete_option('berqwp_exclude_css');
68 delete_option('berq_exclude_cdn');
69 delete_option('berq_css_optimization');
70 delete_option('berq_js_optimization');
71 }
72
73 if (is_multisite()) {
74 // Purge external caches using the network license key
75 $license_key = berqwp_get_license_key();
76 if (!empty($license_key)) {
77 $berqwp = new BerqWP($license_key, null, null);
78 $sites = get_sites(['fields' => 'ids', 'number' => 0]);
79 foreach ($sites as $site_id) {
80 switch_to_blog($site_id);
81 $parsed_url = wp_parse_url(home_url());
82 $domain = $parsed_url['host'];
83 $berqwp->purge_critilclcss($domain);
84 $berqwp->purge_cdn($domain);
85 restore_current_blog();
86 }
87 }
88
89 // Clean up each site's cache and options
90 $sites = get_sites(['fields' => 'ids', 'number' => 0]);
91 foreach ($sites as $site_id) {
92 switch_to_blog($site_id);
93
94 // Delete per-site cache directory
95 $cache_directory = WP_CONTENT_DIR . '/cache/berqwp/html/site-' . $site_id . '/';
96 if (is_dir($cache_directory)) {
97 berqwp_unlink_recursive($cache_directory);
98 @rmdir($cache_directory);
99 }
100
101 // Delete per-site config
102 $config_dir = WP_CONTENT_DIR . '/cache/berqwp/site-' . $site_id . '/';
103 if (is_dir($config_dir)) {
104 berqwp_unlink_recursive($config_dir);
105 @rmdir($config_dir);
106 }
107
108 // Delete per-site options
109 berqwp_uninstall_delete_site_options();
110
111 restore_current_blog();
112 }
113
114 // Delete network-wide options
115 berqwp_delete_license_key();
116 berqwp_delete_network_option('berq_lic_response_cache');
117 berqwp_delete_network_option('berq_lic_cache_expire');
118 berqwp_delete_network_option('berqwp_lic_response_cache');
119 berqwp_delete_network_option('berqwp_lic_cache_expire');
120
121 // Delete blog map
122 $map_file = WP_CONTENT_DIR . '/cache/berqwp/blog-map.json';
123 if (file_exists($map_file)) {
124 @unlink($map_file);
125 }
126
127 // Clean up the entire cache directory
128 $base_cache = WP_CONTENT_DIR . '/cache/berqwp/';
129 if (is_dir($base_cache)) {
130 berqwp_unlink_recursive($base_cache);
131 @rmdir($base_cache);
132 }
133 } else {
134 // Single-site uninstall (original behavior)
135 if (!empty(berqwp_get_license_key())) {
136 $parsed_url = wp_parse_url(home_url());
137 $domain = $parsed_url['host'];
138 $berqwp = new BerqWP(berqwp_get_license_key(), null, null);
139 $berqwp->purge_critilclcss($domain);
140 $berqwp->purge_cdn($domain);
141 }
142
143 // Delete cache directory
144 $cache_directory = bwp_get_cache_dir();
145 berqwp_unlink_recursive($cache_directory);
146
147 // Delete per-site options
148 berqwp_uninstall_delete_site_options();
149 berqwp_delete_license_key();
150 }
151
152 // Remove advanced-cache.php file
153 if (defined('BERQWP_ADVANCED_CACHE_PATH')) {
154 $dropin_file = BERQWP_ADVANCED_CACHE_PATH;
155 } else {
156 $dropin_file = WP_CONTENT_DIR . '/advanced-cache.php';
157 }
158
159 if (file_exists($dropin_file)) {
160 unlink($dropin_file);
161 }
162