From 772462eeca3002a1d52508aeba485aab2b4742ad Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Tue, 03 Mar 2026 19:06:19 +0000
Subject: [PATCH] =MAJOR OVERHAUL. Likely should have made a new branch ages ago. Key changes: Registrar.php is the base for custom post types, taxonomies, and user roles. Replaces JVB_CONTENT, JVB_TAXONOMY, and JVB_USER constants, eliminates most of Features.php (except for JVB_SITE, JVB_MEMBERSHIP), and has built in sanitizing and validation via sub-classes. Also started a major overhaul of the Schema output. Created a shit ton of property traits and classes to help sanitize and ensure proper data for different schema types. Still a bunch to do, but better to be starting committing changes here on this other branch.
---
checks.php | 208 ++--------------------------------------------------
1 files changed, 8 insertions(+), 200 deletions(-)
diff --git a/checks.php b/checks.php
index 86c7526..60474c3 100644
--- a/checks.php
+++ b/checks.php
@@ -1,171 +1,16 @@
<?php
use JVBase\managers\Cache;
+use JVBase\registrar\Registrar;
use JVBase\utility\Features;
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
{
@@ -190,35 +35,20 @@
return $types;
}
-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());
+ return is_tax(array_map(function ($tax) {
+ return jvbCheckBase($tax);
+ }, Registrar::getFeatured('is_content', 'term')));
}
function taxIsJVBContentTax($tax):bool
{
- $tax = jvbCheckBase($tax);
- return in_array($tax, jvbContentTaxonomies());
+ $allowed = Registrar::getFeatured('is_content', 'term');
+ $tax = jvbNoBase($tax);
+ return in_array($tax, $allowed);
}
-function jvbSiteHasIntegrations():bool
-{
- return array_key_exists('integrations', JVB_SITE) && !empty(JVB_SITE['integrations']);
-}
-
-
function jvbIsOpen():bool
{
@@ -237,28 +67,6 @@
}
-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 = Cache::for('termUtility', 30*60)->connect('taxonomy');
--
Gitblit v1.10.0