Automattic\Jetpack\Device_Detection

User_Agent_Info::is_ipad()public staticWPSCache 1.0

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 );
$type(строка)
iPad type.
По умолчанию: 'ipad-any'

Код User_Agent_Info::is_ipad() WPSCache 1.12.0

public static function is_ipad( $type = 'ipad-any' ) {

	if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
		return false;
	}

	$ua = strtolower( wp_unslash( $_SERVER['HTTP_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;
	}
}