PluginProbe
Booking Calendar / 10.1.3
Booking Calendar v10.1.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 / wpbc-emails.php

wpbc-emails.php in Booking Calendar 10.1.3, at core/wpbc-emails.php

506 lines 23.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.1
4 * @package Booking Calendar
5 * @category Send Emails
6 * @author wpdevelop
7 *
8 * @web-site https://wpbookingcalendar.com/
9 * @email info@wpbookingcalendar.com
10 *
11 * @modified 15.09.2015
12 */
13
14 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
15
16
17
18 ////////////////////////////////////////////////////////////////////////////////
19 // Emails
20 ////////////////////////////////////////////////////////////////////////////////
21
22 /**
23 * Check email and format it
24 *
25 * @param string $emails
26 * @return string
27 */
28 function wpbc_validate_emails( $emails ) {
29
30 $emails = str_replace(';', ',', $emails);
31
32 if ( !is_array( $emails ) )
33 $emails = explode( ',', $emails );
34
35 $emails_list = array();
36 foreach ( (array) $emails as $recipient ) {
37
38 // Break $recipient into name and address parts if in the format "Foo <bar@baz.com>"
39 $recipient_name = '';
40 if( preg_match( '/(.*)<(.+)>/', $recipient, $matches ) ) {
41 if ( count( $matches ) == 3 ) {
42 $recipient_name = $matches[1];
43 $recipient = $matches[2];
44 }
45 } else {
46 // Check about correct format of email
47 if( preg_match( '/([\w\.\-_]+)?\w+@[\w\-_]+(\.\w+){1,}/im', $recipient, $matches ) ) { //FixIn: 8.7.7.2
48 $recipient = $matches[0];
49 }
50 }
51
52 $recipient_name = str_replace('"', '', $recipient_name);
53 $recipient_name = trim( wp_specialchars_decode( esc_html( stripslashes( $recipient_name ) ), ENT_QUOTES ) );
54
55 $emails_list[] = ( empty( $recipient_name ) ? '' : $recipient_name . ' ' )
56 . '<' . sanitize_email( $recipient ) . '>';
57 }
58
59 $emails_list = implode( ',', $emails_list );
60
61 return $emails_list;
62 }
63
64
65 /**
66 * Convert email address to the correct format like "Jony Smith" <smith@server.com> - tp prevent "WordPress" title in email.
67 * @param string $wpbc_mail - just simple email
68 * @param type $booking_form_show - array with name and secondname of the person - title
69 * @return string - formated email.
70 */
71 function wpbc_email_prepand_person_name( $wpbc_mail, $booking_form_show = array() ) {
72
73 //FixIn:5.4.4
74 $wpbc_email_title = ((isset($booking_form_show['firstname']))?$booking_form_show['firstname'].' ':'')
75 .((isset($booking_form_show['name']))?$booking_form_show['name'].' ':'')
76 .((isset($booking_form_show['lastname']))?$booking_form_show['lastname'].' ':'')
77 .((isset($booking_form_show['secondname']))?$booking_form_show['secondname'].' ':'');
78 $wpbc_email_title = ( ( empty($wpbc_email_title ) ) ? __('Booking system' ,'booking') : substr( $wpbc_email_title, 0 , -1 ) );
79
80 $wpbc_email_title = str_replace('"', '', $wpbc_email_title);
81 $wpbc_email_title = trim( wp_specialchars_decode( esc_html( stripslashes( $wpbc_email_title ) ), ENT_QUOTES ) );
82
83 $wpbc_mail = wpbc_validate_emails( $wpbc_email_title . ' <' . $wpbc_mail . '> ' );
84
85 return $wpbc_mail;
86 }
87
88 // Old, Replaced in api-emails
89 class wpbc_email_return_path {
90 function __construct() {
91 add_action( 'phpmailer_init', array( $this, 'fix' ) );
92 }
93
94 function fix( $phpmailer ) {
95 $phpmailer->Sender = $phpmailer->From;
96 }
97 }
98
99
100 function wpbc_wp_mail( $mail_recipient, $mail_subject, $mail_body, $mail_headers ){
101
102 $wpbc_email_return_path = new wpbc_email_return_path();
103
104 // $mail_recipient = str_replace( '"', '', $mail_recipient ); //FixIn:5.4.3
105 if ( ! wpbc_is_this_demo() ) //FixIn:6.1.1.19
106 @wp_mail($mail_recipient, $mail_subject, $mail_body, $mail_headers);
107
108 unset( $wpbc_email_return_path );
109 }
110
111
112
113
114
115 function wpbc_check_for_several_emails_in_form( $mail_recipients, $formdata, $bktype ) { //FixIn: 6.0.1.9
116
117 $possible_other_emails = explode('~',$formdata);
118 $possible_other_emails = array_map("explode", array_fill(0,count($possible_other_emails),'^'), $possible_other_emails);
119 $other_emails = array();
120 foreach ( $possible_other_emails as $possible_emails ) {
121 if ( ( $possible_emails[0] == 'email' )
122 //&& ( $possible_emails[1] != 'email' . $bktype )
123 && ( ! empty($possible_emails[2]) )
124 )
125 $other_emails[]= trim( $possible_emails[2] ); //FixIn: 8.2.1.6
126 }
127 $other_emails = array_unique( $other_emails ); //FixIn: 8.2.1.6
128 if ( count( $other_emails ) > 1 ) {
129 $other_emails = implode(',',$other_emails);
130 $mail_recipients = $other_emails;
131 }
132 return $mail_recipients;
133 }
134
135
136 // N E W /////////////////////////////////////////////////////////////////////
137
138
139 /**
140 * Parse email and get Parts of Email - Name and Email
141 *
142 * @param string $email
143 * @return array [email] => beta@wpbookingcalendar.com
144 [title] => Booking system
145 [original] => "Booking system"
146 [original_to_show] => "Booking system" <beta@wpbookingcalendar.com>
147 */
148 function wpbc_get_email_parts( $email ) {
149
150 $email_to_parse = html_entity_decode( $email ); // Convert &quot; to " etc...
151
152 $pure_name = '';
153 $pure_email = '';
154 if( preg_match( '/(.*)<(.+)>/', $email_to_parse, $matches ) ) {
155 if ( count( $matches ) == 3 ) {
156 $pure_name = $matches[1];
157 $pure_email = $matches[2];
158 }
159 } else { // Check about correct format of email
160 if( preg_match( '/([\w\.\-_]+)?\w+@[\w-_]+(\.\w+){1,}/im', $email_to_parse, $matches ) ) {
161 $pure_email = $matches[0];
162 }
163 }
164
165 $pure_name = trim( wp_specialchars_decode( esc_html( stripslashes( $pure_name ) ), ENT_QUOTES ) , ' "');
166
167 $return_email = array(
168 'email' => sanitize_email( $pure_email )
169 , 'title' => $pure_name
170 , 'original' => $email_to_parse
171 , 'original_to_show' => htmlentities( $email_to_parse ) // Convert " to &quot; etc...
172 );
173
174 return $return_email;
175 }
176
177
178 // Get Emails Help Shortcodes for Settings pages
179 function wpbc_get_email_help_shortcodes( $skip_shortcodes = array() , $email_example = '') {
180
181 $fields = array();
182
183 if ( class_exists('wpdev_bk_personal') ) {
184 $fields[] = sprintf(__('You can use (in subject and content of email template) any shortcodes, which you used in the booking form. Use the shortcodes in the same way as you used them in the content form at Settings Fields page.' ,'booking'));
185 $fields[] = '<hr/>';
186 }
187 $fields[] = '<strong>' . __('You can use following shortcodes in content of this template' ,'booking') . '</strong>';
188
189 // [content]
190 if ( class_exists('wpdev_bk_personal') )
191 $fields[] = sprintf(__('%s - inserting data info about the booking, which you configured in the content form at Settings Fields page' ,'booking'),'<code>[content]</code>');
192 else
193 $fields[] = sprintf(__('%s - inserting data info about the booking' ,'booking'),'<code>[content]</code>');
194
195
196 // [dates]
197 $fields[] = sprintf(__('%s - inserting the dates of booking' ,'booking'),'<code>[dates]</code>');
198
199 // [check_in_date]
200 if ( ! in_array( 'check_in_date', $skip_shortcodes ) ) {
201 $fields[] = sprintf( __( '%s - inserting check-in date (first day of reservation),', 'booking' ), '<code>[check_in_date]</code>' );
202 $fields[] = sprintf( __( '%s - inserting check-in date (only date without time) (first day of reservation),', 'booking' ), '<code>[check_in_only_date]</code>' ); //FixIn: 8.7.2.5
203 }
204 // [check_out_date] [check_out_plus1day]
205 if ( ! in_array( 'check_out_date', $skip_shortcodes ) ) {
206 $fields[] = sprintf(__('%s - inserting check-out date (last day of reservation),' ,'booking'),'<code>[check_out_date]</code>');
207 $fields[] = sprintf(__('%s - inserting check-out date (only date without time) (last day of reservation),' ,'booking'),'<code>[check_out_only_date]</code>'); //FixIn: 8.7.2.5
208 $fields[] = sprintf(__('%s - inserting check-out date (last day of reservation),' ,'booking'),'<code>[check_out_plus1day]</code>') . ' + 1 ' . __('day', 'booking');
209 }
210
211 // [dates_count]
212 if ( ! in_array( 'dates_count', $skip_shortcodes ) )
213 $fields[] = sprintf(__('%s - inserting the number of booking dates ' ,'booking'),'<code>[dates_count]</code>');
214
215 $fields[] = '<hr/>';
216
217
218 // [id]
219 $fields[] = sprintf(__('%s - inserting ID of booking ' ,'booking'),'<code>[id]</code>');
220
221 // [resource_title] [bookingtype]
222 if ( class_exists('wpdev_bk_personal') )
223 if ( ! in_array( 'bookingtype', $skip_shortcodes ) )
224 $fields[] = sprintf(__('%s or %s - inserting the title of the booking resource ' ,'booking'),'<code>[resource_title]</code>','<code>[bookingtype]</code>');
225
226
227 // [cost]
228 if ( class_exists('wpdev_bk_biz_s') )
229 if ( ! in_array( 'cost', $skip_shortcodes ) )
230 $fields[] = sprintf(__('%s - inserting the cost of booking ' ,'booking'),'<code>[cost]</code>');
231
232 $fields[] = '<hr/>';
233
234
235 // [siteurl]
236 $fields[] = sprintf(__('%s - inserting your site URL ' ,'booking'),'<code>[siteurl]</code>');
237
238 if ( class_exists('wpdev_bk_personal') ) {
239 $fields[] = sprintf(__('%s - inserting IP address of the user who made this action ' ,'booking'),'<code>[remote_ip]</code>');
240 $fields[] = sprintf(__('%s - inserting contents of the User-Agent: header from the current request, if there is one ' ,'booking'),'<code>[user_agent]</code>');
241 $fields[] = sprintf(__('%s - inserting address of the page (if any), where visitor make this action ' ,'booking'),'<code>[request_url]</code>');
242 $fields[] = sprintf(__('%s - inserting time of this action ' ,'booking'),'<code>[current_time]</code>');
243 }
244
245 $fields[] = sprintf(__('%s - inserting date of this action ' ,'booking'),'<code>[current_date]</code>');
246
247 $fields[] = sprintf(__('%s - inserting modification date of booking ' ,'booking'),'<code>[modification_date]</code>');
248 $fields[] = sprintf(__('%s - inserting modification date of booking ' ,'booking'),'<code>[modification_year]</code>');
249 $fields[] = sprintf(__('%s - inserting modification date of booking ' ,'booking'),'<code>[modification_month]</code>');
250 $fields[] = sprintf(__('%s - inserting modification date of booking ' ,'booking'),'<code>[modification_day]</code>');
251 $fields[] = sprintf(__('%s - inserting modification date of booking ' ,'booking'),'<code>[modification_hour]</code>');
252 $fields[] = sprintf(__('%s - inserting modification date of booking ' ,'booking'),'<code>[modification_minutes]</code>');
253 $fields[] = sprintf(__('%s - inserting modification date of booking ' ,'booking'),'<code>[modification_seconds]</code>');
254 //FixIn: 10.0.0.34
255 $fields[] = sprintf(__('%s - inserting creation date of booking ' ,'booking'),'<code>[creation_date]</code>');
256 $fields[] = sprintf(__('%s - inserting creation date of booking ' ,'booking'),'<code>[creation_year]</code>');
257 $fields[] = sprintf(__('%s - inserting creation date of booking ' ,'booking'),'<code>[creation_month]</code>');
258 $fields[] = sprintf(__('%s - inserting creation date of booking ' ,'booking'),'<code>[creation_day]</code>');
259 $fields[] = sprintf(__('%s - inserting creation date of booking ' ,'booking'),'<code>[creation_hour]</code>');
260 $fields[] = sprintf(__('%s - inserting creation date of booking ' ,'booking'),'<code>[creation_minutes]</code>');
261 $fields[] = sprintf(__('%s - inserting creation date of booking ' ,'booking'),'<code>[creation_seconds]</code>');
262
263
264
265 // [moderatelink]
266 if ( ! in_array( 'moderatelink', $skip_shortcodes ) ) {
267 $fields[] = sprintf(__('%s - inserting moderate link of new booking ' ,'booking'),'<code>[moderatelink]</code>');
268
269 //FixIn: 8.4.7.25
270 $fields[] = sprintf(__('%s - inserting link to approve booking in 1 mouse click ' ,'booking'),'<code>[click2approve]</code>');
271 $fields[] = sprintf(__('%s - inserting link to set booking as pending in 1 mouse click ' ,'booking'),'<code>[click2decline]</code>');
272 $fields[] = sprintf(__('%s - inserting link for move booking to trash in 1 mouse click ' ,'booking'),'<code>[click2trash]</code>');
273
274 }
275
276 //FixIn: 9.6.3.8
277 if ( ! in_array( 'add_to_google_cal_button', $skip_shortcodes ) ) {
278 $fields[] = sprintf(__('%s - inserting link for export booking to' ,'booking'),'<code>[add_to_google_cal_button]</code>') . ' Google Calendar'; //FixIn: 7.1.2.5
279 $fields[] = sprintf(__('%s - inserting URL for export booking to' ,'booking'),'<code>[add_to_google_cal_url]</code>') . ' Google Calendar'; //FixIn: 7.1.2.5
280
281 }
282
283
284 if ( class_exists('wpdev_bk_personal') ) {
285
286 //FixIn: 8.1.3.5.1
287 if ( ! in_array( 'visitorbookingslisting', $skip_shortcodes ) )
288 $fields[] = sprintf(__('%s - inserting link to the page where visitor can see listing of own bookings, (possible to use the %s parameter for setting different %s of this page. Example: %s )' ,'booking'),'<code>[visitorbookingslisting]</code>', '"url"', 'URL', '<em>[visitorbookingslisting url="http://www.server.com/custom-page/"]</em>');
289
290 if ( ! in_array( 'visitorbookingediturl', $skip_shortcodes ) )
291 $fields[] = sprintf(__('%s - inserting link to the page where visitor can edit the reservation, (possible to use the %s parameter for setting different %s of this page. Example: %s )' ,'booking'),'<code>[visitorbookingediturl]</code>', '"url"', 'URL', '<em>[visitorbookingediturl url="http://www.server.com/custom-page/"]</em>');
292
293 // [visitorbookingcancelurl]
294 if ( ! in_array( 'visitorbookingcancelurl', $skip_shortcodes ) )
295 $fields[] = sprintf(__('%s - inserting link to the page where visitor can cancel the reservation, (possible to use the %s parameter for setting different %s of this page. Example: %s )' ,'booking'),'<code>[visitorbookingcancelurl]</code>', '"url"', 'URL', '<em>[visitorbookingcancelurl url="http://www.server.com/custom-page/"]</em>');
296
297 if ( class_exists('wpdev_bk_biz_s') ) {
298 // [visitorbookingpayurl]
299 if ( ! in_array( 'visitorbookingpayurl', $skip_shortcodes ) )
300 $fields[] = sprintf(__('%s - inserting link to payment page where visitor can pay for the reservation (possible to use the %s parameter for setting different %s of this page. Example: %s )' ,'booking'),'<code>[visitorbookingpayurl]</code>', '"url"', 'URL', '<em>[visitorbookingpayurl url="http://www.server.com/custom-page/"]</em>');
301
302 // [paymentreason]
303 if ( ! in_array( 'paymentreason', $skip_shortcodes ) )
304 $fields[] = sprintf(__('%s - add the reason for booking payment, you can enter it before sending email, ' ,'booking'),'<code>[paymentreason]</code>');
305 }
306 }
307
308 // [denyreason]
309 if ( ! in_array( 'denyreason', $skip_shortcodes ) )
310 $fields[] = sprintf(__('%s - add the reason booking was cancelled, you can enter it before sending email, ' ,'booking'),'<code>[denyreason]</code>');
311
312
313 //$fields[] = __('HTML tags is accepted.' ,'booking');
314
315 $fields[] = '<hr/>';
316
317 // show_additional_translation_shortcode_help
318 $fields[] = '<strong>' . sprintf(__('Configuration in several languages' ,'booking') ) . '.</strong>';
319 $fields[] = sprintf(__('%s - start new translation section, where %s - locale of translation' ,'booking'),'<code>[lang=LOCALE]</code>','<code>LOCALE</code>');
320 $fields[] = sprintf(__('Example #1: %s - start French translation section' ,'booking'),'<code>[lang=fr_FR]</code>');
321 $fields[] = sprintf(__('Example #2: "%s" - English and French translation of some message' ,'booking'),'<code>Thank you for your booking.[lang=fr_FR]Je vous remercie de votre reservation.</code>');
322
323
324 return $fields;
325 }
326
327
328 function wpbc_email_troubleshooting_help_notice(){
329
330 ?><div class="wpbc-settings-notice notice-warning notice-helpful-info">
331 <?php printf( __( 'To ensure your notifications arrive in your and your customers inboxes, we recommend connecting your email address to your domain and setting up a dedicated SMTP server. If something does not seem to be sending correctly, install the %s or check the %sEmail FAQ%s page.', 'booking' ),
332 '<a href="https://wordpress.org/plugins/wp-mail-logging/">WP Mail Logging Plugin</a>',
333 '<a href="https://wpbookingcalendar.com/faq/no-emails/">', '</a>' ); ?>
334 </div><?php
335 }
336
337
338 /**
339 * Check Email subject about Language sections
340 *
341 * @param string $subject
342 * @param string $email_id
343 * @return string
344 */
345 function wpbc_email_api_get_subject_before( $subject, $email_id ) {
346
347 $subject = wpbc_lang( $subject );
348
349 return $subject;
350 }
351 add_filter( 'wpbc_email_api_get_subject_before', 'wpbc_email_api_get_subject_before', 10, 2 ); // Hook fire in api-email.php
352
353
354 /**
355 * Check Email sections content about Language sections
356 *
357 * @param array $fields_values - list of params to parse: 'content', 'header_content', 'footer_content' for different languges, etc ....
358 * @param string $email_id - Email ID
359 * @param string $email_type - 'plain' | 'html'
360 */
361 function wpbc_email_api_get_content_before( $fields_values, $email_id , $email_type ) {
362
363 if ( isset( $fields_values['content'] ) ) {
364 $fields_values['content'] = wpbc_lang( $fields_values['content'] );
365 if ( $email_type == 'html' ) {
366 $fields_values['content'] = make_clickable( $fields_values['content'] );
367 }
368 }
369
370 if ( isset( $fields_values['header_content'] ) ) {
371 $fields_values['header_content'] = wpbc_lang( $fields_values['header_content'] );
372 }
373
374 if ( isset( $fields_values['footer_content'] ) ) {
375 $fields_values['footer_content'] = wpbc_lang( $fields_values['footer_content'] );
376 }
377
378 return $fields_values;
379 }
380 add_filter( 'wpbc_email_api_get_content_before', 'wpbc_email_api_get_content_before', 10, 3 ); // Hook fire in api-email.php
381
382
383 /**
384 * Modify email content, if needed. - In HTML mail content, make links clickable.
385 *
386 * @param array $email_content - content of Email
387 * @param string $email_id - Email ID
388 * @param string $email_type - 'plain' | 'html'
389 */
390 function wpbc_email_api_get_content_after( $email_content, $email_id , $email_type ) {
391
392 if ( ( $email_type == 'html' ) || ( $email_type == 'multipart' ) )
393 $email_content = make_clickable( $email_content );
394
395 return $email_content;
396 }
397 add_filter( 'wpbc_email_api_get_content_after', 'wpbc_email_api_get_content_after', 10, 3 ); // Hook fire in api-email.php
398
399
400 /**
401 * Check Email Headers - in New Booking Email (to admin) set Reply-To header to visitor email.
402 *
403 * @param string $headers
404 * @param string $email_id - Email ID
405 * @param array $fields_values - list of params to parse: 'content', 'header_content', 'footer_content' for different languges, etc ....
406 * @param array $replace_array - list of relpaced shortcodes
407 * @return string
408 */
409 function wpbc_email_api_get_headers_after( $mail_headers, $email_id , $fields_values , $replace_array, $additional_params = array() ) {
410
411 /*
412 // Default in api-emails.php:
413 // $mail_headers = 'From: ' . $this->get_from__name() . ' <' . $this->get_from__email_address() . '> ' . "\r\n" ;
414 // $mail_headers .= 'Content-Type: ' . $this->get_content_type() . "\r\n" ;
415 //
416 // $mail_headers = "From: $mail_sender\n";
417 // preg_match('/<(.*)>/', $mail_sender, $simple_email_matches );
418 // $reply_to_email = ( count( $simple_email_matches ) > 1 ) ? $simple_email_matches[1] : $mail_sender;
419 // $mail_headers .= 'Reply-To: ' . $reply_to_email . "\n";
420 // $mail_headers .= 'X-Sender: ' . $reply_to_email . "\n";
421 // $mail_headers .= 'Return-Path: ' . $reply_to_email . "\n";
422 */
423
424 //debuge($mail_headers, $email_id , $fields_values , $replace_array);
425 if (
426 ( $email_id == 'new_admin' ) // Only for email: "New Booking to Admin"
427 || ( isset( $additional_params['reply'] ) )
428 ){
429 //FixIn: 9.7.3.17
430 if (
431 ( ! empty( $replace_array['email'] ) )
432 && ( ! empty( $fields_values['enable_replyto'] ) )
433 && ( 'On' == $fields_values['enable_replyto'] )
434 ){ // Get email from the booking form.
435
436 $reply_to_email = sanitize_email( $replace_array['email'] );
437 if ( ! empty( $reply_to_email ) ) {
438 $mail_headers .= 'Reply-To: ' . $reply_to_email . "\r\n";
439 }
440 // $mail_headers .= 'X-Sender: ' . $reply_to_email . "\r\n" ;
441 // $mail_headers .= 'Return-Path: ' . $reply_to_email . "\r\n" ;
442 }
443 }
444
445 return $mail_headers;
446 }
447 add_filter( 'wpbc_email_api_get_headers_after', 'wpbc_email_api_get_headers_after', 10, 5 ); // Hook fire in api-email.php
448
449
450 /**
451 * Check if we can send Email - block sending in live demos
452 *
453 * @param bool $is_send_email
454 * @param string $email_id
455 * @param array $fields_values - list of params to parse: 'content', 'header_content', 'footer_content' for different languges, etc ....
456 * @return bool
457 */
458 function wpbc_email_api_is_allow_send( $is_send_email, $email_id, $fields_values ) {
459 //debuge($fields_values);
460 if ( wpbc_is_this_demo() )
461 $is_send_email = false;
462
463 return $is_send_email;
464 }
465 add_filter( 'wpbc_email_api_is_allow_send', 'wpbc_email_api_is_allow_send', 10, 3 ); // Hook fire in api-email.php
466
467
468 /**
469 * Show warning about not sending emails, and reason about this.
470 *
471 * @param object $wp_error_object - WP Error object
472 * @param string $error_description - Description
473 */
474 function wpbc_email_sending_error( $wp_error_object, $error_description = '' ) {
475
476 if ( ( defined( 'WPBC_AJAX_ERROR_CATCH' ) ) && ( WPBC_AJAX_ERROR_CATCH ) ) { return false; } //FixIn: 9.2.1.10
477
478 if ( empty( $error_description ) ) {
479 // $error_description = __( 'Unknown exception', 'booking' ) . '.'; // Overwrite to show error, if no description ???
480 }
481
482 if ( ! empty( $error_description ) ) {
483
484 $error_description = '' . __('Error', 'booking') . '! ' . __('Email was not sent. An error occurred.', 'booking') . ' ' . $error_description;
485
486 // Admin side
487 if ( function_exists( 'wpbc_show_message' ) ) {
488 wpbc_show_message ( $error_description , 15 , 'error');
489
490 }
491
492 // Front-end
493 ?>
494 <script type="text/javascript">
495 if (typeof( wpbc_front_end__show_message__warning_under_element ) == 'function') {
496 wpbc_front_end__show_message__warning_under_element( '.booking_form' , '<?php echo esc_js( $error_description ) ; ?>' );
497 }
498 </script>
499 <?php
500 } else {
501
502 // Error that have no description. Its can be Empty Object like this: WP_Error Object( 'errors' => array(), 'error_data' => array() ), or NOT
503 // debuge( $wp_error_object );
504 }
505 }
506 add_action('wpbc_email_sending_error', 'wpbc_email_sending_error', 10, 2);