From 275c0d74cd68677622a5431505c5c870c473063d Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sun, 29 Mar 2026 21:40:15 +0000
Subject: [PATCH] =Seems to be working, huzzah! Added some changes for on-this-page nav
---
inc/helpers/terms.php | 76 +++++++++----------------------------
1 files changed, 19 insertions(+), 57 deletions(-)
diff --git a/inc/helpers/terms.php b/inc/helpers/terms.php
index 77f8fec..e30cc9b 100644
--- a/inc/helpers/terms.php
+++ b/inc/helpers/terms.php
@@ -1,5 +1,7 @@
<?php
+use JVBase\registrar\Registrar;
+
if (!defined('ABSPATH')) {
exit;
}
@@ -41,69 +43,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
-{
- // SAFETY: Skip attachments and other non-content post types
- if (in_array($post->post_type, jvbIgnoredPostTypes())) {
- return;
+ if ($value === '') {
+ return '';
}
- if (jvbNoSaveIt($post_id, $post)) {
- 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 '.jvbNoBase($tax).'">'.$title.implode('',$out).'</ul>' : '';
}
-
/**
* @param int $artistID
* @param string $taxonomy
--
Gitblit v1.10.0