@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $this->to = $email['to']; |
57 | 57 | |
58 | 58 | add_action( 'phpmailer_init', function( PHPMailer $phpmailer ) { |
59 | - if( $phpmailer->ContentType === 'text/plain' || !empty( $phpmailer->AltBody ))return; |
|
59 | + if( $phpmailer->ContentType === 'text/plain' || !empty( $phpmailer->AltBody ) )return; |
|
60 | 60 | $phpmailer->AltBody = $this->buildPlainTextMessage( $phpmailer->Body ); |
61 | 61 | }); |
62 | 62 | |
@@ -107,11 +107,11 @@ discard block |
||
107 | 107 | 'reply-to', |
108 | 108 | ]; |
109 | 109 | |
110 | - $headers = array_intersect_key( $email, array_flip( $allowed )); |
|
110 | + $headers = array_intersect_key( $email, array_flip( $allowed ) ); |
|
111 | 111 | $headers = array_filter( $headers ); |
112 | 112 | |
113 | 113 | foreach( $headers as $key => $value ) { |
114 | - unset( $headers[ $key ] ); |
|
114 | + unset( $headers[$key] ); |
|
115 | 115 | $headers[] = sprintf( '%s: %s', $key, $value ); |
116 | 116 | } |
117 | 117 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | ? $this->renderTemplate( $email['template'], $email['template-tags'] ) |
131 | 131 | : $email['message']; |
132 | 132 | |
133 | - $message = $this->filterHtml( $email['before'] . $message . $email['after'] ); |
|
133 | + $message = $this->filterHtml( $email['before'].$message.$email['after'] ); |
|
134 | 134 | $message = str_replace( '{message}', $message, $body ); |
135 | 135 | |
136 | 136 | return apply_filters( 'castor/email/message', $message, 'html', $this ); |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | */ |
178 | 178 | protected function normalize( $email ) |
179 | 179 | { |
180 | - $defaults = array_fill_keys([ |
|
180 | + $defaults = array_fill_keys( [ |
|
181 | 181 | 'after', 'attachments', 'bcc', 'before', 'cc', 'from', 'message', 'reply-to', 'subject', |
182 | 182 | 'template', 'template-tags', 'to', |
183 | 183 | ], '' ); |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | foreach( ['attachments', 'template-tags'] as $key ) { |
189 | 189 | $email[$key] = array_filter( (array) $email[$key] ); |
190 | 190 | } |
191 | - if( empty( $email['reply-to'] )) { |
|
191 | + if( empty( $email['reply-to'] ) ) { |
|
192 | 192 | $email['reply-to'] = $email['from']; |
193 | 193 | } |
194 | 194 | |
@@ -206,10 +206,10 @@ discard block |
||
206 | 206 | { |
207 | 207 | $file = $this->template->get( 'castor/email/'.$templatePath ); |
208 | 208 | |
209 | - if( !file_exists( $file )) { |
|
210 | - $file = sprintf( '%s/templates/email/%s.php', dirname( dirname( __DIR__ )), $templatePath ); |
|
209 | + if( !file_exists( $file ) ) { |
|
210 | + $file = sprintf( '%s/templates/email/%s.php', dirname( dirname( __DIR__ ) ), $templatePath ); |
|
211 | 211 | } |
212 | - if( !file_exists( $file ))return; |
|
212 | + if( !file_exists( $file ) )return; |
|
213 | 213 | |
214 | 214 | ob_start(); |
215 | 215 | include $file; |
@@ -5,8 +5,7 @@ discard block |
||
5 | 5 | use GeminiLabs\Castor\Helpers\Template; |
6 | 6 | use PHPMailer; |
7 | 7 | |
8 | -class Email |
|
9 | -{ |
|
8 | +class Email { |
|
10 | 9 | /** |
11 | 10 | * @var Template |
12 | 11 | */ |
@@ -56,7 +55,9 @@ discard block |
||
56 | 55 | $this->to = $email['to']; |
57 | 56 | |
58 | 57 | add_action( 'phpmailer_init', function( PHPMailer $phpmailer ) { |
59 | - if( $phpmailer->ContentType === 'text/plain' || !empty( $phpmailer->AltBody ))return; |
|
58 | + if( $phpmailer->ContentType === 'text/plain' || !empty( $phpmailer->AltBody )) { |
|
59 | + return; |
|
60 | + } |
|
60 | 61 | $phpmailer->AltBody = $this->buildPlainTextMessage( $phpmailer->Body ); |
61 | 62 | }); |
62 | 63 | |
@@ -80,7 +81,9 @@ discard block |
||
80 | 81 | */ |
81 | 82 | public function send() |
82 | 83 | { |
83 | - if( !$this->message || !$this->subject || !$this->to )return; |
|
84 | + if( !$this->message || !$this->subject || !$this->to ) { |
|
85 | + return; |
|
86 | + } |
|
84 | 87 | |
85 | 88 | $sent = wp_mail( |
86 | 89 | $this->to, |
@@ -209,7 +212,9 @@ discard block |
||
209 | 212 | if( !file_exists( $file )) { |
210 | 213 | $file = sprintf( '%s/templates/email/%s.php', dirname( dirname( __DIR__ )), $templatePath ); |
211 | 214 | } |
212 | - if( !file_exists( $file ))return; |
|
215 | + if( !file_exists( $file )) { |
|
216 | + return; |
|
217 | + } |
|
213 | 218 | |
214 | 219 | ob_start(); |
215 | 220 | include $file; |