From 56a9a1ccf764ff7a6af8f8a2292cb07443cb4aa7 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Thu, 28 May 2026 18:19:57 +0000
Subject: [PATCH] =New Gitbit setpu

---
 inc/helpers/terms.php |   90 +++++++++++++++++---------------------------
 1 files changed, 35 insertions(+), 55 deletions(-)

diff --git a/inc/helpers/terms.php b/inc/helpers/terms.php
index 6825ae5..6c0f7c0 100644
--- a/inc/helpers/terms.php
+++ b/inc/helpers/terms.php
@@ -1,9 +1,24 @@
 <?php
 
+use JVBase\registrar\Registrar;
+
 if (!defined('ABSPATH')) {
 	exit;
 }
 
+
+function jvbGetTermOwners(int $termID, bool $includeManagers = true):array
+{
+	$owners = get_term_meta($termID, BASE.'owners', true);
+	$owners = empty($owners) ? [] : $owners;
+	if ($includeManagers) {
+		$managers = get_term_meta($termID, BASE.'managers', true);
+		$managers = empty($managers) ? [] : $managers;
+		$owners = array_merge($owners, $managers);
+	}
+	return $owners;
+
+}
 /**
  * @param string $term
  * @param int|false $ID
@@ -41,65 +56,29 @@
     return $out;
 }
 
-/**
- * Clear taxonomy list caches when terms are saved
- * @param int $term_id
- * @param int $tt_id
- * @param string $taxonomy
- *
- * @return void
- */
-add_action('edited_term', 'jvbClearTermListCache', 10, 3);
-add_action('created_term', 'jvbClearTermListCache', 10, 3);
-add_action('delete_term', 'jvbClearTermListCache', 10, 3);
-
-function jvbClearTermListCache(int $term_id, int $tt_id, string $taxonomy):void
+function jvbMetaTermList(string $value, string $tax, bool $icon = true):string
 {
-    // Check if this taxonomy has a corresponding list
-    $types = jvbGlobalDirectoryInfo();
-    foreach ($types as $type) {
-        if ($type['slug'] === $taxonomy) {
-            // Delete the option to force regeneration
-            delete_option(BASE . $type['slug'] . '_list');
-            break;
-        }
-    }
-
-    // If this is a city and it's linked to other taxonomies, clear those too
-    if ($taxonomy === BASE.'city') {
-        foreach ($types as $type) {
-            if (!empty($type['links']) && in_array(BASE.'_city', $type['links'])) {
-                delete_option(BASE . $type['slug'] . '_list');
-            }
-        }
-    }
-}
-
-/**
- * Clear list caches when post types are saved
- */
-add_action('save_post', 'jvbClearListCache', 10, 2);
-function jvbClearListCache(int $post_id, \WP_Post $post):void
-{
-	if (jvbNoSaveIt($post_id, $post)) {
-		return;
+	if ($value === '') {
+		return '';
+	}
+	$tax = jvbCheckBase($tax);
+	$terms = array_map('absint', explode(',', $value));
+	$out = [];
+	foreach ($terms as $t) {
+		$term = get_term($t, $tax);
+		if ($term && !is_wp_error($term)) {
+			$url = get_term_link($t, $tax);
+			$out[] = '<li><a href="'.$url.'" title="View more in '.$term->name.'" rel="tag">'.$term->name.'</a></li>';
+		}
 	}
 
-    // Get post type
-    $post_type = get_post_type($post_id);
-
-    // Check if this post type has a corresponding list
-    $types = jvbGlobalDirectoryInfo();
-    foreach ($types as $type) {
-        if ($type['slug'] === $post_type) {
-            // Delete the option to force regeneration
-            delete_option(BASE . $type['slug'] . '_list');
-            break;
-        }
-    }
+	$registrar = Registrar::getInstance($tax);
+	$icon = ($icon && $registrar) ? $registrar->getIcon() : '';
+	$icon = ($icon === '') ? '' : jvbIcon($icon);
+	$title = $registrar ? '<li class="title">'.$icon.$registrar->getSingular().'</li>' : '';
+	return (!empty($out)) ? '<ul class="term-list row left '.jvbNoBase($tax).'">'.$title.implode('',$out).'</ul>' : '';
 }
 
-
 /**
  * @param int $artistID
  * @param string $taxonomy
@@ -162,7 +141,8 @@
     if ($users === '') {
         $term = get_term($termID);
         $taxonomy = $term->taxonomy;
-        if (taxIsJVBContentTax($taxonomy)) {
+		$registrar = Registrar::getInstance($taxonomy);
+        if ($registrar->hasFeature('is_content')) {
             $posts = new WP_Query([
                 'post_type'    => jvbCheckBase($user),
                 'posts_per_page'    => -1,

--
Gitblit v1.10.0