Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change is_iphone so that it doesn't detect iPad #21

Open
bummzack opened this issue Apr 30, 2012 · 2 comments
Open

Change is_iphone so that it doesn't detect iPad #21

bummzack opened this issue Apr 30, 2012 · 2 comments

Comments

@bummzack
Copy link

I think the is_iphone method should be rewritten to:

return (preg_match('/(ipod;|iphone;)/i', $_SERVER['HTTP_USER_AGENT'])) ? true : false;

By adding the semicolons you're making sure that you match the "correct" part of the user-agent string (the user-agent string also contains iphone on an iPad somewhere, but by adding the semicolon ensures you capture the right part).

I've read the other issues/change requests regarding different templates for different devices and I support that idea. Since iPad and iPhone are quite different when it comes to screen-estate and browsing behavior, iPad should be treated separately or at least not considered to be an iPhone or a "mobile device" at all (hence this issue).

@moveforward
Copy link

+1. Kind of surprised me to see my site's mobile theme being served up to ipad.

@moveforward
Copy link

actually, the issue seems to be related to this line (around line 72 of MobileBrowserDetector.php):

case(preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|vodafone|o2|pocket|kindle|mobile|pda|psp|treo)/i', $agent)):

iPad has 'Mobile' in the UA string so iPad is triggering is_mobile.
Possible solution:
case(preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|vodafone|o2|pocket|kindle|mobile|pda|psp|treo)/i', $agent) && (stripos($_SERVER['HTTP_USER_AGENT'], 'ipad') === false)):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants