cache = CacheManager::for('timelines', WEEK_IN_SECONDS)->connectTo('post', 'timeline');
if (JVB_TESTING){
$this->cache->clear();
}
add_action('init', [ $this, 'registerBlock' ]);
add_action('wp_footer', 'jvbRenderGallery');
}
public function registerBlock()
{
register_block_type($this->path, [
'render_callback' => [ $this, 'render' ]
]);
}
public function render(array $attributes, string $content, WP_Block $block)
{
global $post;
if (!$post || !Features::forContent(jvbNoBase($post->post_type))->has('is_timeline') ) {
return '';
}
$this->parentID = $post->ID;
$cache = $this->cache->get($this->parentID);
if ($cache) {
return $cache;
}
$this->content = jvbNoBase($post->post_type);
$this->children = get_children([
'post_parent' => $this->parentID,
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'ASC',
'fields' => 'ids'
]);
$this->total = count($this->children);
ob_start();
$this->renderBlock();
$content = ob_get_clean();
$this->cache->set($this->parentID, $content);
return $content;
}
protected function renderBlock():void
{
$this->renderHeader();
$this->renderTimeline();
}
protected function get_field(string $fieldName, array $fields) {
if (array_key_exists($fieldName, $fields)) {
return $fields[$fieldName];
}
return '';
}
protected function renderHeader():void
{
$meta = new MetaManager($this->parentID, 'post');
$sharedFields = JVB()->routes('content')->getTimelineSharedFields($this->content);
$fields = $meta->getAll($sharedFields);
$extra = $meta->getAll();
?>
Before and After Laser Tattoo Removal:=$this->get_field('post_title', $extra)?>
$value) {
if ($value === '' || $slug === 'person') {
continue;
}
$config = JVB_TAXONOMY[$slug];
$taxSlug = jvbCheckBase($slug);
$terms = get_the_terms($this->parentID, $taxSlug);
if ($terms && !is_wp_error($terms)) {
$many = count($terms) > 1;
?>
Before
= jvbFormatImage(get_post_thumbnail_id($this->parentID), 'tiny', 'large', false) ?>
After =$this->total?> Treatment= $this->total > 1 ? 's' : '' ?>
= jvbFormatImage(get_post_thumbnail_id($this->children[count($this->children)-1]), 'tiny', 'large', false) ?>
=jvbIcon(jvbLogoIcon())?>= $title?>
get_field('post_date', $fields);
if ($date !== '') {
echo '';
}
echo $this->outputTimelineTax($ID);
$content = $this->get_field('post_content', $fields);
if ($i > 0 && $content !== '') {
echo $this->formatContent($this->get_field('post_content', $fields));
}
?>