PluginProbe
Timetics – Appointment Booking Calendar & Scheduling / 1.0.56
Timetics – Appointment Booking Calendar & Scheduling v1.0.56
1.0.61 1.0.60 1.0.59 1.0.58 1.0.57 1.0.56 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.19 1.0.2 1.0.20 1.0.21 1.0.22 1.0.23 1.0.24 All 62 releases
timetics / core / emails / email.php

email.php in Timetics – Appointment Booking Calendar & Scheduling 1.0.56, at core/emails/email.php

172 lines 3.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Core email class
4 *
5 * @package Timetics
6 */
7
8 namespace Timetics\Core\Emails;
9
10 defined( 'ABSPATH' ) || exit;
11
12 /**
13 * Class Email
14 */
15 abstract class Email {
16 /**
17 * Constructor for core email class
18 *
19 * @return void
20 */
21 public function __construct() {
22 add_action( 'timetics-email-header', [$this, 'add_email_header'] );
23 add_action( 'timetics-email-footer', [$this, 'add_email_footer'] );
24 add_action( 'timetics-email-body', [$this, 'add_email_body'] );
25 }
26
27 /**
28 * Get email subject
29 *
30 * @return string
31 */
32 abstract public function get_subject();
33
34 /**
35 * Get email html template
36 *
37 * @return string
38 */
39 abstract public function get_template();
40
41 /**
42 * Get email recipent
43 *
44 * @return string
45 */
46 abstract public function get_recipient();
47
48 /**
49 * Get email header
50 *
51 * @return string
52 */
53 public function get_headers() {
54 $headers = 'MIME-Version: 1.0' . "\r\n";
55 $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
56 $from = get_bloginfo( 'name' );
57 $from_email = timetics_get_option('booking_created_customer_email_from');
58
59 // Append the "From" header
60 $headers .= 'From: ' .$from. ' <' . $from_email . '> ' . "\r\n";
61
62 return $headers;
63 }
64
65 /**
66 * Add email header
67 *
68 * @return void
69 */
70 public function add_email_header() {
71 include TIMETICS_PLUGIN_DIR . '/templates/emails/email-header.php';
72 }
73
74 /**
75 * Add email body
76 *
77 * @return void
78 */
79 public function add_email_body() {
80 $template = $this->get_template();
81
82 if ( file_exists( $template ) ) {
83 ob_start(); // Start output buffering
84 include $template;
85 $body = ob_get_clean(); // Retrieve and clean output buffer
86 echo wp_kses_post( $body ); // Output the email body
87 }
88 }
89 /**
90 * Add email footer
91 *
92 * @return void
93 */
94 public function add_email_footer() {
95 include TIMETICS_PLUGIN_DIR . '/templates/emails/email-footer.php';
96 }
97
98 /**
99 * Get email content
100 *
101 * @return string
102 */
103 public function get_template_content() {
104 ob_start();
105 $this->add_email_body();
106 $template = ob_get_clean();
107
108 return $template;
109
110 }
111
112 /**
113 * Send email using email template
114 *
115 * @return bool
116 */
117 public function send() {
118 $headers = $this->get_headers();
119 $subject = $this->get_subject();
120 $to = $this->get_recipient();
121 $message = $this->get_template_content();
122
123 /**
124 * Added temporary for leagacy sass. It will remove in future.
125 */
126 $data = apply_filters( 'timetics/admin/email/send', [$to, $subject, $message, $headers] );
127
128 return wp_mail( ...$data );
129 }
130
131 public function sanitize_content( $content ) {
132 // Define the allowed HTML tags and attributes
133 $allowed_tags = array(
134 'a' => array(
135 'href' => true,
136 'title' => true,
137 ),
138 'abbr' => array(
139 'title' => true,
140 ),
141 'acronym' => array(
142 'title' => true,
143 ),
144 'b' => array(),
145 'blockquote' => array(
146 'cite' => true,
147 ),
148 'cite' => array(),
149 'code' => array(),
150 'del' => array(
151 'datetime' => true,
152 ),
153 'em' => array(),
154 'i' => array(),
155 'q' => array(
156 'cite' => true,
157 ),
158 'img' => array (
159 'src' => true,
160 'data-*' => true
161 ),
162 'strike' => array(),
163 'strong' => array(),
164 );
165
166 $sanitized_content = wp_kses( $content, $allowed_tags );
167
168 return $sanitized_content;
169 }
170
171 }
172