| | |
| | | namespace JVBase\managers; |
| | | |
| | | use JVBase\registrar\Registrar; |
| | | use JVBase\utility\Features; |
| | | use JVBase\base\Site; |
| | | |
| | | if (!defined('ABSPATH')) { |
| | | exit; |
| | |
| | | { |
| | | $this->source = $source; |
| | | $this->cache = Cache::for('icons_' . $source, WEEK_IN_SECONDS); |
| | | $this->style = (array_key_exists('icons', JVB_SITE) && in_array(JVB_SITE['icons'], $this->styles)) |
| | | ? JVB_SITE['icons'] |
| | | : 'regular'; |
| | | $this->style = Site::icon(); |
| | | |
| | | $this->addMap(); |
| | | |
| | |
| | | 'apple-logo', |
| | | 'check-circle', |
| | | 'close-circle', |
| | | 'faders-horizontal', |
| | | 'cloud-slash', |
| | | 'exclamation-mark', |
| | | 'cloud-arrow-down', |
| | |
| | | // ] |
| | | ]; |
| | | |
| | | |
| | | // Add icons from content/taxonomy/user configs (like old behavior) |
| | | $configIcons = $this->getIconsFromConfigs(); |
| | | if (!empty($configIcons)) { |
| | |
| | | if (isset($allIcons[$this->source])) { |
| | | $icons = array_merge($icons, $allIcons[$this->source]); |
| | | } |
| | | |
| | | if (!empty($icons)) { |
| | | $this->include($icons); |
| | | } |
| | |
| | | $map = [ |
| | | 'seo' => 'robot' |
| | | ]; |
| | | if (Features::forSite()->has('referrals')) { |
| | | if (Site::has('referrals')) { |
| | | $map['referrals'] = 'hand-heart'; |
| | | } |
| | | if (Features::forSite()->has('dashboard')) { |
| | | if (Site::has('dashboard')) { |
| | | $map['dash'] = 'door'; |
| | | } |
| | | if (Features::forSite()->has('magicLink')) { |
| | | if (Site::has('magicLink')) { |
| | | $map['magicLink'] = 'magic-wand'; |
| | | } |
| | | if (Features::hasAnyIntegration()) { |
| | | if (Site::hasAnyIntegration()) { |
| | | $map['integrations'] = 'plugs-connected'; |
| | | } |
| | | update_option(BASE.'iconMap', $map); |
| | |
| | | protected function registerGlobalHooks(): void |
| | | { |
| | | add_action('wp_loaded', [self::class, 'checkCSS']); |
| | | add_action('shutdown', [self::class, 'checkCSS']); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public function get(string $name, array $options = []): string |
| | | { |
| | | if ($name === '') { |
| | | if (empty($name)) { |
| | | //No icon requested |
| | | return ''; |
| | | } |
| | |
| | | /** |
| | | * Get raw SVG content for CSS mask-image |
| | | */ |
| | | protected function getRawSvg(string $name, ?string $style = null): ?string |
| | | public function getRawSvg(string $name, ?string $style = null): ?string |
| | | { |
| | | if (!$style) { |
| | | $style = $this->style; |
| | |
| | | foreach ($names as $icon) { |
| | | $svg = $this->getEncodedSVG($icon, $style); |
| | | if ($svg !== '') { |
| | | if ($icon === 'caret-down') { |
| | | $css .= 'details summary::after,'; |
| | | } elseif ($icon === 'faders-horizontal') { |
| | | $css .= 'details.all-filters summary::after,'; |
| | | } elseif ($icon === 'link') { |
| | | $css .= 'input[type=url],'; |
| | | } elseif ($icon === apply_filters('jvbSeparatorLogo', 'logo')) { |
| | | $css .= 'hr.logo::before,'; |
| | | } |
| | | $css .= ".icon-{$icon}{$styleClass}{"; |
| | | $css .= "--icon:url('data:image/svg+xml;base64,{$svg}');"; |
| | | $css .= "}"; |
| | |
| | | if (!$style) { |
| | | $style = $this->style; |
| | | } |
| | | |
| | | $icon = $this->map[$icon] ?? $icon; |
| | | |
| | | // Validate icon exists |
| | | if (!$this->iconExists($icon, $style)) { |
| | | error_log('[IconsManager] Icon not found: ' . $icon); |
| | | return ''; |
| | | } |
| | | $svg = $this->getEncodedSVG($icon, $style); |
| | | if ($svg !== '') { |
| | | return "data:image/svg+xml;base64,{$svg}"; |