Return to Snippet

Revision: 64082
at July 2, 2013 18:22 by larscmagnusson


Initial Code
// Lägger till vilken browser man har, plus vilken version (om IE)
add_filter( 'body_class', function($classes){
	global $is_lynx, $is_gecko, $is_IE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone;

	if($is_lynx) $classes[] = 'lynx';
	elseif($is_gecko) $classes[] = 'gecko';
	elseif($is_opera) $classes[] = 'opera';
	elseif($is_NS4) $classes[] = 'ns4';
	elseif($is_safari) $classes[] = 'safari';
	elseif($is_chrome) $classes[] = 'chrome';
	elseif($is_IE) $classes[] = 'ie';
	else $classes[] = 'unknown';

	if($is_iphone) $classes[] = 'iphone';

	// IE version
	if($is_IE) {
		preg_match('/MSIE (.*?);/', $_SERVER['HTTP_USER_AGENT'], $matches);

		if (count($matches) > 1)
		  $classes[] = 'ie-'. round($matches[1]);

  	}

	return $classes;
});

Initial URL

                                

Initial Description

                                

Initial Title
Browser body class

Initial Tags
class, wordpress, browser

Initial Language
PHP