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/ui/CRUDSkeleton.php |   54 ++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 36 insertions(+), 18 deletions(-)

diff --git a/inc/ui/CRUDSkeleton.php b/inc/ui/CRUDSkeleton.php
index c32dcce..c62f3a4 100644
--- a/inc/ui/CRUDSkeleton.php
+++ b/inc/ui/CRUDSkeleton.php
@@ -1,8 +1,10 @@
 <?php
 namespace JVBase\ui;
 
+use JVBase\base\Site;
 use JVBase\managers\UserTermsManager;
 use JVBase\meta\Form;
+use JVBase\registrar\Registrar;
 use WP_User;
 
 if (!defined('ABSPATH')) {
@@ -128,6 +130,7 @@
 	protected array $customDateRanges = [];
 	protected array $additionalClasses = [];
 
+	protected Registrar $registrar;
 	public function __construct() {
 		$this->icon = jvbDefaultIcon();
 		$this->user = wp_get_current_user();
@@ -148,6 +151,7 @@
 	 */
 	public function content(string $type, string $singular, string $plural): self {
 		$this->dataType = $type;
+		$this->registrar = Registrar::getInstance($type);
 		$this->singular = $singular;
 		$this->plural = $plural;
 		return $this;
@@ -213,13 +217,17 @@
 	 */
 	public function addTaxonomyFilter(array $taxonomies, ?string $limit = null): self {
 		foreach($taxonomies as $taxonomy) {
-			$this->taxonomies[$taxonomy] = [
-				'type'	=> 'taxonomy',
-				'taxonomy'=> $taxonomy,
-				'limit'	=> $limit,
-				'label'	=> JVB_TAXONOMY[$taxonomy]['plural']??'',
-				'icon'	=> JVB_TAXONOMY[$taxonomy]['icon']??''
-			];
+			$registrar = Registrar::getInstance($taxonomy);
+
+			if ($registrar) {
+				$this->taxonomies[$taxonomy] = [
+					'type'	=> 'taxonomy',
+					'taxonomy'=> $taxonomy,
+					'limit'	=> $limit,
+					'label'	=> $registrar->getPlural(),
+					'icon'	=> $registrar->getIcon()
+				];
+			}
 		}
 
 		return $this;
@@ -227,8 +235,8 @@
 
 	protected function taxConfig(string $taxonomy, string $label = ''):array
 	{
-		$isVerified = jvbUserIsVerified();
-		$label = ($label === '') ? JVB_TAXONOMY[$taxonomy]['plural'] : $label;
+		$isVerified = $this->userIsVerified();
+		$label = ($label === '') ? Registrar::getInstance($taxonomy)->getPlural() : $label;
 		return [
 			'type'		=> 'taxonomy',
 			'label'		=> $label,
@@ -239,6 +247,13 @@
 		];
 	}
 
+	protected function userIsVerified():bool
+	{
+		$membership = Site::membership();
+
+		return !($membership && $membership->has('member_verified')) || current_user_can('skip_moderation');
+	}
+
 	public function addSearch():self
 	{
 		$this->hasSearch = true;
@@ -894,7 +909,7 @@
 		if ($limit) {
 			if ($limit === 'user') {
 				$manager = new UserTermsManager();
-				return $manager->getUserTerms($this->user_id, $taxonomy);
+				return $manager->fetchUserTerms($this->user_id, $taxonomy);
 			} else {
 				$limit = (int)$limit;
 			}
@@ -973,9 +988,12 @@
 					<option value="<?=$control?>"<?=$disabled?>><?=$label?></option>
 					<?php
 				}
-				foreach ($this->taxonomies as $taxonomy => $config) {
+
+				foreach ($this->taxonomies as $taxonomy =>$config) {
+					$registrar = Registrar::getInstance($taxonomy);
+					if (!$registrar) continue;
 					?>
-					<option value="tax-<?=$taxonomy?>" data-type="selector" data-single="<?=JVB_TAXONOMY[$taxonomy]['singular']?>" data-plural="<?=JVB_TAXONOMY[$taxonomy]['plural']?>" data-taxonomy="<?=$taxonomy?>">Add to <?= JVB_TAXONOMY[$taxonomy]['singular']??$config['label'] ?></option>
+					<option value="tax-<?=$taxonomy?>" data-type="selector" data-single="<?=$registrar->getSingular()?>" data-plural="<?=$registrar->getPlural()?>" data-taxonomy="<?=$taxonomy?>">Add to <?= $registrar->getSingular() ?></option>
 					<?php
 				}
 				?>
@@ -1544,12 +1562,16 @@
 			<input type="hidden" name="content" value="<?=$this->dataType?>" />
 			<div class="fields">
 				<?php
-				echo Form::render('post_status', '', $this->getStatusFieldConfig('edit-'));
+				if (!empty($this->statuses)) {
+					echo Form::render('post_status', '', $this->getStatusFieldConfig('edit-'));
+				}
+
 
 
 				if (!empty($this->sections)) {
 					$tabs = [];
-					foreach ($this->sections as $slug => $config) {
+					foreach ($this->sections as $config) {
+						$slug = $config['slug'];
 						$section = [];
 						if (array_key_exists('icon', $config)) {
 							$section = [
@@ -1561,10 +1583,6 @@
 							'content' => '',
 							'description' => $config['description']??'',
 						], $section);
-						$icon = jvbSectionIcon($slug);
-						if ($icon !== '') {
-							$tabs[$slug]['icon'] = $icon;
-						}
 					}
 				} else {
 					$tabs = false;

--
Gitblit v1.10.0