From 2127b1bdd73ecd2423e443992da4b442f5a3c1a3 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Wed, 04 Feb 2026 21:19:25 +0000
Subject: [PATCH] =Major overhaul of MetaManager.php -> Meta.php and RestRouteManager.php -> Rest.php. Seems to work for JakeVan

---
 inc/rest/routes/SEORoutes.php |   86 ++++++++++++++-----------------------------
 1 files changed, 28 insertions(+), 58 deletions(-)

diff --git a/inc/rest/routes/SEORoutes.php b/inc/rest/routes/SEORoutes.php
index f75dc1a..e5154ed 100644
--- a/inc/rest/routes/SEORoutes.php
+++ b/inc/rest/routes/SEORoutes.php
@@ -1,10 +1,11 @@
 <?php
 namespace JVBase\rest\routes;
 
-use JVBase\rest\RestRouteManager;
-use JVBase\managers\CacheManager;
+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,13 +20,13 @@
  * 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;
 
 	public function __construct()
 	{
-		$this->cache_name = 'schema';
+		$this->cacheName = 'schema';
 		parent::__construct();
 		$this->registry = SchemaBuilder::getInstance();
 	}
@@ -35,42 +36,21 @@
 	 */
 	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);
 
-		// 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'
+			]);
 	}
 
 	/**
@@ -138,13 +118,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 +163,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 +196,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 +232,7 @@
 			$schema[$fieldName] = $value;
 		}
 
-		return new WP_REST_Response([
-			'success' => true,
+		return $this->success([
 			'schema' => $schema
 		]);
 	}
@@ -275,10 +245,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);
 	}
 
 	/**

--
Gitblit v1.10.0