Skip to content

Instantly share code, notes, and snippets.

@liam-lime
Created February 6, 2019 10:40
Show Gist options
  • Save liam-lime/f89106b5a894d1d2ea485cef2707645a to your computer and use it in GitHub Desktop.
Save liam-lime/f89106b5a894d1d2ea485cef2707645a to your computer and use it in GitHub Desktop.
WP Filter: Определяет браузер и добавляет его имя в body
/*
Use WordPress conditional tags to detect the user’s web browser
and add a class with it’s name to the body tag.
*/
<?php
add_filter('body_class','browser_body_class');
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