PluginProbe
WP Directory Kit / 1.5.9
WP Directory Kit v1.5.9
1.5.9 1.5.7 1.5.6 1.5.5 1.5.4 1.5.3 trunk 1.1.0 1.1.6 1.1.8 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.8 All 37 releases
← All changes | elementor-extensions/class-ajax-handler.php +165 -36 1.2.7 → 1.5.9 View file →
@@ -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,15 @@
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 +
34 +
30 35 public function filter_output ($filter_output = array()) {
31 36 $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 37 return $filter_output;
33 38 }
@@ -53,8 +58,9 @@
53 58
54 59 $email = '';
55 60 $message = '';
56 61 $post_id = '';
62 + $wdk_widget = '';
57 63 foreach ($_POST as $key => $value) {
58 64 if (stripos($key, 'mail') !== false || filter_var($value, FILTER_VALIDATE_EMAIL)) {
59 65 $email = sanitize_email($value);
60 66 }
@@ -60,20 +66,39 @@
60 66 }
61 67 if (stripos($key, 'message') !== false) {
62 68 $message = sanitize_text_field($value);
63 69 }
70 + if (stripos($key, 'wdk_widget') !== false) {
71 + $wdk_widget = sanitize_text_field($value);
72 + }
64 73 if (stripos($key, 'listing_id') !== false) {
65 - $post_id = sanitize_text_field($value);
74 + $post_id = (int)sanitize_text_field($value);
66 75 }
67 76 }
68 - if(function_exists('run_wdk_bookings') && get_current_user_id()) {
77 +
78 + if(function_exists('run_wdk_bookings') && (
79 + is_user_logged_in() ||
80 + $wdk_widget == 'wdk-booking-quick-submission' ||
81 + wdk_get_option('wdk_booking_disable_for_not_login') ||
82 + (!wdk_get_option('wdk_booking_disable_for_not_login') && wdk_get_option('wdk_bookings_enable_woocommerce_payments'))
83 + )
84 + ) {
69 85 if(isset($_POST['date_from']) && isset($_POST['date_to']) && !empty($_POST['date_from']) && !empty($_POST['date_to'])) {
70 86 $date_from = sanitize_text_field($_POST['date_from']);
71 87 $date_to = sanitize_text_field($_POST['date_to']);
72 -
88 + $errors = '';
89 +
90 + global $Winter_MVC_wdk_bookings;
91 + $Winter_MVC_wdk_bookings->model('reservation_m');
92 + $Winter_MVC_wdk_bookings->model('calendar_m');
93 + $Winter_MVC_wdk_bookings->model('price_m');
94 +
95 + $calendar = $Winter_MVC_wdk_bookings->calendar_m->get_by(array('post_id'=>$post_id), TRUE); // date_package_expire package_id
96 +
97 +
73 98 if(wdk_is_date($date_from))
74 99 {
75 - $date_from = wdk_normalize_date_db($date_from);
100 + $date_from = wdk_normalize_date_db($date_from, 'Y-m-d H:i:s', (!wmvc_show_data('is_hour_enabled', $calendar,false)) ? 'Y-m-d': 'Y-m-d H:i:s');
76 101 }
77 102 else
78 103 {
79 104 return false;
@@ -80,9 +105,9 @@
80 105 }
81 106
82 107 if(wdk_is_date($date_to))
83 108 {
84 - $date_to = wdk_normalize_date_db($date_to);
109 + $date_to = wdk_normalize_date_db($date_to, 'Y-m-d H:i:s', (!wmvc_show_data('is_hour_enabled', $calendar,false)) ? 'Y-m-d': 'Y-m-d H:i:s');
85 110 }
86 111 else
87 112 {
88 113 return false;
@@ -87,16 +112,14 @@
87 112 {
88 113 return false;
89 114 }
90 115
91 - global $Winter_MVC_wdk_bookings;
92 - $Winter_MVC_wdk_bookings->model('reservation_m');
93 - $Winter_MVC_wdk_bookings->model('calendar_m');
94 - $Winter_MVC_wdk_bookings->model('price_m');
95 116
96 117 /* message data */
118 +
119 +
97 120 $price = $Winter_MVC_wdk_bookings->reservation_m->calculate_price($post_id, $date_from, $date_to);
98 - $calendar = $Winter_MVC_wdk_bookings->calendar_m->get_by(array('post_id'=>$post_id), TRUE); // date_package_expire package_id
121 +
99 122 $calendar_fees = array();
100 123 if($calendar && !empty($calendar->json_data_fees))
101 124 $calendar_fees = json_decode($calendar->json_data_fees );
102 125
@@ -105,9 +128,9 @@
105 128 $nights = (int)abs(strtotime($date_to) - strtotime($date_from))/(60*60*24);
106 129 foreach ($calendar_fees as $fee) {
107 130 if(!wmvc_show_data('is_activated', $fee, false,TRUE,TRUE)) continue;
108 131 if(is_intval(wmvc_show_data('value', $fee,'',TRUE,TRUE))) {
109 - $field = str_replace(' ','_',strtolower(esc_html(wmvc_show_data('title', $fee,'-',TRUE,TRUE))));
132 + $field = wdk_generate_slug(strtolower(esc_html(wmvc_show_data('title', $fee,'-',TRUE,TRUE))));
110 133 if(!wmvc_show_data('is_required', $fee, false,TRUE,TRUE) && !isset($_POST['fee_'.$field])) {
111 134
112 135 } else {
113 136 if(wmvc_show_data('calculation_base', $fee,'',TRUE,TRUE) == 'per_night') {
@@ -151,17 +174,83 @@
151 174 if(true)
152 175 foreach($_POST as $key => $value) {
153 176 if($key=='element_id') continue;
154 177 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;
155 - if(in_array($key, array('listing_link','date_from','date_to','listing_id'))) continue;
178 + 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;
156 179
157 180 if(filter_var($value, FILTER_VALIDATE_URL ) || strpos( $value, 'http' ) !== FALSE) {
181 + // Dynamic field values are registered in the translation catalog separately.
182 +// phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
158 183 $note .= '<b> '.__(str_replace('_',' ', ucfirst($key)), 'wpdirectorykit').':</b> <a href="'.esc_url($value).'">'.$value.'</a><br>';
159 184 } else {
185 + // Dynamic field values are registered in the translation catalog separately.
186 +// phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
160 187 $note .= '<b> '.__(str_replace('_',' ', ucfirst($key)), 'wpdirectorykit').':</b> '.$value.'<br>';
161 188 }
162 189 }
163 190
191 +
192 + if( !is_user_logged_in()) {
193 +
194 + if(
195 + $wdk_widget == 'wdk-booking-quick-submission' ||
196 + (!wdk_get_option('wdk_booking_disable_for_not_login') && wdk_get_option('wdk_bookings_enable_woocommerce_payments'))
197 + ) {
198 +
199 + /* if not disable for not login users, try create user */
200 + $userlogin = $email;
201 + $username = '';
202 + $email_address = $email;
203 + $password = wp_generate_password();
204 +
205 + if(wmvc_show_data('name', $_POST, false))
206 + $username = sanitize_text_field(wmvc_show_data('name', $_POST, false));
207 +
208 + $user_id = wp_create_user( $userlogin, $password, $email_address );
209 +
210 + if(is_intval($user_id)) {
211 + // Set the nickname
212 + wp_update_user(
213 + array(
214 + 'ID' => $user_id,
215 + 'nickname' => $email_address
216 + )
217 + );
218 +
219 + $user = new \WP_User( $user_id );
220 + $user->set_role('wdk_visitor');
221 +
222 + wp_update_user( array ('ID' => $user_id, 'display_name' => esc_html( $username ) ) );
223 +
224 + $userdata = get_userdata($user_id);
225 +
226 + $subject = __('New user on our website!', 'wpdirectorykit');
227 + $data_message = array();
228 + $data_message['login'] = $userlogin;
229 + $data_message['password'] = $password;
230 + $data_message['user'] = $userdata;
231 + $data_message['data'] = '';
232 +
233 + update_user_meta( $user_id, 'first_name', $username);
234 +
235 + wdk_mail($email_address, $subject, $data_message, 'new_user_auto_created');
236 +
237 + /* auto login */
238 + wp_set_current_user($user_id, $userdata->user_login );
239 + wp_set_auth_cookie($user_id);
240 +
241 + } elseif($user = get_user_by( 'email', $email_address)) {
242 + $user_id = $user->ID;
243 + /* translators: 1: User email address. */
244 + $errors .= '<div class="elementinvader_addons_for_elementor_alert elementinvader_addons_for_elementor_alert-danger" role="alert">'.wdk_sprintf(__( 'For Booking required login, user with email %1$s already exists, please first try login', 'wpdirectorykit' ), $email_address).' <a href="'.wdk_login_url().'" target="_blank" style="text-decoration: underline;">'.esc_html__('here', 'wpdirectorykit').'</a></div>';
245 + } else {
246 + $errors .= '<div class="elementinvader_addons_for_elementor_alert elementinvader_addons_for_elementor_alert-danger" role="alert">'.esc_html__('For Booking please login', 'wpdirectorykit').' <a href="'.wdk_login_url().'" target="_blank" style="text-decoration: underline;">'.esc_html__('here', 'wpdirectorykit').'</div>';
247 + }
248 + } else {
249 + $errors .= '<div class="elementinvader_addons_for_elementor_alert elementinvader_addons_for_elementor_alert-danger" role="alert">'.esc_html__('For Booking please login', 'wpdirectorykit').' <a href="'.wdk_login_url().'" target="_blank" style="text-decoration: underline;">'.esc_html__('here', 'wpdirectorykit').'</div>';
250 + }
251 + }
252 +
164 253 $data = array(
165 254 'post_id' => ($post_id),
166 255 'date_from' => ($date_from),
167 256 'date_to' => ($date_to),
@@ -176,9 +265,9 @@
176 265 if(wmvc_show_data('is_enable_noapprovements', $calendar, false))
177 266 $data['is_approved'] = 1;
178 267
179 268 $results = $Winter_MVC_wdk_bookings->reservation_m->is_booked($post_id, $date_from, $date_to);
180 - $errors = '';
269 +
181 270
182 271 $Winter_MVC_wdk_bookings->db->where("date_from <='".$date_from."'");
183 272 $Winter_MVC_wdk_bookings->db->where("date_to >= '".$date_to."'");
184 273 $price_reservation = $Winter_MVC_wdk_bookings->price_m->get_by(array('post_id'=>$post_id), TRUE);
@@ -212,10 +301,10 @@
212 301 '6'=>__('Saturday', 'wpdirectorykit'),
213 302 '7'=>__('Sunday', 'wpdirectorykit'),
214 303 );
215 304
216 - $day_num_from = date('N', strtotime($date_from));
217 - $day_num_to = date('N', strtotime($date_to));
305 + $day_num_from = gmdate('N', strtotime($date_from));
306 + $day_num_to = gmdate('N', strtotime($date_to));
218 307
219 308 if(wmvc_show_data('changeover_day', $price_reservation, false, TRUE, TRUE) && (
220 309 wmvc_show_data('changeover_day', $price_reservation, false, TRUE, TRUE) != $day_num_from
221 310 || wmvc_show_data('changeover_day', $price_reservation, false, TRUE, TRUE) != $day_num_to
@@ -230,9 +319,11 @@
230 319 $period = '';
231 320 $min_hours = intval(wmvc_show_data('min_hours', $price_reservation, false, TRUE, TRUE));
232 321 if((int)($min_hours/24) >= 1) {
233 322 $days = (int)($min_hours/24);
234 - $period .= esc_html(sprintf(_nx(
323 + $period .= esc_html(sprintf(
324 + /* translators: 1: Number of days. */
325 + _nx(
235 326 '%1$s day',
236 327 '%1$s days',
237 328 $days,
238 329 'days',
@@ -242,9 +333,11 @@
242 333 $min_hours -= $days * 24;
243 334 }
244 335
245 336 if(!empty($min_hours)) {
246 - $period .= ' '.esc_html(sprintf(_nx(
337 + $period .= ' '.esc_html(sprintf(
338 + /* translators: 1: Number of hours. */
339 + _nx(
247 340 '%1$s hour',
248 341 '%1$s hours',
249 342 (int)($min_hours),
250 343 'hours',
@@ -259,9 +352,11 @@
259 352 $period = '';
260 353 $max_hours = intval(wmvc_show_data('max_hours', $price_reservation, false, TRUE, TRUE));
261 354 if((int)($max_hours/24) >= 1) {
262 355 $days = (int)($max_hours/24);
263 - $period .= esc_html(sprintf(_nx(
356 + $period .= esc_html(sprintf(
357 + /* translators: 1: Number of days. */
358 + _nx(
264 359 '%1$s day',
265 360 '%1$s days',
266 361 $days,
267 362 'days',
@@ -271,9 +366,11 @@
271 366 $max_hours -= $days * 24;
272 367 }
273 368
274 369 if(!empty($max_hours)) {
275 - $period .= ' '.esc_html(sprintf(_nx(
370 + $period .= ' '.esc_html(sprintf(
371 + /* translators: 1: Number of hours. */
372 + _nx(
276 373 '%1$s hour',
277 374 '%1$s hours',
278 375 (int)($max_hours),
279 376 'hours',
@@ -300,11 +397,11 @@
300 397 return $filter_output;
301 398 } );
302 399 } else {
303 400
304 - if(!$calendar->is_hour_enabled && !empty($data['date_from']) && !empty($data['date_to'])) {
305 - $data['date_from'] = date('Y-m-d 00:00:00', strtotime($data['date_from']));
306 - $data['date_to'] = date('Y-m-d 00:00:00', strtotime($data['date_to']));
401 + if(wmvc_show_data('is_hour_enabled', $calendar, false) && !empty($data['date_from']) && !empty($data['date_to'])) {
402 + $data['date_from'] = gmdate('Y-m-d 00:00:00', strtotime($data['date_from']));
403 + $data['date_to'] = gmdate('Y-m-d 00:00:00', strtotime($data['date_to']));
307 404 }
308 405 $insert_id = $Winter_MVC_wdk_bookings->reservation_m->insert($data, NULL);
309 406
310 407 /* auto is_enable_noapprovements enabled */
@@ -407,9 +504,9 @@
407 504 if(wdk_get_option(('wdk_bookings_time_for_payment'))) {
408 505 $data_message['hours_for_payment'] = intval(wdk_get_option(('wdk_bookings_time_for_payment')));
409 506
410 507 /* set date_expire for reservation */
411 - $update_data = array('date_expire'=>esc_sql(date("Y-m-d H:i:s", strtotime("+".intval(wdk_get_option(('wdk_bookings_time_for_payment')))." hours"))));
508 + $update_data = array('date_expire'=>esc_sql(gmdate("Y-m-d H:i:s", strtotime("+".intval(wdk_get_option(('wdk_bookings_time_for_payment')))." hours"))));
412 509 $Winter_MVC_wdk_bookings->reservation_m->insert($update_data, $insert_id);
413 510 }
414 511
415 512 wdk_mail(wdk_show_data('user_email', $data_message['user'], '' , TRUE, TRUE), __('Reservation waiting for payment', 'wpdirectorykit'), $data_message, 'reservation_user_payment_notify');
@@ -447,8 +544,9 @@
447 544 $data_message['data'] = array(
448 545 __('Reservation ID', 'wpdirectorykit')=> $insert_id,
449 546 __('Date From', 'wpdirectorykit')=> wdk_get_date($date_from),
450 547 __('Date To', 'wpdirectorykit')=> wdk_get_date($date_to),
548 + __('Nights', 'wpdirectorykit')=> wdk_calculate_nights(wdk_get_date($date_from), wdk_get_date($date_to)),
451 549 );
452 550
453 551 $nights = (int)abs(strtotime($date_to) - strtotime($date_from))/(60*60*24);
454 552 $guests_number = intval(wmvc_show_data('guests_number_adults', $_POST, 0)) + intval(wmvc_show_data('guests_number_childs', $_POST, 0));
@@ -454,9 +552,9 @@
454 552 $guests_number = intval(wmvc_show_data('guests_number_adults', $_POST, 0)) + intval(wmvc_show_data('guests_number_childs', $_POST, 0));
455 553 foreach ($calendar_fees as $fee) {
456 554 if(!wmvc_show_data('is_activated', $fee, false,TRUE,TRUE)) continue;
457 555
458 - $field = str_replace(' ','_',strtolower(esc_html(wmvc_show_data('title', $fee,'-',TRUE,TRUE))));
556 + $field = wdk_generate_slug(strtolower(esc_html(wmvc_show_data('title', $fee,'-',TRUE,TRUE))));
459 557 if(!wmvc_show_data('is_required', $fee, false,TRUE,TRUE) && !isset($_POST['fee_'.$field])) {
460 558
461 559 } else {
462 560 if(wmvc_show_data('calculation_base', $fee,'',TRUE,TRUE) == 'per_night') {
@@ -488,9 +586,14 @@
488 586 }
489 587 else
490 588 {
491 589 add_filter( 'eli/ajax-handler/filter_output', function($filter_output) {
492 - $filter_output['message'] = '<div class="elementinvader_addons_for_elementor_alert elementinvader_addons_for_elementor_alert-danger" role="alert">'.esc_html__('Server can\'t send emails, please use SMTP mail configuration.', 'wpdirectorykit').'</div>';
590 + $filter_output['message'] = '<div class="elementinvader_addons_for_elementor_alert elementinvader_addons_for_elementor_alert-danger" role="alert">'. sprintf(
591 + /* translators: 1: Tag with link open, 2: close link tag. */
592 + esc_html__('Server can\'t send emails, please use SMTP mail configuration. Check %1$sGuide%2$s', 'wpdirectorykit'),
593 + '<a href="https://wpdirectorykit.com/e-mail-sending-issues-smtp-mail-configuration/" target="_blank" style="text-decoration: underline">',
594 + '</a>'
595 + ).'</div>';
493 596 $filter_output['no_clear_from'] = true;
494 597 return $filter_output;
495 598 } );
496 599 }
@@ -525,8 +628,9 @@
525 628 $data_message['data'] = array(
526 629 __('Reservation ID', 'wpdirectorykit')=> $insert_id,
527 630 __('Date From', 'wpdirectorykit')=> wdk_get_date($date_from),
528 631 __('Date To', 'wpdirectorykit')=> wdk_get_date($date_to),
632 + __('Nights', 'wpdirectorykit')=> wdk_calculate_nights(wdk_get_date($date_from), wdk_get_date($date_to)),
529 633 );
530 634 $nights = (int)abs(strtotime($date_to) - strtotime($date_from))/(60*60*24);
531 635 $guests_number = intval(wmvc_show_data('guests_number_adults', $_POST, 0)) + intval(wmvc_show_data('guests_number_childs', $_POST, 0));
532 636 foreach ($calendar_fees as $fee) {
@@ -531,9 +635,9 @@
531 635 $guests_number = intval(wmvc_show_data('guests_number_adults', $_POST, 0)) + intval(wmvc_show_data('guests_number_childs', $_POST, 0));
532 636 foreach ($calendar_fees as $fee) {
533 637 if(!wmvc_show_data('is_activated', $fee, false,TRUE,TRUE)) continue;
534 638
535 - $field = str_replace(' ','_',strtolower(esc_html(wmvc_show_data('title', $fee,'-',TRUE,TRUE))));
639 + $field = wdk_generate_slug(strtolower(esc_html(wmvc_show_data('title', $fee,'-',TRUE,TRUE))));
536 640 if(!wmvc_show_data('is_required', $fee, false,TRUE,TRUE) && !isset($_POST['fee_'.$field])) {
537 641
538 642 } else {
539 643 if(wmvc_show_data('calculation_base', $fee,'',TRUE,TRUE) == 'per_night') {
@@ -575,9 +679,9 @@
575 679 $ret = wdk_mail( $owner_email, __('New Reservation Waiting For Approvement', 'wpdirectorykit'), $data_message, 'reservation_waiting_for_approve_owner');
576 680
577 681 /* waiting approve to client */
578 682 $ret = wdk_mail(wdk_show_data('user_email', $user_client, '' , TRUE, TRUE), __('Your reservation waiting approvement by owner', 'wpdirectorykit'), $data_message, 'reservation_waiting_for_approve_visitor');
579 -
683 +
580 684 if( $ret) {
581 685 add_filter( 'eli/ajax-handler/filter_output', function($filter_output){
582 686 $filter_output['message'] = '<div class="elementinvader_addons_for_elementor_alert elementinvader_addons_for_elementor_alert-success" role="alert">'.esc_html__('Thanks on reservation, after owner approvement you will receive details for payment', 'wpdirectorykit').'</div>';
583 687 return $filter_output;
@@ -585,9 +689,14 @@
585 689 }
586 690 else
587 691 {
588 692 add_filter( 'eli/ajax-handler/filter_output', function($filter_output) {
589 - $filter_output['message'] = '<div class="elementinvader_addons_for_elementor_alert elementinvader_addons_for_elementor_alert-danger" role="alert">'.esc_html__('Server can\'t send emails, please use SMTP mail configuration.', 'wpdirectorykit').'</div>';
693 + $filter_output['message'] = '<div class="elementinvader_addons_for_elementor_alert elementinvader_addons_for_elementor_alert-danger" role="alert">'. sprintf(
694 + /* translators: 1: Tag with link open, 2: close link tag. */
695 + esc_html__('Server can\'t send emails, please use SMTP mail configuration. Check %1$sGuide%2$s', 'wpdirectorykit'),
696 + '<a href="https://wpdirectorykit.com/e-mail-sending-issues-smtp-mail-configuration/" target="_blank" style="text-decoration: underline">',
697 + '</a>'
698 + ).'</div>';
590 699 $filter_output['no_clear_from'] = true;
591 700 return $filter_output;
592 701 } );
593 702 }
@@ -617,15 +726,19 @@
617 726 $data_mess= array();
618 727
619 728 foreach($_POST as $key => $value){
620 729 if($key=='element_id') continue;
621 - if(in_array($key, array('eli_id','eli_page_id', 'eli_type','ID','filter','action','send_action_type', 'page_link', 'g-recaptcha-response'))) continue;
730 + 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;
622 731
623 732 if(empty($value)) continue;
624 733
625 734 if(filter_var($value, FILTER_VALIDATE_URL ) || strpos( $value, 'http' ) !== FALSE) {
735 + // Dynamic field values are registered in the translation catalog separately.
736 +// phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
626 737 $data_mess []= '<p><strong>'.__(str_replace('_',' ', ucfirst($key)), 'wpdirectorykit').':</strong> <a href="'.esc_url($value).'">'.$value.'</a></p>';
627 738 } else {
739 + // Dynamic field values are registered in the translation catalog separately.
740 +// phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
628 741 $data_mess []= '<p><strong>'.__(str_replace('_',' ', ucfirst($key)), 'wpdirectorykit').':</strong> '.$value.'</p>';
629 742 }
630 743 }
631 744
@@ -634,8 +747,14 @@
634 747 $Winter_MVC_WDK->model('listing_m');
635 748 $Winter_MVC_WDK->load_helper('listing');
636 749 $data_listing = $Winter_MVC_WDK->listing_m->get($post_id, TRUE);
637 750
751 + if(function_exists('run_wdk_bookings')) {
752 + if(isset($_POST['date_from']) && isset($_POST['date_to']) && !empty($_POST['date_from']) && !empty($_POST['date_to'])) {
753 + $data_mess []= '<p><strong>'.__('Nights', 'wpdirectorykit').':</strong> '.wdk_calculate_nights(wdk_get_date($_POST['date_from']), wdk_get_date($_POST['date_to'])).'</p>';
754 + }
755 + }
756 +
638 757 /* message for user */
639 758 if (!empty($email)) {
640 759 $data_message = array();
641 760 $data_message['email_data'] = $data;
@@ -661,9 +780,9 @@
661 780 $data_message['email_data'] = $data;
662 781 $data_message['message'] = '';
663 782
664 783
665 - $message_title = __('New Message waiting', 'wpdirectorykit');
784 + $message_title = __('New Message', 'wpdirectorykit');
666 785
667 786 if(function_exists('run_wdk_bookings')) {
668 787
669 788 if(isset($_POST['date_from']) && isset($_POST['date_to']) && !empty($_POST['date_from']) && !empty($_POST['date_to'])) {
@@ -668,9 +787,9 @@
668 787
669 788 if(isset($_POST['date_from']) && isset($_POST['date_to']) && !empty($_POST['date_from']) && !empty($_POST['date_to'])) {
670 789 $data_message['message'] .= '<h2>'.__('Date reservation change to', 'wpdirectorykit').'</h2>';
671 790 $data_message['message'] .= '<p>'.__('Details from contact form', 'wpdirectorykit').'</p>';
672 -
791 +
673 792 $message_title = __('Contact message related to reservation on page', 'wpdirectorykit').' '.get_bloginfo('name');
674 793 }
675 794 }
676 795
@@ -686,11 +805,12 @@
686 805 $owner_email = $user_owner->user_email;
687 806 }
688 807
689 808 $ret = wdk_mail($owner_email, $message_title, $data_message, 'new_message', '', NULL, $email);
809 +
690 810 if( $ret) {
691 811 add_filter( 'eli/ajax-handler/filter_output', function($filter_output){
692 - $filter_output['message'] = '<div class="elementinvader_addons_for_elementor_alert elementinvader_addons_for_elementor_alert-success" role="alert">'.esc_html__('Thanks on message', 'wpdirectorykit').'</div>';
812 + $filter_output['message'] = '<div class="elementinvader_addons_for_elementor_alert elementinvader_addons_for_elementor_alert-success" role="alert">'.esc_html__('Thanks for the message.', 'wpdirectorykit').'</div>';
693 813 return $filter_output;
694 814 } );
695 815 add_filter( 'eli/ajax-handler/filter_from_data', function ($form_data = array()) {
696 816 /* disable double sent to admin mail */
@@ -701,9 +821,18 @@
701 821 }
702 822 else
703 823 {
704 824 add_filter( 'eli/ajax-handler/filter_output', function($filter_output) {
705 - $filter_output['message'] = '<div class="elementinvader_addons_for_elementor_alert elementinvader_addons_for_elementor_alert-danger" role="alert">'.esc_html__('Server can\'t send emails, please use SMTP mail configuration.', 'wpdirectorykit').'</div>';
825 + $filter_output['message'] = '<div class="elementinvader_addons_for_elementor_alert elementinvader_addons_for_elementor_alert-danger" role="alert">'.
826 + sprintf(
827 + /* translators: 1: Tag with link open, 2: close link tag. */
828 + esc_html__('Server can\'t send emails, please use SMTP mail configuration. Check %1$sGuide%2$s', 'wpdirectorykit'),
829 + '<a href="https://wpdirectorykit.com/e-mail-sending-issues-smtp-mail-configuration/" target="_blank" style="text-decoration: underline">',
830 + '</a>'
831 + )
832 + .'</div>';
833 +
834 +
706 835 $filter_output['success'] = false;
707 836 $filter_output['no_clear_from'] = true;
708 837 return $filter_output;
709 838 } );