| @@ -60,9 +60,9 @@ | ||
| 60 | 60 | */ |
| 61 | 61 | protected function log(string $message, string $level = 'info'): void { |
| 62 | 62 | $log_message = sprintf( |
| 63 | 63 | '[%s] [%s] %s: %s', |
| 64 | - date('Y-m-d H:i:s'), | |
| 64 | + gmdate('Y-m-d H:i:s'), | |
| 65 | 65 | strtoupper($level), |
| 66 | 66 | $this->service_name, |
| 67 | 67 | $message |
| 68 | 68 | ); |
| @@ -85,8 +85,9 @@ | ||
| 85 | 85 | $errors = []; |
| 86 | 86 | |
| 87 | 87 | foreach ($required_fields as $field) { |
| 88 | 88 | if (!isset($data[$field]) || empty($data[$field])) { |
| 89 | + /* translators: %s: field name. */ | |
| 89 | 90 | $errors[] = sprintf(__('Field "%s" is required.', 'easy-invoice'), $field); |
| 90 | 91 | } |
| 91 | 92 | } |
| 92 | 93 | |
| @@ -177,15 +178,21 @@ | ||
| 177 | 178 | * @param string $message The email message |
| 178 | 179 | * @param array $headers The email headers |
| 179 | 180 | * @return bool True if email was sent successfully |
| 180 | 181 | */ |
| 181 | - protected function sendEmail(string $to, string $subject, string $message, array $headers = []): bool { | |
| 182 | + protected function sendEmail(string $to, string $subject, string $message, array $headers = [], array $attachments = []): bool { | |
| 182 | 183 | // Allow plugins to modify email data |
| 184 | + // | |
| 185 | + // $attachments defaults to empty, so every existing caller behaves exactly as | |
| 186 | + // before. It exists so a document can be attached now that PdfRenderer can | |
| 187 | + // produce one on the server — wp_mail() takes file paths, which is why the | |
| 188 | + // renderer writes to a temp file rather than handing back bytes. | |
| 183 | 189 | $email_data = apply_filters('easy_invoice_service_email_data', [ |
| 184 | 190 | 'to' => $to, |
| 185 | 191 | 'subject' => $subject, |
| 186 | 192 | 'message' => $message, |
| 187 | - 'headers' => $headers | |
| 193 | + 'headers' => $headers, | |
| 194 | + 'attachments' => $attachments | |
| 188 | 195 | ], $this->service_name); |
| 189 | 196 | |
| 190 | 197 | // Allow plugins to handle email sending |
| 191 | 198 | $sent = apply_filters('easy_invoice_service_email_send', null, $email_data, $this->service_name); |
| @@ -195,9 +202,10 @@ | ||
| 195 | 202 | $sent = wp_mail( |
| 196 | 203 | $email_data['to'], |
| 197 | 204 | $email_data['subject'], |
| 198 | 205 | $email_data['message'], |
| 199 | - $email_data['headers'] | |
| 206 | + $email_data['headers'], | |
| 207 | + isset($email_data['attachments']) ? (array) $email_data['attachments'] : [] | |
| 200 | 208 | ); |
| 201 | 209 | } |
| 202 | 210 | |
| 203 | 211 | // Log email sending |