Make WordPress Core

Changeset 39235


Ignore:
Timestamp:
11/15/2016 01:18:37 AM (10 years ago)
Author:
pento
Message:

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.

File:
1 edited

Legend:

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

    r39230 r39235  
    949949 *
    950950 * @since 3.0.0
     951 * @since 4.7.0 The results are now filterable with the get_available_languages filter.
    951952 *
    952953 * @param string $dir A directory to search for language files.
    … …  
    957958        $languages = array();
    958959
    959         $lang_files = glob( ( is_null( $dir) ? WP_LANG_DIR : $dir ) . '/*.mo' );
     960        $lang_files = glob( ( is_null( $dir ) ? WP_LANG_DIR : $dir ) . '/*.mo' );
    960961        if ( $lang_files ) {
    961962                foreach ( $lang_files as $lang_file ) {
    … …  
    968969        }
    969970
    970         return $languages;
     971        /**
     972         * Filters the list of available language codes
     973         *
     974         * @since 4.7.0
     975         *
     976         * @param array $languages An array of available language codes.
     977         * @param string $dir The directory where the language files were found.
     978         */
     979        return apply_filters( 'get_available_languages', $languages, $dir );
    971980}
    972981
Note: See TracChangeset for help on using the changeset viewer.