Automattic\WooCommerce\Vendor\Detection
MobileDetect::isMobile()
Check if the device is mobile. Returns true if any type of mobile device detected, including special ones
Метод класса: MobileDetect{}
Хуков нет.
Возвращает
true|false
.
Использование
$MobileDetect = new MobileDetect(); $MobileDetect->isMobile( $userAgent, $httpHeaders ): bool;
- $userAgent(строка|null)
- deprecated
По умолчанию: null - $httpHeaders(массив|null)
- deprecated
По умолчанию: null
Код MobileDetect::isMobile() MobileDetect::isMobile WC 9.5.1
public function isMobile(string $userAgent = null, array $httpHeaders = null): bool { if ($httpHeaders) { $this->setHttpHeaders($httpHeaders); } if ($userAgent) { $this->setUserAgent($userAgent); } // Check specifically for cloudfront headers if the useragent === 'Amazon CloudFront' if ($this->getUserAgent() === 'Amazon CloudFront') { $cfHeaders = $this->getCfHeaders(); if (array_key_exists('HTTP_CLOUDFRONT_IS_MOBILE_VIEWER', $cfHeaders) && $cfHeaders['HTTP_CLOUDFRONT_IS_MOBILE_VIEWER'] === 'true' ) { return true; } } if ($this->checkHttpHeadersForMobile()) { return true; } else { return $this->matchDetectionRulesAgainstUA(); } }