-
-
Save byjml/1290610 to your computer and use it in GitHub Desktop.
Conditional commented JavaScript in WordPress
This file contains hidden or 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 | |
/* Hook the HTML5 shiv into WP. */ | |
add_action('wp_print_scripts', 'mytheme_ie_specific_js'); | |
/** | |
* Attaches conditionally commented JS file into wp_print_scripts hook. | |
* | |
* A modified version of Peter Wilson's gist https://gist.github.com/1282923 | |
* | |
* @link https://gist.github.com/1282923 | |
*/ | |
function mytheme_ie_specific_js() { | |
if ( is_admin() ) | |
return; | |
print( "<!--[if lt IE 9]>\n" ); | |
printf( '<script src="%s/assets/js/modernizr.min.js"></script>', get_template_directory_uri() ); | |
print( "\n<![endif]-->\n" ); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment