Plugin Author
LBell
(@lbell)
Howdy! That’s beyond the scope of this plugin. Sorry.
Thank you. I have found snippets of php like these but so far they haven’t worked, I think largely because they are just hypothetical. Can you suggest how I might hook into your plugin to implement something like this?
Thanks again.
add_filter(‘hycal_events’, function($events) {
$unique = [];
$output = [];
foreach ($events as $event) {
// Create a unique key based on title + start date
$key = md5($event['title'] . $event['start']);
if (!isset($unique[$key])) {
$unique[$key] = true;
$output[] = $event;
}
}
return $output;
});
/**
- Prevent duplicate events in Hydrogen Calendar Embeds
- Place this in your theme’s functions.php or a custom plugin.
*/
// Hook into Hydrogen Calendar Embeds event filter
add_filter(‘hydrogen_calendar_events’, ‘my_remove_duplicate_calendar_events’);
function my_remove_duplicate_calendar_events($events) {
if (!is_array($events)) {
return $events; // Safety check
}
$unique = [];
$filtered = [];
foreach ($events as $event) {
// Create a unique key based on UID + start date
// Adjust keys if your ICS feed uses different field names
$uid = isset($event['uid']) ? $event['uid'] : '';
$start = isset($event['start']) ? $event['start'] : '';
$key = md5($uid . '|' . $start);
if (!isset($unique[$key])) {
$unique[$key] = true;
$filtered[] = $event;
}
}
return $filtered;
}
Plugin Author
LBell
(@lbell)
That would be the right track.
For a non-exhaustive (and admitted AI-generated) doc of hooks available, see here: https://github.com/lbell/hydrogen-calendar-embeds/blob/master/docs/hooks.md