Automattic\Jetpack\Device_Detection
User_Agent_Info::is_ipad
Detects if the current device is an iPad. They type can check for any iPad, an iPad using Safari, or an iPad using something other than Safari.
Note: If you want to check for Opera mini, Opera mobile or Firefox mobile (or any 3rd party iPad browser), you should put the check condition before the check for 'iphone-any' or 'iphone-not-safari'. Otherwise those browsers will be 'catched' by the ipad string.
Метод класса: User_Agent_Info{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$result = User_Agent_Info::is_ipad( $type, $user_agent );
- $type(строка)
- iPad type.
По умолчанию:'ipad-any' - $user_agent(строка|null)
- User agent string to check. If not provided, uses $_SERVER['HTTP_USER_AGENT'].
По умолчанию:null
Код User_Agent_Info::is_ipad() User Agent Info::is ipad WPSCache 3.0.3
public static function is_ipad( $type = 'ipad-any', $user_agent = null ) {
$user_agent = self::maybe_get_user_agent_from_server( $user_agent );
if ( empty( $user_agent ) ) {
return false;
}
$ua = strtolower( wp_unslash( $user_agent ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
$is_ipad = ( false !== strpos( $ua, 'ipad' ) );
$is_safari = ( false !== strpos( $ua, 'safari' ) );
if ( 'ipad-safari' === $type ) {
return $is_ipad && $is_safari;
} elseif ( 'ipad-not-safari' === $type ) {
return $is_ipad && ! $is_safari;
} else {
return $is_ipad;
}
}