From 76d68c97f572120dc75d0501cc82acf4022d6b33 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Tue, 23 Dec 2025 20:14:14 +0000
Subject: [PATCH] =legacy rebrand finished
---
content/progress.php | 134 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 132 insertions(+), 2 deletions(-)
diff --git a/content/progress.php b/content/progress.php
index 0900884..7ba6d1a 100644
--- a/content/progress.php
+++ b/content/progress.php
@@ -1,5 +1,7 @@
<?php
// /content/progress.php
+use JVBase\meta\MetaManager;
+
function altr_progress():array
{
return [
@@ -23,6 +25,43 @@
'label' => 'Progression',
]
],
+ 'seo' => [
+ 'schema' => [
+ 'type' => 'BeforeAfter',
+ 'name' => '{{post_title}}',
+ 'description' => '{{post_excerpt}}',
+ 'about' => ['@id' => '{{site_url}}/#laser-removal-service'],
+ 'temporalCoverage' => '{{post_date}}/{{last_date}}',
+ 'additionalProperty' => [
+ ['name' => 'Number of sessions', 'value' => '{{number.name}}'],
+ ['name' => 'Treatment area', 'value' => '{{body-part.name}}'],
+ ],
+ 'associatedMedia' => '{{timeline_photos}}', // parent post thumbnail = before; each child post has a post thumbnail, too
+ ],
+ 'meta' => [
+ 'title' => '{{body-part.name}} Laser Tattoo Removal – Before & After',
+ 'description' => 'Documented progress of {{body-part.name}} laser tattoo removal over {{number.name}} sessions.',
+ ],
+ 'archive' => [
+ 'type' => 'CollectionPage',
+ 'name' => 'Tattoos Before and After Laser Tattoo Removal',
+ ],
+ ],
+ 'feed' => [
+ 'single' => [
+ 'pre_title' => 'Before & After Laser Tattoo Removal',
+ ],
+ 'archive' => [
+
+ ],
+ 'config' => [
+ 'is_gallery' => false,
+ 'content' => 'progress',
+ 'context' => 'progress',
+ 'id' => [],
+ 'class' => [],
+ ]
+ ],
'fields' => [
'post_title' => [
'type' => 'text',
@@ -34,7 +73,6 @@
'post_status' => [
'type' => 'radio',
'label' => 'Status',
- 'hidden' => true,
'options' => [
'publish' => 'Show',
'draft' => 'Hide',
@@ -44,8 +82,13 @@
'section' => 'progression',
'for_all' => true,
],
+ 'post_date' => [
+ 'type' => 'date',
+ 'label' => 'Date',
+ 'for_all' => true,
+ ],
'post_thumbnail' => [
- 'type' => 'image',
+ 'type' => 'upload',
'label' => 'Image',
'quickEdit' => true,
'section' => 'progression',
@@ -116,6 +159,15 @@
'createNew' => true,
'section' => 'progression'
],
+ 'number' => [
+ 'type' => 'taxonomy',
+ 'taxonomy' => 'number',
+ 'autocomplete' => true,
+ 'label' => 'Number of Treatments',
+ 'quickEdit' => true,
+ 'createNew' => true,
+ 'section' => 'progression'
+ ],
'post_content' => [
'type' => 'textarea',
'quill' => true,
@@ -127,3 +179,81 @@
'upload_title' => 'Upload Before & Afters',
];
}
+
+add_filter('jvbFeedItem', 'altr_progress_item', 10, 2);
+
+function altr_progress_item(string $out, array $config):string
+{
+ if (!in_array('progress', $config['content'])) {
+ return $out;
+ }
+
+ ob_start();
+ ?>
+ <details class="item feed col a-start" data-timeline>
+ <summary>
+ <a>
+ <span>Before</span>
+ <img width="300px" height="300px" loading="lazy" decoding="async" class="before">
+ <img width="300px" height="300px" loading="lazy" decoding="async" class="after">
+ <span>After</span>
+ </a>
+ </summary>
+ <div class="more">
+ <p class="started">Started:<time></time></p>
+ <p class="updated">Last treated:<time></time></p>
+ <p class="total">Total Treatments: <b></b></p>
+ <ul class="term-list"><li><a></a></li></ul>
+ </div>
+ </details>
+ <?php
+ return ob_get_clean();
+}
+
+
+add_filter('jvbCoreFeaturedImage', 'altr_progress_featured_image', 10, 2);
+function altr_progress_featured_image(string $out, string $postType):string
+{
+ if ($postType !== BASE.'progress') {
+ return $out;
+ }
+ $route = JVB()->routes('content');
+
+ global $post;
+ $data = $route->formatTimeline($post);
+ $timeline = $data['fields']['timeline'];
+ $total = count($timeline);
+ if ($total === 1) {
+ return $out;
+ }
+
+ $total--;
+ $first = '<span class="before">Before</span>'.jvbFormatImage($timeline[0]['post_thumbnail'],'tiny','medium',false);
+ $last = '<span class="after">After '.$total.' Tx</span>'.jvbFormatImage($timeline[$total]['post_thumbnail'],'tiny','medium',false);
+ return $first.$last;
+}
+
+
+add_filter('jvbSEOResolveVariable', 'altr_progress_variables', 10, 6);
+function altr_progress_variables(mixed $return, string $variable, ?int $ID, ?string $objectType, ?string $contentType, ?MetaManager $meta):mixed
+{
+ if ($contentType !== 'progress' || !in_array($variable, ['timeline_photos', 'last_date'])) {
+ return $return;
+ }
+
+ $children = get_children([
+ 'post_parent' => $ID,
+ 'post_status' => 'publish',
+ 'order_by' => 'date',
+ 'fields' => 'ids'
+ ]);
+ //Insert the parent to the beginning
+ array_unshift($children, $ID);
+ if ($variable === 'timeline_photos') {
+ return array_map(function ($item) {
+ return get_post_thumbnail_id($item);
+ }, $children);
+ }
+ // $variable === 'last_date'
+ return get_the_date('c', $children[array_key_last($children)]);
+}
--
Gitblit v1.10.0