PluginProbe
Booking Calendar / 11.6
Booking Calendar v11.6
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 / includes / page-setup / templates / 02.general_info__action.php

02.general_info__action.php in Booking Calendar 11.6, at includes/page-setup/templates/02.general_info__action.php

207 lines 7.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php /**
2 * @version 1.0
3 * @description Action for Template Setup pages
4 * @category Setup Action
5 * @author wpdevelop
6 *
7 * @web-site http://oplugins.com/
8 * @email info@oplugins.com
9 *
10 * @modified 2024-09-29
11 */
12
13 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
14
15
16 // -------------------------------------------------------------------------------------------------------------
17 // == Action - General Info ==
18 // -------------------------------------------------------------------------------------------------------------
19 /**
20 * Template - General Info - Step 01
21 *
22 * Help Tips:
23 *
24 * <script type="text/html" id="tmpl-template_name_a">
25 * Escaped: {{data.test_key}}
26 * HTML: {{{data.test_key}}}
27 * JS: <# if (true) { alert( 1 ); } #>
28 * </script>
29 *
30 * var template__var = wp.template( 'template_name_a' );
31 *
32 * jQuery( '.content' ).html( template__var( { 'test_key' => '<strong>Data</strong>' } ) );
33 *
34 * @return void
35 */
36
37
38 function wpbc_template__general_info__action_validate_data( $post_data ){
39
40 $escaped_data = array(
41 'wpbc_swp_industry' => '',
42 'type' => '', // FixIn: 10.7.1.3.
43 'days' => '',
44 'version' => 'V: ' .wpbc_feedback_01_get_version(),
45 'wpbc_swp_booking_who_setup' => '',
46 'wpbc_swp_business_name' => '',
47 'wpbc_swp_email' => '',
48 'wpbc_swp_accept_send' => 'Off'
49 );
50
51 $how_old_info_arr = wpbc_get_info__about_how_old();
52 if ( ! empty( $how_old_info_arr ) ) {
53 $escaped_data['days'] = 'Days: ' . $how_old_info_arr['days'];
54 }
55
56 $key = 'wpbc_swp_industry';
57 if ( ( isset( $post_data[ $key ] ) ) && ( ! empty( ( $post_data[ $key ] ) ) ) ) {
58 $escaped_data[ $key ] = 'Industry: ' . wpbc_clean_text_value( $post_data[ $key ] );
59 }
60 $key = 'wpbc_swp_booking_who_setup';
61 if ( ( isset( $post_data[ $key ] ) ) && ( ! empty( ( $post_data[ $key ] ) ) ) ) {
62 $escaped_data[ $key ] = 'Who_setup: ' . wpbc_clean_text_value( $post_data[ $key ] );
63 }
64 $key = 'wpbc_swp_business_name';
65 if ( ( isset( $post_data[ $key ] ) ) && ( ! empty( ( $post_data[ $key ] ) ) ) ) {
66 $escaped_data[ $key ] = 'Business_name: ' . wpbc_clean_text_value( $post_data[ $key ] );
67 }
68 $key = 'wpbc_swp_email';
69 if ( ( isset( $post_data[ $key ] ) ) && ( ! empty( ( $post_data[ $key ] ) ) ) ) {
70 $escaped_data[ $key ] = 'Email: ' . wpbc_clean_text_value( $post_data[ $key ] );
71 }
72 $key = 'wpbc_swp_accept_send';
73 if ( ( isset( $post_data[ $key ] ) ) && ( ! empty( ( $post_data[ $key ] ) ) ) ) {
74 $escaped_data[ $key ] = wpbc_clean_text_value( $post_data[ $key ] );
75 }
76
77 return $escaped_data;
78 }
79
80
81 /**
82 * Send email with Setup Feedback
83 *
84 * @param $feedback_description
85 *
86 * @return void
87 */
88 function wpbc_setup_feedback__send_email( $feedback_description_arr ) {
89 $feedback_description = implode( "\n", $feedback_description_arr);
90
91 $us_data = wp_get_current_user();
92
93 $fields_values = array();
94 $fields_values['from_email'] = get_option( 'admin_email' );
95 $fields_values['from_name'] = $us_data->display_name;
96 $fields_values['from_name'] = wp_specialchars_decode( esc_html( stripslashes( $fields_values['from_name'] ) ), ENT_QUOTES );
97 $fields_values['from_email'] = sanitize_email( $fields_values['from_email'] );
98
99 $subject = 'WPBC - Initial Setup';
100
101
102 $message = '';// '=============================================' . "\n";
103 $message .= $feedback_description . "\n";
104 $message .= '=============================================' . "\n";
105 $message .="\n";
106
107 $message .= $fields_values['from_name'] . "\n";
108 $message .="\n";
109 $message .= '---------------------------------------------' . "\n";
110
111 $message .= 'Booking Calendar ' . wpbc_feedback_01_get_version() . "\n";
112
113 $how_old_info_arr = wpbc_get_info__about_how_old();
114 if ( ! empty( $how_old_info_arr ) ) {
115 $message .= "\n";
116 $message .= 'From: ' . $how_old_info_arr['date_echo'];
117 $message .= ' - ' . $how_old_info_arr['days'] . ' days ago.';
118 }
119
120 $message .="\n";
121 $message .= '---------------------------------------------' . "\n";
122 $message .= '[' . date_i18n( get_bk_option( 'booking_date_format' ) ) . ' ' . date_i18n( get_bk_option( 'booking_time_format' ) ) . ']'. "\n";
123 $message .= home_url() ;
124
125 $headers = '';
126
127 if ( ! empty( $fields_values['from_email'] ) ) {
128
129 $headers .= 'From: ' . $fields_values['from_name'] . ' <' . $fields_values['from_email'] . '> ' . "\r\n";
130 } else {
131 /* If we don't have an email from the input headers default to wordpress@$sitename
132 * Some hosts will block outgoing mail from this address if it doesn't exist but
133 * there's no easy alternative. Defaulting to admin_email might appear to be another
134 * option but some hosts may refuse to relay mail from an unknown domain. See
135 * https://core.trac.wordpress.org/ticket/5007.
136 */
137 }
138 $headers .= 'Content-Type: ' . 'text/plain' . "\r\n" ; // 'text/html'
139
140 $attachments = '';
141
142
143 $to = 'setup_feedback@wpbookingcalendar.com';
144
145 // debuge('In email', htmlentities($to), $subject, htmlentities($message), $headers, $attachments) ;
146 // debuge( '$to, $subject, $message, $headers, $attachments',htmlspecialchars($to), htmlspecialchars($subject), htmlspecialchars($message), htmlspecialchars($headers), htmlspecialchars($attachments));
147 if ( wpbc_email_api_is_allow_send( true, '', '' ) ) {
148 $return = @wp_mail( $to, $subject, $message, $headers, $attachments );
149 }
150 }
151
152
153 /**
154 * Update "General Data" like "Email" and "Title"
155 *
156 * @param $cleaned_data array(
157 * 'wpbc_swp_business_name' => '',
158 * 'wpbc_swp_booking_who_setup' => '',
159 * 'wpbc_swp_industry' => '',
160 * 'wpbc_swp_email' => '',
161 * 'wpbc_swp_accept_send' => 'Off'
162 *
163 * )
164 *
165 * @return void
166 */
167 function wpbc_setup__update__general_info( $cleaned_data ){
168
169 if ( ( ! empty( $cleaned_data['wpbc_swp_email'] ) ) && ( false !== is_email( $cleaned_data['wpbc_swp_email'] ) ) ) {
170
171 //update_bk_option( 'wpbc_swp_email', $cleaned_data['wpbc_swp_email'] );
172
173 // -------------------------------------------------------------------------------------------------------------
174 // Update Emails
175 // -------------------------------------------------------------------------------------------------------------
176 $email_option_names = array( WPBC_EMAIL_NEW_ADMIN_PREFIX . WPBC_EMAIL_NEW_ADMIN_ID
177 , WPBC_EMAIL_NEW_VISITOR_PREFIX . WPBC_EMAIL_NEW_VISITOR_ID
178 , WPBC_EMAIL_APPROVED_PREFIX . WPBC_EMAIL_APPROVED_ID
179 , WPBC_EMAIL_DENY_PREFIX . WPBC_EMAIL_DENY_ID
180 , WPBC_EMAIL_TRASH_PREFIX . WPBC_EMAIL_TRASH_ID
181 , WPBC_EMAIL_DELETED_PREFIX . WPBC_EMAIL_DELETED_ID
182 );
183 if ( class_exists( 'wpdev_bk_personal' ) ) {
184 $email_option_names[] = WPBC_EMAIL_MODIFICATION_PREFIX . WPBC_EMAIL_MODIFICATION_ID;
185 }
186 if ( class_exists('wpdev_bk_biz_s')) {
187 $email_option_names[] = WPBC_EMAIL_PAYMENT_REQUEST_PREFIX . WPBC_EMAIL_PAYMENT_REQUEST_ID;
188 }
189 foreach ( $email_option_names as $email_option_name ) {
190
191 // Get Email Data
192 $email_data = get_bk_option( $email_option_name );
193
194 $email_data['from'] = $cleaned_data['wpbc_swp_email'];
195
196 if ( $email_option_name === WPBC_EMAIL_NEW_ADMIN_PREFIX . WPBC_EMAIL_NEW_ADMIN_ID ) {
197 $email_data['to'] = $cleaned_data['wpbc_swp_email'];
198 } else {
199 $email_data['to'] = $cleaned_data['wpbc_swp_email'];
200 }
201
202 // Update Email Data
203 update_bk_option( $email_option_name, $email_data );
204 }
205 // -------------------------------------------------------------------------------------------------------------
206 }
207 }