Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 18 |
|
0.00% |
0 / 1 |
CRAP | n/a |
0 / 0 |
|
| Automattic\Jetpack_Boost\Compatibility\Divi\disable_defer_js_for_divi_builder | |
0.00% |
0 / 17 |
|
0.00% |
0 / 1 |
30 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Compatibility functions for Divi Builder |
| 4 | * |
| 5 | * @package automattic/jetpack-boost |
| 6 | */ |
| 7 | |
| 8 | namespace Automattic\Jetpack_Boost\Compatibility\Divi; |
| 9 | |
| 10 | /** |
| 11 | * Defer JS can break Divi Builder. |
| 12 | */ |
| 13 | function disable_defer_js_for_divi_builder( $should_defer_js ) { |
| 14 | $is_divi_builder = filter_input( INPUT_GET, 'et_fb', FILTER_VALIDATE_INT ); |
| 15 | |
| 16 | if ( 1 === (int) $is_divi_builder ) { |
| 17 | return false; |
| 18 | } |
| 19 | |
| 20 | $is_divi_preview = filter_input( |
| 21 | INPUT_GET, |
| 22 | 'et_pb_preview', |
| 23 | FILTER_VALIDATE_BOOLEAN, |
| 24 | array( |
| 25 | 'flags' => FILTER_NULL_ON_FAILURE, |
| 26 | ) |
| 27 | ); |
| 28 | |
| 29 | if ( true === $is_divi_preview ) { |
| 30 | return false; |
| 31 | } |
| 32 | |
| 33 | if ( function_exists( 'is_et_pb_preview' ) ) { |
| 34 | /** @phan-suppress-next-line PhanUndeclaredFunction */ |
| 35 | if ( \is_et_pb_preview() ) { |
| 36 | return false; |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | return $should_defer_js; |
| 41 | } |
| 42 | |
| 43 | add_filter( 'jetpack_boost_should_defer_js', __NAMESPACE__ . '\disable_defer_js_for_divi_builder' ); |