cache = new CacheManager('feed', WEEK_IN_SECONDS); add_action('init', [$this, 'registerBlock']); } public function registerBlock() { register_block_type($this->path, [ 'render_callback' => [$this, 'render'] ]); } protected function buildParams(array $attributes):array { if (!jvbCheck('inheritQuery', $attributes)) { return [ 'title' => $attributes['title'], 'content' => $attributes['contentTypes'], 'taxonomies'=> $this->getTaxonomies($attributes['contentTypes']) ]; } if (isJVBUserType()) { return $this->buildProfileConfig(); } elseif (isJVBContentTax()) { return $this->buildShopConfig(); } elseif (is_tax()) { return $this->buildTaxonomyConfig(); } return []; } protected function buildProfileConfig():array { $obj = get_queried_object(); $content = jvbGetUserContentTypes($obj->ID); return [ 'is_gallery' => true, 'content' => $content, 'context' => jvbNoBase($obj->post_type), 'taxonomies' => $this->getTaxonomies($content) ]; } protected function buildShopConfig():array { $type = jvbNoBase(get_queried_object()->taxonomy); $content = jvbContentTaxContent($type); $context = [ 'content' => $content, 'taxonomies' => $this->getTaxonomies($content), 'context' => $type, ]; unset($context['taxonomies'][array_search($type, $context['taxonomies'])]); return $context; } protected function buildTaxonomyConfig():array { $type = jvbNoBase(get_queried_object()->taxonomy); $content = jvbContentTaxContent($type); return [ 'content' => $content, 'taxonomies' => $this->getTaxonomies($content), 'context' => $type ]; } protected function getTaxonomies(array $content):array { global $jvb_taxonomy_for; $taxonomies = []; foreach ($jvb_taxonomy_for as $taxonomy => $for) { if (array_intersect($for, $content)) { $taxonomies[] = $taxonomy; } } return $taxonomies; } public function render(array $attributes, string $content, WP_Block $block) { $this->config = $this->buildParams($attributes); return $this->cache->remember( $this->config, function() { return $this->renderBlock(); } ); } protected function renderBlock():string { $work = isJVBUserType() ? ' id="work"' : ''; ob_start(); ?> class="feed-block" data-source="" config)) ? ' data-context="'.$this->config['context'].'"' : '' ?> config)) ? ' data-gallery="true"' : ''?>> renderFilters(); $this->renderGrid(); $this->renderLoader(); $this->renderTemplates(); ?> config)) { return; } $many = count($this->config['content']) > 1; global $jvb_everything; global $jvb_taxonomy_for; ?>
SHOWING: config['content'] as $i => $type) : $checked = $i === 0 ? ' checked' : ''; $label = $jvb_everything[$type]['plural']; ?> >
    $label) { $active = $i === 0 ? ' class="active"' : ''; ?>
  • >
'; } ?>
FILTER BY: $items) : $hidden = !in_array($tax, $this->config['taxonomies']) ? ' hidden' : ''; if (in_array($tax, $this->config['taxonomies'])) { $tax = new TaxonomySelector( 'feed-'.$tax, $tax, [ 'update' => '.selected-items-section .selected-items', 'types' => $items, 'hidden'=> $hidden ] ); echo $tax->render(); } endforeach; ?>
ORDER BY:
ORDER:
config)) { jvbRenderGallery(); } } protected function renderTemplates():void { echo ''; echo ''; echo ''; } }