PluginProbe
Booktics – Appointment Booking Calendar for Service Businesses / 1.0.21
Booktics – Appointment Booking Calendar for Service Businesses v1.0.21
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 1.0.21, at core/admin/notification.php

451 lines 13.8 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 $actions = array(
46 array(
47 'trigger_label' => __( 'Order Created', 'booktics' ),
48 'trigger_value' => 'order_created',
49 'trigger_data' => array(
50 array(
51 'label' => __( 'Order No', 'booktics' ),
52 'value' => 'order_no',
53 'type' => 'string',
54 ),
55 array(
56 'label' => __( 'Order Status', 'booktics' ),
57 'value' => 'order_status',
58 'type' => 'string',
59 ),
60 array(
61 'label' => __( 'Order Date', 'booktics' ),
62 'value' => 'order_date',
63 'type' => 'date',
64 ),
65 array(
66 'label' => __( 'Service Name', 'booktics' ),
67 'value' => 'service_name',
68 'type' => 'string',
69 ),
70 array(
71 'label' => __( 'Team Name', 'booktics' ),
72 'value' => 'team_name',
73 'type' => 'string',
74 ),
75 array(
76 'label' => __( 'Appointment Date', 'booktics' ),
77 'value' => 'appointment_date',
78 'type' => 'date',
79 ),
80 array(
81 'label' => __( 'Appointment Status', 'booktics' ),
82 'value' => 'appointment_status',
83 'type' => 'string',
84 ),
85 array(
86 'label' => __( 'Start Time', 'booktics' ),
87 'value' => 'start_time',
88 'type' => 'string',
89 ),
90 array(
91 'label' => __( 'End Time', 'booktics' ),
92 'value' => 'end_time',
93 'type' => 'string',
94 ),
95 array(
96 'label' => __( 'Location Address', 'booktics' ),
97 'value' => 'location_address',
98 'type' => 'string',
99 ),
100 array(
101 'label' => __( 'Order Total', 'booktics' ),
102 'value' => 'order_total',
103 'type' => 'string',
104 ),
105 array(
106 'label' => __( 'Customer Name', 'booktics' ),
107 'value' => 'customer_name',
108 'type' => 'string',
109 ),
110 array(
111 'label' => __( 'Google meet Url', 'booktics' ),
112 'value' => 'google_meet_url',
113 'type' => 'string',
114 ),
115 array(
116 'label' => __( 'Appointment Reschedule Url', 'booktics' ),
117 'value' => 'appointment_reschedule_url',
118 'type' => 'string',
119 ),
120 array(
121 'label' => __( 'Appointment Cancel Url', 'booktics' ),
122 'value' => 'appointment_cancel_url',
123 'type' => 'string',
124 ),
125 array(
126 'label' => __( 'User Email', 'booktics' ),
127 'value' => 'user_email',
128 'type' => 'string',
129 ),
130 ),
131 'delay_dependencies' => array(
132 array(
133 'label' => 'Order Date',
134 'value' => 'order_date',
135 ),
136 ),
137 'email_receivers' => array(
138 array(
139 'label' => __( 'User Email', 'booktics' ),
140 'value' => 'user_email',
141 ),
142 ),
143 ),
144 array(
145 'trigger_label' => __( 'Appointment Scheduled', 'booktics' ),
146 'trigger_value' => 'appointment_scheduled',
147 'trigger_data' => array(
148 array(
149 'label' => __( 'Service Name', 'booktics' ),
150 'value' => 'appointment_service',
151 'type' => 'string',
152 ),
153 array(
154 'label' => __( 'Team Member Name', 'booktics' ),
155 'value' => 'appointment_team_member',
156 'type' => 'string',
157 ),
158 array(
159 'label' => __( 'Appointment Date', 'booktics' ),
160 'value' => 'appointment_date',
161 'type' => 'date',
162 ),
163 array(
164 'label' => __( 'Appointment Start Time', 'booktics' ),
165 'value' => 'start_time',
166 'type' => 'string',
167 ),
168 array(
169 'label' => __( 'Appointment Time', 'booktics' ),
170 'value' => 'appointment_time',
171 'type' => 'date',
172 ),
173 array(
174 'label' => __( 'Attendee Count', 'booktics' ),
175 'value' => 'attendee_count',
176 'type' => 'string',
177 ),
178 array(
179 'label' => __( 'Customer Name', 'booktics' ),
180 'value' => 'customer_name',
181 'type' => 'string',
182 ),
183 array(
184 'label' => __( 'User Email', 'booktics' ),
185 'value' => 'user_email',
186 'type' => 'string',
187 ),
188 array(
189 'label' => __( 'Google Meet URL', 'booktics' ),
190 'value' => 'google_meet_url',
191 'type' => 'string',
192 ),
193 array(
194 'label' => __( 'Extra Services', 'booktics' ),
195 'value' => 'extra_services',
196 'type' => 'string',
197 ),
198 ),
199 'delay_dependencies' => array(
200 array(
201 'label' => __( 'Appointment Time', 'booktics' ),
202 'value' => 'before_appointment_time',
203 ),
204 ),
205 'email_receivers' => array(
206 array(
207 'label' => __( 'User Email', 'booktics' ),
208 'value' => 'user_email',
209 ),
210 array(
211 'label' => __( 'Team Member Email', 'booktics' ),
212 'value' => 'appointment_team_member_email',
213 ),
214 ),
215 ),
216 array(
217 'trigger_label' => __( 'Appointment Rescheduled', 'booktics' ),
218 'trigger_value' => 'appointment_rescheduled',
219 'trigger_data' => array(
220 array(
221 'label' => __( 'Service Name', 'booktics' ),
222 'value' => 'appointment_service',
223 'type' => 'string',
224 ),
225 array(
226 'label' => __( 'Date', 'booktics' ),
227 'value' => 'date',
228 'type' => 'date',
229 ),
230 array(
231 'label' => __( 'Team Member Name', 'booktics' ),
232 'value' => 'appointment_team_member',
233 'type' => 'string',
234 ),
235 array(
236 'label' => __( 'Start Time', 'booktics' ),
237 'value' => 'start_time',
238 'type' => 'string',
239 ),
240 array(
241 'label' => __( 'End Time', 'booktics' ),
242 'value' => 'end_time',
243 'type' => 'string',
244 ),
245 array(
246 'label' => __( 'Customer Name', 'booktics' ),
247 'value' => 'customer_name',
248 'type' => 'string',
249 ),
250 array(
251 'label' => __( 'User Email', 'booktics' ),
252 'value' => 'user_email',
253 'type' => 'string',
254 ),
255 ),
256 'delay_dependencies' => array(
257 array(
258 'label' => __( 'Date', 'booktics' ),
259 'value' => 'date',
260 ),
261 ),
262 'email_receivers' => array(
263 array(
264 'label' => __( 'User Email', 'booktics' ),
265 'value' => 'user_email',
266 ),
267 array(
268 'label' => __( 'Team Member Email', 'booktics' ),
269 'value' => 'appointment_team_member_email',
270 ),
271 ),
272 ),
273 array(
274 'trigger_label' => __( 'Appointment Cancelled', 'booktics' ),
275 'trigger_value' => 'appointment_cancelled',
276 'trigger_data' => array(
277 array(
278 'label' => __( 'Service Name', 'booktics' ),
279 'value' => 'appointment_service',
280 'type' => 'string',
281 ),
282 array(
283 'label' => __( 'Date', 'booktics' ),
284 'value' => 'date',
285 'type' => 'date',
286 ),
287 array(
288 'label' => __( 'Team Member Name', 'booktics' ),
289 'value' => 'appointment_team_member',
290 'type' => 'string',
291 ),
292 array(
293 'label' => __( 'Start Time', 'booktics' ),
294 'value' => 'start_time',
295 'type' => 'string',
296 ),
297 array(
298 'label' => __( 'End Time', 'booktics' ),
299 'value' => 'end_time',
300 'type' => 'string',
301 ),
302 array(
303 'label' => __( 'Customer Name', 'booktics' ),
304 'value' => 'customer_name',
305 'type' => 'string',
306 ),
307 array(
308 'label' => __( 'User Email', 'booktics' ),
309 'value' => 'user_email',
310 'type' => 'string',
311 ),
312 ),
313 'delay_dependencies' => array(
314 array(
315 'label' => __( 'Date', 'booktics' ),
316 'value' => 'date',
317 ),
318 ),
319 'email_receivers' => array(
320 array(
321 'label' => __( 'User Email', 'booktics' ),
322 'value' => 'user_email',
323 ),
324 array(
325 'label' => __( 'Team Member Email', 'booktics' ),
326 'value' => 'appointment_team_member_email',
327 ),
328 ),
329 ),
330 array(
331 'trigger_label' => __( 'Team Member Created', 'booktics' ),
332 'trigger_value' => 'team_member_created',
333 'trigger_data' => array(
334 array(
335 'label' => __( 'Team Member Name', 'booktics' ),
336 'value' => 'team_member_name',
337 'type' => 'string',
338 ),
339 array(
340 'label' => __( 'Team Member Email', 'booktics' ),
341 'value' => 'team_member_email',
342 'type' => 'string',
343 ),
344 array(
345 'label' => __( 'Password Reset URL', 'booktics' ),
346 'value' => 'password_reset_url',
347 'type' => 'string',
348 ),
349 ),
350 'delay_dependencies' => array(),
351 'email_receivers' => array(
352 array(
353 'label' => __( 'Team Member Email', 'booktics' ),
354 'value' => 'team_member_email',
355 ),
356 ),
357 ),
358 array(
359 'trigger_label' => __( 'Customer Created', 'booktics' ),
360 'trigger_value' => 'customer_created',
361 'trigger_data' => array(
362 array(
363 'label' => __( 'Customer First Name', 'booktics' ),
364 'value' => 'customer_first_name',
365 'type' => 'string',
366 ),
367 array(
368 'label' => __( 'Customer Last Name', 'booktics' ),
369 'value' => 'customer_last_name',
370 'type' => 'string',
371 ),
372 array(
373 'label' => __( 'Customer Full Name', 'booktics' ),
374 'value' => 'customer_full_name',
375 'type' => 'string',
376 ),
377 array(
378 'label' => __( 'Customer Phone', 'booktics' ),
379 'value' => 'customer_phone',
380 'type' => 'string',
381 ),
382 array(
383 'label' => __( 'Customer User Name', 'booktics' ),
384 'value' => 'customer_user_name',
385 'type' => 'string',
386 ),
387 array(
388 'label' => __( 'Customer Email', 'booktics' ),
389 'value' => 'customer_email',
390 'type' => 'string',
391 ),
392 array(
393 'label' => __( 'Password Reset URL', 'booktics' ),
394 'value' => 'password_reset_url',
395 'type' => 'string',
396 ),
397 ),
398 'delay_dependencies' => array(),
399 'email_receivers' => array(
400 array(
401 'label' => __( 'Customer Email', 'booktics' ),
402 'value' => 'customer_email',
403 ),
404 ),
405 ),
406 );
407
408 return $actions;
409 }
410 );
411 }
412 }
413
414 /**
415 * Wrap email body with custom template
416 *
417 * @param string $message
418 * @return string
419 */
420 public function wrap_email_body( $message ) {
421
422 $template_path = BOOKTICS_DIR . '/templates/email/team-member-create.html';
423
424 if ( ! file_exists( $template_path ) ) {
425 return $message;
426 }
427 $template = file_get_contents( $template_path );
428 $default_image = get_template_directory_uri() . '/assets/images/placeholder.jpg';
429 $plugin_name = apply_filters(
430 'booktics_plugin_name',
431 BOOKTICS_PLUGIN_NAME
432 );
433 $show_powered_by = apply_filters( 'booktics_show_email_powered_by', true );
434
435 // Build powered-by HTML if enabled
436 $powered_by_html = '';
437 if ( $show_powered_by ) {
438 $powered_by_html = '<p class="bkt-powered-by">Powered by ' . esc_html( $plugin_name ) . '</p>';
439 }
440 $variables = array(
441 '{{MESSAGE}}' => wp_kses_post( $message ),
442 '{{COMPANY_NAME}}' => booktics_get_option( 'business_name', get_bloginfo( 'name' ) ),
443 '{{COMPANY_LOGO}}' => booktics_get_option( 'business_logo', $default_image ),
444 '{{COMPANY_ADDRESS}}' => booktics_get_option( 'business_address', 'California, USA' ),
445 '{%powered_by_section%}' => $powered_by_html,
446 );
447
448 return str_replace( array_keys( $variables ), array_values( $variables ), $template );
449 }
450 }
451