From 3b83905603d44b1a08f8b2b36a605808ce686ad6 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Tue, 02 Jun 2026 00:46:48 +0000
Subject: [PATCH] =double checking schema outputs for legacytattooremoval
---
inc/meta/Field.php | 67 +++++++++++++++++++++++++++++++--
1 files changed, 63 insertions(+), 4 deletions(-)
diff --git a/inc/meta/Field.php b/inc/meta/Field.php
index 0efb8e3..3c81135 100644
--- a/inc/meta/Field.php
+++ b/inc/meta/Field.php
@@ -17,6 +17,7 @@
public array $config;
public bool $isDirty = false;
public bool $isValid = true;
+ public bool $isDefault = false;
public array $errors = [];
public function __construct(string $name, mixed $value, array $config = [])
@@ -25,20 +26,36 @@
$this->value = $value;
$this->originalValue = $value;
$this->config = $config;
+ if (array_key_exists('wp', $config) && $config['wp'] === true) {
+ $this->isDefault = true;
+ }
}
+ /**
+ * Set field value and track dirty state
+ */
public function set(mixed $value): self
{
- $this->value = $value;
- $this->isDirty = ($value !== $this->originalValue);
+ error_log('Checking if value is the same as old value: '.print_r($value, true));
+ if ($value !== $this->value) {
+ error_log('Saving new value: '.print_r($value, true));
+ $this->value = $value;
+ $this->isDirty = true;
+ }
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 +63,9 @@
return $this;
}
+ /**
+ * Reset to original value
+ */
public function reset(): self
{
$this->value = $this->originalValue;
@@ -53,6 +73,9 @@
return $this;
}
+ /**
+ * Add validation error
+ */
public function addError(string $message): self
{
$this->errors[] = $message;
@@ -60,6 +83,9 @@
return $this;
}
+ /**
+ * Clear all errors
+ */
public function clearErrors(): self
{
$this->errors = [];
@@ -67,18 +93,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;
+ return $this->isDefault ?? 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']);
+ return ($this->type() === 'taxonomy' || ($this->type() === 'selector' && isset($this->config['subtype']) && $this->config['subtype'] === 'taxonomy')) && !isset($this->config['isReference']);
+ }
+
+ /**
+ * 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