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.
---
inc/integrations/Cloudflare.php | 19 +++++++++++--------
1 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/inc/integrations/Cloudflare.php b/inc/integrations/Cloudflare.php
index 8b2bc13..ed37f69 100644
--- a/inc/integrations/Cloudflare.php
+++ b/inc/integrations/Cloudflare.php
@@ -1,7 +1,6 @@
<?php
namespace JVBase\integrations;
-use JVBase\meta\MetaManager;
use WP_Error;
if (!defined('ABSPATH')) {
exit;
@@ -14,7 +13,17 @@
private string $theme = 'light';
private string $size = 'normal';
- public function __construct()
+ 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 self($userID);
+ }
+ return self::$instances[$key];
+ }
+
+ protected function __construct()
{
$this->service_name = 'cloudflare';
$this->title = 'Cloudflare Turnstile';
@@ -254,10 +263,4 @@
// Cloudflare Turnstile uses POST parameters, not headers
return [];
}
-
- protected function getApiUrl(string $endpoint, ?string $baseKey = null): string
- {
- // Only used for direct API calls, not through base class methods
- return 'https://challenges.cloudflare.com/turnstile/v0/siteverify';
- }
}
--
Gitblit v1.10.0