<?php
|
use JVBase\utility\Image;
|
|
function ajv_render_core_site_logo(array $block, string $content):string
|
{
|
$open = $close = '';
|
|
if (!is_home() && !is_front_page()) {
|
$open = '<a href="'.get_home_url().'" rel="home">';
|
$close = '</a>';
|
}
|
$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 $content):string
|
{
|
$types = array_map(function($type) {
|
return BASE.$type;
|
}, array_keys(JVB_CONTENT));
|
if (!is_post_type_archive($types)) {
|
return JVB()->blocks()->render_core_cover($block);
|
}
|
$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>';
|
}
|
}
|
return JVB()->blocks()->render_core_cover($block);
|
}
|
|
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 = '<div class="halftone"></div>';
|
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) ? '<div class="img halftone">'.$img.'</div>' : $img;
|
$class = ($i%2===0) ? ' class="has-img"' :'';
|
$out .= '<div'.$class.'>'.$img. '</div>';
|
}
|
|
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 .= '<div>'.$img. '</div>';
|
}
|
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 .= '<div><div>'.$img. '</div></div>';
|
}
|
$get = 3;
|
for ($i=0; $i<$get; $i++) {
|
$out .= '<div class="radial"></div>';
|
}
|
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.= '<div><div>';
|
$out .= (array_key_exists($i, $images)) ? $images[$i] : '';
|
$out .= '</div></div>';
|
}
|
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 .= '<div>'.$img. '</div>';
|
}
|
return $out;
|
}
|