Jake Vanderwerf
2025-11-04 42fa8304ddb811b0f725f245130f70c0f5e86a6c
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
<?php
 
use JVBase\managers\CacheManager;
 
if (!defined('ABSPATH')) {
    exit; // Exit if accessed directly
}
if (!isOurPeople()) {
    wp_redirect(get_home_url(null, '/dash'));
    exit;
}
$cache = CacheManager::for('news', 3600);
$check = $cache->get('type-options');
 
if ($check) {
    $typeOptions = $check;
} else {
    $terms = get_terms([
        'taxonomy'        => BASE.'ntype',
        'hide_empty'    => false,
    ]);
    $typeOptions = [];
    if ($terms && !is_wp_error($terms)) {
        foreach ($terms as $term) {
            $typeOptions[] = [
                'id'    => $term->term_id,
                'name'    => $term->name,
                'count'    => $term->count,
            ];
        }
    }
    $cache->set('type-options', $typeOptions);
}
 
?>
<div class="container news">
    <!-- Tab navigation -->
    <div class="tabs" role="tablist">
        <button type="button" class="tab active" data-tab="news" role="tab" aria-selected="true">
            <h2><?= jvbIcon('news')?>News</h2>
        </button>
        <button type="button" class="tab" data-tab="mine" role="tab" aria-selected="false">
            <h2>Yours</h2>
        </button>
        <button type="button" class="tab" data-tab="watching" role="tab" aria-selected="false">
            <h2><?= jvbIcon('star')?>Watching</h2>
        </button>
 
        <button type="button" class="add-item-btn">
            <?= jvbIcon('add', ['title' =>'Add News']) ?>
            <span>Post</span>
        </button>
    </div>
 
    <div class="tab-content active" data-tab="news" role="tabpanel">
        <h1>Behind the Scenes<small>Check the pulse on the local scene</small></h1>
    </div>
 
    <div class="tab-content" data-tab="mine" role="tabpanel">
        <h2>Your Content</h2>
        <?= jvbCrudManagement('news'); ?>
 
        <dialog class="bulk-edit-modal">
            <div class="wrap">
                <h2>Bulk Edit <span class="selected-count"></span></h2>
                <form class="bulk-edit-form" data-form-id="bulk-edit-news" data-nocache data-save="news">
                    <div class="selected"></div>
                    <p class="description">You can unselect items by clicking them here.</p>
                    <div class="fields">
                        <div class="field-group radio-options row">
                            <?php
                            $bulkActions = jvbGetBulkActions('news');
 
                            foreach ($bulkActions as $status => $options) {
                                $disabled = ($options['disabled']) ? ' disabled' : '';
                                ?>
                                <input type="radio"
                                    name="bulk_status"
                                    value="<?=$status?>"
                                    id="bulk-status-<?=$status?>>"<?=$disabled;?>>
                                <label for="bulk-status-<?=$status?>">
                                <?= jvbIcon($options['icon']) ?>
                                <span><?= $options['label'] ?></span>
                            </label>
                                <?php
                            }
                            ?>
                        </div>
                        <div class="taxonomies">
                            <div class="taxonomies">
                                <label>Type</label>
 
                                <?php
                                foreach ($typeOptions as $type) {
                                    ?>
                                    <input type="radio" name="type" id="bulk-<?=$type['id']?>">
                                    <label for="bulk-<?=$type['id']?>"><?=$type['name']?></label>
                                    <?php
                                }
                                ?>
                            </div>
 
                        </div>
                    </div>
                </form>
                <div class="actions row">
                    <button type="button" class="cancel">Cancel</button>
                    <button type="button" class="save">Apply to Selected</button>
                </div>
            </div>
        </dialog>
 
    </div>
 
    <div class="tab-content" data-tab="watching" role="tabpanel">
        <h2>Content You're Watching</h2>
    </div>
 
    <details class="type-filters">
        <summary class="row btw">Filters:
            <button class="clear-filters row">
                <?= jvbIcon('close', ['title' => 'Clear Filters'])?>
                <span>Clear Filters</span>
                </span>
            </button>
        </summary>
        <form type="dialog" class="filters" data-nocache data-form-id="news-filters" data-get="news">
            <div class="filters">
                <?php
                $manager = new JVBase\managers\NewsRelationships();
 
                $artists = $manager->getAllArtistsWithNews();
                $shops = $manager->getAllShopsNews();
 
                $filters = [
                    'type' => [
                        'type'        => 'taxonomy',
                        'label'        => 'Type',
                        'icon'        => 'theme',
                        'options'    => $typeOptions,
                    ],
                    'shop'    => [
                        'type'        => 'taxonomy',
                        'label'        => 'Shop',
                        'icon'        => 'shop',
                        'options'    => $shops,
                    ],
                    'artist'    => [
                        'type'        => 'post',
                        'label'        => 'Artist',
                        'icon'        => 'artist',
                        'options'    => $artists,
                    ],
                ];
 
                foreach ($filters as $key => $filter) {
                    $out = sprintf(
                        '<div><label for="filter-%s">%s<span class="screen-reader-text">Filter by %s</span></label>
                        <select id="filter-%s" class="filter %s" name="%s" data-%s="%s">
                        <option value="">[ %s ]</option>',
                        $key,
                        jvbIcon($filter['icon']),
                        esc_html($filter['label']),
                        $key,
                        $key,
                        $key,
                        $key,
                        $key,
                        $filter['label']
                    );
 
                    foreach ($filter['options'] as $option) {
                        $out .= sprintf(
                            '<option value="%s">%s — ( %s )</option>',
                            esc_attr($option['id']),
                            esc_html($option['name']),
                            esc_html($option['count'])
                        );
                    }
                    $out .= '</select></div>';
                    echo $out;
                }
 
                echo jvbRenderDateFilter('news');
                ?>
            </div>
            <div class="order-options">
                <div class="order-by">
                    <span class="type-filter label">ORDER:</span>
                    <div class="radio-group-label">
                        <input type="radio" id="order-title" class="btn" name="orderby" value="title">
                        <label for="order-title" title="Order by Name" class="row">
                            <?= jvbIcon('alphabetical') ?>
                            <span class="label">Name</span>
                        </label>
 
                        <input type="radio" id="order-date" class="btn" name="orderby" value="date" checked>
                        <label for="order-date" title="Order by Date" class="row">
                            <?= jvbIcon('calendar', ['title'=>'Date']) ?>
                            <span class="label">Date</span>
                        </label>
 
                        <input type="radio" id="order-karma" class="btn" name="orderby" value="karma">
                        <label for="order-karma" title="Order by Standing" class="row">
                            <?= jvbIcon('karma') ?>
                            <span class="label">Standing</span>
                        </label>
 
                        <input type="radio" id="order-random" class="btn" name="orderby" value="random">
                        <label for="order-random" title="Random Order" class="row">
                            <?= jvbIcon('random') ?>
                            <span class="label">Random</span>
                        </label>
                    </div>
                </div>
 
                <div class="order-direction radio-group-label" data-for-order="date,title,karma">
                    <input type="radio" id="order-desc" class="btn" name="order" value="DESC" checked>
                    <label for="order-desc" title="Newest First" class="row">
                        <?= jvbIcon('desc') ?>
                    </label>
 
                    <input type="radio" id="order-asc" class="btn" name="order" value="ASC">
                    <label for="order-asc" title="Oldest First" class="row">
                        <?= jvbIcon('asc') ?>
                    </label>
                </div>
            </div>
        </form>
    </details>
    <section class="item-grid list-view">
 
    </section>
 
</div>
 
<!-- Create News Modal -->
<dialog class="create-modal">
    <form method="dialog" data-nocache data-form-id="create-news" data-save="news">
        <h2>Make an Announcement</h2>
 
        <div class="field">
            <label for="type-select">Type:</label>
            <select name="type" id="type-select" required>
                <option>... select type</option>
                <?php $taxonomies = get_terms([
                    'taxonomy'        => BASE.'ntype',
                    'hide_empty'    => false,
                    'fields'        => 'id=>name',
                ]);
                if ($taxonomies && !is_wp_error($taxonomies)) {
                    foreach ($taxonomies as $ID => $name) {
                        echo '<option value="'.$ID.'">'.$name.'</option>';
                        //echo '<input type="radio" name="type" id="type-'.$ID.'" value="'.$ID.'"><label for="type-'.$ID.'">'.$name.'</label>';
                    }
                }
                ?>
            </select>
        </div>
        <?php
        $handler = JVB()->getContent('news');
        $meta = new JVBase\meta\MetaManager();
        foreach ($handler->getFields() as $field_name => $field_config) {
            $meta->render('form', $field_name, $field_config);
        }
        ?>
 
        <div class="actions row">
            <button type="button" class="cancel cancel">Cancel</button>
            <button type="submit" class="create" >Add Update</button>
        </div>
    </form>
</dialog>
<template class="template-own">
    <details class="news item" data-keyboard-nav="true" tabindex="0">
        <summary class="row btw">
            <div class="item-select">
                <input type="checkbox" class="select-checkbox">
                <label>
                    <span class="screen-reader-text">Select this news update</span>
                </label>
            </div>
            <button class="favourite-button" data-type="news" title="Add to watch list" onclick="toggleFavourite(this)">
                <?= jvbIcon('star') ?>
            </button>
            <div class="image"></div>
            <div class="summary">
                <div class="header">
                    <h3></h3>
                    <span class="published"></span>
                </div>
                <span class="byline">
                    <a class="artist" title="Visit their profile"></a>
                    <a class="shop"></a>
                </span>
                <div class="tldr"></div>
            </div>
            <div class="item-actions">
                <button type="button" class="action" data-action="edit" title="Edit tattoo">
                    <?= jvbIcon('edit') ?>
                    <span class="screen-reader-text">Edit news item</span>
                </button>
                <button type="button" class="action" data-action="trash" title="Scrap tattoo">
                    <?= jvbIcon('delete') ?>
                    <span class="screen-reader-text">Scrap news item</span>
                </button>
                <button type="button" class="action" data-action="toggle-status">
                    <?= jvbIcon('eye') ?>
                    <span class="screen-reader-text">Toggle news item Visibility</span>
                </button>
            </div>
        </summary>
        <div class="item-info">
        </div>
    </details>
</template>
<template class="template-all template-watching">
    <details class="news item" data-keyboard-nav="true" tabindex="0">
        <summary class="row btw">
            <button class="favourite-button" data-type="news" title="Add to watch list" onclick="toggleFavourite(this)">
 
            </button>
            <div class="image"></div>
            <div class="summary">
                <div class="header">
                    <h3></h3>
                    <span class="published"></span>
                </div>
                <span class="byline">
                    <a class="artist" title="Visit their profile"></a>
                    <a class="shop"></a>
                </span>
                <div class="tldr"></div>
            </div>
        </summary>
        <div class="item-info">
        </div>
    </details>
</template>
<?= jvbGetReplyTemplate() ?>
<?= jvbGetCommentTemplate() ?>
<?= jvbGetReplyToTemplate() ?>