Automattic\WPSC\Device_Detection
User_Agent_Info::is_chrome_for_iOS
Detects if the current UA is Chrome for iOS
The User-Agent string in Chrome for iOS is the same as the Mobile Safari User-Agent, with CriOS/<ChromeRevision> instead of Version/<VersionNum>.
- 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
@param string|null $user_agent Optional. User agent string to check. If not provided, uses $_SERVER['HTTP_USER_AGENT'].
Method of the class: User_Agent_Info{}
No Hooks.
Returns
null. Nothing (null).
Usage
$result = User_Agent_Info::is_chrome_for_iOS( $user_agent );
- $user_agent
- .
Default:null
User_Agent_Info::is_chrome_for_iOS() User Agent Info::is chrome for iOS code WPSCache 3.1.1
public static function is_chrome_for_iOS( $user_agent = null ) {
$user_agent = self::maybe_get_user_agent_from_server( $user_agent );
if ( empty( $user_agent ) ) {
return false;
}
if ( self::is_iphone_or_ipod( 'iphone-safari', $user_agent ) === false ) {
return false;
}
$ua = strtolower( wp_unslash( $user_agent ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
if ( strpos( $ua, 'crios/' ) !== false ) {
return true;
} else {
return false;
}
}