Widget_Month::the_day_events( Tribe__Template $template, int $events_per_day, array $the_day_events )
Gets the events for “today”, used in filter_month_day() to add to the list if needed.
Contents
Parameters
- $template
-
(Tribe__Template) (Required) Current instance of the Tribe__Template.
- $events_per_day
-
(int) (Required) The number of events to display per day.
- $the_day_events
-
(array) (Required) The events for "today".
Return
(array) $the_day_events The modified events for "today".
Source
File: src/Tribe/Views/V2/Widgets/Widget_Month.php
public function the_day_events( $template, $events_per_day, $the_day_events ) {
$days = $template->get( 'days', [] );
$new_day = Dates::build_date_object( $template->get( 'url_event_date', $template->get( 'today', 'today' ) ) );
while( $events_per_day >= count( $the_day_events ) ) {
// add on day to "today".
$new_day->add( new \DateInterval('P1D') );
$new_day_formatted = $new_day->format('Y-m-d');
// Bail if we've reached the end.
if ( ! isset( $days[ $new_day_formatted ] ) ) {
break;
}
$copied_events = $days[ $new_day_formatted ][ 'events' ];
// Skip to the next day if no events.
if ( 0 === count( $copied_events ) ) {
continue;
}
$the_day_events = array_slice( array_merge( $the_day_events, $copied_events ), 0, $events_per_day );
}
return $the_day_events;
}
Changelog
| Version | Description |
|---|---|
| 5.6.0 | Introduced. |