Skip to content

Instantly share code, notes, and snippets.

@nfsarmento
Last active October 30, 2018 14:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nfsarmento/149228a3a758c41583fd29436f6e6046 to your computer and use it in GitHub Desktop.
Save nfsarmento/149228a3a758c41583fd29436f6e6046 to your computer and use it in GitHub Desktop.
Detect Browser : If you want to use a different stylesheet for different browsers you can use HTML conditional tags or you can use this.
/** Detect Browser : If you want to use a different stylesheet for different browsers you can use HTML conditional tags or you can use this.
*
* https://www.nuno-sarmento.com
*/
add_filter('body_class','ns_browser_body_class');
function ns_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