Skip to content

Instantly share code, notes, and snippets.

@byjml
Forked from peterwilsoncc/functions.php
Created October 16, 2011 07:25
Show Gist options
  • Save byjml/1290610 to your computer and use it in GitHub Desktop.
Save byjml/1290610 to your computer and use it in GitHub Desktop.
Conditional commented JavaScript in WordPress
<?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