<?php
|
|
use JVBase\managers\CacheManager;
|
|
if (!defined('ABSPATH')) {
|
exit; // Exit if accessed directly
|
}
|
/**
|
* Summary Block Render
|
*
|
* @package Edmonton_Ink
|
*/
|
|
function jvbRenderSummaryBlock(array $attributes):string
|
{
|
|
// Buffer output
|
if (is_tax()) {
|
switch (get_queried_object()->taxonomy) {
|
case BASE.'shop':
|
return jvbRenderShopSummary();
|
default:
|
return jvbRenderTermSummary();
|
}
|
} elseif (is_singular()) {
|
return jvbRenderArtistSummary();
|
}
|
return '';
|
}
|
|
function jvbRenderArtistSummary():string
|
{
|
$current = get_queried_object();
|
$cache = CacheManager::for('artists', WEEK_IN_SECONDS);
|
$key = 'artist-bio-'.$current->ID;
|
$cached = $cache->get($key);
|
$cached = false;
|
if ($cached !== false) {
|
return $cached;
|
}
|
|
ob_start();
|
$meta = new JVBase\meta\MetaManager((int)$current->ID, 'post');
|
$artist = jvbContentFromUser((int)$current->post_author);
|
|
$sections = JVB_CONTENT[jvbNoBase($current->post_type)]['sections']??[];
|
|
|
|
// $handler = JVB()->getContent(str_replace(BASE,'', $current->post_type));
|
?>
|
<nav id="artist" class="on-this-page index">
|
<label>Jump to:
|
<button type="button" aria-label="Show Index" title="Show Index" class="toggle" aria-expanded="false">
|
<?= jvbIcon('plus-square')?>
|
</button>
|
</label>
|
<ul>
|
<li><a href="#top" title="Back to Top"><?=jvbIcon('caret-circle-up')?></a></li>
|
<li><a href="#about">About</a></li>
|
<li><a href="#styles">Styles</a></li>
|
<li><a href="#contact">Contact</a></li>
|
<li><a href="#work">Work</a></li>
|
</ul>
|
</nav>
|
<header id="top">
|
<h1><small><?=(!empty($artist['city'])) ? $artist['city']['name'] :'Edmonton'?>'s Best <?= (!empty($artist['type'])) ?
|
$artist['type']['name']:'Tattoo Artists'?>:
|
</small><?=$artist['display_name']?></h1>
|
<div>
|
<?php if (!empty($artist['shop'])) : ?>
|
<ul class="term-list shop">
|
<li>
|
<a href="<?=$artist['shop']['url']?>" title="Learn more about <?=$artist['shop']['name']?>">
|
<?= strtolower($artist['shop']['name'])?>
|
</a>
|
</li>
|
</ul>
|
<?php endif; ?>
|
<?php if (!empty($artist['city'])): ?>
|
<ul class="term-list city">
|
<li>
|
<a href="<?=$artist['city']['url']?>" title="See who else is rocking out of <?=$artist['city']['name']?>">
|
<?= strtolower($artist['city']['name'])?>
|
</a>
|
</li>
|
</ul>
|
<?php endif; ?>
|
<?php $styles = $meta->getValue('top_styles');
|
if (!empty($styles)) {
|
?>
|
<ul class="term-list style">
|
<?php
|
foreach ($styles as $style) {
|
$term = get_term((int)$style, BASE.'style');
|
if ($term && !is_wp_error($term)) {
|
$link = get_term_link((int)$style, BASE.'style');
|
?>
|
<li>
|
<a href="<?=$link?>" title="Learn more about <?=$term->name?>">
|
<?=strtolower($term->name)?>
|
</a>
|
</li>
|
<?php
|
}
|
}
|
?>
|
</ul>
|
<?php
|
}
|
?>
|
</div>
|
</header>
|
<section>
|
<details class="bio-info">
|
<summary class="row btw">
|
<h2>About <?= ($artist['name'] !== '') ? $artist['name'] : strtok($artist['display_name'], ' ')?></h2>
|
</summary>
|
<div class="columns stack-small">
|
<div class="column">
|
<?php $meta->render('render', 'image_portrait'); ?>
|
</div>
|
<div class="column">
|
<?php $meta->render('render', 'short_bio'); ?>
|
</div>
|
</div>
|
<div id="styles">
|
<h3>Works In</h3>
|
<?= jvbGetTheTerms('style', $current->ID) ?>
|
</div>
|
<div class="contact">
|
<h3>Contact:</h3>
|
<?php
|
echo jvbRenderContactInfo($current->ID, $meta);
|
echo jvbRenderLinks($current->ID, $meta);
|
?>
|
</div>
|
|
<div id="about">
|
<?php $meta->render('render', 'bio')?>
|
</div>
|
</details>
|
</section>
|
<section id="contact" class="">
|
<h2>Contact <?=$artist['name']?></h2>
|
<?php
|
echo jvbRenderContactInfo($current->ID, $meta);
|
echo jvbRenderLinks($current->ID, $meta);
|
?>
|
</section>
|
<?php
|
$finished = ob_get_clean();
|
$cache->set($key, $finished);
|
return $finished;
|
}
|
|
function jvbRenderShopSummary()
|
{
|
$current = get_queried_object();
|
|
$cache = CacheManager::for('shops', WEEK_IN_SECONDS);
|
$key = 'shop-bio-'.$current->term_id;
|
$cached = $cache->get($key);
|
$cached = false;
|
if ($cached !== false) {
|
return $cached;
|
}
|
|
ob_start();
|
$handler = JVB()->getContent('shop');
|
|
|
$meta = new JVBase\meta\MetaManager($current->term_id, 'term');
|
$rating = $meta->getValue('average_rating');
|
$opened = $meta->getValue('established');
|
$about = $meta->getValue('bio');
|
$location = $meta->getValue('location');
|
$hours = $meta->getValue('hours');
|
$specialty = $meta->getValue('specialties');
|
$awards = $meta->getValue('awards');
|
$reviews = $meta->getValue('reviews');
|
|
?>
|
<nav id="shop" class="on-this-page index">
|
<label>Jump to:
|
<button type="button" aria-label="Show Index" title="Show Index" class="toggle" aria-expanded="false">
|
<?= jvbIcon('plus-square')?>
|
</button>
|
</label>
|
<ul>
|
<li><a href="#top" title="Back to Top"><?=jvbIcon('caret-circle-up')?></a></li> <?php
|
if ($rating !== 'none') {
|
?>
|
<li><a href="#rating">Rating</a></li>
|
<?php
|
} elseif ($opened !== '') {
|
?>
|
<li><a href="#opened">Opened</a></li>
|
<?php
|
} elseif ($location !== '') {
|
?>
|
<li><a href="#location">Location</a></li>
|
<?php
|
} elseif ($about !== '') {
|
?>
|
<li><a href="#about">About</a></li>
|
<?php
|
} elseif ($hours !== '') {
|
?>
|
<li><a href="#hours">Hours</a></li>
|
<?php
|
} elseif ($specialty !== '') {
|
?>
|
<li><a href="#specialties">Specialties</a></li>
|
<?php
|
} elseif ($awards !== '') {
|
?>
|
<li><a href="#awards">Awards</a></li>
|
<?php
|
} elseif ($reviews !== '') {
|
?>
|
<li><a href="#reviews">Reviews</a></li>
|
<?php
|
}
|
?>
|
<li><a href="#contact">Contact</a></li>
|
<li><a href="#artists">Artists</a></li>
|
</ul>
|
</nav>
|
<header id="top">
|
<div class="columns stack-small">
|
<div class="column">
|
<?=jvbFormatImage($meta->getValue('image'))?>
|
</div>
|
<div class="column">
|
<h1>
|
<small><?= (get_term((int)$meta->getValue('city'), BASE.'city')) ?
|
get_term((int)$meta->getValue('city'), BASE.'city')->name :
|
'Edmonton'?>'s Best Tattoo Shops</small>
|
<?=$current->name?>
|
</h1>
|
<?= jvbFormatRating($current->term_id, $meta) ?>
|
<?php $meta->render('render', 'slogan'); ?>
|
</div>
|
</div>
|
</header>
|
<section>
|
<details class="bio-info">
|
<summary class="row btw">
|
<h2>Learn More About <?=$current->name?></h2>
|
</summary>
|
<div class="map">
|
<?php $meta->render('render', 'location'); ?>
|
</div>
|
<div class="short-bio">
|
<?php $meta->render('render', 'short_bio'); ?>
|
</div>
|
|
<div class="contact">
|
<h3>Contact:</h3>
|
<?php
|
echo jvbRenderContactInfo($current->term_id, $meta);
|
echo jvbRenderLinks($current->term_id, $meta);
|
?>
|
</div>
|
|
<div id="about">
|
<?php $meta->render('render', 'bio')?>
|
</div>
|
</details>
|
</section>
|
<section id="contact" class="">
|
<h2>Contact </h2>
|
<?php
|
echo jvbRenderContactInfo($current->term_id, $meta);
|
echo jvbRenderLinks($current->term_id, $meta);
|
?>
|
</section>
|
<?= jvbRenderHours($current->term_id, $meta)?>
|
|
|
<?php
|
$finished = ob_get_clean();
|
// $cache->set($key, $finished);
|
return $finished;
|
}
|
|
|
function jvbRenderTermSummary()
|
{
|
$current = get_queried_object();
|
$cache = CacheManager::for(jvbNoBase($current->taxonomy), WEEK_IN_SECONDS);
|
$key = $current->ID;
|
$cached = $cache->get($key);
|
$cached = false;
|
if ($cached !== false) {
|
return $cached;
|
}
|
|
ob_start();
|
$tax = jvbNoBase($current->taxonomy);
|
switch ($tax) {
|
case 'style':
|
$title = 'Tattoo Artists';
|
break;
|
case 'theme':
|
$title = 'Tattoos';
|
break;
|
default:
|
$title = '';
|
}
|
|
$meta = new JVBase\meta\MetaManager($current->ID, 'term');
|
$fields = JVB_TAXONOMY[$tax]['fields']??[];
|
|
?>
|
<header id="top">
|
<h1><?= get_the_archive_title() ?></h1>
|
</header>
|
|
<?php
|
$finished = ob_get_clean();
|
$cache->set($key, $finished);
|
return $finished;
|
}
|