Skip to content

Commit

Permalink
Do not translate plugin data
Browse files Browse the repository at this point in the history
When retrieving plugin data, translation is no longer used. This used to cause the plugin's text domain to be loaded. It caused weird situations when working with and overriding WP i18n. Example:

You need to override the translation file using `override_load_textdomain`. For this, you need the name of the text domain to override translations for, so as not to affect other plugins/themes. You decide to retrieve the plugin's text domain by using the plugin created by this plugin factory. This loaded the text domain, which caused your override to be bypassed: you are still in the process of registering it.

Now, the factory no longer causes the plugin text domain to load, and you can safely load it later at a time convenient for you.
  • Loading branch information
XedinUnknown committed Oct 13, 2023
1 parent 179d0c5 commit 21bc00e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/FilePathPluginFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function createPluginFromFilePath(string $filePath): PluginInterface
);
}

$pluginData = get_plugin_data($filePath);
$pluginData = get_plugin_data($filePath, true, false);
if (empty($pluginData)) {
throw new UnexpectedValueException(
sprintf(
Expand Down

0 comments on commit 21bc00e

Please sign in to comment.