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.

Built from https://develop.svn.wordpress.org/trunk@52404


git-svn-id: http://core.svn.wordpress.org/trunk@51996 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
audrasjb 2021-12-21 18:52:03 +00:00
parent e6b9b96130
commit d0b3567730
2 changed files with 61 additions and 52 deletions

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.9-beta3-52403';
$wp_version = '5.9-beta3-52404';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

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 ) ) {