Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#21162 closed enhancement (duplicate)

Add !IE conditional comment on $wp_styles->add_data

Reported by: umbercode's profile Umbercode Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: Cc:


There is no way to use $wp_styles->add_data("css_ie", "conditional", "!IE"); and target non-IE browsers.
There are use cases for this for example:

<!--[if (gt IE 8) | (IEMobile)]><!-->
<link rel='stylesheet' href='<?php bloginfo("template_url"); ?>/css/style.css'><!--<![endif]-->

<!--[if (lt IE 9) & (!IEMobile)]>
<link rel='stylesheet' href='<?php bloginfo("template_url"); ?>/css/ie.css'><![endif]-->

I do not know how to attach a patch or diff file but I changed the code in class.wp-styles.php between lines 69 and 75 to:

if ( isset($obj->extra['conditional']) && $obj->extra['conditional'] ) {
	if (strpos(strtoupper($obj->extra['conditional']), "!IE")) {
	   $tag .= "<!--[if {$obj->extra['conditional']}]><!-->\n";
	   $end_cond = "<!--<![endif]-->\n";
	else {
	   $tag .= "<!--[if {$obj->extra['conditional']}]>\n";
	   $end_cond = "<![endif]-->\n";

which seems to work.

Change History (2)

#1 @Umbercode
12 years ago

It should probably be:

if (strpos(strtoupper($obj->extra['conditional']), "(!IE)")) {

in order to distinguish between !IEMobile and !IE

I guess there could be a more elegant solution?

#2 @ocean90
12 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed
  • Version 3.4 deleted
Note: See TracTickets for help on using tickets.