This is my first post. In advance, thank you for welcoming me...
Context
When you enqueue style, you can output your css link into conditional comments.
global $wp_styles;
wp_enqueue_style("my_styles_ie");
$wp_styles->add_data("my_styles_ie", "conditional", "(lt IE 9) & (!IEMobile)");
It will produce the following code :
<!--[if (lt IE 9) & (!IEMobile)]>
<link rel="stylesheet" href="#" />
<![endif]-->
This is done by the do_item()
method of the WP_Styles
class (class.wp_styles.php).
Goal
I'd like to add a "anticonditionnal" parameter with the condition value...
$wp_styles->add_data("my_styles_ie", "anticonditional", "(gt IE 8) | (IEMobile)");
to be able to output this ("nested comments"):
<!--[if (gt IE 8) | (IEMobile)]><!-->
<link rel="stylesheet" href="#">
<!--<![endif]-->
I have searched about "how to modify core method" but I didn't find any solution... :(
For now, I can do it with a hook but there is no "arguments". Stylesheet and condition are hardcoded...
function antiConditionnal($tag, $handle) {
if('my_styles' == $handle)
$tag = '<!--[if (gt IE 8) | (IEMobile)]><!-->' . "\n" . $tag . '<!--<![endif]-->' . "\n";
return $tag;
}
add_filter( 'style_loader_tag', 'antiConditionnal', 10, 2);
This is mainly for me an opportunity to improve my knowledge and dive deeper into WordPress!
Any idea?
Thank you...
tm