Skip to content

[Bug]: Translation Loading Warning in WordPress 6.7.0 #94

@kishanjasani

Description

@kishanjasani

Description of the bug

After updating to WordPress 6.7.0, a notice appears indicating that translation loading for the inpsyde-google-tag-manager text domain is triggered too early. The function load_plugin_textdomain() is currently called within the plugins_loaded hook, but WordPress now enforces that translations should be loaded at the init hook or later.

This results in the following notice:

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the inpsyde-google-tag-manager 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.

To resolve this issue, the load_plugin_textdomain() call should be moved to the init hook.

Reproduction instructions

  1. Install and activate the inpsyde-google-tag-manager plugin on WordPress 6.7.0 or later.
  2. Enable WP_DEBUG mode in wp-config.php:
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', true);
  1. Load any admin or frontend page.
  2. Observe the PHP notice in the debug log or on-screen.

Expected behavior

The plugin should load translations without triggering any notices or warnings.

Environment info

  • Package version: Latest plugin(2.2.0) and WordPress version(6.7.2)
  • Browser: Chrome
  • OS: MacOS

Relevant log output

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the inpsyde-google-tag-manager 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.

Additional context

Solution:

  • Move translation loading to the init hook and remove it from plugins_loaded.
add_action('init', function () {
    load_plugin_textdomain('inpsyde-google-tag-manager');
});

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions