From d7e7d248cbe41cd7a9ef9c2fb022b6c4831f99a3 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sun, 31 May 2026 15:22:56 +0000
Subject: [PATCH] =jakevan complete
---
inc/admin/SEOAdmin.php | 59 ++++++++++++++++++++---------------------------------------
1 files changed, 20 insertions(+), 39 deletions(-)
diff --git a/inc/admin/SEOAdmin.php b/inc/admin/SEOAdmin.php
index 6c01e01..007e453 100644
--- a/inc/admin/SEOAdmin.php
+++ b/inc/admin/SEOAdmin.php
@@ -2,7 +2,6 @@
namespace JVBase\admin;
use JVBase\meta\Form;
-use JVBase\meta\Sanitizer;
use JVBase\registrar\Registrar;
use JVBase\ui\Tabs;
@@ -29,7 +28,7 @@
'JVBase\managers\SEO\render\Thing\CreativeWork\WebPage\Webpage' => ' - - WebPage',
'JVBase\managers\SEO\render\Thing\CreativeWork\WebPage\AboutPage' => ' - - - About Page',
'JVBase\managers\SEO\render\Thing\CreativeWork\WebPage\CheckoutPage' => ' - - - Checkout Page',
- 'JVBase\managers\SEO\render\Thing\CreativeWork\WebPage\CollectionPage' => ' - - - Collection Page',
+ 'JVBase\inc\managers\SEO\render\Thing\CreativeWork\WebPage\CollectionPage\CollectionPage' => ' - - - Collection Page',
'JVBase\managers\SEO\render\Thing\CreativeWork\WebPage\ContactPage' => ' - - - Contact Page',
'JVBase\managers\SEO\render\Thing\CreativeWork\WebPage\FAQPage' => ' - - - FAQ Page',
'JVBase\managers\SEO\render\Thing\CreativeWork\WebPage\ItemPage' => ' - - - Item Page',
@@ -88,7 +87,9 @@
'sponsor',
'containsInPlace',
'containsPlace',
- 'openingHours'
+ 'openingHours',
+ 'id',
+ 'ignore',
];
protected array $hints = [
@@ -114,7 +115,8 @@
protected function setChecks():void
{
$checks = [
- 'website'
+ 'website',
+ 'organization'
];
$this->checks = array_merge($checks, Registrar::getRegistered());
}
@@ -143,7 +145,7 @@
public function addDashboardSection(string $content, string $page):string
{
- if ($page !== 'jvb-seo') {
+ if ($page !== 'SEO') {
return $content;
}
ob_start();
@@ -201,6 +203,10 @@
$this->renderStyles();
}
}
+ private function renderStyles(): void
+ {
+ jvbInlineStyles('forms');
+ }
public function renderProperty(string $property, ?string $value, mixed $class):void
{
@@ -287,14 +293,14 @@
}
public function renderFieldsFor(string $class, array $stored):void
{
- $fields = $this->getFieldsFor($class);
+ $fields = $this->getFieldsForClass($class);
$instance = new $class();
foreach ($fields as $property => $value) {
$this->renderProperty($property, $stored[$property]??null, $instance);
}
}
- public function getFieldsFor(string $class):array
+ public function getFieldsForClass(string $class):array
{
if (!class_exists($class)) {
error_log('Class not found: '.$class);
@@ -331,7 +337,7 @@
}
-
+ $_POST['type'] = $type;
$result = $this->saveFields($action, $type, $_POST);
@@ -344,6 +350,7 @@
public function saveFields(string $action, string $class, array $data):array
{
+ $action = strtolower($action);
if (!in_array($action, $this->checks)) {
error_log('[SEOAdmin]Action is not allowed: '.$action);
return [
@@ -352,39 +359,13 @@
];
}
- $allowed = $this->getFieldsFor($class);
- if (empty($allowed)) {
- return [
- 'jvb_notice' => 'error',
- 'jvb_message' => 'Could not get fields from class'
- ];
- }
-
- $checked = array_filter($data, function ($item) use ($allowed) {
- return array_key_exists($item, $allowed);
- }, ARRAY_FILTER_USE_KEY);
-
- $stored = get_option(BASE.ucfirst($action).'Schema', []);
- $updates = [];
- foreach ($checked as $property => $value) {
- $sanitized = Sanitizer::sanitize($value, $this->buildConfig($property));
- if (!array_key_exists($property, $stored) || $stored[$property] !== $sanitized)
- $updates[$property] = $sanitized;
- }
- if (!empty($updates)) {
- $history = get_option(BASE.ucfirst($action).'SchemaHistory', []);
- array_unshift($history, $stored);
- if (count($history) > 5){
- array_pop($history);
- }
- update_option(BASE.ucfirst($action).'SchemaHistory', $history);
-
- $update = array_merge($stored, $updates);
- update_option(BASE.ucfirst($action).'Schema', $update);
- }
- return [
+ $success = JVB()->schemaHelper()->updateSchema($action, $data);
+ return $success ? [
'jvb_notice' => 'success',
'jvb_message' => 'Saved changes successfully'
+ ] : [
+ 'jvb_notice' => 'error',
+ 'jvb_message' => 'Something went wrong...'
];
}
}
--
Gitblit v1.10.0