PluginProbe
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification / 5.5.0
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification v5.5.0
5.5.0 5.4.0 5.3.2 5.3.1 5.1.6 5.1.5 trunk 2.1.5 2.11 2.12 2.13 2.15 3.0.0 3.0.1 3.0.2 3.0.3 3.0.5 3.0.51 3.0.60 3.0.61 3.0.62 3.0.70 3.0.71 3.0.72 3.1.0 All 34 releases
double-opt-in / src / Events / Mail / MailPreparingEvent.php

MailPreparingEvent.php in Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification 5.5.0, at src/Events/Mail/MailPreparingEvent.php

147 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Mail Preparing Event
4 *
5 * @package Forge12\DoubleOptIn\Events\Mail
6 * @since 4.0.0
7 */
8
9 namespace Forge12\DoubleOptIn\Events\Mail;
10
11 use Forge12\DoubleOptIn\EventSystem\Event;
12
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 /**
18 * Class MailPreparingEvent
19 *
20 * Dispatched before sending the opt-in verification email.
21 * Listeners can modify the email content, subject, and recipients.
22 */
23 class MailPreparingEvent extends Event {
24
25 private int $optInId;
26 private string $recipient;
27 private string $subject;
28 private string $body;
29 private string $sender;
30 private string $senderName;
31 private array $headers = array();
32 private array $attachments = array();
33 private bool $shouldSend = true;
34
35 /**
36 * Constructor.
37 *
38 * @param int $optInId The opt-in record ID.
39 * @param string $recipient The recipient email.
40 * @param string $subject The email subject.
41 * @param string $body The email body.
42 * @param string $sender The sender email.
43 * @param string $senderName The sender name.
44 */
45 public function __construct(
46 int $optInId,
47 string $recipient,
48 string $subject,
49 string $body,
50 string $sender,
51 string $senderName
52 ) {
53 parent::__construct();
54 $this->optInId = $optInId;
55 $this->recipient = $recipient;
56 $this->subject = $subject;
57 $this->body = $body;
58 $this->sender = $sender;
59 $this->senderName = $senderName;
60 }
61
62 /**
63 * {@inheritdoc}
64 */
65 public static function getWordPressHookName(): string {
66 return 'f12_cf7_doubleoptin_mail_preparing';
67 }
68
69 // Getters
70 public function getOptInId(): int {
71 return $this->optInId;
72 }
73
74 public function getRecipient(): string {
75 return $this->recipient;
76 }
77
78 public function getSubject(): string {
79 return $this->subject;
80 }
81
82 public function getBody(): string {
83 return $this->body;
84 }
85
86 public function getSender(): string {
87 return $this->sender;
88 }
89
90 public function getSenderName(): string {
91 return $this->senderName;
92 }
93
94 public function getHeaders(): array {
95 return $this->headers;
96 }
97
98 public function getAttachments(): array {
99 return $this->attachments;
100 }
101
102 public function shouldSend(): bool {
103 return $this->shouldSend;
104 }
105
106 // Setters for modification by listeners
107 public function setRecipient( string $recipient ): self {
108 $this->recipient = $recipient;
109 return $this;
110 }
111
112 public function setSubject( string $subject ): self {
113 $this->subject = $subject;
114 return $this;
115 }
116
117 public function setBody( string $body ): self {
118 $this->body = $body;
119 return $this;
120 }
121
122 public function setSender( string $sender ): self {
123 $this->sender = $sender;
124 return $this;
125 }
126
127 public function setSenderName( string $name ): self {
128 $this->senderName = $name;
129 return $this;
130 }
131
132 public function addHeader( string $header ): self {
133 $this->headers[] = $header;
134 return $this;
135 }
136
137 public function addAttachment( string $path ): self {
138 $this->attachments[] = $path;
139 return $this;
140 }
141
142 public function cancelSending(): self {
143 $this->shouldSend = false;
144 return $this;
145 }
146 }
147