Skip to content

Commit 564bb4e

Browse files
committed
Bug fix: single day view returned all instances of long-running events.
1 parent 6689eb7 commit 564bb4e

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/my-calendar-output.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1953,20 +1953,21 @@ function my_calendar( $args ) {
19531953
$heading = "<$hl id='mc_head_$id' class='mc-single heading my-calendar-$params[time]'><span>" . trim( $heading_text ) . "</span></$hl>";
19541954
$dateclass = mc_dateclass( $current );
19551955
$mc_events = '';
1956-
$events = my_calendar_events( $query );
1956+
$dates = my_calendar_events( $query );
19571957
$events_class = '';
19581958
$json = '';
1959-
foreach ( $events as $day ) {
1960-
$events_class = mc_events_class( $day, $from );
1961-
$params['groups'] = $shown_groups;
1962-
$params['events'] = $shown_events;
1963-
$event_output = my_calendar_draw_events( $day, $params, $from, $template, $id );
1964-
$shown_groups = array_merge( $shown_groups, $event_output['groups'] );
1965-
$shown_events = array_merge( $shown_events, $event_output['events'] );
1966-
if ( ! empty( $event_output ) ) {
1967-
$mc_events .= $event_output['html'];
1968-
$json = array( $event_output['json'] );
1969-
}
1959+
// The $events array explodes multi-day events to contain each individual day.
1960+
// Only display the versions relevant to the current day.
1961+
$events = $dates[ $from ];
1962+
$events_class = mc_events_class( $events, $from );
1963+
$params['groups'] = $shown_groups;
1964+
$params['events'] = $shown_events;
1965+
$event_output = my_calendar_draw_events( $events, $params, $from, $template, $id );
1966+
$shown_groups = array_merge( $shown_groups, $event_output['groups'] );
1967+
$shown_events = array_merge( $shown_events, $event_output['events'] );
1968+
if ( ! empty( $event_output ) ) {
1969+
$mc_events .= $event_output['html'];
1970+
$json = array( $event_output['json'] );
19701971
}
19711972
$body .= $heading . $top . '
19721973
<div class="mc-content">

0 commit comments

Comments
 (0)