Changeset 12946
- Timestamp:
- 02/04/2010 06:46:25 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/ms-edit.php
r12945 r12946 24 24 wp_die( __("You probably need to go back to the <a href='ms-options.php'>options page</a>") ); 25 25 26 if ( isset($_POST['WPLANG']) )26 if ( isset($_POST['WPLANG']) && ( '' === $_POST['WPLANG'] || in_array($_POST['WPLANG'], get_available_languages()) ) ) 27 27 update_site_option( "WPLANG", $_POST['WPLANG'] ); 28 28 -
trunk/wp-admin/ms-options.php
r12911 r12946 253 253 <table class="form-table"> 254 254 <?php 255 $lang_files = array(); 256 if ( is_dir( ABSPATH . LANGDIR ) && $dh = opendir( ABSPATH . LANGDIR ) ) 257 while( ( $lang_file = readdir( $dh ) ) !== false ) 258 if ( substr( $lang_file, -3 ) == '.mo' ) 259 $lang_files[] = $lang_file; 255 $languages = get_available_languages(); 260 256 $lang = get_site_option('WPLANG'); 261 if ( !empty($lang _files) ) {257 if ( !empty($languages) ) { 262 258 ?> 263 259 <tr valign="top"> … … 265 261 <td> 266 262 <select name="WPLANG" id="WPLANG"> 267 <?php mu_dropdown_languages( $lang _files, get_site_option('WPLANG') ); ?>263 <?php mu_dropdown_languages( $languages, get_site_option('WPLANG') ); ?> 268 264 </select> 269 265 </td> -
trunk/wp-includes/l10n.php
r12900 r12946 485 485 return translate_with_gettext_context( before_last_bar($name), 'User role' ); 486 486 } 487 488 /** 489 * Get all available languages based on the presence of *.mo files in a given directory. The default directory is WP_LANG_DIR. 490 * 491 * @since 3.0.0 492 * 493 * @param string $dir A directory in which to search for language files. The default directory is WP_LANG_DIR. 494 * @return array Array of language codes or an empty array if no languages are present. Language codes are formed by stripping the .mo extension from the language file names. 495 */ 496 function get_available_languages( $dir = null ) { 497 $languages = array(); 498 499 if ( empty($dir) ) 500 $dir = WP_LANG_DIR; 501 502 if ( is_dir( $dir ) && $dh = opendir( $dir ) ) { 503 while ( ( $lang_file = readdir( $dh ) ) !== false ) { 504 if ( substr( $lang_file, -3 ) == '.mo' ) 505 $languages[] = basename($lang_file, '.mo'); 506 } 507 closedir($dh); 508 } 509 510 return $languages; 511 } 512 487 513 ?>
Note: See TracChangeset
for help on using the changeset viewer.