Skip to main content

Add to or change the entries in a show’s Content Calendar iCal export and subscription feed

Premium Intermediate Content Calendar

benecaster_content_calendar_ical_events is a filter, ( array $events, int $show_id, string $context ): array, on one show’s entries before they are written. It runs for both the .ics download ($context download) and the private subscription feed (feed, a request with no logged-in user). Both are described in Download a show’s Content Calendar as iCal, or read its private subscription URL.

An entry is { uid, summary, description, date, time, url, cancelled, stamp }:

  • date (YYYY-MM-DD) and time (HH:MM, or null for all day) are both in the site’s time zone; the writer converts them to UTC.
  • description is plain text with \n between lines.
  • url is written only when it is http or https.
  • cancelled true writes STATUS:CANCELLED.
  • stamp is UTC Y-m-d H:i:s.

A return that is not an array is ignored, and so is any entry that is not an array.

Code

<?php
add_filter( 'benecaster_content_calendar_ical_events', function ( array $events, int $show_id, string $context ): array {
    foreach ( my_sponsor_deadlines( $show_id ) as $deadline ) {
        $events[] = [
            'uid'         => 'my-sponsors-deadline-' . $deadline->id . '@' . wp_parse_url( home_url(), PHP_URL_HOST ),
            'summary'     => 'Sponsor read due: ' . $deadline->sponsor,
            'description' => '',
            'date'        => $deadline->date, // Site time.
            'time'        => null,
            'url'         => '',
            'cancelled'   => false,
            'stamp'       => gmdate( 'Y-m-d H:i:s' ),
        ];
    }
    return $events;
}, 10, 3 );

View on GitHub →

Hooks Used

Need this built rather than just documented? See our services →