-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschedule-page-example.php
More file actions
45 lines (36 loc) · 1.31 KB
/
schedule-page-example.php
File metadata and controls
45 lines (36 loc) · 1.31 KB
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
<?php
/**
* Example usage of schedule with ICS export
*/
// In your page template or shortcode:
?>
<div class="schedule-section">
<h2>Event Schedule</h2>
<!-- The export button will be automatically added by JavaScript -->
<?php echo do_shortcode('[dust_schedule layout="list"]'); ?>
</div>
<!-- Or manually add the button: -->
<button id="manual-ics-export" class="dust-ics-export-btn">📅 Export to Calendar</button>
<script>
jQuery(document).ready(function($) {
$('#manual-ics-export').on('click', function() {
var $btn = $(this);
$btn.prop('disabled', true).text('Generating...');
// Create form and submit to trigger download
var form = $('<form>', {
method: 'POST',
action: dust_events_ajax.ajax_url,
target: '_blank'
});
form.append($('<input>', {type: 'hidden', name: 'action', value: 'export_schedule_ics'}));
form.append($('<input>', {type: 'hidden', name: 'nonce', value: dust_events_ajax.nonce}));
form.append($('<input>', {type: 'hidden', name: 'event_name', value: ''}));
$('body').append(form);
form.submit();
form.remove();
setTimeout(function() {
$btn.prop('disabled', false).text('📅 Export to Calendar');
}, 1000);
});
});
</script>