PluginProbe
Booktics – Appointment Booking Calendar for Service Businesses / trunk
Booktics – Appointment Booking Calendar for Service Businesses vtrunk
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 1.0.4 1.0.5 1.0.6 1.0.7 All 27 releases
booktics / core / admin / notification.php

notification.php in Booktics – Appointment Booking Calendar for Service Businesses trunk, at core/admin/notification.php

459 lines 14.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 }
459