Login and registration: Add a filter to allow to disable the Login screen language dropdown.

This change introduces the `display_login_language_dropdown` filter which allows to disable the Login screen language dropdown. 

Follow-up to [52058].

Props rickcurran, audrasjb, ocean90, hellofromtonya, costdev, johnbillion.
Fixes #54675.


git-svn-id: https://develop.svn.wordpress.org/trunk@52404 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jb Audras 2021-12-21 18:50:36 +00:00
parent 998eb6a98d
commit b8f7405450

View File

@ -312,58 +312,67 @@ function login_footer( $input_id = '' ) {
</div><?php // End of <div id="login">. ?>
<?php
$languages = get_available_languages();
if ( ! empty( $languages ) && ! $interim_login ) {
?>
<div class="language-switcher">
<form id="language-switcher" action="" method="get">
<label for="language-switcher-locales">
<span class="dashicons dashicons-translation" aria-hidden="true"></span>
<span class="screen-reader-text"><?php _e( 'Language' ); ?></span>
</label>
<?php
$args = array(
'id' => 'language-switcher-locales',
'name' => 'wp_lang',
'selected' => determine_locale(),
'show_available_translations' => false,
'explicit_option_en_us' => true,
'languages' => $languages,
);
/**
* Filters default arguments for the Languages select input on the login screen.
*
* @since 5.9.0
*
* @param array $args Arguments for the Languages select input on the login screen.
*/
wp_dropdown_languages( apply_filters( 'wp_login_language_switcher_args', $args ) );
?>
<?php if ( $interim_login ) { ?>
<input type="hidden" name="interim-login" value="1" />
<?php } ?>
<?php if ( isset( $_GET['redirect_to'] ) && '' !== $_GET['redirect_to'] ) { ?>
<input type="hidden" name="redirect_to" value="<?php echo esc_url_raw( $_GET['redirect_to'] ); ?>" />
<?php } ?>
<?php if ( isset( $_GET['action'] ) && '' !== $_GET['action'] ) { ?>
<input type="hidden" name="action" value="<?php echo esc_attr( $_GET['action'] ); ?>" />
<?php } ?>
<input type="submit" class="button button-primary" value="<?php esc_attr_e( 'Change' ); ?>">
</form>
</div>
<?php } ?>
if (
! $interim_login &&
/**
* Filters the Languages select input activation on the login screen.
*
* @since 5.9.0
*
* @param bool Whether to display the Languages select input on the login screen.
*/
apply_filters( 'display_login_language_dropdown', true )
) {
$languages = get_available_languages();
if ( ! empty( $languages ) ) {
?>
<div class="language-switcher">
<form id="language-switcher" action="" method="get">
<label for="language-switcher-locales">
<span class="dashicons dashicons-translation" aria-hidden="true"></span>
<span class="screen-reader-text"><?php _e( 'Language' ); ?></span>
</label>
<?php
$args = array(
'id' => 'language-switcher-locales',
'name' => 'wp_lang',
'selected' => determine_locale(),
'show_available_translations' => false,
'explicit_option_en_us' => true,
'languages' => $languages,
);
/**
* Filters default arguments for the Languages select input on the login screen.
*
* @since 5.9.0
*
* @param array $args Arguments for the Languages select input on the login screen.
*/
wp_dropdown_languages( apply_filters( 'wp_login_language_switcher_args', $args ) );
?>
<?php if ( $interim_login ) { ?>
<input type="hidden" name="interim-login" value="1" />
<?php } ?>
<?php if ( isset( $_GET['redirect_to'] ) && '' !== $_GET['redirect_to'] ) { ?>
<input type="hidden" name="redirect_to" value="<?php echo esc_url_raw( $_GET['redirect_to'] ); ?>" />
<?php } ?>
<?php if ( isset( $_GET['action'] ) && '' !== $_GET['action'] ) { ?>
<input type="hidden" name="action" value="<?php echo esc_attr( $_GET['action'] ); ?>" />
<?php } ?>
<input type="submit" class="button button-primary" value="<?php esc_attr_e( 'Change' ); ?>">
</form>
</div>
<?php } ?>
<?php } ?>
<?php
if ( ! empty( $input_id ) ) {