Skip to content

Instantly share code, notes, and snippets.

@fritids
Forked from wpsmith/wps_enqueue_lt_ie9.php
Created May 30, 2013 00:45
Show Gist options
  • Save fritids/5675053 to your computer and use it in GitHub Desktop.
Save fritids/5675053 to your computer and use it in GitHub Desktop.
<?php
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( 'wps-html5shiv', 'http://html5shim.googlecode.com/svn/trunk/html5.js', array(), 'pre3.6', false );
}
@fritids
Copy link
Author

fritids commented May 30, 2013

/**

  • Conditionally Enqueue Script for IE browsers less than IE 9
    */
    add_action( 'wp_enqueue_scripts', 'wps_enqueue_lt_ie9' );
    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.min.js', get_template_directory_uri() .'/js/respond.min.js', array(), 'jquery', false );
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment