\WP_Stager_Integration\Component::render_event_meta_table(): void
\WP_Stager_Integration\Component::render_event_meta_table(): voidDescription
Render the event meta table component.
Returns:
void
Information
| File | class-component.php line 141 |
|---|
Full Code
/**
* Render the event meta table component.
*
* @return void
*/
public static function render_event_meta_table() {
// Get data
$event = (array) (Event::get_single_event_data() ?: array());
$event_start = (string) ($event[ 'programStartAt' ] ?? '');
$event_end = (string) ($event[ 'programEndAt' ] ?? '');
$event_doors_open = (string) ($event[ 'doorsOpenAt' ] ?? '');
$location = (array) ($event[ 'location' ] ?? array());
// Process data
$event_start_timestamp = (int) (strtotime( $event_start ) ?: 0);
$event_end_timestamp = (int) (strtotime( $event_end ) ?: 0);
$time_format = (string) (get_option( 'time_format' ) ?: 'H:i');
$date_format = (string) (get_option( 'date_format' ) ?: 'F j, Y');
// Location data
$location_name = (string) ($location[ 'name' ] ?? '');
$location_spaces = (array) ($location[ 'spaces' ] ?? array());
$location_spaces_names = wp_list_pluck( $location_spaces, 'name' );
// Build meta table rows array
$meta_rows = array();
// Date
$meta_rows[] = array(
'heading' => esc_html_x( 'Date', 'Noun, as in the date of an event.', 'wp-stager-integration' ),
'value' => esc_html( wp_date( $date_format, $event_start_timestamp ) )
);
// Doors open
if ( $event_doors_open ) {
$meta_rows[] = array(
'heading' => esc_html_x( 'Doors open', 'The time at which a venue opens its doors for an event.', 'wp-stager-integration' ),
'value' => esc_html( wp_date( $time_format, strtotime( $event_doors_open ) ) )
);
}
// Time
$time_content = wp_kses_post( sprintf( /*
* Translators:
* %1$s: The start time of an event, formatted as a string (e.g. "9:00 am")
* %2$s: The end time of an event, formatted as a string (e.g. "8:00 pm")
*/
esc_html_x( '%1$s - %2$s', 'The start and end times of an event as displayed on event pages.', 'wp-stager-integration' ),
'<span class="program-times__start">' . wp_date( $time_format, $event_start_timestamp ) . '</span>',
'<span class="program-times__end">' . wp_date( $time_format, $event_end_timestamp ) . '</span>',
) );
$meta_rows[] = array(
'heading' => esc_html_x( 'Time', 'Noun, as in the time at which an event takes place.', 'wp-stager-integration' ),
'value' => $time_content
);
// Location
$location_content = '';
if ( $location_spaces_names ) {
$location_content = esc_html( sprintf( /*
* Translators:
* %1s: Name of the location/venue of an event
* %2s: Comma separated list of spaces within an event location/venue
*/
esc_html_x( '%1$s – %2$s', 'The location/venue of an event – followed by a comma-separated list of spaces within that venue.', 'wp-stager-integration' ),
$location_name,
implode( ', ', $location_spaces_names ),
) );
} else {
$location_content = esc_html( $location_name );
}
$meta_rows[] = array(
'heading' => esc_html_x( 'Location', 'As in the location of an event.', 'wp-stager-integration' ),
'value' => $location_content
);
// Render the component
self::render( 'event-meta-table', 'template-parts/event-page', array(
'meta_rows' => $meta_rows,
) );
}💡 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!

