Advertisement
Guest User

Reset password file

a guest
Sep 6th, 2017
420
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.39 KB | None | 0 0
  1. <?php
  2.  
  3. if ( ! defined( 'ABSPATH' ) ) {
  4. exit; // Exit if accessed directly
  5. }
  6.  
  7. if ( ! class_exists( 'WC_Email_Customer_Reset_Password', false ) ) :
  8.  
  9. /**
  10. * Customer Reset Password.
  11. *
  12. * An email sent to the customer when they reset their password.
  13. *
  14. * @class WC_Email_Customer_Reset_Password
  15. * @version 2.3.0
  16. * @package WooCommerce/Classes/Emails
  17. * @author WooThemes
  18. * @extends WC_Email
  19. */
  20. class WC_Email_Customer_Reset_Password extends WC_Email {
  21.  
  22. /**
  23. * User login name.
  24. *
  25. * @var string
  26. */
  27. public $user_login;
  28.  
  29. /**
  30. * User email.
  31. *
  32. * @var string
  33. */
  34. public $user_email;
  35.  
  36. /**
  37. * Reset key.
  38. *
  39. * @var string
  40. */
  41. public $reset_key;
  42.  
  43. /**
  44. * Constructor.
  45. */
  46. public function __construct() {
  47.  
  48. $this->id = 'customer_reset_password';
  49. $this->customer_email = true;
  50.  
  51. $this->title = __( 'Reset password', 'woocommerce' );
  52. $this->description = __( 'Customer "reset password" emails are sent when customers reset their passwords.', 'woocommerce' );
  53.  
  54. $this->template_html = 'emails/customer-reset-password.php';
  55. $this->template_plain = 'emails/plain/customer-reset-password.php';
  56.  
  57. // Trigger
  58. add_action( 'woocommerce_reset_password_notification', array( $this, 'trigger' ), 10, 2 );
  59.  
  60. // Call parent constructor
  61. parent::__construct();
  62. }
  63.  
  64. /**
  65. * Get email subject.
  66. *
  67. * @since 3.1.0
  68. * @return string
  69. */
  70. public function get_default_subject() {
  71. return __( 'Password reset for {site_title}', 'woocommerce' );
  72. }
  73.  
  74. /**
  75. * Get email heading.
  76. *
  77. * @since 3.1.0
  78. * @return string
  79. */
  80. public function get_default_heading() {
  81. return __( 'Password reset instructions', 'woocommerce' );
  82. }
  83.  
  84. /**
  85. * Trigger.
  86. *
  87. * @param string $user_login
  88. * @param string $reset_key
  89. */
  90. public function trigger( $user_login = '', $reset_key = '' ) {
  91. if ( $user_login && $reset_key ) {
  92. $this->object = get_user_by( 'login', $user_login );
  93.  
  94. $this->user_login = $user_login;
  95. $this->reset_key = $reset_key;
  96. $this->user_email = stripslashes( $this->object->user_email );
  97. $this->recipient = $this->user_email;
  98. }
  99.  
  100. if ( ! $this->is_enabled() || ! $this->get_recipient() ) {
  101. return;
  102. }
  103.  
  104. $this->setup_locale();
  105. $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
  106. $this->restore_locale();
  107. }
  108.  
  109. /**
  110. * Get content html.
  111. *
  112. * @access public
  113. * @return string
  114. */
  115. public function get_content_html() {
  116. return wc_get_template_html( $this->template_html, array(
  117. 'email_heading' => $this->get_heading(),
  118. 'user_login' => $this->user_login,
  119. 'reset_key' => $this->reset_key,
  120. 'blogname' => $this->get_blogname(),
  121. 'sent_to_admin' => false,
  122. 'plain_text' => false,
  123. 'email' => $this,
  124. ) );
  125. }
  126.  
  127. /**
  128. * Get content plain.
  129. *
  130. * @access public
  131. * @return string
  132. */
  133. public function get_content_plain() {
  134. return wc_get_template_html( $this->template_plain, array(
  135. 'email_heading' => $this->get_heading(),
  136. 'user_login' => $this->user_login,
  137. 'reset_key' => $this->reset_key,
  138. 'blogname' => $this->get_blogname(),
  139. 'sent_to_admin' => false,
  140. 'plain_text' => true,
  141. 'email' => $this,
  142. ) );
  143. }
  144. }
  145.  
  146. endif;
  147.  
  148. return new WC_Email_Customer_Reset_Password();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement