@@ -1,4 +1,4 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <button type="submit" class="glsr-button button btn"> |
4 | 4 | <span class="glsr-button-loading"></span> |
@@ -1,4 +1,4 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <span class="glsr-field-error"> |
4 | 4 | {{ errors }} |
@@ -1,4 +1,4 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <div class="glsr-field {{ class }}"> |
4 | 4 | <div class="glsr-field-choice"> |
@@ -1,4 +1,4 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <div class="glsr-field {{ class }}"> |
4 | 4 | {{ label }} |
@@ -1,4 +1,4 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <div class="pagination"> |
4 | 4 | <nav class="navigation" role="navigation"> |
@@ -1,4 +1,4 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <strong>A new {review_rating}-star review has been submitted:</strong> |
4 | 4 |
@@ -1,4 +1,4 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <div class="glsr-login-register"> |
4 | 4 | <p>{{ text }}</p> |
@@ -1,4 +1,4 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <div class="glsr-reviews-wrap"> |
4 | 4 | <div class="{{ class }}" id="{{ id }}"> |
@@ -9,201 +9,201 @@ |
||
9 | 9 | |
10 | 10 | class Email |
11 | 11 | { |
12 | - /** |
|
13 | - * @var array |
|
14 | - */ |
|
15 | - public $attachments; |
|
16 | - |
|
17 | - /** |
|
18 | - * @var array |
|
19 | - */ |
|
20 | - public $email; |
|
21 | - |
|
22 | - /** |
|
23 | - * @var array |
|
24 | - */ |
|
25 | - public $headers; |
|
26 | - |
|
27 | - /** |
|
28 | - * @var string |
|
29 | - */ |
|
30 | - public $message; |
|
31 | - |
|
32 | - /** |
|
33 | - * @var string |
|
34 | - */ |
|
35 | - public $subject; |
|
36 | - |
|
37 | - /** |
|
38 | - * @var string|array |
|
39 | - */ |
|
40 | - public $to; |
|
41 | - |
|
42 | - /** |
|
43 | - * @return Email |
|
44 | - */ |
|
45 | - public function compose(array $email) |
|
46 | - { |
|
47 | - $this->normalize($email); |
|
48 | - $this->attachments = $this->email['attachments']; |
|
49 | - $this->headers = $this->buildHeaders(); |
|
50 | - $this->message = $this->buildHtmlMessage(); |
|
51 | - $this->subject = $this->email['subject']; |
|
52 | - $this->to = $this->email['to']; |
|
53 | - add_action('phpmailer_init', [$this, 'buildPlainTextMessage']); |
|
54 | - return $this; |
|
55 | - } |
|
56 | - |
|
57 | - /** |
|
58 | - * @param string $format |
|
59 | - * @return string|null |
|
60 | - */ |
|
61 | - public function read($format = '') |
|
62 | - { |
|
63 | - if ('plaintext' == $format) { |
|
64 | - $message = $this->stripHtmlTags($this->message); |
|
65 | - return apply_filters('site-reviews/email/message', $message, 'text', $this); |
|
66 | - } |
|
67 | - return $this->message; |
|
68 | - } |
|
69 | - |
|
70 | - /** |
|
71 | - * @return void|bool |
|
72 | - */ |
|
73 | - public function send() |
|
74 | - { |
|
75 | - if (!$this->message || !$this->subject || !$this->to) { |
|
76 | - return; |
|
77 | - } |
|
78 | - add_action('wp_mail_failed', [$this, 'logMailError']); |
|
79 | - $sent = wp_mail( |
|
80 | - $this->to, |
|
81 | - $this->subject, |
|
82 | - $this->message, |
|
83 | - $this->headers, |
|
84 | - $this->attachments |
|
85 | - ); |
|
86 | - remove_action('wp_mail_failed', [$this, 'logMailError']); |
|
87 | - $this->reset(); |
|
88 | - return $sent; |
|
89 | - } |
|
90 | - |
|
91 | - /** |
|
92 | - * @return void |
|
93 | - * @action phpmailer_init |
|
94 | - */ |
|
95 | - public function buildPlainTextMessage(PHPMailer $phpmailer) |
|
96 | - { |
|
97 | - if (empty($this->email)) { |
|
98 | - return; |
|
99 | - } |
|
100 | - if ('text/plain' === $phpmailer->ContentType || !empty($phpmailer->AltBody)) { |
|
101 | - return; |
|
102 | - } |
|
103 | - $message = $this->stripHtmlTags($phpmailer->Body); |
|
104 | - $phpmailer->AltBody = apply_filters('site-reviews/email/message', $message, 'text', $this); |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * @return array |
|
109 | - */ |
|
110 | - protected function buildHeaders() |
|
111 | - { |
|
112 | - $allowed = [ |
|
113 | - 'bcc', 'cc', 'from', 'reply-to', |
|
114 | - ]; |
|
115 | - $headers = array_intersect_key($this->email, array_flip($allowed)); |
|
116 | - $headers = array_filter($headers); |
|
117 | - foreach ($headers as $key => $value) { |
|
118 | - unset($headers[$key]); |
|
119 | - $headers[] = $key.': '.$value; |
|
120 | - } |
|
121 | - $headers[] = 'Content-Type: text/html'; |
|
122 | - return apply_filters('site-reviews/email/headers', $headers, $this); |
|
123 | - } |
|
124 | - |
|
125 | - /** |
|
126 | - * @return string |
|
127 | - */ |
|
128 | - protected function buildHtmlMessage() |
|
129 | - { |
|
130 | - $template = trim(glsr(OptionManager::class)->get('settings.general.notification_message')); |
|
131 | - if (!empty($template)) { |
|
132 | - $message = glsr(Template::class)->interpolate($template, $this->email['template-tags'], $this->email['template']); |
|
133 | - } elseif ($this->email['template']) { |
|
134 | - $message = glsr(Template::class)->build('templates/'.$this->email['template'], [ |
|
135 | - 'context' => $this->email['template-tags'], |
|
136 | - ]); |
|
137 | - } |
|
138 | - if (!isset($message)) { |
|
139 | - $message = $this->email['message']; |
|
140 | - } |
|
141 | - $message = $this->email['before'].$message.$this->email['after']; |
|
142 | - $message = strip_shortcodes($message); |
|
143 | - $message = wptexturize($message); |
|
144 | - $message = wpautop($message); |
|
145 | - $message = str_replace('<> ', '', $message); |
|
146 | - $message = str_replace(']]>', ']]>', $message); |
|
147 | - $message = glsr(Template::class)->build('partials/email/index', [ |
|
148 | - 'context' => ['message' => $message], |
|
149 | - ]); |
|
150 | - return apply_filters('site-reviews/email/message', stripslashes($message), 'html', $this); |
|
151 | - } |
|
152 | - |
|
153 | - /** |
|
154 | - * @param \WP_Error $error |
|
155 | - * @return void |
|
156 | - */ |
|
157 | - protected function logMailError($error) |
|
158 | - { |
|
159 | - glsr_log()->error('Email was not sent (wp_mail failed)') |
|
160 | - ->debug($this) |
|
161 | - ->debug($error); |
|
162 | - } |
|
163 | - |
|
164 | - /** |
|
165 | - * @return void |
|
166 | - */ |
|
167 | - protected function normalize(array $email = []) |
|
168 | - { |
|
169 | - $email = shortcode_atts(glsr(EmailDefaults::class)->defaults(), $email); |
|
170 | - if (empty($email['reply-to'])) { |
|
171 | - $email['reply-to'] = $email['from']; |
|
172 | - } |
|
173 | - $this->email = apply_filters('site-reviews/email/compose', $email, $this); |
|
174 | - } |
|
175 | - |
|
176 | - /** |
|
177 | - * @return void |
|
178 | - */ |
|
179 | - protected function reset() |
|
180 | - { |
|
181 | - $this->attachments = []; |
|
182 | - $this->email = []; |
|
183 | - $this->headers = []; |
|
184 | - $this->message = null; |
|
185 | - $this->subject = null; |
|
186 | - $this->to = null; |
|
187 | - } |
|
188 | - |
|
189 | - /** |
|
190 | - * @return string |
|
191 | - */ |
|
192 | - protected function stripHtmlTags($string) |
|
193 | - { |
|
194 | - // remove invisible elements |
|
195 | - $string = preg_replace('@<(embed|head|noembed|noscript|object|script|style)[^>]*?>.*?</\\1>@siu', '', $string); |
|
196 | - // replace certain elements with a line-break |
|
197 | - $string = preg_replace('@</(div|h[1-9]|p|pre|tr)@iu', "\r\n\$0", $string); |
|
198 | - // replace other elements with a space |
|
199 | - $string = preg_replace('@</(td|th)@iu', ' $0', $string); |
|
200 | - // add a placeholder for plain-text bullets to list elements |
|
201 | - $string = preg_replace('@<(li)[^>]*?>@siu', '$0-o-^-o-', $string); |
|
202 | - // strip all remaining HTML tags |
|
203 | - $string = wp_strip_all_tags($string); |
|
204 | - $string = wp_specialchars_decode($string, ENT_QUOTES); |
|
205 | - $string = preg_replace('/\v(?:[\v\h]+){2,}/', "\r\n\r\n", $string); |
|
206 | - $string = str_replace('-o-^-o-', ' - ', $string); |
|
207 | - return html_entity_decode($string, ENT_QUOTES, 'UTF-8'); |
|
208 | - } |
|
12 | + /** |
|
13 | + * @var array |
|
14 | + */ |
|
15 | + public $attachments; |
|
16 | + |
|
17 | + /** |
|
18 | + * @var array |
|
19 | + */ |
|
20 | + public $email; |
|
21 | + |
|
22 | + /** |
|
23 | + * @var array |
|
24 | + */ |
|
25 | + public $headers; |
|
26 | + |
|
27 | + /** |
|
28 | + * @var string |
|
29 | + */ |
|
30 | + public $message; |
|
31 | + |
|
32 | + /** |
|
33 | + * @var string |
|
34 | + */ |
|
35 | + public $subject; |
|
36 | + |
|
37 | + /** |
|
38 | + * @var string|array |
|
39 | + */ |
|
40 | + public $to; |
|
41 | + |
|
42 | + /** |
|
43 | + * @return Email |
|
44 | + */ |
|
45 | + public function compose(array $email) |
|
46 | + { |
|
47 | + $this->normalize($email); |
|
48 | + $this->attachments = $this->email['attachments']; |
|
49 | + $this->headers = $this->buildHeaders(); |
|
50 | + $this->message = $this->buildHtmlMessage(); |
|
51 | + $this->subject = $this->email['subject']; |
|
52 | + $this->to = $this->email['to']; |
|
53 | + add_action('phpmailer_init', [$this, 'buildPlainTextMessage']); |
|
54 | + return $this; |
|
55 | + } |
|
56 | + |
|
57 | + /** |
|
58 | + * @param string $format |
|
59 | + * @return string|null |
|
60 | + */ |
|
61 | + public function read($format = '') |
|
62 | + { |
|
63 | + if ('plaintext' == $format) { |
|
64 | + $message = $this->stripHtmlTags($this->message); |
|
65 | + return apply_filters('site-reviews/email/message', $message, 'text', $this); |
|
66 | + } |
|
67 | + return $this->message; |
|
68 | + } |
|
69 | + |
|
70 | + /** |
|
71 | + * @return void|bool |
|
72 | + */ |
|
73 | + public function send() |
|
74 | + { |
|
75 | + if (!$this->message || !$this->subject || !$this->to) { |
|
76 | + return; |
|
77 | + } |
|
78 | + add_action('wp_mail_failed', [$this, 'logMailError']); |
|
79 | + $sent = wp_mail( |
|
80 | + $this->to, |
|
81 | + $this->subject, |
|
82 | + $this->message, |
|
83 | + $this->headers, |
|
84 | + $this->attachments |
|
85 | + ); |
|
86 | + remove_action('wp_mail_failed', [$this, 'logMailError']); |
|
87 | + $this->reset(); |
|
88 | + return $sent; |
|
89 | + } |
|
90 | + |
|
91 | + /** |
|
92 | + * @return void |
|
93 | + * @action phpmailer_init |
|
94 | + */ |
|
95 | + public function buildPlainTextMessage(PHPMailer $phpmailer) |
|
96 | + { |
|
97 | + if (empty($this->email)) { |
|
98 | + return; |
|
99 | + } |
|
100 | + if ('text/plain' === $phpmailer->ContentType || !empty($phpmailer->AltBody)) { |
|
101 | + return; |
|
102 | + } |
|
103 | + $message = $this->stripHtmlTags($phpmailer->Body); |
|
104 | + $phpmailer->AltBody = apply_filters('site-reviews/email/message', $message, 'text', $this); |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * @return array |
|
109 | + */ |
|
110 | + protected function buildHeaders() |
|
111 | + { |
|
112 | + $allowed = [ |
|
113 | + 'bcc', 'cc', 'from', 'reply-to', |
|
114 | + ]; |
|
115 | + $headers = array_intersect_key($this->email, array_flip($allowed)); |
|
116 | + $headers = array_filter($headers); |
|
117 | + foreach ($headers as $key => $value) { |
|
118 | + unset($headers[$key]); |
|
119 | + $headers[] = $key.': '.$value; |
|
120 | + } |
|
121 | + $headers[] = 'Content-Type: text/html'; |
|
122 | + return apply_filters('site-reviews/email/headers', $headers, $this); |
|
123 | + } |
|
124 | + |
|
125 | + /** |
|
126 | + * @return string |
|
127 | + */ |
|
128 | + protected function buildHtmlMessage() |
|
129 | + { |
|
130 | + $template = trim(glsr(OptionManager::class)->get('settings.general.notification_message')); |
|
131 | + if (!empty($template)) { |
|
132 | + $message = glsr(Template::class)->interpolate($template, $this->email['template-tags'], $this->email['template']); |
|
133 | + } elseif ($this->email['template']) { |
|
134 | + $message = glsr(Template::class)->build('templates/'.$this->email['template'], [ |
|
135 | + 'context' => $this->email['template-tags'], |
|
136 | + ]); |
|
137 | + } |
|
138 | + if (!isset($message)) { |
|
139 | + $message = $this->email['message']; |
|
140 | + } |
|
141 | + $message = $this->email['before'].$message.$this->email['after']; |
|
142 | + $message = strip_shortcodes($message); |
|
143 | + $message = wptexturize($message); |
|
144 | + $message = wpautop($message); |
|
145 | + $message = str_replace('<> ', '', $message); |
|
146 | + $message = str_replace(']]>', ']]>', $message); |
|
147 | + $message = glsr(Template::class)->build('partials/email/index', [ |
|
148 | + 'context' => ['message' => $message], |
|
149 | + ]); |
|
150 | + return apply_filters('site-reviews/email/message', stripslashes($message), 'html', $this); |
|
151 | + } |
|
152 | + |
|
153 | + /** |
|
154 | + * @param \WP_Error $error |
|
155 | + * @return void |
|
156 | + */ |
|
157 | + protected function logMailError($error) |
|
158 | + { |
|
159 | + glsr_log()->error('Email was not sent (wp_mail failed)') |
|
160 | + ->debug($this) |
|
161 | + ->debug($error); |
|
162 | + } |
|
163 | + |
|
164 | + /** |
|
165 | + * @return void |
|
166 | + */ |
|
167 | + protected function normalize(array $email = []) |
|
168 | + { |
|
169 | + $email = shortcode_atts(glsr(EmailDefaults::class)->defaults(), $email); |
|
170 | + if (empty($email['reply-to'])) { |
|
171 | + $email['reply-to'] = $email['from']; |
|
172 | + } |
|
173 | + $this->email = apply_filters('site-reviews/email/compose', $email, $this); |
|
174 | + } |
|
175 | + |
|
176 | + /** |
|
177 | + * @return void |
|
178 | + */ |
|
179 | + protected function reset() |
|
180 | + { |
|
181 | + $this->attachments = []; |
|
182 | + $this->email = []; |
|
183 | + $this->headers = []; |
|
184 | + $this->message = null; |
|
185 | + $this->subject = null; |
|
186 | + $this->to = null; |
|
187 | + } |
|
188 | + |
|
189 | + /** |
|
190 | + * @return string |
|
191 | + */ |
|
192 | + protected function stripHtmlTags($string) |
|
193 | + { |
|
194 | + // remove invisible elements |
|
195 | + $string = preg_replace('@<(embed|head|noembed|noscript|object|script|style)[^>]*?>.*?</\\1>@siu', '', $string); |
|
196 | + // replace certain elements with a line-break |
|
197 | + $string = preg_replace('@</(div|h[1-9]|p|pre|tr)@iu', "\r\n\$0", $string); |
|
198 | + // replace other elements with a space |
|
199 | + $string = preg_replace('@</(td|th)@iu', ' $0', $string); |
|
200 | + // add a placeholder for plain-text bullets to list elements |
|
201 | + $string = preg_replace('@<(li)[^>]*?>@siu', '$0-o-^-o-', $string); |
|
202 | + // strip all remaining HTML tags |
|
203 | + $string = wp_strip_all_tags($string); |
|
204 | + $string = wp_specialchars_decode($string, ENT_QUOTES); |
|
205 | + $string = preg_replace('/\v(?:[\v\h]+){2,}/', "\r\n\r\n", $string); |
|
206 | + $string = str_replace('-o-^-o-', ' - ', $string); |
|
207 | + return html_entity_decode($string, ENT_QUOTES, 'UTF-8'); |
|
208 | + } |
|
209 | 209 | } |
@@ -42,15 +42,15 @@ discard block |
||
42 | 42 | /** |
43 | 43 | * @return Email |
44 | 44 | */ |
45 | - public function compose(array $email) |
|
45 | + public function compose( array $email ) |
|
46 | 46 | { |
47 | - $this->normalize($email); |
|
47 | + $this->normalize( $email ); |
|
48 | 48 | $this->attachments = $this->email['attachments']; |
49 | 49 | $this->headers = $this->buildHeaders(); |
50 | 50 | $this->message = $this->buildHtmlMessage(); |
51 | 51 | $this->subject = $this->email['subject']; |
52 | 52 | $this->to = $this->email['to']; |
53 | - add_action('phpmailer_init', [$this, 'buildPlainTextMessage']); |
|
53 | + add_action( 'phpmailer_init', [$this, 'buildPlainTextMessage'] ); |
|
54 | 54 | return $this; |
55 | 55 | } |
56 | 56 | |
@@ -58,11 +58,11 @@ discard block |
||
58 | 58 | * @param string $format |
59 | 59 | * @return string|null |
60 | 60 | */ |
61 | - public function read($format = '') |
|
61 | + public function read( $format = '' ) |
|
62 | 62 | { |
63 | - if ('plaintext' == $format) { |
|
64 | - $message = $this->stripHtmlTags($this->message); |
|
65 | - return apply_filters('site-reviews/email/message', $message, 'text', $this); |
|
63 | + if( 'plaintext' == $format ) { |
|
64 | + $message = $this->stripHtmlTags( $this->message ); |
|
65 | + return apply_filters( 'site-reviews/email/message', $message, 'text', $this ); |
|
66 | 66 | } |
67 | 67 | return $this->message; |
68 | 68 | } |
@@ -72,10 +72,10 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public function send() |
74 | 74 | { |
75 | - if (!$this->message || !$this->subject || !$this->to) { |
|
75 | + if( !$this->message || !$this->subject || !$this->to ) { |
|
76 | 76 | return; |
77 | 77 | } |
78 | - add_action('wp_mail_failed', [$this, 'logMailError']); |
|
78 | + add_action( 'wp_mail_failed', [$this, 'logMailError'] ); |
|
79 | 79 | $sent = wp_mail( |
80 | 80 | $this->to, |
81 | 81 | $this->subject, |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | $this->headers, |
84 | 84 | $this->attachments |
85 | 85 | ); |
86 | - remove_action('wp_mail_failed', [$this, 'logMailError']); |
|
86 | + remove_action( 'wp_mail_failed', [$this, 'logMailError'] ); |
|
87 | 87 | $this->reset(); |
88 | 88 | return $sent; |
89 | 89 | } |
@@ -92,16 +92,16 @@ discard block |
||
92 | 92 | * @return void |
93 | 93 | * @action phpmailer_init |
94 | 94 | */ |
95 | - public function buildPlainTextMessage(PHPMailer $phpmailer) |
|
95 | + public function buildPlainTextMessage( PHPMailer $phpmailer ) |
|
96 | 96 | { |
97 | - if (empty($this->email)) { |
|
97 | + if( empty($this->email) ) { |
|
98 | 98 | return; |
99 | 99 | } |
100 | - if ('text/plain' === $phpmailer->ContentType || !empty($phpmailer->AltBody)) { |
|
100 | + if( 'text/plain' === $phpmailer->ContentType || !empty($phpmailer->AltBody) ) { |
|
101 | 101 | return; |
102 | 102 | } |
103 | - $message = $this->stripHtmlTags($phpmailer->Body); |
|
104 | - $phpmailer->AltBody = apply_filters('site-reviews/email/message', $message, 'text', $this); |
|
103 | + $message = $this->stripHtmlTags( $phpmailer->Body ); |
|
104 | + $phpmailer->AltBody = apply_filters( 'site-reviews/email/message', $message, 'text', $this ); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -112,14 +112,14 @@ discard block |
||
112 | 112 | $allowed = [ |
113 | 113 | 'bcc', 'cc', 'from', 'reply-to', |
114 | 114 | ]; |
115 | - $headers = array_intersect_key($this->email, array_flip($allowed)); |
|
116 | - $headers = array_filter($headers); |
|
117 | - foreach ($headers as $key => $value) { |
|
115 | + $headers = array_intersect_key( $this->email, array_flip( $allowed ) ); |
|
116 | + $headers = array_filter( $headers ); |
|
117 | + foreach( $headers as $key => $value ) { |
|
118 | 118 | unset($headers[$key]); |
119 | 119 | $headers[] = $key.': '.$value; |
120 | 120 | } |
121 | 121 | $headers[] = 'Content-Type: text/html'; |
122 | - return apply_filters('site-reviews/email/headers', $headers, $this); |
|
122 | + return apply_filters( 'site-reviews/email/headers', $headers, $this ); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -127,50 +127,50 @@ discard block |
||
127 | 127 | */ |
128 | 128 | protected function buildHtmlMessage() |
129 | 129 | { |
130 | - $template = trim(glsr(OptionManager::class)->get('settings.general.notification_message')); |
|
131 | - if (!empty($template)) { |
|
132 | - $message = glsr(Template::class)->interpolate($template, $this->email['template-tags'], $this->email['template']); |
|
133 | - } elseif ($this->email['template']) { |
|
134 | - $message = glsr(Template::class)->build('templates/'.$this->email['template'], [ |
|
130 | + $template = trim( glsr( OptionManager::class )->get( 'settings.general.notification_message' ) ); |
|
131 | + if( !empty($template) ) { |
|
132 | + $message = glsr( Template::class )->interpolate( $template, $this->email['template-tags'], $this->email['template'] ); |
|
133 | + } elseif( $this->email['template'] ) { |
|
134 | + $message = glsr( Template::class )->build( 'templates/'.$this->email['template'], [ |
|
135 | 135 | 'context' => $this->email['template-tags'], |
136 | - ]); |
|
136 | + ] ); |
|
137 | 137 | } |
138 | - if (!isset($message)) { |
|
138 | + if( !isset($message) ) { |
|
139 | 139 | $message = $this->email['message']; |
140 | 140 | } |
141 | 141 | $message = $this->email['before'].$message.$this->email['after']; |
142 | - $message = strip_shortcodes($message); |
|
143 | - $message = wptexturize($message); |
|
144 | - $message = wpautop($message); |
|
145 | - $message = str_replace('<> ', '', $message); |
|
146 | - $message = str_replace(']]>', ']]>', $message); |
|
147 | - $message = glsr(Template::class)->build('partials/email/index', [ |
|
142 | + $message = strip_shortcodes( $message ); |
|
143 | + $message = wptexturize( $message ); |
|
144 | + $message = wpautop( $message ); |
|
145 | + $message = str_replace( '<> ', '', $message ); |
|
146 | + $message = str_replace( ']]>', ']]>', $message ); |
|
147 | + $message = glsr( Template::class )->build( 'partials/email/index', [ |
|
148 | 148 | 'context' => ['message' => $message], |
149 | - ]); |
|
150 | - return apply_filters('site-reviews/email/message', stripslashes($message), 'html', $this); |
|
149 | + ] ); |
|
150 | + return apply_filters( 'site-reviews/email/message', stripslashes( $message ), 'html', $this ); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
154 | 154 | * @param \WP_Error $error |
155 | 155 | * @return void |
156 | 156 | */ |
157 | - protected function logMailError($error) |
|
157 | + protected function logMailError( $error ) |
|
158 | 158 | { |
159 | - glsr_log()->error('Email was not sent (wp_mail failed)') |
|
160 | - ->debug($this) |
|
161 | - ->debug($error); |
|
159 | + glsr_log()->error( 'Email was not sent (wp_mail failed)' ) |
|
160 | + ->debug( $this ) |
|
161 | + ->debug( $error ); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
165 | 165 | * @return void |
166 | 166 | */ |
167 | - protected function normalize(array $email = []) |
|
167 | + protected function normalize( array $email = [] ) |
|
168 | 168 | { |
169 | - $email = shortcode_atts(glsr(EmailDefaults::class)->defaults(), $email); |
|
170 | - if (empty($email['reply-to'])) { |
|
169 | + $email = shortcode_atts( glsr( EmailDefaults::class )->defaults(), $email ); |
|
170 | + if( empty($email['reply-to']) ) { |
|
171 | 171 | $email['reply-to'] = $email['from']; |
172 | 172 | } |
173 | - $this->email = apply_filters('site-reviews/email/compose', $email, $this); |
|
173 | + $this->email = apply_filters( 'site-reviews/email/compose', $email, $this ); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
@@ -189,21 +189,21 @@ discard block |
||
189 | 189 | /** |
190 | 190 | * @return string |
191 | 191 | */ |
192 | - protected function stripHtmlTags($string) |
|
192 | + protected function stripHtmlTags( $string ) |
|
193 | 193 | { |
194 | 194 | // remove invisible elements |
195 | - $string = preg_replace('@<(embed|head|noembed|noscript|object|script|style)[^>]*?>.*?</\\1>@siu', '', $string); |
|
195 | + $string = preg_replace( '@<(embed|head|noembed|noscript|object|script|style)[^>]*?>.*?</\\1>@siu', '', $string ); |
|
196 | 196 | // replace certain elements with a line-break |
197 | - $string = preg_replace('@</(div|h[1-9]|p|pre|tr)@iu', "\r\n\$0", $string); |
|
197 | + $string = preg_replace( '@</(div|h[1-9]|p|pre|tr)@iu', "\r\n\$0", $string ); |
|
198 | 198 | // replace other elements with a space |
199 | - $string = preg_replace('@</(td|th)@iu', ' $0', $string); |
|
199 | + $string = preg_replace( '@</(td|th)@iu', ' $0', $string ); |
|
200 | 200 | // add a placeholder for plain-text bullets to list elements |
201 | - $string = preg_replace('@<(li)[^>]*?>@siu', '$0-o-^-o-', $string); |
|
201 | + $string = preg_replace( '@<(li)[^>]*?>@siu', '$0-o-^-o-', $string ); |
|
202 | 202 | // strip all remaining HTML tags |
203 | - $string = wp_strip_all_tags($string); |
|
204 | - $string = wp_specialchars_decode($string, ENT_QUOTES); |
|
205 | - $string = preg_replace('/\v(?:[\v\h]+){2,}/', "\r\n\r\n", $string); |
|
206 | - $string = str_replace('-o-^-o-', ' - ', $string); |
|
207 | - return html_entity_decode($string, ENT_QUOTES, 'UTF-8'); |
|
203 | + $string = wp_strip_all_tags( $string ); |
|
204 | + $string = wp_specialchars_decode( $string, ENT_QUOTES ); |
|
205 | + $string = preg_replace( '/\v(?:[\v\h]+){2,}/', "\r\n\r\n", $string ); |
|
206 | + $string = str_replace( '-o-^-o-', ' - ', $string ); |
|
207 | + return html_entity_decode( $string, ENT_QUOTES, 'UTF-8' ); |
|
208 | 208 | } |
209 | 209 | } |
@@ -130,7 +130,8 @@ |
||
130 | 130 | $template = trim(glsr(OptionManager::class)->get('settings.general.notification_message')); |
131 | 131 | if (!empty($template)) { |
132 | 132 | $message = glsr(Template::class)->interpolate($template, $this->email['template-tags'], $this->email['template']); |
133 | - } elseif ($this->email['template']) { |
|
133 | + } |
|
134 | + elseif ($this->email['template']) { |
|
134 | 135 | $message = glsr(Template::class)->build('templates/'.$this->email['template'], [ |
135 | 136 | 'context' => $this->email['template-tags'], |
136 | 137 | ]); |