From 772462eeca3002a1d52508aeba485aab2b4742ad Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Tue, 03 Mar 2026 19:06:19 +0000
Subject: [PATCH] =MAJOR OVERHAUL. Likely should have made a new branch ages ago. Key changes: Registrar.php is the base for custom post types, taxonomies, and user roles. Replaces JVB_CONTENT, JVB_TAXONOMY, and JVB_USER constants, eliminates most of Features.php (except for JVB_SITE, JVB_MEMBERSHIP), and has built in sanitizing and validation via sub-classes. Also started a major overhaul of the Schema output. Created a shit ton of property traits and classes to help sanitize and ensure proper data for different schema types. Still a bunch to do, but better to be starting committing changes here on this other branch.
---
inc/meta/Field.php | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 51 insertions(+), 0 deletions(-)
diff --git a/inc/meta/Field.php b/inc/meta/Field.php
index 0efb8e3..c6cf372 100644
--- a/inc/meta/Field.php
+++ b/inc/meta/Field.php
@@ -27,6 +27,9 @@
$this->config = $config;
}
+ /**
+ * Set field value and track dirty state
+ */
public function set(mixed $value): self
{
$this->value = $value;
@@ -34,11 +37,17 @@
return $this;
}
+ /**
+ * Get current value
+ */
public function get(): mixed
{
return $this->value;
}
+ /**
+ * Mark field as clean (after save)
+ */
public function markClean(): self
{
$this->originalValue = $this->value;
@@ -46,6 +55,9 @@
return $this;
}
+ /**
+ * Reset to original value
+ */
public function reset(): self
{
$this->value = $this->originalValue;
@@ -53,6 +65,9 @@
return $this;
}
+ /**
+ * Add validation error
+ */
public function addError(string $message): self
{
$this->errors[] = $message;
@@ -60,6 +75,9 @@
return $this;
}
+ /**
+ * Clear all errors
+ */
public function clearErrors(): self
{
$this->errors = [];
@@ -67,18 +85,51 @@
return $this;
}
+ /**
+ * Get field type from config
+ */
public function type(): string
{
return $this->config['type'] ?? 'text';
}
+ /**
+ * Check if this is a WordPress default field
+ */
public function isWpDefault(): bool
{
return $this->config['_wp_default'] ?? false;
}
+ /**
+ * Check if this is a taxonomy relationship field (not taxonomy_type)
+ */
public function isTaxonomy(): bool
{
return $this->type() === 'taxonomy' && !isset($this->config['taxonomy_type']);
}
+
+ /**
+ * Check if field is required
+ */
+ public function isRequired(): bool
+ {
+ return !empty($this->config['required']);
+ }
+
+ /**
+ * Get field label
+ */
+ public function label(): string
+ {
+ return $this->config['label'] ?? $this->name;
+ }
+
+ /**
+ * Get field description
+ */
+ public function description(): string
+ {
+ return $this->config['description'] ?? '';
+ }
}
--
Gitblit v1.10.0