WordPress 6.7+ Compatibility: _load_textdomain_just_in_time notice for restrict-user-access domain
Description
Since WordPress 6.7, sites running Restrict User Access 2.8 with WP_DEBUG and WP_DEBUG_DISPLAY enabled see the following notice on every page load:
Notice: Function _load_textdomain_just_in_time was called incorrectly.
Translation loading for the restrict-user-access 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.
(This message was added in version 6.7.0.)
Root Cause
There are two contributing factors:
1. Freemius SDK hooks textdomain loading to plugins_loaded
In lib/freemius/includes/class-freemius.php around line 3464:
if ( 0 == did_action( 'plugins_loaded' ) ) {
add_action( 'plugins_loaded', array( 'Freemius', '_load_textdomain' ), 1 );
}
This calls load_plugin_textdomain('freemius', ...) during plugins_loaded, but WordPress 6.7+ expects textdomains to be loaded at init or later.
2. RUA_App constructor triggers __() calls before init
The RUA_App constructor is instantiated directly when the plugin file loads (via RUA_App::instance() in restrict-user-access.php). Several callbacks registered in the constructor use __('...', 'restrict-user-access') — for example in add_levels_to_visibility() (app.php, line 245). When these are triggered during plugins_loaded, WordPress's just-in-time textdomain loading kicks in too early, producing the notice.
Suggested Fix
For the Freemius SDK hook — change plugins_loaded to init:
// class-freemius.php, ~line 3464
if ( 0 == did_action( 'init' ) ) {
add_action( 'init', array( 'Freemius', '_load_textdomain' ), 1 );
}
For the RUA_App constructor — defer any code that uses __() with the restrict-user-access domain until init or later. Alternatively, the add_levels_to_visibility callback could lazy-load its translated strings.
Workaround
Until an official fix is released, users can suppress the specific notice with an MU-plugin:
<?php
// wp-content/mu-plugins/fix-rua-textdomain.php
add_filter('doing_it_wrong_trigger_error', function ($trigger, $function_name, $message) {
if ($function_name === '_load_textdomain_just_in_time'
&& strpos($message, 'restrict-user-access') !== false) {
return false;
}
return $trigger;
}, 10, 3);
Environment
- WordPress 6.7.0+
- Restrict User Access 2.8
- PHP 8.x
- WP_DEBUG + WP_DEBUG_DISPLAY enabled
- Any non-English locale (or any locale where just-in-time loading is triggered)
This is a widespread issue affecting many plugins since WP 6.7. Would be great to see it addressed in RUA as well. Thanks for the great plugin!
WordPress 6.7+ Compatibility: _load_textdomain_just_in_time notice for restrict-user-access domain
Description
Since WordPress 6.7, sites running Restrict User Access 2.8 with
WP_DEBUGandWP_DEBUG_DISPLAYenabled see the following notice on every page load:Root Cause
There are two contributing factors:
1. Freemius SDK hooks textdomain loading to
plugins_loadedIn
lib/freemius/includes/class-freemius.phparound line 3464:This calls
load_plugin_textdomain('freemius', ...)duringplugins_loaded, but WordPress 6.7+ expects textdomains to be loaded atinitor later.2. RUA_App constructor triggers
__()calls beforeinitThe
RUA_Appconstructor is instantiated directly when the plugin file loads (viaRUA_App::instance()inrestrict-user-access.php). Several callbacks registered in the constructor use__('...', 'restrict-user-access')— for example inadd_levels_to_visibility()(app.php, line 245). When these are triggered duringplugins_loaded, WordPress's just-in-time textdomain loading kicks in too early, producing the notice.Suggested Fix
For the Freemius SDK hook — change
plugins_loadedtoinit:For the RUA_App constructor — defer any code that uses
__()with therestrict-user-accessdomain untilinitor later. Alternatively, theadd_levels_to_visibilitycallback could lazy-load its translated strings.Workaround
Until an official fix is released, users can suppress the specific notice with an MU-plugin:
Environment
This is a widespread issue affecting many plugins since WP 6.7. Would be great to see it addressed in RUA as well. Thanks for the great plugin!