Admin
2 years ago
App
2 years ago
Authenticator
2 years ago
Shortcodes
2 years ago
Utils
2 years ago
class-email-template.php
2 years ago
class-wp2fa.php
2 years ago
index.php
5 years ago
class-email-template.php
135 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Responsible for email templates generation. |
| 4 | * |
| 5 | * @package wp2fa |
| 6 | * @copyright %%YEAR%% Melapress |
| 7 | * @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0 |
| 8 | * @link https://wordpress.org/plugins/wp-2fa/ |
| 9 | */ |
| 10 | |
| 11 | namespace WP2FA; |
| 12 | |
| 13 | if ( ! class_exists( '\WP2FA\Email_Template' ) ) { |
| 14 | |
| 15 | /** |
| 16 | * Plain old PHP object to hold data for an email template. |
| 17 | * |
| 18 | * @package WP2FA |
| 19 | */ |
| 20 | class Email_Template { |
| 21 | |
| 22 | /** |
| 23 | * Template ID used for most settings form fields and setting keys. |
| 24 | * |
| 25 | * @var string |
| 26 | */ |
| 27 | private $id; |
| 28 | |
| 29 | /** |
| 30 | * The title of the email |
| 31 | * |
| 32 | * @var string |
| 33 | */ |
| 34 | private $title; |
| 35 | |
| 36 | /** |
| 37 | * Email template description |
| 38 | * |
| 39 | * @var string |
| 40 | */ |
| 41 | private $description; |
| 42 | |
| 43 | /** |
| 44 | * ID used for identifying the subject and body of the email. Defaults to $id. |
| 45 | * |
| 46 | * @var string ID used for identifying the subject and body of the email. Defaults to $id. |
| 47 | */ |
| 48 | private $email_content_id; |
| 49 | |
| 50 | /** |
| 51 | * True if the email can be turned on or off in the plugin settings. |
| 52 | * |
| 53 | * @var bool |
| 54 | */ |
| 55 | private $can_be_toggled = true; |
| 56 | |
| 57 | /** |
| 58 | * Email_Template constructor. |
| 59 | * |
| 60 | * @param string $id - The template ID. |
| 61 | * @param string $title - The title. |
| 62 | * @param string $description - The description. |
| 63 | */ |
| 64 | public function __construct( string $id, string $title, string $description ) { |
| 65 | $this->id = $id; |
| 66 | $this->title = $title; |
| 67 | $this->description = $description; |
| 68 | $this->email_content_id = $id; |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * Can it be toggled |
| 73 | * |
| 74 | * @return bool |
| 75 | */ |
| 76 | public function can_be_toggled(): bool { |
| 77 | return $this->can_be_toggled; |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Sets the toggled flag for the template |
| 82 | * |
| 83 | * @param bool $can_be_toggled - Can it be toggled. |
| 84 | */ |
| 85 | public function set_can_be_toggled( $can_be_toggled ) { |
| 86 | $this->can_be_toggled = $can_be_toggled; |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * Returns the template ID |
| 91 | * |
| 92 | * @return string |
| 93 | */ |
| 94 | public function get_id(): string { |
| 95 | return $this->id; |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * Returns the title |
| 100 | * |
| 101 | * @return string |
| 102 | */ |
| 103 | public function get_title(): string { |
| 104 | return $this->title; |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * Returns the description |
| 109 | * |
| 110 | * @return string |
| 111 | */ |
| 112 | public function get_description(): string { |
| 113 | return $this->description; |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * Returns the mail content |
| 118 | * |
| 119 | * @return string |
| 120 | */ |
| 121 | public function get_email_content_id(): string { |
| 122 | return $this->email_content_id; |
| 123 | } |
| 124 | |
| 125 | /** |
| 126 | * Set content ID |
| 127 | * |
| 128 | * @param string $email_content_id - the ID of the content. |
| 129 | */ |
| 130 | public function set_email_content_id( string $email_content_id ) { |
| 131 | $this->email_content_id = $email_content_id; |
| 132 | } |
| 133 | } |
| 134 | } |
| 135 |