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.
Использование
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|массив)
- List of translation files.
По умолчанию: null - $path(строка)
- The path from which translation files are being fetched.
Список изменений
С версии 6.5.0 | Введена. |
Где вызывается хук
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 );