Created
May 1, 2012 10:17
-
-
Save roborourke/2567027 to your computer and use it in GitHub Desktop.
Enables !IE in wordpress's conditional comments for styles mechanism
This file contains 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 | |
add_filter( 'style_loader_tag', 'style_loader_tag_ccs', 10, 2 ); | |
/** | |
* Add support for non IE conditional comments | |
* | |
* Trac ticket: http://core.trac.wordpress.org/ticket/16118 | |
* | |
* Usage: | |
* After registering or enqueuing a script you need to append the CC to the style | |
* handle via the $wp_styles class: | |
* | |
* $wp_styles->add_data( 'my-handle', 'adv_conditional', '!IE' ); | |
* | |
* @param string $tag The <link> tag to the CSS file | |
* @param string $handle The handle the style was registerd with | |
* | |
* @return string Returns the link tag for output | |
*/ | |
function style_loader_tag_ccs( $tag, $handle ) { | |
global $wp_styles; | |
$obj = $wp_styles->registered[ $handle ]; | |
if ( isset( $obj->extra[ 'adv_conditional' ] ) && $obj->extra[ 'adv_conditional' ] ) { | |
$cc = "<!--[if {$obj->extra['adv_conditional']}]>"; | |
$end_cc = ''; | |
if ( strstr( $obj->extra['adv_conditional'], '!IE' ) ) { | |
$cc .= '<!-->'; | |
$end_cc = '<!--'; | |
} | |
$end_cc .= "<![endif]-->\n"; | |
$tag = $cc . "\n" . $tag . $end_cc; | |
} | |
return $tag; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment