From 48721c85ebcfa973ee81719d2467ca80e4253dc9 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Fri, 01 May 2026 17:30:03 +0000
Subject: [PATCH] =Edmonton Ink hard test begins! Real testing of the managers and reset routes will commence. So far, just ensuring our classes are all loaded correctly: Site() and its sub-classes Membership, Login, etc. Care should be taken to load conditionally on 'init', as we finish defining most settings by 'plugins_loaded' at priority 5
---
inc/managers/IconsManager.php | 55 +++++++++++++++++++++++++------------------------------
1 files changed, 25 insertions(+), 30 deletions(-)
diff --git a/inc/managers/IconsManager.php b/inc/managers/IconsManager.php
index 65e583d..45890c5 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;
@@ -43,9 +44,7 @@
{
$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();
@@ -198,12 +197,7 @@
// 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)
@@ -221,28 +215,21 @@
}
/**
- * 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 +349,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('magicLink')) {
$map['magicLink'] = 'magic-wand';
}
- if (Features::hasAnyIntegration()) {
+ if (Site::hasAnyIntegration()) {
$map['integrations'] = 'plugs-connected';
}
update_option(BASE.'iconMap', $map);
@@ -532,7 +519,7 @@
*/
public function get(string $name, array $options = []): string
{
- if ($name === '') {
+ if (empty($name)) {
//No icon requested
return '';
}
@@ -710,6 +697,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}";
--
Gitblit v1.10.0