[wp-trac] [WordPress Trac] #62462: Revert _doing_it_wrong warning when loading translations early
WordPress Trac
noreply at wordpress.org
Mon Nov 18 17:01:31 UTC 2024
#62462: Revert _doing_it_wrong warning when loading translations early
-------------------------------+--------------------
Reporter: TimothyBlynJacobs | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 6.7.1
Component: I18N | Version: 6.7
Severity: normal | Keywords:
Focuses: |
-------------------------------+--------------------
In #44937 we started emitting a `_doing_it_wrong` notice when a plugin
calls a translation function before `after_setup_theme`.
It is almost always incorrect to load those translations early.
When called before `pluggable.php` is loaded, we don't yet have access to
the current user, so the translations will never be loaded in the current
user's domain in WP-Admin.
When called on `plugins_loaded`, the user will be forced to load early,
which can lead to filters being called at unexpected times which can
potentially lead to breakage.
The addition of the `_doing_it_wrong` warning has undoubtedly revealed
some plugins doing things that are obviously wrong. The
[https://make.wordpress.org/core/2024/10/21/i18n-improvements-6-7/ make
post] explains some of these.
However, it effectively prevents plugins from making a "best effort"
chance at emitting a translated error message if they ''do'' need to kill
execution early. For instance, in the context of a Security plugin, or
when critical errors are encountered, and execution cannot continue.
From what I can tell, plugins are now forced to effectively emit messages
in English to prevent a warning from being issued.
In Core, we have `wp_load_translations_early` to be able to make this best
effort to communicate in a language the site owner can understand. I think
ideally, we'd explore something similar that plugin authors could
poptentially use to indicate they are also loading translations "early".
In lieu of that, I think we need to revert this in 6.7.1 and try again in
6.8 with such a mechanism in place.
I've tentatively milestoned this for 6.7.1 for visibility and discussion.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/62462>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list