Automattic\WooCommerce\Vendor\Detection

MobileDetect::isTablet()publicWC 1.0

Check if the device is a tablet. Return true if any type of tablet device is detected.

Method of the class: MobileDetect{}

No Hooks.

Return

true|false.

Usage

$MobileDetect = new MobileDetect();
$MobileDetect->isTablet( $userAgent, $httpHeaders ): bool;
$userAgent(string|null)
deprecated
Default: null
$httpHeaders(array|null)
deprecated
Default: null

MobileDetect::isTablet() code WC 8.9.0

public function isTablet(string $userAgent = null, array $httpHeaders = null): bool
{
    // 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_TABLET_VIEWER', $cfHeaders) &&
            $cfHeaders['HTTP_CLOUDFRONT_IS_TABLET_VIEWER'] === 'true'
        ) {
            return true;
        }
    }

    foreach (static::$tabletDevices as $_regex) {
        if ($this->match($_regex, $userAgent)) {
            return true;
        }
    }

    return false;
}