Automattic\Jetpack

Device_Detection::get_info()public staticWPSCache 1.0

Returns information about the current device accessing the page.

Метод класса: Device_Detection{}

Хуки из метода

Возвращает

Массив. Device information.

array( 'is_phone' => (bool) Whether the current device is a mobile phone. 'is_smartphone' => (bool) Whether the current device is a smartphone. 'is_tablet' => (bool) Whether the current device is a tablet device. 'is_handheld' => (bool) Whether the current device is a handheld device. 'is_desktop' => (bool) Whether the current device is a laptop / desktop device. 'platform' => (string) Detected platform. 'is_phone_matched_ua' => (string) Matched UA. );

Использование

$result = Device_Detection::get_info( $ua );
$ua(строка)
(Optional) User-Agent string.
По умолчанию: ''

Код Device_Detection::get_info() WPSCache 1.9.1

public static function get_info( $ua = '' ) {
	$ua_info = new User_Agent_Info( $ua );

	$info = array(
		'is_phone'            => self::is_mobile( 'any', false, $ua_info ),
		'is_phone_matched_ua' => self::is_mobile( 'any', true, $ua_info ),
		'is_smartphone'       => self::is_mobile( 'smart', false, $ua_info ),
		'is_tablet'           => $ua_info->is_tablet(),
		'platform'            => $ua_info->get_platform(),
	);

	$info['is_handheld'] = $info['is_phone'] || $info['is_tablet'];
	$info['is_desktop']  = ! $info['is_handheld'];

	if ( function_exists( 'apply_filters' ) ) {
		/**
		 * Filter the value of Device_Detection::get_info.
		 *
		 * @since 1.0.0
		 *
		 * @param array           $info    Array of device information.
		 * @param string          $ua      User agent string passed to Device_Detection::get_info.
		 * @param User_Agent_Info $ua_info Instance of Automattic\Jetpack\Device_Detection\User_Agent_Info.
		 */
		$info = apply_filters( 'jetpack_device_detection_get_info', $info, $ua, $ua_info );
	}
	return $info;
}