\WP_Stager_Integration\Event::return_404_for_hidden_statuses(): void

Description

Return a 404 if the event has a hidden status.

Returns:

void

Information

Fileclass-event.php line 181

Full Code

/**
 * Return a 404 if the event has a hidden status.
 *
 * @return void
 */
public static function return_404_for_hidden_statuses() {

    // Bail if not on a single event page
    if ( ! self::is_single_event() ) {
        return;
    }

    // Get data
    $event              = (array) (self::get_single_event_data() ?: array());
    $status             = (string) ($event[ 'status' ] ?? '');
    $displayed_statuses = (array) (Options::get_displayed_event_statuses() ?: array());

    // Bail if status is displayed
    if ( in_array( $status, $displayed_statuses ) ) {
        return;
    }

    // Set query to 404
    global $wp_query;
    $wp_query->set_404();
    status_header( 404 );
    nocache_headers();
}

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