From 772462eeca3002a1d52508aeba485aab2b4742ad Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Tue, 03 Mar 2026 19:06:19 +0000
Subject: [PATCH] =MAJOR OVERHAUL. Likely should have made a new branch ages ago. Key changes: Registrar.php is the base for custom post types, taxonomies, and user roles. Replaces JVB_CONTENT, JVB_TAXONOMY, and JVB_USER constants, eliminates most of Features.php (except for JVB_SITE, JVB_MEMBERSHIP), and has built in sanitizing and validation via sub-classes. Also started a major overhaul of the Schema output. Created a shit ton of property traits and classes to help sanitize and ensure proper data for different schema types. Still a bunch to do, but better to be starting committing changes here on this other branch.
---
inc/managers/queue/executors/ContentTermExecutor.php | 44 +++++++++++++++++++++++---------------------
1 files changed, 23 insertions(+), 21 deletions(-)
diff --git a/inc/managers/queue/executors/ContentTermExecutor.php b/inc/managers/queue/executors/ContentTermExecutor.php
index bac1179..e8f4494 100644
--- a/inc/managers/queue/executors/ContentTermExecutor.php
+++ b/inc/managers/queue/executors/ContentTermExecutor.php
@@ -8,7 +8,7 @@
use JVBase\managers\queue\Result;
use JVBase\managers\RoleManager;
use JVBase\meta\Meta;
-use JVBase\utility\Features;
+use JVBase\registrar\Registrar;
use Exception;
if (!defined('ABSPATH')) {
@@ -35,10 +35,10 @@
public function execute(Operation $operation, Progress $progress): Result
{
// Extract taxonomy from operation type (e.g., "shop_update" -> "shop")
- $parts = explode('_', $operation->type);
- $taxonomy = $parts[0] ?? '';
-
- if (!$taxonomy || !isset(JVB_TAXONOMY[$taxonomy])) {
+ $data= $operation->requestData;
+ $taxonomy = $data['taxonomy']??false;
+ $registrar = $taxonomy? Registrar::getInstance($taxonomy) : false;
+ if (!$taxonomy || !$registrar) {
return Result::fail("Invalid taxonomy: {$taxonomy}");
}
@@ -73,7 +73,7 @@
unset($data['term_id']);
// Filter to only allowed fields
- $allowed = jvbGetFields($taxonomy, 'term');
+ $allowed = Registrar::getFieldsFor($taxonomy);
$setData = array_filter(
$data,
fn($key) => array_key_exists($key, $allowed),
@@ -128,7 +128,8 @@
}
// Check if tracking enabled
- if (!Features::forTaxonomy($taxonomy)->has('track_changes')) {
+ $registrar = Registrar::getInstance($taxonomy);
+ if ($registrar && !$registrar->hasFeature('track_changes')) {
return Result::fail('Member tracking not enabled for ' . $taxonomy);
}
@@ -173,15 +174,18 @@
*/
protected function addMember(int $userID, int $termID, string $taxonomy): Result
{
- $config = JVB_TAXONOMY[$taxonomy] ?? [];
- $content = $config['for_content'] ?? [];
+ $registrar = Registrar::getInstance($taxonomy);
+ if (!$registrar) {
+ return Result::fail('No content registered');
+ }
- if (empty($content)) {
+ $forContent = $registrar->registrar->for;
+ if (empty($forContent)) {
return Result::fail('No content types configured for ' . $taxonomy);
}
// Get table name (e.g., "history_artist_shop")
- $contentType = $content[0]; // Use first content type
+ $contentType = is_array($forContent) ? $forContent[0] : $forContent; // Use first content type
$tableName = "history_{$contentType}_{$taxonomy}";
$table = CustomTable::for($tableName);
@@ -235,9 +239,6 @@
throw new Exception('Failed to set taxonomy term: ' . $termResult->get_error_message());
}
- // Clear cache
- JVB()->cache()->for($taxonomy)->delete("{$taxonomy}_{$termID}_members");
-
// Notify term managers
$this->notifyTermManagers($termID, $userID, $taxonomy, 'member_added');
@@ -254,15 +255,19 @@
*/
protected function removeMember(int $userID, int $termID, string $taxonomy): Result
{
- $config = JVB_TAXONOMY[$taxonomy] ?? [];
- $content = $config['for_content'] ?? [];
+ $registrar = Registrar::getInstance($taxonomy);
+ if (!$registrar) {
+ return Result::fail('No content registered');
+ }
+ $forContent = $registrar->registrar->for;
- if (empty($content)) {
+ if (empty($forContent)) {
return Result::fail('No content types configured for ' . $taxonomy);
}
// Get table name
- $contentType = $content[0];
+ $contentType = is_array($forContent) ? $forContent[0] : $forContent;
+
$tableName = "history_{$contentType}_{$taxonomy}";
$table = CustomTable::for($tableName);
@@ -296,9 +301,6 @@
throw new Exception('Failed to remove taxonomy term: ' . $termResult->get_error_message());
}
- // Clear cache
- JVB()->cache()->for($taxonomy)->delete("{$taxonomy}_{$termID}_members");
-
// Notify term managers
$this->notifyTermManagers($termID, $userID, $taxonomy, 'member_removed');
--
Gitblit v1.10.0