| @@ -94,17 +94,22 @@ | ||
| 94 | 94 | foreach ($attachments as $attachment) { |
| 95 | 95 | wp_delete_file($attachment); |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - $status = $result ? 'sent' : 'sending failed'; | |
| 98 | + $actionTypeLabel = $actionType == 'request' ? __('request', 'fluent-booking') : __('scheduled', 'fluent-booking'); | |
| 99 | + $recipientLabel = $emailTo == 'guest' ? __('guest', 'fluent-booking') : __('host', 'fluent-booking'); | |
| 100 | + $statusLabel = $result ? __('sent', 'fluent-booking') : __('sending failed', 'fluent-booking'); | |
| 101 | + $logType = $result ? 'activity' : 'error'; | |
| 99 | 102 | |
| 100 | - $title = sprintf(__('Booking %s email %s to %s', 'fluent-booking'), $actionType, $status, $emailTo); | |
| 103 | + $title = sprintf( | |
| 104 | + /* translators: %1$s: Action type, %2$s: Status, %3$s: Recipient */ | |
| 105 | + __('Booking %1$s email %2$s to %3$s', 'fluent-booking'), | |
| 106 | + $actionTypeLabel, | |
| 107 | + $statusLabel, | |
| 108 | + $recipientLabel | |
| 109 | + ); | |
| 101 | 110 | |
| 102 | - if ($result) { | |
| 103 | - self::addLog($title, $title, $booking->id); | |
| 104 | - } else { | |
| 105 | - self::addLog($title, $title, $booking->id, 'error'); | |
| 106 | - } | |
| 111 | + self::addLog($title, $title, $booking->id, $logType); | |
| 107 | 112 | |
| 108 | 113 | return $result; |
| 109 | 114 | } |
| 110 | 115 | |
| @@ -181,17 +186,25 @@ | ||
| 181 | 186 | $body = (string)$emogrifier->emogrify(); |
| 182 | 187 | |
| 183 | 188 | $result = Mailer::send($to, $subject, $body, $headers); |
| 184 | 189 | |
| 185 | - if (!$result) { | |
| 186 | - return false; | |
| 187 | - } | |
| 190 | + $recipientLabel = $emailTo == 'guest' ? __('guest', 'fluent-booking') : __('host', 'fluent-booking'); | |
| 191 | + $statusLabel = $result ? __('sent', 'fluent-booking') : __('sending failed', 'fluent-booking'); | |
| 192 | + $logType = $result ? 'activity' : 'error'; | |
| 188 | 193 | |
| 189 | - $title = __('Reminder Email Sent', 'fluent-booking'); | |
| 190 | - $description = sprintf(__('Reminder email sent to %s.', 'fluent-booking'), $emailTo); | |
| 191 | - self::addLog($title, $description, $booking->id); | |
| 194 | + $title = sprintf( | |
| 195 | + /* translators: %1$s: Status, %2$s: Recipient */ | |
| 196 | + __('Booking reminder email %1$s to %2$s', 'fluent-booking'), | |
| 197 | + $statusLabel, | |
| 198 | + $recipientLabel | |
| 199 | + ); | |
| 192 | 200 | |
| 193 | - return true; | |
| 201 | + /* translators: %1$s: Status, %2$s: Recipient */ | |
| 202 | + $description = sprintf(__('Reminder email %1$s to %2$s.', 'fluent-booking'), $statusLabel, $recipientLabel); | |
| 203 | + | |
| 204 | + self::addLog($title, $description, $booking->id, $logType); | |
| 205 | + | |
| 206 | + return $result; | |
| 194 | 207 | } |
| 195 | 208 | |
| 196 | 209 | /** |
| 197 | 210 | * @param \FluentBooking\App\Models\Booking $booking |
| @@ -267,20 +280,23 @@ | ||
| 267 | 280 | $body = (string)$emogrifier->emogrify(); |
| 268 | 281 | |
| 269 | 282 | $result = Mailer::send($to, $subject, $body, $headers); |
| 270 | 283 | |
| 271 | - $actionType = $actionType == 'reject' ? __('Rejection', 'fluent-booking') : __('Cancellation', 'fluent-booking'); | |
| 284 | + $actionTypeLabel = $actionType == 'reject' ? __('Rejection', 'fluent-booking') : __('Cancellation', 'fluent-booking'); | |
| 285 | + $recipientLabel = $emailTo == 'guest' ? __('guest', 'fluent-booking') : __('host', 'fluent-booking'); | |
| 286 | + $statusLabel = $result ? __('sent', 'fluent-booking') : __('sending failed', 'fluent-booking'); | |
| 287 | + $logType = $result ? 'activity' : 'error'; | |
| 272 | 288 | |
| 273 | - $status = $result ? 'sent' : 'sending failed'; | |
| 289 | + $title = sprintf( | |
| 290 | + /* translators: %1$s: Action type, %2$s: Status, %3$s: Recipient */ | |
| 291 | + __('Booking %1$s email %2$s to %3$s', 'fluent-booking'), | |
| 292 | + $actionTypeLabel, | |
| 293 | + $statusLabel, | |
| 294 | + $recipientLabel | |
| 295 | + ); | |
| 274 | 296 | |
| 275 | - $title = sprintf(__('%s email %s to %s', 'fluent-booking'), $actionType, $status, $emailTo); | |
| 297 | + self::addLog($title, $title, $booking->id, $logType); | |
| 276 | 298 | |
| 277 | - if ($result) { | |
| 278 | - self::addLog($title, $title, $booking->id); | |
| 279 | - } else { | |
| 280 | - self::addLog($title, $title, $booking->id, 'error'); | |
| 281 | - } | |
| 282 | - | |
| 283 | 299 | return $result; |
| 284 | 300 | } |
| 285 | 301 | |
| 286 | 302 | /** |
| @@ -366,19 +382,23 @@ | ||
| 366 | 382 | if ($attachments) { |
| 367 | 383 | wp_delete_file($attachments[0]); |
| 368 | 384 | } |
| 369 | 385 | |
| 370 | - $status = $result ? 'sent' : 'sending failed'; | |
| 386 | + $statusLabel = $result ? __('sent', 'fluent-booking') : __('sending failed', 'fluent-booking'); | |
| 387 | + $recipientLabel = $emailTo == 'guest' ? __('guest', 'fluent-booking') : __('host', 'fluent-booking'); | |
| 388 | + $logType = $result ? 'activity' : 'error'; | |
| 371 | 389 | |
| 372 | - $title = sprintf(__('Rescheduled booking email %s to %s', 'fluent-booking'), $status, $emailTo); | |
| 390 | + $title = sprintf( | |
| 391 | + /* translators: %1$s: Status, %2$s: Recipient */ | |
| 392 | + __('Rescheduled booking email %1$s to %2$s', 'fluent-booking'), | |
| 393 | + $statusLabel, | |
| 394 | + $recipientLabel | |
| 395 | + ); | |
| 373 | 396 | |
| 374 | - $description = sprintf(__('Rescheduling email %s to %s', 'fluent-booking'), $status, $emailTo); | |
| 397 | + /* translators: %1$s: Status, %2$s: Recipient */ | |
| 398 | + $description = sprintf(__('Rescheduling email %1$s to %2$s', 'fluent-booking'), $statusLabel, $recipientLabel); | |
| 375 | 399 | |
| 376 | - if ($result) { | |
| 377 | - self::addLog($title, $description, $booking->id); | |
| 378 | - } else { | |
| 379 | - self::addLog($title, $description, $booking->id, 'error'); | |
| 380 | - } | |
| 400 | + self::addLog($title, $description, $booking->id, $logType); | |
| 381 | 401 | |
| 382 | 402 | return $result; |
| 383 | 403 | } |
| 384 | 404 | |
| @@ -422,11 +442,12 @@ | ||
| 422 | 442 | return []; |
| 423 | 443 | } |
| 424 | 444 | |
| 425 | 445 | $icsContent = BookingService::generateBookingICS($booking); |
| 426 | - | |
| 427 | - $filePath = wp_tempnam(null, 'event') . '.ics'; | |
| 428 | - | |
| 446 | + | |
| 447 | + $icsFileName = 'fcal-' . md5(wp_generate_uuid4()) . '.ics'; | |
| 448 | + $filePath = trailingslashit(wp_upload_dir()['path']) . $icsFileName; | |
| 449 | + | |
| 429 | 450 | global $wp_filesystem; |
| 430 | 451 | $wp_filesystem->put_contents($filePath, $icsContent); |
| 431 | 452 | |
| 432 | 453 | return [$filePath]; |