Changeset 11590
- Timestamp:
- 02/22/2022 03:06:29 AM (3 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-openverse
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-openverse/.gitignore
r11559 r11590 4 4 mu-plugins/ 5 5 vendor/ 6 wporg_locales.sql -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-openverse/functions.php
r11217 r11590 2 2 3 3 namespace WordPressdotorg\Openverse\Theme; 4 5 use function WordPressdotorg\Locales\get_locales; 4 6 5 7 /** … … 84 86 /* in_footer */ true 85 87 ); 88 89 $use_path_based_locale_forwarding = get_theme_mod( 'ov_path_based_i18n', false ); 90 $wp_locale = get_locale(); 91 $locale = get_locales()[ $wp_locale ]; 92 $locale_slug = $use_path_based_locale_forwarding && $wp_locale !== 'en_US' ? $locale->slug : ''; 93 86 94 wp_add_inline_script( 87 95 /* handle */ 'openverse-message', 88 96 /* JS */ 'const openverseUrl = ' . wp_json_encode( get_theme_mod( 'ov_src_url', OPENVERSE_URL ) ) . ";\n" . 89 97 /* JS */ 'const openverseSubpath = ' . wp_json_encode( OPENVERSE_SUBPATH ) . ";\n" . 90 /* JS */ 'const currentLocale = ' . wp_json_encode( get_locale() ) . ";\n", 98 /* JS */ 'const currentLocale = ' . wp_json_encode( $wp_locale ) . ";\n" . /* Used for legacy cookie based locale forwarding */ 99 /* JS */ 'const localeSlug = ' . wp_json_encode( $locale_slug ) . ";\n", 91 100 /* position */ 'before' 92 ); 101 ); 93 102 94 103 wp_enqueue_script( … … 161 170 ) 162 171 ) ); 172 173 $wp_customize->add_setting( 'ov_path_based_i18n', array( 174 'type' => 'theme_mod', 175 'capability' => 'edit_theme_options', 176 'default' => false 177 ) ); 178 179 $wp_customize->add_control( 'ov_path_based_i18n', array( 180 'section' => 'ov_embed', 181 'type' => 'checkbox', 182 'id' => 'ov_path_based_i18n', 183 'label' => 'Use path based locale forwarding', 184 'priority' => 10 185 ) ); 163 186 } 164 187 add_action( 'customize_register', __NAMESPACE__ . '\wporg_ov_customizer' ); -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-openverse/js/iframe_nav.js
r11466 r11590 6 6 .replace(openverseSubpath, '') 7 7 .replace(/^\/$/, ''); // Remove Openverse site subpath 8 iframePath = `${openverseUrl}${iframePath}${query}`; // Add domain and query 8 const localePart = localeSlug 9 ? openverseUrl.endsWith('/') 10 ? localeSlug 11 : `/${localeSlug}` 12 : ''; 13 iframePath = `${openverseUrl}${localePart}${iframePath}${query}`; // Add domain and query 9 14 10 15 console.log(`Navigating iframe to ${iframePath}`); -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-openverse/js/message.js
r11466 r11590 12 12 function updatePath(value) { 13 13 const path = value.path; 14 const url = `${openverseSubpath}${path}`; // openverseSubpath defined in `index.php` 14 let url = `${openverseSubpath}${path}`; // openverseSubpath defined in `index.php` 15 if (localeSlug) { 16 url = url.replace(`openverse/${localeSlug}`, 'openverse'); 17 } 15 18 16 19 console.log(`Replacing state URL: ${url}`);
Note: See TracChangeset
for help on using the changeset viewer.