field_types ['user_id'] = esc_html__('Hidden Field Agent ID', 'wpdirectorykit'); parent::register_controls(); $items = [ [ 'key'=>'button_booking', 'label'=> esc_html__('Button Booking', 'wpdirectorykit'), 'selector'=>'.elementinvader_contact_form .wdk-booking', 'options'=>'full', ], ]; foreach ($items as $item) { $this->start_controls_section( $item['key'].'_section', [ 'label' => $item['label'], 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_responsive_control( $item['key'].'_hide', [ 'label' => esc_html__('Hide Element', 'wpdirectorykit'), 'type' => Controls_Manager::SWITCHER, 'none' => esc_html__('Hide', 'wpdirectorykit'), 'block' => esc_html__('Show', 'wpdirectorykit'), 'return_value' => 'none', 'default' => '', 'selectors' => [ '{{WRAPPER}} '.$item['selector'] => 'display: {{VALUE}};', ], ] ); $selectors = array( 'normal' => '{{WRAPPER}} '.$item['selector'], 'hover'=>'{{WRAPPER}} '.$item['selector'].'%1$s' ); $this->generate_renders_tabs($selectors, $item['key'].'_dynamic', $item['options']); $this->end_controls_section(); } $this->start_controls_section( 'booking_section', [ 'label' => esc_html__('Booking', 'wpdirectorykit'), 'tab' => 'fields_tab', ] ); $this->add_control( 'booking_hide_if_сhildrens_allowed_field', [ 'label' => esc_html__('Childrens allowed field hide', 'wpdirectorykit'), 'type' => Controls_Manager::SWITCHER, 'none' => esc_html__('Yes', 'wpdirectorykit'), 'block' => esc_html__('No', 'wpdirectorykit'), 'return_value' => 'yes', 'default' => '', ] ); $this->add_control( 'booking_hide_if_pets_allowed_field', [ 'label' => esc_html__('Pets allowed field hide', 'wpdirectorykit'), 'type' => Controls_Manager::SWITCHER, 'none' => esc_html__('Yes', 'wpdirectorykit'), 'block' => esc_html__('No', 'wpdirectorykit'), 'return_value' => 'yes', 'default' => '', ] ); $this->end_controls_section(); } /** * Render the widget output on the frontend. * * Written in PHP and used to generate the final HTML. * * @since 1.1.0 * * @access protected */ protected function render() { $settings = $this->get_settings(); global $wdk_listing_id; $validation_form_email = false; $validation_form_message = false; foreach ($settings['form_fields'] as $field) { $field_name = ''; if(empty($field['field_id'])) { $field_name = $field['field_id']; } if(empty($field_name)) { $field_name = $field['field_label']; } if(empty($field_name)) { $field_name = $field['placeholder']; } if(strtolower($field_name) == 'email') { $validation_form_email = true; } if(strtolower($field_name) == 'message') { $validation_form_message = true; } } if(!$validation_form_email || !$validation_form_message) { $this->content ['wlisting_fields'] .= '
'; $this->content ['wlisting_fields'] .= ''; $this->content ['wlisting_fields'] .= '
'; } $post_id = get_the_ID(); if(isset($wdk_listing_id)){ $this->content ['wlisting_fields'] .= ''; $this->content ['wlisting_fields'] .= ''; } wp_enqueue_script( 'wdk-booking-calculator-price' ); if(function_exists('run_wdk_bookings')) { global $Winter_MVC_wdk_bookings; $Winter_MVC_wdk_bookings->model('calendar_m'); $Winter_MVC_wdk_bookings->model('reservation_m'); $calendar = $Winter_MVC_wdk_bookings->calendar_m->get_pagination(NULL, NULL, array('post_id' => $wdk_listing_id, 'is_activated' => 1)); $dates = $Winter_MVC_wdk_bookings->reservation_m->get_enabled_dates($wdk_listing_id); $dates = (str_replace("'",'',join(' ',$dates))); /* booking price selector */ $this->content ['wlisting_fields'] ='
'. $this->content ['wlisting_fields']; if( $calendar && isset($calendar[0]) ) if( !is_user_logged_in() && ((isset($settings['booking_hide_if_not_login']) && !$settings['booking_hide_if_not_login'] == 'yes') || wmvc_show_data('is_disable_for_not_login',$calendar[0],false, TRUE, TRUE))){ $this->content ['wlisting_fields'] .= '
'.esc_html__('For Booking please login','wpdirectorykit').'
'; } else { $calendar = $calendar[0]; if(intval(wdk_get_option('wdk_bookings_max_guests')) > 0) { $options = range(1, intval(wdk_get_option('wdk_bookings_max_guests'))); } else { $options = range(1, 10); } if(empty($calendar->is_guests_disabled)) { $output ='
'; $output .='
'; $output .='
'; $output .='
'; $this->content ['wlisting_fields'] .= $output; } $attr = ''; if(get_option('wdk_bookings_calendar_single') && !wmvc_show_data('is_hour_enabled',$calendar, false)) { $attr = "data-wdksingle = 'true'"; } else { $custom_css = '.daterangepicker .drp-calendar.left .calendar-table::after { content: "'.__('Please select from date/time','wpdirectorykit').'"; }'; $custom_css .= '.daterangepicker .drp-calendar.right .calendar-table::after { content: "'.__('Please select to date/time','wpdirectorykit').'"; }'; wp_add_inline_style( 'daterangepicker', $custom_css); } if(!wmvc_show_data('is_hour_enabled',$calendar, false)){ $this->content ['wlisting_fields'] .= '
'; $this->content ['wlisting_fields'] .= '
'; } else { $this->content ['wlisting_fields'] .= '
'; $this->content ['wlisting_fields'] .= '
'; } if(true && function_exists('wdk_booking_currency_symbol')){ if(!empty($calendar->json_data_fees)) $calendar_fees = json_decode($calendar->json_data_fees ); if(!empty($calendar_fees)) { foreach ($calendar_fees as $fee) { if(!wmvc_show_data('is_activated', $fee, false,TRUE,TRUE)) continue; $field = str_replace(' ','_',strtolower(esc_html(wmvc_show_data('title', $fee,'-',TRUE,TRUE)))); $readonly = ''; if(wmvc_show_data('is_required', $fee, false,TRUE,TRUE)) { $readonly = 'readonly disabled'; } $this->content ['wlisting_fields'] .='
'; } } } if($settings['booking_hide_if_сhildrens_allowed_field'] != 'yes') { $this->content ['wlisting_fields'] .='
'; } if ($settings['booking_hide_if_pets_allowed_field'] != 'yes') { $this->content ['wlisting_fields'] .='
'; } wp_enqueue_script( 'daterangepicker-moment' ); wp_enqueue_script( 'daterangepicker' ); wp_enqueue_style('daterangepicker'); } } if( is_user_logged_in()) { wp_enqueue_script( 'wdk-notify' ); $data_user = get_userdata(get_current_user_id()); $custom_js =" jQuery('document').ready(function($){ $('#elementinvader_addons_for_elementor_".esc_html($this->get_id_int())." #namename').val('".esc_js(wdk_show_data('display_name', $data_user, '' , TRUE, TRUE))."').attr('data-default','".esc_js(wdk_show_data('display_name', $data_user, '' , TRUE, TRUE))."'); $('#elementinvader_addons_for_elementor_".esc_html($this->get_id_int())." #emailemail').val('".esc_js(wdk_show_data('user_email', $data_user, '' , TRUE, TRUE))."').attr('data-default','".esc_js(wdk_show_data('user_email', $data_user, '' , TRUE, TRUE))."'); $('#elementinvader_addons_for_elementor_".esc_html($this->get_id_int())." [name=\"Phone\"]').val('".esc_js(wdk_show_data('wdk_phone', $data_user, '' , TRUE, TRUE))."').attr('data-default','".esc_js(wdk_show_data('wdk_phone', $data_user, '' , TRUE, TRUE))."'); $('#elementinvader_addons_for_elementor_".esc_html($this->get_id_int())." #messagemessage').val('".esc_js(esc_html__('Interested for listing', 'wpdirectorykit'))."').attr('data-default','".esc_js(esc_html__('Interested for listing', 'wpdirectorykit'))."'); }) "; wp_add_inline_script( 'wdk-notify', $custom_js ); } parent::render(); } }