\WP_Stager_Integration\Event::get_currently_happening_events(): array[]

Description

Gets currently happening (ongoing) events, i.e. events whose start dates are in the past and end dates are in the future.

Returns:

array[] List of raw Stager event arrays.

Information

Fileclass-event.php line 559

Full Code

/**
 * Gets currently happening (ongoing) events, i.e. events whose start dates are in the past and end dates are in the future.
 *
 * @return array[] List of raw Stager event arrays.
 */
public static function get_currently_happening_events() {

    // Get data
    $now           = time();
    $todays_events = self::get_todays_events();

    $happening = array();

    foreach ( $todays_events as $event ) {
        $start_raw = (string) ( $event[ 'programStartAt' ] ?? '' );
        $end_raw   = (string) ( $event[ 'programEndAt' ] ?? '' );

        if ( ! $start_raw || ! $end_raw ) {
            continue;
        }

        $start_timestamp = strtotime( $start_raw );
        $end_timestamp   = strtotime( $end_raw );

        if ( $start_timestamp && $end_timestamp && $start_timestamp <= $now && $end_timestamp >= $now ) {
            $happening[] = $event;
        }
    }

    return self::parse_events( $happening );
}

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