Version Description
Download this release
Release Info
| Developer | thingalon |
| Plugin | |
| Version | 1.9.1 |
| Comparing to | |
| See all releases | |
Code changes from version 1.9 to 1.9.1
plugins/jetpack.php
CHANGED
|
@@ -1,5 +1,14 @@
|
|
| 1 |
<?php
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
function wp_super_cache_jetpack_admin() {
|
| 4 |
global $cache_jetpack, $wp_cache_config_file, $valid_nonce;
|
| 5 |
|
|
@@ -52,18 +61,6 @@ function wp_super_cache_jetpack_admin() {
|
|
| 52 |
add_cacheaction( 'cache_admin_page', 'wp_super_cache_jetpack_admin' );
|
| 53 |
|
| 54 |
function wp_super_cache_jetpack_cookie_check( $cache_key ) {
|
| 55 |
-
if ( false === function_exists( 'jetpack_is_mobile' ) ) {
|
| 56 |
-
|
| 57 |
-
if ( file_exists( dirname( WPCACHEHOME ) . '/jetpack-dev/class.jetpack-user-agent.php' ) ) {
|
| 58 |
-
wp_cache_debug( "wp_super_cache_jetpack_cookie_check: jetpack dev detected. Returning 'normal' to avoid loading Jetpack." );
|
| 59 |
-
return 'normal';
|
| 60 |
-
} elseif ( file_exists( dirname( WPCACHEHOME ) . '/jetpack/class.jetpack-user-agent.php' ) ) {
|
| 61 |
-
include_once dirname( WPCACHEHOME ) . '/jetpack/class.jetpack-user-agent.php';
|
| 62 |
-
} else {
|
| 63 |
-
wp_cache_debug( 'wp_super_cache_jetpack_cookie_check: jetpack UA file not found.' );
|
| 64 |
-
}
|
| 65 |
-
}
|
| 66 |
-
|
| 67 |
if ( isset ( $_COOKIE['akm_mobile'] ) ) {
|
| 68 |
if ( $_COOKIE['akm_mobile'] == 'true' ) {
|
| 69 |
return 'mobile';
|
|
@@ -72,12 +69,12 @@ function wp_super_cache_jetpack_cookie_check( $cache_key ) {
|
|
| 72 |
}
|
| 73 |
}
|
| 74 |
|
| 75 |
-
if (
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
} else {
|
| 82 |
return 'normal';
|
| 83 |
}
|
| 1 |
<?php
|
| 2 |
|
| 3 |
+
if ( ! class_exists( 'Automattic\Jetpack\Device_Detection' ) ) {
|
| 4 |
+
// Manually load Device_Detection before autoload is initialized.
|
| 5 |
+
if ( defined( 'WPCACHEHOME' ) ) {
|
| 6 |
+
if ( file_exists( WPCACHEHOME . '/vendor/automattic/jetpack-device-detection/src/class-device-detection.php' ) ) {
|
| 7 |
+
require_once WPCACHEHOME . '/vendor/automattic/jetpack-device-detection/src/class-device-detection.php';
|
| 8 |
+
}
|
| 9 |
+
}
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
function wp_super_cache_jetpack_admin() {
|
| 13 |
global $cache_jetpack, $wp_cache_config_file, $valid_nonce;
|
| 14 |
|
| 61 |
add_cacheaction( 'cache_admin_page', 'wp_super_cache_jetpack_admin' );
|
| 62 |
|
| 63 |
function wp_super_cache_jetpack_cookie_check( $cache_key ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
if ( isset ( $_COOKIE['akm_mobile'] ) ) {
|
| 65 |
if ( $_COOKIE['akm_mobile'] == 'true' ) {
|
| 66 |
return 'mobile';
|
| 69 |
}
|
| 70 |
}
|
| 71 |
|
| 72 |
+
if ( ! class_exists( 'Automattic\Jetpack\Device_Detection' ) ) {
|
| 73 |
+
return 'normal';
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
if ( \Automattic\Jetpack\Device_Detection::is_phone() ) {
|
| 77 |
+
return 'mobile';
|
| 78 |
} else {
|
| 79 |
return 'normal';
|
| 80 |
}
|
readme.txt
CHANGED
|
@@ -3,8 +3,8 @@ Contributors: donncha, automattic
|
|
| 3 |
Tags: performance, caching, wp-cache, wp-super-cache, cache
|
| 4 |
Requires at least: 5.9
|
| 5 |
Requires PHP: 5.6
|
| 6 |
-
Tested up to: 6.
|
| 7 |
-
Stable tag: 1.9
|
| 8 |
License: GPLv2 or later
|
| 9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 10 |
|
|
@@ -268,6 +268,10 @@ Your theme is probably responsive which means it resizes the page to suit whatev
|
|
| 268 |
|
| 269 |
|
| 270 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
| 271 |
### 1.9 - 2022-09-16
|
| 272 |
#### Added
|
| 273 |
- Cache deletion: add new hook to trigger actions after a successful cache deletion from the admin bar.
|
| 3 |
Tags: performance, caching, wp-cache, wp-super-cache, cache
|
| 4 |
Requires at least: 5.9
|
| 5 |
Requires PHP: 5.6
|
| 6 |
+
Tested up to: 6.1
|
| 7 |
+
Stable tag: 1.9.1
|
| 8 |
License: GPLv2 or later
|
| 9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 10 |
|
| 268 |
|
| 269 |
|
| 270 |
== Changelog ==
|
| 271 |
+
### 1.9.1 - 2022-11-02
|
| 272 |
+
#### Fixed
|
| 273 |
+
- Fixes crash when using the "Jetpack Mobile Theme" plugin alongside Jetpack 11.5.
|
| 274 |
+
|
| 275 |
### 1.9 - 2022-09-16
|
| 276 |
#### Added
|
| 277 |
- Cache deletion: add new hook to trigger actions after a successful cache deletion from the admin bar.
|
vendor/automattic/jetpack-device-detection/src/class-device-detection.php
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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<?php
|
| 2 |
+
/**
|
| 3 |
+
* Device detection for Jetpack.
|
| 4 |
+
*
|
| 5 |
+
* @package automattic/jetpack-device-detection
|
| 6 |
+
*/
|
| 7 |
+
|
| 8 |
+
namespace Automattic\Jetpack;
|
| 9 |
+
|
| 10 |
+
require_once __DIR__ . '/functions.php';
|
| 11 |
+
require_once __DIR__ . '/class-user-agent-info.php';
|
| 12 |
+
|
| 13 |
+
use Automattic\Jetpack\Device_Detection\User_Agent_Info;
|
| 14 |
+
use function Automattic\Jetpack\Device_Detection\wp_unslash;
|
| 15 |
+
|
| 16 |
+
/**
|
| 17 |
+
* Class Device_Detection
|
| 18 |
+
*
|
| 19 |
+
* Determine if the current User Agent matches the passed $kind.
|
| 20 |
+
*/
|
| 21 |
+
class Device_Detection {
|
| 22 |
+
|
| 23 |
+
/**
|
| 24 |
+
* Returns information about the current device accessing the page.
|
| 25 |
+
*
|
| 26 |
+
* @param string $ua (Optional) User-Agent string.
|
| 27 |
+
*
|
| 28 |
+
* @return array Device information.
|
| 29 |
+
*
|
| 30 |
+
* array(
|
| 31 |
+
* 'is_phone' => (bool) Whether the current device is a mobile phone.
|
| 32 |
+
* 'is_smartphone' => (bool) Whether the current device is a smartphone.
|
| 33 |
+
* 'is_tablet' => (bool) Whether the current device is a tablet device.
|
| 34 |
+
* 'is_handheld' => (bool) Whether the current device is a handheld device.
|
| 35 |
+
* 'is_desktop' => (bool) Whether the current device is a laptop / desktop device.
|
| 36 |
+
* 'platform' => (string) Detected platform.
|
| 37 |
+
* 'is_phone_matched_ua' => (string) Matched UA.
|
| 38 |
+
* );
|
| 39 |
+
*/
|
| 40 |
+
public static function get_info( $ua = '' ) {
|
| 41 |
+
$ua_info = new User_Agent_Info( $ua );
|
| 42 |
+
|
| 43 |
+
$info = array(
|
| 44 |
+
'is_phone' => self::is_mobile( 'any', false, $ua_info ),
|
| 45 |
+
'is_phone_matched_ua' => self::is_mobile( 'any', true, $ua_info ),
|
| 46 |
+
'is_smartphone' => self::is_mobile( 'smart', false, $ua_info ),
|
| 47 |
+
'is_tablet' => $ua_info->is_tablet(),
|
| 48 |
+
'platform' => $ua_info->get_platform(),
|
| 49 |
+
);
|
| 50 |
+
|
| 51 |
+
$info['is_handheld'] = $info['is_phone'] || $info['is_tablet'];
|
| 52 |
+
$info['is_desktop'] = ! $info['is_handheld'];
|
| 53 |
+
|
| 54 |
+
if ( function_exists( 'apply_filters' ) ) {
|
| 55 |
+
/**
|
| 56 |
+
* Filter the value of Device_Detection::get_info.
|
| 57 |
+
*
|
| 58 |
+
* @since 1.0.0
|
| 59 |
+
*
|
| 60 |
+
* @param array $info Array of device information.
|
| 61 |
+
* @param string $ua User agent string passed to Device_Detection::get_info.
|
| 62 |
+
* @param User_Agent_Info $ua_info Instance of Automattic\Jetpack\Device_Detection\User_Agent_Info.
|
| 63 |
+
*/
|
| 64 |
+
$info = apply_filters( 'jetpack_device_detection_get_info', $info, $ua, $ua_info );
|
| 65 |
+
}
|
| 66 |
+
return $info;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
/**
|
| 70 |
+
* Detects phone devices.
|
| 71 |
+
*
|
| 72 |
+
* @param string $ua User-Agent string.
|
| 73 |
+
*
|
| 74 |
+
* @return bool
|
| 75 |
+
*/
|
| 76 |
+
public static function is_phone( $ua = '' ) {
|
| 77 |
+
$device_info = self::get_info( $ua );
|
| 78 |
+
return true === $device_info['is_phone'];
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
/**
|
| 82 |
+
* Detects smartphone devices.
|
| 83 |
+
*
|
| 84 |
+
* @param string $ua User-Agent string.
|
| 85 |
+
*
|
| 86 |
+
* @return bool
|
| 87 |
+
*/
|
| 88 |
+
public static function is_smartphone( $ua = '' ) {
|
| 89 |
+
$device_info = self::get_info( $ua );
|
| 90 |
+
return true === $device_info['is_smartphone'];
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
/**
|
| 94 |
+
* Detects tablet devices.
|
| 95 |
+
*
|
| 96 |
+
* @param string $ua User-Agent string.
|
| 97 |
+
*
|
| 98 |
+
* @return bool
|
| 99 |
+
*/
|
| 100 |
+
public static function is_tablet( $ua = '' ) {
|
| 101 |
+
$device_info = self::get_info( $ua );
|
| 102 |
+
return true === $device_info['is_tablet'];
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
/**
|
| 106 |
+
* Detects desktop devices.
|
| 107 |
+
*
|
| 108 |
+
* @param string $ua User-Agent string.
|
| 109 |
+
*
|
| 110 |
+
* @return bool
|
| 111 |
+
*/
|
| 112 |
+
public static function is_desktop( $ua = '' ) {
|
| 113 |
+
$device_info = self::get_info( $ua );
|
| 114 |
+
return true === $device_info['is_desktop'];
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
/**
|
| 118 |
+
* Detects handheld (i.e. phone + tablet) devices.
|
| 119 |
+
*
|
| 120 |
+
* @param string $ua User-Agent string.
|
| 121 |
+
*
|
| 122 |
+
* @return bool
|
| 123 |
+
*/
|
| 124 |
+
public static function is_handheld( $ua = '' ) {
|
| 125 |
+
$device_info = self::get_info( $ua );
|
| 126 |
+
return true === $device_info['is_handheld'];
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
/**
|
| 130 |
+
* Determine if the current User Agent matches the passed $kind.
|
| 131 |
+
*
|
| 132 |
+
* @param string $kind Category of mobile device to check for. Either: any, dumb, smart.
|
| 133 |
+
* @param bool $return_matched_agent Boolean indicating if the UA should be returned.
|
| 134 |
+
* @param User_Agent_Info $ua_info Boolean indicating if the UA should be returned.
|
| 135 |
+
*
|
| 136 |
+
* @return bool|string Boolean indicating if current UA matches $kind. If `$return_matched_agent` is true, returns the UA string.
|
| 137 |
+
*/
|
| 138 |
+
private static function is_mobile( $kind, $return_matched_agent, $ua_info ) {
|
| 139 |
+
$kinds = array(
|
| 140 |
+
'smart' => false,
|
| 141 |
+
'dumb' => false,
|
| 142 |
+
'any' => false,
|
| 143 |
+
);
|
| 144 |
+
$first_run = true;
|
| 145 |
+
$matched_agent = '';
|
| 146 |
+
|
| 147 |
+
// If an invalid kind is passed in, reset it to default.
|
| 148 |
+
if ( ! isset( $kinds[ $kind ] ) ) {
|
| 149 |
+
$kind = 'any';
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 153 |
+
return false;
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
$agent = strtolower( filter_var( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) );
|
| 157 |
+
if ( strpos( $agent, 'ipad' ) ) {
|
| 158 |
+
return false;
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
// Remove Samsung Galaxy tablets (SCH-I800) from being mobile devices.
|
| 162 |
+
if ( strpos( $agent, 'sch-i800' ) ) {
|
| 163 |
+
return false;
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
if ( $ua_info->is_android_tablet() && false === $ua_info->is_kindle_touch() ) {
|
| 167 |
+
return false;
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
if ( $ua_info->is_blackberry_tablet() ) {
|
| 171 |
+
return false;
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
if ( $first_run ) {
|
| 175 |
+
$first_run = false;
|
| 176 |
+
|
| 177 |
+
// checks for iPhoneTier devices & RichCSS devices.
|
| 178 |
+
if ( $ua_info->isTierIphone() || $ua_info->isTierRichCSS() ) {
|
| 179 |
+
$kinds['smart'] = true;
|
| 180 |
+
$matched_agent = $ua_info->matched_agent;
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
if ( ! $kinds['smart'] ) {
|
| 184 |
+
// if smart, we are not dumb so no need to check.
|
| 185 |
+
$dumb_agents = $ua_info->dumb_agents;
|
| 186 |
+
|
| 187 |
+
foreach ( $dumb_agents as $dumb_agent ) {
|
| 188 |
+
if ( false !== strpos( $agent, $dumb_agent ) ) {
|
| 189 |
+
$kinds['dumb'] = true;
|
| 190 |
+
$matched_agent = $dumb_agent;
|
| 191 |
+
|
| 192 |
+
break;
|
| 193 |
+
}
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
if ( ! $kinds['dumb'] ) {
|
| 197 |
+
if ( isset( $_SERVER['HTTP_X_WAP_PROFILE'] ) ) {
|
| 198 |
+
$kinds['dumb'] = true;
|
| 199 |
+
$matched_agent = 'http_x_wap_profile';
|
| 200 |
+
} elseif ( isset( $_SERVER['HTTP_ACCEPT'] ) && ( preg_match( '/wap\.|\.wap/i', $_SERVER['HTTP_ACCEPT'] ) || false !== strpos( strtolower( $_SERVER['HTTP_ACCEPT'] ), 'application/vnd.wap.xhtml+xml' ) ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput -- This is doing the validating.
|
| 201 |
+
$kinds['dumb'] = true;
|
| 202 |
+
$matched_agent = 'vnd.wap.xhtml+xml';
|
| 203 |
+
}
|
| 204 |
+
}
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
if ( $kinds['dumb'] || $kinds['smart'] ) {
|
| 208 |
+
$kinds['any'] = true;
|
| 209 |
+
}
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
$value = $kinds[ $kind ];
|
| 213 |
+
|
| 214 |
+
if ( $return_matched_agent ) {
|
| 215 |
+
$value = $matched_agent;
|
| 216 |
+
}
|
| 217 |
+
return $value;
|
| 218 |
+
}
|
| 219 |
+
}
|
vendor/automattic/jetpack-device-detection/src/class-user-agent-info.php
ADDED
|
@@ -0,0 +1,1581 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* User agent detection for Jetpack.
|
| 4 |
+
*
|
| 5 |
+
* @package automattic/jetpack-device-detection
|
| 6 |
+
*
|
| 7 |
+
* We don't want to rename public members.
|
| 8 |
+
* @phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
|
| 9 |
+
* @phpcs:disable WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase
|
| 10 |
+
* @phpcs:disable WordPress.NamingConventions.ValidVariableName.PropertyNotSnakeCase
|
| 11 |
+
* @phpcs:disable WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
|
| 12 |
+
*/
|
| 13 |
+
|
| 14 |
+
namespace Automattic\Jetpack\Device_Detection;
|
| 15 |
+
|
| 16 |
+
require_once __DIR__ . '/functions.php';
|
| 17 |
+
|
| 18 |
+
/**
|
| 19 |
+
* A class providing device properties detection.
|
| 20 |
+
*/
|
| 21 |
+
class User_Agent_Info {
|
| 22 |
+
|
| 23 |
+
/**
|
| 24 |
+
* Provided or fetched User-Agent string.
|
| 25 |
+
*
|
| 26 |
+
* @var string
|
| 27 |
+
*/
|
| 28 |
+
public $useragent;
|
| 29 |
+
|
| 30 |
+
/**
|
| 31 |
+
* A device group matched user agent, e.g. 'iphone'.
|
| 32 |
+
*
|
| 33 |
+
* @var string
|
| 34 |
+
*/
|
| 35 |
+
public $matched_agent;
|
| 36 |
+
|
| 37 |
+
/**
|
| 38 |
+
* Stores whether is the iPhone tier of devices.
|
| 39 |
+
*
|
| 40 |
+
* @var bool
|
| 41 |
+
*/
|
| 42 |
+
public $isTierIphone;
|
| 43 |
+
|
| 44 |
+
/**
|
| 45 |
+
* Stores whether the device can probably support Rich CSS, but JavaScript (jQuery) support is not assumed.
|
| 46 |
+
*
|
| 47 |
+
* @var bool
|
| 48 |
+
*/
|
| 49 |
+
public $isTierRichCss;
|
| 50 |
+
|
| 51 |
+
/**
|
| 52 |
+
* Stores whether it is another mobile device, which cannot be assumed to support CSS or JS (eg, older BlackBerry, RAZR)
|
| 53 |
+
*
|
| 54 |
+
* @var bool
|
| 55 |
+
*/
|
| 56 |
+
public $isTierGenericMobile;
|
| 57 |
+
|
| 58 |
+
/**
|
| 59 |
+
* Stores the device platform name
|
| 60 |
+
*
|
| 61 |
+
* @var null|string
|
| 62 |
+
*/
|
| 63 |
+
private $platform = null;
|
| 64 |
+
const PLATFORM_WINDOWS = 'windows';
|
| 65 |
+
const PLATFORM_IPHONE = 'iphone';
|
| 66 |
+
const PLATFORM_IPOD = 'ipod';
|
| 67 |
+
const PLATFORM_IPAD = 'ipad';
|
| 68 |
+
const PLATFORM_BLACKBERRY = 'blackberry';
|
| 69 |
+
const PLATFORM_BLACKBERRY_10 = 'blackberry_10';
|
| 70 |
+
const PLATFORM_SYMBIAN = 'symbian_series60';
|
| 71 |
+
const PLATFORM_SYMBIAN_S40 = 'symbian_series40';
|
| 72 |
+
const PLATFORM_J2ME_MIDP = 'j2me_midp';
|
| 73 |
+
const PLATFORM_ANDROID = 'android';
|
| 74 |
+
const PLATFORM_ANDROID_TABLET = 'android_tablet';
|
| 75 |
+
const PLATFORM_FIREFOX_OS = 'firefoxOS';
|
| 76 |
+
|
| 77 |
+
/**
|
| 78 |
+
* A list of dumb-phone user agent parts.
|
| 79 |
+
*
|
| 80 |
+
* @var array
|
| 81 |
+
*/
|
| 82 |
+
public $dumb_agents = array(
|
| 83 |
+
'nokia',
|
| 84 |
+
'blackberry',
|
| 85 |
+
'philips',
|
| 86 |
+
'samsung',
|
| 87 |
+
'sanyo',
|
| 88 |
+
'sony',
|
| 89 |
+
'panasonic',
|
| 90 |
+
'webos',
|
| 91 |
+
'ericsson',
|
| 92 |
+
'alcatel',
|
| 93 |
+
'palm',
|
| 94 |
+
'windows ce',
|
| 95 |
+
'opera mini',
|
| 96 |
+
'series60',
|
| 97 |
+
'series40',
|
| 98 |
+
'au-mic,',
|
| 99 |
+
'audiovox',
|
| 100 |
+
'avantgo',
|
| 101 |
+
'blazer',
|
| 102 |
+
'danger',
|
| 103 |
+
'docomo',
|
| 104 |
+
'epoc',
|
| 105 |
+
'ericy',
|
| 106 |
+
'i-mode',
|
| 107 |
+
'ipaq',
|
| 108 |
+
'midp-',
|
| 109 |
+
'mot-',
|
| 110 |
+
'netfront',
|
| 111 |
+
'nitro',
|
| 112 |
+
'palmsource',
|
| 113 |
+
'pocketpc',
|
| 114 |
+
'portalmmm',
|
| 115 |
+
'rover',
|
| 116 |
+
'sie-',
|
| 117 |
+
'symbian',
|
| 118 |
+
'cldc-',
|
| 119 |
+
'j2me',
|
| 120 |
+
'smartphone',
|
| 121 |
+
'up.browser',
|
| 122 |
+
'up.link',
|
| 123 |
+
'up.link',
|
| 124 |
+
'vodafone/',
|
| 125 |
+
'wap1.',
|
| 126 |
+
'wap2.',
|
| 127 |
+
'mobile',
|
| 128 |
+
'googlebot-mobile',
|
| 129 |
+
);
|
| 130 |
+
|
| 131 |
+
/**
|
| 132 |
+
* The constructor.
|
| 133 |
+
*
|
| 134 |
+
* @param string $ua (Optional) User agent.
|
| 135 |
+
*/
|
| 136 |
+
public function __construct( $ua = '' ) {
|
| 137 |
+
if ( $ua ) {
|
| 138 |
+
$this->useragent = $ua;
|
| 139 |
+
} else {
|
| 140 |
+
if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 141 |
+
$this->useragent = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This class is all about validating.
|
| 142 |
+
}
|
| 143 |
+
}
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
/**
|
| 147 |
+
* This method detects the mobile User Agent name.
|
| 148 |
+
*
|
| 149 |
+
* @return string The matched User Agent name, false otherwise.
|
| 150 |
+
*/
|
| 151 |
+
public function get_mobile_user_agent_name() {
|
| 152 |
+
if ( $this->is_chrome_for_iOS() ) { // Keep this check before the safari rule.
|
| 153 |
+
return 'chrome-for-ios';
|
| 154 |
+
} elseif ( $this->is_iphone_or_ipod( 'iphone-safari' ) ) {
|
| 155 |
+
return 'iphone';
|
| 156 |
+
} elseif ( $this->is_ipad( 'ipad-safari' ) ) {
|
| 157 |
+
return 'ipad';
|
| 158 |
+
} elseif ( $this->is_android_tablet() ) { // Keep this check before the android rule.
|
| 159 |
+
return 'android_tablet';
|
| 160 |
+
} elseif ( $this->is_android() ) {
|
| 161 |
+
return 'android';
|
| 162 |
+
} elseif ( $this->is_blackberry_10() ) {
|
| 163 |
+
return 'blackberry_10';
|
| 164 |
+
} elseif ( $this->is_blackbeberry() ) {
|
| 165 |
+
return 'blackberry';
|
| 166 |
+
} elseif ( $this->is_WindowsPhone7() ) {
|
| 167 |
+
return 'win7';
|
| 168 |
+
} elseif ( $this->is_windows_phone_8() ) {
|
| 169 |
+
return 'winphone8';
|
| 170 |
+
} elseif ( $this->is_opera_mini() ) {
|
| 171 |
+
return 'opera-mini';
|
| 172 |
+
} elseif ( $this->is_opera_mini_dumb() ) {
|
| 173 |
+
return 'opera-mini-dumb';
|
| 174 |
+
} elseif ( $this->is_opera_mobile() ) {
|
| 175 |
+
return 'opera-mobi';
|
| 176 |
+
} elseif ( $this->is_blackberry_tablet() ) {
|
| 177 |
+
return 'blackberry_tablet';
|
| 178 |
+
} elseif ( $this->is_kindle_fire() ) {
|
| 179 |
+
return 'kindle-fire';
|
| 180 |
+
} elseif ( $this->is_PalmWebOS() ) {
|
| 181 |
+
return 'webos';
|
| 182 |
+
} elseif ( $this->is_S60_OSSBrowser() ) {
|
| 183 |
+
return 'series60';
|
| 184 |
+
} elseif ( $this->is_firefox_os() ) {
|
| 185 |
+
return 'firefoxOS';
|
| 186 |
+
} elseif ( $this->is_firefox_mobile() ) {
|
| 187 |
+
return 'firefox_mobile';
|
| 188 |
+
} elseif ( $this->is_MaemoTablet() ) {
|
| 189 |
+
return 'maemo';
|
| 190 |
+
} elseif ( $this->is_MeeGo() ) {
|
| 191 |
+
return 'meego';
|
| 192 |
+
} elseif ( $this->is_TouchPad() ) {
|
| 193 |
+
return 'hp_tablet';
|
| 194 |
+
} elseif ( $this->is_facebook_for_iphone() ) {
|
| 195 |
+
return 'facebook-for-iphone';
|
| 196 |
+
} elseif ( $this->is_facebook_for_ipad() ) {
|
| 197 |
+
return 'facebook-for-ipad';
|
| 198 |
+
} elseif ( $this->is_twitter_for_iphone() ) {
|
| 199 |
+
return 'twitter-for-iphone';
|
| 200 |
+
} elseif ( $this->is_twitter_for_ipad() ) {
|
| 201 |
+
return 'twitter-for-ipad';
|
| 202 |
+
} elseif ( $this->is_wordpress_for_ios() ) {
|
| 203 |
+
return 'ios-app';
|
| 204 |
+
} elseif ( $this->is_iphone_or_ipod( 'iphone-not-safari' ) ) {
|
| 205 |
+
return 'iphone-unknown';
|
| 206 |
+
} elseif ( $this->is_ipad( 'ipad-not-safari' ) ) {
|
| 207 |
+
return 'ipad-unknown';
|
| 208 |
+
} elseif ( $this->is_Nintendo_3DS() ) {
|
| 209 |
+
return 'nintendo-3ds';
|
| 210 |
+
} else {
|
| 211 |
+
$agent = $this->useragent;
|
| 212 |
+
$dumb_agents = $this->dumb_agents;
|
| 213 |
+
foreach ( $dumb_agents as $dumb_agent ) {
|
| 214 |
+
if ( false !== strpos( $agent, $dumb_agent ) ) {
|
| 215 |
+
return $dumb_agent;
|
| 216 |
+
}
|
| 217 |
+
}
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
return false;
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
/**
|
| 224 |
+
* This method detects the mobile device's platform. All return strings are from the class constants.
|
| 225 |
+
* Note that this function returns the platform name, not the UA name/type. You should use a different function
|
| 226 |
+
* if you need to test the UA capabilites.
|
| 227 |
+
*
|
| 228 |
+
* @return string Name of the platform, false otherwise.
|
| 229 |
+
*/
|
| 230 |
+
public function get_platform() {
|
| 231 |
+
if ( isset( $this->platform ) ) {
|
| 232 |
+
return $this->platform;
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
if ( strpos( $this->useragent, 'windows phone' ) !== false ) {
|
| 236 |
+
$this->platform = self::PLATFORM_WINDOWS;
|
| 237 |
+
} elseif ( strpos( $this->useragent, 'windows ce' ) !== false ) {
|
| 238 |
+
$this->platform = self::PLATFORM_WINDOWS;
|
| 239 |
+
} elseif ( strpos( $this->useragent, 'ipad' ) !== false ) {
|
| 240 |
+
$this->platform = self::PLATFORM_IPAD;
|
| 241 |
+
} elseif ( strpos( $this->useragent, 'ipod' ) !== false ) {
|
| 242 |
+
$this->platform = self::PLATFORM_IPOD;
|
| 243 |
+
} elseif ( strpos( $this->useragent, 'iphone' ) !== false ) {
|
| 244 |
+
$this->platform = self::PLATFORM_IPHONE;
|
| 245 |
+
} elseif ( strpos( $this->useragent, 'android' ) !== false ) {
|
| 246 |
+
if ( $this->is_android_tablet() ) {
|
| 247 |
+
$this->platform = self::PLATFORM_ANDROID_TABLET;
|
| 248 |
+
} else {
|
| 249 |
+
$this->platform = self::PLATFORM_ANDROID;
|
| 250 |
+
}
|
| 251 |
+
} elseif ( $this->is_kindle_fire() ) {
|
| 252 |
+
$this->platform = self::PLATFORM_ANDROID_TABLET;
|
| 253 |
+
} elseif ( $this->is_blackberry_10() ) {
|
| 254 |
+
$this->platform = self::PLATFORM_BLACKBERRY_10;
|
| 255 |
+
} elseif ( strpos( $this->useragent, 'blackberry' ) !== false ) {
|
| 256 |
+
$this->platform = self::PLATFORM_BLACKBERRY;
|
| 257 |
+
} elseif ( $this->is_blackberry_tablet() ) {
|
| 258 |
+
$this->platform = self::PLATFORM_BLACKBERRY;
|
| 259 |
+
} elseif ( $this->is_symbian_platform() ) {
|
| 260 |
+
$this->platform = self::PLATFORM_SYMBIAN;
|
| 261 |
+
} elseif ( $this->is_symbian_s40_platform() ) {
|
| 262 |
+
$this->platform = self::PLATFORM_SYMBIAN_S40;
|
| 263 |
+
} elseif ( $this->is_J2ME_platform() ) {
|
| 264 |
+
$this->platform = self::PLATFORM_J2ME_MIDP;
|
| 265 |
+
} elseif ( $this->is_firefox_os() ) {
|
| 266 |
+
$this->platform = self::PLATFORM_FIREFOX_OS;
|
| 267 |
+
} else {
|
| 268 |
+
$this->platform = false;
|
| 269 |
+
}
|
| 270 |
+
|
| 271 |
+
return $this->platform;
|
| 272 |
+
}
|
| 273 |
+
|
| 274 |
+
/**
|
| 275 |
+
* This method detects for UA which can display iPhone-optimized web content.
|
| 276 |
+
* Includes iPhone, iPod Touch, Android, WebOS, Fennec (Firefox mobile), etc.
|
| 277 |
+
*/
|
| 278 |
+
public function isTierIphone() {
|
| 279 |
+
if ( isset( $this->isTierIphone ) ) {
|
| 280 |
+
return $this->isTierIphone;
|
| 281 |
+
}
|
| 282 |
+
if ( $this->is_iphoneOrIpod() ) {
|
| 283 |
+
$this->matched_agent = 'iphone';
|
| 284 |
+
$this->isTierIphone = true;
|
| 285 |
+
$this->isTierRichCss = false;
|
| 286 |
+
$this->isTierGenericMobile = false;
|
| 287 |
+
} elseif ( $this->is_android() ) {
|
| 288 |
+
$this->matched_agent = 'android';
|
| 289 |
+
$this->isTierIphone = true;
|
| 290 |
+
$this->isTierRichCss = false;
|
| 291 |
+
$this->isTierGenericMobile = false;
|
| 292 |
+
} elseif ( $this->is_windows_phone_8() ) {
|
| 293 |
+
$this->matched_agent = 'winphone8';
|
| 294 |
+
$this->isTierIphone = true;
|
| 295 |
+
$this->isTierRichCss = false;
|
| 296 |
+
$this->isTierGenericMobile = false;
|
| 297 |
+
} elseif ( $this->is_WindowsPhone7() ) {
|
| 298 |
+
$this->matched_agent = 'win7';
|
| 299 |
+
$this->isTierIphone = true;
|
| 300 |
+
$this->isTierRichCss = false;
|
| 301 |
+
$this->isTierGenericMobile = false;
|
| 302 |
+
} elseif ( $this->is_blackberry_10() ) {
|
| 303 |
+
$this->matched_agent = 'blackberry-10';
|
| 304 |
+
$this->isTierIphone = true;
|
| 305 |
+
$this->isTierRichCss = false;
|
| 306 |
+
$this->isTierGenericMobile = false;
|
| 307 |
+
} elseif ( $this->is_blackbeberry() && 'blackberry-webkit' === $this->detect_blackberry_browser_version() ) {
|
| 308 |
+
$this->matched_agent = 'blackberry-webkit';
|
| 309 |
+
$this->isTierIphone = true;
|
| 310 |
+
$this->isTierRichCss = false;
|
| 311 |
+
$this->isTierGenericMobile = false;
|
| 312 |
+
} elseif ( $this->is_blackberry_tablet() ) {
|
| 313 |
+
$this->matched_agent = 'blackberry_tablet';
|
| 314 |
+
$this->isTierIphone = true;
|
| 315 |
+
$this->isTierRichCss = false;
|
| 316 |
+
$this->isTierGenericMobile = false;
|
| 317 |
+
} elseif ( $this->is_PalmWebOS() ) {
|
| 318 |
+
$this->matched_agent = 'webos';
|
| 319 |
+
$this->isTierIphone = true;
|
| 320 |
+
$this->isTierRichCss = false;
|
| 321 |
+
$this->isTierGenericMobile = false;
|
| 322 |
+
} elseif ( $this->is_TouchPad() ) {
|
| 323 |
+
$this->matched_agent = 'hp_tablet';
|
| 324 |
+
$this->isTierIphone = true;
|
| 325 |
+
$this->isTierRichCss = false;
|
| 326 |
+
$this->isTierGenericMobile = false;
|
| 327 |
+
} elseif ( $this->is_firefox_os() ) {
|
| 328 |
+
$this->matched_agent = 'firefoxOS';
|
| 329 |
+
$this->isTierIphone = true;
|
| 330 |
+
$this->isTierRichCss = false;
|
| 331 |
+
$this->isTierGenericMobile = false;
|
| 332 |
+
} elseif ( $this->is_firefox_mobile() ) {
|
| 333 |
+
$this->matched_agent = 'fennec';
|
| 334 |
+
$this->isTierIphone = true;
|
| 335 |
+
$this->isTierRichCss = false;
|
| 336 |
+
$this->isTierGenericMobile = false;
|
| 337 |
+
} elseif ( $this->is_opera_mobile() ) {
|
| 338 |
+
$this->matched_agent = 'opera-mobi';
|
| 339 |
+
$this->isTierIphone = true;
|
| 340 |
+
$this->isTierRichCss = false;
|
| 341 |
+
$this->isTierGenericMobile = false;
|
| 342 |
+
} elseif ( $this->is_MaemoTablet() ) {
|
| 343 |
+
$this->matched_agent = 'maemo';
|
| 344 |
+
$this->isTierIphone = true;
|
| 345 |
+
$this->isTierRichCss = false;
|
| 346 |
+
$this->isTierGenericMobile = false;
|
| 347 |
+
} elseif ( $this->is_MeeGo() ) {
|
| 348 |
+
$this->matched_agent = 'meego';
|
| 349 |
+
$this->isTierIphone = true;
|
| 350 |
+
$this->isTierRichCss = false;
|
| 351 |
+
$this->isTierGenericMobile = false;
|
| 352 |
+
} elseif ( $this->is_kindle_touch() ) {
|
| 353 |
+
$this->matched_agent = 'kindle-touch';
|
| 354 |
+
$this->isTierIphone = true;
|
| 355 |
+
$this->isTierRichCss = false;
|
| 356 |
+
$this->isTierGenericMobile = false;
|
| 357 |
+
} elseif ( $this->is_Nintendo_3DS() ) {
|
| 358 |
+
$this->matched_agent = 'nintendo-3ds';
|
| 359 |
+
$this->isTierIphone = true;
|
| 360 |
+
$this->isTierRichCss = false;
|
| 361 |
+
$this->isTierGenericMobile = false;
|
| 362 |
+
} else {
|
| 363 |
+
$this->isTierIphone = false;
|
| 364 |
+
}
|
| 365 |
+
return $this->isTierIphone;
|
| 366 |
+
}
|
| 367 |
+
|
| 368 |
+
/**
|
| 369 |
+
* This method detects for UA which are likely to be capable
|
| 370 |
+
* but may not necessarily support JavaScript.
|
| 371 |
+
* Excludes all iPhone Tier UA.
|
| 372 |
+
*/
|
| 373 |
+
public function isTierRichCss() {
|
| 374 |
+
if ( isset( $this->isTierRichCss ) ) {
|
| 375 |
+
return $this->isTierRichCss;
|
| 376 |
+
}
|
| 377 |
+
if ( $this->isTierIphone() ) {
|
| 378 |
+
return false;
|
| 379 |
+
}
|
| 380 |
+
|
| 381 |
+
// The following devices are explicitly ok.
|
| 382 |
+
if ( $this->is_S60_OSSBrowser() ) {
|
| 383 |
+
$this->matched_agent = 'series60';
|
| 384 |
+
$this->isTierIphone = false;
|
| 385 |
+
$this->isTierRichCss = true;
|
| 386 |
+
$this->isTierGenericMobile = false;
|
| 387 |
+
} elseif ( $this->is_opera_mini() ) {
|
| 388 |
+
$this->matched_agent = 'opera-mini';
|
| 389 |
+
$this->isTierIphone = false;
|
| 390 |
+
$this->isTierRichCss = true;
|
| 391 |
+
$this->isTierGenericMobile = false;
|
| 392 |
+
} elseif ( $this->is_blackbeberry() ) {
|
| 393 |
+
$detectedDevice = $this->detect_blackberry_browser_version();
|
| 394 |
+
if (
|
| 395 |
+
'blackberry-5' === $detectedDevice
|
| 396 |
+
|| 'blackberry-4.7' === $detectedDevice
|
| 397 |
+
|| 'blackberry-4.6' === $detectedDevice
|
| 398 |
+
) {
|
| 399 |
+
$this->matched_agent = $detectedDevice;
|
| 400 |
+
$this->isTierIphone = false;
|
| 401 |
+
$this->isTierRichCss = true;
|
| 402 |
+
$this->isTierGenericMobile = false;
|
| 403 |
+
}
|
| 404 |
+
} else {
|
| 405 |
+
$this->isTierRichCss = false;
|
| 406 |
+
}
|
| 407 |
+
|
| 408 |
+
return $this->isTierRichCss;
|
| 409 |
+
}
|
| 410 |
+
|
| 411 |
+
/**
|
| 412 |
+
* Detects if the user is using a tablet.
|
| 413 |
+
* props Corey Gilmore, BGR.com
|
| 414 |
+
*
|
| 415 |
+
* @return bool
|
| 416 |
+
*/
|
| 417 |
+
public function is_tablet() {
|
| 418 |
+
return ( 0 // Never true, but makes it easier to manage our list of tablet conditions.
|
| 419 |
+
|| self::is_ipad()
|
| 420 |
+
|| self::is_android_tablet()
|
| 421 |
+
|| self::is_blackberry_tablet()
|
| 422 |
+
|| self::is_kindle_fire()
|
| 423 |
+
|| self::is_MaemoTablet()
|
| 424 |
+
|| self::is_TouchPad()
|
| 425 |
+
);
|
| 426 |
+
}
|
| 427 |
+
|
| 428 |
+
/**
|
| 429 |
+
* Detects if the current UA is the default iPhone or iPod Touch Browser.
|
| 430 |
+
*
|
| 431 |
+
* DEPRECATED: use is_iphone_or_ipod
|
| 432 |
+
*/
|
| 433 |
+
public function is_iphoneOrIpod() {
|
| 434 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 435 |
+
return false;
|
| 436 |
+
}
|
| 437 |
+
|
| 438 |
+
$ua = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 439 |
+
if ( ( strpos( $ua, 'iphone' ) !== false ) || ( strpos( $ua, 'ipod' ) !== false ) ) {
|
| 440 |
+
if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() ) {
|
| 441 |
+
return false;
|
| 442 |
+
} else {
|
| 443 |
+
return true;
|
| 444 |
+
}
|
| 445 |
+
} else {
|
| 446 |
+
return false;
|
| 447 |
+
}
|
| 448 |
+
}
|
| 449 |
+
|
| 450 |
+
/**
|
| 451 |
+
* Detects if the current UA is iPhone Mobile Safari or another iPhone or iPod Touch Browser.
|
| 452 |
+
*
|
| 453 |
+
* They type can check for any iPhone, an iPhone using Safari, or an iPhone using something other than Safari.
|
| 454 |
+
*
|
| 455 |
+
* Note: If you want to check for Opera mini, Opera mobile or Firefox mobile (or any 3rd party iPhone browser),
|
| 456 |
+
* you should put the check condition before the check for 'iphone-any' or 'iphone-not-safari'.
|
| 457 |
+
* Otherwise those browsers will be 'catched' by the iphone string.
|
| 458 |
+
*
|
| 459 |
+
* @param string $type Type of iPhone detection.
|
| 460 |
+
*/
|
| 461 |
+
public static function is_iphone_or_ipod( $type = 'iphone-any' ) {
|
| 462 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 463 |
+
return false;
|
| 464 |
+
}
|
| 465 |
+
|
| 466 |
+
$ua = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 467 |
+
$is_iphone = ( strpos( $ua, 'iphone' ) !== false ) || ( strpos( $ua, 'ipod' ) !== false );
|
| 468 |
+
$is_safari = ( false !== strpos( $ua, 'safari' ) );
|
| 469 |
+
|
| 470 |
+
if ( 'iphone-safari' === $type ) {
|
| 471 |
+
return $is_iphone && $is_safari;
|
| 472 |
+
} elseif ( 'iphone-not-safari' === $type ) {
|
| 473 |
+
return $is_iphone && ! $is_safari;
|
| 474 |
+
} else {
|
| 475 |
+
return $is_iphone;
|
| 476 |
+
}
|
| 477 |
+
}
|
| 478 |
+
|
| 479 |
+
/**
|
| 480 |
+
* Detects if the current UA is Chrome for iOS
|
| 481 |
+
*
|
| 482 |
+
* The User-Agent string in Chrome for iOS is the same as the Mobile Safari User-Agent, with CriOS/<ChromeRevision> instead of Version/<VersionNum>.
|
| 483 |
+
* - Mozilla/5.0 (iPhone; U; CPU iPhone OS 5_1_1 like Mac OS X; en) AppleWebKit/534.46.0 (KHTML, like Gecko) CriOS/19.0.1084.60 Mobile/9B206 Safari/7534.48.3
|
| 484 |
+
*/
|
| 485 |
+
public static function is_chrome_for_iOS() {
|
| 486 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 487 |
+
return false;
|
| 488 |
+
}
|
| 489 |
+
|
| 490 |
+
if ( self::is_iphone_or_ipod( 'iphone-safari' ) === false ) {
|
| 491 |
+
return false;
|
| 492 |
+
}
|
| 493 |
+
|
| 494 |
+
$ua = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 495 |
+
|
| 496 |
+
if ( strpos( $ua, 'crios/' ) !== false ) {
|
| 497 |
+
return true;
|
| 498 |
+
} else {
|
| 499 |
+
return false;
|
| 500 |
+
}
|
| 501 |
+
}
|
| 502 |
+
|
| 503 |
+
/**
|
| 504 |
+
* Detects if the current UA is Twitter for iPhone
|
| 505 |
+
*
|
| 506 |
+
* Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_5 like Mac OS X; nb-no) AppleWebKit/533.17.9 (KHTML, like Gecko) Mobile/8L1 Twitter for iPhone
|
| 507 |
+
* Mozilla/5.0 (iPhone; CPU iPhone OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9B206 Twitter for iPhone
|
| 508 |
+
*/
|
| 509 |
+
public static function is_twitter_for_iphone() {
|
| 510 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 511 |
+
return false;
|
| 512 |
+
}
|
| 513 |
+
|
| 514 |
+
$ua = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 515 |
+
|
| 516 |
+
if ( strpos( $ua, 'ipad' ) !== false ) {
|
| 517 |
+
return false;
|
| 518 |
+
}
|
| 519 |
+
|
| 520 |
+
if ( strpos( $ua, 'twitter for iphone' ) !== false ) {
|
| 521 |
+
return true;
|
| 522 |
+
} else {
|
| 523 |
+
return false;
|
| 524 |
+
}
|
| 525 |
+
}
|
| 526 |
+
|
| 527 |
+
/**
|
| 528 |
+
* Detects if the current UA is Twitter for iPad
|
| 529 |
+
*
|
| 530 |
+
* Old version 4.X - Mozilla/5.0 (iPad; U; CPU OS 4_3_5 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Mobile/8L1 Twitter for iPad
|
| 531 |
+
* Ver 5.0 or Higher - Mozilla/5.0 (iPad; CPU OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9B206 Twitter for iPhone
|
| 532 |
+
*/
|
| 533 |
+
public static function is_twitter_for_ipad() {
|
| 534 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 535 |
+
return false;
|
| 536 |
+
}
|
| 537 |
+
|
| 538 |
+
$ua = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 539 |
+
|
| 540 |
+
if ( strpos( $ua, 'twitter for ipad' ) !== false ) {
|
| 541 |
+
return true;
|
| 542 |
+
} elseif ( strpos( $ua, 'ipad' ) !== false && strpos( $ua, 'twitter for iphone' ) !== false ) {
|
| 543 |
+
return true;
|
| 544 |
+
} else {
|
| 545 |
+
return false;
|
| 546 |
+
}
|
| 547 |
+
}
|
| 548 |
+
|
| 549 |
+
/**
|
| 550 |
+
* Detects if the current UA is Facebook for iPhone
|
| 551 |
+
* - Facebook 4020.0 (iPhone; iPhone OS 5.0.1; fr_FR)
|
| 552 |
+
* - Mozilla/5.0 (iPhone; U; CPU iPhone OS 5_0 like Mac OS X; en_US) AppleWebKit (KHTML, like Gecko) Mobile [FBAN/FBForIPhone;FBAV/4.0.2;FBBV/4020.0;FBDV/iPhone3,1;FBMD/iPhone;FBSN/iPhone OS;FBSV/5.0;FBSS/2; FBCR/O2;FBID/phone;FBLC/en_US;FBSF/2.0]
|
| 553 |
+
* - Mozilla/5.0 (iPhone; CPU iPhone OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9B206 [FBAN/FBIOS;FBAV/5.0;FBBV/47423;FBDV/iPhone3,1;FBMD/iPhone;FBSN/iPhone OS;FBSV/5.1.1;FBSS/2; FBCR/3ITA;FBID/phone;FBLC/en_US]
|
| 554 |
+
*/
|
| 555 |
+
public static function is_facebook_for_iphone() {
|
| 556 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 557 |
+
return false;
|
| 558 |
+
}
|
| 559 |
+
|
| 560 |
+
$ua = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 561 |
+
|
| 562 |
+
if ( false === strpos( $ua, 'iphone' ) ) {
|
| 563 |
+
return false;
|
| 564 |
+
}
|
| 565 |
+
|
| 566 |
+
if ( false !== strpos( $ua, 'facebook' ) && false === strpos( $ua, 'ipad' ) ) {
|
| 567 |
+
return true;
|
| 568 |
+
} elseif ( false !== strpos( $ua, 'fbforiphone' ) && false === strpos( $ua, 'tablet' ) ) {
|
| 569 |
+
return true;
|
| 570 |
+
} elseif ( false !== strpos( $ua, 'fban/fbios;' ) && false === strpos( $ua, 'tablet' ) ) { // FB app v5.0 or higher.
|
| 571 |
+
return true;
|
| 572 |
+
} else {
|
| 573 |
+
return false;
|
| 574 |
+
}
|
| 575 |
+
}
|
| 576 |
+
|
| 577 |
+
/**
|
| 578 |
+
* Detects if the current UA is Facebook for iPad
|
| 579 |
+
* - Facebook 4020.0 (iPad; iPhone OS 5.0.1; en_US)
|
| 580 |
+
* - Mozilla/5.0 (iPad; U; CPU iPhone OS 5_0 like Mac OS X; en_US) AppleWebKit (KHTML, like Gecko) Mobile [FBAN/FBForIPhone;FBAV/4.0.2;FBBV/4020.0;FBDV/iPad2,1;FBMD/iPad;FBSN/iPhone OS;FBSV/5.0;FBSS/1; FBCR/;FBID/tablet;FBLC/en_US;FBSF/1.0]
|
| 581 |
+
* - Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Mobile/10A403 [FBAN/FBIOS;FBAV/5.0;FBBV/47423;FBDV/iPad2,1;FBMD/iPad;FBSN/iPhone OS;FBSV/6.0;FBSS/1; FBCR/;FBID/tablet;FBLC/en_US]
|
| 582 |
+
*/
|
| 583 |
+
public static function is_facebook_for_ipad() {
|
| 584 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 585 |
+
return false;
|
| 586 |
+
}
|
| 587 |
+
|
| 588 |
+
$ua = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 589 |
+
|
| 590 |
+
if ( false === strpos( $ua, 'ipad' ) ) {
|
| 591 |
+
return false;
|
| 592 |
+
}
|
| 593 |
+
|
| 594 |
+
if ( false !== strpos( $ua, 'facebook' ) || false !== strpos( $ua, 'fbforiphone' ) || false !== strpos( $ua, 'fban/fbios;' ) ) {
|
| 595 |
+
return true;
|
| 596 |
+
} else {
|
| 597 |
+
return false;
|
| 598 |
+
}
|
| 599 |
+
}
|
| 600 |
+
|
| 601 |
+
/**
|
| 602 |
+
* Detects if the current UA is WordPress for iOS
|
| 603 |
+
*/
|
| 604 |
+
public static function is_wordpress_for_ios() {
|
| 605 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 606 |
+
return false;
|
| 607 |
+
}
|
| 608 |
+
|
| 609 |
+
$ua = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 610 |
+
if ( false !== strpos( $ua, 'wp-iphone' ) ) {
|
| 611 |
+
return true;
|
| 612 |
+
} else {
|
| 613 |
+
return false;
|
| 614 |
+
}
|
| 615 |
+
}
|
| 616 |
+
|
| 617 |
+
/**
|
| 618 |
+
* Detects if the current device is an iPad.
|
| 619 |
+
* They type can check for any iPad, an iPad using Safari, or an iPad using something other than Safari.
|
| 620 |
+
*
|
| 621 |
+
* Note: If you want to check for Opera mini, Opera mobile or Firefox mobile (or any 3rd party iPad browser),
|
| 622 |
+
* you should put the check condition before the check for 'iphone-any' or 'iphone-not-safari'.
|
| 623 |
+
* Otherwise those browsers will be 'catched' by the ipad string.
|
| 624 |
+
*
|
| 625 |
+
* @param string $type iPad type.
|
| 626 |
+
*/
|
| 627 |
+
public static function is_ipad( $type = 'ipad-any' ) {
|
| 628 |
+
|
| 629 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 630 |
+
return false;
|
| 631 |
+
}
|
| 632 |
+
|
| 633 |
+
$ua = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 634 |
+
|
| 635 |
+
$is_ipad = ( false !== strpos( $ua, 'ipad' ) );
|
| 636 |
+
$is_safari = ( false !== strpos( $ua, 'safari' ) );
|
| 637 |
+
|
| 638 |
+
if ( 'ipad-safari' === $type ) {
|
| 639 |
+
return $is_ipad && $is_safari;
|
| 640 |
+
} elseif ( 'ipad-not-safari' === $type ) {
|
| 641 |
+
return $is_ipad && ! $is_safari;
|
| 642 |
+
} else {
|
| 643 |
+
return $is_ipad;
|
| 644 |
+
}
|
| 645 |
+
}
|
| 646 |
+
|
| 647 |
+
/**
|
| 648 |
+
* Detects if the current browser is Firefox Mobile (Fennec)
|
| 649 |
+
*
|
| 650 |
+
* See http://www.useragentstring.com/pages/Fennec/
|
| 651 |
+
* Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.1.1) Gecko/20110415 Firefox/4.0.2pre Fennec/4.0.1
|
| 652 |
+
* Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1b2pre) Gecko/20081015 Fennec/1.0a1
|
| 653 |
+
*/
|
| 654 |
+
public static function is_firefox_mobile() {
|
| 655 |
+
|
| 656 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 657 |
+
return false;
|
| 658 |
+
}
|
| 659 |
+
|
| 660 |
+
$ua = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 661 |
+
|
| 662 |
+
if ( strpos( $ua, 'fennec' ) !== false ) {
|
| 663 |
+
return true;
|
| 664 |
+
} else {
|
| 665 |
+
return false;
|
| 666 |
+
}
|
| 667 |
+
}
|
| 668 |
+
|
| 669 |
+
/**
|
| 670 |
+
* Detects if the current browser is Firefox for desktop
|
| 671 |
+
*
|
| 672 |
+
* See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox
|
| 673 |
+
* Mozilla/5.0 (platform; rv:geckoversion) Gecko/geckotrail Firefox/firefoxversion
|
| 674 |
+
* The platform section will include 'Mobile' for phones and 'Tablet' for tablets.
|
| 675 |
+
*/
|
| 676 |
+
public static function is_firefox_desktop() {
|
| 677 |
+
|
| 678 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 679 |
+
return false;
|
| 680 |
+
}
|
| 681 |
+
|
| 682 |
+
$ua = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 683 |
+
|
| 684 |
+
if ( false !== strpos( $ua, 'firefox' ) && false === strpos( $ua, 'mobile' ) && false === strpos( $ua, 'tablet' ) ) {
|
| 685 |
+
return true;
|
| 686 |
+
} else {
|
| 687 |
+
return false;
|
| 688 |
+
}
|
| 689 |
+
}
|
| 690 |
+
|
| 691 |
+
/**
|
| 692 |
+
* Detects if the current browser is FirefoxOS Native browser
|
| 693 |
+
*
|
| 694 |
+
* Mozilla/5.0 (Mobile; rv:14.0) Gecko/14.0 Firefox/14.0
|
| 695 |
+
*/
|
| 696 |
+
public static function is_firefox_os() {
|
| 697 |
+
|
| 698 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 699 |
+
return false;
|
| 700 |
+
}
|
| 701 |
+
|
| 702 |
+
$ua = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 703 |
+
|
| 704 |
+
if ( strpos( $ua, 'mozilla' ) !== false && strpos( $ua, 'mobile' ) !== false && strpos( $ua, 'gecko' ) !== false && strpos( $ua, 'firefox' ) !== false ) {
|
| 705 |
+
return true;
|
| 706 |
+
} else {
|
| 707 |
+
return false;
|
| 708 |
+
}
|
| 709 |
+
}
|
| 710 |
+
|
| 711 |
+
/**
|
| 712 |
+
* Detect modern Opera desktop
|
| 713 |
+
*
|
| 714 |
+
* Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36 OPR/74.0.3911.203
|
| 715 |
+
*
|
| 716 |
+
* Looking for "OPR/" specifically.
|
| 717 |
+
*/
|
| 718 |
+
public static function is_opera_desktop() {
|
| 719 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 720 |
+
return false;
|
| 721 |
+
}
|
| 722 |
+
|
| 723 |
+
if ( false === strpos( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ), 'OPR/' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 724 |
+
return false;
|
| 725 |
+
}
|
| 726 |
+
|
| 727 |
+
return true;
|
| 728 |
+
}
|
| 729 |
+
|
| 730 |
+
/**
|
| 731 |
+
* Detects if the current browser is Opera Mobile
|
| 732 |
+
*
|
| 733 |
+
* What is the difference between Opera Mobile and Opera Mini?
|
| 734 |
+
* - Opera Mobile is a full Internet browser for mobile devices.
|
| 735 |
+
* - Opera Mini always uses a transcoder to convert the page for a small display.
|
| 736 |
+
* (it uses Opera advanced server compression technology to compress web content before it gets to a device.
|
| 737 |
+
* The rendering engine is on Opera's server.)
|
| 738 |
+
*
|
| 739 |
+
* Opera/9.80 (Windows NT 6.1; Opera Mobi/14316; U; en) Presto/2.7.81 Version/11.00"
|
| 740 |
+
* Opera/9.50 (Nintendo DSi; Opera/507; U; en-US)
|
| 741 |
+
*/
|
| 742 |
+
public static function is_opera_mobile() {
|
| 743 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 744 |
+
return false;
|
| 745 |
+
}
|
| 746 |
+
|
| 747 |
+
$ua = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 748 |
+
|
| 749 |
+
if ( strpos( $ua, 'opera' ) !== false && strpos( $ua, 'mobi' ) !== false ) {
|
| 750 |
+
return true;
|
| 751 |
+
} elseif ( strpos( $ua, 'opera' ) !== false && strpos( $ua, 'nintendo dsi' ) !== false ) {
|
| 752 |
+
return true;
|
| 753 |
+
} else {
|
| 754 |
+
return false;
|
| 755 |
+
}
|
| 756 |
+
}
|
| 757 |
+
|
| 758 |
+
/**
|
| 759 |
+
* Detects if the current browser is Opera Mini
|
| 760 |
+
*
|
| 761 |
+
* Opera/8.01 (J2ME/MIDP; Opera Mini/3.0.6306/1528; en; U; ssr)
|
| 762 |
+
* Opera/9.80 (Android;Opera Mini/6.0.24212/24.746 U;en) Presto/2.5.25 Version/10.5454
|
| 763 |
+
* Opera/9.80 (iPhone; Opera Mini/5.0.019802/18.738; U; en) Presto/2.4.15
|
| 764 |
+
* Opera/9.80 (J2ME/iPhone;Opera Mini/5.0.019802/886; U; ja) Presto/2.4.15
|
| 765 |
+
* Opera/9.80 (J2ME/iPhone;Opera Mini/5.0.019802/886; U; ja) Presto/2.4.15
|
| 766 |
+
* Opera/9.80 (Series 60; Opera Mini/5.1.22783/23.334; U; en) Presto/2.5.25 Version/10.54
|
| 767 |
+
* Opera/9.80 (BlackBerry; Opera Mini/5.1.22303/22.387; U; en) Presto/2.5.25 Version/10.54
|
| 768 |
+
*/
|
| 769 |
+
public static function is_opera_mini() {
|
| 770 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 771 |
+
return false;
|
| 772 |
+
}
|
| 773 |
+
|
| 774 |
+
$ua = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 775 |
+
|
| 776 |
+
if ( strpos( $ua, 'opera' ) !== false && strpos( $ua, 'mini' ) !== false ) {
|
| 777 |
+
return true;
|
| 778 |
+
} else {
|
| 779 |
+
return false;
|
| 780 |
+
}
|
| 781 |
+
}
|
| 782 |
+
|
| 783 |
+
/**
|
| 784 |
+
* Detects if the current browser is Opera Mini, but not on a smart device OS(Android, iOS, etc)
|
| 785 |
+
* Used to send users on dumb devices to m.wor
|
| 786 |
+
*/
|
| 787 |
+
public static function is_opera_mini_dumb() {
|
| 788 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 789 |
+
return false;
|
| 790 |
+
}
|
| 791 |
+
$ua = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 792 |
+
|
| 793 |
+
if ( self::is_opera_mini() ) {
|
| 794 |
+
if ( strpos( $ua, 'android' ) !== false || strpos( $ua, 'iphone' ) !== false || strpos( $ua, 'ipod' ) !== false
|
| 795 |
+
|| strpos( $ua, 'ipad' ) !== false || strpos( $ua, 'blackberry' ) !== false ) {
|
| 796 |
+
return false;
|
| 797 |
+
} else {
|
| 798 |
+
return true;
|
| 799 |
+
}
|
| 800 |
+
} else {
|
| 801 |
+
return false;
|
| 802 |
+
}
|
| 803 |
+
}
|
| 804 |
+
|
| 805 |
+
/**
|
| 806 |
+
* Detects if the current browser is a Windows Phone 7 device.
|
| 807 |
+
* ex: Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0; LG; GW910)
|
| 808 |
+
*/
|
| 809 |
+
public static function is_WindowsPhone7() {
|
| 810 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 811 |
+
return false;
|
| 812 |
+
}
|
| 813 |
+
|
| 814 |
+
$ua = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 815 |
+
|
| 816 |
+
if ( false === strpos( $ua, 'windows phone os 7' ) ) {
|
| 817 |
+
return false;
|
| 818 |
+
} else {
|
| 819 |
+
if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() ) {
|
| 820 |
+
return false;
|
| 821 |
+
} else {
|
| 822 |
+
return true;
|
| 823 |
+
}
|
| 824 |
+
}
|
| 825 |
+
}
|
| 826 |
+
|
| 827 |
+
/**
|
| 828 |
+
* Detects if the current browser is a Windows Phone 8 device.
|
| 829 |
+
* ex: Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; ARM; Touch; IEMobile/10.0; <Manufacturer>; <Device> [;<Operator>])
|
| 830 |
+
*/
|
| 831 |
+
public static function is_windows_phone_8() {
|
| 832 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 833 |
+
return false;
|
| 834 |
+
}
|
| 835 |
+
|
| 836 |
+
$ua = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 837 |
+
if ( strpos( $ua, 'windows phone 8' ) === false ) {
|
| 838 |
+
return false;
|
| 839 |
+
} else {
|
| 840 |
+
return true;
|
| 841 |
+
}
|
| 842 |
+
}
|
| 843 |
+
|
| 844 |
+
/**
|
| 845 |
+
* Detects if the current browser is on a Palm device running the new WebOS. This EXCLUDES TouchPad.
|
| 846 |
+
*
|
| 847 |
+
* Ex1: Mozilla/5.0 (webOS/1.4.0; U; en-US) AppleWebKit/532.2 (KHTML, like Gecko) Version/1.0 Safari/532.2 Pre/1.1
|
| 848 |
+
* Ex2: Mozilla/5.0 (webOS/1.4.0; U; en-US) AppleWebKit/532.2 (KHTML, like Gecko) Version/1.0 Safari/532.2 Pixi/1.1
|
| 849 |
+
*/
|
| 850 |
+
public static function is_PalmWebOS() {
|
| 851 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 852 |
+
return false;
|
| 853 |
+
}
|
| 854 |
+
|
| 855 |
+
$ua = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 856 |
+
|
| 857 |
+
if ( false === strpos( $ua, 'webos' ) ) {
|
| 858 |
+
return false;
|
| 859 |
+
} else {
|
| 860 |
+
if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() ) {
|
| 861 |
+
return false;
|
| 862 |
+
} else {
|
| 863 |
+
return true;
|
| 864 |
+
}
|
| 865 |
+
}
|
| 866 |
+
}
|
| 867 |
+
|
| 868 |
+
/**
|
| 869 |
+
* Detects if the current browser is the HP TouchPad default browser. This excludes phones wt WebOS.
|
| 870 |
+
*
|
| 871 |
+
* TouchPad Emulator: Mozilla/5.0 (hp-desktop; Linux; hpwOS/2.0; U; it-IT) AppleWebKit/534.6 (KHTML, like Gecko) wOSBrowser/233.70 Safari/534.6 Desktop/1.0
|
| 872 |
+
* TouchPad: Mozilla/5.0 (hp-tablet; Linux; hpwOS/3.0.0; U; en-US) AppleWebKit/534.6 (KHTML, like Gecko) wOSBrowser/233.70 Safari/534.6 TouchPad/1.0
|
| 873 |
+
*/
|
| 874 |
+
public static function is_TouchPad() {
|
| 875 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 876 |
+
return false;
|
| 877 |
+
}
|
| 878 |
+
|
| 879 |
+
$http_user_agent = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 880 |
+
if ( false !== strpos( $http_user_agent, 'hp-tablet' ) || false !== strpos( $http_user_agent, 'hpwos' ) || false !== strpos( $http_user_agent, 'touchpad' ) ) {
|
| 881 |
+
if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() ) {
|
| 882 |
+
return false;
|
| 883 |
+
} else {
|
| 884 |
+
return true;
|
| 885 |
+
}
|
| 886 |
+
} else {
|
| 887 |
+
return false;
|
| 888 |
+
}
|
| 889 |
+
}
|
| 890 |
+
|
| 891 |
+
/**
|
| 892 |
+
* Detects if the current browser is the Series 60 Open Source Browser.
|
| 893 |
+
*
|
| 894 |
+
* OSS Browser 3.2 on E75: Mozilla/5.0 (SymbianOS/9.3; U; Series60/3.2 NokiaE75-1/110.48.125 Profile/MIDP-2.1 Configuration/CLDC-1.1 ) AppleWebKit/413 (KHTML, like Gecko) Safari/413
|
| 895 |
+
*
|
| 896 |
+
* 7.0 Browser (Nokia 5800 XpressMusic (v21.0.025)) : Mozilla/5.0 (SymbianOS/9.4; U; Series60/5.0 Nokia5800d-1/21.0.025; Profile/MIDP-2.1 Configuration/CLDC-1.1 ) AppleWebKit/413 (KHTML, like Gecko) Safari/413
|
| 897 |
+
*
|
| 898 |
+
* Browser 7.1 (Nokia N97 (v12.0.024)) : Mozilla/5.0 (SymbianOS/9.4; Series60/5.0 NokiaN97-1/12.0.024; Profile/MIDP-2.1 Configuration/CLDC-1.1; en-us) AppleWebKit/525 (KHTML, like Gecko) BrowserNG/7.1.12344
|
| 899 |
+
*/
|
| 900 |
+
public static function is_S60_OSSBrowser() {
|
| 901 |
+
|
| 902 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 903 |
+
return false;
|
| 904 |
+
}
|
| 905 |
+
|
| 906 |
+
$agent = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 907 |
+
if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() ) {
|
| 908 |
+
return false;
|
| 909 |
+
}
|
| 910 |
+
|
| 911 |
+
$pos_webkit = strpos( $agent, 'webkit' );
|
| 912 |
+
if ( false !== $pos_webkit ) {
|
| 913 |
+
// First, test for WebKit, then make sure it's either Symbian or S60.
|
| 914 |
+
if ( strpos( $agent, 'symbian' ) !== false || strpos( $agent, 'series60' ) !== false ) {
|
| 915 |
+
return true;
|
| 916 |
+
} else {
|
| 917 |
+
return false;
|
| 918 |
+
}
|
| 919 |
+
} elseif ( strpos( $agent, 'symbianos' ) !== false && strpos( $agent, 'series60' ) !== false ) {
|
| 920 |
+
return true;
|
| 921 |
+
} elseif ( strpos( $agent, 'nokia' ) !== false && strpos( $agent, 'series60' ) !== false ) {
|
| 922 |
+
return true;
|
| 923 |
+
}
|
| 924 |
+
|
| 925 |
+
return false;
|
| 926 |
+
}
|
| 927 |
+
|
| 928 |
+
/**
|
| 929 |
+
* Detects if the device platform is the Symbian Series 60.
|
| 930 |
+
*/
|
| 931 |
+
public static function is_symbian_platform() {
|
| 932 |
+
|
| 933 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 934 |
+
return false;
|
| 935 |
+
}
|
| 936 |
+
|
| 937 |
+
$agent = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 938 |
+
|
| 939 |
+
$pos_webkit = strpos( $agent, 'webkit' );
|
| 940 |
+
if ( false !== $pos_webkit ) {
|
| 941 |
+
// First, test for WebKit, then make sure it's either Symbian or S60.
|
| 942 |
+
if ( strpos( $agent, 'symbian' ) !== false || strpos( $agent, 'series60' ) !== false ) {
|
| 943 |
+
return true;
|
| 944 |
+
} else {
|
| 945 |
+
return false;
|
| 946 |
+
}
|
| 947 |
+
} elseif ( strpos( $agent, 'symbianos' ) !== false && strpos( $agent, 'series60' ) !== false ) {
|
| 948 |
+
return true;
|
| 949 |
+
} elseif ( strpos( $agent, 'nokia' ) !== false && strpos( $agent, 'series60' ) !== false ) {
|
| 950 |
+
return true;
|
| 951 |
+
} elseif ( strpos( $agent, 'opera mini' ) !== false ) {
|
| 952 |
+
if ( strpos( $agent, 'symbianos' ) !== false || strpos( $agent, 'symbos' ) !== false || strpos( $agent, 'series 60' ) !== false ) {
|
| 953 |
+
return true;
|
| 954 |
+
}
|
| 955 |
+
}
|
| 956 |
+
|
| 957 |
+
return false;
|
| 958 |
+
}
|
| 959 |
+
|
| 960 |
+
/**
|
| 961 |
+
* Detects if the device platform is the Symbian Series 40.
|
| 962 |
+
* Nokia Browser for Series 40 is a proxy based browser, previously known as Ovi Browser.
|
| 963 |
+
* This browser will report 'NokiaBrowser' in the header, however some older version will also report 'OviBrowser'.
|
| 964 |
+
*/
|
| 965 |
+
public static function is_symbian_s40_platform() {
|
| 966 |
+
|
| 967 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 968 |
+
return false;
|
| 969 |
+
}
|
| 970 |
+
|
| 971 |
+
$agent = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 972 |
+
|
| 973 |
+
if ( strpos( $agent, 'series40' ) !== false ) {
|
| 974 |
+
if ( strpos( $agent, 'nokia' ) !== false || strpos( $agent, 'ovibrowser' ) !== false || strpos( $agent, 'nokiabrowser' ) !== false ) {
|
| 975 |
+
return true;
|
| 976 |
+
}
|
| 977 |
+
}
|
| 978 |
+
|
| 979 |
+
return false;
|
| 980 |
+
}
|
| 981 |
+
|
| 982 |
+
/**
|
| 983 |
+
* Returns if the device belongs to J2ME capable family.
|
| 984 |
+
*
|
| 985 |
+
* @return bool
|
| 986 |
+
*/
|
| 987 |
+
public static function is_J2ME_platform() {
|
| 988 |
+
|
| 989 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 990 |
+
return false;
|
| 991 |
+
}
|
| 992 |
+
|
| 993 |
+
$agent = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 994 |
+
|
| 995 |
+
if ( strpos( $agent, 'j2me/midp' ) !== false ) {
|
| 996 |
+
return true;
|
| 997 |
+
} elseif ( strpos( $agent, 'midp' ) !== false && strpos( $agent, 'cldc' ) ) {
|
| 998 |
+
return true;
|
| 999 |
+
}
|
| 1000 |
+
return false;
|
| 1001 |
+
}
|
| 1002 |
+
|
| 1003 |
+
/**
|
| 1004 |
+
* Detects if the current UA is on one of the Maemo-based Nokia Internet Tablets.
|
| 1005 |
+
*/
|
| 1006 |
+
public static function is_MaemoTablet() {
|
| 1007 |
+
|
| 1008 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 1009 |
+
return false;
|
| 1010 |
+
}
|
| 1011 |
+
|
| 1012 |
+
$agent = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 1013 |
+
|
| 1014 |
+
$pos_maemo = strpos( $agent, 'maemo' );
|
| 1015 |
+
if ( false === $pos_maemo ) {
|
| 1016 |
+
return false;
|
| 1017 |
+
}
|
| 1018 |
+
|
| 1019 |
+
// Must be Linux + Tablet, or else it could be something else.
|
| 1020 |
+
if ( strpos( $agent, 'tablet' ) !== false && strpos( $agent, 'linux' ) !== false ) {
|
| 1021 |
+
if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() ) {
|
| 1022 |
+
return false;
|
| 1023 |
+
} else {
|
| 1024 |
+
return true;
|
| 1025 |
+
}
|
| 1026 |
+
} else {
|
| 1027 |
+
return false;
|
| 1028 |
+
}
|
| 1029 |
+
}
|
| 1030 |
+
|
| 1031 |
+
/**
|
| 1032 |
+
* Detects if the current UA is a MeeGo device (Nokia Smartphone).
|
| 1033 |
+
*/
|
| 1034 |
+
public static function is_MeeGo() {
|
| 1035 |
+
|
| 1036 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 1037 |
+
return false;
|
| 1038 |
+
}
|
| 1039 |
+
|
| 1040 |
+
$ua = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 1041 |
+
|
| 1042 |
+
if ( false === strpos( $ua, 'meego' ) ) {
|
| 1043 |
+
return false;
|
| 1044 |
+
} else {
|
| 1045 |
+
if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() ) {
|
| 1046 |
+
return false;
|
| 1047 |
+
} else {
|
| 1048 |
+
return true;
|
| 1049 |
+
}
|
| 1050 |
+
}
|
| 1051 |
+
}
|
| 1052 |
+
|
| 1053 |
+
/**
|
| 1054 |
+
* The is_webkit() method can be used to check the User Agent for an webkit generic browser.
|
| 1055 |
+
*/
|
| 1056 |
+
public static function is_webkit() {
|
| 1057 |
+
|
| 1058 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 1059 |
+
return false;
|
| 1060 |
+
}
|
| 1061 |
+
|
| 1062 |
+
$agent = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 1063 |
+
|
| 1064 |
+
$pos_webkit = strpos( $agent, 'webkit' );
|
| 1065 |
+
|
| 1066 |
+
if ( false !== $pos_webkit ) {
|
| 1067 |
+
return true;
|
| 1068 |
+
} else {
|
| 1069 |
+
return false;
|
| 1070 |
+
}
|
| 1071 |
+
}
|
| 1072 |
+
|
| 1073 |
+
/**
|
| 1074 |
+
* Detects if the current browser is the Native Android browser.
|
| 1075 |
+
*
|
| 1076 |
+
* @return boolean true if the browser is Android otherwise false
|
| 1077 |
+
*/
|
| 1078 |
+
public static function is_android() {
|
| 1079 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 1080 |
+
return false;
|
| 1081 |
+
}
|
| 1082 |
+
|
| 1083 |
+
$agent = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 1084 |
+
$pos_android = strpos( $agent, 'android' );
|
| 1085 |
+
if ( false !== $pos_android ) {
|
| 1086 |
+
if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() ) {
|
| 1087 |
+
return false;
|
| 1088 |
+
} else {
|
| 1089 |
+
return true;
|
| 1090 |
+
}
|
| 1091 |
+
} else {
|
| 1092 |
+
return false;
|
| 1093 |
+
}
|
| 1094 |
+
}
|
| 1095 |
+
|
| 1096 |
+
/**
|
| 1097 |
+
* Detects if the current browser is the Native Android Tablet browser.
|
| 1098 |
+
* Assumes 'Android' should be in the user agent, but not 'mobile'
|
| 1099 |
+
*
|
| 1100 |
+
* @return boolean true if the browser is Android and not 'mobile' otherwise false
|
| 1101 |
+
*/
|
| 1102 |
+
public static function is_android_tablet() {
|
| 1103 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 1104 |
+
return false;
|
| 1105 |
+
}
|
| 1106 |
+
|
| 1107 |
+
$agent = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 1108 |
+
|
| 1109 |
+
$pos_android = strpos( $agent, 'android' );
|
| 1110 |
+
$pos_mobile = strpos( $agent, 'mobile' );
|
| 1111 |
+
$post_android_app = strpos( $agent, 'wp-android' );
|
| 1112 |
+
|
| 1113 |
+
if ( false !== $pos_android && false === $pos_mobile && false === $post_android_app ) {
|
| 1114 |
+
if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() ) {
|
| 1115 |
+
return false;
|
| 1116 |
+
} else {
|
| 1117 |
+
return true;
|
| 1118 |
+
}
|
| 1119 |
+
} else {
|
| 1120 |
+
return false;
|
| 1121 |
+
}
|
| 1122 |
+
}
|
| 1123 |
+
|
| 1124 |
+
/**
|
| 1125 |
+
* Detects if the current browser is the Kindle Fire Native browser.
|
| 1126 |
+
*
|
| 1127 |
+
* Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us; Silk/1.1.0-84) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 Silk-Accelerated=true
|
| 1128 |
+
* Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us; Silk/1.1.0-84) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 Silk-Accelerated=false
|
| 1129 |
+
*
|
| 1130 |
+
* @return boolean true if the browser is Kindle Fire Native browser otherwise false
|
| 1131 |
+
*/
|
| 1132 |
+
public static function is_kindle_fire() {
|
| 1133 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 1134 |
+
return false;
|
| 1135 |
+
}
|
| 1136 |
+
|
| 1137 |
+
$agent = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 1138 |
+
$pos_silk = strpos( $agent, 'silk/' );
|
| 1139 |
+
$pos_silk_acc = strpos( $agent, 'silk-accelerated=' );
|
| 1140 |
+
if ( false !== $pos_silk && false !== $pos_silk_acc ) {
|
| 1141 |
+
return true;
|
| 1142 |
+
} else {
|
| 1143 |
+
return false;
|
| 1144 |
+
}
|
| 1145 |
+
}
|
| 1146 |
+
|
| 1147 |
+
/**
|
| 1148 |
+
* Detects if the current browser is the Kindle Touch Native browser
|
| 1149 |
+
*
|
| 1150 |
+
* Mozilla/5.0 (X11; U; Linux armv7l like Android; en-us) AppleWebKit/531.2+ (KHTML, like Gecko) Version/5.0 Safari/533.2+ Kindle/3.0+
|
| 1151 |
+
*
|
| 1152 |
+
* @return boolean true if the browser is Kindle monochrome Native browser otherwise false
|
| 1153 |
+
*/
|
| 1154 |
+
public static function is_kindle_touch() {
|
| 1155 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 1156 |
+
return false;
|
| 1157 |
+
}
|
| 1158 |
+
$agent = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 1159 |
+
$pos_kindle_touch = strpos( $agent, 'kindle/3.0+' );
|
| 1160 |
+
if ( false !== $pos_kindle_touch && false === self::is_kindle_fire() ) {
|
| 1161 |
+
return true;
|
| 1162 |
+
} else {
|
| 1163 |
+
return false;
|
| 1164 |
+
}
|
| 1165 |
+
}
|
| 1166 |
+
|
| 1167 |
+
/**
|
| 1168 |
+
* Detect if user agent is the WordPress.com Windows 8 app (used ONLY on the custom oauth stylesheet)
|
| 1169 |
+
*/
|
| 1170 |
+
public static function is_windows8_auth() {
|
| 1171 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 1172 |
+
return false;
|
| 1173 |
+
}
|
| 1174 |
+
|
| 1175 |
+
$agent = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 1176 |
+
$pos = strpos( $agent, 'msauthhost' );
|
| 1177 |
+
if ( false !== $pos ) {
|
| 1178 |
+
return true;
|
| 1179 |
+
} else {
|
| 1180 |
+
return false;
|
| 1181 |
+
}
|
| 1182 |
+
}
|
| 1183 |
+
|
| 1184 |
+
/**
|
| 1185 |
+
* Detect if user agent is the WordPress.com Windows 8 app.
|
| 1186 |
+
*/
|
| 1187 |
+
public static function is_wordpress_for_win8() {
|
| 1188 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 1189 |
+
return false;
|
| 1190 |
+
}
|
| 1191 |
+
|
| 1192 |
+
$agent = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 1193 |
+
$pos = strpos( $agent, 'wp-windows8' );
|
| 1194 |
+
if ( false !== $pos ) {
|
| 1195 |
+
return true;
|
| 1196 |
+
} else {
|
| 1197 |
+
return false;
|
| 1198 |
+
}
|
| 1199 |
+
}
|
| 1200 |
+
|
| 1201 |
+
/**
|
| 1202 |
+
* Detect if user agent is the WordPress.com Desktop app.
|
| 1203 |
+
*/
|
| 1204 |
+
public static function is_wordpress_desktop_app() {
|
| 1205 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 1206 |
+
return false;
|
| 1207 |
+
}
|
| 1208 |
+
|
| 1209 |
+
$agent = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 1210 |
+
$pos = strpos( $agent, 'WordPressDesktop' );
|
| 1211 |
+
if ( false !== $pos ) {
|
| 1212 |
+
return true;
|
| 1213 |
+
} else {
|
| 1214 |
+
return false;
|
| 1215 |
+
}
|
| 1216 |
+
}
|
| 1217 |
+
|
| 1218 |
+
/**
|
| 1219 |
+
* The is_blackberry_tablet() method can be used to check the User Agent for a RIM blackberry tablet.
|
| 1220 |
+
* The user agent of the BlackBerry® Tablet OS follows a format similar to the following:
|
| 1221 |
+
* Mozilla/5.0 (PlayBook; U; RIM Tablet OS 1.0.0; en-US) AppleWebKit/534.8+ (KHTML, like Gecko) Version/0.0.1 Safari/534.8+
|
| 1222 |
+
*/
|
| 1223 |
+
public static function is_blackberry_tablet() {
|
| 1224 |
+
|
| 1225 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 1226 |
+
return false;
|
| 1227 |
+
}
|
| 1228 |
+
|
| 1229 |
+
$agent = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 1230 |
+
$pos_playbook = stripos( $agent, 'PlayBook' );
|
| 1231 |
+
$pos_rim_tablet = stripos( $agent, 'RIM Tablet' );
|
| 1232 |
+
|
| 1233 |
+
if ( ( false === $pos_playbook ) || ( false === $pos_rim_tablet ) ) {
|
| 1234 |
+
return false;
|
| 1235 |
+
} else {
|
| 1236 |
+
return true;
|
| 1237 |
+
}
|
| 1238 |
+
}
|
| 1239 |
+
|
| 1240 |
+
/**
|
| 1241 |
+
* The is_blackbeberry() method can be used to check the User Agent for a blackberry device.
|
| 1242 |
+
* Note that opera mini on BB matches this rule.
|
| 1243 |
+
*/
|
| 1244 |
+
public static function is_blackbeberry() {
|
| 1245 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 1246 |
+
return false;
|
| 1247 |
+
}
|
| 1248 |
+
|
| 1249 |
+
$agent = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 1250 |
+
|
| 1251 |
+
$pos_blackberry = strpos( $agent, 'blackberry' );
|
| 1252 |
+
if ( false !== $pos_blackberry ) {
|
| 1253 |
+
if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() ) {
|
| 1254 |
+
return false;
|
| 1255 |
+
} else {
|
| 1256 |
+
return true;
|
| 1257 |
+
}
|
| 1258 |
+
} else {
|
| 1259 |
+
return false;
|
| 1260 |
+
}
|
| 1261 |
+
}
|
| 1262 |
+
|
| 1263 |
+
/**
|
| 1264 |
+
* The is_blackberry_10() method can be used to check the User Agent for a BlackBerry 10 device.
|
| 1265 |
+
*/
|
| 1266 |
+
public static function is_blackberry_10() {
|
| 1267 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 1268 |
+
return false;
|
| 1269 |
+
}
|
| 1270 |
+
$agent = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 1271 |
+
return ( strpos( $agent, 'bb10' ) !== false ) && ( strpos( $agent, 'mobile' ) !== false );
|
| 1272 |
+
}
|
| 1273 |
+
|
| 1274 |
+
/**
|
| 1275 |
+
* Retrieve the blackberry OS version.
|
| 1276 |
+
*
|
| 1277 |
+
* Return strings are from the following list:
|
| 1278 |
+
* - blackberry-10
|
| 1279 |
+
* - blackberry-7
|
| 1280 |
+
* - blackberry-6
|
| 1281 |
+
* - blackberry-torch //only the first edition. The 2nd edition has the OS7 onboard and doesn't need any special rule.
|
| 1282 |
+
* - blackberry-5
|
| 1283 |
+
* - blackberry-4.7
|
| 1284 |
+
* - blackberry-4.6
|
| 1285 |
+
* - blackberry-4.5
|
| 1286 |
+
*
|
| 1287 |
+
* @return string Version of the BB OS.
|
| 1288 |
+
* If version is not found, get_blackbeberry_OS_version will return boolean false.
|
| 1289 |
+
*/
|
| 1290 |
+
public static function get_blackbeberry_OS_version() {
|
| 1291 |
+
|
| 1292 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 1293 |
+
return false;
|
| 1294 |
+
}
|
| 1295 |
+
|
| 1296 |
+
if ( self::is_blackberry_10() ) {
|
| 1297 |
+
return 'blackberry-10';
|
| 1298 |
+
}
|
| 1299 |
+
|
| 1300 |
+
$agent = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 1301 |
+
|
| 1302 |
+
$pos_blackberry = stripos( $agent, 'blackberry' );
|
| 1303 |
+
if ( false === $pos_blackberry ) {
|
| 1304 |
+
// Not a blackberry device.
|
| 1305 |
+
return false;
|
| 1306 |
+
}
|
| 1307 |
+
|
| 1308 |
+
// Blackberry devices OS 6.0 or higher.
|
| 1309 |
+
// Mozilla/5.0 (BlackBerry; U; BlackBerry 9670; en) AppleWebKit/534.3+ (KHTML, like Gecko) Version/6.0.0.286 Mobile Safari/534.3+.
|
| 1310 |
+
// Mozilla/5.0 (BlackBerry; U; BlackBerry 9800; en) AppleWebKit/534.1+ (KHTML, Like Gecko) Version/6.0.0.141 Mobile Safari/534.1+.
|
| 1311 |
+
// Mozilla/5.0 (BlackBerry; U; BlackBerry 9900; en-US) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.0.0 Mobile Safari/534.11+.
|
| 1312 |
+
$pos_webkit = stripos( $agent, 'webkit' );
|
| 1313 |
+
if ( false !== $pos_webkit ) {
|
| 1314 |
+
// Detected blackberry webkit browser.
|
| 1315 |
+
$pos_torch = stripos( $agent, 'BlackBerry 9800' );
|
| 1316 |
+
if ( false !== $pos_torch ) {
|
| 1317 |
+
return 'blackberry-torch'; // Match the torch first edition. the 2nd edition should use the OS7 and doesn't need any special rule.
|
| 1318 |
+
} else {
|
| 1319 |
+
// Detecting the BB OS version for devices running OS 6.0 or higher.
|
| 1320 |
+
if ( preg_match( '#Version\/([\d\.]+)#i', $agent, $matches ) ) {
|
| 1321 |
+
$version = $matches[1];
|
| 1322 |
+
$version_num = explode( '.', $version );
|
| 1323 |
+
if ( false === is_array( $version_num ) || count( $version_num ) <= 1 ) {
|
| 1324 |
+
return 'blackberry-6'; // not a BB device that match our rule.
|
| 1325 |
+
} else {
|
| 1326 |
+
return 'blackberry-' . $version_num[0];
|
| 1327 |
+
}
|
| 1328 |
+
} else {
|
| 1329 |
+
// if doesn't match returns the minimun version with a webkit browser. we should never fall here.
|
| 1330 |
+
return 'blackberry-6'; // not a BB device that match our rule.
|
| 1331 |
+
}
|
| 1332 |
+
}
|
| 1333 |
+
}
|
| 1334 |
+
|
| 1335 |
+
// Blackberry devices <= 5.XX.
|
| 1336 |
+
// BlackBerry9000/5.0.0.93 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/179.
|
| 1337 |
+
if ( preg_match( '#BlackBerry\w+\/([\d\.]+)#i', $agent, $matches ) ) {
|
| 1338 |
+
$version = $matches[1];
|
| 1339 |
+
} else {
|
| 1340 |
+
return false; // not a BB device that match our rule.
|
| 1341 |
+
}
|
| 1342 |
+
|
| 1343 |
+
$version_num = explode( '.', $version );
|
| 1344 |
+
|
| 1345 |
+
if ( is_array( $version_num ) === false || count( $version_num ) <= 1 ) {
|
| 1346 |
+
return false;
|
| 1347 |
+
}
|
| 1348 |
+
|
| 1349 |
+
$version_num_major = (int) $version_num[0];
|
| 1350 |
+
$version_num_minor = (int) $version_num[1];
|
| 1351 |
+
|
| 1352 |
+
if ( 5 === $version_num_major ) {
|
| 1353 |
+
return 'blackberry-5';
|
| 1354 |
+
} elseif ( 4 === $version_num_major && 7 === $version_num_minor ) {
|
| 1355 |
+
return 'blackberry-4.7';
|
| 1356 |
+
} elseif ( 4 === $version_num_major && 6 === $version_num_minor ) {
|
| 1357 |
+
return 'blackberry-4.6';
|
| 1358 |
+
} elseif ( 4 === $version_num_major && 5 === $version_num_minor ) {
|
| 1359 |
+
return 'blackberry-4.5';
|
| 1360 |
+
} else {
|
| 1361 |
+
return false;
|
| 1362 |
+
}
|
| 1363 |
+
|
| 1364 |
+
}
|
| 1365 |
+
|
| 1366 |
+
/**
|
| 1367 |
+
* Retrieve the blackberry browser version.
|
| 1368 |
+
*
|
| 1369 |
+
* Return string are from the following list:
|
| 1370 |
+
* - blackberry-10
|
| 1371 |
+
* - blackberry-webkit
|
| 1372 |
+
* - blackberry-5
|
| 1373 |
+
* - blackberry-4.7
|
| 1374 |
+
* - blackberry-4.6
|
| 1375 |
+
*
|
| 1376 |
+
* @return string Type of the BB browser.
|
| 1377 |
+
* If browser's version is not found, detect_blackbeberry_browser_version will return boolean false.
|
| 1378 |
+
*/
|
| 1379 |
+
public static function detect_blackberry_browser_version() {
|
| 1380 |
+
|
| 1381 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 1382 |
+
return false;
|
| 1383 |
+
}
|
| 1384 |
+
|
| 1385 |
+
$agent = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 1386 |
+
|
| 1387 |
+
if ( self::is_blackberry_10() ) {
|
| 1388 |
+
return 'blackberry-10';
|
| 1389 |
+
}
|
| 1390 |
+
|
| 1391 |
+
$pos_blackberry = strpos( $agent, 'blackberry' );
|
| 1392 |
+
if ( false === $pos_blackberry ) {
|
| 1393 |
+
// Not a blackberry device.
|
| 1394 |
+
return false;
|
| 1395 |
+
}
|
| 1396 |
+
|
| 1397 |
+
$pos_webkit = strpos( $agent, 'webkit' );
|
| 1398 |
+
|
| 1399 |
+
if ( ! ( false === $pos_webkit ) ) {
|
| 1400 |
+
return 'blackberry-webkit';
|
| 1401 |
+
} else {
|
| 1402 |
+
if ( ! preg_match( '#BlackBerry\w+\/([\d\.]+)#i', $agent, $matches ) ) {
|
| 1403 |
+
return false; // not a BB device that match our rule.
|
| 1404 |
+
}
|
| 1405 |
+
|
| 1406 |
+
$version_num = explode( '.', $matches[1] );
|
| 1407 |
+
|
| 1408 |
+
if ( false === is_array( $version_num ) || count( $version_num ) <= 1 ) {
|
| 1409 |
+
return false;
|
| 1410 |
+
}
|
| 1411 |
+
|
| 1412 |
+
$version_num_major = (int) $version_num[0];
|
| 1413 |
+
$version_num_minor = (int) $version_num[1];
|
| 1414 |
+
|
| 1415 |
+
if ( 5 === $version_num_major ) {
|
| 1416 |
+
return 'blackberry-5';
|
| 1417 |
+
} elseif ( 4 === $version_num_major && 7 === $version_num_minor ) {
|
| 1418 |
+
return 'blackberry-4.7';
|
| 1419 |
+
} elseif ( 4 === $version_num_major && 6 === $version_num_minor ) {
|
| 1420 |
+
return 'blackberry-4.6';
|
| 1421 |
+
} else {
|
| 1422 |
+
// A very old BB device is found or this is a BB device that doesn't match our rules.
|
| 1423 |
+
return false;
|
| 1424 |
+
}
|
| 1425 |
+
}
|
| 1426 |
+
|
| 1427 |
+
}
|
| 1428 |
+
|
| 1429 |
+
/**
|
| 1430 |
+
* Checks if a visitor is coming from one of the WordPress mobile apps.
|
| 1431 |
+
*
|
| 1432 |
+
* @return bool
|
| 1433 |
+
*/
|
| 1434 |
+
public static function is_mobile_app() {
|
| 1435 |
+
|
| 1436 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 1437 |
+
return false;
|
| 1438 |
+
}
|
| 1439 |
+
|
| 1440 |
+
$agent = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 1441 |
+
|
| 1442 |
+
if ( isset( $_SERVER['X_USER_AGENT'] ) && preg_match( '|wp-webos|', $_SERVER['X_USER_AGENT'] ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput -- This is validating.
|
| 1443 |
+
return true; // Wp4webos 1.1 or higher.
|
| 1444 |
+
}
|
| 1445 |
+
|
| 1446 |
+
$app_agents = array( 'wp-android', 'wp-blackberry', 'wp-iphone', 'wp-nokia', 'wp-webos', 'wp-windowsphone' );
|
| 1447 |
+
// the mobile reader on iOS has an incorrect UA when loading the reader
|
| 1448 |
+
// currently it is the default one provided by the iOS framework which
|
| 1449 |
+
// causes problems with 2-step-auth
|
| 1450 |
+
// User-Agent WordPress/3.1.4 CFNetwork/609 Darwin/13.0.0.
|
| 1451 |
+
$app_agents[] = 'wordpress/3.1';
|
| 1452 |
+
|
| 1453 |
+
foreach ( $app_agents as $app_agent ) {
|
| 1454 |
+
if ( false !== strpos( $agent, $app_agent ) ) {
|
| 1455 |
+
return true;
|
| 1456 |
+
}
|
| 1457 |
+
}
|
| 1458 |
+
return false;
|
| 1459 |
+
}
|
| 1460 |
+
|
| 1461 |
+
/**
|
| 1462 |
+
* Detects if the current browser is Nintendo 3DS handheld.
|
| 1463 |
+
*
|
| 1464 |
+
* Example: Mozilla/5.0 (Nintendo 3DS; U; ; en) Version/1.7498.US
|
| 1465 |
+
* can differ in language, version and region
|
| 1466 |
+
*/
|
| 1467 |
+
public static function is_Nintendo_3DS() {
|
| 1468 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 1469 |
+
return false;
|
| 1470 |
+
}
|
| 1471 |
+
|
| 1472 |
+
$ua = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 1473 |
+
if ( strpos( $ua, 'nintendo 3ds' ) !== false ) {
|
| 1474 |
+
return true;
|
| 1475 |
+
}
|
| 1476 |
+
return false;
|
| 1477 |
+
}
|
| 1478 |
+
|
| 1479 |
+
/**
|
| 1480 |
+
* Was the current request made by a known bot?
|
| 1481 |
+
*
|
| 1482 |
+
* @return boolean
|
| 1483 |
+
*/
|
| 1484 |
+
public static function is_bot() {
|
| 1485 |
+
static $is_bot = null;
|
| 1486 |
+
|
| 1487 |
+
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
| 1488 |
+
return false;
|
| 1489 |
+
}
|
| 1490 |
+
|
| 1491 |
+
if ( $is_bot === null ) {
|
| 1492 |
+
$is_bot = self::is_bot_user_agent( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
|
| 1493 |
+
}
|
| 1494 |
+
|
| 1495 |
+
return $is_bot;
|
| 1496 |
+
}
|
| 1497 |
+
|
| 1498 |
+
/**
|
| 1499 |
+
* Is the given user-agent a known bot?
|
| 1500 |
+
* If you want an is_bot check for the current request's UA, use is_bot() instead of passing a user-agent to this method.
|
| 1501 |
+
*
|
| 1502 |
+
* @param string $ua A user-agent string.
|
| 1503 |
+
*
|
| 1504 |
+
* @return boolean
|
| 1505 |
+
*/
|
| 1506 |
+
public static function is_bot_user_agent( $ua = null ) {
|
| 1507 |
+
|
| 1508 |
+
if ( empty( $ua ) ) {
|
| 1509 |
+
return false;
|
| 1510 |
+
}
|
| 1511 |
+
|
| 1512 |
+
$bot_agents = array(
|
| 1513 |
+
'alexa',
|
| 1514 |
+
'altavista',
|
| 1515 |
+
'ask jeeves',
|
| 1516 |
+
'attentio',
|
| 1517 |
+
'baiduspider',
|
| 1518 |
+
'bingbot',
|
| 1519 |
+
'chtml generic',
|
| 1520 |
+
'crawler',
|
| 1521 |
+
'fastmobilecrawl',
|
| 1522 |
+
'feedfetcher-google',
|
| 1523 |
+
'firefly',
|
| 1524 |
+
'froogle',
|
| 1525 |
+
'gigabot',
|
| 1526 |
+
'googlebot',
|
| 1527 |
+
'googlebot-mobile',
|
| 1528 |
+
'heritrix',
|
| 1529 |
+
'httrack',
|
| 1530 |
+
'ia_archiver',
|
| 1531 |
+
'irlbot',
|
| 1532 |
+
'iescholar',
|
| 1533 |
+
'infoseek',
|
| 1534 |
+
'jumpbot',
|
| 1535 |
+
'linkcheck',
|
| 1536 |
+
'lycos',
|
| 1537 |
+
'mediapartners',
|
| 1538 |
+
'mediobot',
|
| 1539 |
+
'motionbot',
|
| 1540 |
+
'msnbot',
|
| 1541 |
+
'mshots',
|
| 1542 |
+
'openbot',
|
| 1543 |
+
'pss-webkit-request',
|
| 1544 |
+
'pythumbnail',
|
| 1545 |
+
'scooter',
|
| 1546 |
+
'slurp',
|
| 1547 |
+
'snapbot',
|
| 1548 |
+
'spider',
|
| 1549 |
+
'taptubot',
|
| 1550 |
+
'technoratisnoop',
|
| 1551 |
+
'teoma',
|
| 1552 |
+
'twiceler',
|
| 1553 |
+
'yahooseeker',
|
| 1554 |
+
'yahooysmcm',
|
| 1555 |
+
'yammybot',
|
| 1556 |
+
'ahrefsbot',
|
| 1557 |
+
'pingdom.com_bot',
|
| 1558 |
+
'kraken',
|
| 1559 |
+
'yandexbot',
|
| 1560 |
+
'twitterbot',
|
| 1561 |
+
'tweetmemebot',
|
| 1562 |
+
'openhosebot',
|
| 1563 |
+
'queryseekerspider',
|
| 1564 |
+
'linkdexbot',
|
| 1565 |
+
'grokkit-crawler',
|
| 1566 |
+
'livelapbot',
|
| 1567 |
+
'germcrawler',
|
| 1568 |
+
'domaintunocrawler',
|
| 1569 |
+
'grapeshotcrawler',
|
| 1570 |
+
'cloudflare-alwaysonline',
|
| 1571 |
+
);
|
| 1572 |
+
|
| 1573 |
+
foreach ( $bot_agents as $bot_agent ) {
|
| 1574 |
+
if ( false !== stripos( $ua, $bot_agent ) ) {
|
| 1575 |
+
return true;
|
| 1576 |
+
}
|
| 1577 |
+
}
|
| 1578 |
+
|
| 1579 |
+
return false;
|
| 1580 |
+
}
|
| 1581 |
+
}
|
vendor/automattic/jetpack-device-detection/src/functions.php
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Utility functions for device detection.
|
| 4 |
+
*
|
| 5 |
+
* @package automattic/jetpack-device-detection
|
| 6 |
+
*/
|
| 7 |
+
|
| 8 |
+
namespace Automattic\Jetpack\Device_Detection;
|
| 9 |
+
|
| 10 |
+
/**
|
| 11 |
+
* A wrapper for WordPress's `wp_unslash()`.
|
| 12 |
+
*
|
| 13 |
+
* Even though PHP itself dropped the option to add slashes to superglobals a decade ago,
|
| 14 |
+
* WordPress still does it through some misguided extreme backwards compatibility. 🙄
|
| 15 |
+
*
|
| 16 |
+
* If WordPress's function exists, assume it needs to be called.
|
| 17 |
+
* Else if on WordPress.com, do a simplified version because we're running really early.
|
| 18 |
+
* Else, assume it's not needed.
|
| 19 |
+
*
|
| 20 |
+
* @param string $value String of data to unslash.
|
| 21 |
+
* @return string Possibly unslashed $value.
|
| 22 |
+
*/
|
| 23 |
+
function wp_unslash( $value ) {
|
| 24 |
+
if ( function_exists( '\\wp_unslash' ) ) {
|
| 25 |
+
return \wp_unslash( $value );
|
| 26 |
+
} elseif ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
|
| 27 |
+
return stripslashes( $value );
|
| 28 |
+
} else {
|
| 29 |
+
return $value;
|
| 30 |
+
}
|
| 31 |
+
}
|
wp-cache.php
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
* Plugin Name: WP Super Cache
|
| 4 |
* Plugin URI: https://wordpress.org/plugins/wp-super-cache/
|
| 5 |
* Description: Very fast caching plugin for WordPress.
|
| 6 |
-
* Version: 1.9
|
| 7 |
* Author: Automattic
|
| 8 |
* Author URI: https://automattic.com/
|
| 9 |
* License: GPL2+
|
| 3 |
* Plugin Name: WP Super Cache
|
| 4 |
* Plugin URI: https://wordpress.org/plugins/wp-super-cache/
|
| 5 |
* Description: Very fast caching plugin for WordPress.
|
| 6 |
+
* Version: 1.9.1
|
| 7 |
* Author: Automattic
|
| 8 |
* Author URI: https://automattic.com/
|
| 9 |
* License: GPL2+
|
