Automattic\WooCommerce\Vendor\Detection
MobileDetect::match()
Some detection rules are relative (not standard), because of the diversity of devices, vendors and their conventions in representing the User-Agent or the HTTP headers.
This method will be used to check custom regexes against the User-Agent string.
Метод класса: MobileDetect{}
Хуков нет.
Возвращает
true|false
.
Использование
$MobileDetect = new MobileDetect(); $MobileDetect->match( $regex, $userAgent ): bool;
- $regex(строка) (обязательный)
- -
- $userAgent(строка|null)
- -
По умолчанию: null
Код MobileDetect::match() MobileDetect::match WC 9.5.1
public function match(string $regex, string $userAgent = null): bool { if (!\is_string($userAgent) && !\is_string($this->userAgent)) { return false; } $match = (bool) preg_match( sprintf('#%s#is', $regex), (false === empty($userAgent) ? $userAgent : $this->userAgent), $matches ); // If positive match is found, store the results for debug. if ($match) { $this->matchingRegex = $regex; $this->matchesArray = $matches; } return $match; }