1 <?php
  2 
  3 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
  4 
  5 if ( ! class_exists( 'WC_Email_Customer_Reset_Password' ) ) :
  6 
  7 /**
  8  * Customer Reset Password
  9  *
 10  * An email sent to the customer when they reset their password.
 11  *
 12  * @class       WC_Email_Customer_Reset_Password
 13  * @version     2.0.0
 14  * @package     WooCommerce/Classes/Emails
 15  * @author      WooThemes
 16  * @extends     WC_Email
 17  */
 18 class WC_Email_Customer_Reset_Password extends WC_Email {
 19 
 20     /** @var string */
 21     var $user_login;
 22 
 23     /** @var string */
 24     var $user_email;
 25 
 26     /** @var string */
 27     var $reset_key;
 28 
 29     /**
 30      * Constructor
 31      *
 32      * @access public
 33      * @return void
 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         // Trigger
 48         add_action( 'woocommerce_reset_password_notification', array( $this, 'trigger' ), 10, 2 );
 49 
 50         // Call parent constructor
 51         parent::__construct();
 52     }
 53 
 54     /**
 55      * trigger function.
 56      *
 57      * @access public
 58      * @return void
 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      * get_content_html function.
 79      *
 80      * @access public
 81      * @return string
 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      * get_content_plain function.
 98      *
 99      * @access public
100      * @return string
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();
WooCommerce API documentation generated by ApiGen 2.8.0