Jake Vanderwerf
2026-05-01 11f29668ba55c9ef92865a1cfab3d76b25aef086
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
<?php
// /content/offer.php
 
use JVBase\registrar\Registrar;
if (!defined('ABSPATH')) {
    exit;
}
 
add_action('jvbDefineRegistrar', 'aei_offer');
add_action('jvbDefineRegistrarFields', 'aei_offer_fields');
 
add_action('plugins_loaded', 'aei_offer',3);
//Add fields later so we can verify taxonomies/post types exist
add_action('plugins_loaded', 'aei_offer_fields', 4);
 
add_filter('aei_OfferSchemaDefault', 'aei_offer_schema');
add_filter('aei_OfferMetaDefault', 'aei_offer_meta');
add_filter('aei_OfferArchiveDefault', 'aei_offer_archive');
 
function aei_offer(){
    if (!class_exists('JVBase\registrar\Registrar')) {
        return;
    }
    $offer = Registrar::forPost('offer', 'Offer', 'Offers')
        ->setIcon('offer')
        ->make([
            'rewrite'   => [
                'slug'          => 'offers',
                'with_front'    => false,
            ],
            'taxonomies'    => [
                'city',
                'offer_for',
            ],
        ])
        ->setAll([
            'show_directory',
            'hide_single',
            'redirect_to_author',
            'favouritable',
            'karma',
            'show_feed'
        ])
        ->setIntegration('facebook')
        ->setIntegration('instagram');
 
//$directory = $offer->getConfig('directory');
 
}
 
function aei_offer_fields():void
{
    if (!class_exists('JVBase\registrar\Registrar')) {
        return;
    }
    $offer = Registrar::getInstance('offer');
//    $breadcrumbs = $offer->config('breadcrumbs');
//    $breadcrumbs->setCrumb('section');
 
 
    $fields = $offer->fields();
    $fields->modifyField('post_thumbnail', 'label', 'Main Image');
    $fields->modifyField('post_content', 'label', 'Notes (optional)');
    $fields->addField('gallery', [
        'type'      => 'upload',
        'label'     => 'Additional Images',
    ]);
    $fields->addField('referral_code', [
        'type'      => 'text',
        'label'     => 'Referral Code',
        'hint'      => 'Some sort of tracking code to gauge how well it\'s working'
    ]);
    $fields->addField('url', [
        'type'      => 'url',
        'label'     => 'Target URL',
        'hint'      => 'Where you want folks to be directed to.'
    ]);
    $fields->addField('offer_for', [
        'type'      => 'selector',
        'subtype'   => 'taxonomy',
        'taxonomy'  => 'offer_for',
        'label'     => 'Offer for',
    ]);
 
}
 
function aei_offer_schema():array
{
    return [
        'type'              => 'JVBase\managers\SEO\render\Thing\Intangible\Offer',
        'name'              => '{{post_title}} | by our supporter {{post_author.name}}',
    ];
}
 
function aei_offer_meta():array
{
    return[
        'name' => '{{post_title}} | by {{post_author.name}} {{post_author.city}} Offer Artist',
        'description' => '{{style}} {{colour}} {{theme}} offer in {{post_author.city}}.',
    ];
}
 
function aei_offer_archive(array $defaults):array
{
    return array_merge($defaults, [
        'name' => 'Edmonton\'s Best Offers',
        'description' => 'Offers in Edmonton, Alberta.'
    ]);
}
 
function aei_offer_reference_schema(array $defaults):array
{
    return $defaults;
}