| @@ 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 ) { |
|
| @@ 738-776 (lines=39) @@ | ||
| 735 | * @param string $lang Language code. |
|
| 736 | * @return string|bool |
|
| 737 | */ |
|
| 738 | function guess_locale_from_lang( $lang ) { |
|
| 739 | if ( 'en' === $lang || 'en_US' === $lang || ! $lang ) { |
|
| 740 | return 'en_US'; |
|
| 741 | } |
|
| 742 | ||
| 743 | if ( ! class_exists( 'GP_Locales' ) ) { |
|
| 744 | if ( ! defined( 'JETPACK__GLOTPRESS_LOCALES_PATH' ) || ! file_exists( JETPACK__GLOTPRESS_LOCALES_PATH ) ) { |
|
| 745 | return false; |
|
| 746 | } |
|
| 747 | ||
| 748 | require JETPACK__GLOTPRESS_LOCALES_PATH; |
|
| 749 | } |
|
| 750 | ||
| 751 | if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { |
|
| 752 | // WP.com: get_locale() returns 'it' |
|
| 753 | $locale = GP_Locales::by_slug( $lang ); |
|
| 754 | } else { |
|
| 755 | // Jetpack: get_locale() returns 'it_IT'; |
|
| 756 | $locale = GP_Locales::by_field( 'facebook_locale', $lang ); |
|
| 757 | } |
|
| 758 | ||
| 759 | if ( ! $locale ) { |
|
| 760 | return false; |
|
| 761 | } |
|
| 762 | ||
| 763 | if ( empty( $locale->facebook_locale ) ) { |
|
| 764 | if ( empty( $locale->wp_locale ) ) { |
|
| 765 | return false; |
|
| 766 | } else { |
|
| 767 | // Facebook SDK is smart enough to fall back to en_US if a |
|
| 768 | // locale isn't supported. Since supported Facebook locales |
|
| 769 | // can fall out of sync, we'll attempt to use the known |
|
| 770 | // wp_locale value and rely on said fallback. |
|
| 771 | return $locale->wp_locale; |
|
| 772 | } |
|
| 773 | } |
|
| 774 | ||
| 775 | return $locale->facebook_locale; |
|
| 776 | } |
|
| 777 | ||
| 778 | private static function get_site_user_count() { |
|
| 779 | global $wpdb; |
|