pre_get_language_files_from_path
Filters the translation files retrieved from a specified path before the actual lookup.
Returning a non-null value from the filter will effectively short-circuit the MO files lookup, returning that value instead.
This can be useful in situations where the directory contains a large number of files and the default glob() function becomes expensive in terms of performance.
Usage
add_filter( 'pre_get_language_files_from_path', 'wp_kama_pre_get_language_files_from_path_filter', 10, 2 );
/**
* Function for `pre_get_language_files_from_path` filter-hook.
*
* @param null|array $files List of translation files.
* @param string $path The path from which translation files are being fetched.
*
* @return null|array
*/
function wp_kama_pre_get_language_files_from_path_filter( $files, $path ){
// filter...
return $files;
}
- $files(null|array)
- List of translation files.
Default: null - $path(string)
- The path from which translation files are being fetched.
Changelog
| Since 6.5.0 | Introduced. |
Where the hook is called
pre_get_language_files_from_path
wp-includes/class-wp-textdomain-registry.php 197
$files = apply_filters( 'pre_get_language_files_from_path', null, $path );