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

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

595 lines 30.0 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 function wpbc_tooltip_help__fix_quote( $field_val ) {
179
180 $field_val = str_replace( '"', "'", $field_val );
181
182 return $field_val;
183 }
184
185 // Get Emails Help Shortcodes for Settings pages
186 function wpbc_get_email_help_shortcodes( $skip_shortcodes = array() , $email_example = '') {
187
188 $icn = '<a href="https://wpbookingcalendar.com/faq/email-shortcodes/#available_shortcodes"
189 class="tooltip_top wpbc-bi-question-circle wpbc_help_tooltip_icon_left"
190 data-original-title="%2$s"></a> %1$s';
191
192 $fields = array();
193
194 if ( class_exists('wpdev_bk_personal') ) {
195 $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'));
196 $fields[] = '<hr/>';
197 }
198 $fields[] = '<strong>' . esc_html__('You can use following shortcodes in content of this template' ,'booking') . '</strong>';
199
200 // [content]
201 if ( class_exists( 'wpdev_bk_personal' ) ) {
202 /* translators: 1: ... */
203 $fields[] = sprintf( $icn, '<code>[content]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - inserting data info about the booking, which you configured in the content form at Settings Fields page', 'booking' ), '[content]' ) ) );
204 } else {
205 /* translators: 1: ... */
206 $fields[] = sprintf( $icn, '<code>[content]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - inserting data info about the booking', 'booking' ), '[content]' ) ) );
207 }
208
209
210 // [dates]
211 /* translators: 1: ... */
212 $fields[] = sprintf( $icn, '<code>[dates]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - inserting the dates of booking' ,'booking'), '[dates]' ) ) );
213 /* translators: 1: ... */
214 $fields[] = sprintf( $icn, '<code>[only_dates]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - inserting only booking dates without times' ,'booking'), '[only_dates]' ) ) );
215
216 // [check_in_date]
217 if ( ! in_array( 'check_in_date', $skip_shortcodes ) ) {
218 /* translators: 1: ... */
219 $fields[] = sprintf( $icn, '<code>[check_in_date]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - inserting check-in date (first day of reservation),', 'booking' ), '[check_in_date]' ) ) );
220 /* translators: 1: ... */
221 $fields[] = sprintf( $icn, '<code>[check_in_only_date]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - inserting check-in date (only date without time) (first day of reservation),', 'booking' ), '[check_in_only_date]' ) ) ); // FixIn: 8.7.2.5.
222 }
223 // [check_out_date] [check_out_plus1day]
224 if ( ! in_array( 'check_out_date', $skip_shortcodes ) ) {
225 /* translators: 1: ... */
226 $fields[] = sprintf( $icn, '<code>[check_out_date]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - inserting check-out date (last day of reservation),' ,'booking'), '[check_out_date]' ) ) );
227 /* translators: 1: ... */
228 $fields[] = sprintf( $icn, '<code>[check_out_only_date]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - inserting check-out date (only date without time) (last day of reservation),' ,'booking'), '[check_out_only_date]' ) ) ); // FixIn: 8.7.2.5.
229 /* translators: 1: ... */
230 $fields[] = sprintf( $icn, '<code>[check_out_plus1day]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - inserting check-out date (last day of reservation),' ,'booking'), '[check_out_plus1day]') . ' + 1 ' . __('day', 'booking') ) );
231 }
232
233 // [dates_count]
234 if ( ! in_array( 'dates_count', $skip_shortcodes ) ) {
235 /* translators: 1: ... */
236 $fields[] = sprintf( $icn, '<code>[dates_count]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - inserting the number of booking dates ', 'booking' ), '[dates_count]' ) ) );
237 }
238
239 $fields[] = '<hr/>';
240
241
242 // [id]
243 /* translators: 1: ... */
244 $fields[] = sprintf( $icn, '<code>[booking_id]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - inserting ID of booking ' ,'booking'), '[id], [booking_id]' ) ) );
245
246 // [resource_title] [bookingtype]
247 if ( class_exists( 'wpdev_bk_personal' ) ) {
248 if ( ! in_array( 'bookingtype', $skip_shortcodes ) ) {
249 /* translators: 1: ... */
250 $fields[] = sprintf( $icn, '<code>[resource_title]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%1$s or %2$s - inserting the title of the booking resource ', 'booking' ), '[resource_title]', '[bookingtype]' ) ) );
251 }
252 }
253 // FixIn: 10.9.2.4.
254 if ( class_exists( 'wpdev_bk_biz_l' ) ) {
255 if ( ! in_array( 'bookingtype', $skip_shortcodes ) ) {
256 /* translators: 1: ... */
257 $fields[] = sprintf( $icn, '<code>[parent_resource_title]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - inserting the title of the parent booking resource ', 'booking' ), '[parent_resource_title]' ) ) );
258 }
259 }
260
261
262 // [cost]
263 if ( class_exists( 'wpdev_bk_biz_s' ) ) {
264 if ( ! in_array( 'cost', $skip_shortcodes ) ) {
265 /* translators: 1: ... */
266 $fields[] = sprintf( $icn, '<code>[cost]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - inserting the cost of booking ', 'booking' ), '[cost]' ) ) );
267 }
268 }
269
270 $fields[] = '<hr/>';
271
272 // [siteurl]
273 /* translators: 1: ... */
274 $fields[] = sprintf( $icn, '<code>[siteurl]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - inserting your site URL ' ,'booking'), '[siteurl]' ) ) );
275
276 if ( class_exists('wpdev_bk_personal') ) {
277 /* translators: 1: ... */
278 $fields[] = sprintf( $icn, '<code>[remote_ip]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - inserting IP address of the user who made this action ' ,'booking'), '[remote_ip]' ) ) );
279 /* translators: 1: ... */
280 $fields[] = sprintf( $icn, '<code>[user_agent]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - inserting contents of the User-Agent: header from the current request, if there is one ' ,'booking'), '[user_agent]' ) ) );
281 /* translators: 1: ... */
282 $fields[] = sprintf( $icn, '<code>[request_url]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - inserting address of the page (if any), where visitor make this action ' ,'booking'), '[request_url]' ) ) );
283 /* translators: 1: ... */
284 $fields[] = sprintf( $icn, '<code>[current_time]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - inserting time of this action ' ,'booking'), '[current_time]' ) ) );
285 }
286
287 /* translators: 1: ... */
288 $fields[] = sprintf( $icn, '<code>[current_date]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - inserting date of this action ' ,'booking'), '[current_date]' ) ) );
289
290 /* translators: 1: ... */
291 $fields[] = sprintf( $icn, '<code>[modification_date]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - inserting modification date of booking ' ,'booking'), '[modification_date]' ) ) );
292 /* translators: 1: ... */
293 $fields[] = sprintf( $icn, '<code>[modification_year]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - inserting modification date of booking ' ,'booking'), '[modification_year]' ) ) );
294 /* translators: 1: ... */
295 $fields[] = sprintf( $icn, '<code>[modification_month]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - inserting modification date of booking ' ,'booking'), '[modification_month]' ) ) );
296 /* translators: 1: ... */
297 $fields[] = sprintf( $icn, '<code>[modification_day]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - inserting modification date of booking ' ,'booking'), '[modification_day]' ) ) );
298 /* translators: 1: ... */
299 $fields[] = sprintf( $icn, '<code>[modification_hour]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - inserting modification date of booking ' ,'booking'), '[modification_hour]' ) ) );
300 /* translators: 1: ... */
301 $fields[] = sprintf( $icn, '<code>[modification_minutes]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - inserting modification date of booking ' ,'booking'), '[modification_minutes]' ) ) );
302 /* translators: 1: ... */
303 $fields[] = sprintf( $icn, '<code>[modification_seconds]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - inserting modification date of booking ' ,'booking'), '[modification_seconds]' ) ) );
304 // FixIn: 10.0.0.34.
305 /* translators: 1: ... */
306 $fields[] = sprintf( $icn, '<code>[creation_date]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - inserting creation date of booking ' ,'booking'), '[creation_date]' ) ) );
307 /* translators: 1: ... */
308 $fields[] = sprintf( $icn, '<code>[creation_year]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - inserting creation date of booking ' ,'booking'), '[creation_year]' ) ) );
309 /* translators: 1: ... */
310 $fields[] = sprintf( $icn, '<code>[creation_month]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - inserting creation date of booking ' ,'booking'), '[creation_month]' ) ) );
311 /* translators: 1: ... */
312 $fields[] = sprintf( $icn, '<code>[creation_day]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - inserting creation date of booking ' ,'booking'), '[creation_day]' ) ) );
313 /* translators: 1: ... */
314 $fields[] = sprintf( $icn, '<code>[creation_hour]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - inserting creation date of booking ' ,'booking'), '[creation_hour]' ) ) );
315 /* translators: 1: ... */
316 $fields[] = sprintf( $icn, '<code>[creation_minutes]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - inserting creation date of booking ' ,'booking'), '[creation_minutes]' ) ) );
317 /* translators: 1: ... */
318 $fields[] = sprintf( $icn, '<code>[creation_seconds]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - inserting creation date of booking ' ,'booking'), '[creation_seconds]' ) ) );
319
320
321
322 // [moderatelink]
323 if ( ! in_array( 'moderatelink', $skip_shortcodes ) ) {
324 /* translators: 1: ... */
325 $fields[] = sprintf( $icn, '<code>[moderatelink]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - inserting moderate link of new booking ' ,'booking'), '[moderatelink]' ) ) );
326
327 // FixIn: 8.4.7.25.
328 /* translators: 1: ... */
329 $fields[] = sprintf( $icn, '<code>[click2approve]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - inserting link to approve booking in 1 mouse click ' ,'booking'), '[click2approve]' ) ) );
330 /* translators: 1: ... */
331 $fields[] = sprintf( $icn, '<code>[click2decline]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - inserting link to set booking as pending in 1 mouse click ' ,'booking'), '[click2decline]' ) ) );
332 /* translators: 1: ... */
333 $fields[] = sprintf( $icn, '<code>[click2trash]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - inserting link for move booking to trash in 1 mouse click ' ,'booking'), '[click2trash]' ) ) );
334
335 }
336
337 // FixIn: 9.6.3.8.
338 if ( ! in_array( 'add_to_google_cal_button', $skip_shortcodes ) ) {
339 /* translators: 1: ... */
340 $fields[] = sprintf( $icn, '<code>[add_to_google_cal_button]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - inserting link for export booking to' ,'booking'), '[add_to_google_cal_button]') . ' Google Calendar' ) );
341 /* translators: 1: ... */
342 $fields[] = sprintf( $icn, '<code>[add_to_google_cal_url]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - inserting URL for export booking to' ,'booking'), '[add_to_google_cal_url]') . ' Google Calendar' ) );
343
344 }
345
346
347 if ( class_exists('wpdev_bk_personal') ) {
348
349 //FixIn: 8.1.3.5.1
350 if ( ! in_array( 'visitorbookingslisting', $skip_shortcodes ) ) {
351 /* translators: 1: ... */
352 $fields[] = sprintf( $icn, '<code>[visitorbookingslisting]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%1$s - inserting link to the page where visitor can see listing of own bookings, (possible to use the %2$s parameter for setting different %3$s of this page. Example: %4$s )', 'booking' ), '[visitorbookingslisting]', '"url"', 'URL', '[visitorbookingslisting url="http://www.server.com/custom-page/"]' )
353 /* translators: 1: ... */
354 . ' ' . sprintf( __( 'Example of HTML a link usage: %s )', 'booking' ), '[visitorbookingslisting url="http://www.server.com/listing-custom-page/" type="link" title="Listing"]]' ) ) );
355 }
356
357 if ( ! in_array( 'visitorbookingediturl', $skip_shortcodes ) ) {
358 /* translators: 1: ... */
359 $fields[] = sprintf( $icn, '<code>[visitorbookingediturl]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%1$s - inserting link to the page where visitor can edit the reservation, (possible to use the %2$s parameter for setting different %3$s of this page. Example: %4$s )', 'booking' ), '[visitorbookingediturl]', '"url"', 'URL', '[visitorbookingediturl url="http://www.server.com/custom-page/"]' )
360 /* translators: 1: ... */
361 . ' ' . sprintf( __( 'Example of HTML a link usage: %s )', 'booking' ), '[visitorbookingediturl url="http://www.server.com/edit-custom-page/" type="link" title="Edit Booking"]]' ) ) );
362 }
363 // [visitorbookingcancelurl]
364 if ( ! in_array( 'visitorbookingcancelurl', $skip_shortcodes ) ) {
365
366 /* translators: 1: ... */
367 $fields[] = sprintf( $icn, '<code>[visitorbookingcancelurl]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%1$s - inserting link to the page where visitor can cancel the reservation, (possible to use the %2$s parameter for setting different %3$s of this page. Example: %4$s )', 'booking' ), '[visitorbookingcancelurl]', '"url"', 'URL', '[visitorbookingcancelurl url="http://www.server.com/custom-page/"]' )
368 /* translators: 1: ... */
369 . ' ' . sprintf( __( 'Example of HTML a link usage: %s )' ,'booking'), '[visitorbookingcancelurl url="http://www.server.com/cancel-custom-page/" type="link" title="Cancel Booking"]]' )
370 ) );
371 }
372
373 if ( class_exists('wpdev_bk_biz_s') ) {
374 // [visitorbookingpayurl]
375 if ( ! in_array( 'visitorbookingpayurl', $skip_shortcodes ) ) {
376 /* translators: 1: ... */
377 $fields[] = sprintf( $icn, '<code>[visitorbookingpayurl]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%1$s - inserting link to payment page where visitor can pay for the reservation (possible to use the %2$s parameter for setting different %3$s of this page. Example: %4$s )', 'booking' ), '[visitorbookingpayurl]', '"url"', 'URL', '[visitorbookingpayurl url="http://www.server.com/custom-page/"]' )
378 /* translators: 1: ... */
379 . ' ' . sprintf( __( 'Example of HTML a link usage: %s )', 'booking' ), '[visitorbookingpayurl url="http://www.server.com/payment-custom-page/" type="link" title="Pay Now"]]' ) ) );
380 }
381
382 // [paymentreason]
383 if ( ! in_array( 'paymentreason', $skip_shortcodes ) ) {
384 /* translators: 1: ... */
385 $fields[] = sprintf( $icn, '<code>[paymentreason]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - add the reason for booking payment, you can enter it before sending email, ', 'booking' ), '[paymentreason]' ) ) );
386 }
387 }
388 }
389
390 // [denyreason]
391 if ( ! in_array( 'denyreason', $skip_shortcodes ) ) {
392 /* translators: 1: ... */
393 $fields[] = sprintf( $icn, '<code>[denyreason]</code>', wpbc_tooltip_help__fix_quote( sprintf( __( '%s - add the reason booking was cancelled, you can enter it before sending email, ', 'booking' ), '[denyreason]' ) ) );
394 }
395
396
397 //$fields[] = __('HTML tags is accepted.' ,'booking');
398
399 $fields[] = '<hr/>';
400
401 // show_additional_translation_shortcode_help
402 $fields[] = '<strong>' . sprintf(__('Configuration in several languages' ,'booking') ) . '.</strong>';
403 /* translators: 1: ... */
404 $fields[] = sprintf( __( '%1$s - start new translation section, where %2$s - locale of translation', 'booking' ),'<code>[lang=LOCALE]</code>','<code>LOCALE</code>');
405 /* translators: 1: ... */
406 $fields[] = sprintf(__( 'Example #1: %s - start French translation section' ,'booking'),'<code>[lang=fr_FR]</code>');
407 /* translators: 1: ... */
408 $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>');
409
410
411 return $fields;
412 }
413
414
415 function wpbc_email_troubleshooting_help_notice(){
416
417 ?><div class="wpbc-settings-notice notice-warning notice-helpful-info">
418 <?php
419 /* translators: 1: ... */
420 echo wp_kses_post( sprintf( __( '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 %1$s or check the %2$sEmail FAQ%3$s page.', 'booking' ),
421 '<a href="https://wordpress.org/plugins/wp-mail-logging/">WP Mail Logging Plugin</a>',
422 '<a href="https://wpbookingcalendar.com/faq/no-emails/">', '</a>' ) ); ?>
423 </div><?php
424 }
425
426
427 /**
428 * Check Email subject about Language sections
429 *
430 * @param string $subject
431 * @param string $email_id
432 * @return string
433 */
434 function wpbc_email_api_get_subject_before( $subject, $email_id ) {
435
436 $subject = wpbc_lang( $subject );
437
438 return $subject;
439 }
440 add_filter( 'wpbc_email_api_get_subject_before', 'wpbc_email_api_get_subject_before', 10, 2 ); // Hook fire in api-email.php
441
442
443 /**
444 * Check Email sections content about Language sections
445 *
446 * @param array $fields_values - list of params to parse: 'content', 'header_content', 'footer_content' for different languges, etc ....
447 * @param string $email_id - Email ID
448 * @param string $email_type - 'plain' | 'html'
449 */
450 function wpbc_email_api_get_content_before( $fields_values, $email_id , $email_type ) {
451
452 if ( isset( $fields_values['content'] ) ) {
453 $fields_values['content'] = wpbc_lang( $fields_values['content'] );
454 if ( $email_type == 'html' ) {
455 $fields_values['content'] = make_clickable( $fields_values['content'] );
456 }
457 }
458
459 if ( isset( $fields_values['header_content'] ) ) {
460 $fields_values['header_content'] = wpbc_lang( $fields_values['header_content'] );
461 }
462
463 if ( isset( $fields_values['footer_content'] ) ) {
464 $fields_values['footer_content'] = wpbc_lang( $fields_values['footer_content'] );
465 }
466
467 return $fields_values;
468 }
469 add_filter( 'wpbc_email_api_get_content_before', 'wpbc_email_api_get_content_before', 10, 3 ); // Hook fire in api-email.php
470
471
472 /**
473 * Modify email content, if needed. - In HTML mail content, make links clickable.
474 *
475 * @param array $email_content - content of Email
476 * @param string $email_id - Email ID
477 * @param string $email_type - 'plain' | 'html'
478 */
479 function wpbc_email_api_get_content_after( $email_content, $email_id , $email_type ) {
480
481 if ( ( $email_type == 'html' ) || ( $email_type == 'multipart' ) )
482 $email_content = make_clickable( $email_content );
483
484 return $email_content;
485 }
486 add_filter( 'wpbc_email_api_get_content_after', 'wpbc_email_api_get_content_after', 10, 3 ); // Hook fire in api-email.php
487
488
489 /**
490 * Check Email Headers - in New Booking Email (to admin) set Reply-To header to visitor email.
491 *
492 * @param string $headers
493 * @param string $email_id - Email ID
494 * @param array $fields_values - list of params to parse: 'content', 'header_content', 'footer_content' for different languges, etc ....
495 * @param array $replace_array - list of relpaced shortcodes
496 * @return string
497 */
498 function wpbc_email_api_get_headers_after( $mail_headers, $email_id , $fields_values , $replace_array, $additional_params = array() ) {
499
500 /*
501 // Default in api-emails.php:
502 // $mail_headers = 'From: ' . $this->get_from__name() . ' <' . $this->get_from__email_address() . '> ' . "\r\n" ;
503 // $mail_headers .= 'Content-Type: ' . $this->get_content_type() . "\r\n" ;
504 //
505 // $mail_headers = "From: $mail_sender\n";
506 // preg_match('/<(.*)>/', $mail_sender, $simple_email_matches );
507 // $reply_to_email = ( count( $simple_email_matches ) > 1 ) ? $simple_email_matches[1] : $mail_sender;
508 // $mail_headers .= 'Reply-To: ' . $reply_to_email . "\n";
509 // $mail_headers .= 'X-Sender: ' . $reply_to_email . "\n";
510 // $mail_headers .= 'Return-Path: ' . $reply_to_email . "\n";
511 */
512
513 //debuge($mail_headers, $email_id , $fields_values , $replace_array);
514 if (
515 ( $email_id == 'new_admin' ) // Only for email: "New Booking to Admin"
516 || ( isset( $additional_params['reply'] ) )
517 ){
518 // FixIn: 9.7.3.17.
519 if (
520 ( ! empty( $replace_array['email'] ) )
521 && ( ! empty( $fields_values['enable_replyto'] ) )
522 && ( 'On' == $fields_values['enable_replyto'] )
523 ){ // Get email from the booking form.
524
525 $reply_to_email = sanitize_email( $replace_array['email'] );
526 if ( ! empty( $reply_to_email ) ) {
527 $mail_headers .= 'Reply-To: ' . $reply_to_email . "\r\n";
528 }
529 // $mail_headers .= 'X-Sender: ' . $reply_to_email . "\r\n" ;
530 // $mail_headers .= 'Return-Path: ' . $reply_to_email . "\r\n" ;
531 }
532 }
533
534 return $mail_headers;
535 }
536 add_filter( 'wpbc_email_api_get_headers_after', 'wpbc_email_api_get_headers_after', 10, 5 ); // Hook fire in api-email.php
537
538
539 /**
540 * Check if we can send Email - block sending in live demos
541 *
542 * @param bool $is_send_email
543 * @param string $email_id
544 * @param array $fields_values - list of params to parse: 'content', 'header_content', 'footer_content' for different languges, etc ....
545 * @return bool
546 */
547 function wpbc_email_api_is_allow_send( $is_send_email, $email_id, $fields_values ) {
548 //debuge($fields_values);
549 if ( wpbc_is_this_demo() )
550 $is_send_email = false;
551
552 return $is_send_email;
553 }
554 add_filter( 'wpbc_email_api_is_allow_send', 'wpbc_email_api_is_allow_send', 10, 3 ); // Hook fire in api-email.php
555
556
557 /**
558 * Show warning about not sending emails, and reason about this.
559 *
560 * @param object $wp_error_object - WP Error object
561 * @param string $error_description - Description
562 */
563 function wpbc_email_sending_error( $wp_error_object, $error_description = '' ) {
564
565 if ( ( defined( 'WPBC_AJAX_ERROR_CATCH' ) ) && ( WPBC_AJAX_ERROR_CATCH ) ) { return false; } // FixIn: 9.2.1.10.
566
567 if ( empty( $error_description ) ) {
568 // $error_description = __( 'Unknown exception', 'booking' ) . '.'; // Overwrite to show error, if no description ???
569 }
570
571 if ( ! empty( $error_description ) ) {
572
573 $error_description = '' . __('Error', 'booking') . '! ' . __('Email was not sent. An error occurred.', 'booking') . ' ' . $error_description;
574
575 // Admin side
576 if ( function_exists( 'wpbc_show_message' ) ) {
577 wpbc_show_message ( $error_description , 15 , 'error');
578
579 }
580
581 // Front-end
582 ?>
583 <script type="text/javascript">
584 if (typeof( wpbc_front_end__show_message__warning_under_element ) == 'function') {
585 wpbc_front_end__show_message__warning_under_element( '.booking_form' , '<?php echo esc_js( $error_description ) ; ?>' );
586 }
587 </script>
588 <?php
589 } else {
590
591 // Error that have no description. Its can be Empty Object like this: WP_Error Object( 'errors' => array(), 'error_data' => array() ), or NOT
592 // debuge( $wp_error_object );
593 }
594 }
595 add_action('wpbc_email_sending_error', 'wpbc_email_sending_error', 10, 2);