Skip to content

Commit

Permalink
Merge pull request #79 from mageplaza/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
chuccv authored Aug 14, 2024
2 parents 24aa3ea + e74f4e8 commit 403e02f
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
47 changes: 46 additions & 1 deletion Helper/AbstractData.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -398,4 +401,46 @@ public static function getHtmlJqColorPicker(string $htmlId, $value = '')
</script>
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();
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand Down

0 comments on commit 403e02f

Please sign in to comment.