mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-01 15:50:09 +00:00
Introduce wp_is_mobile() and use it instead of $is_iphone global, see #20014
git-svn-id: https://develop.svn.wordpress.org/trunk@20417 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -97,3 +97,28 @@ $is_IIS = !$is_apache && (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !
|
||||
* @global bool $is_iis7
|
||||
*/
|
||||
$is_iis7 = $is_IIS && (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS/7.') !== false);
|
||||
|
||||
/**
|
||||
* Test if the current browser runs on a mobile device (smart phone, tablet, etc.)
|
||||
*
|
||||
* @return bool true|false
|
||||
*/
|
||||
function wp_is_mobile() {
|
||||
static $is_mobile;
|
||||
|
||||
if ( isset($is_mobile) )
|
||||
return $is_mobile;
|
||||
|
||||
if ( empty($_SERVER['HTTP_USER_AGENT']) ) {
|
||||
$is_mobile = false;
|
||||
} elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'Mobile') !== false // many mobile devices (all iPhone, iPad, etc.)
|
||||
|| strpos($_SERVER['HTTP_USER_AGENT'], 'Android') !== false
|
||||
|| strpos($_SERVER['HTTP_USER_AGENT'], 'BlackBerry') !== false
|
||||
|| strpos($_SERVER['HTTP_USER_AGENT'], 'Opera Mini') !== false ) {
|
||||
$is_mobile = true;
|
||||
} else {
|
||||
$is_mobile = false;
|
||||
}
|
||||
|
||||
return $is_mobile;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user