Event_Modifier::include_event_data( array $data, TECTickets_Wallet_PlusPassesApple_WalletPass $pass )
Add the Event date into the Apple Pass back data.
Contents
Parameters
- $data
-
(array) (Required) The Apple Pass data.
- $pass
-
(TECTickets_Wallet_PlusPassesApple_WalletPass) (Required) The Apple Pass object.
Return
(array) Modified pass data.
Source
File: src/Events/Integrations/Plugins/Tickets_Wallet_Plus/Passes/Apple_Wallet/Event_Modifier.php
public function include_event_data( array $data, Pass $pass ): array {
// Bail if `tribe_events` CPT is not enabled to have tickets.
if ( ! in_array( \Tribe__Events__Main::POSTTYPE, tribe( 'tickets.main' )->post_types(), true ) ) {
return $data;
}
// Bail if there is no attendee.
if ( ! $pass->attendee_exists() ) {
return $data;
}
$event_id = $pass->get_event_id();
// Get the event.
$event = tribe_get_event( $event_id );
// Bail if it's empty or if the ticket is from a page/post or any other CPT with tickets.
if ( empty( $event ) || ! in_array( $event->post_type, tribe( 'tickets.main' )->post_types() ) ) {
return $data;
}
if ( empty( $data['secondary'] ) || ! is_array( $data['secondary'] ) ) {
$data['secondary'] = [];
}
if ( empty( $data['auxiliary'] ) || ! is_array( $data['auxiliary'] ) ) {
$data['auxiliary'] = [];
}
// Add the event title.
$data['secondary'][] = [
'key' => 'event_title',
'label' => esc_html__( 'Event', 'the-events-calendar' ),
'value' => $event->post_title,
];
// Add the event start date.
$data['secondary'][] = [
'dateStyle' => 'PKDateStyleMedium',
'isRelative' => true,
'key' => 'event_start_date',
'label' => esc_html__( 'Date', 'the-events-calendar' ),
'timeStyle' => 'PKDateStyleShort',
'value' => $event->dates->start->format( 'Y-m-d\TH:iP' ),
];
return $data;
}
Changelog
| Version | Description |
|---|---|
| 6.2.8 | Introduced. |