Make WordPress Core

Changeset 52404


Ignore:
Timestamp:
12/21/2021 06:50:36 PM (5 years ago)
Author:
audrasjb
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-login.php

    r52332 r52404  
    313313
    314314        <?php
    315         $languages = get_available_languages();
    316 
    317         if ( ! empty( $languages ) && ! $interim_login ) {
    318                 ?>
    319 
    320                 <div class="language-switcher">
    321                         <form id="language-switcher" action="" method="get">
    322 
    323                                 <label for="language-switcher-locales">
    324                                         <span class="dashicons dashicons-translation" aria-hidden="true"></span>
    325                                         <span class="screen-reader-text"><?php _e( 'Language' ); ?></span>
    326                                 </label>
    327 
    328                                 <?php
    329                                 $args = array(
    330                                         'id'                          => 'language-switcher-locales',
    331                                         'name'                        => 'wp_lang',
    332                                         'selected'                    => determine_locale(),
    333                                         'show_available_translations' => false,
    334                                         'explicit_option_en_us'       => true,
    335                                         'languages'                   => $languages,
    336                                 );
    337 
    338                                 /**
    339                                  * Filters default arguments for the Languages select input on the login screen.
    340                                  *
    341                                  * @since 5.9.0
    342                                  *
    343                                  * @param array $args Arguments for the Languages select input on the login screen.
    344                                  */
    345                                 wp_dropdown_languages( apply_filters( 'wp_login_language_switcher_args', $args ) );
    346                                 ?>
    347 
    348                                 <?php if ( $interim_login ) { ?>
    349                                         <input type="hidden" name="interim-login" value="1" />
    350                                 <?php } ?>
    351 
    352                                 <?php if ( isset( $_GET['redirect_to'] ) && '' !== $_GET['redirect_to'] ) { ?>
    353                                         <input type="hidden" name="redirect_to" value="<?php echo esc_url_raw( $_GET['redirect_to'] ); ?>" />
    354                                 <?php } ?>
    355 
    356                                 <?php if ( isset( $_GET['action'] ) && '' !== $_GET['action'] ) { ?>
    357                                         <input type="hidden" name="action" value="<?php echo esc_attr( $_GET['action'] ); ?>" />
    358                                 <?php } ?>
    359 
    360                                         <input type="submit" class="button button-primary" value="<?php esc_attr_e( 'Change' ); ?>">
    361 
    362                                 </form>
    363                         </div>
    364 
    365 <?php } ?>
    366 
     315        if (
     316                ! $interim_login &&
     317                /**
     318                 * Filters the Languages select input activation on the login screen.
     319                 *
     320                 * @since 5.9.0
     321                 *
     322                 * @param bool Whether to display the Languages select input on the login screen.
     323                 */
     324                apply_filters( 'display_login_language_dropdown', true )
     325        ) {
     326                $languages = get_available_languages();
     327
     328                if ( ! empty( $languages ) ) {
     329                        ?>
     330                        <div class="language-switcher">
     331                                <form id="language-switcher" action="" method="get">
     332       
     333                                        <label for="language-switcher-locales">
     334                                                <span class="dashicons dashicons-translation" aria-hidden="true"></span>
     335                                                <span class="screen-reader-text"><?php _e( 'Language' ); ?></span>
     336                                        </label>
     337       
     338                                        <?php
     339                                        $args = array(
     340                                                'id'                          => 'language-switcher-locales',
     341                                                'name'                        => 'wp_lang',
     342                                                'selected'                    => determine_locale(),
     343                                                'show_available_translations' => false,
     344                                                'explicit_option_en_us'       => true,
     345                                                'languages'                   => $languages,
     346                                        );
     347       
     348                                        /**
     349                                         * Filters default arguments for the Languages select input on the login screen.
     350                                         *
     351                                         * @since 5.9.0
     352                                         *
     353                                         * @param array $args Arguments for the Languages select input on the login screen.
     354                                         */
     355                                        wp_dropdown_languages( apply_filters( 'wp_login_language_switcher_args', $args ) );
     356                                        ?>
     357       
     358                                        <?php if ( $interim_login ) { ?>
     359                                                <input type="hidden" name="interim-login" value="1" />
     360                                        <?php } ?>
     361       
     362                                        <?php if ( isset( $_GET['redirect_to'] ) && '' !== $_GET['redirect_to'] ) { ?>
     363                                                <input type="hidden" name="redirect_to" value="<?php echo esc_url_raw( $_GET['redirect_to'] ); ?>" />
     364                                        <?php } ?>
     365       
     366                                        <?php if ( isset( $_GET['action'] ) && '' !== $_GET['action'] ) { ?>
     367                                                <input type="hidden" name="action" value="<?php echo esc_attr( $_GET['action'] ); ?>" />
     368                                        <?php } ?>
     369       
     370                                                <input type="submit" class="button button-primary" value="<?php esc_attr_e( 'Change' ); ?>">
     371       
     372                                        </form>
     373                                </div>
     374                <?php } ?>
     375        <?php } ?>
    367376        <?php
    368377
Note: See TracChangeset for help on using the changeset viewer.