Created
March 2, 2012 19:31
-
-
Save jeremyfelt/1960725 to your computer and use it in GitHub Desktop.
Conditional WordPress stylesheets
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
<?php | |
/* Register our IE specific stylesheets. */ | |
wp_register_style( 'prefix-ie7-only', get_template_directory_uri() . '/css/ie7.css' ); | |
wp_register_style( 'prefix-ie8-only', get_template_directory_uri() . '/css/ie8.css' ); | |
wp_register_style( 'prefix-ie9-only', get_template_directory_uri() . '/css/ie.css' ); | |
/* Use the global wp_styles object to add our conditional statements due to the lack | |
* of conditional support in wp_register_style | |
*/ | |
$wp_styles->add_data( 'prefix-ie9-only', 'conditional', 'IE 9' ); | |
$wp_styles->add_data( 'prefix-ie8-only', 'conditional', 'IE 8' ); | |
$wp_styles->add_data( 'prefix-ie7-only', 'conditional', 'lt IE 8' ); | |
/* Enqueue the IE specific stylesheets, now with conditional statements attached via global */ | |
wp_enqueue_style( 'prefix-ie7-only' ); | |
wp_enqueue_style( 'prefix-ie8-only' ); | |
wp_enqueue_style( 'prefix-ie9-only' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment