wpseek.com
A WordPress-centric search engine for devs and theme authors



wp_get_chromium_major_version › WordPress Function

Since7.1.0
Deprecatedn/a
wp_get_chromium_major_version ( No parameters )
Returns:
  • (int|null) The major Chrome version, or null if not a Chromium browser.
Defined at:
Codex:

Returns the major Chrome/Chromium version from the current request's User-Agent.

Matches all Chromium-based browsers (Chrome, Edge, Opera, Brave).


Source

function wp_get_chromium_major_version(): ?int {
	if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
		return null;
	}
	if ( preg_match( '#Chrome/(\d+)#', $_SERVER['HTTP_USER_AGENT'], $matches ) ) {
		return (int) $matches[1];
	}
	return null;
}