PluginProbe
Blockenberg — 600+ Advanced Gutenberg Blocks & AI Agent for WordPress Block Editor / 2.0.7
Blockenberg — 600+ Advanced Gutenberg Blocks & AI Agent for WordPress Block Editor v2.0.7
2.0.13 2.0.12 2.0.11 2.0.10 2.0.9 trunk 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8
blockenberg / blocks / event-card / frontend.js

frontend.js in Blockenberg — 600+ Advanced Gutenberg Blocks & AI Agent for WordPress Block Editor 2.0.7, at blocks/event-card/frontend.js

46 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 ( function () {
2 document.addEventListener('DOMContentLoaded', function () {
3 document.querySelectorAll('.bkec-wrap[data-schema="1"]').forEach(function (wrap) {
4 var raw = wrap.dataset.event;
5 if (!raw) return;
6 var e;
7 try { e = JSON.parse(raw); } catch(err) { return; }
8
9 var schema = {
10 '@context': 'https://schema.org',
11 '@type': 'Event',
12 'name': e.name || '',
13 'description': e.description || '',
14 'startDate': e.startDate && e.startTime ? e.startDate + 'T' + e.startTime : e.startDate,
15 'endDate': e.endDate && e.endTime ? e.endDate + 'T' + e.endTime : e.endDate,
16 'eventStatus': 'https://schema.org/EventScheduled',
17 'eventAttendanceMode': e.eventType === 'Virtual'
18 ? 'https://schema.org/OnlineEventAttendanceMode'
19 : e.eventType === 'Hybrid'
20 ? 'https://schema.org/MixedEventAttendanceMode'
21 : 'https://schema.org/OfflineEventAttendanceMode',
22 'url': e.url || undefined,
23 };
24
25 if (e.venueName) {
26 schema.location = {
27 '@type': 'Place',
28 'name': e.venueName,
29 'address': { '@type': 'PostalAddress', 'streetAddress': e.venueAddress || '' }
30 };
31 }
32 if (e.organizer) {
33 schema.organizer = { '@type': 'Organization', 'name': e.organizer };
34 }
35 if (e.image) schema.image = e.image;
36
37 schema = JSON.parse(JSON.stringify(schema));
38
39 var script = document.createElement('script');
40 script.type = 'application/ld+json';
41 script.textContent = JSON.stringify(schema);
42 document.head.appendChild(script);
43 });
44 });
45 }() );
46