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.
Method of the class: MobileDetect{}
No Hooks.
Returns
true|false
.
Usage
$MobileDetect = new MobileDetect(); $MobileDetect->match( $regex, ?string $userAgent ): bool;
- $regex(string) (required)
- .
- ?string $userAgent
- .
Default: null
MobileDetect::match() MobileDetect::match code WC 9.9.5
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; }