From 86c6cd3cc099d2480932ede03c12cea01e625c94 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sun, 26 Apr 2026 21:56:28 +0000
Subject: [PATCH] =Requiring files based on Site class settings

---
 inc/rest/routes/ShopRoutes.php |   41 +++++++++++++++++++++--------------------
 1 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/inc/rest/routes/ShopRoutes.php b/inc/rest/routes/ShopRoutes.php
index 1290231..780b253 100644
--- a/inc/rest/routes/ShopRoutes.php
+++ b/inc/rest/routes/ShopRoutes.php
@@ -4,8 +4,9 @@
 use JVBase\JVB;
 use JVBase\managers\ImageGenerator;
 use JVBase\managers\UploadManager;
+use JVBase\registrar\Registrar;
 use JVBase\rest\RestRouteManager;
-use JVBase\meta\MetaManager;
+use JVBase\meta\Meta;
 use WP_REST_Request;
 use WP_REST_Response;
 use WP_Error;
@@ -16,6 +17,7 @@
 }
 
 /***
+ * @deprecated
  * WORKFLOW:
  *      1) Users with 'manage_shop' permissions can invite folks to this shop
  *      2) If user is already a registered member:
@@ -148,8 +150,8 @@
             ];
         }
 
-        $meta = new MetaManager($shop, BASE.'shop');
-		$allowed = jvbGetFields('shop', 'term');
+        $meta = Meta::forTerm($shop);
+		$allowed = Registrar::getFieldsFor('shop');
 		$setData = array_filter(
 			$data,
 			function ($key) use ($allowed) {
@@ -166,13 +168,13 @@
 				unset($setData['shop']);
 			}
 			if (array_intersect(array_keys($data), ['image_portrait', 'shop', 'city', 'type', 'top_style','display_name'])) {
-                if (array_key_exists('image_portrait', $data) || $meta->getValue('image_portrait') !== '') {
+                if (array_key_exists('image_portrait', $data) || $meta->get('image_portrait') !== '') {
                     $this->checkGenerateThumbnail($user_id, $this->buildThumbnailData($user_id));
                 }
             }
 		}
 
-		$results = $meta->setAll($setData);
+		$meta->setAll($setData);
 
 //        $results = [];
 //
@@ -184,13 +186,13 @@
 //            } else {
 //                if ($name === 'shop') {
 //                    JVB()->routes('shop')->requestShopAdmission($operation->user_id, $value);
-//                    $results[] = $meta->updateValue('requested_shop', $value);
+//                    $results[] = $meta->set('requested_shop', $value);
 //                }
 //
 //            }
 //
 //            if (array_intersect(array_keys($data), ['image_portrait', 'shop', 'city', 'type', 'top_style','display_name'])) {
-//                if (array_key_exists('image_portrait', $data) || $meta->getValue('image_portrait') !== '') {
+//                if (array_key_exists('image_portrait', $data) || $meta->get('image_portrait') !== '') {
 //                    $this->checkGenerateThumbnail($user_id, $this->buildThumbnailData($user_id));
 //                }
 //            }
@@ -226,8 +228,8 @@
             $data['name'] = $shop->name;
         }
         if (!array_key_exists('city', $data)) {
-            $meta = new MetaManager($data['shop'], 'term');
-            $city = $meta->getValue('city');
+            $meta = Meta::forTerm($data['shop']);
+            $city = $meta->get('city');
             if ($city !== '') {
                 $city = get_term($city, BASE.'city');
                 if ($city && !is_wp_error($city)) {
@@ -531,7 +533,7 @@
             return;
         }
         // Get shop managers
-        $shopMeta = new MetaManager($shopID, 'term');
+        $shopMeta = Meta::forTerm($shopID, 'term');
 		$owners = $shopMeta->getAll(['managers', 'owner']);
 
         $owners = array_unique(array_merge($owners['managers'], $owners['owner']));
@@ -1218,7 +1220,7 @@
 
             // Create a notification for the shop owner/manager
             $shop_name = get_term($shop_id, BASE . 'shop')->name;
-            $shop_meta = new MetaManager($shop_id, 'term');
+            $shop_meta = Meta::forTerm($shop_id);
 			$owners = $shop_meta->getAll(['owner', 'managers']);
 			$owners = array_unique(array_merge(explode(',', $owners['owner']),explode(',', $owners['managers'])));
 
@@ -1345,10 +1347,10 @@
 
 
         $userLink = get_user_meta($user, BASE . 'link', true);
-        $userMeta = new MetaManager($user, 'user');
-        $artistMeta = new MetaManager($userLink, 'post');
+        $userMeta = Meta::forUser($user);
+        $artistMeta = Meta::forPost($userLink);
 
-        $shopMeta = new MetaManager($shop, 'term');
+        $shopMeta = Meta::forTerm($shop);
 
         error_log('Setting '.$type.' permissions:'.print_r([
             'userLink'  => $userLink,
@@ -1365,7 +1367,7 @@
         $user->add_cap('manage_shop', $grant);
         $user->add_cap('manage_shop_'.$shop, $grant);
 
-        $shops = $userMeta->getValue($uMeta);
+        $shops = $userMeta->get($uMeta);
         $shops = ($shops === '') ? [] : explode(',', $shops);
         if ($grant) {
             if (!in_array($shop, $shops)) {
@@ -1381,18 +1383,17 @@
         $shops = implode(',', $shops);
 
 
-        $userMeta->updateValue($uMeta, $shops);
+        $userMeta->set($uMeta, $shops);
 
-        $artistMeta->updateValue($aMeta, $shops);
+        $artistMeta->set($aMeta, $shops);
 
-        $owners = $shopMeta->getValue($sMeta);
+        $owners = $shopMeta->get($sMeta);
         $owners = ($owners === '') ? [] : explode(',', $shops);
         if (!in_array($user->ID, $owners)) {
             $owners[] = $user->ID;
         }
         $owners = implode(',', $owners);
-        $shopMeta->updateValue($sMeta, $owners);
-
+        $shopMeta->set($sMeta, $owners);
         return true;
     }
 }

--
Gitblit v1.10.0