Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#38729 closed enhancement (duplicate)

Script Conditional does not work for !IE

Reported by: shaunjeffrey's profile shaunjeffrey Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.6.1
Component: Script Loader Keywords:
Focuses: Cc:


Hi team,

It seems that when adding the wp_script_add_data function for use with IE conditional statements, the most important one was not considered; the situation where you want a script to load when the user is using a non-IE browser, or an IE browser over 9.

Because of the fact that conditional statements only work in IE 9 and below, we would either need to (1) add a new key, (2) add an additional flag, (3) parse the data and hope for the best, or (4) apply a new filter for both $cond_before and $cond_after, and pass in the the handle as a reference.

Option 1 above would probably be easiest to implement, for instance, as well as checking

    $conditional = isset( $obj->extra['conditional'] ) ? $obj->extra['conditional'] : '';

We could also check

    $not_conditional = isset( $obj->extra['not-conditional'] ) ? $obj->extra['not-conditional'] : '';

And instead of

    $cond_before = "<!--[if {$conditional}]>\n";
    $cond_after = "<!\[endif]-->\n";

We'd have

    $cond_before = "<!--[if {$not_conditional}]-->\n";
    $cond_after = "<!--\[endif]-->\n";

Alternatively, Option 4 would be the most expandable. We could then add two apply_filters, one inside each check for

if ( $has_conditional_data )

And then the user would be able to manually adjust the conditional statements as required.

From what I can tell, the same limitation exists for styles, and we're unable to to set non-IE styles. Again, applying filters would be the most adaptable way to adjust these conditional statements.

Change History (1)

#1 @peterwilsoncc
7 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

@shaunjeffrey Thanks for the ticket and welcome to trac!

There's another ticket discussing this, #16118, so I'll close this one as a duplicate. I encourage you to add any comments to the original ticket.

If you discover any bugs or think of any further enhancements, feel free to open another ticket.

Note: See TracTickets for help on using tickets.