From 9bbeea742424837fb58207d88e10dbca0b2cae04 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sun, 03 May 2026 22:04:17 +0000
Subject: [PATCH] =SEO Field registration and formatting
---
inc/managers/queue/executors/UploadExecutor.php | 25 ++++++++++---------------
1 files changed, 10 insertions(+), 15 deletions(-)
diff --git a/inc/managers/queue/executors/UploadExecutor.php b/inc/managers/queue/executors/UploadExecutor.php
index cc828d5..8187500 100644
--- a/inc/managers/queue/executors/UploadExecutor.php
+++ b/inc/managers/queue/executors/UploadExecutor.php
@@ -6,7 +6,8 @@
use JVBase\managers\UploadManager;
use JVBase\meta\Meta;
use Exception;
-use JVBase\utility\Features;
+use JVBase\registrar\Registrar;
+use JVBase\base\Site;
if (!defined('ABSPATH')) {
exit;
@@ -384,7 +385,8 @@
}
$content = jvbCheckBase($data['content']);
- if (Features::forContent($data['content'])->has('is_timeline')) {
+ $registrar = Registrar::getInstance($data['content']);
+ if ($registrar && $registrar->hasFeature('is_timeline')) {
return $this->processTimelineUploads($operation, $data, $progress, $all_uploads);
}
@@ -438,14 +440,11 @@
protected function createPostFromGroup(array $post, int $index, string $content, array $uploads, Operation $op):array|false
{
- $config = JVB_CONTENT[jvbNoBase($content)]??false;
- if (!$config) {
- throw new Exception('No config found for content: '.$content.'.');
- }
+ $registrar = Registrar::getInstance($content);
$post_title = array_key_exists('post_title', $post['fields'])
? sanitize_text_field($post['fields']['post_title'])
- : 'New '. $config['singular'].' '.($index + 1);
+ : ($registrar ? 'New '. $registrar->getSingular().' '.($index + 1) : 'New Item '.($index + 1));
$post_excerpt = array_key_exists('post_excerpt', $post['fields'])
? sanitize_textarea_field($post['fields']['post_excerpt'])
@@ -489,7 +488,7 @@
if (!empty($gallery)) {
$meta = Meta::forPost($ID);
- $fields = jvbGetFields($content, 'post');
+ $fields = Registrar::getFieldsFor($content);
//add images to first found gallery field
$found = false;
foreach ($fields as $name =>$config) {
@@ -503,7 +502,6 @@
error_log('Could not find a gallery upload field for post '.$ID);
}
- $meta->save();
}
@@ -521,9 +519,10 @@
$errors = [];
$content = jvbCheckBase($data['content']);
- $config = Features::getConfig($content);
+ $registrar = Registrar::getInstance($data['content']);
- $defaultTitle = 'New '.$config['singular']. ' ';
+
+ $defaultTitle = ($registrar) ? 'New '.$registrar->getSingular(). ' ' : 'New Item ';
foreach($data['posts'] as $index => $post) {
try {
$title = array_key_exists('post_title', $post['fields'])
@@ -715,7 +714,6 @@
$meta->set($data['field_name'], implode(',', $allIds));
}
- $meta->save();
}
private function updateFieldValue(array $data, array $results): void
@@ -735,7 +733,6 @@
$allIds = array_unique(array_merge($existingIds, $attachmentIds));
$meta->set($data['field_name'], implode(',', $allIds));
- $meta->save();
}
private function getMetaManager(array $data): ?Meta
@@ -798,14 +795,12 @@
} elseif (str_starts_with($mimeType, 'video/')) {
$meta = Meta::forPost($postId);
$meta->set('video', $attachmentId);
- $meta->save();
} else {
$meta = Meta::forPost($postId);
$existing = $meta->get('documents');
$existingIds = !empty($existing) ? explode(',', $existing) : [];
$existingIds[] = $attachmentId;
$meta->set('documents', implode(',', $existingIds));
- $meta->save();
}
}
--
Gitblit v1.10.0