From 3d25ad7de4fdbb3eba2cde2a62422e6be5d79a0a Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Tue, 25 Aug 2026 22:57:22 +0000
Subject: [PATCH] =It's been a minute. I went through the Routes and associated Managers and ensured they played together well. Reworked the Cache.php, and I think I caught all the references. Moving away from JVBase() root class, to individuall classes that are Instanced. Double checked for the ABSPATH check in every file, and added index.php to every directory that didn't already have it. Also still working on the MenuBlock to work with WooCommerce for now for Northeh

---
 JVBase.php |  342 +-------------------------------------------------------
 1 files changed, 10 insertions(+), 332 deletions(-)

diff --git a/JVBase.php b/JVBase.php
index 36f94ca..ebbcbc5 100644
--- a/JVBase.php
+++ b/JVBase.php
@@ -5,20 +5,14 @@
 use JVBase\base\SchemaHelper;
 use JVBase\base\Site;
 use JVBase\blocks\CustomBlocks;
-use JVBase\managers\AdminPages;
-use JVBase\managers\ApprovalManager;
-use JVBase\managers\Dashboard\DashboardManager;
+use JVBase\managers\Approvals;
 use JVBase\managers\DirectoryManager;
-use JVBase\managers\EmailManager;
-use JVBase\managers\ErrorHandler;
-use JVBase\managers\FavouritesManager;
+use JVBase\managers\Favourites;
 use JVBase\managers\InvitationsManager;
-use JVBase\managers\LoginManager;
-use JVBase\managers\MagicLinkManager;
+use JVBase\managers\Login;
 use JVBase\managers\NotificationManager;
 use JVBase\managers\queue\Queue;
-use JVBase\managers\ReferralManager;
-use JVBase\managers\RoleManager;
+use JVBase\managers\Referrals;
 use JVBase\managers\SEO\render\SchemaOutput;
 use JVBase\managers\TaxonomyRelationships;
 use JVBase\managers\UserTermsManager;
@@ -31,15 +25,11 @@
 use JVBase\rest\routes\FavouritesRoutes;
 use JVBase\rest\routes\FeedRoutes;
 use JVBase\rest\routes\FormRoutes;
-use JVBase\rest\routes\IntegrationsHelcimRoutes;
-use JVBase\rest\routes\IntegrationsRoutes;
-use JVBase\rest\routes\IntegrationsSquareRoutes;
 use JVBase\rest\routes\Invitations;
 use JVBase\rest\routes\LoginRoutes;
 use JVBase\rest\routes\NewsRoutes;
 use JVBase\rest\routes\NotificationsRoutes;
 use JVBase\rest\routes\OptionsRoutes;
-use JVBase\rest\routes\QueueRoutes;
 use JVBase\rest\routes\ReferralRoutes;
 use JVBase\rest\routes\ResponseRoutes;
 use JVBase\rest\routes\SEORoutes;
@@ -59,23 +49,11 @@
 	protected array $managers = [];
 	protected array $content = [];
 	protected array $taxonomies = [];
-	protected array $integrations = [];
 	protected array $blocks = [];
 	protected array $routes = [];
 	protected CustomBlocks $customBlocks;
 
-	protected array $serviceMap = [
-		'maps' => 'JVBase\integrations\services\GoogleMaps',
-		'square' => 'JVBase\integrations\services\Square',
-		'facebook' => 'JVBase\integrations\services\Facebook',
-		'helcim' => 'JVBase\integrations\services\Helcim',
-		'instagram' => 'JVBase\integrations\services\Instagram',
-		'bluesky' => 'JVBase\integrations\services\BlueSky',
-		'gmb' => 'JVBase\integrations\services\GoogleMyBusiness',
-		'cloudflare' => 'JVBase\integrations\services\Cloudflare',
-		'umami' => 'JVBase\integrations\services\Umami',
-		'postmark' => 'JVBase\integrations\services\PostMark',
-	];
+
 
 	public static function getInstance(): JVB
 	{
@@ -88,177 +66,6 @@
 
 	private function __construct()
 	{
-		$this->customBlocks = new CustomBlocks();
-		$this->managers = [
-			'errors' 	=> new ErrorHandler(),
-			'queue' 	=> new Queue(),
-//            'dash'    => new DashboardManager(),
-			'roles' 	=> new RoleManager(),
-//            'forms'   => new FormManager(),
-//			'schema' 	=> new SchemaOutputManager(),
-			'admin' 	=> new AdminPages(),
-			'seoAdmin' 	=> new SEOAdmin(),
-			'seo'		=> new SchemaOutput(),
-			'schemaHelper' => new SchemaHelper(),
-//			'uploads'	=> new UploadManager(),
-//			'userTerms' => new UserTermsManager(),
-			'email' 	=> new EmailManager(),
-//			'terms'		=> new TaxonomyRelationships(),
-		];
-
-        if (Site::has('feed_block')) {
-            $this->managers['terms'] = new TaxonomyRelationships();
-        }
-
-        if (Site::hasAll(['dashboard', 'membership', 'feed_block'])) {
-            $this->managers['userTerms'] = new UserTermsManager();
-        }
-
-		$this->routes = [
-			'login' => new LoginRoutes(),
-			'integrations' => new IntegrationsRoutes(),
-			'seo' => new SEORoutes(),
-			'queue' => new QueueRoutes(),
-			'settings' => new SettingsRoutes(),
-			'upload' => new UploadRoutes(),
-			'forms' => new FormRoutes(),
-			'user'	=> new UserRoutes()
-		];
-
-		if (Site::has('magic_link')) {
-//			$this->routes['magicLink'] = new MagicLinkRoutes();
-			$this->managers['magicLink'] = new MagicLinkManager();
-		}
-		if (Site::has('referrals')) {
-			$this->managers['referral'] = new ReferralManager();
-			$this->routes['referral'] = new ReferralRoutes();
-		}
-
-
-		if (Site::hasIntegration('square')) {
-			$this->routes['square'] = new IntegrationsSquareRoutes();
-		}
-		if (Site::hasIntegration('helcim')) {
-			$this->routes['helcim'] = new IntegrationsHelcimRoutes();
-		}
-
-		if (Site::has('feed_block')) {
-			$this->routes['feed'] = new FeedRoutes();
-		}
-        $membership = Site::membership();
-		if ($membership && $membership->has('notifications')) {
-			$this->managers['notifications'] = new NotificationManager();
-			$this->routes['notifications'] = new NotificationsRoutes();
-		}
-		if (!empty(Registrar::withFeature('approve_new'))) {
-			$this->managers['approvals'] = new ApprovalManager();
-		}
-		if (Site::has('feed_block') || Site::has('dashboard')) {
-			$this->routes['term'] = new TermRoutes();
-		}
-
-		if (Site::has('is_directory')) {
-			$this->managers['directory'] = new DirectoryManager();
-		}
-
-		if (Site::has('dashboard')) {
-			$this->routes['error'] = new ErrorRoutes();
-            $this->routes['admin']  = new AdminRoutes();
-			$this->routes['content'] = new ContentRoutes();
-//            $this->routes['bio']    = new BioRoutes();
-//			$this->routes['shop'] = new ShopRoutes();
-			$this->routes['contentTax'] = new ContentTermsRoutes();
-			$this->routes['options'] = new OptionsRoutes();
-		}
-
-		if (Site::has('favourites')) {
-			$this->managers['favourites'] = new FavouritesManager();
-			$this->routes['favourites'] = new FavouritesRoutes();
-		}
-
-		if ($membership && $membership->has('forum')) {
-			$this->routes['news'] = new NewsRoutes();
-		}
-		if ($membership && $membership->has('invitable')) {
-			$this->managers['invitations'] = new InvitationsManager();
-		}
-		if (!empty(Registrar::withFeature('has_responses'))) {
-			$this->routes['comments'] = new ResponseRoutes();
-		}
-		if (!empty(Registrar::withFeature('karma'))) {
-			$this->routes['vote'] = new VoteRoutes();
-		}
-		if (!empty(Registrar::withFeature('karma'))
-			|| ($membership && $membership->has('member_verified')) ||
-            ($membership && $membership->has('term_approval'))) {
-			$this->routes['approvals'] = new ApprovalRoutes();
-		}
-		if ($membership && $membership->has('can_invite')) {
-			$this->routes['invites'] = new Invitations();
-		}
-
-
-		if (Site::has('dashboard')) {
-			$this->managers['dash'] = new DashboardManager();
-		}
-
-		$this->setupIntegrations();
-
-		add_action('wp_footer', [$this, 'additionalActions']);
-//        $this->managers['notifications'] = new NotificationManager();
-		// Register activation hook
-		register_activation_hook(JVB_DIR . '/jvb.php', [$this, 'activate']);
-	}
-
-
-	protected function setupIntegrations(): void
-	{
-        foreach(array_keys(Site::getIntegrations()) as $integration) {
-            $this->integrations[$integration] = $this->serviceMap[$integration]::getInstance();
-        }
-	}
-
-	public function registeredContent(): array
-	{
-		return array_merge(array_keys($this->content), array_keys($this->taxonomies));
-	}
-
-	public function favourites(): FavouritesManager|false
-	{
-		return $this->managers['favourites'] ?? false;
-	}
-
-	public function dashboard(): DashboardManager|false
-	{
-		return $this->managers['dash'] ?? false;
-	}
-
-	public function directories(): DirectoryManager|false
-	{
-		return $this->managers['directory'] ?? false;
-	}
-
-	public function error(): ErrorHandler
-	{
-		return $this->managers['errors'];
-	}
-
-	public function file()
-	{
-		return $this->managers['file'];
-	}
-
-	public function queue(): Queue
-	{
-		return $this->managers['queue'];
-	}
-//    public function forms()
-//    {
-//        return $this->managers['forms'];
-//    }
-	public function notification(): NotificationManager|false
-	{
-		return $this->managers['notifications'] ?? false;
 	}
 
 	public function routes($route): mixed
@@ -269,149 +76,20 @@
 		return false;
 	}
 
-	public function roles(): RoleManager
-	{
-		return $this->managers['roles'];
-	}
-
-	public function admin()
-	{
-		return $this->managers['admin'];
-	}
-
-	public function seoAdmin()
-	{
-		return $this->managers['seoAdmin'];
-	}
 
 	public function getFields($type): array
 	{
 		return Registrar::getFieldsFor($type)??[];
 	}
 
+	/**
+	 * @deprecated Should use the Registrar::getInstance
+	 * @param $type
+	 * @return mixed
+	 */
 	public function getContent($type): mixed
 	{
 		return $this->content[$type] ?? $this->taxonomies[$type] ?? $this->blocks[$type] ?? null;
 	}
 
-	public function connect(string $service, ?int $userID = null): mixed
-	{
-//		if ($userID) {
-//			if (!$this->userCanConnect($service, $userID)) {
-//				return null;
-//			}
-//
-//			if (!array_key_exists($service, $this->integrations)) {
-//				return null;
-//			}
-//
-//			return $this->serviceMap[$service]::getInstance($userID);
-//		}
-		$instance = $this->integrations[$service]??null;
-		if ($instance) {
-			$instance->switchUser($userID);
-		}
-		return $instance;
-	}
-
-	public function userCanConnect(string $service, int $userID): bool
-	{
-		$role = jvbUserRole($userID);
-		$registrar = Registrar::getInstance($role);
-		return user_can($userID, 'manage_options') || $registrar->hasIntegration($service);
-	}
-
-	public function getAvailableServices(bool $keys = true): array
-	{
-
-		return ($keys) ? array_keys($this->integrations) : $this->integrations;
-	}
-
-	public function activate(): void
-	{
-		// Activate roles - will be properly initialized after post types are registered
-		$this->roles()->activate();
-	}
-
-	public function addRoute($slug, $class): void
-	{
-		$this->routes[$slug] = $class;
-	}
-
-	public function email(): EmailManager
-	{
-		return $this->managers['email'];
-	}
-
-	public function referrals(): ReferralManager|false
-	{
-		return $this->managers['referral'] ?? false;
-	}
-
-	public function magicLink(): MagicLinkManager|false
-	{
-		return $this->managers['magicLink'] ?? false;
-	}
-
-	public function invitations(): InvitationsManager|false
-	{
-		return $this->managers['invitations'] ?? false;
-	}
-
-	public function additionalActions():void
-	{
-		if (LoginManager::isLogin()) {
-			return;
-		}
-		$extras = apply_filters('jvbAdditionalActions', []);
-		$extras = array_filter($extras, function ($extra) {
-			return is_array($extra) && array_key_exists('button', $extra) && array_key_exists('content', $extra);
-		});
-		if (empty ($extras)) {
-			return;
-		}
-		$buttons = array_map(function ($extra) {
-			return $extra['button'];
-		}, $extras);
-		$contents = array_map(function($extra) {
-			return $extra['content'];
-		}, $extras);
-
-		if (!empty ($buttons)) {
-			?>
-			<section class="main-actions">
-				<div class="buttons col">
-					<?= implode('', $buttons); ?>
-				</div>
-				<div class="actions">
-					<?= implode('', $contents); ?>
-				</div>
-			</section>
-			<?php
-		}
-	}
-
-	public function seo():SchemaOutput
-	{
-		return $this->managers['seo'];
-	}
-
-	public function blocks():CustomBlocks|bool
-	{
-		return $this->customBlocks??false;
-	}
-	public function schemaHelper():SchemaHelper
-	{
-		return $this->managers['schemaHelper'];
-	}
-
-	public function termRelationships():TaxonomyRelationships
-	{
-		return $this->managers['terms'];
-	}
-
-	public function approvals ():ApprovalManager|false
-	{
-		return $this->managers['approvals']??false;
-	}
 }

--
Gitblit v1.10.0