From 5fe601cd1962dca79c0765a54ce864af5abb7d40 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sun, 26 Apr 2026 22:37:14 +0000
Subject: [PATCH] =test
---
content/design.php | 528 ++++++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 379 insertions(+), 149 deletions(-)
diff --git a/content/design.php b/content/design.php
index 213f5d8..8dadd4f 100644
--- a/content/design.php
+++ b/content/design.php
@@ -1,164 +1,394 @@
<?php
// /content/design.php
-function ajv_design():array
-{
- return [
- 'singular' => 'Design',
- 'plural' => 'Designs',
- 'directory' => 'Design',
- 'show_feed' => true,
- 'show_directory'=> true,
- 'addCrumb' => 'project',
- 'favouritable' => true,
- 'karma' => false,
- 'icon' => 'scribble',
- 'rewrite' => [
- 'slug' => 'design',
- 'with_front' => false,
- ],
- // design.php
- 'seo' => [
- 'schema' => [
- 'type' => 'CreativeWork',
- 'name' => '{{post_title}}',
- 'description' => '{{post_excerpt}}',
- 'about' => ['@id' => '{{site_url}}/#design'],
- 'associatedMedia' => '{{post_thumbnail}}',
- 'dateCreated' => '{{post_date}}',
- 'keywords' => '{{style.name}}',
- ],
- 'meta' => [
- 'title' => '{{post_title}} | Human-made Design',
- 'description' => '{{post_excerpt}}',
- ],
- 'archive' => [
- 'type' => 'CollectionPage',
- 'name' => 'Canadian Design. Made in Edmonton, Alberta.',
- ],
- ],
- 'feed' => [
- 'single' => [
- 'pre_title' => 'Canadian Design. Made in Edmonton, Alberta.',
- ],
- 'archive' => [
+use JVBase\meta\Meta;
+use JVBase\registrar\Registrar;
+if (!defined('ABSPATH')) {
+ exit;
+}
+
+add_action('plugins_loaded', 'ajv_design',1);
+//Add fields later so we can verify taxonomies/post types exist
+add_action('plugins_loaded', 'ajv_design_fields', 2);
+
+
+add_filter('ajv_DesignSchemaDefault', 'ajv_design_schema');
+add_filter('ajv_DesignMetaDefault', 'ajv_design_meta');
+add_filter('ajv_DesignArchiveDefault', 'ajv_design_archive');
+
+function ajv_design(){
+ if (!class_exists('JVBase\registrar\Registrar')) {
+ return;
+ }
+ $design = Registrar::forPost('design', 'Design', 'Designs')
+ ->setIcon('scribble')
+ ->make([
+ 'rewrite' => [
+ 'slug' => 'design',
+ 'with_front' => false,
],
- 'config' => [
- 'is_gallery' => false,
- 'content' => 'design',
- 'context' => 'design',
- 'id' => [],
- 'class' => [],
+ 'taxonomies' => [
+ 'project',
+ 'form',
+ 'city',
+ 'style',
+ 'theme',
]
- ],
- 'fields' => [
- 'post_status' => [
- 'type' => 'radio',
- 'label' => 'Status',
- 'options' => [
- 'publish' => 'Show',
- 'draft' => 'Hide',
- 'trash' => 'Scrap',
- 'delete' => 'Permanently Delete'
- ],
- 'hidden' => true,
+ ])
+ ->setAll([
+ 'show_feed',
+ 'show_directory',
+ 'favouritable'
+ ]);
+
+}
+function ajv_design_fields():void
+{
+ if (!class_exists('JVBase\registrar\Registrar')) {
+ return;
+ }
+ $design = Registrar::getInstance('design');
+//$directory = $design->getConfig('directory');
+ $breadcrumbs = $design->config('breadcrumbs');
+ $breadcrumbs->setCrumb('project');
+
+ $fields = $design->fields();
+ $fields->addField('project', [
+ 'type' => 'selector',
+ 'subtype' => 'taxonomy',
+ 'taxonomy' => 'project',
+ 'label' => 'Project',
+ ]);
+ $fields->addField('form', [
+ 'type' => 'selector',
+ 'subtype' => 'taxonomy',
+ 'taxonomy' => 'form',
+ 'label' => 'Form',
+ ]);
+ $fields->addField('city', [
+ 'type' => 'selector',
+ 'subtype' => 'taxonomy',
+ 'taxonomy' => 'city',
+ 'label' => 'City',
+ ]);
+ $fields->addField('style', [
+ 'type' => 'selector',
+ 'subtype' => 'taxonomy',
+ 'taxonomy' => 'style',
+ 'label' => 'Style',
+ ]);
+ $fields->addField('theme', [
+ 'type' => 'selector',
+ 'subtype' => 'taxonomy',
+ 'taxonomy' => 'theme',
+ 'label' => 'Theme',
+ ]);
+ $fields->addField('gallery', [
+ 'type' => 'upload',
+ 'multiple' => true,
+ 'label' => 'Gallery',
+ ]);
+ $fields->addField('price', [
+ 'type' => 'number',
+ 'label' => 'Price',
+ ]);
+ $fields->addField('needs', [
+ 'type' => 'repeater',
+ 'label' => 'Needs',
+ 'fields' => [
+ 'need' => [
+ 'type' => 'text',
+ 'label' => 'Need',
+ 'required' => true
],
- 'post_date' => [
- 'type' => 'date',
- 'label' => 'Date',
- ],
- 'post_title' => [
- 'type' => 'text',
- 'label' => 'Title',
- ],
- 'post_thumbnail' => [
+ 'image' => [
'type' => 'upload',
- 'label' => 'Image',
+ 'multiple' => true,
+ 'label' => 'Example Image'
],
- 'project' => [
- 'type' => 'taxonomy',
- 'taxonomy' => 'project',
- 'autocomplete' => true,
- 'label' => 'Project',
- ],
- 'city' => [
- 'type' => 'taxonomy',
- 'autocomplete' => true,
- 'taxonomy' => 'city',
- 'label' => 'City',
- ],
- 'style' => [
- 'type' => 'taxonomy',
- 'taxonomy' => 'style',
- 'autocomplete' => true,
- 'label' => 'Styles',
- ],
- 'theme' => [
- 'type' => 'taxonomy',
- 'taxonomy' => 'theme',
- 'autocomplete' => true,
- 'label' => 'Theme',
- ],
- 'gallery' => [
- 'type' => 'upload',
- 'multiple' => true,
- 'label' => 'Gallery',
- ],
- 'price' => [
- 'type' => 'number',
- 'label' => 'Price',
- ],
- 'post_content' => [
+ 'fulfilled' => [
'type' => 'textarea',
'quill' => true,
- 'label' => 'Notes'
+ 'label' => 'How I fulfilled it'
+ ]
+ ]
+ ]);
+ $fields->addField('wants', [
+ 'type' => 'repeater',
+ 'label' => 'Wants',
+ 'fields' => [
+ 'need' => [
+ 'type' => 'text',
+ 'label' => 'Need',
+ 'required' => true
],
+ 'image' => [
+ 'type' => 'upload',
+ 'multiple' => true,
+ 'label' => 'Example Image'
+ ],
+ 'fulfilled' => [
+ 'type' => 'textarea',
+ 'quill' => true,
+ 'label' => 'How I fulfilled it'
+ ]
+ ]
+ ]);
+}
+//function ajv_design():array
+//{
+// return [
+// 'singular' => 'Design',
+// 'plural' => 'Designs',
+// 'directory' => 'Design',
+// 'show_feed' => true,
+// 'show_directory'=> true,
+// 'addCrumb' => 'project',
+// 'favouritable' => true,
+// 'karma' => false,
+// 'icon' => 'scribble',
+// 'rewrite' => [
+// 'slug' => 'design',
+// 'with_front' => false,
+// ],
+// // design.php
+// 'seo' => [
+// 'schema' => [
+// 'type' => 'CreativeWork',
+// 'name' => '{{post_title}}',
+// 'description' => '{{post_excerpt}}',
+// 'about' => ['@id' => '{{site_url}}/#design'],
+// 'associatedMedia' => '{{post_thumbnail}}',
+// 'dateCreated' => '{{post_date}}',
+// 'keywords' => '{{style.name}}',
+// ],
+// 'meta' => [
+// 'title' => '{{post_title}} | Human-made Design',
+// 'description' => '{{post_excerpt}}',
+// ],
+// 'archive' => [
+// 'type' => 'CollectionPage',
+// 'name' => 'Canadian Design. Made in Edmonton, Alberta.',
+// ],
+// ],
+// 'feed' => [
+// 'single' => [
+// 'pre_title' => 'Canadian Design. Made in Edmonton, Alberta.',
+// ],
+// 'archive' => [
+//
+// ],
+// 'config' => [
+// 'is_gallery' => false,
+// 'content' => 'design',
+// 'context' => 'design',
+// 'id' => [],
+// 'class' => [],
+// ]
+// ],
+// 'fields' => [
+// 'post_status' => [
+// 'type' => 'radio',
+// 'label' => 'Status',
+// 'options' => [
+// 'publish' => 'Show',
+// 'draft' => 'Hide',
+// 'trash' => 'Scrap',
+// 'delete' => 'Permanently Delete'
+// ],
+// 'hidden' => true,
+// ],
+// 'post_date' => [
+// 'type' => 'date',
+// 'label' => 'Date',
+// ],
+// 'post_title' => [
+// 'type' => 'text',
+// 'label' => 'Title',
+// ],
+// 'post_thumbnail' => [
+// 'type' => 'upload',
+// 'label' => 'Image',
+// ],
+// 'project' => [
+// 'type' => 'taxonomy',
+// 'taxonomy' => 'project',
+// 'autocomplete' => true,
+// 'label' => 'Project',
+// ],
+// 'form' => [
+// 'type' => 'taxonomy',
+// 'taxonomy' => 'form',
+// 'autocomplete' => true,
+// 'label' => 'Format',
+// ],
+// 'city' => [
+// 'type' => 'taxonomy',
+// 'autocomplete' => true,
+// 'taxonomy' => 'city',
+// 'label' => 'City',
+// ],
+// 'style' => [
+// 'type' => 'taxonomy',
+// 'taxonomy' => 'style',
+// 'autocomplete' => true,
+// 'label' => 'Styles',
+// ],
+// 'theme' => [
+// 'type' => 'taxonomy',
+// 'taxonomy' => 'theme',
+// 'autocomplete' => true,
+// 'label' => 'Theme',
+// ],
+// 'gallery' => [
+// 'type' => 'upload',
+// 'multiple'=> true,
+// 'label' => 'Gallery',
+// ],
+// 'price' => [
+// 'type' => 'number',
+// 'label' => 'Price',
+// ],
+// 'post_content' => [
+// 'type' => 'textarea',
+// 'quill' => true,
+// 'label' => 'Notes'
+// ],
+//
+//
+// 'needs' => [
+// 'type' => 'repeater',
+// 'label' => 'Needs',
+// 'fields'=> [
+// 'need' => [
+// 'type' => 'text',
+// 'label' => 'Need',
+// 'required' => true
+// ],
+// 'image' => [
+// 'type' => 'upload',
+// 'multiple' => true,
+// 'label' => 'Example Image'
+// ],
+// 'fulfilled' => [
+// 'type' => 'textarea',
+// 'quill' => true,
+// 'label' => 'How I fulfilled it'
+// ]
+// ]
+// ],
+// 'wants' => [
+// 'type' => 'repeater',
+// 'label' => 'Wants',
+// 'fields'=> [
+// 'need' => [
+// 'type' => 'text',
+// 'label' => 'Want',
+// 'required' => true
+// ],
+// 'image' => [
+// 'type' => 'upload',
+// 'multiple' => true,
+// 'label' => 'Example Image'
+// ],
+// 'fulfilled' => [
+// 'type' => 'textarea',
+// 'quill' => true,
+// 'label' => 'How I fulfilled it'
+// ]
+// ]
+// ],
+// ],
+// 'single_image' => false,
+// 'upload_title' => 'Upload Designs',
+// ];
+//}
- 'needs' => [
- 'type' => 'repeater',
- 'label' => 'Needs',
- 'fields'=> [
- 'need' => [
- 'type' => 'text',
- 'label' => 'Need',
- 'required' => true
- ],
- 'image' => [
- 'type' => 'upload',
- 'multiple' => true,
- 'label' => 'Example Image'
- ],
- 'fulfilled' => [
- 'type' => 'textarea',
- 'quill' => true,
- 'label' => 'How I fulfilled it'
- ]
- ]
- ],
- 'wants' => [
- 'type' => 'repeater',
- 'label' => 'Wants',
- 'fields'=> [
- 'need' => [
- 'type' => 'text',
- 'label' => 'Want',
- 'required' => true
- ],
- 'image' => [
- 'type' => 'upload',
- 'multiple' => true,
- 'label' => 'Example Image'
- ],
- 'fulfilled' => [
- 'type' => 'textarea',
- 'quill' => true,
- 'label' => 'How I fulfilled it'
- ]
- ]
- ],
- ],
- 'single_image' => false,
- 'upload_title' => 'Upload Designs',
+function ajv_render_design_content(array $block, string $content):string
+{
+ $out = '';
+ $ID = get_the_ID();
+ $meta = Meta::forPost($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'])
+ );
+ }
+
+ 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;
+
+ }, $gallery);
+ $gallery = implode('',$gallery);
+ $bits[] = sprintf(
+ '<section id="gallery"><h2>Gallery</h2><div>%s</div></section>',
+ $gallery
+ );
+ }
+
+ if (array_key_exists('post_content', $fields) && !empty($fields['post_content'])) {
+ $bits[] = sprintf(
+ '<section id="content">%s</section>',
+ $fields['post_content']
+ );
+ }
+
+ if (array_key_exists('needs', $fields) && !empty($fields['needs'])) {
+ $bits[] = ajvb_format_needs($fields['needs']);
+ }
+ if (array_key_exists('wants', $fields) && !empty($fields['wants'])) {
+ $bits[] = ajvb_format_wants($fields['wants']);
+ }
+
+ if (!empty($bits)) {
+ $out = implode('',$bits);
+ }
+
+
+ return $out;
+}
+
+function ajv_design_schema():array
+{
+ return [
+ 'type' => 'JVBase\managers\SEO\render\Thing\CreativeWork\CreativeWork',
+ 'name' => '{{post_title}} | Canadian Design',
+ 'description' => '{{post_excerpt}}',
+ 'thumbnail' => '{{post_thumbnail}}',
+ 'dateCreated' => '{{post_date}}',
+ 'dateModified' => '{{post_modified}}',
+ 'keywords' => '{{style.name}}',
+ 'isPartOf' => '{{project}}'
];
}
+
+function ajv_design_meta():array
+{
+ return[
+ 'name' => '{{post_title}} | Human-made Design',
+ ];
+}
+
+function ajv_design_archive(array $defaults):array
+{
+ return array_merge($defaults, [
+ 'name' => 'Canadian Design. Made in Edmonton, Alberta.',
+ ]);
+}
+
+function ajv_design_reference_schema(array $defaults):array
+{
+ return $defaults;
+}
\ No newline at end of file
--
Gitblit v1.10.0