Aeonexe
10/25/2017 - 9:00 PM

Wordpress User Agent Class

Wordpress User Agent Class

<!DOCTYPE html>
<html class="class="<?php wpkit_user_agent_class(); ?>">
	<head></head>
	<body></body>
</html>                                              
<?php 

function wpkit_user_agent_class() {

	global $is_lynx, $is_gecko, $is_IE, $is_winIE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_edge, $is_iphone;
	$opera = strpos( $_SERVER['HTTP_USER_AGENT'], 'OPR');
	$operaneon = strpos( $_SERVER['HTTP_USER_AGENT'], 'MMS');
	$useragent = $_SERVER['HTTP_USER_AGENT'];

	if( $is_lynx ) : echo ' linux';
		elseif( $is_gecko ) : echo 'firefox';
		elseif( $is_winIE ) : echo 'iexplorer';
		elseif( $is_opera ) : echo 'opera';
		elseif( $is_NS4 ) : echo 'ns4';
		elseif( $is_safari ) : echo 'safari';
		// No opera u opera neon
		elseif( $is_chrome && strpos( $useragent, 'WOW64') == false ) : echo 'chrome';
		elseif( $is_chrome && strpos( $useragent, $opera) == true ) : echo 'opera';
		elseif( $is_chrome && strpos( $useragent, $operaneon) == true ) : echo 'operaneon';
		elseif( $is_edge ) : echo ' edge ';
		else : echo ' unknown_browser ';
	endif;

	if($is_iphone) : echo ' iphone '; endif;

	if ( stristr( $_SERVER['HTTP_USER_AGENT'],"mac") ) : echo ' osx';
		elseif ( stristr( $_SERVER['HTTP_USER_AGENT'],"linux") ) : echo ' linux';
		elseif ( stristr( $_SERVER['HTTP_USER_AGENT'],"windows") ) : echo ' windows';
	endif;

}