setIcon('pen-nib') ->make([ 'rewrite' => [ 'slug' => 'writing', 'with_front' => false, ], 'taxonomies' => [ 'project', 'form', 'target', 'city', 'style', 'theme' ] ]) ->setAll([ 'show_feed', 'show_directory', 'favouritable' ]); } function ajv_writing_fields():void { if (!class_exists('JVBase\registrar\Registrar')) { return; } $writing = Registrar::getInstance('writing'); //$directory = $writing->getConfig('directory'); $breadcrumbs = $writing->config('breadcrumbs'); $breadcrumbs->setCrumb('project'); $fields = $writing->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('target', [ 'type' => 'selector', 'subtype' => 'taxonomy', 'taxonomy' => 'target', 'label' => 'Target', ]); $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 ], 'image' => [ 'type' => 'upload', 'multiple' => true, 'label' => 'Example Image' ], 'fulfilled' => [ 'type' => 'textarea', 'quill' => true, '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_writing():array //{ // return [ // 'singular' => 'Writing', // 'plural' => 'Writings', // 'hide_single' => false, // 'redirectToAuthor'=> false, // 'show_feed' => true, // 'addCrumb' => 'project', // 'show_directory'=> true, // 'directory' => 'Writing', // 'favouritable' => true, // 'karma' => false, // 'icon' => 'pen-nib', // 'rewrite' => [ // 'slug' => 'writing', // 'with_front' => false, // ], // // 'seo' => [ // 'schema' => [ // 'type' => 'CreativeWork', // 'name' => '{{post_title}}', // 'description' => '{{post_excerpt}}', // 'about' => ['@id' => '{{site_url}}/#writing'], // 'associatedMedia' => '{{post_thumbnail}}', // 'dateCreated' => '{{post_date}}', // ], // 'meta' => [ // 'title' => '{{post_title}} | Human-made Writing', // 'description' => '{{post_excerpt}}', // ], // 'archive' => [ // 'type' => 'CollectionPage', // 'name' => 'Canadian Content Writing. From Edmonton, Alberta.', // ], // ], // 'feed' => [ // 'single' => [ // 'pre_title' => 'Canadian Content Writing. From Edmonton, Alberta.', // ], // 'archive' => [ // // ], // 'config' => [ // 'is_gallery' => false, // 'content' => 'writing', // 'context' => 'writing', // 'id' => [], // 'class' => [], // ] // ], // 'fields' => [ // 'post_status' => [ // 'type' => 'radio', // 'label' => 'Status', // 'options' => [ // 'publish' => 'Show', // 'draft' => 'Hide', // 'trash' => 'Scrap', // 'delete' => 'Permanently Delete' // ], // 'hidden' => true, // ], // 'post_title' => [ // 'type' => 'text', // 'label' => 'Title', // ], // 'post_date' => [ // 'type' => 'date', // 'label' => 'Date', // ], // 'post_thumbnail' => [ // 'type' => 'upload', // 'label' => 'Image', // ], // 'project' => [ // 'type' => 'taxonomy', // 'taxonomy' => 'project', // 'autocomplete' => true, // 'label' => 'Project', // ], // // 'form' => [ // 'type' => 'taxonomy', // 'taxonomy' => 'form', // 'autocomplete' => true, // 'label' => 'Format', // ], // 'target' => [ // 'type' => 'taxonomy', // 'taxonomy' => 'target', // 'autocomplete' => true, // 'label' => 'Target Audience', // ], // 'city' => [ // 'type' => 'taxonomy', // 'autocomplete' => true, // 'taxonomy' => 'city', // 'label' => 'City', // ], // '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 Writings', // ]; //} function ajv_render_writing_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( '

At a Glance

%s
', 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 = '
'.jvbFormatImage($imgID,'tiny','medium'); $caption = wp_get_attachment_caption($imgID); $out .= ($caption && $caption !== '') ? '
'.apply_filters('the_content', $caption).'
' : ''; $out .= '
'; return $out; }, $gallery); $gallery = implode('',$gallery); $bits[] = sprintf( '', $gallery ); } if (array_key_exists('post_content', $fields) && !empty($fields['post_content'])) { $bits[] = sprintf( '
%s
', $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_writing_schema():array { return [ 'type' => 'JVBase\managers\SEO\render\Thing\CreativeWork\CreativeWork', 'name' => '{{post_title}} | Human-made Canadian Writing', 'description' => '{{post_excerpt}}', 'thumbnail' => '{{post_thumbnail}}', 'dateCreated' => '{{post_date}}', 'dateModified' => '{{post_modified}}', 'keywords' => '{{style.name}}' ]; } function ajv_writing_meta():array { return[ 'name' => '{{post_title}} | Human-made Writing', ]; } function ajv_writing_archive(array $defaults):array { return array_merge($defaults, [ 'name' => 'Canadian Content Writing. From Edmonton, Alberta.', ]); } function ajv_writing_reference_schema(array $defaults):array { return $defaults; }