PluginProbe
Timetics – Appointment Booking Calendar & Scheduling / 1.0.64
Timetics – Appointment Booking Calendar & Scheduling v1.0.64
1.0.64 1.0.62 1.0.63 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 All 65 releases
← All changes | core/emails/email.php +74 -9 1.0.2 → 1.0.64 View file →
@@ -6,8 +6,10 @@
6 6 */
7 7
8 8 namespace Timetics\Core\Emails;
9 9
10 +defined( 'ABSPATH' ) || exit;
11 +
10 12 /**
11 13 * Class Email
12 14 */
13 15 abstract class Email {
@@ -16,10 +18,10 @@
16 18 *
17 19 * @return void
18 20 */
19 21 public function __construct() {
20 - add_action( 'timetics-email-header', [ $this, 'add_email_header' ] );
21 - add_action( 'timetics-email-footer', [ $this, 'add_email_footer' ] );
22 + add_action( 'timetics-email-header', [$this, 'add_email_header'] );
23 + add_action( 'timetics-email-footer', [$this, 'add_email_footer'] );
22 24 add_action( 'timetics-email-body', [$this, 'add_email_body'] );
23 25 }
24 26
25 27 /**
@@ -48,11 +50,23 @@
48 50 *
49 51 * @return string
50 52 */
51 53 public function get_headers() {
52 - $headers = 'MIME-Version: 1.0' . "\r\n";
53 - $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
54 + $charset = get_bloginfo( 'charset' );
55 + $charset = $charset ? $charset : 'UTF-8';
54 56
57 + $headers = 'MIME-Version: 1.0' . "\r\n";
58 + $headers .= 'Content-type: text/html; charset=' . $charset . "\r\n";
59 + $from = get_bloginfo( 'name' );
60 + $from_email = timetics_get_option('booking_created_customer_email_from');
61 +
62 + if ( function_exists( 'mb_encode_mimeheader' ) ) {
63 + $from = mb_encode_mimeheader( $from, $charset );
64 + }
65 +
66 + // Append the "From" header
67 + $headers .= 'From: ' .$from. ' <' . $from_email . '> ' . "\r\n";
68 +
55 69 return $headers;
56 70 }
57 71
58 72 /**
@@ -72,12 +86,14 @@
72 86 public function add_email_body() {
73 87 $template = $this->get_template();
74 88
75 89 if ( file_exists( $template ) ) {
90 + ob_start(); // Start output buffering
76 91 include $template;
92 + $body = ob_get_clean(); // Retrieve and clean output buffer
93 + echo wp_kses_post( $body ); // Output the email body
77 94 }
78 95 }
79 -
80 96 /**
81 97 * Add email footer
82 98 *
83 99 * @return void
@@ -92,10 +108,13 @@
92 108 * @return string
93 109 */
94 110 public function get_template_content() {
95 111 ob_start();
96 - include TIMETICS_PLUGIN_DIR . '/templates/emails/email-body.php';
97 - return ob_get_clean();
112 + $this->add_email_body();
113 + $template = ob_get_clean();
114 +
115 + return $template;
116 +
98 117 }
99 118
100 119 /**
101 120 * Send email using email template
@@ -106,8 +125,54 @@
106 125 $headers = $this->get_headers();
107 126 $subject = $this->get_subject();
108 127 $to = $this->get_recipient();
109 128 $message = $this->get_template_content();
110 -
111 - return wp_mail($to, $subject, $message, $headers);
129 +
130 + /**
131 + * Added temporary for leagacy sass. It will remove in future.
132 + */
133 + $data = apply_filters( 'timetics/admin/email/send', [$to, $subject, $message, $headers] );
134 +
135 + return wp_mail( ...$data );
112 136 }
137 +
138 + public function sanitize_content( $content ) {
139 + // Define the allowed HTML tags and attributes
140 + $allowed_tags = array(
141 + 'a' => array(
142 + 'href' => true,
143 + 'title' => true,
144 + ),
145 + 'abbr' => array(
146 + 'title' => true,
147 + ),
148 + 'acronym' => array(
149 + 'title' => true,
150 + ),
151 + 'b' => array(),
152 + 'blockquote' => array(
153 + 'cite' => true,
154 + ),
155 + 'cite' => array(),
156 + 'code' => array(),
157 + 'del' => array(
158 + 'datetime' => true,
159 + ),
160 + 'em' => array(),
161 + 'i' => array(),
162 + 'q' => array(
163 + 'cite' => true,
164 + ),
165 + 'img' => array (
166 + 'src' => true,
167 + 'data-*' => true
168 + ),
169 + 'strike' => array(),
170 + 'strong' => array(),
171 + );
172 +
173 + $sanitized_content = wp_kses( $content, $allowed_tags );
174 +
175 + return $sanitized_content;
176 + }
177 +
113 178 }