From c68aefb847b09daa0697de7684d3451e2e68ce1e Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Thu, 09 Jul 2026 23:10:23 +0000
Subject: [PATCH] =Refactor of Integrations.php to be a bit more useful with a suite of methods for create, update, delete back and forths for integrations where sharing is enabled. Also considering a single instance with a connect method to connect as the site (no user) vs connecting as an individual user - rather than recreating instances for every user.
---
base/Site.php | 99 ++++++++++++++++++++++++++++++++-----------------
1 files changed, 64 insertions(+), 35 deletions(-)
diff --git a/base/Site.php b/base/Site.php
index dfdff4d..f6ecad0 100644
--- a/base/Site.php
+++ b/base/Site.php
@@ -1,8 +1,6 @@
<?php
namespace JVBase\base;
-use JVBase\base\Login;
-
if (!defined('ABSPATH')) {
exit;
}
@@ -14,11 +12,21 @@
protected static Membership $membershipConfig;
protected static Site $instance;
protected static string $icons = 'regular';
+ /**
+ * @var array Dashboard config
+ */
+ protected static string $dashboardTitle;
/**
* @var bool $is_directory Whether this is a membership directory
*/
protected static bool $is_directory = false;
+ protected static string $directory_singular;
+ protected static string $directory_plural;
+ /**
+ * @var bool Whether to add a help menu to the header
+ */
+ protected static bool $help_menu = false;
/**
* @var bool $has_membership Whether this site has membership
*/
@@ -31,10 +39,12 @@
* @var bool $referrals Whether to implement a referral system, with rewards
*/
protected static bool $referrals = false;
+ protected static string $defaultReferralRole = BASE.'client';
/**
* @var bool $magic_link Whether users can login without a password
*/
protected static bool $magic_link = true;
+ protected static string $defaultRole = 'subscriber';
/**
* @var bool $support Whether to implement the support ticket system
*/
@@ -53,6 +63,10 @@
*/
protected static bool $limit_hours = false;
/**
+ * @var bool $has_hours Whether this site has business hours
+ */
+ protected static bool $has_hours = false;
+ /**
* @var bool $enthusiast Whether to scaffold enthusiasts (users that can interact with and save favourites)
*/
protected static bool $enthusiast = false;
@@ -81,7 +95,7 @@
public static function getInstance():Site {
if (!isset(self::$instance)) {
self::$instance = new self();
- do_action('jvbLoadDefinitions');
+ do_action('jvb_define_site');
}
return self::$instance;
}
@@ -116,7 +130,8 @@
public static function has(string $property):bool
{
- return property_exists(self::class, $property) && self::${$property} === true;
+ $inst = self::getInstance();
+ return property_exists($inst, $property) && $inst::${$property} === true;
}
public static function hasAny(array $properties):bool
@@ -200,35 +215,49 @@
}
return self::$membershipConfig;
}
+
+ public function setDashboardTitle(string $title):void
+ {
+ self::$dashboardTitle = $title;
+ }
+
+ public static function dashboardTitle():bool|string
+ {
+ return self::$dashboardTitle ?? false;
+ }
+
+ public function setDirectorySingular(string $title):void
+ {
+ self::$directory_singular = $title;
+ }
+ public static function getDirectorySingular():bool|string
+ {
+ return self::$directory_singular ?? false;
+ }
+
+ public function setDirectoryPlural(string $title):void
+ {
+ self::$directory_plural = $title;
+ }
+ public static function getDirectoryPlural():bool|string
+ {
+ return self::$directory_plural ?? false;
+ }
+
+ public static function setReferralRole(string $role):void
+ {
+ self::$defaultReferralRole = jvbCheckBase($role);
+ }
+ public static function getReferralRole():string
+ {
+ return self::$defaultReferralRole;
+ }
+ public static function setDefaultRole(string $role):void
+ {
+ self::$defaultRole = jvbCheckBase($role);
+ }
+ public static function getDefaultRole():string
+ {
+ return self::$defaultRole;
+ }
}
-
-
-$defaults = [
- 'icons' => 'light',
- 'directory' => false, //as in, a membership directory
- 'membership' => false,
- 'has_map' => false, //TODO: migrate to integrations['gmb']
- 'dashboard' => false,
- 'support' => false,
- 'feed_block' => false,
- 'email_notifications' => false,
- 'integrations' => [
- 'bluesky' => false,
- 'cloudflare' => false,
- 'facebook' => false,
- 'maps' => false,
- 'gmb' => false,
- 'helcim' => false,
- 'instagram' => false,
- 'square' => false,
- 'umami' => false,
- ],
- 'is_restaurant' => false,
- 'limit_hours' => false,
- 'enthusiast' => false,
- 'favourites' => false, //optional flag to allow enthusiasts, but not favourites
-];
-
-$jvb_site = array_merge($defaults, apply_filters('jvb_site', []));
-
-define('JVB_SITE', $jvb_site);
--
Gitblit v1.10.0