| | |
| | | <?php |
| | | |
| | | // /content/development.php |
| | | function ajv_development():array |
| | | { |
| | | return [ |
| | | 'singular' => 'Development', |
| | | 'plural' => 'Developments', |
| | | 'directory' => 'Development', |
| | | 'hide_single' => false, |
| | | 'redirectToAuthor'=> false, |
| | | 'show_directory'=> true, |
| | | 'show_feed' => true, |
| | | 'favouritable' => true, |
| | | 'karma' => false, |
| | | 'icon' => 'brackets-angle', |
| | | 'rewrite' => [ |
| | | 'slug' => 'development', |
| | | 'with_front' => false, |
| | | ], |
| | | use JVBase\meta\Meta; |
| | | use JVBase\registrar\Registrar; |
| | | use JVBase\utility\Image; |
| | | |
| | | 'seo' => [ |
| | | 'schema' => [ |
| | | 'type' => 'CreativeWork', |
| | | 'name' => '{{post_title}}', |
| | | 'description' => '{{post_excerpt}}', |
| | | 'about' => ['@id' => '{{site_url}}/#development'], |
| | | 'associatedMedia' => '{{post_thumbnail}}', |
| | | 'dateCreated' => '{{post_date}}', |
| | | ], |
| | | 'meta' => [ |
| | | 'title' => '{{post_title}} | Custom Website Development', |
| | | 'description' => '{{post_excerpt}}', |
| | | ], |
| | | 'archive' => [ |
| | | 'type' => 'CollectionPage', |
| | | 'name' => 'Custom Canadian Website Development. Made in Edmonton, Alberta.', |
| | | ], |
| | | ], |
| | | 'feed' => [ |
| | | 'single' => [ |
| | | 'pre_title' => 'Custom Canadian Website Development. Made in Edmonton, Alberta.', |
| | | ], |
| | | 'archive' => [ |
| | | if (!defined('ABSPATH')) { |
| | | exit; |
| | | } |
| | | |
| | | |
| | | add_action('plugins_loaded', 'ajv_development',1); |
| | | //Add fields later so we can verify taxonomies/post types exist |
| | | add_action('plugins_loaded', 'ajv_development_fields', 2); |
| | | |
| | | add_filter('ajv_DevelopmentSchemaDefault', 'ajv_development_schema'); |
| | | add_filter('ajv_DevelopmentMetaDefault', 'ajv_development_meta'); |
| | | add_filter('ajv_DevelopmentArchiveDefault', 'ajv_development_archive'); |
| | | add_filter('ajv_DevelopmentExtras', 'ajv_development_extras'); |
| | | |
| | | function ajv_development(){ |
| | | if (!class_exists('JVBase\registrar\Registrar')) { |
| | | return; |
| | | } |
| | | $development = Registrar::forPost('development', 'Development', 'Developments') |
| | | ->setIcon('brackets-angle') |
| | | ->make([ |
| | | 'rewrite' => [ |
| | | 'slug' => 'development', |
| | | 'with_front' => false, |
| | | ], |
| | | 'config' => [ |
| | | 'is_gallery' => false, |
| | | 'content' => 'development', |
| | | 'context' => 'development', |
| | | 'id' => [], |
| | | 'class' => [], |
| | | 'taxonomies' => [ |
| | | 'project', |
| | | 'form', |
| | | 'city', |
| | | 'style', |
| | | 'theme', |
| | | 'target', |
| | | ] |
| | | ], |
| | | '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_development_fields():void |
| | | { |
| | | if (!class_exists('JVBase\registrar\Registrar')) { |
| | | return; |
| | | } |
| | | $development = Registrar::getInstance('development'); |
| | | |
| | | //$directory = $development->getConfig('directory'); |
| | | $breadcrumbs = $development->config('breadcrumbs'); |
| | | $breadcrumbs->setCrumb('project'); |
| | | |
| | | $fields = $development->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('target', [ |
| | | 'type' => 'selector', |
| | | 'subtype' => 'taxonomy', |
| | | 'taxonomy' => 'target', |
| | | 'label' => 'Target Audience', |
| | | ]); |
| | | $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_title' => [ |
| | | 'type' => 'text', |
| | | 'label' => 'Title', |
| | | ], |
| | | 'post_date' => [ |
| | | 'type' => 'date', |
| | | 'label' => 'Date', |
| | | ], |
| | | 'post_thumbnail' => [ |
| | | 'image' => [ |
| | | 'type' => 'upload', |
| | | 'label' => 'Image', |
| | | 'multiple' => true, |
| | | 'label' => 'Example Image' |
| | | ], |
| | | 'project' => [ |
| | | 'type' => 'taxonomy', |
| | | 'taxonomy' => 'project', |
| | | 'autocomplete' => true, |
| | | 'label' => 'Project', |
| | | ], |
| | | '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' => [ |
| | | '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' |
| | | ] |
| | | ] |
| | | ]); |
| | | } |
| | | |
| | | 'needs' => [ |
| | | 'type' => 'repeater', |
| | | 'label' => 'Needs', |
| | | 'fields'=> [ |
| | | 'need' => [ |
| | | 'type' => 'text', |
| | | 'label' => 'Need', |
| | | 'required' => true |
| | | ], |
| | | 'fulfilled' => [ |
| | | 'type' => 'textarea', |
| | | 'quill' => true, |
| | | 'label' => 'How I fulfilled it' |
| | | ] |
| | | ] |
| | | ], |
| | | 'wants' => [ |
| | | 'type' => 'repeater', |
| | | 'label' => 'Wants', |
| | | 'fields'=> [ |
| | | 'need' => [ |
| | | 'type' => 'text', |
| | | 'label' => 'Want', |
| | | 'required' => true |
| | | ], |
| | | 'fulfilled' => [ |
| | | 'type' => 'textarea', |
| | | 'quill' => true, |
| | | 'label' => 'How I fulfilled it' |
| | | ] |
| | | ] |
| | | ], |
| | | function ajv_development_extras(array $extras):array |
| | | { |
| | | return [[ |
| | | 'type' => 'JVBase\managers\SEO\render\Thing\Intangible\Service', |
| | | 'id' => get_post_type_archive_link(BASE.'development').'#service', |
| | | 'name' => 'Custom Website Development in Edmonton, Alberta', |
| | | 'description' => 'Custom website development by Canadian developer Jake Vanderwerf. |
| | | Whether you\'re looking for custom functionality, integration of your services, or a completely custom development solutions.', |
| | | 'url' => get_post_type_archive_link(BASE.'development'), |
| | | 'provider' => ['id' => get_home_url(null, '#localbusiness')], |
| | | 'areaServed' => [ |
| | | '@type' => 'JVBase\managers\SEO\render\Thing\Place\AdministrativeArea\Country', |
| | | 'name' => 'Canada' |
| | | ], |
| | | 'single_image' => false, |
| | | 'upload_title' => 'Upload Artwork', |
| | | ]]; |
| | | |
| | | } |
| | | |
| | | //function ajv_development():array |
| | | //{ |
| | | // return [ |
| | | // 'singular' => 'Development', |
| | | // 'plural' => 'Developments', |
| | | // 'directory' => 'Development', |
| | | // 'addCrumb' => 'project', |
| | | // 'show_directory'=> true, |
| | | // 'show_feed' => true, |
| | | // 'favouritable' => true, |
| | | // 'karma' => false, |
| | | // 'icon' => 'brackets-angle', |
| | | // 'rewrite' => [ |
| | | // 'slug' => 'development', |
| | | // 'with_front' => false, |
| | | // ], |
| | | // |
| | | // 'seo' => [ |
| | | // 'schema' => [ |
| | | // 'type' => 'CreativeWork', |
| | | // 'name' => '{{post_title}}', |
| | | // 'description' => '{{post_excerpt}}', |
| | | // 'about' => ['@id' => '{{site_url}}/#development'], |
| | | // 'associatedMedia' => '{{post_thumbnail}}', |
| | | // 'dateCreated' => '{{post_date}}', |
| | | // ], |
| | | // 'meta' => [ |
| | | // 'title' => '{{post_title}} | Custom Website Development', |
| | | // 'description' => '{{post_excerpt}}', |
| | | // ], |
| | | // 'archive' => [ |
| | | // 'type' => 'CollectionPage', |
| | | // 'name' => 'Custom Canadian Website Development. Made in Edmonton, Alberta.', |
| | | // ], |
| | | // ], |
| | | // 'feed' => [ |
| | | // 'single' => [ |
| | | // 'pre_title' => 'Custom Canadian Website Development. Made in Edmonton, Alberta.', |
| | | // ], |
| | | // 'archive' => [ |
| | | // |
| | | // ], |
| | | // 'config' => [ |
| | | // 'is_gallery' => false, |
| | | // 'content' => 'development', |
| | | // 'context' => 'development', |
| | | // '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', |
| | | // ], |
| | | // 'url' => [ |
| | | // 'type' => 'url', |
| | | // 'label' => 'Live URL', |
| | | // 'quickEdit' => true |
| | | // ], |
| | | // |
| | | // '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 Development', |
| | | // ]; |
| | | //} |
| | | |
| | | |
| | | |
| | | function ajv_prerender_development_content(array $block, ?string $content, ?WP_Block $parent):?string |
| | | { |
| | | $out = ''; |
| | | $ID = get_the_ID(); |
| | | $meta = Meta::forPost($ID); |
| | | |
| | | $fields = $meta->getAll(); |
| | | |
| | | |
| | | |
| | | $bits = []; |
| | | $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 (!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); |
| | | } |
| | | |
| | | if (!empty($fields['gallery']??'')) { |
| | | $bits[] = sprintf( |
| | | '<section id="gallery"><h2>Gallery</h2>%s</section>', |
| | | Image::gallery($fields['gallery']) |
| | | ); |
| | | } |
| | | |
| | | if (!empty($fields['post_content']??'')) { |
| | | $bits[] = sprintf( |
| | | '<section id="content">%s</section>', |
| | | $fields['post_content'] |
| | | ); |
| | | } |
| | | |
| | | if (!empty($fields['needs']??'')) { |
| | | $bits[] = ajvb_format_needs($fields['needs']); |
| | | } |
| | | if (!empty($fields['wants']??'')) { |
| | | $bits[] = ajvb_format_wants($fields['wants']); |
| | | } |
| | | |
| | | if (!empty($bits)) { |
| | | $out = implode('',$bits); |
| | | } |
| | | |
| | | |
| | | return $out; |
| | | } |
| | | |
| | | |
| | | |
| | | function ajv_development_schema():array |
| | | { |
| | | return [ |
| | | 'type' => 'JVBase\managers\SEO\render\Thing\CreativeWork\CreativeWork', |
| | | 'name' => '{{post_title}} | Canadian Development', |
| | | 'about' => [ |
| | | |
| | | ], |
| | | 'description' => '{{post_excerpt}}', |
| | | 'thumbnail' => '{{post_thumbnail}}', |
| | | 'dateCreated' => '{{post_date}}', |
| | | 'dateModified' => '{{post_modified}}', |
| | | 'keywords' => '{{style.name}}' |
| | | ]; |
| | | } |
| | | |
| | | function ajv_development_meta():array |
| | | { |
| | | return[ |
| | | 'name' => '{{post_title}} | Human-made Development', |
| | | ]; |
| | | } |
| | | |
| | | function ajv_development_archive(array $defaults):array |
| | | { |
| | | return array_merge($defaults, [ |
| | | 'name' => 'Canadian Development. Made in Edmonton, Alberta.', |
| | | ]); |
| | | } |
| | | |
| | | function ajv_development_reference_schema(array $defaults):array |
| | | { |
| | | return $defaults; |
| | | } |