Keith Devon

Menu

Tag: mobile

WordPress $is_iphone global

OK, why did nobody tell me about this, and why is it not documented!

I just found out today that WordPress does some browser detection of its own. I’ve previously relied on other code libraries for this, but maybe now I can use the ‘WordPress Way’.

Detecting mobile in WordPress using $is_iphone

In wp-includes/vars.php there is the following declaration:


global $pagenow,
$is_lynx, $is_gecko, $is_winIE, $is_macIE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone, $is_IE,
$is_apache, $is_IIS, $is_iis7;

So it looks like WordPress detects a number of browsers. The $is_iphone variable is interesting because it seems to work as a general ‘mobile’ detection. I have it working to detect the Android ‘Internet’ browser.

I’ll add more here as I play with the possibilities.