Changeset 20417 for trunk/wp-includes/vars.php
- Timestamp:
- 04/10/2012 01:19:30 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/vars.php
r19712 r20417 98 98 */ 99 99 $is_iis7 = $is_IIS && (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS/7.') !== false); 100 101 /** 102 * Test if the current browser runs on a mobile device (smart phone, tablet, etc.) 103 * 104 * @return bool true|false 105 */ 106 function wp_is_mobile() { 107 static $is_mobile; 108 109 if ( isset($is_mobile) ) 110 return $is_mobile; 111 112 if ( empty($_SERVER['HTTP_USER_AGENT']) ) { 113 $is_mobile = false; 114 } elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'Mobile') !== false // many mobile devices (all iPhone, iPad, etc.) 115 || strpos($_SERVER['HTTP_USER_AGENT'], 'Android') !== false 116 || strpos($_SERVER['HTTP_USER_AGENT'], 'BlackBerry') !== false 117 || strpos($_SERVER['HTTP_USER_AGENT'], 'Opera Mini') !== false ) { 118 $is_mobile = true; 119 } else { 120 $is_mobile = false; 121 } 122 123 return $is_mobile; 124 }
Note: See TracChangeset
for help on using the changeset viewer.