Automattic\Jetpack\Device_Detection

User_Agent_Info::is_opera_desktop()public staticWPSCache 1.0

Detect modern Opera desktop

Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36 OPR/74.0.3911.203

Looking for "OPR/" specifically.

{} It's a method of the class: User_Agent_Info{}

No Hooks.

Return

null. Nothing.

Usage

$result = User_Agent_Info::is_opera_desktop();

Code of User_Agent_Info::is_opera_desktop() WPSCache 1.9.1

public static function is_opera_desktop() {
	if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
		return false;
	}

	if ( false === strpos( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ), 'OPR/' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
		return false;
	}

	return true;
}