start_controls_section( 'display', [ 'label' => __( 'Display', 'burn-events' ) ] ); } protected function event_id_control(): void { $this->add_control( 'event_id', [ 'label' => __( 'Event ID', 'burn-events' ), 'description' => __( 'Leave blank to use the current event or the template preview event.', 'burn-events' ), 'type' => Controls_Manager::NUMBER, 'min' => 1, ] ); } } class Event_Field_Widget extends Burn_Widget { protected const FIELD = ''; public function get_name(): string { return static::FIELD ? 'burn-events-event-' . static::FIELD : 'burn-events-field'; } public function get_title(): string { return match ( static::FIELD ) { 'title' => __( 'Event Title', 'burn-events' ), 'schedule' => __( 'Event Date and Time', 'burn-events' ), 'description' => __( 'Event Description', 'burn-events' ), 'image' => __( 'Event Image', 'burn-events' ), 'venue' => __( 'Event Venue', 'burn-events' ), 'organizer' => __( 'Event Organizer', 'burn-events' ), 'cost' => __( 'Event Cost', 'burn-events' ), 'export' => __( 'Event Calendar Links', 'burn-events' ), 'related' => __( 'Related Events', 'burn-events' ), default => __( 'Event Field', 'burn-events' ), }; } public function get_icon(): string { return 'eicon-post-content'; } protected function register_controls(): void { $this->start_display_controls(); if ( ! static::FIELD ) { $this->add_control( 'field', [ 'label' => __( 'Event field', 'burn-events' ), 'type' => Controls_Manager::SELECT, 'options' => Calendar::fields(), 'default' => 'title', ] ); } $this->event_id_control(); $this->end_controls_section(); $this->start_controls_section( 'appearance', [ 'label' => __( 'Text', 'burn-events' ), 'tab' => Controls_Manager::TAB_STYLE ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'field_typography', 'selector' => '{{WRAPPER}} .be-elementor-field, {{WRAPPER}} .be-elementor-field :is(h1, h2, p, a, dt, dd)', ] ); $this->add_control( 'text_color', [ 'label' => __( 'Text color', 'burn-events' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .be-elementor-field, {{WRAPPER}} .be-elementor-field :is(h1, h2, p, a, dt, dd)' => 'color: {{VALUE}};' ], ] ); $this->end_controls_section(); } protected function render(): void { [ $event, $row ] = Single_Event_Templates::widget_context( (int) $this->get_settings_for_display( 'event_id' ) ); $field = static::FIELD ?: (string) $this->get_settings_for_display( 'field' ); if ( $event ) { echo '
' . Calendar::field( $field, $event, $row ) . '
'; } elseif ( Elementor::instance()->editor->is_edit_mode() || Elementor::instance()->preview->is_preview_mode() ) { $label = Calendar::fields()[ $field ] ?? __( 'Event field', 'burn-events' ); echo '

' . esc_html( $label ) . '

'; } } } final class Event_Title_Widget extends Event_Field_Widget { protected const FIELD = 'title'; } final class Event_Date_Widget extends Event_Field_Widget { protected const FIELD = 'schedule'; } final class Event_Description_Widget extends Event_Field_Widget { protected const FIELD = 'description'; } final class Event_Image_Widget extends Event_Field_Widget { protected const FIELD = 'image'; } final class Event_Venue_Widget extends Event_Field_Widget { protected const FIELD = 'venue'; public function get_script_depends(): array { return Admin::options()['maps'] ? [ Map_View::SCRIPT ] : []; } public function get_style_depends(): array { return Admin::options()['maps'] ? [ Map_View::STYLE ] : []; } } final class Event_Organizer_Widget extends Event_Field_Widget { protected const FIELD = 'organizer'; } final class Event_Cost_Widget extends Event_Field_Widget { protected const FIELD = 'cost'; } final class Event_Calendar_Links_Widget extends Event_Field_Widget { protected const FIELD = 'export'; } final class Event_Related_Widget extends Event_Field_Widget { protected const FIELD = 'related'; } final class Event_Details_Widget extends Burn_Widget { public function get_name(): string { return 'burn-events-event-details'; } public function get_title(): string { return __( 'Event Details', 'burn-events' ); } public function get_icon(): string { return 'eicon-post-content'; } protected function register_controls(): void { $this->start_display_controls(); $this->event_id_control(); $this->add_control( 'fields', [ 'label' => __( 'Show fields', 'burn-events' ), 'type' => Controls_Manager::SELECT2, 'options' => Calendar::fields(), 'multiple' => true, 'default' => [ 'title', 'schedule', 'description', 'venue', 'export' ], ] ); $this->end_controls_section(); } protected function render(): void { [ $event, $row ] = Single_Event_Templates::widget_context( (int) $this->get_settings_for_display( 'event_id' ) ); if ( $event ) { echo '
'; foreach ( (array) $this->get_settings_for_display( 'fields' ) as $field ) { echo Calendar::field( (string) $field, $event, $row ); } echo '
'; } } } class Calendar_Widget extends Burn_Widget { protected const LIST_ONLY = false; public function get_script_depends(): array { return static::LIST_ONLY ? [] : [ Calendar_Grid::SCRIPT ]; } public function get_name(): string { return static::LIST_ONLY ? 'burn-events-list' : 'burn-events-calendar'; } public function get_title(): string { return static::LIST_ONLY ? __( 'Event List', 'burn-events' ) : __( 'Event Calendar', 'burn-events' ); } public function get_icon(): string { return 'eicon-calendar'; } protected function register_controls(): void { $this->start_display_controls(); if ( ! static::LIST_ONLY ) { $this->add_control( 'view', [ 'label' => __( 'View', 'burn-events' ), 'type' => Controls_Manager::SELECT, 'options' => Calendar::view_labels(), 'default' => 'list' ] ); $this->add_control( 'filters', [ 'label' => __( 'Show search and navigation', 'burn-events' ), 'type' => Controls_Manager::SWITCHER, 'default' => 'yes' ] ); } $this->add_control( 'heading', [ 'label' => __( 'Heading', 'burn-events' ), 'type' => Controls_Manager::TEXT, 'default' => __( 'Events', 'burn-events' ) ] ); $this->add_control( 'category', [ 'label' => __( 'Category slug', 'burn-events' ), 'type' => Controls_Manager::TEXT ] ); $this->add_control( 'tag', [ 'label' => __( 'Tag slug', 'burn-events' ), 'type' => Controls_Manager::TEXT ] ); $this->add_control( 'club_scope', [ 'label' => __( 'Club or sub-club', 'burn-events' ), 'type' => Controls_Manager::SELECT2, 'options' => Clubs::options(), 'default' => '', ] ); $this->add_control( 'location', [ 'label' => __( 'Location', 'burn-events' ), 'type' => Controls_Manager::TEXT ] ); $this->add_control( 'limit', [ 'label' => __( 'Events per page', 'burn-events' ), 'type' => Controls_Manager::NUMBER, 'min' => 1, 'max' => 50, 'default' => 12 ] ); $this->add_control( 'featured', [ 'label' => __( 'Featured events only', 'burn-events' ), 'type' => Controls_Manager::SWITCHER ] ); $this->end_controls_section(); } protected function render(): void { $settings = $this->get_settings_for_display(); echo Calendar::render( [ 'view' => $settings['view'] ?? 'list', 'title' => $settings['heading'], 'category' => $settings['category'] ?? '', 'tag' => $settings['tag'] ?? '', 'location' => $settings['location'] ?? '', 'limit' => $settings['limit'], 'scope' => $settings['club_scope'] ?? '', 'filters' => 'yes' === ( $settings['filters'] ?? '' ) ? 'yes' : 'no', 'featured' => $settings['featured'] ?? '', ] ); } } final class Event_List_Widget extends Calendar_Widget { protected const LIST_ONLY = true; } final class Countdown_Widget extends Burn_Widget { public function get_name(): string { return 'burn-events-countdown'; } public function get_title(): string { return __( 'Event Countdown', 'burn-events' ); } public function get_icon(): string { return 'eicon-countdown'; } protected function register_controls(): void { $this->start_display_controls(); $this->event_id_control(); $this->end_controls_section(); } protected function render(): void { [ $event, $row ] = Single_Event_Templates::widget_context( (int) $this->get_settings_for_display( 'event_id' ) ); if ( ! $event || ! $row ) { return; } wp_enqueue_script( 'burn-events' ); $start = strtotime( $row['starts_at'] . ' UTC' ); printf( '', esc_attr( gmdate( DATE_ATOM, $start ) ), $start, esc_attr__( 'Event has started', 'burn-events' ), esc_html( Calendar::period( $row, Events::event_data( $event->ID ) ) ) ); } } final class Community_Widget extends Burn_Widget { public function get_name(): string { return 'burn-events-community'; } public function get_title(): string { return __( 'Community Events', 'burn-events' ); } public function get_icon(): string { return 'eicon-form-horizontal'; } protected function register_controls(): void { $this->start_display_controls(); $this->add_control( 'view', [ 'label' => __( 'Community view', 'burn-events' ), 'type' => Controls_Manager::SELECT, 'options' => [ 'submit' => __( 'Submit an event', 'burn-events' ), 'mine' => __( 'My events', 'burn-events' ) ], 'default' => 'submit', ] ); $this->end_controls_section(); } protected function render(): void { echo 'mine' === $this->get_settings_for_display( 'view' ) ? Community::mine() : Community::form(); } }