wpseek.com
Outil de recherche WordPress pour les développeurs et auteurs de thèmes



wp_get_chromium_major_version › WordPress Function

Depuis7.1.0
Dépréciéen/a
› wp_get_chromium_major_version ( Pas de paramètres )
Retourne:
  • (int|null) The major Chrome version, or null if not a Chromium browser.
Défini(e) dans:
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;
}