Jake Vanderwerf
2026-08-28 a9654f00c8fbc9934289d761843ddd071025013f
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
<?php
 
use JVBase\base\Options;
use JVBase\base\Site;
use JVBase\managers\Cache;
use JVBase\registrar\Registrar;
 
if (!defined('ABSPATH')) {
    exit;
}
function jvbCheck(string $key, $config = []):bool
{
    return (array_key_exists($key, $config) && $config[$key] === true);
}
 
function jvbUserTypes():array
{
    return  Registrar::withFeature('profile_link', 'user');
}
 
 
 
function jvbIsOpen():bool
{
    if (!Site::has('limit_hours')) {
        return true;
    }
    if (Options::get('open_to_public') !== '1') {
        return false;
    }
    if (!empty(Options::get('today_hours'))) {
        return jvbIsTimeBetween();
    }
    return jvbIsCurrentlyOpen();
}
 
 
function jvbTermHasPosts(int $termID, string $taxonomy):bool
{
    $cache = Cache::for('termUtility', 'term', 30*60);
    return $cache->remember(
        $termID,
        function() use($taxonomy, $termID) {
            $taxonomy = jvbCheckBase($taxonomy);
            $tax = get_taxonomy($taxonomy);
            if ($tax) {
                $query = new WP_Query([
                    'post_type' => $tax->object_type,
                    'posts_per_page' => 1,
                    'fields' => 'ids',
                    'tax_query' => [
                        [
                            'taxonomy' => $taxonomy,
                            'terms' => $termID
                        ]
                    ]
                ]);
                $result = ($query->have_posts()) ? 'true' : 'false';
                wp_reset_postdata();
                return $result;
 
            }
            return 'false';
        }
    );
}