Jake Vanderwerf
2025-11-10 e9967fa22781d922ba4eb8fb44fe72d200ac4b14
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
if (!defined('ABSPATH')) {
    exit; // Exit if accessed directly
}
 
if (!current_user_can('manage_shop')) {
    wp_redirect(get_home_url(null, '/dash'));
    exit;
}
 
$user = wp_get_current_user();
 
wp_enqueue_script(
    'jvb-shop-manager',
    JVB_URL.'assets/js/min/shopManager.min.js',
    array('jvb-client-queue', 'sortablejs', 'quill-js', 'jvb-taxonomy-selector'),
    '1.0.0',
    true
);
//wp_localize_script('jvb-shop-manager', 'shopSettings', [
//    'type'   => 'user_settings',
//]);
//jvbAdminMap();
 
$shops = jvbGetArtistShops(get_current_user_id());
if (empty($shops)) {
    echo '<h2>I\'m not sure how you got here...</h2>';
    echo '<p>It doesn\'t look like you manage any shops, so nothing is showing up here.</p>';
}
$nav = '<h1>Your Shops:</h1><div class="tabs-container"><nav class="tabs parent row nowrap start" role="tablist">';
$content = '';
$i = 0;
$temp = [];
foreach ($shops as $shop) {
    $active = ($i=== 0) ? ' active' : '';
    $ariaActive = ($i===0) ? ' aria-selected="true"' : '';
    $shop = get_term((int)$shop, BASE.'shop');
    $temp[] = $shop;
    $nav .= '<button type="button" class="tab'.$active.'" data-tab="shop-'.$shop->term_id.'" role="tab"'.$ariaActive.'><h2>'.$shop->name.'</h2>';
    $i++;
}
$shops = $temp;
 
$nav .= '</nav>';
 
echo $nav;
 
$handler = JVB()->getContent('shop');
$i = 0;
foreach ($shops as $shop) {
    $active = ($i=== 0) ? ' active' : '';
    echo '<section class="tab-content'.$active.'" data-tab="shop-'.$shop->term_id.'" role="tabpanel">';
        jvbRenderSections($handler, $shop->term_id, 'term', BASE.'shop', true);
    echo '</section>';
    $i++;
}
 
    echo '</section>';
 
 
function jvbGetArtistShops($userID)
{
    $owner = explode(',', get_user_meta($userID, BASE.'owner_of', true));
    $manager = explode(',', get_user_meta($userID, BASE.'manager_of', true));
    return array_unique(array_filter(array_merge($owner, $manager)));
}