[theme-reviewers] enqueue conditional CSS?

Sayontan Sinha sayontan at gmail.com
Wed May 16 16:54:44 UTC 2012


There is an issue with the approach suggested by Konstantin. It doesn't
handle negative conditionals. See
http://core.trac.wordpress.org/ticket/16118. If  you need to support
negative conditionals you will either require the patches in the Trac
ticket or use the approach that I have suggested.

On Wed, May 16, 2012 at 9:50 AM, Chip Bennett <chip at chipbennett.net> wrote:

> What Konstantin said. I recommend this method as best practice.
>
> Chip
>
> On 5/16/12, Konstantin Obenland <konstantin at obenland.it> wrote:
> > How about:
> >
> > function prefix_enqueue_scripts() {
> >       wp_enqueue_style( 'handle', get_template_directory_uri() .
> '/ie.css',
> > array('style') );
> >
> >       global $wp_styles;
> >       $wp_styles->add_data( 'handle', 'conditional', 'lt IE 9' );
> > }
> > add_action( 'wp_enqueue_scripts', 'prefix_enqueue_scripts' );
> >
> > Konstantin
> >
> >
> > On 16.05.2012, at 17:18, Sayontan Sinha wrote:
> >
> >> Actually you can use wp_enqueue_style for this, by combining with the
> >> style_loader_tag filter. E.g.:
> >>
> >> add_filter('style_loader_tag', 'suffusion_filter_rounded_corners_css',
> 10,
> >> 2);
> >> function suffusion_filter_rounded_corners_css($css_html_tag, $handle) {
> >>     if ($handle == 'suffusion-rounded') {
> >>         return "<!--[if
> !IE]>-->".$css_html_tag."<!--<![endif]-->\n<!--[if
> >> gt IE 8]>".$css_html_tag."<![endif]-->\n";
> >>     }
> >>     return $css_html_tag;
> >> }
> >>
> >>
> >> On Wed, May 16, 2012 at 8:14 AM, .: chris :. <chris at jazzsequence.com>
> >> wrote:
> >> Why not use conditional classes instead of conditional stylesheets?
> >>
> http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/
> >>
> >> :: code bandit ::
> >> http://protocol.by/jazzsequence
> >> http://about.me/jazzs3quence
> >>
> >> On May 16, 2012, at 9:11 AM, Shinra Web Holdings wrote:
> >>
> >>> Are themes still permitted to load browser-conditional style sheets
> using
> >>> <!--[if IE 7]><link rel="stylesheet" href="ie7.css" type="text/css"
> >>> media="screen" /><![endif]--> or are they required to discover the
> >>> browser using PHP and use wp_enqueue_style() ?
> >>> _______________________________________________
> >>> theme-reviewers mailing list
> >>> theme-reviewers at lists.wordpress.org
> >>> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
> >>
> >>
> >> _______________________________________________
> >> theme-reviewers mailing list
> >> theme-reviewers at lists.wordpress.org
> >> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
> >>
> >>
> >>
> >>
> >> --
> >> Sayontan Sinha
> >> http://mynethome.net | http://mynethome.net/blog
> >> --
> >> Beating Australia in Cricket is like killing a celebrity. The death gets
> >> more coverage than the crime.
> >>
> >> _______________________________________________
> >> theme-reviewers mailing list
> >> theme-reviewers at lists.wordpress.org
> >> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
> >
> >
>
> --
> Sent from my mobile device
> _______________________________________________
> theme-reviewers mailing list
> theme-reviewers at lists.wordpress.org
> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>



-- 
Sayontan Sinha
http://mynethome.net | http://mynethome.net/blog
--
Beating Australia in Cricket is like killing a celebrity. The death gets
more coverage than the crime.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wordpress.org/pipermail/theme-reviewers/attachments/20120516/cf596995/attachment-0001.htm>


More information about the theme-reviewers mailing list