PHP Notice: Function _load_textdomain_just_in_time was called incorrectly
-
Hi there,
I’m running WordPress 6.7.0 and I’ve started seeing the following PHP Notice in my debug log whenever your plugin loads:
PHP Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the “<your-textdomain>” domain was triggered too early. Translations should be loaded at the init action or later. (This message was added in version 6.7.0.) in /…/wp-includes/functions.php on line 6121What’s happening:
WordPress 6.7 introduced a just-in-time translation loader that expects all calls to load a plugin’s textdomain to occur at or after theinithook. If your code calls_load_textdomain_just_in_time()(or internally triggers translation loading) on plugin-file load, WP throws this notice.Why it matters:
- Early translation loading can lead to missing strings or conflicts with other plugins/themes that haven’t initialized yet.
- It clutters debug logs, making it harder to spot real errors.
How to fix:
Wrap yourload_plugin_textdomain()(or equivalent) call in aninitcallback, for example:add_action( 'init', function() { load_plugin_textdomain( '<your-textdomain>', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); }, 5 );This ensures translations are loaded at the correct time in WordPress’s lifecycle.
I hope this helps! Please let me know if you need any further details.
Thanks for all your hard work on the plugin!
The topic ‘PHP Notice: Function _load_textdomain_just_in_time was called incorrectly’ is closed to new replies.