Skip to main content

benecaster_content_calendar_ical_events

Filter Premium content-calendar

Filters one show’s Content Calendar entries before they are written as iCalendar text, for both the .ics download and the show’s private subscription feed. A return that is not an array is ignored, and so is any entry that is not an array.

Parameters

Name Type Default Description
$events array — The show's entries, each `{ uid, summary, description, date, time, url, cancelled, stamp }`. `date` (`YYYY-MM-DD`) and `time` (`HH:MM`, or null for all day) are in the site's time zone; `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`.
$show_id int — The show whose calendar is being written
$context string — `download` (the `.ics` download) or `feed` (the private subscription feed, a request with no logged-in user)

Returns: array

Example

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 );

Notes

Give an entry you add a UID of your own that never changes (my-addon-…@host), and never reuse the benecaster-content-calendar- prefix: subscribed calendars match entries by UID. Whatever you add is seen by anyone holding the show's subscription URL. Walkthrough: Add to or change the entries in a show's Content Calendar iCal export and subscription feed.

Affects

  • GET benecaster-content-calendar/v1/shows/{show_id}/ical
  • Content Calendar subscription feed

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