diff --git a/Helper/AbstractData.php b/Helper/AbstractData.php index 6afce9b..fc366b7 100755 --- a/Helper/AbstractData.php +++ b/Helper/AbstractData.php @@ -29,9 +29,12 @@ use Magento\Framework\App\ObjectManager; use Magento\Framework\App\ProductMetadataInterface; use Magento\Framework\App\State; +use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\Json\Helper\Data as JsonHelper; use Magento\Framework\ObjectManagerInterface; use Magento\Framework\UrlInterface; +use Magento\Framework\View\Design\Theme\ThemeProviderInterface; +use Magento\Framework\View\DesignInterface; use Magento\Store\Model\ScopeInterface; use Magento\Store\Model\StoreManagerInterface; use Mageplaza\Core\Model\Config\Source\NoticeType; @@ -373,7 +376,7 @@ public static function extractBody($response_str) /** * getHtmlJqColorPicker * - * @param string $htmlId // id of the input html + * @param string $htmlId // id of the input html * @param string|null $value * * @return string @@ -398,4 +401,46 @@ public static function getHtmlJqColorPicker(string $htmlId, $value = '') HTML; } + + /** + * Return is Hyva Theme + * + * @return bool + */ + public function checkHyvaTheme() + { + try { + $themeCode = $this->getThemeCodeByCache(); + } catch (\Exception $e) { + try { + /** @var ThemeProviderInterface $themeProviderInterface */ + $themeProviderInterface = $this->objectManager->create(ThemeProviderInterface::Class); + $themeId = $this->storeManager->getStore()->getConfig('design/theme/theme_id'); + $theme = $themeProviderInterface->getThemeById($themeId); + $themeCode = $theme->getCode(); + } catch (NoSuchEntityException $noSuchEntityException) { + return false; + } + } + + if (str_contains($themeCode, 'Hyva')) { + return true; + } + + return false; + } + + /** + * GetThemeCode By Cache in DesignInterface + * + * @return string + */ + private function getThemeCodeByCache() + { + /** @var DesignInterface $themeProviderInterface */ + $themeProviderInterface = $this->objectManager->create(DesignInterface::Class); + $theme = $themeProviderInterface->getDesignTheme(); + + return $theme->getCode(); + } } diff --git a/composer.json b/composer.json index 750913a..1b3b213 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "mageplaza/module-core", "description": "Mageplaza Core for Magento 2", "type": "magento2-module", - "version": "1.5.7", + "version": "1.5.8", "license": "proprietary", "authors": [ {