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 +177 -40 1.2.4 → 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')/* && is_user_logged_in()*/) {
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') {
@@ -135,12 +158,17 @@
135 158
136 159 if(wmvc_show_data ('pets_allowed', $_POST, false))
137 160 $note .= '<b>'.__('Pets', 'wpdirectorykit').':</b> yes'.'<br>'.PHP_EOL;
138 161
139 - $note .= '<b>'.__('Name', 'wpdirectorykit').':</b> '.sanitize_text_field(wmvc_show_data ('Name', $_POST)).'<br>'.PHP_EOL;
140 - $note .= '<b>'.__('Email', 'wpdirectorykit').':</b> '.sanitize_text_field(wmvc_show_data ('Email', $_POST)).'<br>'.PHP_EOL;
141 - $note .= '<b>'.__('Message', 'wpdirectorykit').':</b> '.sanitize_text_field(wmvc_show_data ('Message', $_POST)).'<br>'.PHP_EOL;
162 + if(wmvc_show_data ('Name', $_POST, false))
163 + $note .= '<b>'.__('Name', 'wpdirectorykit').':</b> '.sanitize_text_field(wmvc_show_data ('Name', $_POST)).'<br>'.PHP_EOL;
142 164
165 + if(wmvc_show_data ('Email', $_POST, false))
166 + $note .= '<b>'.__('Email', 'wpdirectorykit').':</b> '.sanitize_text_field(wmvc_show_data ('Email', $_POST)).'<br>'.PHP_EOL;
167 +
168 + if(wmvc_show_data ('Message', $_POST, false))
169 + $note .= '<b>'.__('Message', 'wpdirectorykit').':</b> '.sanitize_text_field(wmvc_show_data ('Message', $_POST)).'<br>'.PHP_EOL;
170 +
143 171 if(wmvc_show_data ('Phone', $_POST, false))
144 172 $note .= '<b>'.__('Phone', 'wpdirectorykit').':</b> '.sanitize_text_field(wmvc_show_data ('Phone', $_POST)).'<br>'.PHP_EOL;
145 173
146 174 if(true)
@@ -145,18 +173,84 @@
145 173
146 174 if(true)
147 175 foreach($_POST as $key => $value) {
148 176 if($key=='element_id') continue;
149 - if(in_array($key, array('eli_page_id','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;
150 - if(in_array($key, array('listing_link','date_from','date_to','listing_id'))) continue;
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;
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;
151 179
152 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
153 183 $note .= '<b> '.__(str_replace('_',' ', ucfirst($key)), 'wpdirectorykit').':</b> <a href="'.esc_url($value).'">'.$value.'</a><br>';
154 184 } else {
185 + // Dynamic field values are registered in the translation catalog separately.
186 +// phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
155 187 $note .= '<b> '.__(str_replace('_',' ', ucfirst($key)), 'wpdirectorykit').':</b> '.$value.'<br>';
156 188 }
157 189 }
158 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 +
159 253 $data = array(
160 254 'post_id' => ($post_id),
161 255 'date_from' => ($date_from),
162 256 'date_to' => ($date_to),
@@ -171,9 +265,9 @@
171 265 if(wmvc_show_data('is_enable_noapprovements', $calendar, false))
172 266 $data['is_approved'] = 1;
173 267
174 268 $results = $Winter_MVC_wdk_bookings->reservation_m->is_booked($post_id, $date_from, $date_to);
175 - $errors = '';
269 +
176 270
177 271 $Winter_MVC_wdk_bookings->db->where("date_from <='".$date_from."'");
178 272 $Winter_MVC_wdk_bookings->db->where("date_to >= '".$date_to."'");
179 273 $price_reservation = $Winter_MVC_wdk_bookings->price_m->get_by(array('post_id'=>$post_id), TRUE);
@@ -207,10 +301,10 @@
207 301 '6'=>__('Saturday', 'wpdirectorykit'),
208 302 '7'=>__('Sunday', 'wpdirectorykit'),
209 303 );
210 304
211 - $day_num_from = date('N', strtotime($date_from));
212 - $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));
213 307
214 308 if(wmvc_show_data('changeover_day', $price_reservation, false, TRUE, TRUE) && (
215 309 wmvc_show_data('changeover_day', $price_reservation, false, TRUE, TRUE) != $day_num_from
216 310 || wmvc_show_data('changeover_day', $price_reservation, false, TRUE, TRUE) != $day_num_to
@@ -225,9 +319,11 @@
225 319 $period = '';
226 320 $min_hours = intval(wmvc_show_data('min_hours', $price_reservation, false, TRUE, TRUE));
227 321 if((int)($min_hours/24) >= 1) {
228 322 $days = (int)($min_hours/24);
229 - $period .= esc_html(sprintf(_nx(
323 + $period .= esc_html(sprintf(
324 + /* translators: 1: Number of days. */
325 + _nx(
230 326 '%1$s day',
231 327 '%1$s days',
232 328 $days,
233 329 'days',
@@ -237,9 +333,11 @@
237 333 $min_hours -= $days * 24;
238 334 }
239 335
240 336 if(!empty($min_hours)) {
241 - $period .= ' '.esc_html(sprintf(_nx(
337 + $period .= ' '.esc_html(sprintf(
338 + /* translators: 1: Number of hours. */
339 + _nx(
242 340 '%1$s hour',
243 341 '%1$s hours',
244 342 (int)($min_hours),
245 343 'hours',
@@ -254,9 +352,11 @@
254 352 $period = '';
255 353 $max_hours = intval(wmvc_show_data('max_hours', $price_reservation, false, TRUE, TRUE));
256 354 if((int)($max_hours/24) >= 1) {
257 355 $days = (int)($max_hours/24);
258 - $period .= esc_html(sprintf(_nx(
356 + $period .= esc_html(sprintf(
357 + /* translators: 1: Number of days. */
358 + _nx(
259 359 '%1$s day',
260 360 '%1$s days',
261 361 $days,
262 362 'days',
@@ -266,9 +366,11 @@
266 366 $max_hours -= $days * 24;
267 367 }
268 368
269 369 if(!empty($max_hours)) {
270 - $period .= ' '.esc_html(sprintf(_nx(
370 + $period .= ' '.esc_html(sprintf(
371 + /* translators: 1: Number of hours. */
372 + _nx(
271 373 '%1$s hour',
272 374 '%1$s hours',
273 375 (int)($max_hours),
274 376 'hours',
@@ -283,21 +385,23 @@
283 385 if( $results ) {
284 386 add_filter( 'eli/ajax-handler/filter_output', function($filter_output){
285 387 $filter_output['message'] = '<div class="elementinvader_addons_for_elementor_alert elementinvader_addons_for_elementor_alert-danger" role="alert">'.esc_html__('Date not available', 'wpdirectorykit').'</div>';
286 388 $filter_output['no_clear_from'] = true;
389 + $filter_output['success'] = false;
287 390 return $filter_output;
288 391 } );
289 392 } elseif( !empty($errors) ) {
290 393 add_filter( 'eli/ajax-handler/filter_output', function($filter_output) use ($errors) {
291 394 $filter_output['message'] = $errors;
395 + $filter_output['success'] = false;
292 396 $filter_output['no_clear_from'] = true;
293 397 return $filter_output;
294 398 } );
295 399 } else {
296 400
297 - if(!$calendar->is_hour_enabled && !empty($data['date_from']) && !empty($data['date_to'])) {
298 - $data['date_from'] = date('Y-m-d 00:00:00', strtotime($data['date_from']));
299 - $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']));
300 404 }
301 405 $insert_id = $Winter_MVC_wdk_bookings->reservation_m->insert($data, NULL);
302 406
303 407 /* auto is_enable_noapprovements enabled */
@@ -400,9 +504,9 @@
400 504 if(wdk_get_option(('wdk_bookings_time_for_payment'))) {
401 505 $data_message['hours_for_payment'] = intval(wdk_get_option(('wdk_bookings_time_for_payment')));
402 506
403 507 /* set date_expire for reservation */
404 - $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"))));
405 509 $Winter_MVC_wdk_bookings->reservation_m->insert($update_data, $insert_id);
406 510 }
407 511
408 512 wdk_mail(wdk_show_data('user_email', $data_message['user'], '' , TRUE, TRUE), __('Reservation waiting for payment', 'wpdirectorykit'), $data_message, 'reservation_user_payment_notify');
@@ -440,8 +544,9 @@
440 544 $data_message['data'] = array(
441 545 __('Reservation ID', 'wpdirectorykit')=> $insert_id,
442 546 __('Date From', 'wpdirectorykit')=> wdk_get_date($date_from),
443 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)),
444 549 );
445 550
446 551 $nights = (int)abs(strtotime($date_to) - strtotime($date_from))/(60*60*24);
447 552 $guests_number = intval(wmvc_show_data('guests_number_adults', $_POST, 0)) + intval(wmvc_show_data('guests_number_childs', $_POST, 0));
@@ -447,9 +552,9 @@
447 552 $guests_number = intval(wmvc_show_data('guests_number_adults', $_POST, 0)) + intval(wmvc_show_data('guests_number_childs', $_POST, 0));
448 553 foreach ($calendar_fees as $fee) {
449 554 if(!wmvc_show_data('is_activated', $fee, false,TRUE,TRUE)) continue;
450 555
451 - $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))));
452 557 if(!wmvc_show_data('is_required', $fee, false,TRUE,TRUE) && !isset($_POST['fee_'.$field])) {
453 558
454 559 } else {
455 560 if(wmvc_show_data('calculation_base', $fee,'',TRUE,TRUE) == 'per_night') {
@@ -481,9 +586,14 @@
481 586 }
482 587 else
483 588 {
484 589 add_filter( 'eli/ajax-handler/filter_output', function($filter_output) {
485 - $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>';
486 596 $filter_output['no_clear_from'] = true;
487 597 return $filter_output;
488 598 } );
489 599 }
@@ -518,8 +628,9 @@
518 628 $data_message['data'] = array(
519 629 __('Reservation ID', 'wpdirectorykit')=> $insert_id,
520 630 __('Date From', 'wpdirectorykit')=> wdk_get_date($date_from),
521 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)),
522 633 );
523 634 $nights = (int)abs(strtotime($date_to) - strtotime($date_from))/(60*60*24);
524 635 $guests_number = intval(wmvc_show_data('guests_number_adults', $_POST, 0)) + intval(wmvc_show_data('guests_number_childs', $_POST, 0));
525 636 foreach ($calendar_fees as $fee) {
@@ -524,9 +635,9 @@
524 635 $guests_number = intval(wmvc_show_data('guests_number_adults', $_POST, 0)) + intval(wmvc_show_data('guests_number_childs', $_POST, 0));
525 636 foreach ($calendar_fees as $fee) {
526 637 if(!wmvc_show_data('is_activated', $fee, false,TRUE,TRUE)) continue;
527 638
528 - $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))));
529 640 if(!wmvc_show_data('is_required', $fee, false,TRUE,TRUE) && !isset($_POST['fee_'.$field])) {
530 641
531 642 } else {
532 643 if(wmvc_show_data('calculation_base', $fee,'',TRUE,TRUE) == 'per_night') {
@@ -568,9 +679,9 @@
568 679 $ret = wdk_mail( $owner_email, __('New Reservation Waiting For Approvement', 'wpdirectorykit'), $data_message, 'reservation_waiting_for_approve_owner');
569 680
570 681 /* waiting approve to client */
571 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');
572 -
683 +
573 684 if( $ret) {
574 685 add_filter( 'eli/ajax-handler/filter_output', function($filter_output){
575 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>';
576 687 return $filter_output;
@@ -578,9 +689,14 @@
578 689 }
579 690 else
580 691 {
581 692 add_filter( 'eli/ajax-handler/filter_output', function($filter_output) {
582 - $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>';
583 699 $filter_output['no_clear_from'] = true;
584 700 return $filter_output;
585 701 } );
586 702 }
@@ -610,15 +726,19 @@
610 726 $data_mess= array();
611 727
612 728 foreach($_POST as $key => $value){
613 729 if($key=='element_id') continue;
614 - if(in_array($key, array('eli_id','eli_page_id', 'eli_type','ID','filter','action','send_action_type', 'page_link'))) 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;
615 731
616 732 if(empty($value)) continue;
617 733
618 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
619 737 $data_mess []= '<p><strong>'.__(str_replace('_',' ', ucfirst($key)), 'wpdirectorykit').':</strong> <a href="'.esc_url($value).'">'.$value.'</a></p>';
620 738 } else {
739 + // Dynamic field values are registered in the translation catalog separately.
740 +// phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
621 741 $data_mess []= '<p><strong>'.__(str_replace('_',' ', ucfirst($key)), 'wpdirectorykit').':</strong> '.$value.'</p>';
622 742 }
623 743 }
624 744
@@ -627,8 +747,14 @@
627 747 $Winter_MVC_WDK->model('listing_m');
628 748 $Winter_MVC_WDK->load_helper('listing');
629 749 $data_listing = $Winter_MVC_WDK->listing_m->get($post_id, TRUE);
630 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 +
631 757 /* message for user */
632 758 if (!empty($email)) {
633 759 $data_message = array();
634 760 $data_message['email_data'] = $data;
@@ -654,9 +780,9 @@
654 780 $data_message['email_data'] = $data;
655 781 $data_message['message'] = '';
656 782
657 783
658 - $message_title = __('New Message waiting', 'wpdirectorykit');
784 + $message_title = __('New Message', 'wpdirectorykit');
659 785
660 786 if(function_exists('run_wdk_bookings')) {
661 787
662 788 if(isset($_POST['date_from']) && isset($_POST['date_to']) && !empty($_POST['date_from']) && !empty($_POST['date_to'])) {
@@ -661,9 +787,9 @@
661 787
662 788 if(isset($_POST['date_from']) && isset($_POST['date_to']) && !empty($_POST['date_from']) && !empty($_POST['date_to'])) {
663 789 $data_message['message'] .= '<h2>'.__('Date reservation change to', 'wpdirectorykit').'</h2>';
664 790 $data_message['message'] .= '<p>'.__('Details from contact form', 'wpdirectorykit').'</p>';
665 -
791 +
666 792 $message_title = __('Contact message related to reservation on page', 'wpdirectorykit').' '.get_bloginfo('name');
667 793 }
668 794 }
669 795
@@ -679,11 +805,12 @@
679 805 $owner_email = $user_owner->user_email;
680 806 }
681 807
682 808 $ret = wdk_mail($owner_email, $message_title, $data_message, 'new_message', '', NULL, $email);
809 +
683 810 if( $ret) {
684 811 add_filter( 'eli/ajax-handler/filter_output', function($filter_output){
685 - $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>';
686 813 return $filter_output;
687 814 } );
688 815 add_filter( 'eli/ajax-handler/filter_from_data', function ($form_data = array()) {
689 816 /* disable double sent to admin mail */
@@ -694,9 +821,19 @@
694 821 }
695 822 else
696 823 {
697 824 add_filter( 'eli/ajax-handler/filter_output', function($filter_output) {
698 - $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 +
835 + $filter_output['success'] = false;
699 836 $filter_output['no_clear_from'] = true;
700 837 return $filter_output;
701 838 } );
702 839 }