| 1 |
<?php |
| 2 |
/** |
| 3 |
* This is logic for integrating with the Autoptimize plugin. |
| 4 |
* |
| 5 |
* @link https://wordpress.org/plugins/autoptimize/ |
| 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 |
// Prevent moving the webfontloader script. |
| 17 |
add_filter( 'autoptimize_filter_js_dontmove', function( $dontmove ) { |
| 18 |
$dontmove[] = 'js/vendor/webfontloader'; |
| 19 |
|
| 20 |
return $dontmove; |
| 21 |
}, 10, 1 ); |
| 22 |
|
| 23 |
// Exclude the webfontloader script. |
| 24 |
add_filter( 'autoptimize_filter_js_exclude', function( $excludeJS ) { |
| 25 |
if ( is_string( $excludeJS ) ) { |
| 26 |
$excludeJS .= ',js/vendor/webfontloader'; |
| 27 |
} elseif ( is_array( $excludeJS ) ) { |
| 28 |
$excludeJS[] = 'js/vendor/webfontloader'; |
| 29 |
} |
| 30 |
|
| 31 |
return $excludeJS; |
| 32 |
}, 10, 1 ); |
| 33 |
|