PluginProbe
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript / 4.1.16
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript v4.1.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.1.16, at uninstall.php

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