Notice: Function _load_textdomain_just_in_time was called incorrectly
If you updated your site to WordPress 6.7 and immediately encountered a PHP notice regarding _load_textdomain_just_in_time, this is an intentional behavior change designed to improve translation performance, not a critical bug. The core team shifted text domain loading from the mupreinit hook (which fires before plugins and themes are fully loaded) to the init action. This ensures that translations only load when they are actually needed, preventing unnecessary memory overhead during the bootstrap process.
The error message explicitly states: "Translation loading for the blahblah domain was triggered too early." The phrase "blahblah" is a placeholder; in your logs, it will reflect the actual slug of your active theme or plugin. This notice appears in /wp-includes/functions.php because the function _load_textdomain_just_in_time() was invoked while the global $load_textdomain_just_in_time flag was false, indicating that the translation system wasn't ready yet.
To resolve this, you need to move your code execution to a later hook. The primary culprit is almost always a custom theme or plugin initializing its text domain on after_setup_theme, wp_loaded, or even directly in the constructor of a class extending WP_Error or similar base classes that hooks into early lifecycle events. While after_setup_theme is still valid for many setup tasks, relying on it to register a translation file is risky because the global $load_textdomain_just_in_time flag might not be set yet depending on how aggressively the core moved the loading logic. The safest approach is to hook your translation registration into the init action or later.
Consider this pattern for a plugin:
function my_plugin_load_translations() {
load_textdomain( 'my-plugin', dirname( MY_PLUGIN_PATH ) . '/languages/my-plugin.pot' );
}
add_action( 'init', __NAMESPACE__ . '\my_plugin_load_translations' );
This ensures that the function runs after WordPress has fully initialized its core hooks, guaranteeing that the translation loader is ready to accept the domain. If you are using a theme, ensure that your functions.php file does not call load_theme_textdomain() before after_setup_theme. While after_setup_theme is technically part of the setup phase, moving it explicitly to init aligns with the strict timing requirements introduced in 6.7.
Another common pitfall involves third-party plugins that attempt to load their own text domains via hooks like wp_register_translation_domain. These should also be deferred until init. If you are building a custom plugin and see this error, check your main file for any early calls to load_theme_textdomain or load_plugin_textdomain.
One trade-off to consider is that deferring translation loading slightly delays the availability of translated strings. However, in 99% of cases, this delay is negligible because the init hook fires very early in the request lifecycle. The performance gain from avoiding premature memory allocation for unused languages far outweighs this microsecond-level difference.
If you are unable to modify the code directlyâfor instance, if the offending plugin is a core dependency or a third-party library you cannot updateâyou can temporarily suppress the notice by adding the following line to your wp-config.php file:
define( 'WP_DEBUG', false );
// Or specifically targeting this notice if WP_DEBUG is already true
remove_action( 'load-admin', '_load_textdomain_just_in_time' );
However, suppressing the symptom without fixing the cause is rarely a long-term strategy. The underlying issue remains that your code is trying to access translation resources before WordPress has prepared them. Until the upstream developer corrects their hook timing, you may experience inconsistent translation behavior or unexpected fallbacks to English in specific contexts where the domain isn't loaded yet.
For developers building on top of WordPress, this change reinforces a best practice: treat the bootstrap process as a sequence of strict phases. Early hooks like mupreinit and wp_loaded are for structural setup; functional logic, including internationalization, belongs in init or later. If you are maintaining legacy code from pre-6.7 versions, this error is your signal to refactor those early hooks immediately.
If you are looking for enterprise-grade solutions to handle complex multi-language setups with strict performance requirements, resources like https://laravelcompany.com offer insights into how modern frameworks manage localization efficiently, though WordPress developers should stick to core patterns unless extending beyond standard themes and plugins.
