wp_get_chromium_major_version(): int|null

In this article

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

Description

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

Return

int|null The major Chrome version, or null if not a Chromium browser.

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;
}

Changelog

VersionDescription
7.1.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.