@@ -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,17 +162,17 @@ 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 | - if ( empty( $url ) ) { |
|
170 | - wp_safe_redirect( home_url() ); |
|
169 | + if (empty($url)) { |
|
170 | + wp_safe_redirect(home_url()); |
|
171 | 171 | give_die(); |
172 | 172 | } |
173 | 173 | |
174 | - if ( isset( $_POST['give-form-id'] ) ) { |
|
175 | - $form_id = sanitize_text_field( $_POST['give-form-id'] ); |
|
174 | + if (isset($_POST['give-form-id'])) { |
|
175 | + $form_id = sanitize_text_field($_POST['give-form-id']); |
|
176 | 176 | } else { |
177 | 177 | $form_id = 0; |
178 | 178 | } |
@@ -182,18 +182,18 @@ discard block |
||
182 | 182 | ); |
183 | 183 | |
184 | 184 | // Check for backward compatibility. |
185 | - if ( is_string( $args ) ) { |
|
186 | - $args = str_replace( '?', '', $args ); |
|
185 | + if (is_string($args)) { |
|
186 | + $args = str_replace('?', '', $args); |
|
187 | 187 | } |
188 | 188 | |
189 | - $args = wp_parse_args( $args, $defaults ); |
|
189 | + $args = wp_parse_args($args, $defaults); |
|
190 | 190 | |
191 | 191 | // Merge URL query with $args to maintain third-party URL parameters after redirect. |
192 | - $url_data = wp_parse_url( $url ); |
|
192 | + $url_data = wp_parse_url($url); |
|
193 | 193 | |
194 | 194 | //Check if an array to prevent notices before parsing. |
195 | - if ( isset( $url_data['query'] ) && ! empty( $url_data['query'] ) ) { |
|
196 | - parse_str( $url_data['query'], $query ); |
|
195 | + if (isset($url_data['query']) && ! empty($url_data['query'])) { |
|
196 | + parse_str($url_data['query'], $query); |
|
197 | 197 | |
198 | 198 | //Precaution: don't allow any CC info. |
199 | 199 | unset($query['card_number']); |
@@ -204,13 +204,13 @@ discard block |
||
204 | 204 | $query = array(); |
205 | 205 | } |
206 | 206 | |
207 | - $new_query = array_merge( $args, $query ); |
|
208 | - $new_query_string = http_build_query( $new_query ); |
|
207 | + $new_query = array_merge($args, $query); |
|
208 | + $new_query_string = http_build_query($new_query); |
|
209 | 209 | |
210 | 210 | // Assemble URL parts. |
211 | - $redirect = home_url( '/' . $url_data['path'] . '?' . $new_query_string . '#give-form-' . $form_id . '-wrap' ); |
|
211 | + $redirect = home_url('/'.$url_data['path'].'?'.$new_query_string.'#give-form-'.$form_id.'-wrap'); |
|
212 | 212 | |
213 | - wp_safe_redirect( apply_filters( 'give_send_back_to_checkout', $redirect, $args ) ); |
|
213 | + wp_safe_redirect(apply_filters('give_send_back_to_checkout', $redirect, $args)); |
|
214 | 214 | give_die(); |
215 | 215 | } |
216 | 216 | |
@@ -225,16 +225,16 @@ discard block |
||
225 | 225 | * @since 1.0 |
226 | 226 | * @return string |
227 | 227 | */ |
228 | -function give_get_success_page_url( $query_string = null ) { |
|
228 | +function give_get_success_page_url($query_string = null) { |
|
229 | 229 | |
230 | - $success_page = give_get_option( 'success_page', 0 ); |
|
231 | - $success_page = get_permalink( $success_page ); |
|
230 | + $success_page = give_get_option('success_page', 0); |
|
231 | + $success_page = get_permalink($success_page); |
|
232 | 232 | |
233 | - if ( $query_string ) { |
|
233 | + if ($query_string) { |
|
234 | 234 | $success_page .= $query_string; |
235 | 235 | } |
236 | 236 | |
237 | - return apply_filters( 'give_success_page_url', $success_page ); |
|
237 | + return apply_filters('give_success_page_url', $success_page); |
|
238 | 238 | |
239 | 239 | } |
240 | 240 | |
@@ -248,15 +248,15 @@ discard block |
||
248 | 248 | * |
249 | 249 | * @return mixed|void Full URL to the Transaction Failed page, if present, home page if it doesn't exist |
250 | 250 | */ |
251 | -function give_get_failed_transaction_uri( $extras = false ) { |
|
251 | +function give_get_failed_transaction_uri($extras = false) { |
|
252 | 252 | global $give_options; |
253 | 253 | |
254 | - $uri = ! empty( $give_options['failure_page'] ) ? trailingslashit( get_permalink( $give_options['failure_page'] ) ) : home_url(); |
|
255 | - if ( $extras ) { |
|
254 | + $uri = ! empty($give_options['failure_page']) ? trailingslashit(get_permalink($give_options['failure_page'])) : home_url(); |
|
255 | + if ($extras) { |
|
256 | 256 | $uri .= $extras; |
257 | 257 | } |
258 | 258 | |
259 | - return apply_filters( 'give_get_failed_transaction_uri', $uri ); |
|
259 | + return apply_filters('give_get_failed_transaction_uri', $uri); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | /** |
@@ -267,9 +267,9 @@ discard block |
||
267 | 267 | */ |
268 | 268 | function give_is_failed_transaction_page() { |
269 | 269 | global $give_options; |
270 | - $ret = isset( $give_options['failure_page'] ) ? is_page( $give_options['failure_page'] ) : false; |
|
270 | + $ret = isset($give_options['failure_page']) ? is_page($give_options['failure_page']) : false; |
|
271 | 271 | |
272 | - return apply_filters( 'give_is_failure_page', $ret ); |
|
272 | + return apply_filters('give_is_failure_page', $ret); |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | /** |
@@ -281,18 +281,18 @@ discard block |
||
281 | 281 | */ |
282 | 282 | function give_listen_for_failed_payments() { |
283 | 283 | |
284 | - $failed_page = give_get_option( 'failure_page', 0 ); |
|
284 | + $failed_page = give_get_option('failure_page', 0); |
|
285 | 285 | |
286 | - if ( ! empty( $failed_page ) && is_page( $failed_page ) && ! empty( $_GET['payment-id'] ) ) { |
|
286 | + if ( ! empty($failed_page) && is_page($failed_page) && ! empty($_GET['payment-id'])) { |
|
287 | 287 | |
288 | - $payment_id = absint( $_GET['payment-id'] ); |
|
289 | - give_update_payment_status( $payment_id, 'failed' ); |
|
288 | + $payment_id = absint($_GET['payment-id']); |
|
289 | + give_update_payment_status($payment_id, 'failed'); |
|
290 | 290 | |
291 | 291 | } |
292 | 292 | |
293 | 293 | } |
294 | 294 | |
295 | -add_action( 'template_redirect', 'give_listen_for_failed_payments' ); |
|
295 | +add_action('template_redirect', 'give_listen_for_failed_payments'); |
|
296 | 296 | |
297 | 297 | |
298 | 298 | /** |
@@ -305,11 +305,11 @@ discard block |
||
305 | 305 | * @since 1.0 |
306 | 306 | * @return bool |
307 | 307 | */ |
308 | -function give_field_is_required( $field = '', $form_id ) { |
|
308 | +function give_field_is_required($field = '', $form_id) { |
|
309 | 309 | |
310 | - $required_fields = give_purchase_form_required_fields( $form_id ); |
|
310 | + $required_fields = give_purchase_form_required_fields($form_id); |
|
311 | 311 | |
312 | - return array_key_exists( $field, $required_fields ); |
|
312 | + return array_key_exists($field, $required_fields); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | /** |
@@ -327,14 +327,14 @@ discard block |
||
327 | 327 | * |
328 | 328 | * @return void |
329 | 329 | */ |
330 | -function give_record_sale_in_log( $give_form_id = 0, $payment_id, $price_id = false, $sale_date = null ) { |
|
330 | +function give_record_sale_in_log($give_form_id = 0, $payment_id, $price_id = false, $sale_date = null) { |
|
331 | 331 | global $give_logs; |
332 | 332 | |
333 | 333 | $log_data = array( |
334 | 334 | 'post_parent' => $give_form_id, |
335 | 335 | 'log_type' => 'sale', |
336 | - 'post_date' => isset( $sale_date ) ? $sale_date : null, |
|
337 | - 'post_date_gmt' => isset( $sale_date ) ? $sale_date : null |
|
336 | + 'post_date' => isset($sale_date) ? $sale_date : null, |
|
337 | + 'post_date_gmt' => isset($sale_date) ? $sale_date : null |
|
338 | 338 | ); |
339 | 339 | |
340 | 340 | $log_meta = array( |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | 'price_id' => (int) $price_id |
343 | 343 | ); |
344 | 344 | |
345 | - $give_logs->insert_log( $log_data, $log_meta ); |
|
345 | + $give_logs->insert_log($log_data, $log_meta); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | |
@@ -356,11 +356,11 @@ discard block |
||
356 | 356 | * |
357 | 357 | * @return bool|int |
358 | 358 | */ |
359 | -function give_increase_purchase_count( $form_id = 0, $quantity = 1 ) { |
|
359 | +function give_increase_purchase_count($form_id = 0, $quantity = 1) { |
|
360 | 360 | $quantity = (int) $quantity; |
361 | - $form = new Give_Donate_Form( $form_id ); |
|
361 | + $form = new Give_Donate_Form($form_id); |
|
362 | 362 | |
363 | - return $form->increase_sales( $quantity ); |
|
363 | + return $form->increase_sales($quantity); |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | /** |
@@ -373,11 +373,11 @@ discard block |
||
373 | 373 | * |
374 | 374 | * @return bool|int |
375 | 375 | */ |
376 | -function give_decrease_purchase_count( $form_id = 0, $quantity = 1 ) { |
|
376 | +function give_decrease_purchase_count($form_id = 0, $quantity = 1) { |
|
377 | 377 | $quantity = (int) $quantity; |
378 | - $form = new Give_Donate_Form( $form_id ); |
|
378 | + $form = new Give_Donate_Form($form_id); |
|
379 | 379 | |
380 | - return $form->decrease_sales( $quantity ); |
|
380 | + return $form->decrease_sales($quantity); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | /** |
@@ -390,10 +390,10 @@ discard block |
||
390 | 390 | * |
391 | 391 | * @return bool|int |
392 | 392 | */ |
393 | -function give_increase_earnings( $give_form_id = 0, $amount ) { |
|
394 | - $form = new Give_Donate_Form( $give_form_id ); |
|
393 | +function give_increase_earnings($give_form_id = 0, $amount) { |
|
394 | + $form = new Give_Donate_Form($give_form_id); |
|
395 | 395 | |
396 | - return $form->increase_earnings( $amount ); |
|
396 | + return $form->increase_earnings($amount); |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | /** |
@@ -406,10 +406,10 @@ discard block |
||
406 | 406 | * |
407 | 407 | * @return bool|int |
408 | 408 | */ |
409 | -function give_decrease_earnings( $form_id = 0, $amount ) { |
|
410 | - $form = new Give_Donate_Form( $form_id ); |
|
409 | +function give_decrease_earnings($form_id = 0, $amount) { |
|
410 | + $form = new Give_Donate_Form($form_id); |
|
411 | 411 | |
412 | - return $form->decrease_earnings( $amount ); |
|
412 | + return $form->decrease_earnings($amount); |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | |
@@ -422,8 +422,8 @@ discard block |
||
422 | 422 | * |
423 | 423 | * @return int $earnings Earnings for a certain form |
424 | 424 | */ |
425 | -function give_get_form_earnings_stats( $form_id = 0 ) { |
|
426 | - $give_form = new Give_Donate_Form( $form_id ); |
|
425 | +function give_get_form_earnings_stats($form_id = 0) { |
|
426 | + $give_form = new Give_Donate_Form($form_id); |
|
427 | 427 | |
428 | 428 | return $give_form->earnings; |
429 | 429 | } |
@@ -438,8 +438,8 @@ discard block |
||
438 | 438 | * |
439 | 439 | * @return int $sales Amount of sales for a certain form |
440 | 440 | */ |
441 | -function give_get_form_sales_stats( $give_form_id = 0 ) { |
|
442 | - $give_form = new Give_Donate_Form( $give_form_id ); |
|
441 | +function give_get_form_sales_stats($give_form_id = 0) { |
|
442 | + $give_form = new Give_Donate_Form($give_form_id); |
|
443 | 443 | |
444 | 444 | return $give_form->sales; |
445 | 445 | } |
@@ -454,16 +454,16 @@ discard block |
||
454 | 454 | * |
455 | 455 | * @return float $sales Average monthly sales |
456 | 456 | */ |
457 | -function give_get_average_monthly_form_sales( $form_id = 0 ) { |
|
458 | - $sales = give_get_form_sales_stats( $form_id ); |
|
459 | - $release_date = get_post_field( 'post_date', $form_id ); |
|
457 | +function give_get_average_monthly_form_sales($form_id = 0) { |
|
458 | + $sales = give_get_form_sales_stats($form_id); |
|
459 | + $release_date = get_post_field('post_date', $form_id); |
|
460 | 460 | |
461 | - $diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) ); |
|
461 | + $diff = abs(current_time('timestamp') - strtotime($release_date)); |
|
462 | 462 | |
463 | - $months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication |
|
463 | + $months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication |
|
464 | 464 | |
465 | - if ( $months > 0 ) { |
|
466 | - $sales = ( $sales / $months ); |
|
465 | + if ($months > 0) { |
|
466 | + $sales = ($sales / $months); |
|
467 | 467 | } |
468 | 468 | |
469 | 469 | return $sales; |
@@ -479,16 +479,16 @@ discard block |
||
479 | 479 | * |
480 | 480 | * @return float $earnings Average monthly earnings |
481 | 481 | */ |
482 | -function give_get_average_monthly_form_earnings( $form_id = 0 ) { |
|
483 | - $earnings = give_get_form_earnings_stats( $form_id ); |
|
484 | - $release_date = get_post_field( 'post_date', $form_id ); |
|
482 | +function give_get_average_monthly_form_earnings($form_id = 0) { |
|
483 | + $earnings = give_get_form_earnings_stats($form_id); |
|
484 | + $release_date = get_post_field('post_date', $form_id); |
|
485 | 485 | |
486 | - $diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) ); |
|
486 | + $diff = abs(current_time('timestamp') - strtotime($release_date)); |
|
487 | 487 | |
488 | - $months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication |
|
488 | + $months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication |
|
489 | 489 | |
490 | - if ( $months > 0 ) { |
|
491 | - $earnings = ( $earnings / $months ); |
|
490 | + if ($months > 0) { |
|
491 | + $earnings = ($earnings / $months); |
|
492 | 492 | } |
493 | 493 | |
494 | 494 | return $earnings < 0 ? 0 : $earnings; |
@@ -508,25 +508,25 @@ discard block |
||
508 | 508 | * |
509 | 509 | * @return string $price_name Name of the price option |
510 | 510 | */ |
511 | -function give_get_price_option_name( $form_id = 0, $price_id = 0, $payment_id = 0 ) { |
|
511 | +function give_get_price_option_name($form_id = 0, $price_id = 0, $payment_id = 0) { |
|
512 | 512 | |
513 | - $prices = give_get_variable_prices( $form_id ); |
|
513 | + $prices = give_get_variable_prices($form_id); |
|
514 | 514 | $price_name = ''; |
515 | 515 | |
516 | - foreach ( $prices as $price ) { |
|
516 | + foreach ($prices as $price) { |
|
517 | 517 | |
518 | - if ( intval( $price['_give_id']['level_id'] ) == intval( $price_id ) ) { |
|
518 | + if (intval($price['_give_id']['level_id']) == intval($price_id)) { |
|
519 | 519 | |
520 | - $price_text = isset( $price['_give_text'] ) ? $price['_give_text'] : ''; |
|
521 | - $price_fallback = give_currency_filter( give_format_amount( $price['_give_amount'] ) ); |
|
522 | - $price_name = ! empty( $price_text ) ? $price_text : $price_fallback; |
|
520 | + $price_text = isset($price['_give_text']) ? $price['_give_text'] : ''; |
|
521 | + $price_fallback = give_currency_filter(give_format_amount($price['_give_amount'])); |
|
522 | + $price_name = ! empty($price_text) ? $price_text : $price_fallback; |
|
523 | 523 | |
524 | 524 | } |
525 | 525 | |
526 | 526 | } |
527 | 527 | |
528 | 528 | |
529 | - return apply_filters( 'give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id ); |
|
529 | + return apply_filters('give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id); |
|
530 | 530 | } |
531 | 531 | |
532 | 532 | |
@@ -539,14 +539,14 @@ discard block |
||
539 | 539 | * |
540 | 540 | * @return string $range A fully formatted price range |
541 | 541 | */ |
542 | -function give_price_range( $form_id = 0 ) { |
|
543 | - $low = give_get_lowest_price_option( $form_id ); |
|
544 | - $high = give_get_highest_price_option( $form_id ); |
|
545 | - $range = '<span class="give_price_range_low">' . give_currency_filter( give_format_amount( $low ) ) . '</span>'; |
|
542 | +function give_price_range($form_id = 0) { |
|
543 | + $low = give_get_lowest_price_option($form_id); |
|
544 | + $high = give_get_highest_price_option($form_id); |
|
545 | + $range = '<span class="give_price_range_low">'.give_currency_filter(give_format_amount($low)).'</span>'; |
|
546 | 546 | $range .= '<span class="give_price_range_sep"> – </span>'; |
547 | - $range .= '<span class="give_price_range_high">' . give_currency_filter( give_format_amount( $high ) ) . '</span>'; |
|
547 | + $range .= '<span class="give_price_range_high">'.give_currency_filter(give_format_amount($high)).'</span>'; |
|
548 | 548 | |
549 | - return apply_filters( 'give_price_range', $range, $form_id, $low, $high ); |
|
549 | + return apply_filters('give_price_range', $range, $form_id, $low, $high); |
|
550 | 550 | } |
551 | 551 | |
552 | 552 | |
@@ -561,36 +561,36 @@ discard block |
||
561 | 561 | * |
562 | 562 | * @return int ID of the lowest price |
563 | 563 | */ |
564 | -function give_get_lowest_price_id( $form_id = 0 ) { |
|
564 | +function give_get_lowest_price_id($form_id = 0) { |
|
565 | 565 | |
566 | - if ( empty( $form_id ) ) { |
|
566 | + if (empty($form_id)) { |
|
567 | 567 | $form_id = get_the_ID(); |
568 | 568 | } |
569 | 569 | |
570 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
571 | - return give_get_form_price( $form_id ); |
|
570 | + if ( ! give_has_variable_prices($form_id)) { |
|
571 | + return give_get_form_price($form_id); |
|
572 | 572 | } |
573 | 573 | |
574 | - $prices = give_get_variable_prices( $form_id ); |
|
574 | + $prices = give_get_variable_prices($form_id); |
|
575 | 575 | |
576 | 576 | $low = 0.00; |
577 | 577 | $min_id = 1; |
578 | 578 | |
579 | - if ( ! empty( $prices ) ) { |
|
579 | + if ( ! empty($prices)) { |
|
580 | 580 | |
581 | - foreach ( $prices as $key => $price ) { |
|
581 | + foreach ($prices as $key => $price) { |
|
582 | 582 | |
583 | - if ( empty( $price['_give_amount'] ) ) { |
|
583 | + if (empty($price['_give_amount'])) { |
|
584 | 584 | continue; |
585 | 585 | } |
586 | 586 | |
587 | - if ( ! isset( $min ) ) { |
|
587 | + if ( ! isset($min)) { |
|
588 | 588 | $min = $price['_give_amount']; |
589 | 589 | } else { |
590 | - $min = min( $min, $price['_give_amount'] ); |
|
590 | + $min = min($min, $price['_give_amount']); |
|
591 | 591 | } |
592 | 592 | |
593 | - if ( $price['_give_amount'] == $min ) { |
|
593 | + if ($price['_give_amount'] == $min) { |
|
594 | 594 | $min_id = $price['_give_id']['level_id']; |
595 | 595 | } |
596 | 596 | } |
@@ -608,43 +608,43 @@ discard block |
||
608 | 608 | * |
609 | 609 | * @return float Amount of the lowest price |
610 | 610 | */ |
611 | -function give_get_lowest_price_option( $form_id = 0 ) { |
|
612 | - if ( empty( $form_id ) ) { |
|
611 | +function give_get_lowest_price_option($form_id = 0) { |
|
612 | + if (empty($form_id)) { |
|
613 | 613 | $form_id = get_the_ID(); |
614 | 614 | } |
615 | 615 | |
616 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
617 | - return give_get_form_price( $form_id ); |
|
616 | + if ( ! give_has_variable_prices($form_id)) { |
|
617 | + return give_get_form_price($form_id); |
|
618 | 618 | } |
619 | 619 | |
620 | - $prices = give_get_variable_prices( $form_id ); |
|
620 | + $prices = give_get_variable_prices($form_id); |
|
621 | 621 | |
622 | 622 | $low = 0.00; |
623 | 623 | |
624 | - if ( ! empty( $prices ) ) { |
|
624 | + if ( ! empty($prices)) { |
|
625 | 625 | |
626 | - foreach ( $prices as $key => $price ) { |
|
626 | + foreach ($prices as $key => $price) { |
|
627 | 627 | |
628 | - if ( empty( $price['_give_amount'] ) ) { |
|
628 | + if (empty($price['_give_amount'])) { |
|
629 | 629 | continue; |
630 | 630 | } |
631 | 631 | |
632 | - if ( ! isset( $min ) ) { |
|
632 | + if ( ! isset($min)) { |
|
633 | 633 | $min = $price['_give_amount']; |
634 | 634 | } else { |
635 | - $min = min( $min, give_sanitize_amount( $price['_give_amount'] ) ); |
|
635 | + $min = min($min, give_sanitize_amount($price['_give_amount'])); |
|
636 | 636 | } |
637 | 637 | |
638 | - if ( $price['_give_amount'] == $min ) { |
|
638 | + if ($price['_give_amount'] == $min) { |
|
639 | 639 | $min_id = $key; |
640 | 640 | } |
641 | 641 | } |
642 | 642 | |
643 | - $low = $prices[ $min_id ]['_give_amount']; |
|
643 | + $low = $prices[$min_id]['_give_amount']; |
|
644 | 644 | |
645 | 645 | } |
646 | 646 | |
647 | - return give_sanitize_amount( $low ); |
|
647 | + return give_sanitize_amount($low); |
|
648 | 648 | } |
649 | 649 | |
650 | 650 | /** |
@@ -656,41 +656,41 @@ discard block |
||
656 | 656 | * |
657 | 657 | * @return float Amount of the highest price |
658 | 658 | */ |
659 | -function give_get_highest_price_option( $form_id = 0 ) { |
|
659 | +function give_get_highest_price_option($form_id = 0) { |
|
660 | 660 | |
661 | - if ( empty( $form_id ) ) { |
|
661 | + if (empty($form_id)) { |
|
662 | 662 | $form_id = get_the_ID(); |
663 | 663 | } |
664 | 664 | |
665 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
666 | - return give_get_form_price( $form_id ); |
|
665 | + if ( ! give_has_variable_prices($form_id)) { |
|
666 | + return give_get_form_price($form_id); |
|
667 | 667 | } |
668 | 668 | |
669 | - $prices = give_get_variable_prices( $form_id ); |
|
669 | + $prices = give_get_variable_prices($form_id); |
|
670 | 670 | |
671 | 671 | $high = 0.00; |
672 | 672 | |
673 | - if ( ! empty( $prices ) ) { |
|
673 | + if ( ! empty($prices)) { |
|
674 | 674 | |
675 | 675 | $max = 0; |
676 | 676 | |
677 | - foreach ( $prices as $key => $price ) { |
|
678 | - if ( empty( $price['_give_amount'] ) ) { |
|
677 | + foreach ($prices as $key => $price) { |
|
678 | + if (empty($price['_give_amount'])) { |
|
679 | 679 | continue; |
680 | 680 | } |
681 | - $give_amount = give_sanitize_amount( $price['_give_amount'] ); |
|
681 | + $give_amount = give_sanitize_amount($price['_give_amount']); |
|
682 | 682 | |
683 | - $max = max( $max, $give_amount ); |
|
683 | + $max = max($max, $give_amount); |
|
684 | 684 | |
685 | - if ( $give_amount == $max ) { |
|
685 | + if ($give_amount == $max) { |
|
686 | 686 | $max_id = $key; |
687 | 687 | } |
688 | 688 | } |
689 | 689 | |
690 | - $high = $prices[ $max_id ]['_give_amount']; |
|
690 | + $high = $prices[$max_id]['_give_amount']; |
|
691 | 691 | } |
692 | 692 | |
693 | - return give_sanitize_amount( $high ); |
|
693 | + return give_sanitize_amount($high); |
|
694 | 694 | } |
695 | 695 | |
696 | 696 | /** |
@@ -702,15 +702,15 @@ discard block |
||
702 | 702 | * |
703 | 703 | * @return mixed string|int Price of the form |
704 | 704 | */ |
705 | -function give_get_form_price( $form_id = 0 ) { |
|
705 | +function give_get_form_price($form_id = 0) { |
|
706 | 706 | |
707 | - if ( empty( $form_id ) ) { |
|
707 | + if (empty($form_id)) { |
|
708 | 708 | return false; |
709 | 709 | } |
710 | 710 | |
711 | - $form = new Give_Donate_Form( $form_id ); |
|
711 | + $form = new Give_Donate_Form($form_id); |
|
712 | 712 | |
713 | - return $form->__get( 'price' ); |
|
713 | + return $form->__get('price'); |
|
714 | 714 | } |
715 | 715 | |
716 | 716 | /** |
@@ -722,15 +722,15 @@ discard block |
||
722 | 722 | * |
723 | 723 | * @return mixed string|int Minimum price of the form |
724 | 724 | */ |
725 | -function give_get_form_minimum_price( $form_id = 0 ) { |
|
725 | +function give_get_form_minimum_price($form_id = 0) { |
|
726 | 726 | |
727 | - if ( empty( $form_id ) ) { |
|
727 | + if (empty($form_id)) { |
|
728 | 728 | return false; |
729 | 729 | } |
730 | 730 | |
731 | - $form = new Give_Donate_Form( $form_id ); |
|
731 | + $form = new Give_Donate_Form($form_id); |
|
732 | 732 | |
733 | - return $form->__get( 'minimum_price' ); |
|
733 | + return $form->__get('minimum_price'); |
|
734 | 734 | |
735 | 735 | } |
736 | 736 | |
@@ -745,52 +745,52 @@ discard block |
||
745 | 745 | * |
746 | 746 | * @return int $formatted_price |
747 | 747 | */ |
748 | -function give_price( $form_id = 0, $echo = true, $price_id = false ) { |
|
748 | +function give_price($form_id = 0, $echo = true, $price_id = false) { |
|
749 | 749 | |
750 | - if ( empty( $form_id ) ) { |
|
750 | + if (empty($form_id)) { |
|
751 | 751 | $form_id = get_the_ID(); |
752 | 752 | } |
753 | 753 | |
754 | - if ( give_has_variable_prices( $form_id ) ) { |
|
754 | + if (give_has_variable_prices($form_id)) { |
|
755 | 755 | |
756 | - $prices = give_get_variable_prices( $form_id ); |
|
756 | + $prices = give_get_variable_prices($form_id); |
|
757 | 757 | |
758 | - if ( false !== $price_id ) { |
|
758 | + if (false !== $price_id) { |
|
759 | 759 | |
760 | 760 | //loop through multi-prices to see which is default |
761 | - foreach ( $prices as $price ) { |
|
761 | + foreach ($prices as $price) { |
|
762 | 762 | //this is the default price |
763 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
763 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
764 | 764 | $price = (float) $price['_give_amount']; |
765 | 765 | }; |
766 | 766 | } |
767 | 767 | |
768 | 768 | } else { |
769 | 769 | |
770 | - $price = give_get_lowest_price_option( $form_id ); |
|
770 | + $price = give_get_lowest_price_option($form_id); |
|
771 | 771 | } |
772 | 772 | |
773 | - $price = give_sanitize_amount( $price ); |
|
773 | + $price = give_sanitize_amount($price); |
|
774 | 774 | |
775 | 775 | } else { |
776 | 776 | |
777 | - $price = give_get_form_price( $form_id ); |
|
777 | + $price = give_get_form_price($form_id); |
|
778 | 778 | |
779 | 779 | } |
780 | 780 | |
781 | - $price = apply_filters( 'give_form_price', give_sanitize_amount( $price ), $form_id ); |
|
782 | - $formatted_price = '<span class="give_price" id="give_price_' . $form_id . '">' . $price . '</span>'; |
|
783 | - $formatted_price = apply_filters( 'give_form_price_after_html', $formatted_price, $form_id, $price ); |
|
781 | + $price = apply_filters('give_form_price', give_sanitize_amount($price), $form_id); |
|
782 | + $formatted_price = '<span class="give_price" id="give_price_'.$form_id.'">'.$price.'</span>'; |
|
783 | + $formatted_price = apply_filters('give_form_price_after_html', $formatted_price, $form_id, $price); |
|
784 | 784 | |
785 | - if ( $echo ) { |
|
785 | + if ($echo) { |
|
786 | 786 | echo $formatted_price; |
787 | 787 | } else { |
788 | 788 | return $formatted_price; |
789 | 789 | } |
790 | 790 | } |
791 | 791 | |
792 | -add_filter( 'give_form_price', 'give_format_amount', 10 ); |
|
793 | -add_filter( 'give_form_price', 'give_currency_filter', 20 ); |
|
792 | +add_filter('give_form_price', 'give_format_amount', 10); |
|
793 | +add_filter('give_form_price', 'give_currency_filter', 20); |
|
794 | 794 | |
795 | 795 | |
796 | 796 | /** |
@@ -803,19 +803,19 @@ discard block |
||
803 | 803 | * |
804 | 804 | * @return float $amount Amount of the price option |
805 | 805 | */ |
806 | -function give_get_price_option_amount( $form_id = 0, $price_id = 0 ) { |
|
807 | - $prices = give_get_variable_prices( $form_id ); |
|
806 | +function give_get_price_option_amount($form_id = 0, $price_id = 0) { |
|
807 | + $prices = give_get_variable_prices($form_id); |
|
808 | 808 | |
809 | 809 | $amount = 0.00; |
810 | 810 | |
811 | - foreach ( $prices as $price ) { |
|
812 | - if ( isset( $price['_give_id']['level_id'] ) && $price['_give_id']['level_id'] == $price_id ) { |
|
813 | - $amount = isset( $price['_give_amount'] ) ? $price['_give_amount'] : 0.00; |
|
811 | + foreach ($prices as $price) { |
|
812 | + if (isset($price['_give_id']['level_id']) && $price['_give_id']['level_id'] == $price_id) { |
|
813 | + $amount = isset($price['_give_amount']) ? $price['_give_amount'] : 0.00; |
|
814 | 814 | break; |
815 | 815 | }; |
816 | 816 | } |
817 | 817 | |
818 | - return apply_filters( 'give_get_price_option_amount', give_sanitize_amount( $amount ), $form_id, $price_id ); |
|
818 | + return apply_filters('give_get_price_option_amount', give_sanitize_amount($amount), $form_id, $price_id); |
|
819 | 819 | } |
820 | 820 | |
821 | 821 | /** |
@@ -827,13 +827,13 @@ discard block |
||
827 | 827 | * |
828 | 828 | * @return mixed string|int Goal of the form |
829 | 829 | */ |
830 | -function give_get_form_goal( $form_id = 0 ) { |
|
830 | +function give_get_form_goal($form_id = 0) { |
|
831 | 831 | |
832 | - if ( empty( $form_id ) ) { |
|
832 | + if (empty($form_id)) { |
|
833 | 833 | return false; |
834 | 834 | } |
835 | 835 | |
836 | - $form = new Give_Donate_Form( $form_id ); |
|
836 | + $form = new Give_Donate_Form($form_id); |
|
837 | 837 | |
838 | 838 | return $form->goal; |
839 | 839 | |
@@ -849,27 +849,27 @@ discard block |
||
849 | 849 | * |
850 | 850 | * @return string $formatted_goal |
851 | 851 | */ |
852 | -function give_goal( $form_id = 0, $echo = true ) { |
|
852 | +function give_goal($form_id = 0, $echo = true) { |
|
853 | 853 | |
854 | - if ( empty( $form_id ) ) { |
|
854 | + if (empty($form_id)) { |
|
855 | 855 | $form_id = get_the_ID(); |
856 | 856 | } |
857 | 857 | |
858 | - $goal = give_get_form_goal( $form_id ); |
|
858 | + $goal = give_get_form_goal($form_id); |
|
859 | 859 | |
860 | - $goal = apply_filters( 'give_form_goal', give_sanitize_amount( $goal ), $form_id ); |
|
861 | - $formatted_goal = '<span class="give_price" id="give_price_' . $form_id . '">' . $goal . '</span>'; |
|
862 | - $formatted_goal = apply_filters( 'give_form_price_after_html', $formatted_goal, $form_id, $goal ); |
|
860 | + $goal = apply_filters('give_form_goal', give_sanitize_amount($goal), $form_id); |
|
861 | + $formatted_goal = '<span class="give_price" id="give_price_'.$form_id.'">'.$goal.'</span>'; |
|
862 | + $formatted_goal = apply_filters('give_form_price_after_html', $formatted_goal, $form_id, $goal); |
|
863 | 863 | |
864 | - if ( $echo ) { |
|
864 | + if ($echo) { |
|
865 | 865 | echo $formatted_goal; |
866 | 866 | } else { |
867 | 867 | return $formatted_goal; |
868 | 868 | } |
869 | 869 | } |
870 | 870 | |
871 | -add_filter( 'give_form_goal', 'give_format_amount', 10 ); |
|
872 | -add_filter( 'give_form_goal', 'give_currency_filter', 20 ); |
|
871 | +add_filter('give_form_goal', 'give_format_amount', 10); |
|
872 | +add_filter('give_form_goal', 'give_currency_filter', 20); |
|
873 | 873 | |
874 | 874 | |
875 | 875 | /** |
@@ -883,13 +883,13 @@ discard block |
||
883 | 883 | * |
884 | 884 | * @return bool $ret Whether or not the logged_in_only setting is set |
885 | 885 | */ |
886 | -function give_logged_in_only( $form_id ) { |
|
886 | +function give_logged_in_only($form_id) { |
|
887 | 887 | |
888 | - $form_option = get_post_meta( $form_id, '_give_logged_in_only', true ); |
|
888 | + $form_option = get_post_meta($form_id, '_give_logged_in_only', true); |
|
889 | 889 | |
890 | - $ret = ! empty( $form_option ) ? $form_option : false; |
|
890 | + $ret = ! empty($form_option) ? $form_option : false; |
|
891 | 891 | |
892 | - return (bool) apply_filters( 'give_logged_in_only', $ret, $form_id ); |
|
892 | + return (bool) apply_filters('give_logged_in_only', $ret, $form_id); |
|
893 | 893 | |
894 | 894 | } |
895 | 895 | |
@@ -903,10 +903,10 @@ discard block |
||
903 | 903 | * |
904 | 904 | * @return string |
905 | 905 | */ |
906 | -function give_show_login_register_option( $form_id ) { |
|
906 | +function give_show_login_register_option($form_id) { |
|
907 | 907 | |
908 | - $show_register_form = get_post_meta( $form_id, '_give_show_register_form', true ); |
|
908 | + $show_register_form = get_post_meta($form_id, '_give_show_register_form', true); |
|
909 | 909 | |
910 | - return apply_filters( 'give_show_register_form', $show_register_form, $form_id ); |
|
910 | + return apply_filters('give_show_register_form', $show_register_form, $form_id); |
|
911 | 911 | |
912 | 912 | } |
913 | 913 | \ No newline at end of file |