From 75a097a018a0090f5902758353c578fce4aa2a25 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sat, 23 May 2026 18:43:42 +0000
Subject: [PATCH] =CustomBlocks.php overhaul relatively complete. Also refactored the gallery in gallery.min.js and the jvbRenderGallery.
---
inc/managers/queue/executors/ContentTermExecutor.php | 51 +++++++++++++++++++++++++--------------------------
1 files changed, 25 insertions(+), 26 deletions(-)
diff --git a/inc/managers/queue/executors/ContentTermExecutor.php b/inc/managers/queue/executors/ContentTermExecutor.php
index bac1179..67d1cfe 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')) {
@@ -34,11 +34,12 @@
public function execute(Operation $operation, Progress $progress): Result
{
+ error_log('Executing Content Term.... ');
// 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 +74,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),
@@ -85,13 +86,9 @@
}
// Update metadata
- $meta->setAll($setData);
- $results = $meta->save();
+ $results = $meta->setAll($setData);
if ($results) {
- // Trigger any post-update actions (e.g., thumbnail generation)
- do_action(BASE . "{$taxonomy}_updated", $termID, $userID, $setData);
-
return Result::success([
'updated_fields' => array_keys($setData),
'term_id' => $termID
@@ -128,7 +125,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 +171,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 +236,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 +252,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 +298,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