@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | * Used to redirect a user back to the purchase |
157 | 157 | * page if there are errors present. |
158 | 158 | * |
159 | - * @param array $args |
|
159 | + * @param string $args |
|
160 | 160 | * |
161 | 161 | * @access public |
162 | 162 | * @since 1.0 |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | * |
391 | 391 | * @param int $form_id Give Form ID |
392 | 392 | * |
393 | - * @return int $earnings Earnings for a certain form |
|
393 | + * @return double $earnings Earnings for a certain form |
|
394 | 394 | */ |
395 | 395 | function give_get_form_earnings_stats( $form_id = 0 ) { |
396 | 396 | $give_form = new Give_Donate_Form( $form_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 | |
@@ -23,14 +23,14 @@ discard block |
||
23 | 23 | |
24 | 24 | global $typenow; |
25 | 25 | |
26 | - if ( $typenow != 'give_forms' ) { |
|
26 | + if ($typenow != 'give_forms') { |
|
27 | 27 | return true; |
28 | 28 | } |
29 | 29 | |
30 | 30 | return false; |
31 | 31 | } |
32 | 32 | |
33 | -add_filter( 'give_shortcode_button_condition', 'give_shortcode_button_condition' ); |
|
33 | +add_filter('give_shortcode_button_condition', 'give_shortcode_button_condition'); |
|
34 | 34 | |
35 | 35 | |
36 | 36 | /** |
@@ -40,11 +40,11 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @return int|false |
42 | 42 | */ |
43 | -function get_form_id_from_args( $args ) { |
|
43 | +function get_form_id_from_args($args) { |
|
44 | 44 | |
45 | - if ( isset( $args['form_id'] ) && $args['form_id'] != 0 ) { |
|
45 | + if (isset($args['form_id']) && $args['form_id'] != 0) { |
|
46 | 46 | |
47 | - return intval( $args['form_id'] ); |
|
47 | + return intval($args['form_id']); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | return false; |
@@ -59,23 +59,23 @@ discard block |
||
59 | 59 | * |
60 | 60 | * @return bool |
61 | 61 | */ |
62 | -function give_is_float_labels_enabled( $args ) { |
|
62 | +function give_is_float_labels_enabled($args) { |
|
63 | 63 | |
64 | 64 | $float_labels = ''; |
65 | 65 | |
66 | - if ( ! empty( $args['float_labels'] ) ) { |
|
66 | + if ( ! empty($args['float_labels'])) { |
|
67 | 67 | $float_labels = $args['float_labels']; |
68 | 68 | } |
69 | 69 | |
70 | - if ( empty( $float_labels ) ) { |
|
71 | - $float_labels = get_post_meta( $args['form_id'], '_give_form_floating_labels', true ); |
|
70 | + if (empty($float_labels)) { |
|
71 | + $float_labels = get_post_meta($args['form_id'], '_give_form_floating_labels', true); |
|
72 | 72 | } |
73 | 73 | |
74 | - if ( empty( $float_labels ) ) { |
|
75 | - $float_labels = give_get_option( 'enable_floatlabels' ) ? 'enabled' : 'disabled'; |
|
74 | + if (empty($float_labels)) { |
|
75 | + $float_labels = give_get_option('enable_floatlabels') ? 'enabled' : 'disabled'; |
|
76 | 76 | } |
77 | 77 | |
78 | - return ( $float_labels == 'enabled' ) ? true : false; |
|
78 | + return ($float_labels == 'enabled') ? true : false; |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | $can_checkout = true; |
93 | 93 | |
94 | - return (bool) apply_filters( 'give_can_checkout', $can_checkout ); |
|
94 | + return (bool) apply_filters('give_can_checkout', $can_checkout); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | function give_get_success_page_uri() { |
106 | 106 | global $give_options; |
107 | 107 | |
108 | - $success_page = isset( $give_options['success_page'] ) ? get_permalink( absint( $give_options['success_page'] ) ) : get_bloginfo( 'url' ); |
|
108 | + $success_page = isset($give_options['success_page']) ? get_permalink(absint($give_options['success_page'])) : get_bloginfo('url'); |
|
109 | 109 | |
110 | - return apply_filters( 'give_get_success_page_uri', $success_page ); |
|
110 | + return apply_filters('give_get_success_page_uri', $success_page); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | */ |
120 | 120 | function give_is_success_page() { |
121 | 121 | global $give_options; |
122 | - $is_success_page = isset( $give_options['success_page'] ) ? is_page( $give_options['success_page'] ) : false; |
|
122 | + $is_success_page = isset($give_options['success_page']) ? is_page($give_options['success_page']) : false; |
|
123 | 123 | |
124 | - return apply_filters( 'give_is_success_page', $is_success_page ); |
|
124 | + return apply_filters('give_is_success_page', $is_success_page); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -135,17 +135,17 @@ discard block |
||
135 | 135 | * @since 1.0 |
136 | 136 | * @return void |
137 | 137 | */ |
138 | -function give_send_to_success_page( $query_string = null ) { |
|
138 | +function give_send_to_success_page($query_string = null) { |
|
139 | 139 | |
140 | 140 | $redirect = give_get_success_page_uri(); |
141 | 141 | |
142 | - if ( $query_string ) { |
|
142 | + if ($query_string) { |
|
143 | 143 | $redirect .= $query_string; |
144 | 144 | } |
145 | 145 | |
146 | - $gateway = isset( $_REQUEST['give-gateway'] ) ? $_REQUEST['give-gateway'] : ''; |
|
146 | + $gateway = isset($_REQUEST['give-gateway']) ? $_REQUEST['give-gateway'] : ''; |
|
147 | 147 | |
148 | - wp_redirect( apply_filters( 'give_success_page_redirect', $redirect, $gateway, $query_string ) ); |
|
148 | + wp_redirect(apply_filters('give_success_page_redirect', $redirect, $gateway, $query_string)); |
|
149 | 149 | give_die(); |
150 | 150 | } |
151 | 151 | |
@@ -162,20 +162,20 @@ discard block |
||
162 | 162 | * @since 1.0 |
163 | 163 | * @return Void |
164 | 164 | */ |
165 | -function give_send_back_to_checkout( $args = array() ) { |
|
165 | +function give_send_back_to_checkout($args = array()) { |
|
166 | 166 | |
167 | - $url = isset( $_POST['give-current-url'] ) ? sanitize_text_field( $_POST['give-current-url'] ) : ''; |
|
167 | + $url = isset($_POST['give-current-url']) ? sanitize_text_field($_POST['give-current-url']) : ''; |
|
168 | 168 | |
169 | 169 | //Set the form_id. |
170 | - if ( isset( $_POST['give-form-id'] ) ) { |
|
171 | - $form_id = sanitize_text_field( $_POST['give-form-id'] ); |
|
170 | + if (isset($_POST['give-form-id'])) { |
|
171 | + $form_id = sanitize_text_field($_POST['give-form-id']); |
|
172 | 172 | } else { |
173 | 173 | $form_id = 0; |
174 | 174 | } |
175 | 175 | |
176 | 176 | //Need a URL to continue. If none, redirect back to single form. |
177 | - if ( empty( $url ) ) { |
|
178 | - wp_safe_redirect( get_permalink( $form_id ) ); |
|
177 | + if (empty($url)) { |
|
178 | + wp_safe_redirect(get_permalink($form_id)); |
|
179 | 179 | give_die(); |
180 | 180 | } |
181 | 181 | |
@@ -184,36 +184,36 @@ discard block |
||
184 | 184 | ); |
185 | 185 | |
186 | 186 | // Check for backward compatibility. |
187 | - if ( is_string( $args ) ) { |
|
188 | - $args = str_replace( '?', '', $args ); |
|
187 | + if (is_string($args)) { |
|
188 | + $args = str_replace('?', '', $args); |
|
189 | 189 | } |
190 | 190 | |
191 | - $args = wp_parse_args( $args, $defaults ); |
|
191 | + $args = wp_parse_args($args, $defaults); |
|
192 | 192 | |
193 | 193 | // Merge URL query with $args to maintain third-party URL parameters after redirect. |
194 | - $url_data = wp_parse_url( $url ); |
|
194 | + $url_data = wp_parse_url($url); |
|
195 | 195 | |
196 | 196 | //Check if an array to prevent notices before parsing. |
197 | - if ( isset( $url_data['query'] ) && ! empty( $url_data['query'] ) ) { |
|
198 | - parse_str( $url_data['query'], $query ); |
|
197 | + if (isset($url_data['query']) && ! empty($url_data['query'])) { |
|
198 | + parse_str($url_data['query'], $query); |
|
199 | 199 | |
200 | 200 | //Precaution: don't allow any CC info. |
201 | - unset( $query['card_number'] ); |
|
202 | - unset( $query['card_cvc'] ); |
|
201 | + unset($query['card_number']); |
|
202 | + unset($query['card_cvc']); |
|
203 | 203 | |
204 | 204 | } else { |
205 | 205 | //No $url_data so pass empty array. |
206 | 206 | $query = array(); |
207 | 207 | } |
208 | 208 | |
209 | - $new_query = array_merge( $args, $query ); |
|
210 | - $new_query_string = http_build_query( $new_query ); |
|
209 | + $new_query = array_merge($args, $query); |
|
210 | + $new_query_string = http_build_query($new_query); |
|
211 | 211 | |
212 | 212 | // Assemble URL parts. |
213 | - $redirect = home_url( '/' . $url_data['path'] . '?' . $new_query_string . '#give-form-' . $form_id . '-wrap' ); |
|
213 | + $redirect = home_url('/'.$url_data['path'].'?'.$new_query_string.'#give-form-'.$form_id.'-wrap'); |
|
214 | 214 | |
215 | 215 | //Redirect them. |
216 | - wp_safe_redirect( apply_filters( 'give_send_back_to_checkout', $redirect, $args ) ); |
|
216 | + wp_safe_redirect(apply_filters('give_send_back_to_checkout', $redirect, $args)); |
|
217 | 217 | give_die(); |
218 | 218 | |
219 | 219 | } |
@@ -229,16 +229,16 @@ discard block |
||
229 | 229 | * @since 1.0 |
230 | 230 | * @return string |
231 | 231 | */ |
232 | -function give_get_success_page_url( $query_string = null ) { |
|
232 | +function give_get_success_page_url($query_string = null) { |
|
233 | 233 | |
234 | - $success_page = give_get_option( 'success_page', 0 ); |
|
235 | - $success_page = get_permalink( $success_page ); |
|
234 | + $success_page = give_get_option('success_page', 0); |
|
235 | + $success_page = get_permalink($success_page); |
|
236 | 236 | |
237 | - if ( $query_string ) { |
|
237 | + if ($query_string) { |
|
238 | 238 | $success_page .= $query_string; |
239 | 239 | } |
240 | 240 | |
241 | - return apply_filters( 'give_success_page_url', $success_page ); |
|
241 | + return apply_filters('give_success_page_url', $success_page); |
|
242 | 242 | |
243 | 243 | } |
244 | 244 | |
@@ -252,15 +252,15 @@ discard block |
||
252 | 252 | * |
253 | 253 | * @return mixed|void Full URL to the Transaction Failed page, if present, home page if it doesn't exist |
254 | 254 | */ |
255 | -function give_get_failed_transaction_uri( $extras = false ) { |
|
255 | +function give_get_failed_transaction_uri($extras = false) { |
|
256 | 256 | global $give_options; |
257 | 257 | |
258 | - $uri = ! empty( $give_options['failure_page'] ) ? trailingslashit( get_permalink( $give_options['failure_page'] ) ) : home_url(); |
|
259 | - if ( $extras ) { |
|
258 | + $uri = ! empty($give_options['failure_page']) ? trailingslashit(get_permalink($give_options['failure_page'])) : home_url(); |
|
259 | + if ($extras) { |
|
260 | 260 | $uri .= $extras; |
261 | 261 | } |
262 | 262 | |
263 | - return apply_filters( 'give_get_failed_transaction_uri', $uri ); |
|
263 | + return apply_filters('give_get_failed_transaction_uri', $uri); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | /** |
@@ -271,9 +271,9 @@ discard block |
||
271 | 271 | */ |
272 | 272 | function give_is_failed_transaction_page() { |
273 | 273 | global $give_options; |
274 | - $ret = isset( $give_options['failure_page'] ) ? is_page( $give_options['failure_page'] ) : false; |
|
274 | + $ret = isset($give_options['failure_page']) ? is_page($give_options['failure_page']) : false; |
|
275 | 275 | |
276 | - return apply_filters( 'give_is_failure_page', $ret ); |
|
276 | + return apply_filters('give_is_failure_page', $ret); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | /** |
@@ -285,18 +285,18 @@ discard block |
||
285 | 285 | */ |
286 | 286 | function give_listen_for_failed_payments() { |
287 | 287 | |
288 | - $failed_page = give_get_option( 'failure_page', 0 ); |
|
288 | + $failed_page = give_get_option('failure_page', 0); |
|
289 | 289 | |
290 | - if ( ! empty( $failed_page ) && is_page( $failed_page ) && ! empty( $_GET['payment-id'] ) ) { |
|
290 | + if ( ! empty($failed_page) && is_page($failed_page) && ! empty($_GET['payment-id'])) { |
|
291 | 291 | |
292 | - $payment_id = absint( $_GET['payment-id'] ); |
|
293 | - give_update_payment_status( $payment_id, 'failed' ); |
|
292 | + $payment_id = absint($_GET['payment-id']); |
|
293 | + give_update_payment_status($payment_id, 'failed'); |
|
294 | 294 | |
295 | 295 | } |
296 | 296 | |
297 | 297 | } |
298 | 298 | |
299 | -add_action( 'template_redirect', 'give_listen_for_failed_payments' ); |
|
299 | +add_action('template_redirect', 'give_listen_for_failed_payments'); |
|
300 | 300 | |
301 | 301 | |
302 | 302 | /** |
@@ -309,11 +309,11 @@ discard block |
||
309 | 309 | * @since 1.0 |
310 | 310 | * @return bool |
311 | 311 | */ |
312 | -function give_field_is_required( $field = '', $form_id ) { |
|
312 | +function give_field_is_required($field = '', $form_id) { |
|
313 | 313 | |
314 | - $required_fields = give_purchase_form_required_fields( $form_id ); |
|
314 | + $required_fields = give_purchase_form_required_fields($form_id); |
|
315 | 315 | |
316 | - return array_key_exists( $field, $required_fields ); |
|
316 | + return array_key_exists($field, $required_fields); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | /** |
@@ -331,14 +331,14 @@ discard block |
||
331 | 331 | * |
332 | 332 | * @return void |
333 | 333 | */ |
334 | -function give_record_sale_in_log( $give_form_id = 0, $payment_id, $price_id = false, $sale_date = null ) { |
|
334 | +function give_record_sale_in_log($give_form_id = 0, $payment_id, $price_id = false, $sale_date = null) { |
|
335 | 335 | global $give_logs; |
336 | 336 | |
337 | 337 | $log_data = array( |
338 | 338 | 'post_parent' => $give_form_id, |
339 | 339 | 'log_type' => 'sale', |
340 | - 'post_date' => isset( $sale_date ) ? $sale_date : null, |
|
341 | - 'post_date_gmt' => isset( $sale_date ) ? $sale_date : null |
|
340 | + 'post_date' => isset($sale_date) ? $sale_date : null, |
|
341 | + 'post_date_gmt' => isset($sale_date) ? $sale_date : null |
|
342 | 342 | ); |
343 | 343 | |
344 | 344 | $log_meta = array( |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | 'price_id' => (int) $price_id |
347 | 347 | ); |
348 | 348 | |
349 | - $give_logs->insert_log( $log_data, $log_meta ); |
|
349 | + $give_logs->insert_log($log_data, $log_meta); |
|
350 | 350 | } |
351 | 351 | |
352 | 352 | |
@@ -360,11 +360,11 @@ discard block |
||
360 | 360 | * |
361 | 361 | * @return bool|int |
362 | 362 | */ |
363 | -function give_increase_purchase_count( $form_id = 0, $quantity = 1 ) { |
|
363 | +function give_increase_purchase_count($form_id = 0, $quantity = 1) { |
|
364 | 364 | $quantity = (int) $quantity; |
365 | - $form = new Give_Donate_Form( $form_id ); |
|
365 | + $form = new Give_Donate_Form($form_id); |
|
366 | 366 | |
367 | - return $form->increase_sales( $quantity ); |
|
367 | + return $form->increase_sales($quantity); |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | /** |
@@ -377,11 +377,11 @@ discard block |
||
377 | 377 | * |
378 | 378 | * @return bool|int |
379 | 379 | */ |
380 | -function give_decrease_purchase_count( $form_id = 0, $quantity = 1 ) { |
|
380 | +function give_decrease_purchase_count($form_id = 0, $quantity = 1) { |
|
381 | 381 | $quantity = (int) $quantity; |
382 | - $form = new Give_Donate_Form( $form_id ); |
|
382 | + $form = new Give_Donate_Form($form_id); |
|
383 | 383 | |
384 | - return $form->decrease_sales( $quantity ); |
|
384 | + return $form->decrease_sales($quantity); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | /** |
@@ -394,10 +394,10 @@ discard block |
||
394 | 394 | * |
395 | 395 | * @return bool|int |
396 | 396 | */ |
397 | -function give_increase_earnings( $give_form_id = 0, $amount ) { |
|
398 | - $form = new Give_Donate_Form( $give_form_id ); |
|
397 | +function give_increase_earnings($give_form_id = 0, $amount) { |
|
398 | + $form = new Give_Donate_Form($give_form_id); |
|
399 | 399 | |
400 | - return $form->increase_earnings( $amount ); |
|
400 | + return $form->increase_earnings($amount); |
|
401 | 401 | } |
402 | 402 | |
403 | 403 | /** |
@@ -410,10 +410,10 @@ discard block |
||
410 | 410 | * |
411 | 411 | * @return bool|int |
412 | 412 | */ |
413 | -function give_decrease_earnings( $form_id = 0, $amount ) { |
|
414 | - $form = new Give_Donate_Form( $form_id ); |
|
413 | +function give_decrease_earnings($form_id = 0, $amount) { |
|
414 | + $form = new Give_Donate_Form($form_id); |
|
415 | 415 | |
416 | - return $form->decrease_earnings( $amount ); |
|
416 | + return $form->decrease_earnings($amount); |
|
417 | 417 | } |
418 | 418 | |
419 | 419 | |
@@ -426,8 +426,8 @@ discard block |
||
426 | 426 | * |
427 | 427 | * @return int $earnings Earnings for a certain form |
428 | 428 | */ |
429 | -function give_get_form_earnings_stats( $form_id = 0 ) { |
|
430 | - $give_form = new Give_Donate_Form( $form_id ); |
|
429 | +function give_get_form_earnings_stats($form_id = 0) { |
|
430 | + $give_form = new Give_Donate_Form($form_id); |
|
431 | 431 | |
432 | 432 | return $give_form->earnings; |
433 | 433 | } |
@@ -442,8 +442,8 @@ discard block |
||
442 | 442 | * |
443 | 443 | * @return int $sales Amount of sales for a certain form |
444 | 444 | */ |
445 | -function give_get_form_sales_stats( $give_form_id = 0 ) { |
|
446 | - $give_form = new Give_Donate_Form( $give_form_id ); |
|
445 | +function give_get_form_sales_stats($give_form_id = 0) { |
|
446 | + $give_form = new Give_Donate_Form($give_form_id); |
|
447 | 447 | |
448 | 448 | return $give_form->sales; |
449 | 449 | } |
@@ -458,16 +458,16 @@ discard block |
||
458 | 458 | * |
459 | 459 | * @return float $sales Average monthly sales |
460 | 460 | */ |
461 | -function give_get_average_monthly_form_sales( $form_id = 0 ) { |
|
462 | - $sales = give_get_form_sales_stats( $form_id ); |
|
463 | - $release_date = get_post_field( 'post_date', $form_id ); |
|
461 | +function give_get_average_monthly_form_sales($form_id = 0) { |
|
462 | + $sales = give_get_form_sales_stats($form_id); |
|
463 | + $release_date = get_post_field('post_date', $form_id); |
|
464 | 464 | |
465 | - $diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) ); |
|
465 | + $diff = abs(current_time('timestamp') - strtotime($release_date)); |
|
466 | 466 | |
467 | - $months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication |
|
467 | + $months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication |
|
468 | 468 | |
469 | - if ( $months > 0 ) { |
|
470 | - $sales = ( $sales / $months ); |
|
469 | + if ($months > 0) { |
|
470 | + $sales = ($sales / $months); |
|
471 | 471 | } |
472 | 472 | |
473 | 473 | return $sales; |
@@ -483,16 +483,16 @@ discard block |
||
483 | 483 | * |
484 | 484 | * @return float $earnings Average monthly earnings |
485 | 485 | */ |
486 | -function give_get_average_monthly_form_earnings( $form_id = 0 ) { |
|
487 | - $earnings = give_get_form_earnings_stats( $form_id ); |
|
488 | - $release_date = get_post_field( 'post_date', $form_id ); |
|
486 | +function give_get_average_monthly_form_earnings($form_id = 0) { |
|
487 | + $earnings = give_get_form_earnings_stats($form_id); |
|
488 | + $release_date = get_post_field('post_date', $form_id); |
|
489 | 489 | |
490 | - $diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) ); |
|
490 | + $diff = abs(current_time('timestamp') - strtotime($release_date)); |
|
491 | 491 | |
492 | - $months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication |
|
492 | + $months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication |
|
493 | 493 | |
494 | - if ( $months > 0 ) { |
|
495 | - $earnings = ( $earnings / $months ); |
|
494 | + if ($months > 0) { |
|
495 | + $earnings = ($earnings / $months); |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | return $earnings < 0 ? 0 : $earnings; |
@@ -512,25 +512,25 @@ discard block |
||
512 | 512 | * |
513 | 513 | * @return string $price_name Name of the price option |
514 | 514 | */ |
515 | -function give_get_price_option_name( $form_id = 0, $price_id = 0, $payment_id = 0 ) { |
|
515 | +function give_get_price_option_name($form_id = 0, $price_id = 0, $payment_id = 0) { |
|
516 | 516 | |
517 | - $prices = give_get_variable_prices( $form_id ); |
|
517 | + $prices = give_get_variable_prices($form_id); |
|
518 | 518 | $price_name = ''; |
519 | 519 | |
520 | - foreach ( $prices as $price ) { |
|
520 | + foreach ($prices as $price) { |
|
521 | 521 | |
522 | - if ( intval( $price['_give_id']['level_id'] ) == intval( $price_id ) ) { |
|
522 | + if (intval($price['_give_id']['level_id']) == intval($price_id)) { |
|
523 | 523 | |
524 | - $price_text = isset( $price['_give_text'] ) ? $price['_give_text'] : ''; |
|
525 | - $price_fallback = give_currency_filter( give_format_amount( $price['_give_amount'] ) ); |
|
526 | - $price_name = ! empty( $price_text ) ? $price_text : $price_fallback; |
|
524 | + $price_text = isset($price['_give_text']) ? $price['_give_text'] : ''; |
|
525 | + $price_fallback = give_currency_filter(give_format_amount($price['_give_amount'])); |
|
526 | + $price_name = ! empty($price_text) ? $price_text : $price_fallback; |
|
527 | 527 | |
528 | 528 | } |
529 | 529 | |
530 | 530 | } |
531 | 531 | |
532 | 532 | |
533 | - return apply_filters( 'give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id ); |
|
533 | + return apply_filters('give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id); |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | |
@@ -543,14 +543,14 @@ discard block |
||
543 | 543 | * |
544 | 544 | * @return string $range A fully formatted price range |
545 | 545 | */ |
546 | -function give_price_range( $form_id = 0 ) { |
|
547 | - $low = give_get_lowest_price_option( $form_id ); |
|
548 | - $high = give_get_highest_price_option( $form_id ); |
|
549 | - $range = '<span class="give_price_range_low">' . give_currency_filter( give_format_amount( $low ) ) . '</span>'; |
|
546 | +function give_price_range($form_id = 0) { |
|
547 | + $low = give_get_lowest_price_option($form_id); |
|
548 | + $high = give_get_highest_price_option($form_id); |
|
549 | + $range = '<span class="give_price_range_low">'.give_currency_filter(give_format_amount($low)).'</span>'; |
|
550 | 550 | $range .= '<span class="give_price_range_sep"> – </span>'; |
551 | - $range .= '<span class="give_price_range_high">' . give_currency_filter( give_format_amount( $high ) ) . '</span>'; |
|
551 | + $range .= '<span class="give_price_range_high">'.give_currency_filter(give_format_amount($high)).'</span>'; |
|
552 | 552 | |
553 | - return apply_filters( 'give_price_range', $range, $form_id, $low, $high ); |
|
553 | + return apply_filters('give_price_range', $range, $form_id, $low, $high); |
|
554 | 554 | } |
555 | 555 | |
556 | 556 | |
@@ -565,36 +565,36 @@ discard block |
||
565 | 565 | * |
566 | 566 | * @return int ID of the lowest price |
567 | 567 | */ |
568 | -function give_get_lowest_price_id( $form_id = 0 ) { |
|
568 | +function give_get_lowest_price_id($form_id = 0) { |
|
569 | 569 | |
570 | - if ( empty( $form_id ) ) { |
|
570 | + if (empty($form_id)) { |
|
571 | 571 | $form_id = get_the_ID(); |
572 | 572 | } |
573 | 573 | |
574 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
575 | - return give_get_form_price( $form_id ); |
|
574 | + if ( ! give_has_variable_prices($form_id)) { |
|
575 | + return give_get_form_price($form_id); |
|
576 | 576 | } |
577 | 577 | |
578 | - $prices = give_get_variable_prices( $form_id ); |
|
578 | + $prices = give_get_variable_prices($form_id); |
|
579 | 579 | |
580 | 580 | $low = 0.00; |
581 | 581 | $min_id = 1; |
582 | 582 | |
583 | - if ( ! empty( $prices ) ) { |
|
583 | + if ( ! empty($prices)) { |
|
584 | 584 | |
585 | - foreach ( $prices as $key => $price ) { |
|
585 | + foreach ($prices as $key => $price) { |
|
586 | 586 | |
587 | - if ( empty( $price['_give_amount'] ) ) { |
|
587 | + if (empty($price['_give_amount'])) { |
|
588 | 588 | continue; |
589 | 589 | } |
590 | 590 | |
591 | - if ( ! isset( $min ) ) { |
|
591 | + if ( ! isset($min)) { |
|
592 | 592 | $min = $price['_give_amount']; |
593 | 593 | } else { |
594 | - $min = min( $min, $price['_give_amount'] ); |
|
594 | + $min = min($min, $price['_give_amount']); |
|
595 | 595 | } |
596 | 596 | |
597 | - if ( $price['_give_amount'] == $min ) { |
|
597 | + if ($price['_give_amount'] == $min) { |
|
598 | 598 | $min_id = $price['_give_id']['level_id']; |
599 | 599 | } |
600 | 600 | } |
@@ -612,43 +612,43 @@ discard block |
||
612 | 612 | * |
613 | 613 | * @return float Amount of the lowest price |
614 | 614 | */ |
615 | -function give_get_lowest_price_option( $form_id = 0 ) { |
|
616 | - if ( empty( $form_id ) ) { |
|
615 | +function give_get_lowest_price_option($form_id = 0) { |
|
616 | + if (empty($form_id)) { |
|
617 | 617 | $form_id = get_the_ID(); |
618 | 618 | } |
619 | 619 | |
620 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
621 | - return give_get_form_price( $form_id ); |
|
620 | + if ( ! give_has_variable_prices($form_id)) { |
|
621 | + return give_get_form_price($form_id); |
|
622 | 622 | } |
623 | 623 | |
624 | - $prices = give_get_variable_prices( $form_id ); |
|
624 | + $prices = give_get_variable_prices($form_id); |
|
625 | 625 | |
626 | 626 | $low = 0.00; |
627 | 627 | |
628 | - if ( ! empty( $prices ) ) { |
|
628 | + if ( ! empty($prices)) { |
|
629 | 629 | |
630 | - foreach ( $prices as $key => $price ) { |
|
630 | + foreach ($prices as $key => $price) { |
|
631 | 631 | |
632 | - if ( empty( $price['_give_amount'] ) ) { |
|
632 | + if (empty($price['_give_amount'])) { |
|
633 | 633 | continue; |
634 | 634 | } |
635 | 635 | |
636 | - if ( ! isset( $min ) ) { |
|
636 | + if ( ! isset($min)) { |
|
637 | 637 | $min = $price['_give_amount']; |
638 | 638 | } else { |
639 | - $min = min( $min, give_sanitize_amount( $price['_give_amount'] ) ); |
|
639 | + $min = min($min, give_sanitize_amount($price['_give_amount'])); |
|
640 | 640 | } |
641 | 641 | |
642 | - if ( $price['_give_amount'] == $min ) { |
|
642 | + if ($price['_give_amount'] == $min) { |
|
643 | 643 | $min_id = $key; |
644 | 644 | } |
645 | 645 | } |
646 | 646 | |
647 | - $low = $prices[ $min_id ]['_give_amount']; |
|
647 | + $low = $prices[$min_id]['_give_amount']; |
|
648 | 648 | |
649 | 649 | } |
650 | 650 | |
651 | - return give_sanitize_amount( $low ); |
|
651 | + return give_sanitize_amount($low); |
|
652 | 652 | } |
653 | 653 | |
654 | 654 | /** |
@@ -660,41 +660,41 @@ discard block |
||
660 | 660 | * |
661 | 661 | * @return float Amount of the highest price |
662 | 662 | */ |
663 | -function give_get_highest_price_option( $form_id = 0 ) { |
|
663 | +function give_get_highest_price_option($form_id = 0) { |
|
664 | 664 | |
665 | - if ( empty( $form_id ) ) { |
|
665 | + if (empty($form_id)) { |
|
666 | 666 | $form_id = get_the_ID(); |
667 | 667 | } |
668 | 668 | |
669 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
670 | - return give_get_form_price( $form_id ); |
|
669 | + if ( ! give_has_variable_prices($form_id)) { |
|
670 | + return give_get_form_price($form_id); |
|
671 | 671 | } |
672 | 672 | |
673 | - $prices = give_get_variable_prices( $form_id ); |
|
673 | + $prices = give_get_variable_prices($form_id); |
|
674 | 674 | |
675 | 675 | $high = 0.00; |
676 | 676 | |
677 | - if ( ! empty( $prices ) ) { |
|
677 | + if ( ! empty($prices)) { |
|
678 | 678 | |
679 | 679 | $max = 0; |
680 | 680 | |
681 | - foreach ( $prices as $key => $price ) { |
|
682 | - if ( empty( $price['_give_amount'] ) ) { |
|
681 | + foreach ($prices as $key => $price) { |
|
682 | + if (empty($price['_give_amount'])) { |
|
683 | 683 | continue; |
684 | 684 | } |
685 | - $give_amount = give_sanitize_amount( $price['_give_amount'] ); |
|
685 | + $give_amount = give_sanitize_amount($price['_give_amount']); |
|
686 | 686 | |
687 | - $max = max( $max, $give_amount ); |
|
687 | + $max = max($max, $give_amount); |
|
688 | 688 | |
689 | - if ( $give_amount == $max ) { |
|
689 | + if ($give_amount == $max) { |
|
690 | 690 | $max_id = $key; |
691 | 691 | } |
692 | 692 | } |
693 | 693 | |
694 | - $high = $prices[ $max_id ]['_give_amount']; |
|
694 | + $high = $prices[$max_id]['_give_amount']; |
|
695 | 695 | } |
696 | 696 | |
697 | - return give_sanitize_amount( $high ); |
|
697 | + return give_sanitize_amount($high); |
|
698 | 698 | } |
699 | 699 | |
700 | 700 | /** |
@@ -706,15 +706,15 @@ discard block |
||
706 | 706 | * |
707 | 707 | * @return mixed string|int Price of the form |
708 | 708 | */ |
709 | -function give_get_form_price( $form_id = 0 ) { |
|
709 | +function give_get_form_price($form_id = 0) { |
|
710 | 710 | |
711 | - if ( empty( $form_id ) ) { |
|
711 | + if (empty($form_id)) { |
|
712 | 712 | return false; |
713 | 713 | } |
714 | 714 | |
715 | - $form = new Give_Donate_Form( $form_id ); |
|
715 | + $form = new Give_Donate_Form($form_id); |
|
716 | 716 | |
717 | - return $form->__get( 'price' ); |
|
717 | + return $form->__get('price'); |
|
718 | 718 | } |
719 | 719 | |
720 | 720 | /** |
@@ -726,15 +726,15 @@ discard block |
||
726 | 726 | * |
727 | 727 | * @return mixed string|int Minimum price of the form |
728 | 728 | */ |
729 | -function give_get_form_minimum_price( $form_id = 0 ) { |
|
729 | +function give_get_form_minimum_price($form_id = 0) { |
|
730 | 730 | |
731 | - if ( empty( $form_id ) ) { |
|
731 | + if (empty($form_id)) { |
|
732 | 732 | return false; |
733 | 733 | } |
734 | 734 | |
735 | - $form = new Give_Donate_Form( $form_id ); |
|
735 | + $form = new Give_Donate_Form($form_id); |
|
736 | 736 | |
737 | - return $form->__get( 'minimum_price' ); |
|
737 | + return $form->__get('minimum_price'); |
|
738 | 738 | |
739 | 739 | } |
740 | 740 | |
@@ -749,52 +749,52 @@ discard block |
||
749 | 749 | * |
750 | 750 | * @return int $formatted_price |
751 | 751 | */ |
752 | -function give_price( $form_id = 0, $echo = true, $price_id = false ) { |
|
752 | +function give_price($form_id = 0, $echo = true, $price_id = false) { |
|
753 | 753 | |
754 | - if ( empty( $form_id ) ) { |
|
754 | + if (empty($form_id)) { |
|
755 | 755 | $form_id = get_the_ID(); |
756 | 756 | } |
757 | 757 | |
758 | - if ( give_has_variable_prices( $form_id ) ) { |
|
758 | + if (give_has_variable_prices($form_id)) { |
|
759 | 759 | |
760 | - $prices = give_get_variable_prices( $form_id ); |
|
760 | + $prices = give_get_variable_prices($form_id); |
|
761 | 761 | |
762 | - if ( false !== $price_id ) { |
|
762 | + if (false !== $price_id) { |
|
763 | 763 | |
764 | 764 | //loop through multi-prices to see which is default |
765 | - foreach ( $prices as $price ) { |
|
765 | + foreach ($prices as $price) { |
|
766 | 766 | //this is the default price |
767 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
767 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
768 | 768 | $price = (float) $price['_give_amount']; |
769 | 769 | }; |
770 | 770 | } |
771 | 771 | |
772 | 772 | } else { |
773 | 773 | |
774 | - $price = give_get_lowest_price_option( $form_id ); |
|
774 | + $price = give_get_lowest_price_option($form_id); |
|
775 | 775 | } |
776 | 776 | |
777 | - $price = give_sanitize_amount( $price ); |
|
777 | + $price = give_sanitize_amount($price); |
|
778 | 778 | |
779 | 779 | } else { |
780 | 780 | |
781 | - $price = give_get_form_price( $form_id ); |
|
781 | + $price = give_get_form_price($form_id); |
|
782 | 782 | |
783 | 783 | } |
784 | 784 | |
785 | - $price = apply_filters( 'give_form_price', give_sanitize_amount( $price ), $form_id ); |
|
786 | - $formatted_price = '<span class="give_price" id="give_price_' . $form_id . '">' . $price . '</span>'; |
|
787 | - $formatted_price = apply_filters( 'give_form_price_after_html', $formatted_price, $form_id, $price ); |
|
785 | + $price = apply_filters('give_form_price', give_sanitize_amount($price), $form_id); |
|
786 | + $formatted_price = '<span class="give_price" id="give_price_'.$form_id.'">'.$price.'</span>'; |
|
787 | + $formatted_price = apply_filters('give_form_price_after_html', $formatted_price, $form_id, $price); |
|
788 | 788 | |
789 | - if ( $echo ) { |
|
789 | + if ($echo) { |
|
790 | 790 | echo $formatted_price; |
791 | 791 | } else { |
792 | 792 | return $formatted_price; |
793 | 793 | } |
794 | 794 | } |
795 | 795 | |
796 | -add_filter( 'give_form_price', 'give_format_amount', 10 ); |
|
797 | -add_filter( 'give_form_price', 'give_currency_filter', 20 ); |
|
796 | +add_filter('give_form_price', 'give_format_amount', 10); |
|
797 | +add_filter('give_form_price', 'give_currency_filter', 20); |
|
798 | 798 | |
799 | 799 | |
800 | 800 | /** |
@@ -807,19 +807,19 @@ discard block |
||
807 | 807 | * |
808 | 808 | * @return float $amount Amount of the price option |
809 | 809 | */ |
810 | -function give_get_price_option_amount( $form_id = 0, $price_id = 0 ) { |
|
811 | - $prices = give_get_variable_prices( $form_id ); |
|
810 | +function give_get_price_option_amount($form_id = 0, $price_id = 0) { |
|
811 | + $prices = give_get_variable_prices($form_id); |
|
812 | 812 | |
813 | 813 | $amount = 0.00; |
814 | 814 | |
815 | - foreach ( $prices as $price ) { |
|
816 | - if ( isset( $price['_give_id']['level_id'] ) && $price['_give_id']['level_id'] == $price_id ) { |
|
817 | - $amount = isset( $price['_give_amount'] ) ? $price['_give_amount'] : 0.00; |
|
815 | + foreach ($prices as $price) { |
|
816 | + if (isset($price['_give_id']['level_id']) && $price['_give_id']['level_id'] == $price_id) { |
|
817 | + $amount = isset($price['_give_amount']) ? $price['_give_amount'] : 0.00; |
|
818 | 818 | break; |
819 | 819 | }; |
820 | 820 | } |
821 | 821 | |
822 | - return apply_filters( 'give_get_price_option_amount', give_sanitize_amount( $amount ), $form_id, $price_id ); |
|
822 | + return apply_filters('give_get_price_option_amount', give_sanitize_amount($amount), $form_id, $price_id); |
|
823 | 823 | } |
824 | 824 | |
825 | 825 | /** |
@@ -831,13 +831,13 @@ discard block |
||
831 | 831 | * |
832 | 832 | * @return mixed string|int Goal of the form |
833 | 833 | */ |
834 | -function give_get_form_goal( $form_id = 0 ) { |
|
834 | +function give_get_form_goal($form_id = 0) { |
|
835 | 835 | |
836 | - if ( empty( $form_id ) ) { |
|
836 | + if (empty($form_id)) { |
|
837 | 837 | return false; |
838 | 838 | } |
839 | 839 | |
840 | - $form = new Give_Donate_Form( $form_id ); |
|
840 | + $form = new Give_Donate_Form($form_id); |
|
841 | 841 | |
842 | 842 | return $form->goal; |
843 | 843 | |
@@ -853,27 +853,27 @@ discard block |
||
853 | 853 | * |
854 | 854 | * @return string $formatted_goal |
855 | 855 | */ |
856 | -function give_goal( $form_id = 0, $echo = true ) { |
|
856 | +function give_goal($form_id = 0, $echo = true) { |
|
857 | 857 | |
858 | - if ( empty( $form_id ) ) { |
|
858 | + if (empty($form_id)) { |
|
859 | 859 | $form_id = get_the_ID(); |
860 | 860 | } |
861 | 861 | |
862 | - $goal = give_get_form_goal( $form_id ); |
|
862 | + $goal = give_get_form_goal($form_id); |
|
863 | 863 | |
864 | - $goal = apply_filters( 'give_form_goal', give_sanitize_amount( $goal ), $form_id ); |
|
865 | - $formatted_goal = '<span class="give_price" id="give_price_' . $form_id . '">' . $goal . '</span>'; |
|
866 | - $formatted_goal = apply_filters( 'give_form_price_after_html', $formatted_goal, $form_id, $goal ); |
|
864 | + $goal = apply_filters('give_form_goal', give_sanitize_amount($goal), $form_id); |
|
865 | + $formatted_goal = '<span class="give_price" id="give_price_'.$form_id.'">'.$goal.'</span>'; |
|
866 | + $formatted_goal = apply_filters('give_form_price_after_html', $formatted_goal, $form_id, $goal); |
|
867 | 867 | |
868 | - if ( $echo ) { |
|
868 | + if ($echo) { |
|
869 | 869 | echo $formatted_goal; |
870 | 870 | } else { |
871 | 871 | return $formatted_goal; |
872 | 872 | } |
873 | 873 | } |
874 | 874 | |
875 | -add_filter( 'give_form_goal', 'give_format_amount', 10 ); |
|
876 | -add_filter( 'give_form_goal', 'give_currency_filter', 20 ); |
|
875 | +add_filter('give_form_goal', 'give_format_amount', 10); |
|
876 | +add_filter('give_form_goal', 'give_currency_filter', 20); |
|
877 | 877 | |
878 | 878 | |
879 | 879 | /** |
@@ -887,13 +887,13 @@ discard block |
||
887 | 887 | * |
888 | 888 | * @return bool $ret Whether or not the logged_in_only setting is set |
889 | 889 | */ |
890 | -function give_logged_in_only( $form_id ) { |
|
890 | +function give_logged_in_only($form_id) { |
|
891 | 891 | |
892 | - $form_option = get_post_meta( $form_id, '_give_logged_in_only', true ); |
|
892 | + $form_option = get_post_meta($form_id, '_give_logged_in_only', true); |
|
893 | 893 | |
894 | - $ret = ! empty( $form_option ) ? $form_option : false; |
|
894 | + $ret = ! empty($form_option) ? $form_option : false; |
|
895 | 895 | |
896 | - return (bool) apply_filters( 'give_logged_in_only', $ret, $form_id ); |
|
896 | + return (bool) apply_filters('give_logged_in_only', $ret, $form_id); |
|
897 | 897 | |
898 | 898 | } |
899 | 899 | |
@@ -907,10 +907,10 @@ discard block |
||
907 | 907 | * |
908 | 908 | * @return string |
909 | 909 | */ |
910 | -function give_show_login_register_option( $form_id ) { |
|
910 | +function give_show_login_register_option($form_id) { |
|
911 | 911 | |
912 | - $show_register_form = get_post_meta( $form_id, '_give_show_register_form', true ); |
|
912 | + $show_register_form = get_post_meta($form_id, '_give_show_register_form', true); |
|
913 | 913 | |
914 | - return apply_filters( 'give_show_register_form', $show_register_form, $form_id ); |
|
914 | + return apply_filters('give_show_register_form', $show_register_form, $form_id); |
|
915 | 915 | |
916 | 916 | } |
917 | 917 | \ No newline at end of file |
@@ -630,7 +630,7 @@ discard block |
||
630 | 630 | * @param int $year Year number. Default is null. |
631 | 631 | * @param int $hour Hour number. Default is null. |
632 | 632 | * |
633 | - * @return int $earnings Earnings |
|
633 | + * @return double $earnings Earnings |
|
634 | 634 | */ |
635 | 635 | function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) { |
636 | 636 | |
@@ -932,7 +932,7 @@ discard block |
||
932 | 932 | * |
933 | 933 | * @param int $payment_id Payment ID |
934 | 934 | * |
935 | - * @return array $user_info User Info Meta Values |
|
935 | + * @return string $user_info User Info Meta Values |
|
936 | 936 | */ |
937 | 937 | function give_get_payment_meta_user_info( $payment_id ) { |
938 | 938 | $payment = new Give_Payment( $payment_id ); |
@@ -948,7 +948,7 @@ discard block |
||
948 | 948 | * |
949 | 949 | * @param int $payment_id Payment ID |
950 | 950 | * |
951 | - * @return int $form_id |
|
951 | + * @return string $form_id |
|
952 | 952 | */ |
953 | 953 | function give_get_payment_form_id( $payment_id ) { |
954 | 954 | $payment = new Give_Payment( $payment_id ); |
@@ -994,7 +994,7 @@ discard block |
||
994 | 994 | * |
995 | 995 | * @param int $payment_id Payment ID |
996 | 996 | * |
997 | - * @return string $user_id User ID |
|
997 | + * @return integer $user_id User ID |
|
998 | 998 | */ |
999 | 999 | function give_get_payment_user_id( $payment_id ) { |
1000 | 1000 | $payment = new Give_Payment( $payment_id ); |
@@ -1009,7 +1009,7 @@ discard block |
||
1009 | 1009 | * |
1010 | 1010 | * @param int $payment_id Payment ID |
1011 | 1011 | * |
1012 | - * @return string $customer_id Customer ID |
|
1012 | + * @return integer $customer_id Customer ID |
|
1013 | 1013 | */ |
1014 | 1014 | function give_get_payment_customer_id( $payment_id ) { |
1015 | 1015 | $payment = new Give_Payment( $payment_id ); |
@@ -1606,7 +1606,7 @@ discard block |
||
1606 | 1606 | * @param array $where |
1607 | 1607 | * @param object $wp_comment_query WordPress Comment Query Object |
1608 | 1608 | * |
1609 | - * @return array $where |
|
1609 | + * @return string $where |
|
1610 | 1610 | */ |
1611 | 1611 | function give_hide_payment_notes_from_feeds( $where, $wp_comment_query ) { |
1612 | 1612 | global $wpdb; |
@@ -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,40 +162,40 @@ 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 purchased 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(); |
193 | 193 | |
194 | 194 | //Hook it |
195 | - do_action( 'give_insert_payment', $payment->ID, $payment_data ); |
|
195 | + do_action('give_insert_payment', $payment->ID, $payment_data); |
|
196 | 196 | |
197 | 197 | //Return payment ID upon success |
198 | - if ( ! empty( $payment->ID ) ) { |
|
198 | + if ( ! empty($payment->ID)) { |
|
199 | 199 | return $payment->ID; |
200 | 200 | } |
201 | 201 | |
@@ -214,9 +214,9 @@ discard block |
||
214 | 214 | * |
215 | 215 | * @return bool |
216 | 216 | */ |
217 | -function give_update_payment_status( $payment_id, $new_status = 'publish' ) { |
|
217 | +function give_update_payment_status($payment_id, $new_status = 'publish') { |
|
218 | 218 | |
219 | - $payment = new Give_Payment( $payment_id ); |
|
219 | + $payment = new Give_Payment($payment_id); |
|
220 | 220 | $payment->status = $new_status; |
221 | 221 | $updated = $payment->save(); |
222 | 222 | |
@@ -235,52 +235,52 @@ discard block |
||
235 | 235 | * |
236 | 236 | * @return void |
237 | 237 | */ |
238 | -function give_delete_purchase( $payment_id = 0, $update_customer = true ) { |
|
238 | +function give_delete_purchase($payment_id = 0, $update_customer = true) { |
|
239 | 239 | global $give_logs; |
240 | 240 | |
241 | - $payment = new Give_Payment( $payment_id ); |
|
242 | - $amount = give_get_payment_amount( $payment_id ); |
|
241 | + $payment = new Give_Payment($payment_id); |
|
242 | + $amount = give_get_payment_amount($payment_id); |
|
243 | 243 | $status = $payment->post_status; |
244 | - $customer_id = give_get_payment_customer_id( $payment_id ); |
|
245 | - $customer = new Give_Customer( $customer_id ); |
|
244 | + $customer_id = give_get_payment_customer_id($payment_id); |
|
245 | + $customer = new Give_Customer($customer_id); |
|
246 | 246 | |
247 | 247 | //Only undo purchases that aren't these statuses |
248 | - $dont_undo_statuses = apply_filters( 'give_undo_purchase_statuses', array( |
|
248 | + $dont_undo_statuses = apply_filters('give_undo_purchase_statuses', array( |
|
249 | 249 | 'pending', |
250 | 250 | 'cancelled' |
251 | - ) ); |
|
251 | + )); |
|
252 | 252 | |
253 | - if ( ! in_array( $status, $dont_undo_statuses ) ) { |
|
254 | - give_undo_purchase( false, $payment_id ); |
|
253 | + if ( ! in_array($status, $dont_undo_statuses)) { |
|
254 | + give_undo_purchase(false, $payment_id); |
|
255 | 255 | } |
256 | 256 | |
257 | - if ( $status == 'publish' ) { |
|
257 | + if ($status == 'publish') { |
|
258 | 258 | |
259 | 259 | // Only decrease earnings if they haven't already been decreased (or were never increased for this payment) |
260 | - give_decrease_total_earnings( $amount ); |
|
260 | + give_decrease_total_earnings($amount); |
|
261 | 261 | // Clear the This Month earnings (this_monththis_month is NOT a typo) |
262 | - delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
262 | + delete_transient(md5('give_earnings_this_monththis_month')); |
|
263 | 263 | |
264 | - if ( $customer->id && $update_customer ) { |
|
264 | + if ($customer->id && $update_customer) { |
|
265 | 265 | |
266 | 266 | // Decrement the stats for the customer |
267 | 267 | $customer->decrease_purchase_count(); |
268 | - $customer->decrease_value( $amount ); |
|
268 | + $customer->decrease_value($amount); |
|
269 | 269 | |
270 | 270 | } |
271 | 271 | } |
272 | 272 | |
273 | - do_action( 'give_payment_delete', $payment_id ); |
|
273 | + do_action('give_payment_delete', $payment_id); |
|
274 | 274 | |
275 | - if ( $customer->id && $update_customer ) { |
|
275 | + if ($customer->id && $update_customer) { |
|
276 | 276 | |
277 | 277 | // Remove the payment ID from the customer |
278 | - $customer->remove_payment( $payment_id ); |
|
278 | + $customer->remove_payment($payment_id); |
|
279 | 279 | |
280 | 280 | } |
281 | 281 | |
282 | 282 | // Remove the payment |
283 | - wp_delete_post( $payment_id, true ); |
|
283 | + wp_delete_post($payment_id, true); |
|
284 | 284 | |
285 | 285 | // Remove related sale log entries |
286 | 286 | $give_logs->delete_logs( |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | ) |
295 | 295 | ); |
296 | 296 | |
297 | - do_action( 'give_payment_deleted', $payment_id ); |
|
297 | + do_action('give_payment_deleted', $payment_id); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | /** |
@@ -310,25 +310,25 @@ discard block |
||
310 | 310 | * |
311 | 311 | * @return void |
312 | 312 | */ |
313 | -function give_undo_purchase( $form_id = false, $payment_id ) { |
|
313 | +function give_undo_purchase($form_id = false, $payment_id) { |
|
314 | 314 | |
315 | - if ( ! empty( $form_id ) ) { |
|
315 | + if ( ! empty($form_id)) { |
|
316 | 316 | $form_id = false; |
317 | - _give_deprected_argument( 'form_id', 'give_undo_purchase', '1.5' ); |
|
317 | + _give_deprected_argument('form_id', 'give_undo_purchase', '1.5'); |
|
318 | 318 | } |
319 | 319 | |
320 | - $payment = new Give_Payment( $payment_id ); |
|
320 | + $payment = new Give_Payment($payment_id); |
|
321 | 321 | |
322 | - $maybe_decrease_earnings = apply_filters( 'give_decrease_earnings_on_undo', true, $payment, $payment->form_id ); |
|
323 | - if ( true === $maybe_decrease_earnings ) { |
|
322 | + $maybe_decrease_earnings = apply_filters('give_decrease_earnings_on_undo', true, $payment, $payment->form_id); |
|
323 | + if (true === $maybe_decrease_earnings) { |
|
324 | 324 | // decrease earnings |
325 | - give_decrease_earnings( $payment->form_id, $payment->total ); |
|
325 | + give_decrease_earnings($payment->form_id, $payment->total); |
|
326 | 326 | } |
327 | 327 | |
328 | - $maybe_decrease_sales = apply_filters( 'give_decrease_sales_on_undo', true, $payment, $payment->form_id ); |
|
329 | - if ( true === $maybe_decrease_sales ) { |
|
328 | + $maybe_decrease_sales = apply_filters('give_decrease_sales_on_undo', true, $payment, $payment->form_id); |
|
329 | + if (true === $maybe_decrease_sales) { |
|
330 | 330 | // decrease purchase count |
331 | - give_decrease_purchase_count( $payment->form_id ); |
|
331 | + give_decrease_purchase_count($payment->form_id); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | } |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | * |
346 | 346 | * @return array $count Number of payments sorted by payment status |
347 | 347 | */ |
348 | -function give_count_payments( $args = array() ) { |
|
348 | +function give_count_payments($args = array()) { |
|
349 | 349 | |
350 | 350 | global $wpdb; |
351 | 351 | |
@@ -357,18 +357,18 @@ discard block |
||
357 | 357 | 'form_id' => null, |
358 | 358 | ); |
359 | 359 | |
360 | - $args = wp_parse_args( $args, $defaults ); |
|
360 | + $args = wp_parse_args($args, $defaults); |
|
361 | 361 | |
362 | 362 | $select = "SELECT p.post_status,count( * ) AS num_posts"; |
363 | 363 | $join = ''; |
364 | 364 | $where = "WHERE p.post_type = 'give_payment'"; |
365 | 365 | |
366 | 366 | // Count payments for a specific user |
367 | - if ( ! empty( $args['user'] ) ) { |
|
367 | + if ( ! empty($args['user'])) { |
|
368 | 368 | |
369 | - if ( is_email( $args['user'] ) ) { |
|
369 | + if (is_email($args['user'])) { |
|
370 | 370 | $field = 'email'; |
371 | - } elseif ( is_numeric( $args['user'] ) ) { |
|
371 | + } elseif (is_numeric($args['user'])) { |
|
372 | 372 | $field = 'id'; |
373 | 373 | } else { |
374 | 374 | $field = ''; |
@@ -376,108 +376,108 @@ discard block |
||
376 | 376 | |
377 | 377 | $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
378 | 378 | |
379 | - if ( ! empty( $field ) ) { |
|
379 | + if ( ! empty($field)) { |
|
380 | 380 | $where .= " |
381 | 381 | AND m.meta_key = '_give_payment_user_{$field}' |
382 | 382 | AND m.meta_value = '{$args['user']}'"; |
383 | 383 | } |
384 | 384 | |
385 | 385 | // Count payments for a search |
386 | - } elseif ( ! empty( $args['s'] ) ) { |
|
386 | + } elseif ( ! empty($args['s'])) { |
|
387 | 387 | |
388 | - if ( is_email( $args['s'] ) || strlen( $args['s'] ) == 32 ) { |
|
388 | + if (is_email($args['s']) || strlen($args['s']) == 32) { |
|
389 | 389 | |
390 | - if ( is_email( $args['s'] ) ) { |
|
390 | + if (is_email($args['s'])) { |
|
391 | 391 | $field = '_give_payment_user_email'; |
392 | 392 | } else { |
393 | 393 | $field = '_give_payment_purchase_key'; |
394 | 394 | } |
395 | 395 | |
396 | 396 | $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
397 | - $where .= $wpdb->prepare( " |
|
397 | + $where .= $wpdb->prepare(" |
|
398 | 398 | AND m.meta_key = %s |
399 | 399 | AND m.meta_value = %s", |
400 | 400 | $field, |
401 | 401 | $args['s'] |
402 | 402 | ); |
403 | 403 | |
404 | - } elseif ( '#' == substr( $args['s'], 0, 1 ) ) { |
|
404 | + } elseif ('#' == substr($args['s'], 0, 1)) { |
|
405 | 405 | |
406 | - $search = str_replace( '#:', '', $args['s'] ); |
|
407 | - $search = str_replace( '#', '', $search ); |
|
406 | + $search = str_replace('#:', '', $args['s']); |
|
407 | + $search = str_replace('#', '', $search); |
|
408 | 408 | |
409 | 409 | $select = "SELECT p2.post_status,count( * ) AS num_posts "; |
410 | 410 | $join = "LEFT JOIN $wpdb->postmeta m ON m.meta_key = '_give_log_payment_id' AND m.post_id = p.ID "; |
411 | 411 | $join .= "INNER JOIN $wpdb->posts p2 ON m.meta_value = p2.ID "; |
412 | 412 | $where = "WHERE p.post_type = 'give_log' "; |
413 | - $where .= $wpdb->prepare( "AND p.post_parent = %d} ", $search ); |
|
413 | + $where .= $wpdb->prepare("AND p.post_parent = %d} ", $search); |
|
414 | 414 | |
415 | - } elseif ( is_numeric( $args['s'] ) ) { |
|
415 | + } elseif (is_numeric($args['s'])) { |
|
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 = '_give_payment_user_id' |
420 | 420 | AND m.meta_value = %d", |
421 | 421 | $args['s'] |
422 | 422 | ); |
423 | 423 | |
424 | 424 | } else { |
425 | - $search = $wpdb->esc_like( $args['s'] ); |
|
426 | - $search = '%' . $search . '%'; |
|
425 | + $search = $wpdb->esc_like($args['s']); |
|
426 | + $search = '%'.$search.'%'; |
|
427 | 427 | |
428 | - $where .= $wpdb->prepare( "AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))", $search, $search ); |
|
428 | + $where .= $wpdb->prepare("AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))", $search, $search); |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | } |
432 | 432 | |
433 | - if ( ! empty( $args['form_id'] ) && is_numeric( $args['form_id'] ) ) { |
|
433 | + if ( ! empty($args['form_id']) && is_numeric($args['form_id'])) { |
|
434 | 434 | |
435 | - $where .= $wpdb->prepare( " AND p.post_parent = %d", $args['form_id'] ); |
|
435 | + $where .= $wpdb->prepare(" AND p.post_parent = %d", $args['form_id']); |
|
436 | 436 | |
437 | 437 | } |
438 | 438 | // Limit payments count by date |
439 | - if ( ! empty( $args['start-date'] ) && false !== strpos( $args['start-date'], '/' ) ) { |
|
439 | + if ( ! empty($args['start-date']) && false !== strpos($args['start-date'], '/')) { |
|
440 | 440 | |
441 | - $date_parts = explode( '/', $args['start-date'] ); |
|
442 | - $month = ! empty( $date_parts[0] ) && is_numeric( $date_parts[0] ) ? $date_parts[0] : 0; |
|
443 | - $day = ! empty( $date_parts[1] ) && is_numeric( $date_parts[1] ) ? $date_parts[1] : 0; |
|
444 | - $year = ! empty( $date_parts[2] ) && is_numeric( $date_parts[2] ) ? $date_parts[2] : 0; |
|
441 | + $date_parts = explode('/', $args['start-date']); |
|
442 | + $month = ! empty($date_parts[0]) && is_numeric($date_parts[0]) ? $date_parts[0] : 0; |
|
443 | + $day = ! empty($date_parts[1]) && is_numeric($date_parts[1]) ? $date_parts[1] : 0; |
|
444 | + $year = ! empty($date_parts[2]) && is_numeric($date_parts[2]) ? $date_parts[2] : 0; |
|
445 | 445 | |
446 | - $is_date = checkdate( $month, $day, $year ); |
|
447 | - if ( false !== $is_date ) { |
|
446 | + $is_date = checkdate($month, $day, $year); |
|
447 | + if (false !== $is_date) { |
|
448 | 448 | |
449 | - $date = new DateTime( $args['start-date'] ); |
|
450 | - $where .= $wpdb->prepare( " AND p.post_date >= '%s'", $date->format( 'Y-m-d' ) ); |
|
449 | + $date = new DateTime($args['start-date']); |
|
450 | + $where .= $wpdb->prepare(" AND p.post_date >= '%s'", $date->format('Y-m-d')); |
|
451 | 451 | |
452 | 452 | } |
453 | 453 | |
454 | 454 | // Fixes an issue with the payments list table counts when no end date is specified (partiy with stats class) |
455 | - if ( empty( $args['end-date'] ) ) { |
|
455 | + if (empty($args['end-date'])) { |
|
456 | 456 | $args['end-date'] = $args['start-date']; |
457 | 457 | } |
458 | 458 | |
459 | 459 | } |
460 | 460 | |
461 | - if ( ! empty ( $args['end-date'] ) && false !== strpos( $args['end-date'], '/' ) ) { |
|
461 | + if ( ! empty ($args['end-date']) && false !== strpos($args['end-date'], '/')) { |
|
462 | 462 | |
463 | - $date_parts = explode( '/', $args['end-date'] ); |
|
463 | + $date_parts = explode('/', $args['end-date']); |
|
464 | 464 | |
465 | - $month = ! empty( $date_parts[0] ) ? $date_parts[0] : 0; |
|
466 | - $day = ! empty( $date_parts[1] ) ? $date_parts[1] : 0; |
|
467 | - $year = ! empty( $date_parts[2] ) ? $date_parts[2] : 0; |
|
465 | + $month = ! empty($date_parts[0]) ? $date_parts[0] : 0; |
|
466 | + $day = ! empty($date_parts[1]) ? $date_parts[1] : 0; |
|
467 | + $year = ! empty($date_parts[2]) ? $date_parts[2] : 0; |
|
468 | 468 | |
469 | - $is_date = checkdate( $month, $day, $year ); |
|
470 | - if ( false !== $is_date ) { |
|
469 | + $is_date = checkdate($month, $day, $year); |
|
470 | + if (false !== $is_date) { |
|
471 | 471 | |
472 | - $date = new DateTime( $args['end-date'] ); |
|
473 | - $where .= $wpdb->prepare( " AND p.post_date <= '%s'", $date->format( 'Y-m-d' ) ); |
|
472 | + $date = new DateTime($args['end-date']); |
|
473 | + $where .= $wpdb->prepare(" AND p.post_date <= '%s'", $date->format('Y-m-d')); |
|
474 | 474 | |
475 | 475 | } |
476 | 476 | |
477 | 477 | } |
478 | 478 | |
479 | - $where = apply_filters( 'give_count_payments_where', $where ); |
|
480 | - $join = apply_filters( 'give_count_payments_join', $join ); |
|
479 | + $where = apply_filters('give_count_payments_where', $where); |
|
480 | + $join = apply_filters('give_count_payments_join', $join); |
|
481 | 481 | |
482 | 482 | $query = "$select |
483 | 483 | FROM $wpdb->posts p |
@@ -486,36 +486,36 @@ discard block |
||
486 | 486 | GROUP BY p.post_status |
487 | 487 | "; |
488 | 488 | |
489 | - $cache_key = md5( $query ); |
|
489 | + $cache_key = md5($query); |
|
490 | 490 | |
491 | - $count = wp_cache_get( $cache_key, 'counts' ); |
|
492 | - if ( false !== $count ) { |
|
491 | + $count = wp_cache_get($cache_key, 'counts'); |
|
492 | + if (false !== $count) { |
|
493 | 493 | return $count; |
494 | 494 | } |
495 | 495 | |
496 | - $count = $wpdb->get_results( $query, ARRAY_A ); |
|
496 | + $count = $wpdb->get_results($query, ARRAY_A); |
|
497 | 497 | |
498 | 498 | $stats = array(); |
499 | 499 | $statuses = get_post_stati(); |
500 | - if ( isset( $statuses['private'] ) && empty( $args['s'] ) ) { |
|
501 | - unset( $statuses['private'] ); |
|
500 | + if (isset($statuses['private']) && empty($args['s'])) { |
|
501 | + unset($statuses['private']); |
|
502 | 502 | } |
503 | 503 | |
504 | - foreach ( $statuses as $state ) { |
|
505 | - $stats[ $state ] = 0; |
|
504 | + foreach ($statuses as $state) { |
|
505 | + $stats[$state] = 0; |
|
506 | 506 | } |
507 | 507 | |
508 | - foreach ( (array) $count as $row ) { |
|
508 | + foreach ((array) $count as $row) { |
|
509 | 509 | |
510 | - if ( 'private' == $row['post_status'] && empty( $args['s'] ) ) { |
|
510 | + if ('private' == $row['post_status'] && empty($args['s'])) { |
|
511 | 511 | continue; |
512 | 512 | } |
513 | 513 | |
514 | - $stats[ $row['post_status'] ] = $row['num_posts']; |
|
514 | + $stats[$row['post_status']] = $row['num_posts']; |
|
515 | 515 | } |
516 | 516 | |
517 | 517 | $stats = (object) $stats; |
518 | - wp_cache_set( $cache_key, $stats, 'counts' ); |
|
518 | + wp_cache_set($cache_key, $stats, 'counts'); |
|
519 | 519 | |
520 | 520 | return $stats; |
521 | 521 | } |
@@ -530,12 +530,12 @@ discard block |
||
530 | 530 | * |
531 | 531 | * @return bool True if payment exists, false otherwise |
532 | 532 | */ |
533 | -function give_check_for_existing_payment( $payment_id ) { |
|
533 | +function give_check_for_existing_payment($payment_id) { |
|
534 | 534 | $exists = false; |
535 | - $payment = new Give_Payment( $payment_id ); |
|
535 | + $payment = new Give_Payment($payment_id); |
|
536 | 536 | |
537 | 537 | |
538 | - if ( $payment_id === $payment->ID && 'publish' === $payment->status ) { |
|
538 | + if ($payment_id === $payment->ID && 'publish' === $payment->status) { |
|
539 | 539 | $exists = true; |
540 | 540 | } |
541 | 541 | |
@@ -552,29 +552,29 @@ discard block |
||
552 | 552 | * |
553 | 553 | * @return bool|mixed True if payment status exists, false otherwise |
554 | 554 | */ |
555 | -function give_get_payment_status( $payment, $return_label = false ) { |
|
555 | +function give_get_payment_status($payment, $return_label = false) { |
|
556 | 556 | |
557 | - if ( ! is_object( $payment ) || ! isset( $payment->post_status ) ) { |
|
557 | + if ( ! is_object($payment) || ! isset($payment->post_status)) { |
|
558 | 558 | return false; |
559 | 559 | } |
560 | 560 | |
561 | 561 | $statuses = give_get_payment_statuses(); |
562 | 562 | |
563 | - if ( ! is_array( $statuses ) || empty( $statuses ) ) { |
|
563 | + if ( ! is_array($statuses) || empty($statuses)) { |
|
564 | 564 | return false; |
565 | 565 | } |
566 | 566 | |
567 | - $payment = new Give_Payment( $payment->ID ); |
|
567 | + $payment = new Give_Payment($payment->ID); |
|
568 | 568 | |
569 | - if ( array_key_exists( $payment->status, $statuses ) ) { |
|
570 | - if ( true === $return_label ) { |
|
571 | - return $statuses[ $payment->status ]; |
|
569 | + if (array_key_exists($payment->status, $statuses)) { |
|
570 | + if (true === $return_label) { |
|
571 | + return $statuses[$payment->status]; |
|
572 | 572 | } else { |
573 | 573 | // Account that our 'publish' status is labeled 'Complete' |
574 | 574 | $post_status = 'publish' == $payment->status ? 'Complete' : $payment->post_status; |
575 | 575 | |
576 | 576 | // Make sure we're matching cases, since they matter |
577 | - return array_search( strtolower( $post_status ), array_map( 'strtolower', $statuses ) ); |
|
577 | + return array_search(strtolower($post_status), array_map('strtolower', $statuses)); |
|
578 | 578 | } |
579 | 579 | } |
580 | 580 | |
@@ -590,17 +590,17 @@ discard block |
||
590 | 590 | */ |
591 | 591 | function give_get_payment_statuses() { |
592 | 592 | $payment_statuses = array( |
593 | - 'pending' => esc_html__( 'Pending', 'give' ), |
|
594 | - 'publish' => esc_html__( 'Complete', 'give' ), |
|
595 | - 'refunded' => esc_html__( 'Refunded', 'give' ), |
|
596 | - 'failed' => esc_html__( 'Failed', 'give' ), |
|
597 | - 'cancelled' => esc_html__( 'Cancelled', 'give' ), |
|
598 | - 'abandoned' => esc_html__( 'Abandoned', 'give' ), |
|
599 | - 'preapproval' => esc_html__( 'Pre-Approved', 'give' ), |
|
600 | - 'revoked' => esc_html__( 'Revoked', 'give' ) |
|
593 | + 'pending' => esc_html__('Pending', 'give'), |
|
594 | + 'publish' => esc_html__('Complete', 'give'), |
|
595 | + 'refunded' => esc_html__('Refunded', 'give'), |
|
596 | + 'failed' => esc_html__('Failed', 'give'), |
|
597 | + 'cancelled' => esc_html__('Cancelled', 'give'), |
|
598 | + 'abandoned' => esc_html__('Abandoned', 'give'), |
|
599 | + 'preapproval' => esc_html__('Pre-Approved', 'give'), |
|
600 | + 'revoked' => esc_html__('Revoked', 'give') |
|
601 | 601 | ); |
602 | 602 | |
603 | - return apply_filters( 'give_payment_statuses', $payment_statuses ); |
|
603 | + return apply_filters('give_payment_statuses', $payment_statuses); |
|
604 | 604 | } |
605 | 605 | |
606 | 606 | /** |
@@ -613,10 +613,10 @@ discard block |
||
613 | 613 | * @return array $payment_status All the available payment statuses. |
614 | 614 | */ |
615 | 615 | function give_get_payment_status_keys() { |
616 | - $statuses = array_keys( give_get_payment_statuses() ); |
|
617 | - asort( $statuses ); |
|
616 | + $statuses = array_keys(give_get_payment_statuses()); |
|
617 | + asort($statuses); |
|
618 | 618 | |
619 | - return array_values( $statuses ); |
|
619 | + return array_values($statuses); |
|
620 | 620 | } |
621 | 621 | |
622 | 622 | /** |
@@ -631,7 +631,7 @@ discard block |
||
631 | 631 | * |
632 | 632 | * @return int $earnings Earnings |
633 | 633 | */ |
634 | -function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) { |
|
634 | +function give_get_earnings_by_date($day = null, $month_num, $year = null, $hour = null) { |
|
635 | 635 | |
636 | 636 | // This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead |
637 | 637 | |
@@ -642,41 +642,41 @@ discard block |
||
642 | 642 | 'nopaging' => true, |
643 | 643 | 'year' => $year, |
644 | 644 | 'monthnum' => $month_num, |
645 | - 'post_status' => array( 'publish' ), |
|
645 | + 'post_status' => array('publish'), |
|
646 | 646 | 'fields' => 'ids', |
647 | 647 | 'update_post_term_cache' => false |
648 | 648 | ); |
649 | - if ( ! empty( $day ) ) { |
|
649 | + if ( ! empty($day)) { |
|
650 | 650 | $args['day'] = $day; |
651 | 651 | } |
652 | 652 | |
653 | - if ( ! empty( $hour ) ) { |
|
653 | + if ( ! empty($hour)) { |
|
654 | 654 | $args['hour'] = $hour; |
655 | 655 | } |
656 | 656 | |
657 | - $args = apply_filters( 'give_get_earnings_by_date_args', $args ); |
|
658 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
657 | + $args = apply_filters('give_get_earnings_by_date_args', $args); |
|
658 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
659 | 659 | |
660 | - if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) { |
|
660 | + if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) { |
|
661 | 661 | $earnings = false; |
662 | 662 | } else { |
663 | - $earnings = get_transient( $key ); |
|
663 | + $earnings = get_transient($key); |
|
664 | 664 | } |
665 | 665 | |
666 | - if ( false === $earnings ) { |
|
667 | - $sales = get_posts( $args ); |
|
666 | + if (false === $earnings) { |
|
667 | + $sales = get_posts($args); |
|
668 | 668 | $earnings = 0; |
669 | - if ( $sales ) { |
|
670 | - $sales = implode( ',', $sales ); |
|
669 | + if ($sales) { |
|
670 | + $sales = implode(',', $sales); |
|
671 | 671 | |
672 | - $earnings = $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$sales})" ); |
|
672 | + $earnings = $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$sales})"); |
|
673 | 673 | |
674 | 674 | } |
675 | 675 | // Cache the results for one hour |
676 | - set_transient( $key, $earnings, HOUR_IN_SECONDS ); |
|
676 | + set_transient($key, $earnings, HOUR_IN_SECONDS); |
|
677 | 677 | } |
678 | 678 | |
679 | - return round( $earnings, 2 ); |
|
679 | + return round($earnings, 2); |
|
680 | 680 | } |
681 | 681 | |
682 | 682 | /** |
@@ -691,7 +691,7 @@ discard block |
||
691 | 691 | * |
692 | 692 | * @return int $count Sales |
693 | 693 | */ |
694 | -function give_get_sales_by_date( $day = null, $month_num = null, $year = null, $hour = null ) { |
|
694 | +function give_get_sales_by_date($day = null, $month_num = null, $year = null, $hour = null) { |
|
695 | 695 | |
696 | 696 | // This is getting deprecated soon. Use Give_Payment_Stats with the get_sales() method instead |
697 | 697 | $args = array( |
@@ -699,14 +699,14 @@ discard block |
||
699 | 699 | 'nopaging' => true, |
700 | 700 | 'year' => $year, |
701 | 701 | 'fields' => 'ids', |
702 | - 'post_status' => array( 'publish' ), |
|
702 | + 'post_status' => array('publish'), |
|
703 | 703 | 'update_post_meta_cache' => false, |
704 | 704 | 'update_post_term_cache' => false |
705 | 705 | ); |
706 | 706 | |
707 | - $show_free = apply_filters( 'give_sales_by_date_show_free', true, $args ); |
|
707 | + $show_free = apply_filters('give_sales_by_date_show_free', true, $args); |
|
708 | 708 | |
709 | - if ( false === $show_free ) { |
|
709 | + if (false === $show_free) { |
|
710 | 710 | $args['meta_query'] = array( |
711 | 711 | array( |
712 | 712 | 'key' => '_give_payment_total', |
@@ -717,33 +717,33 @@ discard block |
||
717 | 717 | ); |
718 | 718 | } |
719 | 719 | |
720 | - if ( ! empty( $month_num ) ) { |
|
720 | + if ( ! empty($month_num)) { |
|
721 | 721 | $args['monthnum'] = $month_num; |
722 | 722 | } |
723 | 723 | |
724 | - if ( ! empty( $day ) ) { |
|
724 | + if ( ! empty($day)) { |
|
725 | 725 | $args['day'] = $day; |
726 | 726 | } |
727 | 727 | |
728 | - if ( ! empty( $hour ) ) { |
|
728 | + if ( ! empty($hour)) { |
|
729 | 729 | $args['hour'] = $hour; |
730 | 730 | } |
731 | 731 | |
732 | - $args = apply_filters( 'give_get_sales_by_date_args', $args ); |
|
732 | + $args = apply_filters('give_get_sales_by_date_args', $args); |
|
733 | 733 | |
734 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
734 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
735 | 735 | |
736 | - if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) { |
|
736 | + if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) { |
|
737 | 737 | $count = false; |
738 | 738 | } else { |
739 | - $count = get_transient( $key ); |
|
739 | + $count = get_transient($key); |
|
740 | 740 | } |
741 | 741 | |
742 | - if ( false === $count ) { |
|
743 | - $sales = new WP_Query( $args ); |
|
742 | + if (false === $count) { |
|
743 | + $sales = new WP_Query($args); |
|
744 | 744 | $count = (int) $sales->post_count; |
745 | 745 | // Cache the results for one hour |
746 | - set_transient( $key, $count, HOUR_IN_SECONDS ); |
|
746 | + set_transient($key, $count, HOUR_IN_SECONDS); |
|
747 | 747 | } |
748 | 748 | |
749 | 749 | return $count; |
@@ -758,20 +758,20 @@ discard block |
||
758 | 758 | * |
759 | 759 | * @return bool True if complete, false otherwise. |
760 | 760 | */ |
761 | -function give_is_payment_complete( $payment_id ) { |
|
762 | - $payment = new Give_Payment( $payment_id ); |
|
761 | +function give_is_payment_complete($payment_id) { |
|
762 | + $payment = new Give_Payment($payment_id); |
|
763 | 763 | |
764 | 764 | $ret = false; |
765 | 765 | |
766 | - if ( $payment->ID > 0 ) { |
|
766 | + if ($payment->ID > 0) { |
|
767 | 767 | |
768 | - if ( (int) $payment_id === (int) $payment->ID && 'publish' == $payment->status ) { |
|
768 | + if ((int) $payment_id === (int) $payment->ID && 'publish' == $payment->status) { |
|
769 | 769 | $ret = true; |
770 | 770 | } |
771 | 771 | |
772 | 772 | } |
773 | 773 | |
774 | - return apply_filters( 'give_is_payment_complete', $ret, $payment_id, $payment->post_status ); |
|
774 | + return apply_filters('give_is_payment_complete', $ret, $payment_id, $payment->post_status); |
|
775 | 775 | } |
776 | 776 | |
777 | 777 | /** |
@@ -797,29 +797,29 @@ discard block |
||
797 | 797 | */ |
798 | 798 | function give_get_total_earnings() { |
799 | 799 | |
800 | - $total = get_option( 'give_earnings_total', false ); |
|
800 | + $total = get_option('give_earnings_total', false); |
|
801 | 801 | |
802 | 802 | // If no total stored in DB, use old method of calculating total earnings |
803 | - if ( false === $total ) { |
|
803 | + if (false === $total) { |
|
804 | 804 | |
805 | 805 | global $wpdb; |
806 | 806 | |
807 | - $total = get_transient( 'give_earnings_total' ); |
|
807 | + $total = get_transient('give_earnings_total'); |
|
808 | 808 | |
809 | - if ( false === $total ) { |
|
809 | + if (false === $total) { |
|
810 | 810 | |
811 | 811 | $total = (float) 0; |
812 | 812 | |
813 | - $args = apply_filters( 'give_get_total_earnings_args', array( |
|
813 | + $args = apply_filters('give_get_total_earnings_args', array( |
|
814 | 814 | 'offset' => 0, |
815 | - 'number' => - 1, |
|
816 | - 'status' => array( 'publish' ), |
|
815 | + 'number' => -1, |
|
816 | + 'status' => array('publish'), |
|
817 | 817 | 'fields' => 'ids' |
818 | - ) ); |
|
818 | + )); |
|
819 | 819 | |
820 | 820 | |
821 | - $payments = give_get_payments( $args ); |
|
822 | - if ( $payments ) { |
|
821 | + $payments = give_get_payments($args); |
|
822 | + if ($payments) { |
|
823 | 823 | |
824 | 824 | /* |
825 | 825 | * If performing a purchase, we need to skip the very last payment in the database, since it calls |
@@ -827,30 +827,30 @@ discard block |
||
827 | 827 | * first purchase |
828 | 828 | */ |
829 | 829 | |
830 | - if ( did_action( 'give_update_payment_status' ) ) { |
|
831 | - array_pop( $payments ); |
|
830 | + if (did_action('give_update_payment_status')) { |
|
831 | + array_pop($payments); |
|
832 | 832 | } |
833 | 833 | |
834 | - if ( ! empty( $payments ) ) { |
|
835 | - $payments = implode( ',', $payments ); |
|
836 | - $total += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})" ); |
|
834 | + if ( ! empty($payments)) { |
|
835 | + $payments = implode(',', $payments); |
|
836 | + $total += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})"); |
|
837 | 837 | } |
838 | 838 | |
839 | 839 | } |
840 | 840 | |
841 | 841 | // Cache results for 1 day. This cache is cleared automatically when a payment is made |
842 | - set_transient( 'give_earnings_total', $total, 86400 ); |
|
842 | + set_transient('give_earnings_total', $total, 86400); |
|
843 | 843 | |
844 | 844 | // Store the total for the first time |
845 | - update_option( 'give_earnings_total', $total ); |
|
845 | + update_option('give_earnings_total', $total); |
|
846 | 846 | } |
847 | 847 | } |
848 | 848 | |
849 | - if ( $total < 0 ) { |
|
849 | + if ($total < 0) { |
|
850 | 850 | $total = 0; // Don't ever show negative earnings |
851 | 851 | } |
852 | 852 | |
853 | - return apply_filters( 'give_total_earnings', round( $total, give_currency_decimal_filter() ) ); |
|
853 | + return apply_filters('give_total_earnings', round($total, give_currency_decimal_filter())); |
|
854 | 854 | } |
855 | 855 | |
856 | 856 | /** |
@@ -863,10 +863,10 @@ discard block |
||
863 | 863 | * |
864 | 864 | * @return float $total Total earnings. |
865 | 865 | */ |
866 | -function give_increase_total_earnings( $amount = 0 ) { |
|
866 | +function give_increase_total_earnings($amount = 0) { |
|
867 | 867 | $total = give_get_total_earnings(); |
868 | 868 | $total += $amount; |
869 | - update_option( 'give_earnings_total', $total ); |
|
869 | + update_option('give_earnings_total', $total); |
|
870 | 870 | |
871 | 871 | return $total; |
872 | 872 | } |
@@ -880,13 +880,13 @@ discard block |
||
880 | 880 | * |
881 | 881 | * @return float $total Total earnings |
882 | 882 | */ |
883 | -function give_decrease_total_earnings( $amount = 0 ) { |
|
883 | +function give_decrease_total_earnings($amount = 0) { |
|
884 | 884 | $total = give_get_total_earnings(); |
885 | 885 | $total -= $amount; |
886 | - if ( $total < 0 ) { |
|
886 | + if ($total < 0) { |
|
887 | 887 | $total = 0; |
888 | 888 | } |
889 | - update_option( 'give_earnings_total', $total ); |
|
889 | + update_option('give_earnings_total', $total); |
|
890 | 890 | |
891 | 891 | return $total; |
892 | 892 | } |
@@ -902,10 +902,10 @@ discard block |
||
902 | 902 | * |
903 | 903 | * @return mixed $meta Payment Meta |
904 | 904 | */ |
905 | -function give_get_payment_meta( $payment_id = 0, $meta_key = '_give_payment_meta', $single = true ) { |
|
906 | - $payment = new Give_Payment( $payment_id ); |
|
905 | +function give_get_payment_meta($payment_id = 0, $meta_key = '_give_payment_meta', $single = true) { |
|
906 | + $payment = new Give_Payment($payment_id); |
|
907 | 907 | |
908 | - return $payment->get_meta( $meta_key, $single ); |
|
908 | + return $payment->get_meta($meta_key, $single); |
|
909 | 909 | } |
910 | 910 | |
911 | 911 | /** |
@@ -918,10 +918,10 @@ discard block |
||
918 | 918 | * |
919 | 919 | * @return mixed Meta ID if successful, false if unsuccessful |
920 | 920 | */ |
921 | -function give_update_payment_meta( $payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '' ) { |
|
922 | - $payment = new Give_Payment( $payment_id ); |
|
921 | +function give_update_payment_meta($payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '') { |
|
922 | + $payment = new Give_Payment($payment_id); |
|
923 | 923 | |
924 | - return $payment->update_meta( $meta_key, $meta_value, $prev_value ); |
|
924 | + return $payment->update_meta($meta_key, $meta_value, $prev_value); |
|
925 | 925 | } |
926 | 926 | |
927 | 927 | /** |
@@ -933,8 +933,8 @@ discard block |
||
933 | 933 | * |
934 | 934 | * @return array $user_info User Info Meta Values |
935 | 935 | */ |
936 | -function give_get_payment_meta_user_info( $payment_id ) { |
|
937 | - $payment = new Give_Payment( $payment_id ); |
|
936 | +function give_get_payment_meta_user_info($payment_id) { |
|
937 | + $payment = new Give_Payment($payment_id); |
|
938 | 938 | |
939 | 939 | return $payment->user_info; |
940 | 940 | } |
@@ -949,8 +949,8 @@ discard block |
||
949 | 949 | * |
950 | 950 | * @return int $form_id |
951 | 951 | */ |
952 | -function give_get_payment_form_id( $payment_id ) { |
|
953 | - $payment = new Give_Payment( $payment_id ); |
|
952 | +function give_get_payment_form_id($payment_id) { |
|
953 | + $payment = new Give_Payment($payment_id); |
|
954 | 954 | |
955 | 955 | return $payment->form_id; |
956 | 956 | } |
@@ -964,8 +964,8 @@ discard block |
||
964 | 964 | * |
965 | 965 | * @return string $email User Email |
966 | 966 | */ |
967 | -function give_get_payment_user_email( $payment_id ) { |
|
968 | - $payment = new Give_Payment( $payment_id ); |
|
967 | +function give_get_payment_user_email($payment_id) { |
|
968 | + $payment = new Give_Payment($payment_id); |
|
969 | 969 | |
970 | 970 | return $payment->email; |
971 | 971 | } |
@@ -979,11 +979,11 @@ discard block |
||
979 | 979 | * |
980 | 980 | * @return bool If the payment is associated with a user (false) or not (true) |
981 | 981 | */ |
982 | -function give_is_guest_payment( $payment_id ) { |
|
983 | - $payment_user_id = give_get_payment_user_id( $payment_id ); |
|
984 | - $is_guest_payment = ! empty( $payment_user_id ) && $payment_user_id > 0 ? false : true; |
|
982 | +function give_is_guest_payment($payment_id) { |
|
983 | + $payment_user_id = give_get_payment_user_id($payment_id); |
|
984 | + $is_guest_payment = ! empty($payment_user_id) && $payment_user_id > 0 ? false : true; |
|
985 | 985 | |
986 | - return (bool) apply_filters( 'give_is_guest_payment', $is_guest_payment, $payment_id ); |
|
986 | + return (bool) apply_filters('give_is_guest_payment', $is_guest_payment, $payment_id); |
|
987 | 987 | } |
988 | 988 | |
989 | 989 | /** |
@@ -995,8 +995,8 @@ discard block |
||
995 | 995 | * |
996 | 996 | * @return string $user_id User ID |
997 | 997 | */ |
998 | -function give_get_payment_user_id( $payment_id ) { |
|
999 | - $payment = new Give_Payment( $payment_id ); |
|
998 | +function give_get_payment_user_id($payment_id) { |
|
999 | + $payment = new Give_Payment($payment_id); |
|
1000 | 1000 | |
1001 | 1001 | return $payment->user_id; |
1002 | 1002 | } |
@@ -1010,8 +1010,8 @@ discard block |
||
1010 | 1010 | * |
1011 | 1011 | * @return string $customer_id Customer ID |
1012 | 1012 | */ |
1013 | -function give_get_payment_customer_id( $payment_id ) { |
|
1014 | - $payment = new Give_Payment( $payment_id ); |
|
1013 | +function give_get_payment_customer_id($payment_id) { |
|
1014 | + $payment = new Give_Payment($payment_id); |
|
1015 | 1015 | |
1016 | 1016 | return $payment->customer_id; |
1017 | 1017 | } |
@@ -1025,8 +1025,8 @@ discard block |
||
1025 | 1025 | * |
1026 | 1026 | * @return string $ip User IP |
1027 | 1027 | */ |
1028 | -function give_get_payment_user_ip( $payment_id ) { |
|
1029 | - $payment = new Give_Payment( $payment_id ); |
|
1028 | +function give_get_payment_user_ip($payment_id) { |
|
1029 | + $payment = new Give_Payment($payment_id); |
|
1030 | 1030 | |
1031 | 1031 | return $payment->ip; |
1032 | 1032 | } |
@@ -1040,8 +1040,8 @@ discard block |
||
1040 | 1040 | * |
1041 | 1041 | * @return string $date The date the payment was completed |
1042 | 1042 | */ |
1043 | -function give_get_payment_completed_date( $payment_id = 0 ) { |
|
1044 | - $payment = new Give_Payment( $payment_id ); |
|
1043 | +function give_get_payment_completed_date($payment_id = 0) { |
|
1044 | + $payment = new Give_Payment($payment_id); |
|
1045 | 1045 | |
1046 | 1046 | return $payment->completed_date; |
1047 | 1047 | } |
@@ -1055,8 +1055,8 @@ discard block |
||
1055 | 1055 | * |
1056 | 1056 | * @return string $gateway Gateway |
1057 | 1057 | */ |
1058 | -function give_get_payment_gateway( $payment_id ) { |
|
1059 | - $payment = new Give_Payment( $payment_id ); |
|
1058 | +function give_get_payment_gateway($payment_id) { |
|
1059 | + $payment = new Give_Payment($payment_id); |
|
1060 | 1060 | |
1061 | 1061 | return $payment->gateway; |
1062 | 1062 | } |
@@ -1070,8 +1070,8 @@ discard block |
||
1070 | 1070 | * |
1071 | 1071 | * @return string $currency The currency code |
1072 | 1072 | */ |
1073 | -function give_get_payment_currency_code( $payment_id = 0 ) { |
|
1074 | - $payment = new Give_Payment( $payment_id ); |
|
1073 | +function give_get_payment_currency_code($payment_id = 0) { |
|
1074 | + $payment = new Give_Payment($payment_id); |
|
1075 | 1075 | |
1076 | 1076 | return $payment->currency; |
1077 | 1077 | } |
@@ -1085,10 +1085,10 @@ discard block |
||
1085 | 1085 | * |
1086 | 1086 | * @return string $currency The currency name |
1087 | 1087 | */ |
1088 | -function give_get_payment_currency( $payment_id = 0 ) { |
|
1089 | - $currency = give_get_payment_currency_code( $payment_id ); |
|
1088 | +function give_get_payment_currency($payment_id = 0) { |
|
1089 | + $currency = give_get_payment_currency_code($payment_id); |
|
1090 | 1090 | |
1091 | - return apply_filters( 'give_payment_currency', give_get_currency_name( $currency ), $payment_id ); |
|
1091 | + return apply_filters('give_payment_currency', give_get_currency_name($currency), $payment_id); |
|
1092 | 1092 | } |
1093 | 1093 | |
1094 | 1094 | /** |
@@ -1100,8 +1100,8 @@ discard block |
||
1100 | 1100 | * |
1101 | 1101 | * @return string $key Purchase key |
1102 | 1102 | */ |
1103 | -function give_get_payment_key( $payment_id = 0 ) { |
|
1104 | - $payment = new Give_Payment( $payment_id ); |
|
1103 | +function give_get_payment_key($payment_id = 0) { |
|
1104 | + $payment = new Give_Payment($payment_id); |
|
1105 | 1105 | |
1106 | 1106 | return $payment->key; |
1107 | 1107 | } |
@@ -1117,8 +1117,8 @@ discard block |
||
1117 | 1117 | * |
1118 | 1118 | * @return string $number Payment order number |
1119 | 1119 | */ |
1120 | -function give_get_payment_number( $payment_id = 0 ) { |
|
1121 | - $payment = new Give_Payment( $payment_id ); |
|
1120 | +function give_get_payment_number($payment_id = 0) { |
|
1121 | + $payment = new Give_Payment($payment_id); |
|
1122 | 1122 | |
1123 | 1123 | return $payment->number; |
1124 | 1124 | } |
@@ -1132,23 +1132,23 @@ discard block |
||
1132 | 1132 | * |
1133 | 1133 | * @return string The formatted payment number |
1134 | 1134 | */ |
1135 | -function give_format_payment_number( $number ) { |
|
1135 | +function give_format_payment_number($number) { |
|
1136 | 1136 | |
1137 | - if ( ! give_get_option( 'enable_sequential' ) ) { |
|
1137 | + if ( ! give_get_option('enable_sequential')) { |
|
1138 | 1138 | return $number; |
1139 | 1139 | } |
1140 | 1140 | |
1141 | - if ( ! is_numeric( $number ) ) { |
|
1141 | + if ( ! is_numeric($number)) { |
|
1142 | 1142 | return $number; |
1143 | 1143 | } |
1144 | 1144 | |
1145 | - $prefix = give_get_option( 'sequential_prefix' ); |
|
1146 | - $number = absint( $number ); |
|
1147 | - $postfix = give_get_option( 'sequential_postfix' ); |
|
1145 | + $prefix = give_get_option('sequential_prefix'); |
|
1146 | + $number = absint($number); |
|
1147 | + $postfix = give_get_option('sequential_postfix'); |
|
1148 | 1148 | |
1149 | - $formatted_number = $prefix . $number . $postfix; |
|
1149 | + $formatted_number = $prefix.$number.$postfix; |
|
1150 | 1150 | |
1151 | - return apply_filters( 'give_format_payment_number', $formatted_number, $prefix, $number, $postfix ); |
|
1151 | + return apply_filters('give_format_payment_number', $formatted_number, $prefix, $number, $postfix); |
|
1152 | 1152 | } |
1153 | 1153 | |
1154 | 1154 | /** |
@@ -1161,17 +1161,17 @@ discard block |
||
1161 | 1161 | */ |
1162 | 1162 | function give_get_next_payment_number() { |
1163 | 1163 | |
1164 | - if ( ! give_get_option( 'enable_sequential' ) ) { |
|
1164 | + if ( ! give_get_option('enable_sequential')) { |
|
1165 | 1165 | return false; |
1166 | 1166 | } |
1167 | 1167 | |
1168 | - $number = get_option( 'give_last_payment_number' ); |
|
1169 | - $start = give_get_option( 'sequential_start', 1 ); |
|
1168 | + $number = get_option('give_last_payment_number'); |
|
1169 | + $start = give_get_option('sequential_start', 1); |
|
1170 | 1170 | $increment_number = true; |
1171 | 1171 | |
1172 | - if ( false !== $number ) { |
|
1172 | + if (false !== $number) { |
|
1173 | 1173 | |
1174 | - if ( empty( $number ) ) { |
|
1174 | + if (empty($number)) { |
|
1175 | 1175 | |
1176 | 1176 | $number = $start; |
1177 | 1177 | $increment_number = false; |
@@ -1181,24 +1181,24 @@ discard block |
||
1181 | 1181 | } else { |
1182 | 1182 | |
1183 | 1183 | // This case handles the first addition of the new option, as well as if it get's deleted for any reason |
1184 | - $payments = new Give_Payments_Query( array( |
|
1184 | + $payments = new Give_Payments_Query(array( |
|
1185 | 1185 | 'number' => 1, |
1186 | 1186 | 'order' => 'DESC', |
1187 | 1187 | 'orderby' => 'ID', |
1188 | 1188 | 'output' => 'posts', |
1189 | 1189 | 'fields' => 'ids' |
1190 | - ) ); |
|
1190 | + )); |
|
1191 | 1191 | $last_payment = $payments->get_payments(); |
1192 | 1192 | |
1193 | - if ( ! empty( $last_payment ) ) { |
|
1193 | + if ( ! empty($last_payment)) { |
|
1194 | 1194 | |
1195 | - $number = give_get_payment_number( $last_payment[0] ); |
|
1195 | + $number = give_get_payment_number($last_payment[0]); |
|
1196 | 1196 | |
1197 | 1197 | } |
1198 | 1198 | |
1199 | - if ( ! empty( $number ) && $number !== (int) $last_payment[0] ) { |
|
1199 | + if ( ! empty($number) && $number !== (int) $last_payment[0]) { |
|
1200 | 1200 | |
1201 | - $number = give_remove_payment_prefix_postfix( $number ); |
|
1201 | + $number = give_remove_payment_prefix_postfix($number); |
|
1202 | 1202 | |
1203 | 1203 | } else { |
1204 | 1204 | |
@@ -1208,13 +1208,13 @@ discard block |
||
1208 | 1208 | |
1209 | 1209 | } |
1210 | 1210 | |
1211 | - $increment_number = apply_filters( 'give_increment_payment_number', $increment_number, $number ); |
|
1211 | + $increment_number = apply_filters('give_increment_payment_number', $increment_number, $number); |
|
1212 | 1212 | |
1213 | - if ( $increment_number ) { |
|
1214 | - $number ++; |
|
1213 | + if ($increment_number) { |
|
1214 | + $number++; |
|
1215 | 1215 | } |
1216 | 1216 | |
1217 | - return apply_filters( 'give_get_next_payment_number', $number ); |
|
1217 | + return apply_filters('give_get_next_payment_number', $number); |
|
1218 | 1218 | } |
1219 | 1219 | |
1220 | 1220 | /** |
@@ -1226,25 +1226,25 @@ discard block |
||
1226 | 1226 | * |
1227 | 1227 | * @return string The new Payment number without prefix and postfix |
1228 | 1228 | */ |
1229 | -function give_remove_payment_prefix_postfix( $number ) { |
|
1229 | +function give_remove_payment_prefix_postfix($number) { |
|
1230 | 1230 | |
1231 | - $prefix = give_get_option( 'sequential_prefix' ); |
|
1232 | - $postfix = give_get_option( 'sequential_postfix' ); |
|
1231 | + $prefix = give_get_option('sequential_prefix'); |
|
1232 | + $postfix = give_get_option('sequential_postfix'); |
|
1233 | 1233 | |
1234 | 1234 | // Remove prefix |
1235 | - $number = preg_replace( '/' . $prefix . '/', '', $number, 1 ); |
|
1235 | + $number = preg_replace('/'.$prefix.'/', '', $number, 1); |
|
1236 | 1236 | |
1237 | 1237 | // Remove the postfix |
1238 | - $length = strlen( $number ); |
|
1239 | - $postfix_pos = strrpos( $number, $postfix ); |
|
1240 | - if ( false !== $postfix_pos ) { |
|
1241 | - $number = substr_replace( $number, '', $postfix_pos, $length ); |
|
1238 | + $length = strlen($number); |
|
1239 | + $postfix_pos = strrpos($number, $postfix); |
|
1240 | + if (false !== $postfix_pos) { |
|
1241 | + $number = substr_replace($number, '', $postfix_pos, $length); |
|
1242 | 1242 | } |
1243 | 1243 | |
1244 | 1244 | // Ensure it's a whole number |
1245 | - $number = intval( $number ); |
|
1245 | + $number = intval($number); |
|
1246 | 1246 | |
1247 | - return apply_filters( 'give_remove_payment_prefix_postfix', $number, $prefix, $postfix ); |
|
1247 | + return apply_filters('give_remove_payment_prefix_postfix', $number, $prefix, $postfix); |
|
1248 | 1248 | |
1249 | 1249 | } |
1250 | 1250 | |
@@ -1260,10 +1260,10 @@ discard block |
||
1260 | 1260 | * |
1261 | 1261 | * @return string $amount Fully formatted payment amount |
1262 | 1262 | */ |
1263 | -function give_payment_amount( $payment_id = 0 ) { |
|
1264 | - $amount = give_get_payment_amount( $payment_id ); |
|
1263 | +function give_payment_amount($payment_id = 0) { |
|
1264 | + $amount = give_get_payment_amount($payment_id); |
|
1265 | 1265 | |
1266 | - return give_currency_filter( give_format_amount( $amount ), give_get_payment_currency_code( $payment_id ) ); |
|
1266 | + return give_currency_filter(give_format_amount($amount), give_get_payment_currency_code($payment_id)); |
|
1267 | 1267 | } |
1268 | 1268 | |
1269 | 1269 | /** |
@@ -1276,11 +1276,11 @@ discard block |
||
1276 | 1276 | * |
1277 | 1277 | * @return mixed|void |
1278 | 1278 | */ |
1279 | -function give_get_payment_amount( $payment_id ) { |
|
1279 | +function give_get_payment_amount($payment_id) { |
|
1280 | 1280 | |
1281 | - $payment = new Give_Payment( $payment_id ); |
|
1281 | + $payment = new Give_Payment($payment_id); |
|
1282 | 1282 | |
1283 | - return apply_filters( 'give_payment_amount', floatval( $payment->total ), $payment_id ); |
|
1283 | + return apply_filters('give_payment_amount', floatval($payment->total), $payment_id); |
|
1284 | 1284 | } |
1285 | 1285 | |
1286 | 1286 | /** |
@@ -1296,10 +1296,10 @@ discard block |
||
1296 | 1296 | * |
1297 | 1297 | * @return array Fully formatted payment subtotal |
1298 | 1298 | */ |
1299 | -function give_payment_subtotal( $payment_id = 0 ) { |
|
1300 | - $subtotal = give_get_payment_subtotal( $payment_id ); |
|
1299 | +function give_payment_subtotal($payment_id = 0) { |
|
1300 | + $subtotal = give_get_payment_subtotal($payment_id); |
|
1301 | 1301 | |
1302 | - return give_currency_filter( give_format_amount( $subtotal ), give_get_payment_currency_code( $payment_id ) ); |
|
1302 | + return give_currency_filter(give_format_amount($subtotal), give_get_payment_currency_code($payment_id)); |
|
1303 | 1303 | } |
1304 | 1304 | |
1305 | 1305 | /** |
@@ -1313,8 +1313,8 @@ discard block |
||
1313 | 1313 | * |
1314 | 1314 | * @return float $subtotal Subtotal for payment (non formatted) |
1315 | 1315 | */ |
1316 | -function give_get_payment_subtotal( $payment_id = 0 ) { |
|
1317 | - $payment = new G_Payment( $payment_id ); |
|
1316 | +function give_get_payment_subtotal($payment_id = 0) { |
|
1317 | + $payment = new G_Payment($payment_id); |
|
1318 | 1318 | |
1319 | 1319 | return $payment->subtotal; |
1320 | 1320 | } |
@@ -1329,10 +1329,10 @@ discard block |
||
1329 | 1329 | * |
1330 | 1330 | * @return mixed array if payment fees found, false otherwise |
1331 | 1331 | */ |
1332 | -function give_get_payment_fees( $payment_id = 0, $type = 'all' ) { |
|
1333 | - $payment = new Give_Payment( $payment_id ); |
|
1332 | +function give_get_payment_fees($payment_id = 0, $type = 'all') { |
|
1333 | + $payment = new Give_Payment($payment_id); |
|
1334 | 1334 | |
1335 | - return $payment->get_fees( $type ); |
|
1335 | + return $payment->get_fees($type); |
|
1336 | 1336 | } |
1337 | 1337 | |
1338 | 1338 | /** |
@@ -1344,8 +1344,8 @@ discard block |
||
1344 | 1344 | * |
1345 | 1345 | * @return string The Transaction ID |
1346 | 1346 | */ |
1347 | -function give_get_payment_transaction_id( $payment_id = 0 ) { |
|
1348 | - $payment = new Give_Payment( $payment_id ); |
|
1347 | +function give_get_payment_transaction_id($payment_id = 0) { |
|
1348 | + $payment = new Give_Payment($payment_id); |
|
1349 | 1349 | |
1350 | 1350 | return $payment->transaction_id; |
1351 | 1351 | } |
@@ -1360,15 +1360,15 @@ discard block |
||
1360 | 1360 | * |
1361 | 1361 | * @return bool|mixed |
1362 | 1362 | */ |
1363 | -function give_set_payment_transaction_id( $payment_id = 0, $transaction_id = '' ) { |
|
1363 | +function give_set_payment_transaction_id($payment_id = 0, $transaction_id = '') { |
|
1364 | 1364 | |
1365 | - if ( empty( $payment_id ) || empty( $transaction_id ) ) { |
|
1365 | + if (empty($payment_id) || empty($transaction_id)) { |
|
1366 | 1366 | return false; |
1367 | 1367 | } |
1368 | 1368 | |
1369 | - $transaction_id = apply_filters( 'give_set_payment_transaction_id', $transaction_id, $payment_id ); |
|
1369 | + $transaction_id = apply_filters('give_set_payment_transaction_id', $transaction_id, $payment_id); |
|
1370 | 1370 | |
1371 | - return give_update_payment_meta( $payment_id, '_give_payment_transaction_id', $transaction_id ); |
|
1371 | + return give_update_payment_meta($payment_id, '_give_payment_transaction_id', $transaction_id); |
|
1372 | 1372 | } |
1373 | 1373 | |
1374 | 1374 | /** |
@@ -1382,12 +1382,12 @@ discard block |
||
1382 | 1382 | * |
1383 | 1383 | * @return int $purchase Purchase ID |
1384 | 1384 | */ |
1385 | -function give_get_purchase_id_by_key( $key ) { |
|
1385 | +function give_get_purchase_id_by_key($key) { |
|
1386 | 1386 | global $wpdb; |
1387 | 1387 | |
1388 | - $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 ) ); |
|
1388 | + $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)); |
|
1389 | 1389 | |
1390 | - if ( $purchase != null ) { |
|
1390 | + if ($purchase != null) { |
|
1391 | 1391 | return $purchase; |
1392 | 1392 | } |
1393 | 1393 | |
@@ -1406,12 +1406,12 @@ discard block |
||
1406 | 1406 | * |
1407 | 1407 | * @return int $purchase Purchase ID |
1408 | 1408 | */ |
1409 | -function give_get_purchase_id_by_transaction_id( $key ) { |
|
1409 | +function give_get_purchase_id_by_transaction_id($key) { |
|
1410 | 1410 | global $wpdb; |
1411 | 1411 | |
1412 | - $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 ) ); |
|
1412 | + $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)); |
|
1413 | 1413 | |
1414 | - if ( $purchase != null ) { |
|
1414 | + if ($purchase != null) { |
|
1415 | 1415 | return $purchase; |
1416 | 1416 | } |
1417 | 1417 | |
@@ -1428,19 +1428,19 @@ discard block |
||
1428 | 1428 | * |
1429 | 1429 | * @return array $notes Payment Notes |
1430 | 1430 | */ |
1431 | -function give_get_payment_notes( $payment_id = 0, $search = '' ) { |
|
1431 | +function give_get_payment_notes($payment_id = 0, $search = '') { |
|
1432 | 1432 | |
1433 | - if ( empty( $payment_id ) && empty( $search ) ) { |
|
1433 | + if (empty($payment_id) && empty($search)) { |
|
1434 | 1434 | return false; |
1435 | 1435 | } |
1436 | 1436 | |
1437 | - remove_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
1438 | - remove_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10 ); |
|
1437 | + remove_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
1438 | + remove_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10); |
|
1439 | 1439 | |
1440 | - $notes = get_comments( array( 'post_id' => $payment_id, 'order' => 'ASC', 'search' => $search ) ); |
|
1440 | + $notes = get_comments(array('post_id' => $payment_id, 'order' => 'ASC', 'search' => $search)); |
|
1441 | 1441 | |
1442 | - add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
1443 | - add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 ); |
|
1442 | + add_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
1443 | + add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2); |
|
1444 | 1444 | |
1445 | 1445 | return $notes; |
1446 | 1446 | } |
@@ -1456,19 +1456,19 @@ discard block |
||
1456 | 1456 | * |
1457 | 1457 | * @return int The new note ID |
1458 | 1458 | */ |
1459 | -function give_insert_payment_note( $payment_id = 0, $note = '' ) { |
|
1460 | - if ( empty( $payment_id ) ) { |
|
1459 | +function give_insert_payment_note($payment_id = 0, $note = '') { |
|
1460 | + if (empty($payment_id)) { |
|
1461 | 1461 | return false; |
1462 | 1462 | } |
1463 | 1463 | |
1464 | - do_action( 'give_pre_insert_payment_note', $payment_id, $note ); |
|
1464 | + do_action('give_pre_insert_payment_note', $payment_id, $note); |
|
1465 | 1465 | |
1466 | - $note_id = wp_insert_comment( wp_filter_comment( array( |
|
1466 | + $note_id = wp_insert_comment(wp_filter_comment(array( |
|
1467 | 1467 | 'comment_post_ID' => $payment_id, |
1468 | 1468 | 'comment_content' => $note, |
1469 | 1469 | 'user_id' => is_admin() ? get_current_user_id() : 0, |
1470 | - 'comment_date' => current_time( 'mysql' ), |
|
1471 | - 'comment_date_gmt' => current_time( 'mysql', 1 ), |
|
1470 | + 'comment_date' => current_time('mysql'), |
|
1471 | + 'comment_date_gmt' => current_time('mysql', 1), |
|
1472 | 1472 | 'comment_approved' => 1, |
1473 | 1473 | 'comment_parent' => 0, |
1474 | 1474 | 'comment_author' => '', |
@@ -1477,9 +1477,9 @@ discard block |
||
1477 | 1477 | 'comment_author_email' => '', |
1478 | 1478 | 'comment_type' => 'give_payment_note' |
1479 | 1479 | |
1480 | - ) ) ); |
|
1480 | + ))); |
|
1481 | 1481 | |
1482 | - do_action( 'give_insert_payment_note', $note_id, $payment_id, $note ); |
|
1482 | + do_action('give_insert_payment_note', $note_id, $payment_id, $note); |
|
1483 | 1483 | |
1484 | 1484 | return $note_id; |
1485 | 1485 | } |
@@ -1494,14 +1494,14 @@ discard block |
||
1494 | 1494 | * |
1495 | 1495 | * @return bool True on success, false otherwise |
1496 | 1496 | */ |
1497 | -function give_delete_payment_note( $comment_id = 0, $payment_id = 0 ) { |
|
1498 | - if ( empty( $comment_id ) ) { |
|
1497 | +function give_delete_payment_note($comment_id = 0, $payment_id = 0) { |
|
1498 | + if (empty($comment_id)) { |
|
1499 | 1499 | return false; |
1500 | 1500 | } |
1501 | 1501 | |
1502 | - do_action( 'give_pre_delete_payment_note', $comment_id, $payment_id ); |
|
1503 | - $ret = wp_delete_comment( $comment_id, true ); |
|
1504 | - do_action( 'give_post_delete_payment_note', $comment_id, $payment_id ); |
|
1502 | + do_action('give_pre_delete_payment_note', $comment_id, $payment_id); |
|
1503 | + $ret = wp_delete_comment($comment_id, true); |
|
1504 | + do_action('give_post_delete_payment_note', $comment_id, $payment_id); |
|
1505 | 1505 | |
1506 | 1506 | return $ret; |
1507 | 1507 | } |
@@ -1516,32 +1516,32 @@ discard block |
||
1516 | 1516 | * |
1517 | 1517 | * @return string |
1518 | 1518 | */ |
1519 | -function give_get_payment_note_html( $note, $payment_id = 0 ) { |
|
1519 | +function give_get_payment_note_html($note, $payment_id = 0) { |
|
1520 | 1520 | |
1521 | - if ( is_numeric( $note ) ) { |
|
1522 | - $note = get_comment( $note ); |
|
1521 | + if (is_numeric($note)) { |
|
1522 | + $note = get_comment($note); |
|
1523 | 1523 | } |
1524 | 1524 | |
1525 | - if ( ! empty( $note->user_id ) ) { |
|
1526 | - $user = get_userdata( $note->user_id ); |
|
1525 | + if ( ! empty($note->user_id)) { |
|
1526 | + $user = get_userdata($note->user_id); |
|
1527 | 1527 | $user = $user->display_name; |
1528 | 1528 | } else { |
1529 | - $user = esc_html__( 'System', 'give' ); |
|
1529 | + $user = esc_html__('System', 'give'); |
|
1530 | 1530 | } |
1531 | 1531 | |
1532 | - $date_format = get_option( 'date_format' ) . ', ' . get_option( 'time_format' ); |
|
1532 | + $date_format = get_option('date_format').', '.get_option('time_format'); |
|
1533 | 1533 | |
1534 | - $delete_note_url = wp_nonce_url( add_query_arg( array( |
|
1534 | + $delete_note_url = wp_nonce_url(add_query_arg(array( |
|
1535 | 1535 | 'give-action' => 'delete_payment_note', |
1536 | 1536 | 'note_id' => $note->comment_ID, |
1537 | 1537 | 'payment_id' => $payment_id |
1538 | - ) ), 'give_delete_payment_note_' . $note->comment_ID ); |
|
1538 | + )), 'give_delete_payment_note_'.$note->comment_ID); |
|
1539 | 1539 | |
1540 | - $note_html = '<div class="give-payment-note" id="give-payment-note-' . $note->comment_ID . '">'; |
|
1540 | + $note_html = '<div class="give-payment-note" id="give-payment-note-'.$note->comment_ID.'">'; |
|
1541 | 1541 | $note_html .= '<p>'; |
1542 | - $note_html .= '<strong>' . $user . '</strong> – <span style="color:#aaa;font-style:italic;">' . date_i18n( $date_format, strtotime( $note->comment_date ) ) . '</span><br/>'; |
|
1542 | + $note_html .= '<strong>'.$user.'</strong> – <span style="color:#aaa;font-style:italic;">'.date_i18n($date_format, strtotime($note->comment_date)).'</span><br/>'; |
|
1543 | 1543 | $note_html .= $note->comment_content; |
1544 | - $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 ) . '" title="' . esc_attr__( 'Delete this payment note', 'give' ) . '">' . esc_html__( 'Delete', 'give' ) . '</a>'; |
|
1544 | + $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).'" title="'.esc_attr__('Delete this payment note', 'give').'">'.esc_html__('Delete', 'give').'</a>'; |
|
1545 | 1545 | $note_html .= '</p>'; |
1546 | 1546 | $note_html .= '</div>'; |
1547 | 1547 | |
@@ -1559,20 +1559,20 @@ discard block |
||
1559 | 1559 | * |
1560 | 1560 | * @return void |
1561 | 1561 | */ |
1562 | -function give_hide_payment_notes( $query ) { |
|
1562 | +function give_hide_payment_notes($query) { |
|
1563 | 1563 | global $wp_version; |
1564 | 1564 | |
1565 | - if ( version_compare( floatval( $wp_version ), '4.1', '>=' ) ) { |
|
1566 | - $types = isset( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array(); |
|
1567 | - if ( ! is_array( $types ) ) { |
|
1568 | - $types = array( $types ); |
|
1565 | + if (version_compare(floatval($wp_version), '4.1', '>=')) { |
|
1566 | + $types = isset($query->query_vars['type__not_in']) ? $query->query_vars['type__not_in'] : array(); |
|
1567 | + if ( ! is_array($types)) { |
|
1568 | + $types = array($types); |
|
1569 | 1569 | } |
1570 | 1570 | $types[] = 'give_payment_note'; |
1571 | 1571 | $query->query_vars['type__not_in'] = $types; |
1572 | 1572 | } |
1573 | 1573 | } |
1574 | 1574 | |
1575 | -add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
1575 | +add_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
1576 | 1576 | |
1577 | 1577 | /** |
1578 | 1578 | * Exclude notes (comments) on give_payment post type from showing in Recent Comments widgets |
@@ -1584,17 +1584,17 @@ discard block |
||
1584 | 1584 | * |
1585 | 1585 | * @return array $clauses Updated comment clauses |
1586 | 1586 | */ |
1587 | -function give_hide_payment_notes_pre_41( $clauses, $wp_comment_query ) { |
|
1587 | +function give_hide_payment_notes_pre_41($clauses, $wp_comment_query) { |
|
1588 | 1588 | global $wpdb, $wp_version; |
1589 | 1589 | |
1590 | - if ( version_compare( floatval( $wp_version ), '4.1', '<' ) ) { |
|
1590 | + if (version_compare(floatval($wp_version), '4.1', '<')) { |
|
1591 | 1591 | $clauses['where'] .= ' AND comment_type != "give_payment_note"'; |
1592 | 1592 | } |
1593 | 1593 | |
1594 | 1594 | return $clauses; |
1595 | 1595 | } |
1596 | 1596 | |
1597 | -add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 ); |
|
1597 | +add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2); |
|
1598 | 1598 | |
1599 | 1599 | |
1600 | 1600 | /** |
@@ -1607,15 +1607,15 @@ discard block |
||
1607 | 1607 | * |
1608 | 1608 | * @return array $where |
1609 | 1609 | */ |
1610 | -function give_hide_payment_notes_from_feeds( $where, $wp_comment_query ) { |
|
1610 | +function give_hide_payment_notes_from_feeds($where, $wp_comment_query) { |
|
1611 | 1611 | global $wpdb; |
1612 | 1612 | |
1613 | - $where .= $wpdb->prepare( " AND comment_type != %s", 'give_payment_note' ); |
|
1613 | + $where .= $wpdb->prepare(" AND comment_type != %s", 'give_payment_note'); |
|
1614 | 1614 | |
1615 | 1615 | return $where; |
1616 | 1616 | } |
1617 | 1617 | |
1618 | -add_filter( 'comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2 ); |
|
1618 | +add_filter('comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2); |
|
1619 | 1619 | |
1620 | 1620 | |
1621 | 1621 | /** |
@@ -1629,32 +1629,32 @@ discard block |
||
1629 | 1629 | * |
1630 | 1630 | * @return array Array of comment counts |
1631 | 1631 | */ |
1632 | -function give_remove_payment_notes_in_comment_counts( $stats, $post_id ) { |
|
1632 | +function give_remove_payment_notes_in_comment_counts($stats, $post_id) { |
|
1633 | 1633 | global $wpdb, $pagenow; |
1634 | 1634 | |
1635 | - if ( 'index.php' != $pagenow ) { |
|
1635 | + if ('index.php' != $pagenow) { |
|
1636 | 1636 | return $stats; |
1637 | 1637 | } |
1638 | 1638 | |
1639 | 1639 | $post_id = (int) $post_id; |
1640 | 1640 | |
1641 | - if ( apply_filters( 'give_count_payment_notes_in_comments', false ) ) { |
|
1641 | + if (apply_filters('give_count_payment_notes_in_comments', false)) { |
|
1642 | 1642 | return $stats; |
1643 | 1643 | } |
1644 | 1644 | |
1645 | - $stats = wp_cache_get( "comments-{$post_id}", 'counts' ); |
|
1645 | + $stats = wp_cache_get("comments-{$post_id}", 'counts'); |
|
1646 | 1646 | |
1647 | - if ( false !== $stats ) { |
|
1647 | + if (false !== $stats) { |
|
1648 | 1648 | return $stats; |
1649 | 1649 | } |
1650 | 1650 | |
1651 | 1651 | $where = 'WHERE comment_type != "give_payment_note"'; |
1652 | 1652 | |
1653 | - if ( $post_id > 0 ) { |
|
1654 | - $where .= $wpdb->prepare( " AND comment_post_ID = %d", $post_id ); |
|
1653 | + if ($post_id > 0) { |
|
1654 | + $where .= $wpdb->prepare(" AND comment_post_ID = %d", $post_id); |
|
1655 | 1655 | } |
1656 | 1656 | |
1657 | - $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A ); |
|
1657 | + $count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A); |
|
1658 | 1658 | |
1659 | 1659 | $total = 0; |
1660 | 1660 | $approved = array( |
@@ -1664,30 +1664,30 @@ discard block |
||
1664 | 1664 | 'trash' => 'trash', |
1665 | 1665 | 'post-trashed' => 'post-trashed' |
1666 | 1666 | ); |
1667 | - foreach ( (array) $count as $row ) { |
|
1667 | + foreach ((array) $count as $row) { |
|
1668 | 1668 | // Don't count post-trashed toward totals |
1669 | - if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) { |
|
1669 | + if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) { |
|
1670 | 1670 | $total += $row['num_comments']; |
1671 | 1671 | } |
1672 | - if ( isset( $approved[ $row['comment_approved'] ] ) ) { |
|
1673 | - $stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments']; |
|
1672 | + if (isset($approved[$row['comment_approved']])) { |
|
1673 | + $stats[$approved[$row['comment_approved']]] = $row['num_comments']; |
|
1674 | 1674 | } |
1675 | 1675 | } |
1676 | 1676 | |
1677 | 1677 | $stats['total_comments'] = $total; |
1678 | - foreach ( $approved as $key ) { |
|
1679 | - if ( empty( $stats[ $key ] ) ) { |
|
1680 | - $stats[ $key ] = 0; |
|
1678 | + foreach ($approved as $key) { |
|
1679 | + if (empty($stats[$key])) { |
|
1680 | + $stats[$key] = 0; |
|
1681 | 1681 | } |
1682 | 1682 | } |
1683 | 1683 | |
1684 | 1684 | $stats = (object) $stats; |
1685 | - wp_cache_set( "comments-{$post_id}", $stats, 'counts' ); |
|
1685 | + wp_cache_set("comments-{$post_id}", $stats, 'counts'); |
|
1686 | 1686 | |
1687 | 1687 | return $stats; |
1688 | 1688 | } |
1689 | 1689 | |
1690 | -add_filter( 'wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2 ); |
|
1690 | +add_filter('wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2); |
|
1691 | 1691 | |
1692 | 1692 | |
1693 | 1693 | /** |
@@ -1700,9 +1700,9 @@ discard block |
||
1700 | 1700 | * |
1701 | 1701 | * @return string $where Modified where clause |
1702 | 1702 | */ |
1703 | -function give_filter_where_older_than_week( $where = '' ) { |
|
1703 | +function give_filter_where_older_than_week($where = '') { |
|
1704 | 1704 | // Payments older than one week |
1705 | - $start = date( 'Y-m-d', strtotime( '-7 days' ) ); |
|
1705 | + $start = date('Y-m-d', strtotime('-7 days')); |
|
1706 | 1706 | $where .= " AND post_date <= '{$start}'"; |
1707 | 1707 | |
1708 | 1708 | return $where; |
@@ -1722,35 +1722,35 @@ discard block |
||
1722 | 1722 | * |
1723 | 1723 | * @return string $form_title Returns the full title if $level_title false, otherwise returns the levels title |
1724 | 1724 | */ |
1725 | -function give_get_payment_form_title( $payment_meta, $level_title = false, $separator = '' ) { |
|
1725 | +function give_get_payment_form_title($payment_meta, $level_title = false, $separator = '') { |
|
1726 | 1726 | |
1727 | - $form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0; |
|
1728 | - $form_title = isset( $payment_meta['form_title'] ) ? $payment_meta['form_title'] : ''; |
|
1729 | - $price_id = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null; |
|
1727 | + $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0; |
|
1728 | + $form_title = isset($payment_meta['form_title']) ? $payment_meta['form_title'] : ''; |
|
1729 | + $price_id = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null; |
|
1730 | 1730 | |
1731 | - if ( $level_title == true ) { |
|
1731 | + if ($level_title == true) { |
|
1732 | 1732 | $form_title = ''; |
1733 | 1733 | } |
1734 | 1734 | |
1735 | - if ( give_has_variable_prices( $form_id ) ) { |
|
1735 | + if (give_has_variable_prices($form_id)) { |
|
1736 | 1736 | |
1737 | - if ( ! empty( $separator ) ) { |
|
1738 | - $form_title .= ' ' . $separator; |
|
1737 | + if ( ! empty($separator)) { |
|
1738 | + $form_title .= ' '.$separator; |
|
1739 | 1739 | } |
1740 | 1740 | $form_title .= ' <span class="donation-level-text-wrap">'; |
1741 | 1741 | |
1742 | - if ( $price_id == 'custom' ) { |
|
1743 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
1744 | - $form_title .= ! empty( $custom_amount_text ) ? $custom_amount_text : esc_html__( 'Custom Amount', 'give' ); |
|
1742 | + if ($price_id == 'custom') { |
|
1743 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
1744 | + $form_title .= ! empty($custom_amount_text) ? $custom_amount_text : esc_html__('Custom Amount', 'give'); |
|
1745 | 1745 | } else { |
1746 | - $form_title .= give_get_price_option_name( $form_id, $price_id ); |
|
1746 | + $form_title .= give_get_price_option_name($form_id, $price_id); |
|
1747 | 1747 | } |
1748 | 1748 | |
1749 | 1749 | $form_title .= '</span>'; |
1750 | 1750 | |
1751 | 1751 | } |
1752 | 1752 | |
1753 | - return apply_filters( 'give_get_payment_form_title', $form_title, $payment_meta ); |
|
1753 | + return apply_filters('give_get_payment_form_title', $form_title, $payment_meta); |
|
1754 | 1754 | |
1755 | 1755 | } |
1756 | 1756 | |
@@ -1764,20 +1764,20 @@ discard block |
||
1764 | 1764 | * |
1765 | 1765 | * @return string $price_id |
1766 | 1766 | */ |
1767 | -function give_get_price_id( $form_id, $price ) { |
|
1767 | +function give_get_price_id($form_id, $price) { |
|
1768 | 1768 | |
1769 | 1769 | $price_id = 0; |
1770 | 1770 | |
1771 | - if ( give_has_variable_prices( $form_id ) ) { |
|
1771 | + if (give_has_variable_prices($form_id)) { |
|
1772 | 1772 | |
1773 | - $levels = maybe_unserialize( get_post_meta( $form_id, '_give_donation_levels', true ) ); |
|
1773 | + $levels = maybe_unserialize(get_post_meta($form_id, '_give_donation_levels', true)); |
|
1774 | 1774 | |
1775 | - foreach ( $levels as $level ) { |
|
1775 | + foreach ($levels as $level) { |
|
1776 | 1776 | |
1777 | - $level_amount = (float) give_sanitize_amount( $level['_give_amount'] ); |
|
1777 | + $level_amount = (float) give_sanitize_amount($level['_give_amount']); |
|
1778 | 1778 | |
1779 | 1779 | //check that this indeed the recurring price |
1780 | - if ( $level_amount == $price ) { |
|
1780 | + if ($level_amount == $price) { |
|
1781 | 1781 | |
1782 | 1782 | $price_id = $level['_give_id']['level_id']; |
1783 | 1783 | |
@@ -1804,10 +1804,10 @@ discard block |
||
1804 | 1804 | * |
1805 | 1805 | * @return string/void |
1806 | 1806 | */ |
1807 | -function give_get_form_dropdown( $args = array(), $echo = false ) { |
|
1808 | - $form_dropdown_html = Give()->html->forms_dropdown( $args ); |
|
1807 | +function give_get_form_dropdown($args = array(), $echo = false) { |
|
1808 | + $form_dropdown_html = Give()->html->forms_dropdown($args); |
|
1809 | 1809 | |
1810 | - if ( ! $echo ) { |
|
1810 | + if ( ! $echo) { |
|
1811 | 1811 | return $form_dropdown_html; |
1812 | 1812 | } |
1813 | 1813 | |
@@ -1824,39 +1824,39 @@ discard block |
||
1824 | 1824 | * |
1825 | 1825 | * @return string/void |
1826 | 1826 | */ |
1827 | -function give_get_form_variable_price_dropdown( $args = array(), $echo = false ) { |
|
1827 | +function give_get_form_variable_price_dropdown($args = array(), $echo = false) { |
|
1828 | 1828 | |
1829 | 1829 | // Check for give form id. |
1830 | - if ( empty( $args['id'] ) ) { |
|
1830 | + if (empty($args['id'])) { |
|
1831 | 1831 | return false; |
1832 | 1832 | } |
1833 | 1833 | |
1834 | 1834 | // Check if form has variable prices or not. |
1835 | - if ( ! ( $variable_prices = give_has_variable_prices( $args['id'] ) ) ) { |
|
1835 | + if ( ! ($variable_prices = give_has_variable_prices($args['id']))) { |
|
1836 | 1836 | return false; |
1837 | 1837 | } |
1838 | 1838 | |
1839 | - $variable_prices = give_get_variable_prices( absint( $args['id'] ) ); |
|
1839 | + $variable_prices = give_get_variable_prices(absint($args['id'])); |
|
1840 | 1840 | $variable_price_options = array(); |
1841 | 1841 | |
1842 | 1842 | // Check if multi donation form support custom donation or not. |
1843 | - if ( give_is_custom_price_mode( absint( $args['id'] ) ) ) { |
|
1844 | - $variable_price_options['custom'] = _x( 'Custom', 'custom donation dropdown item', 'give' ); |
|
1843 | + if (give_is_custom_price_mode(absint($args['id']))) { |
|
1844 | + $variable_price_options['custom'] = _x('Custom', 'custom donation dropdown item', 'give'); |
|
1845 | 1845 | } |
1846 | 1846 | |
1847 | 1847 | // Get variable price and ID from variable price array. |
1848 | - foreach ( $variable_prices as $variable_price ) { |
|
1849 | - $variable_price_options[ $variable_price['_give_id']['level_id'] ] = $variable_price['_give_text']; |
|
1848 | + foreach ($variable_prices as $variable_price) { |
|
1849 | + $variable_price_options[$variable_price['_give_id']['level_id']] = $variable_price['_give_text']; |
|
1850 | 1850 | } |
1851 | 1851 | |
1852 | 1852 | |
1853 | 1853 | // Update options. |
1854 | - $args = array_merge( $args, array( 'options' => $variable_price_options ) ); |
|
1854 | + $args = array_merge($args, array('options' => $variable_price_options)); |
|
1855 | 1855 | |
1856 | 1856 | // Generate select html. |
1857 | - $form_dropdown_html = Give()->html->select( $args ); |
|
1857 | + $form_dropdown_html = Give()->html->select($args); |
|
1858 | 1858 | |
1859 | - if ( ! $echo ) { |
|
1859 | + if ( ! $echo) { |
|
1860 | 1860 | return $form_dropdown_html; |
1861 | 1861 | } |
1862 | 1862 |
@@ -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 | |
@@ -64,50 +64,50 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return bool If the gravatar exists or not |
66 | 66 | */ |
67 | - public function validate_gravatar( $id_or_email ) { |
|
67 | + public function validate_gravatar($id_or_email) { |
|
68 | 68 | //id or email code borrowed from wp-includes/pluggable.php |
69 | 69 | $email = ''; |
70 | - if ( is_numeric( $id_or_email ) ) { |
|
70 | + if (is_numeric($id_or_email)) { |
|
71 | 71 | $id = (int) $id_or_email; |
72 | - $user = get_userdata( $id ); |
|
73 | - if ( $user ) { |
|
72 | + $user = get_userdata($id); |
|
73 | + if ($user) { |
|
74 | 74 | $email = $user->user_email; |
75 | 75 | } |
76 | - } elseif ( is_object( $id_or_email ) ) { |
|
76 | + } elseif (is_object($id_or_email)) { |
|
77 | 77 | // No avatar for pingbacks or trackbacks |
78 | - $allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) ); |
|
79 | - if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) ) { |
|
78 | + $allowed_comment_types = apply_filters('get_avatar_comment_types', array('comment')); |
|
79 | + if ( ! empty($id_or_email->comment_type) && ! in_array($id_or_email->comment_type, (array) $allowed_comment_types)) { |
|
80 | 80 | return false; |
81 | 81 | } |
82 | 82 | |
83 | - if ( ! empty( $id_or_email->user_id ) ) { |
|
83 | + if ( ! empty($id_or_email->user_id)) { |
|
84 | 84 | $id = (int) $id_or_email->user_id; |
85 | - $user = get_userdata( $id ); |
|
86 | - if ( $user ) { |
|
85 | + $user = get_userdata($id); |
|
86 | + if ($user) { |
|
87 | 87 | $email = $user->user_email; |
88 | 88 | } |
89 | - } elseif ( ! empty( $id_or_email->comment_author_email ) ) { |
|
89 | + } elseif ( ! empty($id_or_email->comment_author_email)) { |
|
90 | 90 | $email = $id_or_email->comment_author_email; |
91 | 91 | } |
92 | 92 | } else { |
93 | 93 | $email = $id_or_email; |
94 | 94 | } |
95 | 95 | |
96 | - $hashkey = md5( strtolower( trim( $email ) ) ); |
|
97 | - $uri = 'http://www.gravatar.com/avatar/' . $hashkey . '?d=404'; |
|
96 | + $hashkey = md5(strtolower(trim($email))); |
|
97 | + $uri = 'http://www.gravatar.com/avatar/'.$hashkey.'?d=404'; |
|
98 | 98 | |
99 | - $data = wp_cache_get( $hashkey ); |
|
100 | - if ( false === $data ) { |
|
101 | - $response = wp_remote_head( $uri ); |
|
102 | - if ( is_wp_error( $response ) ) { |
|
99 | + $data = wp_cache_get($hashkey); |
|
100 | + if (false === $data) { |
|
101 | + $response = wp_remote_head($uri); |
|
102 | + if (is_wp_error($response)) { |
|
103 | 103 | $data = 'not200'; |
104 | 104 | } else { |
105 | 105 | $data = $response['response']['code']; |
106 | 106 | } |
107 | - wp_cache_set( $hashkey, $data, $group = '', $expire = 60 * 5 ); |
|
107 | + wp_cache_set($hashkey, $data, $group = '', $expire = 60 * 5); |
|
108 | 108 | |
109 | 109 | } |
110 | - if ( $data == '200' ) { |
|
110 | + if ($data == '200') { |
|
111 | 111 | return true; |
112 | 112 | } else { |
113 | 113 | return false; |
@@ -124,17 +124,17 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @return array IDs if logs, false otherwise |
126 | 126 | */ |
127 | - public function get_log_ids( $form_id = '' ) { |
|
127 | + public function get_log_ids($form_id = '') { |
|
128 | 128 | |
129 | 129 | // get Give_Logging class |
130 | 130 | global $give_logs; |
131 | 131 | |
132 | 132 | // get log for this form |
133 | - $logs = $give_logs->get_logs( $form_id ); |
|
133 | + $logs = $give_logs->get_logs($form_id); |
|
134 | 134 | |
135 | - if ( $logs ) { |
|
135 | + if ($logs) { |
|
136 | 136 | // make an array with all the donor IDs |
137 | - foreach ( $logs as $log ) { |
|
137 | + foreach ($logs as $log) { |
|
138 | 138 | $log_ids[] = $log->ID; |
139 | 139 | } |
140 | 140 | |
@@ -155,49 +155,49 @@ discard block |
||
155 | 155 | * |
156 | 156 | * @return mixed |
157 | 157 | */ |
158 | - public function get_payment_ids( $form_id = '' ) { |
|
158 | + public function get_payment_ids($form_id = '') { |
|
159 | 159 | |
160 | 160 | global $give_options; |
161 | 161 | |
162 | - $log_ids = $this->get_log_ids( $form_id ); |
|
162 | + $log_ids = $this->get_log_ids($form_id); |
|
163 | 163 | |
164 | - if ( $log_ids ) { |
|
164 | + if ($log_ids) { |
|
165 | 165 | |
166 | 166 | $payment_ids = array(); |
167 | 167 | |
168 | - foreach ( $log_ids as $id ) { |
|
168 | + foreach ($log_ids as $id) { |
|
169 | 169 | // get the payment ID for each corresponding log ID |
170 | - $payment_ids[] = get_post_meta( $id, '_give_log_payment_id', true ); |
|
170 | + $payment_ids[] = get_post_meta($id, '_give_log_payment_id', true); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | // remove donors who have purchased more than once so we can have unique avatars |
174 | 174 | $unique_emails = array(); |
175 | 175 | |
176 | - foreach ( $payment_ids as $key => $id ) { |
|
176 | + foreach ($payment_ids as $key => $id) { |
|
177 | 177 | |
178 | - $email = get_post_meta( $id, '_give_payment_user_email', true ); |
|
178 | + $email = get_post_meta($id, '_give_payment_user_email', true); |
|
179 | 179 | |
180 | - if ( isset ( $give_options['give_donators_gravatars_has_gravatar_account'] ) ) { |
|
181 | - if ( ! $this->validate_gravatar( $email ) ) { |
|
180 | + if (isset ($give_options['give_donators_gravatars_has_gravatar_account'])) { |
|
181 | + if ( ! $this->validate_gravatar($email)) { |
|
182 | 182 | continue; |
183 | 183 | } |
184 | 184 | } |
185 | 185 | |
186 | - $unique_emails[ $id ] = get_post_meta( $id, '_give_payment_user_email', true ); |
|
186 | + $unique_emails[$id] = get_post_meta($id, '_give_payment_user_email', true); |
|
187 | 187 | |
188 | 188 | } |
189 | 189 | |
190 | 190 | // strip duplicate emails |
191 | - $unique_emails = array_unique( $unique_emails ); |
|
191 | + $unique_emails = array_unique($unique_emails); |
|
192 | 192 | |
193 | 193 | // convert the unique IDs back into simple array |
194 | - foreach ( $unique_emails as $id => $email ) { |
|
194 | + foreach ($unique_emails as $id => $email) { |
|
195 | 195 | $unique_ids[] = $id; |
196 | 196 | } |
197 | 197 | |
198 | 198 | // randomize the payment IDs if enabled |
199 | - if ( isset( $give_options['give_donators_gravatars_random_gravatars'] ) ) { |
|
200 | - shuffle( $unique_ids ); |
|
199 | + if (isset($give_options['give_donators_gravatars_random_gravatars'])) { |
|
200 | + shuffle($unique_ids); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | // return our unique IDs |
@@ -218,22 +218,22 @@ discard block |
||
218 | 218 | * |
219 | 219 | * @return string |
220 | 220 | */ |
221 | - public function gravatars( $form_id = false, $title = '' ) { |
|
221 | + public function gravatars($form_id = false, $title = '') { |
|
222 | 222 | |
223 | 223 | // unique $payment_ids |
224 | - $payment_ids = $this->get_payment_ids( $form_id ); |
|
224 | + $payment_ids = $this->get_payment_ids($form_id); |
|
225 | 225 | |
226 | 226 | global $give_options; |
227 | 227 | |
228 | 228 | // return if no ID |
229 | - if ( ! $form_id ) { |
|
229 | + if ( ! $form_id) { |
|
230 | 230 | return; |
231 | 231 | } |
232 | 232 | |
233 | 233 | // minimum amount of purchases before showing gravatars |
234 | 234 | // if the number of items in array is not greater or equal to the number specified, then exit |
235 | - if ( isset( $give_options['give_donators_gravatars_min_purchases_required'] ) && '' != $give_options['give_donators_gravatars_min_purchases_required'] ) { |
|
236 | - if ( ! ( count( $payment_ids ) >= $give_options['give_donators_gravatars_min_purchases_required'] ) ) { |
|
235 | + if (isset($give_options['give_donators_gravatars_min_purchases_required']) && '' != $give_options['give_donators_gravatars_min_purchases_required']) { |
|
236 | + if ( ! (count($payment_ids) >= $give_options['give_donators_gravatars_min_purchases_required'])) { |
|
237 | 237 | return; |
238 | 238 | } |
239 | 239 | } |
@@ -244,51 +244,51 @@ discard block |
||
244 | 244 | echo '<div id="give-purchase-gravatars">'; |
245 | 245 | |
246 | 246 | |
247 | - if ( isset ( $title ) ) { |
|
247 | + if (isset ($title)) { |
|
248 | 248 | |
249 | - if ( $title ) { |
|
250 | - echo apply_filters( 'give_donators_gravatars_title', '<h3 class="give-gravatars-title">' . esc_attr( $title ) . '</h3>' ); |
|
251 | - } elseif ( isset( $give_options['give_donators_gravatars_heading'] ) ) { |
|
252 | - echo apply_filters( 'give_donators_gravatars_title', '<h3 class="give-gravatars-title">' . esc_attr( $give_options['give_donators_gravatars_heading'] ) . '</h2>' ); |
|
249 | + if ($title) { |
|
250 | + echo apply_filters('give_donators_gravatars_title', '<h3 class="give-gravatars-title">'.esc_attr($title).'</h3>'); |
|
251 | + } elseif (isset($give_options['give_donators_gravatars_heading'])) { |
|
252 | + echo apply_filters('give_donators_gravatars_title', '<h3 class="give-gravatars-title">'.esc_attr($give_options['give_donators_gravatars_heading']).'</h2>'); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | } |
256 | 256 | echo '<ul class="give-purchase-gravatars-list">'; |
257 | 257 | $i = 0; |
258 | 258 | |
259 | - if ( $payment_ids ) { |
|
260 | - foreach ( $payment_ids as $id ) { |
|
259 | + if ($payment_ids) { |
|
260 | + foreach ($payment_ids as $id) { |
|
261 | 261 | |
262 | 262 | // Give saves a blank option even when the control is turned off, hence the extra check |
263 | - if ( isset( $give_options['give_donators_gravatars_maximum_number'] ) && '' != $give_options['give_donators_gravatars_maximum_number'] && $i == $give_options['give_donators_gravatars_maximum_number'] ) { |
|
263 | + if (isset($give_options['give_donators_gravatars_maximum_number']) && '' != $give_options['give_donators_gravatars_maximum_number'] && $i == $give_options['give_donators_gravatars_maximum_number']) { |
|
264 | 264 | continue; |
265 | 265 | } |
266 | 266 | |
267 | 267 | // get the payment meta |
268 | - $payment_meta = get_post_meta( $id, '_give_payment_meta', true ); |
|
268 | + $payment_meta = get_post_meta($id, '_give_payment_meta', true); |
|
269 | 269 | |
270 | 270 | // unserialize the payment meta |
271 | - $user_info = maybe_unserialize( $payment_meta['user_info'] ); |
|
271 | + $user_info = maybe_unserialize($payment_meta['user_info']); |
|
272 | 272 | |
273 | 273 | // get donor's first name |
274 | 274 | $name = $user_info['first_name']; |
275 | 275 | |
276 | 276 | // get donor's email |
277 | - $email = get_post_meta( $id, '_give_payment_user_email', true ); |
|
277 | + $email = get_post_meta($id, '_give_payment_user_email', true); |
|
278 | 278 | |
279 | 279 | // set gravatar size and provide filter |
280 | - $size = isset( $give_options['give_donators_gravatars_gravatar_size'] ) ? apply_filters( 'give_donators_gravatars_gravatar_size', $give_options['give_donators_gravatars_gravatar_size'] ) : ''; |
|
280 | + $size = isset($give_options['give_donators_gravatars_gravatar_size']) ? apply_filters('give_donators_gravatars_gravatar_size', $give_options['give_donators_gravatars_gravatar_size']) : ''; |
|
281 | 281 | |
282 | 282 | // default image |
283 | - $default_image = apply_filters( 'give_donators_gravatars_gravatar_default_image', false ); |
|
283 | + $default_image = apply_filters('give_donators_gravatars_gravatar_default_image', false); |
|
284 | 284 | |
285 | 285 | // assemble output |
286 | 286 | $output .= '<li>'; |
287 | 287 | |
288 | - $output .= get_avatar( $email, $size, $default_image, $name ); |
|
288 | + $output .= get_avatar($email, $size, $default_image, $name); |
|
289 | 289 | $output .= '</li>'; |
290 | 290 | |
291 | - $i ++; |
|
291 | + $i++; |
|
292 | 292 | |
293 | 293 | } // end foreach |
294 | 294 | } |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | echo '</ul>'; |
298 | 298 | echo '</div>'; |
299 | 299 | |
300 | - return apply_filters( 'give_donators_gravatars', ob_get_clean() ); |
|
300 | + return apply_filters('give_donators_gravatars', ob_get_clean()); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | /** |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | * @return void |
310 | 310 | */ |
311 | 311 | public function register_widget() { |
312 | - register_widget( 'Give_Donators_Gravatars_Widget' ); |
|
312 | + register_widget('Give_Donators_Gravatars_Widget'); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | /** |
@@ -325,19 +325,19 @@ discard block |
||
325 | 325 | * |
326 | 326 | * @todo Set the ID to get_the_ID() if ID parameter is not passed through. Otherwise it will incorrectly get other gravatars |
327 | 327 | */ |
328 | - public function shortcode( $atts, $content = null ) { |
|
328 | + public function shortcode($atts, $content = null) { |
|
329 | 329 | |
330 | - $atts = shortcode_atts( array( |
|
330 | + $atts = shortcode_atts(array( |
|
331 | 331 | 'id' => '', |
332 | 332 | 'title' => '' |
333 | - ), $atts, 'give_donators_gravatars' ); |
|
333 | + ), $atts, 'give_donators_gravatars'); |
|
334 | 334 | |
335 | 335 | // if no ID is passed on single give_forms pages, get the correct ID |
336 | - if ( is_singular( 'give_forms' ) ) { |
|
336 | + if (is_singular('give_forms')) { |
|
337 | 337 | $id = get_the_ID(); |
338 | 338 | } |
339 | 339 | |
340 | - $content = $this->gravatars( $atts['id'], $atts['title'] ); |
|
340 | + $content = $this->gravatars($atts['id'], $atts['title']); |
|
341 | 341 | |
342 | 342 | return $content; |
343 | 343 | |
@@ -353,57 +353,57 @@ discard block |
||
353 | 353 | * |
354 | 354 | * @return array Gravatar settings. |
355 | 355 | */ |
356 | - public function settings( $settings ) { |
|
356 | + public function settings($settings) { |
|
357 | 357 | |
358 | 358 | $give_gravatar_settings = array( |
359 | 359 | array( |
360 | - 'name' => esc_html__( 'Donator Gravatars', 'give' ), |
|
360 | + 'name' => esc_html__('Donator Gravatars', 'give'), |
|
361 | 361 | 'desc' => '<hr>', |
362 | 362 | 'id' => 'give_title', |
363 | 363 | 'type' => 'give_title' |
364 | 364 | ), |
365 | 365 | array( |
366 | - 'name' => esc_html__( 'Heading', 'give' ), |
|
367 | - 'desc' => esc_html__( 'The heading to display above the Gravatars', 'give' ), |
|
366 | + 'name' => esc_html__('Heading', 'give'), |
|
367 | + 'desc' => esc_html__('The heading to display above the Gravatars', 'give'), |
|
368 | 368 | 'type' => 'text', |
369 | 369 | 'id' => 'give_donators_gravatars_heading' |
370 | 370 | ), |
371 | 371 | array( |
372 | - 'name' => esc_html__( 'Gravatar Size', 'give' ), |
|
373 | - 'desc' => esc_html__( 'The size of each Gravatar in pixels (512px maximum)', 'give' ), |
|
372 | + 'name' => esc_html__('Gravatar Size', 'give'), |
|
373 | + 'desc' => esc_html__('The size of each Gravatar in pixels (512px maximum)', 'give'), |
|
374 | 374 | 'type' => 'text_small', |
375 | 375 | 'id' => 'give_donators_gravatars_gravatar_size', |
376 | 376 | 'default' => '64' |
377 | 377 | ), |
378 | 378 | array( |
379 | - 'name' => esc_html__( 'Minimum Unique Purchases Required', 'give' ), |
|
379 | + 'name' => esc_html__('Minimum Unique Purchases Required', 'give'), |
|
380 | 380 | /* translators: %s: form singular label */ |
381 | - 'desc' => sprintf( esc_html__( 'The minimum number of unique purchases a %s must have before the Gravatars are shown. Leave blank for no minimum.', 'give' ), strtolower( give_get_forms_label_singular() ) ), |
|
381 | + 'desc' => sprintf(esc_html__('The minimum number of unique purchases a %s must have before the Gravatars are shown. Leave blank for no minimum.', 'give'), strtolower(give_get_forms_label_singular())), |
|
382 | 382 | 'type' => 'text_small', |
383 | 383 | 'id' => 'give_donators_gravatars_min_purchases_required', |
384 | 384 | ), |
385 | 385 | array( |
386 | - 'name' => esc_html__( 'Maximum Gravatars To Show', 'give' ), |
|
387 | - 'desc' => esc_html__( 'The maximum number of gravatars to show. Leave blank for no limit.', 'give' ), |
|
386 | + 'name' => esc_html__('Maximum Gravatars To Show', 'give'), |
|
387 | + 'desc' => esc_html__('The maximum number of gravatars to show. Leave blank for no limit.', 'give'), |
|
388 | 388 | 'type' => 'text', |
389 | 389 | 'id' => 'give_donators_gravatars_maximum_number', |
390 | 390 | 'default' => '20', |
391 | 391 | ), |
392 | 392 | array( |
393 | - 'name' => esc_html__( 'Gravatar Visibility', 'give' ), |
|
394 | - 'desc' => esc_html__( 'Only show donators with a Gravatar account', 'give' ), |
|
393 | + 'name' => esc_html__('Gravatar Visibility', 'give'), |
|
394 | + 'desc' => esc_html__('Only show donators with a Gravatar account', 'give'), |
|
395 | 395 | 'id' => 'give_donators_gravatars_has_gravatar_account', |
396 | 396 | 'type' => 'checkbox', |
397 | 397 | ), |
398 | 398 | array( |
399 | - 'name' => esc_html__( 'Randomize Gravatars', 'give' ), |
|
400 | - 'desc' => esc_html__( 'Randomize the Gravatars', 'give' ), |
|
399 | + 'name' => esc_html__('Randomize Gravatars', 'give'), |
|
400 | + 'desc' => esc_html__('Randomize the Gravatars', 'give'), |
|
401 | 401 | 'id' => 'give_donators_gravatars_random_gravatars', |
402 | 402 | 'type' => 'checkbox', |
403 | 403 | ), |
404 | 404 | ); |
405 | 405 | |
406 | - return array_merge( $settings, $give_gravatar_settings ); |
|
406 | + return array_merge($settings, $give_gravatar_settings); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | } |
@@ -428,13 +428,13 @@ discard block |
||
428 | 428 | */ |
429 | 429 | public function __construct() { |
430 | 430 | |
431 | - $give_label_singular = function_exists( 'give_get_forms_label_singular' ) ? strtolower( give_get_forms_label_singular() ) : null; |
|
431 | + $give_label_singular = function_exists('give_get_forms_label_singular') ? strtolower(give_get_forms_label_singular()) : null; |
|
432 | 432 | |
433 | 433 | // widget settings |
434 | 434 | $widget_ops = array( |
435 | 435 | 'classname' => 'give-donators-gravatars', |
436 | 436 | /* translators: 1: form singular label 2: form singular label */ |
437 | - 'description' => sprintf( esc_html__( 'Displays gravatars of people who have donated using your your %1$s. Will only show on the single %2$s page.', 'give' ), $give_label_singular, $give_label_singular ) |
|
437 | + 'description' => sprintf(esc_html__('Displays gravatars of people who have donated using your your %1$s. Will only show on the single %2$s page.', 'give'), $give_label_singular, $give_label_singular) |
|
438 | 438 | ); |
439 | 439 | |
440 | 440 | // widget control settings |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | // create the widget |
448 | 448 | parent::__construct( |
449 | 449 | 'give_donators_gravatars_widget', |
450 | - esc_html__( 'Give Donators Gravatars', 'give' ), |
|
450 | + esc_html__('Give Donators Gravatars', 'give'), |
|
451 | 451 | $widget_ops, |
452 | 452 | $control_ops |
453 | 453 | ); |
@@ -467,30 +467,30 @@ discard block |
||
467 | 467 | * |
468 | 468 | * @return void |
469 | 469 | */ |
470 | - public function widget( $args, $instance ) { |
|
470 | + public function widget($args, $instance) { |
|
471 | 471 | global $give_options; |
472 | 472 | |
473 | 473 | //@TODO: Don't extract it!!! |
474 | - extract( $args ); |
|
474 | + extract($args); |
|
475 | 475 | |
476 | - if ( ! is_singular( 'give_forms' ) ) { |
|
476 | + if ( ! is_singular('give_forms')) { |
|
477 | 477 | return; |
478 | 478 | } |
479 | 479 | |
480 | 480 | // Variables from widget settings |
481 | - $title = apply_filters( 'widget_title', $instance['title'] ); |
|
481 | + $title = apply_filters('widget_title', $instance['title']); |
|
482 | 482 | |
483 | 483 | // Used by themes. Opens the widget |
484 | 484 | echo $before_widget; |
485 | 485 | |
486 | 486 | // Display the widget title |
487 | - if ( $title ) { |
|
488 | - echo $before_title . $title . $after_title; |
|
487 | + if ($title) { |
|
488 | + echo $before_title.$title.$after_title; |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | $gravatars = new Give_Donators_Gravatars(); |
492 | 492 | |
493 | - echo $gravatars->gravatars( get_the_ID(), null ); // remove title |
|
493 | + echo $gravatars->gravatars(get_the_ID(), null); // remove title |
|
494 | 494 | |
495 | 495 | // Used by themes. Closes the widget |
496 | 496 | echo $after_widget; |
@@ -510,11 +510,11 @@ discard block |
||
510 | 510 | * |
511 | 511 | * @return array Updated settings to save. |
512 | 512 | */ |
513 | - public function update( $new_instance, $old_instance ) { |
|
513 | + public function update($new_instance, $old_instance) { |
|
514 | 514 | |
515 | 515 | $instance = $old_instance; |
516 | 516 | |
517 | - $instance['title'] = strip_tags( $new_instance['title'] ); |
|
517 | + $instance['title'] = strip_tags($new_instance['title']); |
|
518 | 518 | |
519 | 519 | return $instance; |
520 | 520 | |
@@ -532,19 +532,19 @@ discard block |
||
532 | 532 | * |
533 | 533 | * @return void |
534 | 534 | */ |
535 | - public function form( $instance ) { |
|
535 | + public function form($instance) { |
|
536 | 536 | |
537 | 537 | // Set up some default widget settings. |
538 | 538 | $defaults = array( |
539 | 539 | 'title' => '', |
540 | 540 | ); |
541 | 541 | |
542 | - $instance = wp_parse_args( (array) $instance, $defaults ); ?> |
|
542 | + $instance = wp_parse_args((array) $instance, $defaults); ?> |
|
543 | 543 | |
544 | 544 | <!-- Title --> |
545 | 545 | <p> |
546 | - <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'give' ) ?></label> |
|
547 | - <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $instance['title']; ?>" /> |
|
546 | + <label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('Title:', 'give') ?></label> |
|
547 | + <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $instance['title']; ?>" /> |
|
548 | 548 | </p> |
549 | 549 | |
550 | 550 | <?php |
@@ -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,40 +23,40 @@ discard block |
||
23 | 23 | function give_setup_post_types() { |
24 | 24 | |
25 | 25 | /** Give Forms Post Type */ |
26 | - $give_forms_singular = give_get_option( 'disable_forms_singular' ) !== 'on' ? true : false; |
|
26 | + $give_forms_singular = give_get_option('disable_forms_singular') !== 'on' ? true : false; |
|
27 | 27 | |
28 | - $give_forms_archives = give_get_option( 'disable_forms_archives' ) !== 'on' ? true : false; |
|
28 | + $give_forms_archives = give_get_option('disable_forms_archives') !== 'on' ? true : false; |
|
29 | 29 | |
30 | - $give_forms_slug = defined( 'GIVE_SLUG' ) ? GIVE_SLUG : 'donations'; |
|
30 | + $give_forms_slug = defined('GIVE_SLUG') ? GIVE_SLUG : 'donations'; |
|
31 | 31 | //support for old 'GIVE_FORMS_SLUG' constant |
32 | - if ( defined( 'GIVE_FORMS_SLUG' ) ) { |
|
32 | + if (defined('GIVE_FORMS_SLUG')) { |
|
33 | 33 | $give_forms_slug = GIVE_FORMS_SLUG; |
34 | 34 | } |
35 | 35 | |
36 | - $give_forms_rewrite = defined( 'GIVE_DISABLE_FORMS_REWRITE' ) && GIVE_DISABLE_FORMS_REWRITE ? false : array( |
|
36 | + $give_forms_rewrite = defined('GIVE_DISABLE_FORMS_REWRITE') && GIVE_DISABLE_FORMS_REWRITE ? false : array( |
|
37 | 37 | 'slug' => $give_forms_slug, |
38 | 38 | 'with_front' => false |
39 | 39 | ); |
40 | 40 | |
41 | - $give_forms_labels = apply_filters( 'give_forms_labels', array( |
|
42 | - 'name' => esc_html__( 'Donation %2$s', 'give' ), |
|
41 | + $give_forms_labels = apply_filters('give_forms_labels', array( |
|
42 | + 'name' => esc_html__('Donation %2$s', 'give'), |
|
43 | 43 | 'singular_name' => '%1$s', |
44 | - 'add_new' => esc_html__( 'Add %1$s', 'give' ), |
|
45 | - 'add_new_item' => esc_html__( 'Add New Donation %1$s', 'give' ), |
|
46 | - 'edit_item' => esc_html__( 'Edit Donation %1$s', 'give' ), |
|
47 | - 'new_item' => esc_html__( 'New %1$s', 'give' ), |
|
48 | - 'all_items' => esc_html__( 'All %2$s', 'give' ), |
|
49 | - 'view_item' => esc_html__( 'View %1$s', 'give' ), |
|
50 | - 'search_items' => esc_html__( 'Search %2$s', 'give' ), |
|
51 | - 'not_found' => esc_html__( 'No %2$s found', 'give' ), |
|
52 | - 'not_found_in_trash' => esc_html__( 'No %2$s found in Trash', 'give' ), |
|
44 | + 'add_new' => esc_html__('Add %1$s', 'give'), |
|
45 | + 'add_new_item' => esc_html__('Add New Donation %1$s', 'give'), |
|
46 | + 'edit_item' => esc_html__('Edit Donation %1$s', 'give'), |
|
47 | + 'new_item' => esc_html__('New %1$s', 'give'), |
|
48 | + 'all_items' => esc_html__('All %2$s', 'give'), |
|
49 | + 'view_item' => esc_html__('View %1$s', 'give'), |
|
50 | + 'search_items' => esc_html__('Search %2$s', 'give'), |
|
51 | + 'not_found' => esc_html__('No %2$s found', 'give'), |
|
52 | + 'not_found_in_trash' => esc_html__('No %2$s found in Trash', 'give'), |
|
53 | 53 | 'parent_item_colon' => '', |
54 | - 'menu_name' => apply_filters( 'give_menu_name', esc_html__( 'Donations', 'give' ) ), |
|
55 | - 'name_admin_bar' => apply_filters( 'give_name_admin_bar_name', esc_html__( 'Donation Form', 'give' ) ) |
|
56 | - ) ); |
|
54 | + 'menu_name' => apply_filters('give_menu_name', esc_html__('Donations', 'give')), |
|
55 | + 'name_admin_bar' => apply_filters('give_name_admin_bar_name', esc_html__('Donation Form', 'give')) |
|
56 | + )); |
|
57 | 57 | |
58 | - foreach ( $give_forms_labels as $key => $value ) { |
|
59 | - $give_forms_labels[ $key ] = sprintf( $value, give_get_forms_label_singular(), give_get_forms_label_plural() ); |
|
58 | + foreach ($give_forms_labels as $key => $value) { |
|
59 | + $give_forms_labels[$key] = sprintf($value, give_get_forms_label_singular(), give_get_forms_label_plural()); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | //Default give_forms supports |
@@ -69,14 +69,14 @@ discard block |
||
69 | 69 | ); |
70 | 70 | |
71 | 71 | //Has the user disabled the excerpt |
72 | - if ( give_get_option( 'disable_forms_excerpt' ) === 'on' ) { |
|
73 | - unset( $give_form_supports[2] ); |
|
72 | + if (give_get_option('disable_forms_excerpt') === 'on') { |
|
73 | + unset($give_form_supports[2]); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | //Has user disabled the featured image? |
77 | - if ( give_get_option( 'disable_form_featured_img' ) === 'on' ) { |
|
78 | - unset( $give_form_supports[1] ); |
|
79 | - remove_action( 'give_before_single_form_summary', 'give_show_form_images' ); |
|
77 | + if (give_get_option('disable_form_featured_img') === 'on') { |
|
78 | + unset($give_form_supports[1]); |
|
79 | + remove_action('give_before_single_form_summary', 'give_show_form_images'); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | $give_forms_args = array( |
@@ -92,42 +92,42 @@ discard block |
||
92 | 92 | 'has_archive' => $give_forms_archives, |
93 | 93 | 'menu_icon' => 'dashicons-give', |
94 | 94 | 'hierarchical' => false, |
95 | - 'supports' => apply_filters( 'give_forms_supports', $give_form_supports ), |
|
95 | + 'supports' => apply_filters('give_forms_supports', $give_form_supports), |
|
96 | 96 | ); |
97 | - register_post_type( 'give_forms', apply_filters( 'give_forms_post_type_args', $give_forms_args ) ); |
|
97 | + register_post_type('give_forms', apply_filters('give_forms_post_type_args', $give_forms_args)); |
|
98 | 98 | |
99 | 99 | /** Payment Post Type */ |
100 | 100 | $payment_labels = array( |
101 | - 'name' => _x( 'Donations', 'post type general name', 'give' ), |
|
102 | - 'singular_name' => _x( 'Donation', 'post type singular name', 'give' ), |
|
103 | - 'add_new' => esc_html__( 'Add New', 'give' ), |
|
104 | - 'add_new_item' => esc_html__( 'Add New Donation', 'give' ), |
|
105 | - 'edit_item' => esc_html__( 'Edit Donation', 'give' ), |
|
106 | - 'new_item' => esc_html__( 'New Donation', 'give' ), |
|
107 | - 'all_items' => esc_html__( 'All Donations', 'give' ), |
|
108 | - 'view_item' => esc_html__( 'View Donation', 'give' ), |
|
109 | - 'search_items' => esc_html__( 'Search Donations', 'give' ), |
|
110 | - 'not_found' => esc_html__( 'No Donations found', 'give' ), |
|
111 | - 'not_found_in_trash' => esc_html__( 'No Donations found in Trash', 'give' ), |
|
101 | + 'name' => _x('Donations', 'post type general name', 'give'), |
|
102 | + 'singular_name' => _x('Donation', 'post type singular name', 'give'), |
|
103 | + 'add_new' => esc_html__('Add New', 'give'), |
|
104 | + 'add_new_item' => esc_html__('Add New Donation', 'give'), |
|
105 | + 'edit_item' => esc_html__('Edit Donation', 'give'), |
|
106 | + 'new_item' => esc_html__('New Donation', 'give'), |
|
107 | + 'all_items' => esc_html__('All Donations', 'give'), |
|
108 | + 'view_item' => esc_html__('View Donation', 'give'), |
|
109 | + 'search_items' => esc_html__('Search Donations', 'give'), |
|
110 | + 'not_found' => esc_html__('No Donations found', 'give'), |
|
111 | + 'not_found_in_trash' => esc_html__('No Donations found in Trash', 'give'), |
|
112 | 112 | 'parent_item_colon' => '', |
113 | - 'menu_name' => esc_html__( 'Transactions', 'give' ) |
|
113 | + 'menu_name' => esc_html__('Transactions', 'give') |
|
114 | 114 | ); |
115 | 115 | |
116 | 116 | $payment_args = array( |
117 | - 'labels' => apply_filters( 'give_payment_labels', $payment_labels ), |
|
117 | + 'labels' => apply_filters('give_payment_labels', $payment_labels), |
|
118 | 118 | 'public' => false, |
119 | 119 | 'query_var' => false, |
120 | 120 | 'rewrite' => false, |
121 | 121 | 'map_meta_cap' => true, |
122 | 122 | 'capability_type' => 'give_payment', |
123 | - 'supports' => array( 'title' ), |
|
123 | + 'supports' => array('title'), |
|
124 | 124 | 'can_export' => true |
125 | 125 | ); |
126 | - register_post_type( 'give_payment', $payment_args ); |
|
126 | + register_post_type('give_payment', $payment_args); |
|
127 | 127 | |
128 | 128 | } |
129 | 129 | |
130 | -add_action( 'init', 'give_setup_post_types', 1 ); |
|
130 | +add_action('init', 'give_setup_post_types', 1); |
|
131 | 131 | |
132 | 132 | |
133 | 133 | /** |
@@ -140,32 +140,32 @@ discard block |
||
140 | 140 | */ |
141 | 141 | function give_setup_taxonomies() { |
142 | 142 | |
143 | - $slug = defined( 'GIVE_FORMS_SLUG' ) ? GIVE_FORMS_SLUG : 'donations'; |
|
143 | + $slug = defined('GIVE_FORMS_SLUG') ? GIVE_FORMS_SLUG : 'donations'; |
|
144 | 144 | |
145 | 145 | /** Categories */ |
146 | 146 | $category_labels = array( |
147 | 147 | /* translators: %s: form singular label */ |
148 | - 'name' => sprintf( _x( '%s Categories', 'taxonomy general name', 'give' ), give_get_forms_label_singular() ), |
|
149 | - 'singular_name' => _x( 'Category', 'taxonomy singular name', 'give' ), |
|
150 | - 'search_items' => esc_html__( 'Search Categories', 'give' ), |
|
151 | - 'all_items' => esc_html__( 'All Categories', 'give' ), |
|
152 | - 'parent_item' => esc_html__( 'Parent Category', 'give' ), |
|
153 | - 'parent_item_colon' => esc_html__( 'Parent Category:', 'give' ), |
|
154 | - 'edit_item' => esc_html__( 'Edit Category', 'give' ), |
|
155 | - 'update_item' => esc_html__( 'Update Category', 'give' ), |
|
148 | + 'name' => sprintf(_x('%s Categories', 'taxonomy general name', 'give'), give_get_forms_label_singular()), |
|
149 | + 'singular_name' => _x('Category', 'taxonomy singular name', 'give'), |
|
150 | + 'search_items' => esc_html__('Search Categories', 'give'), |
|
151 | + 'all_items' => esc_html__('All Categories', 'give'), |
|
152 | + 'parent_item' => esc_html__('Parent Category', 'give'), |
|
153 | + 'parent_item_colon' => esc_html__('Parent Category:', 'give'), |
|
154 | + 'edit_item' => esc_html__('Edit Category', 'give'), |
|
155 | + 'update_item' => esc_html__('Update Category', 'give'), |
|
156 | 156 | /* translators: %s: form singular label */ |
157 | - 'add_new_item' => sprintf( esc_html__( 'Add New %s Category', 'give' ), give_get_forms_label_singular() ), |
|
158 | - 'new_item_name' => esc_html__( 'New Category Name', 'give' ), |
|
159 | - 'menu_name' => esc_html__( 'Categories', 'give' ), |
|
157 | + 'add_new_item' => sprintf(esc_html__('Add New %s Category', 'give'), give_get_forms_label_singular()), |
|
158 | + 'new_item_name' => esc_html__('New Category Name', 'give'), |
|
159 | + 'menu_name' => esc_html__('Categories', 'give'), |
|
160 | 160 | ); |
161 | 161 | |
162 | - $category_args = apply_filters( 'give_forms_category_args', array( |
|
162 | + $category_args = apply_filters('give_forms_category_args', array( |
|
163 | 163 | 'hierarchical' => true, |
164 | - 'labels' => apply_filters( 'give_forms_category_labels', $category_labels ), |
|
164 | + 'labels' => apply_filters('give_forms_category_labels', $category_labels), |
|
165 | 165 | 'show_ui' => true, |
166 | 166 | 'query_var' => 'give_forms_category', |
167 | 167 | 'rewrite' => array( |
168 | - 'slug' => $slug . '/category', |
|
168 | + 'slug' => $slug.'/category', |
|
169 | 169 | 'with_front' => false, |
170 | 170 | 'hierarchical' => true |
171 | 171 | ), |
@@ -179,36 +179,36 @@ discard block |
||
179 | 179 | ); |
180 | 180 | |
181 | 181 | //Does the user want categories? |
182 | - if ( give_get_option( 'enable_categories' ) == 'on' ) { |
|
183 | - register_taxonomy( 'give_forms_category', array( 'give_forms' ), $category_args ); |
|
184 | - register_taxonomy_for_object_type( 'give_forms_category', 'give_forms' ); |
|
182 | + if (give_get_option('enable_categories') == 'on') { |
|
183 | + register_taxonomy('give_forms_category', array('give_forms'), $category_args); |
|
184 | + register_taxonomy_for_object_type('give_forms_category', 'give_forms'); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | |
188 | 188 | /** Tags */ |
189 | 189 | $tag_labels = array( |
190 | 190 | /* translators: %s: form singular label */ |
191 | - 'name' => sprintf( _x( '%s Tags', 'taxonomy general name', 'give' ), give_get_forms_label_singular() ), |
|
192 | - 'singular_name' => _x( 'Tag', 'taxonomy singular name', 'give' ), |
|
193 | - 'search_items' => esc_html__( 'Search Tags', 'give' ), |
|
194 | - 'all_items' => esc_html__( 'All Tags', 'give' ), |
|
195 | - 'parent_item' => esc_html__( 'Parent Tag', 'give' ), |
|
196 | - 'parent_item_colon' => esc_html__( 'Parent Tag:', 'give' ), |
|
197 | - 'edit_item' => esc_html__( 'Edit Tag', 'give' ), |
|
198 | - 'update_item' => esc_html__( 'Update Tag', 'give' ), |
|
199 | - 'add_new_item' => esc_html__( 'Add New Tag', 'give' ), |
|
200 | - 'new_item_name' => esc_html__( 'New Tag Name', 'give' ), |
|
201 | - 'menu_name' => esc_html__( 'Tags', 'give' ), |
|
191 | + 'name' => sprintf(_x('%s Tags', 'taxonomy general name', 'give'), give_get_forms_label_singular()), |
|
192 | + 'singular_name' => _x('Tag', 'taxonomy singular name', 'give'), |
|
193 | + 'search_items' => esc_html__('Search Tags', 'give'), |
|
194 | + 'all_items' => esc_html__('All Tags', 'give'), |
|
195 | + 'parent_item' => esc_html__('Parent Tag', 'give'), |
|
196 | + 'parent_item_colon' => esc_html__('Parent Tag:', 'give'), |
|
197 | + 'edit_item' => esc_html__('Edit Tag', 'give'), |
|
198 | + 'update_item' => esc_html__('Update Tag', 'give'), |
|
199 | + 'add_new_item' => esc_html__('Add New Tag', 'give'), |
|
200 | + 'new_item_name' => esc_html__('New Tag Name', 'give'), |
|
201 | + 'menu_name' => esc_html__('Tags', 'give'), |
|
202 | 202 | /* translators: %s: form singular label */ |
203 | - 'choose_from_most_used' => sprintf( esc_html__( 'Choose from most used %s tags.', 'give' ), give_get_forms_label_singular() ), |
|
203 | + 'choose_from_most_used' => sprintf(esc_html__('Choose from most used %s tags.', 'give'), give_get_forms_label_singular()), |
|
204 | 204 | ); |
205 | 205 | |
206 | - $tag_args = apply_filters( 'give_forms_tag_args', array( |
|
206 | + $tag_args = apply_filters('give_forms_tag_args', array( |
|
207 | 207 | 'hierarchical' => false, |
208 | - 'labels' => apply_filters( 'give_forms_tag_labels', $tag_labels ), |
|
208 | + 'labels' => apply_filters('give_forms_tag_labels', $tag_labels), |
|
209 | 209 | 'show_ui' => true, |
210 | 210 | 'query_var' => 'give_forms_tag', |
211 | - 'rewrite' => array( 'slug' => $slug . '/tag', 'with_front' => false, 'hierarchical' => true ), |
|
211 | + 'rewrite' => array('slug' => $slug.'/tag', 'with_front' => false, 'hierarchical' => true), |
|
212 | 212 | 'capabilities' => array( |
213 | 213 | 'manage_terms' => 'manage_give_form_terms', |
214 | 214 | 'edit_terms' => 'edit_give_form_terms', |
@@ -218,15 +218,15 @@ discard block |
||
218 | 218 | ) |
219 | 219 | ); |
220 | 220 | |
221 | - if ( give_get_option( 'enable_tags' ) == 'on' ) { |
|
222 | - register_taxonomy( 'give_forms_tag', array( 'give_forms' ), $tag_args ); |
|
223 | - register_taxonomy_for_object_type( 'give_forms_tag', 'give_forms' ); |
|
221 | + if (give_get_option('enable_tags') == 'on') { |
|
222 | + register_taxonomy('give_forms_tag', array('give_forms'), $tag_args); |
|
223 | + register_taxonomy_for_object_type('give_forms_tag', 'give_forms'); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | |
227 | 227 | } |
228 | 228 | |
229 | -add_action( 'init', 'give_setup_taxonomies', 0 ); |
|
229 | +add_action('init', 'give_setup_taxonomies', 0); |
|
230 | 230 | |
231 | 231 | |
232 | 232 | /** |
@@ -237,11 +237,11 @@ discard block |
||
237 | 237 | */ |
238 | 238 | function give_get_default_form_labels() { |
239 | 239 | $defaults = array( |
240 | - 'singular' => esc_html__( 'Form', 'give' ), |
|
241 | - 'plural' => esc_html__( 'Forms', 'give' ) |
|
240 | + 'singular' => esc_html__('Form', 'give'), |
|
241 | + 'plural' => esc_html__('Forms', 'give') |
|
242 | 242 | ); |
243 | 243 | |
244 | - return apply_filters( 'give_default_form_name', $defaults ); |
|
244 | + return apply_filters('give_default_form_name', $defaults); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -253,10 +253,10 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @return string $defaults['singular'] Singular label |
255 | 255 | */ |
256 | -function give_get_forms_label_singular( $lowercase = false ) { |
|
256 | +function give_get_forms_label_singular($lowercase = false) { |
|
257 | 257 | $defaults = give_get_default_form_labels(); |
258 | 258 | |
259 | - return ( $lowercase ) ? strtolower( $defaults['singular'] ) : $defaults['singular']; |
|
259 | + return ($lowercase) ? strtolower($defaults['singular']) : $defaults['singular']; |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | /** |
@@ -265,10 +265,10 @@ discard block |
||
265 | 265 | * @since 1.0 |
266 | 266 | * @return string $defaults['plural'] Plural label |
267 | 267 | */ |
268 | -function give_get_forms_label_plural( $lowercase = false ) { |
|
268 | +function give_get_forms_label_plural($lowercase = false) { |
|
269 | 269 | $defaults = give_get_default_form_labels(); |
270 | 270 | |
271 | - return ( $lowercase ) ? strtolower( $defaults['plural'] ) : $defaults['plural']; |
|
271 | + return ($lowercase) ? strtolower($defaults['plural']) : $defaults['plural']; |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
@@ -280,12 +280,12 @@ discard block |
||
280 | 280 | * |
281 | 281 | * @return string $title New placeholder text |
282 | 282 | */ |
283 | -function give_change_default_title( $title ) { |
|
283 | +function give_change_default_title($title) { |
|
284 | 284 | // If a frontend plugin uses this filter (check extensions before changing this function) |
285 | - if ( ! is_admin() ) { |
|
285 | + if ( ! is_admin()) { |
|
286 | 286 | $title = sprintf( |
287 | 287 | /* translators: %s: form singular label */ |
288 | - esc_html__( 'Enter %s title here', 'give' ), |
|
288 | + esc_html__('Enter %s title here', 'give'), |
|
289 | 289 | give_get_forms_label_singular() |
290 | 290 | ); |
291 | 291 | |
@@ -294,10 +294,10 @@ discard block |
||
294 | 294 | |
295 | 295 | $screen = get_current_screen(); |
296 | 296 | |
297 | - if ( 'give_forms' == $screen->post_type ) { |
|
297 | + if ('give_forms' == $screen->post_type) { |
|
298 | 298 | $title = sprintf( |
299 | 299 | /* translators: %s: form singular label */ |
300 | - esc_html__( 'Enter %s title here', 'give' ), |
|
300 | + esc_html__('Enter %s title here', 'give'), |
|
301 | 301 | give_get_forms_label_singular() |
302 | 302 | ); |
303 | 303 | } |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | return $title; |
306 | 306 | } |
307 | 307 | |
308 | -add_filter( 'enter_title_here', 'give_change_default_title' ); |
|
308 | +add_filter('enter_title_here', 'give_change_default_title'); |
|
309 | 309 | |
310 | 310 | /** |
311 | 311 | * Registers Custom Post Statuses which are used by the Payments |
@@ -315,50 +315,50 @@ discard block |
||
315 | 315 | */ |
316 | 316 | function give_register_post_type_statuses() { |
317 | 317 | // Payment Statuses |
318 | - register_post_status( 'refunded', array( |
|
319 | - 'label' => _x( 'Refunded', 'payment status', 'give' ), |
|
318 | + register_post_status('refunded', array( |
|
319 | + 'label' => _x('Refunded', 'payment status', 'give'), |
|
320 | 320 | 'public' => true, |
321 | 321 | 'exclude_from_search' => false, |
322 | 322 | 'show_in_admin_all_list' => true, |
323 | 323 | 'show_in_admin_status_list' => true, |
324 | - 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give' ) |
|
325 | - ) ); |
|
326 | - register_post_status( 'failed', array( |
|
327 | - 'label' => _x( 'Failed', 'payment status', 'give' ), |
|
324 | + 'label_count' => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give') |
|
325 | + )); |
|
326 | + register_post_status('failed', array( |
|
327 | + 'label' => _x('Failed', 'payment status', 'give'), |
|
328 | 328 | 'public' => true, |
329 | 329 | 'exclude_from_search' => false, |
330 | 330 | 'show_in_admin_all_list' => true, |
331 | 331 | 'show_in_admin_status_list' => true, |
332 | - 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give' ) |
|
333 | - ) ); |
|
334 | - register_post_status( 'revoked', array( |
|
335 | - 'label' => _x( 'Revoked', 'payment status', 'give' ), |
|
332 | + 'label_count' => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give') |
|
333 | + )); |
|
334 | + register_post_status('revoked', array( |
|
335 | + 'label' => _x('Revoked', 'payment status', 'give'), |
|
336 | 336 | 'public' => true, |
337 | 337 | 'exclude_from_search' => false, |
338 | 338 | 'show_in_admin_all_list' => true, |
339 | 339 | 'show_in_admin_status_list' => true, |
340 | - 'label_count' => _n_noop( 'Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give' ) |
|
341 | - ) ); |
|
342 | - register_post_status( 'cancelled', array( |
|
343 | - 'label' => _x( 'Cancelled', 'payment status', 'give' ), |
|
340 | + 'label_count' => _n_noop('Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give') |
|
341 | + )); |
|
342 | + register_post_status('cancelled', array( |
|
343 | + 'label' => _x('Cancelled', 'payment status', 'give'), |
|
344 | 344 | 'public' => true, |
345 | 345 | 'exclude_from_search' => false, |
346 | 346 | 'show_in_admin_all_list' => true, |
347 | 347 | 'show_in_admin_status_list' => true, |
348 | - 'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give' ) |
|
349 | - ) ); |
|
350 | - register_post_status( 'abandoned', array( |
|
351 | - 'label' => _x( 'Abandoned', 'payment status', 'give' ), |
|
348 | + 'label_count' => _n_noop('Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give') |
|
349 | + )); |
|
350 | + register_post_status('abandoned', array( |
|
351 | + 'label' => _x('Abandoned', 'payment status', 'give'), |
|
352 | 352 | 'public' => true, |
353 | 353 | 'exclude_from_search' => false, |
354 | 354 | 'show_in_admin_all_list' => true, |
355 | 355 | 'show_in_admin_status_list' => true, |
356 | - 'label_count' => _n_noop( 'Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give' ) |
|
357 | - ) ); |
|
356 | + 'label_count' => _n_noop('Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give') |
|
357 | + )); |
|
358 | 358 | |
359 | 359 | } |
360 | 360 | |
361 | -add_action( 'init', 'give_register_post_type_statuses' ); |
|
361 | +add_action('init', 'give_register_post_type_statuses'); |
|
362 | 362 | |
363 | 363 | /** |
364 | 364 | * Updated Messages |
@@ -371,43 +371,43 @@ discard block |
||
371 | 371 | * |
372 | 372 | * @return array $messages New post updated messages |
373 | 373 | */ |
374 | -function give_updated_messages( $messages ) { |
|
374 | +function give_updated_messages($messages) { |
|
375 | 375 | global $post, $post_ID; |
376 | 376 | |
377 | - $url1 = '<a href="' . get_permalink( $post_ID ) . '">'; |
|
377 | + $url1 = '<a href="'.get_permalink($post_ID).'">'; |
|
378 | 378 | $url2 = give_get_forms_label_singular(); |
379 | 379 | $url3 = '</a>'; |
380 | 380 | |
381 | 381 | $messages['give_forms'] = array( |
382 | - 1 => sprintf( __( '%2$s updated. %1$sView %2$s%3$s.', 'give' ), $url1, $url2, $url3 ), |
|
383 | - 4 => sprintf( __( '%2$s updated. %1$sView %2$s%3$s.', 'give' ), $url1, $url2, $url3 ), |
|
384 | - 6 => sprintf( __( '%2$s published. %1$sView %2$s%3$s.', 'give' ), $url1, $url2, $url3 ), |
|
385 | - 7 => sprintf( __( '%2$s saved. %1$sView %2$s%3$s.', 'give' ), $url1, $url2, $url3 ), |
|
386 | - 8 => sprintf( __( '%2$s submitted. %1$sView %2$s%3$s.', 'give' ), $url1, $url2, $url3 ) |
|
382 | + 1 => sprintf(__('%2$s updated. %1$sView %2$s%3$s.', 'give'), $url1, $url2, $url3), |
|
383 | + 4 => sprintf(__('%2$s updated. %1$sView %2$s%3$s.', 'give'), $url1, $url2, $url3), |
|
384 | + 6 => sprintf(__('%2$s published. %1$sView %2$s%3$s.', 'give'), $url1, $url2, $url3), |
|
385 | + 7 => sprintf(__('%2$s saved. %1$sView %2$s%3$s.', 'give'), $url1, $url2, $url3), |
|
386 | + 8 => sprintf(__('%2$s submitted. %1$sView %2$s%3$s.', 'give'), $url1, $url2, $url3) |
|
387 | 387 | ); |
388 | 388 | |
389 | 389 | return $messages; |
390 | 390 | } |
391 | 391 | |
392 | -add_filter( 'post_updated_messages', 'give_updated_messages' ); |
|
392 | +add_filter('post_updated_messages', 'give_updated_messages'); |
|
393 | 393 | |
394 | 394 | |
395 | 395 | /** |
396 | 396 | * Setup Post Type Images |
397 | 397 | */ |
398 | -add_action( 'after_setup_theme', 'give_add_thumbnail_support', 10 ); |
|
398 | +add_action('after_setup_theme', 'give_add_thumbnail_support', 10); |
|
399 | 399 | |
400 | 400 | /** |
401 | 401 | * Ensure post thumbnail support is turned on |
402 | 402 | */ |
403 | 403 | function give_add_thumbnail_support() { |
404 | - if ( give_get_option( 'disable_form_featured_img' ) === 'on' ) { |
|
404 | + if (give_get_option('disable_form_featured_img') === 'on') { |
|
405 | 405 | return; |
406 | 406 | } |
407 | - if ( ! current_theme_supports( 'post-thumbnails' ) ) { |
|
408 | - add_theme_support( 'post-thumbnails' ); |
|
407 | + if ( ! current_theme_supports('post-thumbnails')) { |
|
408 | + add_theme_support('post-thumbnails'); |
|
409 | 409 | } |
410 | - add_post_type_support( 'give_forms', 'thumbnail' ); |
|
410 | + add_post_type_support('give_forms', 'thumbnail'); |
|
411 | 411 | } |
412 | 412 | |
413 | 413 | /** |
@@ -419,19 +419,19 @@ discard block |
||
419 | 419 | function give_widgets_init() { |
420 | 420 | |
421 | 421 | //Single Give Forms (disabled if single turned off in settings) |
422 | - if ( give_get_option( 'disable_forms_singular' ) !== 'on' && give_get_option( 'disable_form_sidebar' ) !== 'on' ) { |
|
422 | + if (give_get_option('disable_forms_singular') !== 'on' && give_get_option('disable_form_sidebar') !== 'on') { |
|
423 | 423 | |
424 | - register_sidebar( apply_filters( 'give_forms_single_sidebar', array( |
|
425 | - 'name' => esc_html__( 'Give Single Form Sidebar', 'give' ), |
|
424 | + register_sidebar(apply_filters('give_forms_single_sidebar', array( |
|
425 | + 'name' => esc_html__('Give Single Form Sidebar', 'give'), |
|
426 | 426 | 'id' => 'give-forms-sidebar', |
427 | - 'description' => esc_html__( 'Widgets in this area will be shown on the single Give forms aside area. This sidebar will not display for embedded forms.', 'give' ), |
|
427 | + 'description' => esc_html__('Widgets in this area will be shown on the single Give forms aside area. This sidebar will not display for embedded forms.', 'give'), |
|
428 | 428 | 'before_widget' => '<div id="%1$s" class="widget %2$s">', |
429 | 429 | 'after_widget' => '</div>', |
430 | 430 | 'before_title' => '<h3 class="widgettitle widget-title">', |
431 | 431 | 'after_title' => '</h3>', |
432 | - ) ) ); |
|
432 | + ))); |
|
433 | 433 | |
434 | 434 | } |
435 | 435 | } |
436 | 436 | |
437 | -add_action( 'widgets_init', 'give_widgets_init', 999 ); |
|
437 | +add_action('widgets_init', 'give_widgets_init', 999); |
@@ -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 | |
@@ -85,19 +85,19 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public function get_predefined_dates() { |
87 | 87 | $predefined = array( |
88 | - 'today' => esc_html__( 'Today', 'give' ), |
|
89 | - 'yesterday' => esc_html__( 'Yesterday', 'give' ), |
|
90 | - 'this_week' => esc_html__( 'This Week', 'give' ), |
|
91 | - 'last_week' => esc_html__( 'Last Week', 'give' ), |
|
92 | - 'this_month' => esc_html__( 'This Month', 'give' ), |
|
93 | - 'last_month' => esc_html__( 'Last Month', 'give' ), |
|
94 | - 'this_quarter' => esc_html__( 'This Quarter', 'give' ), |
|
95 | - 'last_quarter' => esc_html__( 'Last Quarter', 'give' ), |
|
96 | - 'this_year' => esc_html__( 'This Year', 'give' ), |
|
97 | - 'last_year' => esc_html__( 'Last Year', 'give' ) |
|
88 | + 'today' => esc_html__('Today', 'give'), |
|
89 | + 'yesterday' => esc_html__('Yesterday', 'give'), |
|
90 | + 'this_week' => esc_html__('This Week', 'give'), |
|
91 | + 'last_week' => esc_html__('Last Week', 'give'), |
|
92 | + 'this_month' => esc_html__('This Month', 'give'), |
|
93 | + 'last_month' => esc_html__('Last Month', 'give'), |
|
94 | + 'this_quarter' => esc_html__('This Quarter', 'give'), |
|
95 | + 'last_quarter' => esc_html__('Last Quarter', 'give'), |
|
96 | + 'this_year' => esc_html__('This Year', 'give'), |
|
97 | + 'last_year' => esc_html__('Last Year', 'give') |
|
98 | 98 | ); |
99 | 99 | |
100 | - return apply_filters( 'give_stats_predefined_dates', $predefined ); |
|
100 | + return apply_filters('give_stats_predefined_dates', $predefined); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -113,18 +113,18 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return void |
115 | 115 | */ |
116 | - public function setup_dates( $_start_date = 'this_month', $_end_date = false ) { |
|
116 | + public function setup_dates($_start_date = 'this_month', $_end_date = false) { |
|
117 | 117 | |
118 | - if ( empty( $_start_date ) ) { |
|
118 | + if (empty($_start_date)) { |
|
119 | 119 | $_start_date = 'this_month'; |
120 | 120 | } |
121 | 121 | |
122 | - if ( empty( $_end_date ) ) { |
|
122 | + if (empty($_end_date)) { |
|
123 | 123 | $_end_date = $_start_date; |
124 | 124 | } |
125 | 125 | |
126 | - $this->start_date = $this->convert_date( $_start_date ); |
|
127 | - $this->end_date = $this->convert_date( $_end_date, true ); |
|
126 | + $this->start_date = $this->convert_date($_start_date); |
|
127 | + $this->end_date = $this->convert_date($_end_date, true); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -140,26 +140,26 @@ discard block |
||
140 | 140 | * |
141 | 141 | * @return array|WP_Error If the date is invalid, a WP_Error object will be returned. |
142 | 142 | */ |
143 | - public function convert_date( $date, $end_date = false ) { |
|
143 | + public function convert_date($date, $end_date = false) { |
|
144 | 144 | |
145 | 145 | $this->timestamp = false; |
146 | 146 | $second = $end_date ? 59 : 0; |
147 | 147 | $minute = $end_date ? 59 : 0; |
148 | 148 | $hour = $end_date ? 23 : 0; |
149 | 149 | $day = 1; |
150 | - $month = date( 'n', current_time( 'timestamp' ) ); |
|
151 | - $year = date( 'Y', current_time( 'timestamp' ) ); |
|
150 | + $month = date('n', current_time('timestamp')); |
|
151 | + $year = date('Y', current_time('timestamp')); |
|
152 | 152 | |
153 | - if ( array_key_exists( $date, $this->get_predefined_dates() ) ) { |
|
153 | + if (array_key_exists($date, $this->get_predefined_dates())) { |
|
154 | 154 | |
155 | 155 | // This is a predefined date rate, such as last_week |
156 | - switch ( $date ) { |
|
156 | + switch ($date) { |
|
157 | 157 | |
158 | 158 | case 'this_month' : |
159 | 159 | |
160 | - if ( $end_date ) { |
|
160 | + if ($end_date) { |
|
161 | 161 | |
162 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
162 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
163 | 163 | $hour = 23; |
164 | 164 | $minute = 59; |
165 | 165 | $second = 59; |
@@ -169,28 +169,28 @@ discard block |
||
169 | 169 | |
170 | 170 | case 'last_month' : |
171 | 171 | |
172 | - if ( $month == 1 ) { |
|
172 | + if ($month == 1) { |
|
173 | 173 | |
174 | 174 | $month = 12; |
175 | - $year --; |
|
175 | + $year--; |
|
176 | 176 | |
177 | 177 | } else { |
178 | 178 | |
179 | - $month --; |
|
179 | + $month--; |
|
180 | 180 | |
181 | 181 | } |
182 | 182 | |
183 | - if ( $end_date ) { |
|
184 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
183 | + if ($end_date) { |
|
184 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | break; |
188 | 188 | |
189 | 189 | case 'today' : |
190 | 190 | |
191 | - $day = date( 'd', current_time( 'timestamp' ) ); |
|
191 | + $day = date('d', current_time('timestamp')); |
|
192 | 192 | |
193 | - if ( $end_date ) { |
|
193 | + if ($end_date) { |
|
194 | 194 | $hour = 23; |
195 | 195 | $minute = 59; |
196 | 196 | $second = 59; |
@@ -200,23 +200,23 @@ discard block |
||
200 | 200 | |
201 | 201 | case 'yesterday' : |
202 | 202 | |
203 | - $day = date( 'd', current_time( 'timestamp' ) ) - 1; |
|
203 | + $day = date('d', current_time('timestamp')) - 1; |
|
204 | 204 | |
205 | 205 | // Check if Today is the first day of the month (meaning subtracting one will get us 0) |
206 | - if ( $day < 1 ) { |
|
206 | + if ($day < 1) { |
|
207 | 207 | |
208 | 208 | // If current month is 1 |
209 | - if ( 1 == $month ) { |
|
209 | + if (1 == $month) { |
|
210 | 210 | |
211 | 211 | $year -= 1; // Today is January 1, so skip back to last day of December |
212 | 212 | $month = 12; |
213 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
213 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
214 | 214 | |
215 | 215 | } else { |
216 | 216 | |
217 | 217 | // Go back one month and get the last day of the month |
218 | 218 | $month -= 1; |
219 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
219 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
220 | 220 | |
221 | 221 | } |
222 | 222 | } |
@@ -225,12 +225,12 @@ discard block |
||
225 | 225 | |
226 | 226 | case 'this_week' : |
227 | 227 | |
228 | - $days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24; |
|
229 | - $today = date( 'd', current_time( 'timestamp' ) ) * 60 * 60 * 24; |
|
228 | + $days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24; |
|
229 | + $today = date('d', current_time('timestamp')) * 60 * 60 * 24; |
|
230 | 230 | |
231 | - if ( $today < $days_to_week_start ) { |
|
231 | + if ($today < $days_to_week_start) { |
|
232 | 232 | |
233 | - if ( $month > 1 ) { |
|
233 | + if ($month > 1) { |
|
234 | 234 | $month -= 1; |
235 | 235 | } else { |
236 | 236 | $month = 12; |
@@ -238,19 +238,19 @@ discard block |
||
238 | 238 | |
239 | 239 | } |
240 | 240 | |
241 | - if ( ! $end_date ) { |
|
241 | + if ( ! $end_date) { |
|
242 | 242 | |
243 | 243 | // Getting the start day |
244 | 244 | |
245 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1; |
|
246 | - $day += get_option( 'start_of_week' ); |
|
245 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 1; |
|
246 | + $day += get_option('start_of_week'); |
|
247 | 247 | |
248 | 248 | } else { |
249 | 249 | |
250 | 250 | // Getting the end day |
251 | 251 | |
252 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1; |
|
253 | - $day += get_option( 'start_of_week' ) + 6; |
|
252 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 1; |
|
253 | + $day += get_option('start_of_week') + 6; |
|
254 | 254 | |
255 | 255 | } |
256 | 256 | |
@@ -258,12 +258,12 @@ discard block |
||
258 | 258 | |
259 | 259 | case 'last_week' : |
260 | 260 | |
261 | - $days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24; |
|
262 | - $today = date( 'd', current_time( 'timestamp' ) ) * 60 * 60 * 24; |
|
261 | + $days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24; |
|
262 | + $today = date('d', current_time('timestamp')) * 60 * 60 * 24; |
|
263 | 263 | |
264 | - if ( $today < $days_to_week_start ) { |
|
264 | + if ($today < $days_to_week_start) { |
|
265 | 265 | |
266 | - if ( $month > 1 ) { |
|
266 | + if ($month > 1) { |
|
267 | 267 | $month -= 1; |
268 | 268 | } else { |
269 | 269 | $month = 12; |
@@ -271,19 +271,19 @@ discard block |
||
271 | 271 | |
272 | 272 | } |
273 | 273 | |
274 | - if ( ! $end_date ) { |
|
274 | + if ( ! $end_date) { |
|
275 | 275 | |
276 | 276 | // Getting the start day |
277 | 277 | |
278 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8; |
|
279 | - $day += get_option( 'start_of_week' ); |
|
278 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 8; |
|
279 | + $day += get_option('start_of_week'); |
|
280 | 280 | |
281 | 281 | } else { |
282 | 282 | |
283 | 283 | // Getting the end day |
284 | 284 | |
285 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8; |
|
286 | - $day += get_option( 'start_of_week' ) + 6; |
|
285 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 8; |
|
286 | + $day += get_option('start_of_week') + 6; |
|
287 | 287 | |
288 | 288 | } |
289 | 289 | |
@@ -291,39 +291,39 @@ discard block |
||
291 | 291 | |
292 | 292 | case 'this_quarter' : |
293 | 293 | |
294 | - $month_now = date( 'n', current_time( 'timestamp' ) ); |
|
294 | + $month_now = date('n', current_time('timestamp')); |
|
295 | 295 | |
296 | - if ( $month_now <= 3 ) { |
|
296 | + if ($month_now <= 3) { |
|
297 | 297 | |
298 | - if ( ! $end_date ) { |
|
298 | + if ( ! $end_date) { |
|
299 | 299 | $month = 1; |
300 | 300 | } else { |
301 | 301 | $month = 3; |
302 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
302 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
303 | 303 | $hour = 23; |
304 | 304 | $minute = 59; |
305 | 305 | $second = 59; |
306 | 306 | } |
307 | 307 | |
308 | - } else if ( $month_now <= 6 ) { |
|
308 | + } else if ($month_now <= 6) { |
|
309 | 309 | |
310 | - if ( ! $end_date ) { |
|
310 | + if ( ! $end_date) { |
|
311 | 311 | $month = 4; |
312 | 312 | } else { |
313 | 313 | $month = 6; |
314 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
314 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
315 | 315 | $hour = 23; |
316 | 316 | $minute = 59; |
317 | 317 | $second = 59; |
318 | 318 | } |
319 | 319 | |
320 | - } else if ( $month_now <= 9 ) { |
|
320 | + } else if ($month_now <= 9) { |
|
321 | 321 | |
322 | - if ( ! $end_date ) { |
|
322 | + if ( ! $end_date) { |
|
323 | 323 | $month = 7; |
324 | 324 | } else { |
325 | 325 | $month = 9; |
326 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
326 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
327 | 327 | $hour = 23; |
328 | 328 | $minute = 59; |
329 | 329 | $second = 59; |
@@ -331,11 +331,11 @@ discard block |
||
331 | 331 | |
332 | 332 | } else { |
333 | 333 | |
334 | - if ( ! $end_date ) { |
|
334 | + if ( ! $end_date) { |
|
335 | 335 | $month = 10; |
336 | 336 | } else { |
337 | 337 | $month = 12; |
338 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
338 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
339 | 339 | $hour = 23; |
340 | 340 | $minute = 59; |
341 | 341 | $second = 59; |
@@ -347,40 +347,40 @@ discard block |
||
347 | 347 | |
348 | 348 | case 'last_quarter' : |
349 | 349 | |
350 | - $month_now = date( 'n', current_time( 'timestamp' ) ); |
|
350 | + $month_now = date('n', current_time('timestamp')); |
|
351 | 351 | |
352 | - if ( $month_now <= 3 ) { |
|
352 | + if ($month_now <= 3) { |
|
353 | 353 | |
354 | - if ( ! $end_date ) { |
|
354 | + if ( ! $end_date) { |
|
355 | 355 | $month = 10; |
356 | 356 | } else { |
357 | 357 | $year -= 1; |
358 | 358 | $month = 12; |
359 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
359 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
360 | 360 | $hour = 23; |
361 | 361 | $minute = 59; |
362 | 362 | $second = 59; |
363 | 363 | } |
364 | 364 | |
365 | - } else if ( $month_now <= 6 ) { |
|
365 | + } else if ($month_now <= 6) { |
|
366 | 366 | |
367 | - if ( ! $end_date ) { |
|
367 | + if ( ! $end_date) { |
|
368 | 368 | $month = 1; |
369 | 369 | } else { |
370 | 370 | $month = 3; |
371 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
371 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
372 | 372 | $hour = 23; |
373 | 373 | $minute = 59; |
374 | 374 | $second = 59; |
375 | 375 | } |
376 | 376 | |
377 | - } else if ( $month_now <= 9 ) { |
|
377 | + } else if ($month_now <= 9) { |
|
378 | 378 | |
379 | - if ( ! $end_date ) { |
|
379 | + if ( ! $end_date) { |
|
380 | 380 | $month = 4; |
381 | 381 | } else { |
382 | 382 | $month = 6; |
383 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
383 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
384 | 384 | $hour = 23; |
385 | 385 | $minute = 59; |
386 | 386 | $second = 59; |
@@ -388,11 +388,11 @@ discard block |
||
388 | 388 | |
389 | 389 | } else { |
390 | 390 | |
391 | - if ( ! $end_date ) { |
|
391 | + if ( ! $end_date) { |
|
392 | 392 | $month = 7; |
393 | 393 | } else { |
394 | 394 | $month = 9; |
395 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
395 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
396 | 396 | $hour = 23; |
397 | 397 | $minute = 59; |
398 | 398 | $second = 59; |
@@ -404,11 +404,11 @@ discard block |
||
404 | 404 | |
405 | 405 | case 'this_year' : |
406 | 406 | |
407 | - if ( ! $end_date ) { |
|
407 | + if ( ! $end_date) { |
|
408 | 408 | $month = 1; |
409 | 409 | } else { |
410 | 410 | $month = 12; |
411 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
411 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
412 | 412 | $hour = 23; |
413 | 413 | $minute = 59; |
414 | 414 | $second = 59; |
@@ -419,11 +419,11 @@ discard block |
||
419 | 419 | case 'last_year' : |
420 | 420 | |
421 | 421 | $year -= 1; |
422 | - if ( ! $end_date ) { |
|
422 | + if ( ! $end_date) { |
|
423 | 423 | $month = 1; |
424 | 424 | } else { |
425 | 425 | $month = 12; |
426 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
426 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
427 | 427 | $hour = 23; |
428 | 428 | $minute = 59; |
429 | 429 | $second = 59; |
@@ -434,30 +434,30 @@ discard block |
||
434 | 434 | } |
435 | 435 | |
436 | 436 | |
437 | - } else if ( is_numeric( $date ) ) { |
|
437 | + } else if (is_numeric($date)) { |
|
438 | 438 | |
439 | 439 | // return $date unchanged since it is a timestamp |
440 | 440 | $this->timestamp = true; |
441 | 441 | |
442 | - } else if ( false !== strtotime( $date ) ) { |
|
442 | + } else if (false !== strtotime($date)) { |
|
443 | 443 | |
444 | - $date = strtotime( $date, current_time( 'timestamp' ) ); |
|
445 | - $year = date( 'Y', $date ); |
|
446 | - $month = date( 'm', $date ); |
|
447 | - $day = date( 'd', $date ); |
|
444 | + $date = strtotime($date, current_time('timestamp')); |
|
445 | + $year = date('Y', $date); |
|
446 | + $month = date('m', $date); |
|
447 | + $day = date('d', $date); |
|
448 | 448 | |
449 | 449 | } else { |
450 | 450 | |
451 | - return new WP_Error( 'invalid_date', esc_html__( 'Improper date provided.', 'give' ) ); |
|
451 | + return new WP_Error('invalid_date', esc_html__('Improper date provided.', 'give')); |
|
452 | 452 | |
453 | 453 | } |
454 | 454 | |
455 | - if ( false === $this->timestamp ) { |
|
455 | + if (false === $this->timestamp) { |
|
456 | 456 | // Create an exact timestamp |
457 | - $date = mktime( $hour, $minute, $second, $month, $day, $year ); |
|
457 | + $date = mktime($hour, $minute, $second, $month, $day, $year); |
|
458 | 458 | } |
459 | 459 | |
460 | - return apply_filters( 'give_stats_date', $date, $end_date, $this ); |
|
460 | + return apply_filters('give_stats_date', $date, $end_date, $this); |
|
461 | 461 | |
462 | 462 | } |
463 | 463 | |
@@ -473,33 +473,33 @@ discard block |
||
473 | 473 | * |
474 | 474 | * @return string |
475 | 475 | */ |
476 | - public function count_where( $where = '' ) { |
|
476 | + public function count_where($where = '') { |
|
477 | 477 | // Only get payments in our date range |
478 | 478 | |
479 | 479 | $start_where = ''; |
480 | 480 | $end_where = ''; |
481 | 481 | |
482 | - if ( $this->start_date ) { |
|
482 | + if ($this->start_date) { |
|
483 | 483 | |
484 | - if ( $this->timestamp ) { |
|
484 | + if ($this->timestamp) { |
|
485 | 485 | $format = 'Y-m-d H:i:s'; |
486 | 486 | } else { |
487 | 487 | $format = 'Y-m-d 00:00:00'; |
488 | 488 | } |
489 | 489 | |
490 | - $start_date = date( $format, $this->start_date ); |
|
490 | + $start_date = date($format, $this->start_date); |
|
491 | 491 | $start_where = " AND p.post_date >= '{$start_date}'"; |
492 | 492 | } |
493 | 493 | |
494 | - if ( $this->end_date ) { |
|
494 | + if ($this->end_date) { |
|
495 | 495 | |
496 | - if ( $this->timestamp ) { |
|
496 | + if ($this->timestamp) { |
|
497 | 497 | $format = 'Y-m-d H:i:s'; |
498 | 498 | } else { |
499 | 499 | $format = 'Y-m-d 23:59:59'; |
500 | 500 | } |
501 | 501 | |
502 | - $end_date = date( $format, $this->end_date ); |
|
502 | + $end_date = date($format, $this->end_date); |
|
503 | 503 | |
504 | 504 | $end_where = " AND p.post_date <= '{$end_date}'"; |
505 | 505 | } |
@@ -521,34 +521,34 @@ discard block |
||
521 | 521 | * |
522 | 522 | * @return string |
523 | 523 | */ |
524 | - public function payments_where( $where = '' ) { |
|
524 | + public function payments_where($where = '') { |
|
525 | 525 | |
526 | 526 | global $wpdb; |
527 | 527 | |
528 | 528 | $start_where = ''; |
529 | 529 | $end_where = ''; |
530 | 530 | |
531 | - if ( ! is_wp_error( $this->start_date ) ) { |
|
531 | + if ( ! is_wp_error($this->start_date)) { |
|
532 | 532 | |
533 | - if ( $this->timestamp ) { |
|
533 | + if ($this->timestamp) { |
|
534 | 534 | $format = 'Y-m-d H:i:s'; |
535 | 535 | } else { |
536 | 536 | $format = 'Y-m-d 00:00:00'; |
537 | 537 | } |
538 | 538 | |
539 | - $start_date = date( $format, $this->start_date ); |
|
539 | + $start_date = date($format, $this->start_date); |
|
540 | 540 | $start_where = " AND $wpdb->posts.post_date >= '{$start_date}'"; |
541 | 541 | } |
542 | 542 | |
543 | - if ( ! is_wp_error( $this->end_date ) ) { |
|
543 | + if ( ! is_wp_error($this->end_date)) { |
|
544 | 544 | |
545 | - if ( $this->timestamp ) { |
|
545 | + if ($this->timestamp) { |
|
546 | 546 | $format = 'Y-m-d 00:00:00'; |
547 | 547 | } else { |
548 | 548 | $format = 'Y-m-d 23:59:59'; |
549 | 549 | } |
550 | 550 | |
551 | - $end_date = date( $format, $this->end_date ); |
|
551 | + $end_date = date($format, $this->end_date); |
|
552 | 552 | |
553 | 553 | $end_where = " AND $wpdb->posts.post_date <= '{$end_date}'"; |
554 | 554 | } |
@@ -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 | |
@@ -38,29 +38,29 @@ discard block |
||
38 | 38 | /** |
39 | 39 | * Templates |
40 | 40 | */ |
41 | - add_filter( 'template_include', array( __CLASS__, 'template_loader' ) ); |
|
41 | + add_filter('template_include', array(__CLASS__, 'template_loader')); |
|
42 | 42 | |
43 | 43 | /** |
44 | 44 | * Content Wrappers |
45 | 45 | */ |
46 | - add_action( 'give_before_main_content', 'give_output_content_wrapper', 10 ); |
|
47 | - add_action( 'give_after_main_content', 'give_output_content_wrapper_end', 10 ); |
|
46 | + add_action('give_before_main_content', 'give_output_content_wrapper', 10); |
|
47 | + add_action('give_after_main_content', 'give_output_content_wrapper_end', 10); |
|
48 | 48 | |
49 | 49 | /** |
50 | 50 | * Entry Summary Classes |
51 | 51 | */ |
52 | - add_filter( 'give_forms_single_summary_classes', array( $this, 'give_set_single_summary_classes' ) ); |
|
52 | + add_filter('give_forms_single_summary_classes', array($this, 'give_set_single_summary_classes')); |
|
53 | 53 | |
54 | 54 | /** |
55 | 55 | * Sidebar |
56 | 56 | */ |
57 | - add_action( 'give_before_single_form_summary', array( $this, 'give_output_sidebar_option' ), 1 ); |
|
57 | + add_action('give_before_single_form_summary', array($this, 'give_output_sidebar_option'), 1); |
|
58 | 58 | |
59 | 59 | /** |
60 | 60 | * Single Forms Summary Box |
61 | 61 | */ |
62 | - add_action( 'give_single_form_summary', 'give_template_single_title', 5 ); |
|
63 | - add_action( 'give_single_form_summary', 'give_get_donation_form', 10 ); |
|
62 | + add_action('give_single_form_summary', 'give_template_single_title', 5); |
|
63 | + add_action('give_single_form_summary', 'give_get_donation_form', 10); |
|
64 | 64 | |
65 | 65 | } |
66 | 66 | |
@@ -75,12 +75,12 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @return string $classes List of space separated class names. |
77 | 77 | */ |
78 | - public function give_set_single_summary_classes( $classes ) { |
|
78 | + public function give_set_single_summary_classes($classes) { |
|
79 | 79 | |
80 | - $sidebar_option = give_get_option( 'disable_form_sidebar' ); |
|
80 | + $sidebar_option = give_get_option('disable_form_sidebar'); |
|
81 | 81 | |
82 | 82 | //Add full width class when feature image is disabled AND no widgets are present |
83 | - if ( $sidebar_option == 'on' ) { |
|
83 | + if ($sidebar_option == 'on') { |
|
84 | 84 | $classes .= ' give-full-width'; |
85 | 85 | } |
86 | 86 | |
@@ -100,14 +100,14 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function give_output_sidebar_option() { |
102 | 102 | |
103 | - $sidebar_option = give_get_option( 'disable_form_sidebar' ); |
|
103 | + $sidebar_option = give_get_option('disable_form_sidebar'); |
|
104 | 104 | |
105 | 105 | //Add full width class when feature image is disabled AND no widgets are present |
106 | - if ( $sidebar_option !== 'on' ) { |
|
107 | - add_action( 'give_before_single_form_summary', 'give_left_sidebar_pre_wrap', 5 ); |
|
108 | - add_action( 'give_before_single_form_summary', 'give_show_form_images', 10 ); |
|
109 | - add_action( 'give_before_single_form_summary', 'give_get_forms_sidebar', 20 ); |
|
110 | - add_action( 'give_before_single_form_summary', 'give_left_sidebar_post_wrap', 30 ); |
|
106 | + if ($sidebar_option !== 'on') { |
|
107 | + add_action('give_before_single_form_summary', 'give_left_sidebar_pre_wrap', 5); |
|
108 | + add_action('give_before_single_form_summary', 'give_show_form_images', 10); |
|
109 | + add_action('give_before_single_form_summary', 'give_get_forms_sidebar', 20); |
|
110 | + add_action('give_before_single_form_summary', 'give_left_sidebar_post_wrap', 30); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | } |
@@ -129,20 +129,20 @@ discard block |
||
129 | 129 | * |
130 | 130 | * @return string $template |
131 | 131 | */ |
132 | - public static function template_loader( $template ) { |
|
133 | - $find = array( 'give.php' ); |
|
132 | + public static function template_loader($template) { |
|
133 | + $find = array('give.php'); |
|
134 | 134 | $file = ''; |
135 | 135 | |
136 | - if ( is_single() && get_post_type() == 'give_forms' ) { |
|
136 | + if (is_single() && get_post_type() == 'give_forms') { |
|
137 | 137 | $file = 'single-give-form.php'; |
138 | 138 | $find[] = $file; |
139 | - $find[] = apply_filters( 'give_template_path', 'give/' ) . $file; |
|
139 | + $find[] = apply_filters('give_template_path', 'give/').$file; |
|
140 | 140 | } |
141 | 141 | |
142 | - if ( $file ) { |
|
143 | - $template = locate_template( array_unique( $find ) ); |
|
144 | - if ( ! $template ) { |
|
145 | - $template = GIVE_PLUGIN_DIR . '/templates/' . $file; |
|
142 | + if ($file) { |
|
143 | + $template = locate_template(array_unique($find)); |
|
144 | + if ( ! $template) { |
|
145 | + $template = GIVE_PLUGIN_DIR.'/templates/'.$file; |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | // Retrieve the payment ID |
38 | 38 | $payment_id = absint( $data['give_payment_id'] ); |
39 | 39 | |
40 | - /* @var Give_Payment $payment */ |
|
40 | + /* @var Give_Payment $payment */ |
|
41 | 41 | $payment = new Give_Payment( $payment_id ); |
42 | 42 | |
43 | 43 | // Retrieve existing payment meta |
@@ -160,23 +160,23 @@ discard block |
||
160 | 160 | |
161 | 161 | if ( 'publish' == $status ) { |
162 | 162 | |
163 | - // Reduce previous user donation count and amount. |
|
164 | - $previous_customer->decrease_purchase_count(); |
|
165 | - $previous_customer->decrease_value( $curr_total ); |
|
163 | + // Reduce previous user donation count and amount. |
|
164 | + $previous_customer->decrease_purchase_count(); |
|
165 | + $previous_customer->decrease_value( $curr_total ); |
|
166 | 166 | |
167 | - // If purchase was completed adjust stats of new customers. |
|
168 | - $customer->increase_purchase_count(); |
|
167 | + // If purchase was completed adjust stats of new customers. |
|
168 | + $customer->increase_purchase_count(); |
|
169 | 169 | $customer->increase_value( $new_total ); |
170 | 170 | } |
171 | 171 | |
172 | 172 | $payment->customer_id = $customer->id; |
173 | 173 | } else{ |
174 | 174 | |
175 | - if( 'publish' === $status ){ |
|
176 | - // Update user donation stat. |
|
177 | - $customer->update_donation_value( $curr_total, $new_total ); |
|
178 | - } |
|
179 | - } |
|
175 | + if( 'publish' === $status ){ |
|
176 | + // Update user donation stat. |
|
177 | + $customer->update_donation_value( $curr_total, $new_total ); |
|
178 | + } |
|
179 | + } |
|
180 | 180 | |
181 | 181 | // Set new meta values |
182 | 182 | $payment->user_id = $customer->user_id; |
@@ -217,76 +217,76 @@ discard block |
||
217 | 217 | |
218 | 218 | $payment->save(); |
219 | 219 | |
220 | - // Get new give form ID. |
|
221 | - $new_form_id = absint( $data['forms'] ); |
|
222 | - $current_form_id = absint( $payment->get_meta( '_give_payment_form_id' ) ); |
|
220 | + // Get new give form ID. |
|
221 | + $new_form_id = absint( $data['forms'] ); |
|
222 | + $current_form_id = absint( $payment->get_meta( '_give_payment_form_id' ) ); |
|
223 | 223 | |
224 | - // We are adding payment transfer code in last to remove any conflict with above functionality. |
|
225 | - // For example: above code will automatically handle form stat (increase/decrease) when payment status changes. |
|
226 | - /* Check if user want to transfer current payment to new give form id. */ |
|
227 | - if( $new_form_id != $current_form_id ) { |
|
224 | + // We are adding payment transfer code in last to remove any conflict with above functionality. |
|
225 | + // For example: above code will automatically handle form stat (increase/decrease) when payment status changes. |
|
226 | + /* Check if user want to transfer current payment to new give form id. */ |
|
227 | + if( $new_form_id != $current_form_id ) { |
|
228 | 228 | |
229 | - // Get new give form title. |
|
230 | - $new_form_title = get_the_title( $new_form_id ); |
|
229 | + // Get new give form title. |
|
230 | + $new_form_title = get_the_title( $new_form_id ); |
|
231 | 231 | |
232 | - // Update new give form data in payment data. |
|
233 | - $payment_meta = $payment->get_meta(); |
|
234 | - $payment_meta['form_title'] = $new_form_title; |
|
235 | - $payment_meta['form_id'] = $new_form_id; |
|
232 | + // Update new give form data in payment data. |
|
233 | + $payment_meta = $payment->get_meta(); |
|
234 | + $payment_meta['form_title'] = $new_form_title; |
|
235 | + $payment_meta['form_id'] = $new_form_id; |
|
236 | 236 | |
237 | - // Update price id post meta data for set donation form. |
|
238 | - if( ! give_has_variable_prices( $new_form_id ) ) { |
|
239 | - $payment_meta['price_id'] = ''; |
|
240 | - } |
|
237 | + // Update price id post meta data for set donation form. |
|
238 | + if( ! give_has_variable_prices( $new_form_id ) ) { |
|
239 | + $payment_meta['price_id'] = ''; |
|
240 | + } |
|
241 | 241 | |
242 | - // Update payment give form meta data. |
|
243 | - $payment->update_meta( '_give_payment_form_id', $new_form_id ); |
|
244 | - $payment->update_meta( '_give_payment_form_title', $new_form_title ); |
|
245 | - $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
242 | + // Update payment give form meta data. |
|
243 | + $payment->update_meta( '_give_payment_form_id', $new_form_id ); |
|
244 | + $payment->update_meta( '_give_payment_form_title', $new_form_title ); |
|
245 | + $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
246 | 246 | |
247 | - // Update price id payment metadata. |
|
248 | - if( ! give_has_variable_prices( $new_form_id ) ) { |
|
249 | - $payment->update_meta( '_give_payment_price_id', '' ); |
|
250 | - } |
|
247 | + // Update price id payment metadata. |
|
248 | + if( ! give_has_variable_prices( $new_form_id ) ) { |
|
249 | + $payment->update_meta( '_give_payment_price_id', '' ); |
|
250 | + } |
|
251 | 251 | |
252 | 252 | |
253 | - // If purchase was completed, adjust stats of forms |
|
254 | - if ( 'publish' == $status ) { |
|
253 | + // If purchase was completed, adjust stats of forms |
|
254 | + if ( 'publish' == $status ) { |
|
255 | 255 | |
256 | - // Decrease sale of old give form. For other payment status |
|
257 | - $current_form = new Give_Donate_Form( $current_form_id ); |
|
258 | - $current_form->decrease_sales(); |
|
259 | - $current_form->decrease_earnings( $curr_total ); |
|
256 | + // Decrease sale of old give form. For other payment status |
|
257 | + $current_form = new Give_Donate_Form( $current_form_id ); |
|
258 | + $current_form->decrease_sales(); |
|
259 | + $current_form->decrease_earnings( $curr_total ); |
|
260 | 260 | |
261 | - // Increase sale of new give form. |
|
262 | - $new_form = new Give_Donate_Form($new_form_id); |
|
263 | - $new_form->increase_sales(); |
|
264 | - $new_form->increase_earnings($new_total); |
|
265 | - } |
|
261 | + // Increase sale of new give form. |
|
262 | + $new_form = new Give_Donate_Form($new_form_id); |
|
263 | + $new_form->increase_sales(); |
|
264 | + $new_form->increase_earnings($new_total); |
|
265 | + } |
|
266 | 266 | |
267 | - // Re setup payment to update new meta value in object. |
|
268 | - $payment->update_payment_setup( $payment->ID ); |
|
269 | - } |
|
267 | + // Re setup payment to update new meta value in object. |
|
268 | + $payment->update_payment_setup( $payment->ID ); |
|
269 | + } |
|
270 | 270 | |
271 | - // Update price id if current form is variable form. |
|
272 | - if( ! empty( $data['give-variable-price'] ) && give_has_variable_prices( $payment->form_id ) ) { |
|
271 | + // Update price id if current form is variable form. |
|
272 | + if( ! empty( $data['give-variable-price'] ) && give_has_variable_prices( $payment->form_id ) ) { |
|
273 | 273 | |
274 | - // Get payment meta data. |
|
275 | - $payment_meta = $payment->get_meta(); |
|
274 | + // Get payment meta data. |
|
275 | + $payment_meta = $payment->get_meta(); |
|
276 | 276 | |
277 | - // Set payment id to empty string if variable price id is negative ( i.e. custom amount feature enabled ). |
|
278 | - $data['give-variable-price'] = ( 'custom' === $data['give-variable-price'] ) ? 'custom' : ( 0 < $data['give-variable-price'] ) ? $data['give-variable-price'] : ''; |
|
277 | + // Set payment id to empty string if variable price id is negative ( i.e. custom amount feature enabled ). |
|
278 | + $data['give-variable-price'] = ( 'custom' === $data['give-variable-price'] ) ? 'custom' : ( 0 < $data['give-variable-price'] ) ? $data['give-variable-price'] : ''; |
|
279 | 279 | |
280 | - // Update payment meta data. |
|
281 | - $payment_meta['price_id'] = $data['give-variable-price']; |
|
280 | + // Update payment meta data. |
|
281 | + $payment_meta['price_id'] = $data['give-variable-price']; |
|
282 | 282 | |
283 | - // Update payment give form meta data. |
|
284 | - $payment->update_meta( '_give_payment_price_id', $data['give-variable-price'] ); |
|
285 | - $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
283 | + // Update payment give form meta data. |
|
284 | + $payment->update_meta( '_give_payment_price_id', $data['give-variable-price'] ); |
|
285 | + $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
286 | 286 | |
287 | - // Re setup payment to update new meta value in object. |
|
288 | - $payment->update_payment_setup( $payment->ID ); |
|
289 | - } |
|
287 | + // Re setup payment to update new meta value in object. |
|
288 | + $payment->update_payment_setup( $payment->ID ); |
|
289 | + } |
|
290 | 290 | |
291 | 291 | /** |
292 | 292 | * Fires after updating edited purchase. |
@@ -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 | |
@@ -26,52 +26,52 @@ discard block |
||
26 | 26 | * @return void |
27 | 27 | * |
28 | 28 | */ |
29 | -function give_update_payment_details( $data ) { |
|
29 | +function give_update_payment_details($data) { |
|
30 | 30 | |
31 | - if ( ! current_user_can( 'edit_give_payments', $data['give_payment_id'] ) ) { |
|
32 | - wp_die( esc_html__( 'You do not have permission to edit payment records.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
31 | + if ( ! current_user_can('edit_give_payments', $data['give_payment_id'])) { |
|
32 | + wp_die(esc_html__('You do not have permission to edit payment records.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
33 | 33 | } |
34 | 34 | |
35 | - check_admin_referer( 'give_update_payment_details_nonce' ); |
|
35 | + check_admin_referer('give_update_payment_details_nonce'); |
|
36 | 36 | |
37 | 37 | // Retrieve the payment ID |
38 | - $payment_id = absint( $data['give_payment_id'] ); |
|
38 | + $payment_id = absint($data['give_payment_id']); |
|
39 | 39 | |
40 | 40 | /* @var Give_Payment $payment */ |
41 | - $payment = new Give_Payment( $payment_id ); |
|
41 | + $payment = new Give_Payment($payment_id); |
|
42 | 42 | |
43 | 43 | // Retrieve existing payment meta |
44 | 44 | $meta = $payment->get_meta(); |
45 | 45 | $user_info = $payment->user_info; |
46 | 46 | |
47 | 47 | $status = $data['give-payment-status']; |
48 | - $date = sanitize_text_field( $data['give-payment-date'] ); |
|
49 | - $hour = sanitize_text_field( $data['give-payment-time-hour'] ); |
|
48 | + $date = sanitize_text_field($data['give-payment-date']); |
|
49 | + $hour = sanitize_text_field($data['give-payment-time-hour']); |
|
50 | 50 | |
51 | 51 | // Restrict to our high and low |
52 | - if ( $hour > 23 ) { |
|
52 | + if ($hour > 23) { |
|
53 | 53 | $hour = 23; |
54 | - } elseif ( $hour < 0 ) { |
|
54 | + } elseif ($hour < 0) { |
|
55 | 55 | $hour = 00; |
56 | 56 | } |
57 | 57 | |
58 | - $minute = sanitize_text_field( $data['give-payment-time-min'] ); |
|
58 | + $minute = sanitize_text_field($data['give-payment-time-min']); |
|
59 | 59 | |
60 | 60 | // Restrict to our high and low |
61 | - if ( $minute > 59 ) { |
|
61 | + if ($minute > 59) { |
|
62 | 62 | $minute = 59; |
63 | - } elseif ( $minute < 0 ) { |
|
63 | + } elseif ($minute < 0) { |
|
64 | 64 | $minute = 00; |
65 | 65 | } |
66 | 66 | |
67 | - $address = array_map( 'trim', $data['give-payment-address'][0] ); |
|
67 | + $address = array_map('trim', $data['give-payment-address'][0]); |
|
68 | 68 | |
69 | - $curr_total = give_sanitize_amount( $payment->total ); |
|
70 | - $new_total = give_sanitize_amount( $data['give-payment-total'] ); |
|
71 | - $date = date( 'Y-m-d', strtotime( $date ) ) . ' ' . $hour . ':' . $minute . ':00'; |
|
69 | + $curr_total = give_sanitize_amount($payment->total); |
|
70 | + $new_total = give_sanitize_amount($data['give-payment-total']); |
|
71 | + $date = date('Y-m-d', strtotime($date)).' '.$hour.':'.$minute.':00'; |
|
72 | 72 | |
73 | - $curr_customer_id = sanitize_text_field( $data['give-current-customer'] ); |
|
74 | - $new_customer_id = sanitize_text_field( $data['customer-id'] ); |
|
73 | + $curr_customer_id = sanitize_text_field($data['give-current-customer']); |
|
74 | + $new_customer_id = sanitize_text_field($data['customer-id']); |
|
75 | 75 | |
76 | 76 | /** |
77 | 77 | * Fires before updating edited purchase. |
@@ -80,62 +80,62 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @param int $payment_id The ID of the payment. |
82 | 82 | */ |
83 | - do_action( 'give_update_edited_purchase', $payment_id ); |
|
83 | + do_action('give_update_edited_purchase', $payment_id); |
|
84 | 84 | |
85 | 85 | $payment->date = $date; |
86 | 86 | $updated = $payment->save(); |
87 | 87 | |
88 | - if ( 0 === $updated ) { |
|
89 | - wp_die( esc_html__( 'Error Updating Payment.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
88 | + if (0 === $updated) { |
|
89 | + wp_die(esc_html__('Error Updating Payment.', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | |
93 | 93 | $customer_changed = false; |
94 | 94 | |
95 | - if ( isset( $data['give-new-customer'] ) && $data['give-new-customer'] == '1' ) { |
|
95 | + if (isset($data['give-new-customer']) && $data['give-new-customer'] == '1') { |
|
96 | 96 | |
97 | - $email = isset( $data['give-new-customer-email'] ) ? sanitize_text_field( $data['give-new-customer-email'] ) : ''; |
|
98 | - $names = isset( $data['give-new-customer-name'] ) ? sanitize_text_field( $data['give-new-customer-name'] ) : ''; |
|
97 | + $email = isset($data['give-new-customer-email']) ? sanitize_text_field($data['give-new-customer-email']) : ''; |
|
98 | + $names = isset($data['give-new-customer-name']) ? sanitize_text_field($data['give-new-customer-name']) : ''; |
|
99 | 99 | |
100 | - if ( empty( $email ) || empty( $names ) ) { |
|
101 | - wp_die( esc_html__( 'New Customers require a name and email address.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
100 | + if (empty($email) || empty($names)) { |
|
101 | + wp_die(esc_html__('New Customers require a name and email address.', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
102 | 102 | } |
103 | 103 | |
104 | - $customer = new Give_Customer( $email ); |
|
105 | - if ( empty( $customer->id ) ) { |
|
106 | - $customer_data = array( 'name' => $names, 'email' => $email ); |
|
107 | - $user_id = email_exists( $email ); |
|
108 | - if ( false !== $user_id ) { |
|
104 | + $customer = new Give_Customer($email); |
|
105 | + if (empty($customer->id)) { |
|
106 | + $customer_data = array('name' => $names, 'email' => $email); |
|
107 | + $user_id = email_exists($email); |
|
108 | + if (false !== $user_id) { |
|
109 | 109 | $customer_data['user_id'] = $user_id; |
110 | 110 | } |
111 | 111 | |
112 | - if ( ! $customer->create( $customer_data ) ) { |
|
112 | + if ( ! $customer->create($customer_data)) { |
|
113 | 113 | // Failed to crete the new donor, assume the previous donor |
114 | 114 | $customer_changed = false; |
115 | - $customer = new Give_Customer( $curr_customer_id ); |
|
116 | - give_set_error( 'give-payment-new-customer-fail', esc_html__( 'Error creating new donor.', 'give' ) ); |
|
115 | + $customer = new Give_Customer($curr_customer_id); |
|
116 | + give_set_error('give-payment-new-customer-fail', esc_html__('Error creating new donor.', 'give')); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | 120 | $new_customer_id = $customer->id; |
121 | 121 | |
122 | - $previous_customer = new Give_Customer( $curr_customer_id ); |
|
122 | + $previous_customer = new Give_Customer($curr_customer_id); |
|
123 | 123 | |
124 | 124 | $customer_changed = true; |
125 | 125 | |
126 | - } elseif ( $curr_customer_id !== $new_customer_id ) { |
|
126 | + } elseif ($curr_customer_id !== $new_customer_id) { |
|
127 | 127 | |
128 | - $customer = new Give_Customer( $new_customer_id ); |
|
128 | + $customer = new Give_Customer($new_customer_id); |
|
129 | 129 | $email = $customer->email; |
130 | 130 | $names = $customer->name; |
131 | 131 | |
132 | - $previous_customer = new Give_Customer( $curr_customer_id ); |
|
132 | + $previous_customer = new Give_Customer($curr_customer_id); |
|
133 | 133 | |
134 | 134 | $customer_changed = true; |
135 | 135 | |
136 | 136 | } else { |
137 | 137 | |
138 | - $customer = new Give_Customer( $curr_customer_id ); |
|
138 | + $customer = new Give_Customer($curr_customer_id); |
|
139 | 139 | $email = $customer->email; |
140 | 140 | $names = $customer->name; |
141 | 141 | |
@@ -143,38 +143,38 @@ discard block |
||
143 | 143 | |
144 | 144 | |
145 | 145 | // Setup first and last name from input values |
146 | - $names = explode( ' ', $names ); |
|
147 | - $first_name = ! empty( $names[0] ) ? $names[0] : ''; |
|
146 | + $names = explode(' ', $names); |
|
147 | + $first_name = ! empty($names[0]) ? $names[0] : ''; |
|
148 | 148 | $last_name = ''; |
149 | - if ( ! empty( $names[1] ) ) { |
|
150 | - unset( $names[0] ); |
|
151 | - $last_name = implode( ' ', $names ); |
|
149 | + if ( ! empty($names[1])) { |
|
150 | + unset($names[0]); |
|
151 | + $last_name = implode(' ', $names); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | |
155 | - if ( $customer_changed ) { |
|
155 | + if ($customer_changed) { |
|
156 | 156 | |
157 | 157 | // Remove the stats and payment from the previous customer and attach it to the new customer |
158 | - $previous_customer->remove_payment( $payment_id, false ); |
|
159 | - $customer->attach_payment( $payment_id, false ); |
|
158 | + $previous_customer->remove_payment($payment_id, false); |
|
159 | + $customer->attach_payment($payment_id, false); |
|
160 | 160 | |
161 | - if ( 'publish' == $status ) { |
|
161 | + if ('publish' == $status) { |
|
162 | 162 | |
163 | 163 | // Reduce previous user donation count and amount. |
164 | 164 | $previous_customer->decrease_purchase_count(); |
165 | - $previous_customer->decrease_value( $curr_total ); |
|
165 | + $previous_customer->decrease_value($curr_total); |
|
166 | 166 | |
167 | 167 | // If purchase was completed adjust stats of new customers. |
168 | 168 | $customer->increase_purchase_count(); |
169 | - $customer->increase_value( $new_total ); |
|
169 | + $customer->increase_value($new_total); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | $payment->customer_id = $customer->id; |
173 | - } else{ |
|
173 | + } else { |
|
174 | 174 | |
175 | - if( 'publish' === $status ){ |
|
175 | + if ('publish' === $status) { |
|
176 | 176 | // Update user donation stat. |
177 | - $customer->update_donation_value( $curr_total, $new_total ); |
|
177 | + $customer->update_donation_value($curr_total, $new_total); |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | |
@@ -188,10 +188,10 @@ discard block |
||
188 | 188 | |
189 | 189 | |
190 | 190 | // Check for payment notes |
191 | - if ( ! empty( $data['give-payment-note'] ) ) { |
|
191 | + if ( ! empty($data['give-payment-note'])) { |
|
192 | 192 | |
193 | - $note = wp_kses( $data['give-payment-note'], array() ); |
|
194 | - give_insert_payment_note( $payment_id, $note ); |
|
193 | + $note = wp_kses($data['give-payment-note'], array()); |
|
194 | + give_insert_payment_note($payment_id, $note); |
|
195 | 195 | |
196 | 196 | } |
197 | 197 | |
@@ -199,17 +199,17 @@ discard block |
||
199 | 199 | $payment->status = $status; |
200 | 200 | |
201 | 201 | // Adjust total store earnings if the payment total has been changed |
202 | - if ( $new_total !== $curr_total && 'publish' == $status ) { |
|
202 | + if ($new_total !== $curr_total && 'publish' == $status) { |
|
203 | 203 | |
204 | - if ( $new_total > $curr_total ) { |
|
204 | + if ($new_total > $curr_total) { |
|
205 | 205 | // Increase if our new total is higher |
206 | 206 | $difference = $new_total - $curr_total; |
207 | - give_increase_total_earnings( $difference ); |
|
207 | + give_increase_total_earnings($difference); |
|
208 | 208 | |
209 | - } elseif ( $curr_total > $new_total ) { |
|
209 | + } elseif ($curr_total > $new_total) { |
|
210 | 210 | // Decrease if our new total is lower |
211 | 211 | $difference = $curr_total - $new_total; |
212 | - give_decrease_total_earnings( $difference ); |
|
212 | + give_decrease_total_earnings($difference); |
|
213 | 213 | |
214 | 214 | } |
215 | 215 | |
@@ -218,16 +218,16 @@ discard block |
||
218 | 218 | $payment->save(); |
219 | 219 | |
220 | 220 | // Get new give form ID. |
221 | - $new_form_id = absint( $data['forms'] ); |
|
222 | - $current_form_id = absint( $payment->get_meta( '_give_payment_form_id' ) ); |
|
221 | + $new_form_id = absint($data['forms']); |
|
222 | + $current_form_id = absint($payment->get_meta('_give_payment_form_id')); |
|
223 | 223 | |
224 | 224 | // We are adding payment transfer code in last to remove any conflict with above functionality. |
225 | 225 | // For example: above code will automatically handle form stat (increase/decrease) when payment status changes. |
226 | 226 | /* Check if user want to transfer current payment to new give form id. */ |
227 | - if( $new_form_id != $current_form_id ) { |
|
227 | + if ($new_form_id != $current_form_id) { |
|
228 | 228 | |
229 | 229 | // Get new give form title. |
230 | - $new_form_title = get_the_title( $new_form_id ); |
|
230 | + $new_form_title = get_the_title($new_form_id); |
|
231 | 231 | |
232 | 232 | // Update new give form data in payment data. |
233 | 233 | $payment_meta = $payment->get_meta(); |
@@ -235,28 +235,28 @@ discard block |
||
235 | 235 | $payment_meta['form_id'] = $new_form_id; |
236 | 236 | |
237 | 237 | // Update price id post meta data for set donation form. |
238 | - if( ! give_has_variable_prices( $new_form_id ) ) { |
|
238 | + if ( ! give_has_variable_prices($new_form_id)) { |
|
239 | 239 | $payment_meta['price_id'] = ''; |
240 | 240 | } |
241 | 241 | |
242 | 242 | // Update payment give form meta data. |
243 | - $payment->update_meta( '_give_payment_form_id', $new_form_id ); |
|
244 | - $payment->update_meta( '_give_payment_form_title', $new_form_title ); |
|
245 | - $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
243 | + $payment->update_meta('_give_payment_form_id', $new_form_id); |
|
244 | + $payment->update_meta('_give_payment_form_title', $new_form_title); |
|
245 | + $payment->update_meta('_give_payment_meta', $payment_meta); |
|
246 | 246 | |
247 | 247 | // Update price id payment metadata. |
248 | - if( ! give_has_variable_prices( $new_form_id ) ) { |
|
249 | - $payment->update_meta( '_give_payment_price_id', '' ); |
|
248 | + if ( ! give_has_variable_prices($new_form_id)) { |
|
249 | + $payment->update_meta('_give_payment_price_id', ''); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | |
253 | 253 | // If purchase was completed, adjust stats of forms |
254 | - if ( 'publish' == $status ) { |
|
254 | + if ('publish' == $status) { |
|
255 | 255 | |
256 | 256 | // Decrease sale of old give form. For other payment status |
257 | - $current_form = new Give_Donate_Form( $current_form_id ); |
|
257 | + $current_form = new Give_Donate_Form($current_form_id); |
|
258 | 258 | $current_form->decrease_sales(); |
259 | - $current_form->decrease_earnings( $curr_total ); |
|
259 | + $current_form->decrease_earnings($curr_total); |
|
260 | 260 | |
261 | 261 | // Increase sale of new give form. |
262 | 262 | $new_form = new Give_Donate_Form($new_form_id); |
@@ -265,27 +265,27 @@ discard block |
||
265 | 265 | } |
266 | 266 | |
267 | 267 | // Re setup payment to update new meta value in object. |
268 | - $payment->update_payment_setup( $payment->ID ); |
|
268 | + $payment->update_payment_setup($payment->ID); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | // Update price id if current form is variable form. |
272 | - if( ! empty( $data['give-variable-price'] ) && give_has_variable_prices( $payment->form_id ) ) { |
|
272 | + if ( ! empty($data['give-variable-price']) && give_has_variable_prices($payment->form_id)) { |
|
273 | 273 | |
274 | 274 | // Get payment meta data. |
275 | 275 | $payment_meta = $payment->get_meta(); |
276 | 276 | |
277 | 277 | // Set payment id to empty string if variable price id is negative ( i.e. custom amount feature enabled ). |
278 | - $data['give-variable-price'] = ( 'custom' === $data['give-variable-price'] ) ? 'custom' : ( 0 < $data['give-variable-price'] ) ? $data['give-variable-price'] : ''; |
|
278 | + $data['give-variable-price'] = ('custom' === $data['give-variable-price']) ? 'custom' : (0 < $data['give-variable-price']) ? $data['give-variable-price'] : ''; |
|
279 | 279 | |
280 | 280 | // Update payment meta data. |
281 | 281 | $payment_meta['price_id'] = $data['give-variable-price']; |
282 | 282 | |
283 | 283 | // Update payment give form meta data. |
284 | - $payment->update_meta( '_give_payment_price_id', $data['give-variable-price'] ); |
|
285 | - $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
284 | + $payment->update_meta('_give_payment_price_id', $data['give-variable-price']); |
|
285 | + $payment->update_meta('_give_payment_meta', $payment_meta); |
|
286 | 286 | |
287 | 287 | // Re setup payment to update new meta value in object. |
288 | - $payment->update_payment_setup( $payment->ID ); |
|
288 | + $payment->update_payment_setup($payment->ID); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | /** |
@@ -295,13 +295,13 @@ discard block |
||
295 | 295 | * |
296 | 296 | * @param int $payment_id The ID of the payment. |
297 | 297 | */ |
298 | - do_action( 'give_updated_edited_purchase', $payment_id ); |
|
298 | + do_action('give_updated_edited_purchase', $payment_id); |
|
299 | 299 | |
300 | - wp_safe_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&give-message=payment-updated&id=' . $payment_id ) ); |
|
300 | + wp_safe_redirect(admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&give-message=payment-updated&id='.$payment_id)); |
|
301 | 301 | exit; |
302 | 302 | } |
303 | 303 | |
304 | -add_action( 'give_update_payment_details', 'give_update_payment_details' ); |
|
304 | +add_action('give_update_payment_details', 'give_update_payment_details'); |
|
305 | 305 | |
306 | 306 | /** |
307 | 307 | * Trigger a Purchase Deletion |
@@ -312,48 +312,48 @@ discard block |
||
312 | 312 | * |
313 | 313 | * @return void |
314 | 314 | */ |
315 | -function give_trigger_purchase_delete( $data ) { |
|
316 | - if ( wp_verify_nonce( $data['_wpnonce'], 'give_payment_nonce' ) ) { |
|
315 | +function give_trigger_purchase_delete($data) { |
|
316 | + if (wp_verify_nonce($data['_wpnonce'], 'give_payment_nonce')) { |
|
317 | 317 | |
318 | - $payment_id = absint( $data['purchase_id'] ); |
|
318 | + $payment_id = absint($data['purchase_id']); |
|
319 | 319 | |
320 | - if ( ! current_user_can( 'edit_give_payments', $payment_id ) ) { |
|
321 | - wp_die( esc_html__( 'You do not have permission to edit payment records.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
320 | + if ( ! current_user_can('edit_give_payments', $payment_id)) { |
|
321 | + wp_die(esc_html__('You do not have permission to edit payment records.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
322 | 322 | } |
323 | 323 | |
324 | - give_delete_purchase( $payment_id ); |
|
325 | - wp_redirect( admin_url( '/edit.php?post_type=give_forms&page=give-payment-history&give-message=payment_deleted' ) ); |
|
324 | + give_delete_purchase($payment_id); |
|
325 | + wp_redirect(admin_url('/edit.php?post_type=give_forms&page=give-payment-history&give-message=payment_deleted')); |
|
326 | 326 | give_die(); |
327 | 327 | } |
328 | 328 | } |
329 | 329 | |
330 | -add_action( 'give_delete_payment', 'give_trigger_purchase_delete' ); |
|
330 | +add_action('give_delete_payment', 'give_trigger_purchase_delete'); |
|
331 | 331 | |
332 | 332 | /** |
333 | 333 | * AJAX Store Payment Note |
334 | 334 | */ |
335 | 335 | function give_ajax_store_payment_note() { |
336 | 336 | |
337 | - $payment_id = absint( $_POST['payment_id'] ); |
|
338 | - $note = wp_kses( $_POST['note'], array() ); |
|
337 | + $payment_id = absint($_POST['payment_id']); |
|
338 | + $note = wp_kses($_POST['note'], array()); |
|
339 | 339 | |
340 | - if ( ! current_user_can( 'edit_give_payments', $payment_id ) ) { |
|
341 | - wp_die( esc_html__( 'You do not have permission to edit payment records.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
340 | + if ( ! current_user_can('edit_give_payments', $payment_id)) { |
|
341 | + wp_die(esc_html__('You do not have permission to edit payment records.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
342 | 342 | } |
343 | 343 | |
344 | - if ( empty( $payment_id ) ) { |
|
345 | - die( '-1' ); |
|
344 | + if (empty($payment_id)) { |
|
345 | + die('-1'); |
|
346 | 346 | } |
347 | 347 | |
348 | - if ( empty( $note ) ) { |
|
349 | - die( '-1' ); |
|
348 | + if (empty($note)) { |
|
349 | + die('-1'); |
|
350 | 350 | } |
351 | 351 | |
352 | - $note_id = give_insert_payment_note( $payment_id, $note ); |
|
353 | - die( give_get_payment_note_html( $note_id ) ); |
|
352 | + $note_id = give_insert_payment_note($payment_id, $note); |
|
353 | + die(give_get_payment_note_html($note_id)); |
|
354 | 354 | } |
355 | 355 | |
356 | -add_action( 'wp_ajax_give_insert_payment_note', 'give_ajax_store_payment_note' ); |
|
356 | +add_action('wp_ajax_give_insert_payment_note', 'give_ajax_store_payment_note'); |
|
357 | 357 | |
358 | 358 | /** |
359 | 359 | * Triggers a payment note deletion without ajax |
@@ -364,24 +364,24 @@ discard block |
||
364 | 364 | * |
365 | 365 | * @return void |
366 | 366 | */ |
367 | -function give_trigger_payment_note_deletion( $data ) { |
|
367 | +function give_trigger_payment_note_deletion($data) { |
|
368 | 368 | |
369 | - if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_delete_payment_note_' . $data['note_id'] ) ) { |
|
369 | + if ( ! wp_verify_nonce($data['_wpnonce'], 'give_delete_payment_note_'.$data['note_id'])) { |
|
370 | 370 | return; |
371 | 371 | } |
372 | 372 | |
373 | - if ( ! current_user_can( 'edit_give_payments', $data['payment_id'] ) ) { |
|
374 | - wp_die( esc_html__( 'You do not have permission to edit payment records.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
373 | + if ( ! current_user_can('edit_give_payments', $data['payment_id'])) { |
|
374 | + wp_die(esc_html__('You do not have permission to edit payment records.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
375 | 375 | } |
376 | 376 | |
377 | - $edit_order_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&give-message=payment-note-deleted&id=' . absint( $data['payment_id'] ) ); |
|
377 | + $edit_order_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&give-message=payment-note-deleted&id='.absint($data['payment_id'])); |
|
378 | 378 | |
379 | - give_delete_payment_note( $data['note_id'], $data['payment_id'] ); |
|
379 | + give_delete_payment_note($data['note_id'], $data['payment_id']); |
|
380 | 380 | |
381 | - wp_redirect( $edit_order_url ); |
|
381 | + wp_redirect($edit_order_url); |
|
382 | 382 | } |
383 | 383 | |
384 | -add_action( 'give_delete_payment_note', 'give_trigger_payment_note_deletion' ); |
|
384 | +add_action('give_delete_payment_note', 'give_trigger_payment_note_deletion'); |
|
385 | 385 | |
386 | 386 | /** |
387 | 387 | * Delete a payment note deletion with ajax |
@@ -392,16 +392,16 @@ discard block |
||
392 | 392 | */ |
393 | 393 | function give_ajax_delete_payment_note() { |
394 | 394 | |
395 | - if ( ! current_user_can( 'edit_give_payments', $_POST['payment_id'] ) ) { |
|
396 | - wp_die( esc_html__( 'You do not have permission to edit payment records.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
395 | + if ( ! current_user_can('edit_give_payments', $_POST['payment_id'])) { |
|
396 | + wp_die(esc_html__('You do not have permission to edit payment records.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
397 | 397 | } |
398 | 398 | |
399 | - if ( give_delete_payment_note( $_POST['note_id'], $_POST['payment_id'] ) ) { |
|
400 | - die( '1' ); |
|
399 | + if (give_delete_payment_note($_POST['note_id'], $_POST['payment_id'])) { |
|
400 | + die('1'); |
|
401 | 401 | } else { |
402 | - die( '-1' ); |
|
402 | + die('-1'); |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | } |
406 | 406 | |
407 | -add_action( 'wp_ajax_give_delete_payment_note', 'give_ajax_delete_payment_note' ); |
|
408 | 407 | \ No newline at end of file |
408 | +add_action('wp_ajax_give_delete_payment_note', 'give_ajax_delete_payment_note'); |
|
409 | 409 | \ No newline at end of file |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -38,16 +38,16 @@ discard block |
||
38 | 38 | * @return void |
39 | 39 | */ |
40 | 40 | public function headers() { |
41 | - ignore_user_abort( true ); |
|
41 | + ignore_user_abort(true); |
|
42 | 42 | |
43 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
44 | - set_time_limit( 0 ); |
|
43 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
44 | + set_time_limit(0); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | nocache_headers(); |
48 | - header( 'Content-Type: text/csv; charset=utf-8' ); |
|
49 | - header( 'Content-Disposition: attachment; filename=' . apply_filters( 'give_earnings_export_filename', 'give-export-' . $this->export_type . '-' . date( 'n' ) . '-' . date( 'Y' ) ) . '.csv' ); |
|
50 | - header( "Expires: 0" ); |
|
48 | + header('Content-Type: text/csv; charset=utf-8'); |
|
49 | + header('Content-Disposition: attachment; filename='.apply_filters('give_earnings_export_filename', 'give-export-'.$this->export_type.'-'.date('n').'-'.date('Y')).'.csv'); |
|
50 | + header("Expires: 0"); |
|
51 | 51 | |
52 | 52 | } |
53 | 53 | |
@@ -61,10 +61,10 @@ discard block |
||
61 | 61 | public function csv_cols() { |
62 | 62 | |
63 | 63 | $cols = array( |
64 | - 'date' => esc_html__( 'Date', 'give' ), |
|
65 | - 'donations' => esc_html__( 'Donations', 'give' ), |
|
64 | + 'date' => esc_html__('Date', 'give'), |
|
65 | + 'donations' => esc_html__('Donations', 'give'), |
|
66 | 66 | /* translators: %s: currency */ |
67 | - 'earnings' => sprintf( esc_html__( 'Income (%s)', 'give' ), html_entity_decode( give_currency_filter( '' ) ) ) |
|
67 | + 'earnings' => sprintf(esc_html__('Income (%s)', 'give'), html_entity_decode(give_currency_filter(''))) |
|
68 | 68 | ); |
69 | 69 | |
70 | 70 | return $cols; |
@@ -79,28 +79,28 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function get_data() { |
81 | 81 | |
82 | - $start_year = isset( $_POST['start_year'] ) ? absint( $_POST['start_year'] ) : date( 'Y' ); |
|
83 | - $end_year = isset( $_POST['end_year'] ) ? absint( $_POST['end_year'] ) : date( 'Y' ); |
|
84 | - $start_month = isset( $_POST['start_month'] ) ? absint( $_POST['start_month'] ) : date( 'n' ); |
|
85 | - $end_month = isset( $_POST['end_month'] ) ? absint( $_POST['end_month'] ) : date( 'n' ); |
|
82 | + $start_year = isset($_POST['start_year']) ? absint($_POST['start_year']) : date('Y'); |
|
83 | + $end_year = isset($_POST['end_year']) ? absint($_POST['end_year']) : date('Y'); |
|
84 | + $start_month = isset($_POST['start_month']) ? absint($_POST['start_month']) : date('n'); |
|
85 | + $end_month = isset($_POST['end_month']) ? absint($_POST['end_month']) : date('n'); |
|
86 | 86 | |
87 | 87 | $data = array(); |
88 | 88 | $year = $start_year; |
89 | 89 | $stats = new Give_Payment_Stats; |
90 | 90 | |
91 | - while ( $year <= $end_year ) { |
|
91 | + while ($year <= $end_year) { |
|
92 | 92 | |
93 | - if ( $year == $start_year && $year == $end_year ) { |
|
93 | + if ($year == $start_year && $year == $end_year) { |
|
94 | 94 | |
95 | 95 | $m1 = $start_month; |
96 | 96 | $m2 = $end_month; |
97 | 97 | |
98 | - } elseif ( $year == $start_year ) { |
|
98 | + } elseif ($year == $start_year) { |
|
99 | 99 | |
100 | 100 | $m1 = $start_month; |
101 | 101 | $m2 = 12; |
102 | 102 | |
103 | - } elseif ( $year == $end_year ) { |
|
103 | + } elseif ($year == $end_year) { |
|
104 | 104 | |
105 | 105 | $m1 = 1; |
106 | 106 | $m2 = $end_month; |
@@ -112,28 +112,28 @@ discard block |
||
112 | 112 | |
113 | 113 | } |
114 | 114 | |
115 | - while ( $m1 <= $m2 ) { |
|
115 | + while ($m1 <= $m2) { |
|
116 | 116 | |
117 | - $date1 = mktime( 0, 0, 0, $m1, 1, $year ); |
|
118 | - $date2 = mktime( 0, 0, 0, $m1, cal_days_in_month( CAL_GREGORIAN, $m1, $year ), $year ); |
|
117 | + $date1 = mktime(0, 0, 0, $m1, 1, $year); |
|
118 | + $date2 = mktime(0, 0, 0, $m1, cal_days_in_month(CAL_GREGORIAN, $m1, $year), $year); |
|
119 | 119 | |
120 | 120 | $data[] = array( |
121 | - 'date' => date_i18n( 'F Y', $date1 ), |
|
122 | - 'donations' => $stats->get_sales( 0, $date1, $date2 ), |
|
123 | - 'earnings' => give_format_amount( $stats->get_earnings( 0, $date1, $date2 ) ), |
|
121 | + 'date' => date_i18n('F Y', $date1), |
|
122 | + 'donations' => $stats->get_sales(0, $date1, $date2), |
|
123 | + 'earnings' => give_format_amount($stats->get_earnings(0, $date1, $date2)), |
|
124 | 124 | ); |
125 | 125 | |
126 | - $m1 ++; |
|
126 | + $m1++; |
|
127 | 127 | |
128 | 128 | } |
129 | 129 | |
130 | 130 | |
131 | - $year ++; |
|
131 | + $year++; |
|
132 | 132 | |
133 | 133 | } |
134 | 134 | |
135 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
136 | - $data = apply_filters( 'give_export_get_data_' . $this->export_type, $data ); |
|
135 | + $data = apply_filters('give_export_get_data', $data); |
|
136 | + $data = apply_filters('give_export_get_data_'.$this->export_type, $data); |
|
137 | 137 | |
138 | 138 | return $data; |
139 | 139 | } |
@@ -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,15 +23,15 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return array $output Response messages |
25 | 25 | */ |
26 | -function give_edit_customer( $args ) { |
|
26 | +function give_edit_customer($args) { |
|
27 | 27 | |
28 | - $customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' ); |
|
28 | + $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments'); |
|
29 | 29 | |
30 | - if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) { |
|
31 | - wp_die( esc_html__( 'You do not have permission to edit this donor.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
30 | + if ( ! is_admin() || ! current_user_can($customer_edit_role)) { |
|
31 | + wp_die(esc_html__('You do not have permission to edit this donor.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
32 | 32 | } |
33 | 33 | |
34 | - if ( empty( $args ) ) { |
|
34 | + if (empty($args)) { |
|
35 | 35 | return; |
36 | 36 | } |
37 | 37 | |
@@ -39,12 +39,12 @@ discard block |
||
39 | 39 | $customer_id = (int) $args['customerinfo']['id']; |
40 | 40 | $nonce = $args['_wpnonce']; |
41 | 41 | |
42 | - if ( ! wp_verify_nonce( $nonce, 'edit-customer' ) ) { |
|
43 | - wp_die( esc_html__( 'Cheatin\' eh?!', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
42 | + if ( ! wp_verify_nonce($nonce, 'edit-customer')) { |
|
43 | + wp_die(esc_html__('Cheatin\' eh?!', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
44 | 44 | } |
45 | 45 | |
46 | - $customer = new Give_Customer( $customer_id ); |
|
47 | - if ( empty( $customer->id ) ) { |
|
46 | + $customer = new Give_Customer($customer_id); |
|
47 | + if (empty($customer->id)) { |
|
48 | 48 | return false; |
49 | 49 | } |
50 | 50 | |
@@ -54,23 +54,23 @@ discard block |
||
54 | 54 | 'user_id' => 0 |
55 | 55 | ); |
56 | 56 | |
57 | - $customer_info = wp_parse_args( $customer_info, $defaults ); |
|
57 | + $customer_info = wp_parse_args($customer_info, $defaults); |
|
58 | 58 | |
59 | - if ( ! is_email( $customer_info['email'] ) ) { |
|
60 | - give_set_error( 'give-invalid-email', esc_html__( 'Please enter a valid email address.', 'give' ) ); |
|
59 | + if ( ! is_email($customer_info['email'])) { |
|
60 | + give_set_error('give-invalid-email', esc_html__('Please enter a valid email address.', 'give')); |
|
61 | 61 | } |
62 | 62 | |
63 | - if ( (int) $customer_info['user_id'] != (int) $customer->user_id ) { |
|
63 | + if ((int) $customer_info['user_id'] != (int) $customer->user_id) { |
|
64 | 64 | |
65 | 65 | // Make sure we don't already have this user attached to a customer |
66 | - if ( ! empty( $customer_info['user_id'] ) && false !== Give()->customers->get_customer_by( 'user_id', $customer_info['user_id'] ) ) { |
|
67 | - give_set_error( 'give-invalid-customer-user_id', sprintf( esc_html__( 'The User ID %d is already associated with a different donor.', 'give' ), $customer_info['user_id'] ) ); |
|
66 | + if ( ! empty($customer_info['user_id']) && false !== Give()->customers->get_customer_by('user_id', $customer_info['user_id'])) { |
|
67 | + give_set_error('give-invalid-customer-user_id', sprintf(esc_html__('The User ID %d is already associated with a different donor.', 'give'), $customer_info['user_id'])); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | // Make sure it's actually a user |
71 | - $user = get_user_by( 'id', $customer_info['user_id'] ); |
|
72 | - if ( ! empty( $customer_info['user_id'] ) && false === $user ) { |
|
73 | - give_set_error( 'give-invalid-user_id', sprintf( esc_html__( 'The User ID %d does not exist. Please assign an existing user.', 'give' ), $customer_info['user_id'] ) ); |
|
71 | + $user = get_user_by('id', $customer_info['user_id']); |
|
72 | + if ( ! empty($customer_info['user_id']) && false === $user) { |
|
73 | + give_set_error('give-invalid-user_id', sprintf(esc_html__('The User ID %d does not exist. Please assign an existing user.', 'give'), $customer_info['user_id'])); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | } |
@@ -78,53 +78,53 @@ discard block |
||
78 | 78 | // Record this for later |
79 | 79 | $previous_user_id = $customer->user_id; |
80 | 80 | |
81 | - if ( give_get_errors() ) { |
|
81 | + if (give_get_errors()) { |
|
82 | 82 | return; |
83 | 83 | } |
84 | 84 | |
85 | 85 | // Setup the customer address, if present |
86 | 86 | $address = array(); |
87 | - if ( intval( $customer_info['user_id'] ) > 0 ) { |
|
87 | + if (intval($customer_info['user_id']) > 0) { |
|
88 | 88 | |
89 | - $current_address = get_user_meta( $customer_info['user_id'], '_give_user_address', true ); |
|
89 | + $current_address = get_user_meta($customer_info['user_id'], '_give_user_address', true); |
|
90 | 90 | |
91 | - if ( false === $current_address ) { |
|
92 | - $address['line1'] = isset( $customer_info['line1'] ) ? $customer_info['line1'] : ''; |
|
93 | - $address['line2'] = isset( $customer_info['line2'] ) ? $customer_info['line2'] : ''; |
|
94 | - $address['city'] = isset( $customer_info['city'] ) ? $customer_info['city'] : ''; |
|
95 | - $address['country'] = isset( $customer_info['country'] ) ? $customer_info['country'] : ''; |
|
96 | - $address['zip'] = isset( $customer_info['zip'] ) ? $customer_info['zip'] : ''; |
|
97 | - $address['state'] = isset( $customer_info['state'] ) ? $customer_info['state'] : ''; |
|
91 | + if (false === $current_address) { |
|
92 | + $address['line1'] = isset($customer_info['line1']) ? $customer_info['line1'] : ''; |
|
93 | + $address['line2'] = isset($customer_info['line2']) ? $customer_info['line2'] : ''; |
|
94 | + $address['city'] = isset($customer_info['city']) ? $customer_info['city'] : ''; |
|
95 | + $address['country'] = isset($customer_info['country']) ? $customer_info['country'] : ''; |
|
96 | + $address['zip'] = isset($customer_info['zip']) ? $customer_info['zip'] : ''; |
|
97 | + $address['state'] = isset($customer_info['state']) ? $customer_info['state'] : ''; |
|
98 | 98 | } else { |
99 | - $current_address = wp_parse_args( $current_address, array( |
|
99 | + $current_address = wp_parse_args($current_address, array( |
|
100 | 100 | 'line1', |
101 | 101 | 'line2', |
102 | 102 | 'city', |
103 | 103 | 'zip', |
104 | 104 | 'state', |
105 | 105 | 'country' |
106 | - ) ); |
|
107 | - $address['line1'] = isset( $customer_info['line1'] ) ? $customer_info['line1'] : $current_address['line1']; |
|
108 | - $address['line2'] = isset( $customer_info['line2'] ) ? $customer_info['line2'] : $current_address['line2']; |
|
109 | - $address['city'] = isset( $customer_info['city'] ) ? $customer_info['city'] : $current_address['city']; |
|
110 | - $address['country'] = isset( $customer_info['country'] ) ? $customer_info['country'] : $current_address['country']; |
|
111 | - $address['zip'] = isset( $customer_info['zip'] ) ? $customer_info['zip'] : $current_address['zip']; |
|
112 | - $address['state'] = isset( $customer_info['state'] ) ? $customer_info['state'] : $current_address['state']; |
|
106 | + )); |
|
107 | + $address['line1'] = isset($customer_info['line1']) ? $customer_info['line1'] : $current_address['line1']; |
|
108 | + $address['line2'] = isset($customer_info['line2']) ? $customer_info['line2'] : $current_address['line2']; |
|
109 | + $address['city'] = isset($customer_info['city']) ? $customer_info['city'] : $current_address['city']; |
|
110 | + $address['country'] = isset($customer_info['country']) ? $customer_info['country'] : $current_address['country']; |
|
111 | + $address['zip'] = isset($customer_info['zip']) ? $customer_info['zip'] : $current_address['zip']; |
|
112 | + $address['state'] = isset($customer_info['state']) ? $customer_info['state'] : $current_address['state']; |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | } |
116 | 116 | |
117 | 117 | // Sanitize the inputs |
118 | 118 | $customer_data = array(); |
119 | - $customer_data['name'] = strip_tags( stripslashes( $customer_info['name'] ) ); |
|
119 | + $customer_data['name'] = strip_tags(stripslashes($customer_info['name'])); |
|
120 | 120 | $customer_data['email'] = $customer_info['email']; |
121 | 121 | $customer_data['user_id'] = $customer_info['user_id']; |
122 | 122 | |
123 | - $customer_data = apply_filters( 'give_edit_customer_info', $customer_data, $customer_id ); |
|
124 | - $address = apply_filters( 'give_edit_customer_address', $address, $customer_id ); |
|
123 | + $customer_data = apply_filters('give_edit_customer_info', $customer_data, $customer_id); |
|
124 | + $address = apply_filters('give_edit_customer_address', $address, $customer_id); |
|
125 | 125 | |
126 | - $customer_data = array_map( 'sanitize_text_field', $customer_data ); |
|
127 | - $address = array_map( 'sanitize_text_field', $address ); |
|
126 | + $customer_data = array_map('sanitize_text_field', $customer_data); |
|
127 | + $address = array_map('sanitize_text_field', $address); |
|
128 | 128 | |
129 | 129 | |
130 | 130 | /** |
@@ -136,34 +136,34 @@ discard block |
||
136 | 136 | * @param array $customer_data The customer data. |
137 | 137 | * @param array $address The customer address. |
138 | 138 | */ |
139 | - do_action( 'give_pre_edit_customer', $customer_id, $customer_data, $address ); |
|
139 | + do_action('give_pre_edit_customer', $customer_id, $customer_data, $address); |
|
140 | 140 | |
141 | 141 | $output = array(); |
142 | 142 | $previous_email = $customer->email; |
143 | 143 | |
144 | - if ( $customer->update( $customer_data ) ) { |
|
144 | + if ($customer->update($customer_data)) { |
|
145 | 145 | |
146 | - if ( ! empty( $customer->user_id ) && $customer->user_id > 0 ) { |
|
147 | - update_user_meta( $customer->user_id, '_give_user_address', $address ); |
|
146 | + if ( ! empty($customer->user_id) && $customer->user_id > 0) { |
|
147 | + update_user_meta($customer->user_id, '_give_user_address', $address); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | // Update some payment meta if we need to |
151 | - $payments_array = explode( ',', $customer->payment_ids ); |
|
151 | + $payments_array = explode(',', $customer->payment_ids); |
|
152 | 152 | |
153 | - if ( $customer->email != $previous_email ) { |
|
154 | - foreach ( $payments_array as $payment_id ) { |
|
155 | - give_update_payment_meta( $payment_id, 'email', $customer->email ); |
|
153 | + if ($customer->email != $previous_email) { |
|
154 | + foreach ($payments_array as $payment_id) { |
|
155 | + give_update_payment_meta($payment_id, 'email', $customer->email); |
|
156 | 156 | } |
157 | 157 | } |
158 | 158 | |
159 | - if ( $customer->user_id != $previous_user_id ) { |
|
160 | - foreach ( $payments_array as $payment_id ) { |
|
161 | - give_update_payment_meta( $payment_id, '_give_payment_user_id', $customer->user_id ); |
|
159 | + if ($customer->user_id != $previous_user_id) { |
|
160 | + foreach ($payments_array as $payment_id) { |
|
161 | + give_update_payment_meta($payment_id, '_give_payment_user_id', $customer->user_id); |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | |
165 | 165 | $output['success'] = true; |
166 | - $customer_data = array_merge( $customer_data, $address ); |
|
166 | + $customer_data = array_merge($customer_data, $address); |
|
167 | 167 | $output['customer_info'] = $customer_data; |
168 | 168 | |
169 | 169 | } else { |
@@ -180,11 +180,11 @@ discard block |
||
180 | 180 | * @param int $customer_id The ID of the customer. |
181 | 181 | * @param array $customer_data The customer data. |
182 | 182 | */ |
183 | - do_action( 'give_post_edit_customer', $customer_id, $customer_data ); |
|
183 | + do_action('give_post_edit_customer', $customer_id, $customer_data); |
|
184 | 184 | |
185 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
186 | - header( 'Content-Type: application/json' ); |
|
187 | - echo json_encode( $output ); |
|
185 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
186 | + header('Content-Type: application/json'); |
|
187 | + echo json_encode($output); |
|
188 | 188 | wp_die(); |
189 | 189 | } |
190 | 190 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | |
193 | 193 | } |
194 | 194 | |
195 | -add_action( 'give_edit-customer', 'give_edit_customer', 10, 1 ); |
|
195 | +add_action('give_edit-customer', 'give_edit_customer', 10, 1); |
|
196 | 196 | |
197 | 197 | /** |
198 | 198 | * Save a customer note being added |
@@ -203,36 +203,36 @@ discard block |
||
203 | 203 | * |
204 | 204 | * @return int The Note ID that was saved, or 0 if nothing was saved |
205 | 205 | */ |
206 | -function give_customer_save_note( $args ) { |
|
206 | +function give_customer_save_note($args) { |
|
207 | 207 | |
208 | - $customer_view_role = apply_filters( 'give_view_customers_role', 'view_give_reports' ); |
|
208 | + $customer_view_role = apply_filters('give_view_customers_role', 'view_give_reports'); |
|
209 | 209 | |
210 | - if ( ! is_admin() || ! current_user_can( $customer_view_role ) ) { |
|
211 | - wp_die( esc_html__( 'You do not have permission to edit this donor.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
210 | + if ( ! is_admin() || ! current_user_can($customer_view_role)) { |
|
211 | + wp_die(esc_html__('You do not have permission to edit this donor.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
212 | 212 | } |
213 | 213 | |
214 | - if ( empty( $args ) ) { |
|
214 | + if (empty($args)) { |
|
215 | 215 | return; |
216 | 216 | } |
217 | 217 | |
218 | - $customer_note = trim( sanitize_text_field( $args['customer_note'] ) ); |
|
218 | + $customer_note = trim(sanitize_text_field($args['customer_note'])); |
|
219 | 219 | $customer_id = (int) $args['customer_id']; |
220 | 220 | $nonce = $args['add_customer_note_nonce']; |
221 | 221 | |
222 | - if ( ! wp_verify_nonce( $nonce, 'add-customer-note' ) ) { |
|
223 | - wp_die( esc_html__( 'Cheatin\' eh?!', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
222 | + if ( ! wp_verify_nonce($nonce, 'add-customer-note')) { |
|
223 | + wp_die(esc_html__('Cheatin\' eh?!', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
224 | 224 | } |
225 | 225 | |
226 | - if ( empty( $customer_note ) ) { |
|
227 | - give_set_error( 'empty-customer-note', esc_html__( 'A note is required.', 'give' ) ); |
|
226 | + if (empty($customer_note)) { |
|
227 | + give_set_error('empty-customer-note', esc_html__('A note is required.', 'give')); |
|
228 | 228 | } |
229 | 229 | |
230 | - if ( give_get_errors() ) { |
|
230 | + if (give_get_errors()) { |
|
231 | 231 | return; |
232 | 232 | } |
233 | 233 | |
234 | - $customer = new Give_Customer( $customer_id ); |
|
235 | - $new_note = $customer->add_note( $customer_note ); |
|
234 | + $customer = new Give_Customer($customer_id); |
|
235 | + $new_note = $customer->add_note($customer_note); |
|
236 | 236 | |
237 | 237 | /** |
238 | 238 | * Fires before inserting customer note. |
@@ -242,22 +242,22 @@ discard block |
||
242 | 242 | * @param int $customer_id The ID of the customer. |
243 | 243 | * @param string $new_note Note content. |
244 | 244 | */ |
245 | - do_action( 'give_pre_insert_customer_note', $customer_id, $new_note ); |
|
245 | + do_action('give_pre_insert_customer_note', $customer_id, $new_note); |
|
246 | 246 | |
247 | - if ( ! empty( $new_note ) && ! empty( $customer->id ) ) { |
|
247 | + if ( ! empty($new_note) && ! empty($customer->id)) { |
|
248 | 248 | |
249 | 249 | ob_start(); |
250 | 250 | ?> |
251 | 251 | <div class="customer-note-wrapper dashboard-comment-wrap comment-item"> |
252 | 252 | <span class="note-content-wrap"> |
253 | - <?php echo stripslashes( $new_note ); ?> |
|
253 | + <?php echo stripslashes($new_note); ?> |
|
254 | 254 | </span> |
255 | 255 | </div> |
256 | 256 | <?php |
257 | 257 | $output = ob_get_contents(); |
258 | 258 | ob_end_clean(); |
259 | 259 | |
260 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
260 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
261 | 261 | echo $output; |
262 | 262 | exit; |
263 | 263 | } |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | |
271 | 271 | } |
272 | 272 | |
273 | -add_action( 'give_add-customer-note', 'give_customer_save_note', 10, 1 ); |
|
273 | +add_action('give_add-customer-note', 'give_customer_save_note', 10, 1); |
|
274 | 274 | |
275 | 275 | /** |
276 | 276 | * Delete a customer |
@@ -281,37 +281,37 @@ discard block |
||
281 | 281 | * |
282 | 282 | * @return int Whether it was a successful deletion |
283 | 283 | */ |
284 | -function give_customer_delete( $args ) { |
|
284 | +function give_customer_delete($args) { |
|
285 | 285 | |
286 | - $customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' ); |
|
286 | + $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments'); |
|
287 | 287 | |
288 | - if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) { |
|
289 | - wp_die( esc_html__( 'You do not have permission to delete donors.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
288 | + if ( ! is_admin() || ! current_user_can($customer_edit_role)) { |
|
289 | + wp_die(esc_html__('You do not have permission to delete donors.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
290 | 290 | } |
291 | 291 | |
292 | - if ( empty( $args ) ) { |
|
292 | + if (empty($args)) { |
|
293 | 293 | return; |
294 | 294 | } |
295 | 295 | |
296 | 296 | $customer_id = (int) $args['customer_id']; |
297 | - $confirm = ! empty( $args['give-customer-delete-confirm'] ) ? true : false; |
|
298 | - $remove_data = ! empty( $args['give-customer-delete-records'] ) ? true : false; |
|
297 | + $confirm = ! empty($args['give-customer-delete-confirm']) ? true : false; |
|
298 | + $remove_data = ! empty($args['give-customer-delete-records']) ? true : false; |
|
299 | 299 | $nonce = $args['_wpnonce']; |
300 | 300 | |
301 | - if ( ! wp_verify_nonce( $nonce, 'delete-customer' ) ) { |
|
302 | - wp_die( esc_html__( 'Cheatin\' eh?!', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
301 | + if ( ! wp_verify_nonce($nonce, 'delete-customer')) { |
|
302 | + wp_die(esc_html__('Cheatin\' eh?!', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
303 | 303 | } |
304 | 304 | |
305 | - if ( ! $confirm ) { |
|
306 | - give_set_error( 'customer-delete-no-confirm', esc_html__( 'Please confirm you want to delete this donor.', 'give' ) ); |
|
305 | + if ( ! $confirm) { |
|
306 | + give_set_error('customer-delete-no-confirm', esc_html__('Please confirm you want to delete this donor.', 'give')); |
|
307 | 307 | } |
308 | 308 | |
309 | - if ( give_get_errors() ) { |
|
310 | - wp_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer_id ) ); |
|
309 | + if (give_get_errors()) { |
|
310 | + wp_redirect(admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer_id)); |
|
311 | 311 | exit; |
312 | 312 | } |
313 | 313 | |
314 | - $customer = new Give_Customer( $customer_id ); |
|
314 | + $customer = new Give_Customer($customer_id); |
|
315 | 315 | |
316 | 316 | /** |
317 | 317 | * Fires before deleting customer. |
@@ -322,55 +322,55 @@ discard block |
||
322 | 322 | * @param bool $confirm Delete confirmation. |
323 | 323 | * @param bool $remove_data Records delete confirmation. |
324 | 324 | */ |
325 | - do_action( 'give_pre_delete_customer', $customer_id, $confirm, $remove_data ); |
|
325 | + do_action('give_pre_delete_customer', $customer_id, $confirm, $remove_data); |
|
326 | 326 | |
327 | 327 | $success = false; |
328 | 328 | |
329 | - if ( $customer->id > 0 ) { |
|
329 | + if ($customer->id > 0) { |
|
330 | 330 | |
331 | - $payments_array = explode( ',', $customer->payment_ids ); |
|
332 | - $success = Give()->customers->delete( $customer->id ); |
|
331 | + $payments_array = explode(',', $customer->payment_ids); |
|
332 | + $success = Give()->customers->delete($customer->id); |
|
333 | 333 | |
334 | - if ( $success ) { |
|
334 | + if ($success) { |
|
335 | 335 | |
336 | - if ( $remove_data ) { |
|
336 | + if ($remove_data) { |
|
337 | 337 | |
338 | 338 | // Remove all payments, logs, etc |
339 | - foreach ( $payments_array as $payment_id ) { |
|
340 | - give_delete_purchase( $payment_id ); |
|
339 | + foreach ($payments_array as $payment_id) { |
|
340 | + give_delete_purchase($payment_id); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | } else { |
344 | 344 | |
345 | 345 | // Just set the payments to customer_id of 0 |
346 | - foreach ( $payments_array as $payment_id ) { |
|
347 | - give_update_payment_meta( $payment_id, '_give_payment_customer_id', 0 ); |
|
346 | + foreach ($payments_array as $payment_id) { |
|
347 | + give_update_payment_meta($payment_id, '_give_payment_customer_id', 0); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | } |
351 | 351 | |
352 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&give-message=customer-deleted' ); |
|
352 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&give-message=customer-deleted'); |
|
353 | 353 | |
354 | 354 | } else { |
355 | 355 | |
356 | - give_set_error( 'give-donor-delete-failed', esc_html__( 'Error deleting donor.', 'give' ) ); |
|
357 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $customer_id ); |
|
356 | + give_set_error('give-donor-delete-failed', esc_html__('Error deleting donor.', 'give')); |
|
357 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$customer_id); |
|
358 | 358 | |
359 | 359 | } |
360 | 360 | |
361 | 361 | } else { |
362 | 362 | |
363 | - give_set_error( 'give-customer-delete-invalid-id', esc_html__( 'Invalid Donor ID.', 'give' ) ); |
|
364 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors' ); |
|
363 | + give_set_error('give-customer-delete-invalid-id', esc_html__('Invalid Donor ID.', 'give')); |
|
364 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors'); |
|
365 | 365 | |
366 | 366 | } |
367 | 367 | |
368 | - wp_redirect( $redirect ); |
|
368 | + wp_redirect($redirect); |
|
369 | 369 | exit; |
370 | 370 | |
371 | 371 | } |
372 | 372 | |
373 | -add_action( 'give_delete-customer', 'give_customer_delete', 10, 1 ); |
|
373 | +add_action('give_delete-customer', 'give_customer_delete', 10, 1); |
|
374 | 374 | |
375 | 375 | /** |
376 | 376 | * Disconnect a user ID from a donor |
@@ -381,27 +381,27 @@ discard block |
||
381 | 381 | * |
382 | 382 | * @return bool If the disconnect was successful |
383 | 383 | */ |
384 | -function give_disconnect_customer_user_id( $args ) { |
|
384 | +function give_disconnect_customer_user_id($args) { |
|
385 | 385 | |
386 | - $customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' ); |
|
386 | + $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments'); |
|
387 | 387 | |
388 | - if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) { |
|
389 | - wp_die( esc_html__( 'You do not have permission to edit this donor.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
388 | + if ( ! is_admin() || ! current_user_can($customer_edit_role)) { |
|
389 | + wp_die(esc_html__('You do not have permission to edit this donor.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
390 | 390 | } |
391 | 391 | |
392 | - if ( empty( $args ) ) { |
|
392 | + if (empty($args)) { |
|
393 | 393 | return; |
394 | 394 | } |
395 | 395 | |
396 | 396 | $customer_id = (int) $args['customer_id']; |
397 | 397 | $nonce = $args['_wpnonce']; |
398 | 398 | |
399 | - if ( ! wp_verify_nonce( $nonce, 'edit-customer' ) ) { |
|
400 | - wp_die( esc_html__( 'Cheatin\' eh?!', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
399 | + if ( ! wp_verify_nonce($nonce, 'edit-customer')) { |
|
400 | + wp_die(esc_html__('Cheatin\' eh?!', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
401 | 401 | } |
402 | 402 | |
403 | - $customer = new Give_Customer( $customer_id ); |
|
404 | - if ( empty( $customer->id ) ) { |
|
403 | + $customer = new Give_Customer($customer_id); |
|
404 | + if (empty($customer->id)) { |
|
405 | 405 | return false; |
406 | 406 | } |
407 | 407 | |
@@ -415,15 +415,15 @@ discard block |
||
415 | 415 | * @param int $customer_id The ID of the customer. |
416 | 416 | * @param int $user_id The ID of the user. |
417 | 417 | */ |
418 | - do_action( 'give_pre_customer_disconnect_user_id', $customer_id, $user_id ); |
|
418 | + do_action('give_pre_customer_disconnect_user_id', $customer_id, $user_id); |
|
419 | 419 | |
420 | - $customer_args = array( 'user_id' => 0 ); |
|
420 | + $customer_args = array('user_id' => 0); |
|
421 | 421 | |
422 | - if ( $customer->update( $customer_args ) ) { |
|
422 | + if ($customer->update($customer_args)) { |
|
423 | 423 | global $wpdb; |
424 | 424 | |
425 | - if ( ! empty( $customer->payment_ids ) ) { |
|
426 | - $wpdb->query( "UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $customer->payment_ids )" ); |
|
425 | + if ( ! empty($customer->payment_ids)) { |
|
426 | + $wpdb->query("UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $customer->payment_ids )"); |
|
427 | 427 | } |
428 | 428 | |
429 | 429 | $output['success'] = true; |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | } else { |
432 | 432 | |
433 | 433 | $output['success'] = false; |
434 | - give_set_error( 'give-disconnect-user-fail', esc_html__( 'Failed to disconnect user from donor.', 'give' ) ); |
|
434 | + give_set_error('give-disconnect-user-fail', esc_html__('Failed to disconnect user from donor.', 'give')); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | /** |
@@ -441,11 +441,11 @@ discard block |
||
441 | 441 | * |
442 | 442 | * @param int $customer_id The ID of the customer. |
443 | 443 | */ |
444 | - do_action( 'give_post_customer_disconnect_user_id', $customer_id ); |
|
444 | + do_action('give_post_customer_disconnect_user_id', $customer_id); |
|
445 | 445 | |
446 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
447 | - header( 'Content-Type: application/json' ); |
|
448 | - echo json_encode( $output ); |
|
446 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
447 | + header('Content-Type: application/json'); |
|
448 | + echo json_encode($output); |
|
449 | 449 | wp_die(); |
450 | 450 | } |
451 | 451 | |
@@ -453,4 +453,4 @@ discard block |
||
453 | 453 | |
454 | 454 | } |
455 | 455 | |
456 | -add_action( 'give_disconnect-userid', 'give_disconnect_customer_user_id', 10, 1 ); |
|
456 | +add_action('give_disconnect-userid', 'give_disconnect_customer_user_id', 10, 1); |