> */ private function get_yacht_switcher_items() { $yachts = get_posts( array( 'post_type' => 'yacht', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC', ) ); $items = array(); foreach ( $yachts as $yacht ) { $items[] = array( 'id' => (int) $yacht->ID, 'title' => get_the_title( $yacht ), 'description' => wp_kses_post( wpautop( $yacht->post_content ) ), ); } return $items; } /** * Render quick yacht switcher. * * @param array> $yachts Yacht items. * @param int $active_id Active yacht ID. * @return void */ private function render_yacht_switcher( $yachts, $active_id ) { $other_yachts = array_filter( $yachts, static function( $yacht_item ) use ( $active_id ) { return (int) $yacht_item['id'] !== (int) $active_id; } ); if ( empty( $other_yachts ) ) { return; } ?>
start_controls_section( 'content_section', array( 'label' => esc_html__( 'Ustawienia Kalendarza', 'yacht-booking' ), 'tab' => Controls_Manager::TAB_CONTENT, ) ); // Yacht selector $yachts = get_posts( array( 'post_type' => 'yacht', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC', 'fields' => 'ids', ) ); $yacht_options = array(); foreach ( $yachts as $yacht_id ) { $yacht_options[ $yacht_id ] = get_the_title( $yacht_id ); } if ( empty( $yacht_options ) ) { $yacht_options[0] = esc_html__( 'Brak jachtów - dodaj pierwszy jacht w panelu admin', 'yacht-booking' ); } $this->add_control( 'yacht_id', array( 'label' => esc_html__( 'Wybierz Jacht', 'yacht-booking' ), 'type' => Controls_Manager::SELECT, 'options' => $yacht_options, 'default' => array_key_first( $yacht_options ), 'label_block' => true, ) ); $this->add_control( 'show_form', array( 'label' => esc_html__( 'Pokaż formularz rezerwacji', 'yacht-booking' ), 'type' => Controls_Manager::SWITCHER, 'label_on' => esc_html__( 'Tak', 'yacht-booking' ), 'label_off' => esc_html__( 'Nie', 'yacht-booking' ), 'return_value' => 'yes', 'default' => 'yes', ) ); $this->add_control( 'calendar_height', array( 'label' => esc_html__( 'Wysokość kalendarza', 'yacht-booking' ), 'type' => Controls_Manager::SLIDER, 'range' => array( 'px' => array( 'min' => 400, 'max' => 1000, ), ), 'default' => array( 'size' => 600, 'unit' => 'px', ), ) ); $this->end_controls_section(); // Style Section $this->start_controls_section( 'style_section', array( 'label' => esc_html__( 'Styl', 'yacht-booking' ), 'tab' => Controls_Manager::TAB_STYLE, ) ); $this->add_control( 'primary_color', array( 'label' => esc_html__( 'Kolor główny', 'yacht-booking' ), 'type' => Controls_Manager::COLOR, 'default' => '#0e2036', ) ); $this->add_control( 'available_color', array( 'label' => esc_html__( 'Kolor dni dostępnych', 'yacht-booking' ), 'type' => Controls_Manager::COLOR, 'default' => '#f5f9ff', ) ); $this->add_control( 'booked_color', array( 'label' => esc_html__( 'Kolor dni zajętych', 'yacht-booking' ), 'type' => Controls_Manager::COLOR, 'default' => '#bc1834', ) ); $this->end_controls_section(); } /** * Render widget output on the frontend */ protected function render() { $settings = $this->get_settings_for_display(); $yacht_id = ! empty( $settings['yacht_id'] ) ? (int) $settings['yacht_id'] : 0; if ( ! $yacht_id ) { if ( \Elementor\Plugin::$instance->editor->is_edit_mode() ) { echo '
'; echo '

' . esc_html__( 'Uwaga:', 'yacht-booking' ) . ' '; echo esc_html__( 'Najpierw dodaj jacht w panelu administratora.', 'yacht-booking' ) . '

'; echo '
'; } return; } $yacht = get_post( $yacht_id ); $yacht_switcher = $this->get_yacht_switcher_items(); $booking_enabled = Settings::is_booking_enabled(); $show_form = $booking_enabled && 'yes' === $settings['show_form']; $calendar_id = 'yacht-calendar-' . $this->get_id(); $raw_height = ! empty( $settings['calendar_height']['size'] ) ? (int) $settings['calendar_height']['size'] : 600; $height = $raw_height; $primary_color = ! empty( $settings['primary_color'] ) ? $settings['primary_color'] : '#0e2036'; $available_bg = ! empty( $settings['available_color'] ) ? $settings['available_color'] : '#f5f9ff'; $booked_bg = ! empty( $settings['booked_color'] ) ? $settings['booked_color'] : '#bc1834'; $terms_url = Settings::get_terms_page_url(); ?>

post_title ) ); ?> post_title ) ); ?>

post_content ? '' : ' style="display: none;"'; ?>> post_content ) ); ?>

' . esc_html__( 'regulamin', 'yacht-booking' ) . '' ); ?>

render_yacht_switcher( $yacht_switcher, $yacht_id ); ?>
<# var yachtId = settings.yacht_id; var calendarId = 'yacht-calendar-preview-' + view.getID(); var height = settings.calendar_height.size || 600; var showForm = 'yes' === settings.show_form; #>

<# if ( showForm ) { #>

<# } #>