Automattic\WooCommerce\Vendor\Detection
MobileDetect::isMobile()
Check if the device is mobile. Returns true if any type of mobile device detected, including special ones
Method of the class: MobileDetect{}
No Hooks.
Return
true|false
.
Usage
$MobileDetect = new MobileDetect(); $MobileDetect->isMobile( $userAgent, $httpHeaders ): bool;
- $userAgent(string|null)
- deprecated
Default: null - $httpHeaders(array|null)
- deprecated
Default: null
MobileDetect::isMobile() MobileDetect::isMobile code WC 9.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(); } }