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.
Method of the class: User_Agent_Info{}
No Hooks.
Return
null
. Nothing (null).
Usage
$result = User_Agent_Info::is_ipad( $type );
- $type(string)
- iPad type.
Default: 'ipad-any'
User_Agent_Info::is_ipad() User Agent Info::is ipad code WPSCache 1.12.4
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; } }