ThemeShaper Forums » Thematic


List of body class selectors for os/browsers?

(6 posts)
  • Started 11 years ago by marcopolo
  • Latest reply from wlanni
  • This topic is resolved
  1. Hey, I've been dipping into this forum for the past couple months for answers on all things Thematic. So far it's been very helpful, thanks.

    Now I'm at the stage of ironing out cross-browser quirks (e.g., submit button rendering in IE6 ... Aaargh!) and I want to make sure I'm using the proper selectors. The is the list of dynamic body class selectors I've culled from dynamic-classes.php. Let me know if it's complete and correct, thanks.



    Posted 11 years ago #
  2. Hi marcopolo,

    Look here for the thematic_body_class function that creates the classes:


    about two hundred lines down the page you'll see the browser detection & class insertion block of code. Look for the comment

    // A little Browser detection shall we?

    All of the $c[] = ''; represent classes that will potentially be added to the array. Therein lies your answer.


    Posted 11 years ago #
  3. I was trying to add an iPhone body class but couldn't seem to get it to work. Has anyone done this? I was just working directly on Thematic to start:

    } elseif ( preg_match( "/iPhone/", $browser ) ){
    		$c[] = 'iphone';
    Posted 11 years ago #
  4. Hi Devin,

    function mobile_body_class($classes) {
    	$browser = $_SERVER[ 'HTTP_USER_AGENT' ];
    	if ( preg_match( "/iPhone/", $browser ) ){
    		$classes[] = 'mobile-safari';
    	return $classes;

    This should work as a function for a child-theme. I ran a quick test using the Develop>UserAgent switcher in Safari to spoof the browser.

    I like the mobile-safari class better since this preg_match seems to return true for iPod Touches as well.


    Posted 11 years ago #
  5. Thanks Gene. I'll try it out. Didn't realize I could try that trick with "UserAgent"- should be helpful as well.

    Posted 11 years ago #
  6. wlanni

    Great. I'm curious, anyone know how Android, iPad and windows phone appear? Would the preg_math look for /Android/, /iPad/, /Windows/?

    Posted 9 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.