share
Stack OverflowNotice: Function _load_textdomain_just_in_time was called incorrectly
[+27] [7] Hossein
[2024-11-18 04:37:55]
[ php wordpress ]
[ https://stackoverflow.com/questions/79198701/notice-function-load-textdomain-just-in-time-was-called-incorrectly ]

After updating to WordPress 6.7, I’m receiving the following PHP notice on my website. How can I resolve this issue?

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the blahblah domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /wp-includes/functions.php on line 6114
(1) Supplementary, this error is thrown in line 6114 of wp-includes/functions.php. I would like to surpress it for the time being in local and staging. So it's possible to add 6114-6116 if (! str_contains($message, '_load_textdomain_just_in_time') ) {trigger_error($message, $error_level);} but this is hacking core (oo-err). I'd like to use the hook add_filter( 'wp_trigger_error_run','suppress_text_domain_error',999, 2 ); function suppress_text_domain_error( $message, $error_level) {...} but this doesn't work. - Chris Pink
(2) There is discussion on WP for reverting the changes in 6.7 because of this causing to much noise in the debug logs. Also there was this suggested work around to make then doing_it_wrong shut up - didn't test to see if it works. - Ale
(1) @Ale - I can confirm that workaround plugin works. - butlerblog
If you have woocommerce, maybe you have encountered these notices filling logs on your development environments. On developer.woocomerce.com you can find details about how to mitigate this - slamora
@ChrisPink This is not a solution to the underlying error (which is discussed in full below), but you can suppress this particular log message by placing this code at the top of your wp-config file: set_error_handler(function ($errno, $errstr, $errfile, $errline) { if (strpos($errstr, '_load_textdomain_just_in_time') !== false) { return true; // Suppress this specific error. } return false; // Allow other errors to be logged. }, E_USER_NOTICE | E_NOTICE); - lancemonotone
add_action( 'doing_it_wrong_run', static function ( $function_name ) { if ( '_load_textdomain_just_in_time' === $function_name ) { debug_print_backtrace(); } } ); Add this code in the active theme functions.php - To identify from where it's triggering. - mujuonly
[+28] [2024-11-18 04:37:55] Hossein [ACCEPTED]

If You're a Website Owner

  1. Try updating your themes and plugins, as the issue may already have been resolved by the developers.
  2. If the problem persists, report the issue to the plugin or theme authors so they can address it in a future update.
  3. To identify the plugin or theme causing the error, look for the text domain mentioned in the error message. For example, in the following message, blahblah is the text domain:

Translation loading for the blahblah domain.

If You're a Plugin / Theme Author

Check your textdomain registration code and make sure the function is set to init hook or later. By textdomain registration code I mean the load_textdomain [1], load_plugin_textdomain [2], or load_theme_textdomain [3] functions.

For example the following code is wrong and should get fixed.

add_action('plugins_loaded', function()
{
    load_plugin_textdomain('your-textdomain', false, '/path/to/your/plugin/languages/');
});

The following code is the correct one:

add_action('init', function()
{
    load_plugin_textdomain('your-textdomain', false, '/path/to/your/plugin/languages/');
});

Use of the get_plugin_data Function

If you are using the get_plugin_data [4] function before the WordPress init hook, you must pass false as the third parameter or adjust your code logic to ensure it runs after the init hook.

For more information you can check the https://make.wordpress.org/core/2024/10/21/i18n-improvements-6-7/ URL.

[1] https://developer.wordpress.org/reference/functions/load_textdomain/
[2] https://developer.wordpress.org/reference/functions/load_plugin_textdomain/
[3] https://developer.wordpress.org/reference/functions/load_theme_textdomain/
[4] https://developer.wordpress.org/reference/functions/get_plugin_data/

I get this message when I use the function “get_plugin_data” with a corresponding include on “wp-admin/includes/plugin.php”. But I need this for administration and upgrade purposes. - Regnalf
@Regnalf, open your own question if you need help. - mmm
Correct code is missing semicolon after closing load_plugin_textdomain bracket - neilgee
@neilgee Thanks for your report. It's added. - Hossein
(1) Any suggestion for cases where 'load_plugin_textdomain' IS being called via the 'init' action hook but STILL resulting in this error? - Philip Ingram
Appears that __() was the culprit, even if 'load_plugin_textdomain' IS being called via the 'init' action hook, instances of __() translate function may be called earlier and result in the same error. For some plugins, this is quite the effort to refactor. - Philip Ingram
1
[+9] [2025-07-28 19:04:09] Alberto

I found a solution that helped me trace the function that was generating an error. Here is the method I used.

The basic idea is to temporarily modify the WordPress core file responsible for loading text domains to log a full function backtrace whenever your specific text domain is called. This will show you exactly what part of your theme or plugin is responsible.

This should only be done for temporary debugging on a development or staging environment. Remember to remove the code after you are done.

  1. Open the file wp-includes/l10n.php.

  2. Find the function _load_textdomain_just_in_time (it's around line 1350 in recent WordPress versions).

  3. Add the following code at the beginning of the function or anywhere before the _doing_it_wrong() function call. Make sure to add your own textdomain "[textdomain]" to the text domain you are debugging.

    if ($domain == "[texdomain]") {
    
        // Start output buffering to capture the backtrace string
        ob_start();
    
        // The DEBUG_BACKTRACE_IGNORE_ARGS option prevents dumping
        // potentially large argument values, keeping the log concise.
        debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
    
        // Get the captured backtrace content and clean the buffer
        $trace = ob_get_clean();
    
        // Format the final log message
        $log_message = "ERROR: Early textdomain call for '" . $domain . "'\n";
        $log_message .= "Stack Trace:\n" . $trace . "\n";
        $log_message .= "--------------------------------------------------\n";
    
        // Write the message to the server's error log.
        // The location of this log file depends on your server's PHP configuration.
        error_log($log_message);  }
    
    
    

After uploading that code, I refreshed my page. The stack trace in my PHP error log pointed me to the exact string that was generating the error.

The problem was that the line below was being loaded in the theme customizer, which was happening way too early. As a temporary fix to stop the error, I removed the translation function:

//'footer_text' => __('All rights reserved.', '[textdomain]' ),
'footer_text' => 'All rights reserved.',


(2) There goes my hero, watch him as he goes - Jeramiah Harland
Thank you so much! Your solution allowed me to find the source of the problem: uses of the location function "__(", too early in the actions of my theme. - Fadupla
2
[+7] [2024-11-22 17:12:44] Tiago

I manage a lot of websites. Basically, after Wordpres 6.7 update, a few websites which had 'WP_DEBUG' as true, started to show errors about _load_textdomain_just_in_time.

It is happening with a lot of plugins.


How do I fix it - Ian Samz
I was able to fix it by changing my wp-config.php line for WP_DEBUG was set to false, for example: define('WP_DEBUG', false); - Benson
(11) @Benson you have just hide error, Actually error is not solved. - Niranjan Gondaliya
Yes, good point, @Niranjan Gondaliya the error is not resolved, but hidden. However, for live sites, with some templates, the error will kill the website. Hiding the error is the best solution on live sites. As Niranjan Gondaliya infers, it's best to resolve this error by showing it on a development version of your site to fully resolve this error. - Benson
Yes right @Benson - Niranjan Gondaliya
This was the less intrusive fix for me. Updated a theme and it errored. But was forgotten the WP_DEBUG was still enable for a live website. - xor-gate
3
[+6] [2024-11-18 18:18:20] user3788100

Lots of plugins are seeing this error NOT caused by incorrect text domain loading, but by other WordPress functions.

My plugin was using 'get_plugin_data' and getting was this error. I am still seeing it for other WP functions.

I replaced 'get_plugin_data' with

$plugin_data = get_file_data(ABSPATH . 'wp-content/plugins/bbpress/bbpress.php', array('Version' => 'Version'), false);

as a workaround.

But major plugins such as woocommerce (8 million installations)and really simple security (4 million installations) are seeing issues, and I gather it has been raised for a WP fix, rather than forcing plugin authors to work round it.

https://developer.woocommerce.com/2024/11/11/developer-advisory-translation-loading-changes-in-wordpress-6-7/


(3) You can still use get_plugin_data, just with the third parameter set to false. Seee make.wordpress.org/core/2024/10/21/i18n-improvements-6-7 - swissspidy
4
[+1] [2025-04-17 14:21:19] coder618

To fix this issue in your plugin use the following code:

add_action('init', function(){
    $mo = 'YOURTEXTDOMAIN-'. determine_locale() . '.mo';
    $path = plugin_dir_path(__FILE__) . 'languages/' .$mo ;
    load_textdomain( 'YOURTEXTDOMAIN', $path  );
});
;

Please note the path should point to the full path of the file.

So you may need to modify it if your .mo file located in a different directory.


5
[+1] [2025-06-09 07:20:10] Badan

The warning is basically saying that a WordPress translation function, e.g. __() or _e() was called way too early. The warning was non-existent prior version 6.7, that is why a lot of plugins and themes triggered it.

If you are a website owner, update all your themes and plugins. Chances are that the developers have already fixed the issue. If you are plugin or theme author or maintaining a custom codebase, you need to make sure the translation functions do not run before the init or after_setup_theme hooks.

For further reading, I have written a detailed guide on how to fix it: How to Fix Function _load_textdomain_just_in_time was called incorrectly [1]

[1] https://nasiothemes.com/how-to-fix-function-_load_textdomain_just_in_time-was-called-incorrectly/

6
[-6] [2024-11-23 09:05:00] tokach

What worked for me in similar situation:

  1. Go to File Editor, rename wp-content/plugins folder to whatever
  2. This allowed me to log in at /wp-admin
  3. Go to updates and reinstall wordpress even if it is most recent
  4. Go to plugins page, it will show you plugins are missing files
  5. Then go back to file editor, rename folder back to "plugins"
  6. Update all plugins

error should disappear


(2) If you needed to disable all of your plugins just to login to your site, then the problem was not related to this notice, for it is just a notice and not a fatal error that would stop you from logging in. - AuRise
I found this useful to understand where to look for the issue - Mitro
7