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
← All changes | inc/initialize.php +249 -47 1.9.64.1.16 View file →
@@ -1,107 +1,309 @@
1 1 <?php
2 2 if (!defined('ABSPATH')) exit;
3 +$berqconfigs = berqConfigs::getInstance();
4 +$berqwp_configs = $berqconfigs->get_configs();
3 5
4 -if (get_option('berqwp_enable_sandbox') == null) {
5 - update_option('berqwp_enable_sandbox', 0);
6 +if (get_option('berqwp_enable_sandbox') === false) {
7 + update_option('berqwp_enable_sandbox', 0, false);
6 8 }
7 9
8 -if (get_option('berqwp_webp_max_width') == null) {
9 - update_option('berqwp_webp_max_width', 1920);
10 +if (get_option('berqwp_webp_max_width') === false) {
11 + update_option('berqwp_webp_max_width', 1920, false);
10 12 }
11 13
12 -if (get_option('berqwp_webp_quality') == null) {
13 - update_option('berqwp_webp_quality', 80);
14 +if (get_option('berqwp_webp_quality') === false) {
15 + update_option('berqwp_webp_quality', 70, false);
14 16 }
15 17
16 -if (get_option('berqwp_image_lazyloading') == null) {
17 - update_option('berqwp_image_lazyloading', 1);
18 +if (get_option('berqwp_image_lazyloading') === false) {
19 + update_option('berqwp_image_lazyloading', 1, false);
18 20 }
19 21
20 -if (get_option('berqwp_disable_webp') == null) {
21 - update_option('berqwp_disable_webp', 0);
22 +if (get_option('berqwp_enable_cdn') === false) {
23 + update_option('berqwp_enable_cdn', 1, false);
22 24 }
23 25
24 -if (get_option('berqwp_enable_cdn') == null) {
25 - update_option('berqwp_enable_cdn', 1);
26 +if (get_option('berqwp_enable_cwv') === false) {
27 + update_option('berqwp_enable_cwv', 0, false);
26 28 }
27 29
28 -if (get_option('berqwp_preload_fontfaces') == null) {
29 - update_option('berqwp_preload_fontfaces', 0);
30 +if (get_option('berqwp_preload_fontfaces') === false) {
31 + update_option('berqwp_preload_fontfaces', 1, false);
30 32 }
31 33
32 -if (get_option('berqwp_disable_emojis') == null) {
33 - update_option('berqwp_disable_emojis', 1);
34 +if (get_option('berqwp_preload_cookiebanner') === false) {
35 + update_option('berqwp_preload_cookiebanner', 0, false);
34 36 }
35 37
36 -if (get_option('berqwp_lazyload_youtube_embed') == null) {
37 - update_option('berqwp_lazyload_youtube_embed', 1);
38 +if (get_option('berq_css_optimization') === false) {
39 + update_option('berq_css_optimization', 'auto', false);
38 40 }
39 41
40 -if (get_option('berqwp_javascript_execution_mode') == null) {
41 - update_option('berqwp_javascript_execution_mode', 1);
42 +if (get_option('berq_js_optimization') === false) {
43 + update_option('berq_js_optimization', 'auto', false);
42 44 }
43 45
44 -if (get_option('berqwp_enable_preload_mostly_used_font') == null) {
45 - update_option('berqwp_enable_preload_mostly_used_font', 0);
46 +if (get_option('berqwp_disable_emojis') === false) {
47 + update_option('berqwp_disable_emojis', 1, false);
46 48 }
47 49
48 -if (get_option('berqwp_interaction_delay') == null) {
49 - update_option('berqwp_interaction_delay', '');
50 +if (get_option('berqwp_lazyload_youtube_embed') === false) {
51 + update_option('berqwp_lazyload_youtube_embed', 1, false);
50 52 }
51 53
52 -if (get_option('berq_opt_mode') == null) {
53 - update_option('berq_opt_mode', 2);
54 +if (get_option('berqwp_fluid_images') === false) {
55 + update_option('berqwp_fluid_images', 1, false);
54 56 }
55 57
56 -if (get_option('berqwp_optimize_post_types') == null) {
57 - update_option('berqwp_optimize_post_types', ['post', 'page', 'product']);
58 +if (get_option('berqwp_preload_yt_poster') === false) {
59 + update_option('berqwp_preload_yt_poster', 0, false);
58 60 }
59 61
60 -if (get_option('berqwp_optimize_taxonomies') == null) {
61 - update_option('berqwp_optimize_taxonomies', ['category', 'product_cat']);
62 +if (get_option('berqwp_javascript_execution_mode') === false) {
63 + update_option('berqwp_javascript_execution_mode', 5, false);
62 64 }
63 65
64 -if (get_option('berq_ignore_urls_params') == null) {
65 - update_option('berq_ignore_urls_params', ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'gclid', 'fbclid', 'msclkid']);
66 +if (get_option('berqwp_interaction_delay') === false) {
67 + update_option('berqwp_interaction_delay', '', false);
66 68 }
67 69
70 +if (get_option('berq_opt_mode') === false) {
71 + update_option('berq_opt_mode', 2, false);
72 +}
73 +
74 +if (get_option('berqwp_optimize_taxonomies') === false) {
75 +
76 + $taxonomy_names = get_taxonomies([
77 + 'public' => true,
78 + 'publicly_queryable' => true,
79 + 'rewrite' => true,
80 + 'show_ui' => true, // optional but useful
81 + ], 'names');
82 +
83 + $taxonomy_names = array_keys($taxonomy_names);
84 +
85 + update_option('berqwp_optimize_taxonomies', $taxonomy_names, false);
86 +
87 +}
88 +
89 +if (get_option('berqwp_optimize_post_types') === false) {
90 + // update_option('berqwp_optimize_post_types', ['post', 'page', 'product'], false);
91 +
92 + $post_type_names = get_post_types(array(
93 + 'public' => true,
94 + 'exclude_from_search' => false,
95 + ), 'names');
96 + unset($post_type_names['attachment']);
97 + unset($post_type_names['e-floating-buttons']);
98 +
99 + $post_type_names = array_keys($post_type_names);
100 + $post_type_names = array_merge($post_type_names, ['post', 'page']);
101 + $post_type_names = array_unique($post_type_names);
102 +
103 + $post_type_names = array_filter($post_type_names, function ($slug) {
104 + // Get a sample post of this type
105 + $sample = get_posts( [
106 + 'post_type' => $slug,
107 + 'posts_per_page' => 1,
108 + 'post_status' => 'publish',
109 + ] );
110 +
111 + if ( empty( $sample ) ) {
112 + return false;
113 + }
114 +
115 + $url = get_permalink( $sample[0]->ID );
116 +
117 + return strpos($url, '?') === false;
118 +
119 + });
120 +
121 + update_option('berqwp_optimize_post_types', $post_type_names, false);
122 +
123 +}
124 +
125 +// if (get_option('berq_exclude_js_css') === false) {
126 +// update_option('berq_exclude_js_css', [], false);
127 +// }
128 +
129 +if (get_option('berqwp_heartbeat_mode') === false) {
130 + update_option('berqwp_heartbeat_mode', 'default', false);
131 +}
132 +
133 +if (get_option('berqwp_db_schedule_frequency') === false) {
134 + update_option('berqwp_db_schedule_frequency', 'weekly', false);
135 +}
136 +
137 +if (get_option('berqwp_db_revision_limit') === false) {
138 + update_option('berqwp_db_revision_limit', 5, false);
139 +}
140 +
141 +if (get_option('berqwp_db_scheduled_tasks') === false) {
142 + update_option('berqwp_db_scheduled_tasks', ['revisions', 'transients', 'spam_comments'], false);
143 +}
144 +
145 +
146 +
147 +if (get_option('berq_exclude_cdn') === false) {
148 + update_option('berq_exclude_cdn', [], false);
149 +}
150 +
151 +if (get_option('berqwp_optimize_taxonomies') === false) {
152 + update_option('berqwp_optimize_taxonomies', ['category', 'product_cat'], false);
153 +}
154 +
155 +if (get_option('berq_ignore_urls_params') === false) {
156 + update_option('berq_ignore_urls_params', ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'gclid', 'fbclid', 'msclkid'], false);
157 +}
158 +
159 +// if (empty($berqwp_configs['site_id'])) {
160 +// $blog_id = get_current_blog_id();
161 +// $network_id = function_exists('get_current_network_id') ? get_current_network_id() : 1;
162 +// $siteurl = get_option('siteurl');
163 +// $site_id = md5("berqwp|$network_id|$blog_id|$siteurl");
164 +
165 +// $berqconfigs->update_configs(['site_id' => $site_id]);
166 +// }
167 +
168 +
68 169 // if (get_option('berq_exclude_urls', null) == null) {
69 170 // $exclude_urls = [];
70 171
71 172 // if (class_exists('WooCommerce')) {
72 173 // // WooCommerce is active
73 -
174 +
74 175 // // Get cart URL
75 176 // $cart_url = wc_get_cart_url();
76 -
177 +
77 178 // // Get checkout URL
78 179 // $checkout_url = wc_get_checkout_url();
79 -
180 +
80 181 // $exclude_urls[] = esc_url($cart_url);
81 182 // $exclude_urls[] = esc_url($checkout_url);
82 183
83 184 // }
84 -
185 +
85 186 // update_option('berq_exclude_urls', $exclude_urls);
86 -
187 +
87 188 // }
88 189
89 -if (get_option('berq_exclude_urls', []) !== null) {
190 +if (get_option('berqwp_enable_critical_css') === false) {
191 + update_option('berqwp_enable_critical_css', 1, false);
192 +}
193 +
194 +if (get_option('berqwp_enable_used_css') === false) {
195 + update_option('berqwp_enable_used_css', 0, false);
196 +}
197 +
198 +if (get_option('berqwp_force_include_critical_css') === false) {
199 + update_option('berqwp_force_include_critical_css', [], false);
200 +}
201 +
202 +if (!empty(get_option('berq_exclude_js_css'))) {
203 + $css_js_excludes = get_option('berq_exclude_js_css');
204 + update_option('berqwp_exclude_css', $css_js_excludes, false);
205 + update_option('berqwp_exclude_js', $css_js_excludes, false);
206 +
207 + delete_option('berq_exclude_js_css');
208 +}
209 +
210 +if (get_option('berqwp_exclude_css') === false) {
211 + update_option('berqwp_exclude_css', [], false);
212 +}
213 +
214 +if (get_option('berqwp_exclude_js') === false) {
215 + update_option('berqwp_exclude_js', [], false);
216 +}
217 +
218 +if (get_option('berqwp_exclude_third_party_js') === false) {
219 + update_option('berqwp_exclude_third_party_js', [], false);
220 +}
221 +
222 +if (get_option('berqwp_async_excluded_styles') === false) {
223 + update_option('berqwp_async_excluded_styles', 0, false);
224 +}
225 +
226 +if (get_option('berqwp_defer_excluded_styles') === false) {
227 + update_option('berqwp_defer_excluded_styles', 1, false);
228 +}
229 +
230 +if (get_option('berqwp_defer_excluded_js') === false) {
231 + update_option('berqwp_defer_excluded_js', 0, false);
232 +}
233 +
234 +if (get_option('berqwp_delay_third_party_scripts') === false) {
235 + update_option('berqwp_delay_third_party_scripts', 0, false);
236 +}
237 +
238 +if (get_option('berqwp_lazy_render') === false) {
239 + update_option('berqwp_lazy_render', 0, false);
240 +}
241 +
242 +if (get_option('berqwp_prerender_on_hover') === false) {
243 + update_option('berqwp_prerender_on_hover', 1, false);
244 +}
245 +
246 +if (get_option('berqwp_enable_webp') === false) {
247 +
248 + $bwp_enable_webp = 1;
249 + if (get_option('berqwp_disable_webp') !== false) {
250 + $bwp_enable_webp = !get_option('berqwp_disable_webp');
251 + delete_option('berqwp_disable_webp');
252 + }
253 +
254 + update_option('berqwp_enable_webp', (int) $bwp_enable_webp, false);
255 +}
256 +
257 +if (get_option('berqwp_exclude_lazy_load_images') === false) {
258 + update_option('berqwp_exclude_lazy_load_images', [], false);
259 +}
260 +
261 +if (get_option('berqwp_lazy_load_videos') === false) {
262 + update_option('berqwp_lazy_load_videos', 1, false);
263 +}
264 +
265 +
266 +if (get_option('berq_exclude_urls') === false) {
90 267 $urls = get_option('berq_exclude_urls', []);
91 268
92 269 if (class_exists('WooCommerce')) {
93 - $cart_url = wc_get_cart_url();
94 - $checkout_url = wc_get_checkout_url();
270 + $page_excludes = [
271 + wc_get_cart_url(),
272 + wc_get_checkout_url(),
273 + trailingslashit(wc_get_cart_url()),
274 + trailingslashit(wc_get_checkout_url()),
275 + ];
95 276
96 - if (!empty($cart_url) && !in_array($cart_url, $urls) && trailingslashit($cart_url) !== trailingslashit(home_url())) {
97 - $urls[] = esc_url($cart_url);
277 + $page_excludes = array_unique($page_excludes);
278 +
279 + $page_excludes = array_filter($page_excludes, function ($url) use ($urls) {
280 + return !empty($url) && !in_array($url, $urls) && $url !== trailingslashit(home_url());
281 + });
282 +
283 + $should_update = !empty($page_excludes);
284 + $urls = array_merge($urls, $page_excludes);
285 +
286 +
287 + // if (!empty($cart_url) && !in_array($cart_url, $urls) && trailingslashit($cart_url) !== trailingslashit(home_url())) {
288 + // $urls[] = esc_url($cart_url);
289 + // $should_update = true;
290 + // }
291 +
292 + // if (!empty($checkout_url) && !in_array($checkout_url, $urls) && trailingslashit($checkout_url) !== trailingslashit(home_url())) {
293 + // $urls[] = esc_url($checkout_url);
294 + // $should_update = true;
295 + // }
296 +
297 + if ($should_update) {
298 + $berqconfigs->update_configs(['exclude_urls' => $urls]);
299 + update_option('berq_exclude_urls', $urls, false);
300 +
98 301 }
99 302
100 - if (!empty($checkout_url) && !in_array($checkout_url, $urls) && trailingslashit($checkout_url) !== trailingslashit(home_url())) {
101 - $urls[] = esc_url($checkout_url);
102 - }
303 + }
304 +}
103 305
104 - update_option('berq_exclude_urls', $urls);
105 306
106 - }
307 +if (!empty(get_option('berqwp_optimize_queue'))) {
308 + delete_option('berqwp_optimize_queue');
107 309 }