start_controls_section( 'content_section', [ 'label' => esc_html__('Content', 'fluent-booking'), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'selected_calendars', [ 'label' => esc_html__('Select Calendars', 'fluent-booking'), 'type' => \Elementor\Controls_Manager::SELECT2, 'label_block' => true, 'multiple' => true, 'description' => esc_html__('Left empty to show the bookings for all calendars', 'fluent-booking'), 'options' => $this->getCalendars(), ] ); $this->add_control( 'booking_title', [ 'label' => esc_html__('Title', 'fluent-booking'), 'type' => \Elementor\Controls_Manager::TEXT, 'label_block' => true, 'default' => esc_html__('My Bookings', 'fluent-booking'), 'placeholder' => esc_html__('Type your title here', 'fluent-booking'), ] ); $this->add_control( 'no_bookings_title', [ 'label' => esc_html__('No Booking Title', 'fluent-booking'), 'type' => \Elementor\Controls_Manager::TEXT, 'label_block' => true, 'default' => esc_html__('No bookings found', 'fluent-booking'), 'placeholder' => esc_html__('Type your title here', 'fluent-booking'), ] ); $this->add_control( 'default_period', [ 'label' => esc_html__('Default Period', 'fluent-booking'), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => 'all', 'options' => [ 'all' => esc_html__('All', 'fluent-booking'), 'upcoming' => esc_html__('Upcoming', 'fluent-booking'), 'completed' => esc_html__('Completed', 'fluent-booking'), 'cancelled' => esc_html__('Cancelled', 'fluent-booking'), 'pending' => esc_html__('Pending', 'fluent-booking') ], ] ); $this->add_control( 'show_filter', [ 'label' => esc_html__('Show Filter', 'fluent-booking'), 'type' => \Elementor\Controls_Manager::SWITCHER, 'label_on' => esc_html__('Show', 'fluent-booking'), 'label_off' => esc_html__('Hide', 'fluent-booking'), 'return_value' => 'yes', 'default' => 'yes', ] ); $this->add_control( 'show_pagination', [ 'label' => esc_html__('Show Pagination', 'fluent-booking'), 'type' => \Elementor\Controls_Manager::SWITCHER, 'label_on' => esc_html__('Show', 'fluent-booking'), 'label_off' => esc_html__('Hide', 'fluent-booking'), 'return_value' => 'yes', 'default' => 'yes', ] ); $this->add_control( 'per_page', [ 'label' => esc_html__('Per Page', 'fluent-booking'), 'type' => \Elementor\Controls_Manager::SLIDER, 'range' => [ 'px' => [ 'min' => 1, 'max' => 100, 'step' => 1, ] ], 'default' => [ 'size' => 10, ], ] ); $this->end_controls_section(); } private function getCalendars() { $calendars = Calendar::with(['events' => function ($query) { $query->where('status', 'active'); }])->where('status', 'active')->get(); $formattedValue = []; if (empty($calendars)) { return $formattedValue; } foreach ($calendars as $calendar) { $formattedValue[$calendar->id] = $calendar->title; } return $formattedValue; } /** * Render currency widget output on the frontend. * * @access protected */ protected function render() { $settings = $this->get_settings_for_display(); $filter = ($settings['show_filter'] == 'yes') ? 'show' : 'hide'; $pagination = ($settings['show_pagination'] == 'yes') ? 'show' : 'hide'; $calendarIds = (!empty($settings['selected_calendars'])) ? implode(',', $settings['selected_calendars']) : 'all'; $calendar_ids = esc_attr($calendarIds); $period = esc_attr($settings['default_period']); $filter = esc_attr($filter); $pagination = esc_attr($pagination); $per_page = esc_attr($settings['per_page']['size']); $no_bookings = esc_attr($settings['no_bookings_title']); $title = esc_attr($settings['booking_title']); $shortcode = sprintf( '[fluent_booking_lists calendar_ids="%s" period="%s" filter="%s" pagination="%s" per_page="%s" no_bookings="%s" title="%s"]', $calendar_ids, $period, $filter, $pagination, $per_page, $no_bookings, $title ); $shortcode_output = do_shortcode($shortcode); if (\Elementor\Plugin::$instance->editor->is_edit_mode()) : // Output for editor ?>