| 268 | <div class="language-switcher"> |
| 269 | <form id="language-switcher" action="" method="GET"> |
| 270 | |
| 271 | <label for="language-switcher-locales"> |
| 272 | <span aria-hidden="true" class="dashicons dashicons-translation"></span> |
| 273 | <span class="screen-reader-text">Select the language:</span> |
| 274 | </label> |
| 275 | |
| 276 | <?php |
| 277 | $args = array( |
| 278 | 'id' => 'language-switcher-locales', |
| 279 | 'name' => 'wp_lang', |
| 280 | 'selected' => ! empty( $_GET['wp_lang'] ) ? sanitize_text_field( $_GET['wp_lang'] ) : get_locale(), |
| 281 | 'show_available_translations' => false, |
| 282 | 'languages' => get_available_languages(), |
| 283 | ); |
| 284 | |
| 285 | /** |
| 286 | * Filters default arguments for languages list on login screen. |
| 287 | * |
| 288 | * @since x.x.x |
| 289 | * |
| 290 | * @param Array $args Default arguments for dropdown languages on login page. |
| 291 | */ |
| 292 | wp_dropdown_languages( apply_filters( 'wp_login_language_switcher_args', $args ) ); |
| 293 | ?> |
| 294 | |
| 295 | <?php if ( $interim_login ) { ?> |
| 296 | <input type="hidden" name="interim-login" value="1" /> |
| 297 | <?php } ?> |
| 298 | |
| 299 | <?php if ( isset( $_GET['redirect_to'] ) && '' !== $_GET['redirect_to'] ) { ?> |
| 300 | <input type="hidden" name="redirect_to" value="<?php echo sanitize_url( $_GET['redirect_to'] ) ?>" /> |
| 301 | <?php } ?> |
| 302 | |
| 303 | <?php if ( isset( $_GET['action'] ) && '' !== $_GET['action'] ) { ?> |
| 304 | <input type="hidden" name="action" value="<?php echo sanitize_text_field( $_GET['action'] ) ?>" /> |
| 305 | <?php } ?> |
| 306 | |
| 307 | </form> |
| 308 | </div> |
| 309 | |
| 310 | <script> |
| 311 | var switcherForm = document.getElementById( 'language-switcher' ); |
| 312 | var localesSelect = document.getElementById( 'language-switcher-locales' ); |
| 313 | localesSelect.addEventListener( 'change', function() { |
| 314 | switcherForm.submit() |
| 315 | } ); |
| 316 | </script> |
| 317 | |