PluginProbe
Booking Calendar / 11.3
Booking Calendar v11.3
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-approved.php

page-email-approved.php in Booking Calendar 11.3, at core/admin/page-email-approved.php

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