Code Duplication    Length = 39-39 lines in 2 locations

modules/sharedaddy/sharing-sources.php 1 location

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

class.jetpack.php 1 location

@@ 815-853 (lines=39) @@
812
	 * @param string $lang Language code.
813
	 * @return string|bool
814
	 */
815
	function guess_locale_from_lang( $lang ) {
816
		if ( 'en' === $lang || 'en_US' === $lang || ! $lang ) {
817
			return 'en_US';
818
		}
819
820
		if ( ! class_exists( 'GP_Locales' ) ) {
821
			if ( ! defined( 'JETPACK__GLOTPRESS_LOCALES_PATH' ) || ! file_exists( JETPACK__GLOTPRESS_LOCALES_PATH ) ) {
822
				return false;
823
			}
824
825
			require JETPACK__GLOTPRESS_LOCALES_PATH;
826
		}
827
828
		if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
829
			// WP.com: get_locale() returns 'it'
830
			$locale = GP_Locales::by_slug( $lang );
831
		} else {
832
			// Jetpack: get_locale() returns 'it_IT';
833
			$locale = GP_Locales::by_field( 'facebook_locale', $lang );
834
		}
835
836
		if ( ! $locale ) {
837
			return false;
838
		}
839
840
		if ( empty( $locale->facebook_locale ) ) {
841
			if ( empty( $locale->wp_locale ) ) {
842
				return false;
843
			} else {
844
				// Facebook SDK is smart enough to fall back to en_US if a
845
				// locale isn't supported. Since supported Facebook locales
846
				// can fall out of sync, we'll attempt to use the known
847
				// wp_locale value and rely on said fallback.
848
				return $locale->wp_locale;
849
			}
850
		}
851
852
		return $locale->facebook_locale;
853
	}
854
855
	/**
856
	 * Get the locale.