Jake Vanderwerf
4 hours ago b7aed073c23396afa7eccb488dd25bfa222c1819
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php
// /content/event.php
 
use JVBase\registrar\Registrar;
if (!defined('ABSPATH')) {
    exit;
}
 
add_action('jvbDefineRegistrar', 'aei_event');
add_action('jvbDefineRegistrarFields', 'aei_event_fields');
 
add_action('plugins_loaded', 'aei_event',3);
//Add fields later so we can verify taxonomies/post types exist
add_action('plugins_loaded', 'aei_event_fields', 4);
 
add_filter('aei_EventSchemaDefault', 'aei_event_schema');
add_filter('aei_EventMetaDefault', 'aei_event_meta');
add_filter('aei_EventArchiveDefault', 'aei_event_archive');
 
function aei_event(){
    if (!class_exists('JVBase\registrar\Registrar')) {
        return;
    }
    $event = Registrar::forPost('event', 'Event', 'Events')
        ->setIcon('event')
        ->make([
            'rewrite'   => [
                'slug'          => 'events',
                'with_front'    => false,
            ],
            'taxonomies'    => [
                'shop',
                'city',
                'event_type'
            ],
        ])
        ->setAll([
            'show_directory',
            'favouritable',
            'karma',
            'show_feed',
            'is_calendar'
        ])
        ->setIntegration('facebook')
        ->setIntegration('instagram');
 
//$directory = $event->getConfig('directory');
 
}
 
function aei_event_fields():void
{
    if (!class_exists('JVBase\registrar\Registrar')) {
        return;
    }
    $event = Registrar::getInstance('event');
//    $breadcrumbs = $event->config('breadcrumbs');
//    $breadcrumbs->setCrumb('section');
 
 
    $fields = $event->fields();
    $fields->modifyField('post_thumbnail', 'label', 'Event Poster');
    $fields->modifyField('post_content', 'label', 'About the Event');
    $fields->addField('gallery', [
        'type'      => 'upload',
        'label'     => 'Additional Images',
    ]);
    $fields->addField('city', [
        'type'      => 'selector',
        'subtype'      => 'taxonomy',
        'taxonomy'      => 'city',
        'label'     => 'City',
    ]);
    $fields->addField('shop', [
        'type'      => 'selector',
        'subtype'      => 'taxonomy',
        'taxonomy'      => 'shop',
        'label'     => 'Tattoo Shop',
    ]);
    $fields->addField('event_type', [
        'type'      => 'selector',
        'subtype'      => 'taxonomy',
        'taxonomy'      => 'event_type',
        'label'     => 'Type of Event',
    ]);
    $fields->addField('url', [
        'type'      => 'text',
        'subtype'      => 'url',
        'label'     => 'URL for More Information',
    ]);
    $fields->addField('purchase_url', [
        'type'      => 'text',
        'subtype'      => 'url',
        'label'     => 'Purchase link',
    ]);
    $fields->addField('cost', [
       'type'   => 'text',
       'subtype'      => 'number',
       'label'  => 'Cost (leave blank for free)'
    ]);
    $fields->addField('max_attendees', [
       'type'   => 'text',
       'subtype'      => 'number',
       'label'  => 'Maximum Attendees'
    ]);
 
 
}
 
function aei_event_schema():array
{
    return [
        'type'              => 'JVBase\managers\SEO\render\Thing\Event',
        'name'              => '{{post_title}} | by {{post_author.name}} {{post_author.city}} Event Artist',
    ];
}
 
function aei_event_meta():array
{
    return[
        'name' => '{{post_title}} | by {{post_author.name}} {{post_author.city}} Event Artist',
        'description' => '{{style}} {{colour}} {{theme}} event in {{post_author.city}}.',
    ];
}
 
function aei_event_archive(array $defaults):array
{
    return array_merge($defaults, [
        'name' => 'Edmonton\'s Best Events',
        'description' => 'Events in Edmonton, Alberta.'
    ]);
}
 
function aei_event_reference_schema(array $defaults):array
{
    return $defaults;
}