PluginProbe
RabbitLoader / 3.1.0
RabbitLoader v3.1.0
4.0.2 4.0.1 4.0 3.2.0 3.1.1 3.1.0 3.0.5 3.0.3 3.0.4 2.17.1 2.17.2 2.17.3 2.17.4 2.17.5 2.17.6 2.17.7 2.18.0 2.18.1 2.18.2 2.18.3 2.18.4 2.18.5 2.18.6 2.18.7 2.18.8 All 129 releases
rabbit-loader / inc / conflicts.php

conflicts.php in RabbitLoader 3.1.0, at inc/conflicts.php

458 lines 22.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class RabbitLoader_21_Conflicts
4 {
5
6 private static $messages = [];
7 private static $items = [];
8 private static $currentContextKey = null;
9
10 public static function &getMessages($isActivationFlow)
11 {
12 $key = self::ensureContext($isActivationFlow);
13 return self::$messages[$key];
14 }
15
16 public static function &getItems($isActivationFlow)
17 {
18 $key = self::ensureContext($isActivationFlow);
19 return self::$items[$key];
20 }
21
22 public static function getConflictState($isActivationFlow)
23 {
24 $items = self::getItems($isActivationFlow);
25 $messages = [];
26 $blocking_count = 0;
27
28 foreach ($items as $item) {
29 $messages[] = $item['message'];
30 if (!empty($item['blocks_activation'])) {
31 $blocking_count++;
32 }
33 }
34
35 return [
36 'result' => true,
37 'context' => $isActivationFlow ? 'activation' : 'connected',
38 'items' => $items,
39 'messages' => $messages,
40 'message' => empty($messages) ? '' : $messages[0],
41 'warning_count' => count($items),
42 'blocking_count' => $blocking_count,
43 'activation_blocked' => $blocking_count > 0,
44 ];
45 }
46
47 private static function ensureContext($isActivationFlow)
48 {
49 $key = $isActivationFlow ? 'activation' : 'connected';
50 if (!array_key_exists($key, self::$messages)) {
51 self::$messages[$key] = [];
52 self::$items[$key] = [];
53 self::$currentContextKey = $key;
54 self::runSystemChecks();
55 self::runConflictsCheck($isActivationFlow);
56 self::$currentContextKey = null;
57 }
58
59 return $key;
60 }
61
62 private static function addConflict($message, $blocksActivation = false, $severity = '', $code = '', $source = '')
63 {
64 if (self::$currentContextKey === null || empty($message)) {
65 return;
66 }
67
68 if (in_array($message, self::$messages[self::$currentContextKey], true)) {
69 return;
70 }
71
72 if (empty($severity)) {
73 $severity = $blocksActivation ? 'error' : 'warning';
74 }
75
76 self::$messages[self::$currentContextKey][] = $message;
77 self::$items[self::$currentContextKey][] = [
78 'message' => $message,
79 'blocks_activation' => !empty($blocksActivation),
80 'severity' => $severity,
81 'code' => $code,
82 'source' => $source,
83 ];
84 }
85
86 private static function addPluginConflict($plugName, $isActivationFlow, $blocksActivation = true)
87 {
88 if ($isActivationFlow) {
89 $message = sprintf(
90 RL21UtilWP::__("It seems you are also using %s plugin which conflicts with RabbitLoader optimizations. We suggest deactivating %s and reload this page."),
91 $plugName,
92 $plugName
93 );
94 } else {
95 $message = sprintf(
96 RL21UtilWP::__("It seems you are also using %s plugin which conflicts with RabbitLoader optimizations. We suggest deactivating %s and hit the 'Purge All Pages' button on the RabbitLoader home tab."),
97 $plugName,
98 $plugName
99 );
100 }
101
102 self::addConflict($message, $blocksActivation, '', 'plugin_conflict', $plugName);
103 }
104
105 private static function runSystemChecks()
106 {
107 if (defined('PHP_VERSION') && version_compare(PHP_VERSION, '5.6.0') < 0) {
108 self::addConflict(
109 sprintf(
110 RL21UtilWP::__("RabbitLoader requires PHP 5.6 or higher. You're still on version %s which may expose your site to security vulnerabilities. <a href='%s' target='_blank'>Learn more</a>."),
111 PHP_VERSION,
112 "https://wordpress.org/support/update-php/"
113 ),
114 true,
115 'error',
116 'php_version',
117 'PHP'
118 );
119 }
120 }
121
122 private static function runConflictsCheck($isActivationFlow)
123 {
124
125 $otherConflictPlugins = [];
126 $constants_to_check = [
127 'AUTOPTIMIZE_PLUGIN_VERSION' => ['name' => 'Autoptimize', 'blocks_activation' => true],
128 'BREEZE_PLUGIN_DIR' => ['name' => 'Breeze', 'blocks_activation' => true],
129 'COMET_CACHE_PLUGIN_FILE' => ['name' => 'Comet Cache', 'blocks_activation' => true],
130 'CYBVC_PLUGIN_DIR' => ['name' => 'ViperCache', 'blocks_activation' => true],
131 'DEBLOAT_PLUGIN_FILE' => ['name' => 'Debloat', 'blocks_activation' => true],
132 'JETPACK_BOOST_VERSION' => ['name' => 'Jetpack Boost', 'blocks_activation' => true],
133 'LSCACHE_ADV_CACHE' => ['name' => 'LiteSpeed Cache', 'blocks_activation' => true],
134 'LSCWP_DIR' => ['name' => 'LiteSpeed Cache', 'blocks_activation' => true],
135 'LSCWP_V' => ['name' => 'LiteSpeed Cache', 'blocks_activation' => true],
136 'PEGASAAS_ACCELERATOR_VERSION' => ['name' => 'Pegasaas Accelerator WP', 'blocks_activation' => true],
137 'PERFMATTERS_VERSION' => ['name' => 'Perfmatters', 'blocks_activation' => true],
138 'PERFMATTERS_CACHE_DIR' => ['name' => 'Perfmatters', 'blocks_activation' => true],
139 'PHASTPRESS_VERSION' => ['name' => 'PhastPress', 'blocks_activation' => true],
140 'SW_CLOUDFLARE_PAGECACHE' => ['name' => 'WP Cloudflare Super Page Cache', 'blocks_activation' => true],
141 'TENWEB_SO_VERSION' => ['name' => '10Web Booster', 'blocks_activation' => true],
142 'NITROPACK_VERSION' => ['name' => 'NitroPack', 'blocks_activation' => true],
143 'W3TC' => ['name' => 'W3 Total Cache', 'blocks_activation' => true],
144 'WMAC_PLUGIN_VERSION' => ['name' => 'Clearfy Cache', 'blocks_activation' => true],
145 'WP_ROCKET_VERSION' => ['name' => 'WP-Rocket', 'blocks_activation' => true],
146 'WP_SMUSH_VERSION' => ['name' => 'Smush', 'blocks_activation' => false],
147 'WPFC_WP_PLUGIN_DIR' => ['name' => 'WP Fastest Cache', 'blocks_activation' => true],
148 'WPFC_MAIN_PATH' => ['name' => 'WP Fastest Cache', 'blocks_activation' => true],
149 'WPHB_SUI_VERSION' => ['name' => 'Hummingbird', 'blocks_activation' => true], // WPHB_VERSION conflicts with WP Hotel Booking plugin
150 'WPMETEOR_VERSION' => ['name' => 'WP Meteor', 'blocks_activation' => true],
151 ];
152
153 $classes_to_check = [
154 'BJLL' => ['name' => 'BJ Lazy Load', 'blocks_activation' => false],
155 'PagespeedNinja' => ['name' => 'PageSpeed Ninja', 'blocks_activation' => true],
156 'Swift_Performance' => ['name' => 'Swift Performance', 'blocks_activation' => true],
157 'Swift_Performance_Lite' => ['name' => 'Swift Performance', 'blocks_activation' => true],
158 'SWCFPC_Backend' => ['name' => 'WP Cloudflare Super Page Cache', 'blocks_activation' => true],
159 'WPO_Cache_Config' => ['name' => 'WP Optimize page caching', 'blocks_activation' => false],
160 ];
161
162 foreach ($constants_to_check as $plugConst => $plugData) {
163 if (defined($plugConst)) {
164 $otherConflictPlugins[$plugData['name']] = $plugData;
165 }
166 }
167
168 foreach ($classes_to_check as $className => $plugData) {
169 if (class_exists($className)) {
170 $otherConflictPlugins[$plugData['name']] = $plugData;
171 }
172 }
173
174 if (!empty($otherConflictPlugins)) {
175 foreach ($otherConflictPlugins as $plugData) {
176 self::addPluginConflict($plugData['name'], $isActivationFlow, !empty($plugData['blocks_activation']));
177 }
178 }
179
180 if (defined('WPCACHEHOME') && function_exists("wp_cache_phase2")) {
181 self::addConflict(
182 sprintf(
183 RL21UtilWP::__("It seems you are using %s plugin which conflicts with RabbitLoader optimizations. We suggest deactivating it and hit the 'Purge All Pages' button on the RabbitLoader home tab. If you think it is an error, please follow <a href='%s' target='_blank'>this guide</a>."),
184 "WP Super Cache",
185 "https://rabbitloader.com/kb/wordpress-plugin-activation-errors/"
186 ),
187 true,
188 'error',
189 'wp_super_cache',
190 'WP Super Cache'
191 );
192 }
193
194 try {
195 if (defined('JETPACK__VERSION')) {
196 $jp_options = get_option('jetpack_active_modules');
197 if (is_array($jp_options) && in_array('lazy-images', $jp_options)) {
198 self::addConflict(sprintf(RL21UtilWP::__("Please disable %s to avoid conflict with RabbitLoader."), "image lazy loading option in Jetpack"), false, 'warning', 'jetpack_lazy_images', 'Jetpack');
199 }
200 }
201 } catch (Throwable $e) {
202 RabbitLoader_21_Core::on_exception($e);
203 }
204
205 try {
206 if (defined('POWERKIT')) {
207 $powerkit_enabled_lazyload = get_option('powerkit_enabled_lazyload');
208 if (!empty($powerkit_enabled_lazyload)) {
209 self::addConflict(sprintf(RL21UtilWP::__("Please disable %s to avoid conflict with RabbitLoader."), "image lazy loading option in Powerkit"), false, 'warning', 'powerkit_lazyload', 'Powerkit');
210 }
211 }
212 } catch (Throwable $e) {
213 RabbitLoader_21_Core::on_exception($e);
214 }
215
216 try {
217 if (class_exists('Flatsome_Default')) {
218 $theme_mods_flatsome = [];
219 if (function_exists('of_get_options')) {
220 $theme_mods_flatsome = of_get_options();
221 } else {
222 $theme_mods_flatsome = get_option('theme_mods_flatsome-child');
223 }
224 if (!empty($theme_mods_flatsome)) {
225 if (!empty($theme_mods_flatsome['lazy_load_images'])) {
226 self::addConflict(sprintf(RL21UtilWP::__("Please disable %s to avoid conflict with RabbitLoader."), "IMAGE lazy loading options in Flatsome Advanced Options"), false, 'warning', 'flatsome_lazy_images', 'Flatsome');
227 }
228 if (!empty($theme_mods_flatsome['lazy_load_backgrounds'])) {
229 self::addConflict(sprintf(RL21UtilWP::__("Please disable %s to avoid conflict with RabbitLoader."), "BANNER AND SECTION BACKGROUNDS lazy loading options in Flatsome Advanced Options"), false, 'warning', 'flatsome_lazy_backgrounds', 'Flatsome');
230 }
231 }
232 }
233 } catch (Throwable $e) {
234 RabbitLoader_21_Core::on_exception($e);
235 }
236
237 try {
238 if (defined('ET_BUILDER_THEME') && defined('TEMPLATEPATH')) {
239 $themeName = explode('/', TEMPLATEPATH);
240 if (!empty($themeName)) {
241 $themeName_c = end($themeName);
242 $themeName_s = strtolower($themeName_c);
243 $theme_options = get_option('et_' . $themeName_s);
244 if (!empty($theme_options)) {
245 $et_check_options = ['critical_css', 'dynamic_css'];
246 $is_on = false;
247 foreach ($et_check_options as $et_check_option) {
248 $et_current_option = $themeName_s . '_' . $et_check_option;
249 $is_on = !empty($theme_options[$et_current_option]) && $theme_options[$et_current_option] == "on";
250 if ($is_on) {
251 break;
252 }
253 }
254 if ($is_on) {
255 self::addConflict(
256 sprintf(
257 RL21UtilWP::__("Please disable %s to avoid conflict with RabbitLoader <a href='%s' target='_blank'>Check screenshots</a>."),
258 "all performance optimizations in $themeName_c theme",
259 "https://rabbitloader.com/kb/settings-for-wordpress-divi-theme-users/"
260 ),
261 false,
262 'warning',
263 'divi_performance_options',
264 $themeName_c
265 );
266 }
267 }
268
269 if (!empty($theme_options['et_pb_static_css_file']) && strcasecmp($theme_options['et_pb_static_css_file'], "on") === 0) {
270 self::addConflict(
271 sprintf(
272 RL21UtilWP::__("Please disable %s to avoid conflict with RabbitLoader. <a href='%s' target='_blank'>Check screenshots</a>."),
273 "Static CSS File Generation option in $themeName_c theme",
274 "https://rabbitloader.com/kb/settings-for-wordpress-divi-theme-users/"
275 ),
276 false,
277 'warning',
278 'divi_static_css',
279 $themeName_c
280 );
281 }
282 }
283 }
284 } catch (Throwable $e) {
285 RabbitLoader_21_Core::on_exception($e);
286 }
287
288 try {
289 if (defined('WPO_VERSION')) {
290 if (class_exists('WPO_Cache_Config')) {
291 $wpo_inst = WPO_Cache_Config::instance();
292 if ($wpo_inst->get_option('enable_page_caching', false)) {
293 self::addConflict(sprintf(RL21UtilWP::__("Please disable %s to avoid conflict with RabbitLoader."), "page caching option in WP Optimize plugin"), false, 'warning', 'wp_optimize_page_cache', 'WP Optimize');
294 }
295 }
296 }
297 } catch (Throwable $e) {
298 RabbitLoader_21_Core::on_exception($e);
299 }
300
301 try {
302 if (function_exists('ewww_image_optimizer_get_option')) {
303 if (ewww_image_optimizer_get_option('ewww_image_optimizer_lazy_load')) {
304 self::addConflict(sprintf(RL21UtilWP::__("Please disable %s to avoid conflict with RabbitLoader."), "image lazy loading in EWWW Image Optimizer"), false, 'warning', 'ewww_lazyload', 'EWWW Image Optimizer');
305 }
306 }
307 } catch (Throwable $e) {
308 RabbitLoader_21_Core::on_exception($e);
309 }
310
311 try {
312 if (defined('WOOCS_VERSION')) {
313 if (empty(get_option('woocs_shop_is_cached'))) {
314 self::addConflict(
315 sprintf(
316 RL21UtilWP::__("Please enable %s to be compatible with RabbitLoader. <a href='%s' target='_blank'>Check screenshot</a>"),
317 "<i><b>I am using cache plugin</b></i> option in WOOCS Currency Switcher Settings",
318 "https://rabbitloader.com/kb/woocs-currency-switcher-for-woocommerce/"
319 ),
320 false,
321 'warning',
322 'woocs_cache_compatibility',
323 'WOOCS'
324 );
325 }
326 }
327 } catch (Throwable $e) {
328 RabbitLoader_21_Core::on_exception($e);
329 }
330
331 try {
332 if (defined('WOOMULTI_CURRENCY_F_VERSION') && class_exists('WOOMULTI_CURRENCY_F_Admin_Settings')) {
333 if (empty(WOOMULTI_CURRENCY_F_Admin_Settings::get_field('cache_compatible'))) {
334 self::addConflict(
335 sprintf(
336 RL21UtilWP::__("Please enable %s to be compatible with RabbitLoader. <a href='%s' target='_blank'>Check screenshot</a>"),
337 "<i><b>Use Cache Plugin</b></i> option in CURCY - Multi Currency for WooCommerce",
338 "https://rabbitloader.com/kb/curcy-multi-currency-for-woocommerce/"
339 ),
340 false,
341 'warning',
342 'curcy_cache_compatibility',
343 'CURCY'
344 );
345 }
346 }
347 } catch (Throwable $e) {
348 RabbitLoader_21_Core::on_exception($e);
349 }
350
351 try {
352 if (defined('FLYING_PRESS_VERSION')) {
353 $fp_options = get_option('FLYING_PRESS_CONFIG');
354 if (!empty($fp_options['css_extract_used'])) {
355 self::addConflict(sprintf(RL21UtilWP::__("Please disable %s to avoid conflict with RabbitLoader."), "CSS optimizations in Flying Press"), false, 'warning', 'flying_press_css', 'Flying Press');
356 }
357 if (!empty($fp_options['js_preload_links']) || !empty($fp_options['js_defer']) || !empty($fp_options['js_interaction'])) {
358 self::addConflict(sprintf(RL21UtilWP::__("Please disable %s to avoid conflict with RabbitLoader."), "all JavaScript optimizations such as Preload, Defer, Interaction etc in Flying Press"), false, 'warning', 'flying_press_js', 'Flying Press');
359 }
360 if (!empty($fp_options['cache'])) {
361 self::addConflict(sprintf(RL21UtilWP::__("Please disable %s to avoid conflict with RabbitLoader."), "cache option in Flying Press"), false, 'warning', 'flying_press_cache', 'Flying Press');
362 }
363 }
364 } catch (Throwable $e) {
365 RabbitLoader_21_Core::on_exception($e);
366 }
367
368 if (defined('SiteGround_Optimizer\VERSION')) {
369 $sg_combine_css = get_option('siteground_optimizer_combine_css');
370 if (!empty($sg_combine_css)) {
371 self::addConflict(sprintf(RL21UtilWP::__("Please disable %s in %s to avoid conflict with RabbitLoader."), "Combine CSS option", "Siteground Optimizer"), false, 'warning', 'siteground_combine_css', 'SiteGround Optimizer');
372 }
373 }
374
375 if (defined('EZOIC_INTEGRATION_VERSION')) {
376 self::addConflict(sprintf(RL21UtilWP::__("Currently RabbitLoader is not compatible with %s."), "Ezoic"), true, 'error', 'ezoic', 'Ezoic');
377 }
378
379 if (defined('WPACU_PLUGIN_ID') && defined('WPACU_PLUGIN_TITLE')) {
380 $wpassetcleanup_settings = get_option('wpassetcleanup_settings');
381 if (!empty($wpassetcleanup_settings)) {
382 if (!empty($wpassetcleanup_settings['combine_loaded_css_for']) && strcmp($wpassetcleanup_settings['combine_loaded_css_for'], 'guests') === 0) {
383 self::addConflict(sprintf(RL21UtilWP::__("Please disable %s in %s to avoid conflict with RabbitLoader."), "Combine CSS option", WPACU_PLUGIN_TITLE), false, 'warning', 'asset_cleanup_combine_css', WPACU_PLUGIN_TITLE);
384 }
385 if (!empty($wpassetcleanup_settings['critical_css_status']) && strcmp($wpassetcleanup_settings['critical_css_status'], 'off') !== 0) {
386 self::addConflict(sprintf(RL21UtilWP::__("Please disable %s in %s to avoid conflict with RabbitLoader."), "Critical CSS option", WPACU_PLUGIN_TITLE), false, 'warning', 'asset_cleanup_critical_css', WPACU_PLUGIN_TITLE);
387 }
388 }
389 }
390
391 try {
392 if (defined('FUSION_BUILDER_VERSION')) {
393 $template = explode('/', TEMPLATEPATH);
394 if (!empty($template)) {
395 $themeName = end($template);
396 } else {
397 $themeName = 'current';
398 }
399 $fb_options = get_option('fusion_options');
400 $empty_checks = [
401 'lazy_load' => ['none', 'off'],
402 'js_compiler' => ['0'],
403 'defer_jquery' => ['0'],
404 'defer_styles' => ['0'],
405 'css_cache_method' => ['none', 'off'],
406 'css_combine_third_party_assets' => ['0'],
407 'media_queries_async' => ['0'],
408 'critical_css' => ['0'],
409 ];
410 foreach ($empty_checks as $key => $expValues) {
411 if (empty($fb_options[$key])) {
412 continue;
413 } else if (in_array($fb_options[$key], $expValues)) {
414 continue;
415 } else {
416 self::addConflict(
417 sprintf(
418 RL21UtilWP::__("Please disable %s to avoid conflict with RabbitLoader. For help, refer <a href='%s' target='_blank'>this guide</a>."),
419 "all performance options in $themeName theme performance settings such as \"" . str_ireplace("_", " ", $key) . '"',
420 "https://rabbitloader.com/kb/settings-required-for-themefusion-users/"
421 ),
422 false,
423 'warning',
424 'themefusion_performance_options',
425 $themeName
426 );
427 break;
428 }
429 }
430 }
431 } catch (Throwable $e) {
432 RabbitLoader_21_Core::on_exception($e);
433 }
434
435 try {
436 if (defined('ASP_PLUGIN_NAME')) {
437 $asp_compatibility = get_option('asp_compatibility');
438 $script_loading_method = empty($asp_compatibility['script_loading_method']) ? '' : $asp_compatibility['script_loading_method'];
439 $css_loading_method = empty($asp_compatibility['css_loading_method']) ? '' : $asp_compatibility['css_loading_method'];
440 if ($script_loading_method != 'classic' || $css_loading_method != 'file') {
441 self::addConflict(
442 sprintf(
443 RL21UtilWP::__("In the Ajax Search Pro plugin, under the Compatibility and Other Settings, go to CSS and JS loading option. Please choose 'classic' option for Script loading method and file option for Style (CSS) loading method. <a href='%s' target='_blank'>Check screenshot</a>"),
444 "https://rabbitloader.com/kb/settings-required-for-ajax-search-pro-users/"
445 ),
446 false,
447 'warning',
448 'ajax_search_pro_loading',
449 'Ajax Search Pro'
450 );
451 }
452 }
453 } catch (Throwable $e) {
454 RabbitLoader_21_Core::on_exception($e);
455 }
456 }
457 }
458