Skip to content

Commit

Permalink
Avoid loading translations too early (#56)
Browse files Browse the repository at this point in the history
* Avoid loading translations too early

Signed-off-by: Moritz Meißelbach <m.meisselbach@inpsyde.com>

* Update Properties.md

Signed-off-by: Moritz Meißelbach <m.meisselbach@inpsyde.com>

* Fix typo

Signed-off-by: Moritz Meißelbach <m.meisselbach@inpsyde.com>

* Only skip translations if loaded early.

Add tests and improve docs

* Revert "Only skip translations if loaded early."

This reverts commit 2108ee2.

---------

Signed-off-by: Moritz Meißelbach <m.meisselbach@inpsyde.com>
  • Loading branch information
Biont authored Nov 28, 2024
1 parent 171dd96 commit 372a915
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion docs/Properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ Additionally, PluginProperties will have the following public API:
- `PluginProperties::isNetworkActive(): bool` - returns if the current Plugin is network-wide active.
- `PluginProperties::isMuPlugin(): bool` - returns if the current Plugin is a must-use Plugin.


Please note that our usage of `get_plugin_data` opts out of translations and HTML-safe text processing (via `wptexturize`) offered by default.
These functions should not be used before the 'init' hook which may be too late for some applications.

## ThemeProperties

Expand Down
5 changes: 3 additions & 2 deletions src/Properties/PluginProperties.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ protected function __construct(string $pluginMainFile)
}

// $markup = false, to avoid an incorrect early wptexturize call.
// We also probably don't want HTML here anyway
// $translate = false, to avoid loading translations too early
// @see https://core.trac.wordpress.org/ticket/49965
$pluginData = (array) get_plugin_data($pluginMainFile, false);
// @see https://core.trac.wordpress.org/ticket/34114
$pluginData = (array) get_plugin_data($pluginMainFile, false, false);
$properties = Properties::DEFAULT_PROPERTIES;

// Map pluginData to internal structure.
Expand Down

0 comments on commit 372a915

Please sign in to comment.