From c895c453815a60fd27770d2e4fbd5bafd4a10e89 Mon Sep 17 00:00:00 2001
From: David Parker
Date: Mon, 28 Oct 2024 13:52:19 -0400
Subject: [PATCH 01/41] Created abstract PMPro_Email_Template class
---
adminpages/emailtemplates-edit.php | 67 ++++---
.../class-pmpro-email-template.php | 172 ++++++++++++++++++
includes/email-templates.php | 11 ++
paid-memberships-pro.php | 2 +
4 files changed, 217 insertions(+), 35 deletions(-)
create mode 100644 classes/email-templates/class-pmpro-email-template.php
diff --git a/adminpages/emailtemplates-edit.php b/adminpages/emailtemplates-edit.php
index 2fe9a2a3d..0a128d9a2 100644
--- a/adminpages/emailtemplates-edit.php
+++ b/adminpages/emailtemplates-edit.php
@@ -18,7 +18,7 @@
// Email variables.
$email_variables = [
- 'general' => [
+ __( 'General Settings / Membership Info', 'paid-memberships-pro' ) => [
'!!name!!' => __( 'Display Name (Profile/Edit User > Display name publicly as)', 'paid-memberships-pro' ),
'!!user_login!!' => __( 'Username', 'paid-memberships-pro' ),
'!!sitename!!' => __( 'Site Title', 'paid-memberships-pro' ),
@@ -34,7 +34,7 @@
'!!login_url!!' => __( 'Login URL', 'paid-memberships-pro' ),
'!!levels_url!!' => __( 'Membership Levels Page URL', 'paid-memberships-pro' ),
],
- 'billing' => [
+ __( 'Billing Information', 'paid-memberships-pro' ) => [
'!!billing_address!!' => __( 'Billing Info Complete Address', 'paid-memberships-pro' ),
'!!billing_name!!' => __( 'Billing Info Name', 'paid-memberships-pro' ),
'!!billing_street!!' => __( 'Billing Info Street Address', 'paid-memberships-pro' ),
@@ -57,6 +57,15 @@
'!!membership_level_confirmation_message!!' => __( 'Custom Level Confirmation Message', 'paid-memberships-pro' ),
]
];
+
+ // If we have a PMPro_Email_Template class for this template, use those variables instead.
+ $email_template_class = PMPro_Email_Template::get_email_template( $edit );
+ if ( $email_template_class ) {
+ $email_variables = array(
+ __( 'Global Variables', 'paid-memberships-pro' ) => PMPro_Email_Template::get_base_email_template_variables_with_description(),
+ sprintf( __( '%s Variables', 'paid-memberships-pro' ), $email_template_class::get_template_name() ) => $email_template_class::get_email_template_variables_with_description(),
+ );
+ }
?>
@@ -165,39 +174,27 @@
-
-
-
- $description ) {
- ?>
-
-
|
- |
-
-
-
-
-
-
-
-
- $description ) {
- ?>
-
-
-
- |
- |
-
-
-
-
+ $variables ) {
+ ?>
+
+
+
+ $description ) {
+ ?>
+
+
|
+ |
+
+
+
+
+
diff --git a/classes/email-templates/class-pmpro-email-template.php b/classes/email-templates/class-pmpro-email-template.php
new file mode 100644
index 000000000..f894781b1
--- /dev/null
+++ b/classes/email-templates/class-pmpro-email-template.php
@@ -0,0 +1,172 @@
+ email template class name).
+ */
+ final public static function get_all_email_templates() {
+ /**
+ * Allow email templates to be registered.
+ *
+ * @since TBD
+ *
+ * @param array $email_templates All email templates (template slug => email template class name).
+ */
+ return apply_filters( 'pmpro_email_templates', array() );
+ }
+
+ /**
+ * Get an email template by its slug.
+ *
+ * @since TBD
+ *
+ * @param string $template_slug The email template slug.
+ * @return string|null The email template class name, or null if the email template is not found.
+ */
+ final public static function get_email_template( string $template_slug ) {
+ $email_templates = self::get_all_email_templates();
+ return isset( $email_templates[ $template_slug ] ) ? $email_templates[ $template_slug ] : null;
+ }
+
+ /**
+ * Send the email.
+ *
+ * @since TBD
+ *
+ * @return bool Whether the email was sent successfully.
+ */
+ final public function send() {
+ $pmpro_email = new PMProEmail();
+ $pmpro_email->email = $this->get_recipient_email();
+ $pmpro_email->subject = $this->get_default_subject(); // This will be overridden if there is a subject saved in the database.
+ $pmpro_email->data = array_merge( $this->get_base_email_template_variables(), $this->get_email_template_variables() );
+ $pmpro_email->template = apply_filters_deprecated( 'pmpro_email_template', array( $this->get_template_slug() ), 'TBD', 'pmpro_email_body' );
+ return $pmpro_email->sendEmail();
+ }
+
+ /**
+ * Get the base email template variables that should be available for all emails.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ final protected function get_base_email_template_variables() {
+ $base_email_template_variables = array(
+ 'site_name' => get_option( 'blogname' ),
+ 'siteemail' => get_option( 'pmpro_from_email' ),
+ 'site_url' => home_url(),
+ 'levels_url' => pmpro_url( 'levels' ),
+ 'login_link' => pmpro_login_url(),
+ 'login_url' => pmpro_login_url(),
+ 'header_name' => $this->get_recipient_name(),
+ );
+
+ return $base_email_template_variables;
+ }
+
+ /**
+ * Get the base email template variables that should be available for all emails paired with a description of the variable.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ final public static function get_base_email_template_variables_with_description() {
+ $base_email_template_variables_with_description = array(
+ '!!site_name!!' => __( 'The name of the site.', 'paid-memberships-pro' ),
+ '!!siteemail!!' => __( 'The email address of the site.', 'paid-memberships-pro' ),
+ '!!site_url!!' => __( 'The URL of the site.', 'paid-memberships-pro' ),
+ '!!levels_url!!' => __( 'The URL of the page where users can view available membership levels.', 'paid-memberships-pro' ),
+ '!!login_link!!' => __( 'The URL of the login page.', 'paid-memberships-pro' ),
+ '!!login_url!!' => __( 'The URL of the login page.', 'paid-memberships-pro' ),
+ '!!header_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
+ );
+
+ return $base_email_template_variables_with_description;
+ }
+
+ /**
+ * Get the email template slug.
+ *
+ * @since TBD
+ *
+ * @return string The email template slug.
+ */
+ abstract public static function get_template_slug();
+
+ /**
+ * Get the "nice name" of the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "nice name" of the email template.
+ */
+ abstract public static function get_template_name();
+
+ /**
+ * Get "help text" to display to the admin when editing the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "help text" to display to the admin when editing the email template.
+ */
+ abstract public static function get_template_description();
+
+ /**
+ * Get the default subject for the email.
+ *
+ * @since TBD
+ *
+ * @return string The default subject for the email.
+ */
+ abstract public static function get_default_subject();
+
+ /**
+ * Get the default body content for the email.
+ *
+ * @since TBD
+ *
+ * @return string The default body content for the email.
+ */
+ abstract public static function get_default_body();
+
+ /**
+ * Get the email template variables for the email paired with a description of the variable.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ abstract public static function get_email_template_variables_with_description();
+
+ /**
+ * Get the email address to send the email to.
+ *
+ * @since TBD
+ *
+ * @return string The email address to send the email to.
+ */
+ abstract public function get_recipient_email();
+
+ /**
+ * Get the name of the email recipient.
+ *
+ * @since TBD
+ *
+ * @return string The name of the email recipient.
+ */
+ abstract public function get_recipient_name();
+
+ /**
+ * Get the email template variables for the email.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ abstract public function get_email_template_variables();
+}
diff --git a/includes/email-templates.php b/includes/email-templates.php
index ac51eaf28..372e96082 100644
--- a/includes/email-templates.php
+++ b/includes/email-templates.php
@@ -415,6 +415,17 @@
) );
}
+// Add any templates registered via the PMPro_Email_Template class.
+$registered_templates = PMPro_Email_Template::get_all_email_templates();
+foreach ( $registered_templates as $registered_template_slug => $registered_template_class ) {
+ $pmpro_email_templates_defaults[ $registered_template_slug ] = array(
+ 'subject' => $registered_template_class::get_default_subject(),
+ 'description' => $registered_template_class::get_template_name(),
+ 'body' => $registered_template_class::get_default_body(),
+ 'help_text' => $registered_template_class::get_template_description(),
+ );
+}
+
/**
* Filter default template settings and add new templates.
*
diff --git a/paid-memberships-pro.php b/paid-memberships-pro.php
index 556652d7d..f4cf4bfe1 100644
--- a/paid-memberships-pro.php
+++ b/paid-memberships-pro.php
@@ -50,6 +50,8 @@
require_once( PMPRO_DIR . '/classes/class-pmpro-subscription.php' );
require_once( PMPRO_DIR . '/classes/class-pmpro-admin-activity-email.php' ); // setup the admin activity email
+require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template.php' ); // base class for email templates
+
require_once( PMPRO_DIR . '/includes/filters.php' ); // filters, hacks, etc, moved into the plugin
require_once( PMPRO_DIR . '/includes/reports.php' ); // load reports for admin (reports may also include tracking code, etc)
From 73b66260087cdcf70b734945922e1dd9f27165f6 Mon Sep 17 00:00:00 2001
From: David Parker
Date: Mon, 28 Oct 2024 14:11:54 -0400
Subject: [PATCH 02/41] Added PMPro_Email_Template_Cancel class
---
classes/class.pmproemail.php | 27 +--
.../class-pmpro-email-template-cancel.php | 174 ++++++++++++++++++
includes/email-templates.php | 11 --
paid-memberships-pro.php | 1 +
4 files changed, 177 insertions(+), 36 deletions(-)
create mode 100644 classes/email-templates/class-pmpro-email-template-cancel.php
diff --git a/classes/class.pmproemail.php b/classes/class.pmproemail.php
index 42ba504d8..f6a771697 100644
--- a/classes/class.pmproemail.php
+++ b/classes/class.pmproemail.php
@@ -302,31 +302,8 @@ function sendCancelEmail($user = NULL, $old_level_id = NULL)
if(!$user)
return false;
- $this->email = $user->user_email;
- $this->subject = sprintf(__('Your membership at %s has been CANCELLED', 'paid-memberships-pro'), get_option("blogname"));
-
- $this->data = array(
- 'user_email' => $user->user_email,
- 'display_name' => $user->display_name,
- 'header_name' => $user->display_name,
- 'user_login' => $user->user_login,
- 'sitename' => get_option( 'blogname' ),
- 'siteemail' => get_option( 'pmpro_from_email' ),
- 'levels_url' => pmpro_url( 'levels' )
- );
-
- if(!empty($old_level_id)) {
- if(!is_array($old_level_id))
- $old_level_id = array($old_level_id);
- $this->data['membership_id'] = $old_level_id[0]; //pass just the first as the level id
- $this->data['membership_level_name'] = pmpro_implodeToEnglish($wpdb->get_col("SELECT name FROM $wpdb->pmpro_membership_levels WHERE id IN('" . implode("','", $old_level_id) . "')"));
- } else {
- $this->data['membership_id'] = '';
- $this->data['membership_level_name'] = __('All Levels', 'paid-memberships-pro' );
- }
-
- $this->template = apply_filters("pmpro_email_template", "cancel", $this);
- return $this->sendEmail();
+ $email = new PMPro_Email_Template_Cancel( $user, $old_level_id );
+ $email->send();
}
/**
diff --git a/classes/email-templates/class-pmpro-email-template-cancel.php b/classes/email-templates/class-pmpro-email-template-cancel.php
new file mode 100644
index 000000000..cccb8960a
--- /dev/null
+++ b/classes/email-templates/class-pmpro-email-template-cancel.php
@@ -0,0 +1,174 @@
+user = $user;
+ $this->cancelled_level_ids = $cancelled_level_ids;
+ }
+
+ /**
+ * Get the email template slug.
+ *
+ * @since TBD
+ *
+ * @return string The email template slug.
+ */
+ public static function get_template_slug() {
+ return 'cancel';
+ }
+
+ /**
+ * Get the "nice name" of the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "nice name" of the email template.
+ */
+ public static function get_template_name() {
+ return __( 'Cancel', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get "help text" to display to the admin when editing the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "help text" to display to the admin when editing the email template.
+ */
+ public static function get_template_description() {
+ return __( 'The site administrator can manually cancel a user\'s membership through the WordPress admin or the member can cancel their own membership through your site. This email is sent to the member as confirmation of a cancelled membership.', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the default subject for the email.
+ *
+ * @since TBD
+ *
+ * @return string The default subject for the email.
+ */
+ public static function get_default_subject() {
+ return __( 'Your membership at !!sitename!! has been CANCELLED', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the default body content for the email.
+ *
+ * @since TBD
+ *
+ * @return string The default body content for the email.
+ */
+ public static function get_default_body() {
+ return __( 'Your membership at !!sitename!! has been cancelled.
+
+Account: !!display_name!! (!!user_email!!)
+Membership Level: !!membership_level_name!!
+
+If you did not request this cancellation and would like more information please contact us at !!siteemail!!
', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the email template variables for the email paired with a description of the variable.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public static function get_email_template_variables_with_description() {
+ return array(
+ '!!user_email!!' => __( 'The email address of the user who cancelled their membership.', 'paid-memberships-pro' ),
+ '!!display_name!!' => __( 'The display name of the user who cancelled their membership.', 'paid-memberships-pro' ),
+ '!!user_login!!' => __( 'The login name of the user who cancelled their membership.', 'paid-memberships-pro' ),
+ '!!membership_id!!' => __( 'The ID of the membership level that was cancelled.', 'paid-memberships-pro' ),
+ '!!membership_level_name!!' => __( 'The name of the membership level that was cancelled.', 'paid-memberships-pro' ),
+ );
+ }
+
+ /**
+ * Get the email address to send the email to.
+ *
+ * @since TBD
+ *
+ * @return string The email address to send the email to.
+ */
+ public function get_recipient_email() {
+ return $this->user->user_email;
+ }
+
+ /**
+ * Get the name of the email recipient.
+ *
+ * @since TBD
+ *
+ * @return string The name of the email recipient.
+ */
+ public function get_recipient_name() {
+ return $this->user->display_name;
+ }
+
+ /**
+ * Get the email template variables for the email.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public function get_email_template_variables() {
+ global $wpdb;
+
+ $email_template_variables = array(
+ 'user_email' => $this->user->user_email,
+ 'display_name' => $this->user->display_name,
+ 'user_login' => $this->user->user_login,
+ );
+
+ if ( empty( $this->cancelled_level_ids ) ) {
+ $email_template_variables['membership_id'] = '';
+ $email_template_variables['membership_level_name'] = __( 'All Levels', 'paid-memberships-pro' );
+ } elseif ( is_array( $this->cancelled_level_ids ) ) {
+ $email_template_variables['membership_id'] = $this->cancelled_level_ids[0]; // Pass just the first as the level id.
+ $email_template_variables['membership_level_name'] = pmpro_implodeToEnglish( $wpdb->get_col( "SELECT name FROM $wpdb->pmpro_membership_levels WHERE id IN('" . implode( "','", $this->cancelled_level_ids ) . "')" ) );
+ } else {
+ $email_template_variables['membership_id'] = $this->cancelled_level_ids;
+ $email_template_variables['membership_level_name'] = pmpro_implodeToEnglish( $wpdb->get_col( "SELECT name FROM $wpdb->pmpro_membership_levels WHERE id = '" . $this->cancelled_level_ids . "'" ) );
+ }
+
+ return $email_template_variables;
+ }
+}
+
+/**
+ * Register the email template.
+ *
+ * @since TBD
+ *
+ * @param array $email_templates The email templates (template slug => email template class name)
+ * @return array The modified email templates array.
+ */
+function pmpro_email_templates_cancel( $email_templates ) {
+ $email_templates['cancel'] = 'PMPro_Email_Template_Cancel';
+
+ return $email_templates;
+}
+add_filter( 'pmpro_email_templates', 'pmpro_email_templates_cancel' );
diff --git a/includes/email-templates.php b/includes/email-templates.php
index 372e96082..6c364f7eb 100644
--- a/includes/email-templates.php
+++ b/includes/email-templates.php
@@ -102,17 +102,6 @@
', 'paid-memberships-pro' ),
'help_text' => __( 'This email is sent out if a recurring payment has failed for a member, usually due to an expired or cancelled credit card. This email is sent to the site administrator.', 'paid-memberships-pro' )
),
- 'cancel' => array(
- 'subject' => __( "Your membership at !!sitename!! has been CANCELLED", 'paid-memberships-pro' ),
- 'description' => __('Cancel', 'paid-memberships-pro'),
- 'body' => __( 'Your membership at !!sitename!! has been cancelled.
-
-Account: !!display_name!! (!!user_email!!)
-Membership Level: !!membership_level_name!!
-
-If you did not request this cancellation and would like more information please contact us at !!siteemail!!
', 'paid-memberships-pro' ),
- 'help_text' => __( 'The site administrator can manually cancel a user\'s membership through the WordPress admin or the member can cancel their own membership through your site. This email is sent to the member as confirmation of a cancelled membership.', 'paid-memberships-pro' )
- ),
'cancel_admin' => array(
'subject' => __( "Membership for !!user_login!! at !!sitename!! has been CANCELLED", 'paid-memberships-pro' ),
'description' => __('Cancel (admin)', 'paid-memberships-pro'),
diff --git a/paid-memberships-pro.php b/paid-memberships-pro.php
index f4cf4bfe1..78bd02821 100644
--- a/paid-memberships-pro.php
+++ b/paid-memberships-pro.php
@@ -51,6 +51,7 @@
require_once( PMPRO_DIR . '/classes/class-pmpro-admin-activity-email.php' ); // setup the admin activity email
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template.php' ); // base class for email templates
+require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-cancel.php' ); // cancel email template
require_once( PMPRO_DIR . '/includes/filters.php' ); // filters, hacks, etc, moved into the plugin
require_once( PMPRO_DIR . '/includes/reports.php' ); // load reports for admin (reports may also include tracking code, etc)
From e7801edb20de6ff5d5624f9aaea0ba109a5e7f44 Mon Sep 17 00:00:00 2001
From: maximilianoRicoTabo
Date: Tue, 5 Nov 2024 18:37:07 -0300
Subject: [PATCH 03/41] * Fix for sitename variable
---
classes/email-templates/class-pmpro-email-template.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/classes/email-templates/class-pmpro-email-template.php b/classes/email-templates/class-pmpro-email-template.php
index f894781b1..bda906428 100644
--- a/classes/email-templates/class-pmpro-email-template.php
+++ b/classes/email-templates/class-pmpro-email-template.php
@@ -56,7 +56,7 @@ final public function send() {
*/
final protected function get_base_email_template_variables() {
$base_email_template_variables = array(
- 'site_name' => get_option( 'blogname' ),
+ 'sitename' => get_option( 'blogname' ),
'siteemail' => get_option( 'pmpro_from_email' ),
'site_url' => home_url(),
'levels_url' => pmpro_url( 'levels' ),
@@ -77,7 +77,7 @@ final protected function get_base_email_template_variables() {
*/
final public static function get_base_email_template_variables_with_description() {
$base_email_template_variables_with_description = array(
- '!!site_name!!' => __( 'The name of the site.', 'paid-memberships-pro' ),
+ '!!sitename!!' => __( 'The name of the site.', 'paid-memberships-pro' ),
'!!siteemail!!' => __( 'The email address of the site.', 'paid-memberships-pro' ),
'!!site_url!!' => __( 'The URL of the site.', 'paid-memberships-pro' ),
'!!levels_url!!' => __( 'The URL of the page where users can view available membership levels.', 'paid-memberships-pro' ),
From 64105a4c5cfd54a90f5bb0e7c7eb26ae0df6483e Mon Sep 17 00:00:00 2001
From: maximilianoRicoTabo
Date: Wed, 6 Nov 2024 19:13:10 -0300
Subject: [PATCH 04/41] * Add Change Membership Classes ( admin and member )
---
classes/class.pmproemail.php | 58 +------
...lass-pmpro-email-template-change-admin.php | 157 ++++++++++++++++++
.../class-pmpro-email-template-change.php | 153 +++++++++++++++++
paid-memberships-pro.php | 3 +-
4 files changed, 316 insertions(+), 55 deletions(-)
create mode 100644 classes/email-templates/class-pmpro-email-template-change-admin.php
create mode 100644 classes/email-templates/class-pmpro-email-template-change.php
diff --git a/classes/class.pmproemail.php b/classes/class.pmproemail.php
index f6a771697..5bad35d03 100644
--- a/classes/class.pmproemail.php
+++ b/classes/class.pmproemail.php
@@ -1433,34 +1433,9 @@ function sendAdminChangeEmail($user = NULL)
if(!$user)
return false;
-
- $this->email = $user->user_email;
- $this->subject = sprintf(__("Your membership at %s has been changed", "paid-memberships-pro"), get_option("blogname"));
-
- $this->data = array(
- 'subject' => $this->subject,
- 'header_name' => $user->display_name,
- 'name' => $user->display_name,
- 'display_name' => $user->display_name,
- 'user_login' => $user->user_login,
- 'user_email' => $user->user_email,
- 'sitename' => get_option( 'blogname' ),
- 'siteemail' => get_option( 'pmpro_from_email' ),
- 'login_link' => pmpro_login_url(),
- 'login_url' => pmpro_login_url(),
- 'levels_url' => pmpro_url( 'levels' )
- );
-
- // If the user no longer has a membership level, set the membership_change text to "Membership has been cancelled."
- if ( ! pmpro_hasMembershipLevel( null, $user->ID ) ) {
- $this->data['membership_change'] = __( 'Your membership has been cancelled.', 'paid-memberships-pro' );
- } else {
- $this->data['membership_change'] = __( 'You can view your current memberships by logging in and visiting your membership account page.', 'paid-memberships-pro' );
- }
-
- $this->template = apply_filters("pmpro_email_template", "admin_change", $this);
- return $this->sendEmail();
+ $email = new PMPro_Email_Template_Change( $user );
+ $email->send();
}
/**
@@ -1477,33 +1452,8 @@ function sendAdminChangeAdminEmail($user = NULL)
if(!$user)
return false;
- $this->email = get_bloginfo("admin_email");
- $this->subject = sprintf(__("Membership for %s at %s has been changed", "paid-memberships-pro"), $user->user_login, get_option("blogname"));
-
- $this->data = array(
- 'subject' => $this->subject,
- 'header_name' => $this->get_admin_name( $this->email ),
- 'name' =>$user->display_name,
- 'display_name' => $user->display_name,
- 'user_login' => $user->user_login,
- 'user_email' => $user->user_email,
- 'sitename' => get_option('blogname'),
- 'siteemail' => $this->email,
- 'login_link' => pmpro_login_url(),
- 'login_url' => pmpro_login_url(),
- 'levels_url' => pmpro_url( 'levels' )
- );
-
- // If the user no longer has a membership level, set the membership_change text to "Membership has been cancelled."
- if ( ! pmpro_hasMembershipLevel( null, $user->ID ) ) {
- $this->data['membership_change'] = __( "The user's membership has been cancelled.", 'paid-memberships-pro' );
- } else {
- $this->data['membership_change'] = __( "You can view the user's current memberships from their Edit Member page.", 'paid-memberships-pro' );
- }
-
- $this->template = apply_filters("pmpro_email_template", "admin_change_admin", $this);
-
- return $this->sendEmail();
+ $email = new PMPro_Email_Template_Change_Admin( $user );
+ $email->send();
}
/**
diff --git a/classes/email-templates/class-pmpro-email-template-change-admin.php b/classes/email-templates/class-pmpro-email-template-change-admin.php
new file mode 100644
index 000000000..5c409960e
--- /dev/null
+++ b/classes/email-templates/class-pmpro-email-template-change-admin.php
@@ -0,0 +1,157 @@
+user = $user;
+ }
+
+ /**
+ * Get the email template slug.
+ *
+ * @since TBD
+ *
+ * @return string The email template slug.
+ */
+ public static function get_template_slug() {
+ return 'change_admin';
+ }
+
+ /**
+ * Get the "nice name" of the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "nice name" of the email template.
+ */
+ public static function get_template_name() {
+ return __( 'Admin Change (admin)', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get "help text" to display to the admin when editing the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "help text" to display to the admin when editing the email template.
+ */
+ public static function get_template_description() {
+ return __( 'The site administrator can manually update a user\'s membership through the WordPress admin. This email notifies the member of the level update.', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the default subject for the email.
+ *
+ * @since TBD
+ *
+ * @return string The default subject for the email.
+ */
+ public static function get_default_subject() {
+ return __( "Membership for !!display_name!! at !!sitename!! has been changed", 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the default body content for the email.
+ *
+ * @since TBD
+ *
+ * @return string The default body content for the email.
+ */
+ public static function get_default_body() {
+ return __( 'An administrator at !!sitename!! has changed a membership level for !!display_name!!.
+ !!membership_change!!
+ Log in to your WordPress admin here: !!login_url!!
', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the email template variables for the email.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public function get_email_template_variables() {
+ // If the user no longer has a membership level, set the membership_change text to "Membership has been cancelled."
+ if ( ! pmpro_hasMembershipLevel( null, $this->user->ID ) ) {
+ $membership_changed = __( 'The user\'s membership has been cancelled.', 'paid-memberships-pro' );
+ } else {
+ $membership_changed = __( 'You can view the user\'s current memberships from their Edit Member page.', 'paid-memberships-pro' );
+ }
+
+ $email_template_variables = array(
+ 'membership_changed' => $membership_changed,
+ 'display_name' => $this->user->display_name,
+
+ );
+ return $email_template_variables;
+ }
+
+ /**
+ * Get the email template variables for the email paired with a description of the variable.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public static function get_email_template_variables_with_description() {
+ return array(
+ '!!membership_change!!' => __( 'Membership Level Change', 'paid-memberships-pro' ),
+ '!!display_name!!' => __( 'The email address of the user that admin changed their membership.', 'paid-memberships-pro' ),
+ );
+ }
+
+ /**
+ * Get the email address to send the email to.
+ *
+ * @since TBD
+ *
+ * @return string The email address to send the email to.
+ */
+ public function get_recipient_email() {
+ return get_bloginfo( 'admin_email' );
+ }
+
+ /**
+ * Get the name of the email recipient.
+ *
+ * @since TBD
+ *
+ * @return string The name of the email recipient.
+ */
+ public function get_recipient_name() {
+ //get user by email
+ $user = get_user_by( 'email', $this->get_recipient_email() );
+ return $user->display_name;
+ }
+}
+
+ /**
+ * Register the email template.
+ *
+ * @since TBD
+ *
+ * @param array $email_templates The email templates (template slug => email template class name)
+ * @return array The modified email templates array.
+ */
+ function pmpro_email_templates_change_admin( $email_templates ) {
+ $email_templates['admin_change_admin'] = 'PMPro_Email_Template_Change_Admin';
+
+ return $email_templates;
+ }
+
+add_filter( 'pmpro_email_templates', 'pmpro_email_templates_change_admin' );
diff --git a/classes/email-templates/class-pmpro-email-template-change.php b/classes/email-templates/class-pmpro-email-template-change.php
new file mode 100644
index 000000000..c91002592
--- /dev/null
+++ b/classes/email-templates/class-pmpro-email-template-change.php
@@ -0,0 +1,153 @@
+user = $user;
+ }
+
+ /**
+ * Get the email template slug.
+ *
+ * @since TBD
+ *
+ * @return string The email template slug.
+ */
+ public static function get_template_slug() {
+ return 'change';
+ }
+
+ /**
+ * Get the "nice name" of the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "nice name" of the email template.
+ */
+ public static function get_template_name() {
+ return __( 'Change', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get "help text" to display to the admin when editing the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "help text" to display to the admin when editing the email template.
+ */
+ public static function get_template_description() {
+ return __( 'The site administrator can manually update a user\'s membership through the WordPress admin. This email notifies the member of the level update.', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the default subject for the email.
+ *
+ * @since TBD
+ *
+ * @return string The default subject for the email.
+ */
+ public static function get_default_subject() {
+ return __( "Membership for !!header_name!! at !!site_name!! has been changed", "paid-memberships-pro" );
+ }
+
+ /**
+ * Get the default body content for the email.
+ *
+ * @since TBD
+ *
+ * @return string The default body content for the email.
+ */
+ public static function get_default_body() {
+ return __( 'An administrator at !!sitename!! has changed your membership level.
+ !!membership_change!!
+ If you did not request this membership change and would like more information please contact us at !!siteemail!!
+ Log in to your membership account here: !!login_url!!
', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the email template variables for the email.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public function get_email_template_variables() {
+ // If the user no longer has a membership level, set the membership_change text to "Membership has been cancelled."
+ if ( ! pmpro_hasMembershipLevel( null, $this->user->ID ) ) {
+ $membership_changed = __( 'Your membership has been cancelled.', 'paid-memberships-pro' );
+ } else {
+ $membership_changed = __( 'You can view your current memberships by logging in and visiting your membership account page.', 'paid-memberships-pro' );
+ }
+
+ $email_template_variables = array(
+ 'membership_changed' => $membership_changed,
+ );
+ return $email_template_variables;
+ }
+
+ /**
+ * Get the email template variables for the email paired with a description of the variable.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public static function get_email_template_variables_with_description() {
+ return array(
+ '!!membership_change!!' => __( 'Membership Level Change', 'paid-memberships-pro' ),
+ );
+ }
+
+ /**
+ * Get the email address to send the email to.
+ *
+ * @since TBD
+ *
+ * @return string The email address to send the email to.
+ */
+ public function get_recipient_email() {
+ return $this->user->user_email;
+ }
+
+ /**
+ * Get the name of the email recipient.
+ *
+ * @since TBD
+ *
+ * @return string The name of the email recipient.
+ */
+ public function get_recipient_name() {
+ return $this->user->display_name;
+ }
+}
+
+ /**
+ * Register the email template.
+ *
+ * @since TBD
+ *
+ * @param array $email_templates The email templates (template slug => email template class name)
+ * @return array The modified email templates array.
+ */
+ function pmpro_email_templates_change( $email_templates ) {
+ $email_templates['admin_change'] = 'PMPro_Email_Template_Change';
+
+ return $email_templates;
+ }
+
+add_filter( 'pmpro_email_templates', 'pmpro_email_templates_change' );
diff --git a/paid-memberships-pro.php b/paid-memberships-pro.php
index 78bd02821..c6c998efa 100644
--- a/paid-memberships-pro.php
+++ b/paid-memberships-pro.php
@@ -52,7 +52,8 @@
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template.php' ); // base class for email templates
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-cancel.php' ); // cancel email template
-
+require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-change.php' ); // change email template
+require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-change-admin.php' ); // change email template
require_once( PMPRO_DIR . '/includes/filters.php' ); // filters, hacks, etc, moved into the plugin
require_once( PMPRO_DIR . '/includes/reports.php' ); // load reports for admin (reports may also include tracking code, etc)
From 414c2c92a9e398598f1c9e7f3e655c3eb3c6c771 Mon Sep 17 00:00:00 2001
From: maximilianoRicoTabo
Date: Thu, 7 Nov 2024 15:30:13 -0300
Subject: [PATCH 05/41] * Add the body in the send function in the abstract
email template class
---
classes/email-templates/class-pmpro-email-template.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/classes/email-templates/class-pmpro-email-template.php b/classes/email-templates/class-pmpro-email-template.php
index f894781b1..486baa663 100644
--- a/classes/email-templates/class-pmpro-email-template.php
+++ b/classes/email-templates/class-pmpro-email-template.php
@@ -42,6 +42,7 @@ final public function send() {
$pmpro_email = new PMProEmail();
$pmpro_email->email = $this->get_recipient_email();
$pmpro_email->subject = $this->get_default_subject(); // This will be overridden if there is a subject saved in the database.
+ $pmpro_email->body = $this->get_default_body();
$pmpro_email->data = array_merge( $this->get_base_email_template_variables(), $this->get_email_template_variables() );
$pmpro_email->template = apply_filters_deprecated( 'pmpro_email_template', array( $this->get_template_slug() ), 'TBD', 'pmpro_email_body' );
return $pmpro_email->sendEmail();
From 1dd5827bb67718a8b95db8e93c78cde38bbcc2cc Mon Sep 17 00:00:00 2001
From: maximilianoRicoTabo
Date: Thu, 7 Nov 2024 18:55:05 -0300
Subject: [PATCH 06/41] * Add cancel admin class * Pass level id to cancel
function from edit member page
---
...ro-class-member-edit-panel-memberships.php | 4 +-
classes/class.pmproemail.php | 44 +---
...lass-pmpro-email-template-cancel-admin.php | 220 ++++++++++++++++++
.../class-pmpro-email-template-cancel.php | 4 +
paid-memberships-pro.php | 1 +
5 files changed, 229 insertions(+), 44 deletions(-)
create mode 100644 classes/email-templates/class-pmpro-email-template-cancel-admin.php
diff --git a/adminpages/member-edit/pmpro-class-member-edit-panel-memberships.php b/adminpages/member-edit/pmpro-class-member-edit-panel-memberships.php
index d12e0e48c..f36b95bfb 100644
--- a/adminpages/member-edit/pmpro-class-member-edit-panel-memberships.php
+++ b/adminpages/member-edit/pmpro-class-member-edit-panel-memberships.php
@@ -913,11 +913,11 @@ public function save() {
if ( $send_change_email ) {
// Send an email to the user.
$myemail = new PMProEmail();
- $myemail->sendCancelEmail( $user );
+ $myemail->sendCancelEmail( $user, $level_id );
// Send an email to the admin.
$myemail = new PMProEmail();
- $myemail->sendCancelAdminEmail( $user );
+ $myemail->sendCancelAdminEmail( $user, $level_id );
}
} else {
pmpro_setMessage( __( 'Membership action not found.', 'paid-memberships-pro' ), 'pmpro_error');
diff --git a/classes/class.pmproemail.php b/classes/class.pmproemail.php
index 5bad35d03..65f5dc1a9 100644
--- a/classes/class.pmproemail.php
+++ b/classes/class.pmproemail.php
@@ -325,49 +325,9 @@ function sendCancelAdminEmail($user = NULL, $old_level_id = NULL)
if(!$user)
return false;
-
- $this->email = get_bloginfo("admin_email");
- $this->subject = sprintf(__("Membership for %s at %s has been CANCELLED", 'paid-memberships-pro'), $user->user_login, get_option("blogname"));
-
- $this->data = array(
- 'header_name' => $this->get_admin_name( $this->email ),
- 'user_login' => $user->user_login,
- 'user_email' => $user->user_email,
- 'display_name' => $user->display_name,
- 'sitename' => get_option( 'blogname' ),
- 'siteemail' => get_option('pmpro_from_email'),
- 'login_link' => pmpro_login_url(),
- 'login_url' => pmpro_login_url(),
- 'levels_url' => pmpro_url( 'levels' )
- );
-
- if(!empty($old_level_id)) {
- if(!is_array($old_level_id))
- $old_level_id = array($old_level_id);
- $this->data['membership_id'] = $old_level_id[0]; //pass just the first as the level id
- $this->data['membership_level_name'] = pmpro_implodeToEnglish($wpdb->get_col("SELECT name FROM $wpdb->pmpro_membership_levels WHERE id IN('" . implode("','", $old_level_id) . "')"));
-
- //start and end date
- $startdate = $wpdb->get_var("SELECT UNIX_TIMESTAMP(CONVERT_TZ(startdate, '+00:00', @@global.time_zone)) as startdate FROM $wpdb->pmpro_memberships_users WHERE user_id = '" . $user->ID . "' AND membership_id = '" . $old_level_id[0] . "' AND status IN('inactive', 'cancelled', 'admin_cancelled') ORDER BY id DESC");
- if(!empty($startdate))
- $this->data['startdate'] = date_i18n(get_option('date_format'), $startdate);
- else
- $this->data['startdate'] = "";
- $enddate = $wpdb->get_var("SELECT UNIX_TIMESTAMP(CONVERT_TZ(enddate, '+00:00', @@global.time_zone)) as enddate FROM $wpdb->pmpro_memberships_users WHERE user_id = '" . $user->ID . "' AND membership_id = '" . $old_level_id[0] . "' AND status IN('inactive', 'cancelled', 'admin_cancelled') ORDER BY id DESC");
- if(!empty($enddate))
- $this->data['enddate'] = date_i18n(get_option('date_format'), $enddate);
- else
- $this->data['enddate'] = "";
- } else {
- $this->data['membership_id'] = '';
- $this->data['membership_level_name'] = __('All Levels', 'paid-memberships-pro' );
- $this->data['startdate'] = '';
- $this->data['enddate'] = '';
- }
-
- $this->template = apply_filters("pmpro_email_template", "cancel_admin", $this);
- return $this->sendEmail();
+ $email = new PMPro_Email_Template_Cancel_Admin( $user, $old_level_id );
+ $email->send();
}
/**
diff --git a/classes/email-templates/class-pmpro-email-template-cancel-admin.php b/classes/email-templates/class-pmpro-email-template-cancel-admin.php
new file mode 100644
index 000000000..b7b5bd319
--- /dev/null
+++ b/classes/email-templates/class-pmpro-email-template-cancel-admin.php
@@ -0,0 +1,220 @@
+user = $user;
+ $this->cancelled_level_ids = $cancelled_level_ids;
+ }
+
+ /**
+ * Get the email template slug.
+ *
+ * @since TBD
+ *
+ * @return string The email template slug.
+ */
+ public static function get_template_slug() {
+ return 'cancel_admin';
+ }
+
+ /**
+ * Get the "nice name" of the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "nice name" of the email template.
+ */
+ public static function get_template_name() {
+ return __('Cancel (admin)', 'paid-memberships-pro');
+ }
+
+ /**
+ * Get "help text" to display to the admin when editing the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "help text" to display to the admin when editing the email template.
+ */
+ public static function get_template_description() {
+ return __( 'The site administrator can manually cancel a user\'s membership through the WordPress admin or the member can cancel their own membership through your site. This email is sent to the site administrator as confirmation of a cancelled membership.', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the default subject for the email.
+ *
+ * @since TBD
+ *
+ * @return string The default subject for the email.
+ */
+ public static function get_default_subject() {
+ return __( "Membership for !!user_login!! at !!sitename!! has been CANCELLED", 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the default body content for the email.
+ *
+ * @since TBD
+ *
+ * @return string The default body content for the email.
+ */
+ public static function get_default_body() {
+ return __( 'The membership for !!user_login!! at !!sitename!! has been cancelled.
+
+ Account: !!display_name!! (!!user_email!!)
+ Membership Level: !!membership_level_name!!
+ Start Date: !!startdate!!
+ End Date: !!enddate!!
+
+ Log in to your WordPress admin here: !!login_url!!
', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the email template variables for the email paired with a description of the variable.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public static function get_email_template_variables_with_description() {
+ return array(
+ '!!user_email!!' => __( 'The email address of the user who cancelled their membership.', 'paid-memberships-pro' ),
+ '!!display_name!!' => __( 'The display name of the user who cancelled their membership.', 'paid-memberships-pro' ),
+ '!!user_login!!' => __( 'The login name of the user who cancelled their membership.', 'paid-memberships-pro' ),
+ '!!membership_level_name!!' => __( 'The name of the membership level that was cancelled.', 'paid-memberships-pro' ),
+ '!!startdate!!' => __( 'The start date of the membership level that was cancelled.', 'paid-memberships-pro' ),
+ '!!enddate!!' => __( 'The end date of the membership level that was cancelled.', 'paid-memberships-pro' )
+ );
+ }
+
+ /**
+ * Get the email address to send the email to.
+ *
+ * @since TBD
+ *
+ * @return string The email address to send the email to.
+ */
+ public function get_recipient_email() {
+ return $this->user->user_email;
+ }
+
+ /**
+ * Get the name of the email recipient.
+ *
+ * @since TBD
+ *
+ * @return string The name of the email recipient.
+ */
+ public function get_recipient_name() {
+ return $this->user->display_name;
+ }
+
+ /**
+ * Get the email template variables for the email.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public function get_email_template_variables() {
+ global $wpdb;
+
+ $email_template_variables = array(
+ 'user_email' => $this->user->user_email,
+ 'display_name' => $this->user->display_name,
+ 'user_login' => $this->user->user_login,
+ );
+
+ if ( empty( $this->cancelled_level_ids ) ) {
+ $email_template_variables['membership_level_name'] = __( 'All Levels', 'paid-memberships-pro' );
+ } elseif ( is_array( $this->cancelled_level_ids ) ) {
+ $email_template_variables['membership_level_name'] = pmpro_implodeToEnglish( $wpdb->get_col( "SELECT name FROM $wpdb->pmpro_membership_levels WHERE id IN('" . implode( "','", $this->cancelled_level_ids ) . "')" ) );
+ } else {
+ $email_template_variables['membership_level_name'] = pmpro_implodeToEnglish( $wpdb->get_col( "SELECT name FROM $wpdb->pmpro_membership_levels WHERE id = '" . $this->cancelled_level_ids . "'" ) );
+ }
+
+ $startdate = $this->get_start_and_end_date( 'startdate' );
+
+ if( !empty( $startdate ) ) {
+ $email_template_variables['startdate'] = date_i18n( get_option( 'date_format' ), $startdate );
+ } else {
+ $email_template_variables['startdate'] = "";
+ }
+
+ $enddate = $this->get_start_and_end_date( 'enddate' );
+
+ if( !empty( $enddate ) ) {
+ $email_template_variables['enddate'] = date_i18n( get_option( 'date_format' ), $enddate );
+ } else {
+ $email_template_variables['enddate'] = "";
+ }
+
+ return $email_template_variables;
+ }
+
+ /**
+ * Get the start or end date of the membership level that was cancelled.
+ *
+ * @since TBD
+ * @param string $end_or_start_date Either startdate or enddate.
+ * @return int The start or end date of the membership level that was cancelled.
+ *
+ */
+ private function get_start_and_end_date( $end_or_start_date ) {
+ global $wpdb;
+
+ $old_level_id = $this->cancelled_level_ids;
+ // if $this->cancelled_level_ids is an array, get the first level id
+ if( is_array( $this->cancelled_level_ids ) ) {
+ $old_level_id = $this->cancelled_level_ids[0];
+ }
+
+ return $wpdb->get_var(
+ "SELECT UNIX_TIMESTAMP(CONVERT_TZ(" . $end_or_start_date .", '+00:00', @@global.time_zone)) as " . $end_or_start_date . "
+ FROM $wpdb->pmpro_memberships_users
+ WHERE user_id = '" . $this->user->ID . "'
+ AND membership_id = '" . $old_level_id . "'
+ AND status IN('inactive', 'cancelled', 'admin_cancelled')
+ ORDER BY id DESC" );
+ }
+}
+
+/**
+ * Register the email template.
+ *
+ * @since TBD
+ *
+ * @param array $email_templates The email templates (template slug => email template class name)
+ * @return array The modified email templates array.
+ */
+function pmpro_email_templates_cancel_admin( $email_templates ) {
+ $email_templates['cancel_admin'] = 'PMPro_Email_Template_Cancel_Admin';
+
+ return $email_templates;
+}
+add_filter( 'pmpro_email_templates', 'pmpro_email_templates_cancel_admin' );
\ No newline at end of file
diff --git a/classes/email-templates/class-pmpro-email-template-cancel.php b/classes/email-templates/class-pmpro-email-template-cancel.php
index cccb8960a..a2f52454c 100644
--- a/classes/email-templates/class-pmpro-email-template-cancel.php
+++ b/classes/email-templates/class-pmpro-email-template-cancel.php
@@ -24,6 +24,9 @@ class PMPro_Email_Template_Cancel extends PMPro_Email_Template {
* @param int|array|null $cancelled_level_ids The ID or array of IDs of the membership levels that were cancelled. If null, "all" levels were cancelled.
*/
public function __construct( WP_User $user, $cancelled_level_ids ) {
+ if ( $cancelled_level_ids == null ) {
+ _doing_it_wrong( __FUNCTION__, esc_html__( 'The $cancelled_level_ids parameter is required.', 'paid-memberships-pro' ), '3.3' );
+ }
$this->user = $user;
$this->cancelled_level_ids = $cancelled_level_ids;
}
@@ -172,3 +175,4 @@ function pmpro_email_templates_cancel( $email_templates ) {
return $email_templates;
}
add_filter( 'pmpro_email_templates', 'pmpro_email_templates_cancel' );
+
diff --git a/paid-memberships-pro.php b/paid-memberships-pro.php
index c6c998efa..344e13c17 100644
--- a/paid-memberships-pro.php
+++ b/paid-memberships-pro.php
@@ -52,6 +52,7 @@
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template.php' ); // base class for email templates
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-cancel.php' ); // cancel email template
+require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-cancel-admin.php' ); // cancel email template
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-change.php' ); // change email template
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-change-admin.php' ); // change email template
require_once( PMPRO_DIR . '/includes/filters.php' ); // filters, hacks, etc, moved into the plugin
From f28ccea7a22c4437f7a3403380d3da51460228e9 Mon Sep 17 00:00:00 2001
From: maximilianoRicoTabo
Date: Fri, 8 Nov 2024 16:14:59 -0300
Subject: [PATCH 07/41] * Remove added classes from email-templates array
---
includes/email-templates.php | 35 -----------------------------------
1 file changed, 35 deletions(-)
diff --git a/includes/email-templates.php b/includes/email-templates.php
index 6c364f7eb..e0d2734a2 100644
--- a/includes/email-templates.php
+++ b/includes/email-templates.php
@@ -25,28 +25,6 @@
'body' => __( 'Dear !!header_name!!,
', 'paid-memberships-pro' ),
'help_text' => __( 'This is the opening message included in every email sent to members and the site administrator through Paid Memberships Pro.', 'paid-memberships-pro' )
),
- 'admin_change' => array(
- 'subject' => __( "Your membership at !!sitename!! has been changed", 'paid-memberships-pro' ),
- 'description' => __( 'Admin Change', 'paid-memberships-pro'),
- 'body' => __( 'An administrator at !!sitename!! has changed your membership level.
-
-!!membership_change!!
-
-If you did not request this membership change and would like more information please contact us at !!siteemail!!
-
-Log in to your membership account here: !!login_url!!
', 'paid-memberships-pro' ),
- 'help_text' => __( 'The site administrator can manually update a user\'s membership level through the WordPress admin. This email notifies the member of the level update.', 'paid-memberships-pro' )
- ),
- 'admin_change_admin' => array(
- 'subject' => __( "Membership for !!user_login!! at !!sitename!! has been changed", 'paid-memberships-pro' ),
- 'description' => __('Admin Change (admin)', 'paid-memberships-pro'),
- 'body' => __( 'An administrator at !!sitename!! has changed a membership level for !!name!!.
-
-!!membership_change!!
-
-Log in to your WordPress admin here: !!login_url!!
', 'paid-memberships-pro' ),
- 'help_text' => __( 'The site administrator can manually update a user\'s membership level through the WordPress admin. This email notifies the site administrator of the level update.', 'paid-memberships-pro' )
- ),
'billing' => array(
'subject' => __( "Your billing information has been updated at !!sitename!!", 'paid-memberships-pro' ),
'description' => __('Billing Information Updated', 'paid-memberships-pro'),
@@ -102,19 +80,6 @@
', 'paid-memberships-pro' ),
'help_text' => __( 'This email is sent out if a recurring payment has failed for a member, usually due to an expired or cancelled credit card. This email is sent to the site administrator.', 'paid-memberships-pro' )
),
- 'cancel_admin' => array(
- 'subject' => __( "Membership for !!user_login!! at !!sitename!! has been CANCELLED", 'paid-memberships-pro' ),
- 'description' => __('Cancel (admin)', 'paid-memberships-pro'),
- 'body' => __( 'The membership for !!user_login!! at !!sitename!! has been cancelled.
-
-Account: !!display_name!! (!!user_email!!)
-Membership Level: !!membership_level_name!!
-Start Date: !!startdate!!
-End Date: !!enddate!!
-
-Log in to your WordPress admin here: !!login_url!!
', 'paid-memberships-pro' ),
- 'help_text' => __( 'The site administrator can manually cancel a user\'s membership through the WordPress admin or the member can cancel their own membership through your site. This email is sent to the site administrator as confirmation of a cancelled membership.', 'paid-memberships-pro' )
- ),
'cancel_on_next_payment_date' => array(
'subject' => __( "Your payment subscription at !!sitename!! has been CANCELLED", 'paid-memberships-pro' ),
'description' => __('Canceled Auto-Renewals', 'paid-memberships-pro'),
From b5eb2f95a81c8918c65fefe244133152149812f1 Mon Sep 17 00:00:00 2001
From: maximilianoRicoTabo
Date: Fri, 8 Nov 2024 18:20:48 -0300
Subject: [PATCH 08/41] *Rename admin change classes *Add missing variables for
backwards compat
---
classes/class.pmproemail.php | 4 ++--
...pmpro-email-template-admin-change-admin.php} | 15 ++++++++++-----
...class-pmpro-email-template-admin-change.php} | 17 ++++++++++++-----
paid-memberships-pro.php | 4 ++--
4 files changed, 26 insertions(+), 14 deletions(-)
rename classes/email-templates/{class-pmpro-email-template-change-admin.php => class-pmpro-email-template-admin-change-admin.php} (91%)
rename classes/email-templates/{class-pmpro-email-template-change.php => class-pmpro-email-template-admin-change.php} (87%)
diff --git a/classes/class.pmproemail.php b/classes/class.pmproemail.php
index 65f5dc1a9..8816f189c 100644
--- a/classes/class.pmproemail.php
+++ b/classes/class.pmproemail.php
@@ -1394,7 +1394,7 @@ function sendAdminChangeEmail($user = NULL)
if(!$user)
return false;
- $email = new PMPro_Email_Template_Change( $user );
+ $email = new PMPro_Email_Template_Admin_Change( $user );
$email->send();
}
@@ -1412,7 +1412,7 @@ function sendAdminChangeAdminEmail($user = NULL)
if(!$user)
return false;
- $email = new PMPro_Email_Template_Change_Admin( $user );
+ $email = new PMPro_Email_Template_Admin_Change_Admin( $user );
$email->send();
}
diff --git a/classes/email-templates/class-pmpro-email-template-change-admin.php b/classes/email-templates/class-pmpro-email-template-admin-change-admin.php
similarity index 91%
rename from classes/email-templates/class-pmpro-email-template-change-admin.php
rename to classes/email-templates/class-pmpro-email-template-admin-change-admin.php
index 5c409960e..8f9215568 100644
--- a/classes/email-templates/class-pmpro-email-template-change-admin.php
+++ b/classes/email-templates/class-pmpro-email-template-admin-change-admin.php
@@ -1,6 +1,6 @@
value pairs).
*/
public function get_email_template_variables() {
+ $user = $this->user;
// If the user no longer has a membership level, set the membership_change text to "Membership has been cancelled."
if ( ! pmpro_hasMembershipLevel( null, $this->user->ID ) ) {
$membership_changed = __( 'The user\'s membership has been cancelled.', 'paid-memberships-pro' );
@@ -95,8 +96,12 @@ public function get_email_template_variables() {
$email_template_variables = array(
'membership_changed' => $membership_changed,
- 'display_name' => $this->user->display_name,
-
+ 'subject' => $this->get_default_subject(),
+ 'header_name' => $this->get_recipient_name(),
+ 'name' => $user->display_name,
+ 'display_name' => $user->display_name,
+ 'user_login' => $user->user_login,
+ 'user_email' => $user->user_email,
);
return $email_template_variables;
}
@@ -149,7 +154,7 @@ public function get_recipient_name() {
* @return array The modified email templates array.
*/
function pmpro_email_templates_change_admin( $email_templates ) {
- $email_templates['admin_change_admin'] = 'PMPro_Email_Template_Change_Admin';
+ $email_templates['admin_change_admin'] = 'PMPro_Email_Template_Admin_Change_Admin';
return $email_templates;
}
diff --git a/classes/email-templates/class-pmpro-email-template-change.php b/classes/email-templates/class-pmpro-email-template-admin-change.php
similarity index 87%
rename from classes/email-templates/class-pmpro-email-template-change.php
rename to classes/email-templates/class-pmpro-email-template-admin-change.php
index c91002592..11f346e48 100644
--- a/classes/email-templates/class-pmpro-email-template-change.php
+++ b/classes/email-templates/class-pmpro-email-template-admin-change.php
@@ -1,6 +1,6 @@
value pairs).
*/
public function get_email_template_variables() {
+ $user = $this->user;
// If the user no longer has a membership level, set the membership_change text to "Membership has been cancelled."
if ( ! pmpro_hasMembershipLevel( null, $this->user->ID ) ) {
$membership_changed = __( 'Your membership has been cancelled.', 'paid-memberships-pro' );
@@ -96,6 +97,12 @@ public function get_email_template_variables() {
$email_template_variables = array(
'membership_changed' => $membership_changed,
+ 'subject' => $this->get_default_subject(),
+ 'header_name' => $user->display_name,
+ 'name' => $user->display_name,
+ 'display_name' => $user->display_name,
+ 'user_login' => $user->user_login,
+ 'user_email' => $user->user_email,
);
return $email_template_variables;
}
@@ -109,7 +116,7 @@ public function get_email_template_variables() {
*/
public static function get_email_template_variables_with_description() {
return array(
- '!!membership_change!!' => __( 'Membership Level Change', 'paid-memberships-pro' ),
+ '!!membership_changed!!' => __( 'Membership Level Change', 'paid-memberships-pro' ),
);
}
@@ -145,7 +152,7 @@ public function get_recipient_name() {
* @return array The modified email templates array.
*/
function pmpro_email_templates_change( $email_templates ) {
- $email_templates['admin_change'] = 'PMPro_Email_Template_Change';
+ $email_templates['admin_change'] = 'PMPro_Email_Template_Admin_Change';
return $email_templates;
}
diff --git a/paid-memberships-pro.php b/paid-memberships-pro.php
index 344e13c17..fc919808d 100644
--- a/paid-memberships-pro.php
+++ b/paid-memberships-pro.php
@@ -53,8 +53,8 @@
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template.php' ); // base class for email templates
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-cancel.php' ); // cancel email template
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-cancel-admin.php' ); // cancel email template
-require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-change.php' ); // change email template
-require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-change-admin.php' ); // change email template
+require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-admin-change.php' ); // change email template
+require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-admin-change-admin.php' ); // change email template
require_once( PMPRO_DIR . '/includes/filters.php' ); // filters, hacks, etc, moved into the plugin
require_once( PMPRO_DIR . '/includes/reports.php' ); // load reports for admin (reports may also include tracking code, etc)
From 83533ebeb5c4776716db33e1fe8b2756f3e9fc6b Mon Sep 17 00:00:00 2001
From: David Parker
Date: Mon, 11 Nov 2024 09:41:31 -0500
Subject: [PATCH 09/41] Tweaking admin changed templates
---
...mpro-email-template-admin-change-admin.php | 43 ++++++++++---------
...lass-pmpro-email-template-admin-change.php | 42 +++++++++---------
...lass-pmpro-email-template-cancel-admin.php | 10 ++---
3 files changed, 49 insertions(+), 46 deletions(-)
diff --git a/classes/email-templates/class-pmpro-email-template-admin-change-admin.php b/classes/email-templates/class-pmpro-email-template-admin-change-admin.php
index 8f9215568..a6eb8b3ed 100644
--- a/classes/email-templates/class-pmpro-email-template-admin-change-admin.php
+++ b/classes/email-templates/class-pmpro-email-template-admin-change-admin.php
@@ -15,7 +15,6 @@ class PMPro_Email_Template_Admin_Change_Admin extends PMPro_Email_Template {
* @since TBD
*
* @param WP_User $user The user object of the user to send the email to.
- * @param int|array|null $cancelled_level_ids The ID or array of IDs of the membership levels that were cancelled. If null, "all" levels were cancelled.
*/
public function __construct( WP_User $user ) {
$this->user = $user;
@@ -51,7 +50,7 @@ public static function get_template_name() {
* @return string The "help text" to display to the admin when editing the email template.
*/
public static function get_template_description() {
- return __( 'The site administrator can manually update a user\'s membership through the WordPress admin. This email notifies the member of the level update.', 'paid-memberships-pro' );
+ return __( 'The site administrator can manually update a user\'s membership level through the WordPress admin. This email notifies the site administrator of the level update.', 'paid-memberships-pro' );
}
/**
@@ -74,8 +73,8 @@ public static function get_default_subject() {
*/
public static function get_default_body() {
return __( 'An administrator at !!sitename!! has changed a membership level for !!display_name!!.
- !!membership_change!!
- Log in to your WordPress admin here: !!login_url!!
', 'paid-memberships-pro' );
+!!membership_change!!
+Log in to your WordPress admin here: !!login_url!!
', 'paid-memberships-pro' );
}
/**
@@ -97,7 +96,6 @@ public function get_email_template_variables() {
$email_template_variables = array(
'membership_changed' => $membership_changed,
'subject' => $this->get_default_subject(),
- 'header_name' => $this->get_recipient_name(),
'name' => $user->display_name,
'display_name' => $user->display_name,
'user_login' => $user->user_login,
@@ -116,7 +114,11 @@ public function get_email_template_variables() {
public static function get_email_template_variables_with_description() {
return array(
'!!membership_change!!' => __( 'Membership Level Change', 'paid-memberships-pro' ),
- '!!display_name!!' => __( 'The email address of the user that admin changed their membership.', 'paid-memberships-pro' ),
+ '!!subject!!' => __( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
+ '!!name!!' => __( 'The display name of the user whose membership was changed.', 'paid-memberships-pro' ),
+ '!!display_name!!' => __( 'The display name of the user whose membership was changed.', 'paid-memberships-pro' ),
+ '!!user_login!!' => __( 'The login name of the user whose membership was changed.', 'paid-memberships-pro' ),
+ '!!user_email!!' => __( 'The email address of the user whose membership was changed.', 'paid-memberships-pro' ),
);
}
@@ -145,18 +147,17 @@ public function get_recipient_name() {
}
}
- /**
- * Register the email template.
- *
- * @since TBD
- *
- * @param array $email_templates The email templates (template slug => email template class name)
- * @return array The modified email templates array.
- */
- function pmpro_email_templates_change_admin( $email_templates ) {
- $email_templates['admin_change_admin'] = 'PMPro_Email_Template_Admin_Change_Admin';
-
- return $email_templates;
- }
-
-add_filter( 'pmpro_email_templates', 'pmpro_email_templates_change_admin' );
+/**
+ * Register the email template.
+ *
+ * @since TBD
+ *
+ * @param array $email_templates The email templates (template slug => email template class name)
+ * @return array The modified email templates array.
+ */
+function pmpro_email_templates_admin_change_admin( $email_templates ) {
+ $email_templates['admin_change_admin'] = 'PMPro_Email_Template_Admin_Change_Admin';
+
+ return $email_templates;
+}
+add_filter( 'pmpro_email_templates', 'pmpro_email_templates_admin_change_admin' );
diff --git a/classes/email-templates/class-pmpro-email-template-admin-change.php b/classes/email-templates/class-pmpro-email-template-admin-change.php
index 11f346e48..0e4218ebc 100644
--- a/classes/email-templates/class-pmpro-email-template-admin-change.php
+++ b/classes/email-templates/class-pmpro-email-template-admin-change.php
@@ -15,7 +15,6 @@ class PMPro_Email_Template_Admin_Change extends PMPro_Email_Template {
* @since TBD
*
* @param WP_User $user The user object of the user to send the email to.
- * @param int|array|null $cancelled_level_ids The ID or array of IDs of the membership levels that were cancelled. If null, "all" levels were cancelled.
*/
public function __construct( WP_User $user ) {
$this->user = $user;
@@ -74,9 +73,9 @@ public static function get_default_subject() {
*/
public static function get_default_body() {
return __( 'An administrator at !!sitename!! has changed your membership level.
- !!membership_change!!
- If you did not request this membership change and would like more information please contact us at !!siteemail!!
- Log in to your membership account here: !!login_url!!
', 'paid-memberships-pro' );
+!!membership_change!!
+If you did not request this membership change and would like more information please contact us at !!siteemail!!
+Log in to your membership account here: !!login_url!!
', 'paid-memberships-pro' );
}
/**
@@ -98,7 +97,6 @@ public function get_email_template_variables() {
$email_template_variables = array(
'membership_changed' => $membership_changed,
'subject' => $this->get_default_subject(),
- 'header_name' => $user->display_name,
'name' => $user->display_name,
'display_name' => $user->display_name,
'user_login' => $user->user_login,
@@ -116,7 +114,12 @@ public function get_email_template_variables() {
*/
public static function get_email_template_variables_with_description() {
return array(
- '!!membership_changed!!' => __( 'Membership Level Change', 'paid-memberships-pro' ),
+ '!!membership_change!!' => __( 'Membership Level Change', 'paid-memberships-pro' ),
+ '!!subject!!' => __( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
+ '!!name!!' => __( 'The display name of the user whose membership was changed.', 'paid-memberships-pro' ),
+ '!!display_name!!' => __( 'The display name of the user whose membership was changed.', 'paid-memberships-pro' ),
+ '!!user_login!!' => __( 'The login name of the user whose membership was changed.', 'paid-memberships-pro' ),
+ '!!user_email!!' => __( 'The email address of the user whose membership was changed.', 'paid-memberships-pro' ),
);
}
@@ -143,18 +146,17 @@ public function get_recipient_name() {
}
}
- /**
- * Register the email template.
- *
- * @since TBD
- *
- * @param array $email_templates The email templates (template slug => email template class name)
- * @return array The modified email templates array.
- */
- function pmpro_email_templates_change( $email_templates ) {
- $email_templates['admin_change'] = 'PMPro_Email_Template_Admin_Change';
-
- return $email_templates;
- }
-
+/**
+ * Register the email template.
+ *
+ * @since TBD
+ *
+ * @param array $email_templates The email templates (template slug => email template class name)
+ * @return array The modified email templates array.
+ */
+function pmpro_email_templates_change( $email_templates ) {
+ $email_templates['admin_change'] = 'PMPro_Email_Template_Admin_Change';
+
+ return $email_templates;
+}
add_filter( 'pmpro_email_templates', 'pmpro_email_templates_change' );
diff --git a/classes/email-templates/class-pmpro-email-template-cancel-admin.php b/classes/email-templates/class-pmpro-email-template-cancel-admin.php
index b7b5bd319..7f79a756c 100644
--- a/classes/email-templates/class-pmpro-email-template-cancel-admin.php
+++ b/classes/email-templates/class-pmpro-email-template-cancel-admin.php
@@ -86,12 +86,12 @@ public static function get_default_subject() {
public static function get_default_body() {
return __( 'The membership for !!user_login!! at !!sitename!! has been cancelled.
- Account: !!display_name!! (!!user_email!!)
- Membership Level: !!membership_level_name!!
- Start Date: !!startdate!!
- End Date: !!enddate!!
+Account: !!display_name!! (!!user_email!!)
+Membership Level: !!membership_level_name!!
+Start Date: !!startdate!!
+End Date: !!enddate!!
- Log in to your WordPress admin here: !!login_url!!
', 'paid-memberships-pro' );
+Log in to your WordPress admin here: !!login_url!!
', 'paid-memberships-pro' );
}
/**
From 88b4ef290f74bc1a553192fbafaaceace2309c12 Mon Sep 17 00:00:00 2001
From: David Parker
Date: Mon, 11 Nov 2024 09:44:36 -0500
Subject: [PATCH 10/41] Spacing to match original email template
---
.../class-pmpro-email-template-admin-change-admin.php | 2 ++
.../class-pmpro-email-template-admin-change.php | 3 +++
2 files changed, 5 insertions(+)
diff --git a/classes/email-templates/class-pmpro-email-template-admin-change-admin.php b/classes/email-templates/class-pmpro-email-template-admin-change-admin.php
index a6eb8b3ed..f25e51bed 100644
--- a/classes/email-templates/class-pmpro-email-template-admin-change-admin.php
+++ b/classes/email-templates/class-pmpro-email-template-admin-change-admin.php
@@ -73,7 +73,9 @@ public static function get_default_subject() {
*/
public static function get_default_body() {
return __( 'An administrator at !!sitename!! has changed a membership level for !!display_name!!.
+
!!membership_change!!
+
Log in to your WordPress admin here: !!login_url!!
', 'paid-memberships-pro' );
}
diff --git a/classes/email-templates/class-pmpro-email-template-admin-change.php b/classes/email-templates/class-pmpro-email-template-admin-change.php
index 0e4218ebc..10a39db30 100644
--- a/classes/email-templates/class-pmpro-email-template-admin-change.php
+++ b/classes/email-templates/class-pmpro-email-template-admin-change.php
@@ -73,8 +73,11 @@ public static function get_default_subject() {
*/
public static function get_default_body() {
return __( 'An administrator at !!sitename!! has changed your membership level.
+
!!membership_change!!
+
If you did not request this membership change and would like more information please contact us at !!siteemail!!
+
Log in to your membership account here: !!login_url!!
', 'paid-memberships-pro' );
}
From 2bef7f226663dfda7a1f908fe6b309c768046981 Mon Sep 17 00:00:00 2001
From: maximilianoRicoTabo
Date: Tue, 12 Nov 2024 18:55:11 -0300
Subject: [PATCH 11/41] Add payment failure classes
---
classes/class.pmproemail.php | 105 +--------
...o-email-template-billing-failure-admin.php | 207 ++++++++++++++++++
...s-pmpro-email-template-billing-failure.php | 200 +++++++++++++++++
includes/email-templates.php | 20 --
paid-memberships-pro.php | 2 +
5 files changed, 418 insertions(+), 116 deletions(-)
create mode 100644 classes/email-templates/class-pmpro-email-template-billing-failure-admin.php
create mode 100644 classes/email-templates/class-pmpro-email-template-billing-failure.php
diff --git a/classes/class.pmproemail.php b/classes/class.pmproemail.php
index 8816f189c..b50ef6cea 100644
--- a/classes/class.pmproemail.php
+++ b/classes/class.pmproemail.php
@@ -946,62 +946,14 @@ function sendBillingFailureEmail( $user = NULL, $order = NULL ) {
global $current_user;
if(!$user)
$user = $current_user;
-
+
if(!$user || !$order)
return false;
- //get Level from constructor
- $membership_level = new PMPro_Membership_Level( $order->membership_id );
-
- // Try to get the subscription ID.
- $subscription = $order->get_subscription();
- $subscription_id = ! empty( $subscription ) ? $subscription->get_id() : null;
-
- $this->email = $user->user_email;
- $this->subject = sprintf( __("Membership payment for level %s failed at %s", "paid-memberships-pro"),
- $membership_level->name, get_option("blogname") );
-
- $this->data = array(
- 'subject' => $this->subject,
- 'header_name' => $user->display_name,
- 'name' => $user->display_name,
- 'user_login' => $user->user_login,
- 'sitename' => get_option( 'blogname' ),
- 'siteemail' => get_option( 'pmpro_from_email' ),
- 'membership_id' => $membership_level->id,
- 'membership_level_name' => $membership_level->name,
- 'display_name' => $user->display_name,
- 'user_email' => $user->user_email,
- 'billing_name' => $order->billing->name,
- 'billing_street' => $order->billing->street,
- 'billing_street2' => $order->billing->street2,
- 'billing_city' => $order->billing->city,
- 'billing_state' => $order->billing->state,
- 'billing_zip' => $order->billing->zip,
- 'billing_country' => $order->billing->country,
- 'billing_phone' => $order->billing->phone,
- 'cardtype' => $order->cardtype,
- 'accountnumber' => hideCardNumber($order->accountnumber),
- 'expirationmonth' => $order->expirationmonth,
- 'expirationyear' => $order->expirationyear,
- 'login_link' => pmpro_login_url( pmpro_url( 'billing', empty( $subscription_id ) ? '' : '?subscription_id=' . $subscription_id ) ),
- 'login_url' => pmpro_login_url( pmpro_url( 'billing', empty( $subscription_id ) ? '' : '?subscription_id=' . $subscription_id ) ),
- 'levels_url' => pmpro_url( 'levels' )
- );
- $this->data["billing_address"] = pmpro_formatAddress($order->billing->name,
- $order->billing->street,
- $order->billing->street2,
- $order->billing->city,
- $order->billing->state,
- $order->billing->zip,
- $order->billing->country,
- $order->billing->phone);
-
- $this->template = apply_filters("pmpro_email_template", "billing_failure", $this);
+ $email = new PMPro_Email_Template_Billing_Failure( $user, $order );
+ $email->send();
+ }
- return $this->sendEmail();
- }
-
/**
* Send the admin an email when their recurring payment has failed.
*
@@ -1011,52 +963,13 @@ function sendBillingFailureEmail( $user = NULL, $order = NULL ) {
function sendBillingFailureAdminEmail($email, $order = NULL) {
if(!$order)
return false;
-
- $user = get_userdata($order->user_id);
- $membership_level = new PMPro_Membership_Level( $order->membership_id );
-
- $this->email = $email;
- $this->subject = sprintf(__("Membership payment failed For %s at %s", "paid-memberships-pro"), $user->display_name, get_option("blogname"));
-
- $this->data = array(
- 'subject' => $this->subject,
- 'header_name' => $this->get_admin_name( $email ),
- 'name' => 'Admin',
- 'user_login' => $user->user_login,
- 'sitename' => get_option( 'blogname' ),
- 'siteemail' => get_option( 'pmpro_from_email' ),
- 'membership_id' => $membership_level->id,
- 'membership_level_name' => $membership_level->name,
- 'display_name' => $user->display_name,
- 'user_email' => $user->user_email,
- 'billing_name' => $order->billing->name,
- 'billing_street' => $order->billing->street,
- 'billing_street2' => $order->billing->street2,
- 'billing_city' => $order->billing->city,
- 'billing_state' => $order->billing->state,
- 'billing_zip' => $order->billing->zip,
- 'billing_country' => $order->billing->country,
- 'billing_phone' => $order->billing->phone,
- 'cardtype' => $order->cardtype,
- 'accountnumber' => hideCardNumber($order->accountnumber),
- 'expirationmonth' => $order->expirationmonth,
- 'expirationyear' => $order->expirationyear,
- 'login_link' => pmpro_login_url( get_edit_user_link( $user->ID ) ),
- 'login_url' => pmpro_login_url( get_edit_user_link( $user->ID ) ),
- 'levels_url' => pmpro_url( 'levels' ),
- );
- $this->data["billing_address"] = pmpro_formatAddress($order->billing->name,
- $order->billing->street,
- $order->billing->street2,
- $order->billing->city,
- $order->billing->state,
- $order->billing->zip,
- $order->billing->country,
- $order->billing->phone);
- $this->template = apply_filters("pmpro_email_template", "billing_failure_admin", $this);
+ $user = get_userdata( $order->user_id );
+ if(!$user)
+ return false;
- return $this->sendEmail();
+ $email = new PMPro_Email_Template_Billing_Failure_Admin( $user, $order );
+ $email->send();
}
/**
diff --git a/classes/email-templates/class-pmpro-email-template-billing-failure-admin.php b/classes/email-templates/class-pmpro-email-template-billing-failure-admin.php
new file mode 100644
index 000000000..a9babdcf7
--- /dev/null
+++ b/classes/email-templates/class-pmpro-email-template-billing-failure-admin.php
@@ -0,0 +1,207 @@
+user = $user;
+ $this->order = $order;
+ }
+
+ /**
+ * Get the email template slug.
+ *
+ * @since TBD
+ *
+ * @return string The email template slug.
+ */
+ public static function get_template_slug() {
+ return 'billing_failure_admin';
+ }
+
+ /**
+ * Get the "nice name" of the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "nice name" of the email template.
+ */
+ public static function get_template_name() {
+ return __( 'Payment Failure (admin)', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the email template description.
+ *
+ * @since TBD
+ *
+ * @return string The email template description.
+ */
+ public static function get_template_description() {
+ return __( 'This email is sent to the site admin when a member\'s payment fails.', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the email subject.
+ *
+ * @since TBD
+ *
+ * @return string The email subject.
+ */
+ public static function get_default_subject() {
+ return __( "Membership payment failed for !!display_name!! at !!sitename!!", 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the email body.
+ *
+ * @since TBD
+ *
+ * @return string The email body.
+ */
+ public static function get_default_body() {
+ return __( 'The subscription payment for !!user_login!! for level !!membership_level_name!! at !!sitename!! has failed.
+ Account: !!display_name!! (!!user_email!!)
+ Membership Level: !!membership_level_name!!
+
+ Log in to your WordPress admin here: !!login_url!!
', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the email address to send the email to.
+ *
+ * @since TBD
+ *
+ * @return string The email address to send the email to.
+ */
+ public function get_recipient_email() {
+ return get_bloginfo( 'admin_email' );
+ }
+
+ /**
+ * Get the name of the email recipient.
+ *
+ * @since TBD
+ *
+ * @return string The name of the email recipient.
+ */
+ public function get_recipient_name() {
+ //get user by email
+ $user = get_user_by( 'email', $this->get_recipient_email() );
+ return $user->display_name;
+ }
+
+ /**
+ * Get the email template variables for the email paired with a description of the variable.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public static function get_email_template_variables_with_description() {
+ return array(
+ '!!subject!!' => __( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
+ '!!header_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
+ '!!name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
+ '!!user_login!!' => __( 'The username of the user.', 'paid-memberships-pro' ),
+ '!!user_email!!' => __( 'The email address of the user billing failed', 'paid-memberships-pro' ),
+ '!!display_name!!' => __( 'The display name of the user billing failed', 'paid-memberships-pro' ),
+ '!!membership_id!!' => __( 'The ID of the membership level.', 'paid-memberships-pro' ),
+ '!!membership_level_name!!' => __( 'The name of the membership level.', 'paid-memberships-pro' ),
+ '!!billing_name!!' => __( 'Billing Info Name', 'paid-memberships-pro' ),
+ '!!billing_street!!' => __( 'Billing Info Street', 'paid-memberships-pro' ),
+ '!!billing_street2!!' => __( 'Billing Info Street 2', 'paid-memberships-pro' ),
+ '!!billing_city!!' => __( 'Billing Info City', 'paid-memberships-pro' ),
+ '!!billing_state!!' => __( 'Billing Info State', 'paid-memberships-pro' ),
+ '!!billing_zip!!' => __( 'Billing Info Zip', 'paid-memberships-pro' ),
+ '!!billing_country!!' => __( 'Billing Info Country', 'paid-memberships-pro' ),
+ '!!billing_phone!!' => __( 'Billing Info Phone', 'paid-memberships-pro' ),
+ '!!billing_address!!' => __( 'Billing Info Complete Address', 'paid-memberships-pro' ),
+ '!!cardtype!!' => __( 'Credit Card Type', 'paid-memberships-pro' ),
+ '!!accountnumber!!' => __( 'Credit Card Number (last 4 digits)', 'paid-memberships-pro' ),
+ '!!expirationmonth!!' => __( 'Credit Card Expiration Month (mm format)', 'paid-memberships-pro' ),
+ '!!expirationyear!!' => __( 'Credit Card Expiration Year (yyyy format)', 'paid-memberships-pro' ),
+
+ );
+ }
+
+ /**
+ * Get the email template variables for the email.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public function get_email_template_variables() {
+ $order = $this->order;
+ $user = $this->user;
+ $membership_level = pmpro_getLevel( $order->membership_id );
+ return array(
+ 'subject' => $this->get_default_subject(),
+ 'header_name' => $user->display_name,
+ 'name' => $user->display_name,
+ 'user_login' => $user->user_login,
+ 'membership_id' => $membership_level->id,
+ 'membership_level_name' => $membership_level->name,
+ 'display_name' => $user->display_name,
+ 'user_email' => $user->user_email,
+ 'billing_name' => $order->billing->name,
+ 'billing_street' => $order->billing->street,
+ 'billing_street2' => $order->billing->street2,
+ 'billing_city' => $order->billing->city,
+ 'billing_state' => $order->billing->state,
+ 'billing_zip' => $order->billing->zip,
+ 'billing_country' => $order->billing->country,
+ 'billing_phone' => $order->billing->phone,
+ 'billing_address'=> pmpro_formatAddress( $order->billing->name,
+ $order->billing->street,
+ $order->billing->street2,
+ $order->billing->city,
+ $order->billing->state,
+ $order->billing->zip,
+ $order->billing->country,
+ $order->billing->phone ),
+ 'cardtype' => $order->cardtype,
+ 'accountnumber' => hideCardNumber( $order->accountnumber ),
+ 'expirationmonth' => $order->expirationmonth,
+ 'expirationyear' => $order->expirationyear,
+ );
+ }
+}
+
+/**
+ * Register the email template.
+ *
+ * @since TBD
+ *
+ * @param array $email_templates The email templates (template slug => email template class name)
+ * @return array The modified email templates array.
+ */
+function pmpro_email_templates_billing_failure_admin( $email_templates ) {
+ $email_templates['billing_failure_admin'] = 'PMPro_Email_Template_Billing_Failure_Admin';
+ return $email_templates;
+}
+add_filter( 'pmpro_email_templates', 'pmpro_email_templates_billing_failure_admin' );
+
+
diff --git a/classes/email-templates/class-pmpro-email-template-billing-failure.php b/classes/email-templates/class-pmpro-email-template-billing-failure.php
new file mode 100644
index 000000000..9ae2a9ad1
--- /dev/null
+++ b/classes/email-templates/class-pmpro-email-template-billing-failure.php
@@ -0,0 +1,200 @@
+user = $user;
+ $this->order = $order;
+ }
+
+ /**
+ * Get the email template slug.
+ *
+ * @since TBD
+ *
+ * @return string The email template slug.
+ */
+ public static function get_template_slug() {
+ return 'billing_failure';
+ }
+
+ /**
+ * Get the "nice name" of the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "nice name" of the email template.
+ */
+ public static function get_template_name() {
+ return __( 'Payment Failure', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get "help text" to display to the admin when editing the email template.
+ *
+ * @since TBD
+ *
+ * @return string The help text.
+ */
+ public static function get_template_description() {
+ return __( 'This email is sent out if a recurring payment has failed, usually due to an expired or cancelled credit card. This email is sent to the member to allowing them time to update payment information without a disruption in access to your site.', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the email subject.
+ *
+ * @since TBD
+ *
+ * @return string The email subject.
+ */
+ public static function get_default_subject() {
+ return __( "Membership payment failed at !!sitename!!", 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the email body.
+ *
+ * @since TBD
+ *
+ * @return string The email body.
+ */
+ public static function get_default_body() {
+ return __( 'The current subscription payment for level !!membership_level_name!! at !!sitename!! membership has failed. Please click the following link to log in and update your billing information to avoid account suspension.
!!login_url!!
+ Account: !!display_name!! (!!user_email!!)
', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the email address to send the email to.
+ *
+ * @since TBD
+ *
+ * @return string The email address to send the email to.
+ */
+ public function get_recipient_email() {
+ return $this->user->user_email;
+ }
+
+ /**
+ * Get the name of the email recipient.
+ *
+ * @since TBD
+ *
+ * @return string The name of the email recipient.
+ */
+ public function get_recipient_name() {
+ return $this->user->display_name;
+ }
+
+ /**
+ * Get the email template variables for the email paired with a description of the variable.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public static function get_email_template_variables_with_description() {
+ return array(
+ '!!subject!!' => __( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
+ '!!header_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
+ '!!name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
+ '!!user_login!!' => __( 'The username of the user.', 'paid-memberships-pro' ),
+ '!!user_email!!' => __( 'The email address of the user billing failed', 'paid-memberships-pro' ),
+ '!!display_name!!' => __( 'The display name of the user billing failed', 'paid-memberships-pro' ),
+ '!!membership_id!!' => __( 'The ID of the membership level.', 'paid-memberships-pro' ),
+ '!!membership_level_name!!' => __( 'The name of the membership level.', 'paid-memberships-pro' ),
+ '!!billing_name!!' => __( 'Billing Info Name', 'paid-memberships-pro' ),
+ '!!billing_street!!' => __( 'Billing Info Street', 'paid-memberships-pro' ),
+ '!!billing_street2!!' => __( 'Billing Info Street 2', 'paid-memberships-pro' ),
+ '!!billing_city!!' => __( 'Billing Info City', 'paid-memberships-pro' ),
+ '!!billing_state!!' => __( 'Billing Info State', 'paid-memberships-pro' ),
+ '!!billing_zip!!' => __( 'Billing Info Zip', 'paid-memberships-pro' ),
+ '!!billing_country!!' => __( 'Billing Info Country', 'paid-memberships-pro' ),
+ '!!billing_phone!!' => __( 'Billing Info Phone', 'paid-memberships-pro' ),
+ '!!billing_address!!' => __( 'Billing Info Complete Address', 'paid-memberships-pro' ),
+ '!!cardtype!!' => __( 'Credit Card Type', 'paid-memberships-pro' ),
+ '!!accountnumber!!' => __( 'Credit Card Number (last 4 digits)', 'paid-memberships-pro' ),
+ '!!expirationmonth!!' => __( 'Credit Card Expiration Month (mm format)', 'paid-memberships-pro' ),
+ '!!expirationyear!!' => __( 'Credit Card Expiration Year (yyyy format)', 'paid-memberships-pro' ),
+
+ );
+ }
+
+ /**
+ * Get the email template variables for the email.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public function get_email_template_variables() {
+ $order = $this->order;
+ $user = $this->user;
+ $membership_level = pmpro_getLevel( $order->membership_id );
+ return array(
+ 'subject' => $this->get_default_subject(),
+ 'header_name' => $user->display_name,
+ 'name' => $user->display_name,
+ 'user_login' => $user->user_login,
+ 'membership_id' => $membership_level->id,
+ 'membership_level_name' => $membership_level->name,
+ 'display_name' => $user->display_name,
+ 'user_email' => $user->user_email,
+ 'billing_name' => $order->billing->name,
+ 'billing_street' => $order->billing->street,
+ 'billing_street2' => $order->billing->street2,
+ 'billing_city' => $order->billing->city,
+ 'billing_state' => $order->billing->state,
+ 'billing_zip' => $order->billing->zip,
+ 'billing_country' => $order->billing->country,
+ 'billing_phone' => $order->billing->phone,
+ 'billing_address'=> pmpro_formatAddress( $order->billing->name,
+ $order->billing->street,
+ $order->billing->street2,
+ $order->billing->city,
+ $order->billing->state,
+ $order->billing->zip,
+ $order->billing->country,
+ $order->billing->phone ),
+ 'cardtype' => $order->cardtype,
+ 'accountnumber' => hideCardNumber( $order->accountnumber ),
+ 'expirationmonth' => $order->expirationmonth,
+ 'expirationyear' => $order->expirationyear,
+ );
+ }
+}
+
+/**
+ * Register the email template.
+ *
+ * @since TBD
+ *
+ * @param array $email_templates The email templates (template slug => email template class name)
+ * @return array The modified email templates array.
+ */
+function pmpro_email_templates_billing_failure( $email_templates ) {
+ $email_templates['billing_failure'] = 'PMPro_Email_Template_Billing_Failure';
+ return $email_templates;
+}
+add_filter( 'pmpro_email_templates', 'pmpro_email_templates_billing_failure' );
\ No newline at end of file
diff --git a/includes/email-templates.php b/includes/email-templates.php
index e0d2734a2..534eb9360 100644
--- a/includes/email-templates.php
+++ b/includes/email-templates.php
@@ -60,26 +60,6 @@
Log in to your WordPress dashboard here: !!login_url!!
', 'paid-memberships-pro' ),
'help_text' => __( 'Members can update the payment method associated with their recurring subscription. This email is sent to the site administrator as a confirmation of a payment method update.', 'paid-memberships-pro' )
),
- 'billing_failure' => array(
- 'subject' => __( "Membership payment failed at !!sitename!!", 'paid-memberships-pro' ),
- 'description' => __( 'Payment Failure', 'paid-memberships-pro' ),
- 'body' => __( 'The current subscription payment for level !!membership_level_name!! at !!sitename!! membership has failed. Please click the following link to log in and update your billing information to avoid account suspension.
!!login_url!!
-
-Account: !!display_name!! (!!user_email!!)
', 'paid-memberships-pro' ),
- 'help_text' => __( 'This email is sent out if a recurring payment has failed, usually due to an expired or cancelled credit card. This email is sent to the member to allowing them time to update payment information without a disruption in access to your site.', 'paid-memberships-pro' )
- ),
- 'billing_failure_admin' => array(
- 'subject' => __( "Membership payment failed for !!display_name!! at !!sitename!!", 'paid-memberships-pro' ),
- 'description' => __( 'Payment Failure (admin)', 'paid-memberships-pro' ),
- 'body' => __( 'The subscription payment for !!user_login!! for level !!membership_level_name!! at !!sitename!! has failed.
-
-Account: !!display_name!! (!!user_email!!)
-Membership Level: !!membership_level_name!!
-
-Log in to your WordPress admin here: !!login_url!!
-', 'paid-memberships-pro' ),
- 'help_text' => __( 'This email is sent out if a recurring payment has failed for a member, usually due to an expired or cancelled credit card. This email is sent to the site administrator.', 'paid-memberships-pro' )
- ),
'cancel_on_next_payment_date' => array(
'subject' => __( "Your payment subscription at !!sitename!! has been CANCELLED", 'paid-memberships-pro' ),
'description' => __('Canceled Auto-Renewals', 'paid-memberships-pro'),
diff --git a/paid-memberships-pro.php b/paid-memberships-pro.php
index fc919808d..55f827140 100644
--- a/paid-memberships-pro.php
+++ b/paid-memberships-pro.php
@@ -55,6 +55,8 @@
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-cancel-admin.php' ); // cancel email template
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-admin-change.php' ); // change email template
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-admin-change-admin.php' ); // change email template
+require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-billing-failure.php' ); // billing failure email template
+require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-billing-failure-admin.php' ); // billing failure email template
require_once( PMPRO_DIR . '/includes/filters.php' ); // filters, hacks, etc, moved into the plugin
require_once( PMPRO_DIR . '/includes/reports.php' ); // load reports for admin (reports may also include tracking code, etc)
From 749b941e720e77f362085e16e8a8594c68abf5df Mon Sep 17 00:00:00 2001
From: maximilianoRicoTabo
Date: Thu, 14 Nov 2024 11:32:47 -0300
Subject: [PATCH 12/41] * Add canceled autorenewal template / classes for
member and admin
---
classes/class.pmproemail.php | 56 +-----
...late-cancel-on-next-payment-date-admin.php | 171 +++++++++++++++++
...l-template-cancel-on-next-payment-date.php | 172 ++++++++++++++++++
includes/email-templates.php | 21 ---
paid-memberships-pro.php | 2 +
5 files changed, 350 insertions(+), 72 deletions(-)
create mode 100644 classes/email-templates/class-pmpro-email-template-cancel-on-next-payment-date-admin.php
create mode 100644 classes/email-templates/class-pmpro-email-template-cancel-on-next-payment-date.php
diff --git a/classes/class.pmproemail.php b/classes/class.pmproemail.php
index 8816f189c..7dbb0dee8 100644
--- a/classes/class.pmproemail.php
+++ b/classes/class.pmproemail.php
@@ -347,35 +347,8 @@ function sendCancelOnNextPaymentDateEmail( $user, $level_id ) {
_doing_it_wrong( __FUNCTION__, esc_html__( 'The $user parameter should be a WP_User object.', 'paid-memberships-pro' ), '3.0' );
}
- // Get the level object.
- $level = pmpro_getSpecificMembershipLevelForUser( $user->ID, $level_id );
-
- // Make sure that the level is now set to expire.
- if ( empty( $level ) || empty( $level->enddate) ) {
- return false;
- }
-
- $this->email = $user->user_email;
- $this->subject = sprintf( __( 'Your payment subscription at %s has been CANCELLED', 'paid-memberships-pro' ), $user->user_login, get_option( 'blogname' ) );
-
- $this->data = array(
- 'user_login' => $user->user_login,
- 'user_email' => $user->user_email,
- 'display_name' => $user->display_name,
- 'sitename' => get_option( 'blogname' ),
- 'siteemail' => get_option( 'pmpro_from_email' ),
- 'login_link' => pmpro_login_url(),
- 'login_url' => pmpro_login_url(),
- 'levels_url' => pmpro_url( 'levels' ),
- 'membership_id' => $level->id,
- 'membership_level_name' => $level->name,
- 'startdate' => date_i18n( get_option( 'date_format' ), $level->startdate ),
- 'enddate' => date_i18n( get_option( 'date_format' ), $level->enddate ),
- );
-
- $this->template = apply_filters( "pmpro_email_template", "cancel_on_next_payment_date", $this );
-
- return $this->sendEmail();
+ $email = new PMPro_Email_Template_Cancel_On_Next_Payment_Date( $user, $level_id );
+ $email->send();
}
/**
@@ -401,31 +374,12 @@ function sendCancelOnNextPaymentDateAdminEmail( $user, $level_id ) {
$level = pmpro_getSpecificMembershipLevelForUser( $user->ID, $level_id );
// Make sure that the level is now set to expire.
- if ( empty( $level ) || empty( $level->enddate) ) {
+ if ( empty( $level ) || empty( $level->enddate ) ) {
return false;
}
- $this->email = get_option( 'pmpro_from_email' );
- $this->subject = sprintf( __( 'Payment subscription for %s at %s has been CANCELLED', 'paid-memberships-pro' ), $user->user_login, get_option( 'blogname' ) );
-
- $this->data = array(
- 'user_login' => $user->user_login,
- 'user_email' => $user->user_email,
- 'display_name' => $user->display_name,
- 'sitename' => get_option( 'blogname' ),
- 'siteemail' => get_option( 'pmpro_from_email' ),
- 'login_link' => pmpro_login_url(),
- 'login_url' => pmpro_login_url(),
- 'levels_url' => pmpro_url( 'levels' ),
- 'membership_id' => $level->id,
- 'membership_level_name' => $level->name,
- 'startdate' => date_i18n( get_option( 'date_format' ), $level->startdate ),
- 'enddate' => date_i18n( get_option( 'date_format' ), $level->enddate ),
- );
-
- $this->template = apply_filters( "pmpro_email_template", "cancel_on_next_payment_date_admin", $this );
-
- return $this->sendEmail();
+ $email = new PMPro_Email_Template_Cancel_On_Next_Payment_Date_Admin( $user, $level_id );
+ $email->send();
}
/**
diff --git a/classes/email-templates/class-pmpro-email-template-cancel-on-next-payment-date-admin.php b/classes/email-templates/class-pmpro-email-template-cancel-on-next-payment-date-admin.php
new file mode 100644
index 000000000..af8d55638
--- /dev/null
+++ b/classes/email-templates/class-pmpro-email-template-cancel-on-next-payment-date-admin.php
@@ -0,0 +1,171 @@
+user = $user;
+ $this->level_id = $level_id;
+ }
+
+ /**
+ * Get the email template slug.
+ *
+ * @since TBD
+ *
+ * @return string The email template slug.
+ */
+ public static function get_template_slug() {
+ return 'cancel_on_next_payment_date_admin';
+ }
+
+ /**
+ * Get the "nice name" of the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "nice name" of the email template.
+ */
+ public static function get_template_name() {
+ return __( 'Cancelled Auto-Renewals (admin)', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get "help text" to display to the admin when editing the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "help text" to display to the admin when editing the email template.
+ */
+ public static function get_template_description() {
+ return __( 'When a user cancels a membership with a recurring subscription, they will still have access until when their next payment would have been taken. This email is sent to the site administrator to notify them of this change.', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the default subject for the email.
+ *
+ * @since TBD
+ *
+ * @return string The default subject for the email.
+ */
+ public static function get_default_subject() {
+ return __( "Payment subscription for !!user_login!! at !!sitename!! has been CANCELLED", 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the default body content for the email.
+ *
+ * @since TBD
+ *
+ * @return string The default body content for the email.
+ */
+ public static function get_default_body() {
+ return __( 'The payment subscription for !!user_login!! at !!sitename!! has been cancelled.
+ Account: !!display_name!! (!!user_email!!)
+ Membership Level: !!membership_level_name!!
+ Start Date: !!startdate!!
+ Expiration Date: !!enddate!!
', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the email address to send the email to.
+ *
+ * @since TBD
+ *
+ * @return string The email address to send the email to.
+ */
+ public function get_recipient_email() {
+ return get_bloginfo( 'admin_email' );
+ }
+
+ /**
+ * Get the name of the email recipient.
+ *
+ * @since TBD
+ *
+ * @return string The name of the email recipient.
+ */
+ public function get_recipient_name() {
+ //get user by email
+ $user = get_user_by( 'email', $this->get_recipient_email() );
+ return $user->display_name;
+ }
+
+ /**
+ * Get the email template variables for the email paired with a description of the variable.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public static function get_email_template_variables_with_description() {
+ return array(
+ 'user_login' => __( 'The user\'s username.', 'paid-memberships-pro' ),
+ 'user_email' => __( 'The user\'s email address.', 'paid-memberships-pro' ),
+ 'display_name' => __( 'The user\'s display name.', 'paid-memberships-pro' ),
+ 'membership_id' => __( 'The ID of the membership level.', 'paid-memberships-pro' ),
+ 'membership_level_name' => __( 'The name of the membership level.', 'paid-memberships-pro' ),
+ 'startdate' => __( 'The start date of the membership level.', 'paid-memberships-pro' ),
+ 'enddate' => __( 'The end date of the membership level.', 'paid-memberships-pro' ),
+ );
+ }
+
+ /**
+ * Get the email template variables for the email.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public function get_email_template_variables() {
+ $user = $this->user;
+ $level = pmpro_getLevel( $this->level_id );
+
+ $email_template_variables = array(
+ 'user_login' => $user->user_login,
+ 'user_email' => $user->user_email,
+ 'display_name' => $user->display_name,
+ 'membership_id' => $level->id,
+ 'membership_level_name' => $level->name,
+ 'startdate' => date_i18n( get_option( 'date_format' ), $level->startdate ),
+ 'enddate' => date_i18n( get_option( 'date_format' ), $level->enddate ),
+ );
+ return $email_template_variables;
+ }
+}
+// Register the email template.
+
+/**
+ * Register the email template.
+ *
+ * @since TBD
+ *
+ * @param array $email_templates The email templates (template slug => email template class name)
+ * @return array The modified email templates array.
+ */
+function pmpro_email_templates_cancel_on_next_payment_date_admin( $email_templates ) {
+ $email_templates['cancel_on_next_payment_date_admin'] = 'PMPro_Email_Template_Cancel_On_Next_Payment_Date_Admin';
+
+ return $email_templates;
+}
+add_filter( 'pmpro_email_templates', 'pmpro_email_templates_cancel_on_next_payment_date_admin' );
\ No newline at end of file
diff --git a/classes/email-templates/class-pmpro-email-template-cancel-on-next-payment-date.php b/classes/email-templates/class-pmpro-email-template-cancel-on-next-payment-date.php
new file mode 100644
index 000000000..bb7638237
--- /dev/null
+++ b/classes/email-templates/class-pmpro-email-template-cancel-on-next-payment-date.php
@@ -0,0 +1,172 @@
+user = $user;
+ $this->level_id = $level_id;
+ }
+
+ /**
+ * Get the email template slug.
+ *
+ * @since TBD
+ *
+ * @return string The email template slug.
+ */
+ public static function get_template_slug() {
+ return 'cancel_on_next_payment_date';
+ }
+
+ /**
+ * Get the "nice name" of the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "nice name" of the email template.
+ */
+ public static function get_template_name() {
+ return __( 'Cancelled Auto-Renewals', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get "help text" to display to the admin when editing the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "help text" to display to the admin when editing the email template.
+ */
+ public static function get_template_description() {
+ return __( 'When a user cancels a membership with a recurring subscription, they will still have access until when their next payment would have been taken. This email is sent to the member to notify them of this change.', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the default subject for the email.
+ *
+ * @since TBD
+ *
+ * @return string The default subject for the email.
+ */
+ public static function get_default_subject() {
+ return __( 'Your payment subscription at !!sitename!! has been CANCELLED', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the default body content for the email.
+ *
+ * @since TBD
+ *
+ * @return string The default body content for the email.
+ */
+ public static function get_default_body() {
+ return __( 'Your payment subscription at !!sitename!! has been cancelled.
+
+ Account: !!display_name!! (!!user_email!!)
+ Membership Level: !!membership_level_name!!
+ Your access will expire on !!enddate!!.
', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the email template variables for the email paired with a description of the variable.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public static function get_email_template_variables_with_description() {
+ return array(
+ 'user_login' => __( 'The user\'s username.', 'paid-memberships-pro' ),
+ 'user_email' => __( 'The user\'s email address.', 'paid-memberships-pro' ),
+ 'display_name' => __( 'The user\'s display name.', 'paid-memberships-pro' ),
+ 'membership_id' => __( 'The ID of the membership level.', 'paid-memberships-pro' ),
+ 'membership_level_name' => __( 'The name of the membership level.', 'paid-memberships-pro' ),
+ 'startdate' => __( 'The start date of the membership level.', 'paid-memberships-pro' ),
+ 'enddate' => __( 'The end date of the membership level.', 'paid-memberships-pro' ),
+ );
+ }
+
+ /**
+ * Get the email address to send the email to.
+ *
+ * @since TBD
+ *
+ * @return string The email address to send the email to.
+ */
+ public function get_recipient_email() {
+ return $this->user->user_email;
+ }
+
+ /**
+ * Get the name of the email recipient.
+ *
+ * @since TBD
+ *
+ * @return string The name of the email recipient.
+ */
+ public function get_recipient_name() {
+ return $this->user->display_name;
+ }
+
+ /**
+ * Get the email template variables for the email.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public function get_email_template_variables() {
+ $user = $this->user;
+ $level = pmpro_getLevel( $this->level_id );
+
+ $email_template_variables = array(
+ 'user_login' => $user->user_login,
+ 'user_email' => $user->user_email,
+ 'display_name' => $user->display_name,
+ 'membership_id' => $level->id,
+ 'membership_level_name' => $level->name,
+ 'startdate' => date_i18n( get_option( 'date_format' ), $level->startdate ),
+ 'enddate' => date_i18n( get_option( 'date_format' ), $level->enddate ),
+ );
+ return $email_template_variables;
+ }
+}
+
+
+/**
+ * Register the email template.
+ *
+ * @since TBD
+ *
+ * @param array $email_templates The email templates (template slug => email template class name)
+ * @return array The modified email templates array.
+ */
+function pmpro_email_templates_cancel_on_next_payment_date( $email_templates ) {
+ $email_templates['cancel_on_next_payment_date'] = 'PMPro_Email_Template_Cancel_On_Next_Payment_Date';
+
+ return $email_templates;
+}
+add_filter( 'pmpro_email_templates', 'pmpro_email_templates_cancel_on_next_payment_date' );
\ No newline at end of file
diff --git a/includes/email-templates.php b/includes/email-templates.php
index e0d2734a2..4b920c928 100644
--- a/includes/email-templates.php
+++ b/includes/email-templates.php
@@ -80,27 +80,6 @@
', 'paid-memberships-pro' ),
'help_text' => __( 'This email is sent out if a recurring payment has failed for a member, usually due to an expired or cancelled credit card. This email is sent to the site administrator.', 'paid-memberships-pro' )
),
- 'cancel_on_next_payment_date' => array(
- 'subject' => __( "Your payment subscription at !!sitename!! has been CANCELLED", 'paid-memberships-pro' ),
- 'description' => __('Canceled Auto-Renewals', 'paid-memberships-pro'),
- 'body' => __( 'Your payment subscription at !!sitename!! has been cancelled.
-
-Account: !!display_name!! (!!user_email!!)
-Membership Level: !!membership_level_name!!
-Your access will expire on !!enddate!!.
', 'paid-memberships-pro' ),
- 'help_text' => __( 'When a user cancels a membership with a recurring subscription, they will still have access until when their next payment would have been taken. This email is sent to the member to notify them of this change.', 'paid-memberships-pro' )
- ),
- 'cancel_on_next_payment_date_admin' => array(
- 'subject' => __( "Payment subscription for !!user_login!! at !!sitename!! has been CANCELLED", 'paid-memberships-pro' ),
- 'description' => __('Canceled Auto-Renewals (admin)', 'paid-memberships-pro'),
- 'body' => __( 'The payment subscription for !!user_login!! at !!sitename!! has been cancelled.
-
-Account: !!display_name!! (!!user_email!!)
-Membership Level: !!membership_level_name!!
-Start Date: !!startdate!!
-Expiration Date: !!enddate!!
', 'paid-memberships-pro' ),
- 'help_text' => __( 'When a user cancels a membership with a recurring subscription, they will still have access until when their next payment would have been taken. This email is sent to the site administrator to notify them of this change.', 'paid-memberships-pro' )
- ),
'checkout_check' => array(
'subject' => __( "Your membership confirmation for !!sitename!!", 'paid-memberships-pro' ),
'description' => sprintf( __('Checkout - %s', 'paid-memberships-pro' ), $check_gateway_label ),
diff --git a/paid-memberships-pro.php b/paid-memberships-pro.php
index fc919808d..5a3c27bf0 100644
--- a/paid-memberships-pro.php
+++ b/paid-memberships-pro.php
@@ -55,6 +55,8 @@
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-cancel-admin.php' ); // cancel email template
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-admin-change.php' ); // change email template
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-admin-change-admin.php' ); // change email template
+require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-cancel-on-next-payment-date.php' ); //cancel auto renewals email template
+require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-cancel-on-next-payment-date-admin.php' ); //cancel auto renewals admin email template
require_once( PMPRO_DIR . '/includes/filters.php' ); // filters, hacks, etc, moved into the plugin
require_once( PMPRO_DIR . '/includes/reports.php' ); // load reports for admin (reports may also include tracking code, etc)
From 6d95fbbc821c90bd9b7806db46c69988e3874a7a Mon Sep 17 00:00:00 2001
From: maximilianoRicoTabo
Date: Fri, 15 Nov 2024 17:01:27 -0500
Subject: [PATCH 13/41] * Add checkout templates
---
classes/class.pmproemail.php | 214 +++-----------
...il-template-admin-checkout-check-admin.php | 241 ++++++++++++++++
...ro-email-template-admin-checkout-check.php | 208 ++++++++++++++
...pro-email-template-checkout-free-admin.php | 211 ++++++++++++++
...ass-pmpro-email-template-checkout-free.php | 204 ++++++++++++++
...pro-email-template-checkout-paid-admin.php | 261 +++++++++++++++++
...ass-pmpro-email-template-checkout-paid.php | 265 ++++++++++++++++++
includes/email-templates.php | 131 ---------
paid-memberships-pro.php | 8 +
9 files changed, 1440 insertions(+), 303 deletions(-)
create mode 100644 classes/email-templates/class-pmpro-email-template-admin-checkout-check-admin.php
create mode 100644 classes/email-templates/class-pmpro-email-template-admin-checkout-check.php
create mode 100644 classes/email-templates/class-pmpro-email-template-checkout-free-admin.php
create mode 100644 classes/email-templates/class-pmpro-email-template-checkout-free.php
create mode 100644 classes/email-templates/class-pmpro-email-template-checkout-paid-admin.php
create mode 100644 classes/email-templates/class-pmpro-email-template-checkout-paid.php
diff --git a/classes/class.pmproemail.php b/classes/class.pmproemail.php
index 8816f189c..c972f4730 100644
--- a/classes/class.pmproemail.php
+++ b/classes/class.pmproemail.php
@@ -595,102 +595,35 @@ function sendCheckoutEmail($user = NULL, $order = NULL)
return false;
}
- $membership_level = pmpro_getSpecificMembershipLevelForUser($user->ID, $order->membership_id);
-
- $confirmation_in_email = get_pmpro_membership_level_meta( $membership_level->id, 'confirmation_in_email', true );
- if ( ! empty( $confirmation_in_email ) ) {
- $confirmation_message = $membership_level->confirmation;
+ $email = null;
+ if( !empty( $this->template ) ) {
+ switch ( $this->template ) {
+ case 'checkout_check':
+ $email = new PMPro_Email_Template_Checkout_Check( $user, $order );
+ break;
+ case 'checkout_free':
+ $email = new PMPro_Email_Template_Checkout_Free( $user, $order );
+ break;
+ case 'checkout_paid':
+ $email = new PMPro_Email_Template_Checkout_Paid( $user, $order );
+ break;
+ }
} else {
- $confirmation_message = '';
- }
-
- $this->email = $user->user_email;
- $this->subject = sprintf(__("Your membership confirmation for %s", 'paid-memberships-pro' ), get_option("blogname"));
-
- $this->data = array(
- 'subject' => $this->subject,
- 'header_name' => $user->display_name,
- 'name' => $user->display_name,
- 'display_name' => $user->display_name,
- 'user_login' => $user->user_login,
- 'sitename' => get_option('blogname'),
- 'siteemail' => get_option('pmpro_from_email'),
- 'membership_id' => $membership_level->id,
- 'membership_level_name' => $membership_level->name,
- 'membership_level_confirmation_message' => wpautop( $confirmation_message ),
- 'membership_cost' => pmpro_getLevelCost($membership_level),
- 'login_link' => pmpro_login_url(),
- 'login_url' => pmpro_login_url(),
- 'user_email' => $user->user_email,
- 'levels_url' => pmpro_url( 'levels' )
- );
-
- // Figure out which template to use.
- if ( empty( $this->template ) ) {
if( ! empty( $order ) && ! pmpro_isLevelFree( $membership_level ) ) {
if( $order->gateway == "check" ) {
- $this->template = "checkout_check";
+ $email = new PMPro_Email_Template_Checkout_Check( $user, $order );
} else {
- $this->template = "checkout_paid";
- }
+ $email = new PMPro_Email_Template_Checkout_Paid( $user, $order );
+ }
} elseif( pmpro_isLevelFree( $membership_level ) ) {
- $this->template = "checkout_free";
+ $email = new PMPro_Email_Template_Checkout_Free( $user, $order );
}
}
-
- $this->template = apply_filters( "pmpro_email_template", $this->template, $this );
-
- // Gather data depending on template being used.
- if( in_array( $this->template, array( 'checkout_check', 'checkout_paid' ) ) ) {
- if( $this->template === 'checkout_check' ) {
- $this->data["instructions"] = wpautop( get_option( "pmpro_instructions" ) );
- }
-
- $this->data["order_id"] = $order->code;
- $this->data["order_total"] = $order->get_formatted_total();
- $this->data["order_date"] = date_i18n( get_option( 'date_format' ), $order->getTimestamp() );
- $this->data["billing_name"] = $order->billing->name;
- $this->data["billing_street"] = $order->billing->street;
- $this->data["billing_street2"] = $order->billing->street2;
- $this->data["billing_city"] = $order->billing->city;
- $this->data["billing_state"] = $order->billing->state;
- $this->data["billing_zip"] = $order->billing->zip;
- $this->data["billing_country"] = $order->billing->country;
- $this->data["billing_phone"] = $order->billing->phone;
- $this->data["cardtype"] = $order->cardtype;
- $this->data["accountnumber"] = hideCardNumber($order->accountnumber);
- $this->data["expirationmonth"] = $order->expirationmonth;
- $this->data["expirationyear"] = $order->expirationyear;
- $this->data["billing_address"] = pmpro_formatAddress($order->billing->name,
- $order->billing->street,
- $order->billing->street2,
- $order->billing->city,
- $order->billing->state,
- $order->billing->zip,
- $order->billing->country,
- $order->billing->phone);
-
- if( $order->getDiscountCode() ) {
- $this->data["discount_code"] = "" . __("Discount Code", 'paid-memberships-pro' ) . ": " . $order->discount_code->code . "
\n";
- } else {
- $this->data["discount_code"] = "";
- }
- } elseif( $this->template === 'checkout_free' ) {
- if( ! empty( $discount_code ) ) {
- $this->data["discount_code"] = "" . __("Discount Code", 'paid-memberships-pro' ) . ": " . $discount_code . "
\n";
- } else {
- $this->data["discount_code"] = "";
- }
+ //Bail if $email is null
+ if( $email == null ) {
+ return false;
}
-
- $enddate = $wpdb->get_var("SELECT UNIX_TIMESTAMP(CONVERT_TZ(enddate, '+00:00', @@global.time_zone)) FROM $wpdb->pmpro_memberships_users WHERE user_id = '" . $user->ID . "' AND status = 'active' LIMIT 1");
- if( $enddate ) {
- $this->data["membership_expiration"] = "" . sprintf(__("This membership will expire on %s.", 'paid-memberships-pro' ), date_i18n(get_option('date_format'), $enddate)) . "
\n";
- } else {
- $this->data["membership_expiration"] = "";
- }
-
- return $this->sendEmail();
+ $email->send();
}
/**
@@ -712,100 +645,37 @@ function sendCheckoutAdminEmail($user = NULL, $order = NULL)
return false;
}
- $membership_level = pmpro_getSpecificMembershipLevelForUser($user->ID, $order->membership_id);
-
- $confirmation_in_email = get_pmpro_membership_level_meta( $membership_level->id, 'confirmation_in_email', true );
- if ( ! empty( $confirmation_in_email ) ) {
- $confirmation_message = $membership_level->confirmation;
+ $email = null;
+ if( !empty( $this->template ) ) {
+ switch( $this->template ) {
+ case 'checkout_check_admin':
+ $email = new PMPro_Email_Template_Checkout_Check_Admin( $user, $order );
+ break;
+ case 'checkout_free_admin':
+ $email = new PMPro_Email_Template_Checkout_Free_Admin( $user, $order );
+ break;
+ case 'checkout_paid':
+ $email = new PMPro_Email_Template_Checkout_Paid_Admin( $user, $order );
+ break;
+ }
} else {
- $confirmation_message = '';
- }
-
- $this->email = get_bloginfo("admin_email");
- $this->subject = sprintf(__("Member checkout for %s at %s", 'paid-memberships-pro' ), $membership_level->name, get_option("blogname"));
-
- $this->data = array(
- 'subject' => $this->subject,
- 'header_name' => $this->get_admin_name( $this->email ),
- 'name' => $user->display_name,
- 'user_login' => $user->user_login,
- 'sitename' => get_option( 'blogname' ),
- 'siteemail' => get_option( 'pmpro_from_email' ),
- 'membership_id' => $membership_level->id,
- 'membership_level_name' => $membership_level->name,
- 'membership_level_confirmation_message' => $confirmation_message,
- 'membership_cost' => pmpro_getLevelCost($membership_level),
- 'login_link' => pmpro_login_url(),
- 'login_url' => pmpro_login_url(),
- 'display_name' => $user->display_name,
- 'user_email' => $user->user_email,
- 'levels_url' => pmpro_url( 'levels' )
- );
-
- // Figure out which template to use.
- if ( empty( $this->template ) ) {
if( ! empty( $order ) && ! pmpro_isLevelFree( $membership_level ) ) {
if( $order->gateway == "check" ) {
- $this->template = "checkout_check_admin";
+ $email = new PMPro_Email_Template_Checkout_Check_Admin( $user, $order );
} else {
- $this->template = "checkout_paid_admin";
+ $email = new PMPro_Email_Template_Checkout_Paid_Admin( $user, $order );
}
} elseif( pmpro_isLevelFree( $membership_level ) ) {
- $this->template = "checkout_free_admin";
+ $email = new PMPro_Email_Template_Checkout_Free_Admin( $user, $order );
}
}
-
- $this->template = apply_filters( "pmpro_email_template", $this->template, $this );
-
- // Gather data depending on template being used.
- if( in_array( $this->template, array( 'checkout_check_admin', 'checkout_paid_admin' ) ) ) {
- $this->data["order_id"] = $order->code;
- $this->data["order_total"] = $order->get_formatted_total();
- $this->data["order_date"] = date_i18n(get_option('date_format'), $order->getTimestamp());
- $this->data["billing_name"] = $order->billing->name;
- $this->data["billing_street"] = $order->billing->street;
- $this->data["billing_street2"] = $order->billing->street2;
- $this->data["billing_city"] = $order->billing->city;
- $this->data["billing_state"] = $order->billing->state;
- $this->data["billing_zip"] = $order->billing->zip;
- $this->data["billing_country"] = $order->billing->country;
- $this->data["billing_phone"] = $order->billing->phone;
- $this->data["cardtype"] = $order->cardtype;
- $this->data["accountnumber"] = hideCardNumber($order->accountnumber);
- $this->data["expirationmonth"] = $order->expirationmonth;
- $this->data["expirationyear"] = $order->expirationyear;
- $this->data["billing_address"] = pmpro_formatAddress($order->billing->name,
- $order->billing->street,
- $order->billing->street2,
- $order->billing->city,
- $order->billing->state,
- $order->billing->zip,
- $order->billing->country,
- $order->billing->phone);
-
- if( $order->getDiscountCode() ) {
- $this->data["discount_code"] = "" . __("Discount Code", 'paid-memberships-pro' ) . ": " . $order->discount_code->code . "
\n";
- } else {
- $this->data["discount_code"] = "";
- }
- } elseif( $this->template === 'checkout_free_admin' ) {
- if( ! empty( $discount_code ) ) {
- $this->data["discount_code"] = "" . __("Discount Code", 'paid-memberships-pro' ) . ": " . $discount_code . "
\n";
- } else {
- $this->data["discount_code"] = "";
- }
- }
-
- $enddate = $wpdb->get_var("SELECT UNIX_TIMESTAMP(CONVERT_TZ(enddate, '+00:00', @@global.time_zone)) FROM $wpdb->pmpro_memberships_users WHERE user_id = '" . $user->ID . "' AND status = 'active' LIMIT 1");
- if( $enddate ) {
- $this->data["membership_expiration"] = "" . sprintf(__("This membership will expire on %s.", 'paid-memberships-pro' ), date_i18n(get_option('date_format'), $enddate)) . "
\n";
- } else {
- $this->data["membership_expiration"] = "";
+ //Bail if $email is null
+ if( $email == null ) {
+ return false;
}
-
- return $this->sendEmail();
+ $email->send();
}
-
+
/**
* Send the member a confirmation email when updating their billing details
*
diff --git a/classes/email-templates/class-pmpro-email-template-admin-checkout-check-admin.php b/classes/email-templates/class-pmpro-email-template-admin-checkout-check-admin.php
new file mode 100644
index 000000000..7117d8306
--- /dev/null
+++ b/classes/email-templates/class-pmpro-email-template-admin-checkout-check-admin.php
@@ -0,0 +1,241 @@
+user = $user;
+ $this->order = $order;
+ }
+ /**
+ * Get the email template slug.
+ *
+ * @since TBD
+ *
+ * @return string The email template slug.
+ */
+ public static function get_template_slug() {
+ return 'checkout_check_admin';
+ }
+
+ /**
+ * Get the "nice name" of the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "nice name" of the email template.
+ */
+ public static function get_template_name() {
+ return __( 'Checkout - Pay by Check (admin)', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get "help text" to display to the admin when editing the email template.
+ *
+ * @since TBD
+ *
+ * @return string The help text.
+ */
+ public static function get_template_description() {
+ $check_gateway_label = get_option( 'pmpro_check_gateway_label' ) ? get_option( 'pmpro_check_gateway_label' ) : __( 'Check', 'paid-memberships-pro' );
+ return sprintf( __('This is the membership confirmation email sent to the site administrator for every membership checkout using the "%s (Pay by Check)" gateway.', 'paid-memberships-pro' ), $check_gateway_label );
+ }
+
+ /**
+ * Get the default subject for the email.
+ *
+ * @since TBD
+ *
+ * @return string The default subject for the email.
+ */
+ public static function get_default_subject() {
+ return __( 'Member checkout for !!membership_level_name!! at !!sitename!!', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the default body for the email.
+ *
+ * @since TBD
+ *
+ * @return string The default body for the email.
+ */
+ public static function get_default_body() {
+ $check_gateway_label = get_option( 'pmpro_check_gateway_label' ) ? get_option( 'pmpro_check_gateway_label' ) : __( 'Check', 'paid-memberships-pro' );
+
+ return sprintf( __( 'There was a new member checkout at !!sitename!!.
+
+ They have chosen to pay by %s.
+
+ Below are details about the new membership account and a receipt for the initial membership order.
+
+ Account: !!display_name!! (!!user_email!!)
+ Membership Level: !!membership_level_name!!
+ Membership Fee: !!membership_cost!!
+ !!membership_expiration!! !!discount_code!!
+
+
+ Order #!!order_id!! on !!order_date!!
+ Total Billed: !!order_total!!
+
+
+ Log in to your membership account here: !!login_url!!
','paid-memberships-pro' ), $check_gateway_label );
+ }
+
+ /**
+ * Get the email address to send the email to.
+ *
+ * @since TBD
+ *
+ * @return string The email address to send the email to.
+ */
+ public function get_recipient_email() {
+ return get_bloginfo( 'admin_email' );
+ }
+
+ /**
+ * Get the name of the email recipient.
+ *
+ * @since TBD
+ *
+ * @return string The name of the email recipient.
+ */
+ public function get_recipient_name() {
+ //get user by email
+ $user = get_user_by( 'email', $this->get_recipient_email() );
+ return $user->display_name;
+ }
+
+ /**
+ * Get the email template variables for the email.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public function get_email_template_variables() {
+
+ $order = $this->order;
+ $user = $this->user;
+ $membership_level = pmpro_getLevel( $order->membership_id );
+
+ $confirmation_in_email = get_pmpro_membership_level_meta( $membership_level->id, 'confirmation_in_email', true );
+ if ( ! empty( $confirmation_in_email ) ) {
+ $confirmation_message = $membership_level->confirmation;
+ } else {
+ $confirmation_message = '';
+ }
+
+ $enddate = $wpdb->get_var("SELECT UNIX_TIMESTAMP(CONVERT_TZ(enddate, '+00:00', @@global.time_zone)) FROM $wpdb->pmpro_memberships_users WHERE user_id = '" . $user->ID . "' AND status = 'active' LIMIT 1");
+ if( $enddate ) {
+ $membership_expiration = "" . sprintf(__("This membership will expire on %s.", 'paid-memberships-pro' ), date_i18n(get_option('date_format'), $enddate)) . "
\n";
+ } else {
+ $membership_expiration = "";
+ }
+
+ if( $order->getDiscountCode() ) {
+ $discount_code = "" . __( "Discount Code", 'paid-memberships-pro' ) . ": " . $order->discount_code->code . "
\n";
+ } else {
+ $discount_code = "";
+ }
+
+ $email_template_variables = array(
+ 'subject' => $this->get_default_subject(),
+ 'header_name' => $this->get_recipient_name(),
+ 'name' => $this->get_recipient_name(),
+ 'display_name' => $this->get_recipient_name(),
+ 'user_login' => $user->user_login,
+ 'membership_id' => $membership_level->id,
+ 'membership_level_name' => $membership_level->name,
+ 'confirmation_message' => $confirmation_message,
+ 'membership_cost' => pmpro_getLevelCost($membership_level),
+ 'user_email' => $user->user_email,
+ 'order_id' => $order->code,
+ 'order_total' => $order->get_formatted_total(),
+ 'order_date' => date_i18n( get_option( 'date_format' ), $order->getTimestamp() ),
+ 'billing_name' => $order->billing->name,
+ 'billing_street' => $order->billing->street,
+ 'billing_street2' => $order->billing->street2,
+ 'billing_city' => $order->billing->city,
+ 'billing_state' => $order->billing->state,
+ 'billing_zip' => $order->billing->zip,
+ 'billing_country' => $order->billing->country,
+ 'billing_phone' => $order->billing->phone,
+ 'billing_address'=> pmpro_formatAddress( $order->billing->name,
+ $order->billing->street,
+ $order->billing->street2,
+ $order->billing->city,
+ $order->billing->state,
+ $order->billing->zip,
+ $order->billing->country,
+ $order->billing->phone ),
+ 'cardtype' => $order->cardtype,
+ 'accountnumber' => hideCardNumber( $order->accountnumber ),
+ 'expirationmonth' => $order->expirationmonth,
+ 'expirationyear' => $order->expirationyear,
+ 'membership_expiration' => $membership_expiration,
+ 'discount_code' => $discount_code
+ );
+
+ return $email_template_variables;
+ }
+
+ /**
+ * Get the email template variables for the email paired with a description of the variable.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public static function get_email_template_variables_with_description() {
+
+ return array(
+ '!!subject!!' => __( 'The subject of the email.', 'paid-memberships-pro' ),
+ '!!header_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
+ '!!name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
+ '!!display_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
+ '!!user_login!!' => __( 'The login name of the email recipient.', 'paid-memberships-pro' ),
+ '!!membership_id!!' => __( 'The ID of the membership level.', 'paid-memberships-pro' ),
+ '!!membership_level_name!!' => __( 'The name of the membership level.', 'paid-memberships-pro' ),
+ '!!confirmation_message!!' => __( 'The confirmation message for the membership level.', 'paid-memberships-pro' ),
+ '!!membership_cost!!' => __( 'The cost of the membership level.', 'paid-memberships-pro' ),
+ '!!user_email!!' => __( 'The email address of the email recipient.', 'paid-memberships-pro' ),
+ );
+ }
+
+}
+
+/**
+ * Register the email template.
+ *
+ * @since TBD
+ *
+ * @param array $email_templates The email templates (template slug => email template class name)
+ * @return array The modified email templates array.
+ */
+function pmpro_email_templates_checkout_check_admin( $email_templates ) {
+ $email_templates['checkout_check_admin'] = 'PMPro_Email_Template_Checkout_Check_Admin';
+
+ return $email_templates;
+}
+add_filter( 'pmpro_email_templates', 'pmpro_email_templates_checkout_check_admin' );
\ No newline at end of file
diff --git a/classes/email-templates/class-pmpro-email-template-admin-checkout-check.php b/classes/email-templates/class-pmpro-email-template-admin-checkout-check.php
new file mode 100644
index 000000000..5d470b01e
--- /dev/null
+++ b/classes/email-templates/class-pmpro-email-template-admin-checkout-check.php
@@ -0,0 +1,208 @@
+user = $user;
+ $this->order = $order;
+ }
+
+ /**
+ * Get the email template slug.
+ *
+ * @since TBD
+ *
+ * @return string The email template slug.
+ */
+ public static function get_template_slug() {
+ return 'checkout_check';
+ }
+
+ /**
+ * Get the "nice name" of the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "nice name" of the email template.
+ */
+ public static function get_template_name() {
+ return __( 'Checkout - Pay by Check', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get "help text" to display to the admin when editing the email template.
+ *
+ * @since TBD
+ *
+ * @return string The help text.
+ */
+ public static function get_template_description() {
+ return __( 'This is a membership confirmation welcome email sent to a new member or to existing members that change their level using the "Pay by Check" gateway.', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the default subject for the email.
+ *
+ * @since TBD
+ *
+ * @return string The default subject for the email.
+ */
+ public static function get_default_subject() {
+ return __( 'Your membership confirmation for !!sitename!!', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the default body for the email.
+ *
+ * @since TBD
+ *
+ * @return string The default body for the email.
+ */
+ public static function get_default_body() {
+ return __('Thank you for your membership to !!sitename!!. Your membership account is now active.
+
+ !!membership_level_confirmation_message!!
+
+ !!instructions!!
+
+ Below are details about your membership account and a receipt for your initial membership order.
+
+ Account: !!display_name!! (!!user_email!!)
+ Membership Level: !!membership_level_name!!
+ Membership Fee: !!membership_cost!!
+ !!membership_expiration!! !!discount_code!!
+
+
+ Order #!!order_id!! on !!order_date!!
+ Total Billed: !!order_total!!
+
+
+ Log in to your membership account here: !!login_url!!
', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the email address to send the email to.
+ *
+ * @since TBD
+ *
+ * @return string The email address to send the email to.
+ */
+ public function get_recipient_email() {
+ return $this->user->user_email;
+ }
+
+ /**
+ * Get the name of the email recipient.
+ *
+ * @since TBD
+ *
+ * @return string The name of the email recipient.
+ */
+ public function get_recipient_name() {
+ return $this->user->display_name;
+ }
+
+ /**
+ * Get the email template variables for the email paired with a description of the variable.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public static function get_email_template_variables_with_description() {
+
+ return array(
+ '!!subject!!' => __( 'The subject of the email.', 'paid-memberships-pro' ),
+ '!!header_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
+ '!!name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
+ '!!display_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
+ '!!user_login!!' => __( 'The login name of the email recipient.', 'paid-memberships-pro' ),
+ '!!membership_id!!' => __( 'The ID of the membership level.', 'paid-memberships-pro' ),
+ '!!membership_level_name!!' => __( 'The name of the membership level.', 'paid-memberships-pro' ),
+ '!!confirmation_message!!' => __( 'The confirmation message for the membership level.', 'paid-memberships-pro' ),
+ '!!membership_cost!!' => __( 'The cost of the membership level.', 'paid-memberships-pro' ),
+ '!!user_email!!' => __( 'The email address of the email recipient.', 'paid-memberships-pro' ),
+ '!!membership_expiration!!' => __( 'The expiration date of the membership level.', 'paid-memberships-pro' ),
+ '!!discount_code!!' => __( 'The discount code used for the membership level.', 'paid-memberships-pro' ),
+ '!!order_id!!' => __( 'The ID of the order.', 'paid-memberships-pro' ),
+ '!!order_date!!' => __( 'The date of the order.', 'paid-memberships-pro' ),
+ '!!order_total!!' => __( 'The total cost of the order.', 'paid-memberships-pro' ),
+ );
+ }
+
+ /**
+ * Get the email template variables for the email.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public function get_email_template_variables() {
+ $order = $this->order;
+ $user = $this->user;
+ $membership_level = pmpro_getLevel( $order->membership_id );
+
+ $confirmation_in_email = get_pmpro_membership_level_meta( $membership_level->id, 'confirmation_in_email', true );
+ if ( ! empty( $confirmation_in_email ) ) {
+ $confirmation_message = $membership_level->confirmation;
+ } else {
+ $confirmation_message = '';
+ }
+
+ $email_template_variables = array(
+ 'subject' => $this->get_default_subject(),
+ 'header_name' => $this->get_recipient_name(),
+ 'name' => $this->get_recipient_name(),
+ 'display_name' => $this->get_recipient_name(),
+ 'user_login' => $user->user_login,
+ 'membership_id' => $membership_level->id,
+ 'membership_level_name' => $membership_level->name,
+ 'confirmation_message' => $confirmation_message,
+ 'membership_cost' => pmpro_getLevelCost($membership_level),
+ 'user_email' => $user->user_email,
+ 'order_id' => $order->code,
+ 'order_total' => $order->get_formatted_total(),
+ 'order_date' => date_i18n( get_option( 'date_format' ), $order->getTimestamp() ),
+ );
+
+ return $email_template_variables;
+ }
+
+}
+
+/**
+ * Register the email template.
+ *
+ * @since TBD
+ *
+ * @param array $email_templates The email templates (template slug => email template class name)
+ * @return array The modified email templates array.
+ */
+function pmpro_email_templates_checkout_check( $email_templates ) {
+ $email_templates['checkout_check'] = 'PMPro_Email_Template_Checkout_Check';
+
+ return $email_templates;
+}
+add_filter( 'pmpro_email_templates', 'pmpro_email_templates_checkout_check' );
\ No newline at end of file
diff --git a/classes/email-templates/class-pmpro-email-template-checkout-free-admin.php b/classes/email-templates/class-pmpro-email-template-checkout-free-admin.php
new file mode 100644
index 000000000..f4f310472
--- /dev/null
+++ b/classes/email-templates/class-pmpro-email-template-checkout-free-admin.php
@@ -0,0 +1,211 @@
+user = $user;
+ $this->order = $order;
+ }
+
+ /**
+ * Get the email template slug.
+ *
+ * @since TBD
+ *
+ * @return string The email template slug.
+ */
+ public static function get_template_slug() {
+ return 'checkout_free_admin';
+ }
+
+ /**
+ * Get the "nice name" of the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "nice name" of the email template.
+ */
+ public static function get_template_name() {
+ return __( 'Checkout - Free (admin)', 'paid-memberships-pro' );
+ }
+
+
+ /**
+ * Get "help text" to display to the admin when editing the email template.
+ *
+ * @since TBD
+ *
+ * @return string The help text.
+ */
+ public static function get_template_description() {
+ return __( 'This is the membership confirmation email sent to the site administrator for every membership checkout that has no charge.', 'paid-memberships-pro' );
+
+ }
+
+ /**
+ * Get the email subject.
+ *
+ * @since TBD
+ *
+ * @return string The email subject.
+ */
+ public static function get_default_subject() {
+ return __( "Member checkout for !!membership_level_name!! at !!sitename!!", 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the email body.
+ *
+ * @since TBD
+ *
+ * @return string The email body.
+ */
+ public static function get_default_body() {
+ return __( 'There was a new member checkout at !!sitename!!.
+ Below are details about the new membership account.
+
+ Account: !!display_name!! (!!user_email!!)
+ Membership Level: !!membership_level_name!!
+ !!membership_expiration!! !!discount_code!!
+
+ Log in to your membership account here: !!login_url!!
', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the email address to send the email to.
+ *
+ * @since TBD
+ *
+ * @return string The email address to send the email to.
+ */
+ public function get_recipient_email() {
+ return get_bloginfo( 'admin_email' );
+ }
+
+ /**
+ * Get the name of the email recipient.
+ *
+ * @since TBD
+ *
+ * @return string The name of the email recipient.
+ */
+ public function get_recipient_name() {
+ //get user by email
+ $user = get_user_by( 'email', $this->get_recipient_email() );
+ return $user->display_name;
+ }
+
+
+ /**
+ * Get the email template variables for the email paired with a description of the variable.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public static function get_email_template_variables_with_description() {
+
+ return array(
+ '!!subject!!' => __( 'The subject of the email.', 'paid-memberships-pro' ),
+ '!!header_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
+ '!!name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
+ '!!display_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
+ '!!user_login!!' => __( 'The login name of the email recipient.', 'paid-memberships-pro' ),
+ '!!membership_id!!' => __( 'The ID of the membership level.', 'paid-memberships-pro' ),
+ '!!membership_level_name!!' => __( 'The name of the membership level.', 'paid-memberships-pro' ),
+ '!!confirmation_message!!' => __( 'The confirmation message for the membership level.', 'paid-memberships-pro' ),
+ '!!membership_cost!!' => __( 'The cost of the membership level.', 'paid-memberships-pro' ),
+ '!!user_email!!' => __( 'The email address of the email recipient.', 'paid-memberships-pro' ),
+ '!!membership_expiration!!' => __( 'The expiration date of the membership level.', 'paid-memberships-pro' ),
+ '!!discount_code!!' => __( 'The discount code used for the membership level.', 'paid-memberships-pro' ),
+ );
+ }
+
+ /**
+ * Get the email template variables for the email.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public function get_email_template_variables() {
+ global $wpdb;
+ $order = $this->order;
+ $user = $this->user;
+ $membership_level = pmpro_getLevel( $order->membership_id );
+
+ $confirmation_message = '';
+ $confirmation_in_email = get_pmpro_membership_level_meta( $membership_level->id, 'confirmation_in_email', true );
+ if ( ! empty( $confirmation_in_email ) ) {
+ $confirmation_message = $membership_level->confirmation;
+ }
+
+ $membership_expiration = '';
+ $enddate = $wpdb->get_var("SELECT UNIX_TIMESTAMP(CONVERT_TZ(enddate, '+00:00', @@global.time_zone)) FROM $wpdb->pmpro_memberships_users WHERE user_id = '" . $user->ID . "' AND status = 'active' LIMIT 1");
+ if( $enddate ) {
+ $membership_expiration = "" . sprintf(__("This membership will expire on %s.", 'paid-memberships-pro' ), date_i18n(get_option('date_format'), $enddate)) . "
\n";
+ }
+
+ $discount_code = '';
+ if( $order->getDiscountCode() ) {
+ $discount_code = "" . __("Discount Code", 'paid-memberships-pro' ) . ": " . $order->discount_code->code . "
\n";
+ }
+
+
+ $email_template_variables = array(
+ 'subject' => $this->get_default_subject(),
+ 'header_name' => $this->get_recipient_name(),
+ 'name' => $this->get_recipient_name(),
+ 'display_name' => $this->get_recipient_name(),
+ 'user_login' => $user->user_login,
+ 'membership_id' => $membership_level->id,
+ 'membership_level_name' => $membership_level->name,
+ 'membership_level_confirmation_message' => $confirmation_message,
+ 'membership_cost' => pmpro_getLevelCost( $membership_level ),
+ 'user_email' => $user->user_email,
+ 'membership_expiration' => $membership_expiration,
+ 'discount_code' => $discount_code,
+ );
+
+ return $email_template_variables;
+ }
+
+}
+
+
+/**
+ * Register the email template.
+ *
+ * @since TBD
+ *
+ * @param array $email_templates The email templates (template slug => email template class name)
+ * @return array The modified email templates array.
+ */
+function pmpro_email_templates_checkout_free_admin( $email_templates ) {
+ $email_templates['checkout_free_admin'] = 'PMPro_Email_Template_Checkout_Free_Admin';
+
+ return $email_templates;
+}
+add_filter( 'pmpro_email_templates', 'pmpro_email_templates_checkout_free_admin' );
\ No newline at end of file
diff --git a/classes/email-templates/class-pmpro-email-template-checkout-free.php b/classes/email-templates/class-pmpro-email-template-checkout-free.php
new file mode 100644
index 000000000..530f63c51
--- /dev/null
+++ b/classes/email-templates/class-pmpro-email-template-checkout-free.php
@@ -0,0 +1,204 @@
+user = $user;
+ $this->order = $order;
+ }
+
+ /**
+ * Get the email template slug.
+ *
+ * @since TBD
+ *
+ * @return string The email template slug.
+ */
+ public static function get_template_slug() {
+ return 'checkout_free';
+ }
+
+ /**
+ * Get the "nice name" of the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "nice name" of the email template.
+ */
+ public static function get_template_name() {
+ return __( 'Checkout - Free', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get "help text" to display to the admin when editing the email template.
+ *
+ * @since TBD
+ *
+ * @return string The help text.
+ */
+ public static function get_template_description() {
+ return __( 'This is a membership confirmation welcome email sent to a new member or to existing members that change their level when the level has no charge.', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the email subject.
+ *
+ * @since TBD
+ *
+ * @return string The email subject.
+ */
+ public static function get_default_subject() {
+ return sprintf( __( 'Your membership confirmation for %s', 'paid-memberships-pro' ), get_option( 'blogname' ) );
+ }
+
+ /**
+ * Get the email body.
+ *
+ * @since TBD
+ *
+ * @return string The email body.
+ */
+ public static function get_default_body() {
+ return __( 'Thank you for your membership to !!sitename!!. Your membership account is now active.
+ !!membership_level_confirmation_message!!
+ Below are details about your membership account.
+
+ Account: !!display_name!! (!!user_email!!)
+ Membership Level: !!membership_level_name!!
+ !!membership_expiration!! !!discount_code!!', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the email address to send the email to.
+ *
+ * @since TBD
+ *
+ * @return string The email address to send the email to.
+ */
+ public function get_recipient_email() {
+ return $this->user->user_email;
+ }
+
+ /**
+ * Get the name of the email recipient.
+ *
+ * @since TBD
+ *
+ * @return string The name of the email recipient.
+ */
+ public function get_recipient_name() {
+ return $this->user->display_name;
+ }
+
+ /**
+ * Get the email template variables for the email paired with a description of the variable.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public static function get_email_template_variables_with_description() {
+
+ return array(
+ '!!subject!!' => __( 'The subject of the email.', 'paid-memberships-pro' ),
+ '!!header_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
+ '!!name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
+ '!!display_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
+ '!!user_login!!' => __( 'The login name of the email recipient.', 'paid-memberships-pro' ),
+ '!!membership_id!!' => __( 'The ID of the membership level.', 'paid-memberships-pro' ),
+ '!!membership_level_name!!' => __( 'The name of the membership level.', 'paid-memberships-pro' ),
+ '!!confirmation_message!!' => __( 'The confirmation message for the membership level.', 'paid-memberships-pro' ),
+ '!!membership_cost!!' => __( 'The cost of the membership level.', 'paid-memberships-pro' ),
+ '!!user_email!!' => __( 'The email address of the email recipient.', 'paid-memberships-pro' ),
+ '!!membership_expiration!!' => __( 'The expiration date of the membership level.', 'paid-memberships-pro' ),
+ '!!discount_code!!' => __( 'The discount code used for the membership level.', 'paid-memberships-pro' ),
+ );
+ }
+
+ /**
+ * Get the email template variables for the email.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public function get_email_template_variables() {
+ global $wpdb;
+ $order = $this->order;
+ $user = $this->user;
+ $membership_level = pmpro_getLevel( $order->membership_id );
+
+ $confirmation_message = '';
+ $confirmation_in_email = get_pmpro_membership_level_meta( $membership_level->id, 'confirmation_in_email', true );
+ if ( ! empty( $confirmation_in_email ) ) {
+ $confirmation_message = $membership_level->confirmation;
+ }
+
+ $membership_expiration = '';
+ $enddate = $wpdb->get_var("SELECT UNIX_TIMESTAMP(CONVERT_TZ(enddate, '+00:00', @@global.time_zone)) FROM $wpdb->pmpro_memberships_users WHERE user_id = '" . $user->ID . "' AND status = 'active' LIMIT 1");
+ if( $enddate ) {
+ $membership_expiration = "" . sprintf(__("This membership will expire on %s.", 'paid-memberships-pro' ), date_i18n(get_option('date_format'), $enddate)) . "
\n";
+ }
+
+ $discount_code = '';
+ if( $order->getDiscountCode() ) {
+ $discount_code = "" . __("Discount Code", 'paid-memberships-pro' ) . ": " . $order->discount_code->code . "
\n";
+ }
+
+
+ $email_template_variables = array(
+ 'subject' => $this->get_default_subject(),
+ 'header_name' => $this->get_recipient_name(),
+ 'name' => $this->get_recipient_name(),
+ 'display_name' => $this->get_recipient_name(),
+ 'user_login' => $user->user_login,
+ 'membership_id' => $membership_level->id,
+ 'membership_level_name' => $membership_level->name,
+ 'membership_level_confirmation_message' => $confirmation_message,
+ 'membership_cost' => pmpro_getLevelCost( $membership_level ),
+ 'user_email' => $user->user_email,
+ 'membership_expiration' => $membership_expiration,
+ 'discount_code' => $discount_code,
+ );
+
+ return $email_template_variables;
+ }
+
+}
+
+/**
+ * Register the email template.
+ *
+ * @since TBD
+ *
+ * @param array $email_templates The email templates (template slug => email template class name)
+ * @return array The modified email templates array.
+ */
+function pmpro_email_templates_checkout_free( $email_templates ) {
+ $email_templates['checkout_free'] = 'PMPro_Email_Template_Checkout_Free';
+
+ return $email_templates;
+}
+add_filter( 'pmpro_email_templates', 'pmpro_email_templates_checkout_free' );
\ No newline at end of file
diff --git a/classes/email-templates/class-pmpro-email-template-checkout-paid-admin.php b/classes/email-templates/class-pmpro-email-template-checkout-paid-admin.php
new file mode 100644
index 000000000..b0d2676ce
--- /dev/null
+++ b/classes/email-templates/class-pmpro-email-template-checkout-paid-admin.php
@@ -0,0 +1,261 @@
+user = $user;
+ $this->order = $order;
+ }
+
+ /**
+ * Get the email template slug.
+ *
+ * @since TBD
+ *
+ * @return string The email template slug.
+ */
+ public static function get_template_slug() {
+ return 'checkout_paid_admin';
+ }
+
+ /**
+ * Get the "nice name" of the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "nice name" of the email template.
+ */
+ public static function get_template_name() {
+ return __( 'Checkout - Paid (admin)', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get "help text" to display to the admin when editing the email template.
+ *
+ * @since TBD
+ *
+ * @return string The help text.
+ */
+ public static function get_template_description() {
+ return __( 'This is the membership confirmation email sent to the site administrator for every paid membership checkout on the site.', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the email subject.
+ *
+ * @since TBD
+ *
+ * @return string The email subject.
+ */
+ public static function get_default_subject() {
+ return __( 'Member checkout for !!membership_level_name!! at !!sitename!!', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the email body.
+ *
+ * @since TBD
+ *
+ * @return string The email body.
+ */
+ public static function get_default_body() {
+ return __( 'There was a new member checkout at !!sitename!!.
+ Below are details about the new membership account and a receipt for the initial membership order.
+
+ Account: !!display_name!! (!!user_email!!)
+ Membership Level: !!membership_level_name!!
+ Membership Fee: !!membership_cost!!
+ !!membership_expiration!! !!discount_code!!
+
+
+ Order #!!order_id!! on !!order_date!!
+ Total Billed: !!order_total!!
+
+
+ Billing Information:
+ !!billing_address!!
+
+
+
+ !!cardtype!!: !!accountnumber!!
+ Expires: !!expirationmonth!!/!!expirationyear!!
+
+
+ Log in to your membership account here: !!login_url!!
', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the email address to send the email to.
+ *
+ * @since TBD
+ *
+ * @return string The email address to send the email to.
+ */
+ public function get_recipient_email() {
+ return get_bloginfo( 'admin_email' );
+ }
+
+ /**
+ * Get the name of the email recipient.
+ *
+ * @since TBD
+ *
+ * @return string The name of the email recipient.
+ */
+ public function get_recipient_name() {
+ //get user by email
+ $user = get_user_by( 'email', $this->get_recipient_email() );
+ return $user->display_name;
+ }
+
+ /**
+ * Get the email template variables for the email.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public function get_email_template_variables() {
+ global $wpdb;
+ $order = $this->order;
+ $user = $this->user;
+ $membership_level = pmpro_getLevel( $order->membership_id );
+
+ $confirmation_in_email = get_pmpro_membership_level_meta( $membership_level->id, 'confirmation_in_email', true );
+ if ( ! empty( $confirmation_in_email ) ) {
+ $confirmation_message = $membership_level->confirmation;
+ } else {
+ $confirmation_message = '';
+ }
+
+ $membership_expiration = '';
+ $enddate = $wpdb->get_var("SELECT UNIX_TIMESTAMP(CONVERT_TZ(enddate, '+00:00', @@global.time_zone)) FROM $wpdb->pmpro_memberships_users WHERE user_id = '" . $user->ID . "' AND status = 'active' LIMIT 1");
+ if( $enddate ) {
+ $membership_expiration = "" . sprintf(__("This membership will expire on %s.", 'paid-memberships-pro' ), date_i18n(get_option('date_format'), $enddate)) . "
\n";
+ }
+
+ $discount_code = '';
+ if( $order->getDiscountCode() ) {
+ $discount_code = "" . __("Discount Code", 'paid-memberships-pro' ) . ": " . $order->discount_code->code . "
\n";
+ }
+
+ $email_template_variables = array(
+ 'subject' => $this->get_default_subject(),
+ 'header_name' => $this->get_recipient_name(),
+ 'name' => $this->get_recipient_name(),
+ 'display_name' => $this->get_recipient_name(),
+ 'user_login' => $user->user_login,
+ 'membership_id' => $membership_level->id,
+ 'membership_level_name' => $membership_level->name,
+ 'membership_level_confirmation_message' => $confirmation_message,
+ 'membership_cost' => pmpro_getLevelCost($membership_level),
+ 'user_email' => $user->user_email,
+ 'order_id' => $order->code,
+ 'order_total' => $order->get_formatted_total(),
+ 'order_date' => date_i18n( get_option( 'date_format' ), $order->getTimestamp() ),
+ 'billing_address' => pmpro_formatAddress( $order->billing->name,
+ $order->billing->street,
+ $order->billing->street2,
+ $order->billing->city,
+ $order->billing->state,
+ $order->billing->zip,
+ $order->billing->country,
+ $order->billing->phone ),
+ 'billing_name' => $order->billing->name,
+ 'billing_street' => $order->billing->street,
+ 'billing_street2' => $order->billing->street2,
+ 'billing_city' => $order->billing->city,
+ 'billing_state' => $order->billing->state,
+ 'billing_zip' => $order->billing->zip,
+ 'billing_country' => $order->billing->country,
+ 'billing_phone' => $order->billing->phone,
+ 'cardtype' => $order->cardtype,
+ 'accountnumber' => hideCardNumber( $order->accountnumber ),
+ 'expirationmonth' => $order->expirationmonth,
+ 'expirationyear' => $order->expirationyear,
+ 'membership_expiration' => $membership_expiration,
+ 'discount_code' => $discount_code,
+
+
+ );
+
+ return $email_template_variables;
+ }
+
+ /**
+ * Get the email template variables for the email paired with a description of the variable.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public static function get_email_template_variables_with_description() {
+
+ return array(
+ '!!subject!!' => __( 'The subject of the email.', 'paid-memberships-pro' ),
+ '!!header_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
+ '!!name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
+ '!!display_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
+ '!!user_login!!' => __( 'The login name of the email recipient.', 'paid-memberships-pro' ),
+ '!!membership_id!!' => __( 'The ID of the membership level.', 'paid-memberships-pro' ),
+ '!!membership_level_name!!' => __( 'The name of the membership level.', 'paid-memberships-pro' ),
+ '!!confirmation_message!!' => __( 'The confirmation message for the membership level.', 'paid-memberships-pro' ),
+ '!!membership_cost!!' => __( 'The cost of the membership level.', 'paid-memberships-pro' ),
+ '!!user_email!!' => __( 'The email address of the email recipient.', 'paid-memberships-pro' ),
+ '!!membership_expiration!!' => __( 'The expiration date of the membership level.', 'paid-memberships-pro' ),
+ '!!discount_code!!' => __( 'The discount code used for the membership level.', 'paid-memberships-pro' ),
+ '!!order_id!!' => __( 'The ID of the order.', 'paid-memberships-pro' ),
+ '!!order_date!!' => __( 'The date of the order.', 'paid-memberships-pro' ),
+ '!!order_total!!' => __( 'The total cost of the order.', 'paid-memberships-pro' ),
+ '!!billing_name!!' => __( 'Billing Info Name', 'paid-memberships-pro' ),
+ '!!billing_street!!' => __( 'Billing Info Street', 'paid-memberships-pro' ),
+ '!!billing_street2!!' => __( 'Billing Info Street 2', 'paid-memberships-pro' ),
+ '!!billing_city!!' => __( 'Billing Info City', 'paid-memberships-pro' ),
+ '!!billing_state!!' => __( 'Billing Info State', 'paid-memberships-pro' ),
+ '!!billing_zip!!' => __( 'Billing Info Zip', 'paid-memberships-pro' ),
+ '!!billing_country!!' => __( 'Billing Info Country', 'paid-memberships-pro' ),
+ '!!billing_phone!!' => __( 'Billing Info Phone', 'paid-memberships-pro' ),
+ '!!billing_address!!' => __( 'Billing Info Complete Address', 'paid-memberships-pro' ),
+ '!!cardtype!!' => __( 'Credit Card Type', 'paid-memberships-pro' ),
+ '!!accountnumber!!' => __( 'Credit Card Number (last 4 digits)', 'paid-memberships-pro' ),
+ '!!expirationmonth!!' => __( 'Credit Card Expiration Month (mm format)', 'paid-memberships-pro' ),
+ '!!expirationyear!!' => __( 'Credit Card Expiration Year (yyyy format)', 'paid-memberships-pro' ),
+ );
+ }
+}
+
+/**
+ * Register the email template.
+ *
+ * @since TBD
+ *
+ * @param array $email_templates The email templates (template slug => email template class name)
+ * @return array The modified email templates array.
+ */
+function pmpro_email_templates_checkout_paid_admin( $email_templates ) {
+ $email_templates['checkout_paid_admin'] = 'PMPro_Email_Template_Checkout_Paid_Admin';
+
+ return $email_templates;
+}
+add_filter( 'pmpro_email_templates', 'pmpro_email_templates_checkout_paid_admin' );
\ No newline at end of file
diff --git a/classes/email-templates/class-pmpro-email-template-checkout-paid.php b/classes/email-templates/class-pmpro-email-template-checkout-paid.php
new file mode 100644
index 000000000..d25d39c7f
--- /dev/null
+++ b/classes/email-templates/class-pmpro-email-template-checkout-paid.php
@@ -0,0 +1,265 @@
+user = $user;
+ $this->order = $order;
+ }
+
+ /**
+ * Get the email template slug.
+ *
+ * @since TBD
+ *
+ * @return string The email template slug.
+ */
+ public static function get_template_slug() {
+ return 'checkout_paid';
+ }
+
+ /**
+ * Get the "nice name" of the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "nice name" of the email template.
+ */
+ public static function get_template_name() {
+ return __( 'Checkout - Paid', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get "help text" to display to the admin when editing the email template.
+ *
+ * @since TBD
+ *
+ * @return string The help text.
+ */
+ public static function get_template_description() {
+ return __( 'This is a membership confirmation welcome email sent to a new member or to existing members that change their level and complete a paid checkout on the site.', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the email subject.
+ *
+ * @since TBD
+ *
+ * @return string The email subject.
+ */
+ public static function get_default_subject() {
+ return __( "Your membership confirmation for !!sitename!!", 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the email body.
+ *
+ * @since TBD
+ *
+ * @return string The email body.
+ */
+ public static function get_default_body() {
+ return __( 'Thank you for your membership to !!sitename!!. Your membership account is now active.
+ !!membership_level_confirmation_message!!
+ Below are details about your membership account and a receipt for your initial membership order.
+
+ Account: !!display_name!! (!!user_email!!)
+ Membership Level: !!membership_level_name!!
+ Membership Fee: !!membership_cost!!
+ !!membership_expiration!! !!discount_code!!
+
+
+ Order #!!order_id!! on !!order_date!!
+ Total Billed: !!order_total!!
+
+
+ Billing Information:
+ !!billing_address!!
+
+
+
+ !!cardtype!!: !!accountnumber!!
+ Expires: !!expirationmonth!!/!!expirationyear!!
+
+
+ Log in to your membership account here: !!login_url!!
', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the email address to send the email to.
+ *
+ * @since TBD
+ *
+ * @return string The email address to send the email to.
+ */
+ public function get_recipient_email() {
+ return $this->user->user_email;
+ }
+
+ /**
+ * Get the name of the email recipient.
+ *
+ * @since TBD
+ *
+ * @return string The name of the email recipient.
+ */
+ public function get_recipient_name() {
+ return $this->user->display_name;
+ }
+
+ /**
+ * Get the email template variables for the email.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public function get_email_template_variables() {
+ global $wpdb;
+ $order = $this->order;
+ $user = $this->user;
+ $membership_level = pmpro_getLevel( $order->membership_id );
+
+ $confirmation_in_email = get_pmpro_membership_level_meta( $membership_level->id, 'confirmation_in_email', true );
+ if ( ! empty( $confirmation_in_email ) ) {
+ $confirmation_message = $membership_level->confirmation;
+ } else {
+ $confirmation_message = '';
+ }
+
+ $membership_expiration = '';
+ $enddate = $wpdb->get_var("SELECT UNIX_TIMESTAMP(CONVERT_TZ(enddate, '+00:00', @@global.time_zone)) FROM $wpdb->pmpro_memberships_users WHERE user_id = '" . $user->ID . "' AND status = 'active' LIMIT 1");
+ if( $enddate ) {
+ $membership_expiration = "" . sprintf(__("This membership will expire on %s.", 'paid-memberships-pro' ), date_i18n(get_option('date_format'), $enddate)) . "
\n";
+ }
+
+ $discount_code = '';
+ if( $order->getDiscountCode() ) {
+ $discount_code = "" . __("Discount Code", 'paid-memberships-pro' ) . ": " . $order->discount_code->code . "
\n";
+ }
+
+ $email_template_variables = array(
+ 'subject' => $this->get_default_subject(),
+ 'header_name' => $this->get_recipient_name(),
+ 'name' => $this->get_recipient_name(),
+ 'display_name' => $this->get_recipient_name(),
+ 'user_login' => $user->user_login,
+ 'membership_id' => $membership_level->id,
+ 'membership_level_name' => $membership_level->name,
+ 'membership_level_confirmation_message' => $confirmation_message,
+ 'membership_cost' => pmpro_getLevelCost($membership_level),
+ 'user_email' => $user->user_email,
+ 'order_id' => $order->code,
+ 'order_total' => $order->get_formatted_total(),
+ 'order_date' => date_i18n( get_option( 'date_format' ), $order->getTimestamp() ),
+ 'billing_address' => pmpro_formatAddress( $order->billing->name,
+ $order->billing->street,
+ $order->billing->street2,
+ $order->billing->city,
+ $order->billing->state,
+ $order->billing->zip,
+ $order->billing->country,
+ $order->billing->phone ),
+ 'billing_name' => $order->billing->name,
+ 'billing_street' => $order->billing->street,
+ 'billing_street2' => $order->billing->street2,
+ 'billing_city' => $order->billing->city,
+ 'billing_state' => $order->billing->state,
+ 'billing_zip' => $order->billing->zip,
+ 'billing_country' => $order->billing->country,
+ 'billing_phone' => $order->billing->phone,
+ 'cardtype' => $order->cardtype,
+ 'accountnumber' => hideCardNumber( $order->accountnumber ),
+ 'expirationmonth' => $order->expirationmonth,
+ 'expirationyear' => $order->expirationyear,
+ 'membership_expiration' => $membership_expiration,
+ 'discount_code' => $discount_code,
+
+
+ );
+
+ return $email_template_variables;
+ }
+
+ /**
+ * Get the email template variables for the email paired with a description of the variable.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public static function get_email_template_variables_with_description() {
+
+ return array(
+ '!!subject!!' => __( 'The subject of the email.', 'paid-memberships-pro' ),
+ '!!header_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
+ '!!name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
+ '!!display_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
+ '!!user_login!!' => __( 'The login name of the email recipient.', 'paid-memberships-pro' ),
+ '!!membership_id!!' => __( 'The ID of the membership level.', 'paid-memberships-pro' ),
+ '!!membership_level_name!!' => __( 'The name of the membership level.', 'paid-memberships-pro' ),
+ '!!confirmation_message!!' => __( 'The confirmation message for the membership level.', 'paid-memberships-pro' ),
+ '!!membership_cost!!' => __( 'The cost of the membership level.', 'paid-memberships-pro' ),
+ '!!user_email!!' => __( 'The email address of the email recipient.', 'paid-memberships-pro' ),
+ '!!membership_expiration!!' => __( 'The expiration date of the membership level.', 'paid-memberships-pro' ),
+ '!!discount_code!!' => __( 'The discount code used for the membership level.', 'paid-memberships-pro' ),
+ '!!order_id!!' => __( 'The ID of the order.', 'paid-memberships-pro' ),
+ '!!order_date!!' => __( 'The date of the order.', 'paid-memberships-pro' ),
+ '!!order_total!!' => __( 'The total cost of the order.', 'paid-memberships-pro' ),
+ '!!billing_name!!' => __( 'Billing Info Name', 'paid-memberships-pro' ),
+ '!!billing_street!!' => __( 'Billing Info Street', 'paid-memberships-pro' ),
+ '!!billing_street2!!' => __( 'Billing Info Street 2', 'paid-memberships-pro' ),
+ '!!billing_city!!' => __( 'Billing Info City', 'paid-memberships-pro' ),
+ '!!billing_state!!' => __( 'Billing Info State', 'paid-memberships-pro' ),
+ '!!billing_zip!!' => __( 'Billing Info Zip', 'paid-memberships-pro' ),
+ '!!billing_country!!' => __( 'Billing Info Country', 'paid-memberships-pro' ),
+ '!!billing_phone!!' => __( 'Billing Info Phone', 'paid-memberships-pro' ),
+ '!!billing_address!!' => __( 'Billing Info Complete Address', 'paid-memberships-pro' ),
+ '!!cardtype!!' => __( 'Credit Card Type', 'paid-memberships-pro' ),
+ '!!accountnumber!!' => __( 'Credit Card Number (last 4 digits)', 'paid-memberships-pro' ),
+ '!!expirationmonth!!' => __( 'Credit Card Expiration Month (mm format)', 'paid-memberships-pro' ),
+ '!!expirationyear!!' => __( 'Credit Card Expiration Year (yyyy format)', 'paid-memberships-pro' ),
+ );
+ }
+}
+
+/**
+ * Register the email template.
+ *
+ * @since TBD
+ *
+ * @param array $email_templates The email templates (template slug => email template class name)
+ * @return array The modified email templates array.
+ */
+function pmpro_email_templates_checkout_paid( $email_templates ) {
+ $email_templates['checkout_paid'] = 'PMPro_Email_Template_Checkout_Paid';
+
+ return $email_templates;
+}
+add_filter( 'pmpro_email_templates', 'pmpro_email_templates_checkout_paid' );
\ No newline at end of file
diff --git a/includes/email-templates.php b/includes/email-templates.php
index e0d2734a2..076c24323 100644
--- a/includes/email-templates.php
+++ b/includes/email-templates.php
@@ -101,137 +101,6 @@
Expiration Date: !!enddate!!
', 'paid-memberships-pro' ),
'help_text' => __( 'When a user cancels a membership with a recurring subscription, they will still have access until when their next payment would have been taken. This email is sent to the site administrator to notify them of this change.', 'paid-memberships-pro' )
),
- 'checkout_check' => array(
- 'subject' => __( "Your membership confirmation for !!sitename!!", 'paid-memberships-pro' ),
- 'description' => sprintf( __('Checkout - %s', 'paid-memberships-pro' ), $check_gateway_label ),
- 'body' => __( 'Thank you for your membership to !!sitename!!. Your membership account is now active.
-
-!!membership_level_confirmation_message!!
-
-!!instructions!!
-
-Below are details about your membership account and a receipt for your initial membership order.
-
-Account: !!display_name!! (!!user_email!!)
-Membership Level: !!membership_level_name!!
-Membership Fee: !!membership_cost!!
-!!membership_expiration!! !!discount_code!!
-
-
- Order #!!order_id!! on !!order_date!!
- Total Billed: !!order_total!!
-
-
-Log in to your membership account here: !!login_url!!
', 'paid-memberships-pro' ),
- 'help_text' => sprintf( __('This is a membership confirmation welcome email sent to a new member or to existing members that change their level using the "%s (Pay by Check)" gateway.','paid-memberships-pro' ), $check_gateway_label )
-
- ),
- 'checkout_check_admin' => array(
- 'subject' => __( "Member checkout for !!membership_level_name!! at !!sitename!!", 'paid-memberships-pro' ),
- 'description' => sprintf( __('Checkout - %s (admin)', 'paid-memberships-pro') , $check_gateway_label ),
- 'body' => sprintf (__( 'There was a new member checkout at !!sitename!!.
-
-They have chosen to pay by %s.
-
-Below are details about the new membership account and a receipt for the initial membership order.
-
-Account: !!display_name!! (!!user_email!!)
-Membership Level: !!membership_level_name!!
-Membership Fee: !!membership_cost!!
-!!membership_expiration!! !!discount_code!!
-
-
- Order #!!order_id!! on !!order_date!!
- Total Billed: !!order_total!!
-
-
-Log in to your membership account here: !!login_url!!
','paid-memberships-pro' ), $check_gateway_label ),
- 'help_text' => sprintf( __('This is the membership confirmation email sent to the site administrator for every membership checkout using the "%s (Pay by Check)" gateway.', 'paid-memberships-pro' ), $check_gateway_label )
- ),
- 'checkout_free' => array(
- 'subject' => __( "Your membership confirmation for !!sitename!!", 'paid-memberships-pro' ),
- 'description' => __('Checkout - Free', 'paid-memberships-pro'),
- 'body' => __( 'Thank you for your membership to !!sitename!!. Your membership account is now active.
-!!membership_level_confirmation_message!!
-Below are details about your membership account.
-
-Account: !!display_name!! (!!user_email!!)
-Membership Level: !!membership_level_name!!
-!!membership_expiration!! !!discount_code!!
-
-Log in to your membership account here: !!login_url!!
', 'paid-memberships-pro' ),
- 'help_text' => __( 'This is a membership confirmation welcome email sent to a new member or to existing members that change their level when the level has no charge.', 'paid-memberships-pro' )
- ),
- 'checkout_free_admin' => array(
- 'subject' => __( "Member checkout for !!membership_level_name!! at !!sitename!!", 'paid-memberships-pro' ),
- 'description' => __('Checkout - Free (admin)', 'paid-memberships-pro'),
- 'body' => __( 'There was a new member checkout at !!sitename!!.
-Below are details about the new membership account.
-
-Account: !!display_name!! (!!user_email!!)
-Membership Level: !!membership_level_name!!
-!!membership_expiration!! !!discount_code!!
-
-Log in to your membership account here: !!login_url!!
', 'paid-memberships-pro' ),
- 'help_text' => __( 'This is the membership confirmation email sent to the site administrator for every membership checkout that has no charge.', 'paid-memberships-pro' )
- ),
- 'checkout_paid' => array(
- 'subject' => __( "Your membership confirmation for !!sitename!!", 'paid-memberships-pro' ),
- 'description' => __('Checkout - Paid', 'paid-memberships-pro'),
- 'body' => __( 'Thank you for your membership to !!sitename!!. Your membership account is now active.
-!!membership_level_confirmation_message!!
-Below are details about your membership account and a receipt for your initial membership order.
-
-Account: !!display_name!! (!!user_email!!)
-Membership Level: !!membership_level_name!!
-Membership Fee: !!membership_cost!!
-!!membership_expiration!! !!discount_code!!
-
-
- Order #!!order_id!! on !!order_date!!
- Total Billed: !!order_total!!
-
-
- Billing Information:
- !!billing_address!!
-
-
-
- !!cardtype!!: !!accountnumber!!
- Expires: !!expirationmonth!!/!!expirationyear!!
-
-
-Log in to your membership account here: !!login_url!!
', 'paid-memberships-pro' ),
- 'help_text' => __( 'This is a membership confirmation welcome email sent to a new member or to existing members that change their level and complete a paid checkout on the site.', 'paid-memberships-pro' )
- ),
- 'checkout_paid_admin' => array(
- 'subject' => __( "Member checkout for !!membership_level_name!! at !!sitename!!", 'paid-memberships-pro' ),
- 'description' => __('Checkout - Paid (admin)', 'paid-memberships-pro'),
- 'body' => __( 'There was a new member checkout at !!sitename!!.
-Below are details about the new membership account and a receipt for the initial membership order.
-
-Account: !!display_name!! (!!user_email!!)
-Membership Level: !!membership_level_name!!
-Membership Fee: !!membership_cost!!
-!!membership_expiration!! !!discount_code!!
-
-
- Order #!!order_id!! on !!order_date!!
- Total Billed: !!order_total!!
-
-
- Billing Information:
- !!billing_address!!
-
-
-
- !!cardtype!!: !!accountnumber!!
- Expires: !!expirationmonth!!/!!expirationyear!!
-
-
-Log in to your membership account here: !!login_url!!
', 'paid-memberships-pro' ),
- 'help_text' => __( 'This is the membership confirmation email sent to the site administrator for every paid membership checkout on the site.', 'paid-memberships-pro' )
- ),
'credit_card_expiring' => array(
'subject' => __( "Credit card on file expiring soon at !!sitename!!", 'paid-memberships-pro' ),
'description' => __('Credit Card Expiring', 'paid-memberships-pro'),
diff --git a/paid-memberships-pro.php b/paid-memberships-pro.php
index fc919808d..ef483bf00 100644
--- a/paid-memberships-pro.php
+++ b/paid-memberships-pro.php
@@ -55,6 +55,14 @@
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-cancel-admin.php' ); // cancel email template
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-admin-change.php' ); // change email template
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-admin-change-admin.php' ); // change email template
+require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-admin-checkout-check.php' );
+require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-admin-checkout-check-admin.php' );
+require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-checkout-free.php' );
+require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-checkout-free-admin.php' );
+require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-checkout-paid.php' );
+require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-checkout-paid-admin.php' );
+
+
require_once( PMPRO_DIR . '/includes/filters.php' ); // filters, hacks, etc, moved into the plugin
require_once( PMPRO_DIR . '/includes/reports.php' ); // load reports for admin (reports may also include tracking code, etc)
From f0a511ccb9e8d28759853b5d8b148e4d4435dfbb Mon Sep 17 00:00:00 2001
From: maximilianoRicoTabo
Date: Mon, 2 Dec 2024 17:43:43 -0300
Subject: [PATCH 14/41] * Add credit card expiring email class
---
classes/class.pmproemail.php | 47 +---
...ro-email-template-credit-card-expiring.php | 211 ++++++++++++++++++
includes/email-templates.php | 18 --
includes/email.php | 4 +
paid-memberships-pro.php | 1 +
5 files changed, 218 insertions(+), 63 deletions(-)
create mode 100644 classes/email-templates/class-pmpro-email-template-credit-card-expiring.php
diff --git a/classes/class.pmproemail.php b/classes/class.pmproemail.php
index 8816f189c..6dc507842 100644
--- a/classes/class.pmproemail.php
+++ b/classes/class.pmproemail.php
@@ -1081,51 +1081,8 @@ function sendCreditCardExpiringEmail($user = NULL, $order = NULL) {
return false;
}
- $membership_level = pmpro_getSpecificMembershipLevelForUser($user->ID, $order->membership_id);
-
- $this->email = $user->user_email;
- $this->subject = sprintf(__("Credit card on file expiring soon at %s", "paid-memberships-pro"), get_option("blogname"));
-
- $this->data = array(
- 'subject' => $this->subject,
- 'header_name' => $user->display_name,
- 'name' => $user->display_name,
- 'user_login' => $user->user_login,
- 'sitename' => get_option( 'blogname' ),
- 'siteemail' => get_option( 'pmpro_from_email' ),
- 'membership_id' => $membership_level->id,
- 'membership_level_name' => $membership_level->name,
- 'display_name' => $user->display_name,
- 'user_email' => $user->user_email,
- 'billing_name' => $order->billing->name,
- 'billing_street' => $order->billing->street,
- 'billing_street2' => $order->billing->street2,
- 'billing_city' => $order->billing->city,
- 'billing_state' => $order->billing->state,
- 'billing_zip' => $order->billing->zip,
- 'billing_country' => $order->billing->country,
- 'billing_phone' => $order->billing->phone,
- 'cardtype' => $order->cardtype,
- 'accountnumber' => hideCardNumber($order->accountnumber),
- 'expirationmonth' => $order->expirationmonth,
- 'expirationyear' => $order->expirationyear,
- 'login_link' => pmpro_login_url( pmpro_url( 'billing' ) ),
- 'login_url' => pmpro_login_url( pmpro_url( 'billing' ) ),
- 'levels_url' => pmpro_url( 'levels' )
-
- );
- $this->data["billing_address"] = pmpro_formatAddress($order->billing->name,
- $order->billing->street,
- $order->billing->street2,
- $order->billing->city,
- $order->billing->state,
- $order->billing->zip,
- $order->billing->country,
- $order->billing->phone);
-
- $this->template = apply_filters("pmpro_email_template", "credit_card_expiring", $this);
-
- return $this->sendEmail();
+ $email = new PMPro_Email_Template_Credit_Card_Expiring( $user, $order );
+ return $email->send();
}
/**
diff --git a/classes/email-templates/class-pmpro-email-template-credit-card-expiring.php b/classes/email-templates/class-pmpro-email-template-credit-card-expiring.php
new file mode 100644
index 000000000..a9727c979
--- /dev/null
+++ b/classes/email-templates/class-pmpro-email-template-credit-card-expiring.php
@@ -0,0 +1,211 @@
+user = $user;
+ $this->order = $order;
+ }
+
+ /**
+ * Get the email template slug.
+ *
+ * @since TBD
+ *
+ * @return string The email template slug.
+ */
+ public static function get_template_slug() {
+ return 'credit_card_expiring';
+ }
+
+ /**
+ * Get the "nice name" of the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "nice name" of the email template.
+ */
+ public static function get_template_name() {
+ return __( 'Credit Card Expiring', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get "help text" to display to the admin when editing the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "help text" to display to the admin when editing the email template.
+ */
+ public static function get_template_description() {
+ return __( 'This is the membership confirmation email sent to the site administrator for every paid membership checkout on the site.', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the default subject for the email.
+ *
+ * @since TBD
+ *
+ * @return string The default subject for the email.
+ */
+ public static function get_default_subject() {
+ return __( 'Credit card on file expiring soon at !!sitename!!', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the default body content for the email.
+ *
+ * @since TBD
+ *
+ * @return string The default body content for the email.
+ */
+ public static function get_default_body() {
+ return __( 'The payment method used for your membership at !!sitename!! will expire soon. Please click the following link to log in and update your billing information to avoid account suspension. !!login_url!!
+ Account: !!display_name!! (!!user_email!!)
+ The most recent account information we have on file is:
+
+ !!billing_name!!
+ !!billing_address!!
+
+
+
+ !!cardtype!!: !!accountnumber!!
+ Expires: !!expirationmonth!!/!!expirationyear!!
+
', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the email address to send the email to.
+ *
+ * @since TBD
+ *
+ * @return string The email address to send the email to.
+ */
+ public function get_recipient_email() {
+ return $this->user->user_email;
+ }
+
+ /**
+ * Get the name of the email recipient.
+ *
+ * @since TBD
+ *
+ * @return string The name of the email recipient.
+ */
+ public function get_recipient_name() {
+ return $this->user->display_name;
+ }
+
+ /**
+ * Get the email template variables for the email paired with a description of the variable.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public static function get_email_template_variables_with_description() {
+ return array(
+ '!!subject!!' => __( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
+ '!!header_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
+ '!!name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
+ '!!membership_id!!' => __( 'The ID of the membership level.', 'paid-memberships-pro' ),
+ '!!membership_level_name!!' => __( 'The name of the membership level.', 'paid-memberships-pro' ),
+ '!!user_login!!' => __( 'The username of the user.', 'paid-memberships-pro' ),
+ '!!user_email!!' => __( 'The email address of the user.', 'paid-memberships-pro' ),
+ '!!display_name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
+ '!!subject!!' => __( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
+ '!!billing_address!!' => __( 'Billing Info Complete Address', 'paid-memberships-pro' ),
+ '!!billing_name!!' => __( 'The billing name of the user.', 'paid-memberships-pro' ),
+ '!!billing_street!!' => __( 'The billing street address of the user.', 'paid-memberships-pro' ),
+ '!!billing_street2!!' => __( 'The second billing street field address of the user.', 'paid-memberships-pro' ),
+ '!!billing_city!!' => __( 'The billing city of the user.', 'paid-memberships-pro' ),
+ '!!billing_state!!' => __( 'The billing state of the user.', 'paid-memberships-pro' ),
+ '!!billing_zip!!' => __( 'The billing ZIP code of the user.', 'paid-memberships-pro' ),
+ '!!billing_country!!' => __( 'The billing country of the user.', 'paid-memberships-pro' ),
+ '!!billing_phone!!' => __( 'The billing phone number of the user.', 'paid-memberships-pro' ),
+ '!!cardtype!!' => __( 'The type of credit card used.', 'paid-memberships-pro' ),
+ '!!accountnumber!!' => __( 'The last four digits of the credit card number.', 'paid-memberships-pro' ),
+ '!!expirationmonth!!' => __( 'The expiration month of the credit card.', 'paid-memberships-pro' ),
+ '!!expirationyear!!' => __( 'The expiration year of the credit card.', 'paid-memberships-pro' ),
+ );
+ }
+
+ /**
+ * Get the email template variables for the email.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public function get_email_template_variables() {
+ $order = $this->order;
+ $membership_level = pmpro_getLevel( $order->membership_id );
+
+ return array(
+ 'subject' => $this->subject,
+ 'header_name' => $user->display_name,
+ 'name' => $user->display_name,
+ 'user_login' => $user->user_login,
+ 'sitename' => get_option( 'blogname' ),
+ 'siteemail' => get_option( 'pmpro_from_email' ),
+ 'membership_id' => $membership_level->id,
+ 'membership_level_name' => $membership_level->name,
+ 'display_name' => $user->display_name,
+ 'user_email' => $user->user_email,
+ 'billing_name' => $order->billing->name,
+ 'billing_street' => $order->billing->street,
+ 'billing_street2' => $order->billing->street2,
+ 'billing_city' => $order->billing->city,
+ 'billing_state' => $order->billing->state,
+ 'billing_zip' => $order->billing->zip,
+ 'billing_country' => $order->billing->country,
+ 'billing_phone' => $order->billing->phone,
+ 'billing_address'=> pmpro_formatAddress( $order->billing->name,
+ $order->billing->street,
+ $order->billing->street2,
+ $order->billing->city,
+ $order->billing->state,
+ $order->billing->zip,
+ $order->billing->country,
+ $order->billing->phone ),
+ 'cardtype' => $order->cardtype,
+ 'accountnumber' => hideCardNumber( $order->accountnumber ),
+ 'expirationmonth' => $order->expirationmonth,
+ 'expirationyear' => $order->expirationyear,
+ );
+ }
+}
+
+/**
+ * Register the email template.
+ *
+ * @since TBD
+ *
+ * @param array $email_templates The email templates (template slug => email template class name)
+ * @return array The modified email templates array.
+ */
+function pmpro_email_templates_credit_card_expiring( $email_templates ) {
+ $email_templates['credit_card_expiring'] = 'PMPro_Email_Template_Credit_Card_Expiring';
+ return $email_templates;
+}
+add_filter( 'pmpro_email_templates', 'pmpro_email_templates_credit_card_expiring' );
diff --git a/includes/email-templates.php b/includes/email-templates.php
index e0d2734a2..b7f64ab27 100644
--- a/includes/email-templates.php
+++ b/includes/email-templates.php
@@ -232,24 +232,6 @@
Log in to your membership account here: !!login_url!!
', 'paid-memberships-pro' ),
'help_text' => __( 'This is the membership confirmation email sent to the site administrator for every paid membership checkout on the site.', 'paid-memberships-pro' )
),
- 'credit_card_expiring' => array(
- 'subject' => __( "Credit card on file expiring soon at !!sitename!!", 'paid-memberships-pro' ),
- 'description' => __('Credit Card Expiring', 'paid-memberships-pro'),
- 'body' => __( 'The payment method used for your membership at !!sitename!! will expire soon. Please click the following link to log in and update your billing information to avoid account suspension. !!login_url!!
-
-Account: !!display_name!! (!!user_email!!)
-The most recent account information we have on file is:
-
-!!billing_name!!
- !!billing_address!!
-
-
-
- !!cardtype!!: !!accountnumber!!
- Expires: !!expirationmonth!!/!!expirationyear!!
-
', 'paid-memberships-pro' ),
- 'help_text' => __( 'This email is sent when a member\'s payment method will be expiring soon. This allows the member to update their payment method before a payment failure, which may result in lost access to member features.', 'paid-memberships-pro' )
- ),
'invoice' => array(
'subject' => __( "Recurring payment receipt for !!sitename!! membership", 'paid-memberships-pro' ),
'description' => __('Recurring Payment Receipt', 'paid-memberships-pro'),
diff --git a/includes/email.php b/includes/email.php
index c716176a6..0b1d6bdc2 100644
--- a/includes/email.php
+++ b/includes/email.php
@@ -379,6 +379,10 @@ function pmpro_email_templates_send_test() {
$send_email = 'sendPaymentActionRequiredAdminEmail';
$params = array($test_user, $test_order, "http://www.example-notification-url.com/not-a-real-site");
break;
+ case 'credit_card_expiring':
+ $send_email = 'sendCreditCardExpiringEmail';
+ $params = array($test_user, $test_order, "http://www.example-notification-url.com/not-a-real-site");
+ break;
default:
$send_email = 'sendEmail';
$params = array();
diff --git a/paid-memberships-pro.php b/paid-memberships-pro.php
index fc919808d..b7a27c363 100644
--- a/paid-memberships-pro.php
+++ b/paid-memberships-pro.php
@@ -55,6 +55,7 @@
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-cancel-admin.php' ); // cancel email template
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-admin-change.php' ); // change email template
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-admin-change-admin.php' ); // change email template
+require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-credit-card-expiring.php' ); // credit card expiring email template
require_once( PMPRO_DIR . '/includes/filters.php' ); // filters, hacks, etc, moved into the plugin
require_once( PMPRO_DIR . '/includes/reports.php' ); // load reports for admin (reports may also include tracking code, etc)
From c68d73b41918f715698f8c3a04e5dec7a320132a Mon Sep 17 00:00:00 2001
From: maximilianoRicoTabo
Date: Wed, 4 Dec 2024 17:58:39 -0300
Subject: [PATCH 15/41] [ENHANCEMENT] * Add Membership expiring email class
---
classes/class.pmproemail.php | 32 +--
...pro-email-template-membership-expiring.php | 194 ++++++++++++++++++
includes/email-templates.php | 11 -
includes/email.php | 2 +-
paid-memberships-pro.php | 1 +
5 files changed, 201 insertions(+), 39 deletions(-)
create mode 100644 classes/email-templates/class-pmpro-email-template-membership-expiring.php
diff --git a/classes/class.pmproemail.php b/classes/class.pmproemail.php
index 8816f189c..c0fe83ddc 100644
--- a/classes/class.pmproemail.php
+++ b/classes/class.pmproemail.php
@@ -1348,36 +1348,14 @@ function sendMembershipExpiringEmail( $user = NULL, $membership_id = NULL )
if(!$user)
return false;
-
+
if ( empty( $membership_id ) ) {
- $membership_level = pmpro_getMembershipLevelForUser($user->ID);
- } else {
- $membership_level = pmpro_getSpecificMembershipLevelForUser($user->ID, $membership_id);
+ $membership_level = pmpro_getMembershipLevelForUser( $user->ID );
+ $membership_id = $membership_level->id;
}
- $this->email = $user->user_email;
- $this->subject = sprintf(__("Your membership at %s will end soon", "paid-memberships-pro"), get_option("blogname"));
-
- $this->data = array(
- 'subject' => $this->subject,
- 'header_name' => $user->display_name,
- 'name' => $user->display_name,
- 'user_login' => $user->user_login,
- 'sitename' => get_option('blogname'),
- 'membership_id' => $membership_level->id,
- 'membership_level_name' => $membership_level->name,
- 'siteemail' => get_option('pmpro_from_email'),
- 'login_link' => pmpro_login_url(),
- 'login_url' => pmpro_login_url(),
- 'enddate' => date_i18n(get_option('date_format'), $membership_level->enddate),
- 'display_name' => $user->display_name,
- 'user_email' => $user->user_email,
- 'levels_url' => pmpro_url( 'levels' )
- );
-
- $this->template = apply_filters("pmpro_email_template", "membership_expiring", $this);
-
- return $this->sendEmail();
+ $email = new PMPro_Email_Template_Membership_Expiring( $user, $membership_id );
+ $email->send();
}
/**
diff --git a/classes/email-templates/class-pmpro-email-template-membership-expiring.php b/classes/email-templates/class-pmpro-email-template-membership-expiring.php
new file mode 100644
index 000000000..cc729466e
--- /dev/null
+++ b/classes/email-templates/class-pmpro-email-template-membership-expiring.php
@@ -0,0 +1,194 @@
+user = $user;
+ $this->membership_id = $membership_id;
+ }
+
+ /**
+ * Get the email template slug.
+ *
+ * @since TBD
+ *
+ * @return string The email template slug.
+ */
+ public static function get_template_slug() {
+ return 'membership_expiring';
+ }
+
+ /**
+ * Get the "nice name" of the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "nice name" of the email template.
+ */
+ public static function get_template_name() {
+ return __( 'Membership Expiring', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get "help text" to display to the admin when editing the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "help text" to display to the admin when editing the email template.
+ */
+ public static function get_template_description() {
+ return __( 'This email is sent to the member when their expiration date is approaching, at an interval based on the term of the membership.', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the default subject for the email.
+ *
+ * @since TBD
+ *
+ * @return string The default subject for the email.
+ */
+ public static function get_default_subject() {
+ return __( "Your membership at !!sitename!! will end soon", 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the default body content for the email.
+ *
+ * @since TBD
+ *
+ * @return string The default body content for the email.
+ */
+ public static function get_default_body() {
+ return __( 'Thank you for your membership to !!sitename!!. This is just a reminder that your membership will end on !!enddate!!.
+
+ Account: !!display_name!! (!!user_email!!)
+ Membership Level: !!membership_level_name!!
+
+ Log in to your membership account here: !!login_url!!
', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the email address to send the email to.
+ *
+ * @since TBD
+ *
+ * @return string The email address to send the email to.
+ */
+ public function get_recipient_email() {
+ return $this->user->user_email;
+ }
+
+ /**
+ * Get the name of the email recipient.
+ *
+ * @since TBD
+ *
+ * @return string The name of the email recipient.
+ */
+ public function get_recipient_name() {
+ return $this->user->display_name;
+ }
+
+
+ /**
+ * Get the email template variables for the email paired with a description of the variable.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public static function get_email_template_variables_with_description() {
+ return array(
+ '!!subject!!' => __( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
+ '!!header_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
+ '!!name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
+ '!!membership_id!!' => __( 'The ID of the membership level.', 'paid-memberships-pro' ),
+ '!!membership_level_name!!' => __( 'The name of the membership level.', 'paid-memberships-pro' ),
+ '!!user_login!!' => __( 'The username of the user.', 'paid-memberships-pro' ),
+ '!!user_email!!' => __( 'The email address of the user.', 'paid-memberships-pro' ),
+ '!!display_name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
+ '!!levels_link!!' => __( 'The URL of the page where users can view available membership levels.', 'paid-memberships-pro' ),
+ '!!enddate!!' => __( 'The expiration date of the membership level.', 'paid-memberships-pro' ),
+ );
+ }
+
+ /**
+ * Get the email template variables for the email.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public function get_email_template_variables() {
+ global $wpdb;
+ // If we don't have a level ID, query the user's most recently expired level from the database.
+ if ( empty( $this->$membership_id ) ) {
+ $membership_id = $wpdb->get_var(
+ $wpdb->prepare(
+ "SELECT membership_id FROM $wpdb->pmpro_memberships_users
+ WHERE user_id = %d
+ AND status = 'expired'
+ ORDER BY enddate DESC
+ LIMIT 1",
+ $user->ID
+ )
+ );
+
+ // If we still don't have a level ID, bail.
+ if ( empty( $membership_id ) ) {
+ $membership_id = 0;
+ }
+ }
+
+ // Get the membership level object.
+ $membership_level = pmpro_getLevel( $membership_id );
+
+ return array(
+ "subject" => $this->subject,
+ "name" => $user->display_name,
+ "user_login" => $user->user_login,
+ "header_name" => $user->display_name,
+ "display_name" => $user->display_name,
+ "user_email" => $user->user_email,
+ "levels_link" => pmpro_url("levels"),
+ "membership_id" => ( ! empty( $membership_level ) && ! empty( $membership_level->id ) ) ? $membership_level->id : 0,
+ "membership_level_name" => ( ! empty( $membership_level ) && ! empty( $membership_level->name ) ) ? $membership_level->name : '[' . esc_html( 'deleted', 'paid-memberships-pro' ) . ']',
+ "enddate" => date_i18n( get_option('date_format'), $membership_level->enddate ),
+ );
+ }
+}
+
+/**
+ * Register the email template.
+ *
+ * @since TBD
+ *
+ * @param array $email_templates The email templates (template slug => email template class name)
+ * @return array The modified email templates array.
+ */
+function pmpro_email_templates_membership_expiring( $email_templates ) {
+ $email_templates['membership_expiring'] = 'PMPro_Email_Template_Membership_Expiring';
+ return $email_templates;
+}
+add_filter( 'pmpro_email_templates', 'pmpro_email_templates_membership_expiring' );
\ No newline at end of file
diff --git a/includes/email-templates.php b/includes/email-templates.php
index e0d2734a2..1fc17ec71 100644
--- a/includes/email-templates.php
+++ b/includes/email-templates.php
@@ -286,17 +286,6 @@
Log in to manage your account here: !!login_url!!
', 'paid-memberships-pro' ),
'help_text' => __( 'This email is sent to the member when their membership expires.', 'paid-memberships-pro' )
),
- 'membership_expiring' => array(
- 'subject' => __( "Your membership at !!sitename!! will end soon", 'paid-memberships-pro' ),
- 'description' => __('Membership Expiring', 'paid-memberships-pro'),
- 'body' => __( 'Thank you for your membership to !!sitename!!. This is just a reminder that your membership will end on !!enddate!!.
-
-Account: !!display_name!! (!!user_email!!)
-Membership Level: !!membership_level_name!!
-
-Log in to your membership account here: !!login_url!!
', 'paid-memberships-pro' ),
- 'help_text' => __( 'This email is sent to the member when their expiration date is approaching, at an interval based on the term of the membership.', 'paid-memberships-pro' )
- ),
'refund' => array(
'subject' => __( 'Order #!!order_id!! at !!sitename!! has been REFUNDED', 'paid-memberships-pro' ),
'description' => __('Refund', 'paid-memberships-pro'),
diff --git a/includes/email.php b/includes/email.php
index c716176a6..6f39b9b03 100644
--- a/includes/email.php
+++ b/includes/email.php
@@ -369,7 +369,7 @@ function pmpro_email_templates_send_test() {
break;
case 'membership_expiring';
$send_email = 'sendMembershipExpiringEmail';
- $params = array($test_user);
+ $params = array( $test_user, $test_order->membership_id );
break;
case 'payment_action':
$send_email = 'sendPaymentActionRequiredEmail';
diff --git a/paid-memberships-pro.php b/paid-memberships-pro.php
index fc919808d..e9f536841 100644
--- a/paid-memberships-pro.php
+++ b/paid-memberships-pro.php
@@ -55,6 +55,7 @@
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-cancel-admin.php' ); // cancel email template
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-admin-change.php' ); // change email template
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-admin-change-admin.php' ); // change email template
+require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-membership-expiring.php' ); // expiring email template
require_once( PMPRO_DIR . '/includes/filters.php' ); // filters, hacks, etc, moved into the plugin
require_once( PMPRO_DIR . '/includes/reports.php' ); // load reports for admin (reports may also include tracking code, etc)
From 6e80dae95ec583d25a67e1eb240413c9b8176bd7 Mon Sep 17 00:00:00 2001
From: maximilianoRicoTabo
Date: Tue, 3 Dec 2024 19:01:24 -0300
Subject: [PATCH 16/41] *add expired membership email class
---
classes/class.pmproemail.php | 48 +----
...mpro-email-template-membership-expired.php | 193 ++++++++++++++++++
includes/email-templates.php | 12 --
includes/email.php | 2 +-
paid-memberships-pro.php | 1 +
5 files changed, 198 insertions(+), 58 deletions(-)
create mode 100644 classes/email-templates/class-pmpro-email-template-membership-expired.php
diff --git a/classes/class.pmproemail.php b/classes/class.pmproemail.php
index 8816f189c..a56279a44 100644
--- a/classes/class.pmproemail.php
+++ b/classes/class.pmproemail.php
@@ -1278,7 +1278,7 @@ function sendTrialEndingEmail( $user = NULL, $membership_id = NULL ) {
* @since 3.1
*/
function sendMembershipExpiredEmail( $user = NULL, $membership_id = NULL ) {
- global $current_user, $wpdb;
+ global $current_user;
if( !$user ) {
$user = $current_user;
}
@@ -1287,51 +1287,9 @@ function sendMembershipExpiredEmail( $user = NULL, $membership_id = NULL ) {
return false;
}
- // If we don't have a level ID, query the user's most recently expired level from the database.
- if ( empty( $membership_id ) ) {
- $membership_id = $wpdb->get_var(
- $wpdb->prepare(
- "SELECT membership_id FROM $wpdb->pmpro_memberships_users
- WHERE user_id = %d
- AND status = 'expired'
- ORDER BY enddate DESC
- LIMIT 1",
- $user->ID
- )
- );
-
- // If we still don't have a level ID, bail.
- if ( empty( $membership_id ) ) {
- $membership_id = 0;
- }
- }
-
- // Get the membership level object.
- $membership_level = pmpro_getLevel( $membership_id );
-
- $this->email = $user->user_email;
- $this->subject = sprintf( __("Your membership at %s has ended", "paid-memberships-pro"), get_option( "blogname" ) );
+ $email = new PMPro_Email_Template_Membership_Expired( $user, $membership_id );
- $this->data = array(
- "subject" => $this->subject,
- "name" => $user->display_name,
- "user_login" => $user->user_login,
- "header_name" => $user->display_name,
- "sitename" => get_option("blogname"),
- "siteemail" => get_option("pmpro_from_email"),
- "login_link" => pmpro_login_url(),
- "login_url" => pmpro_login_url(),
- "display_name" => $user->display_name,
- "user_email" => $user->user_email,
- "levels_link" => pmpro_url("levels"),
- "levels_url" => pmpro_url("levels"),
- "membership_id" => $membership_id,
- "membership_level_name" => ( ! empty( $membership_level ) && ! empty( $membership_level->name ) ) ? $membership_level->name : '[' . esc_html( 'deleted', 'paid-memberships-pro' ) . ']',
- );
-
- $this->template = apply_filters("pmpro_email_template", "membership_expired", $this);
-
- return $this->sendEmail();
+ $email->send();
}
/**
diff --git a/classes/email-templates/class-pmpro-email-template-membership-expired.php b/classes/email-templates/class-pmpro-email-template-membership-expired.php
new file mode 100644
index 000000000..638284ad2
--- /dev/null
+++ b/classes/email-templates/class-pmpro-email-template-membership-expired.php
@@ -0,0 +1,193 @@
+user = $user;
+ $this->membership_level_id = $membership_level_id;
+ }
+
+ /**
+ * Get the email template slug.
+ *
+ * @since TBD
+ *
+ * @return string The email template slug.
+ */
+ public static function get_template_slug() {
+ return 'membership_expired';
+ }
+
+ /**
+ * Get the "nice name" of the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "nice name" of the email template.
+ */
+ public static function get_template_name() {
+ return __( 'Membership Expired', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get "help text" to display to the admin when editing the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "help text" to display to the admin when editing the email template.
+ */
+ public static function get_template_description() {
+ return __( 'This email is sent to the member when their membership expires.', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the default subject for the email.
+ *
+ * @since TBD
+ *
+ * @return string The default subject for the email.
+ */
+ public static function get_default_subject() {
+ return __( 'Your membership at !!sitename!! has ended', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the default body content for the email.
+ *
+ * @since TBD
+ *
+ * @return string The default body content for the email.
+ */
+ public static function get_default_body() {
+ return __( 'Your membership at !!sitename!! has ended.
+
+ Thank you for your support.
+
+ View our current membership offerings here: !!levels_url!!
+
+ Log in to manage your account here: !!login_url!!
', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the email address to send the email to.
+ *
+ * @since TBD
+ *
+ * @return string The email address to send the email to.
+ */
+ public function get_recipient_email() {
+ return $this->user->user_email;
+ }
+
+ /**
+ * Get the name of the email recipient.
+ *
+ * @since TBD
+ *
+ * @return string The name of the email recipient.
+ */
+ public function get_recipient_name() {
+ return $this->user->display_name;
+ }
+
+
+ /**
+ * Get the email template variables for the email paired with a description of the variable.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public static function get_email_template_variables_with_description() {
+ return array(
+ '!!subject!!' => __( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
+ '!!header_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
+ '!!name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
+ '!!membership_id!!' => __( 'The ID of the membership level.', 'paid-memberships-pro' ),
+ '!!membership_level_name!!' => __( 'The name of the membership level.', 'paid-memberships-pro' ),
+ '!!user_login!!' => __( 'The username of the user.', 'paid-memberships-pro' ),
+ '!!user_email!!' => __( 'The email address of the user.', 'paid-memberships-pro' ),
+ '!!display_name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
+ '!!levels_link!!' => __( 'The URL of the page where users can view available membership levels.', 'paid-memberships-pro' ),
+ );
+ }
+
+ /**
+ * Get the email template variables for the email.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public function get_email_template_variables() {
+ global $wpdb;
+ // If we don't have a level ID, query the user's most recently expired level from the database.
+ if ( empty( $this->$membership_id ) ) {
+ $membership_id = $wpdb->get_var(
+ $wpdb->prepare(
+ "SELECT membership_id FROM $wpdb->pmpro_memberships_users
+ WHERE user_id = %d
+ AND status = 'expired'
+ ORDER BY enddate DESC
+ LIMIT 1",
+ $user->ID
+ )
+ );
+
+ // If we still don't have a level ID, bail.
+ if ( empty( $membership_id ) ) {
+ $membership_id = 0;
+ }
+ }
+
+ // Get the membership level object.
+ $membership_level = pmpro_getLevel( $membership_id );
+
+ return array(
+ "subject" => $this->subject,
+ "name" => $user->display_name,
+ "user_login" => $user->user_login,
+ "header_name" => $user->display_name,
+ "display_name" => $user->display_name,
+ "user_email" => $user->user_email,
+ "levels_link" => pmpro_url("levels"),
+ "membership_id" => ( ! empty( $membership_level ) && ! empty( $membership_level->id ) ) ? $membership_level->id : 0,
+ "membership_level_name" => ( ! empty( $membership_level ) && ! empty( $membership_level->name ) ) ? $membership_level->name : '[' . esc_html( 'deleted', 'paid-memberships-pro' ) . ']',
+ );
+ }
+}
+
+/**
+ * Register the email template.
+ *
+ * @since TBD
+ *
+ * @param array $email_templates The email templates (template slug => email template class name)
+ * @return array The modified email templates array.
+ */
+function pmpro_email_templates_membership_expired( $email_templates ) {
+ $email_templates['membership_expired'] = 'PMPro_Email_Template_Membership_Expired';
+ return $email_templates;
+}
+add_filter( 'pmpro_email_templates', 'pmpro_email_templates_membership_expired' );
\ No newline at end of file
diff --git a/includes/email-templates.php b/includes/email-templates.php
index e0d2734a2..cd76d258d 100644
--- a/includes/email-templates.php
+++ b/includes/email-templates.php
@@ -274,18 +274,6 @@
To view an online version of this order, click here: !!order_url!!
', 'paid-memberships-pro' ),
'help_text' => __( 'This email is sent to the member each time a new subscription payment is made.', 'paid-memberships-pro' )
),
- 'membership_expired' => array(
- 'subject' => __( "Your membership at !!sitename!! has ended", 'paid-memberships-pro' ),
- 'description' => __('Membership Expired', 'paid-memberships-pro'),
- 'body' => __( 'Your membership at !!sitename!! has ended.
-
-Thank you for your support.
-
-View our current membership offerings here: !!levels_url!!
-
-Log in to manage your account here: !!login_url!!
', 'paid-memberships-pro' ),
- 'help_text' => __( 'This email is sent to the member when their membership expires.', 'paid-memberships-pro' )
- ),
'membership_expiring' => array(
'subject' => __( "Your membership at !!sitename!! will end soon", 'paid-memberships-pro' ),
'description' => __('Membership Expiring', 'paid-memberships-pro'),
diff --git a/includes/email.php b/includes/email.php
index c716176a6..d017a0128 100644
--- a/includes/email.php
+++ b/includes/email.php
@@ -365,7 +365,7 @@ function pmpro_email_templates_send_test() {
break;
case 'membership_expired';
$send_email = 'sendMembershipExpiredEmail';
- $params = array($test_user);
+ $params = array($test_user, $test_order->membership_id );
break;
case 'membership_expiring';
$send_email = 'sendMembershipExpiringEmail';
diff --git a/paid-memberships-pro.php b/paid-memberships-pro.php
index fc919808d..e72d7f39f 100644
--- a/paid-memberships-pro.php
+++ b/paid-memberships-pro.php
@@ -55,6 +55,7 @@
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-cancel-admin.php' ); // cancel email template
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-admin-change.php' ); // change email template
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-admin-change-admin.php' ); // change email template
+require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-membership-expired.php' ); // change email template
require_once( PMPRO_DIR . '/includes/filters.php' ); // filters, hacks, etc, moved into the plugin
require_once( PMPRO_DIR . '/includes/reports.php' ); // load reports for admin (reports may also include tracking code, etc)
From 480282e9cd6cc2d652f8275be43a30d336cfbf97 Mon Sep 17 00:00:00 2001
From: maximilianoRicoTabo
Date: Mon, 9 Dec 2024 15:33:51 -0300
Subject: [PATCH 17/41] * Add refund email classes
---
classes/class.pmproemail.php | 117 +--------
...lass-pmpro-email-template-refund-admin.php | 223 ++++++++++++++++++
.../class-pmpro-email-template-refund.php | 222 +++++++++++++++++
includes/email-templates.php | 31 ---
includes/email.php | 8 +
paid-memberships-pro.php | 3 +
6 files changed, 461 insertions(+), 143 deletions(-)
create mode 100644 classes/email-templates/class-pmpro-email-template-refund-admin.php
create mode 100644 classes/email-templates/class-pmpro-email-template-refund.php
diff --git a/classes/class.pmproemail.php b/classes/class.pmproemail.php
index 8816f189c..fbf01ce3d 100644
--- a/classes/class.pmproemail.php
+++ b/classes/class.pmproemail.php
@@ -444,61 +444,8 @@ function sendRefundedEmail( $user = NULL, $order = NULL ) {
return false;
}
- $membership_level = pmpro_getSpecificMembershipLevelForUser( $user->ID, $order->membership_id );
- if ( ! empty( $membership_level ) ) {
- $membership_level_id = $membership_level->id;
- $membership_level_name = $membership_level->name;
- } else {
- $membership_level_id = '';
- $membership_level_name = __( 'N/A', 'paid-memberships-pro' );
- }
-
- $this->email = $user->user_email;
- $this->subject = sprintf(__( 'Order #%s at %s has been REFUNDED', 'paid-memberships-pro' ), $order->code, get_option( 'blogname' ) );
-
- $this->data = array(
- 'user_login' => $user->user_login,
- 'user_email' => $user->user_email,
- 'display_name' => $user->display_name,
- 'header_name' => $user->display_name,
- 'sitename' => get_option('blogname'),
- 'siteemail' => get_option('pmpro_from_email'),
- 'login_link' => pmpro_login_url(),
- 'login_url' => pmpro_login_url(),
- 'membership_id' => $membership_level_id,
- 'membership_level_name' => $membership_level_name,
- 'order_id' => $order->code,
- 'order_total' => $order->get_formatted_total(),
- 'order_date' => date_i18n(get_option('date_format'), $order->getTimestamp()),
- 'billing_name' => $order->billing->name,
- 'billing_street' => $order->billing->street,
- 'billing_street2' => $order->billing->street2,
- 'billing_city' => $order->billing->city,
- 'billing_state' => $order->billing->state,
- 'billing_zip' => $order->billing->zip,
- 'billing_country' => $order->billing->country,
- 'billing_phone' => $order->billing->phone,
- 'cardtype' => $order->cardtype,
- 'accountnumber' => hideCardNumber($order->accountnumber),
- 'expirationmonth' => $order->expirationmonth,
- 'expirationyear' => $order->expirationyear,
- 'order_link' => pmpro_login_url( pmpro_url( 'invoice', '?invoice=' . $order->code ) ),
- 'order_url' => pmpro_login_url( pmpro_url( 'invoice', '?invoice=' . $order->code ) ),
- 'levels_url' => pmpro_url( 'levels' )
- );
- $this->data['billing_address'] = pmpro_formatAddress(
- $order->billing->name,
- $order->billing->street,
- $order->billing->street2,
- $order->billing->city,
- $order->billing->state,
- $order->billing->zip,
- $order->billing->country,
- $order->billing->phone
- );
-
- $this->template = apply_filters( 'pmpro_email_template', 'refund', $this );
- return $this->sendEmail();
+ $email = new PMPro_Email_Template_Refund( $user, $order );
+ $email->send();
}
/**
@@ -517,65 +464,11 @@ function sendRefundedAdminEmail( $user = NULL, $order = NULL ) {
return false;
}
- $membership_level = pmpro_getSpecificMembershipLevelForUser( $user->ID, $order->membership_id );
- if ( ! empty( $membership_level ) ) {
- $membership_level_id = $membership_level->id;
- $membership_level_name = $membership_level->name;
- } else {
- $membership_level_id = '';
- $membership_level_name = __( 'N/A', 'paid-memberships-pro' );
- }
-
- $this->email = get_bloginfo( 'admin_email' );
- $this->subject = sprintf(__( 'Order #%s at %s has been REFUNDED', 'paid-memberships-pro' ), $order->code, get_option( 'blogname' ) );
-
- $this->data = array(
- 'user_login' => $user->user_login,
- 'user_email' => $user->user_email,
- 'display_name' => $user->display_name,
- 'header_name' => $this->get_admin_name( $this->email ),
- 'sitename' => get_option('blogname'),
- 'siteemail' => get_option('pmpro_from_email'),
- 'login_link' => pmpro_login_url(),
- 'login_url' => pmpro_login_url(),
- 'membership_id' => $membership_level_id,
- 'membership_level_name' => $membership_level_name,
- 'order_id' => $order->code,
- 'order_total' => $order->get_formatted_total(),
- 'order_date' => date_i18n(get_option('date_format'), $order->getTimestamp()),
- 'billing_name' => $order->billing->name,
- 'billing_street' => $order->billing->street,
- 'billing_street2' => $order->billing->street2,
- 'billing_city' => $order->billing->city,
- 'billing_state' => $order->billing->state,
- 'billing_zip' => $order->billing->zip,
- 'billing_country' => $order->billing->country,
- 'billing_phone' => $order->billing->phone,
- 'cardtype' => $order->cardtype,
- 'accountnumber' => hideCardNumber($order->accountnumber),
- 'expirationmonth' => $order->expirationmonth,
- 'expirationyear' => $order->expirationyear,
- 'order_link' => pmpro_login_url( pmpro_url( 'invoice', '?invoice=' . $order->code ) ),
- 'order_url' => pmpro_login_url( pmpro_url( 'invoice', '?invoice=' . $order->code ) ),
- 'levels_url' => pmpro_url( 'levels' )
-
- );
- $this->data['billing_address'] = pmpro_formatAddress(
- $order->billing->name,
- $order->billing->street,
- $order->billing->street2,
- $order->billing->city,
- $order->billing->state,
- $order->billing->zip,
- $order->billing->country,
- $order->billing->phone
- );
-
- $this->template = apply_filters( 'pmpro_email_template', 'refund_admin', $this );
+ $email = new PMPro_Email_Template_Refund_Admin( $user, $order );
+ $email->send();
- return $this->sendEmail();
}
-
+
/**
* Send the member a confirmation checkout email after successfully purchasing a membership level.
*
diff --git a/classes/email-templates/class-pmpro-email-template-refund-admin.php b/classes/email-templates/class-pmpro-email-template-refund-admin.php
new file mode 100644
index 000000000..c0b4b5fe1
--- /dev/null
+++ b/classes/email-templates/class-pmpro-email-template-refund-admin.php
@@ -0,0 +1,223 @@
+user = $user;
+ $this->order = $order;
+ }
+
+ /**
+ * Get the email template slug.
+ *
+ * @since TBD
+ *
+ * @return string The email template slug.
+ */
+ public static function get_template_slug() {
+ return 'refund_admin';
+ }
+
+ /**
+ * Get the "nice name" of the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "nice name" of the email template.
+ */
+ public static function get_template_name() {
+ return __( 'Refund (admin)', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get "help text" to display to the admin when editing the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "help text" to display to the admin when editing the email template.
+ */
+ public static function get_template_description() {
+ return __( 'This email is sent to the admin as confirmation of a refunded payment. The email is sent after your
+ membership site receives notification of a successful payment refund through your gateway.', 'paid-memberships-pro' );
+
+ }
+
+ /**
+ * Get the default subject for the email.
+ *
+ * @since TBD
+ *
+ * @return string The default subject for the email.
+ */
+ public static function get_default_subject() {
+ return __( 'Order #!!order_id!! at !!sitename!! has been REFUNDED', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the default body content for the email.
+ *
+ * @since TBD
+ *
+ * @return string The default body content for the email.
+ */
+ public static function get_default_body() {
+ return __( 'Order #!!order_id!! at !!sitename!! has been refunded.
+
+ Account: !!display_name!! (!!user_email!!)
+
+ Order #!!order_id!! on !!order_date!!
+ Total Refunded: !!order_total!!
+
+
+ Log in to your WordPress admin here: !!login_url!!
', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the email template variables for the email paired with a description of the variable.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public static function get_email_template_variables_with_description() {
+ return array(
+ '!!user_login!!' => __( 'The login name of the user who requested the refund.', 'paid-memberships-pro' ),
+ '!!user_email!!' => __( 'The email address of the user who requested the refund.', 'paid-memberships-pro' ),
+ '!!display_name!!' => __( 'The display name of the user who requested the refund.', 'paid-memberships-pro' ),
+ '!!header_name!!' => __( 'The display name of the user who requested the refund.', 'paid-memberships-pro' ),
+ '!!membership_id!!' => __( 'The ID of the membership level that was refunded.', 'paid-memberships-pro' ),
+ '!!membership_level_name!!' => __( 'The name of the membership level that was refunded.', 'paid-memberships-pro' ),
+ '!!order_id!!' => __( 'The order ID of the refunded order.', 'paid-memberships-pro' ),
+ '!!order_total!!' => __( 'The total amount refunded.', 'paid-memberships-pro' ),
+ '!!order_date!!' => __( 'The date the refund was processed.', 'paid-memberships-pro' ),
+ '!!billing_name!!' => __( 'The billing name associated with the refunded order.', 'paid-memberships-pro' ),
+ '!!billing_street!!' => __( 'The billing street address associated with the refunded order.', 'paid-memberships-pro' ),
+ '!!billing_street2!!' => __( 'The billing street address line 2 associated with the refunded order.', 'paid-memberships-pro' ),
+ '!!billing_city!!' => __( 'The billing city associated with the refunded order.', 'paid-memberships-pro' ),
+ '!!billing_state!!' => __( 'The billing state associated with the refunded order.', 'paid-memberships-pro' ),
+ '!!billing_zip!!' => __( 'The billing zip code associated with the refunded order.', 'paid-memberships-pro' ),
+ '!!billing_country!!' => __( 'The billing country associated with the refunded order.', 'paid-memberships-pro' ),
+ '!!billing_phone!!' => __( 'The billing phone number associated with the refunded order.', 'paid-memberships-pro' ),
+ '!!cardtype!!' => __( 'The card type used for the refunded order.', 'paid-memberships-pro' ),
+ '!!accountnumber!!' => __( 'The last four digits of the account number used for the refunded order.', 'paid-memberships-pro' ),
+ '!!expirationmonth!!' => __( 'The expiration month of the card used for the refunded order.', 'paid-memberships-pro' ),
+ '!!expirationyear!!' => __( 'The expiration year of the card used for the refunded order.', 'paid-memberships-pro' ),
+ '!!order_link!!' => __( 'The URL to the invoice for the refunded order.', 'paid-memberships-pro' ),
+ '!!order_url!!' => __( 'The URL to the invoice for the refunded order.', 'paid-memberships-pro' ),
+ );
+
+ }
+
+ /**
+ * Get the email address to send the email to.
+ *
+ * @since TBD
+ *
+ * @return string The email address to send the email to.
+ */
+ public function get_recipient_email() {
+ return get_bloginfo( 'admin_email' );
+ }
+
+ /**
+ * Get the name of the email recipient.
+ *
+ * @since TBD
+ *
+ * @return string The name of the email recipient.
+ */
+ public function get_recipient_name() {
+ //get user by email
+ $user = get_user_by( 'email', $this->get_recipient_email() );
+ return $user->display_name;
+ }
+
+ /**
+ * Get the email template variables for the email.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public function get_email_template_variables() {
+
+ $user = $this->user;
+ $order = $this->order;
+ $level = pmpro_getLevel( $order->membership_id );
+
+ $email_template_variables = array(
+ 'user_login' => $user->user_login,
+ 'user_email' => $user->user_email,
+ 'display_name' => $user->display_name,
+ 'header_name' => $user->display_name,
+ 'membership_id' => $order->membership_id,
+ 'membership_level_name' => $level->name,
+ 'order_id' => $order->code,
+ 'order_total' => $order->total,
+ 'order_date' => date_i18n( get_option( 'date_format' ), $order->timestamp ),
+ 'billing_name' => $order->billing->name,
+ 'billing_street' => $order->billing->street,
+ 'billing_street2' => $order->billing->street2,
+ 'billing_city' => $order->billing->city,
+ 'billing_state' => $order->billing->state,
+ 'billing_zip' => $order->billing->zip,
+ 'billing_country' => $order->billing->country,
+ 'billing_phone' => $order->billing->phone,
+ 'cardtype' => $order->cardtype,
+ 'accountnumber' => hideCardNumber( $order->accountnumber ),
+ 'expirationmonth' => $order->expirationmonth,
+ 'expirationyear' => $order->expirationyear,
+ 'order_link' => pmpro_login_url( pmpro_url( 'invoice', '?invoice=' . $order->code ) ),
+ 'order_url' => pmpro_login_url( pmpro_url( 'invoice', '?invoice=' . $order->code ) ),
+ 'billing_address' => pmpro_formatAddress(
+ $order->billing->name,
+ $order->billing->street,
+ $order->billing->street2,
+ $order->billing->city,
+ $order->billing->state,
+ $order->billing->zip,
+ $order->billing->country,
+ $order->billing->phone
+ ),
+ );
+
+ return $email_template_variables;
+
+ }
+}
+
+/**
+ * Register the email template.
+ *
+ * @since TBD
+ *
+ * @param array $email_templates The email templates (template slug => email template class name)
+ * @return array The modified email templates array.
+ */
+function pmpro_email_templates_refund_admin( $email_templates ) {
+ $email_templates['refund_admin'] = 'PMPro_Email_Template_Refund_Admin';
+
+ return $email_templates;
+}
+add_filter( 'pmpro_email_templates', 'pmpro_email_templates_refund_admin' );
diff --git a/classes/email-templates/class-pmpro-email-template-refund.php b/classes/email-templates/class-pmpro-email-template-refund.php
new file mode 100644
index 000000000..aa4213ace
--- /dev/null
+++ b/classes/email-templates/class-pmpro-email-template-refund.php
@@ -0,0 +1,222 @@
+user = $user;
+ $this->order = $order;
+ }
+
+ /**
+ * Get the email template slug.
+ *
+ * @since TBD
+ *
+ * @return string The email template slug.
+ */
+ public static function get_template_slug() {
+ return 'refund';
+ }
+
+ /**
+ * Get the "nice name" of the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "nice name" of the email template.
+ */
+ public static function get_template_name() {
+ return __( 'Refund', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get "help text" to display to the admin when editing the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "help text" to display to the admin when editing the email template.
+ */
+ public static function get_template_description() {
+ return __( 'This email is sent to the member as confirmation of a refunded payment. The email is sent after your
+ membership site receives notification of a successful payment refund through your gateway.', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the default subject for the email.
+ *
+ * @since TBD
+ *
+ * @return string The default subject for the email.
+ */
+ public static function get_default_subject() {
+ return __( 'Order #!!order_id!! at !!sitename!! has been REFUNDED', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the default body content for the email.
+ *
+ * @since TBD
+ *
+ * @return string The default body content for the email.
+ */
+ public static function get_default_body() {
+ return __( 'Order #!!order_id!! at !!sitename!! has been refunded.
+
+ Account: !!display_name!! (!!user_email!!)
+
+ Order #!!order_id!! on !!order_date!!
+ Total Refunded: !!order_total!!
+
+
+ Log in to your membership account here: !!login_url!!
+ To view an online version of this order, click here: !!order_url!!
+
+ If you did not request this refund and would like more information please contact us at !!siteemail!!
', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the email template variables for the email paired with a description of the variable.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public static function get_email_template_variables_with_description() {
+ return array(
+ '!!user_login!!' => __( 'The login name of the user who requested the refund.', 'paid-memberships-pro' ),
+ '!!user_email!!' => __( 'The email address of the user who requested the refund.', 'paid-memberships-pro' ),
+ '!!display_name!!' => __( 'The display name of the user who requested the refund.', 'paid-memberships-pro' ),
+ '!!header_name!!' => __( 'The display name of the user who requested the refund.', 'paid-memberships-pro' ),
+ '!!membership_id!!' => __( 'The ID of the membership level that was refunded.', 'paid-memberships-pro' ),
+ '!!membership_level_name!!' => __( 'The name of the membership level that was refunded.', 'paid-memberships-pro' ),
+ '!!order_id!!' => __( 'The order ID of the refunded order.', 'paid-memberships-pro' ),
+ '!!order_total!!' => __( 'The total amount refunded.', 'paid-memberships-pro' ),
+ '!!order_date!!' => __( 'The date the refund was processed.', 'paid-memberships-pro' ),
+ '!!billing_name!!' => __( 'The billing name associated with the refunded order.', 'paid-memberships-pro' ),
+ '!!billing_street!!' => __( 'The billing street address associated with the refunded order.', 'paid-memberships-pro' ),
+ '!!billing_street2!!' => __( 'The billing street address line 2 associated with the refunded order.', 'paid-memberships-pro' ),
+ '!!billing_city!!' => __( 'The billing city associated with the refunded order.', 'paid-memberships-pro' ),
+ '!!billing_state!!' => __( 'The billing state associated with the refunded order.', 'paid-memberships-pro' ),
+ '!!billing_zip!!' => __( 'The billing zip code associated with the refunded order.', 'paid-memberships-pro' ),
+ '!!billing_country!!' => __( 'The billing country associated with the refunded order.', 'paid-memberships-pro' ),
+ '!!billing_phone!!' => __( 'The billing phone number associated with the refunded order.', 'paid-memberships-pro' ),
+ '!!cardtype!!' => __( 'The card type used for the refunded order.', 'paid-memberships-pro' ),
+ '!!accountnumber!!' => __( 'The last four digits of the account number used for the refunded order.', 'paid-memberships-pro' ),
+ '!!expirationmonth!!' => __( 'The expiration month of the card used for the refunded order.', 'paid-memberships-pro' ),
+ '!!expirationyear!!' => __( 'The expiration year of the card used for the refunded order.', 'paid-memberships-pro' ),
+ '!!order_link!!' => __( 'The URL to the invoice for the refunded order.', 'paid-memberships-pro' ),
+ '!!order_url!!' => __( 'The URL to the invoice for the refunded order.', 'paid-memberships-pro' ),
+ );
+
+ }
+ /**
+ * Get the email address to send the email to.
+ *
+ * @since TBD
+ *
+ * @return string The email address to send the email to.
+ */
+ public function get_recipient_email() {
+ return $this->user->user_email;
+ }
+
+ /**
+ * Get the name of the email recipient.
+ *
+ * @since TBD
+ *
+ * @return string The name of the email recipient.
+ */
+ public function get_recipient_name() {
+ return $this->user->display_name;
+ }
+
+ /**
+ * Get the email template variables for the email.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public function get_email_template_variables() {
+
+ $user = $this->user;
+ $order = $this->order;
+ $level = pmpro_getLevel( $order->membership_id );
+
+ $email_template_variables = array(
+ 'user_login' => $user->user_login,
+ 'user_email' => $user->user_email,
+ 'display_name' => $user->display_name,
+ 'header_name' => $user->display_name,
+ 'membership_id' => $order->membership_id,
+ 'membership_level_name' => $level->name,
+ 'order_id' => $order->code,
+ 'order_total' => $order->total,
+ 'order_date' => date_i18n( get_option( 'date_format' ), $order->timestamp ),
+ 'billing_name' => $order->billing->name,
+ 'billing_street' => $order->billing->street,
+ 'billing_street2' => $order->billing->street2,
+ 'billing_city' => $order->billing->city,
+ 'billing_state' => $order->billing->state,
+ 'billing_zip' => $order->billing->zip,
+ 'billing_country' => $order->billing->country,
+ 'billing_phone' => $order->billing->phone,
+ 'cardtype' => $order->cardtype,
+ 'accountnumber' => hideCardNumber( $order->accountnumber ),
+ 'expirationmonth' => $order->expirationmonth,
+ 'expirationyear' => $order->expirationyear,
+ 'order_link' => pmpro_login_url( pmpro_url( 'invoice', '?invoice=' . $order->code ) ),
+ 'order_url' => pmpro_login_url( pmpro_url( 'invoice', '?invoice=' . $order->code ) ),
+ 'billing_address' => pmpro_formatAddress(
+ $order->billing->name,
+ $order->billing->street,
+ $order->billing->street2,
+ $order->billing->city,
+ $order->billing->state,
+ $order->billing->zip,
+ $order->billing->country,
+ $order->billing->phone
+ ),
+ );
+
+ return $email_template_variables;
+
+ }
+}
+
+/**
+ * Register the email template.
+ *
+ * @since TBD
+ *
+ * @param array $email_templates The email templates (template slug => email template class name)
+ * @return array The modified email templates array.
+ */
+function pmpro_email_templates_refund( $email_templates ) {
+ $email_templates['refund'] = 'PMPro_Email_Template_Refund';
+
+ return $email_templates;
+}
+add_filter( 'pmpro_email_templates', 'pmpro_email_templates_refund' );
\ No newline at end of file
diff --git a/includes/email-templates.php b/includes/email-templates.php
index e0d2734a2..6b995b5e4 100644
--- a/includes/email-templates.php
+++ b/includes/email-templates.php
@@ -297,37 +297,6 @@
Log in to your membership account here: !!login_url!!
', 'paid-memberships-pro' ),
'help_text' => __( 'This email is sent to the member when their expiration date is approaching, at an interval based on the term of the membership.', 'paid-memberships-pro' )
),
- 'refund' => array(
- 'subject' => __( 'Order #!!order_id!! at !!sitename!! has been REFUNDED', 'paid-memberships-pro' ),
- 'description' => __('Refund', 'paid-memberships-pro'),
- 'body' => __( 'Order #!!order_id!! at !!sitename!! has been refunded.
-
-Account: !!display_name!! (!!user_email!!)
-
- Order #!!order_id!! on !!order_date!!
- Total Refunded: !!order_total!!
-
-
-Log in to your membership account here: !!login_url!!
-To view an online version of this order, click here: !!order_url!!
-
-If you did not request this refund and would like more information please contact us at !!siteemail!!
', 'paid-memberships-pro' ),
- 'help_text' => __( 'This email is sent to the member as confirmation of a refunded payment. The email is sent after your membership site receives notification of a successful payment refund through your gateway.', 'paid-memberships-pro' )
- ),
- 'refund_admin' => array(
- 'subject' => __( 'Order #!!order_id!! at !!sitename!! has been REFUNDED', 'paid-memberships-pro' ),
- 'description' => __('Refund (admin)', 'paid-memberships-pro'),
- 'body' => __( 'Order #!!order_id!! at !!sitename!! has been refunded.
-
-Account: !!display_name!! (!!user_email!!)
-
- Order #!!order_id!! on !!order_date!!
- Total Refunded: !!order_total!!
-
-
-Log in to your WordPress admin here: !!login_url!!
', 'paid-memberships-pro' ),
- 'help_text' => __( 'This email is sent to the admin as confirmation of a refunded payment. The email is sent after your membership site receives notification of a successful payment refund through your gateway.', 'paid-memberships-pro' )
- ),
'membership_recurring' => array(
'subject' => __( "Your membership at !!sitename!! will renew soon", 'paid-memberships-pro' ),
'description' => __('Recurring Payment Reminder', 'paid-memberships-pro'),
diff --git a/includes/email.php b/includes/email.php
index c716176a6..a86d3e3f0 100644
--- a/includes/email.php
+++ b/includes/email.php
@@ -379,6 +379,14 @@ function pmpro_email_templates_send_test() {
$send_email = 'sendPaymentActionRequiredAdminEmail';
$params = array($test_user, $test_order, "http://www.example-notification-url.com/not-a-real-site");
break;
+ case 'refund':
+ $send_email = 'sendRefundedEmail';
+ $params = array( $test_user, $test_order );
+ break;
+ case 'refund_admin':
+ $send_email = 'sendRefundedAdminEmail';
+ $params = array( $test_user, $test_order );
+ break;
default:
$send_email = 'sendEmail';
$params = array();
diff --git a/paid-memberships-pro.php b/paid-memberships-pro.php
index fc919808d..579a9acfd 100644
--- a/paid-memberships-pro.php
+++ b/paid-memberships-pro.php
@@ -55,6 +55,9 @@
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-cancel-admin.php' ); // cancel email template
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-admin-change.php' ); // change email template
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-admin-change-admin.php' ); // change email template
+require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-refund.php' ); // refund email template
+require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-refund-admin.php' ); // refund email admin template
+
require_once( PMPRO_DIR . '/includes/filters.php' ); // filters, hacks, etc, moved into the plugin
require_once( PMPRO_DIR . '/includes/reports.php' ); // load reports for admin (reports may also include tracking code, etc)
From d4ed471a439dfd4490cb54ee5791d54fe2d71fbe Mon Sep 17 00:00:00 2001
From: maximilianoRicoTabo
Date: Sat, 7 Dec 2024 21:41:02 -0300
Subject: [PATCH 18/41] * Add Payment Email Classes
---
classes/class.pmproemail.php | 155 +++--------
...ro-email-template-payment-action-admin.php | 175 ++++++++++++
...ss-pmpro-email-template-payment-action.php | 169 ++++++++++++
...s-pmpro-email-template-payment-receipt.php | 254 ++++++++++++++++++
...-pmpro-email-template-payment-reminder.php | 159 +++++++++++
includes/email-templates.php | 69 +----
includes/email.php | 8 +
paid-memberships-pro.php | 4 +
scheduled/crons.php | 8 +
9 files changed, 817 insertions(+), 184 deletions(-)
create mode 100644 classes/email-templates/class-pmpro-email-template-payment-action-admin.php
create mode 100644 classes/email-templates/class-pmpro-email-template-payment-action.php
create mode 100644 classes/email-templates/class-pmpro-email-template-payment-receipt.php
create mode 100644 classes/email-templates/class-pmpro-email-template-payment-reminder.php
diff --git a/classes/class.pmproemail.php b/classes/class.pmproemail.php
index 8816f189c..57442beb4 100644
--- a/classes/class.pmproemail.php
+++ b/classes/class.pmproemail.php
@@ -1134,8 +1134,7 @@ function sendCreditCardExpiringEmail($user = NULL, $order = NULL) {
* @param object $user The WordPress user object.
* @param MemberOrder $order The order object that is associated to the member.
*/
- function sendInvoiceEmail($user = NULL, $order = NULL)
- {
+ function sendInvoiceEmail( $user = NULL, $order = NULL ) {
global $wpdb, $current_user;
if(!$user)
$user = $current_user;
@@ -1143,75 +1142,13 @@ function sendInvoiceEmail($user = NULL, $order = NULL)
if(!$user || !$order)
return false;
+ //Bail if no membership level in the order
if ( empty( $order->membership_id ) ) {
return false;
}
- $membership_level = pmpro_getSpecificMembershipLevelForUser($user->ID, $order->membership_id);
-
- $this->email = $user->user_email;
- $this->subject = sprintf(__("Order for %s membership", "paid-memberships-pro"), get_option("blogname"));
-
- $this->data = array(
- 'subject' => $this->subject,
- 'header_name' => $user->display_name,
- 'name' => $user->display_name,
- 'user_login' => $user->user_login,
- 'sitename' => get_option( 'blogname' ),
- 'siteemail' => get_option( 'pmpro_from_email' ),
- 'membership_id' => $membership_level->id,
- 'membership_level_name' => $membership_level->name,
- 'display_name' => $user->display_name,
- 'user_email' => $user->user_email,
- 'order_id' => $order->code,
- 'order_total' => $order->get_formatted_total(),
- 'order_date' => date_i18n( get_option( 'date_format' ), $order->getTimestamp() ),
- 'billing_name' => $order->billing->name,
- 'billing_street' => $order->billing->street,
- 'billing_street2' => $order->billing->street2,
- 'billing_city' => $order->billing->city,
- 'billing_state' => $order->billing->state,
- 'billing_zip' => $order->billing->zip,
- 'billing_country' => $order->billing->country,
- 'billing_phone' => $order->billing->phone,
- 'cardtype' => $order->cardtype,
- 'accountnumber' => hideCardNumber($order->accountnumber),
- 'expirationmonth' => $order->expirationmonth,
- 'expirationyear' => $order->expirationyear,
- 'login_link' => pmpro_login_url(),
- 'login_url' => pmpro_login_url(),
- 'order_link' => pmpro_login_url( pmpro_url( 'invoice', '?invoice=' . $order->code ) ),
- 'order_url' => pmpro_login_url( pmpro_url( 'invoice', '?invoice=' . $order->code ) ),
- 'levels_url' => pmpro_url( 'levels' )
- );
- $this->data["billing_address"] = pmpro_formatAddress($order->billing->name,
- $order->billing->street,
- $order->billing->street2,
- $order->billing->city,
- $order->billing->state,
- $order->billing->zip,
- $order->billing->country,
- $order->billing->phone);
-
- if($order->getDiscountCode()) {
- if(!empty($order->discount_code->code))
- $this->data["discount_code"] = "" . __("Discount Code", 'paid-memberships-pro' ) . ": " . $order->discount_code->code . "
\n";
- else
- $this->data["discount_code"] = "" . __("Discount Code", 'paid-memberships-pro' ) . ": " . $order->discount_code . "
\n";
- } else {
- $this->data["discount_code"] = "";
- }
-
- $enddate = $wpdb->get_var("SELECT UNIX_TIMESTAMP(CONVERT_TZ(enddate, '+00:00', @@global.time_zone)) FROM $wpdb->pmpro_memberships_users WHERE user_id = '" . $user->ID . "' AND status = 'active' LIMIT 1");
- if($enddate)
- $this->data["membership_expiration"] = "" . sprintf(__("This membership will expire on %s.", 'paid-memberships-pro' ), date_i18n(get_option('date_format'), $enddate)) . "
\n";
- else
- $this->data["membership_expiration"] = "";
-
-
- $this->template = apply_filters("pmpro_email_template", "invoice", $this);
-
- return $this->sendEmail();
+ $email = new PMPro_Email_Template_Payment_Receipt( $user, $order );
+ $email->send();
}
/**
@@ -1440,44 +1377,25 @@ function sendBillableInvoiceEmail( $user = NULL, $order = NULL ) {
* @param string $order_url The link to the order that is generated by Stripe.
* @return void
*/
- function sendPaymentActionRequiredEmail($user = NULL, $order = NULL, $order_url = NULL)
- {
+ function sendPaymentActionRequiredEmail( $user = NULL, $order = NULL, $order_url = NULL ) {
global $current_user;
if(!$user)
$user = $current_user;
- if(!$user || !$order)
+ if( !$user || !$order )
return false;
// if an order URL wasn't passed in, grab it from the order
- if(empty($order_url) && isset($order->order_url))
+ if( empty( $order_url ) && isset( $order->order_url ) )
$order_url = $order->order_url;
// still no order URL? bail
- if(empty($order_url))
+ if( empty( $order_url ) )
return false;
-
- $this->email = $user->user_email;
- $this->subject = sprintf(__("Payment action required for your %s membership", 'paid-memberships-pro' ), get_option("blogname"));
-
- $this->template = "payment_action";
- $this->template = apply_filters("pmpro_email_template", $this->template, $this);
+ $email = new PMPro_Email_Template_Payment_Action( $user, $order_url );
+ $email->send();
- $this->data = array(
- 'subject' => $this->subject,
- 'header_name' => $user->display_name,
- 'name' => $user->display_name,
- 'display_name' => $user->display_name,
- 'user_login' => $user->user_login,
- 'sitename' => get_option( 'blogname' ),
- 'siteemail' => get_option( 'pmpro_from_email' ),
- 'order_link' => $order_url,
- 'order_url' => $order_url,
- 'levels_url' => pmpro_url( 'levels' )
- );
-
- return $this->sendEmail();
}
/**
@@ -1485,48 +1403,43 @@ function sendPaymentActionRequiredEmail($user = NULL, $order = NULL, $order_url
*
* @param object $user
* @param MemberOrder $order
- * @param string $invoice_url The link to the invoice that is generated by Stripe.
+ * @param string $order_url The url to the order that is generated by Stripe.
* @return void
*/
- function sendPaymentActionRequiredAdminEmail($user = NULL, $order = NULL, $invoice_url = NULL)
- {
+ function sendPaymentActionRequiredAdminEmail($user = NULL, $order = NULL, $order_url = NULL) {
global $current_user;
- if(!$user)
+ if( !$user )
$user = $current_user;
- if(!$user || !$order)
+ if( !$user || !$order )
return false;
// if an invoice URL wasn't passed in, grab it from the order
- if(empty($invoice_url) && isset($order->invoice_url))
- $invoice_url = $order->invoice_url;
+ if( empty( $order_url ) && isset( $order->invoice_url ) )
+ $order_url = $order->invoice_url;
// still no invoice URL? bail
- if(empty($invoice_url))
+ if( empty( $order_url ) )
return false;
-
- $this->email = get_bloginfo("admin_email");
- $this->subject = sprintf(__("Payment action required: membership for %s at %s", 'paid-memberships-pro' ), $user->user_login, get_option("blogname"));
-
- $this->template = "payment_action_admin";
- $this->template = apply_filters("pmpro_email_template", $this->template, $this);
+ $email = new PMPro_Email_Template_Payment_Action_Admin( $user, $order_url );
+ $email->send();
+ }
- $this->data = array(
- 'subject' => $this->subject,
- 'header_name' => $this->get_admin_name( $this->email ),
- 'name' => $user->display_name,
- 'display_name' => $user->display_name,
- 'user_login' => $user->user_login,
- 'sitename' => get_option('blogname'),
- 'siteemail' => get_option('pmpro_from_email'),
- 'user_email' => $user->user_email,
- 'invoice_link' => $invoice_url,
- 'invoice_url' => $invoice_url,
- 'levels_url' => pmpro_url( 'levels' )
- );
-
- return $this->sendEmail();
+ /**
+ * Send the payment reminder email to a member.
+ *
+ * @param object $user The WordPress user object.
+ * @return void
+ * @since TBD
+ */
+ function send_recurring_payment_reminder( $subscription_obj = NULL ) {
+ // Bail if we don't have a subscription object.
+ if ( ! $subscription_obj ) {
+ return false;
+ }
+ $email = new PMPro_Email_Template_Payment_Reminder( $subscription_obj );
+ $email->send();
}
/**
diff --git a/classes/email-templates/class-pmpro-email-template-payment-action-admin.php b/classes/email-templates/class-pmpro-email-template-payment-action-admin.php
new file mode 100644
index 000000000..540c1ec85
--- /dev/null
+++ b/classes/email-templates/class-pmpro-email-template-payment-action-admin.php
@@ -0,0 +1,175 @@
+user = $user;
+ $this->order_url = $order_url;
+ }
+
+ /**
+ * Get the email template slug.
+ *
+ * @since TBD
+ *
+ * @return string The email template slug.
+ */
+ public static function get_template_slug() {
+ return 'payment_action_admin';
+ }
+
+ /**
+ * Get the "nice name" of the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "nice name" of the email template.
+ */
+ public static function get_template_name() {
+ return __( 'Payment Action Required (admin)', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get "help text" to display to the admin when editing the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "help text" to display to the admin when editing the email template.
+ */
+ public static function get_template_description() {
+ return __( 'This email is sent to the site administrator when an attempted membership checkout requires additional customer authentication.', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the default subject for the email.
+ *
+ * @since TBD
+ *
+ * @return string The default subject for the email.
+ */
+ public static function get_default_subject() {
+ return __( "Payment action required: membership for !!user_login!! at !!sitename!!", 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the default body content for the email.
+ *
+ * @since TBD
+ *
+ * @return string The default body content for the email.
+ */
+ public static function get_default_body() {
+ return __( 'A payment at !!sitename!! for !!user_login!! requires additional customer authentication to complete.
+ Below is a copy of the email we sent to !!user_email!! to notify them that they need to complete their payment:
+
+ Customer authentication is required to finish setting up your subscription at !!sitename!!.
+
+ Please complete the verification steps issued by your payment provider at the following link:
+ !!order_url!!
', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the email address to send the email to.
+ *
+ * @since TBD
+ *
+ * @return string The email address to send the email to.
+ */
+ public function get_recipient_email() {
+ return get_bloginfo( 'admin_email' );
+ }
+
+ /**
+ * Get the name of the email recipient.
+ *
+ * @since TBD
+ *
+ * @return string The name of the email recipient.
+ */
+ public function get_recipient_name() {
+ //get user by email
+ $user = get_user_by( 'email', $this->get_recipient_email() );
+ return $user->display_name;
+ }
+
+
+ /**
+ * Get the email template variables for the email paired with a description of the variable.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public static function get_email_template_variables_with_description() {
+ return array(
+ '!!subject!!' => __( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
+ '!!header_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
+ '!!name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
+ '!!user_login!!' => __( 'The username of the user.', 'paid-memberships-pro' ),
+ '!!display_name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
+ '!!order_link!!' => __( 'The URL of the order.', 'paid-memberships-pro' ),
+ '!!order_url!!' => __( 'The URL of the order.', 'paid-memberships-pro' ),
+ '!!invoice_url!!' => __( 'The URL of the order. Legacy purpose', 'paid-memberships-pro' ),
+ '!!levels_url!!' => __( 'The URL of the membership levels page.', 'paid-memberships-pro' ),
+ );
+ }
+
+ /**
+ * Get the email template variables for the email.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public function get_email_template_variables() {
+ $user = $this->user;
+ $order_url = $this->order_url;
+ return array(
+ "subject" => $this->subject,
+ "name" => $user->display_name,
+ "user_login" => $user->user_login,
+ "header_name" => $user->display_name,
+ "display_name" => $user->display_name,
+ "order_link" => $order_url,
+ "order_url" => $order_url,
+ "invoice_url" => $order_url, // Legacy purpose, remove in future version
+ "levels_url" => pmpro_url( 'levels' )
+ );
+ }
+}
+
+/**
+ * Register the email template.
+ *
+ * @since TBD
+ *
+ * @param array $email_templates The email templates (template slug => email template class name)
+ * @return array The modified email templates array.
+ */
+function pmpro_email_templates_payment_action_admin( $email_templates ) {
+ $email_templates['payment_action_admin'] = 'PMPro_Email_Template_Payment_Action_Admin';
+ return $email_templates;
+}
+add_filter( 'pmpro_email_templates', 'pmpro_email_templates_payment_action_admin' );
+
diff --git a/classes/email-templates/class-pmpro-email-template-payment-action.php b/classes/email-templates/class-pmpro-email-template-payment-action.php
new file mode 100644
index 000000000..4fccf1d24
--- /dev/null
+++ b/classes/email-templates/class-pmpro-email-template-payment-action.php
@@ -0,0 +1,169 @@
+user = $user;
+ $this->order_url = $order_url;
+ }
+
+ /**
+ * Get the email template slug.
+ *
+ * @since TBD
+ *
+ * @return string The email template slug.
+ */
+ public static function get_template_slug() {
+ return 'payment_action';
+ }
+
+ /**
+ * Get the "nice name" of the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "nice name" of the email template.
+ */
+ public static function get_template_name() {
+ return __( 'Payment Action Required', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get "help text" to display to the admin when editing the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "help text" to display to the admin when editing the email template.
+ */
+ public static function get_template_description() {
+ return __( 'This email is sent to the user when an attempted membership checkout requires additional customer authentication.', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the default subject for the email.
+ *
+ * @since TBD
+ *
+ * @return string The default subject for the email.
+ */
+ public static function get_default_subject() {
+ return __( "Payment action required for your !!sitename!! membership", 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the default body content for the email.
+ *
+ * @since TBD
+ *
+ * @return string The default body content for the email.
+ */
+ public static function get_default_body() {
+ return __( 'Customer authentication is required to finish setting up your subscription at !!sitename!!.
+
+ Please complete the verification steps issued by your payment provider at the following link:
+ !!order_url!!
', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the email address to send the email to.
+ *
+ * @since TBD
+ *
+ * @return string The email address to send the email to.
+ */
+ public function get_recipient_email() {
+ return $this->user->user_email;
+ }
+
+ /**
+ * Get the name of the email recipient.
+ *
+ * @since TBD
+ *
+ * @return string The name of the email recipient.
+ */
+ public function get_recipient_name() {
+ return $this->user->display_name;
+ }
+
+
+ /**
+ * Get the email template variables for the email paired with a description of the variable.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public static function get_email_template_variables_with_description() {
+ return array(
+ '!!subject!!' => __( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
+ '!!header_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
+ '!!name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
+ '!!user_login!!' => __( 'The username of the user.', 'paid-memberships-pro' ),
+ '!!display_name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
+ '!!order_link!!' => __( 'The URL of the order.', 'paid-memberships-pro' ),
+ '!!order_url!!' => __( 'The URL of the order.', 'paid-memberships-pro' ),
+ '!!invoice_url!!' => __( 'The URL of the order. Legacy purpose', 'paid-memberships-pro' ),
+ '!!levels_url!!' => __( 'The URL of the membership levels page.', 'paid-memberships-pro' ),
+ );
+ }
+
+ /**
+ * Get the email template variables for the email.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public function get_email_template_variables() {
+ $user = $this->user;
+ $order_url = $this->order_url;
+ return array(
+ "subject" => $this->subject,
+ "name" => $user->display_name,
+ "user_login" => $user->user_login,
+ "header_name" => $user->display_name,
+ "display_name" => $user->display_name,
+ "order_link" => $order_url,
+ "order_url" => $order_url,
+ "invoice_url" => $order_url, // Legacy purpose, remove in future version
+ "levels_url" => pmpro_url( 'levels' )
+ );
+ }
+}
+
+/**
+ * Register the email template.
+ *
+ * @since TBD
+ *
+ * @param array $email_templates The email templates (template slug => email template class name)
+ * @return array The modified email templates array.
+ */
+function pmpro_email_templates_payment_action( $email_templates ) {
+ $email_templates['payment_action'] = 'PMPro_Email_Template_Payment_Action';
+ return $email_templates;
+}
+add_filter( 'pmpro_email_templates', 'pmpro_email_templates_payment_action' );
diff --git a/classes/email-templates/class-pmpro-email-template-payment-receipt.php b/classes/email-templates/class-pmpro-email-template-payment-receipt.php
new file mode 100644
index 000000000..4350824d7
--- /dev/null
+++ b/classes/email-templates/class-pmpro-email-template-payment-receipt.php
@@ -0,0 +1,254 @@
+
+user = $user;
+ $this->order = $order;
+ }
+
+ /**
+ * Get the email template slug.
+ *
+ * @since TBD
+ *
+ * @return string The email template slug.
+ */
+ public static function get_template_slug() {
+ return 'invoice';
+ }
+
+ /**
+ * Get the "nice name" of the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "nice name" of the email template.
+ */
+ public static function get_template_name() {
+ return __( 'Recurring Payment Receipt', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get "help text" to display to the admin when editing the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "help text" to display to the admin when editing the email template.
+ */
+ public static function get_template_description() {
+ return __( 'This email is sent to the member each time a new subscription payment is made.', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the default subject for the email.
+ *
+ * @since TBD
+ *
+ * @return string The default subject for the email.
+ */
+ public static function get_default_subject() {
+ return __( "Recurring payment receipt for !!sitename!! membership", 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the default body content for the email.
+ *
+ * @since TBD
+ *
+ * @return string The default body content for the email.
+ */
+ public static function get_default_body() {
+ return __( 'Thank you for your membership to !!sitename!!. Below is a receipt for your most recent membership order.
+
+ Account: !!display_name!! (!!user_email!!)
+
+ Order #!!order_id!! on !!order_date!!
+ Total Billed: !!order_total!!
+
+
+ Billing Information:
+ !!billing_address!!
+
+
+
+ !!cardtype!!: !!accountnumber!!
+ Expires: !!expirationmonth!!/!!expirationyear!!
+
+
+ Log in to your membership account here: !!login_url!!
+ To view an online version of this order, click here: !!order_url!!
', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the email address to send the email to.
+ *
+ * @since TBD
+ *
+ * @return string The email address to send the email to.
+ */
+ public function get_recipient_email() {
+ return $this->user->user_email;
+ }
+
+ /**
+ * Get the name of the email recipient.
+ *
+ * @since TBD
+ *
+ * @return string The name of the email recipient.
+ */
+ public function get_recipient_name() {
+ return $this->user->display_name;
+ }
+
+
+ /**
+ * Get the email template variables for the email paired with a description of the variable.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public static function get_email_template_variables_with_description() {
+ return array(
+ '!!subject!!' => __( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
+ '!!header_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
+ '!!name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
+ '!!membership_id!!' => __( 'The ID of the membership level.', 'paid-memberships-pro' ),
+ '!!membership_level_name!!' => __( 'The name of the membership level.', 'paid-memberships-pro' ),
+ '!!user_login!!' => __( 'The username of the user.', 'paid-memberships-pro' ),
+ '!!user_email!!' => __( 'The email address of the user.', 'paid-memberships-pro' ),
+ '!!display_name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
+ '!!order_id!!' => __( 'The order ID.', 'paid-memberships-pro' ),
+ '!!order_total!!' => __( 'The total amount of the order.', 'paid-memberships-pro' ),
+ '!!order_date!!' => __( 'The date of the order.', 'paid-memberships-pro' ),
+ '!!order_link!!' => __( 'The URL of the order.', 'paid-memberships-pro' ),
+ '!!order_url!!' => __( 'The URL of the order.', 'paid-memberships-pro' ),
+ '!!billing_name!!' => __( 'The name of the billing contact.', 'paid-memberships-pro' ),
+ '!!billing_street!!' => __( 'The street address of the billing contact.', 'paid-memberships-pro' ),
+ '!!billing_street2!!' => __( 'The second line of the street address of the billing contact.', 'paid-memberships-pro' ),
+ '!!billing_city!!' => __( 'The city of the billing contact.', 'paid-memberships-pro' ),
+ '!!billing_state!!' => __( 'The state of the billing contact.', 'paid-memberships-pro' ),
+ '!!billing_zip!!' => __( 'The ZIP code of the billing contact.', 'paid-memberships-pro' ),
+ '!!billing_country!!' => __( 'The country of the billing contact.', 'paid-memberships-pro' ),
+ '!!billing_phone!!' => __( 'The phone number of the billing contact.', 'paid-memberships-pro' ),
+ '!!billing_address!!' => __( 'The formatted billing address.', 'paid-memberships-pro' ),
+ '!!cardtype!!' => __( 'The type of credit card used for the order.', 'paid-memberships-pro' ),
+ '!!accountnumber!!' => __( 'The last four digits of the credit card used for the order.', 'paid-memberships-pro' ),
+ '!!expirationmonth!!' => __( 'The expiration month of the credit card used for the order.', 'paid-memberships-pro' ),
+ '!!expirationyear!!' => __( 'The expiration year of the credit card used for the order.', 'paid-memberships-pro' ),
+ '!!discount_code!!' => __( 'The discount code used for the order.', 'paid-memberships-pro' ),
+ '!!membership_expiration!!' => __( 'The expiration date of the membership level.', 'paid-memberships-pro' ),
+
+
+
+ );
+ }
+
+ /**
+ * Get the email template variables for the email.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public function get_email_template_variables() {
+ global $wpdb;
+ $user = $this->user;
+ $order = $this->order;
+ $membership_level = pmpro_getLevel( $order->membership_id );
+
+ //Get discount code if it exists
+ $discount_code = "";
+ if( $order->getDiscountCode() && !empty( $order->discount_code->code ) ) {
+ $discount_code = "" . __("Discount Code", 'paid-memberships-pro' ) . ": " . $order->discount_code->code . "
\n";
+ } else {
+ $discount_code = "" . __("Discount Code", 'paid-memberships-pro' ) . ": " . $order->discount_code . "
\n";
+ }
+
+ //Get membership expiration date
+ $enddate = $wpdb->get_var("SELECT UNIX_TIMESTAMP(CONVERT_TZ(enddate, '+00:00', @@global.time_zone)) FROM $wpdb->pmpro_memberships_users WHERE user_id = '" . $user->ID . "' AND status = 'active' LIMIT 1");
+ if( $enddate ) {
+ $membership_expiration = "" . sprintf(__("This membership will expire on %s.", 'paid-memberships-pro' ), date_i18n(get_option('date_format'), $enddate)) . "
\n";
+ } else {
+ $membership_expiration = "";
+ }
+
+ $email_template_variables = array(
+ 'subject' => $this->get_default_subject(),
+ 'header_name' => $this->get_recipient_name(),
+ 'name' => $this->get_recipient_name(),
+ 'display_name' => $this->get_recipient_name(),
+ 'user_login' => $user->user_login,
+ 'membership_id' => $membership_level->id,
+ 'membership_level_name' => $membership_level->name,
+ 'user_email' => $user->user_email,
+ 'order_id' => $order->code,
+ 'order_total' => $order->get_formatted_total(),
+ 'order_date' => date_i18n( get_option( 'date_format' ), $order->getTimestamp() ),
+ 'order_link' => pmpro_login_url( pmpro_url( 'invoice', '?invoice=' . $order->code ) ),
+ 'order_url' => pmpro_login_url( pmpro_url( 'invoice', '?invoice=' . $order->code ) ),
+ 'billing_name' => $order->billing->name,
+ 'billing_street' => $order->billing->street,
+ 'billing_street2' => $order->billing->street2,
+ 'billing_city' => $order->billing->city,
+ 'billing_state' => $order->billing->state,
+ 'billing_zip' => $order->billing->zip,
+ 'billing_country' => $order->billing->country,
+ 'billing_phone' => $order->billing->phone,
+ 'billing_address'=> pmpro_formatAddress( $order->billing->name,
+ $order->billing->street,
+ $order->billing->street2,
+ $order->billing->city,
+ $order->billing->state,
+ $order->billing->zip,
+ $order->billing->country,
+ $order->billing->phone ),
+ 'cardtype' => $order->cardtype,
+ 'accountnumber' => hideCardNumber( $order->accountnumber ),
+ 'expirationmonth' => $order->expirationmonth,
+ 'expirationyear' => $order->expirationyear,
+ 'discount_code' => $discount_code,
+ 'membership_expiration' => $membership_expiration
+ );
+
+ return $email_template_variables;
+ }
+}
+
+/**
+ * Register the email template.
+ *
+ * @since TBD
+ *
+ * @param array $email_templates The email templates (template slug => email template class name)
+ * @return array The modified email templates array.
+ */
+function pmpro_email_templates_payment_receipt( $email_templates ) {
+ $email_templates['invoice'] = 'PMPro_Email_Template_Payment_Receipt';
+ return $email_templates;
+}
+add_filter( 'pmpro_email_templates', 'pmpro_email_templates_payment_receipt' );
\ No newline at end of file
diff --git a/classes/email-templates/class-pmpro-email-template-payment-reminder.php b/classes/email-templates/class-pmpro-email-template-payment-reminder.php
new file mode 100644
index 000000000..5b036c475
--- /dev/null
+++ b/classes/email-templates/class-pmpro-email-template-payment-reminder.php
@@ -0,0 +1,159 @@
+subscription_obj = $subscription_obj;
+ }
+
+ /**
+ * Get the email template slug.
+ *
+ * @since TBD
+ *
+ * @return string The email template slug.
+ */
+ public static function get_template_slug() {
+ return 'membership_recurring';
+ }
+
+ /**
+ * Get the "nice name" of the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "nice name" of the email template.
+ */
+ public static function get_template_name() {
+ return __( 'Membership Recurring', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get "help text" to display to the admin when editing the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "help text" to display to the admin when editing the email template.
+ */
+ public static function get_template_description() {
+ return __( 'This email is sent when a subscription is approaching its renewal date. The additional placeholders !!renewaldate!! and !!billing_amount!! can be used to print the date that the subscription will renew and the renewal price.', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the default subject for the email.
+ *
+ * @since TBD
+ *
+ * @return string The default subject for the email.
+ */
+ public static function get_default_subject() {
+ return __( "Your membership at !!sitename!! will end soon", 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the default body content for the email.
+ *
+ * @since TBD
+ *
+ * @return string The default body content for the email.
+ */
+ public static function get_default_body() {
+ return __( 'Thank you for your membership to !!sitename!!.
+
+ This is just a reminder that your !!membership_level_name!! membership will automatically renew on !!renewaldate!!.
+
+ Account: !!display_name!! (!!user_email!!)
+
+ If for some reason you do not want to renew your membership you can cancel by clicking here: !!cancel_link!!
', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the email address to send the email to.
+ *
+ * @since TBD
+ *
+ * @return string The email address to send the email to.
+ */
+ public function get_recipient_email() {
+ return $this->user->user_email;
+ }
+
+ /**
+ * Get the name of the email recipient.
+ *
+ * @since TBD
+ *
+ * @return string The name of the email recipient.
+ */
+ public function get_recipient_name() {
+ return $this->user->display_name;
+ }
+
+
+ /**
+ * Get the email template variables for the email paired with a description of the variable.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public static function get_email_template_variables_with_description() {
+ return array(
+ 'membership_level_name' => __( 'The name of the membership level.', 'paid-memberships-pro' ),
+ 'renewaldate' => __( 'The date of the next payment date.', 'paid-memberships-pro' ),
+ 'display_name' => __( 'The display name of the user.', 'paid-memberships-pro' ),
+ 'user_email' => __( 'The email address of the user.', 'paid-memberships-pro' ),
+ 'cancel_link' => __( 'The link to cancel the subscription.', 'paid-memberships-pro' ),
+ );
+ }
+
+ /**
+ * Get the email template variables for the email.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public function get_email_template_variables() {
+ $subscription_obj = $this->subscription_obj;
+ $membership_id = $subscription_obj->get_membership_level_id();
+ $membership_level = pmpro_getLevel( $membership_id );
+ $user = get_userdata( $subscription_obj->get_user_id() );
+
+ return array(
+ 'membership_level_name' => $membership_level->name,
+ 'renewaldate' => date_i18n( get_option( 'date_format' ), $subscription_obj->get_next_payment_date() ),
+ 'display_name' => $user->display_name,
+ 'user_email' => $user->user_email,
+ 'cancel_link' => wp_login_url( pmpro_url( 'cancel' ) ),
+ );
+ }
+}
+
+/**
+ * Register the email template.
+ *
+ * @since TBD
+ *
+ * @param array $email_templates The email templates (template slug => email template class name)
+ * @return array The modified email templates array.
+ */
+function pmpro_email_templates_membership_recurring( $email_templates ) {
+ $email_templates['membership_recurring'] = 'PMPro_Email_Template_Payment_Reminder';
+ return $email_templates;
+}
+add_filter( 'pmpro_email_templates', 'pmpro_email_templates_membership_recurring' );
\ No newline at end of file
diff --git a/includes/email-templates.php b/includes/email-templates.php
index e0d2734a2..1cd114918 100644
--- a/includes/email-templates.php
+++ b/includes/email-templates.php
@@ -250,30 +250,6 @@
', 'paid-memberships-pro' ),
'help_text' => __( 'This email is sent when a member\'s payment method will be expiring soon. This allows the member to update their payment method before a payment failure, which may result in lost access to member features.', 'paid-memberships-pro' )
),
- 'invoice' => array(
- 'subject' => __( "Recurring payment receipt for !!sitename!! membership", 'paid-memberships-pro' ),
- 'description' => __('Recurring Payment Receipt', 'paid-memberships-pro'),
- 'body' => __( 'Thank you for your membership to !!sitename!!. Below is a receipt for your most recent membership order.
-
-Account: !!display_name!! (!!user_email!!)
-
- Order #!!order_id!! on !!order_date!!
- Total Billed: !!order_total!!
-
-
- Billing Information:
- !!billing_address!!
-
-
-
- !!cardtype!!: !!accountnumber!!
- Expires: !!expirationmonth!!/!!expirationyear!!
-
-
-Log in to your membership account here: !!login_url!!
-To view an online version of this order, click here: !!order_url!!
', 'paid-memberships-pro' ),
- 'help_text' => __( 'This email is sent to the member each time a new subscription payment is made.', 'paid-memberships-pro' )
- ),
'membership_expired' => array(
'subject' => __( "Your membership at !!sitename!! has ended", 'paid-memberships-pro' ),
'description' => __('Membership Expired', 'paid-memberships-pro'),
@@ -328,49 +304,16 @@
Log in to your WordPress admin here: !!login_url!!
', 'paid-memberships-pro' ),
'help_text' => __( 'This email is sent to the admin as confirmation of a refunded payment. The email is sent after your membership site receives notification of a successful payment refund through your gateway.', 'paid-memberships-pro' )
),
- 'membership_recurring' => array(
- 'subject' => __( "Your membership at !!sitename!! will renew soon", 'paid-memberships-pro' ),
- 'description' => __('Recurring Payment Reminder', 'paid-memberships-pro'),
- 'body' => __( 'Thank you for your membership to !!sitename!!.
-
-This is just a reminder that your !!membership_level_name!! membership will automatically renew on !!renewaldate!!.
-
-Account: !!display_name!! (!!user_email!!)
-
-If for some reason you do not want to renew your membership you can cancel by clicking here: !!cancel_link!!
', 'paid-memberships-pro' ),
- 'help_text' => __( 'This email is sent when a subscription is approaching its renewal date. The additional placeholders !!renewaldate!! and !!billing_amount!! can be used to print the date that the subscription will renew and the renewal price.', 'paid-memberships-pro' )
- ),
);
-//we can hide the payment action required emails if default gateway isn't Stripe.
-$default_gateway = get_option( 'pmpro_gateway' );
-if( 'stripe' === $default_gateway ) {
- $pmpro_email_templates_defaults = array_merge( $pmpro_email_templates_defaults, array(
- 'payment_action' => array(
- 'subject' => __( "Payment action required for your !!sitename!! membership", 'paid-memberships-pro' ),
- 'description' => __('Payment Action Required', 'paid-memberships-pro' ),
- 'body' => __( 'Customer authentication is required to finish setting up your subscription at !!sitename!!.
-
-Please complete the verification steps issued by your payment provider at the following link:
-!!invoice_url!!
', 'paid-memberships-pro' ),
- 'help_text' => __( 'This email is sent to the user when an attempted membership checkout requires additional customer authentication.', 'paid-memberships-pro' )
- ),
- 'payment_action_admin' => array(
- 'subject' => __( "Payment action required: membership for !!user_login!! at !!sitename!!", 'paid-memberships-pro' ),
- 'description' => __('Payment Action Required (admin)', 'paid-memberships-pro'),
- 'body' => __( 'A payment at !!sitename!! for !!user_login!! requires additional customer authentication to complete.
-Below is a copy of the email we sent to !!user_email!! to notify them that they need to complete their payment:
-
-Customer authentication is required to finish setting up your subscription at !!sitename!!.
-
-Please complete the verification steps issued by your payment provider at the following link:
-!!invoice_url!!
', 'paid-memberships-pro' ),
- 'help_text' => __( 'This email is sent to the site administrator when an attempted membership checkout requires additional customer authentication.', 'paid-memberships-pro' )
- )
- ) );
-}
// Add any templates registered via the PMPro_Email_Template class.
$registered_templates = PMPro_Email_Template::get_all_email_templates();
+$default_gateway = get_option( 'pmpro_gateway' );
+// if gateway is not stripe, remove the payment action emails
+if( 'stripe' !== $default_gateway ) {
+ unset( $registered_templates['payment_action'] );
+ unset( $registered_templates['payment_action_admin'] );
+}
foreach ( $registered_templates as $registered_template_slug => $registered_template_class ) {
$pmpro_email_templates_defaults[ $registered_template_slug ] = array(
'subject' => $registered_template_class::get_default_subject(),
diff --git a/includes/email.php b/includes/email.php
index c716176a6..12054636d 100644
--- a/includes/email.php
+++ b/includes/email.php
@@ -296,6 +296,10 @@ function pmpro_email_templates_send_test() {
$test_user = $current_user;
+
+ //test subscription object
+ $test_subscription = new PMPro_Subscription( array( 'user_id' => $test_user->ID, 'membership_level_id' => $test_user->membership_level->id, 'next_payment_date' => date( 'Y-m-d', strtotime( '+1 month' ) ) ) );
+
// Grab the first membership level defined as a "test level" to use
$all_levels = pmpro_getAllLevels( true);
$test_user->membership_level = array_pop( $all_levels );
@@ -379,6 +383,10 @@ function pmpro_email_templates_send_test() {
$send_email = 'sendPaymentActionRequiredAdminEmail';
$params = array($test_user, $test_order, "http://www.example-notification-url.com/not-a-real-site");
break;
+ case 'membership_recurring':
+ $send_email = 'send_recurring_payment_reminder';
+ $params = array( $test_subscription );
+ break;
default:
$send_email = 'sendEmail';
$params = array();
diff --git a/paid-memberships-pro.php b/paid-memberships-pro.php
index fc919808d..95f52852f 100644
--- a/paid-memberships-pro.php
+++ b/paid-memberships-pro.php
@@ -55,6 +55,10 @@
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-cancel-admin.php' ); // cancel email template
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-admin-change.php' ); // change email template
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-admin-change-admin.php' ); // change email template
+require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-payment-action.php' ); // expiration email template
+require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-payment-action-admin.php' ); // expiration email template
+require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-payment-receipt.php' ); // invoice email template
+require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-payment-reminder.php' ); // recurring payment email reminder template
require_once( PMPRO_DIR . '/includes/filters.php' ); // filters, hacks, etc, moved into the plugin
require_once( PMPRO_DIR . '/includes/reports.php' ); // load reports for admin (reports may also include tracking code, etc)
diff --git a/scheduled/crons.php b/scheduled/crons.php
index ff3720787..a648dfda9 100644
--- a/scheduled/crons.php
+++ b/scheduled/crons.php
@@ -330,6 +330,13 @@ function pmpro_cron_recurring_payment_reminders() {
*/
$send_email = apply_filters( 'pmpro_send_recurring_payment_reminder_email', true, $subscription_obj, $days );
+ //if template is membership_recurring, use the new method, let pass otherwise.
+ if( $send_email && 'membership_recurring' == $template ) {
+ $send_emails = false;
+ $pmproemail = new PMProEmail();
+ $pmproemail->send_recurring_payment_reminder( $user, $subscription_obj->get_membership_level_id() );
+ }
+
/**
* @filter pmprorm_send_reminder_to_user
*
@@ -340,6 +347,7 @@ function pmpro_cron_recurring_payment_reminders() {
* @param MembershipOrder $lastorder - Deprecated. Now passing null.
*/
$send_emails = apply_filters_deprecated( 'pmprorm_send_reminder_to_user', array( $send_email, $user, null ), '3.2' );
+
if ( $send_emails ) {
// Get the level info.
From 5a5f813959abb9cffda3ec8411aa331ff94916cb Mon Sep 17 00:00:00 2001
From: maximilianoRicoTabo
Date: Mon, 11 Nov 2024 19:47:08 -0300
Subject: [PATCH 19/41] * Add billing info updated and billing info updated
admin classes
---
classes/class.pmproemail.php | 92 +-------
...il-template-billing-info-updated-admin.php | 212 ++++++++++++++++++
...ro-email-template-billing-info-updated.php | 209 +++++++++++++++++
includes/email-templates.php | 35 ---
paid-memberships-pro.php | 3 +
5 files changed, 428 insertions(+), 123 deletions(-)
create mode 100644 classes/email-templates/class-pmpro-email-template-billing-info-updated-admin.php
create mode 100644 classes/email-templates/class-pmpro-email-template-billing-info-updated.php
diff --git a/classes/class.pmproemail.php b/classes/class.pmproemail.php
index 8816f189c..0e0539fc5 100644
--- a/classes/class.pmproemail.php
+++ b/classes/class.pmproemail.php
@@ -825,50 +825,8 @@ function sendBillingEmail($user = NULL, $order = NULL)
return false;
}
- $membership_level = pmpro_getSpecificMembershipLevelForUser($user->ID, $order->membership_id);
-
- $this->email = $user->user_email;
- $this->subject = sprintf(__("Your billing information has been updated at %s", "paid-memberships-pro"), get_option("blogname"));
-
- $this->data = array(
- 'subject' => $this->subject,
- 'header_name' => $user->display_name,
- 'name' => $user->display_name,
- 'user_login' => $user->user_login,
- 'sitename' => get_option( 'blogname' ),
- 'siteemail' => get_option( 'pmpro_from_email' ),
- 'membership_id' => $membership_level->id,
- 'membership_level_name' => $membership_level->name,
- 'display_name' => $user->display_name,
- 'user_email' => $user->user_email,
- 'billing_name' => $order->billing->name,
- 'billing_street' => $order->billing->street,
- 'billing_street2' => $order->billing->street2,
- 'billing_city' => $order->billing->city,
- 'billing_state' => $order->billing->state,
- 'billing_zip' => $order->billing->zip,
- 'billing_country' => $order->billing->country,
- 'billing_phone' => $order->billing->phone,
- 'cardtype' => $order->cardtype,
- 'accountnumber' => hideCardNumber($order->accountnumber),
- 'expirationmonth' => $order->expirationmonth,
- 'expirationyear' => $order->expirationyear,
- 'login_link' => pmpro_login_url(),
- 'login_url' => pmpro_login_url(),
- 'levels_url' => pmpro_url( 'levels' )
- );
- $this->data["billing_address"] = pmpro_formatAddress($order->billing->name,
- $order->billing->street,
- $order->billing->street2,
- $order->billing->city,
- $order->billing->state,
- $order->billing->zip,
- $order->billing->country,
- $order->billing->phone);
-
- $this->template = apply_filters( "pmpro_email_template", "billing", $this );
-
- return $this->sendEmail();
+ $email = new PMPro_Email_Template_Billing_Info_Updated( $user, $order );
+ $email->send();
}
/**
@@ -890,50 +848,8 @@ function sendBillingAdminEmail($user = NULL, $order = NULL)
return false;
}
- $membership_level = pmpro_getSpecificMembershipLevelForUser($user->ID, $order->membership_id);
-
- $this->email = get_bloginfo("admin_email");
- $this->subject = sprintf(__("Billing information has been updated for %s at %s", "paid-memberships-pro"), $user->user_login, get_option("blogname"));
-
- $this->data = array(
- 'subject' => $this->subject,
- 'header_name' => $this->get_admin_name( $this->email ),
- 'name' => $user->display_name,
- 'user_login' => $user->user_login,
- 'sitename' => get_option( 'blogname' ),
- 'siteemail' => get_option( 'pmpro_from_email' ),
- 'membership_id' => $membership_level->id,
- 'membership_level_name' => $membership_level->name,
- 'display_name' => $user->display_name,
- 'user_email' => $user->user_email,
- 'billing_name' => $order->billing->name,
- 'billing_street' => $order->billing->street,
- 'billing_street2' => $order->billing->street2,
- 'billing_city' => $order->billing->city,
- 'billing_state' => $order->billing->state,
- 'billing_zip' => $order->billing->zip,
- 'billing_country' => $order->billing->country,
- 'billing_phone' => $order->billing->phone,
- 'cardtype' => $order->cardtype,
- 'accountnumber' => hideCardNumber($order->accountnumber),
- 'expirationmonth' => $order->expirationmonth,
- 'expirationyear' => $order->expirationyear,
- 'login_link' => pmpro_login_url(),
- 'login_url' => pmpro_login_url(),
- 'levels_url' => pmpro_url( 'levels' )
- );
- $this->data["billing_address"] = pmpro_formatAddress($order->billing->name,
- $order->billing->street,
- $order->billing->street2,
- $order->billing->city,
- $order->billing->state,
- $order->billing->zip,
- $order->billing->country,
- $order->billing->phone);
-
- $this->template = apply_filters( "pmpro_email_template", "billing_admin", $this );
-
- return $this->sendEmail();
+ $email = new PMPro_Email_Template_Billing_Info_Updated_Admin( $user, $order );
+ $email->send();
}
/**
diff --git a/classes/email-templates/class-pmpro-email-template-billing-info-updated-admin.php b/classes/email-templates/class-pmpro-email-template-billing-info-updated-admin.php
new file mode 100644
index 000000000..c1c02959c
--- /dev/null
+++ b/classes/email-templates/class-pmpro-email-template-billing-info-updated-admin.php
@@ -0,0 +1,212 @@
+user = $user;
+ $this->order = $order;
+ }
+
+ /**
+ * Get the email template slug.
+ *
+ * @since TBD
+ *
+ * @return string The email template slug.
+ */
+ public static function get_template_slug() {
+ return 'billing_admin';
+ }
+
+ /**
+ * Get the "nice name" of the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "nice name" of the email template.
+ */
+ public static function get_template_name() {
+ return __( 'Billing Information Updated (admin)', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get "help text" to display to the admin when editing the email template.
+ *
+ * @since TBD
+ *
+ * @return string The help text.
+ */
+ public static function get_template_description() {
+ return __( 'Members can update the payment method associated with their recurring subscription. This email is sent to the site administrator as a confirmation of a payment method update.', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the default subject for the email.
+ *
+ * @since TBD
+ *
+ * @return string The default subject for the email.
+ */
+ public static function get_default_subject() {
+ return __( 'Billing information has been updated for !!user_login!! at !!sitename!!', 'paid-memberships-pro' );
+ }
+
+ public static function get_default_body() {
+ return __( 'The billing information for !!display_name!! at !!sitename!! has been changed.
+Account: !!display_name!! (!!user_email!!)
+
+ Billing Information:
+ !!billing_name!!
+ !!billing_street!!
+ !!billing_city!!, !!billing_state!! !!billing_zip!! !!billing_country!!
+ !!billing_phone!!
+
+
+
+ !!cardtype!!: !!accountnumber!!
+ Expires: !!expirationmonth!!/!!expirationyear!!
+
+
+Log in to your WordPress dashboard here: !!login_url!!
', 'paid-memberships-pro' );
+
+ }
+
+ /**
+ * Get the email template variables for the email paired with a description of the variable.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public static function get_email_template_variables_with_description() {
+ $base_email_template_variables_with_description = array(
+ '!!name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
+ '!!membership_id!!' => __( 'The ID of the membership level.', 'paid-memberships-pro' ),
+ '!!membership_level_name!!' => __( 'The name of the membership level.', 'paid-memberships-pro' ),
+ '!!user_login!!' => __( 'The username of the user.', 'paid-memberships-pro' ),
+ '!!user_email!!' => __( 'The email address of the user.', 'paid-memberships-pro' ),
+ '!!display_name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
+ '!!subject!!' => __( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
+ '!!billing_address!!' => __( 'Billing Info Complete Address', 'paid-memberships-pro' ),
+ '!!billing_name!!' => __( 'The billing name of the user.', 'paid-memberships-pro' ),
+ '!!billing_street!!' => __( 'The billing street address of the user.', 'paid-memberships-pro' ),
+ '!!billing_street2!!' => __( 'The second billing street field address of the user.', 'paid-memberships-pro' ),
+ '!!billing_city!!' => __( 'The billing city of the user.', 'paid-memberships-pro' ),
+ '!!billing_state!!' => __( 'The billing state of the user.', 'paid-memberships-pro' ),
+ '!!billing_zip!!' => __( 'The billing ZIP code of the user.', 'paid-memberships-pro' ),
+ '!!billing_country!!' => __( 'The billing country of the user.', 'paid-memberships-pro' ),
+ '!!billing_phone!!' => __( 'The billing phone number of the user.', 'paid-memberships-pro' ),
+ '!!cardtype!!' => __( 'The type of credit card used.', 'paid-memberships-pro' ),
+ '!!accountnumber!!' => __( 'The last four digits of the credit card number.', 'paid-memberships-pro' ),
+ '!!expirationmonth!!' => __( 'The expiration month of the credit card.', 'paid-memberships-pro' ),
+ '!!expirationyear!!' => __( 'The expiration year of the credit card.', 'paid-memberships-pro' ),
+ );
+
+ return $base_email_template_variables_with_description;
+ }
+
+ /**
+ * Get the email address to send the email to.
+ *
+ * @since TBD
+ *
+ * @return string The email address to send the email to.
+ */
+ public function get_recipient_email() {
+ return get_bloginfo( 'admin_email' );
+ }
+
+ /**
+ * Get the name of the email recipient.
+ *
+ * @since TBD
+ *
+ * @return string The name of the email recipient.
+ */
+ public function get_recipient_name() {
+ //get user by email
+ $user = get_user_by( 'email', $this->get_recipient_email() );
+ return $user->display_name;
+ }
+
+
+ /**
+ * Get the email template variables for the email.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public function get_email_template_variables() {
+ $order = $this->order;
+ $membership_level = pmpro_getLevel( $order->membership_id );
+ $user = $this->user;
+ $email_template_variables = array(
+ 'name' => $user->display_name,
+ 'membership_id' => $membership_level->id,
+ 'membership_level_name' => $membership_level->name,
+ 'user_login' => $user->user_login,
+ 'subject' => $this->get_default_subject(),
+ 'user_email' => $user->user_email,
+ 'display_name' => $this->get_recipient_name(),
+ 'billing_name' => $order->billing->name,
+ 'billing_street' => $order->billing->street,
+ 'billing_street2' => $order->billing->street2,
+ 'billing_city' => $order->billing->city,
+ 'billing_state' => $order->billing->state,
+ 'billing_zip' => $order->billing->zip,
+ 'billing_country' => $order->billing->country,
+ 'billing_phone' => $order->billing->phone,
+ 'billing_address' => pmpro_formatAddress( $order->billing->name,
+ $order->billing->street,
+ $order->billing->street2,
+ $order->billing->city,
+ $order->billing->state,
+ $order->billing->zip,
+ $order->billing->country,
+ $order->billing->phone ),
+ 'cardtype' => $order->cardtype,
+ 'accountnumber' => hideCardNumber( $order->accountnumber ),
+ 'expirationmonth' => $order->expirationmonth,
+ 'expirationyear' => $order->expirationyear,
+ );
+ return $email_template_variables;
+ }
+}
+
+/**
+ * Register the email template.
+ *
+ * @since TBD
+ *
+ * @param array $email_templates The email templates (template slug => email template class name)
+ * @return array The modified email templates array.
+ */
+function pmpro_email_templates_billing_info_updated_admin( $email_templates ) {
+ $email_templates['billing_admin'] = 'PMPro_Email_Template_Billing_Info_Updated_Admin';
+
+ return $email_templates;
+}
+add_filter( 'pmpro_email_templates', 'pmpro_email_templates_billing_info_updated_admin' );
\ No newline at end of file
diff --git a/classes/email-templates/class-pmpro-email-template-billing-info-updated.php b/classes/email-templates/class-pmpro-email-template-billing-info-updated.php
new file mode 100644
index 000000000..95d4740cc
--- /dev/null
+++ b/classes/email-templates/class-pmpro-email-template-billing-info-updated.php
@@ -0,0 +1,209 @@
+user = $user;
+ $this->order = $order;
+ }
+
+ /**
+ * Get the email template slug.
+ *
+ * @since TBD
+ *
+ * @return string The email template slug.
+ */
+ public static function get_template_slug() {
+ return 'billing';
+ }
+
+ /**
+ * Get the "nice name" of the email template.
+ *
+ * @since TBD
+ *
+ * @return string The "nice name" of the email template.
+ */
+ public static function get_template_name() {
+ return __( 'Billing Information Updated', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get "help text" to display to the admin when editing the email template.
+ *
+ * @since TBD
+ *
+ * @return string The help text.
+ */
+ public static function get_template_description() {
+ return __( 'Members can update the payment method associated with their recurring subscription. This email is sent to the member as a confirmation of a payment method update', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the default subject for the email.
+ *
+ * @since TBD
+ *
+ * @return string The default subject for the email.
+ */
+ public static function get_default_subject() {
+ return __( 'Your billing information has been updated at !!sitename!!', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the default body content for the email.
+ *
+ * @since TBD
+ *
+ * @return string The default body content for the email.
+ */
+ public static function get_default_body() {
+ return __( 'Your billing information at !!sitename!! has been changed.
Account: !!display_name!! (!!user_email!!)
+
+ Billing Information:
+ !!billing_address!!
+
+
+ !!cardtype!!: !!accountnumber!!
+ Expires: !!expirationmonth!!/!!expirationyear!!
+
+ If you did not request a billing information change please contact us at !!siteemail!!
+ Log in to your membership account here: !!login_url!!
', 'paid-memberships-pro' );
+ }
+
+ /**
+ * Get the email template variables for the email paired with a description of the variable.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public static function get_email_template_variables_with_description() {
+ return array(
+ '!!subject!!' => __( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
+ '!!user_email!!' => __( 'The email address of the user who cancelled their membership.', 'paid-memberships-pro' ),
+ '!!display_name!!' => __( 'The display name of the user who cancelled their membership.', 'paid-memberships-pro' ),
+ '!!name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
+ '!!user_login!!' => __( 'The username of the user.', 'paid-memberships-pro' ),
+ '!!membership_id!!' => __( 'The ID of the membership level.', 'paid-memberships-pro' ),
+ '!!membership_level_name!!' => __( 'The name of the membership level.', 'paid-memberships-pro' ),
+ '!!billing_name!!' => __( 'Billing Info Name', 'paid-memberships-pro' ),
+ '!!billing_street!!' => __( 'Billing Info Street', 'paid-memberships-pro' ),
+ '!!billing_street2!!' => __( 'Billing Info Street 2', 'paid-memberships-pro' ),
+ '!!billing_city!!' => __( 'Billing Info City', 'paid-memberships-pro' ),
+ '!!billing_state!!' => __( 'Billing Info State', 'paid-memberships-pro' ),
+ '!!billing_zip!!' => __( 'Billing Info Zip', 'paid-memberships-pro' ),
+ '!!billing_country!!' => __( 'Billing Info Country', 'paid-memberships-pro' ),
+ '!!billing_phone!!' => __( 'Billing Info Phone', 'paid-memberships-pro' ),
+ '!!billing_address!!' => __( 'Billing Info Complete Address', 'paid-memberships-pro' ),
+ '!!cardtype!!' => __( 'Credit Card Type', 'paid-memberships-pro' ),
+ '!!accountnumber!!' => __( 'Credit Card Number (last 4 digits)', 'paid-memberships-pro' ),
+ '!!expirationmonth!!' => __( 'Credit Card Expiration Month (mm format)', 'paid-memberships-pro' ),
+ '!!expirationyear!!' => __( 'Credit Card Expiration Year (yyyy format)', 'paid-memberships-pro' ),
+ );
+ }
+
+ /**
+ * Get the email address to send the email to.
+ *
+ * @since TBD
+ *
+ * @return string The email address to send the email to.
+ */
+ public function get_recipient_email() {
+ return $this->user->user_email;
+ }
+
+ /**
+ * Get the name of the email recipient.
+ *
+ * @since TBD
+ *
+ * @return string The name of the email recipient.
+ */
+ public function get_recipient_name() {
+ return $this->user->display_name;
+ }
+
+ /**
+ * Get the email template variables for the email.
+ *
+ * @since TBD
+ *
+ * @return array The email template variables for the email (key => value pairs).
+ */
+ public function get_email_template_variables() {
+ $order = $this->order;
+ $user = $this->user;
+ $membership_level = pmpro_getLevel( $order->membership_id );
+ $email_template_variables = array(
+ 'subject' => $this->get_default_subject(),
+ 'name'=> $this->get_recipient_name(),
+ 'user_login' => $user->user_login,
+ 'membership_id' => $membership_level->id,
+ 'membership_level_name' => $membership_level->name,
+ 'user_email' => $user->user_email,
+ 'display_name' => $this->get_recipient_name(),
+ 'billing_name' => $order->billing->name,
+ 'billing_street' => $order->billing->street,
+ 'billing_street2' => $order->billing->street2,
+ 'billing_city' => $order->billing->city,
+ 'billing_state' => $order->billing->state,
+ 'billing_zip' => $order->billing->zip,
+ 'billing_country' => $order->billing->country,
+ 'billing_phone' => $order->billing->phone,
+ 'billing_address' => pmpro_formatAddress( $order->billing->name,
+ $order->billing->street,
+ $order->billing->street2,
+ $order->billing->city,
+ $order->billing->state,
+ $order->billing->zip,
+ $order->billing->country,
+ $order->billing->phone ),
+ 'cardtype' => $order->cardtype,
+ 'accountnumber' => hideCardNumber( $order->accountnumber ),
+ 'expirationmonth' => $order->expirationmonth,
+ 'expirationyear' => $order->expirationyear,
+ );
+ return $email_template_variables;
+ }
+
+}
+
+/**
+ * Register the email template.
+ *
+ * @since TBD
+ *
+ * @param array $email_templates The email templates (template slug => email template class name)
+ * @return array The modified email templates array.
+ */
+function pmpro_email_templates_billing_info_updated( $email_templates ) {
+ $email_templates['billing'] = 'PMPro_Email_Template_Billing_Info_Updated';
+
+ return $email_templates;
+}
+add_filter( 'pmpro_email_templates', 'pmpro_email_templates_billing_info_updated' );
\ No newline at end of file
diff --git a/includes/email-templates.php b/includes/email-templates.php
index e0d2734a2..022d0deb5 100644
--- a/includes/email-templates.php
+++ b/includes/email-templates.php
@@ -25,41 +25,6 @@
'body' => __( 'Dear !!header_name!!,
', 'paid-memberships-pro' ),
'help_text' => __( 'This is the opening message included in every email sent to members and the site administrator through Paid Memberships Pro.', 'paid-memberships-pro' )
),
- 'billing' => array(
- 'subject' => __( "Your billing information has been updated at !!sitename!!", 'paid-memberships-pro' ),
- 'description' => __('Billing Information Updated', 'paid-memberships-pro'),
- 'body' => __( 'Your billing information at !!sitename!! has been changed.
Account: !!display_name!! (!!user_email!!)
-
- Billing Information:
- !!billing_address!!
-
- !!cardtype!!: !!accountnumber!!
- Expires: !!expirationmonth!!/!!expirationyear!!
-
If you did not request a billing information change please contact us at !!siteemail!!
Log in to your membership account here: !!login_url!!
', 'paid-memberships-pro' ),
- 'help_text' => __( 'Members can update the payment method associated with their recurring subscription. This email is sent to the member as a confirmation of a payment method update.', 'paid-memberships-pro' )
- ),
- 'billing_admin' => array(
- 'subject' => __( "Billing information has been updated for !!user_login!! at !!sitename!!", 'paid-memberships-pro' ),
- 'description' => __('Billing Information Updated (admin)', 'paid-memberships-pro'),
- 'body' => __( 'The billing information for !!display_name!! at !!sitename!! has been changed.
-
-Account: !!display_name!! (!!user_email!!)
-
- Billing Information:
- !!billing_name!!
- !!billing_street!!
- !!billing_city!!, !!billing_state!! !!billing_zip!! !!billing_country!!
- !!billing_phone!!
-
-
-
- !!cardtype!!: !!accountnumber!!
- Expires: !!expirationmonth!!/!!expirationyear!!
-
-
-Log in to your WordPress dashboard here: !!login_url!!
', 'paid-memberships-pro' ),
- 'help_text' => __( 'Members can update the payment method associated with their recurring subscription. This email is sent to the site administrator as a confirmation of a payment method update.', 'paid-memberships-pro' )
- ),
'billing_failure' => array(
'subject' => __( "Membership payment failed at !!sitename!!", 'paid-memberships-pro' ),
'description' => __( 'Payment Failure', 'paid-memberships-pro' ),
diff --git a/paid-memberships-pro.php b/paid-memberships-pro.php
index fc919808d..2edf8b206 100644
--- a/paid-memberships-pro.php
+++ b/paid-memberships-pro.php
@@ -55,6 +55,9 @@
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-cancel-admin.php' ); // cancel email template
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-admin-change.php' ); // change email template
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-admin-change-admin.php' ); // change email template
+require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-billing-info-updated.php' ); // update billing email template
+require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-billing-info-updated-admin.php' ); // update billing admin email template
+
require_once( PMPRO_DIR . '/includes/filters.php' ); // filters, hacks, etc, moved into the plugin
require_once( PMPRO_DIR . '/includes/reports.php' ); // load reports for admin (reports may also include tracking code, etc)
From a5906d7edfe9bc93283aff887f2f08cd10b8fe37 Mon Sep 17 00:00:00 2001
From: maximilianoRicoTabo
Date: Fri, 13 Dec 2024 15:17:52 -0300
Subject: [PATCH 20/41] * Rename billing info updated and billing info updated
admin classes and its references
---
classes/class.pmproemail.php | 4 ++--
...n.php => class-pmpro-email-template-billing-admin.php} | 8 ++++----
...updated.php => class-pmpro-email-template-billing.php} | 8 ++++----
paid-memberships-pro.php | 4 ++--
4 files changed, 12 insertions(+), 12 deletions(-)
rename classes/email-templates/{class-pmpro-email-template-billing-info-updated-admin.php => class-pmpro-email-template-billing-admin.php} (97%)
rename classes/email-templates/{class-pmpro-email-template-billing-info-updated.php => class-pmpro-email-template-billing.php} (96%)
diff --git a/classes/class.pmproemail.php b/classes/class.pmproemail.php
index 0e0539fc5..8d244e726 100644
--- a/classes/class.pmproemail.php
+++ b/classes/class.pmproemail.php
@@ -825,7 +825,7 @@ function sendBillingEmail($user = NULL, $order = NULL)
return false;
}
- $email = new PMPro_Email_Template_Billing_Info_Updated( $user, $order );
+ $email = new PMPro_Email_Template_Billing( $user, $order );
$email->send();
}
@@ -848,7 +848,7 @@ function sendBillingAdminEmail($user = NULL, $order = NULL)
return false;
}
- $email = new PMPro_Email_Template_Billing_Info_Updated_Admin( $user, $order );
+ $email = new PMPro_Email_Template_Billing_Admin( $user, $order );
$email->send();
}
diff --git a/classes/email-templates/class-pmpro-email-template-billing-info-updated-admin.php b/classes/email-templates/class-pmpro-email-template-billing-admin.php
similarity index 97%
rename from classes/email-templates/class-pmpro-email-template-billing-info-updated-admin.php
rename to classes/email-templates/class-pmpro-email-template-billing-admin.php
index c1c02959c..13c44b539 100644
--- a/classes/email-templates/class-pmpro-email-template-billing-info-updated-admin.php
+++ b/classes/email-templates/class-pmpro-email-template-billing-admin.php
@@ -1,6 +1,6 @@
email template class name)
* @return array The modified email templates array.
*/
-function pmpro_email_templates_billing_info_updated_admin( $email_templates ) {
- $email_templates['billing_admin'] = 'PMPro_Email_Template_Billing_Info_Updated_Admin';
+function pmpro_email_templates_billing_admin( $email_templates ) {
+ $email_templates['billing_admin'] = 'PMPro_Email_Template_Billing_Admin';
return $email_templates;
}
-add_filter( 'pmpro_email_templates', 'pmpro_email_templates_billing_info_updated_admin' );
\ No newline at end of file
+add_filter( 'pmpro_email_templates', 'pmpro_email_templates_billing_admin' );
\ No newline at end of file
diff --git a/classes/email-templates/class-pmpro-email-template-billing-info-updated.php b/classes/email-templates/class-pmpro-email-template-billing.php
similarity index 96%
rename from classes/email-templates/class-pmpro-email-template-billing-info-updated.php
rename to classes/email-templates/class-pmpro-email-template-billing.php
index 95d4740cc..93d1dafbf 100644
--- a/classes/email-templates/class-pmpro-email-template-billing-info-updated.php
+++ b/classes/email-templates/class-pmpro-email-template-billing.php
@@ -1,6 +1,6 @@
email template class name)
* @return array The modified email templates array.
*/
-function pmpro_email_templates_billing_info_updated( $email_templates ) {
- $email_templates['billing'] = 'PMPro_Email_Template_Billing_Info_Updated';
+function pmpro_email_templates_billing( $email_templates ) {
+ $email_templates['billing'] = 'PMPro_Email_Template_Billing';
return $email_templates;
}
-add_filter( 'pmpro_email_templates', 'pmpro_email_templates_billing_info_updated' );
\ No newline at end of file
+add_filter( 'pmpro_email_templates', 'pmpro_email_templates_billing' );
\ No newline at end of file
diff --git a/paid-memberships-pro.php b/paid-memberships-pro.php
index 2edf8b206..a0ea0912a 100644
--- a/paid-memberships-pro.php
+++ b/paid-memberships-pro.php
@@ -55,8 +55,8 @@
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-cancel-admin.php' ); // cancel email template
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-admin-change.php' ); // change email template
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-admin-change-admin.php' ); // change email template
-require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-billing-info-updated.php' ); // update billing email template
-require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-billing-info-updated-admin.php' ); // update billing admin email template
+require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-billing.php' ); // update billing email template
+require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-billing-admin.php' ); // update billing admin email template
require_once( PMPRO_DIR . '/includes/filters.php' ); // filters, hacks, etc, moved into the plugin
require_once( PMPRO_DIR . '/includes/reports.php' ); // load reports for admin (reports may also include tracking code, etc)
From fccf2f851c061d96714453448191d288260d6667 Mon Sep 17 00:00:00 2001
From: maximilianoRicoTabo
Date: Fri, 13 Dec 2024 15:21:37 -0300
Subject: [PATCH 21/41] * Remove header_name variable from children class as
it's already present in the abstract Email Template Class.
---
.../class-pmpro-email-template-billing-failure-admin.php | 2 --
.../class-pmpro-email-template-billing-failure.php | 2 --
2 files changed, 4 deletions(-)
diff --git a/classes/email-templates/class-pmpro-email-template-billing-failure-admin.php b/classes/email-templates/class-pmpro-email-template-billing-failure-admin.php
index a9babdcf7..fccc9217d 100644
--- a/classes/email-templates/class-pmpro-email-template-billing-failure-admin.php
+++ b/classes/email-templates/class-pmpro-email-template-billing-failure-admin.php
@@ -122,7 +122,6 @@ public function get_recipient_name() {
public static function get_email_template_variables_with_description() {
return array(
'!!subject!!' => __( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
- '!!header_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
'!!name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
'!!user_login!!' => __( 'The username of the user.', 'paid-memberships-pro' ),
'!!user_email!!' => __( 'The email address of the user billing failed', 'paid-memberships-pro' ),
@@ -159,7 +158,6 @@ public function get_email_template_variables() {
$membership_level = pmpro_getLevel( $order->membership_id );
return array(
'subject' => $this->get_default_subject(),
- 'header_name' => $user->display_name,
'name' => $user->display_name,
'user_login' => $user->user_login,
'membership_id' => $membership_level->id,
diff --git a/classes/email-templates/class-pmpro-email-template-billing-failure.php b/classes/email-templates/class-pmpro-email-template-billing-failure.php
index 9ae2a9ad1..c0c8f941e 100644
--- a/classes/email-templates/class-pmpro-email-template-billing-failure.php
+++ b/classes/email-templates/class-pmpro-email-template-billing-failure.php
@@ -117,7 +117,6 @@ public function get_recipient_name() {
public static function get_email_template_variables_with_description() {
return array(
'!!subject!!' => __( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
- '!!header_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
'!!name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
'!!user_login!!' => __( 'The username of the user.', 'paid-memberships-pro' ),
'!!user_email!!' => __( 'The email address of the user billing failed', 'paid-memberships-pro' ),
@@ -154,7 +153,6 @@ public function get_email_template_variables() {
$membership_level = pmpro_getLevel( $order->membership_id );
return array(
'subject' => $this->get_default_subject(),
- 'header_name' => $user->display_name,
'name' => $user->display_name,
'user_login' => $user->user_login,
'membership_id' => $membership_level->id,
From 7b7ec9ad8a55a2b689b939144eda02c7fd3306db Mon Sep 17 00:00:00 2001
From: maximilianoRicoTabo
Date: Tue, 17 Dec 2024 10:28:23 -0300
Subject: [PATCH 22/41] [BUGFIXING] Send Invoice email from edit order page
takes the wrong user * Compare param user with order user and use the one
from the order if they don't match.
---
.../class-pmpro-email-template-payment-receipt.php | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/classes/email-templates/class-pmpro-email-template-payment-receipt.php b/classes/email-templates/class-pmpro-email-template-payment-receipt.php
index 4350824d7..62e5112af 100644
--- a/classes/email-templates/class-pmpro-email-template-payment-receipt.php
+++ b/classes/email-templates/class-pmpro-email-template-payment-receipt.php
@@ -179,6 +179,10 @@ public function get_email_template_variables() {
global $wpdb;
$user = $this->user;
$order = $this->order;
+ //If user is not the same one from order, let's get the user from order to fill the email
+ if( $order->user_id != $user->ID ) {
+ $user = get_userdata( $order->user_id );
+ }
$membership_level = pmpro_getLevel( $order->membership_id );
//Get discount code if it exists
@@ -199,9 +203,9 @@ public function get_email_template_variables() {
$email_template_variables = array(
'subject' => $this->get_default_subject(),
- 'header_name' => $this->get_recipient_name(),
- 'name' => $this->get_recipient_name(),
- 'display_name' => $this->get_recipient_name(),
+ 'header_name' => $user->display_name,
+ 'name' => $user->display_name,
+ 'display_name' => $user->display_name,
'user_login' => $user->user_login,
'membership_id' => $membership_level->id,
'membership_level_name' => $membership_level->name,
From 33804e4392c8b32f18cdf98031ffb039c939a489 Mon Sep 17 00:00:00 2001
From: maximilianoRicoTabo
Date: Tue, 17 Dec 2024 15:55:29 -0300
Subject: [PATCH 23/41] * Remove unnecesary header_name from templates
---
.../class-pmpro-email-template-admin-checkout-check-admin.php | 2 --
.../class-pmpro-email-template-admin-checkout-check.php | 2 --
.../class-pmpro-email-template-checkout-free-admin.php | 2 --
.../class-pmpro-email-template-checkout-free.php | 2 --
.../class-pmpro-email-template-checkout-paid-admin.php | 2 --
.../class-pmpro-email-template-checkout-paid.php | 2 --
6 files changed, 12 deletions(-)
diff --git a/classes/email-templates/class-pmpro-email-template-admin-checkout-check-admin.php b/classes/email-templates/class-pmpro-email-template-admin-checkout-check-admin.php
index 7117d8306..e98936767 100644
--- a/classes/email-templates/class-pmpro-email-template-admin-checkout-check-admin.php
+++ b/classes/email-templates/class-pmpro-email-template-admin-checkout-check-admin.php
@@ -161,7 +161,6 @@ public function get_email_template_variables() {
$email_template_variables = array(
'subject' => $this->get_default_subject(),
- 'header_name' => $this->get_recipient_name(),
'name' => $this->get_recipient_name(),
'display_name' => $this->get_recipient_name(),
'user_login' => $user->user_login,
@@ -211,7 +210,6 @@ public static function get_email_template_variables_with_description() {
return array(
'!!subject!!' => __( 'The subject of the email.', 'paid-memberships-pro' ),
- '!!header_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
'!!name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
'!!display_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
'!!user_login!!' => __( 'The login name of the email recipient.', 'paid-memberships-pro' ),
diff --git a/classes/email-templates/class-pmpro-email-template-admin-checkout-check.php b/classes/email-templates/class-pmpro-email-template-admin-checkout-check.php
index 5d470b01e..d9f61e27f 100644
--- a/classes/email-templates/class-pmpro-email-template-admin-checkout-check.php
+++ b/classes/email-templates/class-pmpro-email-template-admin-checkout-check.php
@@ -135,7 +135,6 @@ public static function get_email_template_variables_with_description() {
return array(
'!!subject!!' => __( 'The subject of the email.', 'paid-memberships-pro' ),
- '!!header_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
'!!name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
'!!display_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
'!!user_login!!' => __( 'The login name of the email recipient.', 'paid-memberships-pro' ),
@@ -173,7 +172,6 @@ public function get_email_template_variables() {
$email_template_variables = array(
'subject' => $this->get_default_subject(),
- 'header_name' => $this->get_recipient_name(),
'name' => $this->get_recipient_name(),
'display_name' => $this->get_recipient_name(),
'user_login' => $user->user_login,
diff --git a/classes/email-templates/class-pmpro-email-template-checkout-free-admin.php b/classes/email-templates/class-pmpro-email-template-checkout-free-admin.php
index f4f310472..b9f02d185 100644
--- a/classes/email-templates/class-pmpro-email-template-checkout-free-admin.php
+++ b/classes/email-templates/class-pmpro-email-template-checkout-free-admin.php
@@ -129,7 +129,6 @@ public static function get_email_template_variables_with_description() {
return array(
'!!subject!!' => __( 'The subject of the email.', 'paid-memberships-pro' ),
- '!!header_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
'!!name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
'!!display_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
'!!user_login!!' => __( 'The login name of the email recipient.', 'paid-memberships-pro' ),
@@ -176,7 +175,6 @@ public function get_email_template_variables() {
$email_template_variables = array(
'subject' => $this->get_default_subject(),
- 'header_name' => $this->get_recipient_name(),
'name' => $this->get_recipient_name(),
'display_name' => $this->get_recipient_name(),
'user_login' => $user->user_login,
diff --git a/classes/email-templates/class-pmpro-email-template-checkout-free.php b/classes/email-templates/class-pmpro-email-template-checkout-free.php
index 530f63c51..cc2ffd7bb 100644
--- a/classes/email-templates/class-pmpro-email-template-checkout-free.php
+++ b/classes/email-templates/class-pmpro-email-template-checkout-free.php
@@ -123,7 +123,6 @@ public static function get_email_template_variables_with_description() {
return array(
'!!subject!!' => __( 'The subject of the email.', 'paid-memberships-pro' ),
- '!!header_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
'!!name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
'!!display_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
'!!user_login!!' => __( 'The login name of the email recipient.', 'paid-memberships-pro' ),
@@ -170,7 +169,6 @@ public function get_email_template_variables() {
$email_template_variables = array(
'subject' => $this->get_default_subject(),
- 'header_name' => $this->get_recipient_name(),
'name' => $this->get_recipient_name(),
'display_name' => $this->get_recipient_name(),
'user_login' => $user->user_login,
diff --git a/classes/email-templates/class-pmpro-email-template-checkout-paid-admin.php b/classes/email-templates/class-pmpro-email-template-checkout-paid-admin.php
index b0d2676ce..56e11380c 100644
--- a/classes/email-templates/class-pmpro-email-template-checkout-paid-admin.php
+++ b/classes/email-templates/class-pmpro-email-template-checkout-paid-admin.php
@@ -162,7 +162,6 @@ public function get_email_template_variables() {
$email_template_variables = array(
'subject' => $this->get_default_subject(),
- 'header_name' => $this->get_recipient_name(),
'name' => $this->get_recipient_name(),
'display_name' => $this->get_recipient_name(),
'user_login' => $user->user_login,
@@ -214,7 +213,6 @@ public static function get_email_template_variables_with_description() {
return array(
'!!subject!!' => __( 'The subject of the email.', 'paid-memberships-pro' ),
- '!!header_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
'!!name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
'!!display_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
'!!user_login!!' => __( 'The login name of the email recipient.', 'paid-memberships-pro' ),
diff --git a/classes/email-templates/class-pmpro-email-template-checkout-paid.php b/classes/email-templates/class-pmpro-email-template-checkout-paid.php
index d25d39c7f..f9362efda 100644
--- a/classes/email-templates/class-pmpro-email-template-checkout-paid.php
+++ b/classes/email-templates/class-pmpro-email-template-checkout-paid.php
@@ -166,7 +166,6 @@ public function get_email_template_variables() {
$email_template_variables = array(
'subject' => $this->get_default_subject(),
- 'header_name' => $this->get_recipient_name(),
'name' => $this->get_recipient_name(),
'display_name' => $this->get_recipient_name(),
'user_login' => $user->user_login,
@@ -218,7 +217,6 @@ public static function get_email_template_variables_with_description() {
return array(
'!!subject!!' => __( 'The subject of the email.', 'paid-memberships-pro' ),
- '!!header_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
'!!name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
'!!display_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
'!!user_login!!' => __( 'The login name of the email recipient.', 'paid-memberships-pro' ),
From e13b0c7cb43a40759f4a231585491aeb46563252 Mon Sep 17 00:00:00 2001
From: maximilianoRicoTabo
Date: Tue, 17 Dec 2024 16:03:43 -0300
Subject: [PATCH 24/41] * Remove unnecesary header_name variable from child
template
---
.../class-pmpro-email-template-credit-card-expiring.php | 2 --
1 file changed, 2 deletions(-)
diff --git a/classes/email-templates/class-pmpro-email-template-credit-card-expiring.php b/classes/email-templates/class-pmpro-email-template-credit-card-expiring.php
index a9727c979..5e4e2ec8e 100644
--- a/classes/email-templates/class-pmpro-email-template-credit-card-expiring.php
+++ b/classes/email-templates/class-pmpro-email-template-credit-card-expiring.php
@@ -126,7 +126,6 @@ public function get_recipient_name() {
public static function get_email_template_variables_with_description() {
return array(
'!!subject!!' => __( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
- '!!header_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
'!!name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
'!!membership_id!!' => __( 'The ID of the membership level.', 'paid-memberships-pro' ),
'!!membership_level_name!!' => __( 'The name of the membership level.', 'paid-memberships-pro' ),
@@ -163,7 +162,6 @@ public function get_email_template_variables() {
return array(
'subject' => $this->subject,
- 'header_name' => $user->display_name,
'name' => $user->display_name,
'user_login' => $user->user_login,
'sitename' => get_option( 'blogname' ),
From 3194a47906cd4f5e31f80cb8198b0592290b0078 Mon Sep 17 00:00:00 2001
From: maximilianoRicoTabo
Date: Tue, 17 Dec 2024 16:09:07 -0300
Subject: [PATCH 25/41] * Remove unnecesary variable header_name from child
template
---
.../class-pmpro-email-template-membership-expiring.php | 2 --
1 file changed, 2 deletions(-)
diff --git a/classes/email-templates/class-pmpro-email-template-membership-expiring.php b/classes/email-templates/class-pmpro-email-template-membership-expiring.php
index cc729466e..741fa8abe 100644
--- a/classes/email-templates/class-pmpro-email-template-membership-expiring.php
+++ b/classes/email-templates/class-pmpro-email-template-membership-expiring.php
@@ -121,7 +121,6 @@ public function get_recipient_name() {
public static function get_email_template_variables_with_description() {
return array(
'!!subject!!' => __( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
- '!!header_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
'!!name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
'!!membership_id!!' => __( 'The ID of the membership level.', 'paid-memberships-pro' ),
'!!membership_level_name!!' => __( 'The name of the membership level.', 'paid-memberships-pro' ),
@@ -168,7 +167,6 @@ public function get_email_template_variables() {
"subject" => $this->subject,
"name" => $user->display_name,
"user_login" => $user->user_login,
- "header_name" => $user->display_name,
"display_name" => $user->display_name,
"user_email" => $user->user_email,
"levels_link" => pmpro_url("levels"),
From b3ff95ce968b05934d6bf39b49868392940baf6d Mon Sep 17 00:00:00 2001
From: maximilianoRicoTabo
Date: Tue, 17 Dec 2024 16:32:09 -0300
Subject: [PATCH 26/41] * Remove unnecessary header_name variable from child
template
---
.../class-pmpro-email-template-payment-action-admin.php | 2 --
.../class-pmpro-email-template-payment-action.php | 2 --
.../class-pmpro-email-template-payment-receipt.php | 2 --
3 files changed, 6 deletions(-)
diff --git a/classes/email-templates/class-pmpro-email-template-payment-action-admin.php b/classes/email-templates/class-pmpro-email-template-payment-action-admin.php
index 540c1ec85..3b7852bbc 100644
--- a/classes/email-templates/class-pmpro-email-template-payment-action-admin.php
+++ b/classes/email-templates/class-pmpro-email-template-payment-action-admin.php
@@ -124,7 +124,6 @@ public function get_recipient_name() {
public static function get_email_template_variables_with_description() {
return array(
'!!subject!!' => __( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
- '!!header_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
'!!name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
'!!user_login!!' => __( 'The username of the user.', 'paid-memberships-pro' ),
'!!display_name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
@@ -149,7 +148,6 @@ public function get_email_template_variables() {
"subject" => $this->subject,
"name" => $user->display_name,
"user_login" => $user->user_login,
- "header_name" => $user->display_name,
"display_name" => $user->display_name,
"order_link" => $order_url,
"order_url" => $order_url,
diff --git a/classes/email-templates/class-pmpro-email-template-payment-action.php b/classes/email-templates/class-pmpro-email-template-payment-action.php
index 4fccf1d24..f8683b078 100644
--- a/classes/email-templates/class-pmpro-email-template-payment-action.php
+++ b/classes/email-templates/class-pmpro-email-template-payment-action.php
@@ -119,7 +119,6 @@ public function get_recipient_name() {
public static function get_email_template_variables_with_description() {
return array(
'!!subject!!' => __( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
- '!!header_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
'!!name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
'!!user_login!!' => __( 'The username of the user.', 'paid-memberships-pro' ),
'!!display_name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
@@ -144,7 +143,6 @@ public function get_email_template_variables() {
"subject" => $this->subject,
"name" => $user->display_name,
"user_login" => $user->user_login,
- "header_name" => $user->display_name,
"display_name" => $user->display_name,
"order_link" => $order_url,
"order_url" => $order_url,
diff --git a/classes/email-templates/class-pmpro-email-template-payment-receipt.php b/classes/email-templates/class-pmpro-email-template-payment-receipt.php
index 62e5112af..2f7f9a3be 100644
--- a/classes/email-templates/class-pmpro-email-template-payment-receipt.php
+++ b/classes/email-templates/class-pmpro-email-template-payment-receipt.php
@@ -135,7 +135,6 @@ public function get_recipient_name() {
public static function get_email_template_variables_with_description() {
return array(
'!!subject!!' => __( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
- '!!header_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
'!!name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
'!!membership_id!!' => __( 'The ID of the membership level.', 'paid-memberships-pro' ),
'!!membership_level_name!!' => __( 'The name of the membership level.', 'paid-memberships-pro' ),
@@ -203,7 +202,6 @@ public function get_email_template_variables() {
$email_template_variables = array(
'subject' => $this->get_default_subject(),
- 'header_name' => $user->display_name,
'name' => $user->display_name,
'display_name' => $user->display_name,
'user_login' => $user->user_login,
From fa62cb349c00299ff405abcabd05cc0cd229b4f1 Mon Sep 17 00:00:00 2001
From: maximilianoRicoTabo
Date: Tue, 17 Dec 2024 16:40:03 -0300
Subject: [PATCH 27/41] * Remove unnecessary header_name variable from child
template
---
.../email-templates/class-pmpro-email-template-refund-admin.php | 2 --
classes/email-templates/class-pmpro-email-template-refund.php | 2 --
2 files changed, 4 deletions(-)
diff --git a/classes/email-templates/class-pmpro-email-template-refund-admin.php b/classes/email-templates/class-pmpro-email-template-refund-admin.php
index c0b4b5fe1..229c936e1 100644
--- a/classes/email-templates/class-pmpro-email-template-refund-admin.php
+++ b/classes/email-templates/class-pmpro-email-template-refund-admin.php
@@ -105,7 +105,6 @@ public static function get_email_template_variables_with_description() {
'!!user_login!!' => __( 'The login name of the user who requested the refund.', 'paid-memberships-pro' ),
'!!user_email!!' => __( 'The email address of the user who requested the refund.', 'paid-memberships-pro' ),
'!!display_name!!' => __( 'The display name of the user who requested the refund.', 'paid-memberships-pro' ),
- '!!header_name!!' => __( 'The display name of the user who requested the refund.', 'paid-memberships-pro' ),
'!!membership_id!!' => __( 'The ID of the membership level that was refunded.', 'paid-memberships-pro' ),
'!!membership_level_name!!' => __( 'The name of the membership level that was refunded.', 'paid-memberships-pro' ),
'!!order_id!!' => __( 'The order ID of the refunded order.', 'paid-memberships-pro' ),
@@ -170,7 +169,6 @@ public function get_email_template_variables() {
'user_login' => $user->user_login,
'user_email' => $user->user_email,
'display_name' => $user->display_name,
- 'header_name' => $user->display_name,
'membership_id' => $order->membership_id,
'membership_level_name' => $level->name,
'order_id' => $order->code,
diff --git a/classes/email-templates/class-pmpro-email-template-refund.php b/classes/email-templates/class-pmpro-email-template-refund.php
index aa4213ace..5b40f545d 100644
--- a/classes/email-templates/class-pmpro-email-template-refund.php
+++ b/classes/email-templates/class-pmpro-email-template-refund.php
@@ -107,7 +107,6 @@ public static function get_email_template_variables_with_description() {
'!!user_login!!' => __( 'The login name of the user who requested the refund.', 'paid-memberships-pro' ),
'!!user_email!!' => __( 'The email address of the user who requested the refund.', 'paid-memberships-pro' ),
'!!display_name!!' => __( 'The display name of the user who requested the refund.', 'paid-memberships-pro' ),
- '!!header_name!!' => __( 'The display name of the user who requested the refund.', 'paid-memberships-pro' ),
'!!membership_id!!' => __( 'The ID of the membership level that was refunded.', 'paid-memberships-pro' ),
'!!membership_level_name!!' => __( 'The name of the membership level that was refunded.', 'paid-memberships-pro' ),
'!!order_id!!' => __( 'The order ID of the refunded order.', 'paid-memberships-pro' ),
@@ -169,7 +168,6 @@ public function get_email_template_variables() {
'user_login' => $user->user_login,
'user_email' => $user->user_email,
'display_name' => $user->display_name,
- 'header_name' => $user->display_name,
'membership_id' => $order->membership_id,
'membership_level_name' => $level->name,
'order_id' => $order->code,
From ac68088cafd556ef379be7e25a2ea8c9c9abe819 Mon Sep 17 00:00:00 2001
From: David Parker
Date: Wed, 18 Dec 2024 11:32:55 -0500
Subject: [PATCH 28/41] Fixing file name
---
...hp => class-pmpro-email-template-checkout-check-admin.php} | 0
...heck.php => class-pmpro-email-template-checkout-check.php} | 0
paid-memberships-pro.php | 4 ++--
3 files changed, 2 insertions(+), 2 deletions(-)
rename classes/email-templates/{class-pmpro-email-template-admin-checkout-check-admin.php => class-pmpro-email-template-checkout-check-admin.php} (100%)
rename classes/email-templates/{class-pmpro-email-template-admin-checkout-check.php => class-pmpro-email-template-checkout-check.php} (100%)
diff --git a/classes/email-templates/class-pmpro-email-template-admin-checkout-check-admin.php b/classes/email-templates/class-pmpro-email-template-checkout-check-admin.php
similarity index 100%
rename from classes/email-templates/class-pmpro-email-template-admin-checkout-check-admin.php
rename to classes/email-templates/class-pmpro-email-template-checkout-check-admin.php
diff --git a/classes/email-templates/class-pmpro-email-template-admin-checkout-check.php b/classes/email-templates/class-pmpro-email-template-checkout-check.php
similarity index 100%
rename from classes/email-templates/class-pmpro-email-template-admin-checkout-check.php
rename to classes/email-templates/class-pmpro-email-template-checkout-check.php
diff --git a/paid-memberships-pro.php b/paid-memberships-pro.php
index 14f816330..5372769df 100644
--- a/paid-memberships-pro.php
+++ b/paid-memberships-pro.php
@@ -55,8 +55,8 @@
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-cancel-admin.php' ); // cancel email template
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-admin-change.php' ); // change email template
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-admin-change-admin.php' ); // change email template
-require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-admin-checkout-check.php' );
-require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-admin-checkout-check-admin.php' );
+require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-checkout-check.php' );
+require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-checkout-check-admin.php' );
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-checkout-free.php' );
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-checkout-free-admin.php' );
require_once( PMPRO_DIR . '/classes/email-templates/class-pmpro-email-template-checkout-paid.php' );
From c99daa67f3be669378cf7fb009d26577bdf4075a Mon Sep 17 00:00:00 2001
From: David Parker
Date: Wed, 18 Dec 2024 11:35:07 -0500
Subject: [PATCH 29/41] Adding missing global
---
.../class-pmpro-email-template-checkout-check-admin.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/classes/email-templates/class-pmpro-email-template-checkout-check-admin.php b/classes/email-templates/class-pmpro-email-template-checkout-check-admin.php
index e98936767..55f46dca0 100644
--- a/classes/email-templates/class-pmpro-email-template-checkout-check-admin.php
+++ b/classes/email-templates/class-pmpro-email-template-checkout-check-admin.php
@@ -134,6 +134,7 @@ public function get_recipient_name() {
* @return array The email template variables for the email (key => value pairs).
*/
public function get_email_template_variables() {
+ global $wpdb;
$order = $this->order;
$user = $this->user;
From b148ad714f2b802b23e4857ae0e6ace3b0bd10c4 Mon Sep 17 00:00:00 2001
From: David Parker
Date: Wed, 18 Dec 2024 11:40:35 -0500
Subject: [PATCH 30/41] Removing header name
---
.../class-pmpro-email-template-membership-expired.php | 2 --
1 file changed, 2 deletions(-)
diff --git a/classes/email-templates/class-pmpro-email-template-membership-expired.php b/classes/email-templates/class-pmpro-email-template-membership-expired.php
index 638284ad2..2d3fcb965 100644
--- a/classes/email-templates/class-pmpro-email-template-membership-expired.php
+++ b/classes/email-templates/class-pmpro-email-template-membership-expired.php
@@ -122,7 +122,6 @@ public function get_recipient_name() {
public static function get_email_template_variables_with_description() {
return array(
'!!subject!!' => __( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
- '!!header_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
'!!name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
'!!membership_id!!' => __( 'The ID of the membership level.', 'paid-memberships-pro' ),
'!!membership_level_name!!' => __( 'The name of the membership level.', 'paid-memberships-pro' ),
@@ -168,7 +167,6 @@ public function get_email_template_variables() {
"subject" => $this->subject,
"name" => $user->display_name,
"user_login" => $user->user_login,
- "header_name" => $user->display_name,
"display_name" => $user->display_name,
"user_email" => $user->user_email,
"levels_link" => pmpro_url("levels"),
From 9ce0d3c2c04a1487a8e2b0f2379b2db1386e0109 Mon Sep 17 00:00:00 2001
From: David Parker
Date: Wed, 18 Dec 2024 11:42:37 -0500
Subject: [PATCH 31/41] Fixing missing variables
---
...ass-pmpro-email-template-membership-expired.php | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/classes/email-templates/class-pmpro-email-template-membership-expired.php b/classes/email-templates/class-pmpro-email-template-membership-expired.php
index 2d3fcb965..84d43277a 100644
--- a/classes/email-templates/class-pmpro-email-template-membership-expired.php
+++ b/classes/email-templates/class-pmpro-email-template-membership-expired.php
@@ -142,7 +142,7 @@ public static function get_email_template_variables_with_description() {
public function get_email_template_variables() {
global $wpdb;
// If we don't have a level ID, query the user's most recently expired level from the database.
- if ( empty( $this->$membership_id ) ) {
+ if ( empty( $this->membership_id ) ) {
$membership_id = $wpdb->get_var(
$wpdb->prepare(
"SELECT membership_id FROM $wpdb->pmpro_memberships_users
@@ -150,7 +150,7 @@ public function get_email_template_variables() {
AND status = 'expired'
ORDER BY enddate DESC
LIMIT 1",
- $user->ID
+ $this->user->ID
)
);
@@ -164,11 +164,11 @@ public function get_email_template_variables() {
$membership_level = pmpro_getLevel( $membership_id );
return array(
- "subject" => $this->subject,
- "name" => $user->display_name,
- "user_login" => $user->user_login,
- "display_name" => $user->display_name,
- "user_email" => $user->user_email,
+ "subject" => $this->get_default_subject(),
+ "name" => $this->user->display_name,
+ "user_login" => $this->user->user_login,
+ "display_name" => $this->user->display_name,
+ "user_email" => $this->user->user_email,
"levels_link" => pmpro_url("levels"),
"membership_id" => ( ! empty( $membership_level ) && ! empty( $membership_level->id ) ) ? $membership_level->id : 0,
"membership_level_name" => ( ! empty( $membership_level ) && ! empty( $membership_level->name ) ) ? $membership_level->name : '[' . esc_html( 'deleted', 'paid-memberships-pro' ) . ']',
From 3637eafc027d5220e83c32438dbf23a867e5d471 Mon Sep 17 00:00:00 2001
From: David Parker
Date: Wed, 18 Dec 2024 11:44:55 -0500
Subject: [PATCH 32/41] Fixing broken variables
---
...ss-pmpro-email-template-membership-expiring.php | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/classes/email-templates/class-pmpro-email-template-membership-expiring.php b/classes/email-templates/class-pmpro-email-template-membership-expiring.php
index 741fa8abe..a787d1211 100644
--- a/classes/email-templates/class-pmpro-email-template-membership-expiring.php
+++ b/classes/email-templates/class-pmpro-email-template-membership-expiring.php
@@ -142,7 +142,7 @@ public static function get_email_template_variables_with_description() {
public function get_email_template_variables() {
global $wpdb;
// If we don't have a level ID, query the user's most recently expired level from the database.
- if ( empty( $this->$membership_id ) ) {
+ if ( empty( $this->membership_id ) ) {
$membership_id = $wpdb->get_var(
$wpdb->prepare(
"SELECT membership_id FROM $wpdb->pmpro_memberships_users
@@ -150,7 +150,7 @@ public function get_email_template_variables() {
AND status = 'expired'
ORDER BY enddate DESC
LIMIT 1",
- $user->ID
+ $this->user->ID
)
);
@@ -164,11 +164,11 @@ public function get_email_template_variables() {
$membership_level = pmpro_getLevel( $membership_id );
return array(
- "subject" => $this->subject,
- "name" => $user->display_name,
- "user_login" => $user->user_login,
- "display_name" => $user->display_name,
- "user_email" => $user->user_email,
+ "subject" => $this->get_default_subject(),
+ "name" => $this->user->display_name,
+ "user_login" => $this->user->user_login,
+ "display_name" => $this->user->display_name,
+ "user_email" => $this->user->user_email,
"levels_link" => pmpro_url("levels"),
"membership_id" => ( ! empty( $membership_level ) && ! empty( $membership_level->id ) ) ? $membership_level->id : 0,
"membership_level_name" => ( ! empty( $membership_level ) && ! empty( $membership_level->name ) ) ? $membership_level->name : '[' . esc_html( 'deleted', 'paid-memberships-pro' ) . ']',
From a47146e94246f4afc4e4e5842037e0d9360ba718 Mon Sep 17 00:00:00 2001
From: David Parker
Date: Wed, 18 Dec 2024 11:47:05 -0500
Subject: [PATCH 33/41] Make sure that we can get an enddate
---
.../class-pmpro-email-template-membership-expiring.php | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/classes/email-templates/class-pmpro-email-template-membership-expiring.php b/classes/email-templates/class-pmpro-email-template-membership-expiring.php
index a787d1211..02aaab2a2 100644
--- a/classes/email-templates/class-pmpro-email-template-membership-expiring.php
+++ b/classes/email-templates/class-pmpro-email-template-membership-expiring.php
@@ -161,7 +161,11 @@ public function get_email_template_variables() {
}
// Get the membership level object.
- $membership_level = pmpro_getLevel( $membership_id );
+ if ( empty( $membership_id ) ) {
+ $membership_level = pmpro_getMembershipLevelForUser($this->user->ID);
+ } else {
+ $membership_level = pmpro_getSpecificMembershipLevelForUser($this->user->ID, $membership_id);
+ }
return array(
"subject" => $this->get_default_subject(),
From 26f54afa980e4ce1efdf7739449e4d5573479aea Mon Sep 17 00:00:00 2001
From: David Parker
Date: Wed, 18 Dec 2024 11:53:29 -0500
Subject: [PATCH 34/41] Fixing sending payment reminder email
---
scheduled/crons.php | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/scheduled/crons.php b/scheduled/crons.php
index a648dfda9..90929f9ea 100644
--- a/scheduled/crons.php
+++ b/scheduled/crons.php
@@ -330,13 +330,6 @@ function pmpro_cron_recurring_payment_reminders() {
*/
$send_email = apply_filters( 'pmpro_send_recurring_payment_reminder_email', true, $subscription_obj, $days );
- //if template is membership_recurring, use the new method, let pass otherwise.
- if( $send_email && 'membership_recurring' == $template ) {
- $send_emails = false;
- $pmproemail = new PMProEmail();
- $pmproemail->send_recurring_payment_reminder( $user, $subscription_obj->get_membership_level_id() );
- }
-
/**
* @filter pmprorm_send_reminder_to_user
*
@@ -349,7 +342,12 @@ function pmpro_cron_recurring_payment_reminders() {
$send_emails = apply_filters_deprecated( 'pmprorm_send_reminder_to_user', array( $send_email, $user, null ), '3.2' );
- if ( $send_emails ) {
+ if ( $send_emails && 'membership_recurring' == $template ) {
+ // This is the default email. Use the email template class.
+ $pmproemail = new PMPro_Email_Template_Payment_Reminder( $subscription_obj );
+ $pmproemail->send();
+ } else if ( $send_emails ) {
+ // This is not the default email. Build the email from scratch.
// Get the level info.
$membership_level = pmpro_getLevel( $subscription_obj->get_membership_level_id() );
From 89c77c55d3d024caaf386d7e78dbedd4343d00e0 Mon Sep 17 00:00:00 2001
From: David Parker
Date: Wed, 18 Dec 2024 11:58:13 -0500
Subject: [PATCH 35/41] Fixing broken variables
---
.../class-pmpro-email-template-payment-action-admin.php | 2 +-
.../class-pmpro-email-template-payment-action.php | 2 +-
.../class-pmpro-email-template-payment-reminder.php | 6 ++++--
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/classes/email-templates/class-pmpro-email-template-payment-action-admin.php b/classes/email-templates/class-pmpro-email-template-payment-action-admin.php
index 3b7852bbc..63284e1a6 100644
--- a/classes/email-templates/class-pmpro-email-template-payment-action-admin.php
+++ b/classes/email-templates/class-pmpro-email-template-payment-action-admin.php
@@ -145,7 +145,7 @@ public function get_email_template_variables() {
$user = $this->user;
$order_url = $this->order_url;
return array(
- "subject" => $this->subject,
+ "subject" => $this->get_default_subject(),
"name" => $user->display_name,
"user_login" => $user->user_login,
"display_name" => $user->display_name,
diff --git a/classes/email-templates/class-pmpro-email-template-payment-action.php b/classes/email-templates/class-pmpro-email-template-payment-action.php
index f8683b078..b15f4fa99 100644
--- a/classes/email-templates/class-pmpro-email-template-payment-action.php
+++ b/classes/email-templates/class-pmpro-email-template-payment-action.php
@@ -140,7 +140,7 @@ public function get_email_template_variables() {
$user = $this->user;
$order_url = $this->order_url;
return array(
- "subject" => $this->subject,
+ "subject" => $this->get_default_subject(),
"name" => $user->display_name,
"user_login" => $user->user_login,
"display_name" => $user->display_name,
diff --git a/classes/email-templates/class-pmpro-email-template-payment-reminder.php b/classes/email-templates/class-pmpro-email-template-payment-reminder.php
index 5b036c475..ff4f1e104 100644
--- a/classes/email-templates/class-pmpro-email-template-payment-reminder.php
+++ b/classes/email-templates/class-pmpro-email-template-payment-reminder.php
@@ -89,7 +89,8 @@ public static function get_default_body() {
* @return string The email address to send the email to.
*/
public function get_recipient_email() {
- return $this->user->user_email;
+ $user = get_userdata( $this->subscription_obj->get_user_id() );
+ return $user->user_email;
}
/**
@@ -100,7 +101,8 @@ public function get_recipient_email() {
* @return string The name of the email recipient.
*/
public function get_recipient_name() {
- return $this->user->display_name;
+ $user = get_userdata( $this->subscription_obj->get_user_id() );
+ return $user->display_name;
}
From daf9da1300447376687fbff0c6b106349a1d13d9 Mon Sep 17 00:00:00 2001
From: David Parker
Date: Wed, 18 Dec 2024 12:09:10 -0500
Subject: [PATCH 36/41] Fixing payment action required email for Stripe
---
classes/class.pmproemail.php | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/classes/class.pmproemail.php b/classes/class.pmproemail.php
index 2219f9ed5..2d73f4ed7 100644
--- a/classes/class.pmproemail.php
+++ b/classes/class.pmproemail.php
@@ -828,6 +828,10 @@ function sendPaymentActionRequiredEmail( $user = NULL, $order = NULL, $order_url
if( empty( $order_url ) && isset( $order->order_url ) )
$order_url = $order->order_url;
+ // if an order URL wasn't passed in, grab it from the order
+ if(empty($order_url) && isset($order->invoice_url))
+ $order_url = $order->invoice_url;
+
// still no order URL? bail
if( empty( $order_url ) )
return false;
From 770ff46258dd4126f58ff4a61625d97e3c90778a Mon Sep 17 00:00:00 2001
From: Kim Coleman
Date: Sat, 18 Jan 2025 10:21:25 -0500
Subject: [PATCH 37/41] Fixing incorrect variable usage and subject line that
was not meant to change
---
.../class-pmpro-email-template-admin-change-admin.php | 6 +++---
.../class-pmpro-email-template-admin-change.php | 8 ++++----
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/classes/email-templates/class-pmpro-email-template-admin-change-admin.php b/classes/email-templates/class-pmpro-email-template-admin-change-admin.php
index f25e51bed..7b7602fbe 100644
--- a/classes/email-templates/class-pmpro-email-template-admin-change-admin.php
+++ b/classes/email-templates/class-pmpro-email-template-admin-change-admin.php
@@ -90,13 +90,13 @@ public function get_email_template_variables() {
$user = $this->user;
// If the user no longer has a membership level, set the membership_change text to "Membership has been cancelled."
if ( ! pmpro_hasMembershipLevel( null, $this->user->ID ) ) {
- $membership_changed = __( 'The user\'s membership has been cancelled.', 'paid-memberships-pro' );
+ $membership_change = __( 'The user\'s membership has been cancelled.', 'paid-memberships-pro' );
} else {
- $membership_changed = __( 'You can view the user\'s current memberships from their Edit Member page.', 'paid-memberships-pro' );
+ $membership_change = __( 'You can view the user\'s current memberships from their Edit Member page.', 'paid-memberships-pro' );
}
$email_template_variables = array(
- 'membership_changed' => $membership_changed,
+ 'membership_change' => $membership_change,
'subject' => $this->get_default_subject(),
'name' => $user->display_name,
'display_name' => $user->display_name,
diff --git a/classes/email-templates/class-pmpro-email-template-admin-change.php b/classes/email-templates/class-pmpro-email-template-admin-change.php
index 10a39db30..ec5c51f2f 100644
--- a/classes/email-templates/class-pmpro-email-template-admin-change.php
+++ b/classes/email-templates/class-pmpro-email-template-admin-change.php
@@ -61,7 +61,7 @@ public static function get_template_description() {
* @return string The default subject for the email.
*/
public static function get_default_subject() {
- return __( "Membership for !!header_name!! at !!site_name!! has been changed", "paid-memberships-pro" );
+ return __( "Your membership at !!sitename!! has been changed", "paid-memberships-pro" );
}
/**
@@ -92,13 +92,13 @@ public function get_email_template_variables() {
$user = $this->user;
// If the user no longer has a membership level, set the membership_change text to "Membership has been cancelled."
if ( ! pmpro_hasMembershipLevel( null, $this->user->ID ) ) {
- $membership_changed = __( 'Your membership has been cancelled.', 'paid-memberships-pro' );
+ $membership_change = __( 'Your membership has been cancelled.', 'paid-memberships-pro' );
} else {
- $membership_changed = __( 'You can view your current memberships by logging in and visiting your membership account page.', 'paid-memberships-pro' );
+ $membership_change = __( 'You can view your current memberships by logging in and visiting your membership account page.', 'paid-memberships-pro' );
}
$email_template_variables = array(
- 'membership_changed' => $membership_changed,
+ 'membership_change' => $membership_change,
'subject' => $this->get_default_subject(),
'name' => $user->display_name,
'display_name' => $user->display_name,
From a486e87c21000b2e1544a82be4f24e6d5b844035 Mon Sep 17 00:00:00 2001
From: David Parker
Date: Wed, 22 Jan 2025 12:47:44 -0500
Subject: [PATCH 38/41] Switching to !!billing_address!! instead of individual
fields
---
.../class-pmpro-email-template-billing-admin.php | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/classes/email-templates/class-pmpro-email-template-billing-admin.php b/classes/email-templates/class-pmpro-email-template-billing-admin.php
index 13c44b539..63bc87f4a 100644
--- a/classes/email-templates/class-pmpro-email-template-billing-admin.php
+++ b/classes/email-templates/class-pmpro-email-template-billing-admin.php
@@ -78,10 +78,7 @@ public static function get_default_body() {
Account: !!display_name!! (!!user_email!!)
Billing Information:
- !!billing_name!!
- !!billing_street!!
- !!billing_city!!, !!billing_state!! !!billing_zip!! !!billing_country!!
- !!billing_phone!!
+ !!billing_address!!
From 33268c149e9bd960c720163a992a4bb8ac77a587 Mon Sep 17 00:00:00 2001
From: David Parker
Date: Tue, 28 Jan 2025 15:39:32 -0500
Subject: [PATCH 39/41] Using global !!levels_link!!, encouraging _url instead
of _link vars
---
.../class-pmpro-email-template-membership-expired.php | 2 --
.../class-pmpro-email-template-membership-expiring.php | 2 --
classes/email-templates/class-pmpro-email-template.php | 2 +-
3 files changed, 1 insertion(+), 5 deletions(-)
diff --git a/classes/email-templates/class-pmpro-email-template-membership-expired.php b/classes/email-templates/class-pmpro-email-template-membership-expired.php
index 84d43277a..f1690b0b5 100644
--- a/classes/email-templates/class-pmpro-email-template-membership-expired.php
+++ b/classes/email-templates/class-pmpro-email-template-membership-expired.php
@@ -128,7 +128,6 @@ public static function get_email_template_variables_with_description() {
'!!user_login!!' => __( 'The username of the user.', 'paid-memberships-pro' ),
'!!user_email!!' => __( 'The email address of the user.', 'paid-memberships-pro' ),
'!!display_name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
- '!!levels_link!!' => __( 'The URL of the page where users can view available membership levels.', 'paid-memberships-pro' ),
);
}
@@ -169,7 +168,6 @@ public function get_email_template_variables() {
"user_login" => $this->user->user_login,
"display_name" => $this->user->display_name,
"user_email" => $this->user->user_email,
- "levels_link" => pmpro_url("levels"),
"membership_id" => ( ! empty( $membership_level ) && ! empty( $membership_level->id ) ) ? $membership_level->id : 0,
"membership_level_name" => ( ! empty( $membership_level ) && ! empty( $membership_level->name ) ) ? $membership_level->name : '[' . esc_html( 'deleted', 'paid-memberships-pro' ) . ']',
);
diff --git a/classes/email-templates/class-pmpro-email-template-membership-expiring.php b/classes/email-templates/class-pmpro-email-template-membership-expiring.php
index 02aaab2a2..22f85c1b9 100644
--- a/classes/email-templates/class-pmpro-email-template-membership-expiring.php
+++ b/classes/email-templates/class-pmpro-email-template-membership-expiring.php
@@ -127,7 +127,6 @@ public static function get_email_template_variables_with_description() {
'!!user_login!!' => __( 'The username of the user.', 'paid-memberships-pro' ),
'!!user_email!!' => __( 'The email address of the user.', 'paid-memberships-pro' ),
'!!display_name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
- '!!levels_link!!' => __( 'The URL of the page where users can view available membership levels.', 'paid-memberships-pro' ),
'!!enddate!!' => __( 'The expiration date of the membership level.', 'paid-memberships-pro' ),
);
}
@@ -173,7 +172,6 @@ public function get_email_template_variables() {
"user_login" => $this->user->user_login,
"display_name" => $this->user->display_name,
"user_email" => $this->user->user_email,
- "levels_link" => pmpro_url("levels"),
"membership_id" => ( ! empty( $membership_level ) && ! empty( $membership_level->id ) ) ? $membership_level->id : 0,
"membership_level_name" => ( ! empty( $membership_level ) && ! empty( $membership_level->name ) ) ? $membership_level->name : '[' . esc_html( 'deleted', 'paid-memberships-pro' ) . ']',
"enddate" => date_i18n( get_option('date_format'), $membership_level->enddate ),
diff --git a/classes/email-templates/class-pmpro-email-template.php b/classes/email-templates/class-pmpro-email-template.php
index 9b7b9ce8e..58389523c 100644
--- a/classes/email-templates/class-pmpro-email-template.php
+++ b/classes/email-templates/class-pmpro-email-template.php
@@ -61,6 +61,7 @@ final protected function get_base_email_template_variables() {
'siteemail' => get_option( 'pmpro_from_email' ),
'site_url' => home_url(),
'levels_url' => pmpro_url( 'levels' ),
+ 'levels_link' => pmpro_url( 'levels' ),
'login_link' => pmpro_login_url(),
'login_url' => pmpro_login_url(),
'header_name' => $this->get_recipient_name(),
@@ -82,7 +83,6 @@ final public static function get_base_email_template_variables_with_description(
'!!siteemail!!' => __( 'The email address of the site.', 'paid-memberships-pro' ),
'!!site_url!!' => __( 'The URL of the site.', 'paid-memberships-pro' ),
'!!levels_url!!' => __( 'The URL of the page where users can view available membership levels.', 'paid-memberships-pro' ),
- '!!login_link!!' => __( 'The URL of the login page.', 'paid-memberships-pro' ),
'!!login_url!!' => __( 'The URL of the login page.', 'paid-memberships-pro' ),
'!!header_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
);
From fd4da011ccd817bbd26a8eb01cb7099ec952b0d8 Mon Sep 17 00:00:00 2001
From: David Parker
Date: Wed, 29 Jan 2025 09:04:07 -0500
Subject: [PATCH 40/41] Removing duplicate template variable
---
.../class-pmpro-email-template-payment-action-admin.php | 2 --
1 file changed, 2 deletions(-)
diff --git a/classes/email-templates/class-pmpro-email-template-payment-action-admin.php b/classes/email-templates/class-pmpro-email-template-payment-action-admin.php
index 63284e1a6..f6f48f816 100644
--- a/classes/email-templates/class-pmpro-email-template-payment-action-admin.php
+++ b/classes/email-templates/class-pmpro-email-template-payment-action-admin.php
@@ -130,7 +130,6 @@ public static function get_email_template_variables_with_description() {
'!!order_link!!' => __( 'The URL of the order.', 'paid-memberships-pro' ),
'!!order_url!!' => __( 'The URL of the order.', 'paid-memberships-pro' ),
'!!invoice_url!!' => __( 'The URL of the order. Legacy purpose', 'paid-memberships-pro' ),
- '!!levels_url!!' => __( 'The URL of the membership levels page.', 'paid-memberships-pro' ),
);
}
@@ -152,7 +151,6 @@ public function get_email_template_variables() {
"order_link" => $order_url,
"order_url" => $order_url,
"invoice_url" => $order_url, // Legacy purpose, remove in future version
- "levels_url" => pmpro_url( 'levels' )
);
}
}
From 57ca6692ecbc0870e67d75f0ef7e900c710506fa Mon Sep 17 00:00:00 2001
From: David Parker
Date: Thu, 30 Jan 2025 10:58:13 -0500
Subject: [PATCH 41/41] Escaping
---
adminpages/emailtemplates-edit.php | 76 +++++++++----------
classes/class.pmproemail.php | 2 +-
...mpro-email-template-admin-change-admin.php | 24 +++---
...lass-pmpro-email-template-admin-change.php | 24 +++---
...ass-pmpro-email-template-billing-admin.php | 48 ++++++------
...o-email-template-billing-failure-admin.php | 48 ++++++------
...s-pmpro-email-template-billing-failure.php | 48 ++++++------
.../class-pmpro-email-template-billing.php | 48 ++++++------
...lass-pmpro-email-template-cancel-admin.php | 22 +++---
...late-cancel-on-next-payment-date-admin.php | 22 +++---
...l-template-cancel-on-next-payment-date.php | 22 +++---
.../class-pmpro-email-template-cancel.php | 20 ++---
...ro-email-template-checkout-check-admin.php | 32 ++++----
...ss-pmpro-email-template-checkout-check.php | 36 ++++-----
...pro-email-template-checkout-free-admin.php | 32 ++++----
...ass-pmpro-email-template-checkout-free.php | 32 ++++----
...pro-email-template-checkout-paid-admin.php | 64 ++++++++--------
...ass-pmpro-email-template-checkout-paid.php | 64 ++++++++--------
...ro-email-template-credit-card-expiring.php | 50 ++++++------
...mpro-email-template-membership-expired.php | 22 +++---
...pro-email-template-membership-expiring.php | 24 +++---
...ro-email-template-payment-action-admin.php | 22 +++---
...ss-pmpro-email-template-payment-action.php | 24 +++---
...s-pmpro-email-template-payment-receipt.php | 66 ++++++++--------
...-pmpro-email-template-payment-reminder.php | 18 ++---
...lass-pmpro-email-template-refund-admin.php | 52 ++++++-------
.../class-pmpro-email-template-refund.php | 52 ++++++-------
.../class-pmpro-email-template.php | 12 +--
includes/email-templates.php | 22 +++---
includes/email.php | 8 +-
paid-memberships-pro.php | 20 ++---
scheduled/crons.php | 6 +-
32 files changed, 531 insertions(+), 531 deletions(-)
diff --git a/adminpages/emailtemplates-edit.php b/adminpages/emailtemplates-edit.php
index 0a128d9a2..8724f8098 100644
--- a/adminpages/emailtemplates-edit.php
+++ b/adminpages/emailtemplates-edit.php
@@ -18,43 +18,43 @@
// Email variables.
$email_variables = [
- __( 'General Settings / Membership Info', 'paid-memberships-pro' ) => [
- '!!name!!' => __( 'Display Name (Profile/Edit User > Display name publicly as)', 'paid-memberships-pro' ),
- '!!user_login!!' => __( 'Username', 'paid-memberships-pro' ),
- '!!sitename!!' => __( 'Site Title', 'paid-memberships-pro' ),
- '!!siteemail!!' => __( 'Site Email Address (General Settings > Email OR Memberships > Settings > Email Settings)', 'paid-memberships-pro' ),
- '!!membership_id!!' => __( 'Membership Level ID', 'paid-memberships-pro' ),
- '!!membership_level_name!!' => __( 'Membership Level Name', 'paid-memberships-pro' ),
- '!!membership_change!!' => __( 'Membership Level Change', 'paid-memberships-pro' ),
- '!!membership_expiration!!' => __( 'Membership Level Expiration', 'paid-memberships-pro' ),
- '!!startdate!!' => __( 'Membership Start Date', 'paid-memberships-pro' ),
- '!!enddate!!' => __( 'Membership End Date', 'paid-memberships-pro' ),
- '!!display_name!!' => __( 'Display Name (Profile/Edit User > Display name publicly as)', 'paid-memberships-pro' ),
- '!!user_email!!' => __( 'User Email', 'paid-memberships-pro' ),
- '!!login_url!!' => __( 'Login URL', 'paid-memberships-pro' ),
- '!!levels_url!!' => __( 'Membership Levels Page URL', 'paid-memberships-pro' ),
+ esc_html__( 'General Settings / Membership Info', 'paid-memberships-pro' ) => [
+ '!!name!!' => esc_html__( 'Display Name (Profile/Edit User > Display name publicly as)', 'paid-memberships-pro' ),
+ '!!user_login!!' => esc_html__( 'Username', 'paid-memberships-pro' ),
+ '!!sitename!!' => esc_html__( 'Site Title', 'paid-memberships-pro' ),
+ '!!siteemail!!' => esc_html__( 'Site Email Address (General Settings > Email OR Memberships > Settings > Email Settings)', 'paid-memberships-pro' ),
+ '!!membership_id!!' => esc_html__( 'Membership Level ID', 'paid-memberships-pro' ),
+ '!!membership_level_name!!' => esc_html__( 'Membership Level Name', 'paid-memberships-pro' ),
+ '!!membership_change!!' => esc_html__( 'Membership Level Change', 'paid-memberships-pro' ),
+ '!!membership_expiration!!' => esc_html__( 'Membership Level Expiration', 'paid-memberships-pro' ),
+ '!!startdate!!' => esc_html__( 'Membership Start Date', 'paid-memberships-pro' ),
+ '!!enddate!!' => esc_html__( 'Membership End Date', 'paid-memberships-pro' ),
+ '!!display_name!!' => esc_html__( 'Display Name (Profile/Edit User > Display name publicly as)', 'paid-memberships-pro' ),
+ '!!user_email!!' => esc_html__( 'User Email', 'paid-memberships-pro' ),
+ '!!login_url!!' => esc_html__( 'Login URL', 'paid-memberships-pro' ),
+ '!!levels_url!!' => esc_html__( 'Membership Levels Page URL', 'paid-memberships-pro' ),
],
- __( 'Billing Information', 'paid-memberships-pro' ) => [
- '!!billing_address!!' => __( 'Billing Info Complete Address', 'paid-memberships-pro' ),
- '!!billing_name!!' => __( 'Billing Info Name', 'paid-memberships-pro' ),
- '!!billing_street!!' => __( 'Billing Info Street Address', 'paid-memberships-pro' ),
- '!!billing_city!!' => __( 'Billing Info City', 'paid-memberships-pro' ),
- '!!billing_state!!' => __( 'Billing Info State', 'paid-memberships-pro' ),
- '!!billing_zip!!' => __( 'Billing Info ZIP Code', 'paid-memberships-pro' ),
- '!!billing_country!!' => __( 'Billing Info Country', 'paid-memberships-pro' ),
- '!!billing_phone!!' => __( 'Billing Info Phone #', 'paid-memberships-pro' ),
- '!!cardtype!!' => __( 'Credit Card Type', 'paid-memberships-pro' ),
- '!!accountnumber!!' => __( 'Credit Card Number (last 4 digits)', 'paid-memberships-pro' ),
- '!!expirationmonth!!' => __( 'Credit Card Expiration Month (mm format)', 'paid-memberships-pro' ),
- '!!expirationyear!!' => __( 'Credit Card Expiration Year (yyyy format)', 'paid-memberships-pro' ),
- '!!membership_cost!!' => __( 'Membership Level Cost Text', 'paid-memberships-pro' ),
- '!!instructions!!' => __( 'Payment Instructions (used in Checkout - Email Template)', 'paid-memberships-pro' ),
- '!!order_id!!' => __( 'Order ID', 'paid-memberships-pro' ),
- '!!order_total!!' => __( 'Order Total', 'paid-memberships-pro' ),
- '!!order_date!!' => __( 'Order Date', 'paid-memberships-pro' ),
- '!!order_url!!' => __( 'Order Page URL', 'paid-memberships-pro' ),
- '!!discount_code!!' => __( 'Discount Code Applied', 'paid-memberships-pro' ),
- '!!membership_level_confirmation_message!!' => __( 'Custom Level Confirmation Message', 'paid-memberships-pro' ),
+ esc_html__( 'Billing Information', 'paid-memberships-pro' ) => [
+ '!!billing_address!!' => esc_html__( 'Billing Info Complete Address', 'paid-memberships-pro' ),
+ '!!billing_name!!' => esc_html__( 'Billing Info Name', 'paid-memberships-pro' ),
+ '!!billing_street!!' => esc_html__( 'Billing Info Street Address', 'paid-memberships-pro' ),
+ '!!billing_city!!' => esc_html__( 'Billing Info City', 'paid-memberships-pro' ),
+ '!!billing_state!!' => esc_html__( 'Billing Info State', 'paid-memberships-pro' ),
+ '!!billing_zip!!' => esc_html__( 'Billing Info ZIP Code', 'paid-memberships-pro' ),
+ '!!billing_country!!' => esc_html__( 'Billing Info Country', 'paid-memberships-pro' ),
+ '!!billing_phone!!' => esc_html__( 'Billing Info Phone #', 'paid-memberships-pro' ),
+ '!!cardtype!!' => esc_html__( 'Credit Card Type', 'paid-memberships-pro' ),
+ '!!accountnumber!!' => esc_html__( 'Credit Card Number (last 4 digits)', 'paid-memberships-pro' ),
+ '!!expirationmonth!!' => esc_html__( 'Credit Card Expiration Month (mm format)', 'paid-memberships-pro' ),
+ '!!expirationyear!!' => esc_html__( 'Credit Card Expiration Year (yyyy format)', 'paid-memberships-pro' ),
+ '!!membership_cost!!' => esc_html__( 'Membership Level Cost Text', 'paid-memberships-pro' ),
+ '!!instructions!!' => esc_html__( 'Payment Instructions (used in Checkout - Email Template)', 'paid-memberships-pro' ),
+ '!!order_id!!' => esc_html__( 'Order ID', 'paid-memberships-pro' ),
+ '!!order_total!!' => esc_html__( 'Order Total', 'paid-memberships-pro' ),
+ '!!order_date!!' => esc_html__( 'Order Date', 'paid-memberships-pro' ),
+ '!!order_url!!' => esc_html__( 'Order Page URL', 'paid-memberships-pro' ),
+ '!!discount_code!!' => esc_html__( 'Discount Code Applied', 'paid-memberships-pro' ),
+ '!!membership_level_confirmation_message!!' => esc_html__( 'Custom Level Confirmation Message', 'paid-memberships-pro' ),
]
];
@@ -62,8 +62,8 @@
$email_template_class = PMPro_Email_Template::get_email_template( $edit );
if ( $email_template_class ) {
$email_variables = array(
- __( 'Global Variables', 'paid-memberships-pro' ) => PMPro_Email_Template::get_base_email_template_variables_with_description(),
- sprintf( __( '%s Variables', 'paid-memberships-pro' ), $email_template_class::get_template_name() ) => $email_template_class::get_email_template_variables_with_description(),
+ esc_html__( 'Global Variables', 'paid-memberships-pro' ) => PMPro_Email_Template::get_base_email_template_variables_with_description(),
+ sprintf( esc_html__( '%s Variables', 'paid-memberships-pro' ), $email_template_class::get_template_name() ) => $email_template_class::get_email_template_variables_with_description(),
);
}
?>
diff --git a/classes/class.pmproemail.php b/classes/class.pmproemail.php
index 2d73f4ed7..c64450cb0 100644
--- a/classes/class.pmproemail.php
+++ b/classes/class.pmproemail.php
@@ -170,7 +170,7 @@ function sendEmail($email = NULL, $from = NULL, $fromname = NULL, $subject = NUL
} elseif ( ! empty ( $this->data['name'] ) ) {
$this->data['header_name'] = $this->data['name'];
} else {
- $this->data['header_name'] = __( 'User', 'paid-memberships-pro' );
+ $this->data['header_name'] = esc_html__( 'User', 'paid-memberships-pro' );
}
}
diff --git a/classes/email-templates/class-pmpro-email-template-admin-change-admin.php b/classes/email-templates/class-pmpro-email-template-admin-change-admin.php
index 7b7602fbe..e00565295 100644
--- a/classes/email-templates/class-pmpro-email-template-admin-change-admin.php
+++ b/classes/email-templates/class-pmpro-email-template-admin-change-admin.php
@@ -39,7 +39,7 @@ public static function get_template_slug() {
* @return string The "nice name" of the email template.
*/
public static function get_template_name() {
- return __( 'Admin Change (admin)', 'paid-memberships-pro' );
+ return esc_html__( 'Admin Change (admin)', 'paid-memberships-pro' );
}
/**
@@ -50,7 +50,7 @@ public static function get_template_name() {
* @return string The "help text" to display to the admin when editing the email template.
*/
public static function get_template_description() {
- return __( 'The site administrator can manually update a user\'s membership level through the WordPress admin. This email notifies the site administrator of the level update.', 'paid-memberships-pro' );
+ return esc_html__( 'The site administrator can manually update a user\'s membership level through the WordPress admin. This email notifies the site administrator of the level update.', 'paid-memberships-pro' );
}
/**
@@ -61,7 +61,7 @@ public static function get_template_description() {
* @return string The default subject for the email.
*/
public static function get_default_subject() {
- return __( "Membership for !!display_name!! at !!sitename!! has been changed", 'paid-memberships-pro' );
+ return esc_html__( "Membership for !!display_name!! at !!sitename!! has been changed", 'paid-memberships-pro' );
}
/**
@@ -72,7 +72,7 @@ public static function get_default_subject() {
* @return string The default body content for the email.
*/
public static function get_default_body() {
- return __( 'An administrator at !!sitename!! has changed a membership level for !!display_name!!.
+ return wp_kses_post( 'An administrator at !!sitename!! has changed a membership level for !!display_name!!.
!!membership_change!!
@@ -90,9 +90,9 @@ public function get_email_template_variables() {
$user = $this->user;
// If the user no longer has a membership level, set the membership_change text to "Membership has been cancelled."
if ( ! pmpro_hasMembershipLevel( null, $this->user->ID ) ) {
- $membership_change = __( 'The user\'s membership has been cancelled.', 'paid-memberships-pro' );
+ $membership_change = esc_html__( 'The user\'s membership has been cancelled.', 'paid-memberships-pro' );
} else {
- $membership_change = __( 'You can view the user\'s current memberships from their Edit Member page.', 'paid-memberships-pro' );
+ $membership_change = esc_html__( 'You can view the user\'s current memberships from their Edit Member page.', 'paid-memberships-pro' );
}
$email_template_variables = array(
@@ -115,12 +115,12 @@ public function get_email_template_variables() {
*/
public static function get_email_template_variables_with_description() {
return array(
- '!!membership_change!!' => __( 'Membership Level Change', 'paid-memberships-pro' ),
- '!!subject!!' => __( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
- '!!name!!' => __( 'The display name of the user whose membership was changed.', 'paid-memberships-pro' ),
- '!!display_name!!' => __( 'The display name of the user whose membership was changed.', 'paid-memberships-pro' ),
- '!!user_login!!' => __( 'The login name of the user whose membership was changed.', 'paid-memberships-pro' ),
- '!!user_email!!' => __( 'The email address of the user whose membership was changed.', 'paid-memberships-pro' ),
+ '!!membership_change!!' => esc_html__( 'Membership Level Change', 'paid-memberships-pro' ),
+ '!!subject!!' => esc_html__( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
+ '!!name!!' => esc_html__( 'The display name of the user whose membership was changed.', 'paid-memberships-pro' ),
+ '!!display_name!!' => esc_html__( 'The display name of the user whose membership was changed.', 'paid-memberships-pro' ),
+ '!!user_login!!' => esc_html__( 'The login name of the user whose membership was changed.', 'paid-memberships-pro' ),
+ '!!user_email!!' => esc_html__( 'The email address of the user whose membership was changed.', 'paid-memberships-pro' ),
);
}
diff --git a/classes/email-templates/class-pmpro-email-template-admin-change.php b/classes/email-templates/class-pmpro-email-template-admin-change.php
index ec5c51f2f..b7d7e7f2a 100644
--- a/classes/email-templates/class-pmpro-email-template-admin-change.php
+++ b/classes/email-templates/class-pmpro-email-template-admin-change.php
@@ -39,7 +39,7 @@ public static function get_template_slug() {
* @return string The "nice name" of the email template.
*/
public static function get_template_name() {
- return __( 'Admin Change', 'paid-memberships-pro' );
+ return esc_html__( 'Admin Change', 'paid-memberships-pro' );
}
/**
@@ -50,7 +50,7 @@ public static function get_template_name() {
* @return string The "help text" to display to the admin when editing the email template.
*/
public static function get_template_description() {
- return __( 'The site administrator can manually update a user\'s membership through the WordPress admin. This email notifies the member of the level update.', 'paid-memberships-pro' );
+ return esc_html__( 'The site administrator can manually update a user\'s membership through the WordPress admin. This email notifies the member of the level update.', 'paid-memberships-pro' );
}
/**
@@ -61,7 +61,7 @@ public static function get_template_description() {
* @return string The default subject for the email.
*/
public static function get_default_subject() {
- return __( "Your membership at !!sitename!! has been changed", "paid-memberships-pro" );
+ return esc_html__( "Your membership at !!sitename!! has been changed", "paid-memberships-pro" );
}
/**
@@ -72,7 +72,7 @@ public static function get_default_subject() {
* @return string The default body content for the email.
*/
public static function get_default_body() {
- return __( 'An administrator at !!sitename!! has changed your membership level.
+ return wp_kses_post( 'An administrator at !!sitename!! has changed your membership level.
!!membership_change!!
@@ -92,9 +92,9 @@ public function get_email_template_variables() {
$user = $this->user;
// If the user no longer has a membership level, set the membership_change text to "Membership has been cancelled."
if ( ! pmpro_hasMembershipLevel( null, $this->user->ID ) ) {
- $membership_change = __( 'Your membership has been cancelled.', 'paid-memberships-pro' );
+ $membership_change = esc_html__( 'Your membership has been cancelled.', 'paid-memberships-pro' );
} else {
- $membership_change = __( 'You can view your current memberships by logging in and visiting your membership account page.', 'paid-memberships-pro' );
+ $membership_change = esc_html__( 'You can view your current memberships by logging in and visiting your membership account page.', 'paid-memberships-pro' );
}
$email_template_variables = array(
@@ -117,12 +117,12 @@ public function get_email_template_variables() {
*/
public static function get_email_template_variables_with_description() {
return array(
- '!!membership_change!!' => __( 'Membership Level Change', 'paid-memberships-pro' ),
- '!!subject!!' => __( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
- '!!name!!' => __( 'The display name of the user whose membership was changed.', 'paid-memberships-pro' ),
- '!!display_name!!' => __( 'The display name of the user whose membership was changed.', 'paid-memberships-pro' ),
- '!!user_login!!' => __( 'The login name of the user whose membership was changed.', 'paid-memberships-pro' ),
- '!!user_email!!' => __( 'The email address of the user whose membership was changed.', 'paid-memberships-pro' ),
+ '!!membership_change!!' => esc_html__( 'Membership Level Change', 'paid-memberships-pro' ),
+ '!!subject!!' => esc_html__( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
+ '!!name!!' => esc_html__( 'The display name of the user whose membership was changed.', 'paid-memberships-pro' ),
+ '!!display_name!!' => esc_html__( 'The display name of the user whose membership was changed.', 'paid-memberships-pro' ),
+ '!!user_login!!' => esc_html__( 'The login name of the user whose membership was changed.', 'paid-memberships-pro' ),
+ '!!user_email!!' => esc_html__( 'The email address of the user whose membership was changed.', 'paid-memberships-pro' ),
);
}
diff --git a/classes/email-templates/class-pmpro-email-template-billing-admin.php b/classes/email-templates/class-pmpro-email-template-billing-admin.php
index 63bc87f4a..245121459 100644
--- a/classes/email-templates/class-pmpro-email-template-billing-admin.php
+++ b/classes/email-templates/class-pmpro-email-template-billing-admin.php
@@ -48,7 +48,7 @@ public static function get_template_slug() {
* @return string The "nice name" of the email template.
*/
public static function get_template_name() {
- return __( 'Billing Information Updated (admin)', 'paid-memberships-pro' );
+ return esc_html__( 'Billing Information Updated (admin)', 'paid-memberships-pro' );
}
/**
@@ -59,7 +59,7 @@ public static function get_template_name() {
* @return string The help text.
*/
public static function get_template_description() {
- return __( 'Members can update the payment method associated with their recurring subscription. This email is sent to the site administrator as a confirmation of a payment method update.', 'paid-memberships-pro' );
+ return esc_html__( 'Members can update the payment method associated with their recurring subscription. This email is sent to the site administrator as a confirmation of a payment method update.', 'paid-memberships-pro' );
}
/**
@@ -70,11 +70,11 @@ public static function get_template_description() {
* @return string The default subject for the email.
*/
public static function get_default_subject() {
- return __( 'Billing information has been updated for !!user_login!! at !!sitename!!', 'paid-memberships-pro' );
+ return esc_html__( 'Billing information has been updated for !!user_login!! at !!sitename!!', 'paid-memberships-pro' );
}
public static function get_default_body() {
- return __( 'The billing information for !!display_name!! at !!sitename!! has been changed.
+ return wp_kses_post( 'The billing information for !!display_name!! at !!sitename!! has been changed.
Account: !!display_name!! (!!user_email!!)
Billing Information:
@@ -99,26 +99,26 @@ public static function get_default_body() {
*/
public static function get_email_template_variables_with_description() {
$base_email_template_variables_with_description = array(
- '!!name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
- '!!membership_id!!' => __( 'The ID of the membership level.', 'paid-memberships-pro' ),
- '!!membership_level_name!!' => __( 'The name of the membership level.', 'paid-memberships-pro' ),
- '!!user_login!!' => __( 'The username of the user.', 'paid-memberships-pro' ),
- '!!user_email!!' => __( 'The email address of the user.', 'paid-memberships-pro' ),
- '!!display_name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
- '!!subject!!' => __( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
- '!!billing_address!!' => __( 'Billing Info Complete Address', 'paid-memberships-pro' ),
- '!!billing_name!!' => __( 'The billing name of the user.', 'paid-memberships-pro' ),
- '!!billing_street!!' => __( 'The billing street address of the user.', 'paid-memberships-pro' ),
- '!!billing_street2!!' => __( 'The second billing street field address of the user.', 'paid-memberships-pro' ),
- '!!billing_city!!' => __( 'The billing city of the user.', 'paid-memberships-pro' ),
- '!!billing_state!!' => __( 'The billing state of the user.', 'paid-memberships-pro' ),
- '!!billing_zip!!' => __( 'The billing ZIP code of the user.', 'paid-memberships-pro' ),
- '!!billing_country!!' => __( 'The billing country of the user.', 'paid-memberships-pro' ),
- '!!billing_phone!!' => __( 'The billing phone number of the user.', 'paid-memberships-pro' ),
- '!!cardtype!!' => __( 'The type of credit card used.', 'paid-memberships-pro' ),
- '!!accountnumber!!' => __( 'The last four digits of the credit card number.', 'paid-memberships-pro' ),
- '!!expirationmonth!!' => __( 'The expiration month of the credit card.', 'paid-memberships-pro' ),
- '!!expirationyear!!' => __( 'The expiration year of the credit card.', 'paid-memberships-pro' ),
+ '!!name!!' => esc_html__( 'The display name of the user.', 'paid-memberships-pro' ),
+ '!!membership_id!!' => esc_html__( 'The ID of the membership level.', 'paid-memberships-pro' ),
+ '!!membership_level_name!!' => esc_html__( 'The name of the membership level.', 'paid-memberships-pro' ),
+ '!!user_login!!' => esc_html__( 'The username of the user.', 'paid-memberships-pro' ),
+ '!!user_email!!' => esc_html__( 'The email address of the user.', 'paid-memberships-pro' ),
+ '!!display_name!!' => esc_html__( 'The display name of the user.', 'paid-memberships-pro' ),
+ '!!subject!!' => esc_html__( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
+ '!!billing_address!!' => esc_html__( 'Billing Info Complete Address', 'paid-memberships-pro' ),
+ '!!billing_name!!' => esc_html__( 'The billing name of the user.', 'paid-memberships-pro' ),
+ '!!billing_street!!' => esc_html__( 'The billing street address of the user.', 'paid-memberships-pro' ),
+ '!!billing_street2!!' => esc_html__( 'The second billing street field address of the user.', 'paid-memberships-pro' ),
+ '!!billing_city!!' => esc_html__( 'The billing city of the user.', 'paid-memberships-pro' ),
+ '!!billing_state!!' => esc_html__( 'The billing state of the user.', 'paid-memberships-pro' ),
+ '!!billing_zip!!' => esc_html__( 'The billing ZIP code of the user.', 'paid-memberships-pro' ),
+ '!!billing_country!!' => esc_html__( 'The billing country of the user.', 'paid-memberships-pro' ),
+ '!!billing_phone!!' => esc_html__( 'The billing phone number of the user.', 'paid-memberships-pro' ),
+ '!!cardtype!!' => esc_html__( 'The type of credit card used.', 'paid-memberships-pro' ),
+ '!!accountnumber!!' => esc_html__( 'The last four digits of the credit card number.', 'paid-memberships-pro' ),
+ '!!expirationmonth!!' => esc_html__( 'The expiration month of the credit card.', 'paid-memberships-pro' ),
+ '!!expirationyear!!' => esc_html__( 'The expiration year of the credit card.', 'paid-memberships-pro' ),
);
return $base_email_template_variables_with_description;
diff --git a/classes/email-templates/class-pmpro-email-template-billing-failure-admin.php b/classes/email-templates/class-pmpro-email-template-billing-failure-admin.php
index fccc9217d..31bab6847 100644
--- a/classes/email-templates/class-pmpro-email-template-billing-failure-admin.php
+++ b/classes/email-templates/class-pmpro-email-template-billing-failure-admin.php
@@ -48,7 +48,7 @@ public static function get_template_slug() {
* @return string The "nice name" of the email template.
*/
public static function get_template_name() {
- return __( 'Payment Failure (admin)', 'paid-memberships-pro' );
+ return esc_html__( 'Payment Failure (admin)', 'paid-memberships-pro' );
}
/**
@@ -59,7 +59,7 @@ public static function get_template_name() {
* @return string The email template description.
*/
public static function get_template_description() {
- return __( 'This email is sent to the site admin when a member\'s payment fails.', 'paid-memberships-pro' );
+ return esc_html__( 'This email is sent to the site admin when a member\'s payment fails.', 'paid-memberships-pro' );
}
/**
@@ -70,7 +70,7 @@ public static function get_template_description() {
* @return string The email subject.
*/
public static function get_default_subject() {
- return __( "Membership payment failed for !!display_name!! at !!sitename!!", 'paid-memberships-pro' );
+ return esc_html__( "Membership payment failed for !!display_name!! at !!sitename!!", 'paid-memberships-pro' );
}
/**
@@ -81,7 +81,7 @@ public static function get_default_subject() {
* @return string The email body.
*/
public static function get_default_body() {
- return __( '
The subscription payment for !!user_login!! for level !!membership_level_name!! at !!sitename!! has failed.
+ return wp_kses_post( 'The subscription payment for !!user_login!! for level !!membership_level_name!! at !!sitename!! has failed.
Account: !!display_name!! (!!user_email!!)
Membership Level: !!membership_level_name!!
@@ -121,26 +121,26 @@ public function get_recipient_name() {
*/
public static function get_email_template_variables_with_description() {
return array(
- '!!subject!!' => __( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
- '!!name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
- '!!user_login!!' => __( 'The username of the user.', 'paid-memberships-pro' ),
- '!!user_email!!' => __( 'The email address of the user billing failed', 'paid-memberships-pro' ),
- '!!display_name!!' => __( 'The display name of the user billing failed', 'paid-memberships-pro' ),
- '!!membership_id!!' => __( 'The ID of the membership level.', 'paid-memberships-pro' ),
- '!!membership_level_name!!' => __( 'The name of the membership level.', 'paid-memberships-pro' ),
- '!!billing_name!!' => __( 'Billing Info Name', 'paid-memberships-pro' ),
- '!!billing_street!!' => __( 'Billing Info Street', 'paid-memberships-pro' ),
- '!!billing_street2!!' => __( 'Billing Info Street 2', 'paid-memberships-pro' ),
- '!!billing_city!!' => __( 'Billing Info City', 'paid-memberships-pro' ),
- '!!billing_state!!' => __( 'Billing Info State', 'paid-memberships-pro' ),
- '!!billing_zip!!' => __( 'Billing Info Zip', 'paid-memberships-pro' ),
- '!!billing_country!!' => __( 'Billing Info Country', 'paid-memberships-pro' ),
- '!!billing_phone!!' => __( 'Billing Info Phone', 'paid-memberships-pro' ),
- '!!billing_address!!' => __( 'Billing Info Complete Address', 'paid-memberships-pro' ),
- '!!cardtype!!' => __( 'Credit Card Type', 'paid-memberships-pro' ),
- '!!accountnumber!!' => __( 'Credit Card Number (last 4 digits)', 'paid-memberships-pro' ),
- '!!expirationmonth!!' => __( 'Credit Card Expiration Month (mm format)', 'paid-memberships-pro' ),
- '!!expirationyear!!' => __( 'Credit Card Expiration Year (yyyy format)', 'paid-memberships-pro' ),
+ '!!subject!!' => esc_html__( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
+ '!!name!!' => esc_html__( 'The display name of the user.', 'paid-memberships-pro' ),
+ '!!user_login!!' => esc_html__( 'The username of the user.', 'paid-memberships-pro' ),
+ '!!user_email!!' => esc_html__( 'The email address of the user billing failed', 'paid-memberships-pro' ),
+ '!!display_name!!' => esc_html__( 'The display name of the user billing failed', 'paid-memberships-pro' ),
+ '!!membership_id!!' => esc_html__( 'The ID of the membership level.', 'paid-memberships-pro' ),
+ '!!membership_level_name!!' => esc_html__( 'The name of the membership level.', 'paid-memberships-pro' ),
+ '!!billing_name!!' => esc_html__( 'Billing Info Name', 'paid-memberships-pro' ),
+ '!!billing_street!!' => esc_html__( 'Billing Info Street', 'paid-memberships-pro' ),
+ '!!billing_street2!!' => esc_html__( 'Billing Info Street 2', 'paid-memberships-pro' ),
+ '!!billing_city!!' => esc_html__( 'Billing Info City', 'paid-memberships-pro' ),
+ '!!billing_state!!' => esc_html__( 'Billing Info State', 'paid-memberships-pro' ),
+ '!!billing_zip!!' => esc_html__( 'Billing Info Zip', 'paid-memberships-pro' ),
+ '!!billing_country!!' => esc_html__( 'Billing Info Country', 'paid-memberships-pro' ),
+ '!!billing_phone!!' => esc_html__( 'Billing Info Phone', 'paid-memberships-pro' ),
+ '!!billing_address!!' => esc_html__( 'Billing Info Complete Address', 'paid-memberships-pro' ),
+ '!!cardtype!!' => esc_html__( 'Credit Card Type', 'paid-memberships-pro' ),
+ '!!accountnumber!!' => esc_html__( 'Credit Card Number (last 4 digits)', 'paid-memberships-pro' ),
+ '!!expirationmonth!!' => esc_html__( 'Credit Card Expiration Month (mm format)', 'paid-memberships-pro' ),
+ '!!expirationyear!!' => esc_html__( 'Credit Card Expiration Year (yyyy format)', 'paid-memberships-pro' ),
);
}
diff --git a/classes/email-templates/class-pmpro-email-template-billing-failure.php b/classes/email-templates/class-pmpro-email-template-billing-failure.php
index c0c8f941e..3fdcf231d 100644
--- a/classes/email-templates/class-pmpro-email-template-billing-failure.php
+++ b/classes/email-templates/class-pmpro-email-template-billing-failure.php
@@ -48,7 +48,7 @@ public static function get_template_slug() {
* @return string The "nice name" of the email template.
*/
public static function get_template_name() {
- return __( 'Payment Failure', 'paid-memberships-pro' );
+ return esc_html__( 'Payment Failure', 'paid-memberships-pro' );
}
/**
@@ -59,7 +59,7 @@ public static function get_template_name() {
* @return string The help text.
*/
public static function get_template_description() {
- return __( 'This email is sent out if a recurring payment has failed, usually due to an expired or cancelled credit card. This email is sent to the member to allowing them time to update payment information without a disruption in access to your site.', 'paid-memberships-pro' );
+ return esc_html__( 'This email is sent out if a recurring payment has failed, usually due to an expired or cancelled credit card. This email is sent to the member to allowing them time to update payment information without a disruption in access to your site.', 'paid-memberships-pro' );
}
/**
@@ -70,7 +70,7 @@ public static function get_template_description() {
* @return string The email subject.
*/
public static function get_default_subject() {
- return __( "Membership payment failed at !!sitename!!", 'paid-memberships-pro' );
+ return esc_html__( "Membership payment failed at !!sitename!!", 'paid-memberships-pro' );
}
/**
@@ -81,7 +81,7 @@ public static function get_default_subject() {
* @return string The email body.
*/
public static function get_default_body() {
- return __( 'The current subscription payment for level !!membership_level_name!! at !!sitename!! membership has failed. Please click the following link to log in and update your billing information to avoid account suspension.
!!login_url!!
+ return wp_kses_post( 'The current subscription payment for level !!membership_level_name!! at !!sitename!! membership has failed. Please click the following link to log in and update your billing information to avoid account suspension.
!!login_url!!
Account: !!display_name!! (!!user_email!!)
', 'paid-memberships-pro' );
}
@@ -116,26 +116,26 @@ public function get_recipient_name() {
*/
public static function get_email_template_variables_with_description() {
return array(
- '!!subject!!' => __( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
- '!!name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
- '!!user_login!!' => __( 'The username of the user.', 'paid-memberships-pro' ),
- '!!user_email!!' => __( 'The email address of the user billing failed', 'paid-memberships-pro' ),
- '!!display_name!!' => __( 'The display name of the user billing failed', 'paid-memberships-pro' ),
- '!!membership_id!!' => __( 'The ID of the membership level.', 'paid-memberships-pro' ),
- '!!membership_level_name!!' => __( 'The name of the membership level.', 'paid-memberships-pro' ),
- '!!billing_name!!' => __( 'Billing Info Name', 'paid-memberships-pro' ),
- '!!billing_street!!' => __( 'Billing Info Street', 'paid-memberships-pro' ),
- '!!billing_street2!!' => __( 'Billing Info Street 2', 'paid-memberships-pro' ),
- '!!billing_city!!' => __( 'Billing Info City', 'paid-memberships-pro' ),
- '!!billing_state!!' => __( 'Billing Info State', 'paid-memberships-pro' ),
- '!!billing_zip!!' => __( 'Billing Info Zip', 'paid-memberships-pro' ),
- '!!billing_country!!' => __( 'Billing Info Country', 'paid-memberships-pro' ),
- '!!billing_phone!!' => __( 'Billing Info Phone', 'paid-memberships-pro' ),
- '!!billing_address!!' => __( 'Billing Info Complete Address', 'paid-memberships-pro' ),
- '!!cardtype!!' => __( 'Credit Card Type', 'paid-memberships-pro' ),
- '!!accountnumber!!' => __( 'Credit Card Number (last 4 digits)', 'paid-memberships-pro' ),
- '!!expirationmonth!!' => __( 'Credit Card Expiration Month (mm format)', 'paid-memberships-pro' ),
- '!!expirationyear!!' => __( 'Credit Card Expiration Year (yyyy format)', 'paid-memberships-pro' ),
+ '!!subject!!' => esc_html__( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
+ '!!name!!' => esc_html__( 'The display name of the user.', 'paid-memberships-pro' ),
+ '!!user_login!!' => esc_html__( 'The username of the user.', 'paid-memberships-pro' ),
+ '!!user_email!!' => esc_html__( 'The email address of the user billing failed', 'paid-memberships-pro' ),
+ '!!display_name!!' => esc_html__( 'The display name of the user billing failed', 'paid-memberships-pro' ),
+ '!!membership_id!!' => esc_html__( 'The ID of the membership level.', 'paid-memberships-pro' ),
+ '!!membership_level_name!!' => esc_html__( 'The name of the membership level.', 'paid-memberships-pro' ),
+ '!!billing_name!!' => esc_html__( 'Billing Info Name', 'paid-memberships-pro' ),
+ '!!billing_street!!' => esc_html__( 'Billing Info Street', 'paid-memberships-pro' ),
+ '!!billing_street2!!' => esc_html__( 'Billing Info Street 2', 'paid-memberships-pro' ),
+ '!!billing_city!!' => esc_html__( 'Billing Info City', 'paid-memberships-pro' ),
+ '!!billing_state!!' => esc_html__( 'Billing Info State', 'paid-memberships-pro' ),
+ '!!billing_zip!!' => esc_html__( 'Billing Info Zip', 'paid-memberships-pro' ),
+ '!!billing_country!!' => esc_html__( 'Billing Info Country', 'paid-memberships-pro' ),
+ '!!billing_phone!!' => esc_html__( 'Billing Info Phone', 'paid-memberships-pro' ),
+ '!!billing_address!!' => esc_html__( 'Billing Info Complete Address', 'paid-memberships-pro' ),
+ '!!cardtype!!' => esc_html__( 'Credit Card Type', 'paid-memberships-pro' ),
+ '!!accountnumber!!' => esc_html__( 'Credit Card Number (last 4 digits)', 'paid-memberships-pro' ),
+ '!!expirationmonth!!' => esc_html__( 'Credit Card Expiration Month (mm format)', 'paid-memberships-pro' ),
+ '!!expirationyear!!' => esc_html__( 'Credit Card Expiration Year (yyyy format)', 'paid-memberships-pro' ),
);
}
diff --git a/classes/email-templates/class-pmpro-email-template-billing.php b/classes/email-templates/class-pmpro-email-template-billing.php
index 93d1dafbf..226a5c363 100644
--- a/classes/email-templates/class-pmpro-email-template-billing.php
+++ b/classes/email-templates/class-pmpro-email-template-billing.php
@@ -48,7 +48,7 @@ public static function get_template_slug() {
* @return string The "nice name" of the email template.
*/
public static function get_template_name() {
- return __( 'Billing Information Updated', 'paid-memberships-pro' );
+ return esc_html__( 'Billing Information Updated', 'paid-memberships-pro' );
}
/**
@@ -59,7 +59,7 @@ public static function get_template_name() {
* @return string The help text.
*/
public static function get_template_description() {
- return __( 'Members can update the payment method associated with their recurring subscription. This email is sent to the member as a confirmation of a payment method update', 'paid-memberships-pro' );
+ return esc_html__( 'Members can update the payment method associated with their recurring subscription. This email is sent to the member as a confirmation of a payment method update', 'paid-memberships-pro' );
}
/**
@@ -70,7 +70,7 @@ public static function get_template_description() {
* @return string The default subject for the email.
*/
public static function get_default_subject() {
- return __( 'Your billing information has been updated at !!sitename!!', 'paid-memberships-pro' );
+ return esc_html__( 'Your billing information has been updated at !!sitename!!', 'paid-memberships-pro' );
}
/**
@@ -81,7 +81,7 @@ public static function get_default_subject() {
* @return string The default body content for the email.
*/
public static function get_default_body() {
- return __( 'Your billing information at !!sitename!! has been changed.
Account: !!display_name!! (!!user_email!!)
+ return wp_kses_post( 'Your billing information at !!sitename!! has been changed.
Account: !!display_name!! (!!user_email!!)
Billing Information:
!!billing_address!!
@@ -103,26 +103,26 @@ public static function get_default_body() {
*/
public static function get_email_template_variables_with_description() {
return array(
- '!!subject!!' => __( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
- '!!user_email!!' => __( 'The email address of the user who cancelled their membership.', 'paid-memberships-pro' ),
- '!!display_name!!' => __( 'The display name of the user who cancelled their membership.', 'paid-memberships-pro' ),
- '!!name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
- '!!user_login!!' => __( 'The username of the user.', 'paid-memberships-pro' ),
- '!!membership_id!!' => __( 'The ID of the membership level.', 'paid-memberships-pro' ),
- '!!membership_level_name!!' => __( 'The name of the membership level.', 'paid-memberships-pro' ),
- '!!billing_name!!' => __( 'Billing Info Name', 'paid-memberships-pro' ),
- '!!billing_street!!' => __( 'Billing Info Street', 'paid-memberships-pro' ),
- '!!billing_street2!!' => __( 'Billing Info Street 2', 'paid-memberships-pro' ),
- '!!billing_city!!' => __( 'Billing Info City', 'paid-memberships-pro' ),
- '!!billing_state!!' => __( 'Billing Info State', 'paid-memberships-pro' ),
- '!!billing_zip!!' => __( 'Billing Info Zip', 'paid-memberships-pro' ),
- '!!billing_country!!' => __( 'Billing Info Country', 'paid-memberships-pro' ),
- '!!billing_phone!!' => __( 'Billing Info Phone', 'paid-memberships-pro' ),
- '!!billing_address!!' => __( 'Billing Info Complete Address', 'paid-memberships-pro' ),
- '!!cardtype!!' => __( 'Credit Card Type', 'paid-memberships-pro' ),
- '!!accountnumber!!' => __( 'Credit Card Number (last 4 digits)', 'paid-memberships-pro' ),
- '!!expirationmonth!!' => __( 'Credit Card Expiration Month (mm format)', 'paid-memberships-pro' ),
- '!!expirationyear!!' => __( 'Credit Card Expiration Year (yyyy format)', 'paid-memberships-pro' ),
+ '!!subject!!' => esc_html__( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
+ '!!user_email!!' => esc_html__( 'The email address of the user who cancelled their membership.', 'paid-memberships-pro' ),
+ '!!display_name!!' => esc_html__( 'The display name of the user who cancelled their membership.', 'paid-memberships-pro' ),
+ '!!name!!' => esc_html__( 'The display name of the user.', 'paid-memberships-pro' ),
+ '!!user_login!!' => esc_html__( 'The username of the user.', 'paid-memberships-pro' ),
+ '!!membership_id!!' => esc_html__( 'The ID of the membership level.', 'paid-memberships-pro' ),
+ '!!membership_level_name!!' => esc_html__( 'The name of the membership level.', 'paid-memberships-pro' ),
+ '!!billing_name!!' => esc_html__( 'Billing Info Name', 'paid-memberships-pro' ),
+ '!!billing_street!!' => esc_html__( 'Billing Info Street', 'paid-memberships-pro' ),
+ '!!billing_street2!!' => esc_html__( 'Billing Info Street 2', 'paid-memberships-pro' ),
+ '!!billing_city!!' => esc_html__( 'Billing Info City', 'paid-memberships-pro' ),
+ '!!billing_state!!' => esc_html__( 'Billing Info State', 'paid-memberships-pro' ),
+ '!!billing_zip!!' => esc_html__( 'Billing Info Zip', 'paid-memberships-pro' ),
+ '!!billing_country!!' => esc_html__( 'Billing Info Country', 'paid-memberships-pro' ),
+ '!!billing_phone!!' => esc_html__( 'Billing Info Phone', 'paid-memberships-pro' ),
+ '!!billing_address!!' => esc_html__( 'Billing Info Complete Address', 'paid-memberships-pro' ),
+ '!!cardtype!!' => esc_html__( 'Credit Card Type', 'paid-memberships-pro' ),
+ '!!accountnumber!!' => esc_html__( 'Credit Card Number (last 4 digits)', 'paid-memberships-pro' ),
+ '!!expirationmonth!!' => esc_html__( 'Credit Card Expiration Month (mm format)', 'paid-memberships-pro' ),
+ '!!expirationyear!!' => esc_html__( 'Credit Card Expiration Year (yyyy format)', 'paid-memberships-pro' ),
);
}
diff --git a/classes/email-templates/class-pmpro-email-template-cancel-admin.php b/classes/email-templates/class-pmpro-email-template-cancel-admin.php
index 7f79a756c..f18cddc50 100644
--- a/classes/email-templates/class-pmpro-email-template-cancel-admin.php
+++ b/classes/email-templates/class-pmpro-email-template-cancel-admin.php
@@ -51,7 +51,7 @@ public static function get_template_slug() {
* @return string The "nice name" of the email template.
*/
public static function get_template_name() {
- return __('Cancel (admin)', 'paid-memberships-pro');
+ return esc_html__('Cancel (admin)', 'paid-memberships-pro');
}
/**
@@ -62,7 +62,7 @@ public static function get_template_name() {
* @return string The "help text" to display to the admin when editing the email template.
*/
public static function get_template_description() {
- return __( 'The site administrator can manually cancel a user\'s membership through the WordPress admin or the member can cancel their own membership through your site. This email is sent to the site administrator as confirmation of a cancelled membership.', 'paid-memberships-pro' );
+ return esc_html__( 'The site administrator can manually cancel a user\'s membership through the WordPress admin or the member can cancel their own membership through your site. This email is sent to the site administrator as confirmation of a cancelled membership.', 'paid-memberships-pro' );
}
/**
@@ -73,7 +73,7 @@ public static function get_template_description() {
* @return string The default subject for the email.
*/
public static function get_default_subject() {
- return __( "Membership for !!user_login!! at !!sitename!! has been CANCELLED", 'paid-memberships-pro' );
+ return esc_html__( "Membership for !!user_login!! at !!sitename!! has been CANCELLED", 'paid-memberships-pro' );
}
/**
@@ -84,7 +84,7 @@ public static function get_default_subject() {
* @return string The default body content for the email.
*/
public static function get_default_body() {
- return __( '
The membership for !!user_login!! at !!sitename!! has been cancelled.
+ return wp_kses_post( 'The membership for !!user_login!! at !!sitename!! has been cancelled.
Account: !!display_name!! (!!user_email!!)
Membership Level: !!membership_level_name!!
@@ -103,12 +103,12 @@ public static function get_default_body() {
*/
public static function get_email_template_variables_with_description() {
return array(
- '!!user_email!!' => __( 'The email address of the user who cancelled their membership.', 'paid-memberships-pro' ),
- '!!display_name!!' => __( 'The display name of the user who cancelled their membership.', 'paid-memberships-pro' ),
- '!!user_login!!' => __( 'The login name of the user who cancelled their membership.', 'paid-memberships-pro' ),
- '!!membership_level_name!!' => __( 'The name of the membership level that was cancelled.', 'paid-memberships-pro' ),
- '!!startdate!!' => __( 'The start date of the membership level that was cancelled.', 'paid-memberships-pro' ),
- '!!enddate!!' => __( 'The end date of the membership level that was cancelled.', 'paid-memberships-pro' )
+ '!!user_email!!' => esc_html__( 'The email address of the user who cancelled their membership.', 'paid-memberships-pro' ),
+ '!!display_name!!' => esc_html__( 'The display name of the user who cancelled their membership.', 'paid-memberships-pro' ),
+ '!!user_login!!' => esc_html__( 'The login name of the user who cancelled their membership.', 'paid-memberships-pro' ),
+ '!!membership_level_name!!' => esc_html__( 'The name of the membership level that was cancelled.', 'paid-memberships-pro' ),
+ '!!startdate!!' => esc_html__( 'The start date of the membership level that was cancelled.', 'paid-memberships-pro' ),
+ '!!enddate!!' => esc_html__( 'The end date of the membership level that was cancelled.', 'paid-memberships-pro' )
);
}
@@ -151,7 +151,7 @@ public function get_email_template_variables() {
);
if ( empty( $this->cancelled_level_ids ) ) {
- $email_template_variables['membership_level_name'] = __( 'All Levels', 'paid-memberships-pro' );
+ $email_template_variables['membership_level_name'] = esc_html__( 'All Levels', 'paid-memberships-pro' );
} elseif ( is_array( $this->cancelled_level_ids ) ) {
$email_template_variables['membership_level_name'] = pmpro_implodeToEnglish( $wpdb->get_col( "SELECT name FROM $wpdb->pmpro_membership_levels WHERE id IN('" . implode( "','", $this->cancelled_level_ids ) . "')" ) );
} else {
diff --git a/classes/email-templates/class-pmpro-email-template-cancel-on-next-payment-date-admin.php b/classes/email-templates/class-pmpro-email-template-cancel-on-next-payment-date-admin.php
index af8d55638..3b458d769 100644
--- a/classes/email-templates/class-pmpro-email-template-cancel-on-next-payment-date-admin.php
+++ b/classes/email-templates/class-pmpro-email-template-cancel-on-next-payment-date-admin.php
@@ -47,7 +47,7 @@ public static function get_template_slug() {
* @return string The "nice name" of the email template.
*/
public static function get_template_name() {
- return __( 'Cancelled Auto-Renewals (admin)', 'paid-memberships-pro' );
+ return esc_html__( 'Cancelled Auto-Renewals (admin)', 'paid-memberships-pro' );
}
/**
@@ -58,7 +58,7 @@ public static function get_template_name() {
* @return string The "help text" to display to the admin when editing the email template.
*/
public static function get_template_description() {
- return __( 'When a user cancels a membership with a recurring subscription, they will still have access until when their next payment would have been taken. This email is sent to the site administrator to notify them of this change.', 'paid-memberships-pro' );
+ return esc_html__( 'When a user cancels a membership with a recurring subscription, they will still have access until when their next payment would have been taken. This email is sent to the site administrator to notify them of this change.', 'paid-memberships-pro' );
}
/**
@@ -69,7 +69,7 @@ public static function get_template_description() {
* @return string The default subject for the email.
*/
public static function get_default_subject() {
- return __( "Payment subscription for !!user_login!! at !!sitename!! has been CANCELLED", 'paid-memberships-pro' );
+ return esc_html__( "Payment subscription for !!user_login!! at !!sitename!! has been CANCELLED", 'paid-memberships-pro' );
}
/**
@@ -80,7 +80,7 @@ public static function get_default_subject() {
* @return string The default body content for the email.
*/
public static function get_default_body() {
- return __( 'The payment subscription for !!user_login!! at !!sitename!! has been cancelled.
+ return wp_kses_post( 'The payment subscription for !!user_login!! at !!sitename!! has been cancelled.
Account: !!display_name!! (!!user_email!!)
Membership Level: !!membership_level_name!!
Start Date: !!startdate!!
@@ -120,13 +120,13 @@ public function get_recipient_name() {
*/
public static function get_email_template_variables_with_description() {
return array(
- 'user_login' => __( 'The user\'s username.', 'paid-memberships-pro' ),
- 'user_email' => __( 'The user\'s email address.', 'paid-memberships-pro' ),
- 'display_name' => __( 'The user\'s display name.', 'paid-memberships-pro' ),
- 'membership_id' => __( 'The ID of the membership level.', 'paid-memberships-pro' ),
- 'membership_level_name' => __( 'The name of the membership level.', 'paid-memberships-pro' ),
- 'startdate' => __( 'The start date of the membership level.', 'paid-memberships-pro' ),
- 'enddate' => __( 'The end date of the membership level.', 'paid-memberships-pro' ),
+ 'user_login' => esc_html__( 'The user\'s username.', 'paid-memberships-pro' ),
+ 'user_email' => esc_html__( 'The user\'s email address.', 'paid-memberships-pro' ),
+ 'display_name' => esc_html__( 'The user\'s display name.', 'paid-memberships-pro' ),
+ 'membership_id' => esc_html__( 'The ID of the membership level.', 'paid-memberships-pro' ),
+ 'membership_level_name' => esc_html__( 'The name of the membership level.', 'paid-memberships-pro' ),
+ 'startdate' => esc_html__( 'The start date of the membership level.', 'paid-memberships-pro' ),
+ 'enddate' => esc_html__( 'The end date of the membership level.', 'paid-memberships-pro' ),
);
}
diff --git a/classes/email-templates/class-pmpro-email-template-cancel-on-next-payment-date.php b/classes/email-templates/class-pmpro-email-template-cancel-on-next-payment-date.php
index bb7638237..6516c0bf5 100644
--- a/classes/email-templates/class-pmpro-email-template-cancel-on-next-payment-date.php
+++ b/classes/email-templates/class-pmpro-email-template-cancel-on-next-payment-date.php
@@ -50,7 +50,7 @@ public static function get_template_slug() {
* @return string The "nice name" of the email template.
*/
public static function get_template_name() {
- return __( 'Cancelled Auto-Renewals', 'paid-memberships-pro' );
+ return esc_html__( 'Cancelled Auto-Renewals', 'paid-memberships-pro' );
}
/**
@@ -61,7 +61,7 @@ public static function get_template_name() {
* @return string The "help text" to display to the admin when editing the email template.
*/
public static function get_template_description() {
- return __( 'When a user cancels a membership with a recurring subscription, they will still have access until when their next payment would have been taken. This email is sent to the member to notify them of this change.', 'paid-memberships-pro' );
+ return esc_html__( 'When a user cancels a membership with a recurring subscription, they will still have access until when their next payment would have been taken. This email is sent to the member to notify them of this change.', 'paid-memberships-pro' );
}
/**
@@ -72,7 +72,7 @@ public static function get_template_description() {
* @return string The default subject for the email.
*/
public static function get_default_subject() {
- return __( 'Your payment subscription at !!sitename!! has been CANCELLED', 'paid-memberships-pro' );
+ return esc_html__( 'Your payment subscription at !!sitename!! has been CANCELLED', 'paid-memberships-pro' );
}
/**
@@ -83,7 +83,7 @@ public static function get_default_subject() {
* @return string The default body content for the email.
*/
public static function get_default_body() {
- return __( 'Your payment subscription at !!sitename!! has been cancelled.
+ return wp_kses_post( 'Your payment subscription at !!sitename!! has been cancelled.
Account: !!display_name!! (!!user_email!!)
Membership Level: !!membership_level_name!!
@@ -99,13 +99,13 @@ public static function get_default_body() {
*/
public static function get_email_template_variables_with_description() {
return array(
- 'user_login' => __( 'The user\'s username.', 'paid-memberships-pro' ),
- 'user_email' => __( 'The user\'s email address.', 'paid-memberships-pro' ),
- 'display_name' => __( 'The user\'s display name.', 'paid-memberships-pro' ),
- 'membership_id' => __( 'The ID of the membership level.', 'paid-memberships-pro' ),
- 'membership_level_name' => __( 'The name of the membership level.', 'paid-memberships-pro' ),
- 'startdate' => __( 'The start date of the membership level.', 'paid-memberships-pro' ),
- 'enddate' => __( 'The end date of the membership level.', 'paid-memberships-pro' ),
+ 'user_login' => esc_html__( 'The user\'s username.', 'paid-memberships-pro' ),
+ 'user_email' => esc_html__( 'The user\'s email address.', 'paid-memberships-pro' ),
+ 'display_name' => esc_html__( 'The user\'s display name.', 'paid-memberships-pro' ),
+ 'membership_id' => esc_html__( 'The ID of the membership level.', 'paid-memberships-pro' ),
+ 'membership_level_name' => esc_html__( 'The name of the membership level.', 'paid-memberships-pro' ),
+ 'startdate' => esc_html__( 'The start date of the membership level.', 'paid-memberships-pro' ),
+ 'enddate' => esc_html__( 'The end date of the membership level.', 'paid-memberships-pro' ),
);
}
diff --git a/classes/email-templates/class-pmpro-email-template-cancel.php b/classes/email-templates/class-pmpro-email-template-cancel.php
index a2f52454c..5efb882ae 100644
--- a/classes/email-templates/class-pmpro-email-template-cancel.php
+++ b/classes/email-templates/class-pmpro-email-template-cancel.php
@@ -50,7 +50,7 @@ public static function get_template_slug() {
* @return string The "nice name" of the email template.
*/
public static function get_template_name() {
- return __( 'Cancel', 'paid-memberships-pro' );
+ return esc_html__( 'Cancel', 'paid-memberships-pro' );
}
/**
@@ -61,7 +61,7 @@ public static function get_template_name() {
* @return string The "help text" to display to the admin when editing the email template.
*/
public static function get_template_description() {
- return __( 'The site administrator can manually cancel a user\'s membership through the WordPress admin or the member can cancel their own membership through your site. This email is sent to the member as confirmation of a cancelled membership.', 'paid-memberships-pro' );
+ return esc_html__( 'The site administrator can manually cancel a user\'s membership through the WordPress admin or the member can cancel their own membership through your site. This email is sent to the member as confirmation of a cancelled membership.', 'paid-memberships-pro' );
}
/**
@@ -72,7 +72,7 @@ public static function get_template_description() {
* @return string The default subject for the email.
*/
public static function get_default_subject() {
- return __( 'Your membership at !!sitename!! has been CANCELLED', 'paid-memberships-pro' );
+ return esc_html__( 'Your membership at !!sitename!! has been CANCELLED', 'paid-memberships-pro' );
}
/**
@@ -83,7 +83,7 @@ public static function get_default_subject() {
* @return string The default body content for the email.
*/
public static function get_default_body() {
- return __( 'Your membership at !!sitename!! has been cancelled.
+ return wp_kses_post( 'Your membership at !!sitename!! has been cancelled.
Account: !!display_name!! (!!user_email!!)
Membership Level: !!membership_level_name!!
@@ -100,11 +100,11 @@ public static function get_default_body() {
*/
public static function get_email_template_variables_with_description() {
return array(
- '!!user_email!!' => __( 'The email address of the user who cancelled their membership.', 'paid-memberships-pro' ),
- '!!display_name!!' => __( 'The display name of the user who cancelled their membership.', 'paid-memberships-pro' ),
- '!!user_login!!' => __( 'The login name of the user who cancelled their membership.', 'paid-memberships-pro' ),
- '!!membership_id!!' => __( 'The ID of the membership level that was cancelled.', 'paid-memberships-pro' ),
- '!!membership_level_name!!' => __( 'The name of the membership level that was cancelled.', 'paid-memberships-pro' ),
+ '!!user_email!!' => esc_html__( 'The email address of the user who cancelled their membership.', 'paid-memberships-pro' ),
+ '!!display_name!!' => esc_html__( 'The display name of the user who cancelled their membership.', 'paid-memberships-pro' ),
+ '!!user_login!!' => esc_html__( 'The login name of the user who cancelled their membership.', 'paid-memberships-pro' ),
+ '!!membership_id!!' => esc_html__( 'The ID of the membership level that was cancelled.', 'paid-memberships-pro' ),
+ '!!membership_level_name!!' => esc_html__( 'The name of the membership level that was cancelled.', 'paid-memberships-pro' ),
);
}
@@ -148,7 +148,7 @@ public function get_email_template_variables() {
if ( empty( $this->cancelled_level_ids ) ) {
$email_template_variables['membership_id'] = '';
- $email_template_variables['membership_level_name'] = __( 'All Levels', 'paid-memberships-pro' );
+ $email_template_variables['membership_level_name'] = esc_html__( 'All Levels', 'paid-memberships-pro' );
} elseif ( is_array( $this->cancelled_level_ids ) ) {
$email_template_variables['membership_id'] = $this->cancelled_level_ids[0]; // Pass just the first as the level id.
$email_template_variables['membership_level_name'] = pmpro_implodeToEnglish( $wpdb->get_col( "SELECT name FROM $wpdb->pmpro_membership_levels WHERE id IN('" . implode( "','", $this->cancelled_level_ids ) . "')" ) );
diff --git a/classes/email-templates/class-pmpro-email-template-checkout-check-admin.php b/classes/email-templates/class-pmpro-email-template-checkout-check-admin.php
index 55f46dca0..f00d771a6 100644
--- a/classes/email-templates/class-pmpro-email-template-checkout-check-admin.php
+++ b/classes/email-templates/class-pmpro-email-template-checkout-check-admin.php
@@ -47,7 +47,7 @@ public static function get_template_slug() {
* @return string The "nice name" of the email template.
*/
public static function get_template_name() {
- return __( 'Checkout - Pay by Check (admin)', 'paid-memberships-pro' );
+ return esc_html__( 'Checkout - Pay by Check (admin)', 'paid-memberships-pro' );
}
/**
@@ -58,8 +58,8 @@ public static function get_template_name() {
* @return string The help text.
*/
public static function get_template_description() {
- $check_gateway_label = get_option( 'pmpro_check_gateway_label' ) ? get_option( 'pmpro_check_gateway_label' ) : __( 'Check', 'paid-memberships-pro' );
- return sprintf( __('This is the membership confirmation email sent to the site administrator for every membership checkout using the "%s (Pay by Check)" gateway.', 'paid-memberships-pro' ), $check_gateway_label );
+ $check_gateway_label = get_option( 'pmpro_check_gateway_label' ) ? get_option( 'pmpro_check_gateway_label' ) : esc_html__( 'Check', 'paid-memberships-pro' );
+ return sprintf( esc_html__('This is the membership confirmation email sent to the site administrator for every membership checkout using the "%s (Pay by Check)" gateway.', 'paid-memberships-pro' ), $check_gateway_label );
}
/**
@@ -70,7 +70,7 @@ public static function get_template_description() {
* @return string The default subject for the email.
*/
public static function get_default_subject() {
- return __( 'Member checkout for !!membership_level_name!! at !!sitename!!', 'paid-memberships-pro' );
+ return esc_html__( 'Member checkout for !!membership_level_name!! at !!sitename!!', 'paid-memberships-pro' );
}
/**
@@ -81,9 +81,9 @@ public static function get_default_subject() {
* @return string The default body for the email.
*/
public static function get_default_body() {
- $check_gateway_label = get_option( 'pmpro_check_gateway_label' ) ? get_option( 'pmpro_check_gateway_label' ) : __( 'Check', 'paid-memberships-pro' );
+ $check_gateway_label = get_option( 'pmpro_check_gateway_label' ) ? get_option( 'pmpro_check_gateway_label' ) : esc_html__( 'Check', 'paid-memberships-pro' );
- return sprintf( __( 'There was a new member checkout at !!sitename!!.
+ return sprintf( wp_kses_post( 'There was a new member checkout at !!sitename!!.
They have chosen to pay by %s.
@@ -155,7 +155,7 @@ public function get_email_template_variables() {
}
if( $order->getDiscountCode() ) {
- $discount_code = "" . __( "Discount Code", 'paid-memberships-pro' ) . ": " . $order->discount_code->code . "
\n";
+ $discount_code = "" . esc_html__( "Discount Code", 'paid-memberships-pro' ) . ": " . $order->discount_code->code . "
\n";
} else {
$discount_code = "";
}
@@ -210,15 +210,15 @@ public function get_email_template_variables() {
public static function get_email_template_variables_with_description() {
return array(
- '!!subject!!' => __( 'The subject of the email.', 'paid-memberships-pro' ),
- '!!name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
- '!!display_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
- '!!user_login!!' => __( 'The login name of the email recipient.', 'paid-memberships-pro' ),
- '!!membership_id!!' => __( 'The ID of the membership level.', 'paid-memberships-pro' ),
- '!!membership_level_name!!' => __( 'The name of the membership level.', 'paid-memberships-pro' ),
- '!!confirmation_message!!' => __( 'The confirmation message for the membership level.', 'paid-memberships-pro' ),
- '!!membership_cost!!' => __( 'The cost of the membership level.', 'paid-memberships-pro' ),
- '!!user_email!!' => __( 'The email address of the email recipient.', 'paid-memberships-pro' ),
+ '!!subject!!' => esc_html__( 'The subject of the email.', 'paid-memberships-pro' ),
+ '!!name!!' => esc_html__( 'The name of the email recipient.', 'paid-memberships-pro' ),
+ '!!display_name!!' => esc_html__( 'The name of the email recipient.', 'paid-memberships-pro' ),
+ '!!user_login!!' => esc_html__( 'The login name of the email recipient.', 'paid-memberships-pro' ),
+ '!!membership_id!!' => esc_html__( 'The ID of the membership level.', 'paid-memberships-pro' ),
+ '!!membership_level_name!!' => esc_html__( 'The name of the membership level.', 'paid-memberships-pro' ),
+ '!!confirmation_message!!' => esc_html__( 'The confirmation message for the membership level.', 'paid-memberships-pro' ),
+ '!!membership_cost!!' => esc_html__( 'The cost of the membership level.', 'paid-memberships-pro' ),
+ '!!user_email!!' => esc_html__( 'The email address of the email recipient.', 'paid-memberships-pro' ),
);
}
diff --git a/classes/email-templates/class-pmpro-email-template-checkout-check.php b/classes/email-templates/class-pmpro-email-template-checkout-check.php
index d9f61e27f..6c96c1a96 100644
--- a/classes/email-templates/class-pmpro-email-template-checkout-check.php
+++ b/classes/email-templates/class-pmpro-email-template-checkout-check.php
@@ -48,7 +48,7 @@ public static function get_template_slug() {
* @return string The "nice name" of the email template.
*/
public static function get_template_name() {
- return __( 'Checkout - Pay by Check', 'paid-memberships-pro' );
+ return esc_html__( 'Checkout - Pay by Check', 'paid-memberships-pro' );
}
/**
@@ -59,7 +59,7 @@ public static function get_template_name() {
* @return string The help text.
*/
public static function get_template_description() {
- return __( 'This is a membership confirmation welcome email sent to a new member or to existing members that change their level using the "Pay by Check" gateway.', 'paid-memberships-pro' );
+ return esc_html__( 'This is a membership confirmation welcome email sent to a new member or to existing members that change their level using the "Pay by Check" gateway.', 'paid-memberships-pro' );
}
/**
@@ -70,7 +70,7 @@ public static function get_template_description() {
* @return string The default subject for the email.
*/
public static function get_default_subject() {
- return __( 'Your membership confirmation for !!sitename!!', 'paid-memberships-pro' );
+ return esc_html__( 'Your membership confirmation for !!sitename!!', 'paid-memberships-pro' );
}
/**
@@ -81,7 +81,7 @@ public static function get_default_subject() {
* @return string The default body for the email.
*/
public static function get_default_body() {
- return __('Thank you for your membership to !!sitename!!. Your membership account is now active.
+ return wp_kses_post('Thank you for your membership to !!sitename!!. Your membership account is now active.
!!membership_level_confirmation_message!!
@@ -134,20 +134,20 @@ public function get_recipient_name() {
public static function get_email_template_variables_with_description() {
return array(
- '!!subject!!' => __( 'The subject of the email.', 'paid-memberships-pro' ),
- '!!name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
- '!!display_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
- '!!user_login!!' => __( 'The login name of the email recipient.', 'paid-memberships-pro' ),
- '!!membership_id!!' => __( 'The ID of the membership level.', 'paid-memberships-pro' ),
- '!!membership_level_name!!' => __( 'The name of the membership level.', 'paid-memberships-pro' ),
- '!!confirmation_message!!' => __( 'The confirmation message for the membership level.', 'paid-memberships-pro' ),
- '!!membership_cost!!' => __( 'The cost of the membership level.', 'paid-memberships-pro' ),
- '!!user_email!!' => __( 'The email address of the email recipient.', 'paid-memberships-pro' ),
- '!!membership_expiration!!' => __( 'The expiration date of the membership level.', 'paid-memberships-pro' ),
- '!!discount_code!!' => __( 'The discount code used for the membership level.', 'paid-memberships-pro' ),
- '!!order_id!!' => __( 'The ID of the order.', 'paid-memberships-pro' ),
- '!!order_date!!' => __( 'The date of the order.', 'paid-memberships-pro' ),
- '!!order_total!!' => __( 'The total cost of the order.', 'paid-memberships-pro' ),
+ '!!subject!!' => esc_html__( 'The subject of the email.', 'paid-memberships-pro' ),
+ '!!name!!' => esc_html__( 'The name of the email recipient.', 'paid-memberships-pro' ),
+ '!!display_name!!' => esc_html__( 'The name of the email recipient.', 'paid-memberships-pro' ),
+ '!!user_login!!' => esc_html__( 'The login name of the email recipient.', 'paid-memberships-pro' ),
+ '!!membership_id!!' => esc_html__( 'The ID of the membership level.', 'paid-memberships-pro' ),
+ '!!membership_level_name!!' => esc_html__( 'The name of the membership level.', 'paid-memberships-pro' ),
+ '!!confirmation_message!!' => esc_html__( 'The confirmation message for the membership level.', 'paid-memberships-pro' ),
+ '!!membership_cost!!' => esc_html__( 'The cost of the membership level.', 'paid-memberships-pro' ),
+ '!!user_email!!' => esc_html__( 'The email address of the email recipient.', 'paid-memberships-pro' ),
+ '!!membership_expiration!!' => esc_html__( 'The expiration date of the membership level.', 'paid-memberships-pro' ),
+ '!!discount_code!!' => esc_html__( 'The discount code used for the membership level.', 'paid-memberships-pro' ),
+ '!!order_id!!' => esc_html__( 'The ID of the order.', 'paid-memberships-pro' ),
+ '!!order_date!!' => esc_html__( 'The date of the order.', 'paid-memberships-pro' ),
+ '!!order_total!!' => esc_html__( 'The total cost of the order.', 'paid-memberships-pro' ),
);
}
diff --git a/classes/email-templates/class-pmpro-email-template-checkout-free-admin.php b/classes/email-templates/class-pmpro-email-template-checkout-free-admin.php
index b9f02d185..b6fa088e7 100644
--- a/classes/email-templates/class-pmpro-email-template-checkout-free-admin.php
+++ b/classes/email-templates/class-pmpro-email-template-checkout-free-admin.php
@@ -48,7 +48,7 @@ public static function get_template_slug() {
* @return string The "nice name" of the email template.
*/
public static function get_template_name() {
- return __( 'Checkout - Free (admin)', 'paid-memberships-pro' );
+ return esc_html__( 'Checkout - Free (admin)', 'paid-memberships-pro' );
}
@@ -60,7 +60,7 @@ public static function get_template_name() {
* @return string The help text.
*/
public static function get_template_description() {
- return __( 'This is the membership confirmation email sent to the site administrator for every membership checkout that has no charge.', 'paid-memberships-pro' );
+ return esc_html__( 'This is the membership confirmation email sent to the site administrator for every membership checkout that has no charge.', 'paid-memberships-pro' );
}
@@ -72,7 +72,7 @@ public static function get_template_description() {
* @return string The email subject.
*/
public static function get_default_subject() {
- return __( "Member checkout for !!membership_level_name!! at !!sitename!!", 'paid-memberships-pro' );
+ return esc_html__( "Member checkout for !!membership_level_name!! at !!sitename!!", 'paid-memberships-pro' );
}
/**
@@ -83,7 +83,7 @@ public static function get_default_subject() {
* @return string The email body.
*/
public static function get_default_body() {
- return __( 'There was a new member checkout at !!sitename!!.
+ return wp_kses_post( 'There was a new member checkout at !!sitename!!.
Below are details about the new membership account.
Account: !!display_name!! (!!user_email!!)
@@ -128,17 +128,17 @@ public function get_recipient_name() {
public static function get_email_template_variables_with_description() {
return array(
- '!!subject!!' => __( 'The subject of the email.', 'paid-memberships-pro' ),
- '!!name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
- '!!display_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
- '!!user_login!!' => __( 'The login name of the email recipient.', 'paid-memberships-pro' ),
- '!!membership_id!!' => __( 'The ID of the membership level.', 'paid-memberships-pro' ),
- '!!membership_level_name!!' => __( 'The name of the membership level.', 'paid-memberships-pro' ),
- '!!confirmation_message!!' => __( 'The confirmation message for the membership level.', 'paid-memberships-pro' ),
- '!!membership_cost!!' => __( 'The cost of the membership level.', 'paid-memberships-pro' ),
- '!!user_email!!' => __( 'The email address of the email recipient.', 'paid-memberships-pro' ),
- '!!membership_expiration!!' => __( 'The expiration date of the membership level.', 'paid-memberships-pro' ),
- '!!discount_code!!' => __( 'The discount code used for the membership level.', 'paid-memberships-pro' ),
+ '!!subject!!' => esc_html__( 'The subject of the email.', 'paid-memberships-pro' ),
+ '!!name!!' => esc_html__( 'The name of the email recipient.', 'paid-memberships-pro' ),
+ '!!display_name!!' => esc_html__( 'The name of the email recipient.', 'paid-memberships-pro' ),
+ '!!user_login!!' => esc_html__( 'The login name of the email recipient.', 'paid-memberships-pro' ),
+ '!!membership_id!!' => esc_html__( 'The ID of the membership level.', 'paid-memberships-pro' ),
+ '!!membership_level_name!!' => esc_html__( 'The name of the membership level.', 'paid-memberships-pro' ),
+ '!!confirmation_message!!' => esc_html__( 'The confirmation message for the membership level.', 'paid-memberships-pro' ),
+ '!!membership_cost!!' => esc_html__( 'The cost of the membership level.', 'paid-memberships-pro' ),
+ '!!user_email!!' => esc_html__( 'The email address of the email recipient.', 'paid-memberships-pro' ),
+ '!!membership_expiration!!' => esc_html__( 'The expiration date of the membership level.', 'paid-memberships-pro' ),
+ '!!discount_code!!' => esc_html__( 'The discount code used for the membership level.', 'paid-memberships-pro' ),
);
}
@@ -169,7 +169,7 @@ public function get_email_template_variables() {
$discount_code = '';
if( $order->getDiscountCode() ) {
- $discount_code = "" . __("Discount Code", 'paid-memberships-pro' ) . ": " . $order->discount_code->code . "
\n";
+ $discount_code = "" . esc_html__("Discount Code", 'paid-memberships-pro' ) . ": " . $order->discount_code->code . "
\n";
}
diff --git a/classes/email-templates/class-pmpro-email-template-checkout-free.php b/classes/email-templates/class-pmpro-email-template-checkout-free.php
index cc2ffd7bb..bc4ec2afe 100644
--- a/classes/email-templates/class-pmpro-email-template-checkout-free.php
+++ b/classes/email-templates/class-pmpro-email-template-checkout-free.php
@@ -48,7 +48,7 @@ public static function get_template_slug() {
* @return string The "nice name" of the email template.
*/
public static function get_template_name() {
- return __( 'Checkout - Free', 'paid-memberships-pro' );
+ return esc_html__( 'Checkout - Free', 'paid-memberships-pro' );
}
/**
@@ -59,7 +59,7 @@ public static function get_template_name() {
* @return string The help text.
*/
public static function get_template_description() {
- return __( 'This is a membership confirmation welcome email sent to a new member or to existing members that change their level when the level has no charge.', 'paid-memberships-pro' );
+ return esc_html__( 'This is a membership confirmation welcome email sent to a new member or to existing members that change their level when the level has no charge.', 'paid-memberships-pro' );
}
/**
@@ -70,7 +70,7 @@ public static function get_template_description() {
* @return string The email subject.
*/
public static function get_default_subject() {
- return sprintf( __( 'Your membership confirmation for %s', 'paid-memberships-pro' ), get_option( 'blogname' ) );
+ return sprintf( esc_html__( 'Your membership confirmation for %s', 'paid-memberships-pro' ), get_option( 'blogname' ) );
}
/**
@@ -81,7 +81,7 @@ public static function get_default_subject() {
* @return string The email body.
*/
public static function get_default_body() {
- return __( 'Thank you for your membership to !!sitename!!. Your membership account is now active.
+ return wp_kses_post( 'Thank you for your membership to !!sitename!!. Your membership account is now active.
!!membership_level_confirmation_message!!
Below are details about your membership account.
@@ -122,17 +122,17 @@ public function get_recipient_name() {
public static function get_email_template_variables_with_description() {
return array(
- '!!subject!!' => __( 'The subject of the email.', 'paid-memberships-pro' ),
- '!!name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
- '!!display_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
- '!!user_login!!' => __( 'The login name of the email recipient.', 'paid-memberships-pro' ),
- '!!membership_id!!' => __( 'The ID of the membership level.', 'paid-memberships-pro' ),
- '!!membership_level_name!!' => __( 'The name of the membership level.', 'paid-memberships-pro' ),
- '!!confirmation_message!!' => __( 'The confirmation message for the membership level.', 'paid-memberships-pro' ),
- '!!membership_cost!!' => __( 'The cost of the membership level.', 'paid-memberships-pro' ),
- '!!user_email!!' => __( 'The email address of the email recipient.', 'paid-memberships-pro' ),
- '!!membership_expiration!!' => __( 'The expiration date of the membership level.', 'paid-memberships-pro' ),
- '!!discount_code!!' => __( 'The discount code used for the membership level.', 'paid-memberships-pro' ),
+ '!!subject!!' => esc_html__( 'The subject of the email.', 'paid-memberships-pro' ),
+ '!!name!!' => esc_html__( 'The name of the email recipient.', 'paid-memberships-pro' ),
+ '!!display_name!!' => esc_html__( 'The name of the email recipient.', 'paid-memberships-pro' ),
+ '!!user_login!!' => esc_html__( 'The login name of the email recipient.', 'paid-memberships-pro' ),
+ '!!membership_id!!' => esc_html__( 'The ID of the membership level.', 'paid-memberships-pro' ),
+ '!!membership_level_name!!' => esc_html__( 'The name of the membership level.', 'paid-memberships-pro' ),
+ '!!confirmation_message!!' => esc_html__( 'The confirmation message for the membership level.', 'paid-memberships-pro' ),
+ '!!membership_cost!!' => esc_html__( 'The cost of the membership level.', 'paid-memberships-pro' ),
+ '!!user_email!!' => esc_html__( 'The email address of the email recipient.', 'paid-memberships-pro' ),
+ '!!membership_expiration!!' => esc_html__( 'The expiration date of the membership level.', 'paid-memberships-pro' ),
+ '!!discount_code!!' => esc_html__( 'The discount code used for the membership level.', 'paid-memberships-pro' ),
);
}
@@ -163,7 +163,7 @@ public function get_email_template_variables() {
$discount_code = '';
if( $order->getDiscountCode() ) {
- $discount_code = "" . __("Discount Code", 'paid-memberships-pro' ) . ": " . $order->discount_code->code . "
\n";
+ $discount_code = "" . esc_html__("Discount Code", 'paid-memberships-pro' ) . ": " . $order->discount_code->code . "
\n";
}
diff --git a/classes/email-templates/class-pmpro-email-template-checkout-paid-admin.php b/classes/email-templates/class-pmpro-email-template-checkout-paid-admin.php
index 56e11380c..e36e2dcef 100644
--- a/classes/email-templates/class-pmpro-email-template-checkout-paid-admin.php
+++ b/classes/email-templates/class-pmpro-email-template-checkout-paid-admin.php
@@ -47,7 +47,7 @@ public static function get_template_slug() {
* @return string The "nice name" of the email template.
*/
public static function get_template_name() {
- return __( 'Checkout - Paid (admin)', 'paid-memberships-pro' );
+ return esc_html__( 'Checkout - Paid (admin)', 'paid-memberships-pro' );
}
/**
@@ -58,7 +58,7 @@ public static function get_template_name() {
* @return string The help text.
*/
public static function get_template_description() {
- return __( 'This is the membership confirmation email sent to the site administrator for every paid membership checkout on the site.', 'paid-memberships-pro' );
+ return esc_html__( 'This is the membership confirmation email sent to the site administrator for every paid membership checkout on the site.', 'paid-memberships-pro' );
}
/**
@@ -69,7 +69,7 @@ public static function get_template_description() {
* @return string The email subject.
*/
public static function get_default_subject() {
- return __( 'Member checkout for !!membership_level_name!! at !!sitename!!', 'paid-memberships-pro' );
+ return esc_html__( 'Member checkout for !!membership_level_name!! at !!sitename!!', 'paid-memberships-pro' );
}
/**
@@ -80,7 +80,7 @@ public static function get_default_subject() {
* @return string The email body.
*/
public static function get_default_body() {
- return __( 'There was a new member checkout at !!sitename!!.
+ return wp_kses_post( 'There was a new member checkout at !!sitename!!.
Below are details about the new membership account and a receipt for the initial membership order.
Account: !!display_name!! (!!user_email!!)
@@ -157,7 +157,7 @@ public function get_email_template_variables() {
$discount_code = '';
if( $order->getDiscountCode() ) {
- $discount_code = "" . __("Discount Code", 'paid-memberships-pro' ) . ": " . $order->discount_code->code . "
\n";
+ $discount_code = "" . esc_html__("Discount Code", 'paid-memberships-pro' ) . ": " . $order->discount_code->code . "
\n";
}
$email_template_variables = array(
@@ -212,33 +212,33 @@ public function get_email_template_variables() {
public static function get_email_template_variables_with_description() {
return array(
- '!!subject!!' => __( 'The subject of the email.', 'paid-memberships-pro' ),
- '!!name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
- '!!display_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
- '!!user_login!!' => __( 'The login name of the email recipient.', 'paid-memberships-pro' ),
- '!!membership_id!!' => __( 'The ID of the membership level.', 'paid-memberships-pro' ),
- '!!membership_level_name!!' => __( 'The name of the membership level.', 'paid-memberships-pro' ),
- '!!confirmation_message!!' => __( 'The confirmation message for the membership level.', 'paid-memberships-pro' ),
- '!!membership_cost!!' => __( 'The cost of the membership level.', 'paid-memberships-pro' ),
- '!!user_email!!' => __( 'The email address of the email recipient.', 'paid-memberships-pro' ),
- '!!membership_expiration!!' => __( 'The expiration date of the membership level.', 'paid-memberships-pro' ),
- '!!discount_code!!' => __( 'The discount code used for the membership level.', 'paid-memberships-pro' ),
- '!!order_id!!' => __( 'The ID of the order.', 'paid-memberships-pro' ),
- '!!order_date!!' => __( 'The date of the order.', 'paid-memberships-pro' ),
- '!!order_total!!' => __( 'The total cost of the order.', 'paid-memberships-pro' ),
- '!!billing_name!!' => __( 'Billing Info Name', 'paid-memberships-pro' ),
- '!!billing_street!!' => __( 'Billing Info Street', 'paid-memberships-pro' ),
- '!!billing_street2!!' => __( 'Billing Info Street 2', 'paid-memberships-pro' ),
- '!!billing_city!!' => __( 'Billing Info City', 'paid-memberships-pro' ),
- '!!billing_state!!' => __( 'Billing Info State', 'paid-memberships-pro' ),
- '!!billing_zip!!' => __( 'Billing Info Zip', 'paid-memberships-pro' ),
- '!!billing_country!!' => __( 'Billing Info Country', 'paid-memberships-pro' ),
- '!!billing_phone!!' => __( 'Billing Info Phone', 'paid-memberships-pro' ),
- '!!billing_address!!' => __( 'Billing Info Complete Address', 'paid-memberships-pro' ),
- '!!cardtype!!' => __( 'Credit Card Type', 'paid-memberships-pro' ),
- '!!accountnumber!!' => __( 'Credit Card Number (last 4 digits)', 'paid-memberships-pro' ),
- '!!expirationmonth!!' => __( 'Credit Card Expiration Month (mm format)', 'paid-memberships-pro' ),
- '!!expirationyear!!' => __( 'Credit Card Expiration Year (yyyy format)', 'paid-memberships-pro' ),
+ '!!subject!!' => esc_html__( 'The subject of the email.', 'paid-memberships-pro' ),
+ '!!name!!' => esc_html__( 'The name of the email recipient.', 'paid-memberships-pro' ),
+ '!!display_name!!' => esc_html__( 'The name of the email recipient.', 'paid-memberships-pro' ),
+ '!!user_login!!' => esc_html__( 'The login name of the email recipient.', 'paid-memberships-pro' ),
+ '!!membership_id!!' => esc_html__( 'The ID of the membership level.', 'paid-memberships-pro' ),
+ '!!membership_level_name!!' => esc_html__( 'The name of the membership level.', 'paid-memberships-pro' ),
+ '!!confirmation_message!!' => esc_html__( 'The confirmation message for the membership level.', 'paid-memberships-pro' ),
+ '!!membership_cost!!' => esc_html__( 'The cost of the membership level.', 'paid-memberships-pro' ),
+ '!!user_email!!' => esc_html__( 'The email address of the email recipient.', 'paid-memberships-pro' ),
+ '!!membership_expiration!!' => esc_html__( 'The expiration date of the membership level.', 'paid-memberships-pro' ),
+ '!!discount_code!!' => esc_html__( 'The discount code used for the membership level.', 'paid-memberships-pro' ),
+ '!!order_id!!' => esc_html__( 'The ID of the order.', 'paid-memberships-pro' ),
+ '!!order_date!!' => esc_html__( 'The date of the order.', 'paid-memberships-pro' ),
+ '!!order_total!!' => esc_html__( 'The total cost of the order.', 'paid-memberships-pro' ),
+ '!!billing_name!!' => esc_html__( 'Billing Info Name', 'paid-memberships-pro' ),
+ '!!billing_street!!' => esc_html__( 'Billing Info Street', 'paid-memberships-pro' ),
+ '!!billing_street2!!' => esc_html__( 'Billing Info Street 2', 'paid-memberships-pro' ),
+ '!!billing_city!!' => esc_html__( 'Billing Info City', 'paid-memberships-pro' ),
+ '!!billing_state!!' => esc_html__( 'Billing Info State', 'paid-memberships-pro' ),
+ '!!billing_zip!!' => esc_html__( 'Billing Info Zip', 'paid-memberships-pro' ),
+ '!!billing_country!!' => esc_html__( 'Billing Info Country', 'paid-memberships-pro' ),
+ '!!billing_phone!!' => esc_html__( 'Billing Info Phone', 'paid-memberships-pro' ),
+ '!!billing_address!!' => esc_html__( 'Billing Info Complete Address', 'paid-memberships-pro' ),
+ '!!cardtype!!' => esc_html__( 'Credit Card Type', 'paid-memberships-pro' ),
+ '!!accountnumber!!' => esc_html__( 'Credit Card Number (last 4 digits)', 'paid-memberships-pro' ),
+ '!!expirationmonth!!' => esc_html__( 'Credit Card Expiration Month (mm format)', 'paid-memberships-pro' ),
+ '!!expirationyear!!' => esc_html__( 'Credit Card Expiration Year (yyyy format)', 'paid-memberships-pro' ),
);
}
}
diff --git a/classes/email-templates/class-pmpro-email-template-checkout-paid.php b/classes/email-templates/class-pmpro-email-template-checkout-paid.php
index f9362efda..3f983fe3f 100644
--- a/classes/email-templates/class-pmpro-email-template-checkout-paid.php
+++ b/classes/email-templates/class-pmpro-email-template-checkout-paid.php
@@ -52,7 +52,7 @@ public static function get_template_slug() {
* @return string The "nice name" of the email template.
*/
public static function get_template_name() {
- return __( 'Checkout - Paid', 'paid-memberships-pro' );
+ return esc_html__( 'Checkout - Paid', 'paid-memberships-pro' );
}
/**
@@ -63,7 +63,7 @@ public static function get_template_name() {
* @return string The help text.
*/
public static function get_template_description() {
- return __( 'This is a membership confirmation welcome email sent to a new member or to existing members that change their level and complete a paid checkout on the site.', 'paid-memberships-pro' );
+ return esc_html__( 'This is a membership confirmation welcome email sent to a new member or to existing members that change their level and complete a paid checkout on the site.', 'paid-memberships-pro' );
}
/**
@@ -74,7 +74,7 @@ public static function get_template_description() {
* @return string The email subject.
*/
public static function get_default_subject() {
- return __( "Your membership confirmation for !!sitename!!", 'paid-memberships-pro' );
+ return esc_html__( "Your membership confirmation for !!sitename!!", 'paid-memberships-pro' );
}
/**
@@ -85,7 +85,7 @@ public static function get_default_subject() {
* @return string The email body.
*/
public static function get_default_body() {
- return __( 'Thank you for your membership to !!sitename!!. Your membership account is now active.
+ return wp_kses_post( 'Thank you for your membership to !!sitename!!. Your membership account is now active.
!!membership_level_confirmation_message!!
Below are details about your membership account and a receipt for your initial membership order.
@@ -161,7 +161,7 @@ public function get_email_template_variables() {
$discount_code = '';
if( $order->getDiscountCode() ) {
- $discount_code = "" . __("Discount Code", 'paid-memberships-pro' ) . ": " . $order->discount_code->code . "
\n";
+ $discount_code = "" . esc_html__("Discount Code", 'paid-memberships-pro' ) . ": " . $order->discount_code->code . "
\n";
}
$email_template_variables = array(
@@ -216,33 +216,33 @@ public function get_email_template_variables() {
public static function get_email_template_variables_with_description() {
return array(
- '!!subject!!' => __( 'The subject of the email.', 'paid-memberships-pro' ),
- '!!name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
- '!!display_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
- '!!user_login!!' => __( 'The login name of the email recipient.', 'paid-memberships-pro' ),
- '!!membership_id!!' => __( 'The ID of the membership level.', 'paid-memberships-pro' ),
- '!!membership_level_name!!' => __( 'The name of the membership level.', 'paid-memberships-pro' ),
- '!!confirmation_message!!' => __( 'The confirmation message for the membership level.', 'paid-memberships-pro' ),
- '!!membership_cost!!' => __( 'The cost of the membership level.', 'paid-memberships-pro' ),
- '!!user_email!!' => __( 'The email address of the email recipient.', 'paid-memberships-pro' ),
- '!!membership_expiration!!' => __( 'The expiration date of the membership level.', 'paid-memberships-pro' ),
- '!!discount_code!!' => __( 'The discount code used for the membership level.', 'paid-memberships-pro' ),
- '!!order_id!!' => __( 'The ID of the order.', 'paid-memberships-pro' ),
- '!!order_date!!' => __( 'The date of the order.', 'paid-memberships-pro' ),
- '!!order_total!!' => __( 'The total cost of the order.', 'paid-memberships-pro' ),
- '!!billing_name!!' => __( 'Billing Info Name', 'paid-memberships-pro' ),
- '!!billing_street!!' => __( 'Billing Info Street', 'paid-memberships-pro' ),
- '!!billing_street2!!' => __( 'Billing Info Street 2', 'paid-memberships-pro' ),
- '!!billing_city!!' => __( 'Billing Info City', 'paid-memberships-pro' ),
- '!!billing_state!!' => __( 'Billing Info State', 'paid-memberships-pro' ),
- '!!billing_zip!!' => __( 'Billing Info Zip', 'paid-memberships-pro' ),
- '!!billing_country!!' => __( 'Billing Info Country', 'paid-memberships-pro' ),
- '!!billing_phone!!' => __( 'Billing Info Phone', 'paid-memberships-pro' ),
- '!!billing_address!!' => __( 'Billing Info Complete Address', 'paid-memberships-pro' ),
- '!!cardtype!!' => __( 'Credit Card Type', 'paid-memberships-pro' ),
- '!!accountnumber!!' => __( 'Credit Card Number (last 4 digits)', 'paid-memberships-pro' ),
- '!!expirationmonth!!' => __( 'Credit Card Expiration Month (mm format)', 'paid-memberships-pro' ),
- '!!expirationyear!!' => __( 'Credit Card Expiration Year (yyyy format)', 'paid-memberships-pro' ),
+ '!!subject!!' => esc_html__( 'The subject of the email.', 'paid-memberships-pro' ),
+ '!!name!!' => esc_html__( 'The name of the email recipient.', 'paid-memberships-pro' ),
+ '!!display_name!!' => esc_html__( 'The name of the email recipient.', 'paid-memberships-pro' ),
+ '!!user_login!!' => esc_html__( 'The login name of the email recipient.', 'paid-memberships-pro' ),
+ '!!membership_id!!' => esc_html__( 'The ID of the membership level.', 'paid-memberships-pro' ),
+ '!!membership_level_name!!' => esc_html__( 'The name of the membership level.', 'paid-memberships-pro' ),
+ '!!confirmation_message!!' => esc_html__( 'The confirmation message for the membership level.', 'paid-memberships-pro' ),
+ '!!membership_cost!!' => esc_html__( 'The cost of the membership level.', 'paid-memberships-pro' ),
+ '!!user_email!!' => esc_html__( 'The email address of the email recipient.', 'paid-memberships-pro' ),
+ '!!membership_expiration!!' => esc_html__( 'The expiration date of the membership level.', 'paid-memberships-pro' ),
+ '!!discount_code!!' => esc_html__( 'The discount code used for the membership level.', 'paid-memberships-pro' ),
+ '!!order_id!!' => esc_html__( 'The ID of the order.', 'paid-memberships-pro' ),
+ '!!order_date!!' => esc_html__( 'The date of the order.', 'paid-memberships-pro' ),
+ '!!order_total!!' => esc_html__( 'The total cost of the order.', 'paid-memberships-pro' ),
+ '!!billing_name!!' => esc_html__( 'Billing Info Name', 'paid-memberships-pro' ),
+ '!!billing_street!!' => esc_html__( 'Billing Info Street', 'paid-memberships-pro' ),
+ '!!billing_street2!!' => esc_html__( 'Billing Info Street 2', 'paid-memberships-pro' ),
+ '!!billing_city!!' => esc_html__( 'Billing Info City', 'paid-memberships-pro' ),
+ '!!billing_state!!' => esc_html__( 'Billing Info State', 'paid-memberships-pro' ),
+ '!!billing_zip!!' => esc_html__( 'Billing Info Zip', 'paid-memberships-pro' ),
+ '!!billing_country!!' => esc_html__( 'Billing Info Country', 'paid-memberships-pro' ),
+ '!!billing_phone!!' => esc_html__( 'Billing Info Phone', 'paid-memberships-pro' ),
+ '!!billing_address!!' => esc_html__( 'Billing Info Complete Address', 'paid-memberships-pro' ),
+ '!!cardtype!!' => esc_html__( 'Credit Card Type', 'paid-memberships-pro' ),
+ '!!accountnumber!!' => esc_html__( 'Credit Card Number (last 4 digits)', 'paid-memberships-pro' ),
+ '!!expirationmonth!!' => esc_html__( 'Credit Card Expiration Month (mm format)', 'paid-memberships-pro' ),
+ '!!expirationyear!!' => esc_html__( 'Credit Card Expiration Year (yyyy format)', 'paid-memberships-pro' ),
);
}
}
diff --git a/classes/email-templates/class-pmpro-email-template-credit-card-expiring.php b/classes/email-templates/class-pmpro-email-template-credit-card-expiring.php
index 5e4e2ec8e..a4946d78b 100644
--- a/classes/email-templates/class-pmpro-email-template-credit-card-expiring.php
+++ b/classes/email-templates/class-pmpro-email-template-credit-card-expiring.php
@@ -47,7 +47,7 @@ public static function get_template_slug() {
* @return string The "nice name" of the email template.
*/
public static function get_template_name() {
- return __( 'Credit Card Expiring', 'paid-memberships-pro' );
+ return esc_html__( 'Credit Card Expiring', 'paid-memberships-pro' );
}
/**
@@ -58,7 +58,7 @@ public static function get_template_name() {
* @return string The "help text" to display to the admin when editing the email template.
*/
public static function get_template_description() {
- return __( 'This is the membership confirmation email sent to the site administrator for every paid membership checkout on the site.', 'paid-memberships-pro' );
+ return esc_html__( 'This is the membership confirmation email sent to the site administrator for every paid membership checkout on the site.', 'paid-memberships-pro' );
}
/**
@@ -69,7 +69,7 @@ public static function get_template_description() {
* @return string The default subject for the email.
*/
public static function get_default_subject() {
- return __( 'Credit card on file expiring soon at !!sitename!!', 'paid-memberships-pro' );
+ return esc_html__( 'Credit card on file expiring soon at !!sitename!!', 'paid-memberships-pro' );
}
/**
@@ -80,7 +80,7 @@ public static function get_default_subject() {
* @return string The default body content for the email.
*/
public static function get_default_body() {
- return __( 'The payment method used for your membership at !!sitename!! will expire soon. Please click the following link to log in and update your billing information to avoid account suspension. !!login_url!!
+ return wp_kses_post( 'The payment method used for your membership at !!sitename!! will expire soon. Please click the following link to log in and update your billing information to avoid account suspension. !!login_url!!
Account: !!display_name!! (!!user_email!!)
The most recent account information we have on file is:
@@ -125,27 +125,27 @@ public function get_recipient_name() {
*/
public static function get_email_template_variables_with_description() {
return array(
- '!!subject!!' => __( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
- '!!name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
- '!!membership_id!!' => __( 'The ID of the membership level.', 'paid-memberships-pro' ),
- '!!membership_level_name!!' => __( 'The name of the membership level.', 'paid-memberships-pro' ),
- '!!user_login!!' => __( 'The username of the user.', 'paid-memberships-pro' ),
- '!!user_email!!' => __( 'The email address of the user.', 'paid-memberships-pro' ),
- '!!display_name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
- '!!subject!!' => __( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
- '!!billing_address!!' => __( 'Billing Info Complete Address', 'paid-memberships-pro' ),
- '!!billing_name!!' => __( 'The billing name of the user.', 'paid-memberships-pro' ),
- '!!billing_street!!' => __( 'The billing street address of the user.', 'paid-memberships-pro' ),
- '!!billing_street2!!' => __( 'The second billing street field address of the user.', 'paid-memberships-pro' ),
- '!!billing_city!!' => __( 'The billing city of the user.', 'paid-memberships-pro' ),
- '!!billing_state!!' => __( 'The billing state of the user.', 'paid-memberships-pro' ),
- '!!billing_zip!!' => __( 'The billing ZIP code of the user.', 'paid-memberships-pro' ),
- '!!billing_country!!' => __( 'The billing country of the user.', 'paid-memberships-pro' ),
- '!!billing_phone!!' => __( 'The billing phone number of the user.', 'paid-memberships-pro' ),
- '!!cardtype!!' => __( 'The type of credit card used.', 'paid-memberships-pro' ),
- '!!accountnumber!!' => __( 'The last four digits of the credit card number.', 'paid-memberships-pro' ),
- '!!expirationmonth!!' => __( 'The expiration month of the credit card.', 'paid-memberships-pro' ),
- '!!expirationyear!!' => __( 'The expiration year of the credit card.', 'paid-memberships-pro' ),
+ '!!subject!!' => esc_html__( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
+ '!!name!!' => esc_html__( 'The display name of the user.', 'paid-memberships-pro' ),
+ '!!membership_id!!' => esc_html__( 'The ID of the membership level.', 'paid-memberships-pro' ),
+ '!!membership_level_name!!' => esc_html__( 'The name of the membership level.', 'paid-memberships-pro' ),
+ '!!user_login!!' => esc_html__( 'The username of the user.', 'paid-memberships-pro' ),
+ '!!user_email!!' => esc_html__( 'The email address of the user.', 'paid-memberships-pro' ),
+ '!!display_name!!' => esc_html__( 'The display name of the user.', 'paid-memberships-pro' ),
+ '!!subject!!' => esc_html__( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
+ '!!billing_address!!' => esc_html__( 'Billing Info Complete Address', 'paid-memberships-pro' ),
+ '!!billing_name!!' => esc_html__( 'The billing name of the user.', 'paid-memberships-pro' ),
+ '!!billing_street!!' => esc_html__( 'The billing street address of the user.', 'paid-memberships-pro' ),
+ '!!billing_street2!!' => esc_html__( 'The second billing street field address of the user.', 'paid-memberships-pro' ),
+ '!!billing_city!!' => esc_html__( 'The billing city of the user.', 'paid-memberships-pro' ),
+ '!!billing_state!!' => esc_html__( 'The billing state of the user.', 'paid-memberships-pro' ),
+ '!!billing_zip!!' => esc_html__( 'The billing ZIP code of the user.', 'paid-memberships-pro' ),
+ '!!billing_country!!' => esc_html__( 'The billing country of the user.', 'paid-memberships-pro' ),
+ '!!billing_phone!!' => esc_html__( 'The billing phone number of the user.', 'paid-memberships-pro' ),
+ '!!cardtype!!' => esc_html__( 'The type of credit card used.', 'paid-memberships-pro' ),
+ '!!accountnumber!!' => esc_html__( 'The last four digits of the credit card number.', 'paid-memberships-pro' ),
+ '!!expirationmonth!!' => esc_html__( 'The expiration month of the credit card.', 'paid-memberships-pro' ),
+ '!!expirationyear!!' => esc_html__( 'The expiration year of the credit card.', 'paid-memberships-pro' ),
);
}
diff --git a/classes/email-templates/class-pmpro-email-template-membership-expired.php b/classes/email-templates/class-pmpro-email-template-membership-expired.php
index f1690b0b5..b1edf6cba 100644
--- a/classes/email-templates/class-pmpro-email-template-membership-expired.php
+++ b/classes/email-templates/class-pmpro-email-template-membership-expired.php
@@ -47,7 +47,7 @@ public static function get_template_slug() {
* @return string The "nice name" of the email template.
*/
public static function get_template_name() {
- return __( 'Membership Expired', 'paid-memberships-pro' );
+ return esc_html__( 'Membership Expired', 'paid-memberships-pro' );
}
/**
@@ -58,7 +58,7 @@ public static function get_template_name() {
* @return string The "help text" to display to the admin when editing the email template.
*/
public static function get_template_description() {
- return __( 'This email is sent to the member when their membership expires.', 'paid-memberships-pro' );
+ return esc_html__( 'This email is sent to the member when their membership expires.', 'paid-memberships-pro' );
}
/**
@@ -69,7 +69,7 @@ public static function get_template_description() {
* @return string The default subject for the email.
*/
public static function get_default_subject() {
- return __( 'Your membership at !!sitename!! has ended', 'paid-memberships-pro' );
+ return esc_html__( 'Your membership at !!sitename!! has ended', 'paid-memberships-pro' );
}
/**
@@ -80,7 +80,7 @@ public static function get_default_subject() {
* @return string The default body content for the email.
*/
public static function get_default_body() {
- return __( 'Your membership at !!sitename!! has ended.
+ return wp_kses_post( 'Your membership at !!sitename!! has ended.
Thank you for your support.
@@ -121,13 +121,13 @@ public function get_recipient_name() {
*/
public static function get_email_template_variables_with_description() {
return array(
- '!!subject!!' => __( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
- '!!name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
- '!!membership_id!!' => __( 'The ID of the membership level.', 'paid-memberships-pro' ),
- '!!membership_level_name!!' => __( 'The name of the membership level.', 'paid-memberships-pro' ),
- '!!user_login!!' => __( 'The username of the user.', 'paid-memberships-pro' ),
- '!!user_email!!' => __( 'The email address of the user.', 'paid-memberships-pro' ),
- '!!display_name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
+ '!!subject!!' => esc_html__( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
+ '!!name!!' => esc_html__( 'The display name of the user.', 'paid-memberships-pro' ),
+ '!!membership_id!!' => esc_html__( 'The ID of the membership level.', 'paid-memberships-pro' ),
+ '!!membership_level_name!!' => esc_html__( 'The name of the membership level.', 'paid-memberships-pro' ),
+ '!!user_login!!' => esc_html__( 'The username of the user.', 'paid-memberships-pro' ),
+ '!!user_email!!' => esc_html__( 'The email address of the user.', 'paid-memberships-pro' ),
+ '!!display_name!!' => esc_html__( 'The display name of the user.', 'paid-memberships-pro' ),
);
}
diff --git a/classes/email-templates/class-pmpro-email-template-membership-expiring.php b/classes/email-templates/class-pmpro-email-template-membership-expiring.php
index 22f85c1b9..9b638ba07 100644
--- a/classes/email-templates/class-pmpro-email-template-membership-expiring.php
+++ b/classes/email-templates/class-pmpro-email-template-membership-expiring.php
@@ -47,7 +47,7 @@ public static function get_template_slug() {
* @return string The "nice name" of the email template.
*/
public static function get_template_name() {
- return __( 'Membership Expiring', 'paid-memberships-pro' );
+ return esc_html__( 'Membership Expiring', 'paid-memberships-pro' );
}
/**
@@ -58,7 +58,7 @@ public static function get_template_name() {
* @return string The "help text" to display to the admin when editing the email template.
*/
public static function get_template_description() {
- return __( 'This email is sent to the member when their expiration date is approaching, at an interval based on the term of the membership.', 'paid-memberships-pro' );
+ return esc_html__( 'This email is sent to the member when their expiration date is approaching, at an interval based on the term of the membership.', 'paid-memberships-pro' );
}
/**
@@ -69,7 +69,7 @@ public static function get_template_description() {
* @return string The default subject for the email.
*/
public static function get_default_subject() {
- return __( "Your membership at !!sitename!! will end soon", 'paid-memberships-pro' );
+ return esc_html__( "Your membership at !!sitename!! will end soon", 'paid-memberships-pro' );
}
/**
@@ -80,7 +80,7 @@ public static function get_default_subject() {
* @return string The default body content for the email.
*/
public static function get_default_body() {
- return __( 'Thank you for your membership to !!sitename!!. This is just a reminder that your membership will end on !!enddate!!.
+ return wp_kses_post( 'Thank you for your membership to !!sitename!!. This is just a reminder that your membership will end on !!enddate!!.
Account: !!display_name!! (!!user_email!!)
Membership Level: !!membership_level_name!!
@@ -120,14 +120,14 @@ public function get_recipient_name() {
*/
public static function get_email_template_variables_with_description() {
return array(
- '!!subject!!' => __( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
- '!!name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
- '!!membership_id!!' => __( 'The ID of the membership level.', 'paid-memberships-pro' ),
- '!!membership_level_name!!' => __( 'The name of the membership level.', 'paid-memberships-pro' ),
- '!!user_login!!' => __( 'The username of the user.', 'paid-memberships-pro' ),
- '!!user_email!!' => __( 'The email address of the user.', 'paid-memberships-pro' ),
- '!!display_name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
- '!!enddate!!' => __( 'The expiration date of the membership level.', 'paid-memberships-pro' ),
+ '!!subject!!' => esc_html__( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
+ '!!name!!' => esc_html__( 'The display name of the user.', 'paid-memberships-pro' ),
+ '!!membership_id!!' => esc_html__( 'The ID of the membership level.', 'paid-memberships-pro' ),
+ '!!membership_level_name!!' => esc_html__( 'The name of the membership level.', 'paid-memberships-pro' ),
+ '!!user_login!!' => esc_html__( 'The username of the user.', 'paid-memberships-pro' ),
+ '!!user_email!!' => esc_html__( 'The email address of the user.', 'paid-memberships-pro' ),
+ '!!display_name!!' => esc_html__( 'The display name of the user.', 'paid-memberships-pro' ),
+ '!!enddate!!' => esc_html__( 'The expiration date of the membership level.', 'paid-memberships-pro' ),
);
}
diff --git a/classes/email-templates/class-pmpro-email-template-payment-action-admin.php b/classes/email-templates/class-pmpro-email-template-payment-action-admin.php
index f6f48f816..6a20eae4d 100644
--- a/classes/email-templates/class-pmpro-email-template-payment-action-admin.php
+++ b/classes/email-templates/class-pmpro-email-template-payment-action-admin.php
@@ -47,7 +47,7 @@ public static function get_template_slug() {
* @return string The "nice name" of the email template.
*/
public static function get_template_name() {
- return __( 'Payment Action Required (admin)', 'paid-memberships-pro' );
+ return esc_html__( 'Payment Action Required (admin)', 'paid-memberships-pro' );
}
/**
@@ -58,7 +58,7 @@ public static function get_template_name() {
* @return string The "help text" to display to the admin when editing the email template.
*/
public static function get_template_description() {
- return __( 'This email is sent to the site administrator when an attempted membership checkout requires additional customer authentication.', 'paid-memberships-pro' );
+ return esc_html__( 'This email is sent to the site administrator when an attempted membership checkout requires additional customer authentication.', 'paid-memberships-pro' );
}
/**
@@ -69,7 +69,7 @@ public static function get_template_description() {
* @return string The default subject for the email.
*/
public static function get_default_subject() {
- return __( "Payment action required: membership for !!user_login!! at !!sitename!!", 'paid-memberships-pro' );
+ return esc_html__( "Payment action required: membership for !!user_login!! at !!sitename!!", 'paid-memberships-pro' );
}
/**
@@ -80,7 +80,7 @@ public static function get_default_subject() {
* @return string The default body content for the email.
*/
public static function get_default_body() {
- return __( 'A payment at !!sitename!! for !!user_login!! requires additional customer authentication to complete.
+ return wp_kses_post( 'A payment at !!sitename!! for !!user_login!! requires additional customer authentication to complete.
Below is a copy of the email we sent to !!user_email!! to notify them that they need to complete their payment:
Customer authentication is required to finish setting up your subscription at !!sitename!!.
@@ -123,13 +123,13 @@ public function get_recipient_name() {
*/
public static function get_email_template_variables_with_description() {
return array(
- '!!subject!!' => __( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
- '!!name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
- '!!user_login!!' => __( 'The username of the user.', 'paid-memberships-pro' ),
- '!!display_name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
- '!!order_link!!' => __( 'The URL of the order.', 'paid-memberships-pro' ),
- '!!order_url!!' => __( 'The URL of the order.', 'paid-memberships-pro' ),
- '!!invoice_url!!' => __( 'The URL of the order. Legacy purpose', 'paid-memberships-pro' ),
+ '!!subject!!' => esc_html__( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
+ '!!name!!' => esc_html__( 'The display name of the user.', 'paid-memberships-pro' ),
+ '!!user_login!!' => esc_html__( 'The username of the user.', 'paid-memberships-pro' ),
+ '!!display_name!!' => esc_html__( 'The display name of the user.', 'paid-memberships-pro' ),
+ '!!order_link!!' => esc_html__( 'The URL of the order.', 'paid-memberships-pro' ),
+ '!!order_url!!' => esc_html__( 'The URL of the order.', 'paid-memberships-pro' ),
+ '!!invoice_url!!' => esc_html__( 'The URL of the order. Legacy purpose', 'paid-memberships-pro' ),
);
}
diff --git a/classes/email-templates/class-pmpro-email-template-payment-action.php b/classes/email-templates/class-pmpro-email-template-payment-action.php
index b15f4fa99..6a31a31f4 100644
--- a/classes/email-templates/class-pmpro-email-template-payment-action.php
+++ b/classes/email-templates/class-pmpro-email-template-payment-action.php
@@ -47,7 +47,7 @@ public static function get_template_slug() {
* @return string The "nice name" of the email template.
*/
public static function get_template_name() {
- return __( 'Payment Action Required', 'paid-memberships-pro' );
+ return esc_html__( 'Payment Action Required', 'paid-memberships-pro' );
}
/**
@@ -58,7 +58,7 @@ public static function get_template_name() {
* @return string The "help text" to display to the admin when editing the email template.
*/
public static function get_template_description() {
- return __( 'This email is sent to the user when an attempted membership checkout requires additional customer authentication.', 'paid-memberships-pro' );
+ return esc_html__( 'This email is sent to the user when an attempted membership checkout requires additional customer authentication.', 'paid-memberships-pro' );
}
/**
@@ -69,7 +69,7 @@ public static function get_template_description() {
* @return string The default subject for the email.
*/
public static function get_default_subject() {
- return __( "Payment action required for your !!sitename!! membership", 'paid-memberships-pro' );
+ return esc_html__( "Payment action required for your !!sitename!! membership", 'paid-memberships-pro' );
}
/**
@@ -80,7 +80,7 @@ public static function get_default_subject() {
* @return string The default body content for the email.
*/
public static function get_default_body() {
- return __( 'Customer authentication is required to finish setting up your subscription at !!sitename!!.
+ return wp_kses_post( 'Customer authentication is required to finish setting up your subscription at !!sitename!!.
Please complete the verification steps issued by your payment provider at the following link:
!!order_url!!
', 'paid-memberships-pro' );
@@ -118,14 +118,14 @@ public function get_recipient_name() {
*/
public static function get_email_template_variables_with_description() {
return array(
- '!!subject!!' => __( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
- '!!name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
- '!!user_login!!' => __( 'The username of the user.', 'paid-memberships-pro' ),
- '!!display_name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
- '!!order_link!!' => __( 'The URL of the order.', 'paid-memberships-pro' ),
- '!!order_url!!' => __( 'The URL of the order.', 'paid-memberships-pro' ),
- '!!invoice_url!!' => __( 'The URL of the order. Legacy purpose', 'paid-memberships-pro' ),
- '!!levels_url!!' => __( 'The URL of the membership levels page.', 'paid-memberships-pro' ),
+ '!!subject!!' => esc_html__( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
+ '!!name!!' => esc_html__( 'The display name of the user.', 'paid-memberships-pro' ),
+ '!!user_login!!' => esc_html__( 'The username of the user.', 'paid-memberships-pro' ),
+ '!!display_name!!' => esc_html__( 'The display name of the user.', 'paid-memberships-pro' ),
+ '!!order_link!!' => esc_html__( 'The URL of the order.', 'paid-memberships-pro' ),
+ '!!order_url!!' => esc_html__( 'The URL of the order.', 'paid-memberships-pro' ),
+ '!!invoice_url!!' => esc_html__( 'The URL of the order. Legacy purpose', 'paid-memberships-pro' ),
+ '!!levels_url!!' => esc_html__( 'The URL of the membership levels page.', 'paid-memberships-pro' ),
);
}
diff --git a/classes/email-templates/class-pmpro-email-template-payment-receipt.php b/classes/email-templates/class-pmpro-email-template-payment-receipt.php
index 2f7f9a3be..2c7164bfc 100644
--- a/classes/email-templates/class-pmpro-email-template-payment-receipt.php
+++ b/classes/email-templates/class-pmpro-email-template-payment-receipt.php
@@ -48,7 +48,7 @@ public static function get_template_slug() {
* @return string The "nice name" of the email template.
*/
public static function get_template_name() {
- return __( 'Recurring Payment Receipt', 'paid-memberships-pro' );
+ return esc_html__( 'Recurring Payment Receipt', 'paid-memberships-pro' );
}
/**
@@ -59,7 +59,7 @@ public static function get_template_name() {
* @return string The "help text" to display to the admin when editing the email template.
*/
public static function get_template_description() {
- return __( 'This email is sent to the member each time a new subscription payment is made.', 'paid-memberships-pro' );
+ return esc_html__( 'This email is sent to the member each time a new subscription payment is made.', 'paid-memberships-pro' );
}
/**
@@ -70,7 +70,7 @@ public static function get_template_description() {
* @return string The default subject for the email.
*/
public static function get_default_subject() {
- return __( "Recurring payment receipt for !!sitename!! membership", 'paid-memberships-pro' );
+ return esc_html__( "Recurring payment receipt for !!sitename!! membership", 'paid-memberships-pro' );
}
/**
@@ -81,7 +81,7 @@ public static function get_default_subject() {
* @return string The default body content for the email.
*/
public static function get_default_body() {
- return __( 'Thank you for your membership to !!sitename!!. Below is a receipt for your most recent membership order.
+ return wp_kses_post( 'Thank you for your membership to !!sitename!!. Below is a receipt for your most recent membership order.
Account: !!display_name!! (!!user_email!!)
@@ -134,33 +134,33 @@ public function get_recipient_name() {
*/
public static function get_email_template_variables_with_description() {
return array(
- '!!subject!!' => __( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
- '!!name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
- '!!membership_id!!' => __( 'The ID of the membership level.', 'paid-memberships-pro' ),
- '!!membership_level_name!!' => __( 'The name of the membership level.', 'paid-memberships-pro' ),
- '!!user_login!!' => __( 'The username of the user.', 'paid-memberships-pro' ),
- '!!user_email!!' => __( 'The email address of the user.', 'paid-memberships-pro' ),
- '!!display_name!!' => __( 'The display name of the user.', 'paid-memberships-pro' ),
- '!!order_id!!' => __( 'The order ID.', 'paid-memberships-pro' ),
- '!!order_total!!' => __( 'The total amount of the order.', 'paid-memberships-pro' ),
- '!!order_date!!' => __( 'The date of the order.', 'paid-memberships-pro' ),
- '!!order_link!!' => __( 'The URL of the order.', 'paid-memberships-pro' ),
- '!!order_url!!' => __( 'The URL of the order.', 'paid-memberships-pro' ),
- '!!billing_name!!' => __( 'The name of the billing contact.', 'paid-memberships-pro' ),
- '!!billing_street!!' => __( 'The street address of the billing contact.', 'paid-memberships-pro' ),
- '!!billing_street2!!' => __( 'The second line of the street address of the billing contact.', 'paid-memberships-pro' ),
- '!!billing_city!!' => __( 'The city of the billing contact.', 'paid-memberships-pro' ),
- '!!billing_state!!' => __( 'The state of the billing contact.', 'paid-memberships-pro' ),
- '!!billing_zip!!' => __( 'The ZIP code of the billing contact.', 'paid-memberships-pro' ),
- '!!billing_country!!' => __( 'The country of the billing contact.', 'paid-memberships-pro' ),
- '!!billing_phone!!' => __( 'The phone number of the billing contact.', 'paid-memberships-pro' ),
- '!!billing_address!!' => __( 'The formatted billing address.', 'paid-memberships-pro' ),
- '!!cardtype!!' => __( 'The type of credit card used for the order.', 'paid-memberships-pro' ),
- '!!accountnumber!!' => __( 'The last four digits of the credit card used for the order.', 'paid-memberships-pro' ),
- '!!expirationmonth!!' => __( 'The expiration month of the credit card used for the order.', 'paid-memberships-pro' ),
- '!!expirationyear!!' => __( 'The expiration year of the credit card used for the order.', 'paid-memberships-pro' ),
- '!!discount_code!!' => __( 'The discount code used for the order.', 'paid-memberships-pro' ),
- '!!membership_expiration!!' => __( 'The expiration date of the membership level.', 'paid-memberships-pro' ),
+ '!!subject!!' => esc_html__( 'The default subject for the email. This will be removed in a future version.', 'paid-memberships-pro' ),
+ '!!name!!' => esc_html__( 'The display name of the user.', 'paid-memberships-pro' ),
+ '!!membership_id!!' => esc_html__( 'The ID of the membership level.', 'paid-memberships-pro' ),
+ '!!membership_level_name!!' => esc_html__( 'The name of the membership level.', 'paid-memberships-pro' ),
+ '!!user_login!!' => esc_html__( 'The username of the user.', 'paid-memberships-pro' ),
+ '!!user_email!!' => esc_html__( 'The email address of the user.', 'paid-memberships-pro' ),
+ '!!display_name!!' => esc_html__( 'The display name of the user.', 'paid-memberships-pro' ),
+ '!!order_id!!' => esc_html__( 'The order ID.', 'paid-memberships-pro' ),
+ '!!order_total!!' => esc_html__( 'The total amount of the order.', 'paid-memberships-pro' ),
+ '!!order_date!!' => esc_html__( 'The date of the order.', 'paid-memberships-pro' ),
+ '!!order_link!!' => esc_html__( 'The URL of the order.', 'paid-memberships-pro' ),
+ '!!order_url!!' => esc_html__( 'The URL of the order.', 'paid-memberships-pro' ),
+ '!!billing_name!!' => esc_html__( 'The name of the billing contact.', 'paid-memberships-pro' ),
+ '!!billing_street!!' => esc_html__( 'The street address of the billing contact.', 'paid-memberships-pro' ),
+ '!!billing_street2!!' => esc_html__( 'The second line of the street address of the billing contact.', 'paid-memberships-pro' ),
+ '!!billing_city!!' => esc_html__( 'The city of the billing contact.', 'paid-memberships-pro' ),
+ '!!billing_state!!' => esc_html__( 'The state of the billing contact.', 'paid-memberships-pro' ),
+ '!!billing_zip!!' => esc_html__( 'The ZIP code of the billing contact.', 'paid-memberships-pro' ),
+ '!!billing_country!!' => esc_html__( 'The country of the billing contact.', 'paid-memberships-pro' ),
+ '!!billing_phone!!' => esc_html__( 'The phone number of the billing contact.', 'paid-memberships-pro' ),
+ '!!billing_address!!' => esc_html__( 'The formatted billing address.', 'paid-memberships-pro' ),
+ '!!cardtype!!' => esc_html__( 'The type of credit card used for the order.', 'paid-memberships-pro' ),
+ '!!accountnumber!!' => esc_html__( 'The last four digits of the credit card used for the order.', 'paid-memberships-pro' ),
+ '!!expirationmonth!!' => esc_html__( 'The expiration month of the credit card used for the order.', 'paid-memberships-pro' ),
+ '!!expirationyear!!' => esc_html__( 'The expiration year of the credit card used for the order.', 'paid-memberships-pro' ),
+ '!!discount_code!!' => esc_html__( 'The discount code used for the order.', 'paid-memberships-pro' ),
+ '!!membership_expiration!!' => esc_html__( 'The expiration date of the membership level.', 'paid-memberships-pro' ),
@@ -187,9 +187,9 @@ public function get_email_template_variables() {
//Get discount code if it exists
$discount_code = "";
if( $order->getDiscountCode() && !empty( $order->discount_code->code ) ) {
- $discount_code = "
" . __("Discount Code", 'paid-memberships-pro' ) . ": " . $order->discount_code->code . "
\n";
+ $discount_code = "" . esc_html__("Discount Code", 'paid-memberships-pro' ) . ": " . $order->discount_code->code . "
\n";
} else {
- $discount_code = "" . __("Discount Code", 'paid-memberships-pro' ) . ": " . $order->discount_code . "
\n";
+ $discount_code = "" . esc_html__("Discount Code", 'paid-memberships-pro' ) . ": " . $order->discount_code . "
\n";
}
//Get membership expiration date
diff --git a/classes/email-templates/class-pmpro-email-template-payment-reminder.php b/classes/email-templates/class-pmpro-email-template-payment-reminder.php
index ff4f1e104..0584dfb3c 100644
--- a/classes/email-templates/class-pmpro-email-template-payment-reminder.php
+++ b/classes/email-templates/class-pmpro-email-template-payment-reminder.php
@@ -39,7 +39,7 @@ public static function get_template_slug() {
* @return string The "nice name" of the email template.
*/
public static function get_template_name() {
- return __( 'Membership Recurring', 'paid-memberships-pro' );
+ return esc_html__( 'Membership Recurring', 'paid-memberships-pro' );
}
/**
@@ -50,7 +50,7 @@ public static function get_template_name() {
* @return string The "help text" to display to the admin when editing the email template.
*/
public static function get_template_description() {
- return __( 'This email is sent when a subscription is approaching its renewal date. The additional placeholders !!renewaldate!! and !!billing_amount!! can be used to print the date that the subscription will renew and the renewal price.', 'paid-memberships-pro' );
+ return esc_html__( 'This email is sent when a subscription is approaching its renewal date. The additional placeholders !!renewaldate!! and !!billing_amount!! can be used to print the date that the subscription will renew and the renewal price.', 'paid-memberships-pro' );
}
/**
@@ -61,7 +61,7 @@ public static function get_template_description() {
* @return string The default subject for the email.
*/
public static function get_default_subject() {
- return __( "Your membership at !!sitename!! will end soon", 'paid-memberships-pro' );
+ return esc_html__( "Your membership at !!sitename!! will end soon", 'paid-memberships-pro' );
}
/**
@@ -72,7 +72,7 @@ public static function get_default_subject() {
* @return string The default body content for the email.
*/
public static function get_default_body() {
- return __( 'Thank you for your membership to !!sitename!!.
+ return wp_kses_post( 'Thank you for your membership to !!sitename!!.
This is just a reminder that your !!membership_level_name!! membership will automatically renew on !!renewaldate!!.
@@ -115,11 +115,11 @@ public function get_recipient_name() {
*/
public static function get_email_template_variables_with_description() {
return array(
- 'membership_level_name' => __( 'The name of the membership level.', 'paid-memberships-pro' ),
- 'renewaldate' => __( 'The date of the next payment date.', 'paid-memberships-pro' ),
- 'display_name' => __( 'The display name of the user.', 'paid-memberships-pro' ),
- 'user_email' => __( 'The email address of the user.', 'paid-memberships-pro' ),
- 'cancel_link' => __( 'The link to cancel the subscription.', 'paid-memberships-pro' ),
+ 'membership_level_name' => esc_html__( 'The name of the membership level.', 'paid-memberships-pro' ),
+ 'renewaldate' => esc_html__( 'The date of the next payment date.', 'paid-memberships-pro' ),
+ 'display_name' => esc_html__( 'The display name of the user.', 'paid-memberships-pro' ),
+ 'user_email' => esc_html__( 'The email address of the user.', 'paid-memberships-pro' ),
+ 'cancel_link' => esc_html__( 'The link to cancel the subscription.', 'paid-memberships-pro' ),
);
}
diff --git a/classes/email-templates/class-pmpro-email-template-refund-admin.php b/classes/email-templates/class-pmpro-email-template-refund-admin.php
index 229c936e1..8381a2945 100644
--- a/classes/email-templates/class-pmpro-email-template-refund-admin.php
+++ b/classes/email-templates/class-pmpro-email-template-refund-admin.php
@@ -47,7 +47,7 @@ public static function get_template_slug() {
* @return string The "nice name" of the email template.
*/
public static function get_template_name() {
- return __( 'Refund (admin)', 'paid-memberships-pro' );
+ return esc_html__( 'Refund (admin)', 'paid-memberships-pro' );
}
/**
@@ -58,7 +58,7 @@ public static function get_template_name() {
* @return string The "help text" to display to the admin when editing the email template.
*/
public static function get_template_description() {
- return __( 'This email is sent to the admin as confirmation of a refunded payment. The email is sent after your
+ return esc_html__( 'This email is sent to the admin as confirmation of a refunded payment. The email is sent after your
membership site receives notification of a successful payment refund through your gateway.', 'paid-memberships-pro' );
}
@@ -71,7 +71,7 @@ public static function get_template_description() {
* @return string The default subject for the email.
*/
public static function get_default_subject() {
- return __( 'Order #!!order_id!! at !!sitename!! has been REFUNDED', 'paid-memberships-pro' );
+ return esc_html__( 'Order #!!order_id!! at !!sitename!! has been REFUNDED', 'paid-memberships-pro' );
}
/**
@@ -82,7 +82,7 @@ public static function get_default_subject() {
* @return string The default body content for the email.
*/
public static function get_default_body() {
- return __( 'Order #!!order_id!! at !!sitename!! has been refunded.
+ return wp_kses_post( 'Order #!!order_id!! at !!sitename!! has been refunded.
Account: !!display_name!! (!!user_email!!)
@@ -102,28 +102,28 @@ public static function get_default_body() {
*/
public static function get_email_template_variables_with_description() {
return array(
- '!!user_login!!' => __( 'The login name of the user who requested the refund.', 'paid-memberships-pro' ),
- '!!user_email!!' => __( 'The email address of the user who requested the refund.', 'paid-memberships-pro' ),
- '!!display_name!!' => __( 'The display name of the user who requested the refund.', 'paid-memberships-pro' ),
- '!!membership_id!!' => __( 'The ID of the membership level that was refunded.', 'paid-memberships-pro' ),
- '!!membership_level_name!!' => __( 'The name of the membership level that was refunded.', 'paid-memberships-pro' ),
- '!!order_id!!' => __( 'The order ID of the refunded order.', 'paid-memberships-pro' ),
- '!!order_total!!' => __( 'The total amount refunded.', 'paid-memberships-pro' ),
- '!!order_date!!' => __( 'The date the refund was processed.', 'paid-memberships-pro' ),
- '!!billing_name!!' => __( 'The billing name associated with the refunded order.', 'paid-memberships-pro' ),
- '!!billing_street!!' => __( 'The billing street address associated with the refunded order.', 'paid-memberships-pro' ),
- '!!billing_street2!!' => __( 'The billing street address line 2 associated with the refunded order.', 'paid-memberships-pro' ),
- '!!billing_city!!' => __( 'The billing city associated with the refunded order.', 'paid-memberships-pro' ),
- '!!billing_state!!' => __( 'The billing state associated with the refunded order.', 'paid-memberships-pro' ),
- '!!billing_zip!!' => __( 'The billing zip code associated with the refunded order.', 'paid-memberships-pro' ),
- '!!billing_country!!' => __( 'The billing country associated with the refunded order.', 'paid-memberships-pro' ),
- '!!billing_phone!!' => __( 'The billing phone number associated with the refunded order.', 'paid-memberships-pro' ),
- '!!cardtype!!' => __( 'The card type used for the refunded order.', 'paid-memberships-pro' ),
- '!!accountnumber!!' => __( 'The last four digits of the account number used for the refunded order.', 'paid-memberships-pro' ),
- '!!expirationmonth!!' => __( 'The expiration month of the card used for the refunded order.', 'paid-memberships-pro' ),
- '!!expirationyear!!' => __( 'The expiration year of the card used for the refunded order.', 'paid-memberships-pro' ),
- '!!order_link!!' => __( 'The URL to the invoice for the refunded order.', 'paid-memberships-pro' ),
- '!!order_url!!' => __( 'The URL to the invoice for the refunded order.', 'paid-memberships-pro' ),
+ '!!user_login!!' => esc_html__( 'The login name of the user who requested the refund.', 'paid-memberships-pro' ),
+ '!!user_email!!' => esc_html__( 'The email address of the user who requested the refund.', 'paid-memberships-pro' ),
+ '!!display_name!!' => esc_html__( 'The display name of the user who requested the refund.', 'paid-memberships-pro' ),
+ '!!membership_id!!' => esc_html__( 'The ID of the membership level that was refunded.', 'paid-memberships-pro' ),
+ '!!membership_level_name!!' => esc_html__( 'The name of the membership level that was refunded.', 'paid-memberships-pro' ),
+ '!!order_id!!' => esc_html__( 'The order ID of the refunded order.', 'paid-memberships-pro' ),
+ '!!order_total!!' => esc_html__( 'The total amount refunded.', 'paid-memberships-pro' ),
+ '!!order_date!!' => esc_html__( 'The date the refund was processed.', 'paid-memberships-pro' ),
+ '!!billing_name!!' => esc_html__( 'The billing name associated with the refunded order.', 'paid-memberships-pro' ),
+ '!!billing_street!!' => esc_html__( 'The billing street address associated with the refunded order.', 'paid-memberships-pro' ),
+ '!!billing_street2!!' => esc_html__( 'The billing street address line 2 associated with the refunded order.', 'paid-memberships-pro' ),
+ '!!billing_city!!' => esc_html__( 'The billing city associated with the refunded order.', 'paid-memberships-pro' ),
+ '!!billing_state!!' => esc_html__( 'The billing state associated with the refunded order.', 'paid-memberships-pro' ),
+ '!!billing_zip!!' => esc_html__( 'The billing zip code associated with the refunded order.', 'paid-memberships-pro' ),
+ '!!billing_country!!' => esc_html__( 'The billing country associated with the refunded order.', 'paid-memberships-pro' ),
+ '!!billing_phone!!' => esc_html__( 'The billing phone number associated with the refunded order.', 'paid-memberships-pro' ),
+ '!!cardtype!!' => esc_html__( 'The card type used for the refunded order.', 'paid-memberships-pro' ),
+ '!!accountnumber!!' => esc_html__( 'The last four digits of the account number used for the refunded order.', 'paid-memberships-pro' ),
+ '!!expirationmonth!!' => esc_html__( 'The expiration month of the card used for the refunded order.', 'paid-memberships-pro' ),
+ '!!expirationyear!!' => esc_html__( 'The expiration year of the card used for the refunded order.', 'paid-memberships-pro' ),
+ '!!order_link!!' => esc_html__( 'The URL to the invoice for the refunded order.', 'paid-memberships-pro' ),
+ '!!order_url!!' => esc_html__( 'The URL to the invoice for the refunded order.', 'paid-memberships-pro' ),
);
}
diff --git a/classes/email-templates/class-pmpro-email-template-refund.php b/classes/email-templates/class-pmpro-email-template-refund.php
index 5b40f545d..d0ce2b652 100644
--- a/classes/email-templates/class-pmpro-email-template-refund.php
+++ b/classes/email-templates/class-pmpro-email-template-refund.php
@@ -47,7 +47,7 @@ public static function get_template_slug() {
* @return string The "nice name" of the email template.
*/
public static function get_template_name() {
- return __( 'Refund', 'paid-memberships-pro' );
+ return esc_html__( 'Refund', 'paid-memberships-pro' );
}
/**
@@ -58,7 +58,7 @@ public static function get_template_name() {
* @return string The "help text" to display to the admin when editing the email template.
*/
public static function get_template_description() {
- return __( 'This email is sent to the member as confirmation of a refunded payment. The email is sent after your
+ return esc_html__( 'This email is sent to the member as confirmation of a refunded payment. The email is sent after your
membership site receives notification of a successful payment refund through your gateway.', 'paid-memberships-pro' );
}
@@ -70,7 +70,7 @@ public static function get_template_description() {
* @return string The default subject for the email.
*/
public static function get_default_subject() {
- return __( 'Order #!!order_id!! at !!sitename!! has been REFUNDED', 'paid-memberships-pro' );
+ return esc_html__( 'Order #!!order_id!! at !!sitename!! has been REFUNDED', 'paid-memberships-pro' );
}
/**
@@ -81,7 +81,7 @@ public static function get_default_subject() {
* @return string The default body content for the email.
*/
public static function get_default_body() {
- return __( '
Order #!!order_id!! at !!sitename!! has been refunded.
+ return wp_kses_post( 'Order #!!order_id!! at !!sitename!! has been refunded.
Account: !!display_name!! (!!user_email!!)
@@ -104,28 +104,28 @@ public static function get_default_body() {
*/
public static function get_email_template_variables_with_description() {
return array(
- '!!user_login!!' => __( 'The login name of the user who requested the refund.', 'paid-memberships-pro' ),
- '!!user_email!!' => __( 'The email address of the user who requested the refund.', 'paid-memberships-pro' ),
- '!!display_name!!' => __( 'The display name of the user who requested the refund.', 'paid-memberships-pro' ),
- '!!membership_id!!' => __( 'The ID of the membership level that was refunded.', 'paid-memberships-pro' ),
- '!!membership_level_name!!' => __( 'The name of the membership level that was refunded.', 'paid-memberships-pro' ),
- '!!order_id!!' => __( 'The order ID of the refunded order.', 'paid-memberships-pro' ),
- '!!order_total!!' => __( 'The total amount refunded.', 'paid-memberships-pro' ),
- '!!order_date!!' => __( 'The date the refund was processed.', 'paid-memberships-pro' ),
- '!!billing_name!!' => __( 'The billing name associated with the refunded order.', 'paid-memberships-pro' ),
- '!!billing_street!!' => __( 'The billing street address associated with the refunded order.', 'paid-memberships-pro' ),
- '!!billing_street2!!' => __( 'The billing street address line 2 associated with the refunded order.', 'paid-memberships-pro' ),
- '!!billing_city!!' => __( 'The billing city associated with the refunded order.', 'paid-memberships-pro' ),
- '!!billing_state!!' => __( 'The billing state associated with the refunded order.', 'paid-memberships-pro' ),
- '!!billing_zip!!' => __( 'The billing zip code associated with the refunded order.', 'paid-memberships-pro' ),
- '!!billing_country!!' => __( 'The billing country associated with the refunded order.', 'paid-memberships-pro' ),
- '!!billing_phone!!' => __( 'The billing phone number associated with the refunded order.', 'paid-memberships-pro' ),
- '!!cardtype!!' => __( 'The card type used for the refunded order.', 'paid-memberships-pro' ),
- '!!accountnumber!!' => __( 'The last four digits of the account number used for the refunded order.', 'paid-memberships-pro' ),
- '!!expirationmonth!!' => __( 'The expiration month of the card used for the refunded order.', 'paid-memberships-pro' ),
- '!!expirationyear!!' => __( 'The expiration year of the card used for the refunded order.', 'paid-memberships-pro' ),
- '!!order_link!!' => __( 'The URL to the invoice for the refunded order.', 'paid-memberships-pro' ),
- '!!order_url!!' => __( 'The URL to the invoice for the refunded order.', 'paid-memberships-pro' ),
+ '!!user_login!!' => esc_html__( 'The login name of the user who requested the refund.', 'paid-memberships-pro' ),
+ '!!user_email!!' => esc_html__( 'The email address of the user who requested the refund.', 'paid-memberships-pro' ),
+ '!!display_name!!' => esc_html__( 'The display name of the user who requested the refund.', 'paid-memberships-pro' ),
+ '!!membership_id!!' => esc_html__( 'The ID of the membership level that was refunded.', 'paid-memberships-pro' ),
+ '!!membership_level_name!!' => esc_html__( 'The name of the membership level that was refunded.', 'paid-memberships-pro' ),
+ '!!order_id!!' => esc_html__( 'The order ID of the refunded order.', 'paid-memberships-pro' ),
+ '!!order_total!!' => esc_html__( 'The total amount refunded.', 'paid-memberships-pro' ),
+ '!!order_date!!' => esc_html__( 'The date the refund was processed.', 'paid-memberships-pro' ),
+ '!!billing_name!!' => esc_html__( 'The billing name associated with the refunded order.', 'paid-memberships-pro' ),
+ '!!billing_street!!' => esc_html__( 'The billing street address associated with the refunded order.', 'paid-memberships-pro' ),
+ '!!billing_street2!!' => esc_html__( 'The billing street address line 2 associated with the refunded order.', 'paid-memberships-pro' ),
+ '!!billing_city!!' => esc_html__( 'The billing city associated with the refunded order.', 'paid-memberships-pro' ),
+ '!!billing_state!!' => esc_html__( 'The billing state associated with the refunded order.', 'paid-memberships-pro' ),
+ '!!billing_zip!!' => esc_html__( 'The billing zip code associated with the refunded order.', 'paid-memberships-pro' ),
+ '!!billing_country!!' => esc_html__( 'The billing country associated with the refunded order.', 'paid-memberships-pro' ),
+ '!!billing_phone!!' => esc_html__( 'The billing phone number associated with the refunded order.', 'paid-memberships-pro' ),
+ '!!cardtype!!' => esc_html__( 'The card type used for the refunded order.', 'paid-memberships-pro' ),
+ '!!accountnumber!!' => esc_html__( 'The last four digits of the account number used for the refunded order.', 'paid-memberships-pro' ),
+ '!!expirationmonth!!' => esc_html__( 'The expiration month of the card used for the refunded order.', 'paid-memberships-pro' ),
+ '!!expirationyear!!' => esc_html__( 'The expiration year of the card used for the refunded order.', 'paid-memberships-pro' ),
+ '!!order_link!!' => esc_html__( 'The URL to the invoice for the refunded order.', 'paid-memberships-pro' ),
+ '!!order_url!!' => esc_html__( 'The URL to the invoice for the refunded order.', 'paid-memberships-pro' ),
);
}
diff --git a/classes/email-templates/class-pmpro-email-template.php b/classes/email-templates/class-pmpro-email-template.php
index 58389523c..cf73aa59d 100644
--- a/classes/email-templates/class-pmpro-email-template.php
+++ b/classes/email-templates/class-pmpro-email-template.php
@@ -79,12 +79,12 @@ final protected function get_base_email_template_variables() {
*/
final public static function get_base_email_template_variables_with_description() {
$base_email_template_variables_with_description = array(
- '!!sitename!!' => __( 'The name of the site.', 'paid-memberships-pro' ),
- '!!siteemail!!' => __( 'The email address of the site.', 'paid-memberships-pro' ),
- '!!site_url!!' => __( 'The URL of the site.', 'paid-memberships-pro' ),
- '!!levels_url!!' => __( 'The URL of the page where users can view available membership levels.', 'paid-memberships-pro' ),
- '!!login_url!!' => __( 'The URL of the login page.', 'paid-memberships-pro' ),
- '!!header_name!!' => __( 'The name of the email recipient.', 'paid-memberships-pro' ),
+ '!!sitename!!' => esc_html__( 'The name of the site.', 'paid-memberships-pro' ),
+ '!!siteemail!!' => esc_html__( 'The email address of the site.', 'paid-memberships-pro' ),
+ '!!site_url!!' => esc_html__( 'The URL of the site.', 'paid-memberships-pro' ),
+ '!!levels_url!!' => esc_html__( 'The URL of the page where users can view available membership levels.', 'paid-memberships-pro' ),
+ '!!login_url!!' => esc_html__( 'The URL of the login page.', 'paid-memberships-pro' ),
+ '!!header_name!!' => esc_html__( 'The name of the email recipient.', 'paid-memberships-pro' ),
);
return $base_email_template_variables_with_description;
diff --git a/includes/email-templates.php b/includes/email-templates.php
index 5eb38471c..307e612c1 100644
--- a/includes/email-templates.php
+++ b/includes/email-templates.php
@@ -3,27 +3,27 @@
// File used to setup default email templates data.
global $pmpro_email_templates_defaults;
-$check_gateway_label = get_option( 'pmpro_check_gateway_label' ) ? get_option( 'pmpro_check_gateway_label' ) : __( 'Check', 'paid-memberships-pro' );
+$check_gateway_label = get_option( 'pmpro_check_gateway_label' ) ? get_option( 'pmpro_check_gateway_label' ) : esc_html__( 'Check', 'paid-memberships-pro' );
// Default email templates.
$pmpro_email_templates_defaults = array(
'default' => array(
- 'subject' => __( "An email from !!sitename!!", 'paid-memberships-pro' ),
- 'description' => __( 'Default Email', 'paid-memberships-pro'),
- 'body' => __( '!!body!!', 'paid-memberships-pro' ),
- 'help_text' => __( 'This email is sent when there is a general message that needs to be communicated to the site administrator.', 'paid-memberships-pro' )
+ 'subject' => esc_html__( "An email from !!sitename!!", 'paid-memberships-pro' ),
+ 'description' => esc_html__( 'Default Email', 'paid-memberships-pro'),
+ 'body' => esc_html__( '!!body!!', 'paid-memberships-pro' ),
+ 'help_text' => esc_html__( 'This email is sent when there is a general message that needs to be communicated to the site administrator.', 'paid-memberships-pro' )
),
'footer' => array(
'subject' => '',
- 'description' => __( 'Email Footer', 'paid-memberships-pro'),
- 'body' => __( '
Respectfully,
!!sitename!!
', 'paid-memberships-pro' ),
- 'help_text' => __( 'This is the closing message included in every email sent to members and the site administrator through Paid Memberships Pro.', 'paid-memberships-pro' )
+ 'description' => esc_html__( 'Email Footer', 'paid-memberships-pro'),
+ 'body' => wp_kses_post( 'Respectfully,
!!sitename!!
', 'paid-memberships-pro' ),
+ 'help_text' => esc_html__( 'This is the closing message included in every email sent to members and the site administrator through Paid Memberships Pro.', 'paid-memberships-pro' )
),
'header' => array(
'subject' => '',
- 'description' => __( 'Email Header', 'paid-memberships-pro'),
- 'body' => __( 'Dear !!header_name!!,
', 'paid-memberships-pro' ),
- 'help_text' => __( 'This is the opening message included in every email sent to members and the site administrator through Paid Memberships Pro.', 'paid-memberships-pro' )
+ 'description' => esc_html__( 'Email Header', 'paid-memberships-pro'),
+ 'body' => wp_kses_post( 'Dear !!header_name!!,
', 'paid-memberships-pro' ),
+ 'help_text' => esc_html__( 'This is the opening message included in every email sent to members and the site administrator through Paid Memberships Pro.', 'paid-memberships-pro' )
),
);
diff --git a/includes/email.php b/includes/email.php
index 4f699de14..625bc9ef6 100644
--- a/includes/email.php
+++ b/includes/email.php
@@ -421,7 +421,7 @@ function pmpro_email_templates_test_recipient($email) {
//for test emails
function pmpro_email_templates_test_body($body, $email = null) {
- $body .= '
-- ' . __('THIS IS A TEST EMAIL', 'paid-memberships-pro') . ' --';
+ $body .= '
-- ' . esc_html__('THIS IS A TEST EMAIL', 'paid-memberships-pro') . ' --';
return $body;
}
@@ -477,7 +477,7 @@ function pmpro_email_templates_email_data($data, $email) {
// Membership Information.
$new_data['membership_expiration'] = '';
- $new_data["membership_change"] = __("Your membership has been cancelled.", "paid-memberships-pro");
+ $new_data["membership_change"] = esc_html__("Your membership has been cancelled.", "paid-memberships-pro");
if ( empty( $user->membership_level ) ) {
$user->membership_level = pmpro_getMembershipLevelForUser($user->ID, true);
}
@@ -490,10 +490,10 @@ function pmpro_email_templates_email_data($data, $email) {
}
if ( ! empty($user->membership_level->enddate) ) {
$new_data['enddate'] = date_i18n( get_option( 'date_format' ), $user->membership_level->enddate );
- $new_data['membership_expiration'] = "" . sprintf( __("This membership will expire on %s.", "paid-memberships-pro"), date_i18n( get_option( 'date_format' ), $user->membership_level->enddate ) ) . "
\n";
+ $new_data['membership_expiration'] = "" . sprintf( esc_html__("This membership will expire on %s.", "paid-memberships-pro"), date_i18n( get_option( 'date_format' ), $user->membership_level->enddate ) ) . "
\n";
$new_data["membership_change"] .= " " . sprintf(__("This membership will expire on %s.", "paid-memberships-pro"), date_i18n( get_option( 'date_format' ), $user->membership_level->enddate ) );
} else if ( ! empty( $email->expiration_changed ) ) {
- $new_data["membership_change"] .= " " . __("This membership does not expire.", "paid-memberships-pro");
+ $new_data["membership_change"] .= " " . esc_html__("This membership does not expire.", "paid-memberships-pro");
}
}
}
diff --git a/paid-memberships-pro.php b/paid-memberships-pro.php
index ebe23ba3f..d094656a0 100644
--- a/paid-memberships-pro.php
+++ b/paid-memberships-pro.php
@@ -212,22 +212,22 @@
// Returns a list of all available gateway
function pmpro_gateways() {
$pmpro_gateways = array(
- '' => __( 'Testing Only', 'paid-memberships-pro' ),
- 'check' => __( 'Pay by Check', 'paid-memberships-pro' ),
- 'stripe' => __( 'Stripe', 'paid-memberships-pro' ),
- 'paypalexpress' => __( 'PayPal Express', 'paid-memberships-pro' ),
- 'payflowpro' => __( 'PayPal Payflow Pro/PayPal Pro', 'paid-memberships-pro' ),
- 'paypalstandard' => __( 'PayPal Standard', 'paid-memberships-pro' ),
- 'braintree' => __( 'Braintree Payments', 'paid-memberships-pro' ),
+ '' => esc_html__( 'Testing Only', 'paid-memberships-pro' ),
+ 'check' => esc_html__( 'Pay by Check', 'paid-memberships-pro' ),
+ 'stripe' => esc_html__( 'Stripe', 'paid-memberships-pro' ),
+ 'paypalexpress' => esc_html__( 'PayPal Express', 'paid-memberships-pro' ),
+ 'payflowpro' => esc_html__( 'PayPal Payflow Pro/PayPal Pro', 'paid-memberships-pro' ),
+ 'paypalstandard' => esc_html__( 'PayPal Standard', 'paid-memberships-pro' ),
+ 'braintree' => esc_html__( 'Braintree Payments', 'paid-memberships-pro' ),
);
if ( pmpro_onlyFreeLevels() ) {
- $pmpro_gateways[''] = __( 'Default', 'paid-memberships-pro' );
+ $pmpro_gateways[''] = esc_html__( 'Default', 'paid-memberships-pro' );
}
$check_gateway_label = get_option( 'pmpro_check_gateway_label' );
if ( ! empty( $check_gateway_label ) ) {
- $pmpro_gateways['check'] = esc_html( $check_gateway_label . ' (' . __( 'Pay by Check', 'paid-memberships-pro' ) . ')' );
+ $pmpro_gateways['check'] = esc_html( $check_gateway_label . ' (' . esc_html__( 'Pay by Check', 'paid-memberships-pro' ) . ')' );
}
return apply_filters( 'pmpro_gateways', $pmpro_gateways );
@@ -249,7 +249,7 @@ function pmpro_gateways() {
function pmpro_cron_schedules_monthly( $schedules ) {
$schedules['monthly'] = array(
'interval' => 2635200,
- 'display' => __( 'Once a month', 'paid-memberships-pro' ),
+ 'display' => esc_html__( 'Once a month', 'paid-memberships-pro' ),
);
return $schedules;
}
diff --git a/scheduled/crons.php b/scheduled/crons.php
index 90929f9ea..e74ac8164 100644
--- a/scheduled/crons.php
+++ b/scheduled/crons.php
@@ -121,7 +121,7 @@ function pmpro_cron_expiration_warnings()
$pmproemail->sendMembershipExpiringEmail( $euser, $e->membership_id);
if ( WP_DEBUG ) {
- error_log( sprintf( __("Membership expiring email sent to %s. ", 'paid-memberships-pro' ), $euser->user_email) );
+ error_log( sprintf( esc_html__("Membership expiring email sent to %s. ", 'paid-memberships-pro' ), $euser->user_email) );
}
}
}
@@ -214,7 +214,7 @@ function pmpro_cron_credit_card_expiring_warnings() {
$pmproemail->sendCreditCardExpiringEmail($euser,$last_order);
if ( WP_DEBUG ) {
- error_log( sprintf( __("Credit card expiring email sent to %s. ", 'paid-memberships-pro' ), $euser->user_email) );
+ error_log( sprintf( esc_html__("Credit card expiring email sent to %s. ", 'paid-memberships-pro' ), $euser->user_email) );
}
}
@@ -361,7 +361,7 @@ function pmpro_cron_recurring_payment_reminders() {
'user_login' => $user->user_login,
'sitename' => get_option( 'blogname' ),
'membership_id' => $subscription_obj->get_membership_level_id(),
- 'membership_level_name' => empty( $membership_level ) ? sprintf( __( '[Deleted level #%d]', 'pmpro-recurring-emails' ), $subscription_obj->get_membership_level_id() ) : $membership_level->name,
+ 'membership_level_name' => empty( $membership_level ) ? sprintf( esc_html__( '[Deleted level #%d]', 'pmpro-recurring-emails' ), $subscription_obj->get_membership_level_id() ) : $membership_level->name,
'membership_cost' => $subscription_obj->get_cost_text(),
'billing_amount' => pmpro_formatPrice( $subscription_obj->get_billing_amount() ),
'renewaldate' => date_i18n( get_option( 'date_format' ), $subscription_obj->get_next_payment_date() ),