[wp-trac] [WordPress Trac] #49807: load_plugin_textdomain() expects a path relative to plugins/, making i18n for mu-plugins difficult
WordPress Trac
noreply at wordpress.org
Sat Apr 4 15:13:52 UTC 2020
#49807: load_plugin_textdomain() expects a path relative to plugins/, making i18n
for mu-plugins difficult
--------------------------+-----------------------------
Reporter: theMikeD | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: I18N | Version:
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
Looking though the code for `load_plugin_textdomain()`
(https://core.trac.wordpress.org/browser/tags/5.4/src/wp-
includes/l10n.php#L797) I can see that it is expecting to receive a path
relative to the plugins folder, as defined by `WP_PLUGIN_DIR`.
All fine as long as the plugin is located within the folder defined by
`WP_PLUGIN_DIR`...but mu-plugins are not; they are typically in a folder
parallel to `WP_PLUGIN_DIR` but they can be anywhere via the
`WPMU_PLUGIN_DIR` define.
This makes it very difficult to add a text domain to a mu-plugin, since
the only way I have so far found is to pass a relative folder, such as
`../mu-plugins/plugin-folder/languages`, which is problematic because it's
making assumptions about the setup.
Together with the apparently missing easy way to determine if a plugin is
loaded normally or as part of the must-use loader, it's impossible to
write `load_plugin_textdomain()` in a generic way that accounts for mu-
plugins.
The solution would seem to be to un-deprecate the second argument, but I'm
not aware of the discussion around why it was removed.
I hope someone can point out something easy I have overlooked!
--
Ticket URL: <https://core.trac.wordpress.org/ticket/49807>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list