PHP error with WordPress 6.7 – Translation loading too early

[ad_1]

Hi,

There is a PHP error

[22-Nov-2024 10:36:33 UTC] PHP Notice:  Function _load_textdomain_just_in_time was called <strong>incorrectly</strong>. Translation loading for the <code>check-email</code> 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 <code>init</code> action or later. Please see <a href="https://developer.projectdmc.org/advanced-administration/debug/debug-wordpress/">Debugging in WordPress</a> for more information. (This message was added in version 6.7.0.) in \wp-includes\functions.php on line 6114
[22-Nov-2024 10:36:33 UTC] PHP Stack trace:
[22-Nov-2024 10:36:33 UTC] PHP 1. {main}() \wp-admin\index.php:0
[22-Nov-2024 10:36:33 UTC] PHP 2. require_once() \wp-admin\index.php:10
[22-Nov-2024 10:36:33 UTC] PHP 3. require_once() \wp-admin\admin.php:34
[22-Nov-2024 10:36:33 UTC] PHP 4. require_once() \wp-load.php:50
[22-Nov-2024 10:36:33 UTC] PHP 5. require_once() \wp-config.php:102
[22-Nov-2024 10:36:33 UTC] PHP 6. do_action($hook_name="plugins_loaded") \wp-settings.php:559
[22-Nov-2024 10:36:33 UTC] PHP 7. WP_Hook->do_action($args = [0 => '']) \wp-includes\plugin.php:517
[22-Nov-2024 10:36:33 UTC] PHP 8. WP_Hook->apply_filters($value="", $args = [0 => '']) \wp-includes\class-wp-hook.php:348
[22-Nov-2024 10:36:33 UTC] PHP 9. CheckEmail\Core\Check_Email_Log->load('') \wp-includes\class-wp-hook.php:324
[22-Nov-2024 10:36:33 UTC] PHP 10. CheckEmail\Core\UI\Check_Email_UI_Loader->load() \wp-content\plugins\check-email\include\Core\Check_Email_Log.php:56
[22-Nov-2024 10:36:33 UTC] PHP 11. CheckEmail\Core\UI\Check_Email_UI_Loader->initialize_components() \wp-content\plugins\check-email\include\Core\UI\Check_Email_UI_Loader.php:19
[22-Nov-2024 10:36:33 UTC] PHP 12. CheckEmail\Core\UI\Check_Email_UI_Loader->is_show_dashboard_widget() \wp-content\plugins\check-email\include\Core\UI\Check_Email_UI_Loader.php:33
[22-Nov-2024 10:36:33 UTC] PHP 13. CheckEmail\Core\UI\Setting\Check_Email_Setting->__construct() \wp-content\plugins\check-email\include\Core\UI\Check_Email_UI_Loader.php:40
[22-Nov-2024 10:36:33 UTC] PHP 14. CheckEmail\Core\UI\Setting\Check_Email_Core_Setting->initialize() \wp-content\plugins\check-email\include\Core\UI\Setting\Check_Email_Setting.php:15
[22-Nov-2024 10:36:33 UTC] PHP 15. esc_html__($text="Setup Wizard", $domain = 'check-email') \wp-content\plugins\check-email\include\Core\UI\Setting\Check_Email_Core_Setting.php:17
[22-Nov-2024 10:36:33 UTC] PHP 16. translate($text="Setup Wizard", $domain = 'check-email') \wp-includes\l10n.php:339
[22-Nov-2024 10:36:33 UTC] PHP 17. get_translations_for_domain($domain = 'check-email') \wp-includes\l10n.php:194
[22-Nov-2024 10:36:33 UTC] PHP 18. _load_textdomain_just_in_time($domain = 'check-email') \wp-includes\l10n.php:1408
[22-Nov-2024 10:36:33 UTC] PHP 19. _doing_it_wrong($function_name="_load_textdomain_just_in_time", $message="Translation loading for the <code>check-email</code> 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 <code>init</code> action or later.", $version = '6.7.0') \wp-includes\l10n.php:1370
[22-Nov-2024 10:36:33 UTC] PHP 20. wp_trigger_error($function_name="", $message="Function _load_textdomain_just_in_time was called <strong>incorrectly</strong>. Translation loading for the <code>check-email</code> 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 <code>init</code> action or later. Please see <a href="https://developer.projectdmc.org/advanced-administration/debug/debug-wordpress/">Debugging in WordPress</a> for more information. (This message was added in version 6.7.0."..., $error_level = *uninitialized*) \wp-includes\functions.php:6054
[22-Nov-2024 10:36:33 UTC] PHP 21. trigger_error($message="Function _load_textdomain_just_in_time was called <strong>incorrectly</strong>. Translation loading for the <code>check-email</code> 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 <code>init</code> action or later. Please see <a href="https://developer.projectdmc.org/advanced-administration/debug/debug-wordpress/">Debugging in WordPress</a> for more information. (This message was added in version 6.7.0."..., $error_level = 1024) \wp-includes\functions.php:6114

Indeed, load_plugin_textdomain must be called after init hook.

A fix would be for example replacing check-email\include\Core\Check_Email_Log.php line 51

load_plugin_textdomain( 'check-email', false, $this->translations_path );

with

$translations_path = $this->translations_path;
add_action( 'init', function() use ( $translations_path ) { load_plugin_textdomain( 'check-email', false, $translations_path ); }, 5 );

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer