From 3d25ad7de4fdbb3eba2cde2a62422e6be5d79a0a Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Tue, 25 Aug 2026 22:57:22 +0000
Subject: [PATCH] =It's been a minute. I went through the Routes and associated Managers and ensured they played together well. Reworked the Cache.php, and I think I caught all the references. Moving away from JVBase() root class, to individuall classes that are Instanced. Double checked for the ABSPATH check in every file, and added index.php to every directory that didn't already have it. Also still working on the MenuBlock to work with WooCommerce for now for Northeh
---
inc/managers/IconsManager.php | 83 ++++++++++++++++++++++-------------------
1 files changed, 45 insertions(+), 38 deletions(-)
diff --git a/inc/managers/IconsManager.php b/inc/managers/IconsManager.php
index 65e583d..cf48409 100644
--- a/inc/managers/IconsManager.php
+++ b/inc/managers/IconsManager.php
@@ -1,7 +1,8 @@
<?php
namespace JVBase\managers;
-use JVBase\utility\Features;
+use JVBase\registrar\Registrar;
+use JVBase\base\Site;
if (!defined('ABSPATH')) {
exit;
@@ -42,10 +43,8 @@
private function __construct(string $source)
{
$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->cache = Cache::for('icons_' . $source);
+ $this->style = Site::icon();
$this->addMap();
@@ -145,6 +144,7 @@
'apple-logo',
'check-circle',
'close-circle',
+ 'faders-horizontal',
'cloud-slash',
'exclamation-mark',
'cloud-arrow-down',
@@ -195,15 +195,11 @@
// ]
];
+
// Add icons from content/taxonomy/user configs (like old behavior)
$configIcons = $this->getIconsFromConfigs();
if (!empty($configIcons)) {
- foreach ($configIcons as $source => $icons) {
- if (!isset($defaults[$source])) {
- $defaults[$source] = [];
- }
- $defaults[$source] = array_merge($defaults[$source], $icons);
- }
+ $defaults['icons'] = array_merge($defaults['icons'], $configIcons);
}
// Allow filtering per source (extensibility)
@@ -214,35 +210,27 @@
if (isset($allIcons[$this->source])) {
$icons = array_merge($icons, $allIcons[$this->source]);
}
-
if (!empty($icons)) {
$this->include($icons);
}
}
/**
- * Get icons from JVB_CONTENT, JVB_TAXONOMY, JVB_USER configs
+ * Get icons from Registrar instances
+ *
*/
protected function getIconsFromConfigs(): array
{
$icons = [];
- $check = [JVB_CONTENT, JVB_TAXONOMY, JVB_USER];
+ $registered = Registrar::getRegistered();
- foreach ($check as $constant) {
- foreach ($constant as $key => $value) {
- if (isset($value['icon'])) {
- // Determine source based on context (you could add 'icon_source' to configs)
- $source = $value['icon_source'] ?? 'icons';
-
- if (!isset($icons[$source])) {
- $icons[$source] = [];
- }
- $icons[$source][] = $value['icon'];
- }
- }
+ foreach ($registered as $type) {
+ $registrar = Registrar::getInstance($type);
+ $icons[] = $registrar->getIcon();
}
- return $icons;
+
+ return array_unique(array_filter($icons));
}
/**
@@ -362,16 +350,16 @@
$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('magic_link')) {
$map['magicLink'] = 'magic-wand';
}
- if (Features::hasAnyIntegration()) {
+ if (Site::hasAnyIntegration()) {
$map['integrations'] = 'plugs-connected';
}
update_option(BASE.'iconMap', $map);
@@ -386,6 +374,7 @@
protected function registerGlobalHooks(): void
{
add_action('wp_loaded', [self::class, 'checkCSS']);
+ add_action('shutdown', [self::class, 'checkCSS']);
}
/**
@@ -459,7 +448,7 @@
$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");
@@ -497,7 +486,7 @@
$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");
@@ -532,7 +521,7 @@
*/
public function get(string $name, array $options = []): string
{
- if ($name === '') {
+ if (empty($name)) {
//No icon requested
return '';
}
@@ -636,7 +625,7 @@
/**
* 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;
@@ -660,7 +649,7 @@
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(
@@ -683,6 +672,15 @@
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 .= "}";
@@ -710,6 +708,14 @@
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}";
@@ -797,7 +803,7 @@
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;
}
@@ -818,7 +824,8 @@
}
$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
--
Gitblit v1.10.0