PluginProbe
Booking Calendar / 11.3
Booking Calendar v11.3
11.8.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 All 203 releases
booking / core / admin / page-email-new-visitor.php

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

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