Automattic\WooCommerce\Vendor\Detection

MobileDetect::checkHttpHeadersForMobile()publicWC 1.0

Check the HTTP headers for signs of mobile. This is the fastest mobile check possible; it's used inside isMobile() method.

Method of the class: MobileDetect{}

No Hooks.

Return

true|false.

Usage

$MobileDetect = new MobileDetect();
$MobileDetect->checkHttpHeadersForMobile(): bool;

MobileDetect::checkHttpHeadersForMobile() code WC 9.4.2

public function checkHttpHeadersForMobile(): bool
{

    foreach ($this->getMobileHeaders() as $mobileHeader => $matchType) {
        if (isset($this->httpHeaders[$mobileHeader])) {
            if (isset($matchType['matches']) && is_array($matchType['matches'])) {
                foreach ($matchType['matches'] as $_match) {
                    if (strpos($this->httpHeaders[$mobileHeader], $_match) !== false) {
                        return true;
                    }
                }

                return false;
            } else {
                return true;
            }
        }
    }

    return false;
}