Jake Vanderwerf
2026-05-01 48721c85ebcfa973ee81719d2467ca80e4253dc9
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
<?php
 
use JVBase\registrar\Registrar;
 
if (!defined('ABSPATH')) {
    exit;
}
 
//add_action('login_init', 'jvbLoginFormText');
function jvbLoginFormText()
{
    add_filter('gettext', 'jvbTranslations', 10, 2);
    add_filter('ngettext', 'jvbTranslations', 10, 2);
}
 
function jvbTranslations($translation, $text)
{
    if (!$GLOBALS['pagenow'] == 'wp-login.php') {
        return $translation;
    }
    global $_GET;
    if (array_key_exists('action', $_GET) && $_GET['action'] == 'register') {
        $translation = str_ireplace('Register', 'Join the Scene', $translation);
        $translation = str_ireplace('Log in', 'Already joined? Log in', $translation);
    } else {
        $translation = str_ireplace('Register', 'No account? Join In!', $translation);
        $translation = str_ireplace('Log in', 'Get In', $translation);
    }
 
    return $translation;
}
 
add_filter('login_title', 'jvbLoginTitle');
function jvbLoginTitle($title):string
{
    global $_GET;
//    return (array_key_exists('action', $_GET) &&
//            $_GET['action'] === 'register') ?
//        'Join the Scene | edmonton.ink' :
//        'Get Backstage | edmonton.ink';
    return (array_key_exists('action', $_GET) &&
            $_GET['action'] === 'register') ?
        'Register | North\'eh Smoke & Smash' :
        'Log in | North\'eh Smoke & Smash';
}
 
 
/**
 * Checks if the logged in user is one of us
 * @return bool
 */
function isOurPeople():bool
{
    if (!is_user_logged_in()) {
        return false;
    }
    $user = wp_get_current_user();
 
    return count(
        array_intersect(
            array_values($user->roles),
            array_map(function ($role) {
                return BASE.$role;
            },
               Registrar::getFeatured('has_dashboard', 'user'))
        )
    )>0;
}
 
 
 
 
/**
 * Feed Block Helpers
 */
function jvbGetUserContentTypes(int $postID):array
{
    $types = get_post_meta($postID, BASE.'content_types', true);
    if ($types === '') {
        $types = [];
        $link = (int) get_post_meta($postID, BASE.'profile_link', true);
        if ($link === '' || !is_numeric($link)) {
            return $types;
        }
 
        $user = get_userdata($link);
 
        if (!$user) {
            return $types;
        }
 
        $role = jvbUserRole((int) $link);
        $registrar = Registrar::getInstance($role);
        if ($registrar && !empty($registrar->getCreatable())){
            foreach ($registrar->getCreatable() as $type) {
                if (is_array($type)) {
                    $types = array_unique(array_merge($types, array_values($type)[0]));
                } else {
                    $types[] = $type;
                }
            }
        }
 
        $temp = [];
        foreach ($types as $t) {
            $permission = JVB()->roles()->getPermission('edit',$t);
            if (user_can($link, $permission)){
                $temp[] = $t;
            }
        }
 
        $types = Registrar::getFeatured('show_feed');
        $types = array_filter($temp, function ($type) use ($types) {
            return in_array($type, $types);
        });
 
        update_post_meta($postID, BASE.'content_types', $types);
    }
 
    return $types;
}