From f94860aacd6200fb24c9e7431eb379a368cb392d Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Fri, 10 Jul 2026 00:35:44 +0000
Subject: [PATCH] =Refactored CredentialsManager.php to utilize a CustomTable instance instead
---
inc/integrations/Umami.php | 24 +++++++++++++++++-------
1 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/inc/integrations/Umami.php b/inc/integrations/Umami.php
index 0fa280b..4afb1d5 100644
--- a/inc/integrations/Umami.php
+++ b/inc/integrations/Umami.php
@@ -1,7 +1,7 @@
<?php
namespace JVBase\integrations;
-use JVBase\managers\CacheManager;
+use JVBase\managers\Cache;
use WP_Error;
use WP_Post;
use Exception;
@@ -35,7 +35,17 @@
private string $events_table;
private string $metrics_table;
- public function __construct(?int $userID = null)
+ protected static array $instances = [];
+ public static function getInstance(?int $userID = null):self
+ {
+ $key = is_null($userID) ? 'base' : $userID;
+ if (!array_key_exists($key, self::$instances)) {
+ self::$instances[$key] = new static($userID);
+ }
+ return self::$instances[$key];
+ }
+
+ protected function __construct(?int $userID = null)
{
$this->service_name = 'umami';
$this->title = 'Umami.js';
@@ -138,14 +148,14 @@
*/
public function renderTrackingScript(): void
{
+ // Skip on local environments
+ if (JVB_TESTING) {
+ return;
+ }
if (!$this->isSetUp() || is_admin()) {
return;
}
- // Skip on local environments
- if (strpos(get_home_url(), JVB_LOCAL) !== false) {
- return;
- }
$script_url = $this->getTrackingScriptUrl();
$website_id = $this->getWebsiteId();
@@ -677,7 +687,7 @@
if ($data) {
// Clear cache for today
$cache_key = md5("analytics_{$today}_{$today}");
- $this->cache->delete($cache_key);
+ $this->cache->forget($cache_key);
return [
'success' => true,
--
Gitblit v1.10.0