diff --git a/is_themecore/src/Core/Smarty/SmartyHelperFunctions.php b/is_themecore/src/Core/Smarty/SmartyHelperFunctions.php index ab209ff..a28ea5f 100644 --- a/is_themecore/src/Core/Smarty/SmartyHelperFunctions.php +++ b/is_themecore/src/Core/Smarty/SmartyHelperFunctions.php @@ -4,6 +4,7 @@ namespace Oksydan\Module\IsThemeCore\Core\Smarty; use Oksydan\Module\IsThemeCore\Core\Webp\WebpPictureGenerator; use Oksydan\Module\IsThemeCore\Form\Settings\WebpConfiguration; +use PrestaShop\PrestaShop\Core\Util\ColorBrightnessCalculator; class SmartyHelperFunctions { @@ -189,4 +190,9 @@ class SmartyHelperFunctions return $content; } + public static function isBright($hexColor) + { + $calculator = new ColorBrightnessCalculator(); + return $calculator->isBright($hexColor); + } } diff --git a/is_themecore/src/Hook/Smarty.php b/is_themecore/src/Hook/Smarty.php index 368380b..7a9fc00 100644 --- a/is_themecore/src/Hook/Smarty.php +++ b/is_themecore/src/Hook/Smarty.php @@ -51,5 +51,10 @@ public function hookActionDispatcherBefore(): void } else { return; } + if (!isset($this->context->smarty->registered_plugins['modifier']['is_bright'])) { + $this->context->smarty->registerPlugin('modifier', 'is_bright', ['Oksydan\Module\IsThemeCore\Core\Smarty\SmartyHelperFunctions', 'isBright']); + } else { + return; + } } }