Created
March 2, 2019 06:40
-
-
Save ibndawood/c01a5dfee6b88362bbfa90b29e6cc49f to your computer and use it in GitHub Desktop.
Electro v2 - Enqueue latest fontawesome from CDN
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'wp_enqueue_scripts', 'ec_enqueue_latest_fa', 30 ); | |
add_filter( 'style_loader_tag', 'ec_child_add_fa_cdn_attributes', 10, 2 ); | |
function ec_enqueue_latest_fa() { | |
wp_dequeue_style( 'fontawesome' ); | |
wp_dequeue_style( 'ec-fontawesome' ); | |
wp_enqueue_style( 'latest-fontawesome', 'https://use.fontawesome.com/releases/v5.7.2/css/all.css', array(), null ); | |
} | |
function ec_child_add_fa_cdn_attributes( $html, $handle ) { | |
if ( 'latest-fontawesome' === $handle ) { | |
return str_replace( "media='all'", "media='all' integrity='sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr' crossorigin='anonymous'", $html ); | |
} | |
return $html; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment