events = $events; $this->orders = $orders; $this->register_shortcodes(); } private function register_shortcodes() { add_shortcode('tt-event', array($this, 'event_widget_shortcode')); add_shortcode('tt-events', array($this, 'event_listing_shortcode')); add_shortcode('tt-single-event', array($this, 'single_event_shortcode')); } /** * Event widget shortcode (original, enhanced) */ public function event_widget_shortcode($atts) { $atts = shortcode_atts( array( 'url' => '', 'minimal' => 'false', 'bg_fill' => 'true', 'show_logo' => 'true', 'inherit_ref_from_url_param' => '', 'ref' => 'website_widget', ), $atts, 'tt-event' ); if (empty($atts['url'])) { return '

' . esc_html__('Error: No URL set for Ticket Tailor widget', 'ticket-tailor') . '

'; } $url = esc_url($atts['url'], array('http', 'https')); if (empty($url)) { return '

' . esc_html__('Error: Invalid URL provided', 'ticket-tailor') . '

'; } $minimal = $this->sanitize_boolean($atts['minimal']); $bg_fill = $this->sanitize_boolean($atts['bg_fill']); $show_logo = $this->sanitize_boolean($atts['show_logo']); $inherit_ref = sanitize_text_field($atts['inherit_ref_from_url_param']); $ref = sanitize_text_field($atts['ref']); static $widget_count = 0; $widget_count++; $widget_id = 'tt-widget-' . $widget_count; ob_start(); ?>
10, 'layout' => 'grid', 'columns' => 3, 'show_past' => 'false', 'show_image' => 'true', ), $atts, 'tt-events' ); $limit = absint($atts['limit']); $layout = sanitize_key($atts['layout']); $columns = absint($atts['columns']); $show_past = $this->sanitize_boolean($atts['show_past']); $show_image = $this->sanitize_boolean($atts['show_image']); $events = $show_past ? $this->events->get_past_events($limit) : $this->events->get_upcoming_events($limit); if (is_wp_error($events)) { return '
' . esc_html($events->get_error_message()) . '
'; } if (empty($events)) { return '
' . esc_html__('No events found', 'ticket-tailor') . '
'; } ob_start(); $class = 'tt-event-listing tt-layout-' . esc_attr($layout); if ($layout === 'grid') { $class .= ' tt-columns-' . esc_attr($columns); } ?>
<?php echo esc_attr($event['name']); ?>
'', 'show_description' => 'true', 'show_tickets' => 'true', 'show_image' => 'true', ), $atts, 'tt-single-event' ); $event_id = sanitize_text_field($atts['id']); if (empty($event_id)) { return '
' . esc_html__('Error: No event ID specified', 'ticket-tailor') . '
'; } $show_description = $this->sanitize_boolean($atts['show_description']); $show_tickets = $this->sanitize_boolean($atts['show_tickets']); $show_image = $this->sanitize_boolean($atts['show_image']); $event = $this->events->get_event($event_id); if (is_wp_error($event)) { return '
' . esc_html($event->get_error_message()) . '
'; } ob_start(); ?>
<?php echo esc_attr($event['name']); ?>