| @@ -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') && ( |
| @@ -169,13 +174,17 @@ | ||
| 169 | 174 | if(true) |
| 170 | 175 | foreach($_POST as $key => $value) { |
| 171 | 176 | if($key=='element_id') continue; |
| 172 | 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; |
| 173 | - 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; | |
| 174 | 179 | |
| 175 | 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 | |
| 176 | 183 | $note .= '<b> '.__(str_replace('_',' ', ucfirst($key)), 'wpdirectorykit').':</b> <a href="'.esc_url($value).'">'.$value.'</a><br>'; |
| 177 | 184 | } else { |
| 185 | + // Dynamic field values are registered in the translation catalog separately. | |
| 186 | +// phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText | |
| 178 | 187 | $note .= '<b> '.__(str_replace('_',' ', ucfirst($key)), 'wpdirectorykit').':</b> '.$value.'<br>'; |
| 179 | 188 | } |
| 180 | 189 | } |
| 181 | 190 | |
| @@ -213,9 +222,9 @@ | ||
| 213 | 222 | wp_update_user( array ('ID' => $user_id, 'display_name' => esc_html( $username ) ) ); |
| 214 | 223 | |
| 215 | 224 | $userdata = get_userdata($user_id); |
| 216 | 225 | |
| 217 | - $subject = __('New user on our website!', 'wdk-membership'); | |
| 226 | + $subject = __('New user on our website!', 'wpdirectorykit'); | |
| 218 | 227 | $data_message = array(); |
| 219 | 228 | $data_message['login'] = $userlogin; |
| 220 | 229 | $data_message['password'] = $password; |
| 221 | 230 | $data_message['user'] = $userdata; |
| @@ -230,8 +239,9 @@ | ||
| 230 | 239 | wp_set_auth_cookie($user_id); |
| 231 | 240 | |
| 232 | 241 | } elseif($user = get_user_by( 'email', $email_address)) { |
| 233 | 242 | $user_id = $user->ID; |
| 243 | + /* translators: 1: User email address. */ | |
| 234 | 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>'; |
| 235 | 245 | } else { |
| 236 | 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>'; |
| 237 | 247 | } |
| @@ -291,10 +301,10 @@ | ||
| 291 | 301 | '6'=>__('Saturday', 'wpdirectorykit'), |
| 292 | 302 | '7'=>__('Sunday', 'wpdirectorykit'), |
| 293 | 303 | ); |
| 294 | 304 | |
| 295 | - $day_num_from = date('N', strtotime($date_from)); | |
| 296 | - $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)); | |
| 297 | 307 | |
| 298 | 308 | if(wmvc_show_data('changeover_day', $price_reservation, false, TRUE, TRUE) && ( |
| 299 | 309 | wmvc_show_data('changeover_day', $price_reservation, false, TRUE, TRUE) != $day_num_from |
| 300 | 310 | || wmvc_show_data('changeover_day', $price_reservation, false, TRUE, TRUE) != $day_num_to |
| @@ -309,9 +319,11 @@ | ||
| 309 | 319 | $period = ''; |
| 310 | 320 | $min_hours = intval(wmvc_show_data('min_hours', $price_reservation, false, TRUE, TRUE)); |
| 311 | 321 | if((int)($min_hours/24) >= 1) { |
| 312 | 322 | $days = (int)($min_hours/24); |
| 313 | - $period .= esc_html(sprintf(_nx( | |
| 323 | + $period .= esc_html(sprintf( | |
| 324 | + /* translators: 1: Number of days. */ | |
| 325 | + _nx( | |
| 314 | 326 | '%1$s day', |
| 315 | 327 | '%1$s days', |
| 316 | 328 | $days, |
| 317 | 329 | 'days', |
| @@ -321,9 +333,11 @@ | ||
| 321 | 333 | $min_hours -= $days * 24; |
| 322 | 334 | } |
| 323 | 335 | |
| 324 | 336 | if(!empty($min_hours)) { |
| 325 | - $period .= ' '.esc_html(sprintf(_nx( | |
| 337 | + $period .= ' '.esc_html(sprintf( | |
| 338 | + /* translators: 1: Number of hours. */ | |
| 339 | + _nx( | |
| 326 | 340 | '%1$s hour', |
| 327 | 341 | '%1$s hours', |
| 328 | 342 | (int)($min_hours), |
| 329 | 343 | 'hours', |
| @@ -338,9 +352,11 @@ | ||
| 338 | 352 | $period = ''; |
| 339 | 353 | $max_hours = intval(wmvc_show_data('max_hours', $price_reservation, false, TRUE, TRUE)); |
| 340 | 354 | if((int)($max_hours/24) >= 1) { |
| 341 | 355 | $days = (int)($max_hours/24); |
| 342 | - $period .= esc_html(sprintf(_nx( | |
| 356 | + $period .= esc_html(sprintf( | |
| 357 | + /* translators: 1: Number of days. */ | |
| 358 | + _nx( | |
| 343 | 359 | '%1$s day', |
| 344 | 360 | '%1$s days', |
| 345 | 361 | $days, |
| 346 | 362 | 'days', |
| @@ -350,9 +366,11 @@ | ||
| 350 | 366 | $max_hours -= $days * 24; |
| 351 | 367 | } |
| 352 | 368 | |
| 353 | 369 | if(!empty($max_hours)) { |
| 354 | - $period .= ' '.esc_html(sprintf(_nx( | |
| 370 | + $period .= ' '.esc_html(sprintf( | |
| 371 | + /* translators: 1: Number of hours. */ | |
| 372 | + _nx( | |
| 355 | 373 | '%1$s hour', |
| 356 | 374 | '%1$s hours', |
| 357 | 375 | (int)($max_hours), |
| 358 | 376 | 'hours', |
| @@ -380,10 +398,10 @@ | ||
| 380 | 398 | } ); |
| 381 | 399 | } else { |
| 382 | 400 | |
| 383 | 401 | if(wmvc_show_data('is_hour_enabled', $calendar, false) && !empty($data['date_from']) && !empty($data['date_to'])) { |
| 384 | - $data['date_from'] = date('Y-m-d 00:00:00', strtotime($data['date_from'])); | |
| 385 | - $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'])); | |
| 386 | 404 | } |
| 387 | 405 | $insert_id = $Winter_MVC_wdk_bookings->reservation_m->insert($data, NULL); |
| 388 | 406 | |
| 389 | 407 | /* auto is_enable_noapprovements enabled */ |
| @@ -486,9 +504,9 @@ | ||
| 486 | 504 | if(wdk_get_option(('wdk_bookings_time_for_payment'))) { |
| 487 | 505 | $data_message['hours_for_payment'] = intval(wdk_get_option(('wdk_bookings_time_for_payment'))); |
| 488 | 506 | |
| 489 | 507 | /* set date_expire for reservation */ |
| 490 | - $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")))); | |
| 491 | 509 | $Winter_MVC_wdk_bookings->reservation_m->insert($update_data, $insert_id); |
| 492 | 510 | } |
| 493 | 511 | |
| 494 | 512 | wdk_mail(wdk_show_data('user_email', $data_message['user'], '' , TRUE, TRUE), __('Reservation waiting for payment', 'wpdirectorykit'), $data_message, 'reservation_user_payment_notify'); |
| @@ -526,8 +544,9 @@ | ||
| 526 | 544 | $data_message['data'] = array( |
| 527 | 545 | __('Reservation ID', 'wpdirectorykit')=> $insert_id, |
| 528 | 546 | __('Date From', 'wpdirectorykit')=> wdk_get_date($date_from), |
| 529 | 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)), | |
| 530 | 549 | ); |
| 531 | 550 | |
| 532 | 551 | $nights = (int)abs(strtotime($date_to) - strtotime($date_from))/(60*60*24); |
| 533 | 552 | $guests_number = intval(wmvc_show_data('guests_number_adults', $_POST, 0)) + intval(wmvc_show_data('guests_number_childs', $_POST, 0)); |
| @@ -567,9 +586,14 @@ | ||
| 567 | 586 | } |
| 568 | 587 | else |
| 569 | 588 | { |
| 570 | 589 | add_filter( 'eli/ajax-handler/filter_output', function($filter_output) { |
| 571 | - $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>'; | |
| 572 | 596 | $filter_output['no_clear_from'] = true; |
| 573 | 597 | return $filter_output; |
| 574 | 598 | } ); |
| 575 | 599 | } |
| @@ -604,8 +628,9 @@ | ||
| 604 | 628 | $data_message['data'] = array( |
| 605 | 629 | __('Reservation ID', 'wpdirectorykit')=> $insert_id, |
| 606 | 630 | __('Date From', 'wpdirectorykit')=> wdk_get_date($date_from), |
| 607 | 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)), | |
| 608 | 633 | ); |
| 609 | 634 | $nights = (int)abs(strtotime($date_to) - strtotime($date_from))/(60*60*24); |
| 610 | 635 | $guests_number = intval(wmvc_show_data('guests_number_adults', $_POST, 0)) + intval(wmvc_show_data('guests_number_childs', $_POST, 0)); |
| 611 | 636 | foreach ($calendar_fees as $fee) { |
| @@ -654,9 +679,9 @@ | ||
| 654 | 679 | $ret = wdk_mail( $owner_email, __('New Reservation Waiting For Approvement', 'wpdirectorykit'), $data_message, 'reservation_waiting_for_approve_owner'); |
| 655 | 680 | |
| 656 | 681 | /* waiting approve to client */ |
| 657 | 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'); |
| 658 | - | |
| 683 | + | |
| 659 | 684 | if( $ret) { |
| 660 | 685 | add_filter( 'eli/ajax-handler/filter_output', function($filter_output){ |
| 661 | 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>'; |
| 662 | 687 | return $filter_output; |
| @@ -664,9 +689,14 @@ | ||
| 664 | 689 | } |
| 665 | 690 | else |
| 666 | 691 | { |
| 667 | 692 | add_filter( 'eli/ajax-handler/filter_output', function($filter_output) { |
| 668 | - $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>'; | |
| 669 | 699 | $filter_output['no_clear_from'] = true; |
| 670 | 700 | return $filter_output; |
| 671 | 701 | } ); |
| 672 | 702 | } |
| @@ -696,15 +726,19 @@ | ||
| 696 | 726 | $data_mess= array(); |
| 697 | 727 | |
| 698 | 728 | foreach($_POST as $key => $value){ |
| 699 | 729 | 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; | |
| 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; | |
| 701 | 731 | |
| 702 | 732 | if(empty($value)) continue; |
| 703 | 733 | |
| 704 | 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 | |
| 705 | 737 | $data_mess []= '<p><strong>'.__(str_replace('_',' ', ucfirst($key)), 'wpdirectorykit').':</strong> <a href="'.esc_url($value).'">'.$value.'</a></p>'; |
| 706 | 738 | } else { |
| 739 | + // Dynamic field values are registered in the translation catalog separately. | |
| 740 | +// phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText | |
| 707 | 741 | $data_mess []= '<p><strong>'.__(str_replace('_',' ', ucfirst($key)), 'wpdirectorykit').':</strong> '.$value.'</p>'; |
| 708 | 742 | } |
| 709 | 743 | } |
| 710 | 744 | |
| @@ -713,8 +747,14 @@ | ||
| 713 | 747 | $Winter_MVC_WDK->model('listing_m'); |
| 714 | 748 | $Winter_MVC_WDK->load_helper('listing'); |
| 715 | 749 | $data_listing = $Winter_MVC_WDK->listing_m->get($post_id, TRUE); |
| 716 | 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 | + | |
| 717 | 757 | /* message for user */ |
| 718 | 758 | if (!empty($email)) { |
| 719 | 759 | $data_message = array(); |
| 720 | 760 | $data_message['email_data'] = $data; |
| @@ -747,9 +787,9 @@ | ||
| 747 | 787 | |
| 748 | 788 | if(isset($_POST['date_from']) && isset($_POST['date_to']) && !empty($_POST['date_from']) && !empty($_POST['date_to'])) { |
| 749 | 789 | $data_message['message'] .= '<h2>'.__('Date reservation change to', 'wpdirectorykit').'</h2>'; |
| 750 | 790 | $data_message['message'] .= '<p>'.__('Details from contact form', 'wpdirectorykit').'</p>'; |
| 751 | - | |
| 791 | + | |
| 752 | 792 | $message_title = __('Contact message related to reservation on page', 'wpdirectorykit').' '.get_bloginfo('name'); |
| 753 | 793 | } |
| 754 | 794 | } |
| 755 | 795 | |
| @@ -765,11 +805,12 @@ | ||
| 765 | 805 | $owner_email = $user_owner->user_email; |
| 766 | 806 | } |
| 767 | 807 | |
| 768 | 808 | $ret = wdk_mail($owner_email, $message_title, $data_message, 'new_message', '', NULL, $email); |
| 809 | + | |
| 769 | 810 | if( $ret) { |
| 770 | 811 | add_filter( 'eli/ajax-handler/filter_output', function($filter_output){ |
| 771 | - $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>'; | |
| 772 | 813 | return $filter_output; |
| 773 | 814 | } ); |
| 774 | 815 | add_filter( 'eli/ajax-handler/filter_from_data', function ($form_data = array()) { |
| 775 | 816 | /* disable double sent to admin mail */ |
| @@ -780,9 +821,18 @@ | ||
| 780 | 821 | } |
| 781 | 822 | else |
| 782 | 823 | { |
| 783 | 824 | add_filter( 'eli/ajax-handler/filter_output', function($filter_output) { |
| 784 | - $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 | + | |
| 785 | 835 | $filter_output['success'] = false; |
| 786 | 836 | $filter_output['no_clear_from'] = true; |
| 787 | 837 | return $filter_output; |
| 788 | 838 | } ); |