| @@ -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 { |
| @@ -48,11 +50,23 @@ | ||
| 48 | 50 | * |
| 49 | 51 | * @return string |
| 50 | 52 | */ |
| 51 | 53 | public function get_headers() { |
| 54 | + $charset = get_bloginfo( 'charset' ); | |
| 55 | + $charset = $charset ? $charset : 'UTF-8'; | |
| 56 | + | |
| 52 | 57 | $headers = 'MIME-Version: 1.0' . "\r\n"; |
| 53 | - $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\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'); | |
| 54 | 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 | /** |
| @@ -78,9 +92,8 @@ | ||
| 78 | 92 | $body = ob_get_clean(); // Retrieve and clean output buffer |
| 79 | 93 | echo wp_kses_post( $body ); // Output the email body |
| 80 | 94 | } |
| 81 | 95 | } |
| 82 | - | |
| 83 | 96 | /** |
| 84 | 97 | * Add email footer |
| 85 | 98 | * |
| 86 | 99 | * @return void |
| @@ -120,5 +133,46 @@ | ||
| 120 | 133 | $data = apply_filters( 'timetics/admin/email/send', [$to, $subject, $message, $headers] ); |
| 121 | 134 | |
| 122 | 135 | return wp_mail( ...$data ); |
| 123 | 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 | + | |
| 124 | 178 | } |