'; $close = ''; } $icons = (array_key_exists('className', $block['attrs']) && str_contains($block['attrs']['className'], 'is-text')) ? jvbIcon('logo-jakevan') : jvbIcon('logo').jvbIcon('jakevan'); return $open.$icons.$close; } function ajv_render_core_cover(array $block):string { $types = array_map(function($type) { return jvbCheckBase($type); }, Registrar::getRegistered('post')); $taxTypes = array_map(function($type) { return jvbCheckBase($type); }, Registrar::getRegistered('term')); if (is_post_type_archive($types)) { $obj = get_queried_object(); $type = jvbNoBase($obj->name); $function = 'ajv_render_'.$type.'_cover'; if (function_exists($function)) { return '
'.$function().'
'; } // foreach ($types as $type) { // if ($type === $obj->name) { // $type = jvbNoBase($type); // $function = 'ajv_render_'.$type.'_cover'; // return '
'.call_user_func($function).'
'; // } // } } 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 === '' ? '' : '
'.$result.'
'; } } 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); } $ID = get_the_ID(); $imgID = get_post_thumbnail_id($ID); $img = ''; if ($imgID && $imgID > 0) { $img = str_replace('getSingular(); $header = 'Canadian made '.$singular.'. Made in Edmonton.'; $title = get_the_title(); $title = ''.$header.''.$title; $date = ''; return sprintf( '
%s

%s

%s
', $img, $title, $date ); } function ajv_get_limited_posts(string $type, int $limit):array { $posts = new WP_Query([ 'post_type' => jvbCheckBase($type), 'posts_per_page' => $limit, 'post_status' => 'publish', 'fields' => 'ids', ]); return array_map(function($item) { return jvbFormatImage(get_post_thumbnail_id($item), 'tiny', 'large', false); },$posts->posts); } function ajv_render_art_cover():string { $get = 4; $images = ajv_get_limited_posts('art', $get); $out = ''; $halftone = '
'; for ($i=0; $i<$get; $i++) { $img = (array_key_exists($i, $images)) ? $images[$i] : ''; // if ($i%4===2) { // $before = $halftone; // $after = ''; // } elseif($i%4 === 0) { // $before = ''; // $after = $halftone; // } $img = ($i%2===0) ? '
'.$img.'
' : $img; $class = ($i%2===0) ? ' class="has-img"' :''; $out .= ''.$img. ''; } return $out; } function ajv_render_strategy_cover():string { $get = 7; $images = ajv_get_limited_posts('strategy', $get); $out = ''; for ($i=0; $i<$get; $i++) { $img = (array_key_exists($i, $images)) ? $images[$i] : ''; $out .= '
'.$img. '
'; } return $out; } function ajv_render_development_cover():string { $get = 2; $images = ajv_get_limited_posts('development', $get); $out = ''; for ($i=0; $i<$get; $i++) { $img = (array_key_exists($i, $images)) ? $images[$i] : ''; $out .= '
'.$img. '
'; } $get = 3; for ($i=0; $i<$get; $i++) { $out .= '
'; } return $out; } function ajv_render_design_cover():string { $get = 4; $images = ajv_get_limited_posts('design', $get); $out = ''; for ($i=0; $i<$get; $i++) { $out.= '
'; $out .= (array_key_exists($i, $images)) ? $images[$i] : ''; $out .= '
'; } return $out; } function ajv_render_support_cover():string { return ''; } function ajv_render_writing_cover():string { $get = 7; $images = ajv_get_limited_posts('writing', $get); $out = ''; for ($i=0; $i<$get; $i++) { $img = (array_key_exists($i, $images)) ? $images[$i] : ''; $out .= '
'.$img. '
'; } return $out; } function ajv_render_core_post_title($block, $content):string { if (!ajv_is_singular()){ return JVB()->blocks()->render_core_post_title($block); } $ID = get_the_ID(); $city = get_the_terms($ID, BASE.'city'); if ($city && !is_wp_error($city)) { $city = $city[0]->name; } else { $city ='Edmonton'; } $registrar = Registrar::getInstance(get_post_type($ID)); if (!$registrar) { return JVB()->blocks()->render_core_post_title($block); } $form = get_the_terms($ID, BASE.'form'); if ($form && !is_wp_error($form)){ $form = $form[0]->name.' '; } else { $form = ''; } $title = get_the_title($ID); return sprintf( '

Canadian made %s%s. Made in %s.%s

', $form, $registrar->getPlural(), $city, $title ); }