| | |
| | | ] |
| | | ] |
| | | ); |
| | | |
| | | $directory = $progress->config('directory'); |
| | | $directory->setDirectoryExtra([ |
| | | $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 |
| | |
| | | // '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); |
| | | |
| | |
| | | $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>'; |
| | | } |
| | | |