Silence "Translation Loading Triggered Too Early" Notices
Hides the "_load_textdomain_just_in_time was called incorrectly" debug notice (added in WordPress 6.7) for plugins you cannot fix yourself, keeping debug logs readable.
Opens WPIDE on
Code
$wpide_domains = array(); // e.g. array( 'some-plugin' ). Empty = all domains.
add_filter( 'doing_it_wrong_trigger_error', function ( $trigger, $function_name, $message ) use ( $wpide_domains ) {
if ( '_load_textdomain_just_in_time' !== $function_name ) {
return $trigger;
}
if ( ! $wpide_domains ) {
return false;
}
foreach ( $wpide_domains as $domain ) {
if ( false !== strpos( $message, '<code>' . $domain . '</code>' ) ) {
return false;
}
}
return $trigger;
}, 10, 3 );
Notes
List the text domains to silence in $wpide_domains, or leave it empty to silence the notice for all of them. Report the issue to the plugin author too.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.