LiteSpeedCache.php
42 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Hooks into LiteSpeedCache's hooks |
| 4 | * to exclude wpp(.min).js from its JS optimization |
| 5 | * |
| 6 | * @package WordPressPopularPosts |
| 7 | * @subpackage WordPressPopularPosts/Compatibility |
| 8 | * @author Hector Cabrera <me@cabrerahector.com> |
| 9 | */ |
| 10 | |
| 11 | namespace WordPressPopularPosts\Compatibility\LiteSpeedCache; |
| 12 | |
| 13 | use WordPressPopularPosts\Compatibility\Compat; |
| 14 | |
| 15 | class LiteSpeedCache extends Compat |
| 16 | { |
| 17 | /** |
| 18 | * Registers filters to exclude wpp(.min).js from LSC's JS optimization. |
| 19 | */ |
| 20 | public function init() |
| 21 | { |
| 22 | if ( defined('LSCWP_V') ) { |
| 23 | add_filter('litespeed_optimize_js_excludes', [$this, 'exclude_from_js_optimization']); |
| 24 | add_filter('litespeed_optm_js_defer_exc', [$this, 'exclude_from_js_optimization']); |
| 25 | add_filter('litespeed_optm_js_delay_inc', [$this, 'exclude_from_js_optimization']); |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * Adds wpp(.min).js to the exclusions list. |
| 31 | * |
| 32 | * @param array An array of file exclusions |
| 33 | * @return array The modified array of exclusions |
| 34 | */ |
| 35 | public function exclude_from_js_optimization($excluded) { |
| 36 | $excluded[] = 'wpp.min.js'; |
| 37 | $excluded[] = 'wpp.js'; |
| 38 | |
| 39 | return $excluded; |
| 40 | } |
| 41 | } |
| 42 |