| | |
| | | // /content/art.php |
| | | use JVBase\meta\Meta; |
| | | use JVBase\registrar\Registrar; |
| | | use JVBase\utility\Image; |
| | | |
| | | if (!defined('ABSPATH')) { |
| | | exit; |
| | |
| | | add_action('plugins_loaded', 'ajv_art',1); |
| | | //Add fields later so we can verify taxonomies/post types exist |
| | | add_action('plugins_loaded', 'ajv_art_fields', 2); |
| | | //add_action('init', 'ajv_art_extra_schema', 10); |
| | | |
| | | add_filter('ajv_ArtSchemaDefault', 'ajv_art_schema'); |
| | | add_filter('ajv_ArtMetaDefault', 'ajv_art_meta'); |
| | | add_filter('ajv_ArtArchiveDefault', 'ajv_art_archive'); |
| | | add_filter('ajv_ArtExtras', 'ajv_art_extras'); |
| | | |
| | | function ajv_art(){ |
| | | if (!class_exists('JVBase\registrar\Registrar')) { |
| | | return; |
| | | } |
| | | $art = Registrar::forPost('art', 'Art', 'Art') |
| | | // ->setIcon('palette') |
| | | ->setIcon('palette') |
| | | ->make([ |
| | | 'rewrite' => [ |
| | |
| | | ]); |
| | | |
| | | //$directory = $art->getConfig('directory'); |
| | | |
| | | } |
| | | |
| | | function ajv_art_fields():void |
| | |
| | | ]); |
| | | } |
| | | |
| | | function ajv_art_extras(array $extras):array |
| | | { |
| | | return [[ |
| | | 'type' => 'JVBase\managers\SEO\render\Thing\Intangible\Service', |
| | | 'id' => get_post_type_archive_link(BASE.'art').'#service', |
| | | 'name' => 'Art Created in Edmonton, Alberta', |
| | | 'description' => 'Handmade art by Canadian artist Jake Vanderwerf.', |
| | | 'url' => get_post_type_archive_link(BASE.'art'), |
| | | 'provider' => ['id' => get_home_url(null, '#localbusiness')], |
| | | 'areaServed' => [ |
| | | '@type' => 'JVBase\managers\SEO\render\Thing\Place\AdministrativeArea\Country', |
| | | 'name' => 'Canada' |
| | | ], |
| | | ]]; |
| | | |
| | | } |
| | | |
| | | |
| | | //function ajv_art():array |
| | | //{ |
| | |
| | | // ]; |
| | | //} |
| | | |
| | | function ajv_render_art_content(array $block, string $content):string |
| | | function ajv_prerender_art_content(array $block, ?string $content, ?WP_Block $parent):?string |
| | | { |
| | | $out = ''; |
| | | $ID = get_the_ID(); |
| | |
| | | |
| | | $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', 'media', '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']); |
| | | } |
| | | |
| | |
| | | 'dateCreated' => '{{post_date}}', |
| | | 'dateModified' => '{{post_modified}}', |
| | | 'artform' => '{{form.name}}', |
| | | 'artMedium' => '{{medium.name}}', |
| | | 'artMedium' => '{{media.name}}', |
| | | 'keywords' => '{{style.name}}', |
| | | ]; |
| | | } |
| | |
| | | { |
| | | return array_merge($defaults, [ |
| | | 'name' => 'Canadian Art. Made in Edmonton, Alberta.', |
| | | 'description' => 'Handmade sculpture, jewellery, and more from Edmonton, Alberta.' |
| | | 'description' => 'Handmade sculpture, jewellery, and more from Edmonton, Alberta.', |
| | | 'about' => ['id' => get_post_type_archive_link(BASE.'art').'#service'], |
| | | ]); |
| | | } |
| | | |