From 94de71140be2d0c80bf6a2e03cb9381b37736ed5 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Fri, 06 Feb 2026 17:03:02 +0000
Subject: [PATCH] =Some minor CRUD.js and UploadManager.js tweaks
---
inc/meta/Form.php | 36 +++++++++++++++++++++++++-----------
1 files changed, 25 insertions(+), 11 deletions(-)
diff --git a/inc/meta/Form.php b/inc/meta/Form.php
index 048f62b..7fe9aa0 100644
--- a/inc/meta/Form.php
+++ b/inc/meta/Form.php
@@ -141,10 +141,10 @@
protected static function handleCustomDatasets($config):string
{
if (array_key_exists('data', $config) && !empty($config['data'])) {
- $datasets = array_map(function ($key) use ($config) {
+ $datasets = array_map(function ($value, $key) use ($config) {
$name = str_replace('_', '-', sanitize_title($key));
- return ' data-'.$name.'="'.$config['data'][$key].'"';
- }, $config['data']);
+ return ' data-'.$name.'="'.$value.'"';
+ }, array_values($config['data']), array_keys($config['data']));
return implode($datasets);
}
@@ -629,8 +629,22 @@
}
$config['data']['upload-field'] = '';
$config['data']['type'] = $config['multiple'] ? 'gallery' : 'single';
+ $plural = 'images';
+ $singular = 'image';
if (!empty($config['content'])) {
- $config['data']['content'] = $config['content'];
+ $content = $config['content'];
+
+ $config['data']['content'] = $content;
+ $plural =
+ JVB_CONTENT[$content]['plural']
+ ?? JVB_TAXONOMY[$content]['plural']
+ ?? JVB_USER[$content]['plural']
+ ?? str_replace('_', ' ', $content) . 's';
+
+ $singular = JVB_CONTENT[$content]['singular']
+ ?? JVB_TAXONOMY[$content]['singular']
+ ?? JVB_USER[$content]['singular']
+ ?? str_replace('_', ' ',$config['content']);
}
if ($config['limit'] > 0) {
$config['data']['limit'] = $config['limit'];
@@ -644,7 +658,8 @@
<input type="file"
%s
accept="%s"
- data-max-size="%s">
+ data-max-size="%s"
+ data-ignore>
<h2>%s</h2>
%s
<p class="file-upload-text">
@@ -660,8 +675,8 @@
esc_html(static::getAcceptedTypesLabel($config)),
esc_html(static::formatFileSize(static::getMaxFileSize($config)))
);
- $plural = (array_key_exists($config['content'], JVB_CONTENT)) ? JVB_CONTENT[$config['content']]['plural'] : (array_key_exists($config['content'], JVB_TAXONOMY) ? JVB_TAXONOMY[$config['content']]['plural'] : str_replace('_', ' ',$config['content']).'s');
- $singular = (array_key_exists($config['content'], JVB_CONTENT)) ? JVB_CONTENT[$config['content']]['singular'] : (array_key_exists($config['content'], JVB_TAXONOMY) ? JVB_TAXONOMY[$config['content']]['singular'] : str_replace('_', ' ',$config['content']));
+
+
if ($config['destination'] === 'post_group') {
$input .= sprintf(
'<p class="hint">You can group images to create separate %s.</p>
@@ -852,7 +867,7 @@
]
];
- $out .= static::render('image_data', $fields);
+ $out .= static::render('image_data', '', $fields);
$out .= static::renderUploadItemMetaEnd();
if ($additionalFields) {
@@ -920,7 +935,7 @@
]
];
- $out .= static::render('image_data', $fields);
+ $out .= static::render('image_data', '', $fields);
$out .= static::renderUploadItemMetaEnd();
if ($additionalFields) {
@@ -982,7 +997,7 @@
]
];
- $out .= static::render('image_data', $fields);
+ $out .= static::render('image_data', '', $fields);
$out .= static::renderUploadItemMetaEnd();
if ($additionalFields) {
@@ -1577,7 +1592,6 @@
protected static function renderGroup(string $name, mixed $value, array $config): string
{
$fields = $config['fields'] ?? [];
- error_log('Group fields: '.print_r($fields, true));
$values = is_array($value) ? $value : [];
$wrapper = (array_key_exists('wrap', $config)) ? 'details' : 'fieldset';
--
Gitblit v1.10.0