Automattic\Jetpack\Device_Detection

User_Agent_Info::is_facebook_for_iphone()public staticWPSCache 1.0

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]

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

Хуков нет.

Возвращает

null. Ничего.

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

$result = User_Agent_Info::is_facebook_for_iphone();

Код User_Agent_Info::is_facebook_for_iphone() WPSCache 1.9.1

public static function is_facebook_for_iphone() {
	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 ( 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;
	}
}