HTML and CSS Reference
In-Depth Information
CONDITIONAL COMMENTS
When registering CSS using the register and enqueue functions, conditional comments are a
little more complex. WordPress uses the object $wp_styles to store registered style sheets.
To wrap your file in conditional comments, add extra information to this object.
For Internet Explorer 8 and below, excluding mobile IE, we need to register another copy of
our desktop style sheet (using the media type all ) and wrap it in conditional comments.
In the code sample above, /**keepreading**/ would be replaced with the following:
global $wp_styles ;
wp_register_style (
'theme-desktop-ie' ,
'/wp-content/themes/my-theme/desktop.css' ,
array ( 'theme-mobile' ),
'1.0.0'
);
$wp_styles -& gt ; add_data (
'theme-desktop-ie' , //handle
'conditional' , //is a conditional comment
'!(IEMobile)&(lte IE 8)' //the conditional comment
);
Unfortunately, there is no equivalent for wrapping JavaScript files in conditional comments,
presumably due to the concatenation of JavaScript in the admin section.
If you need to wrap a JavaScript file in conditional comments, you will need to add it to
header.php or footer.php in the theme. Alternatively, you could use the wp_head or wp_footer
hooks.
Outputting The Style Sheet HTML
Outputting the style sheet HTML is very similar to outputting the JavaScript HTML. We use the
enqueue function and run it on the wp_print_styles hook.
Search WWH ::




Custom Search