@@ 867-905 (lines=39) @@ | ||
864 | public function display_header() { |
|
865 | } |
|
866 | ||
867 | function guess_locale_from_lang( $lang ) { |
|
868 | if ( 'en' == $lang || 'en_US' == $lang || !$lang ) { |
|
869 | return 'en_US'; |
|
870 | } |
|
871 | ||
872 | if ( !class_exists( 'GP_Locales' ) ) { |
|
873 | if ( !defined( 'JETPACK__GLOTPRESS_LOCALES_PATH' ) || !file_exists( JETPACK__GLOTPRESS_LOCALES_PATH ) ) { |
|
874 | return false; |
|
875 | } |
|
876 | ||
877 | require JETPACK__GLOTPRESS_LOCALES_PATH; |
|
878 | } |
|
879 | ||
880 | if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { |
|
881 | // WP.com: get_locale() returns 'it' |
|
882 | $locale = GP_Locales::by_slug( $lang ); |
|
883 | } else { |
|
884 | // Jetpack: get_locale() returns 'it_IT'; |
|
885 | $locale = GP_Locales::by_field( 'wp_locale', $lang ); |
|
886 | } |
|
887 | ||
888 | if ( ! $locale ) { |
|
889 | return false; |
|
890 | } |
|
891 | ||
892 | if ( empty( $locale->facebook_locale ) ) { |
|
893 | if ( empty( $locale->wp_locale ) ) { |
|
894 | return false; |
|
895 | } else { |
|
896 | // Facebook SDK is smart enough to fall back to en_US if a |
|
897 | // locale isn't supported. Since supported Facebook locales |
|
898 | // can fall out of sync, we'll attempt to use the known |
|
899 | // wp_locale value and rely on said fallback. |
|
900 | return $locale->wp_locale; |
|
901 | } |
|
902 | } |
|
903 | ||
904 | return $locale->facebook_locale; |
|
905 | } |
|
906 | ||
907 | public function get_display( $post ) { |
|
908 | if ( $this->smart ) { |
@@ 799-837 (lines=39) @@ | ||
796 | * @param string $lang Language code. |
|
797 | * @return string|bool |
|
798 | */ |
|
799 | function guess_locale_from_lang( $lang ) { |
|
800 | if ( 'en' === $lang || 'en_US' === $lang || ! $lang ) { |
|
801 | return 'en_US'; |
|
802 | } |
|
803 | ||
804 | if ( ! class_exists( 'GP_Locales' ) ) { |
|
805 | if ( ! defined( 'JETPACK__GLOTPRESS_LOCALES_PATH' ) || ! file_exists( JETPACK__GLOTPRESS_LOCALES_PATH ) ) { |
|
806 | return false; |
|
807 | } |
|
808 | ||
809 | require JETPACK__GLOTPRESS_LOCALES_PATH; |
|
810 | } |
|
811 | ||
812 | if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { |
|
813 | // WP.com: get_locale() returns 'it' |
|
814 | $locale = GP_Locales::by_slug( $lang ); |
|
815 | } else { |
|
816 | // Jetpack: get_locale() returns 'it_IT'; |
|
817 | $locale = GP_Locales::by_field( 'facebook_locale', $lang ); |
|
818 | } |
|
819 | ||
820 | if ( ! $locale ) { |
|
821 | return false; |
|
822 | } |
|
823 | ||
824 | if ( empty( $locale->facebook_locale ) ) { |
|
825 | if ( empty( $locale->wp_locale ) ) { |
|
826 | return false; |
|
827 | } else { |
|
828 | // Facebook SDK is smart enough to fall back to en_US if a |
|
829 | // locale isn't supported. Since supported Facebook locales |
|
830 | // can fall out of sync, we'll attempt to use the known |
|
831 | // wp_locale value and rely on said fallback. |
|
832 | return $locale->wp_locale; |
|
833 | } |
|
834 | } |
|
835 | ||
836 | return $locale->facebook_locale; |
|
837 | } |
|
838 | ||
839 | /** |
|
840 | * Get the locale. |