Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. /**
  2. * Add Security Key and appropiate tags Enqueued Scripts & Styles.
  3. *
  4. * @param string $tag Script Tags to display.
  5. * @param string $handle Name of file specified above.
  6. */
  7. function script_security_checks( $tag, $handle ) {
  8.  
  9. $scripts = array( 'script_handle' );
  10.  
  11. foreach ( $scripts as $script ) {
  12. if ( $script === $handle ) {
  13. return str_replace( ' src', ' async defer integrity="####-###################-##############" crossorigin="anonymous" src', $tag );
  14. }
  15. }
  16. return $tag;
  17. }
  18. add_filter( 'script_loader_tag', 'script_security_checks', 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement