Automattic\Jetpack\Device_Detection
User_Agent_Info::is_opera_mobile
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 );
- $user_agent(строка|null)
- User agent string to check. If not provided, uses $_SERVER['HTTP_USER_AGENT'].
По умолчанию: null
Код User_Agent_Info::is_opera_mobile() User Agent Info::is opera mobile WPSCache 3.0.3
public static function is_opera_mobile( $user_agent = null ) {
$user_agent = self::maybe_get_user_agent_from_server( $user_agent );
if ( empty( $user_agent ) ) {
return false;
}
$ua = strtolower( wp_unslash( $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;
}
}