Last active
January 3, 2018 22:55
-
-
Save kaanra/9214665 to your computer and use it in GitHub Desktop.
[Conditionally include IE scripts] #IE #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
add_action( 'wp_enqueue_scripts', 'wps_enqueue_lt_ie9' ); | |
/** | |
* Conditionally Enqueue Script for IE browsers less than IE 9 | |
* | |
* @link http://php.net/manual/en/function.version-compare.php | |
* @uses wp_check_browser_version() | |
*/ | |
function wps_enqueue_lt_ie9() { | |
global $is_IE; | |
// Return early, if not IE | |
if ( ! $is_IE ) return; | |
// Include the file, if needed | |
if ( ! function_exists( 'wp_check_browser_version' ) ) | |
include_once( ABSPATH . 'wp-admin/includes/dashboard.php' ); | |
// IE version conditional enqueue | |
$response = wp_check_browser_version(); | |
if ( 0 > version_compare( intval( $response['version'] ) , 9 ) ) | |
wp_enqueue_script( 'respond-js', 'https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js', array(), 'v1.4.2', false ); | |
} | |
/** Source: | |
http://wpsmith.net/2012/wp/conditionally-enqueue-scriptstyles-by-browser/ **/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment