Skip to content

Instantly share code, notes, and snippets.

@fumikito
Created August 23, 2010 09:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fumikito/545135 to your computer and use it in GitHub Desktop.
Save fumikito/545135 to your computer and use it in GitHub Desktop.
Browser Detect in WordPress
<?php
/**
* Detect if the browser is Internet Explorer or not
* @package WordPress
* @param int $version optional
* @return Boolean
*/
function is_IE($version = 0)
{
$flg = false;
global $is_winIE;
if(!$is_winIE)
return $flg;
switch($version){
case 6:
if(preg_match("/compatible; MSIE 6\.0;/", $_SERVER["HTTP_USER_AGENT"]))
$flg = true;
break;
case 7:
if(preg_match("/compatible; MSIE 7\.0;/", $_SERVER["HTTP_USER_AGENT"]))
$flg = true;
break;
case 8:
if(preg_match("/MSIE 8\.0/", $_SERVER["HTTP_USER_AGENT"]))
$flg = true;
break;
default:
$flg = true;
break;
}
return $flg;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment