From 86c6cd3cc099d2480932ede03c12cea01e625c94 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sun, 26 Apr 2026 21:56:28 +0000
Subject: [PATCH] =Requiring files based on Site class settings
---
inc/rest/routes/UploadRoutes.php | 21 ++++++++++++++++-----
1 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/inc/rest/routes/UploadRoutes.php b/inc/rest/routes/UploadRoutes.php
index e46aa84..a31212e 100644
--- a/inc/rest/routes/UploadRoutes.php
+++ b/inc/rest/routes/UploadRoutes.php
@@ -130,6 +130,8 @@
{
$data = $request->get_params();
$args = [];
+ $registrar = Registrar::getInstance($data['content']??'');
+
foreach ($data as $key => $value) {
switch ($key) {
case 'depends_on':
@@ -140,15 +142,25 @@
case 'item_id':
if (is_numeric($value)) {
$args['item_id'] = absint($value);
- if (!array_key_exists('post_id', $args)) {
- $args['post_id'] = absint($value);
+ if ($registrar) {
+ switch ($registrar->getType()) {
+ case 'post':
+ $args['post_id'] = absint($value);
+ break;
+ case 'term':
+ $args['term_id'] = absint($value);
+ break;
+ case 'user':
+ $args['user_id'] = absint($value);
+ break;
+ }
}
}
break;
// Post Type/Taxonomy
case 'content':
- $key = str_replace('-', '_', $key);
- if ($value === 'options' || array_key_exists($value, Registrar::getRegistered('post')) || Registrar::getInstance($key)->hasFeature('is_content')??false) {
+ $value = str_replace('-', '_', $value);
+ if ($value === 'options' || $registrar) {
$args['content'] = $value;
}
break;
@@ -640,7 +652,6 @@
// Update with comma-separated string
$meta->set($data['field_name'], implode(',', $all_ids));
- $meta->save();
}
/**
--
Gitblit v1.10.0