customer_mailer.php
56 lines
| 1 | <?php |
| 2 | if ( ! defined( 'ABSPATH' ) ) { |
| 3 | exit; // Exit if accessed directly. |
| 4 | } |
| 5 | |
| 6 | |
| 7 | if ( ! class_exists( 'OsCustomerMailer' ) ) : |
| 8 | |
| 9 | |
| 10 | class OsCustomerMailer extends OsMailer { |
| 11 | |
| 12 | |
| 13 | function __construct() { |
| 14 | parent::__construct(); |
| 15 | $this->views_folder = LATEPOINT_VIEWS_MAILERS_ABSPATH . 'customer/'; |
| 16 | } |
| 17 | |
| 18 | |
| 19 | // PASSWORD RESET TOKEN |
| 20 | |
| 21 | function password_reset_request( $customer, $token ) { |
| 22 | $this->vars['customer'] = $customer; |
| 23 | $to = $customer->email; |
| 24 | $subject = $this->password_reset_request_subject(); |
| 25 | $message = $this->password_reset_request_content(); |
| 26 | $subject = OsReplacerHelper::replace_all_vars( $subject, array( 'customer' => $customer, 'other_vars' => [ 'token' => $token ] ) ); |
| 27 | $message = OsReplacerHelper::replace_all_vars( $message, array( 'customer' => $customer, 'other_vars' => [ 'token' => $token ] ) ); |
| 28 | |
| 29 | return wp_mail( $to, $subject, $message, $this->headers ); |
| 30 | } |
| 31 | |
| 32 | function password_reset_request_subject() { |
| 33 | $default = __( 'Reset Your Password', 'latepoint' ); |
| 34 | |
| 35 | return OsSettingsHelper::get_settings_value( 'email_customer_password_reset_request_subject', $default ); |
| 36 | } |
| 37 | |
| 38 | function password_reset_request_content() { |
| 39 | $content = OsSettingsHelper::get_settings_value( 'email_customer_password_reset_request_content' ); |
| 40 | if ( ! $content ) { |
| 41 | require_once ABSPATH . 'wp-admin/includes/file.php'; |
| 42 | if ( ! WP_Filesystem() ) { |
| 43 | OsDebugHelper::log( __( 'Failed to initialise WC_Filesystem API while trying to show notification templates.', 'latepoint' ) ); |
| 44 | |
| 45 | return ''; |
| 46 | } |
| 47 | global $wp_filesystem; |
| 48 | |
| 49 | return $wp_filesystem->get_contents( LATEPOINT_VIEWS_ABSPATH . 'mailers/customer/password_reset_request.html' ); |
| 50 | } else { |
| 51 | return $content; |
| 52 | } |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | endif; |