Skip to content

Instantly share code, notes, and snippets.

@hofmannsven
Forked from grappler/functions.php
Last active August 29, 2015 14:11
Show Gist options
  • Save hofmannsven/e5a2e6299e5d03ad5c23 to your computer and use it in GitHub Desktop.
Save hofmannsven/e5a2e6299e5d03ad5c23 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', true );
}
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