| 1 |
<?php |
| 2 |
/** |
| 3 |
* This is logic for integrating with the WP-Rocket plugin. |
| 4 |
* |
| 5 |
* @link https://wp-rocket.me/ |
| 6 |
* |
| 7 |
* @see https://pixelgrade.com |
| 8 |
* @author Pixelgrade |
| 9 |
* @since 2.7.1 |
| 10 |
*/ |
| 11 |
|
| 12 |
if ( ! defined( 'ABSPATH' ) ) { |
| 13 |
exit; // Exit if accessed directly |
| 14 |
} |
| 15 |
|
| 16 |
// Exclude the webfontloader script and the inline script. |
| 17 |
function customify_wp_rocket_exclude_webfontloader_script( $list ) { |
| 18 |
$list[] = rocket_clean_exclude_file( plugins_url( 'js/vendor/webfontloader-1-6-28.min.js', PixCustomifyPlugin()->get_file() ) ); |
| 19 |
|
| 20 |
return $list; |
| 21 |
} |
| 22 |
add_filter( 'rocket_exclude_js', 'customify_wp_rocket_exclude_webfontloader_script', 10, 1 ); |
| 23 |
add_filter( 'rocket_exclude_defer_js', 'customify_wp_rocket_exclude_webfontloader_script', 10, 1 ); |
| 24 |
add_filter( 'rocket_exclude_cache_busting', 'customify_wp_rocket_exclude_webfontloader_script', 10, 1 ); |
| 25 |
|
| 26 |
add_filter( 'rocket_excluded_inline_js_content', function( $inline_js ) { |
| 27 |
$webfontloader_inline_script = 'customifyFontLoader = function()'; |
| 28 |
$inline_js[] = $webfontloader_inline_script; |
| 29 |
|
| 30 |
return $inline_js; |
| 31 |
}, 10, 1 ); |
| 32 |
|