wp_dropdown_languages example

<h2><?php _e( 'Language Settings' ); ?></h2> <table class="form-table" role="presentation"> <tr> <th><label for="WPLANG"><?php _e( 'Default Language' ); ?><span class="dashicons dashicons-translation" aria-hidden="true"></span></label></th> <td> <?php                         $lang = get_site_option( 'WPLANG' );
                        if ( ! in_array( $lang$languages, true ) ) {
                            $lang = '';
                        }

                        wp_dropdown_languages(
                            array(
                                'name'         => 'WPLANG',
                                'id'           => 'WPLANG',
                                'selected'     => $lang,
                                'languages'    => $languages,
                                'translations' => $translations,
                                'show_available_translations' => current_user_can( 'install_languages' ) && wp_can_install_language_pack(),
                            )
                        );
                        ?> </td> </tr> </table>
if ( $languages ) :
            ?> <tr class="form-field user-language-wrap"> <th scope="row"> <label for="locale"> <?php /* translators: The user language selection field label. */ ?> <?php _e( 'Language' ); ?><span class="dashicons dashicons-translation" aria-hidden="true"></span> </label> </th> <td> <?php                 wp_dropdown_languages(
                    array(
                        'name'                        => 'locale',
                        'id'                          => 'locale',
                        'selected'                    => 'site-default',
                        'languages'                   => $languages,
                        'show_available_translations' => false,
                        'show_option_site_default'    => true,
                    )
                );
                ?> </td> </tr>
<?php                                 $user_locale = $profile_user->locale;

                            if ( 'en_US' === $user_locale ) {
                                $user_locale = '';
                            } elseif ( '' === $user_locale || ! in_array( $user_locale$languages, true ) ) {
                                $user_locale = 'site-default';
                            }

                            wp_dropdown_languages(
                                array(
                                    'name'      => 'locale',
                                    'id'        => 'locale',
                                    'selected'  => $user_locale,
                                    'languages' => $languages,
                                    'show_available_translations' => $can_install_translations,
                                    'show_option_site_default' => true,
                                )
                            );
                            ?> </td> </tr>
<?php _e( 'Site Language' ); ?></label></th> <td> <?php                     // Network default.                     $lang = get_site_option( 'WPLANG' );

                    // Use English if the default isn't available.                     if ( ! in_array( $lang$languages, true ) ) {
                        $lang = '';
                    }

                    wp_dropdown_languages(
                        array(
                            'name'                        => 'WPLANG',
                            'id'                          => 'site-language',
                            'selected'                    => $lang,
                            'languages'                   => $languages,
                            'translations'                => $translations,
                            'show_available_translations' => current_user_can( 'install_languages' ) && wp_can_install_language_pack(),
                        )
                    );
                    ?> </td> </tr>
if ( ! empty( $languages ) || ! empty( $translations ) ) {
    ?> <tr> <th scope="row"><label for="WPLANG"><?php _e( 'Site Language' ); ?><span class="dashicons dashicons-translation" aria-hidden="true"></span></label></th> <td> <?php             $locale = get_locale();
            if ( ! in_array( $locale$languages, true ) ) {
                $locale = '';
            }

            wp_dropdown_languages(
                array(
                    'name'                        => 'WPLANG',
                    'id'                          => 'WPLANG',
                    'selected'                    => $locale,
                    'languages'                   => $languages,
                    'translations'                => $translations,
                    'show_available_translations' => current_user_can( 'install_languages' ) && wp_can_install_language_pack(),
                )
            );

            // Add note about deprecated WPLANG constant.
            $lang = get_site_option( 'WPLANG' );

            if ( isset( $_POST['WPLANG'] ) ) {
                $lang = $_POST['WPLANG'];
            }

            // Use US English if the default isn't available.             if ( ! in_array( $lang$languages, true ) ) {
                $lang = '';
            }

            wp_dropdown_languages(
                array(
                    'name'                        => 'WPLANG',
                    'id'                          => 'site-language',
                    'selected'                    => $lang,
                    'languages'                   => $languages,
                    'show_available_translations' => false,
                )
            );
            ?> </p> <?php


                    /** * Filters default arguments for the Languages select input on the login screen. * * The arguments get passed to the wp_dropdown_languages() function. * * @since 5.9.0 * * @param array $args Arguments for the Languages select input on the login screen. */
                    wp_dropdown_languages( apply_filters( 'login_language_dropdown_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 sanitize_url( $_GET['redirect_to'] ); ?>" /> <?php } ?> <?php if ( isset( $_GET['action'] ) && '' !== $_GET['action'] ) { ?>
Home | Imprint | This part of the site doesn't use cookies.