PluginProbe
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript / 4.0.21
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript v4.0.21
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 1.9.7 All 169 releases
searchpro / uninstall.php

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

163 lines 4.9 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-prefixed/vendor/scoper-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 delete_option('berqwp_recently_optimized');
72 }
73
74 if (is_multisite()) {
75 // Purge external caches using the network license key
76 $license_key = berqwp_get_license_key();
77 if (!empty($license_key)) {
78 $berqwp = new BerqWP($license_key, null, null);
79 $sites = get_sites(['fields' => 'ids', 'number' => 0]);
80 foreach ($sites as $site_id) {
81 switch_to_blog($site_id);
82 $parsed_url = wp_parse_url(home_url());
83 $domain = $parsed_url['host'];
84 $berqwp->purge_critilclcss($domain);
85 $berqwp->purge_cdn($domain);
86 restore_current_blog();
87 }
88 }
89
90 // Clean up each site's cache and options
91 $sites = get_sites(['fields' => 'ids', 'number' => 0]);
92 foreach ($sites as $site_id) {
93 switch_to_blog($site_id);
94
95 // Delete per-site cache directory
96 $cache_directory = WP_CONTENT_DIR . '/cache/berqwp/html/site-' . $site_id . '/';
97 if (is_dir($cache_directory)) {
98 berqwp_unlink_recursive($cache_directory);
99 @rmdir($cache_directory);
100 }
101
102 // Delete per-site config
103 $config_dir = WP_CONTENT_DIR . '/cache/berqwp/site-' . $site_id . '/';
104 if (is_dir($config_dir)) {
105 berqwp_unlink_recursive($config_dir);
106 @rmdir($config_dir);
107 }
108
109 // Delete per-site options
110 berqwp_uninstall_delete_site_options();
111
112 restore_current_blog();
113 }
114
115 // Delete network-wide options
116 berqwp_delete_license_key();
117 berqwp_delete_network_option('berq_lic_response_cache');
118 berqwp_delete_network_option('berq_lic_cache_expire');
119 berqwp_delete_network_option('berqwp_lic_response_cache');
120 berqwp_delete_network_option('berqwp_lic_cache_expire');
121
122 // Delete blog map
123 $map_file = WP_CONTENT_DIR . '/cache/berqwp/blog-map.json';
124 if (file_exists($map_file)) {
125 @unlink($map_file);
126 }
127
128 // Clean up the entire cache directory
129 $base_cache = WP_CONTENT_DIR . '/cache/berqwp/';
130 if (is_dir($base_cache)) {
131 berqwp_unlink_recursive($base_cache);
132 @rmdir($base_cache);
133 }
134 } else {
135 // Single-site uninstall (original behavior)
136 if (!empty(berqwp_get_license_key())) {
137 $parsed_url = wp_parse_url(home_url());
138 $domain = $parsed_url['host'];
139 $berqwp = new BerqWP(berqwp_get_license_key(), null, null);
140 $berqwp->purge_critilclcss($domain);
141 $berqwp->purge_cdn($domain);
142 }
143
144 // Delete cache directory
145 $cache_directory = bwp_get_cache_dir();
146 berqwp_unlink_recursive($cache_directory);
147
148 // Delete per-site options
149 berqwp_uninstall_delete_site_options();
150 berqwp_delete_license_key();
151 }
152
153 // Remove advanced-cache.php file
154 if (defined('BERQWP_ADVANCED_CACHE_PATH')) {
155 $dropin_file = BERQWP_ADVANCED_CACHE_PATH;
156 } else {
157 $dropin_file = WP_CONTENT_DIR . '/advanced-cache.php';
158 }
159
160 if (file_exists($dropin_file)) {
161 unlink($dropin_file);
162 }
163