PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
← All changes | includes/emails/template.php +60 -44 2.3.14.16.9 View file →
@@ -23,9 +23,9 @@
23 23 * @since 1.0
24 24 * @return array $templates All the registered email templates.
25 25 */
26 26 function give_get_email_templates() {
27 - $templates = new Give_Emails;
27 + $templates = new Give_Emails();
28 28
29 29 return $templates->get_templates();
30 30 }
31 31
@@ -30,8 +30,9 @@
30 30 }
31 31
32 32 /**
33 33 * Email Template Tags.
34 + *
34 35 * @todo Modify this function to remove payment id dependency.
35 36 *
36 37 * @since 1.0
37 38 *
@@ -68,9 +69,9 @@
68 69 give_format_amount(
69 70 10.50,
70 71 array(
71 72 'sanitize' => false,
72 - )
73 + )
73 74 )
74 75 );
75 76
76 77 $message = str_replace( '{name}', $user->display_name, $message );
@@ -112,25 +113,37 @@
112 113 ob_start();
113 114
114 115 echo sprintf(
115 116 '<a href="%1$s" class="button-secondary" target="_blank">%2$s</a>',
116 - wp_nonce_url(
117 - add_query_arg(
118 - array( 'give_action' => 'preview_email', 'email_type' => $field_id ),
119 - home_url()
120 - ), 'give-preview-email'
121 - ),
117 + esc_url(
118 + wp_nonce_url(
119 + add_query_arg(
120 + array(
121 + 'give_action' => 'preview_email',
122 + 'email_type' => $field_id,
123 + ),
124 + home_url()
125 + ),
126 + 'give-preview-email'
127 + )
128 + ),
122 129 $field['name']
123 130 );
124 131
125 132 echo sprintf(
126 133 ' <a href="%1$s" aria-label="%2$s" class="button-secondary">%3$s</a>',
127 - wp_nonce_url(
128 - add_query_arg( array(
129 - 'give_action' => 'send_preview_email',
130 - 'email_type' => $field_id,
131 - 'give-messages[]' => 'sent-test-email',
132 - ) ), 'give-send-preview-email' ),
134 + esc_url(
135 + wp_nonce_url(
136 + add_query_arg(
137 + array(
138 + 'give_action' => 'send_preview_email',
139 + 'email_type' => $field_id,
140 + 'give-messages[]' => 'sent-test-email',
141 + )
142 + ),
143 + 'give-send-preview-email'
144 + )
145 + ),
133 146 esc_attr__( 'Send Test Email.', 'give' ),
134 147 esc_html__( 'Send Test Email', 'give' )
135 148 );
136 149
@@ -142,14 +155,14 @@
142 155 * Give Preview Email Header.
143 156 *
144 157 * Displays a header bar with the ability to change donations to preview actual data within the preview. Will not display if
145 158 *
159 + * @since 2.14.0 reduce number of queries
146 160 * @since 1.6
147 - *
148 161 */
149 162 function give_get_preview_email_header() {
150 163
151 - //Payment receipt switcher
164 + // Payment receipt switcher
152 165 $payment_count = give_count_payments()->publish;
153 166 $payment_id = give_check_variable( give_clean( $_GET ), 'isset', 0, 'preview_id' );
154 167
155 168 if ( $payment_count <= 0 ) {
@@ -155,35 +168,36 @@
155 168 if ( $payment_count <= 0 ) {
156 169 return false;
157 170 }
158 171
159 - //Get payments.
160 - $donations = new Give_Payments_Query( array(
161 - 'number' => 100,
162 - 'output' => '',
163 - 'fields' => 'ids'
164 - ) );
172 + // Get payments.
173 + $donations = new Give_Payments_Query(
174 + array(
175 + 'number' => 100,
176 + )
177 + );
165 178 $donations = $donations->get_payments();
166 - $options = array();
179 + $options = [];
167 180
168 181 // Default option.
169 182 $options[0] = esc_html__( 'No donations found.', 'give' );
170 183
171 - //Provide nice human readable options.
184 + // Provide nice human readable options.
185 + /** @var Give_Payment[] $donations */
172 186 if ( $donations ) {
173 187 $options[0] = esc_html__( '- Select a donation -', 'give' );
174 - foreach ( $donations as $donation_id ) {
188 + foreach ( $donations as $donation ) {
175 189
176 - $options[ $donation_id ] = sprintf(
190 + $options[ $donation->ID ] = sprintf(
177 191 '#%1$s - %2$s - %3$s',
178 - $donation_id,
179 - give_get_donation_donor_email( $donation_id ),
180 - get_the_title( $donation_id )
192 + $donation->ID,
193 + $donation->email,
194 + $donation->number
181 195 );
182 196 }
183 197 }
184 198
185 - //Start constructing HTML output.
199 + // Start constructing HTML output.
186 200 $transaction_header = '<div style="margin:0;padding:10px 0;width:100%;background-color:#FFF;border-bottom:1px solid #eee; text-align:center;">';
187 201
188 202 // Remove payment id query param if set from request url.
189 203 $request_url_data = wp_parse_url( $_SERVER['REQUEST_URI'] );
@@ -189,9 +203,9 @@
189 203 $request_url_data = wp_parse_url( $_SERVER['REQUEST_URI'] );
190 204 $query = $request_url_data['query'];
191 205 $query = remove_query_arg( array( 'preview_id' ), $query );
192 206
193 - $request_url = home_url( '/?' . str_replace( '', '', $query ) );
207 + $request_url = esc_url_raw( home_url( '/?' . str_replace( '', '', $query ) ) );
194 208
195 209 $transaction_header .= '<script>
196 210 function change_preview(){
197 211 var transactions = document.getElementById("give_preview_email_payment_id");
@@ -204,22 +218,24 @@
204 218 </script>';
205 219
206 220 $transaction_header .= '<label for="give_preview_email_payment_id" style="font-size:12px;color:#333;margin:0 4px 0 0;">' . esc_html__( 'Preview email with a donation:', 'give' ) . '</label>';
207 221
208 - //The select field with 100 latest transactions
209 - $transaction_header .= Give()->html->select( array(
210 - 'name' => 'preview_email_payment_id',
211 - 'selected' => $payment_id,
212 - 'id' => 'give_preview_email_payment_id',
213 - 'class' => 'give-preview-email-payment-id',
214 - 'options' => $options,
215 - 'chosen' => false,
216 - 'select_atts' => 'onchange="change_preview()"',
217 - 'show_option_all' => false,
218 - 'show_option_none' => false,
219 - ) );
222 + // The select field with 100 latest transactions
223 + $transaction_header .= Give()->html->select(
224 + array(
225 + 'name' => 'preview_email_payment_id',
226 + 'selected' => $payment_id,
227 + 'id' => 'give_preview_email_payment_id',
228 + 'class' => 'give-preview-email-payment-id',
229 + 'options' => $options,
230 + 'chosen' => false,
231 + 'select_atts' => 'onchange="change_preview()"',
232 + 'show_option_all' => false,
233 + 'show_option_none' => false,
234 + )
235 + );
220 236
221 - //Closing tag
237 + // Closing tag
222 238 $transaction_header .= '</div>';
223 239
224 240 return apply_filters( 'give_preview_email_receipt_header', $transaction_header );
225 241