This commit is contained in:
Martin Slachta
2026-06-11 19:03:29 +02:00
commit 0d829845c4
150 changed files with 38582 additions and 0 deletions
@@ -0,0 +1,22 @@
<?php
class RsvEmailSender {
private function headers(): array {
return [
'From: ' . get_bloginfo('name') . ' <' . get_option('admin_email') . '>',
'Content-Type: text/html; charset=UTF-8',
];
}
private function do_send(string $to, string $subject, string $body): void {
$success = wp_mail($to, $subject, $body, $this->headers());
if (!$success) {
throw new \RuntimeException('wp_mail failed for ' . $to);
}
}
public function send(string $to, string $subject, string $body): void {
$this->do_send($to, $subject, $body);
}
}
@@ -0,0 +1,9 @@
<?php
class RsvEmailTemplater {
public function render(string $template, array $data) : string {
return preg_replace_callback('/{{\s*(\w+)\s*}}/', function($matches) use ($data) {
return $data[$matches[1]] ?? '';
}, $template);
}
}