My WordPress plugin is Network Only plugin and all my local tests on WordPress Multisite only, Since WordPress 6.7, I start to receive (Function _load_textdomain_just_in_time was called incorrectly) notice.
I moved the translation code from 'plugins_loaded' action to 'init' with very low priority but nothing help, finally, I created a single-site for test and I found that the plugin working properly without notices, and this notice only appears in WordPress Multisite.
I tried a lot and even moved the translation code from classes to the main .php file, but still generates that notice.
Because of the plugin working only in a certain site (determined by the user in a constant), I tried to check current blog using (get_current_blog_id) to ensure that the translation code triggered only in the correct site, But nothing help.
Here's my situation:
My Directories:
- pascalplugin
-- languages
-- pascalplugin-en_US.mo
-- pascalplugin-en_US.po
-- pascalplugin.pot
-- pascalplugin.php
pascalplugin.php
/**
* Plugin Name: PascalPlugin
* Version: 1.0.0
* Domain Path: /languages/
* Text Domain: pascalplugin
* Tested up to: 6.7
* Requires at least: 5.9
* Requires PHP: 7.0
* Network: true
*/
if ( ! defined( 'ABSPATH' ) ) {
die( 'You cannot access plugin\'s files directly' );
}
if( !defined('PASCALPLUGIN_TEXTDOMAIN') ) {
define( 'PASCALPLUGIN_TEXTDOMAIN', 'pascalplugin' );
}
if (!defined('PASCALPLUGIN__FILE__')) {
define( 'PASCALPLUGIN__FILE__', __FILE__ );
}
add_action('init', '__init_load_textdomain', 1);
function __init_load_textdomain() {
$dir = wp_normalize_path(dirname(PASCALPLUGIN__FILE__));
$basename = plugin_basename(PASCALPLUGIN__FILE__);
$basepath = trailingslashit(dirname($basename));
$lang_dir = trailingslashit($basepath . 'languages');
// Echo working properly and output "pascalplugin/languages/"
echo $lang_dir;
load_plugin_textdomain(PASCALPLUGIN_TEXTDOMAIN, false, $lang_dir);
}
My WordPress plugin is Network Only plugin and all my local tests on WordPress Multisite only, Since WordPress 6.7, I start to receive (Function _load_textdomain_just_in_time was called incorrectly) notice.
I moved the translation code from 'plugins_loaded' action to 'init' with very low priority but nothing help, finally, I created a single-site for test and I found that the plugin working properly without notices, and this notice only appears in WordPress Multisite.
I tried a lot and even moved the translation code from classes to the main .php file, but still generates that notice.
Because of the plugin working only in a certain site (determined by the user in a constant), I tried to check current blog using (get_current_blog_id) to ensure that the translation code triggered only in the correct site, But nothing help.
Here's my situation:
My Directories:
- pascalplugin
-- languages
-- pascalplugin-en_US.mo
-- pascalplugin-en_US.po
-- pascalplugin.pot
-- pascalplugin.php
pascalplugin.php
/**
* Plugin Name: PascalPlugin
* Version: 1.0.0
* Domain Path: /languages/
* Text Domain: pascalplugin
* Tested up to: 6.7
* Requires at least: 5.9
* Requires PHP: 7.0
* Network: true
*/
if ( ! defined( 'ABSPATH' ) ) {
die( 'You cannot access plugin\'s files directly' );
}
if( !defined('PASCALPLUGIN_TEXTDOMAIN') ) {
define( 'PASCALPLUGIN_TEXTDOMAIN', 'pascalplugin' );
}
if (!defined('PASCALPLUGIN__FILE__')) {
define( 'PASCALPLUGIN__FILE__', __FILE__ );
}
add_action('init', '__init_load_textdomain', 1);
function __init_load_textdomain() {
$dir = wp_normalize_path(dirname(PASCALPLUGIN__FILE__));
$basename = plugin_basename(PASCALPLUGIN__FILE__);
$basepath = trailingslashit(dirname($basename));
$lang_dir = trailingslashit($basepath . 'languages');
// Echo working properly and output "pascalplugin/languages/"
echo $lang_dir;
load_plugin_textdomain(PASCALPLUGIN_TEXTDOMAIN, false, $lang_dir);
}
Share
Improve this question
edited Feb 18 at 7:26
yivi
47.5k18 gold badges130 silver badges153 bronze badges
asked Feb 17 at 17:43
Hady ShaltoutHady Shaltout
6321 gold badge9 silver badges23 bronze badges
1 Answer
Reset to default 1This looks like a known issue and is undergoing active development
Internationalization improvements in 6.7
- #62175 closed defect (bug) (duplicate) PHP Notice in WP 6.7: _load_textdomain_just_in_time was called incorrectly
- #44937 closed enhancement (fixed) Add _doing_it_wrong to load_plugin_textdomain