| @@ -14,8 +14,9 @@ | ||
| 14 | 14 | * @package automattic/jetpack |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | 17 | use Automattic\Jetpack\Connection\Manager as Connection_Manager; |
| 18 | +use Automattic\Jetpack\Status\Host; | |
| 18 | 19 | |
| 19 | 20 | if ( ! defined( 'JETPACK_NOTES__CACHE_BUSTER' ) ) { |
| 20 | 21 | define( 'JETPACK_NOTES__CACHE_BUSTER', JETPACK__VERSION . '-' . gmdate( 'oW' ) . '-lite' ); |
| 21 | 22 | } |
| @@ -109,9 +110,9 @@ | ||
| 109 | 110 | return; |
| 110 | 111 | } |
| 111 | 112 | $is_rtl = is_rtl(); |
| 112 | 113 | |
| 113 | - if ( Jetpack::is_module_active( 'masterbar' ) ) { | |
| 114 | + if ( ( new Host() )->is_woa_site() ) { | |
| 114 | 115 | /** |
| 115 | 116 | * Can be used to force Notifications to display in RTL style. |
| 116 | 117 | * |
| 117 | 118 | * @module notes |
| @@ -172,9 +173,9 @@ | ||
| 172 | 173 | if ( self::is_block_editor() ) { |
| 173 | 174 | return; |
| 174 | 175 | } |
| 175 | 176 | |
| 176 | - $wpcom_locale = get_locale(); | |
| 177 | + $user_locale = get_user_locale(); | |
| 177 | 178 | |
| 178 | 179 | if ( ! class_exists( 'GP_Locales' ) ) { |
| 179 | 180 | if ( defined( 'JETPACK__GLOTPRESS_LOCALES_PATH' ) && file_exists( JETPACK__GLOTPRESS_LOCALES_PATH ) ) { |
| 180 | 181 | require JETPACK__GLOTPRESS_LOCALES_PATH; |
| @@ -181,11 +182,11 @@ | ||
| 181 | 182 | } |
| 182 | 183 | } |
| 183 | 184 | |
| 184 | 185 | if ( class_exists( 'GP_Locales' ) ) { |
| 185 | - $wpcom_locale_object = GP_Locales::by_field( 'wp_locale', $wpcom_locale ); | |
| 186 | - if ( $wpcom_locale_object instanceof GP_Locale ) { | |
| 187 | - $wpcom_locale = $wpcom_locale_object->slug; | |
| 186 | + $jetpack_locale_object = GP_Locales::by_field( 'slug', $user_locale ); | |
| 187 | + if ( $jetpack_locale_object instanceof GP_Locale ) { | |
| 188 | + $user_locale = $jetpack_locale_object->slug; | |
| 188 | 189 | } |
| 189 | 190 | } |
| 190 | 191 | |
| 191 | 192 | $third_party_cookie_check_iframe = '<span style="display:none;"><iframe class="jetpack-notes-cookie-check" src="https://widgets.wp.com/3rd-party-cookie-check/index.html"></iframe></span>'; |
| @@ -190,14 +191,18 @@ | ||
| 190 | 191 | |
| 191 | 192 | $third_party_cookie_check_iframe = '<span style="display:none;"><iframe class="jetpack-notes-cookie-check" src="https://widgets.wp.com/3rd-party-cookie-check/index.html"></iframe></span>'; |
| 192 | 193 | |
| 193 | 194 | $title = self::get_notes_markup(); |
| 195 | + | |
| 196 | + // The default fallback is `en_US`. Remove underscore if present, noting that lang codes can be more than three chars. | |
| 197 | + $user_locale = strtolower( explode( '_', $user_locale, 2 )[0] ); | |
| 198 | + | |
| 194 | 199 | $wp_admin_bar->add_menu( |
| 195 | 200 | array( |
| 196 | 201 | 'id' => 'notes', |
| 197 | 202 | 'title' => $title, |
| 198 | 203 | 'meta' => array( |
| 199 | - 'html' => '<div id="wpnt-notes-panel2" class="intrinsic-ignore" style="display:none" lang="' . esc_attr( $wpcom_locale ) . '" dir="' . ( is_rtl() ? 'rtl' : 'ltr' ) . '"><div class="wpnt-notes-panel-header"><span class="wpnt-notes-header">' . __( 'Notifications', 'jetpack' ) . '</span><span class="wpnt-notes-panel-link"></span></div></div>' . $third_party_cookie_check_iframe, | |
| 204 | + 'html' => '<div id="wpnt-notes-panel2" class="intrinsic-ignore" style="display:none" lang="' . esc_attr( $user_locale ) . '" dir="' . ( is_rtl() ? 'rtl' : 'ltr' ) . '"><div class="wpnt-notes-panel-header"><span class="wpnt-notes-header">' . __( 'Notifications', 'jetpack' ) . '</span><span class="wpnt-notes-panel-link"></span></div></div>' . $third_party_cookie_check_iframe, | |
| 200 | 205 | 'class' => 'menupop', |
| 201 | 206 | ), |
| 202 | 207 | 'parent' => 'top-secondary', |
| 203 | 208 | 'href' => 'https://wordpress.com/notifications', |