| | |
| | | private function __construct(string $source) |
| | | { |
| | | $this->source = $source; |
| | | $this->cache = Cache::for('icons_' . $source, WEEK_IN_SECONDS); |
| | | $this->cache = Cache::for('icons_' . $source); |
| | | $this->style = Site::icon(); |
| | | |
| | | $this->addMap(); |
| | |
| | | if (Site::has('dashboard')) { |
| | | $map['dash'] = 'door'; |
| | | } |
| | | if (Site::has('magicLink')) { |
| | | if (Site::has('magic_link')) { |
| | | $map['magicLink'] = 'magic-wand'; |
| | | } |
| | | if (Site::hasAnyIntegration()) { |
| | |
| | | $instance->archiveCurrentVersion($css); |
| | | |
| | | if (file_put_contents($css_path, $css) !== false) { |
| | | Cache::touch('icons_' . $source); |
| | | Cache::for('icons_'.$source)->flush(); |
| | | error_log("[IconsManager] Updated {$source}.css"); |
| | | } else { |
| | | error_log("[IconsManager] Could not write {$source}.css"); |
| | |
| | | $instance->archiveCurrentVersion($css); |
| | | |
| | | if (file_put_contents($css_path, $css) !== false) { |
| | | Cache::touch('icons_' . $source); |
| | | Cache::for('icons_'.$source)->flush(); |
| | | error_log("[IconsManager] Updated {$source}.css"); |
| | | } else { |
| | | error_log("[IconsManager] Could not write {$source}.css"); |
| | |
| | | /** |
| | | * 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; |
| | |
| | | |
| | | public function registerStyle(): void |
| | | { |
| | | $timestamp = Cache::lastModified('icons_' . $this->source); |
| | | $timestamp = Cache::for('icons_'.$this->source)->getTimestamp(); |
| | | $handle = 'jvb-icons-' . $this->source; |
| | | |
| | | wp_register_style( |
| | |
| | | $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}');"; |
| | |
| | | if (file_put_contents($css_path, $entry['css']) !== false) { |
| | | $this->icons = $entry['iconList']; |
| | | $this->saveIcons(); |
| | | Cache::touch('icons_' . $this->source); |
| | | Cache::for('icons_'.$this->source)->flush(); |
| | | return true; |
| | | } |
| | | |
| | |
| | | } |
| | | $needsUpdate[$this->source] = true; |
| | | update_option(BASE.'icons_needs_update', $needsUpdate); |
| | | Cache::touch('icons_' . $this->source); |
| | | |
| | | Cache::for('icons_'.$this->source)->flush(); |
| | | } |
| | | |
| | | public function mergeVersions(array $timestamps): bool |