From fc1255a2c7811f7bac3253bc4f2d20a379dcfb62 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Tue, 15 Nov 2016 01:19:31 +0000 Subject: [PATCH] I18N: Add the `get_available_languages` filter. Sometimes, a language file may not exist in exactly the format or location that `get_available_languages()` expects it to be in - for sites with this level of customisation, they need to be able to add their own language files to the list of those available. Props yoavf. Fixes #38788. Built from https://develop.svn.wordpress.org/trunk@39235 git-svn-id: http://core.svn.wordpress.org/trunk@39175 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/l10n.php | 13 +++++++++++-- wp-includes/version.php | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/wp-includes/l10n.php b/wp-includes/l10n.php index 1827166b14..adb8483c73 100644 --- a/wp-includes/l10n.php +++ b/wp-includes/l10n.php @@ -948,6 +948,7 @@ function translate_user_role( $name ) { * The default directory is WP_LANG_DIR. * * @since 3.0.0 + * @since 4.7.0 The results are now filterable with the get_available_languages filter. * * @param string $dir A directory to search for language files. * Default WP_LANG_DIR. @@ -956,7 +957,7 @@ function translate_user_role( $name ) { function get_available_languages( $dir = null ) { $languages = array(); - $lang_files = glob( ( is_null( $dir) ? WP_LANG_DIR : $dir ) . '/*.mo' ); + $lang_files = glob( ( is_null( $dir ) ? WP_LANG_DIR : $dir ) . '/*.mo' ); if ( $lang_files ) { foreach ( $lang_files as $lang_file ) { $lang_file = basename( $lang_file, '.mo' ); @@ -967,7 +968,15 @@ function get_available_languages( $dir = null ) { } } - return $languages; + /** + * Filters the list of available language codes + * + * @since 4.7.0 + * + * @param array $languages An array of available language codes. + * @param string $dir The directory where the language files were found. + */ + return apply_filters( 'get_available_languages', $languages, $dir ); } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index cdc5c8b2c0..11dd2d9e0f 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.7-beta3-39234'; +$wp_version = '4.7-beta3-39235'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.