ThemeShaper Forums » Thematic

[closed]

Dynamic Body Classes

(10 posts)
  • Started 3 years ago by driftwood
  • Latest reply from wlanni
  • This topic is not resolved
  1. driftwood
    Member

    How do I initiate Thematics Dynamic Body Classes or is that automatically set to run?

    Posted 3 years ago #
  2. put this in your function.php file

    define('THEMATIC_COMPATIBLE_BODY_CLASS', true);
    define('THEMATIC_COMPATIBLE_POST_CLASS', true);

    Posted 3 years ago #
  3. driftwood
    Member

    epic awesomeness, THANK YOU!!!

    Posted 3 years ago #
  4. driftwood
    Member

    all good in lala land.

    Posted 3 years ago #
  5. wlanni
    Member

    Just a note: IE9 (and probably 10) aren't defined yet.

    The function to redefine is browser_class_names($classes). I'm working on filtering that right now, will post back code here in a little bit.

    Posted 3 years ago #
  6. wlanni
    Member

    Add this to your childtheme functions. I'm making a HUGE assumption that IE 10 is going to show up with its version as I listed below. Who knows, maybe they'll call it "Version HAHAHATAKETHATWLANNI!!!"

    //add IE9, IE10 to body class
    function add_ie_browser_class_names($classes) {
    	// add 'class-name' to the $classes array
    	// $classes[] = 'class-name';
    	$browser = $_SERVER[ 'HTTP_USER_AGENT' ];
    
    	// Checks browsers in this order: Chrome, Safari, Opera, MSIE, FF
    	if ( preg_match( "/MSIE/", $browser ) ) {
    		//$classes[] = 'msie';
    
    		if ( preg_match( "/MSIE 9.0/", $browser) ) {
    			$classes[] = 'ie9';
    		} elseif ( preg_match( "/MSIE 10.0/", $browser) ) {
    			$classes[] = 'ie10';
    		}
    	}
    	// return the $classes array
    	return $classes;
    }
    add_filter('thematic_body_class', 'add_ie_browser_class_names');
    Posted 3 years ago #
  7. wlanni
    Member

    Whoops!

    //add IE9, IE10 to body class
    function add_ie_browser_class_names($classes) {
    	// add 'class-name' to the $classes array
    	// $classes[] = 'class-name';
    	$browser = $_SERVER[ 'HTTP_USER_AGENT' ];
    
    	if ( preg_match( "/MSIE/", $browser ) ) {
    		//$classes[] = 'msie';
    
    		if ( preg_match( "/MSIE 9.0/", $browser) ) {
    			$classes[] = 'ie9';
    		} elseif ( preg_match( "/MSIE 10.0/", $browser) ) {
    			$classes[] = 'ie10';
    		}
    	}
    	// return the $classes array
    	return $classes;
    }
    add_filter('thematic_body_class', 'add_ie_browser_class_names');
    Posted 3 years ago #
  8. wlanni
    Member

    Hey Driftwood, would you set this to resolved if it is resolved?

    Posted 3 years ago #
  9. Will be included in a couple of days. Added some new stuff that needs some documentation.

    Chris

    Posted 3 years ago #
  10. wlanni
    Member

    As an update, here's some mobile body classes. I'm not 100% the iemobile one works yet, if anyone has a windows phone 7, can you test?

    //add mobile browsers
    function mobile_body_class($classes) {
    	$browser = $_SERVER[ 'HTTP_USER_AGENT' ];
    
    	if ( preg_match( "/iPhone/", $browser ) ){
    		$classes[] = 'mobile-safari mobile';
    	} elseif ( preg_match( "/Android/", $browser ) ) {
    		$classes[] = 'mobile-android mobile';
    	} elseif ( preg_match( "/iemobile/", $browser) ) {
    		$classes[] = 'mobile-ie mobile';
    	}
    	return $classes;
    }
    add_filter('thematic_body_class','mobile_body_class');
    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.