| | |
| | | <?php |
| | | |
| | | use JVBase\managers\Cache; |
| | | use JVBase\meta\Meta; |
| | | use JVBase\registrar\Registrar; |
| | | |
| | | function ajv_render_core_site_logo(array $block, string $content):string |
| | | function ajv_prerender_core_site_logo(array $block, ?string $content):?string |
| | | { |
| | | $open = $close = ''; |
| | | |
| | |
| | | return $open.$icons.$close; |
| | | } |
| | | |
| | | function ajv_render_core_cover(array $block):string |
| | | function ajv_prerender_core_cover(array $block, ?string $content, ?WP_Block $parent):?string |
| | | { |
| | | $types = array_map(function($type) { return jvbCheckBase($type); }, Registrar::getRegistered('post')); |
| | | $taxTypes = array_map(function($type) { return jvbCheckBase($type); }, Registrar::getRegistered('term')); |
| | | |
| | | $type = null; |
| | | if (is_post_type_archive($types)) { |
| | | $obj = get_queried_object(); |
| | | $type = jvbNoBase($obj->name); |
| | | $function = 'ajv_render_'.$type.'_cover'; |
| | | if (function_exists($function)) { |
| | | return '<section class="align-full cover alt '.$type.'">'.$function().'</section>'; |
| | | } |
| | | // foreach ($types as $type) { |
| | | // if ($type === $obj->name) { |
| | | // $type = jvbNoBase($type); |
| | | // $function = 'ajv_render_'.$type.'_cover'; |
| | | // return '<section class="align-full cover alt '.$type.'">'.call_user_func($function).'</section>'; |
| | | // } |
| | | // } |
| | | |
| | | } else if (is_tax($taxTypes)) { |
| | | $obj = get_queried_object(); |
| | | $type = jvbNoBase($obj->taxonomy); |
| | | $function = 'ajv_render_'.$type.'_cover'; |
| | | if (function_exists($function)) { |
| | | $result = $function($obj->term_id); |
| | | return $result === '' ? '' : '<section class="align-full cover '.$type.'">'.$result.'</section>'; |
| | | } |
| | | if (is_singular($types)) { |
| | | if (!$type) { |
| | | $type = jvbNoBase(get_queried_object()->post_type); |
| | | } |
| | | } |
| | | $registrar = Registrar::getInstance($type); |
| | | |
| | | if (!$registrar) { |
| | | return JVB()->blocks()->prerender_core_cover($block, null, null); |
| | | } |
| | | |
| | | $ID = get_the_ID(); |
| | | $imgID = get_post_thumbnail_id($ID); |
| | | $img = ''; |
| | | if ($imgID && $imgID > 0) { |
| | | $img = str_replace('<img', '<img style="object-fit:center"',jvbFormatImage($imgID, 'tiny', 'large', false)) ; |
| | | } |
| | | |
| | | $singular = $registrar->getSingular(); |
| | | $header = match($type) { |
| | | 'art' => 'Canadian made Art.<br>Made in Edmonton.', |
| | | 'design' => 'Canadian Design in Edmonton.', |
| | | 'development'=> 'Canadian Development in Edmonton.', |
| | | 'strategy' => 'Canadian Brand Strategy based in Edmonton, Alberta.', |
| | | 'writing' => 'Canadian Content Writing.<br>From Edmonton, Alberta.', |
| | | 'project' => 'Canadian-based Projects.' |
| | | }; |
| | | |
| | | $title = get_the_title(); |
| | | |
| | | $title = '<small>'.$header.'</small>'.$title; |
| | | |
| | | |
| | | if(!is_singular($types)) { |
| | | return JVB()->blocks()->render_core_cover($block); |
| | | } |
| | | $post_type = jvbNoBase(get_post_type()); |
| | | $registrar = Registrar::getInstance($post_type); |
| | | if (!$registrar) { |
| | | return JVB()->blocks()->render_core_cover($block); |
| | | } |
| | | $date = '<small><time datetime="'.get_the_date('c').'" itemprop="datePublished">'.get_the_date().'</time></small>'; |
| | | |
| | | |
| | | $ID = get_the_ID(); |
| | | $imgID = get_post_thumbnail_id($ID); |
| | | $img = ''; |
| | | if ($imgID && $imgID > 0) { |
| | | $img = str_replace('<img', '<img style="object-fit:center"',jvbFormatImage($imgID, 'tiny', 'large', false)) ; |
| | | } |
| | | |
| | | $singular = $registrar->getSingular(); |
| | | |
| | | $header = 'Canadian made '.$singular.'. Made in Edmonton.'; |
| | | $title = get_the_title(); |
| | | |
| | | $title = '<small>'.$header.'</small>'.$title; |
| | | |
| | | |
| | | $date = '<small><time datetime="'.get_the_date('c').'" itemprop="datePublished">'.get_the_date().'</time></small>'; |
| | | |
| | | |
| | | return sprintf( |
| | | '<section class="overlay-50 a-end end align-full cover row" style="background-color: rgba(var(--base-rgb), var(--rgb-medium));"> |
| | | return sprintf( |
| | | '<section class="btm right align-full cover row"> |
| | | %s |
| | | <div class="content"> |
| | | <h1>%s</h1> |
| | | %s |
| | | </div> |
| | | </section>', |
| | | $img, |
| | | $title, |
| | | $date |
| | | $img, |
| | | $title, |
| | | $date |
| | | ); |
| | | } |
| | | if (!$type) { |
| | | return JVB()->blocks()->prerender_core_cover($block, null, null); |
| | | } |
| | | $cache = Cache::for('jakevanIcons'); |
| | | |
| | | $icon = $cache->remember( |
| | | $type, |
| | | function () use ($type) { |
| | | return file_get_contents(AJV_DIR.'/assets/icons/jakevan-does-'.$type.'.svg'); |
| | | } |
| | | ); |
| | | |
| | | return sprintf( |
| | | '<section class="bottom left align-full cover alt %s row">%s</section>', |
| | | $type, |
| | | $icon |
| | | ); |
| | | } |
| | | |
| | | function ajv_get_limited_posts(string $type, int $limit):array { |
| | |
| | | },$posts->posts); |
| | | } |
| | | |
| | | function ajv_get_limited_post_images(array $args, bool $includeImages = false, int $limit = 3):array { |
| | | $posts = new WP_Query([ |
| | | 'posts_per_page' => $limit, |
| | | 'post_status' => 'publish', |
| | | 'fields' => 'ids', |
| | | ... $args |
| | | ]); |
| | | return array_map(function($item) use ($includeImages) { |
| | | $aOpen = $includeImages ? sprintf('<a href="%s" class="%s">', get_the_permalink($item), jvbNoBase(get_post_type($item))) : ''; |
| | | $aClose = $includeImages ? '</a>' : ''; |
| | | |
| | | return $aOpen.jvbFormatImage(get_post_thumbnail_id($item), 'tiny', 'large', false).$aClose; |
| | | },$posts->posts); |
| | | } |
| | | |
| | | function ajv_render_art_cover():string |
| | | { |
| | | $get = 4; |
| | |
| | | return $out; |
| | | } |
| | | |
| | | function ajv_render_core_post_title($block, $content):string |
| | | function ajv_prerender_core_post_title(array $block, ?string $content):string |
| | | { |
| | | if (!ajv_is_singular()){ |
| | | return JVB()->blocks()->render_core_post_title($block); |
| | | return JVB()->blocks()->prerender_core_post_title($block, $content, null); |
| | | } |
| | | $ID = get_the_ID(); |
| | | $city = get_the_terms($ID, BASE.'city'); |
| | |
| | | } |
| | | $registrar = Registrar::getInstance(get_post_type($ID)); |
| | | if (!$registrar) { |
| | | return JVB()->blocks()->render_core_post_title($block); |
| | | return JVB()->blocks()->prerender_core_post_title($block, $content, null); |
| | | } |
| | | |
| | | $form = get_the_terms($ID, BASE.'form'); |