Automattic\Jetpack\Device_Detection

User_Agent_Info::is_opera_mobile()public staticWPSCache 1.0

Detects if the current browser is Opera Mobile

What is the difference between Opera Mobile and Opera Mini?

  • Opera Mobile is a full Internet browser for mobile devices.
  • Opera Mini always uses a transcoder to convert the page for a small display. (it uses Opera advanced server compression technology to compress web content before it gets to a device. The rendering engine is on Opera's server.)

Opera/9.80 (Windows NT 6.1; Opera Mobi/14316; U; en) Presto/2.7.81 Version/11.00" Opera/9.50 (Nintendo DSi; Opera/507; U; en-US)

Метод класса: User_Agent_Info{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$result = User_Agent_Info::is_opera_mobile();

Код User_Agent_Info::is_opera_mobile() WPSCache 1.12.0

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

	$ua = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.

	if ( strpos( $ua, 'opera' ) !== false && strpos( $ua, 'mobi' ) !== false ) {
		return true;
	} elseif ( strpos( $ua, 'opera' ) !== false && strpos( $ua, 'nintendo dsi' ) !== false ) {
		return true;
	} else {
		return false;
	}
}