From 86c6cd3cc099d2480932ede03c12cea01e625c94 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sun, 26 Apr 2026 21:56:28 +0000
Subject: [PATCH] =Requiring files based on Site class settings
---
inc/registry/PostTypeRegistrar.php | 49 ++++---------------------------------------------
1 files changed, 4 insertions(+), 45 deletions(-)
diff --git a/inc/registry/PostTypeRegistrar.php b/inc/registry/PostTypeRegistrar.php
index 1d6c2f4..d248ca4 100644
--- a/inc/registry/PostTypeRegistrar.php
+++ b/inc/registry/PostTypeRegistrar.php
@@ -3,10 +3,9 @@
use JVBase\forms\TaxonomySelector;
use JVBase\managers\CRUD;
-use JVBase\utility\Features;
-use WP_Post;
-use JVBase\meta\MetaRegistry;
-use JVBase\managers\CacheManager;
+use JVBase\base\Site;
+
+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