Advertisement
webreach

Untitled

Jan 7th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.99 KB | None | 0 0
  1. function browser_body_class($classes) {
  2.     global $is_lynx, $is_gecko, $is_IE, $is_edge, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone;
  3.     if($is_lynx) $classes[] = 'lynx';
  4.     elseif($is_gecko) $classes[] = 'gecko';
  5.     elseif($is_opera) $classes[] = 'opera';
  6.     elseif($is_NS4) $classes[] = 'ns4';
  7.     elseif($is_safari) $classes[] = 'safari';
  8.     elseif($is_chrome) $classes[] = 'chrome';
  9.     elseif($is_edge) $classes[] = 'edge';
  10.     elseif($is_IE) {
  11.         $classes[] = 'ie';
  12.         if(preg_match('/MSIE ([0-9]+)([a-zA-Z0-9.]+)/', $_SERVER['HTTP_USER_AGENT'], $browser_version))
  13.             $classes[] = 'ie'.$browser_version[1];
  14.     } else $classes[] = 'unknown';
  15.     if($is_iphone) $classes[] = 'iphone';
  16.     if ( stristr( $_SERVER['HTTP_USER_AGENT'],"mac") ) {
  17.         $classes[] = 'osx';
  18.     } elseif ( stristr( $_SERVER['HTTP_USER_AGENT'],"linux") ) {
  19.         $classes[] = 'linux';
  20.     } elseif ( stristr( $_SERVER['HTTP_USER_AGENT'],"windows") ) {
  21.         $classes[] = 'windows';
  22.     }
  23.     return $classes;
  24. }
  25. add_filter('body_class','browser_body_class');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement