Automattic\WooCommerce\Vendor\Detection

MobileDetect::setUserAgent()publicWC 1.0

Set the User-Agent to be used.

Method of the class: MobileDetect{}

No Hooks.

Return

String|null.

Usage

$MobileDetect = new MobileDetect();
$MobileDetect->setUserAgent( $userAgent ): ?string;
$userAgent(string|null)
The user agent string to set.
Default: null

MobileDetect::setUserAgent() code WC 8.9.0

public function setUserAgent(string $userAgent = null): ?string
{
    // Invalidate cache due to #375
    $this->cache = array();

    if (false === empty($userAgent)) {
        return $this->userAgent = $this->prepareUserAgent($userAgent);
    } else {
        $this->userAgent = null;
        foreach ($this->getUaHttpHeaders() as $altHeader) {
            // @todo: should use getHttpHeader(), but it would be slow. (Serban)
            if (false === empty($this->httpHeaders[$altHeader])) {
                $this->userAgent .= $this->httpHeaders[$altHeader] . " ";
            }
        }

        if (!empty($this->userAgent)) {
            return $this->userAgent = $this->prepareUserAgent($this->userAgent);
        }
    }

    if (count($this->getCfHeaders()) > 0) {
        return $this->userAgent = 'Amazon CloudFront';
    }
    return $this->userAgent = null;
}