Created
April 5, 2018 03:36
-
-
Save cameronjonesweb/0216c498928be97e056564e4f5c78724 to your computer and use it in GitHub Desktop.
Add the script handle to enqueued script tags
This file contains 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
<?php | |
add_filter( 'script_loader_tag', 'cameronjonesweb_add_script_handle', 10, 3 ); | |
function cameronjonesweb_add_script_handle( $tag, $handle, $src ) { | |
return str_replace( '<script', sprintf( | |
'<script data-handle="%1$s"', | |
esc_attr( $handle ) | |
), $tag ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment