PluginProbe
Booktics – Appointment Booking Calendar for Service Businesses / 1.0.28
Booktics – Appointment Booking Calendar for Service Businesses v1.0.28
1.0.29 1.0.28 1.0.27 1.0.26 1.0.25 1.0.24 1.0.23 1.0.22 1.0.21 1.0.20 1.0.19 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.2 1.0.3 All 31 releases
← All changes | core/admin/notification.php +458 -263 1.0.1 → 1.0.28 View file →
@@ -1,263 +1,458 @@
1 -<?php
2 -
3 -namespace Booktics\Admin;
4 -
5 -use Booktics\Contracts\Hookable_Service_Contract;
6 -use ENS\Core\SDK;
7 -
8 -class Notification implements Hookable_Service_Contract {
9 -
10 - /**
11 - * Register notification
12 - *
13 - * @return void
14 - */
15 - public function register() {
16 - if ( class_exists( SDK::class ) ) {
17 - SDK::get_instance()
18 - ->setup(
19 - array(
20 - 'plugin_name' => 'Booktics',
21 - 'plugin_slug' => 'booktics',
22 - 'general_prefix' => 'bt',
23 - 'text_domain' => 'booktics',
24 - 'admin_script_handler' => 'booktics-dashboard-scripts',
25 - 'sub_menu_filter_hook' => 'booktics_menu',
26 - 'sub_menu_details' =>
27 - array(
28 - 'id' => 'booktics-automation',
29 - 'title' => __( 'Automation', 'booktics' ),
30 - 'link' => '/automation',
31 - 'capability' => apply_filters( 'booktics_menu_permission_automation_dashboard', 'manage_options' ),
32 - 'position' => apply_filters( 'booktics_menu_position_automation', 11 ),
33 - ),
34 - )
35 - )
36 - ->init();
37 -
38 - add_filter(
39 - 'ens_available_actions', function ( $actions ) {
40 - $actions = array(
41 - array(
42 - 'trigger_label' => 'Order Created',
43 - 'trigger_value' => 'order_created',
44 - 'trigger_data' => array(
45 - array(
46 - 'label' => 'Order No',
47 - 'value' => 'order_no',
48 - 'type' => 'string',
49 - ),
50 - array(
51 - 'label' => 'Order Date',
52 - 'value' => 'order_date',
53 - 'type' => 'date',
54 - ),
55 - array(
56 - 'label' => 'Order Total',
57 - 'value' => 'order_total',
58 - 'type' => 'string',
59 - ),
60 - array(
61 - 'label' => 'User Email',
62 - 'value' => 'user_email',
63 - 'type' => 'string',
64 - ),
65 - ),
66 - 'delay_dependencies' => array(
67 - array(
68 - 'label' => 'Order Date',
69 - 'value' => 'order_date',
70 - ),
71 - ),
72 - 'email_receivers' => array(
73 - array(
74 - 'label' => 'User Email',
75 - 'value' => 'user_email',
76 - ),
77 - ),
78 - ),
79 - array(
80 - 'trigger_label' => 'Appointment Scheduled',
81 - 'trigger_value' => 'appointment_scheduled',
82 - 'trigger_data' => array(
83 - array(
84 - 'label' => 'Service Name',
85 - 'value' => 'appointment_service',
86 - 'type' => 'string',
87 - ),
88 - array(
89 - 'label' => 'Team Member Name',
90 - 'value' => 'appointment_team_member',
91 - 'type' => 'string',
92 - ),
93 - array(
94 - 'label' => 'Appointment Date',
95 - 'value' => 'appointment_date',
96 - 'type' => 'date',
97 - ),
98 - array(
99 - 'label' => 'Appointment Start Time',
100 - 'value' => 'start_time',
101 - 'type' => 'string',
102 - ),
103 - array(
104 - 'label' => 'Appointment Time',
105 - 'value' => 'appointment_time',
106 - 'type' => 'date',
107 - ),
108 - array(
109 - 'label' => 'Attendee Count',
110 - 'value' => 'attendee_count',
111 - 'type' => 'string',
112 - ),
113 - array(
114 - 'label' => 'User Email',
115 - 'value' => 'user_email',
116 - 'type' => 'string',
117 - ),
118 - ),
119 - 'delay_dependencies' => array(
120 - array(
121 - 'label' => 'Appointment Time',
122 - 'value' => 'before_appointment_time',
123 - ),
124 - ),
125 - 'email_receivers' => array(
126 - array(
127 - 'label' => 'User Email',
128 - 'value' => 'user_email',
129 - ),
130 - ),
131 - ),
132 - array(
133 - 'trigger_label' => 'Appointment Rescheduled',
134 - 'trigger_value' => 'appointment_rescheduled',
135 - 'trigger_data' => array(
136 - array(
137 - 'label' => 'Service Name',
138 - 'value' => 'appointment_service',
139 - 'type' => 'string',
140 - ),
141 - array(
142 - 'label' => 'Date',
143 - 'value' => 'date',
144 - 'type' => 'date',
145 - ),
146 - array(
147 - 'label' => 'Team Member Name',
148 - 'value' => 'appointment_team_member',
149 - 'type' => 'string',
150 - ),
151 - array(
152 - 'label' => 'Start Time',
153 - 'value' => 'start_time',
154 - 'type' => 'string',
155 - ),
156 - array(
157 - 'label' => 'End Time',
158 - 'value' => 'end_time',
159 - 'type' => 'string',
160 - ),
161 - array(
162 - 'label' => 'User Email',
163 - 'value' => 'user_email',
164 - 'type' => 'string',
165 - ),
166 - ),
167 - 'delay_dependencies' => array(
168 - array(
169 - 'label' => 'Date',
170 - 'value' => 'date',
171 - ),
172 - ),
173 - 'email_receivers' => array(
174 - array(
175 - 'label' => 'User Email',
176 - 'value' => 'user_email',
177 - ),
178 - ),
179 - ),
180 - array(
181 - 'trigger_label' => 'Appointment Cancelled',
182 - 'trigger_value' => 'appointment_cancelled',
183 - 'trigger_data' => array(
184 - array(
185 - 'label' => 'Service Name',
186 - 'value' => 'appointment_service',
187 - 'type' => 'string',
188 - ),
189 - array(
190 - 'label' => 'Date',
191 - 'value' => 'date',
192 - 'type' => 'date',
193 - ),
194 - array(
195 - 'label' => 'Team Member Name',
196 - 'value' => 'appointment_team_member',
197 - 'type' => 'string',
198 - ),
199 - array(
200 - 'label' => 'Start Time',
201 - 'value' => 'start_time',
202 - 'type' => 'string',
203 - ),
204 - array(
205 - 'label' => 'End Time',
206 - 'value' => 'end_time',
207 - 'type' => 'string',
208 - ),
209 - array(
210 - 'label' => 'User Email',
211 - 'value' => 'user_email',
212 - 'type' => 'string',
213 - ),
214 - ),
215 - 'delay_dependencies' => array(
216 - array(
217 - 'label' => 'Date',
218 - 'value' => 'date',
219 - ),
220 - ),
221 - 'email_receivers' => array(
222 - array(
223 - 'label' => 'User Email',
224 - 'value' => 'user_email',
225 - ),
226 - ),
227 - ),
228 - array(
229 - 'trigger_label' => 'Team Member Created',
230 - 'trigger_value' => 'team_member_created',
231 - 'trigger_data' => array(
232 - array(
233 - 'label' => 'Team Member Name',
234 - 'value' => 'team_member_name',
235 - 'type' => 'string',
236 - ),
237 - array(
238 - 'label' => 'Team Member Email',
239 - 'value' => 'team_member_email',
240 - 'type' => 'string',
241 - ),
242 - array(
243 - 'label' => 'Password Reset URL',
244 - 'value' => 'password_reset_url',
245 - 'type' => 'string',
246 - ),
247 - ),
248 - 'delay_dependencies' => array(),
249 - 'email_receivers' => array(
250 - array(
251 - 'label' => 'Team Member Email',
252 - 'value' => 'team_member_email',
253 - ),
254 - ),
255 - ),
256 - );
257 -
258 - return $actions;
259 - }
260 - );
261 - }
262 - }
263 -}
1 +<?php
2 +
3 +namespace Booktics\Admin;
4 +
5 +if ( ! defined( 'ABSPATH' ) ) exit;
6 +
7 +use Booktics\Contracts\Hookable_Service_Contract;
8 +use Ens\Core\SDK;
9 +
10 +class Notification implements Hookable_Service_Contract {
11 +
12 + /**
13 + * Register notification
14 + *
15 + * @return void
16 + */
17 + public function register() {
18 + if ( class_exists( SDK::class ) ) {
19 + add_filter( 'notification_sdk_email_body', [ $this, 'wrap_email_body' ], 10, 1 );
20 +
21 + SDK::get_instance()
22 + ->setup(
23 + array(
24 + 'plugin_name' => 'Booktics',
25 + 'plugin_slug' => 'booktics',
26 + 'general_prefix' => 'bt',
27 + 'hook_prefix' => 'booktics',
28 + 'text_domain' => 'booktics',
29 + 'admin_script_handler' => 'booktics-dashboard-scripts',
30 + 'sub_menu_filter_hook' => 'booktics_menu',
31 + 'sub_menu_details' =>
32 + array(
33 + 'id' => 'booktics-automation',
34 + 'title' => __( 'Automation', 'booktics' ),
35 + 'link' => '/automation',
36 + 'capability' => apply_filters( 'booktics_menu_permission_automation_dashboard', 'manage_options' ),
37 + 'position' => apply_filters( 'booktics_menu_position_automation', 11 ),
38 + ),
39 + )
40 + )
41 + ->init();
42 +
43 + add_filter(
44 + 'ens_bt_available_actions', function ( $actions ) {
45 + // Google Meet link generation is gated behind Pro (the pro plugin is what
46 + // adds the enable_google_meet field to the service model), but the tag
47 + // itself is registered here in free. Without this, a free user picks the
48 + // tag, gets an empty value in the email and reads it as a broken feature.
49 + $meet_label = booktics_is_pro_active()
50 + ? __( 'Google Meet URL', 'booktics' )
51 + : __( 'Google Meet URL (Pro)', 'booktics' );
52 +
53 + $actions = array(
54 + array(
55 + 'trigger_label' => __( 'Order Created', 'booktics' ),
56 + 'trigger_value' => 'order_created',
57 + 'trigger_data' => array(
58 + array(
59 + 'label' => __( 'Order No', 'booktics' ),
60 + 'value' => 'order_no',
61 + 'type' => 'string',
62 + ),
63 + array(
64 + 'label' => __( 'Order Status', 'booktics' ),
65 + 'value' => 'order_status',
66 + 'type' => 'string',
67 + ),
68 + array(
69 + 'label' => __( 'Order Date', 'booktics' ),
70 + 'value' => 'order_date',
71 + 'type' => 'date',
72 + ),
73 + array(
74 + 'label' => __( 'Service Name', 'booktics' ),
75 + 'value' => 'service_name',
76 + 'type' => 'string',
77 + ),
78 + array(
79 + 'label' => __( 'Team Name', 'booktics' ),
80 + 'value' => 'team_name',
81 + 'type' => 'string',
82 + ),
83 + array(
84 + 'label' => __( 'Appointment Date', 'booktics' ),
85 + 'value' => 'appointment_date',
86 + 'type' => 'date',
87 + ),
88 + array(
89 + 'label' => __( 'Appointment Status', 'booktics' ),
90 + 'value' => 'appointment_status',
91 + 'type' => 'string',
92 + ),
93 + array(
94 + 'label' => __( 'Start Time', 'booktics' ),
95 + 'value' => 'start_time',
96 + 'type' => 'string',
97 + ),
98 + array(
99 + 'label' => __( 'End Time', 'booktics' ),
100 + 'value' => 'end_time',
101 + 'type' => 'string',
102 + ),
103 + array(
104 + 'label' => __( 'Location Address', 'booktics' ),
105 + 'value' => 'location_address',
106 + 'type' => 'string',
107 + ),
108 + array(
109 + 'label' => __( 'Order Total', 'booktics' ),
110 + 'value' => 'order_total',
111 + 'type' => 'string',
112 + ),
113 + array(
114 + 'label' => __( 'Customer Name', 'booktics' ),
115 + 'value' => 'customer_name',
116 + 'type' => 'string',
117 + ),
118 + array(
119 + 'label' => $meet_label,
120 + 'value' => 'google_meet_url',
121 + 'type' => 'string',
122 + ),
123 + array(
124 + 'label' => __( 'Appointment Reschedule Url', 'booktics' ),
125 + 'value' => 'appointment_reschedule_url',
126 + 'type' => 'string',
127 + ),
128 + array(
129 + 'label' => __( 'Appointment Cancel Url', 'booktics' ),
130 + 'value' => 'appointment_cancel_url',
131 + 'type' => 'string',
132 + ),
133 + array(
134 + 'label' => __( 'User Email', 'booktics' ),
135 + 'value' => 'user_email',
136 + 'type' => 'string',
137 + ),
138 + ),
139 + 'delay_dependencies' => array(
140 + array(
141 + 'label' => 'Order Date',
142 + 'value' => 'order_date',
143 + ),
144 + ),
145 + 'email_receivers' => array(
146 + array(
147 + 'label' => __( 'User Email', 'booktics' ),
148 + 'value' => 'user_email',
149 + ),
150 + ),
151 + ),
152 + array(
153 + 'trigger_label' => __( 'Appointment Scheduled', 'booktics' ),
154 + 'trigger_value' => 'appointment_scheduled',
155 + 'trigger_data' => array(
156 + array(
157 + 'label' => __( 'Service Name', 'booktics' ),
158 + 'value' => 'appointment_service',
159 + 'type' => 'string',
160 + ),
161 + array(
162 + 'label' => __( 'Team Member Name', 'booktics' ),
163 + 'value' => 'appointment_team_member',
164 + 'type' => 'string',
165 + ),
166 + array(
167 + 'label' => __( 'Appointment Date', 'booktics' ),
168 + 'value' => 'appointment_date',
169 + 'type' => 'date',
170 + ),
171 + array(
172 + 'label' => __( 'Appointment Start Time', 'booktics' ),
173 + 'value' => 'start_time',
174 + 'type' => 'string',
175 + ),
176 + array(
177 + 'label' => __( 'Appointment Time', 'booktics' ),
178 + 'value' => 'appointment_time',
179 + 'type' => 'date',
180 + ),
181 + array(
182 + 'label' => __( 'Attendee Count', 'booktics' ),
183 + 'value' => 'attendee_count',
184 + 'type' => 'string',
185 + ),
186 + array(
187 + 'label' => __( 'Customer Name', 'booktics' ),
188 + 'value' => 'customer_name',
189 + 'type' => 'string',
190 + ),
191 + array(
192 + 'label' => __( 'User Email', 'booktics' ),
193 + 'value' => 'user_email',
194 + 'type' => 'string',
195 + ),
196 + array(
197 + 'label' => $meet_label,
198 + 'value' => 'google_meet_url',
199 + 'type' => 'string',
200 + ),
201 + array(
202 + 'label' => __( 'Extra Services', 'booktics' ),
203 + 'value' => 'extra_services',
204 + 'type' => 'string',
205 + ),
206 + ),
207 + 'delay_dependencies' => array(
208 + array(
209 + 'label' => __( 'Appointment Time', 'booktics' ),
210 + 'value' => 'before_appointment_time',
211 + ),
212 + ),
213 + 'email_receivers' => array(
214 + array(
215 + 'label' => __( 'User Email', 'booktics' ),
216 + 'value' => 'user_email',
217 + ),
218 + array(
219 + 'label' => __( 'Team Member Email', 'booktics' ),
220 + 'value' => 'appointment_team_member_email',
221 + ),
222 + ),
223 + ),
224 + array(
225 + 'trigger_label' => __( 'Appointment Rescheduled', 'booktics' ),
226 + 'trigger_value' => 'appointment_rescheduled',
227 + 'trigger_data' => array(
228 + array(
229 + 'label' => __( 'Service Name', 'booktics' ),
230 + 'value' => 'appointment_service',
231 + 'type' => 'string',
232 + ),
233 + array(
234 + 'label' => __( 'Date', 'booktics' ),
235 + 'value' => 'date',
236 + 'type' => 'date',
237 + ),
238 + array(
239 + 'label' => __( 'Team Member Name', 'booktics' ),
240 + 'value' => 'appointment_team_member',
241 + 'type' => 'string',
242 + ),
243 + array(
244 + 'label' => __( 'Start Time', 'booktics' ),
245 + 'value' => 'start_time',
246 + 'type' => 'string',
247 + ),
248 + array(
249 + 'label' => __( 'End Time', 'booktics' ),
250 + 'value' => 'end_time',
251 + 'type' => 'string',
252 + ),
253 + array(
254 + 'label' => __( 'Customer Name', 'booktics' ),
255 + 'value' => 'customer_name',
256 + 'type' => 'string',
257 + ),
258 + array(
259 + 'label' => __( 'User Email', 'booktics' ),
260 + 'value' => 'user_email',
261 + 'type' => 'string',
262 + ),
263 + ),
264 + 'delay_dependencies' => array(
265 + array(
266 + 'label' => __( 'Date', 'booktics' ),
267 + 'value' => 'date',
268 + ),
269 + ),
270 + 'email_receivers' => array(
271 + array(
272 + 'label' => __( 'User Email', 'booktics' ),
273 + 'value' => 'user_email',
274 + ),
275 + array(
276 + 'label' => __( 'Team Member Email', 'booktics' ),
277 + 'value' => 'appointment_team_member_email',
278 + ),
279 + ),
280 + ),
281 + array(
282 + 'trigger_label' => __( 'Appointment Cancelled', 'booktics' ),
283 + 'trigger_value' => 'appointment_cancelled',
284 + 'trigger_data' => array(
285 + array(
286 + 'label' => __( 'Service Name', 'booktics' ),
287 + 'value' => 'appointment_service',
288 + 'type' => 'string',
289 + ),
290 + array(
291 + 'label' => __( 'Date', 'booktics' ),
292 + 'value' => 'date',
293 + 'type' => 'date',
294 + ),
295 + array(
296 + 'label' => __( 'Team Member Name', 'booktics' ),
297 + 'value' => 'appointment_team_member',
298 + 'type' => 'string',
299 + ),
300 + array(
301 + 'label' => __( 'Start Time', 'booktics' ),
302 + 'value' => 'start_time',
303 + 'type' => 'string',
304 + ),
305 + array(
306 + 'label' => __( 'End Time', 'booktics' ),
307 + 'value' => 'end_time',
308 + 'type' => 'string',
309 + ),
310 + array(
311 + 'label' => __( 'Customer Name', 'booktics' ),
312 + 'value' => 'customer_name',
313 + 'type' => 'string',
314 + ),
315 + array(
316 + 'label' => __( 'User Email', 'booktics' ),
317 + 'value' => 'user_email',
318 + 'type' => 'string',
319 + ),
320 + ),
321 + 'delay_dependencies' => array(
322 + array(
323 + 'label' => __( 'Date', 'booktics' ),
324 + 'value' => 'date',
325 + ),
326 + ),
327 + 'email_receivers' => array(
328 + array(
329 + 'label' => __( 'User Email', 'booktics' ),
330 + 'value' => 'user_email',
331 + ),
332 + array(
333 + 'label' => __( 'Team Member Email', 'booktics' ),
334 + 'value' => 'appointment_team_member_email',
335 + ),
336 + ),
337 + ),
338 + array(
339 + 'trigger_label' => __( 'Team Member Created', 'booktics' ),
340 + 'trigger_value' => 'team_member_created',
341 + 'trigger_data' => array(
342 + array(
343 + 'label' => __( 'Team Member Name', 'booktics' ),
344 + 'value' => 'team_member_name',
345 + 'type' => 'string',
346 + ),
347 + array(
348 + 'label' => __( 'Team Member Email', 'booktics' ),
349 + 'value' => 'team_member_email',
350 + 'type' => 'string',
351 + ),
352 + array(
353 + 'label' => __( 'Password Reset URL', 'booktics' ),
354 + 'value' => 'password_reset_url',
355 + 'type' => 'string',
356 + ),
357 + ),
358 + 'delay_dependencies' => array(),
359 + 'email_receivers' => array(
360 + array(
361 + 'label' => __( 'Team Member Email', 'booktics' ),
362 + 'value' => 'team_member_email',
363 + ),
364 + ),
365 + ),
366 + array(
367 + 'trigger_label' => __( 'Customer Created', 'booktics' ),
368 + 'trigger_value' => 'customer_created',
369 + 'trigger_data' => array(
370 + array(
371 + 'label' => __( 'Customer First Name', 'booktics' ),
372 + 'value' => 'customer_first_name',
373 + 'type' => 'string',
374 + ),
375 + array(
376 + 'label' => __( 'Customer Last Name', 'booktics' ),
377 + 'value' => 'customer_last_name',
378 + 'type' => 'string',
379 + ),
380 + array(
381 + 'label' => __( 'Customer Full Name', 'booktics' ),
382 + 'value' => 'customer_full_name',
383 + 'type' => 'string',
384 + ),
385 + array(
386 + 'label' => __( 'Customer Phone', 'booktics' ),
387 + 'value' => 'customer_phone',
388 + 'type' => 'string',
389 + ),
390 + array(
391 + 'label' => __( 'Customer User Name', 'booktics' ),
392 + 'value' => 'customer_user_name',
393 + 'type' => 'string',
394 + ),
395 + array(
396 + 'label' => __( 'Customer Email', 'booktics' ),
397 + 'value' => 'customer_email',
398 + 'type' => 'string',
399 + ),
400 + array(
401 + 'label' => __( 'Password Reset URL', 'booktics' ),
402 + 'value' => 'password_reset_url',
403 + 'type' => 'string',
404 + ),
405 + ),
406 + 'delay_dependencies' => array(),
407 + 'email_receivers' => array(
408 + array(
409 + 'label' => __( 'Customer Email', 'booktics' ),
410 + 'value' => 'customer_email',
411 + ),
412 + ),
413 + ),
414 + );
415 +
416 + return $actions;
417 + }
418 + );
419 + }
420 + }
421 +
422 + /**
423 + * Wrap email body with custom template
424 + *
425 + * @param string $message
426 + * @return string
427 + */
428 + public function wrap_email_body( $message ) {
429 +
430 + $template_path = BOOKTICS_DIR . '/templates/email/team-member-create.html';
431 +
432 + if ( ! file_exists( $template_path ) ) {
433 + return $message;
434 + }
435 + $template = file_get_contents( $template_path );
436 + $default_image = get_template_directory_uri() . '/assets/images/placeholder.jpg';
437 + $plugin_name = apply_filters(
438 + 'booktics_plugin_name',
439 + BOOKTICS_PLUGIN_NAME
440 + );
441 + $show_powered_by = apply_filters( 'booktics_show_email_powered_by', true );
442 +
443 + // Build powered-by HTML if enabled
444 + $powered_by_html = '';
445 + if ( $show_powered_by ) {
446 + $powered_by_html = '<p class="bkt-powered-by">Powered by ' . esc_html( $plugin_name ) . '</p>';
447 + }
448 + $variables = array(
449 + '{{MESSAGE}}' => wp_kses_post( $message ),
450 + '{{COMPANY_NAME}}' => booktics_get_option( 'business_name', get_bloginfo( 'name' ) ),
451 + '{{COMPANY_LOGO}}' => booktics_get_option( 'business_logo', $default_image ),
452 + '{{COMPANY_ADDRESS}}' => booktics_get_option( 'business_address', 'California, USA' ),
453 + '{%powered_by_section%}' => $powered_by_html,
454 + );
455 +
456 + return str_replace( array_keys( $variables ), array_values( $variables ), $template );
457 + }
458 +}