PluginProbe
Booking Calendar / 11.8
Booking Calendar v11.8
11.8.2 11.8.1 11.8 11.7 11.6.1 11.6 11.5 11.4.3 11.4.2 11.4.1 11.4 11.3 11.2.1 11.2 11.1 11.0 10.15.7 10.15.6 10.1.3 10.10 10.10.1 10.10.2 10.11 10.11.2 10.11.3 All 202 releases
booking / core / admin / page-email-deny.php

page-email-deny.php in Booking Calendar 11.8, at core/admin/page-email-deny.php

1,095 lines 62.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @version 1.0
4 * @package Content
5 * @category Menu
6 * @author wpdevelop
7 *
8 * @web-site https://wpbookingcalendar.com/
9 * @email info@wpbookingcalendar.com
10 *
11 * @modified 2015-04-09
12 */
13
14 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
15
16
17 if ( ! defined( 'WPBC_EMAIL_DENY_PREFIX' ) ) define( 'WPBC_EMAIL_DENY_PREFIX', 'booking_email_' ); // Its defined in api-emails.php file & its same for all emails, here its used only for easy coding...
18
19 if ( ! defined( 'WPBC_EMAIL_DENY_ID' ) ) define( 'WPBC_EMAIL_DENY_ID', 'deny' ); /* Define Name of Email Template.
20 Note. Prefix "booking_email_" defined in api-emails.php file.
21 Full name of option is - "booking_email_deny"
22 Other email templates names:
23 - 'new_admin'
24 - 'new_visitor'
25 - 'approved'
26 - 'deny' -- pending, trash, deleted
27 - 'payment_request'
28 - 'modification'
29 */
30
31
32 require_once WPBC_PLUGIN_DIR . '/core/any/api-emails.php'; // API
33
34
35
36 // <editor-fold defaultstate="collapsed" desc=" Import Old Data " >
37
38 function wpbc_import6_is_old_email_deny_exist() {
39
40 $is_old_data_exist = get_bk_option( 'booking_email_deny_content' );
41
42 if ( ! empty( $is_old_data_exist ) ) // Check if Old data exist
43 return true;
44 else
45 return false;
46 }
47
48 function wpbc_import6_get_old_email_deny_data() {
49
50 $default_values = array();
51 if ( wpbc_import6_is_old_email_deny_exist() ) {
52
53 $default_values['enabled'] = get_bk_option( 'booking_is_email_deny_adress' );
54 $default_values['copy_to_admin'] = get_bk_option( 'booking_is_email_deny_send_copy_to_admin' ); //Parse it to Name and Email
55 $default_values['from'] = get_bk_option( 'booking_email_deny_adress' ); //Parse it to Name and Email, relpace [visitoremail]
56 $default_values['subject'] = get_bk_option( 'booking_email_deny_subject' );
57 $default_values['content'] = get_bk_option( 'booking_email_deny_content' );
58
59 }
60 return $default_values;
61 }
62
63
64 function wpbc_import6_is_new_email_deny_exist() {
65
66 $is_data_exist = get_bk_option( WPBC_EMAIL_DENY_PREFIX . WPBC_EMAIL_DENY_ID ); // ''booking_email_' - defined in api-emails.php file.
67
68 if ( ! empty( $is_data_exist ) ) // Check if data exist
69 return true;
70 else
71 return false;
72 }
73
74
75 function wpbc_import6_email__deny__get_fields_array_for_activation() {
76
77
78 if ( ! wpbc_import6_is_new_email_deny_exist() ) { // New Email Template NOT exist
79
80 // Import
81 $old_data = wpbc_import6_get_old_email_deny_data();
82 if ( ! empty( $old_data ) ) { // Get Old data
83
84 /*
85 $old_data = [
86 [enabled] => On
87 [to] => "Booking system" <beta@wpbookingcalendar.com>
88 [from] => [visitoremail]
89 [subject] => New booking
90 [content] => You need to approve a new booking [bookingtype] for: [dates]<br/><br/> Person detail information:<br/> [content]<br/><br/> Currently a new booking is waiting for approval. Please visit the moderation panel [moderatelink]<br/><br/>Thank you, Beta<br/>[siteurl]
91 ]
92 wpbc_get_email_parts() >>> return [
93 [email] => beta@wpbookingcalendar.com
94 [title] => Booking system
95 [original] => "Booking system"
96 [original_to_show] => "Booking system" <beta@wpbookingcalendar.com>
97 ]
98 */
99
100 // Make transform - emails
101 // $email_to = wpbc_get_email_parts( $old_data['to'] );
102 $email_from = wpbc_get_email_parts( $old_data['from'] );
103
104 // $old_data['to'] = $email_to['email']; // 'beta@wpbookingcalendar.com' // booking_email_reservation_adress
105 // $old_data['to_name'] = $email_to['title']; // 'Booking system' // booking_email_reservation_adress
106 /* Description of Code.
107 * Here we replacing any shortcodes, like [visitoremail] to get_option( 'admin_email' )
108 * because we are setting in header "Reply-To" visitor emil from the booking form - its exist by hook for this email template at the wpbc-emails.php file
109 *
110 * Here we need to use for field "From" email with DNS same as DNS in the website. In most cases its have to be the get_option( 'admin_email' )
111 *
112 * After parsing with wpbc_get_email_parts, if we was have [visitoremail] in this field, then $email_from['email'] will be empty. So we check it and set admin email.
113 *
114 */
115 $old_data['from'] = ( empty( $email_from['email'] ) ? get_option( 'admin_email' ) /*$email_from['original']*/ : $email_from['email'] ); // [visitoremail] | email@server.com // booking_email_reservation_from_adress
116 $old_data['from_name'] = $email_from['title']; // [visitoremail] | 'Booking System' | '' // booking_email_reservation_from_adress
117
118 // $old_data['subject'] = html_entity_decode( $old_data['subject'] );
119 // $old_data['content'] = html_entity_decode( $old_data['content'] );
120 }
121
122 // Default
123 $init_fields_values = $old_data;
124 $mail_api = new WPBC_Emails_API_Deny( WPBC_EMAIL_DENY_ID , $init_fields_values );
125
126 $default_fields_in_settings = $mail_api->get_default_values() ; // Get default fields values, from settings - defined in function init_settings_fields {class WPBC_Emails_API_Deny}
127
128 $fields_values = wp_parse_args( $old_data, $default_fields_in_settings );
129
130 return array( WPBC_EMAIL_DENY_PREFIX . WPBC_EMAIL_DENY_ID => $fields_values );
131
132 /*
133 Array (
134 [booking_email_deny] => Array
135 (
136 [enabled] => On
137 [to] => beta@wpbookingcalendar.com
138 [to_name] => Booking system
139 [from] => admin@wpbookingcalendar.com
140 [from_name] =>
141 [subject] => New booking
142 [content] => You need to approve a new booking [bookingtype] for: [dates]...
143 [header_content] =>
144 [footer_content] =>
145 [template_file] => plain
146 [base_color] => #557da1
147 [background_color] => #f5f5f5
148 [body_color] => #fdfdfd
149 [text_color] => #505050
150 [email_content_type] => html
151 )
152 )
153
154 // $mail_api->save_to_db( $fields_values );
155
156 */
157
158 } else { // New Email Template is Exist - return empty array(), its will make loading of data from DB, during activation Mail API class.
159 return array( WPBC_EMAIL_DENY_PREFIX . WPBC_EMAIL_DENY_ID => array() );
160 }
161 }
162 // </editor-fold>
163
164
165
166 /** Email F i e l d s */
167 class WPBC_Emails_API_Deny extends WPBC_Emails_API { // O v e r r i d i n g "WPBC_Emails_API" ClASS
168
169
170 /** Overrided functions - define Email Fields & Values */
171 public function init_settings_fields() {
172
173 $this->fields = array();
174
175 $this->fields['enabled'] = array(
176 'type' => 'checkbox'
177 , 'default' => 'On'
178 , 'title' => __('Enable / Disable', 'booking')
179 , 'label' => __('Enable this email notification', 'booking')
180 , 'description' => ''
181 , 'group' => 'general'
182
183 );
184
185
186
187 $this->fields['copy_to_admin'] = array(
188 'type' => 'checkbox'
189 , 'default' => 'Off'
190 , 'title' => __('Copy(ies)', 'booking') //FixIn: 8.1.2.17.1
191 , 'label' => __('Enable / disable sending email(s) to additional addresses', 'booking') . ' (admin@; sales@; others@)' //FixIn: 8.1.2.17.1
192 , 'description' => ''
193 , 'group' => 'general'
194
195 );
196
197
198
199 // FixIn: 8.1.2.17.
200 $this->fields['to_html_prefix'] = array(
201 'type' => 'pure_html'
202 , 'group' => 'general'
203 , 'html' => '<tr valign="top" class="wpbc_tr_copy_to_admin_to">
204 <th scope="row">
205 <label class="wpbc-form-email" for="'
206 . esc_attr( 'approved_to' )
207 . '">' . wp_kses_post( __('To' ,'booking') ) . ' (' . strtolower( __('Copy(ies)', 'booking') ). ')' //FixIn: 8.1.2.17.1
208 . '</label>
209 </th>
210 <td><fieldset style="float:left;width:50%;margin-right:5%;">'
211 );
212 $this->fields['to'] = array(
213 'type' => 'text' // We are using here 'text' and not 'email', for ability to save several comma seperated emails.
214 , 'default' => get_option( 'admin_email' )
215 //, 'placeholder' => ''
216 , 'title' => ''
217 , 'description' => __('Email Address', 'booking') . '. ' . __('Required', 'booking') . '. '
218 . __('You can put multiple emails separated by', 'booking') . ' <code>;</code>' //FixIn: 8.1.2.17.1
219 , 'description_tag' => ''
220 , 'css' => 'width:100%'
221 , 'group' => 'general'
222 , 'tr_class' => ''
223 , 'only_field' => true
224 , 'validate_as' => array( )
225 );
226 $this->fields['to_html_middle'] = array(
227 'type' => 'pure_html'
228 , 'group' => 'general'
229 , 'html' => '</fieldset><fieldset style="float:left;width:45%;">'
230 );
231 $this->fields['to_name'] = array(
232 'type' => 'text'
233 , 'default' => 'Booking system'
234 //, 'placeholder' => ''
235 , 'title' => ''
236 , 'description' => __('Title', 'booking') . ' (' . __('optional', 'booking') . ').' //. ' ' . __('If empty then title defined as WordPress', 'booking')
237 , 'description_tag' => ''
238 , 'css' => 'width:100%'
239 , 'group' => 'general'
240 , 'tr_class' => ''
241 , 'only_field' => true
242 );
243 $this->fields['to_html_sufix'] = array(
244 'type' => 'pure_html'
245 , 'group' => 'general'
246 , 'html' => ' </fieldset>
247 </td>
248 </tr>'
249 );
250
251 $this->fields['to_hr'] = array( 'type' => 'hr' );
252 /**/
253 //FixIn: 8.1.2.17 - END
254
255 $this->fields['from_html_prefix'] = array(
256 'type' => 'pure_html'
257 , 'group' => 'general'
258 , 'html' => '<tr valign="top">
259 <th scope="row">
260 <label class="wpbc-form-email" for="'
261 . esc_attr( 'deny_from' )
262 . '">' . wp_kses_post( __('From' ,'booking') )
263 . '</label>
264 </th>
265 <td><fieldset style="float:left;width:50%;margin-right:5%;">'
266 );
267 $this->fields['from'] = array(
268 'type' => 'email' // Its can be only 1 email, so check it as Email field.
269 , 'default' => get_option( 'admin_email' )
270 //, 'placeholder' => ''
271 , 'title' => ''
272 , 'description' => __('Email Address', 'booking') . '. ' . __('Required', 'booking') . '.'
273 , 'description_tag' => ''
274 , 'css' => 'width:100%'
275 , 'group' => 'general'
276 , 'tr_class' => ''
277 , 'only_field' => true
278 , 'validate_as' => array( 'required' )
279 );
280 $this->fields['from_html_middle'] = array(
281 'type' => 'pure_html'
282 , 'group' => 'general'
283 , 'html' => '</fieldset><fieldset style="float:left;width:45%;">'
284 );
285 $this->fields['from_name'] = array(
286 'type' => 'text'
287 , 'default' => 'Booking system'
288 //, 'placeholder' => ''
289 , 'title' => ''
290 , 'description' => __('Title', 'booking') . ' (' . __('optional', 'booking') . ').' //. ' ' . __('If empty then title defined as WordPress', 'booking')
291 , 'description_tag' => ''
292 , 'css' => 'width:100%'
293 , 'group' => 'general'
294 , 'tr_class' => ''
295 , 'only_field' => true
296 );
297 $this->fields['from_html_sufix'] = array(
298 'type' => 'pure_html'
299 , 'group' => 'general'
300 , 'html' => ' </fieldset>
301 </td>
302 </tr>'
303 );
304
305
306
307
308
309 $this->fields['subject_before'] = array(
310 'type' => 'pure_html'
311 , 'group' => 'general_content'
312 , 'html' => '<tr><td colspan="2">'
313 .'<div style="margin: 0 0 15px;font-weight: 600;">'
314 .'<label class="wpbc-form-email-subject" for="' . WPBC_EMAIL_DENY_ID . '_subject">' .
315 __( 'Subject', 'booking' )
316 . '</label></div>'
317 );
318 $this->fields['subject'] = array(
319 'type' => 'text'
320 , 'default' => __( 'Your booking has been declined', 'booking' )
321 //, 'placeholder' => ''
322 , 'title' => __('Subject', 'booking')
323 , 'description' => ''
324 , 'description_tag' => ''
325 , 'css' => 'width:100%;font-size:16px;line-height:34px;font-weight:600;'
326 , 'group' => 'general_content'
327 , 'tr_class' => ''
328 , 'validate_as' => array( 'required' )
329 , 'only_field' => true
330 );
331 $this->fields['subject_after'] = array( 'type' => 'pure_html', 'group' => 'general_content',
332 'html' => '<p style="text-align: right;font-size:12px;">'
333 /* translators: 1: ... */
334 . sprintf( __( 'Type your email %1$ssubject%2$s for the booking confirmation message.', 'booking' ),'<b>','</b>') . ' ' . __('Required', 'booking')
335 . '.</p>' . '</td></tr>' );
336
337 $blg_title = get_option( 'blogname' );
338 $blg_title = str_replace( array( '"', "'" ), '', $blg_title );
339
340 /* translators: 1: ... */
341 $email_content = sprintf( __( 'Your booking %1$s for: %2$s has been canceled. %3$sThank you, %4$s', 'booking' ), '[bookingtype]', '[dates]', '<br/>[denyreason]<br/><br/>[content]<br/><br/>', $blg_title . '<br/>[siteurl]' );
342
343 $this->fields['content_before'] = array(
344 'type' => 'pure_html',
345 'group' => 'general_content',
346 'html' => '<tr><td colspan="2" style="padding-bottom:0;">'
347 . '<div style="margin: 0;font-weight: 600;">'
348 . '<label class="wpbc-form-email-content" for="' . WPBC_EMAIL_DENY_ID . '_content">' .
349 __( 'Content', 'booking' )
350 . '</label></div>'
351 );
352 $this->fields['content'] = array(
353 'type' => 'wp_textarea'
354 , 'default' => $email_content
355 //, 'placeholder' => ''
356 , 'title' => __('Content', 'booking')
357 , 'description' => ''//__('Type your email message content. ', 'booking')
358 , 'description_tag' => ''
359 , 'css' => ''
360 , 'group' => 'general_content'
361 , 'tr_class' => ''
362 , 'rows' => 17
363 , 'show_in_2_cols' => true
364 , 'only_field' => true
365 );
366 $this->fields['content_after'] = array( 'type' => 'pure_html', 'group' => 'general_content', 'html' => '</td></tr>' );
367 // $this->fields['content'] = htmlspecialchars( $this->fields['content'] );// Convert > to &gt;
368 // $this->fields['content'] = html_entity_decode( $this->fields['content'] );// Convert &gt; to >
369
370
371
372 ////////////////////////////////////////////////////////////////////
373 // Style
374 ////////////////////////////////////////////////////////////////////
375
376
377 $this->fields['header_content'] = array(
378 'type' => 'textarea'
379 , 'default' => ''
380 , 'title' => __('Email Heading', 'booking')
381 , 'description' => __('Enter main heading contained within the email notification.', 'booking')
382 //, 'placeholder' => ''
383 , 'rows' => 2
384 , 'css' => "width:100%;"
385 , 'group' => 'parts'
386 );
387 $this->fields['footer_content'] = array(
388 'type' => 'textarea'
389 , 'default' => ''
390 , 'title' => __('Email Footer Text', 'booking')
391 , 'description' => __('Enter text contained within footer of the email notification', 'booking')
392 //, 'placeholder' => ''
393 , 'rows' => 2
394 , 'css' => 'width:100%;'
395 , 'group' => 'parts'
396 );
397
398 $this->fields['template_file'] = array(
399 'type' => 'select'
400 , 'default' => 'plain'
401 , 'title' => __('Email template', 'booking')
402 , 'description' => __('Choose email template.', 'booking')
403 , 'description_tag' => 'span'
404 , 'css' => ''
405 , 'options' => array(
406 'plain' => __('Plain (without styles)', 'booking')
407 , 'standard' => __('Standard 1 column', 'booking')
408 )
409 , 'group' => 'style'
410 );
411
412 $this->fields['template_file_help'] = array(
413 'type' => 'help'
414 /* translators: 1: ... */
415 , 'value' => array( sprintf( __( 'You can override this email template in this folder %s', 'booking')
416 , '<code>' . realpath( dirname(__FILE__) . '/../any/emails_tpl/' ) . '</code>' )
417 )
418 , 'cols' => 2
419 , 'group' => 'style'
420 );
421
422 $this->fields['base_color'] = array(
423 'type' => 'color'
424 , 'default' => '#557da1'
425 , 'title' => __('Base Color', 'booking')
426 , 'description' => __('The base color for email templates.', 'booking')
427 . ' ' . __('Default color', 'booking') .': <code>#557da1</code>.'
428 , 'group' => 'style'
429 , 'tr_class' => 'template_colors'
430 );
431 $this->fields['background_color'] = array(
432 'type' => 'color'
433 , 'default' => '#f5f5f5'
434 , 'title' => __('Background Color', 'booking')
435 , 'description' => __('The background color for email templates.', 'booking')
436 . ' ' . __('Default color', 'booking') .': <code>#f5f5f5</code>.'
437 , 'group' => 'style'
438 , 'tr_class' => 'template_colors'
439 );
440 $this->fields['body_color'] = array(
441 'type' => 'color'
442 , 'default' => '#fdfdfd'
443 , 'title' => __('Email Body Background Color', 'booking')
444 , 'description' => __('The main body background color for email templates.', 'booking')
445 . ' ' . __('Default color', 'booking') .': <code>#fdfdfd</code>.'
446 , 'group' => 'style'
447 , 'tr_class' => 'template_colors'
448 );
449 $this->fields['text_color'] = array(
450 'type' => 'color'
451 , 'default' => '#505050'
452 , 'title' => __('Email Body Text Colour', 'booking')
453 , 'description' => __('The main body text color for email templates.', 'booking')
454 . ' ' . __('Default color', 'booking') .': <code>#505050</code>.'
455 , 'group' => 'style'
456 , 'tr_class' => 'template_colors'
457 );
458
459
460 ////////////////////////////////////////////////////////////////////
461 // Email format: Plain, HTML, MultiPart
462 ////////////////////////////////////////////////////////////////////
463
464
465 $this->fields['email_content_type'] = array(
466 'type' => 'select'
467 , 'default' => 'plain'
468 , 'title' => __('Email format', 'booking')
469 , 'description' => __('Choose which format of email to send.', 'booking')
470 , 'description_tag' => 'p'
471 , 'css' => 'width:100%;'
472 , 'options' => array(
473 'plain' => __('Plain text', 'booking')
474 // , 'html' => __('HTML', 'booking')
475 // , 'multipart' => __('Multipart', 'booking')
476 )
477 , 'group' => 'email_content_type'
478 );
479 if ( class_exists( 'DOMDocument' ) ) {
480 $this->fields['email_content_type']['options']['html'] = __('HTML', 'booking');
481 $this->fields['email_content_type']['options']['multipart'] = __('Multipart', 'booking');
482
483 $this->fields['email_content_type']['default'] = 'html';
484 }
485
486
487
488 ////////////////////////////////////////////////////////////////////
489 // Help
490 ////////////////////////////////////////////////////////////////////
491
492 $this->fields['content_help'] = array(
493 'type' => 'help'
494 , 'value' => array()
495 , 'cols' => 2
496 , 'group' => 'help'
497 , 'css' => 'padding-right: 10px !important;max-height: 598px;overflow: auto;'
498 , 'only_field' => true
499 );
500
501 $skip_shortcodes = array(
502 // 'denyreason'
503 'moderatelink'
504 , 'paymentreason'
505 , 'visitorbookingediturl'
506 //, 'visitorbookingslisting' //FixIn: 8.1.3.5.1
507 , 'visitorbookingcancelurl'
508 , 'visitorbookingpayurl'
509 );
510 /* translators: 1: ... */
511 $email_example = sprintf( __( 'For example: "You have a new reservation %1$s on the following date(s): %2$s Contact information: %3$s You can approve or cancel this booking at: %4$s Thank you, Reservation service."', 'booking' ),'','[dates]&lt;br/&gt;&lt;br/&gt;','&lt;br/&gt; [content]&lt;br/&gt;&lt;br/&gt;', htmlentities( ' <a href="[moderatelink]">'.__('here' ,'booking').'</a> ') . '&lt;br/&gt;&lt;br/&gt; ');
512
513 $help_fields = wpbc_get_email_help_shortcodes( $skip_shortcodes, $email_example );
514
515 foreach ( $help_fields as $help_fields_key => $help_fields_value ) {
516 $this->fields['content_help']['value'][] = $help_fields_value;
517 }
518
519 }
520
521 }
522
523
524
525 /** Settings Emails P a g e */
526 class WPBC_Settings_Page_Email_Deny extends WPBC_Page_Structure {
527
528 public $email_settings_api = false;
529
530
531 /**
532 * Define interface for Email API
533 *
534 * @param string $selected_email_name - name of Email template
535 * @param array $init_fields_values - array of init form fields data
536 * @return object Email API
537 */
538 public function mail_api( $selected_email_name ='', $init_fields_values = array() ){
539
540 if ( $this->email_settings_api === false ) {
541 $this->email_settings_api = new WPBC_Emails_API_Deny( $selected_email_name , $init_fields_values );
542 }
543
544 return $this->email_settings_api;
545 }
546
547
548 public function in_page() { // P a g e t a g
549 return 'wpbc-settings';
550 }
551
552
553 public function tabs() { // T a b s A r r a y
554
555 $tabs = array();
556
557 // $tabs[ 'email' ] = array(
558 // 'title' => __( 'Emails', 'booking') // Title of TAB
559 // , 'page_title'=> __( 'Emails Settings', 'booking') // Title of Page
560 // , 'hint' => __( 'Emails Settings', 'booking') // Hint
561 // //, 'link' => '' // Can be skiped, then generated link based on Page and Tab tags. Or can be extenral link
562 // //, 'position' => '' // 'left' || 'right' || ''
563 // //, 'css_classes'=> '' // CSS class(es)
564 // //, 'icon' => '' // Icon - link to the real PNG img
565 // , 'font_icon' => 'wpbc_icn_mail_outline' // CSS definition of forn Icon
566 // //, 'default' => false // Is this tab activated by default or not: true || false.
567 // //, 'disabled' => false // Is this tab disbaled: true || false.
568 // //, 'hided' => false // Is this tab hided: true || false.
569 // , 'subtabs' => array()
570 // );
571
572 $subtabs = array();
573
574 $is_data_exist = get_bk_option( WPBC_EMAIL_NEW_ADMIN_PREFIX . WPBC_EMAIL_DENY_ID );
575 if ( ( ! empty( $is_data_exist ) ) && ( isset( $is_data_exist['copy_to_admin'] ) ) && ( $is_data_exist['copy_to_admin'] == 'On' ) )
576 $sufix = '<sup> 2</sup>';
577 else
578 $sufix = '';
579
580
581 $subtabs['deny'] = array(
582 'type' => 'subtab' // Required| Possible values: 'subtab' | 'separator' | 'button' | 'goto-link' | 'html'
583 , 'title' => '<span>' . esc_html__( 'Pending', 'booking' ) . $sufix . '</span>' // Title of TAB
584 , 'page_title' => __('Emails Settings', 'booking') . ' - <span>' . esc_html__( 'Pending', 'booking' ) . $sufix . '</span>' // Title of Page.
585 , 'hint' => __('Customization of email template, which is sent to Visitor, when booking status is set to Pending' ,'booking') //FixIn: 8.1.2.17.1
586 , 'link' => '' // link
587 , 'position' => '' // 'left' || 'right' || ''
588 , 'css_classes' => 'wpbc_navigation_top_border' // CSS class(es)
589 //, 'icon' => 'http://.../icon.png' // Icon - link to the real PNG img
590 //, 'font_icon' => 'wpbc_icn_mail_outline' // CSS definition of Font Icon
591 , 'default' => false // Is this sub tab activated by default or not: true || false.
592 , 'disabled' => false // Is this sub tab deactivated: true || false.
593 , 'checkbox' => false // or definition array for specific checkbox: array( 'checked' => true, 'name' => 'feature1_active_status' ) //, 'checkbox' => array( 'checked' => $is_checked, 'name' => 'enabled_active_status' )
594 , 'content' => 'content' // Function to load as conten of this TAB
595 , 'font_icon' => 'wpbc_icn_hourglass_empty'
596 , 'show_checked_icon' => true
597 , 'checked_data' => WPBC_EMAIL_NEW_ADMIN_PREFIX . WPBC_EMAIL_DENY_ID // This is where we get content
598 );
599
600 $tabs[ 'email' ]['subtabs'] = $subtabs;
601
602 return $tabs;
603 }
604
605
606 /** Show Content of Settings page */
607 public function content() {
608 $this->css();
609
610 // -------------------------------------------------------------------------------------------------------------
611 // Checking
612 // -------------------------------------------------------------------------------------------------------------
613 do_action( 'wpbc_hook_settings_page_header', 'emails_settings'); // Define Notices Section and show some static messages, if needed
614
615 if ( ! wpbc_is_mu_user_can_be_here('activated_user') ) return false; // Check if MU user activated, otherwise show Warning message.
616 // if ( ! wpbc_is_mu_user_can_be_here('only_super_admin') ) return false; // User is not Super admin, so exit. Basically its was already checked at the bottom of the PHP file, just in case.
617
618
619 // -------------------------------------------------------------------------------------------------------------
620 // S u b m i t Main Form
621 // -------------------------------------------------------------------------------------------------------------
622 $submit_form_name = 'wpbc_emails_template'; // Define form name
623 // $this->maybe_update(); // It is run from parent CLASS before showing this content on Actual Selected by user Page
624
625
626 ////////////////////////////////////////////////////////////////////////
627 // JavaScript: Tooltips, Popover, Datepick (js & css)
628 ////////////////////////////////////////////////////////////////////////
629
630 echo '<span class="wpdevelop">';
631
632 wpbc_js_for_bookings_page();
633
634 echo '</span>';
635
636
637 ////////////////////////////////////////////////////////////////////////
638 // Content
639 ////////////////////////////////////////////////////////////////////////
640 ?>
641 <div class="clear"></div>
642
643 <span class="metabox-holder">
644
645 <form name="<?php echo esc_attr( $submit_form_name ); ?>" id="<?php echo esc_attr( $submit_form_name ); ?>" action="" method="post" autocomplete="off">
646 <?php
647 // N o n c e field, and key for checking S u b m i t
648 wp_nonce_field( 'wpbc_settings_page_' . $submit_form_name );
649 ?><input type="hidden" name="is_form_sbmitted_<?php echo esc_attr( $submit_form_name ); ?>" id="is_form_sbmitted_<?php echo esc_attr( $submit_form_name ); ?>" value="1" />
650
651 <div class="clear"></div>
652 <?php
653
654 wpbc_email_troubleshooting_help_notice();
655
656 ?>
657 <div class="metabox-holder">
658 <?php
659 wpbc_open_meta_box_section( $submit_form_name . 'general', __('Email is sent to Visitor after booking set as Pending.', 'booking') ); //FixIn: 8.1.2.17.1
660
661 $this->mail_api()->show( 'general' );
662
663 wpbc_close_meta_box_section();
664 ?>
665 <div class="wpbc_settings_row wpbc_settings_row_left" >
666 <?php
667 wpbc_open_meta_box_section( $submit_form_name . 'general_content', __('Email Content', 'booking') ); //FixIn: 8.1.2.17.1
668
669 $this->mail_api()->show( 'general_content' );
670
671 wpbc_close_meta_box_section();
672 ?>
673 </div>
674
675 <div class="wpbc_settings_row wpbc_settings_row_right">
676 <?php
677 wpbc_open_meta_box_section( $submit_form_name . 'help', __('Help', 'booking') );
678
679 $this->mail_api()->show( 'help' );
680
681 wpbc_close_meta_box_section();
682 ?>
683 </div>
684 <div class="clear"></div>
685 <?php
686 wpbc_open_meta_box_section( $submit_form_name . 'email_content_type', __('Email Type', 'booking') . ' / ' . __('Email Styles', 'booking') );
687
688 $this->mail_api()->show( 'email_content_type' );
689
690 $this->mail_api()->show( 'style' );
691
692 wpbc_close_meta_box_section();
693
694 wpbc_open_meta_box_section( $submit_form_name . 'parts' , __('Header / Footer', 'booking') );
695
696 $this->mail_api()->show( 'parts' );
697
698 wpbc_close_meta_box_section();
699 ?>
700 </div>
701 <input type="submit" value="<?php echo esc_attr( __( 'Save Changes', 'booking' ) ); ?>" class="button button-primary" />
702 </form>
703 </span>
704 <?php
705
706 $this->enqueue_js();
707 }
708
709
710 /**
711 * This function called from PARENT CLASS for actual selected tab. Firstly it load data and then Maybe Save changes.
712 * @return void
713 */
714 public function maybe_update() {
715
716 // -------------------------------------------------------------------------------------------------------------
717 // Load Data
718 // -------------------------------------------------------------------------------------------------------------
719
720 /* Check if New Email Template Exist or NOT
721 * Exist - return empty array in format: array( OPTION_NAME => array() )
722 * It will load DATA from DB, during creation mail_api CLASS
723 * during initial activation of the API its try to get option from DB
724 * We need to define this API before checking POST, to know all available fields
725 * Define Email Name & define field values from DB, if not exist, then default values.
726 * Not Exist - import Old Data from DB
727 * or get "default" data from settings and return array with this data
728 * This data its initial parameters for definition fields in mail_api CLASS
729 *
730 */
731
732 $init_fields_values = wpbc_import6_email__deny__get_fields_array_for_activation();
733
734 // Get Value of first element - array of default or imported OLD data, because need only array of values without key - name of options for wp_options table
735 $init_fields_values_temp = array_values( $init_fields_values ); // FixIn: 7.0.1.32.
736 $init_fields_values = array_shift( $init_fields_values_temp );
737
738
739 $this->mail_api( WPBC_EMAIL_DENY_ID, $init_fields_values );
740
741
742 // -------------------------------------------------------------------------------------------------------------
743 // Maybe Update Data
744 // -------------------------------------------------------------------------------------------------------------
745
746 $submit_form_name = 'wpbc_emails_template'; // Define form name
747
748 $this->mail_api()->validated_form_id = $submit_form_name; // Define ID of Form for ability to validate fields before submit.
749
750 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
751 if ( isset( $_POST['is_form_sbmitted_'. $submit_form_name ] ) ) {
752
753 // Nonce checking {Return false if invalid, 1 if generated between, 0-12 hours ago, 2 if generated between 12-24 hours ago. }
754 $nonce_gen_time = check_admin_referer( 'wpbc_settings_page_' . $submit_form_name ); // Its stop show anything on submiting, if its not refear to the original page
755
756 // Save Changes
757 $this->update();
758 }
759 }
760
761
762 /** Update Email template to DB */
763 public function update() {
764
765 // Get Validated Email fields
766 $validated_fields = $this->mail_api()->validate_post();
767
768 $this->mail_api()->save_to_db( $validated_fields );
769
770 wpbc_show_message ( __('Settings saved.', 'booking'), 5 ); // Show Save message
771 }
772
773 // <editor-fold defaultstate="collapsed" desc=" CSS & JS " >
774
775 /** CSS for this page */
776 private function css() {
777 ?>
778 <style type="text/css">
779 .wpbc-help-message {
780 border:none;
781 margin:0 !important;
782 padding:0 !important;
783 }
784
785 @media (max-width: 399px) {
786 }
787 </style>
788 <?php
789 }
790
791
792 /**
793 * Add Custon JavaScript - for some specific settings options
794 * Executed After post content, after initial definition of settings, and possible definition after POST request.
795 *
796 * @param type $menu_slug
797 *
798 */
799 private function enqueue_js(){ // $page_tag, $active_page_tab, $active_page_subtab ) {
800 $js_script = '';
801 //Show or hide colors section in settings page depend form selected email template.
802 $js_script .= " jQuery('select[name=\"deny_template_file\"]').on( 'change', function(){
803 if ( jQuery('select[name=\"deny_template_file\"] option:selected').val() == 'plain' ) {
804 jQuery('.template_colors').hide();
805 } else {
806 jQuery('.template_colors').show();
807 }
808 } ); ";
809 $js_script .= "\n"; //New Line
810 $js_script .= " if ( jQuery('select[name=\"deny_template_file\"] option:selected').val() == 'plain' ) {
811 jQuery('.template_colors').hide();
812 } ";
813
814 // Show Warning messages if Title (optional) is empty - title of email will be "WordPress
815 $js_script .= " jQuery(document).ready(function(){ ";
816 $js_script .= " if ( jQuery('#deny_to_name').val() == '' ) {";
817 $js_script .= " jQuery('#deny_to_name').parent().append('<div class=\'updated\' style=\'border-left-color:#ffb900;padding:5px 10px;\'>". esc_js(__('If empty then title defined as WordPress', 'booking' ))."</div>')";
818 $js_script .= " }";
819 $js_script .= " if ( jQuery('#deny_from_name').val() == '' ) {";
820 $js_script .= " jQuery('#deny_from_name').parent().append('<div class=\'updated\' style=\'border-left-color:#ffb900;padding:5px 10px;\'>". esc_js(__('If empty then title defined as WordPress', 'booking' ))."</div>')";
821 $js_script .= " }";
822 $js_script .= " }); ";
823
824 // FixIn: 8.1.2.17.
825 $js_script .= " jQuery('#deny_copy_to_admin').on( 'change', function(){ ";
826 $js_script .= " if ( jQuery('#deny_copy_to_admin').is(':checked') ) {";
827 $js_script .= " jQuery('.wpbc_tr_copy_to_admin_to').show();";
828 $js_script .= " } else { ";
829 $js_script .= " jQuery('.wpbc_tr_copy_to_admin_to').hide();";
830 $js_script .= " } ";
831 $js_script .= " }); ";
832 $js_script .= " jQuery(document).ready(function(){ ";
833 $js_script .= " if ( jQuery('#deny_copy_to_admin').is(':checked') ) {";
834 $js_script .= " jQuery('.wpbc_tr_copy_to_admin_to').show();";
835 $js_script .= " } else { ";
836 $js_script .= " jQuery('.wpbc_tr_copy_to_admin_to').hide();";
837 $js_script .= " } ";
838 $js_script .= " }); ";
839 //FixIn: 8.1.2.17 - END
840
841 // Eneque JS to the footer of the page
842 wpbc_enqueue_js( $js_script );
843 }
844
845
846 // </editor-fold>
847 }
848 add_action('wpbc_menu_created', array( new WPBC_Settings_Page_Email_Deny() , '__construct') ); // Executed after creation of Menu
849
850
851
852 // <editor-fold defaultstate="collapsed" desc=" Emails Sending" >
853
854 /**
855 * Get ShortCodes to Replace
856 *
857 * @param int $booking_id - ID of booking
858 * @param int $bktype - booking resource type
859 * @param string $formdata - booking form data content
860 */
861 function wpbc__get_replace_shortcodes__email_deny( $booking_id, $bktype, $formdata ) {
862
863 $replace = array();
864
865 // Resources ///////////////////////////////////////////////////////////////
866 $bk_title = wpbc_get_resource_title( $bktype );
867 $parent_resource_title = wpbc_get_parent_resource_title( $bktype ); // FixIn: 10.9.2.4.
868
869 // Dates ///////////////////////////////////////////////////////////////////
870 $my_dates4emeil = wpbc_db__get_sql_dates__in_booking__as_str( $booking_id );
871
872 $my_dates_4_send = ( 'short' === get_bk_option( 'booking_date_view_type' ) )
873 ? wpbc_get_dates_short_format( $my_dates4emeil )
874 : wpbc_get_dates_comma_string_localized( $my_dates4emeil );
875 $my_dates4emeil_check_in_out = explode( ',', $my_dates4emeil );
876
877 $my_check_in_date = wpbc_get_dates_comma_string_localized( $my_dates4emeil_check_in_out[0] );
878 $my_check_out_date = wpbc_get_dates_comma_string_localized( $my_dates4emeil_check_in_out[ count( $my_dates4emeil_check_in_out ) - 1 ] );
879 $my_check_in_onlydate = wpbc_get_dates_comma_string_localized( wpbc_datetime_localized( gmdate( 'Y-m-d 00:00:00', strtotime( $my_dates4emeil_check_in_out[0] ) ), 'Y-m-d 00:00:00' ) ); // FixIn: 8.7.2.5.
880 $my_check_out_onlydate = wpbc_get_dates_comma_string_localized( wpbc_datetime_localized( gmdate( 'Y-m-d 00:00:00', strtotime( $my_dates4emeil_check_in_out[ count( $my_dates4emeil_check_in_out ) - 1 ] ) ), 'Y-m-d 00:00:00' ) );
881 $my_check_out_plus1day = wpbc_get_dates_comma_string_localized( wpbc_datetime_localized( gmdate( 'Y-m-d H:i:s', strtotime( $my_dates4emeil_check_in_out[ count( $my_dates4emeil_check_in_out ) - 1 ] . " +1 day" ) ), 'Y-m-d H:i:s' ) ); // FixIn: 6.0.1.11.
882
883 // FixIn: 10.1.5.6.
884 $dates_only_arr = wpbc_get_only_dates__from_dates_ymd_his_csv__as_arr( $my_dates4emeil ); // -> '2023-10-09, 2023-10-09'
885 $dates_only_str = implode( ',', $dates_only_arr );
886 $dates_only_str_formatted = ( 'short' === get_bk_option( 'booking_date_view_type' ) )
887 ? wpbc_get_dates_short_format( $dates_only_str )
888 : wpbc_get_dates_comma_string_localized( $dates_only_str );
889
890 // Cost ////////////////////////////////////////////////////////////////////
891 $booking_cost_digits_only = apply_bk_filter( 'get_booking_cost_from_db', '', $booking_id ); // FixIn: 9.2.3.1.
892 $booking_cost = wpbc_get_cost_with_currency_for_user( $booking_cost_digits_only );
893 // Other ///////////////////////////////////////////////////////////////////
894 $replace[ 'booking_id' ] = $booking_id;
895 $replace[ 'id' ] = $replace[ 'booking_id' ];
896 $replace[ 'dates' ] = $my_dates_4_send;
897 $replace[ 'only_dates' ] = $dates_only_str_formatted;
898 $replace[ 'dates_only' ] = $dates_only_str_formatted;
899 $replace[ 'check_in_date' ] = $my_check_in_date;
900 $replace[ 'check_out_date' ] = $my_check_out_date;
901 // FixIn: 8.7.2.5.
902 $replace[ 'check_in_only_date' ] = $my_check_in_onlydate;
903 $replace[ 'check_out_only_date' ] = $my_check_out_onlydate;
904
905 $replace[ 'check_out_plus1day'] = $my_check_out_plus1day; // FixIn: 6.0.1.11.
906
907 $replace['dates_count'] = count( $my_dates4emeil_check_in_out );
908 $replace['days_count'] = intval( $replace['dates_count'] ); // FixIn: 10.15.1.3.
909 $replace['nights_count'] = ( $replace['days_count'] > 1 ) ? intval( $replace['days_count'] - 1 ) : 1;
910 $replace['days_count_plus1day'] = intval( $replace['days_count'] + 1 );
911
912
913 $replace['cost'] = $booking_cost;
914 $replace['cost_digits_only'] = $booking_cost_digits_only;
915 $replace[ 'siteurl' ] = htmlspecialchars_decode( '<a href="' . esc_url( home_url() ) . '">' . home_url() . '</a>' );
916 $replace[ 'resource_title'] = wpbc_lang( $bk_title );
917 $replace[ 'parent_resource_title'] = wpbc_lang( $parent_resource_title ); // FixIn: 10.9.2.4.
918 $replace[ 'bookingtype' ] = $replace[ 'resource_title'];
919 $replace[ 'remote_ip' ] = wpbc_get_user_ip(); //FixIn:7.1.2.4 // The IP address from which the user is viewing the current page.
920 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
921 $replace[ 'user_agent' ] = ( ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) ? sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] ) : '' ); // Contents of the User-Agent: header from the current request, if there is one.
922 $server_http_referer_uri = ( ( isset( $_SERVER['HTTP_REFERER'] ) ) ? sanitize_text_field( $_SERVER['HTTP_REFERER'] ) : '' ); /* phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.MissingUnslash */ /* FixIn: sanitize_unslash */
923 $replace['request_url'] = $server_http_referer_uri; // The address of the page (if any) where action was occured. Because we are sending it in Ajax request, we need to use the REFERER HTTP
924 $replace[ 'current_date' ] = date_i18n( get_bk_option( 'booking_date_format' ) );
925 $replace[ 'current_time' ] = date_i18n( get_bk_option( 'booking_time_format' ) );
926
927 // Form Fields /////////////////////////////////////////////////////////////
928 $booking_form_show_array = wpbc__legacy__get_form_content_arr( $formdata, $bktype, '', $replace ); // We use here $replace array, becaise in "Content of booking filds data" form can be shortcodes from above definition
929
930 foreach ( $booking_form_show_array['_all_fields_'] as $shortcode_name => $shortcode_value ) {
931
932 if ( ! isset( $replace[ $shortcode_name ] ) )
933 $replace[ $shortcode_name ] = $shortcode_value;
934 }
935 $replace[ 'content' ] = $booking_form_show_array['content'];
936
937 // Links ///////////////////////////////////////////////////////////////////
938 $replace[ 'moderatelink' ] = htmlspecialchars_decode(
939 // '<a href="' .
940 esc_url( wpbc_get_bookings_url() . '&tab=vm_booking_listing&wh_booking_id=' . $booking_id )
941 // . '">' . esc_html__('here', 'booking') . '</a>'
942 );
943 $replace[ 'visitorbookingediturl' ] = apply_bk_filter( 'wpdev_booking_set_booking_edit_link_at_email', '[visitorbookingediturl]', $booking_id );
944 $replace[ 'visitorbookingslisting' ] = apply_bk_filter( 'wpdev_booking_set_booking_edit_link_at_email', '[visitorbookingslisting]', $booking_id ); //FixIn: 8.1.3.5.1
945 $replace[ 'visitorbookingcancelurl' ] = apply_bk_filter( 'wpdev_booking_set_booking_edit_link_at_email', '[visitorbookingcancelurl]', $booking_id );
946 $replace[ 'visitorbookingpayurl' ] = apply_bk_filter( 'wpdev_booking_set_booking_edit_link_at_email', '[visitorbookingpayurl]', $booking_id );
947 $replace[ 'bookinghash' ] = apply_bk_filter( 'wpdev_booking_set_booking_edit_link_at_email', '[bookinghash]', $booking_id );
948 // FixIn: 9.6.3.8.
949 $google_calendar_link = wpbc_booking_do_action__get_google_calendar_link( array(
950 'form_data' => $booking_form_show_array['_all_fields_'],
951 'form_show' => $booking_form_show_array['content'], //wp_strip_all_tags( $parsed_form_show ),
952 'dates_short' => array(
953 $my_dates4emeil_check_in_out[0]
954 , '-'
955 , $my_dates4emeil_check_in_out[ count( $my_dates4emeil_check_in_out ) - 1 ]
956 )
957 ) );
958 $replace['add_to_google_cal_url'] = htmlspecialchars_decode( esc_url( $google_calendar_link ) );
959 $replace['add_to_google_cal_button'] = '<a href="' . esc_attr( $replace['add_to_google_cal_url'] ) . '" target="_blank" rel="nofollow">' . esc_attr__( 'Add to Google Calendar', 'booking' ) . '</a>';
960
961
962
963 // -----------------------------------------------------------------------------------------------------------------
964 // Get additional replace paramaters to the email shortcodes
965 $replace = apply_filters( 'wpbc_replace_params_for_booking', $replace, $booking_id, $bktype, $formdata ); // FixIn: 8.0.1.7.
966
967
968 return $replace;
969
970
971 }
972
973
974 /**
975 * Send email
976 *
977 * @param type $booking_id - ID of booking
978 * @param type $bktype - type
979 * @param type $formdata - booking form data
980 */
981
982 function wpbc_send_email_deny( $deny_id_str, $is_send_emeils, $denyreason = '' ) {
983
984 global $wpdb;
985 $sql = "SELECT * FROM {$wpdb->prefix}booking as bk WHERE bk.booking_id IN ({$deny_id_str})";
986 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
987 $result = $wpdb->get_results( $sql );
988
989 foreach ( $result as $res ) {
990
991 $booking_id = $res->booking_id;
992 $bktype = $res->booking_type;
993 $formdata = $res->form;
994
995 $previous_active_user = apply_bk_filter( 'wpbc_mu_set_environment_for_owner_of_resource', - 1, $bktype ); // MU
996
997 // Check for ability to change HASH during Decline (set pending) booking. //FixIn: 10.9.6.1.
998 make_bk_action( 'booking_pending_send_email', $res, '' );
999
1000
1001 ////////////////////////////////////////////////////////////////////////
1002 // Load Data
1003 ////////////////////////////////////////////////////////////////////////
1004
1005 /* Check if New Email Template Exist or NOT
1006 * Exist - return empty array in format: array( OPTION_NAME => array() )
1007 * Its will load DATA from DB, during creattion mail_api CLASS
1008 * during initial activation of the API its try to get option from DB
1009 * We need to define this API before checking POST, to know all available fields
1010 * Define Email Name & define field values from DB, if not exist, then default values.
1011 * Not Exist - import Old Data from DB
1012 * or get "default" data from settings and return array with this data
1013 * This data its initial parameters for definition fields in mail_api CLASS
1014 *
1015 */
1016
1017 $init_fields_values = wpbc_import6_email__deny__get_fields_array_for_activation();
1018
1019 // Get Value of first element - array of default or imported OLD data, because need only array of values without key - name of options for wp_options table
1020 $init_fields_values_temp = array_values( $init_fields_values ); // FixIn: 7.0.1.32.
1021 $init_fields_values = array_shift( $init_fields_values_temp );
1022
1023
1024 $mail_api = new WPBC_Emails_API_Deny( WPBC_EMAIL_DENY_ID, $init_fields_values );
1025
1026 ////////////////////////////////////////////////////////////////////////////
1027
1028 if ( $mail_api->fields_values['enabled'] == 'Off' ) return false; // Email template deactivated - exit.
1029
1030
1031 $replace = wpbc__get_replace_shortcodes__email_deny( $booking_id, $bktype, $formdata );
1032 $replace['denyreason'] = $denyreason; // FixIn: 7.0.1.1.
1033 $replace['reason'] = $denyreason;
1034 // Replace shortcodes with custom URL parameter, like: 'visitorbookingediturl', 'visitorbookingcancelurl', 'visitorbookingpayurl'
1035 foreach ( array( 'visitorbookingediturl', 'visitorbookingcancelurl', 'visitorbookingpayurl' , 'visitorbookingslisting') as $url_shortcode ) { //FixIn: 7.0.1.8 //FixIn: 8.1.3.5.1
1036
1037 // Loop to search if we are having several such shortcodes in our $mail_api->fields_values['content'] (For example, if we have several languges ).
1038 $pos = 0; // FixIn: 7.0.1.52.
1039 do {
1040 $shortcode_params = wpbc_get_params_of_shortcode_in_string( $url_shortcode, $mail_api->fields_values['content'] , $pos );
1041
1042 if ( ( ! empty( $shortcode_params ) ) && ( isset( $shortcode_params['url'] ) ) ){
1043
1044 $pos = $shortcode_params['end'];
1045
1046 $exist_replace = substr( $mail_api->fields_values['content'], $shortcode_params['start'], ( $shortcode_params['end'] - $shortcode_params['start'] ) );
1047
1048 $new_replace = $url_shortcode . wp_rand(1000,9000);
1049
1050 $pos = $shortcode_params['start'] + strlen( $new_replace ); //FixIn: 9.7.3.5.1
1051 $mail_api->fields_values['content'] = str_replace( $exist_replace, $new_replace ,$mail_api->fields_values['content'] );
1052
1053 $replace[ $new_replace ] = apply_bk_filter( 'wpdev_booking_set_booking_edit_link_at_email', '['.$exist_replace.']', $booking_id );
1054 } else if ( // FixIn: 8.1.1.8.
1055 ( ! empty( $shortcode_params ) )
1056 && ( isset( $shortcode_params['end'] ) )
1057 && ( $shortcode_params['end'] < strlen( $mail_api->fields_values['content'] ) )
1058 ) {
1059 $pos = $shortcode_params['end'];
1060 } else {
1061 $shortcode_params = false; // FixIn: 7.0.1.58.
1062 }
1063
1064 } while ( ! empty( $shortcode_params ) ); // FixIn: 7.0.1.52.
1065
1066 }
1067
1068 $mail_api->set_replace( $replace );
1069 $mail_api->fields_values['from_name'] = $mail_api->replace_shortcodes( $mail_api->fields_values['from_name'] ); // FixIn: 7.0.1.29.
1070
1071
1072 $to = ( isset( $replace['email'] ) ) ? $replace['email'] : ''; // Get To field
1073
1074 if ( ! empty( $replace['email'] ) ) {
1075 $to = wpbc_email_prepand_person_name( $replace['email'], $replace );
1076 }
1077
1078 $to = wpbc_check_for_several_emails_in_form( $to, $formdata, $bktype ); // FixIn: 6.0.1.9.
1079
1080 $to = str_replace( ';', ',', $to );
1081
1082
1083 if ( wpbc_is_not_blank_email( $to, $replace['content'] ) ) {
1084 $email_result = $mail_api->send( $to, $replace );
1085 }
1086
1087 make_bk_action( 'wpbc_mu_set_environment_for_user', $previous_active_user ); // MU
1088 }
1089
1090 $email_result = ( isset( $email_result ) ) ? $email_result : false;
1091 return $email_result;
1092 }
1093
1094 // </editor-fold>
1095