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/integrations/Integrations.php |   39 +++++++++++++++------------------------
 1 files changed, 15 insertions(+), 24 deletions(-)

diff --git a/inc/integrations/Integrations.php b/inc/integrations/Integrations.php
index 9f7f851..e059b5e 100644
--- a/inc/integrations/Integrations.php
+++ b/inc/integrations/Integrations.php
@@ -2,9 +2,9 @@
 namespace JVBase\integrations;
 
 use Exception;
-use JVBase\managers\CacheManager;
-use JVBase\managers\UploadManager;
-use JVBase\meta\MetaManager;
+use JVBase\managers\Cache;
+use JVBase\meta\Form;
+use JVBase\meta\Meta;
 use JVBase\managers\ErrorHandler;
 use WP_Error;
 use WP_Post;
@@ -96,7 +96,7 @@
 	 * Caching Configuration
 	 */
 	protected ?string $cacheName = null;
-	protected CacheManager $cache;
+	protected Cache $cache;
 	protected array $cacheStrategy = [
 		'aggressive' => 3600,  // 1 hour for stable data (e.g., profile info)
 		'moderate' => 300,     // 5 minutes for semi-dynamic data (e.g., posts)
@@ -167,7 +167,7 @@
 	{
 		$this->cacheName = $this->cacheName ?: $this->service_name;
 		$this->userID = $userID;
-		$this->cache = CacheManager::for('integrations_' . $this->cacheName, $this->ttl);
+		$this->cache = Cache::for('integrations_' . $this->cacheName, $this->ttl);
 
 		// Load error stats from cache
 		$this->loadErrorStats();
@@ -669,7 +669,7 @@
 
 	protected function clearCache():array
 	{
-		$success = $this->cache->clear();
+		$success = $this->cache->flush();
 		return [
 			'success'	=> $success,
 		];
@@ -2081,20 +2081,11 @@
 	 */
 	protected function mapFieldsToService(int $postID, array $mapping): array
 	{
-		$meta_manager = new MetaManager($postID, 'post');
-		$post = get_post($postID);
+		$meta_manager = Meta::forPost($postID);
 		$service_data = [];
 
 		foreach ($mapping as $wp_field => $service_field) {
-			$value = null;
-
-			// Check if it's a post field
-			if (property_exists($post, $wp_field)) {
-				$value = $post->$wp_field;
-			} else {
-				// It's a meta field
-				$value = $meta_manager->getValue($wp_field);
-			}
+			$value = $meta_manager->get($wp_field);
 
 			if ($value !== null && $value !== '') {
 				$this->setNestedValue($service_data, $service_field, $value);
@@ -2169,7 +2160,7 @@
 
 	protected function getSyncFields(int $postID, string $type, array $additional = []):array
 	{
-		$meta = new MetaManager($postID, $type);
+		$meta = new Meta($postID, $type);
 		$fieldsToCheck = [
 			'share_to_' . $this->service_name,
 			'_keep_synced_' . $this->service_name,
@@ -2930,7 +2921,7 @@
 			return '';
 		}
 
-		$meta = new MetaManager($this->userID, 'integrations');
+		$meta = Meta::forOptions($this->userID.'_integrations');
 		$is_connected = $this->isSetUp();
 		$credentials = $this->getCredentials();
 
@@ -3007,7 +2998,7 @@
 						$config['value'] = $credentials[$name]??'';
 						$config['autocomplete'] = 'off';
 						$config['base'] = $this->service_name.'_';
-						$meta->render('form', $name, $config);
+						Form::render($name, null, $config);
 					}
 				}
 				if ($this->handleWebhooks) {
@@ -3038,7 +3029,7 @@
 							$config['value'] = $credentials[$name]??'';
 							$config['base'] = $this->service_name.'_';
 							$config['autocomplete'] = 'off';
-							$meta->render('form', $name, $config);
+							Form::render($name,null, $config);
 						}
 						?>
 					</details>
@@ -3277,7 +3268,7 @@
 		if (empty($types)) {
 			return;
 		}
-		$meta = new MetaManager($this->userID, 'integrations');
+		$meta = Meta::forOptions($this->userID.'_integrations');
 		?>
 		<form>
 			<h1><?= $this->title?> Defaults:</h1>
@@ -3289,7 +3280,7 @@
 
 				$config['base'] = $this->service_name.'_';
 				$config['autocomplete'] = 'off';
-				$meta->render('form', $name, $config);
+				echo Form::render($name, null, $config);
 			}
 			foreach ($this->syncPostTypes as $type) {
 				$config = JVB_CONTENT[$type];
@@ -3309,7 +3300,7 @@
 							$c['hint'] = $c['description'];
 							unset($c['description']);
 						}
-						$meta->render('form', $name, $c);
+						echo Form::render($name, null, $c);
 					}
 					?>
 				</details>

--
Gitblit v1.10.0