There are some issues with the "conditional" enqueue method above - it cannot handle negative conditions properly. Consider, for example, including a CSS for rounded corners if the browser is not IE. See this ticket: <a href="http://core.trac.wordpress.org/ticket/16118">http://core.trac.wordpress.org/ticket/16118</a>. There is a patch provided in this thread, but I haven't checked if the patch is a part of the core yet.<br>
<br>I believe you can use an alternative approach making use of the "style_loader_tag":<br><br>// First add a filter to style_loader_tag:<br>add_filter('style_loader_tag', 'filter_rounded_corners_css', 10, 2);<br>
<br>// Define the filter function:<br>function filter_rounded_corners_css($css_html_tag, $handle) {<br> // If the stylesheet handle is "rounded" only then this style will take effect<br> if ($handle == 'rounded') {<br>
return "<!--[if !IE]>-->".$css_html_tag."<!--<![endif]-->\n";<br> }<br> return $css_html_tag;<br>}<br><br>// The handle is "rounded", which causes the inclusion of the rounded-corners.css file.<br>
wp_register_style('rounded', get_template_directory_uri().'/rounded-corners.css');<br><br>
<br>Sayontan.<br><br><div class="gmail_quote">On Thu, Apr 21, 2011 at 11:50 AM, Edward Caissie <span dir="ltr"><<a href="mailto:edward.caissie@gmail.com">edward.caissie@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I agree with "recommended" for adding additional stylesheets via wp_enqueue_style() immediately and pushing it to required with 3.2; which seems will not be all that far off.<br><br>I would also think that example, or similar ones, should be linked to so authors have something to work from if/when they adapt this "new" method.<br>
<br><br>Cais.<div><div></div><div class="h5"><br><br><div class="gmail_quote">On Thu, Apr 21, 2011 at 2:39 PM, Chip Bennett <span dir="ltr"><<a href="mailto:chip@chipbennett.net" target="_blank">chip@chipbennett.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I agree - but we rarely take something from a non-suggestion to *required* in one step, unless a critical need exists.<div><br></div><div>The general path is to make something *recommended*, fit-test it for a while, and then bump it up to *required*.</div>
<div><br></div><div><font color="#888888">Chip</font><div><div></div><div><br><br><div class="gmail_quote">On Fri, Apr 22, 2011 at 1:27 PM, Justin Tadlock <span dir="ltr"><<a href="mailto:justin@justintadlock.com" target="_blank">justin@justintadlock.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#ffffff">
This should be the *required* way. Additional stylesheets should
always be added with wp_enqueue_style(). This is what I've been
putting in my reviews, even for conditional stylesheets.<div><div></div><div><br>
<br>
On 4/21/2011 1:22 PM, Chip Bennett wrote:
</div></div><blockquote type="cite"><div><div></div><div>I just found this:
<div><a href="http://iamzed.com/2010/01/07/using-wordpress-wp_enqueue_style-with-conditionals/" target="_blank">http://iamzed.com/2010/01/07/using-wordpress-wp_enqueue_style-with-conditionals/</a></div>
<div><br>
</div>
<blockquote style="margin:0pt 0pt 0pt 40px;border:medium none;padding:0px">
<div><span style="font-family:'Courier New',Courier,monospace;font-size:medium;color:rgb(0, 0, 187)">wp_enqueue_style<span style="margin:0px;padding:0px;color:rgb(102, 204, 102)">(</span><br style="margin:0px;padding:0px">
<span style="margin:0px;padding:0px;color:rgb(255, 0, 0)">'ie7-style'</span>, <br style="margin:0px;padding:0px">
get_template_directory_uri<span style="margin:0px;padding:0px;color:rgb(102, 204, 102)">(</span><span style="margin:0px;padding:0px;color:rgb(102, 204, 102)">)</span> . <span style="margin:0px;padding:0px;color:rgb(255, 0, 0)">'/ie7.css'</span><br style="margin:0px;padding:0px">
<span style="margin:0px;padding:0px;color:rgb(102, 204, 102)">)</span>;<br style="margin:0px;padding:0px">
<a href="http://www.php.net/global" style="margin:0px;padding:0px;color:rgb(208, 11, 11)" target="_blank"><span style="margin:0px;padding:0px;color:rgb(0, 0, 102)">global</span></a> <span style="margin:0px;padding:0px">$wp_styles</span>;<br style="margin:0px;padding:0px">
<span style="margin:0px;padding:0px">$wp_styles</span>-><span style="margin:0px;padding:0px">add_data</span><span style="margin:0px;padding:0px;color:rgb(102, 204, 102)">(</span> <span style="margin:0px;padding:0px;color:rgb(255, 0, 0)">'ie7-style'</span>, <span style="margin:0px;padding:0px;color:rgb(255, 0, 0)">'conditional'</span>, <span style="margin:0px;padding:0px;color:rgb(255, 0, 0)">'lte
IE 7′</span><span style="margin:0px;padding:0px;color:rgb(102, 204, 102)">)</span>;</span></div>
</blockquote>
<div><br>
</div>
<div>This might move into the Guidelines, as *Recommended*
implementation of enqueueing IE-conditional stylesheets.
Thoughts?</div>
<div><br>
</div>
<div>Chip</div>
</div></div><pre><fieldset></fieldset>
_______________________________________________
theme-reviewers mailing list
<a href="mailto:theme-reviewers@lists.wordpress.org" target="_blank">theme-reviewers@lists.wordpress.org</a>
<a href="http://lists.wordpress.org/mailman/listinfo/theme-reviewers" target="_blank">http://lists.wordpress.org/mailman/listinfo/theme-reviewers</a>
</pre>
</blockquote>
</div>
<br>_______________________________________________<br>
theme-reviewers mailing list<br>
<a href="mailto:theme-reviewers@lists.wordpress.org" target="_blank">theme-reviewers@lists.wordpress.org</a><br>
<a href="http://lists.wordpress.org/mailman/listinfo/theme-reviewers" target="_blank">http://lists.wordpress.org/mailman/listinfo/theme-reviewers</a><br>
<br></blockquote></div><br></div></div></div>
<br>_______________________________________________<br>
theme-reviewers mailing list<br>
<a href="mailto:theme-reviewers@lists.wordpress.org" target="_blank">theme-reviewers@lists.wordpress.org</a><br>
<a href="http://lists.wordpress.org/mailman/listinfo/theme-reviewers" target="_blank">http://lists.wordpress.org/mailman/listinfo/theme-reviewers</a><br>
<br></blockquote></div><br>
</div></div><br>_______________________________________________<br>
theme-reviewers mailing list<br>
<a href="mailto:theme-reviewers@lists.wordpress.org">theme-reviewers@lists.wordpress.org</a><br>
<a href="http://lists.wordpress.org/mailman/listinfo/theme-reviewers" target="_blank">http://lists.wordpress.org/mailman/listinfo/theme-reviewers</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Sayontan Sinha<br><a href="http://mynethome.net" target="_blank">http://mynethome.net</a> | <a href="http://mynethome.net/blog" target="_blank">http://mynethome.net/blog</a><br>
--<br>Beating Australia in Cricket is like killing a celebrity. The death gets more coverage than the crime.<br><br>