From 3baf3d2545ba6ece6b74a64c0def59bd0774cf54 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Wed, 10 Jun 2026 16:34:12 +0000
Subject: [PATCH] =Laid the groundwork for an improved DashboardManager.php setup. Have to put it aside so I can get the dang Northeh done though.
---
inc/rest/routes/SEORoutes.php | 95 +++++++++++++++++------------------------------
1 files changed, 34 insertions(+), 61 deletions(-)
diff --git a/inc/rest/routes/SEORoutes.php b/inc/rest/routes/SEORoutes.php
index f75dc1a..786452a 100644
--- a/inc/rest/routes/SEORoutes.php
+++ b/inc/rest/routes/SEORoutes.php
@@ -1,10 +1,12 @@
<?php
namespace JVBase\rest\routes;
-use JVBase\rest\RestRouteManager;
-use JVBase\managers\CacheManager;
+use JVBase\registrar\Registrar;
+use JVBase\rest\Rest;
+use JVBase\managers\Cache;
use JVBase\managers\SEO\ConfigManager;
use JVBase\managers\SEO\SchemaBuilder;
+use JVBase\rest\Route;
use WP_REST_Request;
use WP_REST_Response;
use WP_Error;
@@ -19,15 +21,15 @@
* Handles REST API endpoints for SEO configuration
* Works with FormController.js for unified form handling
*/
-class SEORoutes extends RestRouteManager
+class SEORoutes extends Rest
{
- protected SchemaBuilder $registry;
+// protected SchemaBuilder $registry;
public function __construct()
{
- $this->cache_name = 'schema';
+ $this->cacheName = 'schema';
parent::__construct();
- $this->registry = SchemaBuilder::getInstance();
+// $this->registry = SchemaBuilder::getInstance();
}
/**
@@ -35,42 +37,23 @@
*/
public function registerRoutes(): void
{
- // Main SEO endpoint - handles save, reset, preview
- register_rest_route($this->namespace, '/seo', [
- [
- 'methods' => 'POST',
- 'callback' => [$this, 'handleSEO'],
- 'permission_callback' => fn() => current_user_can('manage_options'),
- 'args' => [
- 'action' => [
- 'required' => false,
- 'type' => 'string',
- 'default' => 'save',
- 'enum' => ['save', 'reset', 'preview']
- ],
- 'context' => [
- 'required' => true,
- 'type' => 'string',
- 'description' => 'site, business, or content/taxonomy/user type'
- ]
- ]
- ]
- ]);
+ Route::for('seo')
+ ->post([$this, 'handleSEO'])
+ ->auth('admin')
+ ->args([
+ 'action' => 'string|required|enum:save,reset,preview',
+ 'context'=> 'string|required'
+ ])
+ ->rateLimit(30)
+ ->register();
- // Get fields for a schema type (for dynamic type switching)
- register_rest_route($this->namespace, '/seo/fields', [
- [
- 'methods' => 'GET',
- 'callback' => [$this, 'getFields'],
- 'permission_callback' => fn() => current_user_can('manage_options'),
- 'args' => [
- 'type' => [
- 'required' => true,
- 'type' => 'string'
- ]
- ]
- ]
- ]);
+ Route::for('seo/fields')
+ ->get([$this, 'getFields'])
+ ->auth('admin')
+ ->args([
+ 'type'=>'string|required'
+ ])
+ ->register();
}
/**
@@ -138,13 +121,9 @@
}
// Invalidate cache
- $this->cache->invalidate();
+ $this->cache->flush();
- return new WP_REST_Response([
- 'success' => true,
- 'status' => 'completed',
- 'message' => ucfirst($context) . ' settings saved successfully'
- ]);
+ return$this->success(['message'=>ucfirst($context).' settings saved successfully']);
}
/**
@@ -187,13 +166,9 @@
}
// Invalidate cache
- $this->cache->invalidate();
+ $this->cache->flush();
- return new WP_REST_Response([
- 'success' => true,
- 'status' => 'completed',
- 'message' => 'Configuration saved successfully'
- ]);
+ return $this->success(['status'=> 'completed', 'message' => 'Configuration saved successfully']);
}
/**
@@ -224,10 +199,9 @@
}
// Invalidate cache
- $this->cache->invalidate();
+ $this->cache->flush();
- return new WP_REST_Response([
- 'success' => true,
+ return $this->success([
'status' => 'completed',
'message' => 'Reset to defaults successfully',
'meta' => $config->meta(),
@@ -261,8 +235,7 @@
$schema[$fieldName] = $value;
}
- return new WP_REST_Response([
- 'success' => true,
+ return $this->success([
'schema' => $schema
]);
}
@@ -275,10 +248,10 @@
{
$type = $request->get_param('type');
- // Get MetaManager field definitions from registry
+ // Get Meta field definitions from registry
$fields = $this->registry->getMetaConfigForType($type);
- return new WP_REST_Response($fields);
+ return $this->success($fields);
}
/**
@@ -292,6 +265,6 @@
}
// Check if it's a valid content/taxonomy/user type
- return $this->checkContent($context, true);
+ return (bool)Registrar::getInstance($context);
}
}
--
Gitblit v1.10.0