functions - wp_enqueue_script add integrity parameter

I'm adding fontawesome script to my site, and I didn't found a proper way to add the fontawesome's integr

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 badges
Add a comment  | 

1 Answer 1

Reset to default 3

You 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;
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745458956a4628617.html

相关推荐

  • functions - wp_enqueue_script add integrity parameter

    I'm adding fontawesome script to my site, and I didn't found a proper way to add the fontawesome's integr

    4小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信