From 2bb9aaaf24b794b528e3894ee9f9c42ca6d7fe93 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Thu, 01 Jan 2026 21:08:58 +0000
Subject: [PATCH] =FeedRoutes: extractTaxonomies added
---
inc/helpers/formatting.php | 64 ++++++++++++++++++++++++++------
1 files changed, 52 insertions(+), 12 deletions(-)
diff --git a/inc/helpers/formatting.php b/inc/helpers/formatting.php
index 4ac5520..ec0c40f 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,9 +73,9 @@
*/
function jvbFormatRating(int $ID, JVBase\meta\MetaManager|null $meta = null):string
{
- $cache = new JVBase\managers\CacheManager('bio-'.$ID, WEEK_IN_SECONDS);
- $key = 'rating';
- $cached = $cache->get($key);
+ $cache = CacheManager::for('rating', WEEK_IN_SECONDS)->connectTo('post')->connectTo('term');
+
+ $cached = $cache->get($ID);
$cached = false;
if ($cached) {
return $cached;
@@ -98,7 +100,7 @@
$out .= jvbFormatStarRating($avg, (int)$total);
}
- $cache->set($key, $out);
+ $cache->set($ID, $out);
return $out;
}
@@ -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)->connectTo('post');
$cached = $cache->get($imgID);
if ($cached) {
return $cached;
@@ -145,13 +147,13 @@
return [];
}
$image = [
- 'tiny' => wp_get_attachment_image_src($imgID, 'tiny')[0],
- 'small' => wp_get_attachment_image_src($imgID, 'medium')[0],
- 'medium' => wp_get_attachment_image_src($imgID, 'large')[0],
- 'large' => wp_get_attachment_image_src($imgID, 'full')[0],
- 'alt' => get_post_meta($imgID, '_wp_attachment_image_alt', true),
- 'title' => get_the_title($imgID),
- 'caption' => get_the_excerpt($imgID),
+ 'tiny' => wp_get_attachment_image_src($imgID, 'tiny')[0],
+ 'small' => wp_get_attachment_image_src($imgID, 'medium')[0],
+ 'medium' => wp_get_attachment_image_src($imgID, 'large')[0],
+ 'large' => wp_get_attachment_image_src($imgID, 'full')[0],
+ 'image-alt-text'=> get_post_meta($imgID, '_wp_attachment_image_alt', true),
+ 'image-title' => get_the_title($imgID),
+ 'image-caption' => get_the_excerpt($imgID),
];
$cache->set($imgID, $image);
return $image;
@@ -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