admin管理员组文章数量:1425658
I'm adding fontawesome script to my site, and I didn't found a proper way to add the fontawesome's integrity parameter (integrity="sha384-DJ25uNYET2XCl5ZF++U8eNxPWqcKohUUBUpKGlNLMchM7q4Wjg2CUpjHLaL8yYPH"
).
There's a way to do this? Or wordpress doesn't have a current support
I'm adding fontawesome script to my site, and I didn't found a proper way to add the fontawesome's integrity parameter (integrity="sha384-DJ25uNYET2XCl5ZF++U8eNxPWqcKohUUBUpKGlNLMchM7q4Wjg2CUpjHLaL8yYPH"
).
There's a way to do this? Or wordpress doesn't have a current support
Share Improve this question asked May 27, 2019 at 20:47 GendrithGendrith 1638 bronze badges1 Answer
Reset to default 3You will have to generate your own tag after the script is enqueued. Below, it's looking for the fontawesome
handle (the one you're using to enqueue the script) before returning the custom tag.
add_filter( 'script_loader_tag', 'my_scripts_modifier', 10, 3 );
function my_scripts_modifier( $tag, $handle, $src ) {
if ( 'fontawesome' === $handle ) {
return '<script src="' . $src . '" type="text/javascript" integrity="sha384-DJ25uNYET2XCl5ZF++U8eNxPWqcKohUUBUpKGlNLMchM7q4Wjg2CUpjHLaL8yYPH"></script>' . "\n";
}
return $tag;
}
本文标签: functionswpenqueuescript add integrity parameter
版权声明:本文标题:functions - wp_enqueue_script add integrity parameter 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745458938a2659233.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论