*/ $attendees = tribe( 'tickets.attendees' ); // Register the Attendees tab. $attendees_report = new Attendees_Tab( $tabbed_view ); $attendees_report->set_url( $attendees->get_report_link( $post ) ); $tabbed_view->register( $attendees_report ); /** * Fires before the tabbed view renders to allow for additional tabs registration after the default tabs are added. * * Note that the tabbed view will not render if only a tab is registered; tabs registered during this action will * appear left (before) the default ones. * * @since 5.6.8 * * @param Tribe__Tabbed_View $tabbed_view The tabbed view that is rendering. * @param WP_Post $post The post orders should be shown for. * @param string|null $active The currently active tab, use the `tec_tickets_commerce_reports_tabbed_view_tab_map` filter * to add tabs registered here to the map that will allow them to be activated. */ do_action( 'tec_tickets_commerce_reports_tabbed_view_after_register_tab', $tabbed_view, $post ); // if there is only one tab registered then do not show the tabbed view if ( count( $tabbed_view->get() ) <= 1 ) { return; } if ( null !== $this->active_tab_slug ) { $tabbed_view->set_active( $this->active_tab_slug ); } echo $tabbed_view->render(); } /** * Generates the title based on the page type and post ID. * * @since 5.6.8 * * @param int $post_id The post ID. * * @return string The generated title. */ public function get_title( int $post_id ): string { $page_type = tribe_get_request_var( 'page' ); // Check $page_type to confirm if we are on Order or Attendees page. if ( $page_type === 'tickets-commerce-orders' ) { // Translators: %1$s: the post/event title, %2$d: the post/event ID. $title = _x( 'Orders for: %1$s [#%2$d]', 'orders report screen heading', 'event-tickets' ); } else { // Translators: %1$s: the post/event title, %2$d: the post/event ID. $title = _x( 'Attendees for: %1$s [#%2$d]', 'attendees report screen heading', 'event-tickets' ); } $view_title = sprintf( $title, get_the_title( $post_id ), $post_id ); /** * Filters the title on the Attendees, and Order list page. * * @since 5.6.8 * * @param string $view_title The view title. * @param int $post_id The post ID. * @param string $page_type Possible values `tickets-attendees` or `tickets-orders`. */ return (string) apply_filters( 'tec_tickets_commerce_reports_tabbed_page_title', $view_title, $post_id, $page_type ); } /** * Returns the attendee and orders tabbed view tabs to map the tab request slug to * the registered tabs. * * @since 5.6.8 * * @return array $tab_map An associative array in the [ => ] format. */ protected function get_tab_map(): array { /** * Filters the attendee and orders tabbed view tabs to map the tab request slug to * the registered tabs. * * The map will relate the GET query variable to the registered tab slugs. * * @since 5.6.8 * * @param array $tab_map An associative array in the [ => ] format. * */ return (array) apply_filters( 'tec_tickets_commerce_reports_tabbed_view_tab_map', $this->tab_map ); } /** * Sets the currently active tab slug. * * @since 5.6.8 * * @param string $tab_slug * * @return void */ public function set_active( string $tab_slug ): void { $this->active_tab_slug = $tab_slug; } }