mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 12:20:22 +00:00
I18N: Allow to short-circuit load_textdomain().
Introduces a new `pre_load_textdomain` filter, which is useful for plugins to develop and test alternative loading/caching strategies for translations. This brings consistency with the existing `pre_load_script_translations` filter for JavaScript translations. Props ocean90, swissspidy. Fixes #58035. git-svn-id: https://develop.svn.wordpress.org/trunk@55928 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -717,6 +717,28 @@ function load_textdomain( $domain, $mofile, $locale = null ) {
|
||||
|
||||
$l10n_unloaded = (array) $l10n_unloaded;
|
||||
|
||||
/**
|
||||
* Filters whether to short-circuit loading .mo file.
|
||||
*
|
||||
* Returning a non-null value from the filter will effectively short-circuit
|
||||
* the loading, returning the passed value instead.
|
||||
*
|
||||
* @since 6.3.0
|
||||
*
|
||||
* @param bool|null $loaded The result of loading a .mo file. Default null.
|
||||
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
|
||||
* @param string $mofile Path to the MO file.
|
||||
* @param string|null $locale Locale.
|
||||
*/
|
||||
$loaded = apply_filters( 'pre_load_textdomain', null, $domain, $mofile, $locale );
|
||||
if ( null !== $loaded ) {
|
||||
if ( true === $loaded ) {
|
||||
unset( $l10n_unloaded[ $domain ] );
|
||||
}
|
||||
|
||||
return $loaded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters whether to override the .mo file loading.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user