| 1 |
<?php |
| 2 |
/** |
| 3 |
* Mail Sent 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 MailSentEvent |
| 19 |
* |
| 20 |
* @api |
| 21 |
* |
| 22 |
* Dispatched after an opt-in verification email is sent. |
| 23 |
* Covered by the Addon API semver policy as of Core API 4.3.0. |
| 24 |
*/ |
| 25 |
class MailSentEvent extends Event { |
| 26 |
|
| 27 |
private int $optInId; |
| 28 |
private string $recipient; |
| 29 |
private string $subject; |
| 30 |
private bool $success; |
| 31 |
private string $mailType; |
| 32 |
|
| 33 |
/** |
| 34 |
* Constructor. |
| 35 |
* |
| 36 |
* @param int $optInId The opt-in record ID. |
| 37 |
* @param string $recipient The recipient email. |
| 38 |
* @param string $subject The email subject. |
| 39 |
* @param bool $success Whether sending was successful. |
| 40 |
* @param string $mailType The type: 'optin' or 'confirmation'. |
| 41 |
*/ |
| 42 |
public function __construct( |
| 43 |
int $optInId, |
| 44 |
string $recipient, |
| 45 |
string $subject, |
| 46 |
bool $success, |
| 47 |
string $mailType = 'optin' |
| 48 |
) { |
| 49 |
parent::__construct(); |
| 50 |
$this->optInId = $optInId; |
| 51 |
$this->recipient = $recipient; |
| 52 |
$this->subject = $subject; |
| 53 |
$this->success = $success; |
| 54 |
$this->mailType = $mailType; |
| 55 |
} |
| 56 |
|
| 57 |
/** |
| 58 |
* {@inheritdoc} |
| 59 |
*/ |
| 60 |
public static function getWordPressHookName(): string { |
| 61 |
return 'f12_cf7_doubleoptin_mail_sent'; |
| 62 |
} |
| 63 |
|
| 64 |
public function getOptInId(): int { |
| 65 |
return $this->optInId; |
| 66 |
} |
| 67 |
|
| 68 |
public function getRecipient(): string { |
| 69 |
return $this->recipient; |
| 70 |
} |
| 71 |
|
| 72 |
public function getSubject(): string { |
| 73 |
return $this->subject; |
| 74 |
} |
| 75 |
|
| 76 |
public function wasSuccessful(): bool { |
| 77 |
return $this->success; |
| 78 |
} |
| 79 |
|
| 80 |
public function getMailType(): string { |
| 81 |
return $this->mailType; |
| 82 |
} |
| 83 |
} |
| 84 |
|