From 0113d2e9c9ff34a6ffb10707cc76d34b67a0c367 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Mon, 19 Jan 2026 16:29:41 +0000
Subject: [PATCH] =Refactored window.getTemplate into a full templating class window.jvbTemplates. Refactored CRUD.js, UploadManager.js, FormController.js, PopulateForm.js with that in mind
---
inc/registry/TaxonomyRegistrar.php | 29 +++++++++++++++++++++++------
1 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/inc/registry/TaxonomyRegistrar.php b/inc/registry/TaxonomyRegistrar.php
index bd0c049..c1bf6e2 100644
--- a/inc/registry/TaxonomyRegistrar.php
+++ b/inc/registry/TaxonomyRegistrar.php
@@ -55,12 +55,32 @@
$post_types = array_map(fn($type) => BASE . $type, $this->config['for_content'] ?? []);
register_taxonomy($this->taxonomy, $post_types, $args);
+ $this->maybeAddRewriteRule($args['rewrite']);
if (!empty($this->fields)) {
$meta_registry = new MetaRegistry($this->fields, $this->slug, 'term');
$meta_registry->registerMetaFields();
}
}
+ /**
+ * Add custom rewrite rule for hierarchical taxonomy slugs (e.g., post-type/by/taxonomy-slug)
+ */
+ protected function maybeAddRewriteRule(array $rewrite_config): void
+ {
+ $slug = $rewrite_config['slug'] ?? $this->slug;
+
+ // Only add custom rule if slug contains slashes (hierarchical path)
+ if (!str_contains($slug, '/')) {
+ return;
+ }
+
+ add_rewrite_rule(
+ "^{$slug}/([^/]+)/?$",
+ 'index.php?' . $this->taxonomy . '=$matches[1]',
+ 'top'
+ );
+ }
+
private function buildLabels(string $singular, string $plural): array
{
return [
@@ -336,19 +356,16 @@
if ($tax !== $taxonomy) return;
$term = get_term($term_id, $tax);
- jvbUpdateCacheTimestamp('term', $term);
- // Clear taxonomy cache
- CacheManager::invalidateGroup($taxonomy);
- CacheManager::invalidateGroup('terms');
- CacheManager::invalidateGroup('termCheck');
+ CacheManager::for(jvbNoBase($taxonomy))->invalidate();
+ CacheManager::for(jvbNoBase($taxonomy))->clear();
// Clear cache for associated content types
$checker = Checker::getInstance();
$content_types = $checker->getContentForTaxonomy($taxonomy);
foreach ($content_types as $content_type) {
- CacheManager::invalidateGroup($content_type);
+ CacheManager::for($content_type)->invalidate();
}
do_action("jvb_taxonomy_cache_invalidated_{$taxonomy}", $term, $action);
--
Gitblit v1.10.0