\WP_Stager_Integration\Calendar::component_month(int $year, int $month, array $all_events = null, array $args = array()): void
\WP_Stager_Integration\Calendar::component_month(int $year, int $month, array $all_events = null, array $args = array()): voidDescription
Renders a full month view of events.
Ensures that all days covering the month exist in the hierarchy, even if they contain no events. When clipping is enabled, only days within $args['start'] and $args['end'] are included.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$year | int | The year (e.g. 2025). |
$month | int | The month number (1ā12). |
$all_events | array | Nested hierarchy of events (year ā month ā day). |
$args | array | (Optional) Additional arguments to pass to the component template. |
Returns:
void
Information
| File | class-calendar.php line 1798 |
|---|
Full Code
/**
* Renders a full month view of events.
*
* Ensures that all days covering the month exist in the hierarchy,
* even if they contain no events. When clipping is enabled,
* only days within <code>$args['start']</code> and <code>$args['end']</code> are included.
*
* @param int $year The year (e.g. 2025).
* @param int $month The month number (1ā12).
* @param array $all_events Nested hierarchy of events (year ā month ā day).
* @param array $args (Optional) Additional arguments to pass to the component template.
*
* @return void
*/
public static function component_month( $year, $month, $all_events = null, $args = array() ) {
// Type casting
$year = (int) $year;
$month = (int) $month;
$all_events = (array) $all_events;
$args = (array) $args;
// Fill missing days
self::fill_missing_days( $all_events, $year, $month );
// Get data
$clip = (bool) ($args[ 'clip' ] ?? false);
$start = (int) ($args[ 'start' ] ?? 0);
$end = (int) ($args[ 'end' ] ?? 0);
// Clip filtering
if ( $clip && $start && $end ) {
// Init
$clipped = array();
// Loop over events
foreach ( $all_events[ $year ][ $month ] as $day => $events ) {
// Calculate timestamp
$timestamp = self::calculate_local_timestamp( sprintf( '%04d-%02d-%02d 00:00:00', $year, $month, $day ) );
// Continue if event not in range
if ( $timestamp < $args[ 'start' ] || $timestamp > $args[ 'end' ] ) {
continue;
}
// Keep event, within range
$clipped[ $day ] = $events;
}
// Replace with clipped rangge
$all_events[ $year ][ $month ] = $clipped;
}
self::render_calendar_component( 'month', array(
'year' => $year,
'month' => $month,
'events' => $all_events,
'component_args' => $args,
) );
}š” If you ever get stuck or have a question, please check our FAQs, our Free Integration Service, our paid Full Integration Service, or reach out to us!

Get WP Stager Integration
š Limited offer: Use code WELCOME26 to get your first month for free!

