Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abstract email templates into individual classes #3234

Open
wants to merge 57 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
c895c45
Created abstract PMPro_Email_Template class
dparker1005 Oct 28, 2024
73b6626
Added PMPro_Email_Template_Cancel class
dparker1005 Oct 28, 2024
368dab3
Merge pull request #3181 from dparker1005/create-email-template-class
dparker1005 Nov 4, 2024
e7801ed
* Fix for sitename variable
MaximilianoRicoTabo Nov 5, 2024
686ad9a
Merge pull request #3187 from MaximilianoRicoTabo/bugfixing/sitename
dparker1005 Nov 6, 2024
64105a4
* Add Change Membership Classes ( admin and member )
MaximilianoRicoTabo Nov 6, 2024
414c2c9
* Add the body in the send function in the abstract email template class
MaximilianoRicoTabo Nov 7, 2024
1dd5827
* Add cancel admin class
MaximilianoRicoTabo Nov 7, 2024
f28ccea
* Remove added classes from email-templates array
MaximilianoRicoTabo Nov 8, 2024
b5eb2f9
*Rename admin change classes
MaximilianoRicoTabo Nov 8, 2024
83533eb
Tweaking admin changed templates
dparker1005 Nov 11, 2024
88b4ef2
Spacing to match original email template
dparker1005 Nov 11, 2024
fb6611e
Merge pull request #3188 from MaximilianoRicoTabo/add-admin-change-class
dparker1005 Nov 11, 2024
2bef7f2
Add payment failure classes
MaximilianoRicoTabo Nov 12, 2024
749b941
* Add canceled autorenewal template / classes for member and admin
MaximilianoRicoTabo Nov 14, 2024
6d95fbb
* Add checkout templates
MaximilianoRicoTabo Nov 15, 2024
f0a511c
* Add credit card expiring email class
MaximilianoRicoTabo Dec 2, 2024
c68d73b
[ENHANCEMENT] * Add Membership expiring email class
MaximilianoRicoTabo Dec 4, 2024
6e80dae
*add expired membership email class
MaximilianoRicoTabo Dec 3, 2024
480282e
* Add refund email classes
MaximilianoRicoTabo Dec 9, 2024
d4ed471
* Add Payment Email Classes
MaximilianoRicoTabo Dec 8, 2024
5a5f813
* Add billing info updated and billing info updated admin classes
MaximilianoRicoTabo Nov 11, 2024
9d8e83e
Merge pull request #3199 from MaximilianoRicoTabo/enhancement/add-cen…
dparker1005 Dec 13, 2024
a5906d7
* Rename billing info updated and billing info updated admin classes…
MaximilianoRicoTabo Dec 13, 2024
fccf2f8
* Remove header_name variable from children class as it's already pre…
MaximilianoRicoTabo Dec 13, 2024
7b7ec9a
[BUGFIXING] Send Invoice email from edit order page takes the wrong user
MaximilianoRicoTabo Dec 17, 2024
a4e187f
Merge branch 'enhancement/email-template-abstraction' into enhancemen…
dparker1005 Dec 17, 2024
a927512
Merge pull request #3197 from MaximilianoRicoTabo/enhancement/add-bil…
dparker1005 Dec 17, 2024
e7ec36b
Merge branch 'enhancement/email-template-abstraction' into enhancemen…
dparker1005 Dec 17, 2024
33804e4
* Remove unnecesary header_name from templates
MaximilianoRicoTabo Dec 17, 2024
e13b0c7
* Remove unnecesary header_name variable from child template
MaximilianoRicoTabo Dec 17, 2024
3194a47
* Remove unnecesary variable header_name from child template
MaximilianoRicoTabo Dec 17, 2024
b3ff95c
* Remove unnecessary header_name variable from child template
MaximilianoRicoTabo Dec 17, 2024
fa62cb3
* Remove unnecessary header_name variable from child template
MaximilianoRicoTabo Dec 17, 2024
0049752
Merge pull request #3193 from MaximilianoRicoTabo/enhancement/add-bil…
dparker1005 Dec 18, 2024
c8a76a4
Merge branch 'enhancement/email-template-abstraction' into enhancemen…
dparker1005 Dec 18, 2024
ac68088
Fixing file name
dparker1005 Dec 18, 2024
c99daa6
Adding missing global
dparker1005 Dec 18, 2024
b72ee4d
Merge pull request #3202 from MaximilianoRicoTabo/enhancement/add-che…
dparker1005 Dec 18, 2024
bcc3d90
Merge branch 'enhancement/email-template-abstraction' into enhancemen…
dparker1005 Dec 18, 2024
f664370
Merge pull request #3218 from MaximilianoRicoTabo/enhancement/add-cre…
dparker1005 Dec 18, 2024
b148ad7
Removing header name
dparker1005 Dec 18, 2024
9ce0d3c
Fixing missing variables
dparker1005 Dec 18, 2024
1ce3e8f
Merge branch 'enhancement/email-template-abstraction' into enhancemen…
dparker1005 Dec 18, 2024
3637eaf
Fixing broken variables
dparker1005 Dec 18, 2024
a47146e
Make sure that we can get an enddate
dparker1005 Dec 18, 2024
12f4c97
Merge branch 'enhancement/email-template-abstraction' into enhancemen…
dparker1005 Dec 18, 2024
8bdff4b
Merge pull request #3220 from MaximilianoRicoTabo/enhancement/members…
dparker1005 Dec 18, 2024
24dc95a
Merge branch 'enhancement/email-template-abstraction' into enhancemen…
dparker1005 Dec 18, 2024
d0c9a62
Merge pull request #3221 from MaximilianoRicoTabo/enhancement/members…
dparker1005 Dec 18, 2024
26f54af
Fixing sending payment reminder email
dparker1005 Dec 18, 2024
89c77c5
Fixing broken variables
dparker1005 Dec 18, 2024
0f56c2d
Merge branch 'enhancement/email-template-abstraction' into enhancemen…
dparker1005 Dec 18, 2024
85e17db
Merge pull request #3227 from MaximilianoRicoTabo/enhancement/payment…
dparker1005 Dec 18, 2024
9c74e72
Merge branch 'enhancement/email-template-abstraction' into enhancemen…
dparker1005 Dec 18, 2024
b6747f7
Merge pull request #3228 from MaximilianoRicoTabo/enhancement/add-ref…
dparker1005 Dec 18, 2024
daf9da1
Fixing payment action required email for Stripe
dparker1005 Dec 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 32 additions & 35 deletions adminpages/emailtemplates-edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ),
Expand All @@ -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' ),
Expand All @@ -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(),
);
}
?>
<hr class="wp-header-end">
<div id="poststuff">
Expand Down Expand Up @@ -165,39 +174,27 @@
</div>
<div class="pmpro_section_inside">
<p><?php esc_html_e( 'Use the placeholder variables below to customize your member and admin emails with specific user or membership data.', 'paid-memberships-pro' ); ?></p>
<h3><?php esc_html_e('General Settings / Membership Info', 'paid-memberships-pro'); ?></h3>
<table class="widefat fixed striped">
<tbody>
<?php
foreach ( $email_variables['general'] as $email_variable => $description ) {
?>
<tr>
<th><code><?php echo esc_html( $email_variable ); ?></code></th>
<td><?php echo esc_html( $description ); ?></td>
</tr>
<?php
}
?>
</tbody>
</table>

<h3><?php esc_html_e( 'Billing Information', 'paid-memberships-pro' ); ?></h3>
<table class="widefat fixed striped">
<tbody>
<?php
foreach ( $email_variables['billing'] as $email_variable => $description ) {
?>
<tr>
<th>
<code><?php echo esc_html( $email_variable ); ?></code>
</th>
<td><?php echo esc_html( $description ); ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
<?php
foreach ( $email_variables as $section => $variables ) {
?>
<h3><?php echo esc_html( $section ); ?></h3>
<table class="widefat fixed striped">
<tbody>
<?php
foreach ( $variables as $email_variable => $description ) {
?>
<tr>
<th><code><?php echo esc_html( $email_variable ); ?></code></th>
<td><?php echo esc_html( $description ); ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
<?php
}
?>
</div> <!-- end pmpro_section_inside -->
</div> <!-- end pmpro_section -->
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Loading