[wp-trac] [WordPress Trac] #44937: Add _doing_it_wrong to load_plugin_textdomain
WordPress Trac
noreply at wordpress.org
Tue Oct 1 17:21:39 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):
If you don't need the plugin data to be translated, pass `false` as the
third argument to `get_plugin_data()`, e.g. `get_plugin_data(
'foo/bar.php', true, false )`. Then WordPress won't attempt to load the
translations.
First and foremost you should not be calling `get_plugin_data()` too
early. If you get a PHP notice because of it, it means you are calling it
before `after_setup_theme` or `init` fires. So if you move your call to
after `init`, these notices should not appear.
Hope that makes sense :-) Please let me know if you encounter any issues
while doing so.
There will be a dev-note post about this change as well where I'll try to
provide some concrete examples too.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/44937#comment:27>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list