| 1 |
<?php |
| 2 |
|
| 3 |
namespace YayMail\Emails; |
| 4 |
|
| 5 |
use YayMail\Abstracts\BaseEmail; |
| 6 |
use YayMail\Elements\ElementsLoader; |
| 7 |
use YayMail\Utils\SingletonTrait; |
| 8 |
|
| 9 |
/** |
| 10 |
* CustomerResetPassword Class |
| 11 |
* |
| 12 |
* @method static CustomerResetPassword get_instance() |
| 13 |
*/ |
| 14 |
class CustomerResetPassword extends BaseEmail { |
| 15 |
use SingletonTrait; |
| 16 |
|
| 17 |
public $email_types = [ YAYMAIL_NON_ORDER_EMAILS ]; |
| 18 |
|
| 19 |
protected function __construct() { |
| 20 |
$emails = \WC_Emails::instance()->get_emails(); |
| 21 |
$email = $emails['WC_Email_Customer_Reset_Password']; |
| 22 |
if ( ! $email ) { |
| 23 |
return; |
| 24 |
} |
| 25 |
|
| 26 |
$this->id = $email->id; |
| 27 |
$this->title = $email->get_title(); |
| 28 |
$this->root_email = $email; |
| 29 |
$this->recipient = function_exists( 'yaymail_get_email_recipient_zone' ) ? yaymail_get_email_recipient_zone( $email ) : ''; |
| 30 |
|
| 31 |
$this->render_priority = apply_filters( 'yaymail_email_render_priority', $this->render_priority, $this->id ); |
| 32 |
add_filter( 'wc_get_template', [ $this, 'get_template_file' ], $this->render_priority ?? 10, 3 ); |
| 33 |
$this->maybe_disable_block_email_editor(); |
| 34 |
} |
| 35 |
|
| 36 |
public function get_default_elements() { |
| 37 |
$email_title = __( 'Password Reset Request', 'woocommerce' ); |
| 38 |
// translators: customer username. |
| 39 |
$email_hi = sprintf( esc_html__( 'Hi %s,', 'woocommerce' ), '[yaymail_customer_username]' ); |
| 40 |
// translators: site name. |
| 41 |
$email_text = sprintf( esc_html__( 'Someone has requested a new password for the following account on %s:,', 'woocommerce' ), '[yaymail_site_name]' ); |
| 42 |
$email_text_1 = esc_html__( 'If you didn\'t make this request, just ignore this email. If you\'d like to proceed:', 'woocommerce' ); |
| 43 |
$text_username = __( 'Username', 'woocommerce' ); |
| 44 |
$additional_text = __( 'Thanks for reading.', 'woocommerce' ); |
| 45 |
|
| 46 |
$default_elements = ElementsLoader::load_elements( |
| 47 |
[ |
| 48 |
[ |
| 49 |
'type' => 'Logo', |
| 50 |
], |
| 51 |
[ |
| 52 |
'type' => 'Heading', |
| 53 |
'attributes' => [ |
| 54 |
'rich_text' => $email_title, |
| 55 |
], |
| 56 |
], |
| 57 |
[ |
| 58 |
'type' => 'Text', |
| 59 |
'attributes' => [ |
| 60 |
'rich_text' => '<p style=\"margin: 0 0 16px;\"><span>' . $email_hi . '</span></p><p style=\"margin: 0 0 16px;\"><span>' . $email_text . '</span></p><p style=\"margin: 0 0 16px;\"><span>' . $text_username . ': [yaymail_customer_username]</span></p><p style=\"margin: 0 0 16px;\"><span>' . $email_text_1 . '</span></p><p style=\"margin: 0 0 16px;\"><span>[yaymail_password_reset_link]</span></p><p style=\"margin: 0 0 16px;\"><span>' . $additional_text . '</span></p>', |
| 61 |
], |
| 62 |
], |
| 63 |
[ |
| 64 |
'type' => 'Footer', |
| 65 |
], |
| 66 |
] |
| 67 |
); |
| 68 |
|
| 69 |
return $default_elements; |
| 70 |
} |
| 71 |
|
| 72 |
public function get_template_path() { |
| 73 |
return YAYMAIL_PLUGIN_PATH . 'templates/emails/customer-reset-password.php'; |
| 74 |
} |
| 75 |
} |
| 76 |
|