Skip to content

Instantly share code, notes, and snippets.

@anandkumar
Forked from grappler/functions.php
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anandkumar/28c150a8da72d03b2e7e to your computer and use it in GitHub Desktop.
Save anandkumar/28c150a8da72d03b2e7e to your computer and use it in GitHub Desktop.
<?php
// add ie conditional html5 shim to header
function _s_add_ie_html5_shim () {
echo '<!--[if lt IE 9]>';
echo '<script src="' . get_template_directory_uri() . '/js/html5.js"></script>';
echo '<![endif]-->';
}
add_action('wp_head', '_s_add_ie_html5_shim');
<?php
/**
* Enqueue scripts and styles.
*/
function _s_scripts() {
wp_enqueue_script( '_s-html5shiv', get_template_directory_uri() . '/js/html5shiv.js', array(), '3.7.2', false );
}
add_action( 'wp_enqueue_scripts', '_s_scripts' );
/**
* Load only in IE as of WP 4.1
*/
function _s_html5shiv( $tag, $handle, $src ) {
if ( '_s-html5shiv' === $handle ) {
$tag = "<!--[if lt IE 9]>\n";
$tag .= "<script type='text/javascript' src='$src'></script>\n";
$tag .= "<![endif]-->\n";
}
return $tag;
}
add_filter( 'script_loader_tag', '_s_html5shiv', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment