Last active
March 30, 2018 09:45
-
-
Save oalansari82/f4afde99687712931f2c80e338f454c3 to your computer and use it in GitHub Desktop.
Add body class based on browser
This file contains hidden or 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 | |
// Only add the content below this line | |
add_filter('body_class','browser_body_class'); | |
/** | |
* | |
* Add browser class based on user browser | |
* | |
*/ | |
function 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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment