phpwordpress

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

Solution

  • 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, load_plugin_textdomain, or load_theme_textdomain 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 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.