From df6c00db050e188a6bd5707e72c4f1f331ced923 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sun, 08 Feb 2026 20:46:43 +0000
Subject: [PATCH] =Port over to jakevan 2

---
 inc/rest/Route.php |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/inc/rest/Route.php b/inc/rest/Route.php
index 4deb44a..dd356a9 100644
--- a/inc/rest/Route.php
+++ b/inc/rest/Route.php
@@ -334,9 +334,33 @@
 			'email' => 'sanitize_email',
 			'url' => 'esc_url_raw',
 			'boolean', 'bool' => 'rest_sanitize_boolean',
+			'array' => function($value) {
+				if (is_array($value)) {
+					return $value;
+				}
+				return [];
+			},
+			'object' => function($value) {
+				if (is_array($value) || is_object($value)) {
+					return (array) $value;
+				}
+				return [];
+			},
 			default => null,
 		};
 
+		// Add validate callback for array/object types
+		if (in_array($type, ['array', 'object'])) {
+			$arg['validate_callback'] = function($value, $request, $param) {
+				// Allow empty arrays/objects
+				if (empty($value)) {
+					return true;
+				}
+				// Ensure it's an array or object
+				return is_array($value) || is_object($value);
+			};
+		}
+
 		// Parse modifiers
 		foreach (array_slice($parts, 1) as $part) {
 			$part = trim($part);

--
Gitblit v1.10.0