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( ?string $userAgent, ?array $httpHeaders ): bool;
- ?string $userAgent
- .
По умолчанию: null - ?array $httpHeaders
- .
По умолчанию: null
Код MobileDetect::isMobile() MobileDetect::isMobile WC 10.4.2
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();
}
}