PluginProbe
Booktics – Appointment Booking Calendar for Service Businesses / 1.0.22
Booktics – Appointment Booking Calendar for Service Businesses v1.0.22
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
booktics / core / customer / handlers / customer-event-handler.php

customer-event-handler.php in Booktics – Appointment Booking Calendar for Service Businesses 1.0.22, at core/customer/handlers/customer-event-handler.php

72 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Booktics\Customer\Handlers;
4
5 if ( ! defined( 'ABSPATH' ) ) exit;
6
7 use Booktics\Models\Customer_Model;
8
9 class Customer_Event_Handler {
10
11 /**
12 * Send invitation mail on customer creation
13 *
14 * @param $customer_id
15 *
16 * @return bool
17 */
18 public function on_customer_create( $customer_id ) {
19 $customer = ( new Customer_Model() )->find( $customer_id );
20 $user = get_user_by( 'ID', $customer_id );
21 $reset_key = get_password_reset_key( $user );
22 $reset_url = network_site_url( "wp-login.php?action=rp&key=$reset_key&login=" . rawurlencode( $user->user_login ), 'login' );
23
24 add_filter(
25 'notification_sdk_email_body', array(
26 $this,
27 'wrap_email_body',
28 ), 10, 1
29 );
30 do_action(
31 'booktics_gln_hook', 'customer_created', array(
32 'customer_first_name' => $customer->first_name,
33 'customer_last_name' => $customer->last_name,
34 'customer_full_name' => $customer->display_name,
35 'customer_phone' => $customer->phone,
36 'customer_user_name' => $customer->user_login,
37 'customer_email' => $customer->user_email,
38 'password_reset_url' => $reset_url,
39 )
40 );
41
42 return true;
43 }
44
45
46 /**
47 * Wrap email body content with template and replace variables
48 *
49 * @param string $message Email body content to be wrapped
50 *
51 * @return string Modified email body content with template applied
52 */
53 public function wrap_email_body( $message ) {
54
55 $template_path = BOOKTICS_DIR . '/templates/email/team-member-create.html';
56
57 if ( ! file_exists( $template_path ) ) {
58 return $message;
59 }
60 $template = file_get_contents( $template_path );
61 $default_image = get_template_directory_uri() . '/assets/images/placeholder.jpg';
62 $variables = array(
63 '{{MESSAGE}}' => wp_kses_post( $message ),
64 '{{COMPANY_NAME}}' => booktics_get_option( 'business_name', 'Booktics' ),
65 '{{COMPANY_LOGO}}' => booktics_get_option( 'business_logo', $default_image ),
66 '{{COMPANY_ADDRESS}}' => booktics_get_option( 'business_address', 'California, USA' ),
67 );
68
69 return str_replace( array_keys( $variables ), array_values( $variables ), $template );
70 }
71 }
72