On this page
unload_textdomain( string $domain, bool $reloadable = false ): bool
Unloads translations for a text domain.
Parameters
$domainstring Required-
Text domain. Unique identifier for retrieving translated strings.
$reloadablebool Optional-
Whether the text domain can be loaded just-in-time again.
Default:
false
Return
bool Whether textdomain was unloaded.
Source
File: wp-includes/l10n.php. View all references
function unload_textdomain( $domain, $reloadable = false ) {
global $l10n, $l10n_unloaded;
$l10n_unloaded = (array) $l10n_unloaded;
/**
* Filters whether to override the text domain unloading.
*
* @since 3.0.0
* @since 6.1.0 Added the `$reloadable` parameter.
*
* @param bool $override Whether to override the text domain unloading. Default false.
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
* @param bool $reloadable Whether the text domain can be loaded just-in-time again.
*/
$plugin_override = apply_filters( 'override_unload_textdomain', false, $domain, $reloadable );
if ( $plugin_override ) {
if ( ! $reloadable ) {
$l10n_unloaded[ $domain ] = true;
}
return true;
}
/**
* Fires before the text domain is unloaded.
*
* @since 3.0.0
* @since 6.1.0 Added the `$reloadable` parameter.
*
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
* @param bool $reloadable Whether the text domain can be loaded just-in-time again.
*/
do_action( 'unload_textdomain', $domain, $reloadable );
if ( isset( $l10n[ $domain ] ) ) {
unset( $l10n[ $domain ] );
if ( ! $reloadable ) {
$l10n_unloaded[ $domain ] = true;
}
return true;
}
return false;
}
Hooks
- apply_filters( 'override_unload_textdomain',
bool $override ,string $domain ,bool $reloadable ) -
Filters whether to override the text domain unloading.
- do_action( 'unload_textdomain',
string $domain ,bool $reloadable ) -
Fires before the text domain is unloaded.
Related
Uses
| Uses | Description |
|---|---|
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
| do_action() wp-includes/plugin.php | Calls the callback functions that have been added to an action hook. |
Used By
| Used By | Description |
|---|---|
| WP_Locale_Switcher::load_translations() wp-includes/class-wp-locale-switcher.php | Load translations for a given locale. |
| load_default_textdomain() wp-includes/l10n.php | Loads default translated strings based on locale. |
| wp_timezone_choice() wp-includes/functions.php | Gives a nicely-formatted list of timezone strings. |
Changelog
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/unload_textdomain