Jake Vanderwerf
2 hours ago a17c578433ef543e220697813a9367a260df83e1
content/design.php
@@ -2,6 +2,7 @@
// /content/design.php
use JVBase\meta\Meta;
use JVBase\registrar\Registrar;
use JVBase\utility\Image;
if (!defined('ABSPATH')) {
    exit;
@@ -15,6 +16,7 @@
add_filter('ajv_DesignSchemaDefault', 'ajv_design_schema');
add_filter('ajv_DesignMetaDefault', 'ajv_design_meta');
add_filter('ajv_DesignArchiveDefault', 'ajv_design_archive');
add_filter('ajv_DesignExtras', 'ajv_design_extras');
function ajv_design(){
    if (!class_exists('JVBase\registrar\Registrar')) {
@@ -135,6 +137,25 @@
        ]
    ]);
}
function ajv_design_extras(array $extras):array
{
    return [[
        'type'          => 'JVBase\managers\SEO\render\Thing\Intangible\Service',
        'id'            => get_post_type_archive_link(BASE.'design').'#service',
        'name'          => 'Custom Designs in Edmonton, Alberta',
        'description'   => 'Design by Canadian designer Jake Vanderwerf.
        Whether you\'re looking for design for print or digital media, let Jake help bring your idea to life.',
        'url'           => get_post_type_archive_link(BASE.'design'),
        'provider'      => ['id' => get_home_url(null, '#localbusiness')],
        'areaServed'    => [
            '@type' => 'JVBase\managers\SEO\render\Thing\Place\AdministrativeArea\Country',
            'name'  => 'Canada'
        ],
    ]];
}
//function ajv_design():array
//{
//    return [
@@ -305,7 +326,7 @@
//}
function ajv_render_design_content(array $block, string $content):string
function ajv_prerender_design_content(array $block, ?string $content, ?WP_Block $parent):?string
{
    $out = '';
    $ID = get_the_ID();
@@ -313,42 +334,53 @@
    $fields = $meta->getAll();
    $bits = [];
    if (array_key_exists('post_excerpt', $fields) && !empty($fields['post_excerpt'])) {
        $bits[] = sprintf(
            '<section id="excerpt"><h2>At a Glance</h2>%s</section>',
            jvb_filter_content($fields['post_excerpt'])
    $excerpt = '';
    $rows = [];
    foreach (['project', 'form', 'city', 'style', 'theme'] as $type) {
        if (!empty($fields[$type])) {
            $rows[] = jvbMetaTermList($fields[$type], $type);
        }
    }
    if (!empty($rows)) {
        $excerpt .= sprintf(
            '<ul class="summary">%s</ul>',
            implode('', array_map(function ($row) {
                return '<li>'.$row.'</li>';
            }, $rows))
        );
    }
    if (array_key_exists('gallery', $fields) && !empty($fields['gallery'])) {
        $gallery = explode(',',$fields['gallery']);
        $gallery = array_map(function ($imgID) {
            $out = '<figure>'.jvbFormatImage($imgID,'tiny','medium');
            $caption = wp_get_attachment_caption($imgID);
            $out .= ($caption && $caption !== '') ? '<figcaption>'.jvb_filter_content($caption).'</figcaption>' : '';
            $out .= '</figure>';
            return $out;
    if (!empty($fields['post_excerpt']??'')) {
        $excerpt .= wpautop($fields['post_excerpt']);
    }
    if (!empty($excerpt)) {
        $bits[] = sprintf('<section id="summary"><h3>At a Glance</h3>%s</section>',$excerpt);
    }
        }, $gallery);
        $gallery = implode('',$gallery);
    if (!empty($fields['gallery']??'')) {
        $bits[] = sprintf(
            '<section id="gallery"><h2>Gallery</h2><div>%s</div></section>',
            $gallery
            '<section id="gallery"><h2>Gallery</h2>%s</section>',
            Image::gallery($fields['gallery'])
        );
    }
    if (array_key_exists('post_content', $fields) && !empty($fields['post_content'])) {
    if (!empty($fields['post_content']??'')) {
        $bits[] = sprintf(
            '<section id="content">%s</section>',
            $fields['post_content']
        );
    }
    if (array_key_exists('needs', $fields) && !empty($fields['needs'])) {
    if (!empty($fields['needs']??'')) {
        $bits[] = ajvb_format_needs($fields['needs']);
    }
    if (array_key_exists('wants', $fields) && !empty($fields['wants'])) {
    if (!empty($fields['wants']??'')) {
        $bits[] = ajvb_format_wants($fields['wants']);
    }