-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
538 lines (446 loc) · 17.4 KB
/
functions.php
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
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
<?php
use HnutiBrontosaurus\Theme\Assets;
use HnutiBrontosaurus\Theme\Container;
use HnutiBrontosaurus\Theme\PostTypeInitializer;
use HnutiBrontosaurus\Theme\Rewrites\Event;
use HnutiBrontosaurus\Theme\Rewrites\Opportunity;
use HnutiBrontosaurus\Theme\DataContainers\Events\EventCollectionDC;
use HnutiBrontosaurus\Theme\DataContainers\Events\EventDC;
use Nette\Utils\Strings;
/** @var Container $hb_container */
$hb_container = require_once __DIR__ . '/bootstrap.php';
require_once __DIR__ . '/hb-events/hb-events.php';
require_once __DIR__ . '/homepage-banner.php';
(function (Container $container, WP_Theme $theme) {
/**
* turn off <link rel="canonical"> produced by rank math seo plugin
* that's because on `/akce/ID` and `/prilezitost/ID` it generates bad URL (with no ID) and I couldn't find any simple way to modify it inside of controller
*/
add_filter('rank_math/frontend/canonical', static fn($canonical) => null);
add_action('init', function () use ($container) {
Event::rewriteRule();
Opportunity::rewriteRule();
PostTypeInitializer::novinky();
PostTypeInitializer::pribehyNadseni();
PostTypeInitializer::kontakty();
register_nav_menus([
'header' => __('Hlavička'),
'footer-left' => __('Patička – vlevo'),
'footer-center' => __('Patička – uprostřed'),
'footer-right' => __('Patička – vpravo'),
]);
hb_events($container);
});
add_filter('query_vars', function($vars) {
Event::queryVars($vars);
Opportunity::queryVars($vars);
return $vars;
});
add_action('after_switch_theme', function () {
Event::rewriteRule();
Opportunity::rewriteRule();
flush_rewrite_rules();
});
add_action('after_setup_theme', function () {
add_theme_support('post-thumbnails');
add_theme_support('title-tag');
});
add_action('wp_enqueue_scripts', function () use ($theme) {
wp_enqueue_script(
handle: "hb-unpkg-headroom",
src: "https://unpkg.com/[email protected]/dist/headroom.min.js",
ver: null,
);
wp_enqueue_script(
handle: "hb-unpkg-lazyload",
src: "https://unpkg.com/[email protected]/dist/lazyload.min.js",
ver: null,
);
wp_enqueue_script(
handle: "hb-unpkg-glightbox",
src: "https://unpkg.com/[email protected]/dist/js/glightbox.min.js",
ver: null,
);
wp_enqueue_style(
handle: "hb-unpkg-glightbox",
src: "https://unpkg.com/[email protected]/dist/css/glightbox.min.css",
ver: null,
);
Assets::staticScript('expandable', $theme);
Assets::staticScript('lazyLoad', $theme);
Assets::staticScript('menuHandler', $theme);
Assets::staticScript('lightbox', $theme);
Assets::staticScript('administrativeUnitsMap', $theme);
Assets::staticScript('references', $theme);
Assets::style('style', $theme);
});
add_action('enqueue_block_editor_assets', function () use ($theme) {
Assets::staticScript('editor', $theme);
Assets::style('editor', $theme);
});
})($hb_container, wp_get_theme());
function hb_administrative_units_map(string $administrationUnitsInJson, bool $hasBeenUnableToLoad)
{
?>
<div class="administrativeUnitsMap">
<?php if ($hasBeenUnableToLoad): ?>
<div class="noResults">
Promiňte, zrovna nám vypadl systém, kde máme uloženy všechny informace o našich článcích.
Zkuste to prosím za chvilku znovu.
</div>
<?php else: ?>
<ul class="administrativeUnitsMap__filters" id="administrativeUnitsMap-filters">
<li class="administrativeUnitsMap__filter" id="mapa-vse">
<a class="administrativeUnitsMap__filterLink button button--customization" href="#mapa-vse">
vše
</a>
</li>
<li class="administrativeUnitsMap__filter" id="mapa-ustredi" data-slug="office">
<a class="administrativeUnitsMap__filterLink administrativeUnitsMap__filterLink--icon administrativeUnitsMap__filterLink--office button button--customization" href="#mapa-ustredi">
ústředí
</a>
</li>
<li class="administrativeUnitsMap__filter" id="mapa-regionalni-centra" data-slug="regional">
<a class="administrativeUnitsMap__filterLink administrativeUnitsMap__filterLink--icon administrativeUnitsMap__filterLink--regional button button--customization" href="#mapa-regionalni-centra">
regionální centra
</a>
</li>
<li class="administrativeUnitsMap__filter" id="mapa-zakladni-clanky" data-slug="base">
<a class="administrativeUnitsMap__filterLink administrativeUnitsMap__filterLink--icon administrativeUnitsMap__filterLink--base button button--customization" href="#mapa-zakladni-clanky">
základní články
</a>
</li>
<li class="administrativeUnitsMap__filter" id="mapa-kluby" data-slug="club">
<a class="administrativeUnitsMap__filterLink administrativeUnitsMap__filterLink--icon administrativeUnitsMap__filterLink--club button button--customization" href="#mapa-kluby">
kluby
</a>
</li>
<li class="administrativeUnitsMap__filter" id="mapa-detske-oddily" data-slug="children">
<a class="administrativeUnitsMap__filterLink administrativeUnitsMap__filterLink--icon administrativeUnitsMap__filterLink--children button button--customization" href="#mapa-detske-oddily">
dětské oddíly BRĎO
</a>
</li>
</ul>
<div class="administrativeUnitsMap__map"
id="map"
data-administrativeUnits='<?php echo $administrationUnitsInJson ?>'
></div>
<?php endif; ?>
</div>
<?php
}
function hb_references(?string $link = null)
{
?>
<div class="references" data-references>
<button class="references__button references__button--previous button button--customization" data-references-button="previous" type="button" aria-hidden="true"></button>
<button class="references__button references__button--next button button--customization" data-references-button="next" type="button" aria-hidden="true"></button>
<?php if ($link !== null): ?><a class="references__link" href="<?php echo $link ?>"><?php endif; ?>
<ul class="references__list" data-references-slides style="--carouselPosition: 1">
<li class="references__list-item presentationBox" style="--presentationBox-background-image-url: url('https://brontosaurus.cz/wp-content/uploads/2024/12/aboutCrossroad-references-bohuslav-binka.jpg')">
<div class="presentationBox__text">
<div class="hb-fs-l hb-fw-b">
doc. Mgr. Bohuslav Binka, Ph.D.
</div>
<div class="hb-fs-xs hb-mbns-2">
vedoucí katedry environmentálních studií MU
</div>
</div>
<div class="hb-fs-s presentationBox__text presentationBox__quotation quotation">Hnutí Brontosaurus pro mě vždy bylo spojené se slovy mládí, příroda, pomoc, zábava, letní tábor, smysl, fajn. A to je kombinace, která prostě láká. Ať láká i další generace tak, jako lákala tu moji.</div>
</li>
<li class="references__list-item presentationBox presentationBox--textOnRight" style="--presentationBox-background-image-url: url('https://brontosaurus.cz/wp-content/uploads/2024/12/aboutCrossroad-references-dalajlama.jpg')">
<div class="presentationBox__text">
<div class="hb-fs-l hb-fw-b">
Dalajláma
</div>
<div class="hb-fs-xs hb-mbns-2">
tibetský duchovní vůdce
</div>
</div>
<div class="hb-fs-s presentationBox__text presentationBox__quotation quotation">Jsem opravdu šťastný, že jsme s vámi z České republiky navázali takto výjimečný vztah, čehož si velmi cením.</div>
</li>
<li class="references__list-item presentationBox" style="--presentationBox-background-image-url: url('https://brontosaurus.cz/wp-content/uploads/2024/12/aboutCrossroad-references-ladislav-tesar.jpg')">
<div class="presentationBox__text">
<div class="hb-fs-l hb-fw-b">
Ladislav Tesař
</div>
<div class="hb-fs-xs hb-mbns-2">
starosta Českého Sela, krajanské obce v Srbsku
</div>
</div>
<div class="hb-fs-s presentationBox__text presentationBox__quotation quotation">S Brontosaury spolupracujeme velmi rádi. Ceníme si jejich pomoci s péčí o obec i naše drobné památky. Když přijedou, vždy to tady velmi ožije a ve vsi je na čas veseleji. Doufám, že budou přijíždět i v dalších letech.</div>
</li>
<li class="references__list-item presentationBox presentationBox--textOnRight" style="--presentationBox-background-image-url: url('https://brontosaurus.cz/wp-content/uploads/2024/12/aboutCrossroad-references-jaroslav-pavlicek.jpg')">
<div class="presentationBox__text">
<div class="hb-fs-l hb-fw-b">
Jaroslav Pavlíček
</div>
<div class="hb-fs-xs hb-mbns-2">
český polárník, cestovatel a spisovatel
</div>
</div>
<div class="hb-fs-s presentationBox__text presentationBox__quotation quotation">Brontosaurům fandím, protože jejich akce, stejně jako pobyt v drsné přírodě, člověka výborně připraví na skutečný, ne virtuální život. Navíc umí i z dobrovolnictví udělat zábavu a vždy je za nimi vidět kus práce.</div>
</li>
</ul>
</a>
</div>
<?php
}
function hb_related(
?string $headingText = null,
?string $subheadingText = null,
?bool $excludeCourses = false,
?bool $excludeVoluntary = false,
?bool $excludeMeetups = false,
?bool $excludeSupport = false,
?bool $excludeForChildren = false,
)
{
?>
<section class="related">
<h1 class="related-heading">
<?php if ($headingText): ?>
<?php echo $headingText ?>
<?php else: ?>
Ještě by tě mohlo zajímat
<?php endif; ?>
</h1>
<?php if ($subheadingText !== null): ?>
<div class="related-subheading">
<?php echo $subheadingText ?>
</div>
<?php endif; ?>
<div class="related-list">
<?php if ( ! $excludeCourses): ?>
<a class="related-list-item related-list-item--courses button--secondary-wrapper" href="/kurzy-a-prednasky">
<h2 class="related-list-item-heading">
Kurzy a přednášky
</h2>
<ul class="related-list-item-list">
<li class="related-list-item-list-item">
Kurzy a workshopy
</li>
<li class="related-list-item-list-item">
Přednášky a diskuze
</li>
<li class="related-list-item-list-item">
Výukové programy pro školy
</li>
</ul>
<div class="related-list-item-roundedPhoto related-list-item--courses-roundedPhoto"></div>
<div class="related-list-item-moreLink related-list-item--courses-moreLink button button--secondary">Chci více info
<div class="related-list-item-moreLink-background related-list-item--courses-moreLink-background"></div>
</div>
</a>
<?php endif; ?>
<?php if ( ! $excludeVoluntary): ?>
<a class="related-list-item related-list-item--voluntary button--secondary-wrapper" href="/dobrovolnicke-akce">
<h2 class="related-list-item-heading">
Zážitkové a dobrovolnické akce
</h2>
<ul class="related-list-item-list">
<li>
Jednodenní
</li>
<li>
Víkendovky
</li>
<li>
Prázdninové
</li>
</ul>
<div class="related-list-item-roundedPhoto related-list-item--voluntary-roundedPhoto"></div>
<div class="related-list-item-moreLink related-list-item--voluntary-moreLink button button--secondary">Chci více info
<div class="related-list-item-moreLink-background related-list-item--voluntary-moreLink-background"></div>
</div>
</a>
<?php endif; ?>
<?php if ( ! $excludeMeetups): ?>
<a class="related-list-item related-list-item--meetups button--secondary-wrapper" href="/setkavani-a-kluby">
<h2 class="related-list-item-heading">
Setkávání a kluby
</h2>
<ul class="related-list-item-list">
<li>
Klubová setkání
</li>
<li>
Sportovní aktivity
</li>
<li>
Herní večery
</li>
</ul>
<div class="related-list-item-roundedPhoto related-list-item--meetups-roundedPhoto"></div>
<div class="related-list-item-moreLink related-list-item--meetups-moreLink button button--secondary">Chci více info
<div class="related-list-item-moreLink-background related-list-item--meetups-moreLink-background"></div>
</div>
</a>
<?php endif; ?>
<?php if ( ! $excludeSupport): ?>
<a class="related-list-item related-list-item--donation button--secondary-wrapper" href="/podpor-nas">
<h2 class="related-list-item-heading">
Podpoř nás
</h2>
<ul class="related-list-item-list">
<li>
Podpora našich projektů
</li>
<li>
Adopce Brontosaura
</li>
<li>
E-shop s dárky přírodě
</li>
</ul>
<div class="related-list-item-roundedPhoto related-list-item--donation-roundedPhoto"></div>
<div class="related-list-item-moreLink related-list-item--donation-moreLink button button--secondary">Chci více info
<div class="related-list-item-moreLink-background related-list-item--donation-moreLink-background"></div>
</div>
</a>
<?php endif; ?>
<?php if ( ! $excludeForChildren): ?>
<a class="related-list-item related-list-item--children button--secondary-wrapper" href="/pro-deti">
<h2 class="related-list-item-heading">
Pro děti i rodiče
</h2>
<ul class="related-list-item-list">
<li>
Tábory pro děti
</li>
<li>
Dětské oddíly
</li>
<li>
Akce pro rodiče s dětmi
</li>
</ul>
<div class="related-list-item-roundedPhoto related-list-item--children-roundedPhoto"></div>
<div class="related-list-item-moreLink related-list-item--children-moreLink button button--secondary">Chci více info
<div class="related-list-item-moreLink-background related-list-item--children-moreLink-background"></div>
</div>
</a>
<?php endif; ?>
</div>
</section>
<?php
}
function hb_eventList(EventCollectionDC $eventCollection, bool $lazyLoading = true, bool $inFutureView = false, bool $smaller = false)
{
?>
<div class="hb-eventList<?php if ($smaller): ?> hb-eventList--smaller<?php endif; ?>">
<?php if ($eventCollection->hasAny): ?>
<?php $eventsDisplayedOnLoad = 9; ?>
<div class="hb-eventList__grid">
<?php
$counter = 1;
foreach ($eventCollection as $event) {
hb_event($event, lazyLoading: $lazyLoading, smaller: $smaller);
if ( ! $inFutureView && $counter === $eventsDisplayedOnLoad) {
break;
}
$counter++;
}
?>
</div>
<?php if ( ! $inFutureView && $eventCollection->count > $eventsDisplayedOnLoad): ?>
<div class="hb-expandable">
<button class="hb-eventList__moreLink button button--customization" type="button" data-hb-expandable-toggler data-hb-expandable-toggler-remove-on-expand>
Zobrazit další
</button>
<div class="hb-eventList__grid" data-hb-expandable-content>
<?php
$counter = 1;
foreach ($eventCollection as $event) {
if ($counter <= $eventsDisplayedOnLoad) {
$counter++;
continue;
}
hb_event($event, smaller: $smaller);
}
?>
</div>
</div>
<?php endif; ?>
<?php else: ?>
<div class="hb-eventList__noResults noResults">
<?php if ($eventCollection->hasBeenUnableToLoad): ?>
Promiňte, zrovna nám vypadl systém, kde máme uloženy všechny informace o plánovaných akcích.
Zkuste to prosím za chvilku znovu.
<?php else: ?>
Zrovna tu žádné akce nemáme, ale zkus to později…
<?php endif; ?>
</div>
<?php endif; ?>
</div>
<?php
}
function hb_event(EventDC $event, bool $lazyLoading = true, bool $smaller = false)
{
?>
<a class="hb-event<?php if ($event->isFull): ?> hb-event--full<?php endif; ?><?php if ($smaller): ?> hb-event--smaller<?php endif; ?>" href="<?php echo $event->link ?>">
<div class="hb-event__imageWrapper">
<img alt="" class="hb-event__image<?php if ( ! $event->hasCoverPhoto): ?> hb-event__image--noThumbnail<?php endif; ?>" <?php if ($lazyLoading): ?>data-<?php endif; ?>src="<?php if ($event->hasCoverPhoto): echo $event->coverPhotoPath; else: ?>https://brontosaurus.cz/wp-content/uploads/2024/12/logo-hb-brontosaurus.svg<?php endif; ?>">
<noscript>
<img alt="" class="hb-event__image<?php if ( ! $event->hasCoverPhoto): ?> hb-event__image--noThumbnail<?php endif; ?>" src="<?php if ($event->hasCoverPhoto): echo $event->coverPhotoPath; else: ?>https://brontosaurus.cz/wp-content/uploads/2024/12/logo-hb-brontosaurus.svg<?php endif; ?>">
</noscript>
<div class="hb-event__labels">
<?php hb_eventLabels($event->labels) ?>
</div>
</div>
<?php if ($event->isFull): ?>
<div class="hb-event__full">
plně obsazeno
</div>
<?php endif; ?>
<header class="hb-event__header">
<h4 class="hb-event__heading">
<?php echo $event->title ?>
</h4>
<?php if ($event->tags): ?>
<div class="hb-event__tags">
<?php hb_tags($event->tags, 'hb-event__tag') ?>
</div>
<?php endif; ?>
<div class="hb-event__meta">
<time class="hb-event__date" datetime="<?php echo $event->dateStartForRobots ?>">
<?php echo $event->dateSpan ?>
</time>
<span class="hb-event__place" title="Místo konání">
<?php echo $event->place->name ?>
</span>
</div>
</header>
<p class="hb-event__excerpt">
<?php
$charsCount = $smaller ? 60 : 200;
echo nl2br(Strings::truncate(hb_strip_tags($event->invitation->introduction), $charsCount));
?>
</p>
</a>
<?php
}
/** @param \HnutiBrontosaurus\Theme\DataContainers\Events\Label[] $labels */
function hb_eventLabels(array $labels)
{
?>
<div class="eventLabels">
<?php foreach ($labels as $label): ?>
<div class="eventLabels__item<?php if ($label->hasSelectorModifier): ?> eventLabels__item--type eventLabels__item--<?php echo $label->selectorModifier; endif; ?>">
<?php echo $label->label ?>
</div>
<?php endforeach; ?>
</div>
<?php
}
/** @param string[] $tags */
function hb_tags(array $tags, ?string $className)
{
foreach ($tags as $tag):
?>
<span class="<?php echo $className !== null ? $className . ' ' : ''; ?>eventTag">
<?php echo $tag ?>
</span>
<?php
endforeach;
}