| 1 |
<?php |
| 2 |
/** |
| 3 |
* This is logic for integrating with the W3 Total Cache plugin. |
| 4 |
* |
| 5 |
* @link https://wordpress.org/plugins/w3-total-cache/ |
| 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 |
add_filter( 'w3tc_minify_js_script_tags', function ( $script_tags ) { |
| 18 |
if ( ! empty( $script_tags ) && is_array( $script_tags ) ) { |
| 19 |
$webfontloader_script_url = trailingslashit( dirname( plugin_basename( PixCustomifyPlugin::instance()->get_file() ) ) ) . 'js/vendor/webfontloader'; |
| 20 |
$webfontloader_inline_script = 'customifyFontLoader = function()'; |
| 21 |
foreach ( $script_tags as $key => $tag ) { |
| 22 |
if ( is_string( $tag ) && |
| 23 |
( false !== strpos( $tag, $webfontloader_script_url ) || false !== strpos( $tag, $webfontloader_inline_script ) ) ) { |
| 24 |
|
| 25 |
unset( $script_tags[ $key ] ); |
| 26 |
} |
| 27 |
} |
| 28 |
} |
| 29 |
|
| 30 |
return $script_tags; |
| 31 |
}, 10, 1 ); |
| 32 |
|