Revision: 21978
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at December 27, 2009 23:54 by afj176
Initial Code
/*Browser Detect*/ function browser_detect(){ $ipod = stripos($_SERVER['HTTP_USER_AGENT'],"iPod"); $iphone = stripos($_SERVER['HTTP_USER_AGENT'],"iPhone"); $firefox = stripos($_SERVER['HTTP_USER_AGENT'],"Firefox"); $safari = stripos($_SERVER['HTTP_USER_AGENT'],"Safari"); $ie = stripos($_SERVER['HTTP_USER_AGENT'],"MSIE"); $opera = stripos($_SERVER['HTTP_USER_AGENT'],"Opera"); $maxthon = stripos($_SERVER['HTTP_USER_AGENT'],"Maxthon"); $chrome = stripos($_SERVER['HTTP_USER_AGENT'],"Chrome"); $netscape = stripos($_SERVER['HTTP_USER_AGENT'],"Netscape"); $traveler = stripos($_SERVER['HTTP_USER_AGENT'], "Traveler"); //detecting device if ($ipod == true || $iphone == true){ echo "<div class=\"browser\">"; echo "<img src=\"images/iphone.png\">"; echo "<br />"; echo "<p>You are viewing this site on an Ipod or Iphone</p>"; echo "</div>"; }elseif($firefox == true){ echo "<div class=\"browser\">"; echo "<img src=\"images/Firefox.png\">"; echo "<br />"; echo "<p>You are viewing this site in Firefox</p>"; echo "</div>"; }elseif($ie == true){ echo "<div class=\"browser\">"; echo "<img src=\"images/IE.png\">"; echo "<br />"; echo "<p>You are viewing this site in Internet Explorer</p>"; echo "</div>"; }elseif($netscape == true){ echo "<div class=\"browser\">"; echo "<img src=\"images/Netcape.png\">"; echo "<br />"; echo "<p>You are viewing this site in Netscape</p>"; echo "</div>"; }elseif($traveler == true){ echo "<div class=\"browser\">"; echo "<img src=\"images/Traveler.png\">"; echo "<br />"; echo "<p>You are viewing this site in Traveler</p>"; echo "</div>"; }elseif($maxthon == true){ echo "<div class=\"browser\">"; echo "<img src=\"images/Maxthon.png\">"; echo "<br />"; echo "<p>You are viewing this site in Maxthon</p>"; echo "</div>"; }elseif($chrome == true){ echo "<div class=\"browser\">"; echo "<img src=\"images/Chrome.png\">"; echo "<br />"; echo "<p>You are viewing this site in Chrome</p>"; echo "</div>"; }elseif($safari == true){ echo "<div class=\"browser\">"; echo "<img src=\"images/Safari.png\">"; echo "<br />"; echo "<p>You are viewing this site in Safari</p>"; echo "</div>"; }elseif($opera == true){ echo "<div class=\"browser\">"; echo "<img src=\"images/Opera.png\">"; echo "<br />"; echo "<p>You are viewing this site in Opera</p>"; echo "</div>"; }else{ echo "<div class=\"browser\">"; echo "<img src=\"images/Q.png\">"; echo "<br />"; echo "<p>We currently dont know your browser.</p>"; echo "</div>"; } };
Initial URL
http://afj176.com
Initial Description
Place in your functions.php file and call it in your theme like this: <?php>
Initial Title
Wordpress Browser Detection Function
Initial Tags
php, wordpress, browser, function
Initial Language
PHP