Add a custom stylesheet for BlackBerry

I want a little help loading a custom stylesheet in wordpress. I’m using PHP to check if the user agent is BlackBerry. If yes, I want to load blackberry.css, if no, regular wordpress style.css.

Here’s what I have so far:

Read More
$ua = strtolower($_SERVER['HTTP_USER_AGENT']);
   $pos_blackberry = strrpos($ua, "blackberry");
   $pos_webkit = strrpos($ua, "webkit");

   if (!($pos_blackberry === false)) {
      if (!($pos_webkit === false)) {

         **//load blackberry.css**

      }
   } else {
     wp_enqueue_style( 'twentytwelve-style', get_stylesheet_uri() );
   }

Question: what is the “grammatically correct” WordPress syntax for loading blackberry.css stylesheet?

Related posts

1 comment

  1. Well… You’ve already used wp_enqueue_style. Use it again. That is the canonical mechanism for loading stylesheets either by itself or in combination with wp_register_style

    wp_enqueue_style('blackberry',get_stylesheet_directory_uri().'/path/to/blackberry.css');
    

    I feel compelled to note that user agent sniffing is not especially reliable. Is it not possible to do this with media queries?

    Reference

    http://codex.wordpress.org/Function_Reference/get_stylesheet_directory_uri

Comments are closed.