From f383c3a4325bc173b6f9676274bc19694be6f9c0 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Fri, 05 Jun 2026 16:49:44 +0000
Subject: [PATCH] =Modified the Feed Fields config in Registrar, to utilize the built in functionality there

---
 content/progress.php |   94 +++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 86 insertions(+), 8 deletions(-)

diff --git a/content/progress.php b/content/progress.php
index 5410ddc..7f910eb 100644
--- a/content/progress.php
+++ b/content/progress.php
@@ -183,13 +183,25 @@
             ]
         ]
     );
-
-    $directory = $progress->config('directory');
-    $directory->setDirectoryExtra([
-         'goal',
+    $feed->setFields([
+        'post_title',
+        'post_date',
+        'post_modified',
+        'post_excerpt',
+        'goal',
+        'body_part',
         'skin_type',
-        'age'
+        'age',
+        'style',
+        'theme',
     ]);
+
+//    $directory = $progress->config('directory');
+//    $directory->setDirectoryExtra([
+//         'goal',
+//        'skin_type',
+//        'age'
+//    ]);
 }
 
 function altr_progressTitleAlts():array
@@ -629,6 +641,72 @@
 //        'upload_title' => 'Upload Before & Afters',
 //    ];
 //}
+function altr_render_progress_field_post_modified(?int $ID = null, bool $isTemplate = false):string
+{
+    $points = is_null($ID) ? [] : jvbTimelinePoints($ID, BASE.'progress');
+    $value = '';
+    if (!empty($points)){
+        $last = $points[array_key_last($points)];
+        $lastMeta = Meta::forPost($last);
+        $value = $lastMeta->get('post_date');
+    }
+    return $isTemplate || !empty($value) ? sprintf(
+         '<div class="row left"><span class="label">Last Treated:</span><time data-field="post_modified"%s>%s</time></div>',
+        date('c', strtotime($value)),
+        date('M Y', strtotime($value))
+    ) : '';
+}
+function altr_render_progress_field_post_date(?int $ID = null, bool $isTemplate = false):string
+{
+    $meta = ($ID) ? Meta::forPost($ID) : false;
+    $value = ($meta) ? $meta->get('post_date') : '';
+    return $isTemplate || !empty($value) ? sprintf(
+        '<div class="row left"><span class="label">Started:</span><time data-field="post_date"%s>%s</time></div>',
+        date('c', strtotime($value)),
+        date('M Y', strtotime($value))
+    ) : '';
+}
+function altr_render_progress_feed_item_images(?int $ID = null, array $images = []):string
+{
+    $meta = ($ID) ? Meta::forPost($ID) : false;
+    $points = is_null($ID) ? [] : get_children([
+        'post_parent'   => $ID,
+        'post_type'     => BASE.'progress',
+        'post_status'   => 'publish',
+        'orderby'       => 'date',
+        'order'         => 'ASC',
+        'fields'        => 'ids',
+    ]);
+
+    $lastImg = '';
+    if (!empty($points)) {
+        $last = $points[array_key_last($points)];
+        $lastMeta = Meta::forPost($last);
+        $lastImg = $lastMeta->get('post_thumbnail');
+    }
+
+    $defaultBefore = '<img data-field="before" width="300px" height="300px" loading="lazy" decoding="async">';
+    $defaultAfter = '<img data-field="after" width="300px" height="300px" loading="lazy" decoding="async">';
+
+    $total = count($points);
+    return sprintf(
+        '<span class="before-text">Before</span>
+        %s%s
+        <span class="after-text">After%s</span>',
+        $meta ? str_replace('<img', '<img data-field="before" class="before"',jvbFormatImage($meta->get('post_thumbnail'), 'tiny', 'medium')) : $defaultBefore,
+        !empty($lastImg) ? str_replace('<img', '<img data-field="after" class="after"',jvbFormatImage($lastImg, 'tiny', 'medium')) : $defaultAfter,
+        empty($points) ? '' : ' '.$total.' Tx'
+    );
+
+}
+
+add_filter('jvbFeedItemData', 'altr_progress_item_data', 10, 2);
+function altr_progress_item_data(string $out, string $content) {
+    if ($content === 'progress') {
+        return ' data-timeline';
+    }
+    return $out;
+}
 
 add_filter('jvbFeedItem', 'altr_progress_item', 10, 2);
 
@@ -713,11 +791,11 @@
         $after = jvbIcon('logo-triangle-fill').jvbFormatImage(get_post_thumbnail_id($last),'tiny','directory-preview',false);
     }
 
-    return '<li class="row btw">
+    return '<li class="row x-btw">
         
                     <a href="'.$item['url'].'" title="More about '.$item['name'].'">
-                        '.$item['name'].'</a>'.$extra.'
-                        <div class="image">'.$before.$after.'</div>
+                        '.$item['name'].'</a>
+                        <div class="image">'.$before.$after.'</div>'.$extra.'
                 </li>';
 }
 

--
Gitblit v1.10.0