\WP_Stager_Integration\Calendar::render_range(int $start, int $end, array $args = array()): void
\WP_Stager_Integration\Calendar::render_range(int $start, int $end, array $args = array()): voidDescription
Renders a specific date range.
The passed $start and $end timestamps are automatically converted to the start and end of the days that they fall on in the site's timezone (00:00:00 and 23:59:59 respectively)
Parameters:
| Parameter | Type | Description |
|---|---|---|
$start | int | A Unix timestamp of the start of the range to render |
$end | int | A Unix timestamp of the end of the range to render |
$args | array | (Optional) An array of calendar settings. See \WP_Stager_Integration\Calendar::render_calendar() for accepted arguments. |
Returns:
void
Information
| File | class-calendar.php line 1097 |
|---|---|
| See also |
|
Full Code
/**
* Renders a specific date range.
*
* The passed <code>$start</code> and <code>$end</code> timestamps are automatically converted to
* the start and end of the days that they fall on in the site's timezone (00:00:00 and 23:59:59 respectively)
*
* @param int $start A Unix timestamp of the start of the range to render
* @param int $end A Unix timestamp of the end of the range to render
* @param array $args (Optional) An array of calendar settings. See <code>\WP_Stager_Integration\Calendar::render_calendar()</code> for accepted arguments.
*
* @return void
*
* @see \WP_Stager_Integration\Calendar::render_calendar() for accepted <code>$args</code>.
*/
public static function render_range( $start, $end, $args = array() ) {
// Type casting
$start = (int) $start;
$end = (int) $end;
$args = (array) $args;
// Bail if either start or end is missing
if ( ! $start || ! $end ) {
return;
}
// Bail if invalid range specified
if ( $end < $start ) {
return;
}
// Normalize to local day start/end
$start = self::calculate_timestamp_day_start( $start );
$end = self::calculate_timestamp_day_end( $end );
// Extract components
$start_year = (int) wp_date( 'Y', $start );
$end_year = (int) wp_date( 'Y', $end );
$start_month = (int) self::get_month_number( $start );
$end_month = (int) self::get_month_number( $end );
$start_day = (int) self::get_day_number( $start );
$end_day = (int) self::get_day_number( $end );
$start_week = (int) self::get_week_number( $start );
$end_week = (int) self::get_week_number( $end );
// Get data
$diff = $end - $start;
if (
$start_year === $end_year &&
$start_month === $end_month &&
$start_day === $end_day
) {
$scope = 'day';
} else if (
self::get_year_number( $start ) === self::get_year_number( $end ) &&
$start_week === $end_week
) {
$scope = 'week';
} else if (
$start_year === $end_year &&
$start_month === $end_month
) {
$scope = 'month';
} else {
$scope = 'year';
}
// Override args with calculated values
$args[ 'scope' ] = $scope;
$args[ 'start' ] = $start;
$args[ 'end' ] = $end;
$args[ 'clip' ] = true;
self::render_calendar( $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!

