From 3b83905603d44b1a08f8b2b36a605808ce686ad6 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Tue, 02 Jun 2026 00:46:48 +0000
Subject: [PATCH] =double checking schema outputs for legacytattooremoval
---
inc/helpers/formatting.php | 33 ++++++++++++++++++---------------
1 files changed, 18 insertions(+), 15 deletions(-)
diff --git a/inc/helpers/formatting.php b/inc/helpers/formatting.php
index 6f7f077..d294044 100644
--- a/inc/helpers/formatting.php
+++ b/inc/helpers/formatting.php
@@ -1,6 +1,7 @@
<?php
use JVBase\managers\Cache;
+use JVBase\meta\Meta;
use JVBase\utility\Image;
if (!defined('ABSPATH')) {
@@ -40,6 +41,9 @@
{
$count = count($arr);
$and = ($and) ? ' and ' : ' or ';
+ if (empty($arr)){
+ return '';
+ }
switch ($count) {
case '1':
return implode(',', $arr);
@@ -68,11 +72,10 @@
/**
* @param int $ID
- * @param JVBase\meta\MetaManager|null $meta
- *
+ * @param string $type 'post', 'user', or 'term'
* @return string
*/
-function jvbFormatRating(int $ID, JVBase\meta\MetaManager|null $meta = null):string
+function jvbFormatRating(int $ID, string $type = 'post'):string
{
$cache = Cache::for('rating', WEEK_IN_SECONDS)->connect('post')->connect('taxonomy')->connect('user');
@@ -81,21 +84,21 @@
return $cached;
}
- if (!$meta) {
- if (term_exists((int)$ID)) {
- $type = 'term';
- } elseif (get_post_status((int)$ID)) {
- $type = 'post';
- } else {
- $type = 'user';
- }
- $meta = new JVBase\meta\MetaManager($ID, $type);
- }
+ $meta = match ($type) {
+ 'term' => Meta::forTerm($ID),
+ 'post' => Meta::forPost($ID),
+ 'user' => Meta::forUser($ID),
+ default => false
+ };
+ if (!$type) {
+ return '';
+ }
+
$out = '';
- $avg = $meta->getValue('average_rating');
+ $avg = $meta->get('average_rating');
- $total = $meta->getValue('total_ratings');
+ $total = $meta->get('total_ratings');
if ($avg !== 'none') {
$out .= jvbFormatStarRating($avg, (int)$total);
}
--
Gitblit v1.10.0