| @@ -9,14 +9,14 @@ | ||
| 9 | 9 | * |
| 10 | 10 | * @var array |
| 11 | 11 | */ |
| 12 | 12 | protected $data = array(); |
| 13 | + public $_translate_strings = array(); | |
| 13 | 14 | protected $WMVC = NULL; |
| 14 | 15 | |
| 15 | - public function __construct($data = array(), $args = null) { | |
| 16 | - add_action( 'eli/ajax-handler/after', array( $this, 'after' ) ); | |
| 17 | - add_filter( 'eli/ajax-handler/filter_from_data', array( $this, 'filter_from_data' ) ); | |
| 18 | 16 | |
| 17 | + public function helper_transalte_strings($data = array(), $args = null) { | |
| 18 | + | |
| 19 | 19 | $this->_translate_strings = array( |
| 20 | 20 | __('Guests number', 'wpdirectorykit'), |
| 21 | 21 | __('Listing link', 'wpdirectorykit'), |
| 22 | 22 | __('Name', 'wpdirectorykit'), |
| @@ -24,8 +24,15 @@ | ||
| 24 | 24 | __('Date to', 'wpdirectorykit'), |
| 25 | 25 | ); |
| 26 | 26 | } |
| 27 | 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 | + | |
| 28 | 35 | public function filter_output ($filter_output = array()) { |
| 29 | 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>'; |
| 30 | 37 | return $filter_output; |
| 31 | 38 | } |
| @@ -42,8 +49,9 @@ | ||
| 42 | 49 | return $form_data; |
| 43 | 50 | } |
| 44 | 51 | |
| 45 | 52 | public function after ($form_data = array()) { |
| 53 | + | |
| 46 | 54 | $this->WMVC = &wdk_get_instance(); |
| 47 | 55 | $this->WMVC->model('messages_m'); |
| 48 | 56 | |
| 49 | 57 | $message_skip = false; |
| @@ -50,8 +58,9 @@ | ||
| 50 | 58 | |
| 51 | 59 | $email = ''; |
| 52 | 60 | $message = ''; |
| 53 | 61 | $post_id = ''; |
| 62 | + $wdk_widget = ''; | |
| 54 | 63 | foreach ($_POST as $key => $value) { |
| 55 | 64 | if (stripos($key, 'mail') !== false || filter_var($value, FILTER_VALIDATE_EMAIL)) { |
| 56 | 65 | $email = sanitize_email($value); |
| 57 | 66 | } |
| @@ -57,21 +66,39 @@ | ||
| 57 | 66 | } |
| 58 | 67 | if (stripos($key, 'message') !== false) { |
| 59 | 68 | $message = sanitize_text_field($value); |
| 60 | 69 | } |
| 70 | + if (stripos($key, 'wdk_widget') !== false) { | |
| 71 | + $wdk_widget = sanitize_text_field($value); | |
| 72 | + } | |
| 61 | 73 | if (stripos($key, 'listing_id') !== false) { |
| 62 | - $post_id = sanitize_text_field($value); | |
| 74 | + $post_id = (int)sanitize_text_field($value); | |
| 63 | 75 | } |
| 64 | 76 | } |
| 65 | - | |
| 66 | - 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 | + ) { | |
| 67 | 85 | if(isset($_POST['date_from']) && isset($_POST['date_to']) && !empty($_POST['date_from']) && !empty($_POST['date_to'])) { |
| 68 | 86 | $date_from = sanitize_text_field($_POST['date_from']); |
| 69 | 87 | $date_to = sanitize_text_field($_POST['date_to']); |
| 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 | |
| 70 | 96 | |
| 97 | + | |
| 71 | 98 | if(wdk_is_date($date_from)) |
| 72 | 99 | { |
| 73 | - $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'); | |
| 74 | 101 | } |
| 75 | 102 | else |
| 76 | 103 | { |
| 77 | 104 | return false; |
| @@ -78,9 +105,9 @@ | ||
| 78 | 105 | } |
| 79 | 106 | |
| 80 | 107 | if(wdk_is_date($date_to)) |
| 81 | 108 | { |
| 82 | - $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'); | |
| 83 | 110 | } |
| 84 | 111 | else |
| 85 | 112 | { |
| 86 | 113 | return false; |
| @@ -85,16 +112,14 @@ | ||
| 85 | 112 | { |
| 86 | 113 | return false; |
| 87 | 114 | } |
| 88 | 115 | |
| 89 | - global $Winter_MVC_wdk_bookings; | |
| 90 | - $Winter_MVC_wdk_bookings->model('reservation_m'); | |
| 91 | - $Winter_MVC_wdk_bookings->model('calendar_m'); | |
| 92 | - $Winter_MVC_wdk_bookings->model('price_m'); | |
| 93 | 116 | |
| 94 | 117 | /* message data */ |
| 118 | + | |
| 119 | + | |
| 95 | 120 | $price = $Winter_MVC_wdk_bookings->reservation_m->calculate_price($post_id, $date_from, $date_to); |
| 96 | - $calendar = $Winter_MVC_wdk_bookings->calendar_m->get_by(array('post_id'=>$post_id), TRUE); // date_package_expire package_id | |
| 121 | + | |
| 97 | 122 | $calendar_fees = array(); |
| 98 | 123 | if($calendar && !empty($calendar->json_data_fees)) |
| 99 | 124 | $calendar_fees = json_decode($calendar->json_data_fees ); |
| 100 | 125 | |
| @@ -103,9 +128,9 @@ | ||
| 103 | 128 | $nights = (int)abs(strtotime($date_to) - strtotime($date_from))/(60*60*24); |
| 104 | 129 | foreach ($calendar_fees as $fee) { |
| 105 | 130 | if(!wmvc_show_data('is_activated', $fee, false,TRUE,TRUE)) continue; |
| 106 | 131 | if(is_intval(wmvc_show_data('value', $fee,'',TRUE,TRUE))) { |
| 107 | - $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)))); | |
| 108 | 133 | if(!wmvc_show_data('is_required', $fee, false,TRUE,TRUE) && !isset($_POST['fee_'.$field])) { |
| 109 | 134 | |
| 110 | 135 | } else { |
| 111 | 136 | if(wmvc_show_data('calculation_base', $fee,'',TRUE,TRUE) == 'per_night') { |
| @@ -133,12 +158,17 @@ | ||
| 133 | 158 | |
| 134 | 159 | if(wmvc_show_data ('pets_allowed', $_POST, false)) |
| 135 | 160 | $note .= '<b>'.__('Pets', 'wpdirectorykit').':</b> yes'.'<br>'.PHP_EOL; |
| 136 | 161 | |
| 137 | - $note .= '<b>'.__('Name', 'wpdirectorykit').':</b> '.sanitize_text_field(wmvc_show_data ('Name', $_POST)).'<br>'.PHP_EOL; | |
| 138 | - $note .= '<b>'.__('Email', 'wpdirectorykit').':</b> '.sanitize_text_field(wmvc_show_data ('Email', $_POST)).'<br>'.PHP_EOL; | |
| 139 | - $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; | |
| 140 | 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 | + | |
| 141 | 171 | if(wmvc_show_data ('Phone', $_POST, false)) |
| 142 | 172 | $note .= '<b>'.__('Phone', 'wpdirectorykit').':</b> '.sanitize_text_field(wmvc_show_data ('Phone', $_POST)).'<br>'.PHP_EOL; |
| 143 | 173 | |
| 144 | 174 | if(true) |
| @@ -143,18 +173,84 @@ | ||
| 143 | 173 | |
| 144 | 174 | if(true) |
| 145 | 175 | foreach($_POST as $key => $value) { |
| 146 | 176 | if($key=='element_id') continue; |
| 147 | - 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; | |
| 148 | - 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; | |
| 149 | 179 | |
| 150 | 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 | |
| 151 | 183 | $note .= '<b> '.__(str_replace('_',' ', ucfirst($key)), 'wpdirectorykit').':</b> <a href="'.esc_url($value).'">'.$value.'</a><br>'; |
| 152 | 184 | } else { |
| 185 | + // Dynamic field values are registered in the translation catalog separately. | |
| 186 | +// phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText | |
| 153 | 187 | $note .= '<b> '.__(str_replace('_',' ', ucfirst($key)), 'wpdirectorykit').':</b> '.$value.'<br>'; |
| 154 | 188 | } |
| 155 | 189 | } |
| 156 | 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 | + | |
| 157 | 253 | $data = array( |
| 158 | 254 | 'post_id' => ($post_id), |
| 159 | 255 | 'date_from' => ($date_from), |
| 160 | 256 | 'date_to' => ($date_to), |
| @@ -169,9 +265,9 @@ | ||
| 169 | 265 | if(wmvc_show_data('is_enable_noapprovements', $calendar, false)) |
| 170 | 266 | $data['is_approved'] = 1; |
| 171 | 267 | |
| 172 | 268 | $results = $Winter_MVC_wdk_bookings->reservation_m->is_booked($post_id, $date_from, $date_to); |
| 173 | - $errors = ''; | |
| 269 | + | |
| 174 | 270 | |
| 175 | 271 | $Winter_MVC_wdk_bookings->db->where("date_from <='".$date_from."'"); |
| 176 | 272 | $Winter_MVC_wdk_bookings->db->where("date_to >= '".$date_to."'"); |
| 177 | 273 | $price_reservation = $Winter_MVC_wdk_bookings->price_m->get_by(array('post_id'=>$post_id), TRUE); |
| @@ -205,10 +301,10 @@ | ||
| 205 | 301 | '6'=>__('Saturday', 'wpdirectorykit'), |
| 206 | 302 | '7'=>__('Sunday', 'wpdirectorykit'), |
| 207 | 303 | ); |
| 208 | 304 | |
| 209 | - $day_num_from = date('N', strtotime($date_from)); | |
| 210 | - $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)); | |
| 211 | 307 | |
| 212 | 308 | if(wmvc_show_data('changeover_day', $price_reservation, false, TRUE, TRUE) && ( |
| 213 | 309 | wmvc_show_data('changeover_day', $price_reservation, false, TRUE, TRUE) != $day_num_from |
| 214 | 310 | || wmvc_show_data('changeover_day', $price_reservation, false, TRUE, TRUE) != $day_num_to |
| @@ -223,9 +319,11 @@ | ||
| 223 | 319 | $period = ''; |
| 224 | 320 | $min_hours = intval(wmvc_show_data('min_hours', $price_reservation, false, TRUE, TRUE)); |
| 225 | 321 | if((int)($min_hours/24) >= 1) { |
| 226 | 322 | $days = (int)($min_hours/24); |
| 227 | - $period .= esc_html(sprintf(_nx( | |
| 323 | + $period .= esc_html(sprintf( | |
| 324 | + /* translators: 1: Number of days. */ | |
| 325 | + _nx( | |
| 228 | 326 | '%1$s day', |
| 229 | 327 | '%1$s days', |
| 230 | 328 | $days, |
| 231 | 329 | 'days', |
| @@ -235,9 +333,11 @@ | ||
| 235 | 333 | $min_hours -= $days * 24; |
| 236 | 334 | } |
| 237 | 335 | |
| 238 | 336 | if(!empty($min_hours)) { |
| 239 | - $period .= ' '.esc_html(sprintf(_nx( | |
| 337 | + $period .= ' '.esc_html(sprintf( | |
| 338 | + /* translators: 1: Number of hours. */ | |
| 339 | + _nx( | |
| 240 | 340 | '%1$s hour', |
| 241 | 341 | '%1$s hours', |
| 242 | 342 | (int)($min_hours), |
| 243 | 343 | 'hours', |
| @@ -252,9 +352,11 @@ | ||
| 252 | 352 | $period = ''; |
| 253 | 353 | $max_hours = intval(wmvc_show_data('max_hours', $price_reservation, false, TRUE, TRUE)); |
| 254 | 354 | if((int)($max_hours/24) >= 1) { |
| 255 | 355 | $days = (int)($max_hours/24); |
| 256 | - $period .= esc_html(sprintf(_nx( | |
| 356 | + $period .= esc_html(sprintf( | |
| 357 | + /* translators: 1: Number of days. */ | |
| 358 | + _nx( | |
| 257 | 359 | '%1$s day', |
| 258 | 360 | '%1$s days', |
| 259 | 361 | $days, |
| 260 | 362 | 'days', |
| @@ -264,9 +366,11 @@ | ||
| 264 | 366 | $max_hours -= $days * 24; |
| 265 | 367 | } |
| 266 | 368 | |
| 267 | 369 | if(!empty($max_hours)) { |
| 268 | - $period .= ' '.esc_html(sprintf(_nx( | |
| 370 | + $period .= ' '.esc_html(sprintf( | |
| 371 | + /* translators: 1: Number of hours. */ | |
| 372 | + _nx( | |
| 269 | 373 | '%1$s hour', |
| 270 | 374 | '%1$s hours', |
| 271 | 375 | (int)($max_hours), |
| 272 | 376 | 'hours', |
| @@ -281,21 +385,23 @@ | ||
| 281 | 385 | if( $results ) { |
| 282 | 386 | add_filter( 'eli/ajax-handler/filter_output', function($filter_output){ |
| 283 | 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>'; |
| 284 | 388 | $filter_output['no_clear_from'] = true; |
| 389 | + $filter_output['success'] = false; | |
| 285 | 390 | return $filter_output; |
| 286 | 391 | } ); |
| 287 | 392 | } elseif( !empty($errors) ) { |
| 288 | 393 | add_filter( 'eli/ajax-handler/filter_output', function($filter_output) use ($errors) { |
| 289 | 394 | $filter_output['message'] = $errors; |
| 395 | + $filter_output['success'] = false; | |
| 290 | 396 | $filter_output['no_clear_from'] = true; |
| 291 | 397 | return $filter_output; |
| 292 | 398 | } ); |
| 293 | 399 | } else { |
| 294 | 400 | |
| 295 | - if(!$calendar->is_hour_enabled && !empty($data['date_from']) && !empty($data['date_to'])) { | |
| 296 | - $data['date_from'] = date('Y-m-d 00:00:00', strtotime($data['date_from'])); | |
| 297 | - $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'])); | |
| 298 | 404 | } |
| 299 | 405 | $insert_id = $Winter_MVC_wdk_bookings->reservation_m->insert($data, NULL); |
| 300 | 406 | |
| 301 | 407 | /* auto is_enable_noapprovements enabled */ |
| @@ -398,9 +504,9 @@ | ||
| 398 | 504 | if(wdk_get_option(('wdk_bookings_time_for_payment'))) { |
| 399 | 505 | $data_message['hours_for_payment'] = intval(wdk_get_option(('wdk_bookings_time_for_payment'))); |
| 400 | 506 | |
| 401 | 507 | /* set date_expire for reservation */ |
| 402 | - $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")))); | |
| 403 | 509 | $Winter_MVC_wdk_bookings->reservation_m->insert($update_data, $insert_id); |
| 404 | 510 | } |
| 405 | 511 | |
| 406 | 512 | wdk_mail(wdk_show_data('user_email', $data_message['user'], '' , TRUE, TRUE), __('Reservation waiting for payment', 'wpdirectorykit'), $data_message, 'reservation_user_payment_notify'); |
| @@ -438,8 +544,9 @@ | ||
| 438 | 544 | $data_message['data'] = array( |
| 439 | 545 | __('Reservation ID', 'wpdirectorykit')=> $insert_id, |
| 440 | 546 | __('Date From', 'wpdirectorykit')=> wdk_get_date($date_from), |
| 441 | 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)), | |
| 442 | 549 | ); |
| 443 | 550 | |
| 444 | 551 | $nights = (int)abs(strtotime($date_to) - strtotime($date_from))/(60*60*24); |
| 445 | 552 | $guests_number = intval(wmvc_show_data('guests_number_adults', $_POST, 0)) + intval(wmvc_show_data('guests_number_childs', $_POST, 0)); |
| @@ -445,9 +552,9 @@ | ||
| 445 | 552 | $guests_number = intval(wmvc_show_data('guests_number_adults', $_POST, 0)) + intval(wmvc_show_data('guests_number_childs', $_POST, 0)); |
| 446 | 553 | foreach ($calendar_fees as $fee) { |
| 447 | 554 | if(!wmvc_show_data('is_activated', $fee, false,TRUE,TRUE)) continue; |
| 448 | 555 | |
| 449 | - $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)))); | |
| 450 | 557 | if(!wmvc_show_data('is_required', $fee, false,TRUE,TRUE) && !isset($_POST['fee_'.$field])) { |
| 451 | 558 | |
| 452 | 559 | } else { |
| 453 | 560 | if(wmvc_show_data('calculation_base', $fee,'',TRUE,TRUE) == 'per_night') { |
| @@ -479,9 +586,14 @@ | ||
| 479 | 586 | } |
| 480 | 587 | else |
| 481 | 588 | { |
| 482 | 589 | add_filter( 'eli/ajax-handler/filter_output', function($filter_output) { |
| 483 | - $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>'; | |
| 484 | 596 | $filter_output['no_clear_from'] = true; |
| 485 | 597 | return $filter_output; |
| 486 | 598 | } ); |
| 487 | 599 | } |
| @@ -516,8 +628,9 @@ | ||
| 516 | 628 | $data_message['data'] = array( |
| 517 | 629 | __('Reservation ID', 'wpdirectorykit')=> $insert_id, |
| 518 | 630 | __('Date From', 'wpdirectorykit')=> wdk_get_date($date_from), |
| 519 | 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)), | |
| 520 | 633 | ); |
| 521 | 634 | $nights = (int)abs(strtotime($date_to) - strtotime($date_from))/(60*60*24); |
| 522 | 635 | $guests_number = intval(wmvc_show_data('guests_number_adults', $_POST, 0)) + intval(wmvc_show_data('guests_number_childs', $_POST, 0)); |
| 523 | 636 | foreach ($calendar_fees as $fee) { |
| @@ -522,9 +635,9 @@ | ||
| 522 | 635 | $guests_number = intval(wmvc_show_data('guests_number_adults', $_POST, 0)) + intval(wmvc_show_data('guests_number_childs', $_POST, 0)); |
| 523 | 636 | foreach ($calendar_fees as $fee) { |
| 524 | 637 | if(!wmvc_show_data('is_activated', $fee, false,TRUE,TRUE)) continue; |
| 525 | 638 | |
| 526 | - $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)))); | |
| 527 | 640 | if(!wmvc_show_data('is_required', $fee, false,TRUE,TRUE) && !isset($_POST['fee_'.$field])) { |
| 528 | 641 | |
| 529 | 642 | } else { |
| 530 | 643 | if(wmvc_show_data('calculation_base', $fee,'',TRUE,TRUE) == 'per_night') { |
| @@ -566,9 +679,9 @@ | ||
| 566 | 679 | $ret = wdk_mail( $owner_email, __('New Reservation Waiting For Approvement', 'wpdirectorykit'), $data_message, 'reservation_waiting_for_approve_owner'); |
| 567 | 680 | |
| 568 | 681 | /* waiting approve to client */ |
| 569 | 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'); |
| 570 | - | |
| 683 | + | |
| 571 | 684 | if( $ret) { |
| 572 | 685 | add_filter( 'eli/ajax-handler/filter_output', function($filter_output){ |
| 573 | 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>'; |
| 574 | 687 | return $filter_output; |
| @@ -576,9 +689,14 @@ | ||
| 576 | 689 | } |
| 577 | 690 | else |
| 578 | 691 | { |
| 579 | 692 | add_filter( 'eli/ajax-handler/filter_output', function($filter_output) { |
| 580 | - $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>'; | |
| 581 | 699 | $filter_output['no_clear_from'] = true; |
| 582 | 700 | return $filter_output; |
| 583 | 701 | } ); |
| 584 | 702 | } |
| @@ -608,15 +726,19 @@ | ||
| 608 | 726 | $data_mess= array(); |
| 609 | 727 | |
| 610 | 728 | foreach($_POST as $key => $value){ |
| 611 | 729 | if($key=='element_id') continue; |
| 612 | - 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; | |
| 613 | 731 | |
| 614 | 732 | if(empty($value)) continue; |
| 615 | 733 | |
| 616 | 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 | |
| 617 | 737 | $data_mess []= '<p><strong>'.__(str_replace('_',' ', ucfirst($key)), 'wpdirectorykit').':</strong> <a href="'.esc_url($value).'">'.$value.'</a></p>'; |
| 618 | 738 | } else { |
| 739 | + // Dynamic field values are registered in the translation catalog separately. | |
| 740 | +// phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText | |
| 619 | 741 | $data_mess []= '<p><strong>'.__(str_replace('_',' ', ucfirst($key)), 'wpdirectorykit').':</strong> '.$value.'</p>'; |
| 620 | 742 | } |
| 621 | 743 | } |
| 622 | 744 | |
| @@ -625,8 +747,14 @@ | ||
| 625 | 747 | $Winter_MVC_WDK->model('listing_m'); |
| 626 | 748 | $Winter_MVC_WDK->load_helper('listing'); |
| 627 | 749 | $data_listing = $Winter_MVC_WDK->listing_m->get($post_id, TRUE); |
| 628 | 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 | + | |
| 629 | 757 | /* message for user */ |
| 630 | 758 | if (!empty($email)) { |
| 631 | 759 | $data_message = array(); |
| 632 | 760 | $data_message['email_data'] = $data; |
| @@ -652,9 +780,9 @@ | ||
| 652 | 780 | $data_message['email_data'] = $data; |
| 653 | 781 | $data_message['message'] = ''; |
| 654 | 782 | |
| 655 | 783 | |
| 656 | - $message_title = __('New Message waiting', 'wpdirectorykit'); | |
| 784 | + $message_title = __('New Message', 'wpdirectorykit'); | |
| 657 | 785 | |
| 658 | 786 | if(function_exists('run_wdk_bookings')) { |
| 659 | 787 | |
| 660 | 788 | if(isset($_POST['date_from']) && isset($_POST['date_to']) && !empty($_POST['date_from']) && !empty($_POST['date_to'])) { |
| @@ -659,9 +787,9 @@ | ||
| 659 | 787 | |
| 660 | 788 | if(isset($_POST['date_from']) && isset($_POST['date_to']) && !empty($_POST['date_from']) && !empty($_POST['date_to'])) { |
| 661 | 789 | $data_message['message'] .= '<h2>'.__('Date reservation change to', 'wpdirectorykit').'</h2>'; |
| 662 | 790 | $data_message['message'] .= '<p>'.__('Details from contact form', 'wpdirectorykit').'</p>'; |
| 663 | - | |
| 791 | + | |
| 664 | 792 | $message_title = __('Contact message related to reservation on page', 'wpdirectorykit').' '.get_bloginfo('name'); |
| 665 | 793 | } |
| 666 | 794 | } |
| 667 | 795 | |
| @@ -677,11 +805,12 @@ | ||
| 677 | 805 | $owner_email = $user_owner->user_email; |
| 678 | 806 | } |
| 679 | 807 | |
| 680 | 808 | $ret = wdk_mail($owner_email, $message_title, $data_message, 'new_message', '', NULL, $email); |
| 809 | + | |
| 681 | 810 | if( $ret) { |
| 682 | 811 | add_filter( 'eli/ajax-handler/filter_output', function($filter_output){ |
| 683 | - $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>'; | |
| 684 | 813 | return $filter_output; |
| 685 | 814 | } ); |
| 686 | 815 | add_filter( 'eli/ajax-handler/filter_from_data', function ($form_data = array()) { |
| 687 | 816 | /* disable double sent to admin mail */ |
| @@ -692,9 +821,19 @@ | ||
| 692 | 821 | } |
| 693 | 822 | else |
| 694 | 823 | { |
| 695 | 824 | add_filter( 'eli/ajax-handler/filter_output', function($filter_output) { |
| 696 | - $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; | |
| 697 | 836 | $filter_output['no_clear_from'] = true; |
| 698 | 837 | return $filter_output; |
| 699 | 838 | } ); |
| 700 | 839 | } |