From 2127b1bdd73ecd2423e443992da4b442f5a3c1a3 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Wed, 04 Feb 2026 21:19:25 +0000
Subject: [PATCH] =Major overhaul of MetaManager.php -> Meta.php and RestRouteManager.php -> Rest.php. Seems to work for JakeVan

---
 inc/registry/PostTypeRegistrar.php |   45 ++-------------------------------------------
 1 files changed, 2 insertions(+), 43 deletions(-)

diff --git a/inc/registry/PostTypeRegistrar.php b/inc/registry/PostTypeRegistrar.php
index 1d6c2f4..0c60e5e 100644
--- a/inc/registry/PostTypeRegistrar.php
+++ b/inc/registry/PostTypeRegistrar.php
@@ -5,8 +5,7 @@
 use JVBase\managers\CRUD;
 use JVBase\utility\Features;
 use WP_Post;
-use JVBase\meta\MetaRegistry;
-use JVBase\managers\CacheManager;
+use JVBase\meta\Registry;
 if (!defined('ABSPATH')) {
 	exit;
 }
@@ -80,11 +79,10 @@
 		if ($this->config['is_timeline']??false) {
 
 		}
-
 		register_post_type($this->post_type, $args);
 
 		if (!empty($this->fields)) {
-			$meta_registry = new MetaRegistry($this->fields, $this->slug, 'post');
+			$meta_registry = new Registry($this->fields, $this->slug, 'post');
 			$meta_registry->registerMetaFields();
 		}
 	}
@@ -130,45 +128,6 @@
 			add_action('post_type_link', [$this, 'rewriteTaxonomySingle'], 15, 2);
 			add_filter('post_type_archive_link', [$this, 'rewriteTaxonomyArchive'], 15, 2);
 		}
-
-		$postType = $this->post_type;
-		add_action("save_post_{$this->post_type}", function($post_id, $post, $update) use ($postType) {
-			if (jvbNoSaveIt($post_id, $post)) {
-				return;
-			}
-			$this->invalidatePostCache($postType, $post, $update ? 'update' : 'create');
-		}, 10, 3);
-
-		add_action("delete_post", function($post_id, $post) use ($postType) {
-			$post = get_post($post_id);
-			if ($post && $post->post_type === $postType) {
-				$this->invalidatePostCache($postType, $post, 'delete');
-			}
-		}, 10, 2);
-
-		add_action("transition_post_status", function($new_status, $old_status, $post) use ($postType) {
-			if ($post->post_type === $postType && $new_status !== $old_status) {
-				$this->invalidatePostCache($postType, $post, 'status_change');
-			}
-		}, 10, 3);
-	}
-
-	protected function invalidatePostCache(string $type, $post, string $action) {
-		error_log('Clearing Cache for '.print_r($type, true));
-
-		$cache = CacheManager::for(jvbNoBase($type))->invalidate();
-
-		// Clear related caches (taxonomies attached to this post)
-		$taxonomies = get_object_taxonomies($post->post_type);
-		foreach ($taxonomies as $taxonomy) {
-			$terms = wp_get_post_terms($post->ID, $taxonomy, ['fields' => 'ids']);
-			if (!empty($terms)) {
-				CacheManager::for(jvbNoBase($taxonomy))->invalidate();
-			}
-		}
-
-		// Trigger custom action for additional handling
-		do_action("jvb_cache_invalidated_{$type}", $post, $action);
 	}
 
 	public function hideFromPublic(bool $is_viewable): bool

--
Gitblit v1.10.0