Automattic\Jetpack\Device_Detection

User_Agent_Info::get_platform()publicWPSCache 1.0

This method detects the mobile device's platform. All return strings are from the class constants. Note that this function returns the platform name, not the UA name/type. You should use a different function if you need to test the UA capabilites.

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

Хуков нет.

Возвращает

Строку|true|false. Name of the platform, false otherwise.

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

$User_Agent_Info = new User_Agent_Info();
$User_Agent_Info->get_platform();

Код User_Agent_Info::get_platform() WPSCache 1.12.0

public function get_platform() {
	if ( isset( $this->platform ) ) {
			return $this->platform;
	}

	if ( empty( $this->useragent ) ) {
		return false;
	}

	if ( strpos( $this->useragent, 'windows phone' ) !== false ) {
			$this->platform = self::PLATFORM_WINDOWS;
	} elseif ( strpos( $this->useragent, 'windows ce' ) !== false ) {
		$this->platform = self::PLATFORM_WINDOWS;
	} elseif ( strpos( $this->useragent, 'ipad' ) !== false ) {
		$this->platform = self::PLATFORM_IPAD;
	} elseif ( strpos( $this->useragent, 'ipod' ) !== false ) {
		$this->platform = self::PLATFORM_IPOD;
	} elseif ( strpos( $this->useragent, 'iphone' ) !== false ) {
		$this->platform = self::PLATFORM_IPHONE;
	} elseif ( strpos( $this->useragent, 'android' ) !== false ) {
		if ( static::is_android_tablet() ) {
			$this->platform = self::PLATFORM_ANDROID_TABLET;
		} else {
			$this->platform = self::PLATFORM_ANDROID;
		}
	} elseif ( static::is_kindle_fire() ) {
		$this->platform = self::PLATFORM_ANDROID_TABLET;
	} elseif ( static::is_blackberry_10() ) {
		$this->platform = self::PLATFORM_BLACKBERRY_10;
	} elseif ( strpos( $this->useragent, 'blackberry' ) !== false ) {
		$this->platform = self::PLATFORM_BLACKBERRY;
	} elseif ( static::is_blackberry_tablet() ) {
		$this->platform = self::PLATFORM_BLACKBERRY;
	} elseif ( static::is_symbian_platform() ) {
		$this->platform = self::PLATFORM_SYMBIAN;
	} elseif ( static::is_symbian_s40_platform() ) {
		$this->platform = self::PLATFORM_SYMBIAN_S40;
	} elseif ( static::is_J2ME_platform() ) {
		$this->platform = self::PLATFORM_J2ME_MIDP;
	} elseif ( static::is_firefox_os() ) {
		$this->platform = self::PLATFORM_FIREFOX_OS;
	} else {
		$this->platform = false;
	}

	return $this->platform;
}