cache = CacheManager::for('timelines', WEEK_IN_SECONDS)->connectTo('post', 'timeline');
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 renderHeader():void
{
$title = get_the_title();
?>
Before and After Laser Tattoo Removal:=$title?>
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?>
= array_key_exists('post_date', $fields) && $fields['date'] !== '' ? '' : '' ?>
= array_key_exists('timeline', $fields) && $fields['timeline'] !== '' ? $this->outputTimelineTax($ID) : '' ?>
= array_key_exists('post_content', $fields) && $fields['post_content'] !== '' ? '