pre_get_language_files_from_path
Filter HookDescription
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.Hook Information
File Location |
wp-includes/class-wp-textdomain-registry.php
View on GitHub
|
Hook Type | Filter |
Line Number | 197 |
Hook Parameters
Type | Name | Description |
---|---|---|
null|array
|
$files
|
List of translation files. Default null. |
string
|
$path
|
The path from which translation files are being fetched. |
Usage Examples
Basic Usage
<?php
// Hook into pre_get_language_files_from_path
add_filter('pre_get_language_files_from_path', 'my_custom_filter', 10, 2);
function my_custom_filter($files, $path) {
// Your custom filtering logic here
return $files;
}
Source Code Context
wp-includes/class-wp-textdomain-registry.php:197
- How this hook is used in WordPress core
<?php
192 * @since 6.5.0
193 *
194 * @param null|array $files List of translation files. Default null.
195 * @param string $path The path from which translation files are being fetched.
196 */
197 $files = apply_filters( 'pre_get_language_files_from_path', null, $path );
198
199 if ( null !== $files ) {
200 return $files;
201 }
202
PHP Documentation
<?php
/**
* 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.
*
* @since 6.5.0
*
* @param null|array $files List of translation files. Default null.
* @param string $path The path from which translation files are being fetched.
*/
Quick Info
- Hook Type: Filter
- Parameters: 2
- File: wp-includes/class-wp-textdomain-registry.php
Related Hooks
Related hooks will be displayed here in future updates.