Code Duplication    Length = 39-39 lines in 2 locations

modules/sharedaddy/sharing-sources.php 1 location

@@ 905-943 (lines=39) @@
902
	public function display_header() {
903
	}
904
905
	function guess_locale_from_lang( $lang ) {
906
		if ( 'en' == $lang || 'en_US' == $lang || ! $lang ) {
907
			return 'en_US';
908
		}
909
910
		if ( ! class_exists( 'GP_Locales' ) ) {
911
			if ( ! defined( 'JETPACK__GLOTPRESS_LOCALES_PATH' ) || ! file_exists( JETPACK__GLOTPRESS_LOCALES_PATH ) ) {
912
				return false;
913
			}
914
915
			require JETPACK__GLOTPRESS_LOCALES_PATH;
916
		}
917
918
		if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
919
			// WP.com: get_locale() returns 'it'
920
			$locale = GP_Locales::by_slug( $lang );
921
		} else {
922
			// Jetpack: get_locale() returns 'it_IT';
923
			$locale = GP_Locales::by_field( 'wp_locale', $lang );
924
		}
925
926
		if ( ! $locale ) {
927
			return false;
928
		}
929
930
		if ( empty( $locale->facebook_locale ) ) {
931
			if ( empty( $locale->wp_locale ) ) {
932
				return false;
933
			} else {
934
				// Facebook SDK is smart enough to fall back to en_US if a
935
				// locale isn't supported. Since supported Facebook locales
936
				// can fall out of sync, we'll attempt to use the known
937
				// wp_locale value and rely on said fallback.
938
				return $locale->wp_locale;
939
			}
940
		}
941
942
		return $locale->facebook_locale;
943
	}
944
945
	public function get_display( $post ) {
946
		if ( $this->smart ) {

class.jetpack.php 1 location

@@ 1036-1074 (lines=39) @@
1033
	 * @param string $lang Language code.
1034
	 * @return string|bool
1035
	 */
1036
	function guess_locale_from_lang( $lang ) {
1037
		if ( 'en' === $lang || 'en_US' === $lang || ! $lang ) {
1038
			return 'en_US';
1039
		}
1040
1041
		if ( ! class_exists( 'GP_Locales' ) ) {
1042
			if ( ! defined( 'JETPACK__GLOTPRESS_LOCALES_PATH' ) || ! file_exists( JETPACK__GLOTPRESS_LOCALES_PATH ) ) {
1043
				return false;
1044
			}
1045
1046
			require JETPACK__GLOTPRESS_LOCALES_PATH;
1047
		}
1048
1049
		if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
1050
			// WP.com: get_locale() returns 'it'
1051
			$locale = GP_Locales::by_slug( $lang );
1052
		} else {
1053
			// Jetpack: get_locale() returns 'it_IT';
1054
			$locale = GP_Locales::by_field( 'facebook_locale', $lang );
1055
		}
1056
1057
		if ( ! $locale ) {
1058
			return false;
1059
		}
1060
1061
		if ( empty( $locale->facebook_locale ) ) {
1062
			if ( empty( $locale->wp_locale ) ) {
1063
				return false;
1064
			} else {
1065
				// Facebook SDK is smart enough to fall back to en_US if a
1066
				// locale isn't supported. Since supported Facebook locales
1067
				// can fall out of sync, we'll attempt to use the known
1068
				// wp_locale value and rely on said fallback.
1069
				return $locale->wp_locale;
1070
			}
1071
		}
1072
1073
		return $locale->facebook_locale;
1074
	}
1075
1076
	/**
1077
	 * Get the locale.