Tribe__Events__Community__Tickets__Shortcodes::do_shortcode( array $attributes = array(), string $tag = 'tribe_community_tickets' )
Display the Community Tickets Shortcodes
Contents
To display the Attendees Report use: [tribe_community_tickets view="attendees_report" id="your_event_id"]
To display the Sales Report use: [tribe_community_tickets view="sales_report" id="your_event_id"]
Parameters
- $attributes
-
(array) (Optional)
Default value: array()
- $tag
-
(string) (Optional) the name of the shortcode
Default value: 'tribe_community_tickets'
Return
(mixed)
Source
File: src/Tribe/Shortcodes.php
public function do_shortcode( $attributes = array(), $tag = 'tribe_community_tickets' ) { // Normalize attribute keys, lowercase $attributes = array_change_key_case( (array) $attributes, CASE_LOWER ); $tribe_id = $this->check_id( $attributes ); $tribe_view = array_key_exists( 'view', $attributes ) ? $attributes['view'] : 'submission_form'; // Override default attributes with user attributes $tribe_attributes = shortcode_atts( array( 'view' => $tribe_view, 'id' => $tribe_id, ), $attributes, $tag ); // Check if current user is allowed to visualize the reports $login = $this->is_logged_in( $tribe_id ); if ( $login !== true ) { return $login; } $attendees_report = new Tribe__Events__Community__Tickets__Route__Attendees_Report( '', true ); $sales_report = new Tribe__Events__Community__Tickets__Route__Sales_Report( '', true ); $shortcode_notice = esc_html__( 'Community Tickets Shortcode error: The provided Event ID is invalid', 'tribe-events-community-tickets' ); $this->enqueue_assets(); switch ( $tribe_attributes['view'] ) { case 'attendees_report': if ( $tribe_id === false ) { $view = $shortcode_notice; } else { add_filter( 'tribe_events_tickets_attendees_table_nav', array( $this, 'attendees_buttons', ), 1 ); $view = $attendees_report->callback( $tribe_attributes['id'], true ); } break; case 'sales_report': if ( $tribe_id === false ) { $view = $shortcode_notice; } else { $view = $sales_report->callback( $tribe_attributes['id'], true ); } break; default: $view = esc_html__( 'Community Tickets Shortcode error: The view you specified doesn\'t exist or the Event ID is invalid.', 'tribe-events-community-tickets' ); } $display = "<div id='tribe-community-tickets-shortcode' style='visibility:hidden;'>$view</div>"; $display .= '<script>setTimeout(function(){document.getElementById("tribe-community-tickets-shortcode").style.visibility = "visible";},400);</script>'; return $display; }
Changelog
Version | Description |
---|---|
4.6.2 | Introduced. |