WordPress.org

Make WordPress Core

Changeset 14417


Ignore:
Timestamp:
05/03/2010 10:07:31 PM (9 years ago)
Author:
nbachiyski
Message:

Refactor get_available_languages() to use glob() instead of *dir functions. See #13023

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/l10n.php

    r14186 r14417  
    492492 */
    493493function get_available_languages( $dir = null ) {
    494     $languages = array();
    495 
    496     if ( empty($dir) )
    497         $dir = WP_LANG_DIR;
    498 
    499     if ( is_dir( $dir ) && $dh = opendir( $dir ) ) {
    500         while ( ( $lang_file = readdir( $dh ) ) !== false ) {
    501             if ( substr( $lang_file, -3 ) == '.mo' && ( false === strpos( $lang_file, 'continents-cities' ) ) )
    502                 $languages[] = basename($lang_file, '.mo');
     494    $languages = array();   
     495       
     496    foreach( glob( ( is_null( $dir) ? WP_LANG_DIR : $dir ) . '/*.mo' ) as $lang_file ) {
     497        if ( false === strpos( $lang_file, 'continents-cities' ) ) {
     498            $languages[] = basename($lang_file, '.mo');
    503499        }
    504         closedir($dh);
    505500    }
    506 
     501   
    507502    return $languages;
    508503}
    509 
    510 ?>
Note: See TracChangeset for help on using the changeset viewer.