class-wc-email-cancelled-order.php
3 years ago
class-wc-email-customer-completed-order.php
5 years ago
class-wc-email-customer-invoice.php
5 years ago
class-wc-email-customer-new-account.php
4 years ago
class-wc-email-customer-note.php
5 years ago
class-wc-email-customer-on-hold-order.php
3 years ago
class-wc-email-customer-processing-order.php
5 years ago
class-wc-email-customer-refunded-order.php
5 years ago
class-wc-email-customer-reset-password.php
5 years ago
class-wc-email-failed-order.php
5 years ago
class-wc-email-new-order.php
3 years ago
class-wc-email.php
3 years ago
class-wc-email-customer-reset-password.php
178 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Class WC_Email_Customer_Reset_Password file. |
| 4 | * |
| 5 | * @package WooCommerce\Emails |
| 6 | */ |
| 7 | |
| 8 | if ( ! defined( 'ABSPATH' ) ) { |
| 9 | exit; // Exit if accessed directly. |
| 10 | } |
| 11 | |
| 12 | if ( ! class_exists( 'WC_Email_Customer_Reset_Password', false ) ) : |
| 13 | |
| 14 | /** |
| 15 | * Customer Reset Password. |
| 16 | * |
| 17 | * An email sent to the customer when they reset their password. |
| 18 | * |
| 19 | * @class WC_Email_Customer_Reset_Password |
| 20 | * @version 3.5.0 |
| 21 | * @package WooCommerce\Classes\Emails |
| 22 | * @extends WC_Email |
| 23 | */ |
| 24 | class WC_Email_Customer_Reset_Password extends WC_Email { |
| 25 | |
| 26 | /** |
| 27 | * User ID. |
| 28 | * |
| 29 | * @var integer |
| 30 | */ |
| 31 | public $user_id; |
| 32 | |
| 33 | /** |
| 34 | * User login name. |
| 35 | * |
| 36 | * @var string |
| 37 | */ |
| 38 | public $user_login; |
| 39 | |
| 40 | /** |
| 41 | * User email. |
| 42 | * |
| 43 | * @var string |
| 44 | */ |
| 45 | public $user_email; |
| 46 | |
| 47 | /** |
| 48 | * Reset key. |
| 49 | * |
| 50 | * @var string |
| 51 | */ |
| 52 | public $reset_key; |
| 53 | |
| 54 | /** |
| 55 | * Constructor. |
| 56 | */ |
| 57 | public function __construct() { |
| 58 | |
| 59 | $this->id = 'customer_reset_password'; |
| 60 | $this->customer_email = true; |
| 61 | |
| 62 | $this->title = __( 'Reset password', 'woocommerce' ); |
| 63 | $this->description = __( 'Customer "reset password" emails are sent when customers reset their passwords.', 'woocommerce' ); |
| 64 | |
| 65 | $this->template_html = 'emails/customer-reset-password.php'; |
| 66 | $this->template_plain = 'emails/plain/customer-reset-password.php'; |
| 67 | |
| 68 | // Trigger. |
| 69 | add_action( 'woocommerce_reset_password_notification', array( $this, 'trigger' ), 10, 2 ); |
| 70 | |
| 71 | // Call parent constructor. |
| 72 | parent::__construct(); |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Get email subject. |
| 77 | * |
| 78 | * @since 3.1.0 |
| 79 | * @return string |
| 80 | */ |
| 81 | public function get_default_subject() { |
| 82 | return __( 'Password Reset Request for {site_title}', 'woocommerce' ); |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * Get email heading. |
| 87 | * |
| 88 | * @since 3.1.0 |
| 89 | * @return string |
| 90 | */ |
| 91 | public function get_default_heading() { |
| 92 | return __( 'Password Reset Request', 'woocommerce' ); |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * Trigger. |
| 97 | * |
| 98 | * @param string $user_login User login. |
| 99 | * @param string $reset_key Password reset key. |
| 100 | */ |
| 101 | public function trigger( $user_login = '', $reset_key = '' ) { |
| 102 | $this->setup_locale(); |
| 103 | |
| 104 | if ( $user_login && $reset_key ) { |
| 105 | $this->object = get_user_by( 'login', $user_login ); |
| 106 | $this->user_id = $this->object->ID; |
| 107 | $this->user_login = $user_login; |
| 108 | $this->reset_key = $reset_key; |
| 109 | $this->user_email = stripslashes( $this->object->user_email ); |
| 110 | $this->recipient = $this->user_email; |
| 111 | } |
| 112 | |
| 113 | if ( $this->is_enabled() && $this->get_recipient() ) { |
| 114 | $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() ); |
| 115 | } |
| 116 | |
| 117 | $this->restore_locale(); |
| 118 | } |
| 119 | |
| 120 | /** |
| 121 | * Get content html. |
| 122 | * |
| 123 | * @return string |
| 124 | */ |
| 125 | public function get_content_html() { |
| 126 | return wc_get_template_html( |
| 127 | $this->template_html, |
| 128 | array( |
| 129 | 'email_heading' => $this->get_heading(), |
| 130 | 'user_id' => $this->user_id, |
| 131 | 'user_login' => $this->user_login, |
| 132 | 'reset_key' => $this->reset_key, |
| 133 | 'blogname' => $this->get_blogname(), |
| 134 | 'additional_content' => $this->get_additional_content(), |
| 135 | 'sent_to_admin' => false, |
| 136 | 'plain_text' => false, |
| 137 | 'email' => $this, |
| 138 | ) |
| 139 | ); |
| 140 | } |
| 141 | |
| 142 | /** |
| 143 | * Get content plain. |
| 144 | * |
| 145 | * @return string |
| 146 | */ |
| 147 | public function get_content_plain() { |
| 148 | return wc_get_template_html( |
| 149 | $this->template_plain, |
| 150 | array( |
| 151 | 'email_heading' => $this->get_heading(), |
| 152 | 'user_id' => $this->user_id, |
| 153 | 'user_login' => $this->user_login, |
| 154 | 'reset_key' => $this->reset_key, |
| 155 | 'blogname' => $this->get_blogname(), |
| 156 | 'additional_content' => $this->get_additional_content(), |
| 157 | 'sent_to_admin' => false, |
| 158 | 'plain_text' => true, |
| 159 | 'email' => $this, |
| 160 | ) |
| 161 | ); |
| 162 | } |
| 163 | |
| 164 | /** |
| 165 | * Default content to show below main email content. |
| 166 | * |
| 167 | * @since 3.7.0 |
| 168 | * @return string |
| 169 | */ |
| 170 | public function get_default_additional_content() { |
| 171 | return __( 'Thanks for reading.', 'woocommerce' ); |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | endif; |
| 176 | |
| 177 | return new WC_Email_Customer_Reset_Password(); |
| 178 |