← All changes
|
includes/admin/emails/class-donor-register-email.php
+57
-39
2.3.2
→
4.17.0
View file →
| @@ -3,9 +3,9 @@ | ||
| 3 | 3 | * Donor Register Email |
| 4 | 4 | * |
| 5 | 5 | * @package Give |
| 6 | 6 | * @subpackage Classes/Emails |
| 7 | - * @copyright Copyright (c) 2016, GiveWP | |
| 7 | + * @copyright Copyright (c) 2019, GiveWP | |
| 8 | 8 | * @license https://opensource.org/licenses/gpl-license GNU Public License |
| 9 | 9 | * @since 2.0 |
| 10 | 10 | */ |
| 11 | 11 | |
| @@ -30,25 +30,28 @@ | ||
| 30 | 30 | * @access public |
| 31 | 31 | * @since 2.0 |
| 32 | 32 | */ |
| 33 | 33 | public function init() { |
| 34 | - $this->load( array( | |
| 34 | + | |
| 35 | + $args = array( | |
| 35 | 36 | 'id' => 'donor-register', |
| 36 | 37 | 'label' => __( 'User Registration Information', 'give' ), |
| 37 | - 'description' => __( 'Sent to the donor when they register for an account on the site.', 'give' ), | |
| 38 | + 'description' => __( 'Sent to the donor when they register for an account on the site when giving.', 'give' ), | |
| 38 | 39 | 'notification_status' => 'enabled', |
| 39 | 40 | 'form_metabox_setting' => false, |
| 40 | 41 | 'recipient_group_name' => __( 'Donor', 'give' ), |
| 41 | 42 | 'email_tag_context' => array( 'donor', 'general' ), |
| 42 | 43 | 'default_email_subject' => sprintf( |
| 43 | - /* translators: %s: site name */ | |
| 44 | + /* translators: %s: site name */ | |
| 44 | 45 | esc_attr__( '[%s] Your username and password', 'give' ), |
| 45 | 46 | get_bloginfo( 'name' ) |
| 46 | 47 | ), |
| 47 | 48 | 'default_email_message' => $this->get_default_email_message(), |
| 48 | 49 | 'default_email_header' => __( 'New User Registration', 'give' ), |
| 49 | - ) ); | |
| 50 | + ); | |
| 50 | 51 | |
| 52 | + $this->load( $args ); | |
| 53 | + | |
| 51 | 54 | // Setup action hook. |
| 52 | 55 | add_action( |
| 53 | 56 | "give_{$this->config['id']}_email_notification", |
| 54 | 57 | array( $this, 'setup_email_notification' ), |
| @@ -66,22 +69,23 @@ | ||
| 66 | 69 | |
| 67 | 70 | /** |
| 68 | 71 | * Get default email message. |
| 69 | 72 | * |
| 73 | + * @return string | |
| 70 | 74 | * @since 2.0 |
| 71 | 75 | * @access public |
| 72 | - * | |
| 73 | - * @return string | |
| 74 | 76 | */ |
| 75 | 77 | function get_default_email_message() { |
| 76 | - $message = esc_attr__( 'Username: {username}', 'give' ) . "\r\n\r\n"; | |
| 77 | - | |
| 78 | - $message .= __( 'To reset your password, simply click the link below which will take you to a web page where you can create a new password.', 'give' ) . "\r\n"; | |
| 78 | + $message = esc_attr__( 'Dear {name}', 'give' ) . "\r\n\r\n"; | |
| 79 | + $message .= esc_attr__( 'A user account has been created for you on {site_url}. You may access your account at anytime by using "{username}" to log in.', 'give' ) . "\r\n\r\n"; | |
| 80 | + $message .= __( 'To reset your password, simply click the link below to create a new password:', 'give' ) . "\r\n\n"; | |
| 79 | 81 | $message .= '{reset_password_link}' . "\r\n\r\n"; |
| 82 | + $message .= __( 'You can log in to your account using the link below:', 'give' ); | |
| 83 | + $message .= "\r\n\r\n"; | |
| 84 | + $message .= '<a href="' . wp_login_url() . '"> ' . esc_attr__( 'Click Here to Log In »', 'give' ) . '</a>'; | |
| 85 | + $message .= "\r\n\r\n"; | |
| 86 | + $message .= __( 'Sincerely', 'give' ) . "\r\n" . '{sitename}'; | |
| 80 | 87 | |
| 81 | - $message .= __( 'After resetting password, Please login to your account with link below.', 'give' ) . "\r\n"; | |
| 82 | - $message .= '<a href="' . wp_login_url() . '"> ' . esc_attr__( 'Click Here to Login »', 'give' ) . '</a>' . "\r\n"; | |
| 83 | - | |
| 84 | 88 | /** |
| 85 | 89 | * Filter the default email message |
| 86 | 90 | * |
| 87 | 91 | * @since 2.0 |
| @@ -87,9 +91,10 @@ | ||
| 87 | 91 | * @since 2.0 |
| 88 | 92 | */ |
| 89 | 93 | return apply_filters( |
| 90 | 94 | "give_{$this->config['id']}_get_default_email_message", |
| 91 | - $message, $this | |
| 95 | + $message, | |
| 96 | + $this | |
| 92 | 97 | ); |
| 93 | 98 | } |
| 94 | 99 | |
| 95 | 100 | /** |
| @@ -94,36 +99,46 @@ | ||
| 94 | 99 | |
| 95 | 100 | /** |
| 96 | 101 | * Setup and send new donor register notifications. |
| 97 | 102 | * |
| 98 | - * @since 2.0 | |
| 99 | - * @access public | |
| 100 | - * | |
| 101 | 103 | * @param int $user_id User ID. |
| 102 | 104 | * @param array $user_data User Information. |
| 103 | 105 | * |
| 104 | 106 | * @return string |
| 107 | + * @since 2.0 | |
| 108 | + * @access public | |
| 105 | 109 | */ |
| 106 | 110 | public function setup_email_notification( $user_id, $user_data ) { |
| 111 | + if ( ! is_int( $user_id ) || ! $user_id ) { | |
| 112 | + wp_die( | |
| 113 | + esc_html__( 'Cheatin’ uh?', 'give' ), | |
| 114 | + esc_html__( 'Error', 'give' ), | |
| 115 | + array( | |
| 116 | + 'response' => 400, | |
| 117 | + ) | |
| 118 | + ); | |
| 119 | + } | |
| 120 | + | |
| 107 | 121 | $this->setup_email_data(); |
| 108 | 122 | |
| 109 | 123 | $this->recipient_email = $user_data['email']; |
| 110 | 124 | |
| 111 | - $this->send_email_notification( array( | |
| 112 | - 'user_id' => $user_id, | |
| 113 | - ) ); | |
| 125 | + $this->send_email_notification( | |
| 126 | + array( | |
| 127 | + 'user_id' => $user_id, | |
| 128 | + ) | |
| 129 | + ); | |
| 114 | 130 | } |
| 115 | 131 | |
| 116 | 132 | /** |
| 117 | 133 | * email preview header. |
| 118 | 134 | * |
| 119 | - * @since 2.0 | |
| 120 | - * @access public | |
| 121 | - * | |
| 122 | 135 | * @param string $email_preview_header |
| 123 | 136 | * @param Give_Donor_Register_Email $email |
| 124 | 137 | * |
| 125 | 138 | * @return bool |
| 139 | + * @since 2.0 | |
| 140 | + * @access public | |
| 126 | 141 | */ |
| 127 | 142 | public function email_preview_header( $email_preview_header, $email ) { |
| 128 | 143 | // Bailout. |
| 129 | 144 | if ( $this->config['id'] !== $email->config['id'] ) { |
| @@ -158,19 +173,20 @@ | ||
| 158 | 173 | |
| 159 | 174 | // Remove user id query param if set from request url. |
| 160 | 175 | $query = remove_query_arg( array( 'user_id' ), $query ); |
| 161 | 176 | |
| 162 | - $request_url = home_url( '/?' . str_replace( '', '', $query ) ); | |
| 177 | + $request_url = esc_url_raw( home_url( '/?' . str_replace( '', '', $query ) ) ); | |
| 163 | 178 | ?> |
| 164 | 179 | |
| 165 | 180 | <!-- Start constructing HTML output.--> |
| 166 | - <div style="margin:0;padding:10px 0;width:100%;background-color:#FFF;border-bottom:1px solid #eee; text-align:center;"> | |
| 181 | + <div | |
| 182 | + style="margin:0;padding:10px 0;width:100%;background-color:#FFF;border-bottom:1px solid #eee; text-align:center;"> | |
| 167 | 183 | |
| 168 | 184 | <script type="text/javascript"> |
| 169 | 185 | function change_preview() { |
| 170 | - var transactions = document.getElementById("give_preview_email_user_id"); | |
| 171 | - var selected_trans = transactions.options[transactions.selectedIndex]; | |
| 172 | - if (selected_trans) { | |
| 186 | + var transactions = document.getElementById( "give_preview_email_user_id" ); | |
| 187 | + var selected_trans = transactions.options[ transactions.selectedIndex ]; | |
| 188 | + if ( selected_trans ) { | |
| 173 | 189 | var url_string = "<?php echo $request_url; ?>&user_id=" + selected_trans.value; |
| 174 | 190 | window.location = url_string; |
| 175 | 191 | } |
| 176 | 192 | } |
| @@ -181,19 +197,21 @@ | ||
| 181 | 197 | </label> |
| 182 | 198 | |
| 183 | 199 | <?php |
| 184 | 200 | // The select field with 100 latest transactions |
| 185 | - echo Give()->html->select( array( | |
| 186 | - 'name' => 'preview_email_user_id', | |
| 187 | - 'selected' => $user_id, | |
| 188 | - 'id' => 'give_preview_email_user_id', | |
| 189 | - 'class' => 'give-preview-email-donor-id', | |
| 190 | - 'options' => $options, | |
| 191 | - 'chosen' => false, | |
| 192 | - 'select_atts' => 'onchange="change_preview()"', | |
| 193 | - 'show_option_all' => false, | |
| 194 | - 'show_option_none' => false, | |
| 195 | - ) ); | |
| 201 | + echo Give()->html->select( | |
| 202 | + array( | |
| 203 | + 'name' => 'preview_email_user_id', | |
| 204 | + 'selected' => $user_id, | |
| 205 | + 'id' => 'give_preview_email_user_id', | |
| 206 | + 'class' => 'give-preview-email-donor-id', | |
| 207 | + 'options' => $options, | |
| 208 | + 'chosen' => false, | |
| 209 | + 'select_atts' => 'onchange="change_preview()"', | |
| 210 | + 'show_option_all' => false, | |
| 211 | + 'show_option_none' => false, | |
| 212 | + ) | |
| 213 | + ); | |
| 196 | 214 | ?> |
| 197 | 215 | </div> |
| 198 | 216 | <?php |
| 199 | 217 | } |