Jake Vanderwerf
2026-04-26 5fe601cd1962dca79c0765a54ce864af5abb7d40
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
<?php
/*
Plugin Name: JakeVan Extension
Plugin URI: https://jakevan.ca/
Description: An Extension of JakeVan Base, for jakevan.
Author: Jake Vanderwerf
Version: 1.0.0
Author URI: https://jakevan.ca/
Textdomain: ajv
*/
 
//PLUGIN STRUCTURE
// /content/
//      art.php
//      design.php
//      development.php
//      setup.php
//      strategy.php
//      writing.php
// /dashboard/
//      setup.php
// /files/
//      fileManagement.php
// /forms/
//      setup.php
// /login/
//      setup.php
// /taxonomies/
//      city.php
//      form.php
//      media.php
//      progress.php
//      setup.php
//      style.php
//      target.php
//      theme.php
// /users/
//      client.php
//      setup.php
// ajakevan.php     <-- main plugin file
 
if (!defined('ABSPATH')) {
    exit;
}
 
define('JVB_LOADED', is_plugin_active('jvb/jvb.php'));
 
use JVBase\managers\Cache;
use JVBase\managers\CacheManager;
use JVBase\meta\Meta;
use JVBase\registrar\Registrar;
 
add_filter('jvb_base', function () {
    return 'ajv_';
});
 
 
const AJV_DIR = WP_PLUGIN_DIR . '/ajakevan';
define('AJV_URL', plugin_dir_url(__FILE__));
 
add_filter('jvbChildDir', function() { return AJV_DIR; });
add_filter('jvbChildUrl', function() { return AJV_URL; });
 
 
require(AJV_DIR . '/blocks/_setup.php');
require(AJV_DIR . '/content/_setup.php');
//require(AJV_DIR . '/dashboard/setup.php');
require(AJV_DIR . '/forms/_setup.php');
require(AJV_DIR . '/email/_setup.php');
require(AJV_DIR . '/login/_setup.php');
require(AJV_DIR . '/taxonomies/_setup.php');
//require(AJV_DIR . '/users/setup.php');
//require(AJV_DIR . '/files/fileManagement.php');
require(AJV_DIR . '/seo.php');
 
 
/**
 * Defines base options like:
 *         - directory & Membership
 *         - dashboard
 *         - membership settings (JVB_MEMBERSHIP)
 *         - post types (JVB_CONTENT)
 *         - taxonomies (JVB_TAXONOMY)
 *         - User Roles (JVB_USER)
 *         - enthusiast     = (bool) short form for a subscriber-like user that can collect content for reference
 *         - forum            = (bool) create a forum
 *         - member_only    = (bool) if forum and this is true, creates a member-only forum in the custom dashboard
 *
 * as well as central filters for
 *         - rewrite rules
 *         - archive title
 */
add_filter('jvb_site', 'ajv_setup_site');
function ajv_setup_site():array
{
    return [
        'icons'               => 'light',
        'is_directory'        => true,        //as in, a membership directory
        'directory_label'     => ['List', 'Lists'],
        'has_membership'      => false,
//        'has_map'             => true,
        'dashboard'           => true,
        'support'         => true,
        'feed_block'      => true,
        'email_notifications' => true,
        'integrations'  => [
            'bluesky'     => true,
            'cloudflare'  => true,
            'facebook'    => false,
            'maps'        => true,
            'gmb'         => true,
            'helcim'      => true,
            'instagram'   => false,
            'square'      => false,
            'umami'       => true,
            'postmark'       => true,
        ],
        'is_restaurant'       => false,
        'limit_hours'         => false,
        'enthusiast'          => true,
        'favourites'          => false,    //optional flag to allow enthusiasts, but not favourites
    ];
}
/**
 * JVB_MEMBERSHIP defines the structure of the directory
 *         Options include:
 *         - membership_expires        = useful if members pay a yearly membership fee
 *         - hide_expired                = removes users once membership expired; only used if membership_expires is true
 *         - clip_expired                = keeps users once membership expires, but limits the information shown; only used if membership_expires is true
 *         - membership_approval        = verified users can approve other users
 *         - term_approval              = (bool) verified users can create new terms, but needs approval
 *          - member_only              = (array) if empty, open to any registered user. otherwise an array of registered user roles
 */
//add_filter('jvb_membership', 'ajv_setup_membership');
//function ajv_setup_membership():array
//{
//    return [
//        'member_content'  => true,
//        'can_invite'      => ['artist' => ['artist']],
//        'member_verified' => true,
//        'notifications'   => true,
//        'forum'           => true,
//        'member_only'     => [ 'artist' ],
//        'member_expires'  => false,
//        'hide_expired'    => false,
//        'clip_expired'    => false,
//        'term_approval'   => true,
//        'can_approve'     => [ 'artist' ]
//    ];
//}
//
//add_filter('jvbLoadingQuips', 'ajv_loading_quips');
//function ajv_loading_quips(array $quips):array
//{
//    return [];
//}
 
add_filter('jvbLoadingIcon', 'ajv_loading_icon', 999999);
function ajv_loading_icon():string
{
    return 'loading';
}
 
add_filter('jvbDrawerItems', 'jvDrawerItems', 10, 2);
function jvDrawerItems(array $items, string $menuID):array
{
    if ($menuID !== 'main') {
        return $items;
    }
    $items = [
        [
            'text'  => 'About Jake',
            'url'   => home_url('/about'),
            'icon'  => 'user-square',
        ]
    ];
 
    foreach (Registrar::getRegistered('post') as $slug) {
 
        $registrar = Registrar::getInstance($slug);
        if (!$registrar || !$registrar->registrar->public) {
            continue;
        }
        $items[] = [
            'text'  => $registrar->getSingular(),
            'url'   => get_post_type_archive_link(BASE.$slug),
            'icon'  => $registrar->getIcon('icon'),
            'class' => $slug,
        ];
    }
    $items[] = [
        'text'      => 'Contact',
        'icon'      => 'chat-teardrop',
        'url'       => home_url('/contact'),
    ];
//    $items[] = [
//            'text'  => 'Account',
//            'url'   => home_url('/dash'),
//            'icon'  => 'user-circle',
//        ];
    return $items;
}
 
add_filter('jvbBeforeFooter', 'ajv_acknowledgement');
function ajv_acknowledgement():string
{
 
    return '<p>I live and work in amiskwacîwâskahikan ᐊᒥᐢᑲᐧᒋᐋᐧᐢᑲᐦᐃᑲᐣ</p><p><a href="https://www.treatysix.org/#comp-lkljqlw1" title="Learn More">Treaty 6 territory</a></p><p>Edmonton, Alberta, Canada</p>';
}
 
add_filter('jvbRegisterCustomIcons', 'ajv_custom_icons');
function ajv_custom_icons(array $icons):array
{
    $icons['logo'] = AJV_DIR . '/assets/icons/logo-concentric.svg';
    $icons['logo-jakevan'] = AJV_DIR . '/assets/icons/logo-concentric-jakevan.svg';
    $icons['logo-right'] = AJV_DIR . '/assets/icons/logo-right-aligned.svg';
    $icons['logo-right-jakevan'] = AJV_DIR . '/assets/icons/logo-right-aligned-jakevan.svg';
    $icons['jakevan'] = AJV_DIR . '/assets/icons/jakevan.svg';
    $icons['loading'] = AJV_DIR . '/assets/icons/loading.svg';
    return $icons;
}
 
 
 
add_filter('jvbMenuExtra', 'ajv_contact_nav', 10, 3);
function ajv_contact_nav(string $nav, string $menuName, array $block):string
{
    if (array_key_exists('attrs', $block)
        && array_key_exists('className', $block['attrs'])
        && $block['attrs']['className'] === 'is-style-fixed'
        && $nav === '') {
        $text = '<li><a href="'.jvbTextLink(8258239916,'I have an idea - can you help bring it to life?').'" title="Text Me">'.jvbIcon('chat').'<span class="hide-small">825.823.9916</span></a></li>';
        $email = '<li><a href="'.jvbMailToLink(
                'get@jakevan.ca',
                '[JakeVan] I have an idea - can you help bring it to life?','Be sure to as much detail as possible, including what your idea is about, when you need it done by, and budget.'
            ).'" title="Email Me">'.jvbIcon('envelope').'<span class="hide-small">get@jakevan.ca</span></a></li>';
 
        return $text.$email;
    }
 
    return $nav;
}
 
add_filter('jvbRandomFooterText', 'ajv_footer_text');
function ajv_footer_text(string $text):string
{
    $privacy = get_privacy_policy_url();
    $privacy = ($privacy === '') ? '' : ' | <a href="'.$privacy.'">Privacy Policy</a>';
    return '<p class="font-small">©'.date('Y').' <a href="'.get_home_url().'">'.get_bloginfo('name').'</a>'.$privacy.' | <a href="'.get_home_url(null, '/legal/terms-of-service/').'" title="Terms of Service">Terms of Service</a></p><p class="font-small">Built with ♡ by <a href="https://jakevan.ca">Jake Van</a>  <small>(of course!)</small></p>';
}
 
 
add_filter('jvbSummaryHeader', 'ajv_summary_header', 10, 2);
function ajv_summary_header(string $return, string $type):string
{
    $extra = match($type) {
        'strategy'  => 'Edmonton-focused brand',
        default => 'Edmonton made'
    };
    $title = ($type === 'directory') ? 'Directory' : Registrar::getInstance($type)->getSingular();
    return '<small>'.$extra.'</small>'.$title.'.';
}
 
add_filter('jvbSummaryHeaderExtra', 'ajv_summary_extra', 10, 2);
function ajv_summary_extra(string $return, string $type):string
{
    return ($type === 'directory') ? '' : '<p>Or see <a href="'.JVB()->directories()->getDirectoryList()[$type]['url'].'">alphabetical list</a>.</p>';
}
 
function ajv_render_core_post_content(array $block, string $content = ''):string
{
    if(!is_singular(array_map(function($item) { return BASE.$item; }, Registrar::getRegistered('post')))) {
        return JVB()->blocks()->render_core_post_content($block, $content);
    }
    $postType = jvbNoBase(get_post_type());
    $function = "ajv_render_{$postType}_content";
    $base = '';
    if (function_exists($function)) {
        $base = call_user_func($function, $block, $content);
    }
    return ($base === '') ? JVB()->blocks()->render_core_post_content($block, $content) : $base;
}
 
add_filter('the_seo_framework_meta_render_data', 'ajvb_no_next_archive', 10, 1);
function ajvb_no_next_archive($tags) {
    if (is_tax() || is_post_type_archive()) {
        if (array_key_exists('next', $tags)) {
            unset($tags['next']);
        }
    }
    return $tags; // Keep the link for other pages
}
 
 
 
 
add_filter('jvbSummaryDetailsOutput', 'ajvb_summary_info',10, 1);
function ajvb_summary_info(string $return):string
{
    if (!is_singular(array_map(function($item) { return BASE.$item;}, Registrar::getRegistered('post')))) {
        return $return;
    }
 
    $return = ajvb_term_list();
    $return .= ajvb_meta_output();
 
    return $return;
}
 
function ajvb_term_list():string
{
    if (empty(Registrar::getRegistered('term'))){
        return '';
    }
    $ID = get_the_ID();
    $type = jvbNoBase(get_post_type($ID));
 
    $registrar = Registrar::getInstance($type);
    $taxonomies = $registrar->registrar->taxonomies;
 
    $lists = [];
    foreach ($taxonomies as $taxonomy) {
        $baseless = jvbNoBase($taxonomy);
        $taxRegistrar = Registrar::getInstance($baseless);
        $terms = wp_get_object_terms($ID, $taxonomy);
        if ($terms && !is_wp_error($terms)) {
            $list = sprintf(
                '<li>%s<span>%s</span><ul class="term-list">',
                jvbIcon($taxRegistrar->getIcon()),
                $taxRegistrar->getPlural()
            );
            foreach ($terms as $term) {
                $list .= sprintf(
                    '<li><a href="%s" rel="tag">%s</a></li>',
                    get_term_link($term),
                    $term->name
                );
            }
            $list .='</ul></li>';
            $lists[] = $list;
        }
    }
    $out ='';
    if (!empty($lists)){
        $out = sprintf(
            '<ul class="ajv-term-list">%s</ul>',
            implode('',$lists)
        );
    }
 
    return $out;
 
}
 
function ajvb_meta_output():string
{
    if (!class_exists('JVBase\meta\Meta')) {
        return '';
    }
    $ID = get_the_ID();
    $type = jvbNoBase(get_post_type($ID));
 
    return apply_filters('ajvb_summary_meta_output', '', $type);
}
 
function ajvb_format_needs(array $needs):string
{
    $theNeeds = '';
    jvbDump($needs);
    foreach ($needs as $need) {
        $theNeeds .= sprintf(
            '<li><h3>%s</h3>%s<div class="info">%s</div></li>',
            $need['need'],
            $need['image'] !== '' ? jvbFormatImage((int)$need['image']) : '',
            $need['fulfilled']
        );
    }
    return sprintf(
        '<section id="needs"><h2>What we needed:</h2><ul class="needs-wants">%s</ul></section>',
        $theNeeds
    );
}
 
function ajvb_format_wants(array $wants):string
{
    $theWants = '';
    foreach ($wants as $want) {
        $theWants .= sprintf(
            '<li><h3>%s</h3>%s<div class="info">%s</div></li>',
            $want['need'],
            $want['image'] !== '' ? jvbFormatImage($want['image']) : '',
            $want['fulfilled']
        );
    }
    return sprintf(
        '<section id="wants"><h2>What we wanted:</h2><ul class="needs-wants">%s</ul></section>',
        $theWants
    );
}
 
function ajv_is_singular(null|array|string $types = null):bool
{
    if ($types) {
        if (is_string($types)) {
            $types = [$types];
        }
        $types = array_map(function($type) { return jvbCheckBase($type); }, $types);
 
    }else {
        $types = Cache::for('ajakevan')->remember(
            'types',
            function() {
                return array_map(function($type) { return jvbCheckBase($type);}, Registrar::getRegistered('post'));
            }
        );
    }
    return is_singular($types);
}