PluginProbe
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript / 4.0.27
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript v4.0.27
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 / inc / initialize.php

initialize.php in BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript 4.0.27, at inc/initialize.php

246 lines 7.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!defined('ABSPATH')) exit;
3 $berqconfigs = berqConfigs::getInstance();
4 $berqwp_configs = $berqconfigs->get_configs();
5
6 if (get_option('berqwp_enable_sandbox') === false) {
7 update_option('berqwp_enable_sandbox', 0, false);
8 }
9
10 if (get_option('berqwp_webp_max_width') === false) {
11 update_option('berqwp_webp_max_width', 1920, false);
12 }
13
14 if (get_option('berqwp_webp_quality') === false) {
15 update_option('berqwp_webp_quality', 70, false);
16 }
17
18 if (get_option('berqwp_image_lazyloading') === false) {
19 update_option('berqwp_image_lazyloading', 1, false);
20 }
21
22 if (get_option('berqwp_enable_cdn') === false) {
23 update_option('berqwp_enable_cdn', 1, false);
24 }
25
26 if (get_option('berqwp_enable_cwv') === false) {
27 update_option('berqwp_enable_cwv', 0, false);
28 }
29
30 if (get_option('berqwp_preload_fontfaces') === false) {
31 update_option('berqwp_preload_fontfaces', 1, false);
32 }
33
34 if (get_option('berqwp_preload_cookiebanner') === false) {
35 update_option('berqwp_preload_cookiebanner', 0, false);
36 }
37
38 if (get_option('berq_css_optimization') === false) {
39 update_option('berq_css_optimization', 'auto', false);
40 }
41
42 if (get_option('berq_js_optimization') === false) {
43 update_option('berq_js_optimization', 'auto', false);
44 }
45
46 if (get_option('berqwp_disable_emojis') === false) {
47 update_option('berqwp_disable_emojis', 1, false);
48 }
49
50 if (get_option('berqwp_lazyload_youtube_embed') === false) {
51 update_option('berqwp_lazyload_youtube_embed', 1, false);
52 }
53
54 if (get_option('berqwp_fluid_images') === false) {
55 update_option('berqwp_fluid_images', 0, false);
56 }
57
58 if (get_option('berqwp_preload_yt_poster') === false) {
59 update_option('berqwp_preload_yt_poster', 0, false);
60 }
61
62 if (get_option('berqwp_javascript_execution_mode') === false) {
63 update_option('berqwp_javascript_execution_mode', 4, false);
64 }
65
66 if (get_option('berqwp_interaction_delay') === false) {
67 update_option('berqwp_interaction_delay', '', false);
68 }
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_post_types') === false) {
75 update_option('berqwp_optimize_post_types', ['post', 'page', 'product'], false);
76 }
77
78 // if (get_option('berq_exclude_js_css') === false) {
79 // update_option('berq_exclude_js_css', [], false);
80 // }
81
82
83
84 if (get_option('berq_exclude_cdn') === false) {
85 update_option('berq_exclude_cdn', [], false);
86 }
87
88 if (get_option('berqwp_optimize_taxonomies') === false) {
89 update_option('berqwp_optimize_taxonomies', ['category', 'product_cat'], false);
90 }
91
92 if (get_option('berq_ignore_urls_params') === false) {
93 update_option('berq_ignore_urls_params', ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'gclid', 'fbclid', 'msclkid'], false);
94 }
95
96 // if (empty($berqwp_configs['site_id'])) {
97 // $blog_id = get_current_blog_id();
98 // $network_id = function_exists('get_current_network_id') ? get_current_network_id() : 1;
99 // $siteurl = get_option('siteurl');
100 // $site_id = md5("berqwp|$network_id|$blog_id|$siteurl");
101
102 // $berqconfigs->update_configs(['site_id' => $site_id]);
103 // }
104
105
106 // if (get_option('berq_exclude_urls', null) == null) {
107 // $exclude_urls = [];
108
109 // if (class_exists('WooCommerce')) {
110 // // WooCommerce is active
111
112 // // Get cart URL
113 // $cart_url = wc_get_cart_url();
114
115 // // Get checkout URL
116 // $checkout_url = wc_get_checkout_url();
117
118 // $exclude_urls[] = esc_url($cart_url);
119 // $exclude_urls[] = esc_url($checkout_url);
120
121 // }
122
123 // update_option('berq_exclude_urls', $exclude_urls);
124
125 // }
126
127 if (get_option('berqwp_enable_critical_css') === false) {
128 update_option('berqwp_enable_critical_css', 1, false);
129 }
130
131 if (get_option('berqwp_enable_used_css') === false) {
132 update_option('berqwp_enable_used_css', 0, false);
133 }
134
135 if (get_option('berqwp_force_include_critical_css') === false) {
136 update_option('berqwp_force_include_critical_css', [], false);
137 }
138
139 if (!empty(get_option('berq_exclude_js_css'))) {
140 $css_js_excludes = get_option('berq_exclude_js_css');
141 update_option('berqwp_exclude_css', $css_js_excludes, false);
142 update_option('berqwp_exclude_js', $css_js_excludes, false);
143
144 delete_option('berq_exclude_js_css');
145 }
146
147 if (get_option('berqwp_exclude_css') === false) {
148 update_option('berqwp_exclude_css', [], false);
149 }
150
151 if (get_option('berqwp_exclude_js') === false) {
152 update_option('berqwp_exclude_js', [], false);
153 }
154
155 if (get_option('berqwp_exclude_third_party_js') === false) {
156 update_option('berqwp_exclude_third_party_js', [], false);
157 }
158
159 if (get_option('berqwp_async_excluded_styles') === false) {
160 update_option('berqwp_async_excluded_styles', 0, false);
161 }
162
163 if (get_option('berqwp_defer_excluded_styles') === false) {
164 update_option('berqwp_defer_excluded_styles', 1, false);
165 }
166
167 if (get_option('berqwp_defer_excluded_js') === false) {
168 update_option('berqwp_defer_excluded_js', 1, false);
169 }
170
171 if (get_option('berqwp_delay_third_party_scripts') === false) {
172 update_option('berqwp_delay_third_party_scripts', 0, false);
173 }
174
175 if (get_option('berqwp_lazy_render') === false) {
176 update_option('berqwp_lazy_render', 0, false);
177 }
178
179 if (get_option('berqwp_prerender_on_hover') === false) {
180 update_option('berqwp_prerender_on_hover', 1, false);
181 }
182
183 if (get_option('berqwp_enable_webp') === false) {
184
185 $bwp_enable_webp = 1;
186 if (get_option('berqwp_disable_webp') !== false) {
187 $bwp_enable_webp = !get_option('berqwp_disable_webp');
188 delete_option('berqwp_disable_webp');
189 }
190
191 update_option('berqwp_enable_webp', (int) $bwp_enable_webp, false);
192 }
193
194 if (get_option('berqwp_exclude_lazy_load_images') === false) {
195 update_option('berqwp_exclude_lazy_load_images', [], false);
196 }
197
198 if (get_option('berqwp_lazy_load_videos') === false) {
199 update_option('berqwp_lazy_load_videos', 1, false);
200 }
201
202
203 if (get_option('berq_exclude_urls') === false) {
204 $urls = get_option('berq_exclude_urls', []);
205
206 if (class_exists('WooCommerce')) {
207 $page_excludes = [
208 wc_get_cart_url(),
209 wc_get_checkout_url(),
210 trailingslashit(wc_get_cart_url()),
211 trailingslashit(wc_get_checkout_url()),
212 ];
213
214 $page_excludes = array_unique($page_excludes);
215
216 $page_excludes = array_filter($page_excludes, function ($url) use ($urls) {
217 return !empty($url) && !in_array($url, $urls) && $url !== trailingslashit(home_url());
218 });
219
220 $should_update = !empty($page_excludes);
221 $urls = array_merge($urls, $page_excludes);
222
223
224 // if (!empty($cart_url) && !in_array($cart_url, $urls) && trailingslashit($cart_url) !== trailingslashit(home_url())) {
225 // $urls[] = esc_url($cart_url);
226 // $should_update = true;
227 // }
228
229 // if (!empty($checkout_url) && !in_array($checkout_url, $urls) && trailingslashit($checkout_url) !== trailingslashit(home_url())) {
230 // $urls[] = esc_url($checkout_url);
231 // $should_update = true;
232 // }
233
234 if ($should_update) {
235 $berqconfigs->update_configs(['exclude_urls' => $urls]);
236 update_option('berq_exclude_urls', $urls, false);
237
238 }
239
240 }
241 }
242
243
244 if (!empty(get_option('berqwp_optimize_queue'))) {
245 delete_option('berqwp_optimize_queue');
246 }