setIcon('cards-three')
->make([
'rewrite' => [
'slug' => 'projects',
'with_front' => false,
],
'for' => [
'art',
'design',
'development',
'strategy',
'writing'
],
'hierarchical' => true,
])
->setAll([
'show_feed',
'show_directory',
'is_content',
]);
}
function ajv_project_fields():void
{
if (!class_exists('JVBase\registrar\Registrar')) {
return;
}
$project = Registrar::getInstance('project');
$directory = $project->config('directory');
$directory->setTitle('Projects');
//$breadcrumbs = $project->config('breadcrumbs');
//$breadcrumbs->setCrumb('project');
$fields = $project->fields();
$fields->addField(
'city',
[
'type' => 'selector',
'subtype' => 'taxonomy',
'isReference' => true,
'taxonomy' => 'city',
'label' => 'City',
'quickEdit' => true,
]
);
$fields->addField(
'thumbnail',
[
'type' => 'upload',
'multiple' => false,
'label' => 'Featured Image',
]
);
$fields->addField(
'summary',
[
'type' => 'textarea',
'quill' => true,
'label' => 'Summary',
]
);
$fields->addField(
'target',
[
'type' => 'taxonomy',
'isReference' => true,
'taxonomy' => 'target',
'label' => 'Target Audience',
'quickEdit' => true,
]
);
$fields->addField(
'started',
[
'type' => 'date',
'label' => 'Started',
'quickEdit' => true,
]
);
$fields->addField(
'ended',
[
'type' => 'date',
'label' => 'Ended',
'quickEdit' => true,
]
);
$fields->addField(
'budget',
[
'type' => 'radio',
'label' => 'Budget',
'options' => [
'low' => '$',
'medium-low'=> '$$',
'medium' => '$$$',
'medium-high'=> '$$$$',
'high' => '$$$$$',
]
]
);
$fields->addField(
'timeline',
[
'type' => 'text',
'label' => 'Timeline',
'quickEdit' => true,
]
);
$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'
]
]
]);
$fields->addField(
'forType',
[
'type' => 'repeater',
'label' => 'Person, Organization, or LocalBusiness this is for',
'fields' => [
'type' => [
'type' => 'select',
'label' => 'Type',
'options' => [
'JVBase\managers\SEO\render\Thing\Person' => 'Person',
'JVBase\managers\SEO\render\Thing\Organization\LocalBusiness\LocalBusiness' => 'Local Business',
'JVBase\managers\SEO\render\Thing\Organization\Organization' => 'Organization'
]
],
'name' => [
'type' => 'text',
'label' => 'Name',
],
'url' => [
'type' => 'url',
'label' => 'Website',
],
'location' => [
'type' => 'text',
'label' => 'Location',
],
]
]
);
$fields->addCommon('review');
$fields->addCommon('wiki');
}
//function ajv_project():array
//{
// return [
// 'singular' => 'Project',
// 'plural' => 'Projects',
// 'icon' => 'cards-three',
// 'show_feed' => true,
// 'show_directory' => true,
// 'approve_new' => false,
// 'rewrite' => [
// 'slug' => 'projects',
// 'with_front' => false,
// 'hierarchical' => true,
// ],
// 'hierarchical' => true,
// 'for_content' => [
// 'art',
// 'project',
// 'development',
// 'strategy',
// 'writing',
// ],
// 'seo' => [
// 'schema' => [
// 'type' => 'CreativeWork',
// 'name' => '{{name}}',
// 'description' => '{{description}}',
// 'dateCreated' => '{{started}}',
// 'keywords' => '{{target.name}}',
// ],
// 'meta' => [
// 'title' => '{{name}} | Project by JakeVan',
// 'description' => '{{description}}',
// ],
// 'archive' => [
// 'type' => 'CollectionPage',
// 'name' => '{{name}}',
// 'description' => '{{description}}',
// ],
// ],
// 'fields' => [
// 'term_name' => [
// 'label' => 'Name',
// 'type' => 'text',
// 'quickEdit' => true,
// ],
// 'city' => [
// 'type' => 'taxonomy',
// 'isReference' => true,
// 'taxonomy' => 'city',
// 'autocomplete' => true,
// 'quickEdit' => true,
// 'label' => 'City',
// ],
// 'target' => [
// 'type' => 'taxonomy',
// 'isReference' => true,
// 'taxonomy' => 'target',
// 'autocomplete' => true,
// 'quickEdit' => true,
// 'label' => 'Target Audience',
// ],
// 'started' => [
// 'type' => 'date',
// 'label' => 'Started',
// 'quickEdit' => true,
// ],
// 'ended' => [
// 'type' => 'date',
// 'label' => 'Ended',
// 'quickEdit' => true,
// ],
// 'budget' => [
// 'type' => 'radio',
// 'label' => 'Budget',
// 'options' => [
// 'low' => '$',
// 'medium-low'=> '$$',
// 'medium' => '$$$',
// 'medium-high'=> '$$$$',
// 'high' => '$$$$$',
// ]
// ],
// 'timeline' => [
// 'type' => 'text',
// 'label' => 'Timeline',
// 'quickEdit' => true,
// ],
// 'url' => [
// 'type' => 'url',
// 'label' => 'Project URL',
// 'quickEdit' => true,
// ],
// 'description' => [
// 'type' => 'textarea',
// 'quill' => true,
// 'quickEdit' => true,
// 'label' => 'Project Description',
// ],
// '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'
// ]
// ]
// ],
//
// 'common' => [ 'wiki' ]
// ]
// ];
//}
function ajv_project_schema():array
{
return [
// 'type' => 'JVBase\managers\SEO\render\Thing\CreativeWork\CreativeWork',
'name' => 'Projects by JakeVan',
'description' => 'Each project can have multiple aspects - from Design to Strategy.',
// 'primaryImageOfPage' => '{{thumbnail}}',
];
}
function ajv_project_meta():array
{
return[
'name' => '{{name}} | Project',
];
}
function ajv_project_archive(array $defaults):array
{
return array_merge($defaults, [
'name' => '{{name}} | Project',
'description' => '{{description}}',
'primaryImageOfPage' => '{{thumbnail}}',
'about' => [
'type' => 'JVBase\managers\SEO\render\Thing\CreativeWork\CreativeWork',
'name' => '{{name}}',
'creator' => '{{CREATOR}}',
'sourceOrganization'=> '{{forType}}',
'abstract' => '{{summary}}'
],
]);
}
function ajv_project_reference_schema(array $defaults):array
{
return $defaults;
}
function ajv_render_project_cover(int $ID):string
{
return '';
$background = '';
$meta = Meta::forTerm($ID);
$thumbnail = $meta->get('thumbnail');
if ($thumbnail !== '') {
$background = str_replace('getAll();
$extra = 'Edmonton';
if ($fields['city'] !== '') {
$cities = explode(',', $fields['city']);
$temp = [];
foreach ($cities as $city) {
$term = get_term($city, 'ajv_city');
if ($term && !is_wp_error($term)) {
$temp[] = $term->name;
}
}
if (!empty($temp)) {
$extra = jvbCommaList($temp);
}
}
$extra .= '-Based Project';
return ''.$extra.''.$fields['name'].'.';
}
add_filter('jvbSummaryHeaderExtra', 'ajv_project_summary_extra', 11, 2);
function ajv_project_summary_extra(string $return, string $type):string
{
if ($type !== 'project') {
return $return;
}
return '
Or see all projects.
'; } add_filter('jvbBeforeSummary', 'ajv_project_before_summary', 10, 2); function ajv_project_before_summary(string $return, string $type):string { if ($type !== 'project') { return $return; } $meta = Meta::forTerm(get_queried_object_id()); $fields = $meta->getAll(); $rows = []; if (!empty($fields['city'])) { $rows[] = jvbMetaTermList($fields['city'], 'city'); } if ($fields['target'] !== '') { $rows[] = jvbMetaTermList($fields['target'], 'target'); } if ($fields['started'] !== '') { $rows[] = ''.jvbIcon('calendar-blank').'Started:'; } if ($fields['ended'] !== '') { $rows[] = 'Ended:'; } if ($fields['budget'] !== '') { $budget = ''; for ($i = 0; $i <= (int) $fields['budget']; $i++) { $budget .= '$'; } $budget = match($fields['budget']) { 'low' => '$', 'medium-low' => '$$', 'medium' => '$$$', 'medium-high' => '$$$$', 'high' => '$$$$$' }; $title = ucwords($fields['budget']); $rows[] = ''.jvbIcon('currency-dollar-simple').'Budget:'.$budget.''; } if ($fields['timeline'] !== '') { $rows[] = ''.jvbIcon('hourglass-medium').'Timeline:'.$fields['timeline']; } $summary = 'Nothing here yet.
'; } $section .= '