From 27fb820ae9081fb56957cf75e79eccd8a99edd52 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sat, 14 Feb 2026 19:14:48 +0000
Subject: [PATCH] =minor css changes, queue merge logic restructured, and double checking changes actually changed in cRUD.js before sending to server
---
inc/rest/routes/ContentRoutes.php | 67 ++++++++++++++++++++++++++++-----
1 files changed, 56 insertions(+), 11 deletions(-)
diff --git a/inc/rest/routes/ContentRoutes.php b/inc/rest/routes/ContentRoutes.php
index 1c90f30..0b9cea6 100644
--- a/inc/rest/routes/ContentRoutes.php
+++ b/inc/rest/routes/ContentRoutes.php
@@ -429,6 +429,7 @@
return $this->formatTimeline($post);
}
$this->meta = Meta::forPost($post->ID);
+ $fields = ($fields) ? $this->meta->getAll() : [];
$data = [
'id' => $post->ID,
'title' => $post->post_title,
@@ -439,7 +440,7 @@
'alt' => get_post_meta(get_post_thumbnail_id(), '_wp_attachment_image_alt', true),
'icon' => $this->post_type,
'taxonomies' => [],
- 'fields' => ($fields) ? $this->meta->getAll() : [],
+ 'fields' => $fields,
'images' => [],
];
@@ -474,25 +475,69 @@
$images = [];
$get = [];
$fields = (empty($fields)) ? $this->fields : $fields;
- foreach ($fields as $field => $config) {
- if ($config['type'] === 'gallery' || $config['type'] === 'image' || $field === 'post_thumbnail') {
- $get[] = $field;
- }
- }
+ $get = $this->getUploadFields($fields);
+
if (!empty($get)) {
- $allImages = $this->meta->getAll($get);
+ $actualGet = array_map(function($fieldName) {
+ return (str_contains($fieldName, ':')) ? strtok($fieldName, ':') : $fieldName;
+ }, $get);
+ $complex = array_map(function($item) {
+ return explode(':', $item);
+ },array_filter($get, function($fieldName) {
+ return str_contains($fieldName, ':');
+ }));
+
+ $allImages = $this->meta->getAll($actualGet);
foreach ($allImages as $k => $imgs) {
- $temp = explode(',', $imgs);
- foreach ($temp as $img) {
- if (is_numeric($img) && !array_key_exists($img, $images)) {
- $images[$img] = jvbImageData((int)$img);
+ //It's a complex field
+ if (is_array($imgs)) {
+ foreach ($imgs as $row) {
+ foreach ($row as $fName => $fValue) {
+ foreach ($complex as $c) {
+ if (in_array($k, $c)) {
+ foreach ($c as $complexField) {
+ if ($complexField === $fName) {
+ $images = $this->addImages($fValue, $images);
+ }
+ }
+ }
+ }
+ }
}
+ } else {
+ $images = $this->addImages($imgs, $images);
}
}
}
return $images;
}
+ public function addImages(string $imgs, array $images):array
+ {
+ $temp = explode(',', $imgs);
+ foreach ($temp as $img) {
+ if (is_numeric($img) && !array_key_exists($img, $images)) {
+ $images[$img] = jvbImageData((int)$img);
+ }
+ }
+ return $images;
+ }
+ public function getUploadFields($fields):array
+ {
+ $get = [];
+ foreach ($fields as $field => $config) {
+ if (in_array($config['type'], ['group', 'repeater'])) {
+ $nestedUploads = $this->getUploadFields($config['fields']);
+ foreach ($nestedUploads as $nested) {
+ $get[] = $field.':'.$nested;
+ }
+ } elseif ($config['type'] === 'upload' || $config['type'] === 'gallery' || $config['type'] === 'image' ) {
+ $get[] = $field;
+ }
+ }
+
+ return $get;
+ }
public function formatTimeline(WP_Post $post): array
{
--
Gitblit v1.10.0