From f4be611c51473359e6d41780f0313c446079e9d3 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Tue, 09 Jun 2026 15:19:24 +0000
Subject: [PATCH] =Switched the /base/options.php to the same pattern as Site.php: a class based approached rather than a filter. Updated Meta.php to play along with the defined fields from there in Meta::forOptions. Had to change openingHoursSpecificationsTrait.php to not use the translater functions __('text','textdomain') for now, as we load before init.

---
 checks.php |  288 ++++++---------------------------------------------------
 1 files changed, 32 insertions(+), 256 deletions(-)

diff --git a/checks.php b/checks.php
index 3c6ee74..79cc829 100644
--- a/checks.php
+++ b/checks.php
@@ -1,287 +1,63 @@
 <?php
 
-use JVBase\managers\CacheManager;
-use JVBase\utility\Features;
+use JVBase\base\Options;
+use JVBase\base\Site;
+use JVBase\managers\Cache;
+use JVBase\registrar\Registrar;
 
 if (!defined('ABSPATH')) {
 	exit;
 }
-function jvbCheck(string $key, $config = [])
+function jvbCheck(string $key, $config = []):bool
 {
     return (array_key_exists($key, $config) && $config[$key] === true);
 }
-/**
- * Tests whether this site needs forum functionality
- * @return bool
- */
-function jvbSiteHasForum():bool
-{
-    return jvbCheck('forum', JVB_MEMBERSHIP);
-}
-
-function jvbSiteUsesSquare():bool
-{
-	return jvbSiteHasIntegrations() && jvbCheck('square', JVB_SITE['integrations']);
-}
-function jvbSiteUsesGoogleBusiness():bool
-{
-	return jvbSiteUsesGMB();
-}
-
-function jvbSiteHasFavourites():bool
-{
-	return jvbCheck('favourites', JVB_SITE);
-}
-
-/**
- * Tests whether this site has a custom dashboard
- * @return bool
- */
-function jvbSiteHasDashboard():bool
-{
-    return jvbCheck('dashboard', JVB_SITE);
-}
-
-function jvbSiteHasKarma():bool
-{
-    global $jvb_karma;
-    return (!empty($jvb_karma['content']) || !empty($jvb_karma['taxonomy']));
-}
-
-function jvbSiteHasSupport():bool
-{
-    return  jvbCheck('has_support', JVB_SITE);
-}
-
-function jvbSiteHasInvitations():bool
-{
-    return jvbCheck('can_invite', JVB_MEMBERSHIP);
-}
-
-function jvbSiteHasMemberApproval():bool
-{
-    return jvbCheck('member_verified', JVB_MEMBERSHIP);
-}
-
-function jvbSiteHasMembership():bool
-{
-    return jvbCheck('has_membership', JVB_SITE);
-}
-
-function jvbSiteHasResponse():bool
-{
-    global $jvb_responses;
-    return (!empty($jvb_responses['content']) || !empty($jvb_responses['taxonomy']));
-}
-
-function jvbSiteUsesFeedBlock():bool
-{
-    return jvbCheck('use_feed_block', JVB_SITE);
-}
-
-function jvbSiteCanFavourite():bool
-{
-    return jvbCheck('enthusiast', JVB_SITE) && jvbCheck('favourites', JVB_SITE);
-}
-
-function jvbSiteUsesUmami():bool
-{
-    return jvbSiteHasIntegrations() && jvbCheck('umami', JVB_SITE['integrations']);
-}
-function jvbSiteUsesCloudflare():bool
-{
-	return jvbSiteHasIntegrations() && jvbCheck('cloudflare', JVB_SITE['integrations']);
-}
-
-function jvbSiteUsesFacebook():bool
-{
-	return jvbSiteHasIntegrations() && jvbCheck('facebook', JVB_SITE['integrations']);
-}
-function jvbSiteUsesInstagram():bool
-{
-	return jvbSiteHasIntegrations() && jvbCheck('instagram', JVB_SITE['integrations']);
-}
-function jvbSiteUsesBluesky():bool
-{
-	return jvbSiteHasIntegrations() && jvbCheck('bluesky', JVB_SITE['integrations']);
-}
-function jvbSiteUsesGMB():bool
-{
-	return jvbSiteHasIntegrations() && jvbCheck('gmb', JVB_SITE['integrations']);
-}
-function jvbSiteUsesHelcim():bool
-{
-	return jvbSiteHasIntegrations() && jvbCheck('helcim', JVB_SITE['integrations']);
-}
-
-function jvbSiteUses(string $key):bool
-{
-	return jvbCheck($key, JVB_SITE);
-}
-
-function jvbSiteUsesMaps():bool
-{
-	return true;
-}
-
-function jvbSiteHasTermContent():bool
-{
-    return (!empty(array_keys(array_filter(JVB_TAXONOMY, function ($taxonomy) {
-        return jvbCheck('is_content', $taxonomy);
-    }))));
-}
-
-function jvbSiteHasNotifications():bool
-{
-    return jvbCheck('notifications', JVB_MEMBERSHIP);
-}
-
-function jvbUserCanCreate(int $userID = 0):bool
-{
-    $user = ($userID === 0) ? wp_get_current_user() : get_userdata($userID);
-    $roles = array_intersect(
-        jvbRolesWithDashboard(),
-        array_map(function ($role) {
-            return jvbNoBase($role);
-        },
-            $user->roles)
-    );
-    $creatable = [];
-    foreach ($roles as $role) {
-        $creatable = array_merge($creatable, JVB_USER[$role]['can_create']??[]);
-    }
-
-    $creatable = jvbExtractUserContent($creatable);
-    return !empty($creatable);
-}
-
-function jvbRolesWithDashboard():array
-{
-    return array_keys(array_filter(JVB_USER, function ($role) {
-        return jvbCheck('has_dashboard', $role);
-    }));
-}
-
-function jvbSiteHasTermApproval():bool
-{
-    return jvbCheck('terms_approval', JVB_MEMBERSHIP);
-}
-
-function jvbUserIsVerified():bool
-{
-    return !(Features::forMembership()->has('member_verified')) || current_user_can('skip_moderation');
-}
 
 function jvbUserTypes():array
 {
-	$types = get_option(BASE.'user_types');
-	if (JVB_TESTING) {
-		$types = false;
-	}
-	if ($types === false) {
-		$types = [];
-		foreach (JVB_USER as $type => $config) {
-			if (array_key_exists('profile', $config)) {
-				$types[$type] = BASE.$config['profile'];
-			}
-		}
-		update_option(BASE.'user_types', $types);
-	}
-	return $types;
+	return  Registrar::withFeature('profile_link', 'user');
 }
 
-function isJVBUserType():bool
-{
-	return (is_singular(jvbUserTypes()) || is_post_type_archive(jvbUserTypes()));
-}
-
-function contentIsJVBUserType(string $content):bool
-{
-	$content = jvbCheckBase($content);
-	return in_array($content, jvbUserTypes());
-}
-
-
-function isJVBContentTax():bool
-{
-	return is_tax(jvbContentTaxonomies());
-}
-
-function taxIsJVBContentTax($tax):bool
-{
-	$tax = jvbCheckBase($tax);
-	return in_array($tax, jvbContentTaxonomies());
-}
-
-function jvbSiteHasIntegrations():bool
-{
-	return array_key_exists('integrations', JVB_SITE) && !empty(JVB_SITE['integrations']);
-}
 
 
 function jvbIsOpen():bool
 {
-
-	if (!jvbCheck('limit_hours', JVB_SITE)) {
+	if (!Site::has('limit_hours')) {
 		return true;
 	}
-	if (get_option(BASE.'open_to_public') !== '1') {
+	if (Options::get('open_to_public') !== 1) {
+		error_log('Not open to public');
 		return false;
 	}
-	//Check if today_hours is set
-	if (get_option(BASE.'today_hours')) {
+	if (Options::get('today_hours')) {
 		return jvbIsTimeBetween();
 	}
-	//Default to the stored settings
 	return jvbIsCurrentlyOpen();
 }
 
 
-function jvbIsValidType(string $type):bool {
-
-	return (array_key_exists($type, JVB_CONTENT) ||
-		array_key_exists($type, JVB_TAXONOMY) ||
-		array_key_exists($type, JVB_USER) ||
-		$type === 'options');
-}
-
-function jvbGetObjectType(string $type):string {
-	if (array_key_exists($type, JVB_CONTENT)) {
-		return 'post';
-	} elseif (array_key_exists($type, JVB_TAXONOMY)) {
-		return 'term';
-	} elseif (array_key_exists($type, JVB_USER)) {
-		return 'user';
-	} elseif ($type === 'options') {
-		return 'options';
-	}
-	return '';
-}
-
-
 function jvbTermHasPosts(int $termID, string $taxonomy):bool
 {
-	$cache = CacheManager::for('terms', 30*60)->connectTo('taxonomy');
-	$key = $termID.$taxonomy;
-	$cached = $cache->get($key);
-	if ($cached) {
-		return ($cached === 'true');
-	}
-	$taxonomy = jvbCheckBase($taxonomy);
-	$tax = get_taxonomy($taxonomy);
-	$query = new WP_Query([
-		'post_type'	=> $tax->object_type,
-		'posts_per_page'	=> 1,
-		'fields'	=> 'id',
-		'tax_query'	=> [
-			[
-				'taxonomy'	=> $taxonomy,
-				'terms'	=> $termID
-			]
-		]
-	]);
-	$result = ($query->have_posts()) ? 'true': 'false';
-	wp_reset_postdata();
-	$cache->set($key, $result);
-	return $result === 'true';
+	$cache = Cache::for('termUtility', 30*60)->connect('taxonomy');
+	return $cache->remember(
+		$termID,
+		function() use($taxonomy, $termID) {
+			$taxonomy = jvbCheckBase($taxonomy);
+			$tax = get_taxonomy($taxonomy);
+			$query = new WP_Query([
+				'post_type'	=> $tax->object_type,
+				'posts_per_page' => 1,
+				'fields' => 'ids',
+				'tax_query'	=> [
+					[
+						'taxonomy' => $taxonomy,
+						'terms'	=> $termID
+					]
+				]
+			]);
+			$result = ($query->have_posts()) ? 'true' : 'false';
+			wp_reset_postdata();
+			return $result;
+		}
+	);
 }

--
Gitblit v1.10.0