Refactor get_available_languages() to use glob() instead of *dir functions. See #13023
git-svn-id: http://svn.automattic.com/wordpress/trunk@14417 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
1f18095da6
commit
7ee70968ce
|
@ -491,20 +491,13 @@ function translate_user_role( $name ) {
|
|||
* @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.
|
||||
*/
|
||||
function get_available_languages( $dir = null ) {
|
||||
$languages = array();
|
||||
|
||||
if ( empty($dir) )
|
||||
$dir = WP_LANG_DIR;
|
||||
|
||||
if ( is_dir( $dir ) && $dh = opendir( $dir ) ) {
|
||||
while ( ( $lang_file = readdir( $dh ) ) !== false ) {
|
||||
if ( substr( $lang_file, -3 ) == '.mo' && ( false === strpos( $lang_file, 'continents-cities' ) ) )
|
||||
$languages[] = basename($lang_file, '.mo');
|
||||
$languages = array();
|
||||
|
||||
foreach( glob( ( is_null( $dir) ? WP_LANG_DIR : $dir ) . '/*.mo' ) as $lang_file ) {
|
||||
if ( false === strpos( $lang_file, 'continents-cities' ) ) {
|
||||
$languages[] = basename($lang_file, '.mo');
|
||||
}
|
||||
closedir($dh);
|
||||
}
|
||||
|
||||
|
||||
return $languages;
|
||||
}
|
||||
|
||||
?>
|
||||
}
|
Loading…
Reference in New Issue