Make WordPress Core


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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.