Wordpress Browser Body Class


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



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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.