From c195f01346e182b562a65b963b7723c43da2a861 Mon Sep 17 00:00:00 2001 From: Nate Wright Date: Fri, 15 Nov 2024 16:54:42 +0000 Subject: [PATCH] pkp/pkp-lib#10616 Add ThemePlugin function to get localized theme option value --- classes/plugins/ThemePlugin.inc.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/classes/plugins/ThemePlugin.inc.php b/classes/plugins/ThemePlugin.inc.php index 5d0ef15afe6..068daf4e67a 100644 --- a/classes/plugins/ThemePlugin.inc.php +++ b/classes/plugins/ThemePlugin.inc.php @@ -460,6 +460,22 @@ public function getOption($name) { return isset($option->default) ? $option->default : null; } + /** + * Get the localized value of an option + * + * @param string $name The name of the option + * @param string $localeKey (Optional) Get the value for a specific locale. + * If unset, it will return the current locale + */ + public function getLocalizedOption($name, $localeKey = null) + { + $localeKey = $localeKey ?? AppLocale::getLocale(); + $value = $this->getOption($name); + return is_array($value) && isset($value[$localeKey]) + ? $value[$localeKey] + : null; + } + /** * Get an option's configuration settings *