[wp-trac] [WordPress Trac] #44937: Add _doing_it_wrong to load_plugin_textdomain
WordPress Trac
noreply at wordpress.org
Wed Oct 2 13:42:26 UTC 2024
#44937: Add _doing_it_wrong to load_plugin_textdomain
--------------------------------------+-------------------------
Reporter: garrett-eclipse | Owner: swissspidy
Type: enhancement | Status: closed
Priority: normal | Milestone: 6.7
Component: I18N | Version: 4.7
Severity: normal | Resolution: fixed
Keywords: has-patch needs-dev-note | Focuses:
--------------------------------------+-------------------------
Comment (by swissspidy):
In [changeset:"59157" 59157]:
{{{
#!CommitTicketReference repository="" revision="59157"
I18N: Do not load translations directly in `load_*_textdomain`.
In [59127], `_doing_it_wrong` warnings were added if plugins or themes
load translations too early, either through a manual function call or
just-in-time loading.
Because many plugins and themes still manually call
`load_plugin_textdomain()`, `load_theme_textdomain()` or
`load_muplugin_textdomain()`, even though they don't have to anymore, that
caused a lot of warnings.
With this new approach, these functions merely register the translations
path in the existing `WP_Textdomain_Registry` and do not immediately try
to load the translations anymore. The loading is all handled by the just-
in-time functionality.
This way, warnings will only be emitted if triggering the just-in-time
loading too early, greatly improving the developer experience and to a
degree also performance.
Props swissspidy, sergeybiryukov, mukesh27.
See #44937.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/44937#comment:38>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list