php - Wordpress Bootstrap html5 wp_enqueue_style -
i'm trying wp_style_add_data bootstrap html5shiv.min.js , respond.min.js
tried:
wp_enqueue_style( 'theme-ie', 'https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js', array( 'theme-style' ), '3.7.2' ); wp_enqueue_style( 'theme-ie-2', 'https://oss.maxcdn.com/respond/1.4.2/respond.min.js', array( 'theme-style' ), '1.4.2' ); wp_style_add_data( 'theme-ie', 'conditional', 'lt ie 9' ); wp_style_add_data( 'theme-ie-2', 'conditional', 'lt ie 9' );
but adding if lt ie 9 twice:
<!--[if lt ie 9]> <link rel='stylesheet' id='theme-ie-css' href='https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js?ver=3.7.2' type='text/css' media='all' /> <![endif]--> <!--[if lt ie 9]> <link rel='stylesheet' id='theme-ie-2-css' href='https://oss.maxcdn.com/respond/1.4.2/respond.min.js?ver=1.4.2' type='text/css' media='all' /> <![endif]-->
it's possible add html5shiv , respond scripts within same if lt ie 9 using wp_style_add_data, or neccesary add codes manually wordpress header.php?
use script_loader_tag
:
// conditional polyfills $conditional_scripts = array( 'html5shiv' => '//cdn.jsdelivr.net/html5shiv/3.7.2/html5shiv.js', 'html5shiv-printshiv' => '//cdn.jsdelivr.net/html5shiv/3.7.2/html5shiv-printshiv.js', 'respond' => '//cdn.jsdelivr.net/respond/1.4.2/respond.min.js' ); foreach ( $conditional_scripts $handle => $src ) { wp_enqueue_script( $handle, $src, array(), '', false ); } add_filter( 'script_loader_tag', function( $tag, $handle ) use ( $conditional_scripts ) { if ( array_key_exists( $handle, $conditional_scripts ) ) { $tag = "<!--[if lt ie 9]>$tag<![endif]-->"; } return $tag; }, 10, 2 );