From 42fa8304ddb811b0f725f245130f70c0f5e86a6c Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Tue, 04 Nov 2025 06:12:02 +0000
Subject: [PATCH] =Refactored LoginManager to be more extensible and configurable, as well as an AjaxRateLimiter

---
 inc/helpers/formatting.php |   44 ++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/inc/helpers/formatting.php b/inc/helpers/formatting.php
index 4ac5520..dae808e 100644
--- a/inc/helpers/formatting.php
+++ b/inc/helpers/formatting.php
@@ -1,5 +1,7 @@
 <?php
 
+use JVBase\managers\CacheManager;
+
 if (!defined('ABSPATH')) {
 	exit;
 }
@@ -71,7 +73,7 @@
  */
 function jvbFormatRating(int $ID, JVBase\meta\MetaManager|null $meta = null):string
 {
-    $cache = new JVBase\managers\CacheManager('bio-'.$ID, WEEK_IN_SECONDS);
+    $cache = CacheManager::for('bio-'.$ID, WEEK_IN_SECONDS);
     $key = 'rating';
     $cached = $cache->get($key);
     $cached = false;
@@ -135,7 +137,7 @@
  */
 function jvbImageData(int $imgID):array
 {
-    $cache = new JVBase\managers\CacheManager('image_data', WEEK_IN_SECONDS);
+    $cache = CacheManager::for('imageData', WEEK_IN_SECONDS);
     $cached = $cache->get($imgID);
     if ($cached) {
         return $cached;
@@ -193,3 +195,41 @@
 	list($dollars, $cents) = explode('.', $number);
 	return '$'.$dollars.'.<span>'.$cents.'</span>';
 }
+
+function jvbMailToLink(string $emailTo,
+					   string $subject = 'Contact from Website',
+					   string $message = '',
+					   bool $icon = true,
+					   ?string $linkText = null
+):string
+{
+	if (!is_email($emailTo)) {
+		return '';
+	}
+	$link = 'mailto:'.$emailTo.'?subject='.rawurlencode($subject);
+	if ($message !== '') {
+		$link .= '&body='.rawurlencode($message);
+	}
+	return $link;
+}
+function jvbTextLink(int $phoneNumber, string $message=''):string
+{
+	$length =strlen((string)$phoneNumber);
+	if ($length < 10 || $length > 10) {
+		return '';
+	}
+	$link = 'sms:+1'.$phoneNumber;
+	if ($message !== '') {
+		$link .= '?body='.rawurlencode($message);
+	}
+	return $link;
+}
+
+function jvbPhoneLink(int $phoneNumber):string
+{
+	$length =strlen((string)$phoneNumber);
+	if ($length < 10 || $length > 10) {
+		return '';
+	}
+	return 'tel:+1'.$phoneNumber;
+}

--
Gitblit v1.10.0