| | |
| | | $function = BASE.$method; |
| | | |
| | | if (function_exists($function)) { |
| | | return $function($block, $content); |
| | | // return $this->cache->remember( |
| | | // $block, |
| | | // function () use ($function, $block, $content) { |
| | | // return $function($block, $content); |
| | | // } |
| | | // ); |
| | | return $function($block, $content); |
| | | } else if (method_exists($this, $method)) { |
| | | return $this->$method($block, $content); |
| | | //TODO: Recache it |
| | | |
| | | // return $this->cache->remember( |
| | | // $block, |
| | | // function () use ($method, $block, $content) { |
| | |
| | | 'core/site-title', |
| | | 'jvb/forms' |
| | | ]; |
| | | if (!in_array($block['blockName'], $ignore)) { |
| | | // if (!in_array($block['blockName'], $ignore)) { |
| | | // jvbDump('No method found for '.print_r($block['blockName'], true)); |
| | | } |
| | | // } |
| | | } |
| | | if ($block['blockName'] === 'jvb/feed') { |
| | | // Enqueue the feed block script (it will automatically load dependencies) |
| | | $this->localize_feedblock(); |
| | | } |
| | | if ($block['blockName'] === 'jvb/forms') { |
| | | wp_enqueue_style('jvb-form'); |
| | | } |
| | | return $content; |
| | | } |
| | | |
| | |
| | | if (str_contains($url[1], 'maps.apple.com')) { |
| | | $icon = 'apple-logo'; |
| | | } |
| | | |
| | | if ($icon !== '') { |
| | | return sprintf( |
| | | '<li%s><a href="%s" title="Find Us On %s">%s Maps</a></li>', |
| | |
| | | protected function render_core_group(array $block):string |
| | | { |
| | | $tag = (array_key_exists('tagName', $block['attrs'])) ? $block['attrs']['tagName'] : 'div'; |
| | | |
| | | $classes = ($tag === 'main') ? |
| | | $this->getClassesAndStyles($block['attrs']) : |
| | | '' : |
| | | $this->getClassesAndStyles($block['attrs'], ['group']); |
| | | return '<'.$tag.$classes.'>'.$this->innerBlocks($block).'</'.$tag.'>'; |
| | | } |
| | |
| | | wp_get_attachment_caption($ID) . |
| | | '</figcaption>' : |
| | | '<figcaption>' . $title . '</figcaption>'; |
| | | |
| | | $size = array_key_exists('sizeSlug', $block['attrs']) ? $block['attrs']['sizeSlug'] : 'large'; |
| | | return '<figure'. |
| | | $this->getClassesAndStyles($block['attrs']).'>'. |
| | | $this->imageLink(true, $ID) . |
| | | $this->imageLink(true, $ID, 'tiny', $size) . |
| | | $caption.'</figure>'; |
| | | } |
| | | |
| | |
| | | { |
| | | |
| | | $ID = $this->imageID('', $block); |
| | | $imgLink = ($ID) ? $this->imageLink(true, $ID) : ''; |
| | | |
| | | $size = array_key_exists('mediaSizeSlug', $block['attrs']) ? $block['attrs']['mediaSizeSlug'] : 'large'; |
| | | $imgLink = ($ID) ? $this->imageLink(true, $ID, 'tiny', $size) : ''; |
| | | |
| | | $inner = $this->innerBlocks($block); |
| | | |
| | |
| | | home_url($block['attrs']['url']) : |
| | | $block['attrs']['url']; |
| | | $current = (home_url($wp->request.'/') == $url); |
| | | |
| | | $temp = $block['attrs']; |
| | | unset($temp['url']); |
| | | $classes = ($current) ? |
| | | $this->getClassesAndStyles($block['attrs'], ['current']): |
| | | $this->getClassesAndStyles($block['attrs']); |
| | | $this->getClassesAndStyles($temp, ['current']): |
| | | $this->getClassesAndStyles($temp); |
| | | $aria = ''; |
| | | if ($current) { |
| | | $aria = ' aria-current="page"'; |
| | |
| | | $block['attrs']['url']; |
| | | $current = (home_url($wp->request) == $url); |
| | | |
| | | $temp = $block['attrs']; |
| | | unset($temp['url']); |
| | | $classes = ($current) ? |
| | | $this->getClassesAndStyles($block['attrs'], ['has-submenu', 'current']): |
| | | $this->getClassesAndStyles($block['attrs'], ['has-submenu']); |
| | | $this->getClassesAndStyles($temp, ['has-submenu', 'current']): |
| | | $this->getClassesAndStyles($temp, ['has-submenu']); |
| | | |
| | | $aria = ''; |
| | | if ($current) { |
| | |
| | | 'main'; |
| | | |
| | | if ($content == '') { |
| | | return do_blocks(get_the_content(get_the_ID())); |
| | | global $post; |
| | | $block['innerBlocks'] = parse_blocks($post->post_content); |
| | | return $this->innerBlocks($block); |
| | | } else { |
| | | return $this->inside($block, $tag, $content); |
| | | } |
| | |
| | | { |
| | | global $post; |
| | | $ID = get_post_thumbnail_id($post->ID); |
| | | return '<figure'.$this->getClassesAndStyles($block['attrs']).'>'. |
| | | $this->image($ID). |
| | | '</figure>'; |
| | | $aOpen = $aClose = ''; |
| | | if(!is_single($ID)) { |
| | | $aOpen = '<a href="'.get_the_permalink($post->ID).'">'; |
| | | $aClose = '</a>'; |
| | | } |
| | | |
| | | return $aOpen.'<figure'.$this->getClassesAndStyles($block['attrs']).'>'. |
| | | apply_filters('jvbCoreFeaturedImage', $this->image($ID), $post->post_type). |
| | | '</figure>'.$aClose; |
| | | } |
| | | //core_post_navigation_link |
| | | //core_post_template |
| | |
| | | |
| | | protected function render_core_query(array $block, string $content):string |
| | | { |
| | | // jvbDump($block); |
| | | // $queryID = $block['attrs']['queryId']; |
| | | // $args = []; |
| | | // $inherit = $block['attrs']['inherit']??false; |
| | | // if ($inherit) { |
| | | // global $wp_query; |
| | | // $loop = $wp_query; |
| | | // } else { |
| | | // foreach ($block['attrs']['query'] as $key => $value) { |
| | | // if (empty($value)) { |
| | | // continue; |
| | | // } |
| | | // switch ($key) { |
| | | // case 'postType': |
| | | // $args['post_type'] = $value; |
| | | // break; |
| | | // case 'perPage': |
| | | // $args['posts_per_page'] = $value; |
| | | // break; |
| | | // case 'orderBy': |
| | | // $args['orderby'] = $value; |
| | | // break; |
| | | // case 'taxQuery': |
| | | // $taxQuery = []; |
| | | // foreach ($value as $tax => $terms) { |
| | | // $taxQuery[] = [ |
| | | // 'taxonomy' => $tax, |
| | | // 'terms' => $terms |
| | | // ]; |
| | | // } |
| | | // if (!empty($taxQuery)) { |
| | | // $args['tax_query'] = $taxQuery; |
| | | // if (count($taxQuery) > 1) { |
| | | // $args['tax_query']['relation'] = 'OR'; |
| | | // } |
| | | // } |
| | | // break; |
| | | // case 'sticky': |
| | | // if ($value === 'ignore') { |
| | | // $args['ignore_sticky_posts'] = true; |
| | | // } else if ($value === 'exclude'){ |
| | | // $args['post__not_in'] = get_option('sticky_posts'); |
| | | // } else if ($value === 'only') { |
| | | // $args['include'] = get_option('sticky_posts'); |
| | | // } |
| | | // break; |
| | | // case 'search': |
| | | // $args['s'] = $value; |
| | | // break; |
| | | // default: |
| | | // $args[$key] = $value; |
| | | // break; |
| | | // |
| | | // } |
| | | // } |
| | | // //Add in any args from the query string |
| | | // $search = 'query-'.$queryID; |
| | | // foreach ($_GET as $key => $value) { |
| | | // if (str_contains($key, $search)) { |
| | | // $key = str_replace($search, '', $key); |
| | | // if ($key === 'page') { |
| | | // $args['paged'] = (int)$value; |
| | | // } |
| | | // } |
| | | // } |
| | | // $loop = new WP_Query($args); |
| | | // } |
| | | |
| | | // $inner = $this->innerBlocks($block); |
| | | // foreach ($block['innerBlocks'] as $innerBlock) { |
| | | // switch ($innerBlock['blockName']) { |
| | | // case 'core/post-template': |
| | | // $inner .= '<ul class="item-grid">'; |
| | | // if ($loop->have_posts()) { |
| | | // while($loop->have_posts()) { |
| | | // $loop->the_post(); |
| | | // $inner .= $this->doBlocks |
| | | // } |
| | | // } |
| | | // $inner .= '</ul>'; |
| | | // break; |
| | | // } |
| | | // } |
| | | $queryID = $block['attrs']['queryId']; |
| | | $args = []; |
| | | $inherit = $block['attrs']['inherit']??false; |
| | | if ($inherit) { |
| | | global $wp_query; |
| | | $loop = $wp_query; |
| | | } else { |
| | | foreach ($block['attrs']['query'] as $key => $value) { |
| | | if (empty($value)) { |
| | | continue; |
| | | } |
| | | switch ($key) { |
| | | case 'postType': |
| | | if ($value === BASE.'progress'){ |
| | | $args['post_parent'] = 0; |
| | | } |
| | | $args['post_type'] = $value; |
| | | break; |
| | | case 'perPage': |
| | | $args['posts_per_page'] = $value; |
| | | break; |
| | | case 'orderBy': |
| | | $args['orderby'] = $value; |
| | | break; |
| | | case 'taxQuery': |
| | | $taxQuery = []; |
| | | foreach ($value as $tax => $terms) { |
| | | $taxQuery[] = [ |
| | | 'taxonomy' => $tax, |
| | | 'terms' => $terms |
| | | ]; |
| | | } |
| | | if (!empty($taxQuery)) { |
| | | $args['tax_query'] = $taxQuery; |
| | | if (count($taxQuery) > 1) { |
| | | $args['tax_query']['relation'] = 'OR'; |
| | | } |
| | | } |
| | | break; |
| | | case 'sticky': |
| | | if ($value === 'ignore') { |
| | | $args['ignore_sticky_posts'] = true; |
| | | } else if ($value === 'exclude'){ |
| | | $args['post__not_in'] = get_option('sticky_posts'); |
| | | } else if ($value === 'only') { |
| | | $args['include'] = get_option('sticky_posts'); |
| | | } |
| | | break; |
| | | case 'search': |
| | | $args['s'] = $value; |
| | | break; |
| | | default: |
| | | $args[$key] = $value; |
| | | break; |
| | | |
| | | } |
| | | } |
| | | //Add in any args from the query string |
| | | $search = 'query-'.$queryID; |
| | | foreach ($_GET as $key => $value) { |
| | | if (str_contains($key, $search)) { |
| | | $key = str_replace($search, '', $key); |
| | | if ($key === 'page') { |
| | | $args['paged'] = (int)$value; |
| | | } |
| | | } |
| | | } |
| | | $loop = new WP_Query($args); |
| | | } |
| | | |
| | | $inner = ''; |
| | | |
| | | foreach ($block['innerBlocks'] as $innerBlock) { |
| | | switch ($innerBlock['blockName']) { |
| | | case 'core/post-template': |
| | | $inner .= '<section class="item-grid">'; |
| | | if ($loop->have_posts()) { |
| | | while($loop->have_posts()) { |
| | | $loop->the_post(); |
| | | $postType = get_post_type(); |
| | | $inner .= '<div class="item '.jvbNoBase($postType).'">'.$this->innerBlocks($innerBlock).'</div>'; |
| | | } |
| | | } |
| | | $inner .= '</section>'; |
| | | break; |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | $tagName = (array_key_exists('tagName', $block['attrs'])) ? $block['attrs']['tagName'] : 'div'; |
| | | $out = '<'.$tagName.' class="loop">'.$this->innerBlocks($block).'</'.$tagName.'>'; |
| | | // if ($inherit) { |
| | | // wp_reset_postdata(); |
| | | // } |
| | | $out = '<'.$tagName.' class="loop">'.$inner.'</'.$tagName.'>'; |
| | | if ($inherit) { |
| | | wp_reset_postdata(); |
| | | } |
| | | return $out; |
| | | } |
| | | |
| | |
| | | $title = ($checked == '') ? 'Toggle Dark Mode' : 'Toggle Light Mode'; |
| | | $showThemeSwitch = (bool)apply_filters('jvb_show_theme_switch', true); |
| | | $themeSwitch = ($showThemeSwitch) ? '<label title="'.$title.'" id="theme-switch" class="toggle-switch" for="theme-switcher"> |
| | | <input class="theme-switch row" id="theme-switcher" type="checkbox"'.$checked.' data-setting="theme" data-theme role="switch" name="dark-mode"><span class="slider">'. |
| | | <input class="theme-switch row" id="theme-switcher" name="theme-switcher" type="checkbox"'.$checked.' data-setting="theme" data-theme role="switch" name="dark-mode" aria-label="Toggle dark mode"><span class="slider">'. |
| | | jvbIcon('sun-dim', ['title'=> 'Light Mode']). |
| | | jvbIcon('moon', ['title'=>'Dark Mode']). |
| | | '</span></label>' : ''; |
| | | $breadcrumbs = jvbBuildBreadcrumbs(); |
| | | $afterHeader = apply_filters('jvbBelowHeader', $afterHeader); |
| | | |
| | | if ($afterHeader !== '') { |
| | | $afterHeader = '<aside class="sub-header">'.$afterHeader.'</aside>'; |
| | | } |
| | | $footerText = '<div class="scroll-progress"><div class="bar"></div> |
| | | </div>'; |
| | | } elseif ($isFooterTemplate) { |
| | | $beforeHeader = apply_filters('jvbBeforeFooter', ''); |
| | | if ($beforeHeader !== '') { |
| | |
| | | $type = 'row'; |
| | | if (array_key_exists('type', $value)) { |
| | | $type = 'col'; |
| | | if ($value['type'] === 'constrained') { |
| | | $classes[] = 'container col'; |
| | | } |
| | | // if ($value['type'] === 'constrained') { |
| | | // $classes[] = 'container col'; |
| | | // } |
| | | } |
| | | if (array_key_exists('orientation', $value)) { |
| | | $type = 'col'; |
| | |
| | | |
| | | // Background URL (for cover, media blocks) |
| | | case 'url': |
| | | jvbDump($value); |
| | | if (!empty($value) && str_starts_with($value, 'http')) { |
| | | $styles[] = 'background-image: url('.$value.')'; |
| | | } |