Automattic\WPSC\Device_Detection
User_Agent_Info::is_facebook_for_iphone
Detects if the current UA is Facebook for iPhone
- Facebook 4020.0 (iPhone; iPhone OS 5.0.1; fr_FR)
- Mozilla/5.0 (iPhone; U; CPU iPhone OS 5_0 like Mac OS X; en_US) AppleWebKit (KHTML, like Gecko) Mobile [FBAN/FBForIPhone;FBAV/4.0.2;FBBV/4020.0;FBDV/iPhone3,1;FBMD/iPhone;FBSN/iPhone OS;FBSV/5.0;FBSS/2; FBCR/O2;FBID/phone;FBLC/en_US;FBSF/2.0]
- Mozilla/5.0 (iPhone; CPU iPhone OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9B206 [FBAN/FBIOS;FBAV/5.0;FBBV/47423;FBDV/iPhone3,1;FBMD/iPhone;FBSN/iPhone OS;FBSV/5.1.1;FBSS/2; FBCR/3ITA;FBID/phone;FBLC/en_US]
Method of the class: User_Agent_Info{}
No Hooks.
Returns
null. Nothing (null).
Usage
$result = User_Agent_Info::is_facebook_for_iphone( $user_agent );
- $user_agent(string|null)
- User agent string to check. If not provided, uses $_SERVER['HTTP_USER_AGENT'].
Default:null
User_Agent_Info::is_facebook_for_iphone() User Agent Info::is facebook for iphone code WPSCache 3.1.0
public static function is_facebook_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 ( false === strpos( $ua, 'iphone' ) ) {
return false;
}
if ( false !== strpos( $ua, 'facebook' ) && false === strpos( $ua, 'ipad' ) ) {
return true;
} elseif ( false !== strpos( $ua, 'fbforiphone' ) && false === strpos( $ua, 'tablet' ) ) {
return true;
} elseif ( false !== strpos( $ua, 'fban/fbios;' ) && false === strpos( $ua, 'tablet' ) ) { // FB app v5.0 or higher.
return true;
} else {
return false;
}
}