-
-
Save loorlab/7e2bc3c632a39e240c3086218ed9d14b to your computer and use it in GitHub Desktop.
Display Handle Name JS WordPress - 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