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 +86 -30 1.3.0 → 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 }
@@ -65,9 +70,9 @@
65 70 if (stripos($key, 'wdk_widget') !== false) {
66 71 $wdk_widget = sanitize_text_field($value);
67 72 }
68 73 if (stripos($key, 'listing_id') !== false) {
69 - $post_id = sanitize_text_field($value);
74 + $post_id = (int)sanitize_text_field($value);
70 75 }
71 76 }
72 77
73 78 if(function_exists('run_wdk_bookings') && (
@@ -80,12 +85,20 @@
80 85 if(isset($_POST['date_from']) && isset($_POST['date_to']) && !empty($_POST['date_from']) && !empty($_POST['date_to'])) {
81 86 $date_from = sanitize_text_field($_POST['date_from']);
82 87 $date_to = sanitize_text_field($_POST['date_to']);
83 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
84 96
97 +
85 98 if(wdk_is_date($date_from))
86 99 {
87 - $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');
88 101 }
89 102 else
90 103 {
91 104 return false;
@@ -92,9 +105,9 @@
92 105 }
93 106
94 107 if(wdk_is_date($date_to))
95 108 {
96 - $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');
97 110 }
98 111 else
99 112 {
100 113 return false;
@@ -99,16 +112,14 @@
99 112 {
100 113 return false;
101 114 }
102 115
103 - global $Winter_MVC_wdk_bookings;
104 - $Winter_MVC_wdk_bookings->model('reservation_m');
105 - $Winter_MVC_wdk_bookings->model('calendar_m');
106 - $Winter_MVC_wdk_bookings->model('price_m');
107 116
108 117 /* message data */
118 +
119 +
109 120 $price = $Winter_MVC_wdk_bookings->reservation_m->calculate_price($post_id, $date_from, $date_to);
110 - $calendar = $Winter_MVC_wdk_bookings->calendar_m->get_by(array('post_id'=>$post_id), TRUE); // date_package_expire package_id
121 +
111 122 $calendar_fees = array();
112 123 if($calendar && !empty($calendar->json_data_fees))
113 124 $calendar_fees = json_decode($calendar->json_data_fees );
114 125
@@ -163,13 +174,17 @@
163 174 if(true)
164 175 foreach($_POST as $key => $value) {
165 176 if($key=='element_id') continue;
166 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;
167 - if(in_array($key, array('listing_link','date_from','date_to','listing_id','wdk_widget', 'function','page'))) 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;
168 179
169 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
170 183 $note .= '<b> '.__(str_replace('_',' ', ucfirst($key)), 'wpdirectorykit').':</b> <a href="'.esc_url($value).'">'.$value.'</a><br>';
171 184 } else {
185 + // Dynamic field values are registered in the translation catalog separately.
186 +// phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
172 187 $note .= '<b> '.__(str_replace('_',' ', ucfirst($key)), 'wpdirectorykit').':</b> '.$value.'<br>';
173 188 }
174 189 }
175 190
@@ -207,9 +222,9 @@
207 222 wp_update_user( array ('ID' => $user_id, 'display_name' => esc_html( $username ) ) );
208 223
209 224 $userdata = get_userdata($user_id);
210 225
211 - $subject = __('New user on our website!', 'wdk-membership');
226 + $subject = __('New user on our website!', 'wpdirectorykit');
212 227 $data_message = array();
213 228 $data_message['login'] = $userlogin;
214 229 $data_message['password'] = $password;
215 230 $data_message['user'] = $userdata;
@@ -224,8 +239,9 @@
224 239 wp_set_auth_cookie($user_id);
225 240
226 241 } elseif($user = get_user_by( 'email', $email_address)) {
227 242 $user_id = $user->ID;
243 + /* translators: 1: User email address. */
228 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>';
229 245 } else {
230 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>';
231 247 }
@@ -285,10 +301,10 @@
285 301 '6'=>__('Saturday', 'wpdirectorykit'),
286 302 '7'=>__('Sunday', 'wpdirectorykit'),
287 303 );
288 304
289 - $day_num_from = date('N', strtotime($date_from));
290 - $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));
291 307
292 308 if(wmvc_show_data('changeover_day', $price_reservation, false, TRUE, TRUE) && (
293 309 wmvc_show_data('changeover_day', $price_reservation, false, TRUE, TRUE) != $day_num_from
294 310 || wmvc_show_data('changeover_day', $price_reservation, false, TRUE, TRUE) != $day_num_to
@@ -303,9 +319,11 @@
303 319 $period = '';
304 320 $min_hours = intval(wmvc_show_data('min_hours', $price_reservation, false, TRUE, TRUE));
305 321 if((int)($min_hours/24) >= 1) {
306 322 $days = (int)($min_hours/24);
307 - $period .= esc_html(sprintf(_nx(
323 + $period .= esc_html(sprintf(
324 + /* translators: 1: Number of days. */
325 + _nx(
308 326 '%1$s day',
309 327 '%1$s days',
310 328 $days,
311 329 'days',
@@ -315,9 +333,11 @@
315 333 $min_hours -= $days * 24;
316 334 }
317 335
318 336 if(!empty($min_hours)) {
319 - $period .= ' '.esc_html(sprintf(_nx(
337 + $period .= ' '.esc_html(sprintf(
338 + /* translators: 1: Number of hours. */
339 + _nx(
320 340 '%1$s hour',
321 341 '%1$s hours',
322 342 (int)($min_hours),
323 343 'hours',
@@ -332,9 +352,11 @@
332 352 $period = '';
333 353 $max_hours = intval(wmvc_show_data('max_hours', $price_reservation, false, TRUE, TRUE));
334 354 if((int)($max_hours/24) >= 1) {
335 355 $days = (int)($max_hours/24);
336 - $period .= esc_html(sprintf(_nx(
356 + $period .= esc_html(sprintf(
357 + /* translators: 1: Number of days. */
358 + _nx(
337 359 '%1$s day',
338 360 '%1$s days',
339 361 $days,
340 362 'days',
@@ -344,9 +366,11 @@
344 366 $max_hours -= $days * 24;
345 367 }
346 368
347 369 if(!empty($max_hours)) {
348 - $period .= ' '.esc_html(sprintf(_nx(
370 + $period .= ' '.esc_html(sprintf(
371 + /* translators: 1: Number of hours. */
372 + _nx(
349 373 '%1$s hour',
350 374 '%1$s hours',
351 375 (int)($max_hours),
352 376 'hours',
@@ -374,10 +398,10 @@
374 398 } );
375 399 } else {
376 400
377 401 if(wmvc_show_data('is_hour_enabled', $calendar, false) && !empty($data['date_from']) && !empty($data['date_to'])) {
378 - $data['date_from'] = date('Y-m-d 00:00:00', strtotime($data['date_from']));
379 - $data['date_to'] = date('Y-m-d 00:00:00', strtotime($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']));
380 404 }
381 405 $insert_id = $Winter_MVC_wdk_bookings->reservation_m->insert($data, NULL);
382 406
383 407 /* auto is_enable_noapprovements enabled */
@@ -480,9 +504,9 @@
480 504 if(wdk_get_option(('wdk_bookings_time_for_payment'))) {
481 505 $data_message['hours_for_payment'] = intval(wdk_get_option(('wdk_bookings_time_for_payment')));
482 506
483 507 /* set date_expire for reservation */
484 - $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"))));
485 509 $Winter_MVC_wdk_bookings->reservation_m->insert($update_data, $insert_id);
486 510 }
487 511
488 512 wdk_mail(wdk_show_data('user_email', $data_message['user'], '' , TRUE, TRUE), __('Reservation waiting for payment', 'wpdirectorykit'), $data_message, 'reservation_user_payment_notify');
@@ -520,8 +544,9 @@
520 544 $data_message['data'] = array(
521 545 __('Reservation ID', 'wpdirectorykit')=> $insert_id,
522 546 __('Date From', 'wpdirectorykit')=> wdk_get_date($date_from),
523 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)),
524 549 );
525 550
526 551 $nights = (int)abs(strtotime($date_to) - strtotime($date_from))/(60*60*24);
527 552 $guests_number = intval(wmvc_show_data('guests_number_adults', $_POST, 0)) + intval(wmvc_show_data('guests_number_childs', $_POST, 0));
@@ -561,9 +586,14 @@
561 586 }
562 587 else
563 588 {
564 589 add_filter( 'eli/ajax-handler/filter_output', function($filter_output) {
565 - $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>';
566 596 $filter_output['no_clear_from'] = true;
567 597 return $filter_output;
568 598 } );
569 599 }
@@ -598,8 +628,9 @@
598 628 $data_message['data'] = array(
599 629 __('Reservation ID', 'wpdirectorykit')=> $insert_id,
600 630 __('Date From', 'wpdirectorykit')=> wdk_get_date($date_from),
601 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)),
602 633 );
603 634 $nights = (int)abs(strtotime($date_to) - strtotime($date_from))/(60*60*24);
604 635 $guests_number = intval(wmvc_show_data('guests_number_adults', $_POST, 0)) + intval(wmvc_show_data('guests_number_childs', $_POST, 0));
605 636 foreach ($calendar_fees as $fee) {
@@ -648,9 +679,9 @@
648 679 $ret = wdk_mail( $owner_email, __('New Reservation Waiting For Approvement', 'wpdirectorykit'), $data_message, 'reservation_waiting_for_approve_owner');
649 680
650 681 /* waiting approve to client */
651 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');
652 -
683 +
653 684 if( $ret) {
654 685 add_filter( 'eli/ajax-handler/filter_output', function($filter_output){
655 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>';
656 687 return $filter_output;
@@ -658,9 +689,14 @@
658 689 }
659 690 else
660 691 {
661 692 add_filter( 'eli/ajax-handler/filter_output', function($filter_output) {
662 - $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>';
663 699 $filter_output['no_clear_from'] = true;
664 700 return $filter_output;
665 701 } );
666 702 }
@@ -690,15 +726,19 @@
690 726 $data_mess= array();
691 727
692 728 foreach($_POST as $key => $value){
693 729 if($key=='element_id') continue;
694 - 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;
695 731
696 732 if(empty($value)) continue;
697 733
698 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
699 737 $data_mess []= '<p><strong>'.__(str_replace('_',' ', ucfirst($key)), 'wpdirectorykit').':</strong> <a href="'.esc_url($value).'">'.$value.'</a></p>';
700 738 } else {
739 + // Dynamic field values are registered in the translation catalog separately.
740 +// phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
701 741 $data_mess []= '<p><strong>'.__(str_replace('_',' ', ucfirst($key)), 'wpdirectorykit').':</strong> '.$value.'</p>';
702 742 }
703 743 }
704 744
@@ -707,8 +747,14 @@
707 747 $Winter_MVC_WDK->model('listing_m');
708 748 $Winter_MVC_WDK->load_helper('listing');
709 749 $data_listing = $Winter_MVC_WDK->listing_m->get($post_id, TRUE);
710 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 +
711 757 /* message for user */
712 758 if (!empty($email)) {
713 759 $data_message = array();
714 760 $data_message['email_data'] = $data;
@@ -734,9 +780,9 @@
734 780 $data_message['email_data'] = $data;
735 781 $data_message['message'] = '';
736 782
737 783
738 - $message_title = __('New Message waiting', 'wpdirectorykit');
784 + $message_title = __('New Message', 'wpdirectorykit');
739 785
740 786 if(function_exists('run_wdk_bookings')) {
741 787
742 788 if(isset($_POST['date_from']) && isset($_POST['date_to']) && !empty($_POST['date_from']) && !empty($_POST['date_to'])) {
@@ -741,9 +787,9 @@
741 787
742 788 if(isset($_POST['date_from']) && isset($_POST['date_to']) && !empty($_POST['date_from']) && !empty($_POST['date_to'])) {
743 789 $data_message['message'] .= '<h2>'.__('Date reservation change to', 'wpdirectorykit').'</h2>';
744 790 $data_message['message'] .= '<p>'.__('Details from contact form', 'wpdirectorykit').'</p>';
745 -
791 +
746 792 $message_title = __('Contact message related to reservation on page', 'wpdirectorykit').' '.get_bloginfo('name');
747 793 }
748 794 }
749 795
@@ -759,11 +805,12 @@
759 805 $owner_email = $user_owner->user_email;
760 806 }
761 807
762 808 $ret = wdk_mail($owner_email, $message_title, $data_message, 'new_message', '', NULL, $email);
809 +
763 810 if( $ret) {
764 811 add_filter( 'eli/ajax-handler/filter_output', function($filter_output){
765 - $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>';
766 813 return $filter_output;
767 814 } );
768 815 add_filter( 'eli/ajax-handler/filter_from_data', function ($form_data = array()) {
769 816 /* disable double sent to admin mail */
@@ -774,9 +821,18 @@
774 821 }
775 822 else
776 823 {
777 824 add_filter( 'eli/ajax-handler/filter_output', function($filter_output) {
778 - $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 +
779 835 $filter_output['success'] = false;
780 836 $filter_output['no_clear_from'] = true;
781 837 return $filter_output;
782 838 } );