Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP Notice _load_textdomain_just_in_time was called incorrectly #70

Open
cannobbio opened this issue Nov 14, 2024 · 9 comments
Open

PHP Notice _load_textdomain_just_in_time was called incorrectly #70

cannobbio opened this issue Nov 14, 2024 · 9 comments

Comments

@cannobbio
Copy link

WordPress 6.7 update PHP Notice:

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the wp-pagenavi 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

load_plugin_textdomain( 'wp-pagenavi' );

Possible fix:

add_action('init', function() {
    load_plugin_textdomain('wp-pagenavi');
});

Thank You!

@lesterchan
Copy link
Owner

Thanks @cannobbio, fixed 7fb9556

@muriukip
Copy link

Hi, I'm afraid I'm still getting this warning even after the fix

@muriukip
Copy link

I've created the following pull request to address this problem.
lesterchan/wp-scb-framework#1

@bolorino
Copy link

I can confirm @muriukip patch fixes the _load_textdomain_just_in_time notice.

Also, there is no need to use load_plugin_textdomain, except if you want to support old WordPress versions, so you could also get rid of this code in wp-pagenavi.php

add_action( 'init', 'pagenavi_textdomain' );
function pagenavi_textdomain() {
	load_plugin_textdomain( 'wp-pagenavi' );
}

@lesterchan
Copy link
Owner

@bolorino, can you explain why the code is not needed anymore? WP will now automatically call load_plugin_textdomain for plugins? Sorry been out of the community for too long lol.

@bolorino
Copy link

Sure @lesterchan

Since WordPress 4.6, plugins and themes no longer need load_plugin_textdomain() or load_theme_textdomain(). WordPress automatically loads the translations for you when needed.

https://make.wordpress.org/core/2024/10/21/i18n-improvements-6-7/

🙂

@lesterchan
Copy link
Owner

Wow since WP 4.6, is a TIL for me! Thanks for the tip. I will remove them.

@lesterchan
Copy link
Owner

I have released 2.94.3, hopefully it fixes this issue, thank you guys!

@lesterchan
Copy link
Owner

Hey guys, I have to revert to use plugins_loaded as it is breaking widgets from being loaded. I think removing load_plugin_textdomain should already fixed the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants