unload_textdomain

The timeline below displays how wordpress function unload_textdomain has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.5

/**
 * Unloads translations for a text domain.
 *
 * @since 3.0.0
 * @since 6.1.0 Added the `$reloadable` parameter.
 *
 * @global MO[] $l10n          An array of all currently loaded text domains.
 * @global MO[] $l10n_unloaded An array of all text domains that have been unloaded again.
 *
 * @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.
 * @return bool Whether textdomain was unloaded.
 */
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);
    // Since multiple locales are supported, reloadable text domains don't actually need to be unloaded.
    if (!$reloadable) {
        WP_Translation_Controller::get_instance()->unload_textdomain($domain);
    }
    if (isset($l10n[$domain])) {
        if ($l10n[$domain] instanceof NOOP_Translations) {
            unset($l10n[$domain]);
            return false;
        }
        unset($l10n[$domain]);
        if (!$reloadable) {
            $l10n_unloaded[$domain] = true;
        }
        return true;
    }
    return false;
}

WordPress Version: 6.3

/**
 * Unloads translations for a text domain.
 *
 * @since 3.0.0
 * @since 6.1.0 Added the `$reloadable` parameter.
 *
 * @global MO[] $l10n          An array of all currently loaded text domains.
 * @global MO[] $l10n_unloaded An array of all text domains that have been unloaded again.
 *
 * @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.
 * @return bool Whether textdomain was unloaded.
 */
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])) {
        if ($l10n[$domain] instanceof NOOP_Translations) {
            unset($l10n[$domain]);
            return false;
        }
        unset($l10n[$domain]);
        if (!$reloadable) {
            $l10n_unloaded[$domain] = true;
        }
        return true;
    }
    return false;
}

WordPress Version: 6.1

/**
 * Unloads translations for a text domain.
 *
 * @since 3.0.0
 * @since 6.1.0 Added the `$reloadable` parameter.
 *
 * @global MO[] $l10n          An array of all currently loaded text domains.
 * @global MO[] $l10n_unloaded An array of all text domains that have been unloaded again.
 *
 * @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.
 * @return bool Whether textdomain was unloaded.
 */
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;
}

WordPress Version: 5.1

/**
 * Unload translations for a text domain.
 *
 * @since 3.0.0
 *
 * @global MO[] $l10n          An array of all currently loaded text domains.
 * @global MO[] $l10n_unloaded An array of all text domains that have been unloaded again.
 *
 * @param string $domain Text domain. Unique identifier for retrieving translated strings.
 * @return bool Whether textdomain was unloaded.
 */
function unload_textdomain($domain)
{
    global $l10n, $l10n_unloaded;
    $l10n_unloaded = (array) $l10n_unloaded;
    /**
     * Filters whether to override the text domain unloading.
     *
     * @since 3.0.0
     *
     * @param bool   $override Whether to override the text domain unloading. Default false.
     * @param string $domain   Text domain. Unique identifier for retrieving translated strings.
     */
    $plugin_override = apply_filters('override_unload_textdomain', false, $domain);
    if ($plugin_override) {
        $l10n_unloaded[$domain] = true;
        return true;
    }
    /**
     * Fires before the text domain is unloaded.
     *
     * @since 3.0.0
     *
     * @param string $domain Text domain. Unique identifier for retrieving translated strings.
     */
    do_action('unload_textdomain', $domain);
    if (isset($l10n[$domain])) {
        unset($l10n[$domain]);
        $l10n_unloaded[$domain] = true;
        return true;
    }
    return false;
}

WordPress Version: 4.6

/**
 * Unload translations for a text domain.
 *
 * @since 3.0.0
 *
 * @global array $l10n          An array of all currently loaded text domains.
 * @global array $l10n_unloaded An array of all text domains that have been unloaded again.
 *
 * @param string $domain Text domain. Unique identifier for retrieving translated strings.
 * @return bool Whether textdomain was unloaded.
 */
function unload_textdomain($domain)
{
    global $l10n, $l10n_unloaded;
    $l10n_unloaded = (array) $l10n_unloaded;
    /**
     * Filters whether to override the text domain unloading.
     *
     * @since 3.0.0
     *
     * @param bool   $override Whether to override the text domain unloading. Default false.
     * @param string $domain   Text domain. Unique identifier for retrieving translated strings.
     */
    $plugin_override = apply_filters('override_unload_textdomain', false, $domain);
    if ($plugin_override) {
        $l10n_unloaded[$domain] = true;
        return true;
    }
    /**
     * Fires before the text domain is unloaded.
     *
     * @since 3.0.0
     *
     * @param string $domain Text domain. Unique identifier for retrieving translated strings.
     */
    do_action('unload_textdomain', $domain);
    if (isset($l10n[$domain])) {
        unset($l10n[$domain]);
        $l10n_unloaded[$domain] = true;
        return true;
    }
    return false;
}

WordPress Version: 4.3

/**
 * Unload translations for a text domain.
 *
 * @since 3.0.0
 *
 * @global array $l10n
 *
 * @param string $domain Text domain. Unique identifier for retrieving translated strings.
 * @return bool Whether textdomain was unloaded.
 */
function unload_textdomain($domain)
{
    global $l10n;
    /**
     * Filter the text domain for loading translation.
     *
     * @since 3.0.0
     *
     * @param bool   $override Whether to override unloading the text domain. Default false.
     * @param string $domain   Text domain. Unique identifier for retrieving translated strings.
     */
    $plugin_override = apply_filters('override_unload_textdomain', false, $domain);
    if ($plugin_override) {
        return true;
    }
    /**
     * Fires before the text domain is unloaded.
     *
     * @since 3.0.0
     *
     * @param string $domain Text domain. Unique identifier for retrieving translated strings.
     */
    do_action('unload_textdomain', $domain);
    if (isset($l10n[$domain])) {
        unset($l10n[$domain]);
        return true;
    }
    return false;
}

WordPress Version: 3.9

/**
 * Unload translations for a text domain.
 *
 * @since 3.0.0
 *
 * @param string $domain Text domain. Unique identifier for retrieving translated strings.
 * @return bool Whether textdomain was unloaded.
 */
function unload_textdomain($domain)
{
    global $l10n;
    /**
     * Filter the text domain for loading translation.
     *
     * @since 3.0.0
     *
     * @param bool   $override Whether to override unloading the text domain. Default false.
     * @param string $domain   Text domain. Unique identifier for retrieving translated strings.
     */
    $plugin_override = apply_filters('override_unload_textdomain', false, $domain);
    if ($plugin_override) {
        return true;
    }
    /**
     * Fires before the text domain is unloaded.
     *
     * @since 3.0.0
     *
     * @param string $domain Text domain. Unique identifier for retrieving translated strings.
     */
    do_action('unload_textdomain', $domain);
    if (isset($l10n[$domain])) {
        unset($l10n[$domain]);
        return true;
    }
    return false;
}

WordPress Version: 3.7

/**
 * Unload translations for a text domain.
 *
 * @since 3.0.0
 *
 * @param string $domain Text domain. Unique identifier for retrieving translated strings.
 * @return bool Whether textdomain was unloaded.
 */
function unload_textdomain($domain)
{
    global $l10n;
    /**
     * Filter text text domain for loading translation.
     *
     * @since 3.0.0
     *
     * @param boolean        Whether to override unloading the text domain. Default false.
     * @param string $domain Text domain. Unique identifier for retrieving translated strings.
     */
    $plugin_override = apply_filters('override_unload_textdomain', false, $domain);
    if ($plugin_override) {
        return true;
    }
    /**
     * Fires before the text domain is unloaded.
     *
     * @since 3.0.0
     *
     * @param string $domain Text domain. Unique identifier for retrieving translated strings.
     */
    do_action('unload_textdomain', $domain);
    if (isset($l10n[$domain])) {
        unset($l10n[$domain]);
        return true;
    }
    return false;
}