\WP_Stager_Integration\Calendar::component_cards_scope(array $args = array()): void

Description

Renders the cards-scope component (single scope wrapper and flat cards list).

When $args['clip'] is true, events are clipped to the scope range ($args['start']$args['end']) so that custom event data supplied via the wpstagerintegration_events filter in {@see \WP_Stager_Integration\Event::parse_events()} still respects the current scope.

Parameters:

ParameterTypeDescription
$args['start'] int Start timestamp of the scope range.
$args['end'] int End timestamp of the scope range.
$args['scope'] string Scope type: day, week, month, year.
$args['events'] array[] Flat array of raw Stager event arrays.
$args['component_args'] array Component options (view, show_label_*, etc.).
$args['show_past_events'] bool Whether past events are shown.
$args['show_upcoming_events'] bool Whether events that have not started yet are shown.
$args['clip'] bool Whether to clip events to the scope range. Default true.

Returns:

void

Information

Fileclass-calendar.php line 1642

Full Code

/**
 * Renders the cards-scope component (single scope wrapper and flat cards list).
 *
 * When <code>$args['clip']</code> is true, events are clipped to the scope range
 * (<code>$args['start']</code>–<code>$args['end']</code>) so that custom event data
 * supplied via the <code>wpstagerintegration_events</code> filter in
 * {@see \WP_Stager_Integration\Event::parse_events()} still respects the current scope.
 *
 * @param array $args {
 *     @type int      $start             Start timestamp of the scope range.
 *     @type int      $end               End timestamp of the scope range.
 *     @type string   $scope             Scope type: day, week, month, year.
 *     @type array[]  $events            Flat array of raw Stager event arrays.
 *     @type array    $component_args    Component options (view, show_label_*, etc.).
 *     @type bool     $show_past_events     Whether past events are shown.
 *     @type bool     $show_upcoming_events   Whether events that have not started yet are shown.
 *     @type bool     $clip             Whether to clip events to the scope range. Default true.
 * }
 *
 * @return void
 */
public static function component_cards_scope( $args = array() ) {

    $args = (array) $args;

    $start                = (int) ( $args[ 'start' ] ?? 0 );
    $end                  = (int) ( $args[ 'end' ] ?? 0 );
    $scope                = (string) ( $args[ 'scope' ] ?? '' );
    $events               = (array) ( $args[ 'events' ] ?? array() );
    $component_args       = (array) ( $args[ 'component_args' ] ?? array() );
    $show_past_events     = (bool) ( $args[ 'show_past_events' ] ?? true );
    $show_upcoming_events = (bool) ( $args[ 'show_upcoming_events' ] ?? true );
    $clip                 = (bool) ( $args[ 'clip' ] ?? false );

    if ( $clip && $start && $end ) {
        $events = self::clip_events_to_range( $events, $start, $end );
    }

    self::render_calendar_component( 'cards-scope', array(
        'start'                => $start,
        'end'                  => $end,
        'scope'                => $scope,
        'events'               => $events,
        'component_args'       => $component_args,
        'show_past_events'     => $show_past_events,
        'show_upcoming_events' => $show_upcoming_events,
        'clip'                 => $clip,
    ) );
}

💡 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!