Main menu

loco_unload_early_textdomain

Prevent Loco Translate from removing early-loaded text domains

Read first: Why do I see warnings that translations are loaded too early?

Since v2.7.0 Loco Translate's loading helper forcefully removes any text domains that were loaded before it was allowed to start. This is necessary for custom translation files to be loaded.

Domain unloading is catch-all solution to the problem of early translation calls, made worse by a critical change in WordPress 6.7 which is unlikely to be reversed.

This filter allows our workaround to be disabled in the interests of performance. Here's an example where we restrict the fix to only one domain we know to be affected:

// Disallow domain unloading except for "naughty-plugin"...
add_filter('loco_unload_early_textdomain', function($allow,$domain){
    if( 'naughty-plugin' !== $domain ){
        return false;
    }
    return $allow;
}, 10, 2 );
Last updated by