Make WordPress Core

Changeset 29007


Ignore:
Timestamp:
07/05/2014 06:18:50 AM (10 years ago)
Author:
nacin
Message:

Introduce wp_dropdown_languages() and use it on general settings.

Early rough cut. Obviously not fully implemented.

see #15677.

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/options-general.php

    r28848 r29007  
    305305<?php
    306306    $languages = get_available_languages();
    307     if ( is_multisite() && !empty( $languages ) ):
     307    if ( $languages ) :
    308308?>
    309309    <tr>
    310310        <th width="33%" scope="row"><?php _e('Site Language') ?></th>
    311311        <td>
    312             <select name="WPLANG" id="WPLANG">
    313                 <?php mu_dropdown_languages( $languages, get_option('WPLANG') ); ?>
    314             </select>
     312            <?php wp_dropdown_languages( array(
     313                'name'      => 'WPLANG',
     314                'id'        => 'WPLANG',
     315                'selected'  => get_option( 'WPLANG' ),
     316                'languages' => $languages,
     317            ) ); ?>
    315318        </td>
    316319    </tr>
  • trunk/src/wp-admin/options.php

    r28833 r29007  
    7373
    7474$whitelist_options = array(
    75     'general' => array( 'blogname', 'blogdescription', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'timezone_string' ),
     75    'general' => array( 'blogname', 'blogdescription', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'timezone_string', 'WPLANG' ),
    7676    'discussion' => array( 'default_pingback_flag', 'default_ping_status', 'default_comment_status', 'comments_notify', 'moderation_notify', 'comment_moderation', 'require_name_email', 'comment_whitelist', 'comment_max_links', 'moderation_keys', 'blacklist_keys', 'show_avatars', 'avatar_rating', 'avatar_default', 'close_comments_for_old_posts', 'close_comments_days_old', 'thread_comments', 'thread_comments_depth', 'page_comments', 'comments_per_page', 'default_comments_page', 'comment_order', 'comment_registration' ),
    7777    'media' => array( 'thumbnail_size_w', 'thumbnail_size_h', 'thumbnail_crop', 'medium_size_w', 'medium_size_h', 'large_size_w', 'large_size_h', 'image_default_size', 'image_default_align', 'image_default_link_type' ),
     
    108108} else {
    109109    $whitelist_options['general'][] = 'new_admin_email';
    110     $whitelist_options['general'][] = 'WPLANG';
    111110
    112111    /**
  • trunk/src/wp-includes/l10n.php

    r28938 r29007  
    817817    return $headers;
    818818}
     819
     820/**
     821 * Language selector. More to come.
     822 *
     823 * @since 4.0.0
     824 */
     825function wp_dropdown_languages( $args = array() ) {
     826    if ( isset( $args['languages'] ) ) {
     827        $languages = $args['languages'];
     828    } else {
     829        $languages = get_available_languages();
     830    }
     831
     832    printf( '<select name="%s" id="%s">', esc_attr( $args['name'] ), esc_attr( $args['id'] ) );
     833    echo '<option value="">en_US</option>';
     834    foreach ( $languages as $language ) {
     835        $selected = selected( $language, $args['selected'], false );
     836        echo '<option value="' . esc_attr( $language ) .'"' . $selected . '>' . $language . '</option>';
     837    }
     838    echo '</select>';
     839}
Note: See TracChangeset for help on using the changeset viewer.