PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / trunk
Booking for Appointments and Events Calendar – Amelia vtrunk
2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / src / Infrastructure / WP / Compatibility / LiteSpeedCacheCompatibility.php
ameliabooking / src / Infrastructure / WP / Compatibility Last commit date
LiteSpeedCacheCompatibility.php 3 months ago
LiteSpeedCacheCompatibility.php
63 lines
1 <?php
2
3 /**
4 * LiteSpeed Cache Compatibility
5 *
6 * Automatically adds Amelia scripts to LiteSpeed Cache exclusion lists
7 * to prevent JavaScript errors caused by script optimization interfering with wp_localize_script data.
8 *
9 * @since 9.1
10 */
11
12 namespace AmeliaBooking\Infrastructure\WP\Compatibility;
13
14 /**
15 * Class LiteSpeedCacheCompatibility
16 *
17 * @package AmeliaBooking\Infrastructure\WP\Compatibility
18 */
19 class LiteSpeedCacheCompatibility
20 {
21 /**
22 * Initialize LiteSpeed Cache compatibility hooks
23 */
24 public static function init()
25 {
26 if (self::isLiteSpeedActive()) {
27 add_filter('litespeed_optimize_js_excludes', array(__CLASS__, 'excludeAmeliaScripts'));
28 add_filter('litespeed_optm_js_defer_exc', array(__CLASS__, 'excludeAmeliaScripts'));
29 }
30 }
31
32 /**
33 * Exclude Amelia scripts from LiteSpeed Cache optimization
34 */
35 public static function excludeAmeliaScripts(array $excluded_js): array
36 {
37 if (!is_array($excluded_js)) {
38 $excluded_js = array();
39 }
40
41 $amelia_patterns = array(
42 'amelia',
43 'wpAmeliaUrls',
44 'wpAmeliaLabels',
45 'wpAmeliaSettings',
46 'amelia_booking_script',
47 'amelia_booking_scripts',
48 '/ameliabooking/',
49 '/wpamelia-',
50 );
51
52 return array_merge($excluded_js, $amelia_patterns);
53 }
54
55 /**
56 * Check if LiteSpeed Cache is active
57 */
58 private static function isLiteSpeedActive(): bool
59 {
60 return defined('LSCWP_V') || class_exists('LiteSpeed\Core');
61 }
62 }
63