From 32ce5c542c90be348895328078e392dde2052957 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Fri, 04 Sep 2026 19:15:16 +0000
Subject: [PATCH] =Working at adding defined fields to a dedicated panel in the gutenberg editor. Registrar now has AddCustomFields.php, which currently only supports post fields. Added a @wordpress/plugins base _meta/fields in /build and /src that successfully creates a panel. Next steps: determine sections and fields, group fields by section (each section to a panel), and save output
---
inc/registrar/Fields.php | 16 ++++++++++++++--
1 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/inc/registrar/Fields.php b/inc/registrar/Fields.php
index 75b10b3..d48c56e 100644
--- a/inc/registrar/Fields.php
+++ b/inc/registrar/Fields.php
@@ -28,7 +28,6 @@
switch ($type) {
case 'post':
$this->addPostFields();
- //TODO: Add fields to post edit screen
// add_action('add_meta_boxes', [$this, 'registerPostFields']);
break;
case 'term':
@@ -235,8 +234,21 @@
$field->$property($value);
}
- public function getFields():array
+ public function getFields(bool $includeDefaults = true):array
{
+ if (!$includeDefaults) {
+ $added = array_keys(match($this->type) {
+ 'post' => $this->defaultPostFields(),
+ 'term' => $this->defaultTermFields(),
+ 'user' => $this->defaultUserFields(),
+ });
+ $fields = array_filter($this->fields, function($field) use ($added) {
+ return !in_array($field, $added);
+ }, ARRAY_FILTER_USE_KEY);
+ return array_filter($fields, function($field) {
+ return !$field->isHidden();
+ });
+ }
return $this->fields;
}
--
Gitblit v1.10.0