Return to Snippet

Revision: 47340
at June 6, 2011 00:56 by alp


Initial Code
/**
 * Detect Visitors Browser
 *
 **/
add_filter('body_class','myfunction_browser_body_class');
function myfunction_browser_body_class($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';
	return $classes;
}

Initial URL

                                

Initial Description

                                

Initial Title
Wordpress: Detect Visitors Browser and output in body class

Initial Tags
wordpress

Initial Language
PHP