{"id":985,"date":"2012-10-14T14:50:31","date_gmt":"2012-10-14T14:50:31","guid":{"rendered":"http:\/\/keithdevon.wpengine.com\/?p=985"},"modified":"2012-11-09T12:22:31","modified_gmt":"2012-11-09T12:22:31","slug":"wordpress-is_iphone-global","status":"publish","type":"post","link":"https:\/\/keithdevon.com\/wordpress-is_iphone-global\/","title":{"rendered":"WordPress $is_iphone global"},"content":{"rendered":"<p>OK, why did nobody tell me about this, and why is it not documented!<\/p>\n<p>I just found out today that WordPress does some browser detection of its own. I&#8217;ve previously relied on other code libraries for this, but maybe now I can use the &#8216;WordPress Way&#8217;.<\/p>\n<h2>Detecting mobile in WordPress using $is_iphone<\/h2>\n<p>In wp-includes\/vars.php there is the following declaration:<\/p>\n<p>[code lang=&#8221;php&#8221;]<\/p>\n<p>global $pagenow,<br \/>\n$is_lynx, $is_gecko, $is_winIE, $is_macIE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone, $is_IE,<br \/>\n$is_apache, $is_IIS, $is_iis7;<\/p>\n<p>[\/code]<\/p>\n<p>So it looks like WordPress detects a number of browsers. The $is_iphone variable is interesting because it seems to work as a general &#8216;mobile&#8217; detection. I have it working to detect the Android &#8216;Internet&#8217; browser.<\/p>\n<p>I&#8217;ll add more here as I play with the possibilities.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;ve previously relied on other code libraries for this, but maybe now I can use the &#8216;WordPress Way&#8217;. Detecting mobile in WordPress using $is_iphone In wp-includes\/vars.php there [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false},"categories":[81],"tags":[83,47],"acf":[],"_links":{"self":[{"href":"https:\/\/keithdevon.com\/wp-json\/wp\/v2\/posts\/985"}],"collection":[{"href":"https:\/\/keithdevon.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/keithdevon.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/keithdevon.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/keithdevon.com\/wp-json\/wp\/v2\/comments?post=985"}],"version-history":[{"count":0,"href":"https:\/\/keithdevon.com\/wp-json\/wp\/v2\/posts\/985\/revisions"}],"wp:attachment":[{"href":"https:\/\/keithdevon.com\/wp-json\/wp\/v2\/media?parent=985"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/keithdevon.com\/wp-json\/wp\/v2\/categories?post=985"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/keithdevon.com\/wp-json\/wp\/v2\/tags?post=985"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}