1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) exit;
4
5 if ( ! class_exists( 'WC_Email_Customer_Reset_Password' ) ) :
6
7 8 9 10 11 12 13 14 15 16 17
18 class WC_Email_Customer_Reset_Password extends WC_Email {
19
20
21 var $user_login;
22
23
24 var $user_email;
25
26
27 var $reset_key;
28
29 30 31 32 33 34
35 function __construct() {
36
37 $this->id = 'customer_reset_password';
38 $this->title = __( 'Reset password', 'woocommerce' );
39 $this->description = __( 'Customer reset password emails are sent when a customer resets their password.', 'woocommerce' );
40
41 $this->template_html = 'emails/customer-reset-password.php';
42 $this->template_plain = 'emails/plain/customer-reset-password.php';
43
44 $this->subject = __( 'Password Reset for {site_title}', 'woocommerce');
45 $this->heading = __( 'Password Reset Instructions', 'woocommerce');
46
47
48 add_action( 'woocommerce_reset_password_notification', array( $this, 'trigger' ), 10, 2 );
49
50
51 parent::__construct();
52 }
53
54 55 56 57 58 59
60 function trigger( $user_login = '', $reset_key = '' ) {
61 if ( $user_login && $reset_key ) {
62 $this->object = get_user_by( 'login', $user_login );
63
64 $this->user_login = $user_login;
65 $this->reset_key = $reset_key;
66 $this->user_email = stripslashes( $this->object->user_email );
67 $this->recipient = $this->user_email;
68 }
69
70 if ( ! $this->is_enabled() || ! $this->get_recipient() )
71 return;
72
73 $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
74
75 }
76
77 78 79 80 81 82
83 function get_content_html() {
84 ob_start();
85 wc_get_template( $this->template_html, array(
86 'email_heading' => $this->get_heading(),
87 'user_login' => $this->user_login,
88 'reset_key' => $this->reset_key,
89 'blogname' => $this->get_blogname(),
90 'sent_to_admin' => false,
91 'plain_text' => false
92 ) );
93 return ob_get_clean();
94 }
95
96 97 98 99 100 101
102 function get_content_plain() {
103 ob_start();
104 wc_get_template( $this->template_plain, array(
105 'email_heading' => $this->get_heading(),
106 'user_login' => $this->user_login,
107 'reset_key' => $this->reset_key,
108 'blogname' => $this->get_blogname(),
109 'sent_to_admin' => false,
110 'plain_text' => true
111 ) );
112 return ob_get_clean();
113 }
114 }
115
116 endif;
117
118 return new WC_Email_Customer_Reset_Password();