Change style depending on user browser in Wordpress


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. add_filter('body_class','browser_body_class');
  2. function browser_body_class($classes) {
  3. global $is_lynx, $is_gecko, $is_IE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone;
  4.  
  5. if($is_lynx) $classes[] = 'lynx';
  6. elseif($is_gecko) $classes[] = 'gecko';
  7. elseif($is_opera) $classes[] = 'opera';
  8. elseif($is_NS4) $classes[] = 'ns4';
  9. elseif($is_safari) $classes[] = 'safari';
  10. elseif($is_chrome) $classes[] = 'chrome';
  11. elseif($is_IE) $classes[] = 'ie';
  12. else $classes[] = 'unknown';
  13.  
  14. if($is_iphone) $classes[] = 'iphone';
  15. return $classes;
  16. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.