Automattic\WPSC\Device_Detection

User_Agent_Info::is_twitter_for_iphonepublic staticWPSCache 1.0

Detects if the current UA is Twitter for iPhone

Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_5 like Mac OS X; nb-no) AppleWebKit/533.17.9 (KHTML, like Gecko) Mobile/8L1 Twitter for iPhone Mozilla/5.0 (iPhone; CPU iPhone OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9B206 Twitter for iPhone

@param string|null $user_agent Optional. User agent string to check. If not provided, uses $_SERVER['HTTP_USER_AGENT'].

Method of the class: User_Agent_Info{}

No Hooks.

Returns

null. Nothing (null).

Usage

$result = User_Agent_Info::is_twitter_for_iphone( $user_agent );
$user_agent
.
Default: null

User_Agent_Info::is_twitter_for_iphone() code WPSCache 3.1.1

public static function is_twitter_for_iphone( $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, 'ipad' ) !== false ) {
		return false;
	}

	if ( strpos( $ua, 'twitter for iphone' ) !== false ) {
		return true;
	} else {
		return false;
	}
}