Last active
October 25, 2017 21:04
-
-
Save Aeonexe/4aaab5e52163e0535c9f97e01e50a361 to your computer and use it in GitHub Desktop.
Wordpress User Agent Class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html class="class="<?php wpkit_user_agent_class(); ?>"> | |
<head></head> | |
<body></body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment