| @@ -13,11 +13,9 @@ | ||
| 13 | 13 | public $_translate_strings = array(); |
| 14 | 14 | protected $WMVC = NULL; |
| 15 | 15 | |
| 16 | 16 | |
| 17 | - public function __construct($data = array(), $args = null) { | |
| 18 | - add_action( 'eli/ajax-handler/after', array( $this, 'after' ) ); | |
| 19 | - add_filter( 'eli/ajax-handler/filter_from_data', array( $this, 'filter_from_data' ) ); | |
| 17 | + public function helper_transalte_strings($data = array(), $args = null) { | |
| 20 | 18 | |
| 21 | 19 | $this->_translate_strings = array( |
| 22 | 20 | __('Guests number', 'wpdirectorykit'), |
| 23 | 21 | __('Listing link', 'wpdirectorykit'), |
| @@ -26,8 +24,14 @@ | ||
| 26 | 24 | __('Date to', 'wpdirectorykit'), |
| 27 | 25 | ); |
| 28 | 26 | } |
| 29 | 27 | |
| 28 | + public function __construct($data = array(), $args = null) { | |
| 29 | + add_action( 'init', array( $this, 'helper_transalte_strings' ) ); | |
| 30 | + add_action( 'eli/ajax-handler/after', array( $this, 'after' ) ); | |
| 31 | + add_filter( 'eli/ajax-handler/filter_from_data', array( $this, 'filter_from_data' ) ); | |
| 32 | + } | |
| 33 | + | |
| 30 | 34 | public function filter_output ($filter_output = array()) { |
| 31 | 35 | $filter_output['message'] = '<div class="elementinvader_addons_for_elementor_alert elementinvader_addons_for_elementor_alert-primary" role="alert">The form was sent successfully.</div>'; |
| 32 | 36 | return $filter_output; |
| 33 | 37 | } |
| @@ -169,9 +173,9 @@ | ||
| 169 | 173 | if(true) |
| 170 | 174 | foreach($_POST as $key => $value) { |
| 171 | 175 | if($key=='element_id') continue; |
| 172 | 176 | if(in_array($key, array('eli_page_id', 'g-recaptcha-response','eli_id', 'eli_type','ID','filter','action','send_action_type','Phone','Message','Email','Name','pets_allowed','сhildrens_allowed','guests_number','guests_number_childs','guests_number_adults'))) continue; |
| 173 | - if(in_array($key, array('listing_link','date_from','date_to','listing_id','wdk_widget', 'function','page'))) continue; | |
| 177 | + if(in_array($key, array('listing_link','date_from','date_to','listing_id','wdk_widget', 'function','page','eli_nonce','eli_token','_wp_http_referer'))) continue; | |
| 174 | 178 | |
| 175 | 179 | if(filter_var($value, FILTER_VALIDATE_URL ) || strpos( $value, 'http' ) !== FALSE) { |
| 176 | 180 | $note .= '<b> '.__(str_replace('_',' ', ucfirst($key)), 'wpdirectorykit').':</b> <a href="'.esc_url($value).'">'.$value.'</a><br>'; |
| 177 | 181 | } else { |
| @@ -526,8 +530,9 @@ | ||
| 526 | 530 | $data_message['data'] = array( |
| 527 | 531 | __('Reservation ID', 'wpdirectorykit')=> $insert_id, |
| 528 | 532 | __('Date From', 'wpdirectorykit')=> wdk_get_date($date_from), |
| 529 | 533 | __('Date To', 'wpdirectorykit')=> wdk_get_date($date_to), |
| 534 | + __('Nights', 'wpdirectorykit')=> wdk_calculate_nights(wdk_get_date($date_from), wdk_get_date($date_to)), | |
| 530 | 535 | ); |
| 531 | 536 | |
| 532 | 537 | $nights = (int)abs(strtotime($date_to) - strtotime($date_from))/(60*60*24); |
| 533 | 538 | $guests_number = intval(wmvc_show_data('guests_number_adults', $_POST, 0)) + intval(wmvc_show_data('guests_number_childs', $_POST, 0)); |
| @@ -604,8 +609,9 @@ | ||
| 604 | 609 | $data_message['data'] = array( |
| 605 | 610 | __('Reservation ID', 'wpdirectorykit')=> $insert_id, |
| 606 | 611 | __('Date From', 'wpdirectorykit')=> wdk_get_date($date_from), |
| 607 | 612 | __('Date To', 'wpdirectorykit')=> wdk_get_date($date_to), |
| 613 | + __('Nights', 'wpdirectorykit')=> wdk_calculate_nights(wdk_get_date($date_from), wdk_get_date($date_to)), | |
| 608 | 614 | ); |
| 609 | 615 | $nights = (int)abs(strtotime($date_to) - strtotime($date_from))/(60*60*24); |
| 610 | 616 | $guests_number = intval(wmvc_show_data('guests_number_adults', $_POST, 0)) + intval(wmvc_show_data('guests_number_childs', $_POST, 0)); |
| 611 | 617 | foreach ($calendar_fees as $fee) { |
| @@ -696,9 +702,9 @@ | ||
| 696 | 702 | $data_mess= array(); |
| 697 | 703 | |
| 698 | 704 | foreach($_POST as $key => $value){ |
| 699 | 705 | if($key=='element_id') continue; |
| 700 | - if(in_array($key, array('eli_id','eli_page_id', 'eli_type','ID','filter','action','send_action_type', 'page_link', 'g-recaptcha-response'))) continue; | |
| 706 | + if(in_array($key, array('eli_id','eli_page_id', 'eli_type','ID','filter','action','send_action_type', 'page_link', 'g-recaptcha-response','eli_nonce','eli_token','_wp_http_referer'))) continue; | |
| 701 | 707 | |
| 702 | 708 | if(empty($value)) continue; |
| 703 | 709 | |
| 704 | 710 | if(filter_var($value, FILTER_VALIDATE_URL ) || strpos( $value, 'http' ) !== FALSE) { |
| @@ -713,8 +719,14 @@ | ||
| 713 | 719 | $Winter_MVC_WDK->model('listing_m'); |
| 714 | 720 | $Winter_MVC_WDK->load_helper('listing'); |
| 715 | 721 | $data_listing = $Winter_MVC_WDK->listing_m->get($post_id, TRUE); |
| 716 | 722 | |
| 723 | + if(function_exists('run_wdk_bookings')) { | |
| 724 | + if(isset($_POST['date_from']) && isset($_POST['date_to']) && !empty($_POST['date_from']) && !empty($_POST['date_to'])) { | |
| 725 | + $data_mess []= '<p><strong>'.__('Nights', 'wpdirectorykit').':</strong> '.wdk_calculate_nights(wdk_get_date($_POST['date_from']), wdk_get_date($_POST['date_to'])).'</p>'; | |
| 726 | + } | |
| 727 | + } | |
| 728 | + | |
| 717 | 729 | /* message for user */ |
| 718 | 730 | if (!empty($email)) { |
| 719 | 731 | $data_message = array(); |
| 720 | 732 | $data_message['email_data'] = $data; |
| @@ -747,9 +759,9 @@ | ||
| 747 | 759 | |
| 748 | 760 | if(isset($_POST['date_from']) && isset($_POST['date_to']) && !empty($_POST['date_from']) && !empty($_POST['date_to'])) { |
| 749 | 761 | $data_message['message'] .= '<h2>'.__('Date reservation change to', 'wpdirectorykit').'</h2>'; |
| 750 | 762 | $data_message['message'] .= '<p>'.__('Details from contact form', 'wpdirectorykit').'</p>'; |
| 751 | - | |
| 763 | + | |
| 752 | 764 | $message_title = __('Contact message related to reservation on page', 'wpdirectorykit').' '.get_bloginfo('name'); |
| 753 | 765 | } |
| 754 | 766 | } |
| 755 | 767 | |