start_controls_section( 'content_section', [ 'label' => esc_html__('Content', 'fluent-booking'), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'title', [ 'label' => esc_html__('Title', 'fluent-booking'), 'type' => \Elementor\Controls_Manager::TEXT, 'placeholder' => esc_html__('Enter title here', 'fluent-booking'), ] ); $this->add_control( 'description', [ 'label' => esc_html__('Description', 'fluent-booking'), 'type' => \Elementor\Controls_Manager::TEXTAREA, 'rows' => 4, 'placeholder' => esc_html__('Enter description here', 'fluent-booking'), ] ); $this->add_control( 'header_image', [ 'label' => esc_html__('Choose Header Image', 'fluent-booking'), 'type' => \Elementor\Controls_Manager::MEDIA ] ); $this->add_control( 'show_host_info', [ 'label' => esc_html__('Host Info', '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( 'selected_cal_id', [ 'label' => esc_html__('Select Calendar', 'fluent-booking'), 'type' => \Elementor\Controls_Manager::SELECT, 'label_block' => true, 'options' => $this->getCalendars() ] ); $this->add_control( 'selected_event_ids', [ 'label' => esc_html__('Select Events', 'fluent-booking'), 'type' => \Elementor\Controls_Manager::SELECT2, 'label_block' => true, 'multiple' => true, 'options' => [] ] ); $this->end_controls_section(); $this->styleSettings(); } private function styleSettings() { $this->start_controls_section( 'content_style', [ 'label' => esc_html__('Style', 'fluent-booking'), 'tab' => \Elementor\Controls_Manager::TAB_STYLE, ] ); $this->add_control('fcal_primary_color', [ 'label' => esc_html__('Primary Color', 'fluent-booking'), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .fcal_calendar_inner .fcal_date_wrapper .calendar .day .is-today, {{WRAPPER}} .fcal_slot_picker .fcal_spot_lists .fcal_spot.fcal_spot_selected .fcal_spot_name' => 'color: {{VALUE}}', '{{WRAPPER}} .fcal_calendar_inner .fcal_date_wrapper .calendar .day .is-today:before' => 'background: {{VALUE}}', '{{WRAPPER}} .fcal_slot_picker .fcal_spot_lists .fcal_spot .fcal_spot_confirm' => 'background: {{VALUE}}', '{{WRAPPER}} .calendar_nav .fcal_nav_active svg' => 'color: {{VALUE}}', '{{WRAPPER}} .fcal_timezone_select .svelte-select.focused' => 'border-color: {{VALUE}} !important', '{{WRAPPER}} .fcal_timezone_select .svelte-select .svelte-select-list .item.active' => 'border-color: {{VALUE}} !important', '{{WRAPPER}} .fcal_slot_picker .fcal_spot_lists .fcal_spot.fcal_spot_selected' => 'border-color: {{VALUE}}', '{{WRAPPER}} .fcal_slot_picker .fcal_spot_lists .fcal_spot:hover' => 'border-color: {{VALUE}}', '{{WRAPPER}} .fcal_timezone_select .svelte-select .svelte-select-list .item.hover' => 'background: {{VALUE}} !important', '{{WRAPPER}} .fcal_slot_picker .fcal_spot_lists .fcal_spot:before' => 'background: {{VALUE}} !important', '{{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item .fcal_input_content input:focus' => 'border-color: {{VALUE}} !important', '{{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item .fcal_input_content select:focus' => 'border-color: {{VALUE}} !important', '{{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item .fcal_input_content textarea:focus' => 'border-color: {{VALUE}} !important', '{{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item button' => 'border-color: {{VALUE}}; background: {{VALUE}};', '{{WRAPPER}} span.fcal_host_badge' => 'color: {{VALUE}}', '{{WRAPPER}} span.fcal_host_badge:before' => 'background: {{VALUE}}', '{{WRAPPER}} .fcal_normal_booking_footer a' => 'color: {{VALUE}}', '{{WRAPPER}} .fcal_timezone_select .svelte-select.list-open:before' => 'border-bottom-color: {{VALUE}}; border-left-color: {{VALUE}}', '{{WRAPPER}} .fcal_loading_dates_inner .wrapper .cube' => 'background-color: {{VALUE}}', '{{WRAPPER}} .fcal_calendar_inner .fcal_icon_item .fcal_multi_duration .fcal_duration.is_selected' => 'background-color: {{VALUE}}', '{{WRAPPER}} .fcal_calendar_inner .fcal_date_wrapper .calendar .day.day-enabled:hover span' => 'background-color: {{VALUE}}', '{{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item .fcal_input_content .fcal_radio_group .fcal_radio_icon::before, {{WRAPPER}} .fcal_calendar_inner .fcal_date_wrapper .fcal_date_event_details .fcal_date_event_details_header .fcal_back button.fcal_svg:hover' => 'background: {{VALUE}}', '{{WRAPPER}} .fcal_no_availability button' => 'background-color: {{VALUE}}', '{{WRAPPER}} .fcal_slot button svg path' => 'stroke: {{VALUE}}', '{{WRAPPER}} .fcal_slot_wrapper .fcal_back .fcal_back_btn:hover, {{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item .fcal_input_content .fcal_radio_group input:checked ~ .fcal_radio_icon, {{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item .fcal_input_content .fcal_custom_checkbox input:checked ~ .checkbox_mark, {{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item .fcal_input_content .fcal_custom_checkbox input:focus ~ .checkbox_mark' => 'border-color: {{VALUE}}', '{{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item .fcal_input_content .fcal_custom_checkbox input:checked ~ .checkbox_mark' => 'background: {{VALUE}}' ], ] ); $this->add_control('fcal_border_color', [ 'label' => esc_html__('Border Color', 'fluent-booking'), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .fcal_calendar_inner .fcal_side' => 'border-right-color: {{VALUE}}', '{{WRAPPER}} .fcal_calendar_inner .fcal_date_wrapper .fcal_date_event_details .fcal_date_event_details_header' => 'border-bottom-color: {{VALUE}}', '{{WRAPPER}} {{WRAPPER}} .fcal_payment_items table tbody td' => 'border-bottom-color: {{VALUE}} !important', '{{WRAPPER}} .fcal_wrap .fcal_calendar_inner, {{WRAPPER}} .fcal_slot_picker .fcal_slot_picker_header .fcal_slot_picker_header_action, {{WRAPPER}} .fcal_slot_picker .fcal_spot_lists .fcal_spot, {{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item .fcal_input_content select, {{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item .fcal_input_content textarea, {{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item .fcal_input_content input, {{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item .fcal_input_content .fcal_radio_group .fcal_radio_icon, {{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item .fcal_input_content .fcal_custom_checkbox .checkbox_mark, {{WRAPPER}} .fcal_payment_items table' => 'border-color: {{VALUE}}', '{{WRAPPER}} .fcal_timezone_select .svelte-select, {{WRAPPER}} .fcal_slot_picker .fcal_slot_picker_header .fcal_back .fcal_svg, {{WRAPPER}} .fcal_calendar_inner .fcal_date_wrapper .fcal_date_event_details .fcal_date_event_details_header .fcal_back button.fcal_svg' => 'border-color: {{VALUE}} !important', '{{WRAPPER}} .fcal_slot' => 'border-bottom-color: {{VALUE}}', '{{WRAPPER}} .fcal_slots, {{WRAPPER}} .fcal_slot .book_now' => 'border-color: {{VALUE}}' ], ] ); $this->add_control( 'avatar-radius', [ 'label' => esc_html__('Avatar Radius', 'fluent-booking'), 'type' => \Elementor\Controls_Manager::DIMENSIONS, 'size_units' => ['px', '%', 'em', 'rem', 'custom'], 'default' => [ 'top' => 8, 'right' => 8, 'bottom' => 8, 'left' => 8, 'unit' => 'px', 'isLinked' => true, ], 'selectors' => [ '{{WRAPPER}} .fcal_calendar_inner .fcal_side .fcal_author_avatar img, {{WRAPPER}} .fcal_author_header img, {{WRAPPER}} .fcal_calendar_wrapper .fcal_calendar_header .fcal_person_avatar img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], 'condition' => [ 'show_host_info' => 'yes', ], ] ); $this->add_control( 'date-radius', [ 'label' => esc_html__('Date Radius', 'fluent-booking'), 'type' => \Elementor\Controls_Manager::DIMENSIONS, 'size_units' => ['px', '%', 'em', 'rem', 'custom'], 'default' => [ 'top' => 4, 'right' => 4, 'bottom' => 4, 'left' => 4, 'unit' => 'px', 'isLinked' => true, ], 'selectors' => [ '{{WRAPPER}} .fcal_calendar_inner .fcal_date_wrapper .calendar .day.day-enabled span' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;', ], ] ); $this->add_control('enabled_date_background', [ 'label' => esc_html__('Enabled Date Background', 'fluent-booking'), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .fcal_payment_items table thead th' => 'background-color: {{VALUE}}', '{{WRAPPER}} .fcal_calendar_inner .fcal_date_wrapper .calendar .day.day-enabled span' => 'background-color: {{VALUE}}', '{{WRAPPER}} .fcal_calendar_inner .fcal_icon_item .fcal_multi_duration .fcal_duration:not(.is_selected)' => 'background-color: {{VALUE}}', ], ] ); $this->add_control('enabled_date_color', [ 'label' => esc_html__('Enabled Date Color', 'fluent-booking'), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .fcal_calendar_inner .fcal_date_wrapper .calendar .day.day-enabled span' => 'color: {{VALUE}}', ], ] ); $this->add_control('disabled_date_color', [ 'label' => esc_html__('Disabled Date Color', 'fluent-booking'), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .fcal_calendar_inner .fcal_date_wrapper .calendar .day.day-disabled' => 'color: {{VALUE}}', ], ] ); $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; } private function getCalendarEvents($selectedCalId, $eventIds) { if (empty($eventIds) || empty($selectedCalId)) { return []; } $events = CalendarSlot::where('calendar_id', $selectedCalId) ->whereIn('id', $eventIds) ->get(); $calendar = Calendar::find($selectedCalId); if (!$calendar || !$events) { return []; } $formattedData = [ 'user_profile' => $calendar->getAuthorProfile(), 'events' => $this->formatEvents($events), ]; $formattedData['user_profile']['description'] = $calendar->description; return $formattedData; } private function formatEvents($events) { $formattedEvents = []; foreach ($events as $event) { $event->description = $event->getDescription(); $formattedEvents[] = [ 'title' => $event->title, 'color_schema' => $event->color_schema, 'short_description' => $event->short_description, 'durations' => $event->getAvailableDurations(), ]; } return $formattedEvents; } /** * Render currency widget output on the frontend. * * @access protected */ protected function render() { $settings = $this->get_settings_for_display(); $events = $this->getCalendarEvents($settings['selected_cal_id'], $settings['selected_event_ids']); $blockEditor = new BlockEditorHandler(); $hostInfo = true; if ($settings['show_host_info'] == 'yes') { $hostInfo = false; } $attributes = [ 'calendarId' => $settings['selected_cal_id'], 'eventIds' => $settings['selected_event_ids'], 'title' => $settings['title'], 'description' => $settings['description'], 'headerImage' => $settings['header_image'], 'hideInfo' => $hostInfo ]; if (\Elementor\Plugin::$instance->editor->is_edit_mode()) : // Output for editor ?>
<?php echo esc_html($settings['title']); ?>

<?php echo esc_attr($events['user_profile']['name']); ?>

Book Now
fcalRenderCalendarManagementBlock($attributes); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped endif; ?>