| | |
| | | <?php |
| | | |
| | | use JVBase\registrar\Registrar; |
| | | |
| | | function ajv_render_core_site_logo(array $block, string $content):string |
| | | { |
| | | $open = $close = ''; |
| | |
| | | |
| | | function ajv_render_core_cover(array $block):string |
| | | { |
| | | $types = array_map(function($type) { |
| | | return BASE.$type; |
| | | }, array_keys(JVB_CONTENT)); |
| | | $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(); |
| | | 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>'; |
| | | } |
| | | $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(array_map(function($item) { return BASE.$item; }, array_keys(JVB_CONTENT)))) { |
| | | 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 = str_replace('<img', '<img style="object-fit:center"',jvbFormatImage($imgID, 'tiny', 'large', false)) ; |
| | | } |
| | | |
| | | $post_type = jvbNoBase(get_post_type()); |
| | | $singular = JVB_CONTENT[$post_type]['singular']; |
| | | $singular = $registrar->getSingular(); |
| | | |
| | | $header = 'Canadian made '.$singular.'. Made in Edmonton.'; |
| | | $title = get_the_title(); |
| | |
| | | $out .= '<div>'.$img. '</div>'; |
| | | } |
| | | 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( |
| | | '<h1><small>Canadian made %s%s. Made in %s.</small>%s</h1>', |
| | | $form, |
| | | $registrar->getPlural(), |
| | | $city, |
| | | $title |
| | | ); |
| | | |
| | | } |