@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @return string Donations dropdown. |
37 | 37 | */ |
38 | - public function transactions_dropdown( $args = array() ) { |
|
38 | + public function transactions_dropdown($args = array()) { |
|
39 | 39 | |
40 | 40 | $defaults = array( |
41 | 41 | 'name' => 'transactions', |
@@ -45,34 +45,34 @@ discard block |
||
45 | 45 | 'selected' => 0, |
46 | 46 | 'chosen' => false, |
47 | 47 | 'number' => 30, |
48 | - 'placeholder' => esc_html__( 'Select a transaction', 'give' ) |
|
48 | + 'placeholder' => esc_html__('Select a transaction', 'give') |
|
49 | 49 | ); |
50 | 50 | |
51 | - $args = wp_parse_args( $args, $defaults ); |
|
51 | + $args = wp_parse_args($args, $defaults); |
|
52 | 52 | |
53 | 53 | |
54 | - $payments = new Give_Payments_Query( array( |
|
54 | + $payments = new Give_Payments_Query(array( |
|
55 | 55 | 'number' => $args['number'] |
56 | - ) ); |
|
56 | + )); |
|
57 | 57 | |
58 | 58 | $payments = $payments->get_payments(); |
59 | 59 | |
60 | 60 | $options = array(); |
61 | 61 | |
62 | 62 | //Provide nice human readable options. |
63 | - if ( $payments ) { |
|
64 | - $options[0] = esc_html__( 'Select a donation', 'give' ); |
|
65 | - foreach ( $payments as $payment ) { |
|
63 | + if ($payments) { |
|
64 | + $options[0] = esc_html__('Select a donation', 'give'); |
|
65 | + foreach ($payments as $payment) { |
|
66 | 66 | |
67 | - $options[ absint( $payment->ID ) ] = esc_html( '#' . $payment->ID . ' - ' . $payment->email . ' - ' . $payment->form_title); |
|
67 | + $options[absint($payment->ID)] = esc_html('#'.$payment->ID.' - '.$payment->email.' - '.$payment->form_title); |
|
68 | 68 | |
69 | 69 | } |
70 | 70 | } else { |
71 | - $options[0] = esc_html__( 'No donations found.', 'give' ); |
|
71 | + $options[0] = esc_html__('No donations found.', 'give'); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | |
75 | - $output = $this->select( array( |
|
75 | + $output = $this->select(array( |
|
76 | 76 | 'name' => $args['name'], |
77 | 77 | 'selected' => $args['selected'], |
78 | 78 | 'id' => $args['id'], |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | 'select_atts' => $args['select_atts'], |
85 | 85 | 'show_option_all' => false, |
86 | 86 | 'show_option_none' => false |
87 | - ) ); |
|
87 | + )); |
|
88 | 88 | |
89 | 89 | return $output; |
90 | 90 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return string Give forms dropdown. |
103 | 103 | */ |
104 | - public function forms_dropdown( $args = array() ) { |
|
104 | + public function forms_dropdown($args = array()) { |
|
105 | 105 | |
106 | 106 | $defaults = array( |
107 | 107 | 'name' => 'forms', |
@@ -111,43 +111,43 @@ discard block |
||
111 | 111 | 'selected' => 0, |
112 | 112 | 'chosen' => false, |
113 | 113 | 'number' => 30, |
114 | - 'placeholder' => esc_attr__( 'Select a Form', 'give' ) |
|
114 | + 'placeholder' => esc_attr__('Select a Form', 'give') |
|
115 | 115 | ); |
116 | 116 | |
117 | - $args = wp_parse_args( $args, $defaults ); |
|
117 | + $args = wp_parse_args($args, $defaults); |
|
118 | 118 | |
119 | - $forms = get_posts( array( |
|
119 | + $forms = get_posts(array( |
|
120 | 120 | 'post_type' => 'give_forms', |
121 | 121 | 'orderby' => 'title', |
122 | 122 | 'order' => 'ASC', |
123 | 123 | 'posts_per_page' => $args['number'] |
124 | - ) ); |
|
124 | + )); |
|
125 | 125 | |
126 | 126 | $options = array(); |
127 | 127 | |
128 | - if ( $forms ) { |
|
129 | - $options[0] = esc_attr__( 'Select a Form', 'give' ); |
|
130 | - foreach ( $forms as $form ) { |
|
131 | - $options[ absint( $form->ID ) ] = esc_html( $form->post_title ); |
|
128 | + if ($forms) { |
|
129 | + $options[0] = esc_attr__('Select a Form', 'give'); |
|
130 | + foreach ($forms as $form) { |
|
131 | + $options[absint($form->ID)] = esc_html($form->post_title); |
|
132 | 132 | } |
133 | 133 | } else { |
134 | - $options[0] = esc_html__( 'No forms found.', 'give' ); |
|
134 | + $options[0] = esc_html__('No forms found.', 'give'); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | // This ensures that any selected forms are included in the drop down |
138 | - if ( is_array( $args['selected'] ) ) { |
|
139 | - foreach ( $args['selected'] as $item ) { |
|
140 | - if ( ! in_array( $item, $options ) ) { |
|
141 | - $options[ $item ] = get_the_title( $item ); |
|
138 | + if (is_array($args['selected'])) { |
|
139 | + foreach ($args['selected'] as $item) { |
|
140 | + if ( ! in_array($item, $options)) { |
|
141 | + $options[$item] = get_the_title($item); |
|
142 | 142 | } |
143 | 143 | } |
144 | - } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) { |
|
145 | - if ( ! in_array( $args['selected'], $options ) ) { |
|
146 | - $options[ $args['selected'] ] = get_the_title( $args['selected'] ); |
|
144 | + } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) { |
|
145 | + if ( ! in_array($args['selected'], $options)) { |
|
146 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
147 | 147 | } |
148 | 148 | } |
149 | 149 | |
150 | - $output = $this->select( array( |
|
150 | + $output = $this->select(array( |
|
151 | 151 | 'name' => $args['name'], |
152 | 152 | 'selected' => $args['selected'], |
153 | 153 | 'id' => $args['id'], |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | 'placeholder' => $args['placeholder'], |
159 | 159 | 'show_option_all' => false, |
160 | 160 | 'show_option_none' => false |
161 | - ) ); |
|
161 | + )); |
|
162 | 162 | |
163 | 163 | return $output; |
164 | 164 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @return string Donors dropdown. |
177 | 177 | */ |
178 | - public function donor_dropdown( $args = array() ) { |
|
178 | + public function donor_dropdown($args = array()) { |
|
179 | 179 | |
180 | 180 | $defaults = array( |
181 | 181 | 'name' => 'customers', |
@@ -184,38 +184,38 @@ discard block |
||
184 | 184 | 'multiple' => false, |
185 | 185 | 'selected' => 0, |
186 | 186 | 'chosen' => true, |
187 | - 'placeholder' => esc_attr__( 'Select a Donor', 'give' ), |
|
187 | + 'placeholder' => esc_attr__('Select a Donor', 'give'), |
|
188 | 188 | 'number' => 30 |
189 | 189 | ); |
190 | 190 | |
191 | - $args = wp_parse_args( $args, $defaults ); |
|
191 | + $args = wp_parse_args($args, $defaults); |
|
192 | 192 | |
193 | - $customers = Give()->customers->get_customers( array( |
|
193 | + $customers = Give()->customers->get_customers(array( |
|
194 | 194 | 'number' => $args['number'] |
195 | - ) ); |
|
195 | + )); |
|
196 | 196 | |
197 | 197 | $options = array(); |
198 | 198 | |
199 | - if ( $customers ) { |
|
200 | - $options[0] = esc_html__( 'No donor attached', 'give' ); |
|
201 | - foreach ( $customers as $customer ) { |
|
202 | - $options[ absint( $customer->id ) ] = esc_html( $customer->name . ' (' . $customer->email . ')' ); |
|
199 | + if ($customers) { |
|
200 | + $options[0] = esc_html__('No donor attached', 'give'); |
|
201 | + foreach ($customers as $customer) { |
|
202 | + $options[absint($customer->id)] = esc_html($customer->name.' ('.$customer->email.')'); |
|
203 | 203 | } |
204 | 204 | } else { |
205 | - $options[0] = esc_html__( 'No donors found.', 'give' ); |
|
205 | + $options[0] = esc_html__('No donors found.', 'give'); |
|
206 | 206 | } |
207 | 207 | |
208 | - if ( ! empty( $args['selected'] ) ) { |
|
208 | + if ( ! empty($args['selected'])) { |
|
209 | 209 | |
210 | 210 | // If a selected customer has been specified, we need to ensure it's in the initial list of customers displayed. |
211 | 211 | |
212 | - if ( ! array_key_exists( $args['selected'], $options ) ) { |
|
212 | + if ( ! array_key_exists($args['selected'], $options)) { |
|
213 | 213 | |
214 | - $customer = new Give_Customer( $args['selected'] ); |
|
214 | + $customer = new Give_Customer($args['selected']); |
|
215 | 215 | |
216 | - if ( $customer ) { |
|
216 | + if ($customer) { |
|
217 | 217 | |
218 | - $options[ absint( $args['selected'] ) ] = esc_html( $customer->name . ' (' . $customer->email . ')' ); |
|
218 | + $options[absint($args['selected'])] = esc_html($customer->name.' ('.$customer->email.')'); |
|
219 | 219 | |
220 | 220 | } |
221 | 221 | |
@@ -223,17 +223,17 @@ discard block |
||
223 | 223 | |
224 | 224 | } |
225 | 225 | |
226 | - $output = $this->select( array( |
|
226 | + $output = $this->select(array( |
|
227 | 227 | 'name' => $args['name'], |
228 | 228 | 'selected' => $args['selected'], |
229 | 229 | 'id' => $args['id'], |
230 | - 'class' => $args['class'] . ' give-customer-select', |
|
230 | + 'class' => $args['class'].' give-customer-select', |
|
231 | 231 | 'options' => $options, |
232 | 232 | 'multiple' => $args['multiple'], |
233 | 233 | 'chosen' => $args['chosen'], |
234 | 234 | 'show_option_all' => false, |
235 | 235 | 'show_option_none' => false |
236 | - ) ); |
|
236 | + )); |
|
237 | 237 | |
238 | 238 | return $output; |
239 | 239 | } |
@@ -251,21 +251,21 @@ discard block |
||
251 | 251 | * |
252 | 252 | * @return string Categories dropdown. |
253 | 253 | */ |
254 | - public function category_dropdown( $name = 'give_forms_categories', $selected = 0 ) { |
|
255 | - $categories = get_terms( 'give_forms_category', apply_filters( 'give_forms_category_dropdown', array() ) ); |
|
254 | + public function category_dropdown($name = 'give_forms_categories', $selected = 0) { |
|
255 | + $categories = get_terms('give_forms_category', apply_filters('give_forms_category_dropdown', array())); |
|
256 | 256 | $options = array(); |
257 | 257 | |
258 | - foreach ( $categories as $category ) { |
|
259 | - $options[ absint( $category->term_id ) ] = esc_html( $category->name ); |
|
258 | + foreach ($categories as $category) { |
|
259 | + $options[absint($category->term_id)] = esc_html($category->name); |
|
260 | 260 | } |
261 | 261 | |
262 | - $output = $this->select( array( |
|
262 | + $output = $this->select(array( |
|
263 | 263 | 'name' => $name, |
264 | 264 | 'selected' => $selected, |
265 | 265 | 'options' => $options, |
266 | - 'show_option_all' => esc_html__( 'All Categories', 'give' ), |
|
266 | + 'show_option_all' => esc_html__('All Categories', 'give'), |
|
267 | 267 | 'show_option_none' => false |
268 | - ) ); |
|
268 | + )); |
|
269 | 269 | |
270 | 270 | return $output; |
271 | 271 | } |
@@ -285,25 +285,25 @@ discard block |
||
285 | 285 | * |
286 | 286 | * @return string Years dropdown. |
287 | 287 | */ |
288 | - public function year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) { |
|
289 | - $current = date( 'Y' ); |
|
290 | - $start_year = $current - absint( $years_before ); |
|
291 | - $end_year = $current + absint( $years_after ); |
|
292 | - $selected = empty( $selected ) ? date( 'Y' ) : $selected; |
|
288 | + public function year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) { |
|
289 | + $current = date('Y'); |
|
290 | + $start_year = $current - absint($years_before); |
|
291 | + $end_year = $current + absint($years_after); |
|
292 | + $selected = empty($selected) ? date('Y') : $selected; |
|
293 | 293 | $options = array(); |
294 | 294 | |
295 | - while ( $start_year <= $end_year ) { |
|
296 | - $options[ absint( $start_year ) ] = $start_year; |
|
297 | - $start_year ++; |
|
295 | + while ($start_year <= $end_year) { |
|
296 | + $options[absint($start_year)] = $start_year; |
|
297 | + $start_year++; |
|
298 | 298 | } |
299 | 299 | |
300 | - $output = $this->select( array( |
|
300 | + $output = $this->select(array( |
|
301 | 301 | 'name' => $name, |
302 | 302 | 'selected' => $selected, |
303 | 303 | 'options' => $options, |
304 | 304 | 'show_option_all' => false, |
305 | 305 | 'show_option_none' => false |
306 | - ) ); |
|
306 | + )); |
|
307 | 307 | |
308 | 308 | return $output; |
309 | 309 | } |
@@ -321,23 +321,23 @@ discard block |
||
321 | 321 | * |
322 | 322 | * @return string Months dropdown. |
323 | 323 | */ |
324 | - public function month_dropdown( $name = 'month', $selected = 0 ) { |
|
324 | + public function month_dropdown($name = 'month', $selected = 0) { |
|
325 | 325 | $month = 1; |
326 | 326 | $options = array(); |
327 | - $selected = empty( $selected ) ? date( 'n' ) : $selected; |
|
327 | + $selected = empty($selected) ? date('n') : $selected; |
|
328 | 328 | |
329 | - while ( $month <= 12 ) { |
|
330 | - $options[ absint( $month ) ] = give_month_num_to_name( $month ); |
|
331 | - $month ++; |
|
329 | + while ($month <= 12) { |
|
330 | + $options[absint($month)] = give_month_num_to_name($month); |
|
331 | + $month++; |
|
332 | 332 | } |
333 | 333 | |
334 | - $output = $this->select( array( |
|
334 | + $output = $this->select(array( |
|
335 | 335 | 'name' => $name, |
336 | 336 | 'selected' => $selected, |
337 | 337 | 'options' => $options, |
338 | 338 | 'show_option_all' => false, |
339 | 339 | 'show_option_none' => false |
340 | - ) ); |
|
340 | + )); |
|
341 | 341 | |
342 | 342 | return $output; |
343 | 343 | } |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | * |
355 | 355 | * @return string The dropdown. |
356 | 356 | */ |
357 | - public function select( $args = array() ) { |
|
357 | + public function select($args = array()) { |
|
358 | 358 | $defaults = array( |
359 | 359 | 'options' => array(), |
360 | 360 | 'name' => null, |
@@ -365,60 +365,60 @@ discard block |
||
365 | 365 | 'placeholder' => null, |
366 | 366 | 'multiple' => false, |
367 | 367 | 'select_atts' => false, |
368 | - 'show_option_all' => esc_html__( 'All', 'give' ), |
|
369 | - 'show_option_none' => esc_html__( 'None', 'give' ) |
|
368 | + 'show_option_all' => esc_html__('All', 'give'), |
|
369 | + 'show_option_none' => esc_html__('None', 'give') |
|
370 | 370 | ); |
371 | 371 | |
372 | - $args = wp_parse_args( $args, $defaults ); |
|
372 | + $args = wp_parse_args($args, $defaults); |
|
373 | 373 | |
374 | - if ( $args['multiple'] ) { |
|
374 | + if ($args['multiple']) { |
|
375 | 375 | $multiple = ' MULTIPLE'; |
376 | 376 | } else { |
377 | 377 | $multiple = ''; |
378 | 378 | } |
379 | 379 | |
380 | - if ( $args['chosen'] ) { |
|
380 | + if ($args['chosen']) { |
|
381 | 381 | $args['class'] .= ' give-select-chosen'; |
382 | 382 | } |
383 | 383 | |
384 | - if ( $args['placeholder'] ) { |
|
384 | + if ($args['placeholder']) { |
|
385 | 385 | $placeholder = $args['placeholder']; |
386 | 386 | } else { |
387 | 387 | $placeholder = ''; |
388 | 388 | } |
389 | 389 | |
390 | 390 | |
391 | - $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( sanitize_key( str_replace( '-', '_', $args['id'] ) ) ) . '" class="give-select ' . esc_attr( $args['class'] ) . '"' . $multiple . ' ' . $args['select_atts'] . ' data-placeholder="' . $placeholder . '">'; |
|
391 | + $output = '<select name="'.esc_attr($args['name']).'" id="'.esc_attr(sanitize_key(str_replace('-', '_', $args['id']))).'" class="give-select '.esc_attr($args['class']).'"'.$multiple.' '.$args['select_atts'].' data-placeholder="'.$placeholder.'">'; |
|
392 | 392 | |
393 | - if ( $args['show_option_all'] ) { |
|
394 | - if ( $args['multiple'] ) { |
|
395 | - $selected = selected( true, in_array( 0, $args['selected'] ), false ); |
|
393 | + if ($args['show_option_all']) { |
|
394 | + if ($args['multiple']) { |
|
395 | + $selected = selected(true, in_array(0, $args['selected']), false); |
|
396 | 396 | } else { |
397 | - $selected = selected( $args['selected'], 0, false ); |
|
397 | + $selected = selected($args['selected'], 0, false); |
|
398 | 398 | } |
399 | - $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
399 | + $output .= '<option value="all"'.$selected.'>'.esc_html($args['show_option_all']).'</option>'; |
|
400 | 400 | } |
401 | 401 | |
402 | - if ( ! empty( $args['options'] ) ) { |
|
402 | + if ( ! empty($args['options'])) { |
|
403 | 403 | |
404 | - if ( $args['show_option_none'] ) { |
|
405 | - if ( $args['multiple'] ) { |
|
406 | - $selected = selected( true, in_array( - 1, $args['selected'] ), false ); |
|
404 | + if ($args['show_option_none']) { |
|
405 | + if ($args['multiple']) { |
|
406 | + $selected = selected(true, in_array( -1, $args['selected'] ), false); |
|
407 | 407 | } else { |
408 | - $selected = selected( $args['selected'], - 1, false ); |
|
408 | + $selected = selected($args['selected'], - 1, false); |
|
409 | 409 | } |
410 | - $output .= '<option value="-1"' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
410 | + $output .= '<option value="-1"'.$selected.'>'.esc_html($args['show_option_none']).'</option>'; |
|
411 | 411 | } |
412 | 412 | |
413 | - foreach ( $args['options'] as $key => $option ) { |
|
413 | + foreach ($args['options'] as $key => $option) { |
|
414 | 414 | |
415 | - if ( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
416 | - $selected = selected( true, in_array( $key, $args['selected'] ), false ); |
|
415 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
416 | + $selected = selected(true, in_array($key, $args['selected']), false); |
|
417 | 417 | } else { |
418 | - $selected = selected( $args['selected'], $key, false ); |
|
418 | + $selected = selected($args['selected'], $key, false); |
|
419 | 419 | } |
420 | 420 | |
421 | - $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
|
421 | + $output .= '<option value="'.esc_attr($key).'"'.$selected.'>'.esc_html($option).'</option>'; |
|
422 | 422 | } |
423 | 423 | } |
424 | 424 | |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | * |
440 | 440 | * @return string The checkbox. |
441 | 441 | */ |
442 | - public function checkbox( $args = array() ) { |
|
442 | + public function checkbox($args = array()) { |
|
443 | 443 | $defaults = array( |
444 | 444 | 'name' => null, |
445 | 445 | 'current' => null, |
@@ -450,16 +450,16 @@ discard block |
||
450 | 450 | ) |
451 | 451 | ); |
452 | 452 | |
453 | - $args = wp_parse_args( $args, $defaults ); |
|
453 | + $args = wp_parse_args($args, $defaults); |
|
454 | 454 | |
455 | 455 | $options = ''; |
456 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
456 | + if ( ! empty($args['options']['disabled'])) { |
|
457 | 457 | $options .= ' disabled="disabled"'; |
458 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
458 | + } elseif ( ! empty($args['options']['readonly'])) { |
|
459 | 459 | $options .= ' readonly'; |
460 | 460 | } |
461 | 461 | |
462 | - $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
462 | + $output = '<input type="checkbox"'.$options.' name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" class="'.$args['class'].' '.esc_attr($args['name']).'" '.checked(1, $args['current'], false).' />'; |
|
463 | 463 | |
464 | 464 | return $output; |
465 | 465 | } |
@@ -476,22 +476,22 @@ discard block |
||
476 | 476 | * |
477 | 477 | * @return string The text field. |
478 | 478 | */ |
479 | - public function text( $args = array() ) { |
|
479 | + public function text($args = array()) { |
|
480 | 480 | // Backwards compatibility |
481 | - if ( func_num_args() > 1 ) { |
|
481 | + if (func_num_args() > 1) { |
|
482 | 482 | $args = func_get_args(); |
483 | 483 | |
484 | 484 | $name = $args[0]; |
485 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
486 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
487 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
485 | + $value = isset($args[1]) ? $args[1] : ''; |
|
486 | + $label = isset($args[2]) ? $args[2] : ''; |
|
487 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
488 | 488 | } |
489 | 489 | |
490 | 490 | $defaults = array( |
491 | - 'name' => isset( $name ) ? $name : 'text', |
|
492 | - 'value' => isset( $value ) ? $value : null, |
|
493 | - 'label' => isset( $label ) ? $label : null, |
|
494 | - 'desc' => isset( $desc ) ? $desc : null, |
|
491 | + 'name' => isset($name) ? $name : 'text', |
|
492 | + 'value' => isset($value) ? $value : null, |
|
493 | + 'label' => isset($label) ? $label : null, |
|
494 | + 'desc' => isset($desc) ? $desc : null, |
|
495 | 495 | 'placeholder' => '', |
496 | 496 | 'class' => 'regular-text', |
497 | 497 | 'disabled' => false, |
@@ -499,29 +499,29 @@ discard block |
||
499 | 499 | 'data' => false |
500 | 500 | ); |
501 | 501 | |
502 | - $args = wp_parse_args( $args, $defaults ); |
|
502 | + $args = wp_parse_args($args, $defaults); |
|
503 | 503 | |
504 | 504 | $disabled = ''; |
505 | - if ( $args['disabled'] ) { |
|
505 | + if ($args['disabled']) { |
|
506 | 506 | $disabled = ' disabled="disabled"'; |
507 | 507 | } |
508 | 508 | |
509 | 509 | $data = ''; |
510 | - if ( ! empty( $args['data'] ) ) { |
|
511 | - foreach ( $args['data'] as $key => $value ) { |
|
512 | - $data .= 'data-' . $key . '="' . $value . '" '; |
|
510 | + if ( ! empty($args['data'])) { |
|
511 | + foreach ($args['data'] as $key => $value) { |
|
512 | + $data .= 'data-'.$key.'="'.$value.'" '; |
|
513 | 513 | } |
514 | 514 | } |
515 | 515 | |
516 | - $output = '<span id="give-' . sanitize_key( $args['name'] ) . '-wrap">'; |
|
516 | + $output = '<span id="give-'.sanitize_key($args['name']).'-wrap">'; |
|
517 | 517 | |
518 | - $output .= '<label class="give-label" for="give-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
518 | + $output .= '<label class="give-label" for="give-'.sanitize_key($args['name']).'">'.esc_html($args['label']).'</label>'; |
|
519 | 519 | |
520 | - if ( ! empty( $args['desc'] ) ) { |
|
521 | - $output .= '<span class="give-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
520 | + if ( ! empty($args['desc'])) { |
|
521 | + $output .= '<span class="give-description">'.esc_html($args['desc']).'</span>'; |
|
522 | 522 | } |
523 | 523 | |
524 | - $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $args['class'] . '" ' . $data . '' . $disabled . '/>'; |
|
524 | + $output .= '<input type="text" name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" autocomplete="'.esc_attr($args['autocomplete']).'" value="'.esc_attr($args['value']).'" placeholder="'.esc_attr($args['placeholder']).'" class="'.$args['class'].'" '.$data.''.$disabled.'/>'; |
|
525 | 525 | |
526 | 526 | $output .= '</span>'; |
527 | 527 | |
@@ -540,15 +540,15 @@ discard block |
||
540 | 540 | * |
541 | 541 | * @return string The date picker. |
542 | 542 | */ |
543 | - public function date_field( $args = array() ) { |
|
543 | + public function date_field($args = array()) { |
|
544 | 544 | |
545 | - if ( empty( $args['class'] ) ) { |
|
545 | + if (empty($args['class'])) { |
|
546 | 546 | $args['class'] = 'give_datepicker'; |
547 | - } elseif ( ! strpos( $args['class'], 'give_datepicker' ) ) { |
|
547 | + } elseif ( ! strpos($args['class'], 'give_datepicker')) { |
|
548 | 548 | $args['class'] .= ' give_datepicker'; |
549 | 549 | } |
550 | 550 | |
551 | - return $this->text( $args ); |
|
551 | + return $this->text($args); |
|
552 | 552 | } |
553 | 553 | |
554 | 554 | /** |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | * |
564 | 564 | * @return string The textarea. |
565 | 565 | */ |
566 | - public function textarea( $args = array() ) { |
|
566 | + public function textarea($args = array()) { |
|
567 | 567 | $defaults = array( |
568 | 568 | 'name' => 'textarea', |
569 | 569 | 'value' => null, |
@@ -573,21 +573,21 @@ discard block |
||
573 | 573 | 'disabled' => false |
574 | 574 | ); |
575 | 575 | |
576 | - $args = wp_parse_args( $args, $defaults ); |
|
576 | + $args = wp_parse_args($args, $defaults); |
|
577 | 577 | |
578 | 578 | $disabled = ''; |
579 | - if ( $args['disabled'] ) { |
|
579 | + if ($args['disabled']) { |
|
580 | 580 | $disabled = ' disabled="disabled"'; |
581 | 581 | } |
582 | 582 | |
583 | - $output = '<span id="give-' . sanitize_key( $args['name'] ) . '-wrap">'; |
|
583 | + $output = '<span id="give-'.sanitize_key($args['name']).'-wrap">'; |
|
584 | 584 | |
585 | - $output .= '<label class="give-label" for="give-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
585 | + $output .= '<label class="give-label" for="give-'.sanitize_key($args['name']).'">'.esc_html($args['label']).'</label>'; |
|
586 | 586 | |
587 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
587 | + $output .= '<textarea name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" class="'.$args['class'].'"'.$disabled.'>'.esc_attr($args['value']).'</textarea>'; |
|
588 | 588 | |
589 | - if ( ! empty( $args['desc'] ) ) { |
|
590 | - $output .= '<span class="give-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
589 | + if ( ! empty($args['desc'])) { |
|
590 | + $output .= '<span class="give-description">'.esc_html($args['desc']).'</span>'; |
|
591 | 591 | } |
592 | 592 | |
593 | 593 | $output .= '</span>'; |
@@ -607,12 +607,12 @@ discard block |
||
607 | 607 | * |
608 | 608 | * @return string The text field with ajax search. |
609 | 609 | */ |
610 | - public function ajax_user_search( $args = array() ) { |
|
610 | + public function ajax_user_search($args = array()) { |
|
611 | 611 | |
612 | 612 | $defaults = array( |
613 | 613 | 'name' => 'user_id', |
614 | 614 | 'value' => null, |
615 | - 'placeholder' => esc_attr__( 'Enter username', 'give' ), |
|
615 | + 'placeholder' => esc_attr__('Enter username', 'give'), |
|
616 | 616 | 'label' => null, |
617 | 617 | 'desc' => null, |
618 | 618 | 'class' => '', |
@@ -621,13 +621,13 @@ discard block |
||
621 | 621 | 'data' => false |
622 | 622 | ); |
623 | 623 | |
624 | - $args = wp_parse_args( $args, $defaults ); |
|
624 | + $args = wp_parse_args($args, $defaults); |
|
625 | 625 | |
626 | - $args['class'] = 'give-ajax-user-search ' . $args['class']; |
|
626 | + $args['class'] = 'give-ajax-user-search '.$args['class']; |
|
627 | 627 | |
628 | 628 | $output = '<span class="give_user_search_wrap">'; |
629 | - $output .= $this->text( $args ); |
|
630 | - $output .= '<span class="give_user_search_results hidden"><a class="give-ajax-user-cancel" aria-label="' . esc_attr__( 'Cancel', 'give' ) . '" href="#">x</a><span></span></span>'; |
|
629 | + $output .= $this->text($args); |
|
630 | + $output .= '<span class="give_user_search_results hidden"><a class="give-ajax-user-cancel" aria-label="'.esc_attr__('Cancel', 'give').'" href="#">x</a><span></span></span>'; |
|
631 | 631 | $output .= '</span>'; |
632 | 632 | |
633 | 633 | return $output; |
@@ -661,7 +661,7 @@ |
||
661 | 661 | * |
662 | 662 | * @since 1.6.3 |
663 | 663 | * |
664 | - * @param $pending_reason |
|
664 | + * @param string $pending_reason |
|
665 | 665 | * |
666 | 666 | * @return string |
667 | 667 | */ |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @since 1.0 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * @access private |
22 | 22 | * @since 1.0 |
23 | 23 | */ |
24 | -add_action( 'give_paypal_cc_form', '__return_false' ); |
|
24 | +add_action('give_paypal_cc_form', '__return_false'); |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * Process PayPal Purchase. |
@@ -32,14 +32,14 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @return void |
34 | 34 | */ |
35 | -function give_process_paypal_purchase( $purchase_data ) { |
|
35 | +function give_process_paypal_purchase($purchase_data) { |
|
36 | 36 | |
37 | - if ( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'give-gateway' ) ) { |
|
38 | - wp_die( esc_html__( 'Nonce verification has failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
37 | + if ( ! wp_verify_nonce($purchase_data['gateway_nonce'], 'give-gateway')) { |
|
38 | + wp_die(esc_html__('Nonce verification has failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
39 | 39 | } |
40 | 40 | |
41 | - $form_id = intval( $purchase_data['post_data']['give-form-id'] ); |
|
42 | - $price_id = isset( $purchase_data['post_data']['give-price-id'] ) ? $purchase_data['post_data']['give-price-id'] : ''; |
|
41 | + $form_id = intval($purchase_data['post_data']['give-form-id']); |
|
42 | + $price_id = isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : ''; |
|
43 | 43 | |
44 | 44 | // Collect payment data. |
45 | 45 | $payment_data = array( |
@@ -57,101 +57,101 @@ discard block |
||
57 | 57 | ); |
58 | 58 | |
59 | 59 | // Record the pending payment. |
60 | - $payment_id = give_insert_payment( $payment_data ); |
|
60 | + $payment_id = give_insert_payment($payment_data); |
|
61 | 61 | |
62 | 62 | // Check payment. |
63 | - if ( ! $payment_id ) { |
|
63 | + if ( ! $payment_id) { |
|
64 | 64 | // Record the error. |
65 | 65 | give_record_gateway_error( |
66 | - esc_html__( 'Payment Error', 'give' ), |
|
66 | + esc_html__('Payment Error', 'give'), |
|
67 | 67 | sprintf( |
68 | 68 | /* translators: %s: payment data */ |
69 | - esc_html__( 'Payment creation failed before sending donor to PayPal. Payment data: %s', 'give' ), |
|
70 | - json_encode( $payment_data ) |
|
69 | + esc_html__('Payment creation failed before sending donor to PayPal. Payment data: %s', 'give'), |
|
70 | + json_encode($payment_data) |
|
71 | 71 | ), |
72 | 72 | $payment_id |
73 | 73 | ); |
74 | 74 | // Problems? Send back. |
75 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
75 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
76 | 76 | |
77 | 77 | } else { |
78 | 78 | |
79 | 79 | // Only send to PayPal if the pending payment is created successfully. |
80 | - $listener_url = add_query_arg( 'give-listener', 'IPN', home_url( 'index.php' ) ); |
|
80 | + $listener_url = add_query_arg('give-listener', 'IPN', home_url('index.php')); |
|
81 | 81 | |
82 | 82 | // Get the success url. |
83 | - $return_url = add_query_arg( array( |
|
83 | + $return_url = add_query_arg(array( |
|
84 | 84 | 'payment-confirmation' => 'paypal', |
85 | 85 | 'payment-id' => $payment_id |
86 | 86 | |
87 | - ), get_permalink( give_get_option( 'success_page' ) ) ); |
|
87 | + ), get_permalink(give_get_option('success_page'))); |
|
88 | 88 | |
89 | 89 | // Get the PayPal redirect uri. |
90 | - $paypal_redirect = trailingslashit( give_get_paypal_redirect() ) . '?'; |
|
90 | + $paypal_redirect = trailingslashit(give_get_paypal_redirect()).'?'; |
|
91 | 91 | |
92 | 92 | //Item name - pass level name if variable priced. |
93 | 93 | $item_name = $purchase_data['post_data']['give-form-title']; |
94 | 94 | |
95 | 95 | //Verify has variable prices. |
96 | - if ( give_has_variable_prices( $form_id ) && isset( $purchase_data['post_data']['give-price-id'] ) ) { |
|
96 | + if (give_has_variable_prices($form_id) && isset($purchase_data['post_data']['give-price-id'])) { |
|
97 | 97 | |
98 | - $item_price_level_text = give_get_price_option_name( $form_id, $purchase_data['post_data']['give-price-id'] ); |
|
98 | + $item_price_level_text = give_get_price_option_name($form_id, $purchase_data['post_data']['give-price-id']); |
|
99 | 99 | |
100 | - $price_level_amount = give_get_price_option_amount( $form_id, $purchase_data['post_data']['give-price-id'] ); |
|
100 | + $price_level_amount = give_get_price_option_amount($form_id, $purchase_data['post_data']['give-price-id']); |
|
101 | 101 | |
102 | 102 | //Donation given doesn't match selected level (must be a custom amount). |
103 | - if ( $price_level_amount != give_sanitize_amount( $purchase_data['price'] ) ) { |
|
104 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
103 | + if ($price_level_amount != give_sanitize_amount($purchase_data['price'])) { |
|
104 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
105 | 105 | //user custom amount text if any, fallback to default if not. |
106 | - $item_name .= ' - ' . ( ! empty( $custom_amount_text ) ? $custom_amount_text : esc_html__( 'Custom Amount', 'give' ) ); |
|
106 | + $item_name .= ' - '.( ! empty($custom_amount_text) ? $custom_amount_text : esc_html__('Custom Amount', 'give')); |
|
107 | 107 | |
108 | 108 | } //Is there any donation level text? |
109 | - elseif ( ! empty( $item_price_level_text ) ) { |
|
110 | - $item_name .= ' - ' . $item_price_level_text; |
|
109 | + elseif ( ! empty($item_price_level_text)) { |
|
110 | + $item_name .= ' - '.$item_price_level_text; |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | } //Single donation: Custom Amount. |
114 | - elseif ( give_get_form_price( $form_id ) !== give_sanitize_amount( $purchase_data['price'] ) ) { |
|
115 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
114 | + elseif (give_get_form_price($form_id) !== give_sanitize_amount($purchase_data['price'])) { |
|
115 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
116 | 116 | //user custom amount text if any, fallback to default if not. |
117 | - $item_name .= ' - ' . ( ! empty( $custom_amount_text ) ? $custom_amount_text : esc_html__( 'Custom Amount', 'give' ) ); |
|
117 | + $item_name .= ' - '.( ! empty($custom_amount_text) ? $custom_amount_text : esc_html__('Custom Amount', 'give')); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | // Setup PayPal API params. |
121 | 121 | $paypal_args = array( |
122 | - 'business' => give_get_option( 'paypal_email', false ), |
|
122 | + 'business' => give_get_option('paypal_email', false), |
|
123 | 123 | 'first_name' => $purchase_data['user_info']['first_name'], |
124 | 124 | 'last_name' => $purchase_data['user_info']['last_name'], |
125 | 125 | 'email' => $purchase_data['user_email'], |
126 | 126 | 'invoice' => $purchase_data['purchase_key'], |
127 | 127 | 'amount' => $purchase_data['price'], |
128 | - 'item_name' => stripslashes( $item_name ), |
|
128 | + 'item_name' => stripslashes($item_name), |
|
129 | 129 | 'no_shipping' => '1', |
130 | 130 | 'shipping' => '0', |
131 | 131 | 'no_note' => '1', |
132 | 132 | 'currency_code' => give_get_currency(), |
133 | - 'charset' => get_bloginfo( 'charset' ), |
|
133 | + 'charset' => get_bloginfo('charset'), |
|
134 | 134 | 'custom' => $payment_id, |
135 | 135 | 'rm' => '2', |
136 | 136 | 'return' => $return_url, |
137 | - 'cancel_return' => give_get_failed_transaction_uri( '?payment-id=' . $payment_id ), |
|
137 | + 'cancel_return' => give_get_failed_transaction_uri('?payment-id='.$payment_id), |
|
138 | 138 | 'notify_url' => $listener_url, |
139 | 139 | 'page_style' => give_get_paypal_page_style(), |
140 | - 'cbt' => get_bloginfo( 'name' ), |
|
140 | + 'cbt' => get_bloginfo('name'), |
|
141 | 141 | 'bn' => 'givewp_SP' |
142 | 142 | ); |
143 | 143 | |
144 | 144 | //Add user address if present. |
145 | - if ( ! empty( $purchase_data['user_info']['address'] ) ) { |
|
146 | - $paypal_args['address1'] = isset( $purchase_data['user_info']['address']['line1'] ) ? $purchase_data['user_info']['address']['line1'] : ''; |
|
147 | - $paypal_args['address2'] = isset( $purchase_data['user_info']['address']['line2'] ) ? $purchase_data['user_info']['address']['line2'] : ''; |
|
148 | - $paypal_args['city'] = isset( $purchase_data['user_info']['address']['city'] ) ? $purchase_data['user_info']['address']['city'] : ''; |
|
149 | - $paypal_args['state'] = isset( $purchase_data['user_info']['address']['state'] ) ? $purchase_data['user_info']['address']['state'] : ''; |
|
150 | - $paypal_args['country'] = isset( $purchase_data['user_info']['address']['country'] ) ? $purchase_data['user_info']['address']['country'] : ''; |
|
145 | + if ( ! empty($purchase_data['user_info']['address'])) { |
|
146 | + $paypal_args['address1'] = isset($purchase_data['user_info']['address']['line1']) ? $purchase_data['user_info']['address']['line1'] : ''; |
|
147 | + $paypal_args['address2'] = isset($purchase_data['user_info']['address']['line2']) ? $purchase_data['user_info']['address']['line2'] : ''; |
|
148 | + $paypal_args['city'] = isset($purchase_data['user_info']['address']['city']) ? $purchase_data['user_info']['address']['city'] : ''; |
|
149 | + $paypal_args['state'] = isset($purchase_data['user_info']['address']['state']) ? $purchase_data['user_info']['address']['state'] : ''; |
|
150 | + $paypal_args['country'] = isset($purchase_data['user_info']['address']['country']) ? $purchase_data['user_info']['address']['country'] : ''; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | //Donations or regular transactions? |
154 | - if ( give_get_option( 'paypal_button_type' ) === 'standard' ) { |
|
154 | + if (give_get_option('paypal_button_type') === 'standard') { |
|
155 | 155 | $paypal_extra_args = array( |
156 | 156 | 'cmd' => '_xclick', |
157 | 157 | ); |
@@ -161,23 +161,23 @@ discard block |
||
161 | 161 | ); |
162 | 162 | } |
163 | 163 | |
164 | - $paypal_args = array_merge( $paypal_extra_args, $paypal_args ); |
|
165 | - $paypal_args = apply_filters( 'give_paypal_redirect_args', $paypal_args, $purchase_data ); |
|
164 | + $paypal_args = array_merge($paypal_extra_args, $paypal_args); |
|
165 | + $paypal_args = apply_filters('give_paypal_redirect_args', $paypal_args, $purchase_data); |
|
166 | 166 | |
167 | 167 | // Build query. |
168 | - $paypal_redirect .= http_build_query( $paypal_args ); |
|
168 | + $paypal_redirect .= http_build_query($paypal_args); |
|
169 | 169 | |
170 | 170 | // Fix for some sites that encode the entities. |
171 | - $paypal_redirect = str_replace( '&', '&', $paypal_redirect ); |
|
171 | + $paypal_redirect = str_replace('&', '&', $paypal_redirect); |
|
172 | 172 | |
173 | 173 | // Redirect to PayPal. |
174 | - wp_redirect( $paypal_redirect ); |
|
174 | + wp_redirect($paypal_redirect); |
|
175 | 175 | exit; |
176 | 176 | } |
177 | 177 | |
178 | 178 | } |
179 | 179 | |
180 | -add_action( 'give_gateway_paypal', 'give_process_paypal_purchase' ); |
|
180 | +add_action('give_gateway_paypal', 'give_process_paypal_purchase'); |
|
181 | 181 | |
182 | 182 | /** |
183 | 183 | * Listens for a PayPal IPN requests and then sends to the processing function |
@@ -187,17 +187,17 @@ discard block |
||
187 | 187 | */ |
188 | 188 | function give_listen_for_paypal_ipn() { |
189 | 189 | // Regular PayPal IPN |
190 | - if ( isset( $_GET['give-listener'] ) && $_GET['give-listener'] == 'IPN' ) { |
|
190 | + if (isset($_GET['give-listener']) && $_GET['give-listener'] == 'IPN') { |
|
191 | 191 | /** |
192 | 192 | * Fires while verifying PayPal IPN |
193 | 193 | * |
194 | 194 | * @since 1.0 |
195 | 195 | */ |
196 | - do_action( 'give_verify_paypal_ipn' ); |
|
196 | + do_action('give_verify_paypal_ipn'); |
|
197 | 197 | } |
198 | 198 | } |
199 | 199 | |
200 | -add_action( 'init', 'give_listen_for_paypal_ipn' ); |
|
200 | +add_action('init', 'give_listen_for_paypal_ipn'); |
|
201 | 201 | |
202 | 202 | /** |
203 | 203 | * Process PayPal IPN |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | function give_process_paypal_ipn() { |
209 | 209 | |
210 | 210 | // Check the request method is POST |
211 | - if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) { |
|
211 | + if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') { |
|
212 | 212 | return; |
213 | 213 | } |
214 | 214 | |
@@ -216,11 +216,11 @@ discard block |
||
216 | 216 | $post_data = ''; |
217 | 217 | |
218 | 218 | // Fallback just in case post_max_size is lower than needed |
219 | - if ( ini_get( 'allow_url_fopen' ) ) { |
|
220 | - $post_data = file_get_contents( 'php://input' ); |
|
219 | + if (ini_get('allow_url_fopen')) { |
|
220 | + $post_data = file_get_contents('php://input'); |
|
221 | 221 | } else { |
222 | 222 | // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough |
223 | - ini_set( 'post_max_size', '12M' ); |
|
223 | + ini_set('post_max_size', '12M'); |
|
224 | 224 | } |
225 | 225 | // Start the encoded data collection with notification command |
226 | 226 | $encoded_data = 'cmd=_notify-validate'; |
@@ -229,40 +229,40 @@ discard block |
||
229 | 229 | $arg_separator = give_get_php_arg_separator_output(); |
230 | 230 | |
231 | 231 | // Verify there is a post_data |
232 | - if ( $post_data || strlen( $post_data ) > 0 ) { |
|
232 | + if ($post_data || strlen($post_data) > 0) { |
|
233 | 233 | // Append the data |
234 | - $encoded_data .= $arg_separator . $post_data; |
|
234 | + $encoded_data .= $arg_separator.$post_data; |
|
235 | 235 | } else { |
236 | 236 | // Check if POST is empty |
237 | - if ( empty( $_POST ) ) { |
|
237 | + if (empty($_POST)) { |
|
238 | 238 | // Nothing to do |
239 | 239 | return; |
240 | 240 | } else { |
241 | 241 | // Loop through each POST |
242 | - foreach ( $_POST as $key => $value ) { |
|
242 | + foreach ($_POST as $key => $value) { |
|
243 | 243 | // Encode the value and append the data. |
244 | - $encoded_data .= $arg_separator . "$key=" . urlencode( $value ); |
|
244 | + $encoded_data .= $arg_separator."$key=".urlencode($value); |
|
245 | 245 | } |
246 | 246 | } |
247 | 247 | } |
248 | 248 | |
249 | 249 | // Convert collected post data to an array. |
250 | - parse_str( $encoded_data, $encoded_data_array ); |
|
250 | + parse_str($encoded_data, $encoded_data_array); |
|
251 | 251 | |
252 | - foreach ( $encoded_data_array as $key => $value ) { |
|
252 | + foreach ($encoded_data_array as $key => $value) { |
|
253 | 253 | |
254 | - if ( false !== strpos( $key, 'amp;' ) ) { |
|
255 | - $new_key = str_replace( '&', '&', $key ); |
|
256 | - $new_key = str_replace( 'amp;', '&', $new_key ); |
|
254 | + if (false !== strpos($key, 'amp;')) { |
|
255 | + $new_key = str_replace('&', '&', $key); |
|
256 | + $new_key = str_replace('amp;', '&', $new_key); |
|
257 | 257 | |
258 | - unset( $encoded_data_array[ $key ] ); |
|
259 | - $encoded_data_array[ $new_key ] = $value; |
|
258 | + unset($encoded_data_array[$key]); |
|
259 | + $encoded_data_array[$new_key] = $value; |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | } |
263 | 263 | |
264 | 264 | //Validate IPN request w/ PayPal if user hasn't disabled this security measure |
265 | - if ( give_is_setting_enabled( give_get_option( 'paypal_verification' ) ) ) { |
|
265 | + if (give_is_setting_enabled(give_get_option('paypal_verification'))) { |
|
266 | 266 | |
267 | 267 | $remote_post_vars = array( |
268 | 268 | 'method' => 'POST', |
@@ -282,28 +282,28 @@ discard block |
||
282 | 282 | ); |
283 | 283 | |
284 | 284 | // Validate the IPN. |
285 | - $api_response = wp_remote_post( give_get_paypal_redirect(), $remote_post_vars ); |
|
285 | + $api_response = wp_remote_post(give_get_paypal_redirect(), $remote_post_vars); |
|
286 | 286 | |
287 | - if ( is_wp_error( $api_response ) ) { |
|
287 | + if (is_wp_error($api_response)) { |
|
288 | 288 | give_record_gateway_error( |
289 | - esc_html__( 'IPN Error', 'give' ), |
|
289 | + esc_html__('IPN Error', 'give'), |
|
290 | 290 | sprintf( |
291 | 291 | /* translators: %s: Paypal IPN response */ |
292 | - esc_html__( 'Invalid IPN verification response. IPN data: %s', 'give' ), |
|
293 | - json_encode( $api_response ) |
|
292 | + esc_html__('Invalid IPN verification response. IPN data: %s', 'give'), |
|
293 | + json_encode($api_response) |
|
294 | 294 | ) |
295 | 295 | ); |
296 | 296 | |
297 | 297 | return; // Something went wrong |
298 | 298 | } |
299 | 299 | |
300 | - if ( $api_response['body'] !== 'VERIFIED' ) { |
|
300 | + if ($api_response['body'] !== 'VERIFIED') { |
|
301 | 301 | give_record_gateway_error( |
302 | - esc_html__( 'IPN Error', 'give' ), |
|
302 | + esc_html__('IPN Error', 'give'), |
|
303 | 303 | sprintf( |
304 | 304 | /* translators: %s: Paypal IPN response */ |
305 | - esc_html__( 'Invalid IPN verification response. IPN data: %s', 'give' ), |
|
306 | - json_encode( $api_response ) |
|
305 | + esc_html__('Invalid IPN verification response. IPN data: %s', 'give'), |
|
306 | + json_encode($api_response) |
|
307 | 307 | ) |
308 | 308 | ); |
309 | 309 | |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | } |
314 | 314 | |
315 | 315 | // Check if $post_data_array has been populated |
316 | - if ( ! is_array( $encoded_data_array ) && ! empty( $encoded_data_array ) ) { |
|
316 | + if ( ! is_array($encoded_data_array) && ! empty($encoded_data_array)) { |
|
317 | 317 | return; |
318 | 318 | } |
319 | 319 | |
@@ -322,12 +322,12 @@ discard block |
||
322 | 322 | 'payment_status' => '' |
323 | 323 | ); |
324 | 324 | |
325 | - $encoded_data_array = wp_parse_args( $encoded_data_array, $defaults ); |
|
325 | + $encoded_data_array = wp_parse_args($encoded_data_array, $defaults); |
|
326 | 326 | |
327 | - $payment_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0; |
|
327 | + $payment_id = isset($encoded_data_array['custom']) ? absint($encoded_data_array['custom']) : 0; |
|
328 | 328 | $txn_type = $encoded_data_array['txn_type']; |
329 | 329 | |
330 | - if ( has_action( 'give_paypal_' . $txn_type ) ) { |
|
330 | + if (has_action('give_paypal_'.$txn_type)) { |
|
331 | 331 | /** |
332 | 332 | * Fires while processing PayPal IPN $txn_type. |
333 | 333 | * |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | * @param array $encoded_data_array Encoded data. |
339 | 339 | * @param int $payment_id Payment id. |
340 | 340 | */ |
341 | - do_action( "give_paypal_{$txn_type}", $encoded_data_array, $payment_id ); |
|
341 | + do_action("give_paypal_{$txn_type}", $encoded_data_array, $payment_id); |
|
342 | 342 | } else { |
343 | 343 | /** |
344 | 344 | * Fires while process PayPal IPN. |
@@ -350,12 +350,12 @@ discard block |
||
350 | 350 | * @param array $encoded_data_array Encoded data. |
351 | 351 | * @param int $payment_id Payment id. |
352 | 352 | */ |
353 | - do_action( 'give_paypal_web_accept', $encoded_data_array, $payment_id ); |
|
353 | + do_action('give_paypal_web_accept', $encoded_data_array, $payment_id); |
|
354 | 354 | } |
355 | 355 | exit; |
356 | 356 | } |
357 | 357 | |
358 | -add_action( 'give_verify_paypal_ipn', 'give_process_paypal_ipn' ); |
|
358 | +add_action('give_verify_paypal_ipn', 'give_process_paypal_ipn'); |
|
359 | 359 | |
360 | 360 | /** |
361 | 361 | * Process web accept (one time) payment IPNs. |
@@ -367,127 +367,127 @@ discard block |
||
367 | 367 | * |
368 | 368 | * @return void |
369 | 369 | */ |
370 | -function give_process_paypal_web_accept_and_cart( $data, $payment_id ) { |
|
370 | +function give_process_paypal_web_accept_and_cart($data, $payment_id) { |
|
371 | 371 | |
372 | 372 | //Only allow through these transaction types. |
373 | - if ( $data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && strtolower( $data['payment_status'] ) != 'refunded' ) { |
|
373 | + if ($data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && strtolower($data['payment_status']) != 'refunded') { |
|
374 | 374 | return; |
375 | 375 | } |
376 | 376 | |
377 | 377 | //Need $payment_id to continue. |
378 | - if ( empty( $payment_id ) ) { |
|
378 | + if (empty($payment_id)) { |
|
379 | 379 | return; |
380 | 380 | } |
381 | 381 | |
382 | 382 | // Collect donation payment details. |
383 | 383 | $paypal_amount = $data['mc_gross']; |
384 | - $payment_status = strtolower( $data['payment_status'] ); |
|
385 | - $currency_code = strtolower( $data['mc_currency'] ); |
|
386 | - $business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] ); |
|
387 | - $payment_meta = give_get_payment_meta( $payment_id ); |
|
384 | + $payment_status = strtolower($data['payment_status']); |
|
385 | + $currency_code = strtolower($data['mc_currency']); |
|
386 | + $business_email = isset($data['business']) && is_email($data['business']) ? trim($data['business']) : trim($data['receiver_email']); |
|
387 | + $payment_meta = give_get_payment_meta($payment_id); |
|
388 | 388 | |
389 | 389 | // Must be a PayPal standard IPN. |
390 | - if ( give_get_payment_gateway( $payment_id ) != 'paypal' ) { |
|
390 | + if (give_get_payment_gateway($payment_id) != 'paypal') { |
|
391 | 391 | return; |
392 | 392 | } |
393 | 393 | |
394 | 394 | // Verify payment recipient |
395 | - if ( strcasecmp( $business_email, trim( give_get_option( 'paypal_email' ) ) ) != 0 ) { |
|
395 | + if (strcasecmp($business_email, trim(give_get_option('paypal_email'))) != 0) { |
|
396 | 396 | |
397 | 397 | give_record_gateway_error( |
398 | - esc_html__( 'IPN Error', 'give' ), |
|
398 | + esc_html__('IPN Error', 'give'), |
|
399 | 399 | sprintf( |
400 | 400 | /* translators: %s: Paypal IPN response */ |
401 | - esc_html__( 'Invalid business email in IPN response. IPN data: %s', 'give' ), |
|
402 | - json_encode( $data ) |
|
401 | + esc_html__('Invalid business email in IPN response. IPN data: %s', 'give'), |
|
402 | + json_encode($data) |
|
403 | 403 | ), |
404 | 404 | $payment_id |
405 | 405 | ); |
406 | - give_update_payment_status( $payment_id, 'failed' ); |
|
407 | - give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid PayPal business email.', 'give' ) ); |
|
406 | + give_update_payment_status($payment_id, 'failed'); |
|
407 | + give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid PayPal business email.', 'give')); |
|
408 | 408 | |
409 | 409 | return; |
410 | 410 | } |
411 | 411 | |
412 | 412 | // Verify payment currency. |
413 | - if ( $currency_code != strtolower( $payment_meta['currency'] ) ) { |
|
413 | + if ($currency_code != strtolower($payment_meta['currency'])) { |
|
414 | 414 | |
415 | 415 | give_record_gateway_error( |
416 | - esc_html__( 'IPN Error', 'give' ), |
|
416 | + esc_html__('IPN Error', 'give'), |
|
417 | 417 | sprintf( |
418 | 418 | /* translators: %s: Paypal IPN response */ |
419 | - esc_html__( 'Invalid currency in IPN response. IPN data: %s', 'give' ), |
|
420 | - json_encode( $data ) |
|
419 | + esc_html__('Invalid currency in IPN response. IPN data: %s', 'give'), |
|
420 | + json_encode($data) |
|
421 | 421 | ), |
422 | 422 | $payment_id |
423 | 423 | ); |
424 | - give_update_payment_status( $payment_id, 'failed' ); |
|
425 | - give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid currency in PayPal IPN.', 'give' ) ); |
|
424 | + give_update_payment_status($payment_id, 'failed'); |
|
425 | + give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid currency in PayPal IPN.', 'give')); |
|
426 | 426 | |
427 | 427 | return; |
428 | 428 | } |
429 | 429 | |
430 | 430 | //Process refunds & reversed. |
431 | - if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) { |
|
432 | - give_process_paypal_refund( $data, $payment_id ); |
|
431 | + if ($payment_status == 'refunded' || $payment_status == 'reversed') { |
|
432 | + give_process_paypal_refund($data, $payment_id); |
|
433 | 433 | return; |
434 | 434 | } |
435 | 435 | |
436 | 436 | // Only complete payments once. |
437 | - if ( get_post_status( $payment_id ) == 'publish' ) { |
|
437 | + if (get_post_status($payment_id) == 'publish') { |
|
438 | 438 | return; |
439 | 439 | } |
440 | 440 | |
441 | 441 | // Retrieve the total donation amount (before PayPal). |
442 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
442 | + $payment_amount = give_get_payment_amount($payment_id); |
|
443 | 443 | |
444 | 444 | //Check that the donation PP and local db amounts match. |
445 | - if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
445 | + if (number_format((float) $paypal_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
446 | 446 | // The prices don't match |
447 | 447 | give_record_gateway_error( |
448 | - esc_html__( 'IPN Error', 'give' ), |
|
448 | + esc_html__('IPN Error', 'give'), |
|
449 | 449 | sprintf( |
450 | 450 | /* translators: %s: Paypal IPN response */ |
451 | - esc_html__( 'Invalid payment amount in IPN response. IPN data: %s', 'give' ), |
|
452 | - json_encode( $data ) |
|
451 | + esc_html__('Invalid payment amount in IPN response. IPN data: %s', 'give'), |
|
452 | + json_encode($data) |
|
453 | 453 | ), |
454 | 454 | $payment_id |
455 | 455 | ); |
456 | - give_update_payment_status( $payment_id, 'failed' ); |
|
457 | - give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid amount in PayPal IPN.', 'give' ) ); |
|
456 | + give_update_payment_status($payment_id, 'failed'); |
|
457 | + give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid amount in PayPal IPN.', 'give')); |
|
458 | 458 | |
459 | 459 | return; |
460 | 460 | } |
461 | 461 | |
462 | 462 | //Process completed donations. |
463 | - if ( $payment_status == 'completed' || give_is_test_mode() ) { |
|
463 | + if ($payment_status == 'completed' || give_is_test_mode()) { |
|
464 | 464 | |
465 | 465 | give_insert_payment_note( |
466 | 466 | $payment_id, |
467 | 467 | sprintf( |
468 | 468 | /* translators: %s: Paypal transaction ID */ |
469 | - esc_html__( 'PayPal Transaction ID: %s', 'give' ), |
|
469 | + esc_html__('PayPal Transaction ID: %s', 'give'), |
|
470 | 470 | $data['txn_id'] |
471 | 471 | ) |
472 | 472 | ); |
473 | - give_set_payment_transaction_id( $payment_id, $data['txn_id'] ); |
|
474 | - give_update_payment_status( $payment_id, 'publish' ); |
|
473 | + give_set_payment_transaction_id($payment_id, $data['txn_id']); |
|
474 | + give_update_payment_status($payment_id, 'publish'); |
|
475 | 475 | |
476 | - } elseif ( 'pending' == $payment_status && isset( $data['pending_reason'] ) ) { |
|
476 | + } elseif ('pending' == $payment_status && isset($data['pending_reason'])) { |
|
477 | 477 | |
478 | 478 | // Look for possible pending reasons, such as an echeck. |
479 | - $note = give_paypal_get_pending_donation_note( strtolower( $data['pending_reason'] ) ); |
|
479 | + $note = give_paypal_get_pending_donation_note(strtolower($data['pending_reason'])); |
|
480 | 480 | |
481 | - if ( ! empty( $note ) ) { |
|
481 | + if ( ! empty($note)) { |
|
482 | 482 | |
483 | - give_insert_payment_note( $payment_id, $note ); |
|
483 | + give_insert_payment_note($payment_id, $note); |
|
484 | 484 | |
485 | 485 | } |
486 | 486 | } |
487 | 487 | |
488 | 488 | } |
489 | 489 | |
490 | -add_action( 'give_paypal_web_accept', 'give_process_paypal_web_accept_and_cart', 10, 2 ); |
|
490 | +add_action('give_paypal_web_accept', 'give_process_paypal_web_accept_and_cart', 10, 2); |
|
491 | 491 | |
492 | 492 | /** |
493 | 493 | * Process PayPal IPN Refunds |
@@ -499,28 +499,28 @@ discard block |
||
499 | 499 | * |
500 | 500 | * @return void |
501 | 501 | */ |
502 | -function give_process_paypal_refund( $data, $payment_id = 0 ) { |
|
502 | +function give_process_paypal_refund($data, $payment_id = 0) { |
|
503 | 503 | |
504 | 504 | // Collect payment details |
505 | 505 | |
506 | - if ( empty( $payment_id ) ) { |
|
506 | + if (empty($payment_id)) { |
|
507 | 507 | return; |
508 | 508 | } |
509 | 509 | |
510 | - if ( get_post_status( $payment_id ) == 'refunded' ) { |
|
510 | + if (get_post_status($payment_id) == 'refunded') { |
|
511 | 511 | return; // Only refund payments once |
512 | 512 | } |
513 | 513 | |
514 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
514 | + $payment_amount = give_get_payment_amount($payment_id); |
|
515 | 515 | $refund_amount = $data['payment_gross'] * - 1; |
516 | 516 | |
517 | - if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
517 | + if (number_format((float) $refund_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
518 | 518 | |
519 | 519 | give_insert_payment_note( |
520 | 520 | $payment_id, |
521 | 521 | sprintf( |
522 | 522 | /* translators: %s: Paypal parent transaction ID */ |
523 | - esc_html__( 'Partial PayPal refund processed: %s', 'give' ), |
|
523 | + esc_html__('Partial PayPal refund processed: %s', 'give'), |
|
524 | 524 | $data['parent_txn_id'] |
525 | 525 | ) |
526 | 526 | ); |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | $payment_id, |
534 | 534 | sprintf( |
535 | 535 | /* translators: 1: Paypal parent transaction ID 2. Paypal reason code */ |
536 | - esc_html__( 'PayPal Payment #%1$s Refunded for reason: %2$s', 'give' ), |
|
536 | + esc_html__('PayPal Payment #%1$s Refunded for reason: %2$s', 'give'), |
|
537 | 537 | $data['parent_txn_id'], |
538 | 538 | $data['reason_code'] |
539 | 539 | ) |
@@ -542,11 +542,11 @@ discard block |
||
542 | 542 | $payment_id, |
543 | 543 | sprintf( |
544 | 544 | /* translators: %s: Paypal transaction ID */ |
545 | - esc_html__( 'PayPal Refund Transaction ID: %s', 'give' ), |
|
545 | + esc_html__('PayPal Refund Transaction ID: %s', 'give'), |
|
546 | 546 | $data['txn_id'] |
547 | 547 | ) |
548 | 548 | ); |
549 | - give_update_payment_status( $payment_id, 'refunded' ); |
|
549 | + give_update_payment_status($payment_id, 'refunded'); |
|
550 | 550 | } |
551 | 551 | |
552 | 552 | /** |
@@ -558,24 +558,24 @@ discard block |
||
558 | 558 | * |
559 | 559 | * @return string |
560 | 560 | */ |
561 | -function give_get_paypal_redirect( $ssl_check = false ) { |
|
561 | +function give_get_paypal_redirect($ssl_check = false) { |
|
562 | 562 | |
563 | - if ( is_ssl() || ! $ssl_check ) { |
|
563 | + if (is_ssl() || ! $ssl_check) { |
|
564 | 564 | $protocal = 'https://'; |
565 | 565 | } else { |
566 | 566 | $protocal = 'http://'; |
567 | 567 | } |
568 | 568 | |
569 | 569 | // Check the current payment mode |
570 | - if ( give_is_test_mode() ) { |
|
570 | + if (give_is_test_mode()) { |
|
571 | 571 | // Test mode |
572 | - $paypal_uri = $protocal . 'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
572 | + $paypal_uri = $protocal.'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
573 | 573 | } else { |
574 | 574 | // Live mode |
575 | - $paypal_uri = $protocal . 'www.paypal.com/cgi-bin/webscr'; |
|
575 | + $paypal_uri = $protocal.'www.paypal.com/cgi-bin/webscr'; |
|
576 | 576 | } |
577 | 577 | |
578 | - return apply_filters( 'give_paypal_uri', $paypal_uri ); |
|
578 | + return apply_filters('give_paypal_uri', $paypal_uri); |
|
579 | 579 | } |
580 | 580 | |
581 | 581 | /** |
@@ -585,9 +585,9 @@ discard block |
||
585 | 585 | * @return string |
586 | 586 | */ |
587 | 587 | function give_get_paypal_page_style() { |
588 | - $page_style = trim( give_get_option( 'paypal_page_style', 'PayPal' ) ); |
|
588 | + $page_style = trim(give_get_option('paypal_page_style', 'PayPal')); |
|
589 | 589 | |
590 | - return apply_filters( 'give_paypal_page_style', $page_style ); |
|
590 | + return apply_filters('give_paypal_page_style', $page_style); |
|
591 | 591 | } |
592 | 592 | |
593 | 593 | /** |
@@ -602,26 +602,26 @@ discard block |
||
602 | 602 | * @return string |
603 | 603 | * |
604 | 604 | */ |
605 | -function give_paypal_success_page_content( $content ) { |
|
605 | +function give_paypal_success_page_content($content) { |
|
606 | 606 | |
607 | - if ( ! isset( $_GET['payment-id'] ) && ! give_get_purchase_session() ) { |
|
607 | + if ( ! isset($_GET['payment-id']) && ! give_get_purchase_session()) { |
|
608 | 608 | return $content; |
609 | 609 | } |
610 | 610 | |
611 | - $payment_id = isset( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : false; |
|
611 | + $payment_id = isset($_GET['payment-id']) ? absint($_GET['payment-id']) : false; |
|
612 | 612 | |
613 | - if ( ! $payment_id ) { |
|
613 | + if ( ! $payment_id) { |
|
614 | 614 | $session = give_get_purchase_session(); |
615 | - $payment_id = give_get_purchase_id_by_key( $session['purchase_key'] ); |
|
615 | + $payment_id = give_get_purchase_id_by_key($session['purchase_key']); |
|
616 | 616 | } |
617 | 617 | |
618 | - $payment = get_post( $payment_id ); |
|
619 | - if ( $payment && 'pending' == $payment->post_status ) { |
|
618 | + $payment = get_post($payment_id); |
|
619 | + if ($payment && 'pending' == $payment->post_status) { |
|
620 | 620 | |
621 | 621 | // Payment is still pending so show processing indicator to fix the race condition. |
622 | 622 | ob_start(); |
623 | 623 | |
624 | - give_get_template_part( 'payment', 'processing' ); |
|
624 | + give_get_template_part('payment', 'processing'); |
|
625 | 625 | |
626 | 626 | $content = ob_get_clean(); |
627 | 627 | |
@@ -631,7 +631,7 @@ discard block |
||
631 | 631 | |
632 | 632 | } |
633 | 633 | |
634 | -add_filter( 'give_payment_confirm_paypal', 'give_paypal_success_page_content' ); |
|
634 | +add_filter('give_payment_confirm_paypal', 'give_paypal_success_page_content'); |
|
635 | 635 | |
636 | 636 | /** |
637 | 637 | * Given a Payment ID, extract the transaction ID |
@@ -642,22 +642,22 @@ discard block |
||
642 | 642 | * |
643 | 643 | * @return string Transaction ID |
644 | 644 | */ |
645 | -function give_paypal_get_payment_transaction_id( $payment_id ) { |
|
645 | +function give_paypal_get_payment_transaction_id($payment_id) { |
|
646 | 646 | |
647 | 647 | $transaction_id = ''; |
648 | - $notes = give_get_payment_notes( $payment_id ); |
|
648 | + $notes = give_get_payment_notes($payment_id); |
|
649 | 649 | |
650 | - foreach ( $notes as $note ) { |
|
651 | - if ( preg_match( '/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match ) ) { |
|
650 | + foreach ($notes as $note) { |
|
651 | + if (preg_match('/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match)) { |
|
652 | 652 | $transaction_id = $match[1]; |
653 | 653 | continue; |
654 | 654 | } |
655 | 655 | } |
656 | 656 | |
657 | - return apply_filters( 'give_paypal_set_payment_transaction_id', $transaction_id, $payment_id ); |
|
657 | + return apply_filters('give_paypal_set_payment_transaction_id', $transaction_id, $payment_id); |
|
658 | 658 | } |
659 | 659 | |
660 | -add_filter( 'give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1 ); |
|
660 | +add_filter('give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1); |
|
661 | 661 | |
662 | 662 | /** |
663 | 663 | * Given a transaction ID, generate a link to the PayPal transaction ID details |
@@ -669,16 +669,16 @@ discard block |
||
669 | 669 | * |
670 | 670 | * @return string A link to the PayPal transaction details |
671 | 671 | */ |
672 | -function give_paypal_link_transaction_id( $transaction_id, $payment_id ) { |
|
672 | +function give_paypal_link_transaction_id($transaction_id, $payment_id) { |
|
673 | 673 | |
674 | 674 | $paypal_base_url = 'https://history.paypal.com/cgi-bin/webscr?cmd=_history-details-from-hub&id='; |
675 | - $transaction_url = '<a href="' . esc_url( $paypal_base_url . $transaction_id ) . '" target="_blank">' . $transaction_id . '</a>'; |
|
675 | + $transaction_url = '<a href="'.esc_url($paypal_base_url.$transaction_id).'" target="_blank">'.$transaction_id.'</a>'; |
|
676 | 676 | |
677 | - return apply_filters( 'give_paypal_link_payment_details_transaction_id', $transaction_url ); |
|
677 | + return apply_filters('give_paypal_link_payment_details_transaction_id', $transaction_url); |
|
678 | 678 | |
679 | 679 | } |
680 | 680 | |
681 | -add_filter( 'give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2 ); |
|
681 | +add_filter('give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2); |
|
682 | 682 | |
683 | 683 | |
684 | 684 | /** |
@@ -690,64 +690,64 @@ discard block |
||
690 | 690 | * |
691 | 691 | * @return string |
692 | 692 | */ |
693 | -function give_paypal_get_pending_donation_note( $pending_reason ) { |
|
693 | +function give_paypal_get_pending_donation_note($pending_reason) { |
|
694 | 694 | |
695 | 695 | $note = ''; |
696 | 696 | |
697 | - switch ( $pending_reason ) { |
|
697 | + switch ($pending_reason) { |
|
698 | 698 | |
699 | 699 | case 'echeck' : |
700 | 700 | |
701 | - $note = esc_html__( 'Payment made via eCheck and will clear automatically in 5-8 days.', 'give' ); |
|
701 | + $note = esc_html__('Payment made via eCheck and will clear automatically in 5-8 days.', 'give'); |
|
702 | 702 | |
703 | 703 | break; |
704 | 704 | |
705 | 705 | case 'address' : |
706 | 706 | |
707 | - $note = esc_html__( 'Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give' ); |
|
707 | + $note = esc_html__('Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give'); |
|
708 | 708 | |
709 | 709 | break; |
710 | 710 | |
711 | 711 | case 'intl' : |
712 | 712 | |
713 | - $note = esc_html__( 'Payment must be accepted manually through PayPal due to international account regulations.', 'give' ); |
|
713 | + $note = esc_html__('Payment must be accepted manually through PayPal due to international account regulations.', 'give'); |
|
714 | 714 | |
715 | 715 | break; |
716 | 716 | |
717 | 717 | case 'multi-currency' : |
718 | 718 | |
719 | - $note = esc_html__( 'Payment received in non-shop currency and must be accepted manually through PayPal.', 'give' ); |
|
719 | + $note = esc_html__('Payment received in non-shop currency and must be accepted manually through PayPal.', 'give'); |
|
720 | 720 | |
721 | 721 | break; |
722 | 722 | |
723 | 723 | case 'paymentreview' : |
724 | 724 | case 'regulatory_review' : |
725 | 725 | |
726 | - $note = esc_html__( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give' ); |
|
726 | + $note = esc_html__('Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give'); |
|
727 | 727 | |
728 | 728 | break; |
729 | 729 | |
730 | 730 | case 'unilateral' : |
731 | 731 | |
732 | - $note = esc_html__( 'Payment was sent to non-confirmed or non-registered email address.', 'give' ); |
|
732 | + $note = esc_html__('Payment was sent to non-confirmed or non-registered email address.', 'give'); |
|
733 | 733 | |
734 | 734 | break; |
735 | 735 | |
736 | 736 | case 'upgrade' : |
737 | 737 | |
738 | - $note = esc_html__( 'PayPal account must be upgraded before this payment can be accepted.', 'give' ); |
|
738 | + $note = esc_html__('PayPal account must be upgraded before this payment can be accepted.', 'give'); |
|
739 | 739 | |
740 | 740 | break; |
741 | 741 | |
742 | 742 | case 'verify' : |
743 | 743 | |
744 | - $note = esc_html__( 'PayPal account is not verified. Verify account in order to accept this donation.', 'give' ); |
|
744 | + $note = esc_html__('PayPal account is not verified. Verify account in order to accept this donation.', 'give'); |
|
745 | 745 | |
746 | 746 | break; |
747 | 747 | |
748 | 748 | case 'other' : |
749 | 749 | |
750 | - $note = esc_html__( 'Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give' ); |
|
750 | + $note = esc_html__('Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give'); |
|
751 | 751 | |
752 | 752 | break; |
753 | 753 |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | * |
327 | 327 | * @since 1.0 |
328 | 328 | * |
329 | - * @param int|bool $form_id Form ID (default: false). |
|
329 | + * @param boolean $form_id Form ID (default: false). |
|
330 | 330 | * @param int $payment_id Payment ID. |
331 | 331 | * |
332 | 332 | * @return void |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | * @param int $year Year number. Default is null. |
645 | 645 | * @param int $hour Hour number. Default is null. |
646 | 646 | * |
647 | - * @return int $earnings Earnings |
|
647 | + * @return double $earnings Earnings |
|
648 | 648 | */ |
649 | 649 | function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) { |
650 | 650 | |
@@ -959,7 +959,7 @@ discard block |
||
959 | 959 | * |
960 | 960 | * @param int $payment_id Payment ID. |
961 | 961 | * |
962 | - * @return int $form_id Form ID. |
|
962 | + * @return string $form_id Form ID. |
|
963 | 963 | */ |
964 | 964 | function give_get_payment_form_id( $payment_id ) { |
965 | 965 | $payment = new Give_Payment( $payment_id ); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -43,15 +43,15 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @return object $payments Payments retrieved from the database |
45 | 45 | */ |
46 | -function give_get_payments( $args = array() ) { |
|
46 | +function give_get_payments($args = array()) { |
|
47 | 47 | |
48 | 48 | // Fallback to post objects to ensure backwards compatibility. |
49 | - if ( ! isset( $args['output'] ) ) { |
|
49 | + if ( ! isset($args['output'])) { |
|
50 | 50 | $args['output'] = 'posts'; |
51 | 51 | } |
52 | 52 | |
53 | - $args = apply_filters( 'give_get_payments_args', $args ); |
|
54 | - $payments = new Give_Payments_Query( $args ); |
|
53 | + $args = apply_filters('give_get_payments_args', $args); |
|
54 | + $payments = new Give_Payments_Query($args); |
|
55 | 55 | |
56 | 56 | return $payments->get_payments(); |
57 | 57 | } |
@@ -66,48 +66,48 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @return mixed |
68 | 68 | */ |
69 | -function give_get_payment_by( $field = '', $value = '' ) { |
|
69 | +function give_get_payment_by($field = '', $value = '') { |
|
70 | 70 | |
71 | - if ( empty( $field ) || empty( $value ) ) { |
|
71 | + if (empty($field) || empty($value)) { |
|
72 | 72 | return false; |
73 | 73 | } |
74 | 74 | |
75 | - switch ( strtolower( $field ) ) { |
|
75 | + switch (strtolower($field)) { |
|
76 | 76 | |
77 | 77 | case 'id': |
78 | - $payment = new Give_Payment( $value ); |
|
78 | + $payment = new Give_Payment($value); |
|
79 | 79 | $id = $payment->ID; |
80 | 80 | |
81 | - if ( empty( $id ) ) { |
|
81 | + if (empty($id)) { |
|
82 | 82 | return false; |
83 | 83 | } |
84 | 84 | |
85 | 85 | break; |
86 | 86 | |
87 | 87 | case 'key': |
88 | - $payment = give_get_payments( array( |
|
88 | + $payment = give_get_payments(array( |
|
89 | 89 | 'meta_key' => '_give_payment_purchase_key', |
90 | 90 | 'meta_value' => $value, |
91 | 91 | 'posts_per_page' => 1, |
92 | 92 | 'fields' => 'ids', |
93 | - ) ); |
|
93 | + )); |
|
94 | 94 | |
95 | - if ( $payment ) { |
|
96 | - $payment = new Give_Payment( $payment[0] ); |
|
95 | + if ($payment) { |
|
96 | + $payment = new Give_Payment($payment[0]); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | break; |
100 | 100 | |
101 | 101 | case 'payment_number': |
102 | - $payment = give_get_payments( array( |
|
102 | + $payment = give_get_payments(array( |
|
103 | 103 | 'meta_key' => '_give_payment_number', |
104 | 104 | 'meta_value' => $value, |
105 | 105 | 'posts_per_page' => 1, |
106 | 106 | 'fields' => 'ids', |
107 | - ) ); |
|
107 | + )); |
|
108 | 108 | |
109 | - if ( $payment ) { |
|
110 | - $payment = new Give_Payment( $payment[0] ); |
|
109 | + if ($payment) { |
|
110 | + $payment = new Give_Payment($payment[0]); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | break; |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | return false; |
117 | 117 | } |
118 | 118 | |
119 | - if ( $payment ) { |
|
119 | + if ($payment) { |
|
120 | 120 | return $payment; |
121 | 121 | } |
122 | 122 | |
@@ -132,23 +132,23 @@ discard block |
||
132 | 132 | * |
133 | 133 | * @return int|bool Payment ID if payment is inserted, false otherwise. |
134 | 134 | */ |
135 | -function give_insert_payment( $payment_data = array() ) { |
|
135 | +function give_insert_payment($payment_data = array()) { |
|
136 | 136 | |
137 | - if ( empty( $payment_data ) ) { |
|
137 | + if (empty($payment_data)) { |
|
138 | 138 | return false; |
139 | 139 | } |
140 | 140 | |
141 | 141 | $payment = new Give_Payment(); |
142 | - $gateway = ! empty( $payment_data['gateway'] ) ? $payment_data['gateway'] : ''; |
|
143 | - $gateway = empty( $gateway ) && isset( $_POST['give-gateway'] ) ? $_POST['give-gateway'] : $gateway; |
|
144 | - $form_id = isset( $payment_data['give_form_id'] ) ? $payment_data['give_form_id'] : 0; |
|
145 | - $price_id = isset( $payment_data['give_price_id'] ) ? $payment_data['give_price_id'] : give_get_price_id( $payment_data['give_form_id'], $payment_data['price'] ); |
|
146 | - $form_title = isset( $payment_data['give_form_title'] ) ? $payment_data['give_form_title'] : get_the_title( $form_id ); |
|
142 | + $gateway = ! empty($payment_data['gateway']) ? $payment_data['gateway'] : ''; |
|
143 | + $gateway = empty($gateway) && isset($_POST['give-gateway']) ? $_POST['give-gateway'] : $gateway; |
|
144 | + $form_id = isset($payment_data['give_form_id']) ? $payment_data['give_form_id'] : 0; |
|
145 | + $price_id = isset($payment_data['give_price_id']) ? $payment_data['give_price_id'] : give_get_price_id($payment_data['give_form_id'], $payment_data['price']); |
|
146 | + $form_title = isset($payment_data['give_form_title']) ? $payment_data['give_form_title'] : get_the_title($form_id); |
|
147 | 147 | |
148 | 148 | // Set properties. |
149 | 149 | $payment->total = $payment_data['price']; |
150 | - $payment->status = ! empty( $payment_data['status'] ) ? $payment_data['status'] : 'pending'; |
|
151 | - $payment->currency = ! empty( $payment_data['currency'] ) ? $payment_data['currency'] : give_get_currency(); |
|
150 | + $payment->status = ! empty($payment_data['status']) ? $payment_data['status'] : 'pending'; |
|
151 | + $payment->currency = ! empty($payment_data['currency']) ? $payment_data['currency'] : give_get_currency(); |
|
152 | 152 | $payment->user_info = $payment_data['user_info']; |
153 | 153 | $payment->gateway = $gateway; |
154 | 154 | $payment->form_title = $form_title; |
@@ -162,31 +162,31 @@ discard block |
||
162 | 162 | $payment->ip = give_get_ip(); |
163 | 163 | $payment->key = $payment_data['purchase_key']; |
164 | 164 | $payment->mode = give_is_test_mode() ? 'test' : 'live'; |
165 | - $payment->parent_payment = ! empty( $payment_data['parent'] ) ? absint( $payment_data['parent'] ) : ''; |
|
165 | + $payment->parent_payment = ! empty($payment_data['parent']) ? absint($payment_data['parent']) : ''; |
|
166 | 166 | |
167 | 167 | // Add the donation. |
168 | 168 | $args = array( |
169 | 169 | 'price' => $payment->total, |
170 | 170 | 'price_id' => $payment->price_id, |
171 | - 'fees' => isset( $payment_data['fees'] ) ? $payment_data['fees'] : array(), |
|
171 | + 'fees' => isset($payment_data['fees']) ? $payment_data['fees'] : array(), |
|
172 | 172 | ); |
173 | 173 | |
174 | - $payment->add_donation( $payment->form_id, $args ); |
|
174 | + $payment->add_donation($payment->form_id, $args); |
|
175 | 175 | |
176 | 176 | // Set date if present. |
177 | - if ( isset( $payment_data['post_date'] ) ) { |
|
177 | + if (isset($payment_data['post_date'])) { |
|
178 | 178 | $payment->date = $payment_data['post_date']; |
179 | 179 | } |
180 | 180 | |
181 | 181 | // Handle sequential payments. |
182 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
182 | + if (give_get_option('enable_sequential')) { |
|
183 | 183 | $number = give_get_next_payment_number(); |
184 | - $payment->number = give_format_payment_number( $number ); |
|
185 | - update_option( 'give_last_payment_number', $number ); |
|
184 | + $payment->number = give_format_payment_number($number); |
|
185 | + update_option('give_last_payment_number', $number); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | // Clear the user's donation cache. |
189 | - delete_transient( 'give_user_' . $payment_data['user_info']['id'] . '_purchases' ); |
|
189 | + delete_transient('give_user_'.$payment_data['user_info']['id'].'_purchases'); |
|
190 | 190 | |
191 | 191 | // Save payment. |
192 | 192 | $payment->save(); |
@@ -199,10 +199,10 @@ discard block |
||
199 | 199 | * @param int $payment_id The payment ID. |
200 | 200 | * @param array $payment_data Arguments passed. |
201 | 201 | */ |
202 | - do_action( 'give_insert_payment', $payment->ID, $payment_data ); |
|
202 | + do_action('give_insert_payment', $payment->ID, $payment_data); |
|
203 | 203 | |
204 | 204 | // Return payment ID upon success. |
205 | - if ( ! empty( $payment->ID ) ) { |
|
205 | + if ( ! empty($payment->ID)) { |
|
206 | 206 | return $payment->ID; |
207 | 207 | } |
208 | 208 | |
@@ -221,9 +221,9 @@ discard block |
||
221 | 221 | * |
222 | 222 | * @return bool |
223 | 223 | */ |
224 | -function give_update_payment_status( $payment_id, $new_status = 'publish' ) { |
|
224 | +function give_update_payment_status($payment_id, $new_status = 'publish') { |
|
225 | 225 | |
226 | - $payment = new Give_Payment( $payment_id ); |
|
226 | + $payment = new Give_Payment($payment_id); |
|
227 | 227 | $payment->status = $new_status; |
228 | 228 | $updated = $payment->save(); |
229 | 229 | |
@@ -242,37 +242,37 @@ discard block |
||
242 | 242 | * |
243 | 243 | * @return void |
244 | 244 | */ |
245 | -function give_delete_purchase( $payment_id = 0, $update_customer = true ) { |
|
245 | +function give_delete_purchase($payment_id = 0, $update_customer = true) { |
|
246 | 246 | global $give_logs; |
247 | 247 | |
248 | - $payment = new Give_Payment( $payment_id ); |
|
249 | - $amount = give_get_payment_amount( $payment_id ); |
|
248 | + $payment = new Give_Payment($payment_id); |
|
249 | + $amount = give_get_payment_amount($payment_id); |
|
250 | 250 | $status = $payment->post_status; |
251 | - $customer_id = give_get_payment_customer_id( $payment_id ); |
|
252 | - $customer = new Give_Customer( $customer_id ); |
|
251 | + $customer_id = give_get_payment_customer_id($payment_id); |
|
252 | + $customer = new Give_Customer($customer_id); |
|
253 | 253 | |
254 | 254 | // Only undo donations that aren't these statuses. |
255 | - $dont_undo_statuses = apply_filters( 'give_undo_purchase_statuses', array( |
|
255 | + $dont_undo_statuses = apply_filters('give_undo_purchase_statuses', array( |
|
256 | 256 | 'pending', |
257 | 257 | 'cancelled', |
258 | - ) ); |
|
258 | + )); |
|
259 | 259 | |
260 | - if ( ! in_array( $status, $dont_undo_statuses ) ) { |
|
261 | - give_undo_purchase( false, $payment_id ); |
|
260 | + if ( ! in_array($status, $dont_undo_statuses)) { |
|
261 | + give_undo_purchase(false, $payment_id); |
|
262 | 262 | } |
263 | 263 | |
264 | - if ( $status == 'publish' ) { |
|
264 | + if ($status == 'publish') { |
|
265 | 265 | |
266 | 266 | // Only decrease earnings if they haven't already been decreased (or were never increased for this payment). |
267 | - give_decrease_total_earnings( $amount ); |
|
267 | + give_decrease_total_earnings($amount); |
|
268 | 268 | // Clear the This Month earnings (this_monththis_month is NOT a typo). |
269 | - delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
269 | + delete_transient(md5('give_earnings_this_monththis_month')); |
|
270 | 270 | |
271 | - if ( $customer->id && $update_customer ) { |
|
271 | + if ($customer->id && $update_customer) { |
|
272 | 272 | |
273 | 273 | // Decrement the stats for the customer. |
274 | 274 | $customer->decrease_purchase_count(); |
275 | - $customer->decrease_value( $amount ); |
|
275 | + $customer->decrease_value($amount); |
|
276 | 276 | |
277 | 277 | } |
278 | 278 | } |
@@ -284,17 +284,17 @@ discard block |
||
284 | 284 | * |
285 | 285 | * @param int $payment_id Payment ID. |
286 | 286 | */ |
287 | - do_action( 'give_payment_delete', $payment_id ); |
|
287 | + do_action('give_payment_delete', $payment_id); |
|
288 | 288 | |
289 | - if ( $customer->id && $update_customer ) { |
|
289 | + if ($customer->id && $update_customer) { |
|
290 | 290 | |
291 | 291 | // Remove the payment ID from the customer. |
292 | - $customer->remove_payment( $payment_id ); |
|
292 | + $customer->remove_payment($payment_id); |
|
293 | 293 | |
294 | 294 | } |
295 | 295 | |
296 | 296 | // Remove the payment. |
297 | - wp_delete_post( $payment_id, true ); |
|
297 | + wp_delete_post($payment_id, true); |
|
298 | 298 | |
299 | 299 | // Remove related sale log entries. |
300 | 300 | $give_logs->delete_logs( |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | * |
316 | 316 | * @param int $payment_id Payment ID. |
317 | 317 | */ |
318 | - do_action( 'give_payment_deleted', $payment_id ); |
|
318 | + do_action('give_payment_deleted', $payment_id); |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | /** |
@@ -331,25 +331,25 @@ discard block |
||
331 | 331 | * |
332 | 332 | * @return void |
333 | 333 | */ |
334 | -function give_undo_purchase( $form_id = false, $payment_id ) { |
|
334 | +function give_undo_purchase($form_id = false, $payment_id) { |
|
335 | 335 | |
336 | - if ( ! empty( $form_id ) ) { |
|
336 | + if ( ! empty($form_id)) { |
|
337 | 337 | $form_id = false; |
338 | - _give_deprected_argument( 'form_id', 'give_undo_purchase', '1.5' ); |
|
338 | + _give_deprected_argument('form_id', 'give_undo_purchase', '1.5'); |
|
339 | 339 | } |
340 | 340 | |
341 | - $payment = new Give_Payment( $payment_id ); |
|
341 | + $payment = new Give_Payment($payment_id); |
|
342 | 342 | |
343 | - $maybe_decrease_earnings = apply_filters( 'give_decrease_earnings_on_undo', true, $payment, $payment->form_id ); |
|
344 | - if ( true === $maybe_decrease_earnings ) { |
|
343 | + $maybe_decrease_earnings = apply_filters('give_decrease_earnings_on_undo', true, $payment, $payment->form_id); |
|
344 | + if (true === $maybe_decrease_earnings) { |
|
345 | 345 | // Decrease earnings. |
346 | - give_decrease_earnings( $payment->form_id, $payment->total ); |
|
346 | + give_decrease_earnings($payment->form_id, $payment->total); |
|
347 | 347 | } |
348 | 348 | |
349 | - $maybe_decrease_sales = apply_filters( 'give_decrease_sales_on_undo', true, $payment, $payment->form_id ); |
|
350 | - if ( true === $maybe_decrease_sales ) { |
|
349 | + $maybe_decrease_sales = apply_filters('give_decrease_sales_on_undo', true, $payment, $payment->form_id); |
|
350 | + if (true === $maybe_decrease_sales) { |
|
351 | 351 | // Decrease donation count. |
352 | - give_decrease_purchase_count( $payment->form_id ); |
|
352 | + give_decrease_purchase_count($payment->form_id); |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | } |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | * |
367 | 367 | * @return array $count Number of payments sorted by payment status. |
368 | 368 | */ |
369 | -function give_count_payments( $args = array() ) { |
|
369 | +function give_count_payments($args = array()) { |
|
370 | 370 | |
371 | 371 | global $wpdb; |
372 | 372 | |
@@ -378,18 +378,18 @@ discard block |
||
378 | 378 | 'form_id' => null, |
379 | 379 | ); |
380 | 380 | |
381 | - $args = wp_parse_args( $args, $defaults ); |
|
381 | + $args = wp_parse_args($args, $defaults); |
|
382 | 382 | |
383 | 383 | $select = 'SELECT p.post_status,count( * ) AS num_posts'; |
384 | 384 | $join = ''; |
385 | 385 | $where = "WHERE p.post_type = 'give_payment'"; |
386 | 386 | |
387 | 387 | // Count payments for a specific user. |
388 | - if ( ! empty( $args['user'] ) ) { |
|
388 | + if ( ! empty($args['user'])) { |
|
389 | 389 | |
390 | - if ( is_email( $args['user'] ) ) { |
|
390 | + if (is_email($args['user'])) { |
|
391 | 391 | $field = 'email'; |
392 | - } elseif ( is_numeric( $args['user'] ) ) { |
|
392 | + } elseif (is_numeric($args['user'])) { |
|
393 | 393 | $field = 'id'; |
394 | 394 | } else { |
395 | 395 | $field = ''; |
@@ -397,105 +397,105 @@ discard block |
||
397 | 397 | |
398 | 398 | $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
399 | 399 | |
400 | - if ( ! empty( $field ) ) { |
|
400 | + if ( ! empty($field)) { |
|
401 | 401 | $where .= " |
402 | 402 | AND m.meta_key = '_give_payment_user_{$field}' |
403 | 403 | AND m.meta_value = '{$args['user']}'"; |
404 | 404 | } |
405 | 405 | |
406 | 406 | // Count payments for a search. |
407 | - } elseif ( ! empty( $args['s'] ) ) { |
|
407 | + } elseif ( ! empty($args['s'])) { |
|
408 | 408 | |
409 | - if ( is_email( $args['s'] ) || strlen( $args['s'] ) == 32 ) { |
|
409 | + if (is_email($args['s']) || strlen($args['s']) == 32) { |
|
410 | 410 | |
411 | - if ( is_email( $args['s'] ) ) { |
|
411 | + if (is_email($args['s'])) { |
|
412 | 412 | $field = '_give_payment_user_email'; |
413 | 413 | } else { |
414 | 414 | $field = '_give_payment_purchase_key'; |
415 | 415 | } |
416 | 416 | |
417 | 417 | $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
418 | - $where .= $wpdb->prepare( ' |
|
418 | + $where .= $wpdb->prepare(' |
|
419 | 419 | AND m.meta_key = %s |
420 | 420 | AND m.meta_value = %s', |
421 | 421 | $field, |
422 | 422 | $args['s'] |
423 | 423 | ); |
424 | 424 | |
425 | - } elseif ( '#' == substr( $args['s'], 0, 1 ) ) { |
|
425 | + } elseif ('#' == substr($args['s'], 0, 1)) { |
|
426 | 426 | |
427 | - $search = str_replace( '#:', '', $args['s'] ); |
|
428 | - $search = str_replace( '#', '', $search ); |
|
427 | + $search = str_replace('#:', '', $args['s']); |
|
428 | + $search = str_replace('#', '', $search); |
|
429 | 429 | |
430 | 430 | $select = 'SELECT p2.post_status,count( * ) AS num_posts '; |
431 | 431 | $join = "LEFT JOIN $wpdb->postmeta m ON m.meta_key = '_give_log_payment_id' AND m.post_id = p.ID "; |
432 | 432 | $join .= "INNER JOIN $wpdb->posts p2 ON m.meta_value = p2.ID "; |
433 | 433 | $where = "WHERE p.post_type = 'give_log' "; |
434 | - $where .= $wpdb->prepare( 'AND p.post_parent = %d} ', $search ); |
|
434 | + $where .= $wpdb->prepare('AND p.post_parent = %d} ', $search); |
|
435 | 435 | |
436 | - } elseif ( is_numeric( $args['s'] ) ) { |
|
436 | + } elseif (is_numeric($args['s'])) { |
|
437 | 437 | |
438 | 438 | $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
439 | - $where .= $wpdb->prepare( " |
|
439 | + $where .= $wpdb->prepare(" |
|
440 | 440 | AND m.meta_key = '_give_payment_user_id' |
441 | 441 | AND m.meta_value = %d", |
442 | 442 | $args['s'] |
443 | 443 | ); |
444 | 444 | |
445 | 445 | } else { |
446 | - $search = $wpdb->esc_like( $args['s'] ); |
|
447 | - $search = '%' . $search . '%'; |
|
446 | + $search = $wpdb->esc_like($args['s']); |
|
447 | + $search = '%'.$search.'%'; |
|
448 | 448 | |
449 | - $where .= $wpdb->prepare( 'AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search ); |
|
449 | + $where .= $wpdb->prepare('AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search); |
|
450 | 450 | } |
451 | 451 | } |
452 | 452 | |
453 | - if ( ! empty( $args['form_id'] ) && is_numeric( $args['form_id'] ) ) { |
|
453 | + if ( ! empty($args['form_id']) && is_numeric($args['form_id'])) { |
|
454 | 454 | |
455 | - $where .= $wpdb->prepare( ' AND p.post_parent = %d', $args['form_id'] ); |
|
455 | + $where .= $wpdb->prepare(' AND p.post_parent = %d', $args['form_id']); |
|
456 | 456 | |
457 | 457 | } |
458 | 458 | // Limit payments count by date. |
459 | - if ( ! empty( $args['start-date'] ) && false !== strpos( $args['start-date'], '/' ) ) { |
|
459 | + if ( ! empty($args['start-date']) && false !== strpos($args['start-date'], '/')) { |
|
460 | 460 | |
461 | - $date_parts = explode( '/', $args['start-date'] ); |
|
462 | - $month = ! empty( $date_parts[0] ) && is_numeric( $date_parts[0] ) ? $date_parts[0] : 0; |
|
463 | - $day = ! empty( $date_parts[1] ) && is_numeric( $date_parts[1] ) ? $date_parts[1] : 0; |
|
464 | - $year = ! empty( $date_parts[2] ) && is_numeric( $date_parts[2] ) ? $date_parts[2] : 0; |
|
461 | + $date_parts = explode('/', $args['start-date']); |
|
462 | + $month = ! empty($date_parts[0]) && is_numeric($date_parts[0]) ? $date_parts[0] : 0; |
|
463 | + $day = ! empty($date_parts[1]) && is_numeric($date_parts[1]) ? $date_parts[1] : 0; |
|
464 | + $year = ! empty($date_parts[2]) && is_numeric($date_parts[2]) ? $date_parts[2] : 0; |
|
465 | 465 | |
466 | - $is_date = checkdate( $month, $day, $year ); |
|
467 | - if ( false !== $is_date ) { |
|
466 | + $is_date = checkdate($month, $day, $year); |
|
467 | + if (false !== $is_date) { |
|
468 | 468 | |
469 | - $date = new DateTime( $args['start-date'] ); |
|
470 | - $where .= $wpdb->prepare( " AND p.post_date >= '%s'", $date->format( 'Y-m-d' ) ); |
|
469 | + $date = new DateTime($args['start-date']); |
|
470 | + $where .= $wpdb->prepare(" AND p.post_date >= '%s'", $date->format('Y-m-d')); |
|
471 | 471 | |
472 | 472 | } |
473 | 473 | |
474 | 474 | // Fixes an issue with the payments list table counts when no end date is specified (partiy with stats class). |
475 | - if ( empty( $args['end-date'] ) ) { |
|
475 | + if (empty($args['end-date'])) { |
|
476 | 476 | $args['end-date'] = $args['start-date']; |
477 | 477 | } |
478 | 478 | } |
479 | 479 | |
480 | - if ( ! empty( $args['end-date'] ) && false !== strpos( $args['end-date'], '/' ) ) { |
|
480 | + if ( ! empty($args['end-date']) && false !== strpos($args['end-date'], '/')) { |
|
481 | 481 | |
482 | - $date_parts = explode( '/', $args['end-date'] ); |
|
482 | + $date_parts = explode('/', $args['end-date']); |
|
483 | 483 | |
484 | - $month = ! empty( $date_parts[0] ) ? $date_parts[0] : 0; |
|
485 | - $day = ! empty( $date_parts[1] ) ? $date_parts[1] : 0; |
|
486 | - $year = ! empty( $date_parts[2] ) ? $date_parts[2] : 0; |
|
484 | + $month = ! empty($date_parts[0]) ? $date_parts[0] : 0; |
|
485 | + $day = ! empty($date_parts[1]) ? $date_parts[1] : 0; |
|
486 | + $year = ! empty($date_parts[2]) ? $date_parts[2] : 0; |
|
487 | 487 | |
488 | - $is_date = checkdate( $month, $day, $year ); |
|
489 | - if ( false !== $is_date ) { |
|
488 | + $is_date = checkdate($month, $day, $year); |
|
489 | + if (false !== $is_date) { |
|
490 | 490 | |
491 | - $date = new DateTime( $args['end-date'] ); |
|
492 | - $where .= $wpdb->prepare( " AND p.post_date <= '%s'", $date->format( 'Y-m-d' ) ); |
|
491 | + $date = new DateTime($args['end-date']); |
|
492 | + $where .= $wpdb->prepare(" AND p.post_date <= '%s'", $date->format('Y-m-d')); |
|
493 | 493 | |
494 | 494 | } |
495 | 495 | } |
496 | 496 | |
497 | - $where = apply_filters( 'give_count_payments_where', $where ); |
|
498 | - $join = apply_filters( 'give_count_payments_join', $join ); |
|
497 | + $where = apply_filters('give_count_payments_where', $where); |
|
498 | + $join = apply_filters('give_count_payments_join', $join); |
|
499 | 499 | |
500 | 500 | $query = "$select |
501 | 501 | FROM $wpdb->posts p |
@@ -504,36 +504,36 @@ discard block |
||
504 | 504 | GROUP BY p.post_status |
505 | 505 | "; |
506 | 506 | |
507 | - $cache_key = md5( $query ); |
|
507 | + $cache_key = md5($query); |
|
508 | 508 | |
509 | - $count = wp_cache_get( $cache_key, 'counts' ); |
|
510 | - if ( false !== $count ) { |
|
509 | + $count = wp_cache_get($cache_key, 'counts'); |
|
510 | + if (false !== $count) { |
|
511 | 511 | return $count; |
512 | 512 | } |
513 | 513 | |
514 | - $count = $wpdb->get_results( $query, ARRAY_A ); |
|
514 | + $count = $wpdb->get_results($query, ARRAY_A); |
|
515 | 515 | |
516 | 516 | $stats = array(); |
517 | 517 | $statuses = get_post_stati(); |
518 | - if ( isset( $statuses['private'] ) && empty( $args['s'] ) ) { |
|
519 | - unset( $statuses['private'] ); |
|
518 | + if (isset($statuses['private']) && empty($args['s'])) { |
|
519 | + unset($statuses['private']); |
|
520 | 520 | } |
521 | 521 | |
522 | - foreach ( $statuses as $state ) { |
|
523 | - $stats[ $state ] = 0; |
|
522 | + foreach ($statuses as $state) { |
|
523 | + $stats[$state] = 0; |
|
524 | 524 | } |
525 | 525 | |
526 | - foreach ( (array) $count as $row ) { |
|
526 | + foreach ((array) $count as $row) { |
|
527 | 527 | |
528 | - if ( 'private' == $row['post_status'] && empty( $args['s'] ) ) { |
|
528 | + if ('private' == $row['post_status'] && empty($args['s'])) { |
|
529 | 529 | continue; |
530 | 530 | } |
531 | 531 | |
532 | - $stats[ $row['post_status'] ] = $row['num_posts']; |
|
532 | + $stats[$row['post_status']] = $row['num_posts']; |
|
533 | 533 | } |
534 | 534 | |
535 | 535 | $stats = (object) $stats; |
536 | - wp_cache_set( $cache_key, $stats, 'counts' ); |
|
536 | + wp_cache_set($cache_key, $stats, 'counts'); |
|
537 | 537 | |
538 | 538 | return $stats; |
539 | 539 | } |
@@ -548,11 +548,11 @@ discard block |
||
548 | 548 | * |
549 | 549 | * @return bool $exists True if payment exists, false otherwise. |
550 | 550 | */ |
551 | -function give_check_for_existing_payment( $payment_id ) { |
|
551 | +function give_check_for_existing_payment($payment_id) { |
|
552 | 552 | $exists = false; |
553 | - $payment = new Give_Payment( $payment_id ); |
|
553 | + $payment = new Give_Payment($payment_id); |
|
554 | 554 | |
555 | - if ( $payment_id === $payment->ID && 'publish' === $payment->status ) { |
|
555 | + if ($payment_id === $payment->ID && 'publish' === $payment->status) { |
|
556 | 556 | $exists = true; |
557 | 557 | } |
558 | 558 | |
@@ -569,24 +569,24 @@ discard block |
||
569 | 569 | * instead of status value. Default false. |
570 | 570 | * @return bool|mixed True if payment status exists, false otherwise. |
571 | 571 | */ |
572 | -function give_get_payment_status( $payment, $return_label = false ) { |
|
572 | +function give_get_payment_status($payment, $return_label = false) { |
|
573 | 573 | |
574 | - if ( ! is_object( $payment ) || ! isset( $payment->post_status ) ) { |
|
574 | + if ( ! is_object($payment) || ! isset($payment->post_status)) { |
|
575 | 575 | return false; |
576 | 576 | } |
577 | 577 | |
578 | 578 | $statuses = give_get_payment_statuses(); |
579 | 579 | |
580 | - if ( ! is_array( $statuses ) || empty( $statuses ) ) { |
|
580 | + if ( ! is_array($statuses) || empty($statuses)) { |
|
581 | 581 | return false; |
582 | 582 | } |
583 | 583 | |
584 | - $payment = new Give_Payment( $payment->ID ); |
|
584 | + $payment = new Give_Payment($payment->ID); |
|
585 | 585 | |
586 | - if ( array_key_exists( $payment->status, $statuses ) ) { |
|
587 | - if ( true === $return_label ) { |
|
586 | + if (array_key_exists($payment->status, $statuses)) { |
|
587 | + if (true === $return_label) { |
|
588 | 588 | // Return translated status label. |
589 | - return $statuses[ $payment->status ]; |
|
589 | + return $statuses[$payment->status]; |
|
590 | 590 | } else { |
591 | 591 | // Return status value. |
592 | 592 | return $payment->status; |
@@ -605,17 +605,17 @@ discard block |
||
605 | 605 | */ |
606 | 606 | function give_get_payment_statuses() { |
607 | 607 | $payment_statuses = array( |
608 | - 'pending' => esc_html__( 'Pending', 'give' ), |
|
609 | - 'publish' => esc_html__( 'Complete', 'give' ), |
|
610 | - 'refunded' => esc_html__( 'Refunded', 'give' ), |
|
611 | - 'failed' => esc_html__( 'Failed', 'give' ), |
|
612 | - 'cancelled' => esc_html__( 'Cancelled', 'give' ), |
|
613 | - 'abandoned' => esc_html__( 'Abandoned', 'give' ), |
|
614 | - 'preapproval' => esc_html__( 'Pre-Approved', 'give' ), |
|
615 | - 'revoked' => esc_html__( 'Revoked', 'give' ), |
|
608 | + 'pending' => esc_html__('Pending', 'give'), |
|
609 | + 'publish' => esc_html__('Complete', 'give'), |
|
610 | + 'refunded' => esc_html__('Refunded', 'give'), |
|
611 | + 'failed' => esc_html__('Failed', 'give'), |
|
612 | + 'cancelled' => esc_html__('Cancelled', 'give'), |
|
613 | + 'abandoned' => esc_html__('Abandoned', 'give'), |
|
614 | + 'preapproval' => esc_html__('Pre-Approved', 'give'), |
|
615 | + 'revoked' => esc_html__('Revoked', 'give'), |
|
616 | 616 | ); |
617 | 617 | |
618 | - return apply_filters( 'give_payment_statuses', $payment_statuses ); |
|
618 | + return apply_filters('give_payment_statuses', $payment_statuses); |
|
619 | 619 | } |
620 | 620 | |
621 | 621 | /** |
@@ -628,10 +628,10 @@ discard block |
||
628 | 628 | * @return array $payment_status All the available payment statuses. |
629 | 629 | */ |
630 | 630 | function give_get_payment_status_keys() { |
631 | - $statuses = array_keys( give_get_payment_statuses() ); |
|
632 | - asort( $statuses ); |
|
631 | + $statuses = array_keys(give_get_payment_statuses()); |
|
632 | + asort($statuses); |
|
633 | 633 | |
634 | - return array_values( $statuses ); |
|
634 | + return array_values($statuses); |
|
635 | 635 | } |
636 | 636 | |
637 | 637 | /** |
@@ -646,7 +646,7 @@ discard block |
||
646 | 646 | * |
647 | 647 | * @return int $earnings Earnings |
648 | 648 | */ |
649 | -function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) { |
|
649 | +function give_get_earnings_by_date($day = null, $month_num, $year = null, $hour = null) { |
|
650 | 650 | |
651 | 651 | // This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead. |
652 | 652 | global $wpdb; |
@@ -656,41 +656,41 @@ discard block |
||
656 | 656 | 'nopaging' => true, |
657 | 657 | 'year' => $year, |
658 | 658 | 'monthnum' => $month_num, |
659 | - 'post_status' => array( 'publish' ), |
|
659 | + 'post_status' => array('publish'), |
|
660 | 660 | 'fields' => 'ids', |
661 | 661 | 'update_post_term_cache' => false, |
662 | 662 | ); |
663 | - if ( ! empty( $day ) ) { |
|
663 | + if ( ! empty($day)) { |
|
664 | 664 | $args['day'] = $day; |
665 | 665 | } |
666 | 666 | |
667 | - if ( ! empty( $hour ) ) { |
|
667 | + if ( ! empty($hour)) { |
|
668 | 668 | $args['hour'] = $hour; |
669 | 669 | } |
670 | 670 | |
671 | - $args = apply_filters( 'give_get_earnings_by_date_args', $args ); |
|
672 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
671 | + $args = apply_filters('give_get_earnings_by_date_args', $args); |
|
672 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
673 | 673 | |
674 | - if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) { |
|
674 | + if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) { |
|
675 | 675 | $earnings = false; |
676 | 676 | } else { |
677 | - $earnings = get_transient( $key ); |
|
677 | + $earnings = get_transient($key); |
|
678 | 678 | } |
679 | 679 | |
680 | - if ( false === $earnings ) { |
|
681 | - $sales = get_posts( $args ); |
|
680 | + if (false === $earnings) { |
|
681 | + $sales = get_posts($args); |
|
682 | 682 | $earnings = 0; |
683 | - if ( $sales ) { |
|
684 | - $sales = implode( ',', $sales ); |
|
683 | + if ($sales) { |
|
684 | + $sales = implode(',', $sales); |
|
685 | 685 | |
686 | - $earnings = $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$sales})" ); |
|
686 | + $earnings = $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$sales})"); |
|
687 | 687 | |
688 | 688 | } |
689 | 689 | // Cache the results for one hour. |
690 | - set_transient( $key, $earnings, HOUR_IN_SECONDS ); |
|
690 | + set_transient($key, $earnings, HOUR_IN_SECONDS); |
|
691 | 691 | } |
692 | 692 | |
693 | - return round( $earnings, 2 ); |
|
693 | + return round($earnings, 2); |
|
694 | 694 | } |
695 | 695 | |
696 | 696 | /** |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | * |
706 | 706 | * @return int $count Sales |
707 | 707 | */ |
708 | -function give_get_sales_by_date( $day = null, $month_num = null, $year = null, $hour = null ) { |
|
708 | +function give_get_sales_by_date($day = null, $month_num = null, $year = null, $hour = null) { |
|
709 | 709 | |
710 | 710 | // This is getting deprecated soon. Use Give_Payment_Stats with the get_sales() method instead. |
711 | 711 | $args = array( |
@@ -713,14 +713,14 @@ discard block |
||
713 | 713 | 'nopaging' => true, |
714 | 714 | 'year' => $year, |
715 | 715 | 'fields' => 'ids', |
716 | - 'post_status' => array( 'publish' ), |
|
716 | + 'post_status' => array('publish'), |
|
717 | 717 | 'update_post_meta_cache' => false, |
718 | 718 | 'update_post_term_cache' => false, |
719 | 719 | ); |
720 | 720 | |
721 | - $show_free = apply_filters( 'give_sales_by_date_show_free', true, $args ); |
|
721 | + $show_free = apply_filters('give_sales_by_date_show_free', true, $args); |
|
722 | 722 | |
723 | - if ( false === $show_free ) { |
|
723 | + if (false === $show_free) { |
|
724 | 724 | $args['meta_query'] = array( |
725 | 725 | array( |
726 | 726 | 'key' => '_give_payment_total', |
@@ -731,33 +731,33 @@ discard block |
||
731 | 731 | ); |
732 | 732 | } |
733 | 733 | |
734 | - if ( ! empty( $month_num ) ) { |
|
734 | + if ( ! empty($month_num)) { |
|
735 | 735 | $args['monthnum'] = $month_num; |
736 | 736 | } |
737 | 737 | |
738 | - if ( ! empty( $day ) ) { |
|
738 | + if ( ! empty($day)) { |
|
739 | 739 | $args['day'] = $day; |
740 | 740 | } |
741 | 741 | |
742 | - if ( ! empty( $hour ) ) { |
|
742 | + if ( ! empty($hour)) { |
|
743 | 743 | $args['hour'] = $hour; |
744 | 744 | } |
745 | 745 | |
746 | - $args = apply_filters( 'give_get_sales_by_date_args', $args ); |
|
746 | + $args = apply_filters('give_get_sales_by_date_args', $args); |
|
747 | 747 | |
748 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
748 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
749 | 749 | |
750 | - if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) { |
|
750 | + if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) { |
|
751 | 751 | $count = false; |
752 | 752 | } else { |
753 | - $count = get_transient( $key ); |
|
753 | + $count = get_transient($key); |
|
754 | 754 | } |
755 | 755 | |
756 | - if ( false === $count ) { |
|
757 | - $sales = new WP_Query( $args ); |
|
756 | + if (false === $count) { |
|
757 | + $sales = new WP_Query($args); |
|
758 | 758 | $count = (int) $sales->post_count; |
759 | 759 | // Cache the results for one hour. |
760 | - set_transient( $key, $count, HOUR_IN_SECONDS ); |
|
760 | + set_transient($key, $count, HOUR_IN_SECONDS); |
|
761 | 761 | } |
762 | 762 | |
763 | 763 | return $count; |
@@ -772,19 +772,19 @@ discard block |
||
772 | 772 | * |
773 | 773 | * @return bool $ret True if complete, false otherwise. |
774 | 774 | */ |
775 | -function give_is_payment_complete( $payment_id ) { |
|
776 | - $payment = new Give_Payment( $payment_id ); |
|
775 | +function give_is_payment_complete($payment_id) { |
|
776 | + $payment = new Give_Payment($payment_id); |
|
777 | 777 | |
778 | 778 | $ret = false; |
779 | 779 | |
780 | - if ( $payment->ID > 0 ) { |
|
780 | + if ($payment->ID > 0) { |
|
781 | 781 | |
782 | - if ( (int) $payment_id === (int) $payment->ID && 'publish' == $payment->status ) { |
|
782 | + if ((int) $payment_id === (int) $payment->ID && 'publish' == $payment->status) { |
|
783 | 783 | $ret = true; |
784 | 784 | } |
785 | 785 | } |
786 | 786 | |
787 | - return apply_filters( 'give_is_payment_complete', $ret, $payment_id, $payment->post_status ); |
|
787 | + return apply_filters('give_is_payment_complete', $ret, $payment_id, $payment->post_status); |
|
788 | 788 | } |
789 | 789 | |
790 | 790 | /** |
@@ -810,28 +810,28 @@ discard block |
||
810 | 810 | */ |
811 | 811 | function give_get_total_earnings() { |
812 | 812 | |
813 | - $total = get_option( 'give_earnings_total', false ); |
|
813 | + $total = get_option('give_earnings_total', false); |
|
814 | 814 | |
815 | 815 | // If no total stored in DB, use old method of calculating total earnings. |
816 | - if ( false === $total ) { |
|
816 | + if (false === $total) { |
|
817 | 817 | |
818 | 818 | global $wpdb; |
819 | 819 | |
820 | - $total = get_transient( 'give_earnings_total' ); |
|
820 | + $total = get_transient('give_earnings_total'); |
|
821 | 821 | |
822 | - if ( false === $total ) { |
|
822 | + if (false === $total) { |
|
823 | 823 | |
824 | 824 | $total = (float) 0; |
825 | 825 | |
826 | - $args = apply_filters( 'give_get_total_earnings_args', array( |
|
826 | + $args = apply_filters('give_get_total_earnings_args', array( |
|
827 | 827 | 'offset' => 0, |
828 | - 'number' => - 1, |
|
829 | - 'status' => array( 'publish' ), |
|
828 | + 'number' => -1, |
|
829 | + 'status' => array('publish'), |
|
830 | 830 | 'fields' => 'ids', |
831 | - ) ); |
|
831 | + )); |
|
832 | 832 | |
833 | - $payments = give_get_payments( $args ); |
|
834 | - if ( $payments ) { |
|
833 | + $payments = give_get_payments($args); |
|
834 | + if ($payments) { |
|
835 | 835 | |
836 | 836 | /* |
837 | 837 | * If performing a donation, we need to skip the very last payment in the database, |
@@ -839,29 +839,29 @@ discard block |
||
839 | 839 | * which results in duplicated earnings for the very first donation. |
840 | 840 | */ |
841 | 841 | |
842 | - if ( did_action( 'give_update_payment_status' ) ) { |
|
843 | - array_pop( $payments ); |
|
842 | + if (did_action('give_update_payment_status')) { |
|
843 | + array_pop($payments); |
|
844 | 844 | } |
845 | 845 | |
846 | - if ( ! empty( $payments ) ) { |
|
847 | - $payments = implode( ',', $payments ); |
|
848 | - $total += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})" ); |
|
846 | + if ( ! empty($payments)) { |
|
847 | + $payments = implode(',', $payments); |
|
848 | + $total += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})"); |
|
849 | 849 | } |
850 | 850 | } |
851 | 851 | |
852 | 852 | // Cache results for 1 day. This cache is cleared automatically when a payment is made. |
853 | - set_transient( 'give_earnings_total', $total, 86400 ); |
|
853 | + set_transient('give_earnings_total', $total, 86400); |
|
854 | 854 | |
855 | 855 | // Store the total for the first time. |
856 | - update_option( 'give_earnings_total', $total ); |
|
856 | + update_option('give_earnings_total', $total); |
|
857 | 857 | } |
858 | 858 | } |
859 | 859 | |
860 | - if ( $total < 0 ) { |
|
860 | + if ($total < 0) { |
|
861 | 861 | $total = 0; // Don't ever show negative earnings. |
862 | 862 | } |
863 | 863 | |
864 | - return apply_filters( 'give_total_earnings', round( $total, give_currency_decimal_filter() ) ); |
|
864 | + return apply_filters('give_total_earnings', round($total, give_currency_decimal_filter())); |
|
865 | 865 | } |
866 | 866 | |
867 | 867 | /** |
@@ -874,10 +874,10 @@ discard block |
||
874 | 874 | * |
875 | 875 | * @return float $total Total earnings. |
876 | 876 | */ |
877 | -function give_increase_total_earnings( $amount = 0 ) { |
|
877 | +function give_increase_total_earnings($amount = 0) { |
|
878 | 878 | $total = give_get_total_earnings(); |
879 | 879 | $total += $amount; |
880 | - update_option( 'give_earnings_total', $total ); |
|
880 | + update_option('give_earnings_total', $total); |
|
881 | 881 | |
882 | 882 | return $total; |
883 | 883 | } |
@@ -891,13 +891,13 @@ discard block |
||
891 | 891 | * |
892 | 892 | * @return float $total Total earnings. |
893 | 893 | */ |
894 | -function give_decrease_total_earnings( $amount = 0 ) { |
|
894 | +function give_decrease_total_earnings($amount = 0) { |
|
895 | 895 | $total = give_get_total_earnings(); |
896 | 896 | $total -= $amount; |
897 | - if ( $total < 0 ) { |
|
897 | + if ($total < 0) { |
|
898 | 898 | $total = 0; |
899 | 899 | } |
900 | - update_option( 'give_earnings_total', $total ); |
|
900 | + update_option('give_earnings_total', $total); |
|
901 | 901 | |
902 | 902 | return $total; |
903 | 903 | } |
@@ -913,10 +913,10 @@ discard block |
||
913 | 913 | * |
914 | 914 | * @return mixed $meta Payment Meta. |
915 | 915 | */ |
916 | -function give_get_payment_meta( $payment_id = 0, $meta_key = '_give_payment_meta', $single = true ) { |
|
917 | - $payment = new Give_Payment( $payment_id ); |
|
916 | +function give_get_payment_meta($payment_id = 0, $meta_key = '_give_payment_meta', $single = true) { |
|
917 | + $payment = new Give_Payment($payment_id); |
|
918 | 918 | |
919 | - return $payment->get_meta( $meta_key, $single ); |
|
919 | + return $payment->get_meta($meta_key, $single); |
|
920 | 920 | } |
921 | 921 | |
922 | 922 | /** |
@@ -929,10 +929,10 @@ discard block |
||
929 | 929 | * |
930 | 930 | * @return mixed Meta ID if successful, false if unsuccessful. |
931 | 931 | */ |
932 | -function give_update_payment_meta( $payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '' ) { |
|
933 | - $payment = new Give_Payment( $payment_id ); |
|
932 | +function give_update_payment_meta($payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '') { |
|
933 | + $payment = new Give_Payment($payment_id); |
|
934 | 934 | |
935 | - return $payment->update_meta( $meta_key, $meta_value, $prev_value ); |
|
935 | + return $payment->update_meta($meta_key, $meta_value, $prev_value); |
|
936 | 936 | } |
937 | 937 | |
938 | 938 | /** |
@@ -944,8 +944,8 @@ discard block |
||
944 | 944 | * |
945 | 945 | * @return string $user_info User Info Meta Values. |
946 | 946 | */ |
947 | -function give_get_payment_meta_user_info( $payment_id ) { |
|
948 | - $payment = new Give_Payment( $payment_id ); |
|
947 | +function give_get_payment_meta_user_info($payment_id) { |
|
948 | + $payment = new Give_Payment($payment_id); |
|
949 | 949 | |
950 | 950 | return $payment->user_info; |
951 | 951 | } |
@@ -961,8 +961,8 @@ discard block |
||
961 | 961 | * |
962 | 962 | * @return int $form_id Form ID. |
963 | 963 | */ |
964 | -function give_get_payment_form_id( $payment_id ) { |
|
965 | - $payment = new Give_Payment( $payment_id ); |
|
964 | +function give_get_payment_form_id($payment_id) { |
|
965 | + $payment = new Give_Payment($payment_id); |
|
966 | 966 | |
967 | 967 | return $payment->form_id; |
968 | 968 | } |
@@ -976,8 +976,8 @@ discard block |
||
976 | 976 | * |
977 | 977 | * @return string $email User email. |
978 | 978 | */ |
979 | -function give_get_payment_user_email( $payment_id ) { |
|
980 | - $payment = new Give_Payment( $payment_id ); |
|
979 | +function give_get_payment_user_email($payment_id) { |
|
980 | + $payment = new Give_Payment($payment_id); |
|
981 | 981 | |
982 | 982 | return $payment->email; |
983 | 983 | } |
@@ -991,11 +991,11 @@ discard block |
||
991 | 991 | * |
992 | 992 | * @return bool $is_guest_payment If the payment is associated with a user (false) or not (true) |
993 | 993 | */ |
994 | -function give_is_guest_payment( $payment_id ) { |
|
995 | - $payment_user_id = give_get_payment_user_id( $payment_id ); |
|
996 | - $is_guest_payment = ! empty( $payment_user_id ) && $payment_user_id > 0 ? false : true; |
|
994 | +function give_is_guest_payment($payment_id) { |
|
995 | + $payment_user_id = give_get_payment_user_id($payment_id); |
|
996 | + $is_guest_payment = ! empty($payment_user_id) && $payment_user_id > 0 ? false : true; |
|
997 | 997 | |
998 | - return (bool) apply_filters( 'give_is_guest_payment', $is_guest_payment, $payment_id ); |
|
998 | + return (bool) apply_filters('give_is_guest_payment', $is_guest_payment, $payment_id); |
|
999 | 999 | } |
1000 | 1000 | |
1001 | 1001 | /** |
@@ -1007,8 +1007,8 @@ discard block |
||
1007 | 1007 | * |
1008 | 1008 | * @return int $user_id User ID. |
1009 | 1009 | */ |
1010 | -function give_get_payment_user_id( $payment_id ) { |
|
1011 | - $payment = new Give_Payment( $payment_id ); |
|
1010 | +function give_get_payment_user_id($payment_id) { |
|
1011 | + $payment = new Give_Payment($payment_id); |
|
1012 | 1012 | |
1013 | 1013 | return $payment->user_id; |
1014 | 1014 | } |
@@ -1022,8 +1022,8 @@ discard block |
||
1022 | 1022 | * |
1023 | 1023 | * @return int $customer_id Customer ID. |
1024 | 1024 | */ |
1025 | -function give_get_payment_customer_id( $payment_id ) { |
|
1026 | - $payment = new Give_Payment( $payment_id ); |
|
1025 | +function give_get_payment_customer_id($payment_id) { |
|
1026 | + $payment = new Give_Payment($payment_id); |
|
1027 | 1027 | |
1028 | 1028 | return $payment->customer_id; |
1029 | 1029 | } |
@@ -1037,8 +1037,8 @@ discard block |
||
1037 | 1037 | * |
1038 | 1038 | * @return string $ip User IP. |
1039 | 1039 | */ |
1040 | -function give_get_payment_user_ip( $payment_id ) { |
|
1041 | - $payment = new Give_Payment( $payment_id ); |
|
1040 | +function give_get_payment_user_ip($payment_id) { |
|
1041 | + $payment = new Give_Payment($payment_id); |
|
1042 | 1042 | |
1043 | 1043 | return $payment->ip; |
1044 | 1044 | } |
@@ -1052,8 +1052,8 @@ discard block |
||
1052 | 1052 | * |
1053 | 1053 | * @return string $date The date the payment was completed. |
1054 | 1054 | */ |
1055 | -function give_get_payment_completed_date( $payment_id = 0 ) { |
|
1056 | - $payment = new Give_Payment( $payment_id ); |
|
1055 | +function give_get_payment_completed_date($payment_id = 0) { |
|
1056 | + $payment = new Give_Payment($payment_id); |
|
1057 | 1057 | |
1058 | 1058 | return $payment->completed_date; |
1059 | 1059 | } |
@@ -1067,8 +1067,8 @@ discard block |
||
1067 | 1067 | * |
1068 | 1068 | * @return string $gateway Gateway. |
1069 | 1069 | */ |
1070 | -function give_get_payment_gateway( $payment_id ) { |
|
1071 | - $payment = new Give_Payment( $payment_id ); |
|
1070 | +function give_get_payment_gateway($payment_id) { |
|
1071 | + $payment = new Give_Payment($payment_id); |
|
1072 | 1072 | |
1073 | 1073 | return $payment->gateway; |
1074 | 1074 | } |
@@ -1082,8 +1082,8 @@ discard block |
||
1082 | 1082 | * |
1083 | 1083 | * @return string $currency The currency code. |
1084 | 1084 | */ |
1085 | -function give_get_payment_currency_code( $payment_id = 0 ) { |
|
1086 | - $payment = new Give_Payment( $payment_id ); |
|
1085 | +function give_get_payment_currency_code($payment_id = 0) { |
|
1086 | + $payment = new Give_Payment($payment_id); |
|
1087 | 1087 | |
1088 | 1088 | return $payment->currency; |
1089 | 1089 | } |
@@ -1097,10 +1097,10 @@ discard block |
||
1097 | 1097 | * |
1098 | 1098 | * @return string $currency The currency name. |
1099 | 1099 | */ |
1100 | -function give_get_payment_currency( $payment_id = 0 ) { |
|
1101 | - $currency = give_get_payment_currency_code( $payment_id ); |
|
1100 | +function give_get_payment_currency($payment_id = 0) { |
|
1101 | + $currency = give_get_payment_currency_code($payment_id); |
|
1102 | 1102 | |
1103 | - return apply_filters( 'give_payment_currency', give_get_currency_name( $currency ), $payment_id ); |
|
1103 | + return apply_filters('give_payment_currency', give_get_currency_name($currency), $payment_id); |
|
1104 | 1104 | } |
1105 | 1105 | |
1106 | 1106 | /** |
@@ -1112,8 +1112,8 @@ discard block |
||
1112 | 1112 | * |
1113 | 1113 | * @return string $key Donation key. |
1114 | 1114 | */ |
1115 | -function give_get_payment_key( $payment_id = 0 ) { |
|
1116 | - $payment = new Give_Payment( $payment_id ); |
|
1115 | +function give_get_payment_key($payment_id = 0) { |
|
1116 | + $payment = new Give_Payment($payment_id); |
|
1117 | 1117 | |
1118 | 1118 | return $payment->key; |
1119 | 1119 | } |
@@ -1129,8 +1129,8 @@ discard block |
||
1129 | 1129 | * |
1130 | 1130 | * @return string $number Payment order number. |
1131 | 1131 | */ |
1132 | -function give_get_payment_number( $payment_id = 0 ) { |
|
1133 | - $payment = new Give_Payment( $payment_id ); |
|
1132 | +function give_get_payment_number($payment_id = 0) { |
|
1133 | + $payment = new Give_Payment($payment_id); |
|
1134 | 1134 | |
1135 | 1135 | return $payment->number; |
1136 | 1136 | } |
@@ -1144,23 +1144,23 @@ discard block |
||
1144 | 1144 | * |
1145 | 1145 | * @return string The formatted payment number. |
1146 | 1146 | */ |
1147 | -function give_format_payment_number( $number ) { |
|
1147 | +function give_format_payment_number($number) { |
|
1148 | 1148 | |
1149 | - if ( ! give_get_option( 'enable_sequential' ) ) { |
|
1149 | + if ( ! give_get_option('enable_sequential')) { |
|
1150 | 1150 | return $number; |
1151 | 1151 | } |
1152 | 1152 | |
1153 | - if ( ! is_numeric( $number ) ) { |
|
1153 | + if ( ! is_numeric($number)) { |
|
1154 | 1154 | return $number; |
1155 | 1155 | } |
1156 | 1156 | |
1157 | - $prefix = give_get_option( 'sequential_prefix' ); |
|
1158 | - $number = absint( $number ); |
|
1159 | - $postfix = give_get_option( 'sequential_postfix' ); |
|
1157 | + $prefix = give_get_option('sequential_prefix'); |
|
1158 | + $number = absint($number); |
|
1159 | + $postfix = give_get_option('sequential_postfix'); |
|
1160 | 1160 | |
1161 | - $formatted_number = $prefix . $number . $postfix; |
|
1161 | + $formatted_number = $prefix.$number.$postfix; |
|
1162 | 1162 | |
1163 | - return apply_filters( 'give_format_payment_number', $formatted_number, $prefix, $number, $postfix ); |
|
1163 | + return apply_filters('give_format_payment_number', $formatted_number, $prefix, $number, $postfix); |
|
1164 | 1164 | } |
1165 | 1165 | |
1166 | 1166 | /** |
@@ -1173,17 +1173,17 @@ discard block |
||
1173 | 1173 | */ |
1174 | 1174 | function give_get_next_payment_number() { |
1175 | 1175 | |
1176 | - if ( ! give_get_option( 'enable_sequential' ) ) { |
|
1176 | + if ( ! give_get_option('enable_sequential')) { |
|
1177 | 1177 | return false; |
1178 | 1178 | } |
1179 | 1179 | |
1180 | - $number = get_option( 'give_last_payment_number' ); |
|
1181 | - $start = give_get_option( 'sequential_start', 1 ); |
|
1180 | + $number = get_option('give_last_payment_number'); |
|
1181 | + $start = give_get_option('sequential_start', 1); |
|
1182 | 1182 | $increment_number = true; |
1183 | 1183 | |
1184 | - if ( false !== $number ) { |
|
1184 | + if (false !== $number) { |
|
1185 | 1185 | |
1186 | - if ( empty( $number ) ) { |
|
1186 | + if (empty($number)) { |
|
1187 | 1187 | |
1188 | 1188 | $number = $start; |
1189 | 1189 | $increment_number = false; |
@@ -1192,24 +1192,24 @@ discard block |
||
1192 | 1192 | } else { |
1193 | 1193 | |
1194 | 1194 | // This case handles the first addition of the new option, as well as if it get's deleted for any reason. |
1195 | - $payments = new Give_Payments_Query( array( |
|
1195 | + $payments = new Give_Payments_Query(array( |
|
1196 | 1196 | 'number' => 1, |
1197 | 1197 | 'order' => 'DESC', |
1198 | 1198 | 'orderby' => 'ID', |
1199 | 1199 | 'output' => 'posts', |
1200 | 1200 | 'fields' => 'ids', |
1201 | - ) ); |
|
1201 | + )); |
|
1202 | 1202 | $last_payment = $payments->get_payments(); |
1203 | 1203 | |
1204 | - if ( ! empty( $last_payment ) ) { |
|
1204 | + if ( ! empty($last_payment)) { |
|
1205 | 1205 | |
1206 | - $number = give_get_payment_number( $last_payment[0] ); |
|
1206 | + $number = give_get_payment_number($last_payment[0]); |
|
1207 | 1207 | |
1208 | 1208 | } |
1209 | 1209 | |
1210 | - if ( ! empty( $number ) && $number !== (int) $last_payment[0] ) { |
|
1210 | + if ( ! empty($number) && $number !== (int) $last_payment[0]) { |
|
1211 | 1211 | |
1212 | - $number = give_remove_payment_prefix_postfix( $number ); |
|
1212 | + $number = give_remove_payment_prefix_postfix($number); |
|
1213 | 1213 | |
1214 | 1214 | } else { |
1215 | 1215 | |
@@ -1218,13 +1218,13 @@ discard block |
||
1218 | 1218 | } |
1219 | 1219 | } |
1220 | 1220 | |
1221 | - $increment_number = apply_filters( 'give_increment_payment_number', $increment_number, $number ); |
|
1221 | + $increment_number = apply_filters('give_increment_payment_number', $increment_number, $number); |
|
1222 | 1222 | |
1223 | - if ( $increment_number ) { |
|
1224 | - $number ++; |
|
1223 | + if ($increment_number) { |
|
1224 | + $number++; |
|
1225 | 1225 | } |
1226 | 1226 | |
1227 | - return apply_filters( 'give_get_next_payment_number', $number ); |
|
1227 | + return apply_filters('give_get_next_payment_number', $number); |
|
1228 | 1228 | } |
1229 | 1229 | |
1230 | 1230 | /** |
@@ -1236,25 +1236,25 @@ discard block |
||
1236 | 1236 | * |
1237 | 1237 | * @return string The new Payment number without prefix and postfix. |
1238 | 1238 | */ |
1239 | -function give_remove_payment_prefix_postfix( $number ) { |
|
1239 | +function give_remove_payment_prefix_postfix($number) { |
|
1240 | 1240 | |
1241 | - $prefix = give_get_option( 'sequential_prefix' ); |
|
1242 | - $postfix = give_get_option( 'sequential_postfix' ); |
|
1241 | + $prefix = give_get_option('sequential_prefix'); |
|
1242 | + $postfix = give_get_option('sequential_postfix'); |
|
1243 | 1243 | |
1244 | 1244 | // Remove prefix. |
1245 | - $number = preg_replace( '/' . $prefix . '/', '', $number, 1 ); |
|
1245 | + $number = preg_replace('/'.$prefix.'/', '', $number, 1); |
|
1246 | 1246 | |
1247 | 1247 | // Remove the postfix. |
1248 | - $length = strlen( $number ); |
|
1249 | - $postfix_pos = strrpos( $number, $postfix ); |
|
1250 | - if ( false !== $postfix_pos ) { |
|
1251 | - $number = substr_replace( $number, '', $postfix_pos, $length ); |
|
1248 | + $length = strlen($number); |
|
1249 | + $postfix_pos = strrpos($number, $postfix); |
|
1250 | + if (false !== $postfix_pos) { |
|
1251 | + $number = substr_replace($number, '', $postfix_pos, $length); |
|
1252 | 1252 | } |
1253 | 1253 | |
1254 | 1254 | // Ensure it's a whole number. |
1255 | - $number = intval( $number ); |
|
1255 | + $number = intval($number); |
|
1256 | 1256 | |
1257 | - return apply_filters( 'give_remove_payment_prefix_postfix', $number, $prefix, $postfix ); |
|
1257 | + return apply_filters('give_remove_payment_prefix_postfix', $number, $prefix, $postfix); |
|
1258 | 1258 | |
1259 | 1259 | } |
1260 | 1260 | |
@@ -1270,10 +1270,10 @@ discard block |
||
1270 | 1270 | * |
1271 | 1271 | * @return string $amount Fully formatted payment amount. |
1272 | 1272 | */ |
1273 | -function give_payment_amount( $payment_id = 0 ) { |
|
1274 | - $amount = give_get_payment_amount( $payment_id ); |
|
1273 | +function give_payment_amount($payment_id = 0) { |
|
1274 | + $amount = give_get_payment_amount($payment_id); |
|
1275 | 1275 | |
1276 | - return give_currency_filter( give_format_amount( $amount ), give_get_payment_currency_code( $payment_id ) ); |
|
1276 | + return give_currency_filter(give_format_amount($amount), give_get_payment_currency_code($payment_id)); |
|
1277 | 1277 | } |
1278 | 1278 | |
1279 | 1279 | /** |
@@ -1286,11 +1286,11 @@ discard block |
||
1286 | 1286 | * |
1287 | 1287 | * @return mixed|void |
1288 | 1288 | */ |
1289 | -function give_get_payment_amount( $payment_id ) { |
|
1289 | +function give_get_payment_amount($payment_id) { |
|
1290 | 1290 | |
1291 | - $payment = new Give_Payment( $payment_id ); |
|
1291 | + $payment = new Give_Payment($payment_id); |
|
1292 | 1292 | |
1293 | - return apply_filters( 'give_payment_amount', floatval( $payment->total ), $payment_id ); |
|
1293 | + return apply_filters('give_payment_amount', floatval($payment->total), $payment_id); |
|
1294 | 1294 | } |
1295 | 1295 | |
1296 | 1296 | /** |
@@ -1306,10 +1306,10 @@ discard block |
||
1306 | 1306 | * |
1307 | 1307 | * @return array Fully formatted payment subtotal. |
1308 | 1308 | */ |
1309 | -function give_payment_subtotal( $payment_id = 0 ) { |
|
1310 | - $subtotal = give_get_payment_subtotal( $payment_id ); |
|
1309 | +function give_payment_subtotal($payment_id = 0) { |
|
1310 | + $subtotal = give_get_payment_subtotal($payment_id); |
|
1311 | 1311 | |
1312 | - return give_currency_filter( give_format_amount( $subtotal ), give_get_payment_currency_code( $payment_id ) ); |
|
1312 | + return give_currency_filter(give_format_amount($subtotal), give_get_payment_currency_code($payment_id)); |
|
1313 | 1313 | } |
1314 | 1314 | |
1315 | 1315 | /** |
@@ -1323,8 +1323,8 @@ discard block |
||
1323 | 1323 | * |
1324 | 1324 | * @return float $subtotal Subtotal for payment (non formatted). |
1325 | 1325 | */ |
1326 | -function give_get_payment_subtotal( $payment_id = 0 ) { |
|
1327 | - $payment = new G_Payment( $payment_id ); |
|
1326 | +function give_get_payment_subtotal($payment_id = 0) { |
|
1327 | + $payment = new G_Payment($payment_id); |
|
1328 | 1328 | |
1329 | 1329 | return $payment->subtotal; |
1330 | 1330 | } |
@@ -1339,10 +1339,10 @@ discard block |
||
1339 | 1339 | * |
1340 | 1340 | * @return mixed array if payment fees found, false otherwise. |
1341 | 1341 | */ |
1342 | -function give_get_payment_fees( $payment_id = 0, $type = 'all' ) { |
|
1343 | - $payment = new Give_Payment( $payment_id ); |
|
1342 | +function give_get_payment_fees($payment_id = 0, $type = 'all') { |
|
1343 | + $payment = new Give_Payment($payment_id); |
|
1344 | 1344 | |
1345 | - return $payment->get_fees( $type ); |
|
1345 | + return $payment->get_fees($type); |
|
1346 | 1346 | } |
1347 | 1347 | |
1348 | 1348 | /** |
@@ -1354,8 +1354,8 @@ discard block |
||
1354 | 1354 | * |
1355 | 1355 | * @return string The donation ID. |
1356 | 1356 | */ |
1357 | -function give_get_payment_transaction_id( $payment_id = 0 ) { |
|
1358 | - $payment = new Give_Payment( $payment_id ); |
|
1357 | +function give_get_payment_transaction_id($payment_id = 0) { |
|
1358 | + $payment = new Give_Payment($payment_id); |
|
1359 | 1359 | |
1360 | 1360 | return $payment->transaction_id; |
1361 | 1361 | } |
@@ -1370,15 +1370,15 @@ discard block |
||
1370 | 1370 | * |
1371 | 1371 | * @return bool|mixed |
1372 | 1372 | */ |
1373 | -function give_set_payment_transaction_id( $payment_id = 0, $transaction_id = '' ) { |
|
1373 | +function give_set_payment_transaction_id($payment_id = 0, $transaction_id = '') { |
|
1374 | 1374 | |
1375 | - if ( empty( $payment_id ) || empty( $transaction_id ) ) { |
|
1375 | + if (empty($payment_id) || empty($transaction_id)) { |
|
1376 | 1376 | return false; |
1377 | 1377 | } |
1378 | 1378 | |
1379 | - $transaction_id = apply_filters( 'give_set_payment_transaction_id', $transaction_id, $payment_id ); |
|
1379 | + $transaction_id = apply_filters('give_set_payment_transaction_id', $transaction_id, $payment_id); |
|
1380 | 1380 | |
1381 | - return give_update_payment_meta( $payment_id, '_give_payment_transaction_id', $transaction_id ); |
|
1381 | + return give_update_payment_meta($payment_id, '_give_payment_transaction_id', $transaction_id); |
|
1382 | 1382 | } |
1383 | 1383 | |
1384 | 1384 | /** |
@@ -1391,12 +1391,12 @@ discard block |
||
1391 | 1391 | * |
1392 | 1392 | * @return int $purchase Donation ID |
1393 | 1393 | */ |
1394 | -function give_get_purchase_id_by_key( $key ) { |
|
1394 | +function give_get_purchase_id_by_key($key) { |
|
1395 | 1395 | global $wpdb; |
1396 | 1396 | |
1397 | - $purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key ) ); |
|
1397 | + $purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key)); |
|
1398 | 1398 | |
1399 | - if ( $purchase != null ) { |
|
1399 | + if ($purchase != null) { |
|
1400 | 1400 | return $purchase; |
1401 | 1401 | } |
1402 | 1402 | |
@@ -1414,12 +1414,12 @@ discard block |
||
1414 | 1414 | * |
1415 | 1415 | * @return int $purchase Donation ID. |
1416 | 1416 | */ |
1417 | -function give_get_purchase_id_by_transaction_id( $key ) { |
|
1417 | +function give_get_purchase_id_by_transaction_id($key) { |
|
1418 | 1418 | global $wpdb; |
1419 | 1419 | |
1420 | - $purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key ) ); |
|
1420 | + $purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key)); |
|
1421 | 1421 | |
1422 | - if ( $purchase != null ) { |
|
1422 | + if ($purchase != null) { |
|
1423 | 1423 | return $purchase; |
1424 | 1424 | } |
1425 | 1425 | |
@@ -1436,19 +1436,19 @@ discard block |
||
1436 | 1436 | * |
1437 | 1437 | * @return array $notes Donation Notes |
1438 | 1438 | */ |
1439 | -function give_get_payment_notes( $payment_id = 0, $search = '' ) { |
|
1439 | +function give_get_payment_notes($payment_id = 0, $search = '') { |
|
1440 | 1440 | |
1441 | - if ( empty( $payment_id ) && empty( $search ) ) { |
|
1441 | + if (empty($payment_id) && empty($search)) { |
|
1442 | 1442 | return false; |
1443 | 1443 | } |
1444 | 1444 | |
1445 | - remove_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
1446 | - remove_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10 ); |
|
1445 | + remove_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
1446 | + remove_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10); |
|
1447 | 1447 | |
1448 | - $notes = get_comments( array( 'post_id' => $payment_id, 'order' => 'ASC', 'search' => $search ) ); |
|
1448 | + $notes = get_comments(array('post_id' => $payment_id, 'order' => 'ASC', 'search' => $search)); |
|
1449 | 1449 | |
1450 | - add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
1451 | - add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 ); |
|
1450 | + add_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
1451 | + add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2); |
|
1452 | 1452 | |
1453 | 1453 | return $notes; |
1454 | 1454 | } |
@@ -1464,8 +1464,8 @@ discard block |
||
1464 | 1464 | * |
1465 | 1465 | * @return int The new note ID |
1466 | 1466 | */ |
1467 | -function give_insert_payment_note( $payment_id = 0, $note = '' ) { |
|
1468 | - if ( empty( $payment_id ) ) { |
|
1467 | +function give_insert_payment_note($payment_id = 0, $note = '') { |
|
1468 | + if (empty($payment_id)) { |
|
1469 | 1469 | return false; |
1470 | 1470 | } |
1471 | 1471 | |
@@ -1477,14 +1477,14 @@ discard block |
||
1477 | 1477 | * @param int $payment_id Payment ID. |
1478 | 1478 | * @param string $note The note. |
1479 | 1479 | */ |
1480 | - do_action( 'give_pre_insert_payment_note', $payment_id, $note ); |
|
1480 | + do_action('give_pre_insert_payment_note', $payment_id, $note); |
|
1481 | 1481 | |
1482 | - $note_id = wp_insert_comment( wp_filter_comment( array( |
|
1482 | + $note_id = wp_insert_comment(wp_filter_comment(array( |
|
1483 | 1483 | 'comment_post_ID' => $payment_id, |
1484 | 1484 | 'comment_content' => $note, |
1485 | 1485 | 'user_id' => is_admin() ? get_current_user_id() : 0, |
1486 | - 'comment_date' => current_time( 'mysql' ), |
|
1487 | - 'comment_date_gmt' => current_time( 'mysql', 1 ), |
|
1486 | + 'comment_date' => current_time('mysql'), |
|
1487 | + 'comment_date_gmt' => current_time('mysql', 1), |
|
1488 | 1488 | 'comment_approved' => 1, |
1489 | 1489 | 'comment_parent' => 0, |
1490 | 1490 | 'comment_author' => '', |
@@ -1493,7 +1493,7 @@ discard block |
||
1493 | 1493 | 'comment_author_email' => '', |
1494 | 1494 | 'comment_type' => 'give_payment_note', |
1495 | 1495 | |
1496 | - ) ) ); |
|
1496 | + ))); |
|
1497 | 1497 | |
1498 | 1498 | /** |
1499 | 1499 | * Fires after payment note inserted. |
@@ -1504,7 +1504,7 @@ discard block |
||
1504 | 1504 | * @param int $payment_id Payment ID. |
1505 | 1505 | * @param string $note The note. |
1506 | 1506 | */ |
1507 | - do_action( 'give_insert_payment_note', $note_id, $payment_id, $note ); |
|
1507 | + do_action('give_insert_payment_note', $note_id, $payment_id, $note); |
|
1508 | 1508 | |
1509 | 1509 | return $note_id; |
1510 | 1510 | } |
@@ -1519,8 +1519,8 @@ discard block |
||
1519 | 1519 | * |
1520 | 1520 | * @return bool True on success, false otherwise. |
1521 | 1521 | */ |
1522 | -function give_delete_payment_note( $comment_id = 0, $payment_id = 0 ) { |
|
1523 | - if ( empty( $comment_id ) ) { |
|
1522 | +function give_delete_payment_note($comment_id = 0, $payment_id = 0) { |
|
1523 | + if (empty($comment_id)) { |
|
1524 | 1524 | return false; |
1525 | 1525 | } |
1526 | 1526 | |
@@ -1532,9 +1532,9 @@ discard block |
||
1532 | 1532 | * @param int $comment_id Note ID. |
1533 | 1533 | * @param int $payment_id Payment ID. |
1534 | 1534 | */ |
1535 | - do_action( 'give_pre_delete_payment_note', $comment_id, $payment_id ); |
|
1535 | + do_action('give_pre_delete_payment_note', $comment_id, $payment_id); |
|
1536 | 1536 | |
1537 | - $ret = wp_delete_comment( $comment_id, true ); |
|
1537 | + $ret = wp_delete_comment($comment_id, true); |
|
1538 | 1538 | |
1539 | 1539 | /** |
1540 | 1540 | * Fires after donation note deleted. |
@@ -1544,7 +1544,7 @@ discard block |
||
1544 | 1544 | * @param int $comment_id Note ID. |
1545 | 1545 | * @param int $payment_id Payment ID. |
1546 | 1546 | */ |
1547 | - do_action( 'give_post_delete_payment_note', $comment_id, $payment_id ); |
|
1547 | + do_action('give_post_delete_payment_note', $comment_id, $payment_id); |
|
1548 | 1548 | |
1549 | 1549 | return $ret; |
1550 | 1550 | } |
@@ -1559,34 +1559,34 @@ discard block |
||
1559 | 1559 | * |
1560 | 1560 | * @return string |
1561 | 1561 | */ |
1562 | -function give_get_payment_note_html( $note, $payment_id = 0 ) { |
|
1562 | +function give_get_payment_note_html($note, $payment_id = 0) { |
|
1563 | 1563 | |
1564 | - if ( is_numeric( $note ) ) { |
|
1565 | - $note = get_comment( $note ); |
|
1564 | + if (is_numeric($note)) { |
|
1565 | + $note = get_comment($note); |
|
1566 | 1566 | } |
1567 | 1567 | |
1568 | - if ( ! empty( $note->user_id ) ) { |
|
1569 | - $user = get_userdata( $note->user_id ); |
|
1568 | + if ( ! empty($note->user_id)) { |
|
1569 | + $user = get_userdata($note->user_id); |
|
1570 | 1570 | $user = $user->display_name; |
1571 | 1571 | } else { |
1572 | - $user = esc_html__( 'System', 'give' ); |
|
1572 | + $user = esc_html__('System', 'give'); |
|
1573 | 1573 | } |
1574 | 1574 | |
1575 | - $date_format = give_date_format() . ', ' . get_option( 'time_format' ); |
|
1575 | + $date_format = give_date_format().', '.get_option('time_format'); |
|
1576 | 1576 | |
1577 | - $delete_note_url = wp_nonce_url( add_query_arg( array( |
|
1577 | + $delete_note_url = wp_nonce_url(add_query_arg(array( |
|
1578 | 1578 | 'give-action' => 'delete_payment_note', |
1579 | 1579 | 'note_id' => $note->comment_ID, |
1580 | 1580 | 'payment_id' => $payment_id, |
1581 | - ) ), |
|
1582 | - 'give_delete_payment_note_' . $note->comment_ID |
|
1581 | + )), |
|
1582 | + 'give_delete_payment_note_'.$note->comment_ID |
|
1583 | 1583 | ); |
1584 | 1584 | |
1585 | - $note_html = '<div class="give-payment-note" id="give-payment-note-' . $note->comment_ID . '">'; |
|
1585 | + $note_html = '<div class="give-payment-note" id="give-payment-note-'.$note->comment_ID.'">'; |
|
1586 | 1586 | $note_html .= '<p>'; |
1587 | - $note_html .= '<strong>' . $user . '</strong> – <span style="color:#aaa;font-style:italic;">' . date_i18n( $date_format, strtotime( $note->comment_date ) ) . '</span><br/>'; |
|
1587 | + $note_html .= '<strong>'.$user.'</strong> – <span style="color:#aaa;font-style:italic;">'.date_i18n($date_format, strtotime($note->comment_date)).'</span><br/>'; |
|
1588 | 1588 | $note_html .= $note->comment_content; |
1589 | - $note_html .= ' – <a href="' . esc_url( $delete_note_url ) . '" class="give-delete-payment-note" data-note-id="' . absint( $note->comment_ID ) . '" data-payment-id="' . absint( $payment_id ) . '" aria-label="' . esc_attr__( 'Delete this donation note.', 'give' ) . '">' . esc_html__( 'Delete', 'give' ) . '</a>'; |
|
1589 | + $note_html .= ' – <a href="'.esc_url($delete_note_url).'" class="give-delete-payment-note" data-note-id="'.absint($note->comment_ID).'" data-payment-id="'.absint($payment_id).'" aria-label="'.esc_attr__('Delete this donation note.', 'give').'">'.esc_html__('Delete', 'give').'</a>'; |
|
1590 | 1590 | $note_html .= '</p>'; |
1591 | 1591 | $note_html .= '</div>'; |
1592 | 1592 | |
@@ -1604,18 +1604,18 @@ discard block |
||
1604 | 1604 | * |
1605 | 1605 | * @return void |
1606 | 1606 | */ |
1607 | -function give_hide_payment_notes( $query ) { |
|
1608 | - if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '>=' ) ) { |
|
1609 | - $types = isset( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array(); |
|
1610 | - if ( ! is_array( $types ) ) { |
|
1611 | - $types = array( $types ); |
|
1607 | +function give_hide_payment_notes($query) { |
|
1608 | + if (version_compare(floatval(get_bloginfo('version')), '4.1', '>=')) { |
|
1609 | + $types = isset($query->query_vars['type__not_in']) ? $query->query_vars['type__not_in'] : array(); |
|
1610 | + if ( ! is_array($types)) { |
|
1611 | + $types = array($types); |
|
1612 | 1612 | } |
1613 | 1613 | $types[] = 'give_payment_note'; |
1614 | 1614 | $query->query_vars['type__not_in'] = $types; |
1615 | 1615 | } |
1616 | 1616 | } |
1617 | 1617 | |
1618 | -add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
1618 | +add_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
1619 | 1619 | |
1620 | 1620 | /** |
1621 | 1621 | * Exclude notes (comments) on give_payment post type from showing in Recent Comments widgets |
@@ -1627,15 +1627,15 @@ discard block |
||
1627 | 1627 | * |
1628 | 1628 | * @return array $clauses Updated comment clauses. |
1629 | 1629 | */ |
1630 | -function give_hide_payment_notes_pre_41( $clauses, $wp_comment_query ) { |
|
1631 | - if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '<' ) ) { |
|
1630 | +function give_hide_payment_notes_pre_41($clauses, $wp_comment_query) { |
|
1631 | + if (version_compare(floatval(get_bloginfo('version')), '4.1', '<')) { |
|
1632 | 1632 | $clauses['where'] .= ' AND comment_type != "give_payment_note"'; |
1633 | 1633 | } |
1634 | 1634 | |
1635 | 1635 | return $clauses; |
1636 | 1636 | } |
1637 | 1637 | |
1638 | -add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 ); |
|
1638 | +add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2); |
|
1639 | 1639 | |
1640 | 1640 | |
1641 | 1641 | /** |
@@ -1648,15 +1648,15 @@ discard block |
||
1648 | 1648 | * |
1649 | 1649 | * @return string $where |
1650 | 1650 | */ |
1651 | -function give_hide_payment_notes_from_feeds( $where, $wp_comment_query ) { |
|
1651 | +function give_hide_payment_notes_from_feeds($where, $wp_comment_query) { |
|
1652 | 1652 | global $wpdb; |
1653 | 1653 | |
1654 | - $where .= $wpdb->prepare( ' AND comment_type != %s', 'give_payment_note' ); |
|
1654 | + $where .= $wpdb->prepare(' AND comment_type != %s', 'give_payment_note'); |
|
1655 | 1655 | |
1656 | 1656 | return $where; |
1657 | 1657 | } |
1658 | 1658 | |
1659 | -add_filter( 'comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2 ); |
|
1659 | +add_filter('comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2); |
|
1660 | 1660 | |
1661 | 1661 | |
1662 | 1662 | /** |
@@ -1670,32 +1670,32 @@ discard block |
||
1670 | 1670 | * |
1671 | 1671 | * @return array Array of comment counts. |
1672 | 1672 | */ |
1673 | -function give_remove_payment_notes_in_comment_counts( $stats, $post_id ) { |
|
1673 | +function give_remove_payment_notes_in_comment_counts($stats, $post_id) { |
|
1674 | 1674 | global $wpdb, $pagenow; |
1675 | 1675 | |
1676 | - if ( 'index.php' != $pagenow ) { |
|
1676 | + if ('index.php' != $pagenow) { |
|
1677 | 1677 | return $stats; |
1678 | 1678 | } |
1679 | 1679 | |
1680 | 1680 | $post_id = (int) $post_id; |
1681 | 1681 | |
1682 | - if ( apply_filters( 'give_count_payment_notes_in_comments', false ) ) { |
|
1682 | + if (apply_filters('give_count_payment_notes_in_comments', false)) { |
|
1683 | 1683 | return $stats; |
1684 | 1684 | } |
1685 | 1685 | |
1686 | - $stats = wp_cache_get( "comments-{$post_id}", 'counts' ); |
|
1686 | + $stats = wp_cache_get("comments-{$post_id}", 'counts'); |
|
1687 | 1687 | |
1688 | - if ( false !== $stats ) { |
|
1688 | + if (false !== $stats) { |
|
1689 | 1689 | return $stats; |
1690 | 1690 | } |
1691 | 1691 | |
1692 | 1692 | $where = 'WHERE comment_type != "give_payment_note"'; |
1693 | 1693 | |
1694 | - if ( $post_id > 0 ) { |
|
1695 | - $where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id ); |
|
1694 | + if ($post_id > 0) { |
|
1695 | + $where .= $wpdb->prepare(' AND comment_post_ID = %d', $post_id); |
|
1696 | 1696 | } |
1697 | 1697 | |
1698 | - $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A ); |
|
1698 | + $count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A); |
|
1699 | 1699 | |
1700 | 1700 | $total = 0; |
1701 | 1701 | $approved = array( |
@@ -1705,30 +1705,30 @@ discard block |
||
1705 | 1705 | 'trash' => 'trash', |
1706 | 1706 | 'post-trashed' => 'post-trashed', |
1707 | 1707 | ); |
1708 | - foreach ( (array) $count as $row ) { |
|
1708 | + foreach ((array) $count as $row) { |
|
1709 | 1709 | // Don't count post-trashed toward totals. |
1710 | - if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) { |
|
1710 | + if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) { |
|
1711 | 1711 | $total += $row['num_comments']; |
1712 | 1712 | } |
1713 | - if ( isset( $approved[ $row['comment_approved'] ] ) ) { |
|
1714 | - $stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments']; |
|
1713 | + if (isset($approved[$row['comment_approved']])) { |
|
1714 | + $stats[$approved[$row['comment_approved']]] = $row['num_comments']; |
|
1715 | 1715 | } |
1716 | 1716 | } |
1717 | 1717 | |
1718 | 1718 | $stats['total_comments'] = $total; |
1719 | - foreach ( $approved as $key ) { |
|
1720 | - if ( empty( $stats[ $key ] ) ) { |
|
1721 | - $stats[ $key ] = 0; |
|
1719 | + foreach ($approved as $key) { |
|
1720 | + if (empty($stats[$key])) { |
|
1721 | + $stats[$key] = 0; |
|
1722 | 1722 | } |
1723 | 1723 | } |
1724 | 1724 | |
1725 | 1725 | $stats = (object) $stats; |
1726 | - wp_cache_set( "comments-{$post_id}", $stats, 'counts' ); |
|
1726 | + wp_cache_set("comments-{$post_id}", $stats, 'counts'); |
|
1727 | 1727 | |
1728 | 1728 | return $stats; |
1729 | 1729 | } |
1730 | 1730 | |
1731 | -add_filter( 'wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2 ); |
|
1731 | +add_filter('wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2); |
|
1732 | 1732 | |
1733 | 1733 | |
1734 | 1734 | /** |
@@ -1741,9 +1741,9 @@ discard block |
||
1741 | 1741 | * |
1742 | 1742 | * @return string $where Modified where clause. |
1743 | 1743 | */ |
1744 | -function give_filter_where_older_than_week( $where = '' ) { |
|
1744 | +function give_filter_where_older_than_week($where = '') { |
|
1745 | 1745 | // Payments older than one week. |
1746 | - $start = date( 'Y-m-d', strtotime( '-7 days' ) ); |
|
1746 | + $start = date('Y-m-d', strtotime('-7 days')); |
|
1747 | 1747 | $where .= " AND post_date <= '{$start}'"; |
1748 | 1748 | |
1749 | 1749 | return $where; |
@@ -1763,37 +1763,37 @@ discard block |
||
1763 | 1763 | * |
1764 | 1764 | * @return string $form_title Returns the full title if $level_title false, otherwise returns the levels title. |
1765 | 1765 | */ |
1766 | -function give_get_payment_form_title( $payment_meta, $level_title = false, $separator = '' ) { |
|
1766 | +function give_get_payment_form_title($payment_meta, $level_title = false, $separator = '') { |
|
1767 | 1767 | |
1768 | - $form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0; |
|
1769 | - $form_title = isset( $payment_meta['form_title'] ) ? $payment_meta['form_title'] : ''; |
|
1770 | - $price_id = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null; |
|
1768 | + $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0; |
|
1769 | + $form_title = isset($payment_meta['form_title']) ? $payment_meta['form_title'] : ''; |
|
1770 | + $price_id = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null; |
|
1771 | 1771 | |
1772 | - if ( $level_title == true ) { |
|
1772 | + if ($level_title == true) { |
|
1773 | 1773 | $form_title = ''; |
1774 | 1774 | } |
1775 | 1775 | |
1776 | - if ( give_has_variable_prices( $form_id ) ) { |
|
1776 | + if (give_has_variable_prices($form_id)) { |
|
1777 | 1777 | |
1778 | - if ( ! empty( $separator ) ) { |
|
1779 | - $form_title .= ' ' . $separator; |
|
1778 | + if ( ! empty($separator)) { |
|
1779 | + $form_title .= ' '.$separator; |
|
1780 | 1780 | } |
1781 | 1781 | $form_title .= ' <span class="donation-level-text-wrap">'; |
1782 | 1782 | |
1783 | - if ( $price_id == 'custom' ) { |
|
1783 | + if ($price_id == 'custom') { |
|
1784 | 1784 | |
1785 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
1786 | - $form_title .= ! empty( $custom_amount_text ) ? $custom_amount_text : esc_html__( 'Custom Amount', 'give' ); |
|
1785 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
1786 | + $form_title .= ! empty($custom_amount_text) ? $custom_amount_text : esc_html__('Custom Amount', 'give'); |
|
1787 | 1787 | |
1788 | 1788 | } else { |
1789 | - $form_title .= give_get_price_option_name( $form_id, $price_id ); |
|
1789 | + $form_title .= give_get_price_option_name($form_id, $price_id); |
|
1790 | 1790 | } |
1791 | 1791 | |
1792 | 1792 | $form_title .= '</span>'; |
1793 | 1793 | |
1794 | 1794 | } |
1795 | 1795 | |
1796 | - return apply_filters( 'give_get_payment_form_title', $form_title, $payment_meta ); |
|
1796 | + return apply_filters('give_get_payment_form_title', $form_title, $payment_meta); |
|
1797 | 1797 | |
1798 | 1798 | } |
1799 | 1799 | |
@@ -1807,20 +1807,20 @@ discard block |
||
1807 | 1807 | * |
1808 | 1808 | * @return string $price_id |
1809 | 1809 | */ |
1810 | -function give_get_price_id( $form_id, $price ) { |
|
1810 | +function give_get_price_id($form_id, $price) { |
|
1811 | 1811 | |
1812 | 1812 | $price_id = 0; |
1813 | 1813 | |
1814 | - if ( give_has_variable_prices( $form_id ) ) { |
|
1814 | + if (give_has_variable_prices($form_id)) { |
|
1815 | 1815 | |
1816 | - $levels = maybe_unserialize( get_post_meta( $form_id, '_give_donation_levels', true ) ); |
|
1816 | + $levels = maybe_unserialize(get_post_meta($form_id, '_give_donation_levels', true)); |
|
1817 | 1817 | |
1818 | - foreach ( $levels as $level ) { |
|
1818 | + foreach ($levels as $level) { |
|
1819 | 1819 | |
1820 | - $level_amount = (float) give_sanitize_amount( $level['_give_amount'] ); |
|
1820 | + $level_amount = (float) give_sanitize_amount($level['_give_amount']); |
|
1821 | 1821 | |
1822 | 1822 | // Check that this indeed the recurring price. |
1823 | - if ( $level_amount == $price ) { |
|
1823 | + if ($level_amount == $price) { |
|
1824 | 1824 | |
1825 | 1825 | $price_id = $level['_give_id']['level_id']; |
1826 | 1826 | |
@@ -1845,10 +1845,10 @@ discard block |
||
1845 | 1845 | * |
1846 | 1846 | * @return string|void |
1847 | 1847 | */ |
1848 | -function give_get_form_dropdown( $args = array(), $echo = false ) { |
|
1849 | - $form_dropdown_html = Give()->html->forms_dropdown( $args ); |
|
1848 | +function give_get_form_dropdown($args = array(), $echo = false) { |
|
1849 | + $form_dropdown_html = Give()->html->forms_dropdown($args); |
|
1850 | 1850 | |
1851 | - if ( ! $echo ) { |
|
1851 | + if ( ! $echo) { |
|
1852 | 1852 | return $form_dropdown_html; |
1853 | 1853 | } |
1854 | 1854 | |
@@ -1865,38 +1865,38 @@ discard block |
||
1865 | 1865 | * |
1866 | 1866 | * @return string|void |
1867 | 1867 | */ |
1868 | -function give_get_form_variable_price_dropdown( $args = array(), $echo = false ) { |
|
1868 | +function give_get_form_variable_price_dropdown($args = array(), $echo = false) { |
|
1869 | 1869 | |
1870 | 1870 | // Check for give form id. |
1871 | - if ( empty( $args['id'] ) ) { |
|
1871 | + if (empty($args['id'])) { |
|
1872 | 1872 | return false; |
1873 | 1873 | } |
1874 | 1874 | |
1875 | 1875 | // Check if form has variable prices or not. |
1876 | - if ( ! ( $variable_prices = give_has_variable_prices( $args['id'] ) ) ) { |
|
1876 | + if ( ! ($variable_prices = give_has_variable_prices($args['id']))) { |
|
1877 | 1877 | return false; |
1878 | 1878 | } |
1879 | 1879 | |
1880 | - $variable_prices = give_get_variable_prices( absint( $args['id'] ) ); |
|
1880 | + $variable_prices = give_get_variable_prices(absint($args['id'])); |
|
1881 | 1881 | $variable_price_options = array(); |
1882 | 1882 | |
1883 | 1883 | // Check if multi donation form support custom donation or not. |
1884 | - if ( give_is_custom_price_mode( absint( $args['id'] ) ) ) { |
|
1885 | - $variable_price_options['custom'] = _x( 'Custom', 'custom donation dropdown item', 'give' ); |
|
1884 | + if (give_is_custom_price_mode(absint($args['id']))) { |
|
1885 | + $variable_price_options['custom'] = _x('Custom', 'custom donation dropdown item', 'give'); |
|
1886 | 1886 | } |
1887 | 1887 | |
1888 | 1888 | // Get variable price and ID from variable price array. |
1889 | - foreach ( $variable_prices as $variable_price ) { |
|
1890 | - $variable_price_options[ $variable_price['_give_id']['level_id'] ] = $variable_price['_give_text']; |
|
1889 | + foreach ($variable_prices as $variable_price) { |
|
1890 | + $variable_price_options[$variable_price['_give_id']['level_id']] = $variable_price['_give_text']; |
|
1891 | 1891 | } |
1892 | 1892 | |
1893 | 1893 | // Update options. |
1894 | - $args = array_merge( $args, array( 'options' => $variable_price_options ) ); |
|
1894 | + $args = array_merge($args, array('options' => $variable_price_options)); |
|
1895 | 1895 | |
1896 | 1896 | // Generate select html. |
1897 | - $form_dropdown_html = Give()->html->select( $args ); |
|
1897 | + $form_dropdown_html = Give()->html->select($args); |
|
1898 | 1898 | |
1899 | - if ( ! $echo ) { |
|
1899 | + if ( ! $echo) { |
|
1900 | 1900 | return $form_dropdown_html; |
1901 | 1901 | } |
1902 | 1902 |
@@ -1001,8 +1001,11 @@ discard block |
||
1001 | 1001 | } |
1002 | 1002 | ?> |
1003 | 1003 | </select> |
1004 | - <?php else : ?> |
|
1005 | - <input type="text" size="6" name="card_state" id="card_state" class="card_state give-input" placeholder="<?php esc_attr_e( 'State / Province', 'give' ); ?>"/> |
|
1004 | + <?php else { |
|
1005 | + : ?> |
|
1006 | + <input type="text" size="6" name="card_state" id="card_state" class="card_state give-input" placeholder="<?php esc_attr_e( 'State / Province', 'give' ); |
|
1007 | +} |
|
1008 | +?>"/> |
|
1006 | 1009 | <?php endif; ?> |
1007 | 1010 | </p> |
1008 | 1011 | <?php |
@@ -1288,7 +1291,10 @@ discard block |
||
1288 | 1291 | do_action( 'give_payment_mode_top', $form_id ); |
1289 | 1292 | ?> |
1290 | 1293 | |
1291 | - <fieldset id="give-payment-mode-select" <?php if ( count($gateways) <= 1 ) echo 'style="display: none;"'; ?>> |
|
1294 | + <fieldset id="give-payment-mode-select" <?php if ( count($gateways) <= 1 ) { |
|
1295 | + echo 'style="display: none;"'; |
|
1296 | +} |
|
1297 | +?>> |
|
1292 | 1298 | <?php |
1293 | 1299 | /** |
1294 | 1300 | * Fires while selecting payment gateways, before the wrap div. |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param array $args An array of form arguments. |
23 | 23 | * |
24 | - * @return string Donation form. |
|
24 | + * @return false|null Donation form. |
|
25 | 25 | */ |
26 | 26 | function give_get_donation_form( $args = array() ) { |
27 | 27 | |
@@ -1391,7 +1391,7 @@ discard block |
||
1391 | 1391 | * |
1392 | 1392 | * @param int $form_id The form ID. |
1393 | 1393 | * |
1394 | - * @return void|bool |
|
1394 | + * @return false|null |
|
1395 | 1395 | */ |
1396 | 1396 | function give_terms_agreement( $form_id ) { |
1397 | 1397 | $form_option = get_post_meta( $form_id, '_give_terms_option', true ); |
@@ -1589,7 +1589,7 @@ discard block |
||
1589 | 1589 | * @param int $form_id The form ID. |
1590 | 1590 | * @param array $args An array of form arguments. |
1591 | 1591 | * |
1592 | - * @return mixed |
|
1592 | + * @return boolean |
|
1593 | 1593 | */ |
1594 | 1594 | function give_show_goal_progress( $form_id, $args ) { |
1595 | 1595 | |
@@ -1608,7 +1608,7 @@ discard block |
||
1608 | 1608 | * Get form content position. |
1609 | 1609 | * |
1610 | 1610 | * @since 1.8 |
1611 | - * @param $form_id |
|
1611 | + * @param integer $form_id |
|
1612 | 1612 | * @param $args |
1613 | 1613 | * @return mixed|string |
1614 | 1614 | */ |
@@ -1632,7 +1632,7 @@ discard block |
||
1632 | 1632 | * @param int $form_id The form ID. |
1633 | 1633 | * @param array $args An array of form arguments. |
1634 | 1634 | * |
1635 | - * @return void|bool |
|
1635 | + * @return false|null |
|
1636 | 1636 | */ |
1637 | 1637 | function give_form_content( $form_id, $args ) { |
1638 | 1638 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -23,47 +23,47 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return string Donation form. |
25 | 25 | */ |
26 | -function give_get_donation_form( $args = array() ) { |
|
26 | +function give_get_donation_form($args = array()) { |
|
27 | 27 | |
28 | 28 | global $post; |
29 | 29 | |
30 | - $form_id = is_object( $post ) ? $post->ID : 0; |
|
30 | + $form_id = is_object($post) ? $post->ID : 0; |
|
31 | 31 | |
32 | - if ( isset( $args['id'] ) ) { |
|
32 | + if (isset($args['id'])) { |
|
33 | 33 | $form_id = $args['id']; |
34 | 34 | } |
35 | 35 | |
36 | - $defaults = apply_filters( 'give_form_args_defaults', array( |
|
36 | + $defaults = apply_filters('give_form_args_defaults', array( |
|
37 | 37 | 'form_id' => $form_id, |
38 | - ) ); |
|
38 | + )); |
|
39 | 39 | |
40 | - $args = wp_parse_args( $args, $defaults ); |
|
40 | + $args = wp_parse_args($args, $defaults); |
|
41 | 41 | |
42 | - $form = new Give_Donate_Form( $args['form_id'] ); |
|
42 | + $form = new Give_Donate_Form($args['form_id']); |
|
43 | 43 | |
44 | 44 | //bail if no form ID. |
45 | - if ( empty( $form->ID ) ) { |
|
45 | + if (empty($form->ID)) { |
|
46 | 46 | return false; |
47 | 47 | } |
48 | 48 | |
49 | - $payment_mode = give_get_chosen_gateway( $form->ID ); |
|
49 | + $payment_mode = give_get_chosen_gateway($form->ID); |
|
50 | 50 | |
51 | - $form_action = add_query_arg( apply_filters( 'give_form_action_args', array( |
|
51 | + $form_action = add_query_arg(apply_filters('give_form_action_args', array( |
|
52 | 52 | 'payment-mode' => $payment_mode, |
53 | - ) ), |
|
53 | + )), |
|
54 | 54 | give_get_current_page_url() |
55 | 55 | ); |
56 | 56 | |
57 | 57 | //Sanity Check: Donation form not published or user doesn't have permission to view drafts. |
58 | - if ( 'publish' !== $form->post_status && ! current_user_can( 'edit_give_forms', $form->ID ) ) { |
|
58 | + if ('publish' !== $form->post_status && ! current_user_can('edit_give_forms', $form->ID)) { |
|
59 | 59 | return false; |
60 | 60 | } |
61 | 61 | |
62 | 62 | //Get the form wrap CSS classes. |
63 | - $form_wrap_classes = $form->get_form_wrap_classes( $args ); |
|
63 | + $form_wrap_classes = $form->get_form_wrap_classes($args); |
|
64 | 64 | |
65 | 65 | //Get the <form> tag wrap CSS classes. |
66 | - $form_classes = $form->get_form_classes( $args ); |
|
66 | + $form_classes = $form->get_form_classes($args); |
|
67 | 67 | |
68 | 68 | ob_start(); |
69 | 69 | |
@@ -75,25 +75,25 @@ discard block |
||
75 | 75 | * @param int $form_id The form ID. |
76 | 76 | * @param array $args An array of form arguments. |
77 | 77 | */ |
78 | - do_action( 'give_pre_form_output', $form->ID, $args ); |
|
78 | + do_action('give_pre_form_output', $form->ID, $args); |
|
79 | 79 | |
80 | 80 | ?> |
81 | 81 | <div id="give-form-<?php echo $form->ID; ?>-wrap" class="<?php echo $form_wrap_classes; ?>"> |
82 | 82 | |
83 | - <?php if ( $form->is_close_donation_form() ) { |
|
83 | + <?php if ($form->is_close_donation_form()) { |
|
84 | 84 | |
85 | 85 | //Get Goal thank you message. |
86 | - $display_thankyou_message = get_post_meta( $form->ID, '_give_form_goal_achieved_message', true ); |
|
87 | - $display_thankyou_message = ! empty( $display_thankyou_message ) ? $display_thankyou_message : esc_html__( 'Thank you to all our donors, we have met our fundraising goal.', 'give' ); |
|
86 | + $display_thankyou_message = get_post_meta($form->ID, '_give_form_goal_achieved_message', true); |
|
87 | + $display_thankyou_message = ! empty($display_thankyou_message) ? $display_thankyou_message : esc_html__('Thank you to all our donors, we have met our fundraising goal.', 'give'); |
|
88 | 88 | |
89 | 89 | //Print thank you message. |
90 | - echo apply_filters( 'give_goal_closed_output', give_output_error( $display_thankyou_message, false, 'success' ), $form->ID ); |
|
90 | + echo apply_filters('give_goal_closed_output', give_output_error($display_thankyou_message, false, 'success'), $form->ID); |
|
91 | 91 | |
92 | 92 | } else { |
93 | 93 | |
94 | - if ( isset( $args['show_title'] ) && $args['show_title'] == true ) { |
|
94 | + if (isset($args['show_title']) && $args['show_title'] == true) { |
|
95 | 95 | |
96 | - echo apply_filters( 'give_form_title', '<h2 class="give-form-title">' . get_the_title( $form_id ) . '</h2>' ); |
|
96 | + echo apply_filters('give_form_title', '<h2 class="give-form-title">'.get_the_title($form_id).'</h2>'); |
|
97 | 97 | |
98 | 98 | } |
99 | 99 | |
@@ -105,15 +105,15 @@ discard block |
||
105 | 105 | * @param int $form_id The form ID. |
106 | 106 | * @param array $args An array of form arguments. |
107 | 107 | */ |
108 | - do_action( 'give_pre_form', $form->ID, $args ); |
|
108 | + do_action('give_pre_form', $form->ID, $args); |
|
109 | 109 | ?> |
110 | 110 | |
111 | - <form id="give-form-<?php echo $form_id; ?>" class="<?php echo $form_classes; ?>" action="<?php echo esc_url_raw( $form_action ); ?>" method="post"> |
|
111 | + <form id="give-form-<?php echo $form_id; ?>" class="<?php echo $form_classes; ?>" action="<?php echo esc_url_raw($form_action); ?>" method="post"> |
|
112 | 112 | <input type="hidden" name="give-form-id" value="<?php echo $form->ID; ?>"/> |
113 | - <input type="hidden" name="give-form-title" value="<?php echo htmlentities( $form->post_title ); ?>"/> |
|
114 | - <input type="hidden" name="give-current-url" value="<?php echo htmlspecialchars( give_get_current_page_url() ); ?>"/> |
|
115 | - <input type="hidden" name="give-form-url" value="<?php echo htmlspecialchars( give_get_current_page_url() ); ?>"/> |
|
116 | - <input type="hidden" name="give-form-minimum" value="<?php echo give_format_amount( give_get_form_minimum_price( $form->ID ) ); ?>"/> |
|
113 | + <input type="hidden" name="give-form-title" value="<?php echo htmlentities($form->post_title); ?>"/> |
|
114 | + <input type="hidden" name="give-current-url" value="<?php echo htmlspecialchars(give_get_current_page_url()); ?>"/> |
|
115 | + <input type="hidden" name="give-form-url" value="<?php echo htmlspecialchars(give_get_current_page_url()); ?>"/> |
|
116 | + <input type="hidden" name="give-form-minimum" value="<?php echo give_format_amount(give_get_form_minimum_price($form->ID)); ?>"/> |
|
117 | 117 | |
118 | 118 | <!-- The following field is for robots only, invisible to humans: --> |
119 | 119 | <span class="give-hidden" style="display: none !important;"> |
@@ -124,13 +124,13 @@ discard block |
||
124 | 124 | <?php |
125 | 125 | |
126 | 126 | //Price ID hidden field for variable (mult-level) donation forms. |
127 | - if ( give_has_variable_prices( $form_id ) ) { |
|
127 | + if (give_has_variable_prices($form_id)) { |
|
128 | 128 | //get default selected price ID. |
129 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
129 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
130 | 130 | $price_id = 0; |
131 | 131 | //loop through prices. |
132 | - foreach ( $prices as $price ) { |
|
133 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
132 | + foreach ($prices as $price) { |
|
133 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
134 | 134 | $price_id = $price['_give_id']['level_id']; |
135 | 135 | }; |
136 | 136 | } |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * @param int $form_id The form ID. |
147 | 147 | * @param array $args An array of form arguments. |
148 | 148 | */ |
149 | - do_action( 'give_checkout_form_top', $form->ID, $args ); |
|
149 | + do_action('give_checkout_form_top', $form->ID, $args); |
|
150 | 150 | |
151 | 151 | /** |
152 | 152 | * Fires while outputing donation form, for payment gatways fields. |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | * @param int $form_id The form ID. |
157 | 157 | * @param array $args An array of form arguments. |
158 | 158 | */ |
159 | - do_action( 'give_payment_mode_select', $form->ID, $args ); |
|
159 | + do_action('give_payment_mode_select', $form->ID, $args); |
|
160 | 160 | |
161 | 161 | /** |
162 | 162 | * Fires while outputing donation form, after all other fields. |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * @param int $form_id The form ID. |
167 | 167 | * @param array $args An array of form arguments. |
168 | 168 | */ |
169 | - do_action( 'give_checkout_form_bottom', $form->ID, $args ); |
|
169 | + do_action('give_checkout_form_bottom', $form->ID, $args); |
|
170 | 170 | |
171 | 171 | ?> |
172 | 172 | </form> |
@@ -180,12 +180,12 @@ discard block |
||
180 | 180 | * @param int $form_id The form ID. |
181 | 181 | * @param array $args An array of form arguments. |
182 | 182 | */ |
183 | - do_action( 'give_post_form', $form->ID, $args ); |
|
183 | + do_action('give_post_form', $form->ID, $args); |
|
184 | 184 | |
185 | 185 | } |
186 | 186 | ?> |
187 | 187 | |
188 | - </div><!--end #give-form-<?php echo absint( $form->ID ); ?>--> |
|
188 | + </div><!--end #give-form-<?php echo absint($form->ID); ?>--> |
|
189 | 189 | <?php |
190 | 190 | |
191 | 191 | /** |
@@ -196,11 +196,11 @@ discard block |
||
196 | 196 | * @param int $form_id The form ID. |
197 | 197 | * @param array $args An array of form arguments. |
198 | 198 | */ |
199 | - do_action( 'give_post_form_output', $form->ID, $args ); |
|
199 | + do_action('give_post_form_output', $form->ID, $args); |
|
200 | 200 | |
201 | 201 | $final_output = ob_get_clean(); |
202 | 202 | |
203 | - echo apply_filters( 'give_donate_form', $final_output, $args ); |
|
203 | + echo apply_filters('give_donate_form', $final_output, $args); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -217,11 +217,11 @@ discard block |
||
217 | 217 | * |
218 | 218 | * @return string |
219 | 219 | */ |
220 | -function give_show_purchase_form( $form_id ) { |
|
220 | +function give_show_purchase_form($form_id) { |
|
221 | 221 | |
222 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
222 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
223 | 223 | |
224 | - if ( ! isset( $form_id ) && isset( $_POST['give_form_id'] ) ) { |
|
224 | + if ( ! isset($form_id) && isset($_POST['give_form_id'])) { |
|
225 | 225 | $form_id = $_POST['give_form_id']; |
226 | 226 | } |
227 | 227 | |
@@ -230,33 +230,33 @@ discard block |
||
230 | 230 | * |
231 | 231 | * @since 1.7 |
232 | 232 | */ |
233 | - do_action( 'give_donation_form_top', $form_id ); |
|
233 | + do_action('give_donation_form_top', $form_id); |
|
234 | 234 | |
235 | - if ( give_can_checkout() && isset( $form_id ) ) { |
|
235 | + if (give_can_checkout() && isset($form_id)) { |
|
236 | 236 | |
237 | 237 | /** |
238 | 238 | * Fires while displaying donation form, before registration login. |
239 | 239 | * |
240 | 240 | * @since 1.7 |
241 | 241 | */ |
242 | - do_action( 'give_donation_form_before_register_login', $form_id ); |
|
242 | + do_action('give_donation_form_before_register_login', $form_id); |
|
243 | 243 | |
244 | 244 | /** |
245 | 245 | * Fire when register/login form fields render. |
246 | 246 | * |
247 | 247 | * @since 1.7 |
248 | 248 | */ |
249 | - do_action( 'give_donation_form_register_login_fields', $form_id ); |
|
249 | + do_action('give_donation_form_register_login_fields', $form_id); |
|
250 | 250 | |
251 | 251 | /** |
252 | 252 | * Fire when credit card form fields render. |
253 | 253 | * |
254 | 254 | * @since 1.7 |
255 | 255 | */ |
256 | - do_action( 'give_donation_form_before_cc_form', $form_id ); |
|
256 | + do_action('give_donation_form_before_cc_form', $form_id); |
|
257 | 257 | |
258 | 258 | // Load the credit card form and allow gateways to load their own if they wish. |
259 | - if ( has_action( 'give_' . $payment_mode . '_cc_form' ) ) { |
|
259 | + if (has_action('give_'.$payment_mode.'_cc_form')) { |
|
260 | 260 | /** |
261 | 261 | * Fires while displaying donation form, credit card form fields for a given gateway. |
262 | 262 | * |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | * |
265 | 265 | * @param int $form_id The form ID. |
266 | 266 | */ |
267 | - do_action( "give_{$payment_mode}_cc_form", $form_id ); |
|
267 | + do_action("give_{$payment_mode}_cc_form", $form_id); |
|
268 | 268 | } else { |
269 | 269 | /** |
270 | 270 | * Fires while displaying donation form, credit card form fields. |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | * |
274 | 274 | * @param int $form_id The form ID. |
275 | 275 | */ |
276 | - do_action( 'give_cc_form', $form_id ); |
|
276 | + do_action('give_cc_form', $form_id); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | /** |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | * |
282 | 282 | * @since 1.7 |
283 | 283 | */ |
284 | - do_action( 'give_donation_form_after_cc_form', $form_id ); |
|
284 | + do_action('give_donation_form_after_cc_form', $form_id); |
|
285 | 285 | |
286 | 286 | } else { |
287 | 287 | /** |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | * |
290 | 290 | * @since 1.7 |
291 | 291 | */ |
292 | - do_action( 'give_donation_form_no_access', $form_id ); |
|
292 | + do_action('give_donation_form_no_access', $form_id); |
|
293 | 293 | |
294 | 294 | } |
295 | 295 | |
@@ -298,10 +298,10 @@ discard block |
||
298 | 298 | * |
299 | 299 | * @since 1.7 |
300 | 300 | */ |
301 | - do_action( 'give_donation_form_bottom', $form_id ); |
|
301 | + do_action('give_donation_form_bottom', $form_id); |
|
302 | 302 | } |
303 | 303 | |
304 | -add_action( 'give_donation_form', 'give_show_purchase_form' ); |
|
304 | +add_action('give_donation_form', 'give_show_purchase_form'); |
|
305 | 305 | |
306 | 306 | /** |
307 | 307 | * Give Show Login/Register Form Fields. |
@@ -312,11 +312,11 @@ discard block |
||
312 | 312 | * |
313 | 313 | * @return void |
314 | 314 | */ |
315 | -function give_show_register_login_fields( $form_id ) { |
|
315 | +function give_show_register_login_fields($form_id) { |
|
316 | 316 | |
317 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
317 | + $show_register_form = give_show_login_register_option($form_id); |
|
318 | 318 | |
319 | - if ( ( $show_register_form === 'registration' || ( $show_register_form === 'both' && ! isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : |
|
319 | + if (($show_register_form === 'registration' || ($show_register_form === 'both' && ! isset($_GET['login']))) && ! is_user_logged_in()) : |
|
320 | 320 | ?> |
321 | 321 | <div id="give-checkout-login-register-<?php echo $form_id; ?>"> |
322 | 322 | <?php |
@@ -325,11 +325,11 @@ discard block |
||
325 | 325 | * |
326 | 326 | * @since 1.7 |
327 | 327 | */ |
328 | - do_action( 'give_donation_form_register_fields', $form_id ); |
|
328 | + do_action('give_donation_form_register_fields', $form_id); |
|
329 | 329 | ?> |
330 | 330 | </div> |
331 | 331 | <?php |
332 | - elseif ( ( $show_register_form === 'login' || ( $show_register_form === 'both' && isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : |
|
332 | + elseif (($show_register_form === 'login' || ($show_register_form === 'both' && isset($_GET['login']))) && ! is_user_logged_in()) : |
|
333 | 333 | ?> |
334 | 334 | <div id="give-checkout-login-register-<?php echo $form_id; ?>"> |
335 | 335 | <?php |
@@ -338,23 +338,23 @@ discard block |
||
338 | 338 | * |
339 | 339 | * @since 1.7 |
340 | 340 | */ |
341 | - do_action( 'give_donation_form_login_fields', $form_id ); |
|
341 | + do_action('give_donation_form_login_fields', $form_id); |
|
342 | 342 | ?> |
343 | 343 | </div> |
344 | 344 | <?php |
345 | 345 | endif; |
346 | 346 | |
347 | - if ( ( ! isset( $_GET['login'] ) && is_user_logged_in() ) || ! isset( $show_register_form ) || 'none' === $show_register_form || 'login' === $show_register_form ) { |
|
347 | + if (( ! isset($_GET['login']) && is_user_logged_in()) || ! isset($show_register_form) || 'none' === $show_register_form || 'login' === $show_register_form) { |
|
348 | 348 | /** |
349 | 349 | * Fire when user info render. |
350 | 350 | * |
351 | 351 | * @since 1.7 |
352 | 352 | */ |
353 | - do_action( 'give_donation_form_after_user_info', $form_id ); |
|
353 | + do_action('give_donation_form_after_user_info', $form_id); |
|
354 | 354 | } |
355 | 355 | } |
356 | 356 | |
357 | -add_action( 'give_donation_form_register_login_fields', 'give_show_register_login_fields' ); |
|
357 | +add_action('give_donation_form_register_login_fields', 'give_show_register_login_fields'); |
|
358 | 358 | |
359 | 359 | /** |
360 | 360 | * Donation Amount Field. |
@@ -368,16 +368,16 @@ discard block |
||
368 | 368 | * |
369 | 369 | * @return void |
370 | 370 | */ |
371 | -function give_output_donation_amount_top( $form_id = 0, $args = array() ) { |
|
371 | +function give_output_donation_amount_top($form_id = 0, $args = array()) { |
|
372 | 372 | |
373 | 373 | $give_options = give_get_settings(); |
374 | - $variable_pricing = give_has_variable_prices( $form_id ); |
|
375 | - $allow_custom_amount = get_post_meta( $form_id, '_give_custom_amount', true ); |
|
376 | - $currency_position = isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before'; |
|
377 | - $symbol = give_currency_symbol( give_get_currency() ); |
|
378 | - $currency_output = '<span class="give-currency-symbol give-currency-position-' . $currency_position . '">' . $symbol . '</span>'; |
|
379 | - $default_amount = give_format_amount( give_get_default_form_amount( $form_id ) ); |
|
380 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
374 | + $variable_pricing = give_has_variable_prices($form_id); |
|
375 | + $allow_custom_amount = get_post_meta($form_id, '_give_custom_amount', true); |
|
376 | + $currency_position = isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before'; |
|
377 | + $symbol = give_currency_symbol(give_get_currency()); |
|
378 | + $currency_output = '<span class="give-currency-symbol give-currency-position-'.$currency_position.'">'.$symbol.'</span>'; |
|
379 | + $default_amount = give_format_amount(give_get_default_form_amount($form_id)); |
|
380 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
381 | 381 | |
382 | 382 | /** |
383 | 383 | * Fires while displaying donation form, before donation level fields. |
@@ -387,19 +387,19 @@ discard block |
||
387 | 387 | * @param int $form_id The form ID. |
388 | 388 | * @param array $args An array of form arguments. |
389 | 389 | */ |
390 | - do_action( 'give_before_donation_levels', $form_id, $args ); |
|
390 | + do_action('give_before_donation_levels', $form_id, $args); |
|
391 | 391 | |
392 | 392 | //Set Price, No Custom Amount Allowed means hidden price field |
393 | - if ( ! give_is_setting_enabled( $allow_custom_amount ) ) { |
|
393 | + if ( ! give_is_setting_enabled($allow_custom_amount)) { |
|
394 | 394 | ?> |
395 | - <label class="give-hidden" for="give-amount-hidden"><?php esc_html_e( 'Donation Amount:', 'give' ); ?></label> |
|
395 | + <label class="give-hidden" for="give-amount-hidden"><?php esc_html_e('Donation Amount:', 'give'); ?></label> |
|
396 | 396 | <input id="give-amount" class="give-amount-hidden" type="hidden" name="give-amount" value="<?php echo $default_amount; ?>" required aria-required="true" /> |
397 | 397 | <div class="set-price give-donation-amount form-row-wide"> |
398 | - <?php if ( $currency_position == 'before' ) { |
|
398 | + <?php if ($currency_position == 'before') { |
|
399 | 399 | echo $currency_output; |
400 | 400 | } ?> |
401 | 401 | <span id="give-amount-text" class="give-text-input give-amount-top"><?php echo $default_amount; ?></span> |
402 | - <?php if ( $currency_position == 'after' ) { |
|
402 | + <?php if ($currency_position == 'after') { |
|
403 | 403 | echo $currency_output; |
404 | 404 | } ?> |
405 | 405 | </div> |
@@ -409,12 +409,12 @@ discard block |
||
409 | 409 | ?> |
410 | 410 | <div class="give-total-wrap"> |
411 | 411 | <div class="give-donation-amount form-row-wide"> |
412 | - <?php if ( $currency_position == 'before' ) { |
|
412 | + <?php if ($currency_position == 'before') { |
|
413 | 413 | echo $currency_output; |
414 | 414 | } ?> |
415 | - <label class="give-hidden" for="give-amount"><?php esc_html_e( 'Donation Amount:', 'give' ); ?></label> |
|
415 | + <label class="give-hidden" for="give-amount"><?php esc_html_e('Donation Amount:', 'give'); ?></label> |
|
416 | 416 | <input class="give-text-input give-amount-top" id="give-amount" name="give-amount" type="tel" placeholder="" value="<?php echo $default_amount; ?>" autocomplete="off"> |
417 | - <?php if ( $currency_position == 'after' ) { |
|
417 | + <?php if ($currency_position == 'after') { |
|
418 | 418 | echo $currency_output; |
419 | 419 | } ?> |
420 | 420 | </div> |
@@ -429,16 +429,16 @@ discard block |
||
429 | 429 | * @param int $form_id The form ID. |
430 | 430 | * @param array $args An array of form arguments. |
431 | 431 | */ |
432 | - do_action( 'give_after_donation_amount', $form_id, $args ); |
|
432 | + do_action('give_after_donation_amount', $form_id, $args); |
|
433 | 433 | |
434 | 434 | //Custom Amount Text |
435 | - if ( ! $variable_pricing && give_is_setting_enabled( $allow_custom_amount ) && ! empty( $custom_amount_text ) ) { ?> |
|
435 | + if ( ! $variable_pricing && give_is_setting_enabled($allow_custom_amount) && ! empty($custom_amount_text)) { ?> |
|
436 | 436 | <p class="give-custom-amount-text"><?php echo $custom_amount_text; ?></p> |
437 | 437 | <?php } |
438 | 438 | |
439 | 439 | //Output Variable Pricing Levels. |
440 | - if ( $variable_pricing ) { |
|
441 | - give_output_levels( $form_id ); |
|
440 | + if ($variable_pricing) { |
|
441 | + give_output_levels($form_id); |
|
442 | 442 | } |
443 | 443 | |
444 | 444 | /** |
@@ -449,10 +449,10 @@ discard block |
||
449 | 449 | * @param int $form_id The form ID. |
450 | 450 | * @param array $args An array of form arguments. |
451 | 451 | */ |
452 | - do_action( 'give_after_donation_levels', $form_id, $args ); |
|
452 | + do_action('give_after_donation_levels', $form_id, $args); |
|
453 | 453 | } |
454 | 454 | |
455 | -add_action( 'give_checkout_form_top', 'give_output_donation_amount_top', 10, 2 ); |
|
455 | +add_action('give_checkout_form_top', 'give_output_donation_amount_top', 10, 2); |
|
456 | 456 | |
457 | 457 | /** |
458 | 458 | * Outputs the Donation Levels in various formats such as dropdown, radios, and buttons. |
@@ -463,32 +463,32 @@ discard block |
||
463 | 463 | * |
464 | 464 | * @return string Donation levels. |
465 | 465 | */ |
466 | -function give_output_levels( $form_id ) { |
|
466 | +function give_output_levels($form_id) { |
|
467 | 467 | |
468 | 468 | //Get variable pricing. |
469 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
470 | - $display_style = get_post_meta( $form_id, '_give_display_style', true ); |
|
471 | - $custom_amount = get_post_meta( $form_id, '_give_custom_amount', true ); |
|
472 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
473 | - if ( empty( $custom_amount_text ) ) { |
|
474 | - $custom_amount_text = esc_html__( 'Give a Custom Amount', 'give' ); |
|
469 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
470 | + $display_style = get_post_meta($form_id, '_give_display_style', true); |
|
471 | + $custom_amount = get_post_meta($form_id, '_give_custom_amount', true); |
|
472 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
473 | + if (empty($custom_amount_text)) { |
|
474 | + $custom_amount_text = esc_html__('Give a Custom Amount', 'give'); |
|
475 | 475 | } |
476 | 476 | |
477 | 477 | $output = ''; |
478 | 478 | $counter = 0; |
479 | 479 | |
480 | - switch ( $display_style ) { |
|
480 | + switch ($display_style) { |
|
481 | 481 | case 'buttons': |
482 | 482 | |
483 | 483 | $output .= '<ul id="give-donation-level-button-wrap" class="give-donation-levels-wrap give-list-inline">'; |
484 | 484 | |
485 | - foreach ( $prices as $price ) { |
|
486 | - $counter ++; |
|
487 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'] ) ), $form_id, $price ); |
|
488 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-donation-level-btn give-btn give-btn-level-' . $counter . ' ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'give-default-level' : '' ), $form_id, $price ); |
|
485 | + foreach ($prices as $price) { |
|
486 | + $counter++; |
|
487 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'])), $form_id, $price); |
|
488 | + $level_classes = apply_filters('give_form_level_classes', 'give-donation-level-btn give-btn give-btn-level-'.$counter.' '.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'give-default-level' : ''), $form_id, $price); |
|
489 | 489 | |
490 | 490 | $output .= '<li>'; |
491 | - $output .= '<button type="button" data-price-id="' . $price['_give_id']['level_id'] . '" class=" ' . $level_classes . '" value="' . give_format_amount( $price['_give_amount'] ) . '">'; |
|
491 | + $output .= '<button type="button" data-price-id="'.$price['_give_id']['level_id'].'" class=" '.$level_classes.'" value="'.give_format_amount($price['_give_amount']).'">'; |
|
492 | 492 | $output .= $level_text; |
493 | 493 | $output .= '</button>'; |
494 | 494 | $output .= '</li>'; |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | } |
497 | 497 | |
498 | 498 | //Custom Amount. |
499 | - if ( give_is_setting_enabled( $custom_amount ) && ! empty( $custom_amount_text ) ) { |
|
499 | + if (give_is_setting_enabled($custom_amount) && ! empty($custom_amount_text)) { |
|
500 | 500 | $output .= '<li>'; |
501 | 501 | $output .= '<button type="button" data-price-id="custom" class="give-donation-level-btn give-btn give-btn-level-custom" value="custom">'; |
502 | 502 | $output .= $custom_amount_text; |
@@ -512,23 +512,23 @@ discard block |
||
512 | 512 | |
513 | 513 | $output .= '<ul id="give-donation-level-radio-list" class="give-donation-levels-wrap">'; |
514 | 514 | |
515 | - foreach ( $prices as $price ) { |
|
516 | - $counter ++; |
|
517 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'] ) ), $form_id, $price ); |
|
518 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-radio-input give-radio-input-level give-radio-level-' . $counter . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? ' give-default-level' : '' ), $form_id, $price ); |
|
515 | + foreach ($prices as $price) { |
|
516 | + $counter++; |
|
517 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'])), $form_id, $price); |
|
518 | + $level_classes = apply_filters('give_form_level_classes', 'give-radio-input give-radio-input-level give-radio-level-'.$counter.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? ' give-default-level' : ''), $form_id, $price); |
|
519 | 519 | |
520 | 520 | $output .= '<li>'; |
521 | - $output .= '<input type="radio" data-price-id="' . $price['_give_id']['level_id'] . '" class="' . $level_classes . '" name="give-radio-donation-level" id="give-radio-level-' . $counter . '" ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'checked="checked"' : '' ) . ' value="' . give_format_amount( $price['_give_amount'] ) . '">'; |
|
522 | - $output .= '<label for="give-radio-level-' . $counter . '">' . $level_text . '</label>'; |
|
521 | + $output .= '<input type="radio" data-price-id="'.$price['_give_id']['level_id'].'" class="'.$level_classes.'" name="give-radio-donation-level" id="give-radio-level-'.$counter.'" '.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'checked="checked"' : '').' value="'.give_format_amount($price['_give_amount']).'">'; |
|
522 | + $output .= '<label for="give-radio-level-'.$counter.'">'.$level_text.'</label>'; |
|
523 | 523 | $output .= '</li>'; |
524 | 524 | |
525 | 525 | } |
526 | 526 | |
527 | 527 | //Custom Amount |
528 | - if ( give_is_setting_enabled( $custom_amount ) && ! empty( $custom_amount_text ) ) { |
|
528 | + if (give_is_setting_enabled($custom_amount) && ! empty($custom_amount_text)) { |
|
529 | 529 | $output .= '<li>'; |
530 | 530 | $output .= '<input type="radio" data-price-id="custom" class="give-radio-input give-radio-input-level give-radio-level-custom" name="give-radio-donation-level" id="give-radio-level-custom" value="custom">'; |
531 | - $output .= '<label for="give-radio-level-custom">' . $custom_amount_text . '</label>'; |
|
531 | + $output .= '<label for="give-radio-level-custom">'.$custom_amount_text.'</label>'; |
|
532 | 532 | $output .= '</li>'; |
533 | 533 | } |
534 | 534 | |
@@ -538,23 +538,23 @@ discard block |
||
538 | 538 | |
539 | 539 | case 'dropdown': |
540 | 540 | |
541 | - $output .= '<label for="give-donation-level" class="give-hidden">' . esc_html__( 'Choose Your Donation Amount', 'give' ) . ':</label>'; |
|
542 | - $output .= '<select id="give-donation-level-' . $form_id . '" class="give-select give-select-level give-donation-levels-wrap">'; |
|
541 | + $output .= '<label for="give-donation-level" class="give-hidden">'.esc_html__('Choose Your Donation Amount', 'give').':</label>'; |
|
542 | + $output .= '<select id="give-donation-level-'.$form_id.'" class="give-select give-select-level give-donation-levels-wrap">'; |
|
543 | 543 | |
544 | 544 | //first loop through prices. |
545 | - foreach ( $prices as $price ) { |
|
546 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'] ) ), $form_id, $price ); |
|
547 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-donation-level-' . $form_id . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? ' give-default-level' : '' ), $form_id, $price ); |
|
545 | + foreach ($prices as $price) { |
|
546 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'])), $form_id, $price); |
|
547 | + $level_classes = apply_filters('give_form_level_classes', 'give-donation-level-'.$form_id.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? ' give-default-level' : ''), $form_id, $price); |
|
548 | 548 | |
549 | - $output .= '<option data-price-id="' . $price['_give_id']['level_id'] . '" class="' . $level_classes . '" ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'selected="selected"' : '' ) . ' value="' . give_format_amount( $price['_give_amount'] ) . '">'; |
|
549 | + $output .= '<option data-price-id="'.$price['_give_id']['level_id'].'" class="'.$level_classes.'" '.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'selected="selected"' : '').' value="'.give_format_amount($price['_give_amount']).'">'; |
|
550 | 550 | $output .= $level_text; |
551 | 551 | $output .= '</option>'; |
552 | 552 | |
553 | 553 | } |
554 | 554 | |
555 | 555 | //Custom Amount. |
556 | - if ( give_is_setting_enabled( $custom_amount ) && ! empty( $custom_amount_text ) ) { |
|
557 | - $output .= '<option data-price-id="custom" class="give-donation-level-custom" value="custom">' . $custom_amount_text . '</option>'; |
|
556 | + if (give_is_setting_enabled($custom_amount) && ! empty($custom_amount_text)) { |
|
557 | + $output .= '<option data-price-id="custom" class="give-donation-level-custom" value="custom">'.$custom_amount_text.'</option>'; |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | $output .= '</select>'; |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | break; |
563 | 563 | } |
564 | 564 | |
565 | - echo apply_filters( 'give_form_level_output', $output, $form_id ); |
|
565 | + echo apply_filters('give_form_level_output', $output, $form_id); |
|
566 | 566 | } |
567 | 567 | |
568 | 568 | /** |
@@ -577,26 +577,26 @@ discard block |
||
577 | 577 | * |
578 | 578 | * @return string Checkout button. |
579 | 579 | */ |
580 | -function give_display_checkout_button( $form_id, $args ) { |
|
580 | +function give_display_checkout_button($form_id, $args) { |
|
581 | 581 | |
582 | - $display_option = ( isset( $args['display_style'] ) && ! empty( $args['display_style'] ) ) |
|
582 | + $display_option = (isset($args['display_style']) && ! empty($args['display_style'])) |
|
583 | 583 | ? $args['display_style'] |
584 | - : get_post_meta( $form_id, '_give_payment_display', true ); |
|
584 | + : get_post_meta($form_id, '_give_payment_display', true); |
|
585 | 585 | |
586 | 586 | //no btn for onpage. |
587 | - if ( $display_option === 'onpage' ) { |
|
587 | + if ($display_option === 'onpage') { |
|
588 | 588 | return; |
589 | 589 | } |
590 | 590 | |
591 | - $display_label_field = get_post_meta( $form_id, '_give_reveal_label', true ); |
|
592 | - $display_label = ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) ); |
|
591 | + $display_label_field = get_post_meta($form_id, '_give_reveal_label', true); |
|
592 | + $display_label = ( ! empty($display_label_field) ? $display_label_field : esc_html__('Donate Now', 'give')); |
|
593 | 593 | |
594 | - $output = '<button type="button" class="give-btn give-btn-' . $display_option . '">' . $display_label . '</button>'; |
|
594 | + $output = '<button type="button" class="give-btn give-btn-'.$display_option.'">'.$display_label.'</button>'; |
|
595 | 595 | |
596 | - echo apply_filters( 'give_display_checkout_button', $output ); |
|
596 | + echo apply_filters('give_display_checkout_button', $output); |
|
597 | 597 | } |
598 | 598 | |
599 | -add_action( 'give_after_donation_levels', 'give_display_checkout_button', 10, 2 ); |
|
599 | +add_action('give_after_donation_levels', 'give_display_checkout_button', 10, 2); |
|
600 | 600 | |
601 | 601 | /** |
602 | 602 | * Shows the User Info fields in the Personal Info box, more fields can be added via the hooks provided. |
@@ -607,54 +607,54 @@ discard block |
||
607 | 607 | * |
608 | 608 | * @return void |
609 | 609 | */ |
610 | -function give_user_info_fields( $form_id ) { |
|
610 | +function give_user_info_fields($form_id) { |
|
611 | 611 | // Get user info. |
612 | - $give_user_info = _give_get_prefill_form_field_values( $form_id ); |
|
612 | + $give_user_info = _give_get_prefill_form_field_values($form_id); |
|
613 | 613 | |
614 | 614 | /** |
615 | 615 | * Fire before user personal information fields |
616 | 616 | * |
617 | 617 | * @since 1.7 |
618 | 618 | */ |
619 | - do_action( 'give_donation_form_before_personal_info', $form_id ); |
|
619 | + do_action('give_donation_form_before_personal_info', $form_id); |
|
620 | 620 | ?> |
621 | 621 | <fieldset id="give_checkout_user_info"> |
622 | - <legend><?php echo apply_filters( 'give_checkout_personal_info_text', esc_html__( 'Personal Info', 'give' ) ); ?></legend> |
|
622 | + <legend><?php echo apply_filters('give_checkout_personal_info_text', esc_html__('Personal Info', 'give')); ?></legend> |
|
623 | 623 | <p id="give-first-name-wrap" class="form-row form-row-first"> |
624 | 624 | <label class="give-label" for="give-first"> |
625 | - <?php esc_html_e( 'First Name', 'give' ); ?> |
|
626 | - <?php if ( give_field_is_required( 'give_first', $form_id ) ) : ?> |
|
625 | + <?php esc_html_e('First Name', 'give'); ?> |
|
626 | + <?php if (give_field_is_required('give_first', $form_id)) : ?> |
|
627 | 627 | <span class="give-required-indicator">*</span> |
628 | 628 | <?php endif ?> |
629 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'We will use this to personalize your account experience.', 'give' ); ?>"></span> |
|
629 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('We will use this to personalize your account experience.', 'give'); ?>"></span> |
|
630 | 630 | </label> |
631 | 631 | <input |
632 | 632 | class="give-input required" |
633 | 633 | type="text" |
634 | 634 | name="give_first" |
635 | - placeholder="<?php esc_attr_e( 'First Name', 'give' ); ?>" |
|
636 | - id="give-first" value="<?php echo isset( $give_user_info['give_first'] ) ? $give_user_info['give_first'] : ''; ?>" |
|
637 | - <?php echo( give_field_is_required( 'give_first', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
635 | + placeholder="<?php esc_attr_e('First Name', 'give'); ?>" |
|
636 | + id="give-first" value="<?php echo isset($give_user_info['give_first']) ? $give_user_info['give_first'] : ''; ?>" |
|
637 | + <?php echo(give_field_is_required('give_first', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
638 | 638 | /> |
639 | 639 | </p> |
640 | 640 | |
641 | 641 | <p id="give-last-name-wrap" class="form-row form-row-last"> |
642 | 642 | <label class="give-label" for="give-last"> |
643 | - <?php esc_html_e( 'Last Name', 'give' ); ?> |
|
644 | - <?php if ( give_field_is_required( 'give_last', $form_id ) ) : ?> |
|
643 | + <?php esc_html_e('Last Name', 'give'); ?> |
|
644 | + <?php if (give_field_is_required('give_last', $form_id)) : ?> |
|
645 | 645 | <span class="give-required-indicator">*</span> |
646 | 646 | <?php endif ?> |
647 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'We will use this as well to personalize your account experience.', 'give' ); ?>"></span> |
|
647 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('We will use this as well to personalize your account experience.', 'give'); ?>"></span> |
|
648 | 648 | </label> |
649 | 649 | |
650 | 650 | <input |
651 | - class="give-input<?php echo( give_field_is_required( 'give_last', $form_id ) ? ' required' : '' ); ?>" |
|
651 | + class="give-input<?php echo(give_field_is_required('give_last', $form_id) ? ' required' : ''); ?>" |
|
652 | 652 | type="text" |
653 | 653 | name="give_last" |
654 | 654 | id="give-last" |
655 | - placeholder="<?php esc_attr_e( 'Last Name', 'give' ); ?>" |
|
656 | - value="<?php echo isset( $give_user_info['give_last'] ) ? $give_user_info['give_last'] : ''; ?>" |
|
657 | - <?php echo( give_field_is_required( 'give_last', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
655 | + placeholder="<?php esc_attr_e('Last Name', 'give'); ?>" |
|
656 | + value="<?php echo isset($give_user_info['give_last']) ? $give_user_info['give_last'] : ''; ?>" |
|
657 | + <?php echo(give_field_is_required('give_last', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
658 | 658 | /> |
659 | 659 | </p> |
660 | 660 | |
@@ -664,24 +664,24 @@ discard block |
||
664 | 664 | * |
665 | 665 | * @since 1.7 |
666 | 666 | */ |
667 | - do_action( 'give_donation_form_before_email', $form_id ); |
|
667 | + do_action('give_donation_form_before_email', $form_id); |
|
668 | 668 | ?> |
669 | 669 | <p id="give-email-wrap" class="form-row form-row-wide"> |
670 | 670 | <label class="give-label" for="give-email"> |
671 | - <?php esc_html_e( 'Email Address', 'give' ); ?> |
|
672 | - <?php if ( give_field_is_required( 'give_email', $form_id ) ) { ?> |
|
671 | + <?php esc_html_e('Email Address', 'give'); ?> |
|
672 | + <?php if (give_field_is_required('give_email', $form_id)) { ?> |
|
673 | 673 | <span class="give-required-indicator">*</span> |
674 | 674 | <?php } ?> |
675 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'We will send the donation receipt to this address.', 'give' ); ?>"></span> |
|
675 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('We will send the donation receipt to this address.', 'give'); ?>"></span> |
|
676 | 676 | </label> |
677 | 677 | |
678 | 678 | <input |
679 | 679 | class="give-input required" |
680 | 680 | type="email" |
681 | 681 | name="give_email" |
682 | - placeholder="<?php esc_attr_e( 'Email Address', 'give' ); ?>" |
|
683 | - id="give-email" value="<?php echo isset( $give_user_info['give_email'] ) ? $give_user_info['give_email'] : ''; ?>" |
|
684 | - <?php echo( give_field_is_required( 'give_email', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
682 | + placeholder="<?php esc_attr_e('Email Address', 'give'); ?>" |
|
683 | + id="give-email" value="<?php echo isset($give_user_info['give_email']) ? $give_user_info['give_email'] : ''; ?>" |
|
684 | + <?php echo(give_field_is_required('give_email', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
685 | 685 | /> |
686 | 686 | |
687 | 687 | </p> |
@@ -691,14 +691,14 @@ discard block |
||
691 | 691 | * |
692 | 692 | * @since 1.7 |
693 | 693 | */ |
694 | - do_action( 'give_donation_form_after_email', $form_id ); |
|
694 | + do_action('give_donation_form_after_email', $form_id); |
|
695 | 695 | |
696 | 696 | /** |
697 | 697 | * Fire after personal email field |
698 | 698 | * |
699 | 699 | * @since 1.7 |
700 | 700 | */ |
701 | - do_action( 'give_donation_form_user_info', $form_id ); |
|
701 | + do_action('give_donation_form_user_info', $form_id); |
|
702 | 702 | ?> |
703 | 703 | </fieldset> |
704 | 704 | <?php |
@@ -707,11 +707,11 @@ discard block |
||
707 | 707 | * |
708 | 708 | * @since 1.7 |
709 | 709 | */ |
710 | - do_action( 'give_donation_form_after_personal_info', $form_id ); |
|
710 | + do_action('give_donation_form_after_personal_info', $form_id); |
|
711 | 711 | } |
712 | 712 | |
713 | -add_action( 'give_donation_form_after_user_info', 'give_user_info_fields' ); |
|
714 | -add_action( 'give_register_fields_before', 'give_user_info_fields' ); |
|
713 | +add_action('give_donation_form_after_user_info', 'give_user_info_fields'); |
|
714 | +add_action('give_register_fields_before', 'give_user_info_fields'); |
|
715 | 715 | |
716 | 716 | /** |
717 | 717 | * Renders the credit card info form. |
@@ -722,7 +722,7 @@ discard block |
||
722 | 722 | * |
723 | 723 | * @return void |
724 | 724 | */ |
725 | -function give_get_cc_form( $form_id ) { |
|
725 | +function give_get_cc_form($form_id) { |
|
726 | 726 | |
727 | 727 | ob_start(); |
728 | 728 | |
@@ -733,45 +733,45 @@ discard block |
||
733 | 733 | * |
734 | 734 | * @param int $form_id The form ID. |
735 | 735 | */ |
736 | - do_action( 'give_before_cc_fields', $form_id ); |
|
736 | + do_action('give_before_cc_fields', $form_id); |
|
737 | 737 | ?> |
738 | 738 | <fieldset id="give_cc_fields-<?php echo $form_id ?>" class="give-do-validate"> |
739 | - <legend><?php echo apply_filters( 'give_credit_card_fieldset_heading', esc_html__( 'Credit Card Info', 'give' ) ); ?></legend> |
|
740 | - <?php if ( is_ssl() ) : ?> |
|
739 | + <legend><?php echo apply_filters('give_credit_card_fieldset_heading', esc_html__('Credit Card Info', 'give')); ?></legend> |
|
740 | + <?php if (is_ssl()) : ?> |
|
741 | 741 | <div id="give_secure_site_wrapper-<?php echo $form_id ?>"> |
742 | 742 | <span class="give-icon padlock"></span> |
743 | - <span><?php esc_html_e( 'This is a secure SSL encrypted payment.', 'give' ); ?></span> |
|
743 | + <span><?php esc_html_e('This is a secure SSL encrypted payment.', 'give'); ?></span> |
|
744 | 744 | </div> |
745 | 745 | <?php endif; ?> |
746 | 746 | <p id="give-card-number-wrap-<?php echo $form_id ?>" class="form-row form-row-two-thirds"> |
747 | 747 | <label for="card_number-<?php echo $form_id ?>" class="give-label"> |
748 | - <?php esc_html_e( 'Card Number', 'give' ); ?> |
|
748 | + <?php esc_html_e('Card Number', 'give'); ?> |
|
749 | 749 | <span class="give-required-indicator">*</span> |
750 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'The (typically) 16 digits on the front of your credit card.', 'give' ); ?>"></span> |
|
750 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('The (typically) 16 digits on the front of your credit card.', 'give'); ?>"></span> |
|
751 | 751 | <span class="card-type"></span> |
752 | 752 | </label> |
753 | 753 | |
754 | - <input type="tel" autocomplete="off" name="card_number" id="card_number-<?php echo $form_id ?>" class="card-number give-input required" placeholder="<?php esc_attr_e( 'Card number', 'give' ); ?>" required aria-required="true" /> |
|
754 | + <input type="tel" autocomplete="off" name="card_number" id="card_number-<?php echo $form_id ?>" class="card-number give-input required" placeholder="<?php esc_attr_e('Card number', 'give'); ?>" required aria-required="true" /> |
|
755 | 755 | </p> |
756 | 756 | |
757 | 757 | <p id="give-card-cvc-wrap-<?php echo $form_id ?>" class="form-row form-row-one-third"> |
758 | 758 | <label for="card_cvc-<?php echo $form_id ?>" class="give-label"> |
759 | - <?php esc_html_e( 'CVC', 'give' ); ?> |
|
759 | + <?php esc_html_e('CVC', 'give'); ?> |
|
760 | 760 | <span class="give-required-indicator">*</span> |
761 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'The 3 digit (back) or 4 digit (front) value on your card.', 'give' ); ?>"></span> |
|
761 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('The 3 digit (back) or 4 digit (front) value on your card.', 'give'); ?>"></span> |
|
762 | 762 | </label> |
763 | 763 | |
764 | - <input type="tel" size="4" autocomplete="off" name="card_cvc" id="card_cvc-<?php echo $form_id ?>" class="card-cvc give-input required" placeholder="<?php esc_attr_e( 'Security code', 'give' ); ?>" required aria-required="true" /> |
|
764 | + <input type="tel" size="4" autocomplete="off" name="card_cvc" id="card_cvc-<?php echo $form_id ?>" class="card-cvc give-input required" placeholder="<?php esc_attr_e('Security code', 'give'); ?>" required aria-required="true" /> |
|
765 | 765 | </p> |
766 | 766 | |
767 | 767 | <p id="give-card-name-wrap-<?php echo $form_id ?>" class="form-row form-row-two-thirds"> |
768 | 768 | <label for="card_name-<?php echo $form_id ?>" class="give-label"> |
769 | - <?php esc_html_e( 'Name on the Card', 'give' ); ?> |
|
769 | + <?php esc_html_e('Name on the Card', 'give'); ?> |
|
770 | 770 | <span class="give-required-indicator">*</span> |
771 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'The name printed on the front of your credit card.', 'give' ); ?>"></span> |
|
771 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('The name printed on the front of your credit card.', 'give'); ?>"></span> |
|
772 | 772 | </label> |
773 | 773 | |
774 | - <input type="text" autocomplete="off" name="card_name" id="card_name-<?php echo $form_id ?>" class="card-name give-input required" placeholder="<?php esc_attr_e( 'Card name', 'give' ); ?>" required aria-required="true" /> |
|
774 | + <input type="text" autocomplete="off" name="card_name" id="card_name-<?php echo $form_id ?>" class="card-name give-input required" placeholder="<?php esc_attr_e('Card name', 'give'); ?>" required aria-required="true" /> |
|
775 | 775 | </p> |
776 | 776 | <?php |
777 | 777 | /** |
@@ -781,19 +781,19 @@ discard block |
||
781 | 781 | * |
782 | 782 | * @param int $form_id The form ID. |
783 | 783 | */ |
784 | - do_action( 'give_before_cc_expiration' ); |
|
784 | + do_action('give_before_cc_expiration'); |
|
785 | 785 | ?> |
786 | 786 | <p class="card-expiration form-row form-row-one-third"> |
787 | 787 | <label for="card_expiry-<?php echo $form_id ?>" class="give-label"> |
788 | - <?php esc_html_e( 'Expiration', 'give' ); ?> |
|
788 | + <?php esc_html_e('Expiration', 'give'); ?> |
|
789 | 789 | <span class="give-required-indicator">*</span> |
790 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'The date your credit card expires, typically on the front of the card.', 'give' ); ?>"></span> |
|
790 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('The date your credit card expires, typically on the front of the card.', 'give'); ?>"></span> |
|
791 | 791 | </label> |
792 | 792 | |
793 | 793 | <input type="hidden" id="card_exp_month-<?php echo $form_id ?>" name="card_exp_month" class="card-expiry-month"/> |
794 | 794 | <input type="hidden" id="card_exp_year-<?php echo $form_id ?>" name="card_exp_year" class="card-expiry-year"/> |
795 | 795 | |
796 | - <input type="tel" autocomplete="off" name="card_expiry" id="card_expiry-<?php echo $form_id ?>" class="card-expiry give-input required" placeholder="<?php esc_attr_e( 'MM / YY', 'give' ); ?>" required aria-required="true" /> |
|
796 | + <input type="tel" autocomplete="off" name="card_expiry" id="card_expiry-<?php echo $form_id ?>" class="card-expiry give-input required" placeholder="<?php esc_attr_e('MM / YY', 'give'); ?>" required aria-required="true" /> |
|
797 | 797 | </p> |
798 | 798 | <?php |
799 | 799 | /** |
@@ -803,7 +803,7 @@ discard block |
||
803 | 803 | * |
804 | 804 | * @param int $form_id The form ID. |
805 | 805 | */ |
806 | - do_action( 'give_after_cc_expiration', $form_id ); |
|
806 | + do_action('give_after_cc_expiration', $form_id); |
|
807 | 807 | ?> |
808 | 808 | </fieldset> |
809 | 809 | <?php |
@@ -814,12 +814,12 @@ discard block |
||
814 | 814 | * |
815 | 815 | * @param int $form_id The form ID. |
816 | 816 | */ |
817 | - do_action( 'give_after_cc_fields', $form_id ); |
|
817 | + do_action('give_after_cc_fields', $form_id); |
|
818 | 818 | |
819 | 819 | echo ob_get_clean(); |
820 | 820 | } |
821 | 821 | |
822 | -add_action( 'give_cc_form', 'give_get_cc_form' ); |
|
822 | +add_action('give_cc_form', 'give_get_cc_form'); |
|
823 | 823 | |
824 | 824 | /** |
825 | 825 | * Outputs the default credit card address fields. |
@@ -830,24 +830,24 @@ discard block |
||
830 | 830 | * |
831 | 831 | * @return void |
832 | 832 | */ |
833 | -function give_default_cc_address_fields( $form_id ) { |
|
833 | +function give_default_cc_address_fields($form_id) { |
|
834 | 834 | // Get user info. |
835 | - $give_user_info = _give_get_prefill_form_field_values( $form_id ); |
|
835 | + $give_user_info = _give_get_prefill_form_field_values($form_id); |
|
836 | 836 | |
837 | 837 | $logged_in = is_user_logged_in(); |
838 | 838 | |
839 | - if ( $logged_in ) { |
|
840 | - $user_address = get_user_meta( get_current_user_id(), '_give_user_address', true ); |
|
839 | + if ($logged_in) { |
|
840 | + $user_address = get_user_meta(get_current_user_id(), '_give_user_address', true); |
|
841 | 841 | } |
842 | - $line1 = $logged_in && ! empty( $user_address['line1'] ) ? $user_address['line1'] : ''; |
|
843 | - $line2 = $logged_in && ! empty( $user_address['line2'] ) ? $user_address['line2'] : ''; |
|
844 | - $city = $logged_in && ! empty( $user_address['city'] ) ? $user_address['city'] : ''; |
|
845 | - $zip = $logged_in && ! empty( $user_address['zip'] ) ? $user_address['zip'] : ''; |
|
842 | + $line1 = $logged_in && ! empty($user_address['line1']) ? $user_address['line1'] : ''; |
|
843 | + $line2 = $logged_in && ! empty($user_address['line2']) ? $user_address['line2'] : ''; |
|
844 | + $city = $logged_in && ! empty($user_address['city']) ? $user_address['city'] : ''; |
|
845 | + $zip = $logged_in && ! empty($user_address['zip']) ? $user_address['zip'] : ''; |
|
846 | 846 | |
847 | 847 | ob_start(); |
848 | 848 | ?> |
849 | 849 | <fieldset id="give_cc_address" class="cc-address"> |
850 | - <legend><?php echo apply_filters( 'give_billing_details_fieldset_heading', esc_html__( 'Billing Details', 'give' ) ); ?></legend> |
|
850 | + <legend><?php echo apply_filters('give_billing_details_fieldset_heading', esc_html__('Billing Details', 'give')); ?></legend> |
|
851 | 851 | <?php |
852 | 852 | /** |
853 | 853 | * Fires while rendering credit card billing form, before address fields. |
@@ -856,75 +856,75 @@ discard block |
||
856 | 856 | * |
857 | 857 | * @param int $form_id The form ID. |
858 | 858 | */ |
859 | - do_action( 'give_cc_billing_top' ); |
|
859 | + do_action('give_cc_billing_top'); |
|
860 | 860 | ?> |
861 | 861 | <p id="give-card-address-wrap" class="form-row form-row-two-thirds"> |
862 | 862 | <label for="card_address" class="give-label"> |
863 | - <?php esc_html_e( 'Address 1', 'give' ); ?> |
|
863 | + <?php esc_html_e('Address 1', 'give'); ?> |
|
864 | 864 | <?php |
865 | - if ( give_field_is_required( 'card_address', $form_id ) ) : ?> |
|
865 | + if (give_field_is_required('card_address', $form_id)) : ?> |
|
866 | 866 | <span class="give-required-indicator">*</span> |
867 | 867 | <?php endif; ?> |
868 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'The primary billing address for your credit card.', 'give' ); ?>"></span> |
|
868 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('The primary billing address for your credit card.', 'give'); ?>"></span> |
|
869 | 869 | </label> |
870 | 870 | |
871 | 871 | <input |
872 | 872 | type="text" |
873 | 873 | id="card_address" |
874 | 874 | name="card_address" |
875 | - class="card-address give-input<?php echo( give_field_is_required( 'card_address', $form_id ) ? ' required' : '' ); ?>" |
|
876 | - placeholder="<?php esc_attr_e( 'Address line 1', 'give' ); ?>" |
|
877 | - value="<?php echo isset( $give_user_info['card_address'] ) ? $give_user_info['card_address'] : ''; ?>" |
|
878 | - <?php echo( give_field_is_required( 'card_address', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
875 | + class="card-address give-input<?php echo(give_field_is_required('card_address', $form_id) ? ' required' : ''); ?>" |
|
876 | + placeholder="<?php esc_attr_e('Address line 1', 'give'); ?>" |
|
877 | + value="<?php echo isset($give_user_info['card_address']) ? $give_user_info['card_address'] : ''; ?>" |
|
878 | + <?php echo(give_field_is_required('card_address', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
879 | 879 | /> |
880 | 880 | </p> |
881 | 881 | |
882 | 882 | <p id="give-card-address-2-wrap" class="form-row form-row-one-third"> |
883 | 883 | <label for="card_address_2" class="give-label"> |
884 | - <?php esc_html_e( 'Address 2', 'give' ); ?> |
|
885 | - <?php if ( give_field_is_required( 'card_address_2', $form_id ) ) : ?> |
|
884 | + <?php esc_html_e('Address 2', 'give'); ?> |
|
885 | + <?php if (give_field_is_required('card_address_2', $form_id)) : ?> |
|
886 | 886 | <span class="give-required-indicator">*</span> |
887 | 887 | <?php endif; ?> |
888 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( '(optional) The suite, apt no, PO box, etc, associated with your billing address.', 'give' ); ?>"></span> |
|
888 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('(optional) The suite, apt no, PO box, etc, associated with your billing address.', 'give'); ?>"></span> |
|
889 | 889 | </label> |
890 | 890 | |
891 | 891 | <input |
892 | 892 | type="text" |
893 | 893 | id="card_address_2" |
894 | 894 | name="card_address_2" |
895 | - class="card-address-2 give-input<?php echo( give_field_is_required( 'card_address_2', $form_id ) ? ' required' : '' ); ?>" |
|
896 | - placeholder="<?php esc_attr_e( 'Address line 2', 'give' ); ?>" |
|
897 | - value="<?php echo isset( $give_user_info['card_address_2'] ) ? $give_user_info['card_address_2'] : ''; ?>" |
|
898 | - <?php echo( give_field_is_required( 'card_address_2', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
895 | + class="card-address-2 give-input<?php echo(give_field_is_required('card_address_2', $form_id) ? ' required' : ''); ?>" |
|
896 | + placeholder="<?php esc_attr_e('Address line 2', 'give'); ?>" |
|
897 | + value="<?php echo isset($give_user_info['card_address_2']) ? $give_user_info['card_address_2'] : ''; ?>" |
|
898 | + <?php echo(give_field_is_required('card_address_2', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
899 | 899 | /> |
900 | 900 | </p> |
901 | 901 | |
902 | 902 | <p id="give-card-city-wrap" class="form-row form-row-two-thirds"> |
903 | 903 | <label for="card_city" class="give-label"> |
904 | - <?php esc_html_e( 'City', 'give' ); ?> |
|
905 | - <?php if ( give_field_is_required( 'card_city', $form_id ) ) : ?> |
|
904 | + <?php esc_html_e('City', 'give'); ?> |
|
905 | + <?php if (give_field_is_required('card_city', $form_id)) : ?> |
|
906 | 906 | <span class="give-required-indicator">*</span> |
907 | 907 | <?php endif; ?> |
908 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'The city for your billing address.', 'give' ); ?>"></span> |
|
908 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('The city for your billing address.', 'give'); ?>"></span> |
|
909 | 909 | </label> |
910 | 910 | <input |
911 | 911 | type="text" |
912 | 912 | id="card_city" |
913 | 913 | name="card_city" |
914 | - class="card-city give-input<?php echo( give_field_is_required( 'card_city', $form_id ) ? ' required' : '' ); ?>" |
|
915 | - placeholder="<?php esc_attr_e( 'City', 'give' ); ?>" |
|
916 | - value="<?php echo isset( $give_user_info['card_city'] ) ? $give_user_info['card_city'] : ''; ?>" |
|
917 | - <?php echo( give_field_is_required( 'card_city', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
914 | + class="card-city give-input<?php echo(give_field_is_required('card_city', $form_id) ? ' required' : ''); ?>" |
|
915 | + placeholder="<?php esc_attr_e('City', 'give'); ?>" |
|
916 | + value="<?php echo isset($give_user_info['card_city']) ? $give_user_info['card_city'] : ''; ?>" |
|
917 | + <?php echo(give_field_is_required('card_city', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
918 | 918 | /> |
919 | 919 | </p> |
920 | 920 | |
921 | 921 | <p id="give-card-zip-wrap" class="form-row form-row-one-third"> |
922 | 922 | <label for="card_zip" class="give-label"> |
923 | - <?php esc_html_e( 'Zip / Postal Code', 'give' ); ?> |
|
924 | - <?php if ( give_field_is_required( 'card_zip', $form_id ) ) : ?> |
|
923 | + <?php esc_html_e('Zip / Postal Code', 'give'); ?> |
|
924 | + <?php if (give_field_is_required('card_zip', $form_id)) : ?> |
|
925 | 925 | <span class="give-required-indicator">*</span> |
926 | 926 | <?php endif; ?> |
927 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'The zip or postal code for your billing address.', 'give' ); ?>"></span> |
|
927 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('The zip or postal code for your billing address.', 'give'); ?>"></span> |
|
928 | 928 | </label> |
929 | 929 | |
930 | 930 | <input |
@@ -932,39 +932,39 @@ discard block |
||
932 | 932 | size="4" |
933 | 933 | id="card_zip" |
934 | 934 | name="card_zip" |
935 | - class="card-zip give-input<?php echo( give_field_is_required( 'card_zip', $form_id ) ? ' required' : '' ); ?>" |
|
936 | - placeholder="<?php esc_attr_e( 'Zip / Postal Code', 'give' ); ?>" |
|
937 | - value="<?php echo isset( $give_user_info['card_zip'] ) ? $give_user_info['card_zip'] : ''; ?>" |
|
938 | - <?php echo( give_field_is_required( 'card_zip', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
935 | + class="card-zip give-input<?php echo(give_field_is_required('card_zip', $form_id) ? ' required' : ''); ?>" |
|
936 | + placeholder="<?php esc_attr_e('Zip / Postal Code', 'give'); ?>" |
|
937 | + value="<?php echo isset($give_user_info['card_zip']) ? $give_user_info['card_zip'] : ''; ?>" |
|
938 | + <?php echo(give_field_is_required('card_zip', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
939 | 939 | /> |
940 | 940 | </p> |
941 | 941 | |
942 | 942 | <p id="give-card-country-wrap" class="form-row form-row-first"> |
943 | 943 | <label for="billing_country" class="give-label"> |
944 | - <?php esc_html_e( 'Country', 'give' ); ?> |
|
945 | - <?php if ( give_field_is_required( 'billing_country', $form_id ) ) : ?> |
|
944 | + <?php esc_html_e('Country', 'give'); ?> |
|
945 | + <?php if (give_field_is_required('billing_country', $form_id)) : ?> |
|
946 | 946 | <span class="give-required-indicator">*</span> |
947 | 947 | <?php endif; ?> |
948 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'The country for your billing address.', 'give' ); ?>"></span> |
|
948 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('The country for your billing address.', 'give'); ?>"></span> |
|
949 | 949 | </label> |
950 | 950 | |
951 | 951 | <select |
952 | 952 | name="billing_country" |
953 | 953 | id="billing_country" |
954 | - class="billing-country billing_country give-select<?php echo( give_field_is_required( 'billing_country', $form_id ) ? ' required' : '' ); ?>" |
|
955 | - <?php echo( give_field_is_required( 'billing_country', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
954 | + class="billing-country billing_country give-select<?php echo(give_field_is_required('billing_country', $form_id) ? ' required' : ''); ?>" |
|
955 | + <?php echo(give_field_is_required('billing_country', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
956 | 956 | > |
957 | 957 | <?php |
958 | 958 | |
959 | 959 | $selected_country = give_get_country(); |
960 | 960 | |
961 | - if ( ! empty( $give_user_info['billing_country'] ) && '*' !== $give_user_info['billing_country'] ) { |
|
961 | + if ( ! empty($give_user_info['billing_country']) && '*' !== $give_user_info['billing_country']) { |
|
962 | 962 | $selected_country = $give_user_info['billing_country']; |
963 | 963 | } |
964 | 964 | |
965 | 965 | $countries = give_get_country_list(); |
966 | - foreach ( $countries as $country_code => $country ) { |
|
967 | - echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>'; |
|
966 | + foreach ($countries as $country_code => $country) { |
|
967 | + echo '<option value="'.esc_attr($country_code).'"'.selected($country_code, $selected_country, false).'>'.$country.'</option>'; |
|
968 | 968 | } |
969 | 969 | ?> |
970 | 970 | </select> |
@@ -972,35 +972,35 @@ discard block |
||
972 | 972 | |
973 | 973 | <p id="give-card-state-wrap" class="form-row form-row-last"> |
974 | 974 | <label for="card_state" class="give-label"> |
975 | - <?php esc_html_e( 'State / Province', 'give' ); ?> |
|
976 | - <?php if ( give_field_is_required( 'card_state', $form_id ) ) : ?> |
|
975 | + <?php esc_html_e('State / Province', 'give'); ?> |
|
976 | + <?php if (give_field_is_required('card_state', $form_id)) : ?> |
|
977 | 977 | <span class="give-required-indicator">*</span> |
978 | 978 | <?php endif; ?> |
979 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'The state or province for your billing address.', 'give' ); ?>"></span> |
|
979 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('The state or province for your billing address.', 'give'); ?>"></span> |
|
980 | 980 | </label> |
981 | 981 | |
982 | 982 | <?php |
983 | 983 | $selected_state = give_get_state(); |
984 | - $states = give_get_states( $selected_country ); |
|
984 | + $states = give_get_states($selected_country); |
|
985 | 985 | |
986 | - if ( ! empty( $give_user_info['card_state'] ) ) { |
|
986 | + if ( ! empty($give_user_info['card_state'])) { |
|
987 | 987 | $selected_state = $give_user_info['card_state']; |
988 | 988 | } |
989 | 989 | |
990 | - if ( ! empty( $states ) ) : ?> |
|
990 | + if ( ! empty($states)) : ?> |
|
991 | 991 | <select |
992 | 992 | name="card_state" |
993 | 993 | id="card_state" |
994 | - class="card_state give-select<?php echo( give_field_is_required( 'card_state', $form_id ) ? ' required' : '' ); ?>" |
|
995 | - <?php echo( give_field_is_required( 'card_state', $form_id ) ? ' required aria-required="true" ' : '' ); ?>> |
|
994 | + class="card_state give-select<?php echo(give_field_is_required('card_state', $form_id) ? ' required' : ''); ?>" |
|
995 | + <?php echo(give_field_is_required('card_state', $form_id) ? ' required aria-required="true" ' : ''); ?>> |
|
996 | 996 | <?php |
997 | - foreach ( $states as $state_code => $state ) { |
|
998 | - echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>'; |
|
997 | + foreach ($states as $state_code => $state) { |
|
998 | + echo '<option value="'.$state_code.'"'.selected($state_code, $selected_state, false).'>'.$state.'</option>'; |
|
999 | 999 | } |
1000 | 1000 | ?> |
1001 | 1001 | </select> |
1002 | 1002 | <?php else : ?> |
1003 | - <input type="text" size="6" name="card_state" id="card_state" class="card_state give-input" placeholder="<?php esc_attr_e( 'State / Province', 'give' ); ?>"/> |
|
1003 | + <input type="text" size="6" name="card_state" id="card_state" class="card_state give-input" placeholder="<?php esc_attr_e('State / Province', 'give'); ?>"/> |
|
1004 | 1004 | <?php endif; ?> |
1005 | 1005 | </p> |
1006 | 1006 | <?php |
@@ -1011,14 +1011,14 @@ discard block |
||
1011 | 1011 | * |
1012 | 1012 | * @param int $form_id The form ID. |
1013 | 1013 | */ |
1014 | - do_action( 'give_cc_billing_bottom' ); |
|
1014 | + do_action('give_cc_billing_bottom'); |
|
1015 | 1015 | ?> |
1016 | 1016 | </fieldset> |
1017 | 1017 | <?php |
1018 | 1018 | echo ob_get_clean(); |
1019 | 1019 | } |
1020 | 1020 | |
1021 | -add_action( 'give_after_cc_fields', 'give_default_cc_address_fields' ); |
|
1021 | +add_action('give_after_cc_fields', 'give_default_cc_address_fields'); |
|
1022 | 1022 | |
1023 | 1023 | |
1024 | 1024 | /** |
@@ -1030,26 +1030,26 @@ discard block |
||
1030 | 1030 | * |
1031 | 1031 | * @return string |
1032 | 1032 | */ |
1033 | -function give_get_register_fields( $form_id ) { |
|
1033 | +function give_get_register_fields($form_id) { |
|
1034 | 1034 | |
1035 | 1035 | global $user_ID; |
1036 | 1036 | |
1037 | - if ( is_user_logged_in() ) { |
|
1038 | - $user_data = get_userdata( $user_ID ); |
|
1037 | + if (is_user_logged_in()) { |
|
1038 | + $user_data = get_userdata($user_ID); |
|
1039 | 1039 | } |
1040 | 1040 | |
1041 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
1041 | + $show_register_form = give_show_login_register_option($form_id); |
|
1042 | 1042 | |
1043 | 1043 | ob_start(); ?> |
1044 | 1044 | <fieldset id="give-register-fields-<?php echo $form_id; ?>"> |
1045 | 1045 | |
1046 | - <?php if ( $show_register_form == 'both' ) { ?> |
|
1046 | + <?php if ($show_register_form == 'both') { ?> |
|
1047 | 1047 | <div class="give-login-account-wrap"> |
1048 | - <p class="give-login-message"><?php esc_html_e( 'Already have an account?', 'give' ); ?> |
|
1049 | - <a href="<?php echo esc_url( add_query_arg( 'login', 1 ) ); ?>" class="give-checkout-login" data-action="give_checkout_login"><?php esc_html_e( 'Login', 'give' ); ?></a> |
|
1048 | + <p class="give-login-message"><?php esc_html_e('Already have an account?', 'give'); ?> |
|
1049 | + <a href="<?php echo esc_url(add_query_arg('login', 1)); ?>" class="give-checkout-login" data-action="give_checkout_login"><?php esc_html_e('Login', 'give'); ?></a> |
|
1050 | 1050 | </p> |
1051 | 1051 | <p class="give-loading-text"> |
1052 | - <span class="give-loading-animation"></span> <?php esc_html_e( 'Loading...', 'give' ); ?></p> |
|
1052 | + <span class="give-loading-animation"></span> <?php esc_html_e('Loading...', 'give'); ?></p> |
|
1053 | 1053 | </div> |
1054 | 1054 | <?php } ?> |
1055 | 1055 | |
@@ -1061,15 +1061,15 @@ discard block |
||
1061 | 1061 | * |
1062 | 1062 | * @param int $form_id The form ID. |
1063 | 1063 | */ |
1064 | - do_action( 'give_register_fields_before', $form_id ); |
|
1064 | + do_action('give_register_fields_before', $form_id); |
|
1065 | 1065 | ?> |
1066 | 1066 | |
1067 | 1067 | <fieldset id="give-register-account-fields-<?php echo $form_id; ?>"> |
1068 | 1068 | <legend> |
1069 | 1069 | <?php |
1070 | - echo apply_filters( 'give_create_account_fieldset_heading', esc_html__( 'Create an account', 'give' ) ); |
|
1071 | - if ( ! give_logged_in_only( $form_id ) ) { |
|
1072 | - echo ' <span class="sub-text">' . esc_html__( '(optional)', 'give' ) . '</span>'; |
|
1070 | + echo apply_filters('give_create_account_fieldset_heading', esc_html__('Create an account', 'give')); |
|
1071 | + if ( ! give_logged_in_only($form_id)) { |
|
1072 | + echo ' <span class="sub-text">'.esc_html__('(optional)', 'give').'</span>'; |
|
1073 | 1073 | } |
1074 | 1074 | ?> |
1075 | 1075 | </legend> |
@@ -1081,42 +1081,42 @@ discard block |
||
1081 | 1081 | * |
1082 | 1082 | * @param int $form_id The form ID. |
1083 | 1083 | */ |
1084 | - do_action( 'give_register_account_fields_before', $form_id ); |
|
1084 | + do_action('give_register_account_fields_before', $form_id); |
|
1085 | 1085 | ?> |
1086 | 1086 | <div id="give-user-login-wrap-<?php echo $form_id; ?>" class="form-row form-row-one-third form-row-first"> |
1087 | 1087 | <label for="give-user-login-<?php echo $form_id; ?>"> |
1088 | - <?php esc_html_e( 'Username', 'give' ); ?> |
|
1089 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
1088 | + <?php esc_html_e('Username', 'give'); ?> |
|
1089 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
1090 | 1090 | <span class="give-required-indicator">*</span> |
1091 | 1091 | <?php } ?> |
1092 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'The username you will use to log into your account.', 'give' ); ?>"></span> |
|
1092 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('The username you will use to log into your account.', 'give'); ?>"></span> |
|
1093 | 1093 | </label> |
1094 | 1094 | |
1095 | - <input name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" class="give-input" type="text" placeholder="<?php esc_attr_e( 'Username', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
1095 | + <input name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" class="give-input" type="text" placeholder="<?php esc_attr_e('Username', 'give'); ?>"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
1096 | 1096 | </div> |
1097 | 1097 | |
1098 | 1098 | <div id="give-user-pass-wrap-<?php echo $form_id; ?>" class="form-row form-row-one-third"> |
1099 | 1099 | <label for="give-user-pass-<?php echo $form_id; ?>"> |
1100 | - <?php esc_html_e( 'Password', 'give' ); ?> |
|
1101 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
1100 | + <?php esc_html_e('Password', 'give'); ?> |
|
1101 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
1102 | 1102 | <span class="give-required-indicator">*</span> |
1103 | 1103 | <?php } ?> |
1104 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'The password used to access your account.', 'give' ); ?>"></span> |
|
1104 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('The password used to access your account.', 'give'); ?>"></span> |
|
1105 | 1105 | </label> |
1106 | 1106 | |
1107 | - <input name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" class="give-input" placeholder="<?php esc_attr_e( 'Password', 'give' ); ?>" type="password"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
1107 | + <input name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" class="give-input" placeholder="<?php esc_attr_e('Password', 'give'); ?>" type="password"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
1108 | 1108 | </div> |
1109 | 1109 | |
1110 | 1110 | <div id="give-user-pass-confirm-wrap-<?php echo $form_id; ?>" class="give-register-password form-row form-row-one-third"> |
1111 | 1111 | <label for="give-user-pass-confirm-<?php echo $form_id; ?>"> |
1112 | - <?php esc_html_e( 'Confirm PW', 'give' ); ?> |
|
1113 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
1112 | + <?php esc_html_e('Confirm PW', 'give'); ?> |
|
1113 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
1114 | 1114 | <span class="give-required-indicator">*</span> |
1115 | 1115 | <?php } ?> |
1116 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'Please retype your password to confirm.', 'give' ); ?>"></span> |
|
1116 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('Please retype your password to confirm.', 'give'); ?>"></span> |
|
1117 | 1117 | </label> |
1118 | 1118 | |
1119 | - <input name="give_user_pass_confirm" id="give-user-pass-confirm-<?php echo $form_id; ?>" class="give-input" placeholder="<?php esc_attr_e( 'Confirm password', 'give' ); ?>" type="password"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
1119 | + <input name="give_user_pass_confirm" id="give-user-pass-confirm-<?php echo $form_id; ?>" class="give-input" placeholder="<?php esc_attr_e('Confirm password', 'give'); ?>" type="password"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
1120 | 1120 | </div> |
1121 | 1121 | <?php |
1122 | 1122 | /** |
@@ -1126,7 +1126,7 @@ discard block |
||
1126 | 1126 | * |
1127 | 1127 | * @param int $form_id The form ID. |
1128 | 1128 | */ |
1129 | - do_action( 'give_register_account_fields_after', $form_id ); |
|
1129 | + do_action('give_register_account_fields_after', $form_id); |
|
1130 | 1130 | ?> |
1131 | 1131 | </fieldset> |
1132 | 1132 | |
@@ -1138,7 +1138,7 @@ discard block |
||
1138 | 1138 | * |
1139 | 1139 | * @param int $form_id The form ID. |
1140 | 1140 | */ |
1141 | - do_action( 'give_register_fields_after', $form_id ); |
|
1141 | + do_action('give_register_fields_after', $form_id); |
|
1142 | 1142 | ?> |
1143 | 1143 | |
1144 | 1144 | <input type="hidden" name="give-purchase-var" value="needs-to-register"/> |
@@ -1149,7 +1149,7 @@ discard block |
||
1149 | 1149 | * |
1150 | 1150 | * @since 1.7 |
1151 | 1151 | */ |
1152 | - do_action( 'give_donation_form_user_info', $form_id ); |
|
1152 | + do_action('give_donation_form_user_info', $form_id); |
|
1153 | 1153 | ?> |
1154 | 1154 | |
1155 | 1155 | </fieldset> |
@@ -1157,7 +1157,7 @@ discard block |
||
1157 | 1157 | echo ob_get_clean(); |
1158 | 1158 | } |
1159 | 1159 | |
1160 | -add_action( 'give_donation_form_register_fields', 'give_get_register_fields' ); |
|
1160 | +add_action('give_donation_form_register_fields', 'give_get_register_fields'); |
|
1161 | 1161 | |
1162 | 1162 | /** |
1163 | 1163 | * Gets the login fields for the login form on the checkout. This function hooks |
@@ -1170,31 +1170,31 @@ discard block |
||
1170 | 1170 | * |
1171 | 1171 | * @return string |
1172 | 1172 | */ |
1173 | -function give_get_login_fields( $form_id ) { |
|
1173 | +function give_get_login_fields($form_id) { |
|
1174 | 1174 | |
1175 | - $form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : $form_id; |
|
1176 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
1175 | + $form_id = isset($_POST['form_id']) ? $_POST['form_id'] : $form_id; |
|
1176 | + $show_register_form = give_show_login_register_option($form_id); |
|
1177 | 1177 | |
1178 | 1178 | ob_start(); |
1179 | 1179 | ?> |
1180 | 1180 | <fieldset id="give-login-fields-<?php echo $form_id; ?>"> |
1181 | - <legend><?php echo apply_filters( 'give_account_login_fieldset_heading', esc_html__( 'Login to Your Account', 'give' ) ); |
|
1182 | - if ( ! give_logged_in_only( $form_id ) ) { |
|
1183 | - echo ' <span class="sub-text">' . esc_html__( '(optional)', 'give' ) . '</span>'; |
|
1181 | + <legend><?php echo apply_filters('give_account_login_fieldset_heading', esc_html__('Login to Your Account', 'give')); |
|
1182 | + if ( ! give_logged_in_only($form_id)) { |
|
1183 | + echo ' <span class="sub-text">'.esc_html__('(optional)', 'give').'</span>'; |
|
1184 | 1184 | } ?> |
1185 | 1185 | </legend> |
1186 | - <?php if ( $show_register_form == 'both' ) { ?> |
|
1186 | + <?php if ($show_register_form == 'both') { ?> |
|
1187 | 1187 | <p class="give-new-account-link"> |
1188 | - <?php esc_html_e( 'Need to create an account?', 'give' ); ?> |
|
1189 | - <a href="<?php echo remove_query_arg( 'login' ); ?>" class="give-checkout-register-cancel" data-action="give_checkout_register"> |
|
1190 | - <?php esc_html_e( 'Register', 'give' ); |
|
1191 | - if ( ! give_logged_in_only( $form_id ) ) { |
|
1192 | - echo ' ' . esc_html__( 'or checkout as a guest »', 'give' ); |
|
1188 | + <?php esc_html_e('Need to create an account?', 'give'); ?> |
|
1189 | + <a href="<?php echo remove_query_arg('login'); ?>" class="give-checkout-register-cancel" data-action="give_checkout_register"> |
|
1190 | + <?php esc_html_e('Register', 'give'); |
|
1191 | + if ( ! give_logged_in_only($form_id)) { |
|
1192 | + echo ' '.esc_html__('or checkout as a guest »', 'give'); |
|
1193 | 1193 | } ?> |
1194 | 1194 | </a> |
1195 | 1195 | </p> |
1196 | 1196 | <p class="give-loading-text"> |
1197 | - <span class="give-loading-animation"></span> <?php esc_html_e( 'Loading...', 'give' ); ?> </p> |
|
1197 | + <span class="give-loading-animation"></span> <?php esc_html_e('Loading...', 'give'); ?> </p> |
|
1198 | 1198 | <?php } ?> |
1199 | 1199 | <?php |
1200 | 1200 | /** |
@@ -1204,40 +1204,40 @@ discard block |
||
1204 | 1204 | * |
1205 | 1205 | * @param int $form_id The form ID. |
1206 | 1206 | */ |
1207 | - do_action( 'give_checkout_login_fields_before', $form_id ); |
|
1207 | + do_action('give_checkout_login_fields_before', $form_id); |
|
1208 | 1208 | ?> |
1209 | 1209 | <div id="give-user-login-wrap-<?php echo $form_id; ?>" class="form-row form-row-first"> |
1210 | 1210 | <label class="give-label" for="give-user-login-<?php echo $form_id; ?>"> |
1211 | - <?php esc_html_e( 'Username', 'give' ); ?> |
|
1212 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
1211 | + <?php esc_html_e('Username', 'give'); ?> |
|
1212 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
1213 | 1213 | <span class="give-required-indicator">*</span> |
1214 | 1214 | <?php } ?> |
1215 | 1215 | </label> |
1216 | 1216 | |
1217 | - <input class="give-input<?php echo ( give_logged_in_only( $form_id ) ) ? ' required' : ''; ?>" type="text" name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" value="" placeholder="<?php esc_attr_e( 'Your username', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
1217 | + <input class="give-input<?php echo (give_logged_in_only($form_id)) ? ' required' : ''; ?>" type="text" name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" value="" placeholder="<?php esc_attr_e('Your username', 'give'); ?>"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
1218 | 1218 | </div> |
1219 | 1219 | |
1220 | 1220 | <div id="give-user-pass-wrap-<?php echo $form_id; ?>" class="give_login_password form-row form-row-last"> |
1221 | 1221 | <label class="give-label" for="give-user-pass-<?php echo $form_id; ?>"> |
1222 | - <?php esc_html_e( 'Password', 'give' ); ?> |
|
1223 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
1222 | + <?php esc_html_e('Password', 'give'); ?> |
|
1223 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
1224 | 1224 | <span class="give-required-indicator">*</span> |
1225 | 1225 | <?php } ?> |
1226 | 1226 | </label> |
1227 | - <input class="give-input<?php echo ( give_logged_in_only( $form_id ) ) ? ' required' : ''; ?>" type="password" name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" placeholder="<?php esc_attr_e( 'Your password', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
1227 | + <input class="give-input<?php echo (give_logged_in_only($form_id)) ? ' required' : ''; ?>" type="password" name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" placeholder="<?php esc_attr_e('Your password', 'give'); ?>"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
1228 | 1228 | <input type="hidden" name="give-purchase-var" value="needs-to-login"/> |
1229 | 1229 | </div> |
1230 | 1230 | |
1231 | 1231 | <div id="give-forgot-password-wrap-<?php echo $form_id; ?>" class="give_login_forgot_password"> |
1232 | 1232 | <span class="give-forgot-password "> |
1233 | - <a href="<?php echo wp_lostpassword_url() ?>" target="_blank"><?php esc_html_e( 'Reset Password', 'give' ) ?></a> |
|
1233 | + <a href="<?php echo wp_lostpassword_url() ?>" target="_blank"><?php esc_html_e('Reset Password', 'give') ?></a> |
|
1234 | 1234 | </span> |
1235 | 1235 | </div> |
1236 | 1236 | |
1237 | 1237 | <div id="give-user-login-submit-<?php echo $form_id; ?>" class="give-clearfix"> |
1238 | - <input type="submit" class="give-submit give-btn button" name="give_login_submit" value="<?php esc_attr_e( 'Login', 'give' ); ?>"/> |
|
1239 | - <?php if ( $show_register_form !== 'login' ) { ?> |
|
1240 | - <input type="button" data-action="give_cancel_login" class="give-cancel-login give-checkout-register-cancel give-btn button" name="give_login_cancel" value="<?php esc_attr_e( 'Cancel', 'give' ); ?>"/> |
|
1238 | + <input type="submit" class="give-submit give-btn button" name="give_login_submit" value="<?php esc_attr_e('Login', 'give'); ?>"/> |
|
1239 | + <?php if ($show_register_form !== 'login') { ?> |
|
1240 | + <input type="button" data-action="give_cancel_login" class="give-cancel-login give-checkout-register-cancel give-btn button" name="give_login_cancel" value="<?php esc_attr_e('Cancel', 'give'); ?>"/> |
|
1241 | 1241 | <?php } ?> |
1242 | 1242 | <span class="give-loading-animation"></span> |
1243 | 1243 | </div> |
@@ -1249,14 +1249,14 @@ discard block |
||
1249 | 1249 | * |
1250 | 1250 | * @param int $form_id The form ID. |
1251 | 1251 | */ |
1252 | - do_action( 'give_checkout_login_fields_after', $form_id ); |
|
1252 | + do_action('give_checkout_login_fields_after', $form_id); |
|
1253 | 1253 | ?> |
1254 | 1254 | </fieldset><!--end #give-login-fields--> |
1255 | 1255 | <?php |
1256 | 1256 | echo ob_get_clean(); |
1257 | 1257 | } |
1258 | 1258 | |
1259 | -add_action( 'give_donation_form_login_fields', 'give_get_login_fields', 10, 1 ); |
|
1259 | +add_action('give_donation_form_login_fields', 'give_get_login_fields', 10, 1); |
|
1260 | 1260 | |
1261 | 1261 | /** |
1262 | 1262 | * Payment Mode Select. |
@@ -1272,9 +1272,9 @@ discard block |
||
1272 | 1272 | * |
1273 | 1273 | * @return void |
1274 | 1274 | */ |
1275 | -function give_payment_mode_select( $form_id ) { |
|
1275 | +function give_payment_mode_select($form_id) { |
|
1276 | 1276 | |
1277 | - $gateways = give_get_enabled_payment_gateways( $form_id ); |
|
1277 | + $gateways = give_get_enabled_payment_gateways($form_id); |
|
1278 | 1278 | |
1279 | 1279 | /** |
1280 | 1280 | * Fires while selecting payment gateways, before the fields. |
@@ -1283,10 +1283,10 @@ discard block |
||
1283 | 1283 | * |
1284 | 1284 | * @param int $form_id The form ID. |
1285 | 1285 | */ |
1286 | - do_action( 'give_payment_mode_top', $form_id ); |
|
1286 | + do_action('give_payment_mode_top', $form_id); |
|
1287 | 1287 | ?> |
1288 | 1288 | |
1289 | - <fieldset id="give-payment-mode-select" <?php if ( count($gateways) <= 1 ) echo 'style="display: none;"'; ?>> |
|
1289 | + <fieldset id="give-payment-mode-select" <?php if (count($gateways) <= 1) echo 'style="display: none;"'; ?>> |
|
1290 | 1290 | <?php |
1291 | 1291 | /** |
1292 | 1292 | * Fires while selecting payment gateways, before the wrap div. |
@@ -1295,12 +1295,12 @@ discard block |
||
1295 | 1295 | * |
1296 | 1296 | * @param int $form_id The form ID. |
1297 | 1297 | */ |
1298 | - do_action( 'give_payment_mode_before_gateways_wrap' ); |
|
1298 | + do_action('give_payment_mode_before_gateways_wrap'); |
|
1299 | 1299 | ?> |
1300 | - <legend class="give-payment-mode-label"><?php echo apply_filters( 'give_checkout_payment_method_text', esc_html__( 'Select Payment Method', 'give' ) ); ?></legend> |
|
1300 | + <legend class="give-payment-mode-label"><?php echo apply_filters('give_checkout_payment_method_text', esc_html__('Select Payment Method', 'give')); ?></legend> |
|
1301 | 1301 | |
1302 | 1302 | <div id="give-payment-mode-wrap"> |
1303 | - <span class="give-loading-text"><span class="give-loading-animation"></span> <?php esc_html_e( 'Loading...', 'give' ); ?></span> |
|
1303 | + <span class="give-loading-text"><span class="give-loading-animation"></span> <?php esc_html_e('Loading...', 'give'); ?></span> |
|
1304 | 1304 | |
1305 | 1305 | <?php |
1306 | 1306 | /** |
@@ -1308,19 +1308,19 @@ discard block |
||
1308 | 1308 | * |
1309 | 1309 | * @since 1.7 |
1310 | 1310 | */ |
1311 | - do_action( 'give_payment_mode_before_gateways' ) |
|
1311 | + do_action('give_payment_mode_before_gateways') |
|
1312 | 1312 | ?> |
1313 | 1313 | <ul id="give-gateway-radio-list"> |
1314 | 1314 | <?php |
1315 | - foreach ( $gateways as $gateway_id => $gateway ) : |
|
1316 | - $selected_gateway = give_get_default_gateway( $form_id ); |
|
1317 | - $selected_gateway = isset( $_REQUEST['payment_mode'] ) ? $_REQUEST['payment_mode'] : $selected_gateway; |
|
1318 | - $checked = checked( $gateway_id, $selected_gateway, false ); |
|
1315 | + foreach ($gateways as $gateway_id => $gateway) : |
|
1316 | + $selected_gateway = give_get_default_gateway($form_id); |
|
1317 | + $selected_gateway = isset($_REQUEST['payment_mode']) ? $_REQUEST['payment_mode'] : $selected_gateway; |
|
1318 | + $checked = checked($gateway_id, $selected_gateway, false); |
|
1319 | 1319 | $checked_class = $checked ? ' give-gateway-option-selected' : ''; |
1320 | 1320 | ?> |
1321 | 1321 | <li> |
1322 | - <input type="radio" name="payment-mode" class="give-gateway" id="give-gateway-<?php echo esc_attr( $gateway_id ) . '-' . $form_id; ?>" value="<?php echo esc_attr( $gateway_id ); ?>"<?php echo $checked; ?>> |
|
1323 | - <label for="give-gateway-<?php echo esc_attr( $gateway_id ) . '-' . $form_id; ?>" class="give-gateway-option<?php echo $checked_class; ?>" id="give-gateway-option-<?php echo esc_attr( $gateway_id ); ?>"> <?php echo esc_html( $gateway['checkout_label'] ); ?></label> |
|
1322 | + <input type="radio" name="payment-mode" class="give-gateway" id="give-gateway-<?php echo esc_attr($gateway_id).'-'.$form_id; ?>" value="<?php echo esc_attr($gateway_id); ?>"<?php echo $checked; ?>> |
|
1323 | + <label for="give-gateway-<?php echo esc_attr($gateway_id).'-'.$form_id; ?>" class="give-gateway-option<?php echo $checked_class; ?>" id="give-gateway-option-<?php echo esc_attr($gateway_id); ?>"> <?php echo esc_html($gateway['checkout_label']); ?></label> |
|
1324 | 1324 | </li> |
1325 | 1325 | <?php |
1326 | 1326 | endforeach; |
@@ -1332,7 +1332,7 @@ discard block |
||
1332 | 1332 | * |
1333 | 1333 | * @since 1.7 |
1334 | 1334 | */ |
1335 | - do_action( 'give_payment_mode_after_gateways' ); |
|
1335 | + do_action('give_payment_mode_after_gateways'); |
|
1336 | 1336 | ?> |
1337 | 1337 | </div> |
1338 | 1338 | <?php |
@@ -1343,7 +1343,7 @@ discard block |
||
1343 | 1343 | * |
1344 | 1344 | * @param int $form_id The form ID. |
1345 | 1345 | */ |
1346 | - do_action( 'give_payment_mode_after_gateways_wrap' ); |
|
1346 | + do_action('give_payment_mode_after_gateways_wrap'); |
|
1347 | 1347 | ?> |
1348 | 1348 | </fieldset> |
1349 | 1349 | |
@@ -1355,7 +1355,7 @@ discard block |
||
1355 | 1355 | * |
1356 | 1356 | * @param int $form_id The form ID. |
1357 | 1357 | */ |
1358 | - do_action( 'give_payment_mode_bottom', $form_id ); |
|
1358 | + do_action('give_payment_mode_bottom', $form_id); |
|
1359 | 1359 | ?> |
1360 | 1360 | |
1361 | 1361 | <div id="give_purchase_form_wrap"> |
@@ -1366,7 +1366,7 @@ discard block |
||
1366 | 1366 | * |
1367 | 1367 | * @since 1.7 |
1368 | 1368 | */ |
1369 | - do_action( 'give_donation_form', $form_id ); |
|
1369 | + do_action('give_donation_form', $form_id); |
|
1370 | 1370 | ?> |
1371 | 1371 | |
1372 | 1372 | </div> |
@@ -1377,10 +1377,10 @@ discard block |
||
1377 | 1377 | * |
1378 | 1378 | * @since 1.7 |
1379 | 1379 | */ |
1380 | - do_action( 'give_donation_form_wrap_bottom', $form_id ); |
|
1380 | + do_action('give_donation_form_wrap_bottom', $form_id); |
|
1381 | 1381 | } |
1382 | 1382 | |
1383 | -add_action( 'give_payment_mode_select', 'give_payment_mode_select' ); |
|
1383 | +add_action('give_payment_mode_select', 'give_payment_mode_select'); |
|
1384 | 1384 | |
1385 | 1385 | /** |
1386 | 1386 | * Renders the Checkout Agree to Terms, this displays a checkbox for users to |
@@ -1393,25 +1393,25 @@ discard block |
||
1393 | 1393 | * |
1394 | 1394 | * @return void|bool |
1395 | 1395 | */ |
1396 | -function give_terms_agreement( $form_id ) { |
|
1397 | - $form_option = get_post_meta( $form_id, '_give_terms_option', true ); |
|
1396 | +function give_terms_agreement($form_id) { |
|
1397 | + $form_option = get_post_meta($form_id, '_give_terms_option', true); |
|
1398 | 1398 | |
1399 | 1399 | // Bailout if per form and global term and conditions is not setup. |
1400 | - if ( 'yes' !== $form_option ) { |
|
1400 | + if ('yes' !== $form_option) { |
|
1401 | 1401 | return false; |
1402 | 1402 | } |
1403 | 1403 | |
1404 | - $label = get_post_meta( $form_id, '_give_agree_label', true ); |
|
1405 | - $terms = get_post_meta( $form_id, '_give_agree_text', true ); |
|
1404 | + $label = get_post_meta($form_id, '_give_agree_label', true); |
|
1405 | + $terms = get_post_meta($form_id, '_give_agree_text', true); |
|
1406 | 1406 | |
1407 | 1407 | // Set term and conditions label and text on basis of per form and global setting. |
1408 | 1408 | // $label = ( $label = get_post_meta( $form_id, '_give_agree_label', true ) ) ? stripslashes( $label ) : give_get_option( 'agree_to_terms_label', esc_html__( 'Agree to Terms?', 'give' ) ); |
1409 | 1409 | // $terms = ( $terms = get_post_meta( $form_id, '_give_agree_text', true ) ) ? $terms : give_get_option( 'agreement_text', '' ); |
1410 | 1410 | |
1411 | 1411 | // Bailout: Check if term and conditions text is empty or not. |
1412 | - if ( empty( $terms ) ) { |
|
1413 | - if ( is_user_logged_in() && current_user_can( 'manage_options' ) ) { |
|
1414 | - echo sprintf( __( 'Please enter term and conditions in <a href="%s">this form\'s settings</a>.', 'give' ), admin_url( 'post.php?post=' . $form_id . '&action=edit' ) ); |
|
1412 | + if (empty($terms)) { |
|
1413 | + if (is_user_logged_in() && current_user_can('manage_options')) { |
|
1414 | + echo sprintf(__('Please enter term and conditions in <a href="%s">this form\'s settings</a>.', 'give'), admin_url('post.php?post='.$form_id.'&action=edit')); |
|
1415 | 1415 | } |
1416 | 1416 | |
1417 | 1417 | return false; |
@@ -1419,7 +1419,7 @@ discard block |
||
1419 | 1419 | |
1420 | 1420 | ?> |
1421 | 1421 | <fieldset id="give_terms_agreement"> |
1422 | - <legend><?php echo apply_filters( 'give_terms_agreement_text', esc_html__( 'Terms', 'give' ) ); ?></legend> |
|
1422 | + <legend><?php echo apply_filters('give_terms_agreement_text', esc_html__('Terms', 'give')); ?></legend> |
|
1423 | 1423 | <div id="give_terms" class="give_terms-<?php echo $form_id; ?>" style="display:none;"> |
1424 | 1424 | <?php |
1425 | 1425 | /** |
@@ -1427,20 +1427,20 @@ discard block |
||
1427 | 1427 | * |
1428 | 1428 | * @since 1.0 |
1429 | 1429 | */ |
1430 | - do_action( 'give_before_terms' ); |
|
1430 | + do_action('give_before_terms'); |
|
1431 | 1431 | |
1432 | - echo wpautop( stripslashes( $terms ) ); |
|
1432 | + echo wpautop(stripslashes($terms)); |
|
1433 | 1433 | /** |
1434 | 1434 | * Fires while rendering terms of agreement, after the fields. |
1435 | 1435 | * |
1436 | 1436 | * @since 1.0 |
1437 | 1437 | */ |
1438 | - do_action( 'give_after_terms' ); |
|
1438 | + do_action('give_after_terms'); |
|
1439 | 1439 | ?> |
1440 | 1440 | </div> |
1441 | 1441 | <div id="give_show_terms"> |
1442 | - <a href="#" class="give_terms_links give_terms_links-<?php echo $form_id; ?>" role="button" aria-controls="give_terms"><?php esc_html_e( 'Show Terms', 'give' ); ?></a> |
|
1443 | - <a href="#" class="give_terms_links give_terms_links-<?php echo $form_id; ?>" role="button" aria-controls="give_terms" style="display:none;"><?php esc_html_e( 'Hide Terms', 'give' ); ?></a> |
|
1442 | + <a href="#" class="give_terms_links give_terms_links-<?php echo $form_id; ?>" role="button" aria-controls="give_terms"><?php esc_html_e('Show Terms', 'give'); ?></a> |
|
1443 | + <a href="#" class="give_terms_links give_terms_links-<?php echo $form_id; ?>" role="button" aria-controls="give_terms" style="display:none;"><?php esc_html_e('Hide Terms', 'give'); ?></a> |
|
1444 | 1444 | </div> |
1445 | 1445 | |
1446 | 1446 | <input name="give_agree_to_terms" class="required" type="checkbox" id="give_agree_to_terms" value="1"/> |
@@ -1450,7 +1450,7 @@ discard block |
||
1450 | 1450 | <?php |
1451 | 1451 | } |
1452 | 1452 | |
1453 | -add_action( 'give_donation_form_after_cc_form', 'give_terms_agreement', 8888, 1 ); |
|
1453 | +add_action('give_donation_form_after_cc_form', 'give_terms_agreement', 8888, 1); |
|
1454 | 1454 | |
1455 | 1455 | /** |
1456 | 1456 | * Checkout Final Total. |
@@ -1463,27 +1463,27 @@ discard block |
||
1463 | 1463 | * |
1464 | 1464 | * @return void |
1465 | 1465 | */ |
1466 | -function give_checkout_final_total( $form_id ) { |
|
1466 | +function give_checkout_final_total($form_id) { |
|
1467 | 1467 | |
1468 | - if ( isset( $_POST['give_total'] ) ) { |
|
1469 | - $total = apply_filters( 'give_donation_total', $_POST['give_total'] ); |
|
1468 | + if (isset($_POST['give_total'])) { |
|
1469 | + $total = apply_filters('give_donation_total', $_POST['give_total']); |
|
1470 | 1470 | } else { |
1471 | 1471 | //default total. |
1472 | - $total = give_get_default_form_amount( $form_id ); |
|
1472 | + $total = give_get_default_form_amount($form_id); |
|
1473 | 1473 | } |
1474 | 1474 | //Only proceed if give_total available. |
1475 | - if ( empty( $total ) ) { |
|
1475 | + if (empty($total)) { |
|
1476 | 1476 | return; |
1477 | 1477 | } |
1478 | 1478 | ?> |
1479 | 1479 | <p id="give-final-total-wrap" class="form-wrap "> |
1480 | - <span class="give-donation-total-label"><?php echo apply_filters( 'give_donation_total_label', esc_html__( 'Donation Total:', 'give' ) ); ?></span> |
|
1481 | - <span class="give-final-total-amount" data-total="<?php echo give_format_amount( $total ); ?>"><?php echo give_currency_filter( give_format_amount( $total ) ); ?></span> |
|
1480 | + <span class="give-donation-total-label"><?php echo apply_filters('give_donation_total_label', esc_html__('Donation Total:', 'give')); ?></span> |
|
1481 | + <span class="give-final-total-amount" data-total="<?php echo give_format_amount($total); ?>"><?php echo give_currency_filter(give_format_amount($total)); ?></span> |
|
1482 | 1482 | </p> |
1483 | 1483 | <?php |
1484 | 1484 | } |
1485 | 1485 | |
1486 | -add_action( 'give_donation_form_before_submit', 'give_checkout_final_total', 999 ); |
|
1486 | +add_action('give_donation_form_before_submit', 'give_checkout_final_total', 999); |
|
1487 | 1487 | |
1488 | 1488 | /** |
1489 | 1489 | * Renders the Checkout Submit section. |
@@ -1494,7 +1494,7 @@ discard block |
||
1494 | 1494 | * |
1495 | 1495 | * @return void |
1496 | 1496 | */ |
1497 | -function give_checkout_submit( $form_id ) { |
|
1497 | +function give_checkout_submit($form_id) { |
|
1498 | 1498 | ?> |
1499 | 1499 | <fieldset id="give_purchase_submit"> |
1500 | 1500 | <?php |
@@ -1503,24 +1503,24 @@ discard block |
||
1503 | 1503 | * |
1504 | 1504 | * @since 1.7 |
1505 | 1505 | */ |
1506 | - do_action( 'give_donation_form_before_submit', $form_id ); |
|
1506 | + do_action('give_donation_form_before_submit', $form_id); |
|
1507 | 1507 | |
1508 | - give_checkout_hidden_fields( $form_id ); |
|
1508 | + give_checkout_hidden_fields($form_id); |
|
1509 | 1509 | |
1510 | - echo give_checkout_button_purchase( $form_id ); |
|
1510 | + echo give_checkout_button_purchase($form_id); |
|
1511 | 1511 | |
1512 | 1512 | /** |
1513 | 1513 | * Fire after donation form submit. |
1514 | 1514 | * |
1515 | 1515 | * @since 1.7 |
1516 | 1516 | */ |
1517 | - do_action( 'give_donation_form_after_submit', $form_id ); |
|
1517 | + do_action('give_donation_form_after_submit', $form_id); |
|
1518 | 1518 | ?> |
1519 | 1519 | </fieldset> |
1520 | 1520 | <?php |
1521 | 1521 | } |
1522 | 1522 | |
1523 | -add_action( 'give_donation_form_after_cc_form', 'give_checkout_submit', 9999 ); |
|
1523 | +add_action('give_donation_form_after_cc_form', 'give_checkout_submit', 9999); |
|
1524 | 1524 | |
1525 | 1525 | /** |
1526 | 1526 | * Give Checkout Button. |
@@ -1533,17 +1533,17 @@ discard block |
||
1533 | 1533 | * |
1534 | 1534 | * @return string |
1535 | 1535 | */ |
1536 | -function give_checkout_button_purchase( $form_id ) { |
|
1536 | +function give_checkout_button_purchase($form_id) { |
|
1537 | 1537 | |
1538 | - $display_label_field = get_post_meta( $form_id, '_give_checkout_label', true ); |
|
1539 | - $display_label = ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) ); |
|
1538 | + $display_label_field = get_post_meta($form_id, '_give_checkout_label', true); |
|
1539 | + $display_label = ( ! empty($display_label_field) ? $display_label_field : esc_html__('Donate Now', 'give')); |
|
1540 | 1540 | ob_start(); ?> |
1541 | 1541 | <div class="give-submit-button-wrap give-clearfix"> |
1542 | 1542 | <input type="submit" class="give-submit give-btn" id="give-purchase-button" name="give-purchase" value="<?php echo $display_label; ?>"/> |
1543 | 1543 | <span class="give-loading-animation"></span> |
1544 | 1544 | </div> |
1545 | 1545 | <?php |
1546 | - return apply_filters( 'give_checkout_button_purchase', ob_get_clean(), $form_id ); |
|
1546 | + return apply_filters('give_checkout_button_purchase', ob_get_clean(), $form_id); |
|
1547 | 1547 | } |
1548 | 1548 | |
1549 | 1549 | /** |
@@ -1557,18 +1557,18 @@ discard block |
||
1557 | 1557 | * |
1558 | 1558 | * @return void |
1559 | 1559 | */ |
1560 | -function give_agree_to_terms_js( $form_id ) { |
|
1560 | +function give_agree_to_terms_js($form_id) { |
|
1561 | 1561 | |
1562 | - $form_option = get_post_meta( $form_id, '_give_terms_option', true ); |
|
1562 | + $form_option = get_post_meta($form_id, '_give_terms_option', true); |
|
1563 | 1563 | |
1564 | - if ( $form_option === 'yes' ) { |
|
1564 | + if ($form_option === 'yes') { |
|
1565 | 1565 | ?> |
1566 | 1566 | <script type="text/javascript"> |
1567 | 1567 | jQuery(document).ready(function ($) { |
1568 | - $('body').on('click', '.give_terms_links-<?php echo $form_id;?>', function (e) { |
|
1568 | + $('body').on('click', '.give_terms_links-<?php echo $form_id; ?>', function (e) { |
|
1569 | 1569 | e.preventDefault(); |
1570 | - $('.give_terms-<?php echo $form_id;?>').slideToggle(); |
|
1571 | - $('.give_terms_links-<?php echo $form_id;?>').toggle(); |
|
1570 | + $('.give_terms-<?php echo $form_id; ?>').slideToggle(); |
|
1571 | + $('.give_terms_links-<?php echo $form_id; ?>').toggle(); |
|
1572 | 1572 | return false; |
1573 | 1573 | }); |
1574 | 1574 | }); |
@@ -1577,7 +1577,7 @@ discard block |
||
1577 | 1577 | } |
1578 | 1578 | } |
1579 | 1579 | |
1580 | -add_action( 'give_checkout_form_top', 'give_agree_to_terms_js', 10, 2 ); |
|
1580 | +add_action('give_checkout_form_top', 'give_agree_to_terms_js', 10, 2); |
|
1581 | 1581 | |
1582 | 1582 | /** |
1583 | 1583 | * Show Give Goals. |
@@ -1591,17 +1591,17 @@ discard block |
||
1591 | 1591 | * |
1592 | 1592 | * @return mixed |
1593 | 1593 | */ |
1594 | -function give_show_goal_progress( $form_id, $args ) { |
|
1594 | +function give_show_goal_progress($form_id, $args) { |
|
1595 | 1595 | |
1596 | 1596 | ob_start(); |
1597 | - give_get_template( 'shortcode-goal', array( 'form_id' => $form_id, 'args' => $args ) ); |
|
1597 | + give_get_template('shortcode-goal', array('form_id' => $form_id, 'args' => $args)); |
|
1598 | 1598 | |
1599 | - echo apply_filters( 'give_goal_output', ob_get_clean() ); |
|
1599 | + echo apply_filters('give_goal_output', ob_get_clean()); |
|
1600 | 1600 | |
1601 | 1601 | return true; |
1602 | 1602 | } |
1603 | 1603 | |
1604 | -add_action( 'give_pre_form', 'give_show_goal_progress', 10, 2 ); |
|
1604 | +add_action('give_pre_form', 'give_show_goal_progress', 10, 2); |
|
1605 | 1605 | |
1606 | 1606 | |
1607 | 1607 | /** |
@@ -1612,13 +1612,13 @@ discard block |
||
1612 | 1612 | * @param $args |
1613 | 1613 | * @return mixed|string |
1614 | 1614 | */ |
1615 | -function give_get_form_content_placement( $form_id, $args ) { |
|
1615 | +function give_get_form_content_placement($form_id, $args) { |
|
1616 | 1616 | $show_content = ''; |
1617 | 1617 | |
1618 | - if( isset( $args['show_content'] ) && ! empty( $args['show_content'] ) ) { |
|
1619 | - $show_content = ( 'none' !== $args['show_content'] ? $args['show_content'] : '' ); |
|
1620 | - } elseif ( give_is_setting_enabled( get_post_meta( $form_id, '_give_display_content', true ) ) ) { |
|
1621 | - $show_content = get_post_meta( $form_id, '_give_content_placement', true ); |
|
1618 | + if (isset($args['show_content']) && ! empty($args['show_content'])) { |
|
1619 | + $show_content = ('none' !== $args['show_content'] ? $args['show_content'] : ''); |
|
1620 | + } elseif (give_is_setting_enabled(get_post_meta($form_id, '_give_display_content', true))) { |
|
1621 | + $show_content = get_post_meta($form_id, '_give_content_placement', true); |
|
1622 | 1622 | } |
1623 | 1623 | |
1624 | 1624 | return $show_content; |
@@ -1634,20 +1634,20 @@ discard block |
||
1634 | 1634 | * |
1635 | 1635 | * @return void|bool |
1636 | 1636 | */ |
1637 | -function give_form_content( $form_id, $args ) { |
|
1637 | +function give_form_content($form_id, $args) { |
|
1638 | 1638 | |
1639 | - $show_content = give_get_form_content_placement( $form_id, $args ); |
|
1639 | + $show_content = give_get_form_content_placement($form_id, $args); |
|
1640 | 1640 | |
1641 | 1641 | // Bailout. |
1642 | - if( empty( $show_content ) ) { |
|
1642 | + if (empty($show_content)) { |
|
1643 | 1643 | return false; |
1644 | 1644 | } |
1645 | 1645 | |
1646 | 1646 | // Add action according to value. |
1647 | - add_action( $show_content, 'give_form_display_content', 10, 2 ); |
|
1647 | + add_action($show_content, 'give_form_display_content', 10, 2); |
|
1648 | 1648 | } |
1649 | 1649 | |
1650 | -add_action( 'give_pre_form_output', 'give_form_content', 10, 2 ); |
|
1650 | +add_action('give_pre_form_output', 'give_form_content', 10, 2); |
|
1651 | 1651 | |
1652 | 1652 | /** |
1653 | 1653 | * Renders Post Form Content. |
@@ -1661,22 +1661,22 @@ discard block |
||
1661 | 1661 | * |
1662 | 1662 | * @return void |
1663 | 1663 | */ |
1664 | -function give_form_display_content( $form_id, $args ) { |
|
1664 | +function give_form_display_content($form_id, $args) { |
|
1665 | 1665 | |
1666 | - $content = wpautop( get_post_meta( $form_id, '_give_form_content', true ) ); |
|
1667 | - $show_content = give_get_form_content_placement( $form_id, $args ); |
|
1666 | + $content = wpautop(get_post_meta($form_id, '_give_form_content', true)); |
|
1667 | + $show_content = give_get_form_content_placement($form_id, $args); |
|
1668 | 1668 | |
1669 | - if ( give_is_setting_enabled( give_get_option( 'the_content_filter' ) ) ) { |
|
1670 | - $content = apply_filters( 'the_content', $content ); |
|
1669 | + if (give_is_setting_enabled(give_get_option('the_content_filter'))) { |
|
1670 | + $content = apply_filters('the_content', $content); |
|
1671 | 1671 | } |
1672 | 1672 | |
1673 | - $output = '<div id="give-form-content-' . $form_id . '" class="give-form-content-wrap" >' . $content . '</div>'; |
|
1673 | + $output = '<div id="give-form-content-'.$form_id.'" class="give-form-content-wrap" >'.$content.'</div>'; |
|
1674 | 1674 | |
1675 | - echo apply_filters( 'give_form_content_output', $output ); |
|
1675 | + echo apply_filters('give_form_content_output', $output); |
|
1676 | 1676 | |
1677 | 1677 | //remove action to prevent content output on addition forms on page. |
1678 | 1678 | //@see: https://github.com/WordImpress/Give/issues/634. |
1679 | - remove_action( $show_content, 'give_form_display_content' ); |
|
1679 | + remove_action($show_content, 'give_form_display_content'); |
|
1680 | 1680 | } |
1681 | 1681 | |
1682 | 1682 | /** |
@@ -1688,7 +1688,7 @@ discard block |
||
1688 | 1688 | * |
1689 | 1689 | * @return void |
1690 | 1690 | */ |
1691 | -function give_checkout_hidden_fields( $form_id ) { |
|
1691 | +function give_checkout_hidden_fields($form_id) { |
|
1692 | 1692 | |
1693 | 1693 | /** |
1694 | 1694 | * Fires while rendering hidden checkout fields, before the fields. |
@@ -1697,13 +1697,13 @@ discard block |
||
1697 | 1697 | * |
1698 | 1698 | * @param int $form_id The form ID. |
1699 | 1699 | */ |
1700 | - do_action( 'give_hidden_fields_before', $form_id ); |
|
1700 | + do_action('give_hidden_fields_before', $form_id); |
|
1701 | 1701 | |
1702 | - if ( is_user_logged_in() ) { ?> |
|
1702 | + if (is_user_logged_in()) { ?> |
|
1703 | 1703 | <input type="hidden" name="give-user-id" value="<?php echo get_current_user_id(); ?>"/> |
1704 | 1704 | <?php } ?> |
1705 | 1705 | <input type="hidden" name="give_action" value="purchase"/> |
1706 | - <input type="hidden" name="give-gateway" value="<?php echo give_get_chosen_gateway( $form_id ); ?>"/> |
|
1706 | + <input type="hidden" name="give-gateway" value="<?php echo give_get_chosen_gateway($form_id); ?>"/> |
|
1707 | 1707 | <?php |
1708 | 1708 | /** |
1709 | 1709 | * Fires while rendering hidden checkout fields, after the fields. |
@@ -1712,7 +1712,7 @@ discard block |
||
1712 | 1712 | * |
1713 | 1713 | * @param int $form_id The form ID. |
1714 | 1714 | */ |
1715 | - do_action( 'give_hidden_fields_after', $form_id ); |
|
1715 | + do_action('give_hidden_fields_after', $form_id); |
|
1716 | 1716 | |
1717 | 1717 | } |
1718 | 1718 | |
@@ -1727,20 +1727,20 @@ discard block |
||
1727 | 1727 | * |
1728 | 1728 | * @return string $content Filtered content. |
1729 | 1729 | */ |
1730 | -function give_filter_success_page_content( $content ) { |
|
1730 | +function give_filter_success_page_content($content) { |
|
1731 | 1731 | |
1732 | 1732 | $give_options = give_get_settings(); |
1733 | 1733 | |
1734 | - if ( isset( $give_options['success_page'] ) && isset( $_GET['payment-confirmation'] ) && is_page( $give_options['success_page'] ) ) { |
|
1735 | - if ( has_filter( 'give_donation_confirm_' . $_GET['payment-confirmation'] ) ) { |
|
1736 | - $content = apply_filters( 'give_donation_confirm_' . $_GET['payment-confirmation'], $content ); |
|
1734 | + if (isset($give_options['success_page']) && isset($_GET['payment-confirmation']) && is_page($give_options['success_page'])) { |
|
1735 | + if (has_filter('give_donation_confirm_'.$_GET['payment-confirmation'])) { |
|
1736 | + $content = apply_filters('give_donation_confirm_'.$_GET['payment-confirmation'], $content); |
|
1737 | 1737 | } |
1738 | 1738 | } |
1739 | 1739 | |
1740 | 1740 | return $content; |
1741 | 1741 | } |
1742 | 1742 | |
1743 | -add_filter( 'the_content', 'give_filter_success_page_content' ); |
|
1743 | +add_filter('the_content', 'give_filter_success_page_content'); |
|
1744 | 1744 | |
1745 | 1745 | /** |
1746 | 1746 | * Test Mode Frontend Warning. |
@@ -1751,14 +1751,14 @@ discard block |
||
1751 | 1751 | */ |
1752 | 1752 | function give_test_mode_frontend_warning() { |
1753 | 1753 | |
1754 | - $test_mode = give_get_option( 'test_mode' ); |
|
1754 | + $test_mode = give_get_option('test_mode'); |
|
1755 | 1755 | |
1756 | - if ( $test_mode == 'on' ) { |
|
1757 | - echo '<div class="give_error give_warning" id="give_error_test_mode"><p><strong>' . esc_html__( 'Notice:', 'give' ) . '</strong> ' . esc_html__( 'Test mode is enabled. While in test mode no live donations are processed.', 'give' ) . '</p></div>'; |
|
1756 | + if ($test_mode == 'on') { |
|
1757 | + echo '<div class="give_error give_warning" id="give_error_test_mode"><p><strong>'.esc_html__('Notice:', 'give').'</strong> '.esc_html__('Test mode is enabled. While in test mode no live donations are processed.', 'give').'</p></div>'; |
|
1758 | 1758 | } |
1759 | 1759 | } |
1760 | 1760 | |
1761 | -add_action( 'give_pre_form', 'give_test_mode_frontend_warning', 10 ); |
|
1761 | +add_action('give_pre_form', 'give_test_mode_frontend_warning', 10); |
|
1762 | 1762 | |
1763 | 1763 | /** |
1764 | 1764 | * Members-only Form. |
@@ -1772,21 +1772,21 @@ discard block |
||
1772 | 1772 | * |
1773 | 1773 | * @return string |
1774 | 1774 | */ |
1775 | -function give_members_only_form( $final_output, $args ) { |
|
1775 | +function give_members_only_form($final_output, $args) { |
|
1776 | 1776 | |
1777 | - $form_id = isset( $args['form_id'] ) ? $args['form_id'] : 0; |
|
1777 | + $form_id = isset($args['form_id']) ? $args['form_id'] : 0; |
|
1778 | 1778 | |
1779 | 1779 | //Sanity Check: Must have form_id & not be logged in. |
1780 | - if ( empty( $form_id ) || is_user_logged_in() ) { |
|
1780 | + if (empty($form_id) || is_user_logged_in()) { |
|
1781 | 1781 | return $final_output; |
1782 | 1782 | } |
1783 | 1783 | |
1784 | 1784 | //Logged in only and Register / Login set to none. |
1785 | - if ( give_logged_in_only( $form_id ) && give_show_login_register_option( $form_id ) == 'none' ) { |
|
1785 | + if (give_logged_in_only($form_id) && give_show_login_register_option($form_id) == 'none') { |
|
1786 | 1786 | |
1787 | - $final_output = give_output_error( esc_html__( 'Please log in in order to complete your donation.', 'give' ), false ); |
|
1787 | + $final_output = give_output_error(esc_html__('Please log in in order to complete your donation.', 'give'), false); |
|
1788 | 1788 | |
1789 | - return apply_filters( 'give_members_only_output', $final_output, $form_id ); |
|
1789 | + return apply_filters('give_members_only_output', $final_output, $form_id); |
|
1790 | 1790 | |
1791 | 1791 | } |
1792 | 1792 | |
@@ -1794,4 +1794,4 @@ discard block |
||
1794 | 1794 | |
1795 | 1795 | } |
1796 | 1796 | |
1797 | -add_filter( 'give_donate_form', 'give_members_only_form', 10, 2 ); |
|
1797 | +add_filter('give_donate_form', 'give_members_only_form', 10, 2); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -25,14 +25,14 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_get_actions() { |
27 | 27 | |
28 | - $_get_action = ! empty( $_GET['give_action'] ) ? $_GET['give_action'] : null; |
|
28 | + $_get_action = ! empty($_GET['give_action']) ? $_GET['give_action'] : null; |
|
29 | 29 | |
30 | 30 | // Add backward compatibility to give-action param ( $_GET or $_POST ) |
31 | - if( doing_action( 'admin_init' ) && empty( $_get_action ) ) { |
|
32 | - $_get_action = ! empty( $_GET['give-action'] ) ? $_GET['give-action'] : null; |
|
31 | + if (doing_action('admin_init') && empty($_get_action)) { |
|
32 | + $_get_action = ! empty($_GET['give-action']) ? $_GET['give-action'] : null; |
|
33 | 33 | } |
34 | 34 | |
35 | - if ( isset( $_get_action ) ) { |
|
35 | + if (isset($_get_action)) { |
|
36 | 36 | /** |
37 | 37 | * Fires in WordPress init or admin init, when give_action is present in $_GET. |
38 | 38 | * |
@@ -40,13 +40,13 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @param array $_GET Array of HTTP GET variables. |
42 | 42 | */ |
43 | - do_action( "give_{$_get_action}", $_GET ); |
|
43 | + do_action("give_{$_get_action}", $_GET); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | } |
47 | 47 | |
48 | -add_action( 'init', 'give_get_actions' ); |
|
49 | -add_action( 'admin_init', 'give_get_actions' ); |
|
48 | +add_action('init', 'give_get_actions'); |
|
49 | +add_action('admin_init', 'give_get_actions'); |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * Hooks Give actions, when present in the $_POST superglobal. Every give_action |
@@ -59,15 +59,15 @@ discard block |
||
59 | 59 | */ |
60 | 60 | function give_post_actions() { |
61 | 61 | |
62 | - $_post_action = ! empty( $_POST['give_action'] ) ? $_POST['give_action'] : null; |
|
62 | + $_post_action = ! empty($_POST['give_action']) ? $_POST['give_action'] : null; |
|
63 | 63 | |
64 | 64 | |
65 | 65 | // Add backward compatibility to give-action param ( $_GET or $_POST ) |
66 | - if( doing_action( 'admin_init' ) && empty( $_post_action ) ) { |
|
67 | - $_post_action = ! empty( $_POST['give-action'] ) ? $_POST['give-action'] : null; |
|
66 | + if (doing_action('admin_init') && empty($_post_action)) { |
|
67 | + $_post_action = ! empty($_POST['give-action']) ? $_POST['give-action'] : null; |
|
68 | 68 | } |
69 | 69 | |
70 | - if ( isset( $_post_action ) ) { |
|
70 | + if (isset($_post_action)) { |
|
71 | 71 | /** |
72 | 72 | * Fires in WordPress init or admin init, when give_action is present in $_POST. |
73 | 73 | * |
@@ -75,13 +75,13 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @param array $_POST Array of HTTP POST variables. |
77 | 77 | */ |
78 | - do_action( "give_{$_post_action}", $_POST ); |
|
78 | + do_action("give_{$_post_action}", $_POST); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | } |
82 | 82 | |
83 | -add_action( 'init', 'give_post_actions' ); |
|
84 | -add_action( 'admin_init', 'give_post_actions' ); |
|
83 | +add_action('init', 'give_post_actions'); |
|
84 | +add_action('admin_init', 'give_post_actions'); |
|
85 | 85 | |
86 | 86 | /** |
87 | 87 | * Connect WordPress user with Donor. |
@@ -91,27 +91,27 @@ discard block |
||
91 | 91 | * @param array $user_data User Data |
92 | 92 | * @return void |
93 | 93 | */ |
94 | -function give_connect_donor_to_wpuser( $user_id, $user_data ){ |
|
95 | - $donor = new Give_Customer( $user_data['user_email'] ); |
|
94 | +function give_connect_donor_to_wpuser($user_id, $user_data) { |
|
95 | + $donor = new Give_Customer($user_data['user_email']); |
|
96 | 96 | |
97 | 97 | // Validate donor id and check if do nor is already connect to wp user or not. |
98 | - if( $donor->id && ! $donor->user_id ) { |
|
98 | + if ($donor->id && ! $donor->user_id) { |
|
99 | 99 | |
100 | 100 | // Update donor user_id. |
101 | - if( $donor->update( array( 'user_id' => $user_id ) ) ) { |
|
102 | - $donor_note = sprintf( esc_html__( 'WordPress user #%d is connected to #%d', 'give' ), $user_id, $donor->id ); |
|
103 | - $donor->add_note( $donor_note ); |
|
101 | + if ($donor->update(array('user_id' => $user_id))) { |
|
102 | + $donor_note = sprintf(esc_html__('WordPress user #%d is connected to #%d', 'give'), $user_id, $donor->id); |
|
103 | + $donor->add_note($donor_note); |
|
104 | 104 | |
105 | 105 | // Update user_id meta in payments. |
106 | - if( ! empty( $donor->payment_ids ) && ( $donations = explode( ',', $donor->payment_ids ) ) ) { |
|
107 | - foreach ( $donations as $donation ) { |
|
108 | - update_post_meta( $donation, '_give_payment_user_id', $user_id ); |
|
106 | + if ( ! empty($donor->payment_ids) && ($donations = explode(',', $donor->payment_ids))) { |
|
107 | + foreach ($donations as $donation) { |
|
108 | + update_post_meta($donation, '_give_payment_user_id', $user_id); |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | } |
112 | 112 | } |
113 | 113 | } |
114 | -add_action( 'give_insert_user', 'give_connect_donor_to_wpuser', 10, 2 ); |
|
114 | +add_action('give_insert_user', 'give_connect_donor_to_wpuser', 10, 2); |
|
115 | 115 | |
116 | 116 | |
117 | 117 | /** |
@@ -125,21 +125,21 @@ discard block |
||
125 | 125 | function give_validate_license_when_site_migrated() { |
126 | 126 | // Store current site address if not already stored. |
127 | 127 | $homeurl = home_url(); |
128 | - if( ! get_option( 'give_site_address_before_migrate' ) ) { |
|
128 | + if ( ! get_option('give_site_address_before_migrate')) { |
|
129 | 129 | // Update site address. |
130 | - update_option( 'give_site_address_before_migrate', $homeurl ); |
|
130 | + update_option('give_site_address_before_migrate', $homeurl); |
|
131 | 131 | |
132 | 132 | return; |
133 | 133 | } |
134 | 134 | |
135 | - if( $homeurl !== get_option( 'give_site_address_before_migrate' ) ) { |
|
135 | + if ($homeurl !== get_option('give_site_address_before_migrate')) { |
|
136 | 136 | // Immediately run cron. |
137 | - wp_schedule_single_event( time() , 'give_validate_license_when_site_migrated' ); |
|
137 | + wp_schedule_single_event(time(), 'give_validate_license_when_site_migrated'); |
|
138 | 138 | |
139 | 139 | // Update site address. |
140 | - update_option( 'give_site_address_before_migrate', home_url() ); |
|
140 | + update_option('give_site_address_before_migrate', home_url()); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | } |
144 | -add_action( 'init', 'give_validate_license_when_site_migrated' ); |
|
145 | -add_action( 'admin_init', 'give_validate_license_when_site_migrated' ); |
|
144 | +add_action('init', 'give_validate_license_when_site_migrated'); |
|
145 | +add_action('admin_init', 'give_validate_license_when_site_migrated'); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -21,12 +21,12 @@ discard block |
||
21 | 21 | * @return void |
22 | 22 | */ |
23 | 23 | function give_register_dashboard_widgets() { |
24 | - if ( current_user_can( apply_filters( 'give_dashboard_stats_cap', 'view_give_reports' ) ) ) { |
|
25 | - wp_add_dashboard_widget( 'give_dashboard_sales', esc_html__( 'Give: Donation Statistics', 'give' ), 'give_dashboard_sales_widget' ); |
|
24 | + if (current_user_can(apply_filters('give_dashboard_stats_cap', 'view_give_reports'))) { |
|
25 | + wp_add_dashboard_widget('give_dashboard_sales', esc_html__('Give: Donation Statistics', 'give'), 'give_dashboard_sales_widget'); |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
29 | -add_action( 'wp_dashboard_setup', 'give_register_dashboard_widgets', 10 ); |
|
29 | +add_action('wp_dashboard_setup', 'give_register_dashboard_widgets', 10); |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Sales Summary Dashboard Widget |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | function give_dashboard_sales_widget() { |
40 | 40 | |
41 | - if ( ! current_user_can( apply_filters( 'give_dashboard_stats_cap', 'view_give_reports' ) ) ) { |
|
41 | + if ( ! current_user_can(apply_filters('give_dashboard_stats_cap', 'view_give_reports'))) { |
|
42 | 42 | return; |
43 | 43 | } |
44 | 44 | $stats = new Give_Payment_Stats; ?> |
@@ -46,27 +46,27 @@ discard block |
||
46 | 46 | <div class="give-dashboard-widget"> |
47 | 47 | |
48 | 48 | <div class="give-dashboard-today give-clearfix"> |
49 | - <h3 class="give-dashboard-date-today"><?php echo date( _x( 'F j, Y', 'dashboard widget', 'give' ) ); ?></h3> |
|
49 | + <h3 class="give-dashboard-date-today"><?php echo date(_x('F j, Y', 'dashboard widget', 'give')); ?></h3> |
|
50 | 50 | |
51 | 51 | <p class="give-dashboard-happy-day"><?php |
52 | 52 | printf( |
53 | 53 | /* translators: %s: day of the week */ |
54 | - esc_html__( 'Happy %s!', 'give' ), |
|
55 | - date( 'l', current_time( 'timestamp' ) ) |
|
54 | + esc_html__('Happy %s!', 'give'), |
|
55 | + date('l', current_time('timestamp')) |
|
56 | 56 | ); |
57 | 57 | ?></p> |
58 | 58 | |
59 | 59 | <p class="give-dashboard-today-earnings"><?php |
60 | - $earnings_today = $stats->get_earnings( 0, 'today', false ); |
|
61 | - echo give_currency_filter( give_format_amount( $earnings_today ) ); |
|
60 | + $earnings_today = $stats->get_earnings(0, 'today', false); |
|
61 | + echo give_currency_filter(give_format_amount($earnings_today)); |
|
62 | 62 | ?></p> |
63 | 63 | |
64 | 64 | <p class="give-orders-today"><?php |
65 | - $donations_today = $stats->get_sales( 0, 'today', false ); |
|
65 | + $donations_today = $stats->get_sales(0, 'today', false); |
|
66 | 66 | printf( |
67 | 67 | /* translators: %s: daily donation count */ |
68 | - esc_html__( '%s donations today', 'give' ), |
|
69 | - give_format_amount( $donations_today, false ) |
|
68 | + esc_html__('%s donations today', 'give'), |
|
69 | + give_format_amount($donations_today, false) |
|
70 | 70 | ); |
71 | 71 | ?></p> |
72 | 72 | |
@@ -76,34 +76,34 @@ discard block |
||
76 | 76 | <table class="give-table-stats"> |
77 | 77 | <thead style="display: none;"> |
78 | 78 | <tr> |
79 | - <th><?php esc_html_e( 'This Week', 'give' ); ?></th> |
|
80 | - <th><?php esc_html_e( 'This Month', 'give' ); ?></th> |
|
81 | - <th><?php esc_html_e( 'Past 30 Days', 'give' ); ?></th> |
|
79 | + <th><?php esc_html_e('This Week', 'give'); ?></th> |
|
80 | + <th><?php esc_html_e('This Month', 'give'); ?></th> |
|
81 | + <th><?php esc_html_e('Past 30 Days', 'give'); ?></th> |
|
82 | 82 | </tr> |
83 | 83 | </thead> |
84 | 84 | <tbody> |
85 | 85 | <tr id="give-table-stats-tr-1"> |
86 | 86 | <td> |
87 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_week' ) ) ); ?></p> |
|
87 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_week'))); ?></p> |
|
88 | 88 | |
89 | - <p class="give-dashboard-stat-total-label"><?php esc_html_e( 'This Week', 'give' ); ?></p> |
|
89 | + <p class="give-dashboard-stat-total-label"><?php esc_html_e('This Week', 'give'); ?></p> |
|
90 | 90 | </td> |
91 | 91 | <td> |
92 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_month' ) ) ); ?></p> |
|
92 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_month'))); ?></p> |
|
93 | 93 | |
94 | - <p class="give-dashboard-stat-total-label"><?php esc_html_e( 'This Month', 'give' ); ?></p> |
|
94 | + <p class="give-dashboard-stat-total-label"><?php esc_html_e('This Month', 'give'); ?></p> |
|
95 | 95 | </td> |
96 | 96 | </tr> |
97 | 97 | <tr id="give-table-stats-tr-2"> |
98 | 98 | <td> |
99 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'last_month' ) ) ) ?></p> |
|
99 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'last_month'))) ?></p> |
|
100 | 100 | |
101 | - <p class="give-dashboard-stat-total-label"><?php esc_html_e( 'Last Month', 'give' ); ?></p> |
|
101 | + <p class="give-dashboard-stat-total-label"><?php esc_html_e('Last Month', 'give'); ?></p> |
|
102 | 102 | </td> |
103 | 103 | <td> |
104 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_year', false ) ) ) ?></p> |
|
104 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_year', false))) ?></p> |
|
105 | 105 | |
106 | - <p class="give-dashboard-stat-total-label"><?php esc_html_e( 'This Year', 'give' ); ?></p> |
|
106 | + <p class="give-dashboard-stat-total-label"><?php esc_html_e('This Year', 'give'); ?></p> |
|
107 | 107 | </td> |
108 | 108 | </tr> |
109 | 109 | </tbody> |
@@ -123,23 +123,23 @@ discard block |
||
123 | 123 | * |
124 | 124 | * @return array |
125 | 125 | */ |
126 | -function give_dashboard_at_a_glance_widget( $items ) { |
|
127 | - $num_posts = wp_count_posts( 'give_forms' ); |
|
126 | +function give_dashboard_at_a_glance_widget($items) { |
|
127 | + $num_posts = wp_count_posts('give_forms'); |
|
128 | 128 | |
129 | - if ( $num_posts && $num_posts->publish ) { |
|
129 | + if ($num_posts && $num_posts->publish) { |
|
130 | 130 | |
131 | 131 | $text = sprintf( |
132 | 132 | /* translators: %s: number of posts published */ |
133 | - _n( '%s Give Form', '%s Give Forms', $num_posts->publish, 'give' ), |
|
133 | + _n('%s Give Form', '%s Give Forms', $num_posts->publish, 'give'), |
|
134 | 134 | $num_posts->publish |
135 | 135 | ); |
136 | 136 | |
137 | - $text = sprintf( $text, number_format_i18n( $num_posts->publish ) ); |
|
137 | + $text = sprintf($text, number_format_i18n($num_posts->publish)); |
|
138 | 138 | |
139 | - if ( current_user_can( 'edit_give_forms', get_current_user_id() ) ) { |
|
139 | + if (current_user_can('edit_give_forms', get_current_user_id())) { |
|
140 | 140 | $text = sprintf( |
141 | 141 | '<a class="give-forms-count" href="%1$s">%2$s</a>', |
142 | - admin_url( 'edit.php?post_type=give_forms' ), |
|
142 | + admin_url('edit.php?post_type=give_forms'), |
|
143 | 143 | $text |
144 | 144 | ); |
145 | 145 | } else { |
@@ -155,4 +155,4 @@ discard block |
||
155 | 155 | return $items; |
156 | 156 | } |
157 | 157 | |
158 | -add_filter( 'dashboard_glance_items', 'give_dashboard_at_a_glance_widget', 1, 1 ); |
|
158 | +add_filter('dashboard_glance_items', 'give_dashboard_at_a_glance_widget', 1, 1); |
@@ -66,23 +66,23 @@ discard block |
||
66 | 66 | * @param $args |
67 | 67 | * |
68 | 68 | */ |
69 | - public function __construct( $args ) { |
|
69 | + public function __construct($args) { |
|
70 | 70 | |
71 | 71 | //Only for admins. |
72 | - if ( ! is_admin() ) { |
|
72 | + if ( ! is_admin()) { |
|
73 | 73 | return; |
74 | 74 | } |
75 | 75 | |
76 | 76 | //This plugin is en_US native. |
77 | 77 | $this->locale = get_locale(); |
78 | - if ( 'en_US' === $this->locale ) { |
|
78 | + if ('en_US' === $this->locale) { |
|
79 | 79 | return; |
80 | 80 | } |
81 | 81 | |
82 | - $this->init( $args ); |
|
82 | + $this->init($args); |
|
83 | 83 | |
84 | - if ( ! $this->hide_promo() ) { |
|
85 | - add_action( $this->hook, array( $this, 'promo' ) ); |
|
84 | + if ( ! $this->hide_promo()) { |
|
85 | + add_action($this->hook, array($this, 'promo')); |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @param array $args |
95 | 95 | */ |
96 | - private function init( $args ) { |
|
97 | - foreach ( $args as $key => $arg ) { |
|
96 | + private function init($args) { |
|
97 | + foreach ($args as $key => $arg) { |
|
98 | 98 | $this->$key = $arg; |
99 | 99 | } |
100 | 100 | |
@@ -108,11 +108,11 @@ discard block |
||
108 | 108 | * @return bool |
109 | 109 | */ |
110 | 110 | private function hide_promo() { |
111 | - $hide_promo = get_transient( 'give_i18n_give_promo_hide' ); |
|
112 | - if ( ! $hide_promo ) { |
|
113 | - if ( filter_input( INPUT_GET, 'remove_i18n_promo', FILTER_VALIDATE_INT ) === 1 ) { |
|
111 | + $hide_promo = get_transient('give_i18n_give_promo_hide'); |
|
112 | + if ( ! $hide_promo) { |
|
113 | + if (filter_input(INPUT_GET, 'remove_i18n_promo', FILTER_VALIDATE_INT) === 1) { |
|
114 | 114 | // No expiration time, so this would normally not expire, but it wouldn't be copied to other sites etc. |
115 | - set_transient( 'give_i18n_give_promo_hide', true ); |
|
115 | + set_transient('give_i18n_give_promo_hide', true); |
|
116 | 116 | $hide_promo = true; |
117 | 117 | } |
118 | 118 | } |
@@ -131,20 +131,20 @@ discard block |
||
131 | 131 | $message = false; |
132 | 132 | |
133 | 133 | //Using a translation less than 90% complete. |
134 | - if ( $this->translation_exists && $this->translation_loaded && $this->percent_translated < 90 ) { |
|
135 | - $message = __( 'As you can see, there is a translation of this plugin in %1$s. This translation is currently %3$d%% complete. We need your help to make it complete and to fix any errors. Please register at %4$s to help %5$s to %1$s!', 'give' ); |
|
136 | - } elseif ( ! $this->translation_loaded && $this->translation_exists ) { |
|
137 | - $message = __( 'You\'re using WordPress in %1$s. While %2$s has been translated to %1$s for %3$d%%, it\'s not been shipped with the plugin yet. You can help! Register at %4$s to help complete the translation to %1$s!', 'give' ); |
|
138 | - } elseif ( ! $this->translation_exists ) { |
|
139 | - $message = __( 'You\'re using WordPress in a language we don\'t support yet. We\'d love for %2$s to be translated in that language too, but unfortunately, it isn\'t right now. You can change that! Register at %4$s to help translate it!', 'give' ); |
|
134 | + if ($this->translation_exists && $this->translation_loaded && $this->percent_translated < 90) { |
|
135 | + $message = __('As you can see, there is a translation of this plugin in %1$s. This translation is currently %3$d%% complete. We need your help to make it complete and to fix any errors. Please register at %4$s to help %5$s to %1$s!', 'give'); |
|
136 | + } elseif ( ! $this->translation_loaded && $this->translation_exists) { |
|
137 | + $message = __('You\'re using WordPress in %1$s. While %2$s has been translated to %1$s for %3$d%%, it\'s not been shipped with the plugin yet. You can help! Register at %4$s to help complete the translation to %1$s!', 'give'); |
|
138 | + } elseif ( ! $this->translation_exists) { |
|
139 | + $message = __('You\'re using WordPress in a language we don\'t support yet. We\'d love for %2$s to be translated in that language too, but unfortunately, it isn\'t right now. You can change that! Register at %4$s to help translate it!', 'give'); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | //Links. |
143 | - $registration_link = sprintf( '<a href="%1$s" target="_blank">%2$s</a>', 'https://wordpress.org/support/register.php', esc_html__( 'WordPress.org', 'give' ) ); |
|
144 | - $translations_link = sprintf( '<a href="%1$s" target="_blank">%2$s</a>', 'https://translate.wordpress.org/projects/wp-plugins/give', esc_html__( 'complete the translation', 'give' ) ); |
|
143 | + $registration_link = sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://wordpress.org/support/register.php', esc_html__('WordPress.org', 'give')); |
|
144 | + $translations_link = sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://translate.wordpress.org/projects/wp-plugins/give', esc_html__('complete the translation', 'give')); |
|
145 | 145 | |
146 | 146 | //Message. |
147 | - $message = sprintf( $message, esc_html( $this->locale_name ), esc_html( 'Give' ), $this->percent_translated, $registration_link, $translations_link ); |
|
147 | + $message = sprintf($message, esc_html($this->locale_name), esc_html('Give'), $this->percent_translated, $registration_link, $translations_link); |
|
148 | 148 | |
149 | 149 | |
150 | 150 | return $message; |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | $this->translation_details(); |
160 | 160 | $message = $this->promo_message(); |
161 | 161 | |
162 | - if ( $message ) { ?> |
|
162 | + if ($message) { ?> |
|
163 | 163 | |
164 | 164 | <style> |
165 | 165 | /* Banner specific styles */ |
@@ -212,12 +212,12 @@ discard block |
||
212 | 212 | <a href="https://wordpress.org/support/register.php" class="alignleft give-i18n-icon" style="margin:0" target="_blank"><span class="dashicons dashicons-translation" style="font-size: 110px; text-decoration: none;"></span></a> |
213 | 213 | |
214 | 214 | <div class="give-i18n-notice-content"> |
215 | - <a href="<?php echo esc_url( add_query_arg( array( 'remove_i18n_promo' => '1' ) ) ); ?>" class="dismiss"><span class="dashicons dashicons-dismiss"></span></a> |
|
215 | + <a href="<?php echo esc_url(add_query_arg(array('remove_i18n_promo' => '1'))); ?>" class="dismiss"><span class="dashicons dashicons-dismiss"></span></a> |
|
216 | 216 | |
217 | - <h2 style="margin: 10px 0;"><?php printf( esc_html__( 'Help Translate Give to %s', 'give' ), $this->locale_name ); ?></h2> |
|
217 | + <h2 style="margin: 10px 0;"><?php printf(esc_html__('Help Translate Give to %s', 'give'), $this->locale_name); ?></h2> |
|
218 | 218 | <p><?php echo $message; ?></p> |
219 | 219 | <p> |
220 | - <a href="https://wordpress.org/support/register.php" target="_blank"><?php _e( 'Register now »', 'give' ); ?></a> |
|
220 | + <a href="https://wordpress.org/support/register.php" target="_blank"><?php _e('Register now »', 'give'); ?></a> |
|
221 | 221 | </p> |
222 | 222 | </div> |
223 | 223 | </div> |
@@ -234,11 +234,11 @@ discard block |
||
234 | 234 | */ |
235 | 235 | private function find_or_initialize_translation_details() { |
236 | 236 | |
237 | - $set = get_transient( 'give_i18n_give_' . $this->locale ); |
|
237 | + $set = get_transient('give_i18n_give_'.$this->locale); |
|
238 | 238 | |
239 | - if ( ! $set ) { |
|
239 | + if ( ! $set) { |
|
240 | 240 | $set = $this->retrieve_translation_details(); |
241 | - set_transient( 'give_i18n_give_' . $this->locale, $set, DAY_IN_SECONDS ); |
|
241 | + set_transient('give_i18n_give_'.$this->locale, $set, DAY_IN_SECONDS); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | return $set; |
@@ -252,10 +252,10 @@ discard block |
||
252 | 252 | private function translation_details() { |
253 | 253 | $set = $this->find_or_initialize_translation_details(); |
254 | 254 | |
255 | - $this->translation_exists = ! is_null( $set ); |
|
256 | - $this->translation_loaded = is_textdomain_loaded( 'give' ); |
|
255 | + $this->translation_exists = ! is_null($set); |
|
256 | + $this->translation_loaded = is_textdomain_loaded('give'); |
|
257 | 257 | |
258 | - $this->parse_translation_set( $set ); |
|
258 | + $this->parse_translation_set($set); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | /** |
@@ -267,26 +267,26 @@ discard block |
||
267 | 267 | */ |
268 | 268 | private function retrieve_translation_details() { |
269 | 269 | |
270 | - $api_url = trailingslashit( $this->glotpress_url ); |
|
270 | + $api_url = trailingslashit($this->glotpress_url); |
|
271 | 271 | |
272 | - $resp = wp_remote_get( $api_url ); |
|
272 | + $resp = wp_remote_get($api_url); |
|
273 | 273 | |
274 | - if ( is_wp_error( $resp ) || wp_remote_retrieve_response_code( $resp ) === '404' ) { |
|
274 | + if (is_wp_error($resp) || wp_remote_retrieve_response_code($resp) === '404') { |
|
275 | 275 | return null; |
276 | 276 | } |
277 | 277 | |
278 | - $body = wp_remote_retrieve_body( $resp ); |
|
279 | - unset( $resp ); |
|
278 | + $body = wp_remote_retrieve_body($resp); |
|
279 | + unset($resp); |
|
280 | 280 | |
281 | - if ( $body ) { |
|
282 | - $body = json_decode( $body ); |
|
281 | + if ($body) { |
|
282 | + $body = json_decode($body); |
|
283 | 283 | |
284 | - foreach ( $body->translation_sets as $set ) { |
|
285 | - if ( ! property_exists( $set, 'wp_locale' ) ) { |
|
284 | + foreach ($body->translation_sets as $set) { |
|
285 | + if ( ! property_exists($set, 'wp_locale')) { |
|
286 | 286 | continue; |
287 | 287 | } |
288 | 288 | |
289 | - if ( $this->locale == $set->wp_locale ) { |
|
289 | + if ($this->locale == $set->wp_locale) { |
|
290 | 290 | return $set; |
291 | 291 | } |
292 | 292 | } |
@@ -302,8 +302,8 @@ discard block |
||
302 | 302 | * |
303 | 303 | * @access private |
304 | 304 | */ |
305 | - private function parse_translation_set( $set ) { |
|
306 | - if ( $this->translation_exists && is_object( $set ) ) { |
|
305 | + private function parse_translation_set($set) { |
|
306 | + if ($this->translation_exists && is_object($set)) { |
|
307 | 307 | $this->locale_name = $set->name; |
308 | 308 | $this->percent_translated = $set->percent_translated; |
309 | 309 | } else { |
@@ -10,13 +10,13 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
17 | 17 | // Load WP_List_Table if not loaded |
18 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
19 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
18 | +if ( ! class_exists('WP_List_Table')) { |
|
19 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -61,11 +61,11 @@ discard block |
||
61 | 61 | public function __construct() { |
62 | 62 | |
63 | 63 | // Set parent defaults |
64 | - parent::__construct( array( |
|
65 | - 'singular' => esc_html__( 'Donor', 'give' ), // Singular name of the listed records |
|
66 | - 'plural' => esc_html__( 'Donors', 'give' ), // Plural name of the listed records |
|
64 | + parent::__construct(array( |
|
65 | + 'singular' => esc_html__('Donor', 'give'), // Singular name of the listed records |
|
66 | + 'plural' => esc_html__('Donors', 'give'), // Plural name of the listed records |
|
67 | 67 | 'ajax' => false // Does this table support ajax? |
68 | - ) ); |
|
68 | + )); |
|
69 | 69 | |
70 | 70 | } |
71 | 71 | |
@@ -80,20 +80,20 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @return void |
82 | 82 | */ |
83 | - public function search_box( $text, $input_id ) { |
|
84 | - $input_id = $input_id . '-search-input'; |
|
83 | + public function search_box($text, $input_id) { |
|
84 | + $input_id = $input_id.'-search-input'; |
|
85 | 85 | |
86 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
87 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
86 | + if ( ! empty($_REQUEST['orderby'])) { |
|
87 | + echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />'; |
|
88 | 88 | } |
89 | - if ( ! empty( $_REQUEST['order'] ) ) { |
|
90 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
89 | + if ( ! empty($_REQUEST['order'])) { |
|
90 | + echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />'; |
|
91 | 91 | } |
92 | 92 | ?> |
93 | 93 | <p class="search-box" role="search"> |
94 | 94 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
95 | 95 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>"/> |
96 | - <?php submit_button( $text, 'button', false, false, array( 'ID' => 'search-submit' ) ); ?> |
|
96 | + <?php submit_button($text, 'button', false, false, array('ID' => 'search-submit')); ?> |
|
97 | 97 | </p> |
98 | 98 | <?php |
99 | 99 | } |
@@ -109,29 +109,29 @@ discard block |
||
109 | 109 | * |
110 | 110 | * @return string Column Name. |
111 | 111 | */ |
112 | - public function column_default( $item, $column_name ) { |
|
113 | - switch ( $column_name ) { |
|
112 | + public function column_default($item, $column_name) { |
|
113 | + switch ($column_name) { |
|
114 | 114 | |
115 | 115 | case 'num_purchases' : |
116 | - $value = '<a href="' . |
|
117 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . urlencode( $item['email'] ) |
|
118 | - ) . '">' . esc_html( $item['num_purchases'] ) . '</a>'; |
|
116 | + $value = '<a href="'. |
|
117 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&user='.urlencode($item['email']) |
|
118 | + ).'">'.esc_html($item['num_purchases']).'</a>'; |
|
119 | 119 | break; |
120 | 120 | |
121 | 121 | case 'amount_spent' : |
122 | - $value = give_currency_filter( give_format_amount( $item[ $column_name ] ) ); |
|
122 | + $value = give_currency_filter(give_format_amount($item[$column_name])); |
|
123 | 123 | break; |
124 | 124 | |
125 | 125 | case 'date_created' : |
126 | - $value = date_i18n( give_date_format(), strtotime( $item['date_created'] ) ); |
|
126 | + $value = date_i18n(give_date_format(), strtotime($item['date_created'])); |
|
127 | 127 | break; |
128 | 128 | |
129 | 129 | default: |
130 | - $value = isset( $item[ $column_name ] ) ? $item[ $column_name ] : null; |
|
130 | + $value = isset($item[$column_name]) ? $item[$column_name] : null; |
|
131 | 131 | break; |
132 | 132 | } |
133 | 133 | |
134 | - return apply_filters( "give_report_column_{$column_name}", $value, $item['id'] ); |
|
134 | + return apply_filters("give_report_column_{$column_name}", $value, $item['id']); |
|
135 | 135 | |
136 | 136 | } |
137 | 137 | |
@@ -142,13 +142,13 @@ discard block |
||
142 | 142 | * |
143 | 143 | * @return string |
144 | 144 | */ |
145 | - public function column_name( $item ) { |
|
146 | - $name = '#' . $item['id'] . ' '; |
|
147 | - $name .= ! empty( $item['name'] ) ? $item['name'] : '<em>' . esc_html__( 'Unnamed Donor', 'give' ) . '</em>'; |
|
148 | - $view_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $item['id'] ); |
|
149 | - $actions = $this->get_row_actions( $item ); |
|
145 | + public function column_name($item) { |
|
146 | + $name = '#'.$item['id'].' '; |
|
147 | + $name .= ! empty($item['name']) ? $item['name'] : '<em>'.esc_html__('Unnamed Donor', 'give').'</em>'; |
|
148 | + $view_url = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$item['id']); |
|
149 | + $actions = $this->get_row_actions($item); |
|
150 | 150 | |
151 | - return '<a href="' . esc_url( $view_url ) . '">' . $name . '</a>' . $this->row_actions( $actions ); |
|
151 | + return '<a href="'.esc_url($view_url).'">'.$name.'</a>'.$this->row_actions($actions); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
@@ -160,14 +160,14 @@ discard block |
||
160 | 160 | */ |
161 | 161 | public function get_columns() { |
162 | 162 | $columns = array( |
163 | - 'name' => esc_html__( 'Name', 'give' ), |
|
164 | - 'email' => esc_html__( 'Email', 'give' ), |
|
165 | - 'num_purchases' => esc_html__( 'Donations', 'give' ), |
|
166 | - 'amount_spent' => esc_html__( 'Total Donated', 'give' ), |
|
167 | - 'date_created' => esc_html__( 'Date Created', 'give' ) |
|
163 | + 'name' => esc_html__('Name', 'give'), |
|
164 | + 'email' => esc_html__('Email', 'give'), |
|
165 | + 'num_purchases' => esc_html__('Donations', 'give'), |
|
166 | + 'amount_spent' => esc_html__('Total Donated', 'give'), |
|
167 | + 'date_created' => esc_html__('Date Created', 'give') |
|
168 | 168 | ); |
169 | 169 | |
170 | - return apply_filters( 'give_report_customer_columns', $columns ); |
|
170 | + return apply_filters('give_report_customer_columns', $columns); |
|
171 | 171 | |
172 | 172 | } |
173 | 173 | |
@@ -180,10 +180,10 @@ discard block |
||
180 | 180 | */ |
181 | 181 | public function get_sortable_columns() { |
182 | 182 | return array( |
183 | - 'date_created' => array( 'date_created', true ), |
|
184 | - 'name' => array( 'name', true ), |
|
185 | - 'num_purchases' => array( 'purchase_count', false ), |
|
186 | - 'amount_spent' => array( 'purchase_value', false ), |
|
183 | + 'date_created' => array('date_created', true), |
|
184 | + 'name' => array('name', true), |
|
185 | + 'num_purchases' => array('purchase_count', false), |
|
186 | + 'amount_spent' => array('purchase_value', false), |
|
187 | 187 | ); |
188 | 188 | } |
189 | 189 | |
@@ -195,34 +195,34 @@ discard block |
||
195 | 195 | * |
196 | 196 | * @return array An array of action links. |
197 | 197 | */ |
198 | - public function get_row_actions( $item ) { |
|
198 | + public function get_row_actions($item) { |
|
199 | 199 | |
200 | 200 | $actions = array( |
201 | 201 | |
202 | 202 | 'view' => sprintf( |
203 | 203 | '<a href="%1$s" aria-label="%2$s">%3$s</a>', |
204 | - admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $item['id'] ), |
|
205 | - sprintf( esc_attr__( 'View "%s"', 'give' ), $item['name'] ), |
|
206 | - esc_html__( 'View Donor', 'give' ) |
|
204 | + admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$item['id']), |
|
205 | + sprintf(esc_attr__('View "%s"', 'give'), $item['name']), |
|
206 | + esc_html__('View Donor', 'give') |
|
207 | 207 | ), |
208 | 208 | |
209 | 209 | 'notes' => sprintf( |
210 | 210 | '<a href="%1$s" aria-label="%2$s">%3$s</a>', |
211 | - admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=notes&id=' . $item['id'] ), |
|
212 | - sprintf( esc_attr__( 'Notes for "%s"', 'give' ), $item['name'] ), |
|
213 | - esc_html__( 'Notes', 'give' ) |
|
211 | + admin_url('edit.php?post_type=give_forms&page=give-donors&view=notes&id='.$item['id']), |
|
212 | + sprintf(esc_attr__('Notes for "%s"', 'give'), $item['name']), |
|
213 | + esc_html__('Notes', 'give') |
|
214 | 214 | ), |
215 | 215 | |
216 | 216 | 'delete' => sprintf( |
217 | 217 | '<a href="%1$s" aria-label="%2$s">%3$s</a>', |
218 | - admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $item['id'] ), |
|
219 | - sprintf( esc_attr__( 'Delete "%s"', 'give' ), $item['name'] ), |
|
220 | - esc_html__( 'Delete', 'give' ) |
|
218 | + admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$item['id']), |
|
219 | + sprintf(esc_attr__('Delete "%s"', 'give'), $item['name']), |
|
220 | + esc_html__('Delete', 'give') |
|
221 | 221 | ) |
222 | 222 | |
223 | 223 | ); |
224 | 224 | |
225 | - return apply_filters( 'give_donor_row_actions', $actions, $item ); |
|
225 | + return apply_filters('give_donor_row_actions', $actions, $item); |
|
226 | 226 | |
227 | 227 | } |
228 | 228 | |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | * @since 1.0 |
234 | 234 | * @return void |
235 | 235 | */ |
236 | - public function bulk_actions( $which = '' ) { |
|
236 | + public function bulk_actions($which = '') { |
|
237 | 237 | // These aren't really bulk actions but this outputs the markup in the right place. |
238 | 238 | } |
239 | 239 | |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | * @return int Current page number. |
246 | 246 | */ |
247 | 247 | public function get_paged() { |
248 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
248 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | /** |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | * @return mixed string If search is present, false otherwise. |
257 | 257 | */ |
258 | 258 | public function get_search() { |
259 | - return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
|
259 | + return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false; |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | /** |
@@ -273,10 +273,10 @@ discard block |
||
273 | 273 | |
274 | 274 | $data = array(); |
275 | 275 | $paged = $this->get_paged(); |
276 | - $offset = $this->per_page * ( $paged - 1 ); |
|
276 | + $offset = $this->per_page * ($paged - 1); |
|
277 | 277 | $search = $this->get_search(); |
278 | - $order = isset( $_GET['order'] ) ? sanitize_text_field( $_GET['order'] ) : 'DESC'; |
|
279 | - $orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( $_GET['orderby'] ) : 'id'; |
|
278 | + $order = isset($_GET['order']) ? sanitize_text_field($_GET['order']) : 'DESC'; |
|
279 | + $orderby = isset($_GET['orderby']) ? sanitize_text_field($_GET['orderby']) : 'id'; |
|
280 | 280 | |
281 | 281 | $args = array( |
282 | 282 | 'number' => $this->per_page, |
@@ -285,21 +285,21 @@ discard block |
||
285 | 285 | 'orderby' => $orderby |
286 | 286 | ); |
287 | 287 | |
288 | - if ( is_email( $search ) ) { |
|
288 | + if (is_email($search)) { |
|
289 | 289 | $args['email'] = $search; |
290 | - } elseif ( is_numeric( $search ) ) { |
|
290 | + } elseif (is_numeric($search)) { |
|
291 | 291 | $args['id'] = $search; |
292 | 292 | } else { |
293 | 293 | $args['name'] = $search; |
294 | 294 | } |
295 | 295 | |
296 | - $customers = Give()->customers->get_customers( $args ); |
|
296 | + $customers = Give()->customers->get_customers($args); |
|
297 | 297 | |
298 | - if ( $customers ) { |
|
298 | + if ($customers) { |
|
299 | 299 | |
300 | - foreach ( $customers as $customer ) { |
|
300 | + foreach ($customers as $customer) { |
|
301 | 301 | |
302 | - $user_id = ! empty( $customer->user_id ) ? intval( $customer->user_id ) : 0; |
|
302 | + $user_id = ! empty($customer->user_id) ? intval($customer->user_id) : 0; |
|
303 | 303 | |
304 | 304 | $data[] = array( |
305 | 305 | 'id' => $customer->id, |
@@ -333,16 +333,16 @@ discard block |
||
333 | 333 | $hidden = array(); // No hidden columns |
334 | 334 | $sortable = $this->get_sortable_columns(); |
335 | 335 | |
336 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
336 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
337 | 337 | |
338 | 338 | $this->items = $this->reports_data(); |
339 | 339 | |
340 | 340 | $this->total = give_count_total_customers(); |
341 | 341 | |
342 | - $this->set_pagination_args( array( |
|
342 | + $this->set_pagination_args(array( |
|
343 | 343 | 'total_items' => $this->total, |
344 | 344 | 'per_page' => $this->per_page, |
345 | - 'total_pages' => ceil( $this->total / $this->per_page ) |
|
346 | - ) ); |
|
345 | + 'total_pages' => ceil($this->total / $this->per_page) |
|
346 | + )); |
|
347 | 347 | } |
348 | 348 | } |
349 | 349 | \ No newline at end of file |
@@ -173,8 +173,8 @@ |
||
173 | 173 | |
174 | 174 | case 'num_purchases' : |
175 | 175 | $value = '<a href="' . |
176 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . urlencode( $item['email'] ) |
|
177 | - ) . '">' . esc_html( $item['num_purchases'] ) . '</a>'; |
|
176 | + admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . urlencode( $item['email'] ) |
|
177 | + ) . '">' . esc_html( $item['num_purchases'] ) . '</a>'; |
|
178 | 178 | break; |
179 | 179 | |
180 | 180 | case 'amount_spent' : |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -24,9 +24,9 @@ discard block |
||
24 | 24 | */ |
25 | 25 | function give_customers_page() { |
26 | 26 | $default_views = give_customer_views(); |
27 | - $requested_view = isset( $_GET['view'] ) ? sanitize_text_field( $_GET['view'] ) : 'customers'; |
|
28 | - if ( array_key_exists( $requested_view, $default_views ) && function_exists( $default_views[ $requested_view ] ) ) { |
|
29 | - give_render_customer_view( $requested_view, $default_views ); |
|
27 | + $requested_view = isset($_GET['view']) ? sanitize_text_field($_GET['view']) : 'customers'; |
|
28 | + if (array_key_exists($requested_view, $default_views) && function_exists($default_views[$requested_view])) { |
|
29 | + give_render_customer_view($requested_view, $default_views); |
|
30 | 30 | } else { |
31 | 31 | give_customers_list(); |
32 | 32 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | |
43 | 43 | $views = array(); |
44 | 44 | |
45 | - return apply_filters( 'give_customer_views', $views ); |
|
45 | + return apply_filters('give_customer_views', $views); |
|
46 | 46 | |
47 | 47 | } |
48 | 48 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | |
57 | 57 | $tabs = array(); |
58 | 58 | |
59 | - return apply_filters( 'give_customer_tabs', $tabs ); |
|
59 | + return apply_filters('give_customer_tabs', $tabs); |
|
60 | 60 | |
61 | 61 | } |
62 | 62 | |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @return void |
68 | 68 | */ |
69 | 69 | function give_customers_list() { |
70 | - include( dirname( __FILE__ ) . '/class-customer-table.php' ); |
|
70 | + include(dirname(__FILE__).'/class-customer-table.php'); |
|
71 | 71 | |
72 | 72 | $customers_table = new Give_Customer_Reports_Table(); |
73 | 73 | $customers_table->prepare_items(); |
@@ -80,11 +80,11 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @since 1.0 |
82 | 82 | */ |
83 | - do_action( 'give_donors_table_top' ); |
|
83 | + do_action('give_donors_table_top'); |
|
84 | 84 | ?> |
85 | - <form id="give-donors-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors' ); ?>"> |
|
85 | + <form id="give-donors-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors'); ?>"> |
|
86 | 86 | <?php |
87 | - $customers_table->search_box( esc_html__( 'Search Donors', 'give' ), 'give-donors' ); |
|
87 | + $customers_table->search_box(esc_html__('Search Donors', 'give'), 'give-donors'); |
|
88 | 88 | $customers_table->display(); |
89 | 89 | ?> |
90 | 90 | <input type="hidden" name="post_type" value="give_forms" /> |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * |
98 | 98 | * @since 1.0 |
99 | 99 | */ |
100 | - do_action( 'give_donors_table_bottom' ); |
|
100 | + do_action('give_donors_table_bottom'); |
|
101 | 101 | ?> |
102 | 102 | </div> |
103 | 103 | <?php |
@@ -113,27 +113,27 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return void |
115 | 115 | */ |
116 | -function give_render_customer_view( $view, $callbacks ) { |
|
116 | +function give_render_customer_view($view, $callbacks) { |
|
117 | 117 | |
118 | 118 | $render = true; |
119 | 119 | |
120 | - $customer_view_role = apply_filters( 'give_view_customers_role', 'view_give_reports' ); |
|
120 | + $customer_view_role = apply_filters('give_view_customers_role', 'view_give_reports'); |
|
121 | 121 | |
122 | - if ( ! current_user_can( $customer_view_role ) ) { |
|
123 | - give_set_error( 'give-no-access', esc_html__( 'You are not permitted to view this data.', 'give' ) ); |
|
122 | + if ( ! current_user_can($customer_view_role)) { |
|
123 | + give_set_error('give-no-access', esc_html__('You are not permitted to view this data.', 'give')); |
|
124 | 124 | $render = false; |
125 | 125 | } |
126 | 126 | |
127 | - if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
128 | - give_set_error( 'give-invalid_customer', esc_html__( 'Invalid Donor ID.', 'give' ) ); |
|
127 | + if ( ! isset($_GET['id']) || ! is_numeric($_GET['id'])) { |
|
128 | + give_set_error('give-invalid_customer', esc_html__('Invalid Donor ID.', 'give')); |
|
129 | 129 | $render = false; |
130 | 130 | } |
131 | 131 | |
132 | 132 | $customer_id = (int) $_GET['id']; |
133 | - $customer = new Give_Customer( $customer_id ); |
|
133 | + $customer = new Give_Customer($customer_id); |
|
134 | 134 | |
135 | - if ( empty( $customer->id ) ) { |
|
136 | - give_set_error( 'give-invalid_customer', esc_html__( 'Invalid Donor ID.', 'give' ) ); |
|
135 | + if (empty($customer->id)) { |
|
136 | + give_set_error('give-invalid_customer', esc_html__('Invalid Donor ID.', 'give')); |
|
137 | 137 | $render = false; |
138 | 138 | } |
139 | 139 | |
@@ -142,34 +142,34 @@ discard block |
||
142 | 142 | |
143 | 143 | <div class='wrap'> |
144 | 144 | |
145 | - <?php if ( give_get_errors() ) : ?> |
|
145 | + <?php if (give_get_errors()) : ?> |
|
146 | 146 | <div class="error settings-error"> |
147 | - <?php give_print_errors( 0 ); ?> |
|
147 | + <?php give_print_errors(0); ?> |
|
148 | 148 | </div> |
149 | 149 | <?php endif; ?> |
150 | 150 | |
151 | - <h1 class="screen-reader-text"><?php esc_html_e( 'Donor', 'give' ); ?></h1> |
|
151 | + <h1 class="screen-reader-text"><?php esc_html_e('Donor', 'give'); ?></h1> |
|
152 | 152 | |
153 | - <?php if ( $customer && $render ) : ?> |
|
153 | + <?php if ($customer && $render) : ?> |
|
154 | 154 | |
155 | 155 | <h2 class="nav-tab-wrapper"> |
156 | 156 | <?php |
157 | - foreach ( $customer_tabs as $key => $tab ) : |
|
157 | + foreach ($customer_tabs as $key => $tab) : |
|
158 | 158 | $active = $key === $view ? true : false; |
159 | 159 | $class = $active ? 'nav-tab nav-tab-active' : 'nav-tab'; |
160 | 160 | printf( |
161 | 161 | '<a href="%1$s" class="%2$s"><span class="dashicons %3$s"></span>%4$s</a>'."\n", |
162 | - esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=' . $key . '&id=' . $customer->id ) ), |
|
163 | - esc_attr( $class ), |
|
164 | - sanitize_html_class( $tab['dashicon'] ), |
|
165 | - esc_html( $tab['title'] ) |
|
162 | + esc_url(admin_url('edit.php?post_type=give_forms&page=give-donors&view='.$key.'&id='.$customer->id)), |
|
163 | + esc_attr($class), |
|
164 | + sanitize_html_class($tab['dashicon']), |
|
165 | + esc_html($tab['title']) |
|
166 | 166 | ); |
167 | 167 | endforeach; |
168 | 168 | ?> |
169 | 169 | </h2> |
170 | 170 | |
171 | 171 | <div id="give-customer-card-wrapper"> |
172 | - <?php $callbacks[ $view ]( $customer ) ?> |
|
172 | + <?php $callbacks[$view]($customer) ?> |
|
173 | 173 | </div> |
174 | 174 | |
175 | 175 | <?php endif; ?> |
@@ -189,9 +189,9 @@ discard block |
||
189 | 189 | * |
190 | 190 | * @return void |
191 | 191 | */ |
192 | -function give_customers_view( $customer ) { |
|
192 | +function give_customers_view($customer) { |
|
193 | 193 | |
194 | - $customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' ); |
|
194 | + $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments'); |
|
195 | 195 | |
196 | 196 | /** |
197 | 197 | * Fires in donor profile screen, above the donor card. |
@@ -200,32 +200,32 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @param object $customer The customer object being displayed. |
202 | 202 | */ |
203 | - do_action( 'give_donor_card_top', $customer ); |
|
203 | + do_action('give_donor_card_top', $customer); |
|
204 | 204 | ?> |
205 | 205 | |
206 | 206 | <div id="donor-summary" class="info-wrapper customer-section postbox"> |
207 | 207 | |
208 | - <form id="edit-customer-info" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer->id ); ?>"> |
|
208 | + <form id="edit-customer-info" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer->id); ?>"> |
|
209 | 209 | |
210 | 210 | <div class="customer-info"> |
211 | 211 | |
212 | 212 | <div class="donor-bio-header clearfix"> |
213 | 213 | |
214 | 214 | <div class="avatar-wrap left" id="customer-avatar"> |
215 | - <?php echo get_avatar( $customer->email ); ?> |
|
215 | + <?php echo get_avatar($customer->email); ?> |
|
216 | 216 | </div> |
217 | 217 | |
218 | 218 | <div id="customer-name-wrap" class="left"> |
219 | 219 | <span class="customer-id">#<?php echo $customer->id; ?></span> |
220 | - <span class="customer-name info-item edit-item"><input size="15" data-key="name" name="customerinfo[name]" type="text" value="<?php echo esc_attr( $customer->name ); ?>" placeholder="<?php esc_attr_e( 'Donor Name', 'give' ); ?>" /></span> |
|
220 | + <span class="customer-name info-item edit-item"><input size="15" data-key="name" name="customerinfo[name]" type="text" value="<?php echo esc_attr($customer->name); ?>" placeholder="<?php esc_attr_e('Donor Name', 'give'); ?>" /></span> |
|
221 | 221 | <span class="customer-name info-item editable"><span data-key="name"><?php echo $customer->name; ?></span></span> |
222 | 222 | </div> |
223 | 223 | <p class="customer-since info-item"> |
224 | - <?php esc_html_e( 'Donor since', 'give' ); ?> |
|
225 | - <?php echo date_i18n( give_date_format(), strtotime( $customer->date_created ) ) ?> |
|
224 | + <?php esc_html_e('Donor since', 'give'); ?> |
|
225 | + <?php echo date_i18n(give_date_format(), strtotime($customer->date_created)) ?> |
|
226 | 226 | </p> |
227 | - <?php if ( current_user_can( $customer_edit_role ) ): ?> |
|
228 | - <a href="#" id="edit-customer" class="button info-item editable customer-edit-link"><?php esc_html_e( 'Edit Donor', 'give' ); ?></a> |
|
227 | + <?php if (current_user_can($customer_edit_role)): ?> |
|
228 | + <a href="#" id="edit-customer" class="button info-item editable customer-edit-link"><?php esc_html_e('Edit Donor', 'give'); ?></a> |
|
229 | 229 | <?php endif; ?> |
230 | 230 | </div> |
231 | 231 | <!-- /donor-bio-header --> |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | <table class="widefat"> |
236 | 236 | <tbody> |
237 | 237 | <tr class="alternate"> |
238 | - <th scope="col"><label for="tablecell"><?php esc_html_e( 'User ID:', 'give' ); ?></label></th> |
|
238 | + <th scope="col"><label for="tablecell"><?php esc_html_e('User ID:', 'give'); ?></label></th> |
|
239 | 239 | <td class="row-title"> |
240 | 240 | <span class="customer-user-id info-item edit-item"> |
241 | 241 | <?php |
@@ -251,38 +251,38 @@ discard block |
||
251 | 251 | 'data' => $data_atts, |
252 | 252 | ); |
253 | 253 | |
254 | - if ( ! empty( $user_id ) ) { |
|
255 | - $userdata = get_userdata( $user_id ); |
|
254 | + if ( ! empty($user_id)) { |
|
255 | + $userdata = get_userdata($user_id); |
|
256 | 256 | $user_args['value'] = $userdata->user_login; |
257 | 257 | } |
258 | 258 | |
259 | - echo Give()->html->ajax_user_search( $user_args ); |
|
259 | + echo Give()->html->ajax_user_search($user_args); |
|
260 | 260 | ?> |
261 | 261 | <input type="hidden" name="customerinfo[user_id]" data-key="user_id" value="<?php echo $customer->user_id; ?>" /> |
262 | 262 | </span> |
263 | 263 | |
264 | 264 | <span class="customer-user-id info-item editable"> |
265 | - <?php if ( intval( $customer->user_id ) > 0 ) { ?> |
|
265 | + <?php if (intval($customer->user_id) > 0) { ?> |
|
266 | 266 | <span data-key="user_id"><?php echo $customer->user_id; ?></span> |
267 | 267 | <?php } else { ?> |
268 | - <span data-key="user_id"><?php esc_html_e( 'None', 'give' ); ?></span> |
|
268 | + <span data-key="user_id"><?php esc_html_e('None', 'give'); ?></span> |
|
269 | 269 | <?php } ?> |
270 | - <?php if ( current_user_can( $customer_edit_role ) && intval( $customer->user_id ) > 0 ) { ?> |
|
271 | - <span class="disconnect-user"> - <a id="disconnect-customer" href="#disconnect" aria-label="<?php esc_attr_e( 'Disconnects the current user ID from this customer record.', 'give' ); ?>"><?php esc_html_e( 'Disconnect User', 'give' ); ?></a></span> |
|
270 | + <?php if (current_user_can($customer_edit_role) && intval($customer->user_id) > 0) { ?> |
|
271 | + <span class="disconnect-user"> - <a id="disconnect-customer" href="#disconnect" aria-label="<?php esc_attr_e('Disconnects the current user ID from this customer record.', 'give'); ?>"><?php esc_html_e('Disconnect User', 'give'); ?></a></span> |
|
272 | 272 | <?php } ?> |
273 | 273 | </span> |
274 | 274 | </td> |
275 | 275 | </tr> |
276 | - <?php if ( isset( $customer->user_id ) && $customer->user_id > 0 ) : ?> |
|
276 | + <?php if (isset($customer->user_id) && $customer->user_id > 0) : ?> |
|
277 | 277 | |
278 | 278 | <tr> |
279 | - <th scope="col"><?php esc_html_e( 'Address:', 'give' ); ?></th> |
|
279 | + <th scope="col"><?php esc_html_e('Address:', 'give'); ?></th> |
|
280 | 280 | <td class="row-title"> |
281 | 281 | |
282 | 282 | <div class="customer-address-wrapper"> |
283 | 283 | |
284 | 284 | <?php |
285 | - $address = get_user_meta( $customer->user_id, '_give_user_address', true ); |
|
285 | + $address = get_user_meta($customer->user_id, '_give_user_address', true); |
|
286 | 286 | $defaults = array( |
287 | 287 | 'line1' => '', |
288 | 288 | 'line2' => '', |
@@ -292,10 +292,10 @@ discard block |
||
292 | 292 | 'zip' => '' |
293 | 293 | ); |
294 | 294 | |
295 | - $address = wp_parse_args( $address, $defaults ); |
|
295 | + $address = wp_parse_args($address, $defaults); |
|
296 | 296 | ?> |
297 | 297 | |
298 | - <?php if ( ! empty( $address ) ) { ?> |
|
298 | + <?php if ( ! empty($address)) { ?> |
|
299 | 299 | <span class="customer-address info-item editable"> |
300 | 300 | <span class="info-item" data-key="line1"><?php echo $address['line1']; ?></span> |
301 | 301 | <span class="info-item" data-key="line2"><?php echo $address['line2']; ?></span> |
@@ -306,43 +306,43 @@ discard block |
||
306 | 306 | </span> |
307 | 307 | <?php } ?> |
308 | 308 | <span class="customer-address info-item edit-item"> |
309 | - <input class="info-item" type="text" data-key="line1" name="customerinfo[line1]" placeholder="<?php esc_attr_e( 'Address 1', 'give' ); ?>" value="<?php echo $address['line1']; ?>" /> |
|
310 | - <input class="info-item" type="text" data-key="line2" name="customerinfo[line2]" placeholder="<?php esc_attr_e( 'Address 2', 'give' ); ?>" value="<?php echo $address['line2']; ?>" /> |
|
311 | - <input class="info-item" type="text" data-key="city" name="customerinfo[city]" placeholder="<?php esc_attr_e( 'City', 'give' ); ?>" value="<?php echo $address['city']; ?>" /> |
|
309 | + <input class="info-item" type="text" data-key="line1" name="customerinfo[line1]" placeholder="<?php esc_attr_e('Address 1', 'give'); ?>" value="<?php echo $address['line1']; ?>" /> |
|
310 | + <input class="info-item" type="text" data-key="line2" name="customerinfo[line2]" placeholder="<?php esc_attr_e('Address 2', 'give'); ?>" value="<?php echo $address['line2']; ?>" /> |
|
311 | + <input class="info-item" type="text" data-key="city" name="customerinfo[city]" placeholder="<?php esc_attr_e('City', 'give'); ?>" value="<?php echo $address['city']; ?>" /> |
|
312 | 312 | <select data-key="country" name="customerinfo[country]" id="billing_country" class="billing_country give-select edit-item"> |
313 | 313 | <?php |
314 | 314 | |
315 | 315 | $selected_country = $address['country']; |
316 | 316 | |
317 | 317 | $countries = give_get_country_list(); |
318 | - foreach ( $countries as $country_code => $country ) { |
|
319 | - echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>'; |
|
318 | + foreach ($countries as $country_code => $country) { |
|
319 | + echo '<option value="'.esc_attr($country_code).'"'.selected($country_code, $selected_country, false).'>'.$country.'</option>'; |
|
320 | 320 | } |
321 | 321 | ?> |
322 | 322 | </select> |
323 | 323 | <?php |
324 | 324 | $selected_state = give_get_state(); |
325 | - $states = give_get_states( $selected_country ); |
|
325 | + $states = give_get_states($selected_country); |
|
326 | 326 | |
327 | - $selected_state = isset( $address['state'] ) ? $address['state'] : $selected_state; |
|
327 | + $selected_state = isset($address['state']) ? $address['state'] : $selected_state; |
|
328 | 328 | |
329 | - if ( ! empty( $states ) ) { |
|
329 | + if ( ! empty($states)) { |
|
330 | 330 | ?> |
331 | 331 | <select data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-select info-item"> |
332 | 332 | <?php |
333 | - foreach ( $states as $state_code => $state ) { |
|
334 | - echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>'; |
|
333 | + foreach ($states as $state_code => $state) { |
|
334 | + echo '<option value="'.$state_code.'"'.selected($state_code, $selected_state, false).'>'.$state.'</option>'; |
|
335 | 335 | } |
336 | 336 | ?> |
337 | 337 | </select> |
338 | 338 | <?php |
339 | 339 | } else { |
340 | 340 | ?> |
341 | - <input type="text" size="6" data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-input info-item" placeholder="<?php esc_attr_e( 'State / Province', 'give' ); ?>" /> |
|
341 | + <input type="text" size="6" data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-input info-item" placeholder="<?php esc_attr_e('State / Province', 'give'); ?>" /> |
|
342 | 342 | <?php |
343 | 343 | } |
344 | 344 | ?> |
345 | - <input class="info-item" type="text" data-key="zip" name="customerinfo[zip]" placeholder="<?php esc_attr_e( 'Zip / Postal Code', 'give' ); ?>" value="<?php echo $address['zip']; ?>" /> |
|
345 | + <input class="info-item" type="text" data-key="zip" name="customerinfo[zip]" placeholder="<?php esc_attr_e('Zip / Postal Code', 'give'); ?>" value="<?php echo $address['zip']; ?>" /> |
|
346 | 346 | </span> |
347 | 347 | |
348 | 348 | </div> |
@@ -358,10 +358,10 @@ discard block |
||
358 | 358 | |
359 | 359 | <span id="customer-edit-actions" class="edit-item"> |
360 | 360 | <input type="hidden" data-key="id" name="customerinfo[id]" value="<?php echo $customer->id; ?>" /> |
361 | - <?php wp_nonce_field( 'edit-customer', '_wpnonce', false, true ); ?> |
|
361 | + <?php wp_nonce_field('edit-customer', '_wpnonce', false, true); ?> |
|
362 | 362 | <input type="hidden" name="give_action" value="edit-customer" /> |
363 | - <input type="submit" id="give-edit-customer-save" class="button-secondary" value="<?php esc_attr_e( 'Update Donor', 'give' ); ?>" /> |
|
364 | - <a id="give-edit-customer-cancel" href="" class="delete"><?php esc_html_e( 'Cancel', 'give' ); ?></a> |
|
363 | + <input type="submit" id="give-edit-customer-save" class="button-secondary" value="<?php esc_attr_e('Update Donor', 'give'); ?>" /> |
|
364 | + <a id="give-edit-customer-cancel" href="" class="delete"><?php esc_html_e('Cancel', 'give'); ?></a> |
|
365 | 365 | </span> |
366 | 366 | |
367 | 367 | </form> |
@@ -376,24 +376,24 @@ discard block |
||
376 | 376 | * |
377 | 377 | * @param object $customer The customer object being displayed. |
378 | 378 | */ |
379 | - do_action( 'give_donor_before_stats', $customer ); |
|
379 | + do_action('give_donor_before_stats', $customer); |
|
380 | 380 | ?> |
381 | 381 | |
382 | 382 | <div id="customer-stats-wrapper" class="customer-section postbox clear"> |
383 | 383 | <ul> |
384 | 384 | <li> |
385 | - <a href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . urlencode( $customer->email ) ); ?>"> |
|
385 | + <a href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history&user='.urlencode($customer->email)); ?>"> |
|
386 | 386 | <span class="dashicons dashicons-heart"></span> |
387 | 387 | <?php |
388 | 388 | //Completed Donations |
389 | - $completed_donations_text = sprintf( _n( '%d Completed Donation', '%d Completed Donations', $customer->purchase_count, 'give' ), $customer->purchase_count ); |
|
390 | - echo apply_filters( 'give_donor_completed_donations', $completed_donations_text, $customer ); |
|
389 | + $completed_donations_text = sprintf(_n('%d Completed Donation', '%d Completed Donations', $customer->purchase_count, 'give'), $customer->purchase_count); |
|
390 | + echo apply_filters('give_donor_completed_donations', $completed_donations_text, $customer); |
|
391 | 391 | ?> |
392 | 392 | </a> |
393 | 393 | </li> |
394 | 394 | <li> |
395 | 395 | <span class="dashicons dashicons-chart-area"></span> |
396 | - <?php echo give_currency_filter( give_format_amount( $customer->purchase_value ) ); ?> <?php esc_html_e( 'Lifetime Donations', 'give' ); ?> |
|
396 | + <?php echo give_currency_filter(give_format_amount($customer->purchase_value)); ?> <?php esc_html_e('Lifetime Donations', 'give'); ?> |
|
397 | 397 | </li> |
398 | 398 | <?php |
399 | 399 | /** |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | * |
406 | 406 | * @param object $customer The customer object being displayed. |
407 | 407 | */ |
408 | - do_action( 'give_donor_stats_list', $customer ); |
|
408 | + do_action('give_donor_stats_list', $customer); |
|
409 | 409 | ?> |
410 | 410 | </ul> |
411 | 411 | </div> |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | * |
419 | 419 | * @param object $customer The customer object being displayed. |
420 | 420 | */ |
421 | - do_action( 'give_donor_before_tables_wrapper', $customer ); |
|
421 | + do_action('give_donor_before_tables_wrapper', $customer); |
|
422 | 422 | ?> |
423 | 423 | |
424 | 424 | <div id="customer-tables-wrapper" class="customer-section"> |
@@ -431,40 +431,40 @@ discard block |
||
431 | 431 | * |
432 | 432 | * @param object $customer The customer object being displayed. |
433 | 433 | */ |
434 | - do_action( 'give_donor_before_tables', $customer ); |
|
434 | + do_action('give_donor_before_tables', $customer); |
|
435 | 435 | ?> |
436 | 436 | |
437 | - <h3><?php _e( 'Donor Emails', 'give' ); ?></h3> |
|
437 | + <h3><?php _e('Donor Emails', 'give'); ?></h3> |
|
438 | 438 | |
439 | 439 | <table class="wp-list-table widefat striped emails"> |
440 | 440 | <thead> |
441 | 441 | <tr> |
442 | - <th><?php _e( 'Email', 'give' ); ?></th> |
|
443 | - <th><?php _e( 'Actions', 'give' ); ?></th> |
|
442 | + <th><?php _e('Email', 'give'); ?></th> |
|
443 | + <th><?php _e('Actions', 'give'); ?></th> |
|
444 | 444 | </tr> |
445 | 445 | </thead> |
446 | 446 | |
447 | 447 | <tbody> |
448 | - <?php if ( ! empty( $customer->emails ) ) { ?> |
|
448 | + <?php if ( ! empty($customer->emails)) { ?> |
|
449 | 449 | |
450 | - <?php foreach ( $customer->emails as $key => $email ) : ?> |
|
450 | + <?php foreach ($customer->emails as $key => $email) : ?> |
|
451 | 451 | <tr data-key="<?php echo $key; ?>"> |
452 | 452 | <td> |
453 | 453 | <?php echo $email; ?> |
454 | - <?php if ( 'primary' === $key ) : ?> |
|
454 | + <?php if ('primary' === $key) : ?> |
|
455 | 455 | <span class="dashicons dashicons-star-filled primary-email-icon"></span> |
456 | 456 | <?php endif; ?> |
457 | 457 | </td> |
458 | 458 | <td> |
459 | - <?php if ( 'primary' !== $key ) : ?> |
|
459 | + <?php if ('primary' !== $key) : ?> |
|
460 | 460 | <?php |
461 | - $base_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer->id ); |
|
462 | - $promote_url = wp_nonce_url( add_query_arg( array( 'email' => rawurlencode( $email ), 'give_action' => 'set_donor_primary_email'), $base_url ), 'give-set-donor-primary-email' ); |
|
463 | - $remove_url = wp_nonce_url( add_query_arg( array( 'email' => rawurlencode( $email ), 'give_action' => 'remove_donor_email' ), $base_url ), 'give-remove-donor-email' ); |
|
461 | + $base_url = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer->id); |
|
462 | + $promote_url = wp_nonce_url(add_query_arg(array('email' => rawurlencode($email), 'give_action' => 'set_donor_primary_email'), $base_url), 'give-set-donor-primary-email'); |
|
463 | + $remove_url = wp_nonce_url(add_query_arg(array('email' => rawurlencode($email), 'give_action' => 'remove_donor_email'), $base_url), 'give-remove-donor-email'); |
|
464 | 464 | ?> |
465 | - <a href="<?php echo $promote_url; ?>"><?php _e( 'Make Primary', 'give' ); ?></a> |
|
465 | + <a href="<?php echo $promote_url; ?>"><?php _e('Make Primary', 'give'); ?></a> |
|
466 | 466 | | |
467 | - <a href="<?php echo $remove_url; ?>" class="delete"><?php _e( 'Remove', 'give' ); ?></a> |
|
467 | + <a href="<?php echo $remove_url; ?>" class="delete"><?php _e('Remove', 'give'); ?></a> |
|
468 | 468 | <?php endif; ?> |
469 | 469 | </td> |
470 | 470 | </tr> |
@@ -474,56 +474,56 @@ discard block |
||
474 | 474 | <td colspan="2" class="add-customer-email-td"> |
475 | 475 | <div class="add-customer-email-wrapper"> |
476 | 476 | <input type="hidden" name="customer-id" value="<?php echo $customer->id; ?>" /> |
477 | - <?php wp_nonce_field( 'give_add_donor_email', 'add_email_nonce', false, true ); ?> |
|
478 | - <input type="email" name="additional-email" value="" placeholder="<?php _e( 'Email Address', 'give' ); ?>" /> |
|
479 | - <input type="checkbox" name="make-additional-primary" value="1" id="make-additional-primary" /> <label for="make-additional-primary"><?php _e( 'Make Primary', 'give' ); ?></label> |
|
480 | - <button class="button-secondary give-add-customer-email" id="add-customer-email"><?php _e( 'Add Email', 'give' ); ?></button> |
|
477 | + <?php wp_nonce_field('give_add_donor_email', 'add_email_nonce', false, true); ?> |
|
478 | + <input type="email" name="additional-email" value="" placeholder="<?php _e('Email Address', 'give'); ?>" /> |
|
479 | + <input type="checkbox" name="make-additional-primary" value="1" id="make-additional-primary" /> <label for="make-additional-primary"><?php _e('Make Primary', 'give'); ?></label> |
|
480 | + <button class="button-secondary give-add-customer-email" id="add-customer-email"><?php _e('Add Email', 'give'); ?></button> |
|
481 | 481 | <span class="spinner"></span> |
482 | 482 | </div> |
483 | 483 | <div class="notice-wrap"></div> |
484 | 484 | </td> |
485 | 485 | </tr> |
486 | 486 | <?php } else { ?> |
487 | - <tr><td colspan="2"><?php _e( 'No Emails Found', 'easy-digital-downloads' ); ?></td></tr> |
|
487 | + <tr><td colspan="2"><?php _e('No Emails Found', 'easy-digital-downloads'); ?></td></tr> |
|
488 | 488 | <?php } ?> |
489 | 489 | </tbody> |
490 | 490 | </table> |
491 | 491 | |
492 | - <h3><?php esc_html_e( 'Recent Donations', 'give' ); ?></h3> |
|
492 | + <h3><?php esc_html_e('Recent Donations', 'give'); ?></h3> |
|
493 | 493 | <?php |
494 | - $payment_ids = explode( ',', $customer->payment_ids ); |
|
495 | - $payments = give_get_payments( array( 'post__in' => $payment_ids ) ); |
|
496 | - $payments = array_slice( $payments, 0, 10 ); |
|
494 | + $payment_ids = explode(',', $customer->payment_ids); |
|
495 | + $payments = give_get_payments(array('post__in' => $payment_ids)); |
|
496 | + $payments = array_slice($payments, 0, 10); |
|
497 | 497 | ?> |
498 | 498 | <table class="wp-list-table widefat striped payments"> |
499 | 499 | <thead> |
500 | 500 | <tr> |
501 | - <th scope="col"><?php esc_html_e( 'ID', 'give' ); ?></th> |
|
502 | - <th scope="col"><?php esc_html_e( 'Amount', 'give' ); ?></th> |
|
503 | - <th scope="col"><?php esc_html_e( 'Date', 'give' ); ?></th> |
|
504 | - <th scope="col"><?php esc_html_e( 'Status', 'give' ); ?></th> |
|
505 | - <th scope="col"><?php esc_html_e( 'Actions', 'give' ); ?></th> |
|
501 | + <th scope="col"><?php esc_html_e('ID', 'give'); ?></th> |
|
502 | + <th scope="col"><?php esc_html_e('Amount', 'give'); ?></th> |
|
503 | + <th scope="col"><?php esc_html_e('Date', 'give'); ?></th> |
|
504 | + <th scope="col"><?php esc_html_e('Status', 'give'); ?></th> |
|
505 | + <th scope="col"><?php esc_html_e('Actions', 'give'); ?></th> |
|
506 | 506 | </tr> |
507 | 507 | </thead> |
508 | 508 | <tbody> |
509 | - <?php if ( ! empty( $payments ) ) { ?> |
|
510 | - <?php foreach ( $payments as $payment ) : ?> |
|
509 | + <?php if ( ! empty($payments)) { ?> |
|
510 | + <?php foreach ($payments as $payment) : ?> |
|
511 | 511 | <tr> |
512 | 512 | <td><?php echo $payment->ID; ?></td> |
513 | - <td><?php echo give_payment_amount( $payment->ID ); ?></td> |
|
514 | - <td><?php echo date_i18n( give_date_format(), strtotime( $payment->post_date ) ); ?></td> |
|
515 | - <td><?php echo give_get_payment_status( $payment, true ); ?></td> |
|
513 | + <td><?php echo give_payment_amount($payment->ID); ?></td> |
|
514 | + <td><?php echo date_i18n(give_date_format(), strtotime($payment->post_date)); ?></td> |
|
515 | + <td><?php echo give_get_payment_status($payment, true); ?></td> |
|
516 | 516 | <td> |
517 | 517 | <?php |
518 | 518 | printf( |
519 | 519 | '<a href="%1$s" aria-label="%2$s">%3$s</a>', |
520 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $payment->ID ), |
|
520 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id='.$payment->ID), |
|
521 | 521 | sprintf( |
522 | 522 | /* translators: %s: Donation ID */ |
523 | - esc_attr__( 'View Donation %s.', 'give' ), |
|
523 | + esc_attr__('View Donation %s.', 'give'), |
|
524 | 524 | $payment->ID |
525 | 525 | ), |
526 | - esc_html__( 'View Donation', 'give' ) |
|
526 | + esc_html__('View Donation', 'give') |
|
527 | 527 | ); |
528 | 528 | ?> |
529 | 529 | |
@@ -538,46 +538,46 @@ discard block |
||
538 | 538 | * @param object $customer The customer object being displayed. |
539 | 539 | * @param object $payment The payment object being displayed. |
540 | 540 | */ |
541 | - do_action( 'give_donor_recent_purchases_actions', $customer, $payment ); |
|
541 | + do_action('give_donor_recent_purchases_actions', $customer, $payment); |
|
542 | 542 | ?> |
543 | 543 | </td> |
544 | 544 | </tr> |
545 | 545 | <?php endforeach; ?> |
546 | 546 | <?php } else { ?> |
547 | 547 | <tr> |
548 | - <td colspan="5"><?php esc_html_e( 'No donations found.', 'give' ); ?></td> |
|
548 | + <td colspan="5"><?php esc_html_e('No donations found.', 'give'); ?></td> |
|
549 | 549 | </tr> |
550 | 550 | <?php } ?> |
551 | 551 | </tbody> |
552 | 552 | </table> |
553 | 553 | |
554 | - <h3><?php esc_html_e( 'Completed Forms', 'give' ); ?></h3> |
|
554 | + <h3><?php esc_html_e('Completed Forms', 'give'); ?></h3> |
|
555 | 555 | <?php |
556 | - $donations = give_get_users_completed_donations( $customer->email ); |
|
556 | + $donations = give_get_users_completed_donations($customer->email); |
|
557 | 557 | ?> |
558 | 558 | <table class="wp-list-table widefat striped donations"> |
559 | 559 | <thead> |
560 | 560 | <tr> |
561 | - <th scope="col"><?php esc_html_e( 'Form', 'give' ); ?></th> |
|
562 | - <th scope="col" width="120px"><?php esc_html_e( 'Actions', 'give' ); ?></th> |
|
561 | + <th scope="col"><?php esc_html_e('Form', 'give'); ?></th> |
|
562 | + <th scope="col" width="120px"><?php esc_html_e('Actions', 'give'); ?></th> |
|
563 | 563 | </tr> |
564 | 564 | </thead> |
565 | 565 | <tbody> |
566 | - <?php if ( ! empty( $donations ) ) { ?> |
|
567 | - <?php foreach ( $donations as $donation ) : ?> |
|
566 | + <?php if ( ! empty($donations)) { ?> |
|
567 | + <?php foreach ($donations as $donation) : ?> |
|
568 | 568 | <tr> |
569 | 569 | <td><?php echo $donation->post_title; ?></td> |
570 | 570 | <td> |
571 | 571 | <?php |
572 | 572 | printf( |
573 | 573 | '<a href="%1$s" aria-label="%2$s">%3$s</a>', |
574 | - esc_url( admin_url( 'post.php?action=edit&post=' . $donation->ID ) ), |
|
574 | + esc_url(admin_url('post.php?action=edit&post='.$donation->ID)), |
|
575 | 575 | sprintf( |
576 | 576 | /* translators: %s: form name */ |
577 | - esc_attr__( 'View Form %s.', 'give' ), |
|
577 | + esc_attr__('View Form %s.', 'give'), |
|
578 | 578 | $donation->post_title |
579 | 579 | ), |
580 | - esc_html__( 'View Form', 'give' ) |
|
580 | + esc_html__('View Form', 'give') |
|
581 | 581 | ); |
582 | 582 | ?> |
583 | 583 | </td> |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | <?php endforeach; ?> |
586 | 586 | <?php } else { ?> |
587 | 587 | <tr> |
588 | - <td colspan="2"><?php esc_html_e( 'No completed donations found.', 'give' ); ?></td> |
|
588 | + <td colspan="2"><?php esc_html_e('No completed donations found.', 'give'); ?></td> |
|
589 | 589 | </tr> |
590 | 590 | <?php } ?> |
591 | 591 | </tbody> |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | * |
600 | 600 | * @param object $customer The customer object being displayed. |
601 | 601 | */ |
602 | - do_action( 'give_donor_after_tables', $customer ); |
|
602 | + do_action('give_donor_after_tables', $customer); |
|
603 | 603 | ?> |
604 | 604 | |
605 | 605 | </div> |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | * |
613 | 613 | * @param object $customer The customer object being displayed. |
614 | 614 | */ |
615 | - do_action( 'give_donor_card_bottom', $customer ); |
|
615 | + do_action('give_donor_card_bottom', $customer); |
|
616 | 616 | |
617 | 617 | } |
618 | 618 | |
@@ -625,30 +625,30 @@ discard block |
||
625 | 625 | * |
626 | 626 | * @return void |
627 | 627 | */ |
628 | -function give_customer_notes_view( $customer ) { |
|
628 | +function give_customer_notes_view($customer) { |
|
629 | 629 | |
630 | - $paged = isset( $_GET['paged'] ) && is_numeric( $_GET['paged'] ) ? $_GET['paged'] : 1; |
|
631 | - $paged = absint( $paged ); |
|
630 | + $paged = isset($_GET['paged']) && is_numeric($_GET['paged']) ? $_GET['paged'] : 1; |
|
631 | + $paged = absint($paged); |
|
632 | 632 | $note_count = $customer->get_notes_count(); |
633 | - $per_page = apply_filters( 'give_customer_notes_per_page', 20 ); |
|
634 | - $total_pages = ceil( $note_count / $per_page ); |
|
635 | - $customer_notes = $customer->get_notes( $per_page, $paged ); |
|
633 | + $per_page = apply_filters('give_customer_notes_per_page', 20); |
|
634 | + $total_pages = ceil($note_count / $per_page); |
|
635 | + $customer_notes = $customer->get_notes($per_page, $paged); |
|
636 | 636 | ?> |
637 | 637 | |
638 | 638 | <div id="customer-notes-wrapper"> |
639 | 639 | <div class="customer-notes-header"> |
640 | - <?php echo get_avatar( $customer->email, 30 ); ?> <span><?php echo $customer->name; ?></span> |
|
640 | + <?php echo get_avatar($customer->email, 30); ?> <span><?php echo $customer->name; ?></span> |
|
641 | 641 | </div> |
642 | - <h3><?php esc_html_e( 'Notes', 'give' ); ?></h3> |
|
642 | + <h3><?php esc_html_e('Notes', 'give'); ?></h3> |
|
643 | 643 | |
644 | - <?php if ( 1 == $paged ) : ?> |
|
644 | + <?php if (1 == $paged) : ?> |
|
645 | 645 | <div style="display: block; margin-bottom: 55px;"> |
646 | - <form id="give-add-customer-note" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=notes&id=' . $customer->id ); ?>"> |
|
646 | + <form id="give-add-customer-note" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=notes&id='.$customer->id); ?>"> |
|
647 | 647 | <textarea id="customer-note" name="customer_note" class="customer-note-input" rows="10"></textarea> |
648 | 648 | <br /> |
649 | 649 | <input type="hidden" id="customer-id" name="customer_id" value="<?php echo $customer->id; ?>" /> |
650 | 650 | <input type="hidden" name="give_action" value="add-customer-note" /> |
651 | - <?php wp_nonce_field( 'add-customer-note', 'add_customer_note_nonce', true, true ); ?> |
|
651 | + <?php wp_nonce_field('add-customer-note', 'add_customer_note_nonce', true, true); ?> |
|
652 | 652 | <input id="add-customer-note" class="right button-primary" type="submit" value="Add Note" /> |
653 | 653 | </form> |
654 | 654 | </div> |
@@ -663,26 +663,26 @@ discard block |
||
663 | 663 | 'show_all' => true |
664 | 664 | ); |
665 | 665 | |
666 | - echo paginate_links( $pagination_args ); |
|
666 | + echo paginate_links($pagination_args); |
|
667 | 667 | ?> |
668 | 668 | |
669 | 669 | <div id="give-customer-notes" class="postbox"> |
670 | - <?php if ( count( $customer_notes ) > 0 ) { ?> |
|
671 | - <?php foreach ( $customer_notes as $key => $note ) : ?> |
|
670 | + <?php if (count($customer_notes) > 0) { ?> |
|
671 | + <?php foreach ($customer_notes as $key => $note) : ?> |
|
672 | 672 | <div class="customer-note-wrapper dashboard-comment-wrap comment-item"> |
673 | 673 | <span class="note-content-wrap"> |
674 | - <?php echo stripslashes( $note ); ?> |
|
674 | + <?php echo stripslashes($note); ?> |
|
675 | 675 | </span> |
676 | 676 | </div> |
677 | 677 | <?php endforeach; ?> |
678 | 678 | <?php } else { ?> |
679 | 679 | <div class="give-no-customer-notes"> |
680 | - <?php esc_html_e( 'No donor notes found.', 'give' ); ?> |
|
680 | + <?php esc_html_e('No donor notes found.', 'give'); ?> |
|
681 | 681 | </div> |
682 | 682 | <?php } ?> |
683 | 683 | </div> |
684 | 684 | |
685 | - <?php echo paginate_links( $pagination_args ); ?> |
|
685 | + <?php echo paginate_links($pagination_args); ?> |
|
686 | 686 | |
687 | 687 | </div> |
688 | 688 | |
@@ -698,9 +698,9 @@ discard block |
||
698 | 698 | * |
699 | 699 | * @return void |
700 | 700 | */ |
701 | -function give_customers_delete_view( $customer ) { |
|
701 | +function give_customers_delete_view($customer) { |
|
702 | 702 | |
703 | - $customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' ); |
|
703 | + $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments'); |
|
704 | 704 | |
705 | 705 | /** |
706 | 706 | * Fires in donor delete screen, above the content. |
@@ -709,15 +709,15 @@ discard block |
||
709 | 709 | * |
710 | 710 | * @param object $customer The customer object being displayed. |
711 | 711 | */ |
712 | - do_action( 'give_customer_delete_top', $customer ); |
|
712 | + do_action('give_customer_delete_top', $customer); |
|
713 | 713 | ?> |
714 | 714 | |
715 | 715 | <div class="info-wrapper customer-section"> |
716 | 716 | |
717 | - <form id="delete-customer" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $customer->id ); ?>"> |
|
717 | + <form id="delete-customer" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$customer->id); ?>"> |
|
718 | 718 | |
719 | 719 | <div class="customer-notes-header"> |
720 | - <?php echo get_avatar( $customer->email, 30 ); ?> <span><?php echo $customer->name; ?></span> |
|
720 | + <?php echo get_avatar($customer->email, 30); ?> <span><?php echo $customer->name; ?></span> |
|
721 | 721 | </div> |
722 | 722 | |
723 | 723 | |
@@ -725,16 +725,16 @@ discard block |
||
725 | 725 | |
726 | 726 | <span class="delete-customer-options"> |
727 | 727 | <p> |
728 | - <?php echo Give()->html->checkbox( array( 'name' => 'give-customer-delete-confirm' ) ); ?> |
|
729 | - <label for="give-customer-delete-confirm"><?php esc_html_e( 'Are you sure you want to delete this donor?', 'give' ); ?></label> |
|
728 | + <?php echo Give()->html->checkbox(array('name' => 'give-customer-delete-confirm')); ?> |
|
729 | + <label for="give-customer-delete-confirm"><?php esc_html_e('Are you sure you want to delete this donor?', 'give'); ?></label> |
|
730 | 730 | </p> |
731 | 731 | |
732 | 732 | <p> |
733 | - <?php echo Give()->html->checkbox( array( |
|
733 | + <?php echo Give()->html->checkbox(array( |
|
734 | 734 | 'name' => 'give-customer-delete-records', |
735 | - 'options' => array( 'disabled' => true ) |
|
736 | - ) ); ?> |
|
737 | - <label for="give-customer-delete-records"><?php esc_html_e( 'Delete all associated donations and records?', 'give' ); ?></label> |
|
735 | + 'options' => array('disabled' => true) |
|
736 | + )); ?> |
|
737 | + <label for="give-customer-delete-records"><?php esc_html_e('Delete all associated donations and records?', 'give'); ?></label> |
|
738 | 738 | </p> |
739 | 739 | |
740 | 740 | <?php |
@@ -747,16 +747,16 @@ discard block |
||
747 | 747 | * |
748 | 748 | * @param object $customer The customer object being displayed. |
749 | 749 | */ |
750 | - do_action( 'give_customer_delete_inputs', $customer ); |
|
750 | + do_action('give_customer_delete_inputs', $customer); |
|
751 | 751 | ?> |
752 | 752 | </span> |
753 | 753 | |
754 | 754 | <span id="customer-edit-actions"> |
755 | 755 | <input type="hidden" name="customer_id" value="<?php echo $customer->id; ?>" /> |
756 | - <?php wp_nonce_field( 'delete-customer', '_wpnonce', false, true ); ?> |
|
756 | + <?php wp_nonce_field('delete-customer', '_wpnonce', false, true); ?> |
|
757 | 757 | <input type="hidden" name="give_action" value="delete-customer" /> |
758 | - <input type="submit" disabled="disabled" id="give-delete-customer" class="button-primary" value="<?php esc_attr_e( 'Delete Donor', 'give' ); ?>" /> |
|
759 | - <a id="give-delete-customer-cancel" href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer->id ); ?>" class="delete"><?php esc_html_e( 'Cancel', 'give' ); ?></a> |
|
758 | + <input type="submit" disabled="disabled" id="give-delete-customer" class="button-primary" value="<?php esc_attr_e('Delete Donor', 'give'); ?>" /> |
|
759 | + <a id="give-delete-customer-cancel" href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer->id); ?>" class="delete"><?php esc_html_e('Cancel', 'give'); ?></a> |
|
760 | 760 | </span> |
761 | 761 | |
762 | 762 | </div> |
@@ -772,5 +772,5 @@ discard block |
||
772 | 772 | * |
773 | 773 | * @param object $customer The customer object being displayed. |
774 | 774 | */ |
775 | - do_action( 'give_customer_delete_bottom', $customer ); |
|
775 | + do_action('give_customer_delete_bottom', $customer); |
|
776 | 776 | } |