@@ -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 = give_get_meta( $args['form_id'], '_give_form_floating_labels', true ); |
|
70 | + if (empty($float_labels)) { |
|
71 | + $float_labels = give_get_meta($args['form_id'], '_give_form_floating_labels', true); |
|
72 | 72 | } |
73 | 73 | |
74 | - if ( empty( $float_labels ) || ( 'global' === $float_labels ) ) { |
|
75 | - $float_labels = give_get_option( 'floatlabels', 'disabled' ); |
|
74 | + if (empty($float_labels) || ('global' === $float_labels)) { |
|
75 | + $float_labels = give_get_option('floatlabels', 'disabled'); |
|
76 | 76 | } |
77 | 77 | |
78 | - return give_is_setting_enabled( $float_labels ); |
|
78 | + return give_is_setting_enabled($float_labels); |
|
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 | $give_options = give_get_settings(); |
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 | /** |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * @return bool True if on the Success page, false otherwise. |
119 | 119 | */ |
120 | 120 | function give_is_success_page() { |
121 | - return apply_filters( 'give_is_success_page', is_page( give_get_success_page_uri() ) ); |
|
121 | + return apply_filters('give_is_success_page', is_page(give_get_success_page_uri())); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -132,17 +132,17 @@ discard block |
||
132 | 132 | * @since 1.0 |
133 | 133 | * @return void |
134 | 134 | */ |
135 | -function give_send_to_success_page( $query_string = null ) { |
|
135 | +function give_send_to_success_page($query_string = null) { |
|
136 | 136 | |
137 | 137 | $redirect = give_get_success_page_uri(); |
138 | 138 | |
139 | - if ( $query_string ) { |
|
139 | + if ($query_string) { |
|
140 | 140 | $redirect .= $query_string; |
141 | 141 | } |
142 | 142 | |
143 | - $gateway = isset( $_REQUEST['give-gateway'] ) ? $_REQUEST['give-gateway'] : ''; |
|
143 | + $gateway = isset($_REQUEST['give-gateway']) ? $_REQUEST['give-gateway'] : ''; |
|
144 | 144 | |
145 | - wp_redirect( apply_filters( 'give_success_page_redirect', $redirect, $gateway, $query_string ) ); |
|
145 | + wp_redirect(apply_filters('give_success_page_redirect', $redirect, $gateway, $query_string)); |
|
146 | 146 | give_die(); |
147 | 147 | } |
148 | 148 | |
@@ -158,19 +158,19 @@ discard block |
||
158 | 158 | * @since 1.0 |
159 | 159 | * @return Void |
160 | 160 | */ |
161 | -function give_send_back_to_checkout( $args = array() ) { |
|
161 | +function give_send_back_to_checkout($args = array()) { |
|
162 | 162 | |
163 | - $url = isset( $_POST['give-current-url'] ) ? sanitize_text_field( $_POST['give-current-url'] ) : ''; |
|
163 | + $url = isset($_POST['give-current-url']) ? sanitize_text_field($_POST['give-current-url']) : ''; |
|
164 | 164 | $form_id = 0; |
165 | 165 | |
166 | 166 | // Set the form_id. |
167 | - if ( isset( $_POST['give-form-id'] ) ) { |
|
168 | - $form_id = sanitize_text_field( $_POST['give-form-id'] ); |
|
167 | + if (isset($_POST['give-form-id'])) { |
|
168 | + $form_id = sanitize_text_field($_POST['give-form-id']); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | // Need a URL to continue. If none, redirect back to single form. |
172 | - if ( empty( $url ) ) { |
|
173 | - wp_safe_redirect( get_permalink( $form_id ) ); |
|
172 | + if (empty($url)) { |
|
173 | + wp_safe_redirect(get_permalink($form_id)); |
|
174 | 174 | give_die(); |
175 | 175 | } |
176 | 176 | |
@@ -179,41 +179,41 @@ discard block |
||
179 | 179 | ); |
180 | 180 | |
181 | 181 | // Set the $level_id. |
182 | - if ( isset( $_POST['give-price-id'] ) ) { |
|
183 | - $defaults['level-id'] = sanitize_text_field( $_POST['give-price-id'] ); |
|
182 | + if (isset($_POST['give-price-id'])) { |
|
183 | + $defaults['level-id'] = sanitize_text_field($_POST['give-price-id']); |
|
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 | |
@@ -251,32 +251,31 @@ discard block |
||
251 | 251 | * |
252 | 252 | * @return mixed Full URL to the Failed Donation Page, if present, home page if it doesn't exist. |
253 | 253 | */ |
254 | -function give_get_failed_transaction_uri( $extras = false ) { |
|
254 | +function give_get_failed_transaction_uri($extras = false) { |
|
255 | 255 | $give_options = give_get_settings(); |
256 | 256 | |
257 | 257 | // Remove question mark. |
258 | - if ( 0 === strpos( $extras, '?' ) ) { |
|
259 | - $extras = substr( $extras, 1 ); |
|
258 | + if (0 === strpos($extras, '?')) { |
|
259 | + $extras = substr($extras, 1); |
|
260 | 260 | } |
261 | 261 | |
262 | - $extras_args = wp_parse_args( $extras ); |
|
262 | + $extras_args = wp_parse_args($extras); |
|
263 | 263 | |
264 | 264 | // Set nonce if payment id exist in extra params. |
265 | - if ( array_key_exists( 'payment-id', $extras_args ) ) { |
|
266 | - $extras_args['_wpnonce'] = wp_create_nonce( "give-failed-donation-{$extras_args['payment-id']}" ); |
|
267 | - $extras = http_build_query( $extras_args ); |
|
265 | + if (array_key_exists('payment-id', $extras_args)) { |
|
266 | + $extras_args['_wpnonce'] = wp_create_nonce("give-failed-donation-{$extras_args['payment-id']}"); |
|
267 | + $extras = http_build_query($extras_args); |
|
268 | 268 | } |
269 | 269 | |
270 | - $uri = ! empty( $give_options['failure_page'] ) ? |
|
271 | - trailingslashit( get_permalink( $give_options['failure_page'] ) ) : |
|
272 | - home_url(); |
|
270 | + $uri = ! empty($give_options['failure_page']) ? |
|
271 | + trailingslashit(get_permalink($give_options['failure_page'])) : home_url(); |
|
273 | 272 | |
274 | 273 | |
275 | - if ( $extras ) { |
|
274 | + if ($extras) { |
|
276 | 275 | $uri .= "?{$extras}"; |
277 | 276 | } |
278 | 277 | |
279 | - return apply_filters( 'give_get_failed_transaction_uri', $uri ); |
|
278 | + return apply_filters('give_get_failed_transaction_uri', $uri); |
|
280 | 279 | } |
281 | 280 | |
282 | 281 | /** |
@@ -287,9 +286,9 @@ discard block |
||
287 | 286 | */ |
288 | 287 | function give_is_failed_transaction_page() { |
289 | 288 | $give_options = give_get_settings(); |
290 | - $ret = isset( $give_options['failure_page'] ) ? is_page( $give_options['failure_page'] ) : false; |
|
289 | + $ret = isset($give_options['failure_page']) ? is_page($give_options['failure_page']) : false; |
|
291 | 290 | |
292 | - return apply_filters( 'give_is_failure_page', $ret ); |
|
291 | + return apply_filters('give_is_failure_page', $ret); |
|
293 | 292 | } |
294 | 293 | |
295 | 294 | /** |
@@ -302,25 +301,25 @@ discard block |
||
302 | 301 | */ |
303 | 302 | function give_listen_for_failed_payments() { |
304 | 303 | |
305 | - $failed_page = give_get_option( 'failure_page', 0 ); |
|
306 | - $payment_id = ! empty( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : 0; |
|
307 | - $nonce = ! empty( $_GET['_wpnonce'] ) ? give_clean( $_GET['_wpnonce'] ) : false; |
|
304 | + $failed_page = give_get_option('failure_page', 0); |
|
305 | + $payment_id = ! empty($_GET['payment-id']) ? absint($_GET['payment-id']) : 0; |
|
306 | + $nonce = ! empty($_GET['_wpnonce']) ? give_clean($_GET['_wpnonce']) : false; |
|
308 | 307 | |
309 | 308 | // Bailout. |
310 | - if ( ! $failed_page || ! is_page( $failed_page ) || ! $payment_id || ! $nonce ) { |
|
309 | + if ( ! $failed_page || ! is_page($failed_page) || ! $payment_id || ! $nonce) { |
|
311 | 310 | return false; |
312 | 311 | } |
313 | 312 | |
314 | 313 | // Security check. |
315 | - if ( ! wp_verify_nonce( $nonce, "give-failed-donation-{$payment_id}" ) ) { |
|
316 | - wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ) ); |
|
314 | + if ( ! wp_verify_nonce($nonce, "give-failed-donation-{$payment_id}")) { |
|
315 | + wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give')); |
|
317 | 316 | } |
318 | 317 | |
319 | 318 | // Set payment status to failure |
320 | - give_update_payment_status( $payment_id, 'failed' ); |
|
319 | + give_update_payment_status($payment_id, 'failed'); |
|
321 | 320 | } |
322 | 321 | |
323 | -add_action( 'template_redirect', 'give_listen_for_failed_payments' ); |
|
322 | +add_action('template_redirect', 'give_listen_for_failed_payments'); |
|
324 | 323 | |
325 | 324 | /** |
326 | 325 | * Retrieve the Donation History page URI |
@@ -333,9 +332,9 @@ discard block |
||
333 | 332 | function give_get_history_page_uri() { |
334 | 333 | $give_options = give_get_settings(); |
335 | 334 | |
336 | - $history_page = isset( $give_options['history_page'] ) ? get_permalink( absint( $give_options['history_page'] ) ) : get_bloginfo( 'url' ); |
|
335 | + $history_page = isset($give_options['history_page']) ? get_permalink(absint($give_options['history_page'])) : get_bloginfo('url'); |
|
337 | 336 | |
338 | - return apply_filters( 'give_get_history_page_uri', $history_page ); |
|
337 | + return apply_filters('give_get_history_page_uri', $history_page); |
|
339 | 338 | } |
340 | 339 | |
341 | 340 | /** |
@@ -348,11 +347,11 @@ discard block |
||
348 | 347 | * @since 1.0 |
349 | 348 | * @return bool |
350 | 349 | */ |
351 | -function give_field_is_required( $field = '', $form_id ) { |
|
350 | +function give_field_is_required($field = '', $form_id) { |
|
352 | 351 | |
353 | - $required_fields = give_get_required_fields( $form_id ); |
|
352 | + $required_fields = give_get_required_fields($form_id); |
|
354 | 353 | |
355 | - return array_key_exists( $field, $required_fields ); |
|
354 | + return array_key_exists($field, $required_fields); |
|
356 | 355 | } |
357 | 356 | |
358 | 357 | /** |
@@ -369,12 +368,12 @@ discard block |
||
369 | 368 | * |
370 | 369 | * @return void |
371 | 370 | */ |
372 | -function give_record_donation_in_log( $give_form_id = 0, $payment_id, $price_id = false, $donation_date = null ) { |
|
371 | +function give_record_donation_in_log($give_form_id = 0, $payment_id, $price_id = false, $donation_date = null) { |
|
373 | 372 | $log_data = array( |
374 | 373 | 'log_parent' => $payment_id, |
375 | 374 | 'log_type' => 'sale', |
376 | - 'log_date' => isset( $donation_date ) ? $donation_date : null, |
|
377 | - 'log_date_gmt' => isset( $donation_date ) ? $donation_date : null, |
|
375 | + 'log_date' => isset($donation_date) ? $donation_date : null, |
|
376 | + 'log_date_gmt' => isset($donation_date) ? $donation_date : null, |
|
378 | 377 | ); |
379 | 378 | |
380 | 379 | $log_meta = array( |
@@ -382,7 +381,7 @@ discard block |
||
382 | 381 | 'price_id' => (int) $price_id, |
383 | 382 | ); |
384 | 383 | |
385 | - Give()->logs->insert_log( $log_data, $log_meta ); |
|
384 | + Give()->logs->insert_log($log_data, $log_meta); |
|
386 | 385 | } |
387 | 386 | |
388 | 387 | |
@@ -396,13 +395,13 @@ discard block |
||
396 | 395 | * |
397 | 396 | * @return bool|int |
398 | 397 | */ |
399 | -function give_increase_donation_count( $form_id = 0, $quantity = 1 ) { |
|
398 | +function give_increase_donation_count($form_id = 0, $quantity = 1) { |
|
400 | 399 | $quantity = (int) $quantity; |
401 | 400 | |
402 | 401 | /** @var \Give_Donate_Form $form */ |
403 | - $form = new Give_Donate_Form( $form_id ); |
|
402 | + $form = new Give_Donate_Form($form_id); |
|
404 | 403 | |
405 | - return $form->increase_sales( $quantity ); |
|
404 | + return $form->increase_sales($quantity); |
|
406 | 405 | } |
407 | 406 | |
408 | 407 | /** |
@@ -415,13 +414,13 @@ discard block |
||
415 | 414 | * |
416 | 415 | * @return bool|int |
417 | 416 | */ |
418 | -function give_decrease_donation_count( $form_id = 0, $quantity = 1 ) { |
|
417 | +function give_decrease_donation_count($form_id = 0, $quantity = 1) { |
|
419 | 418 | $quantity = (int) $quantity; |
420 | 419 | |
421 | 420 | /** @var \Give_Donate_Form $form */ |
422 | - $form = new Give_Donate_Form( $form_id ); |
|
421 | + $form = new Give_Donate_Form($form_id); |
|
423 | 422 | |
424 | - return $form->decrease_sales( $quantity ); |
|
423 | + return $form->decrease_sales($quantity); |
|
425 | 424 | } |
426 | 425 | |
427 | 426 | /** |
@@ -437,11 +436,11 @@ discard block |
||
437 | 436 | * |
438 | 437 | * @return bool|int |
439 | 438 | */ |
440 | -function give_increase_earnings( $give_form_id = 0, $amount, $payment_id = 0 ) { |
|
439 | +function give_increase_earnings($give_form_id = 0, $amount, $payment_id = 0) { |
|
441 | 440 | /** @var \Give_Donate_Form $form */ |
442 | - $form = new Give_Donate_Form( $give_form_id ); |
|
441 | + $form = new Give_Donate_Form($give_form_id); |
|
443 | 442 | |
444 | - return $form->increase_earnings( $amount, $payment_id ); |
|
443 | + return $form->increase_earnings($amount, $payment_id); |
|
445 | 444 | } |
446 | 445 | |
447 | 446 | /** |
@@ -459,11 +458,11 @@ discard block |
||
459 | 458 | * |
460 | 459 | * @return bool|int |
461 | 460 | */ |
462 | -function give_decrease_form_earnings( $form_id = 0, $amount, $payment_id = 0 ) { |
|
461 | +function give_decrease_form_earnings($form_id = 0, $amount, $payment_id = 0) { |
|
463 | 462 | /** @var \Give_Donate_Form $form */ |
464 | - $form = new Give_Donate_Form( $form_id ); |
|
463 | + $form = new Give_Donate_Form($form_id); |
|
465 | 464 | |
466 | - return $form->decrease_earnings( $amount, $payment_id ); |
|
465 | + return $form->decrease_earnings($amount, $payment_id); |
|
467 | 466 | } |
468 | 467 | |
469 | 468 | |
@@ -476,15 +475,15 @@ discard block |
||
476 | 475 | * |
477 | 476 | * @return int $earnings Earnings for a certain form |
478 | 477 | */ |
479 | -function give_get_form_earnings_stats( $form_id = 0 ) { |
|
480 | - $give_form = new Give_Donate_Form( $form_id ); |
|
478 | +function give_get_form_earnings_stats($form_id = 0) { |
|
479 | + $give_form = new Give_Donate_Form($form_id); |
|
481 | 480 | |
482 | 481 | /** |
483 | 482 | * Filter the form earnings |
484 | 483 | * |
485 | 484 | * @since 1.8.17 |
486 | 485 | */ |
487 | - return apply_filters( 'give_get_form_earnings_stats', $give_form->earnings, $form_id, $give_form ); |
|
486 | + return apply_filters('give_get_form_earnings_stats', $give_form->earnings, $form_id, $give_form); |
|
488 | 487 | } |
489 | 488 | |
490 | 489 | |
@@ -497,8 +496,8 @@ discard block |
||
497 | 496 | * |
498 | 497 | * @return int $sales Amount of sales for a certain form |
499 | 498 | */ |
500 | -function give_get_form_sales_stats( $give_form_id = 0 ) { |
|
501 | - $give_form = new Give_Donate_Form( $give_form_id ); |
|
499 | +function give_get_form_sales_stats($give_form_id = 0) { |
|
500 | + $give_form = new Give_Donate_Form($give_form_id); |
|
502 | 501 | |
503 | 502 | return $give_form->sales; |
504 | 503 | } |
@@ -513,16 +512,16 @@ discard block |
||
513 | 512 | * |
514 | 513 | * @return float $sales Average monthly sales |
515 | 514 | */ |
516 | -function give_get_average_monthly_form_sales( $form_id = 0 ) { |
|
517 | - $sales = give_get_form_sales_stats( $form_id ); |
|
518 | - $release_date = get_post_field( 'post_date', $form_id ); |
|
515 | +function give_get_average_monthly_form_sales($form_id = 0) { |
|
516 | + $sales = give_get_form_sales_stats($form_id); |
|
517 | + $release_date = get_post_field('post_date', $form_id); |
|
519 | 518 | |
520 | - $diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) ); |
|
519 | + $diff = abs(current_time('timestamp') - strtotime($release_date)); |
|
521 | 520 | |
522 | - $months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication |
|
521 | + $months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication |
|
523 | 522 | |
524 | - if ( $months > 0 ) { |
|
525 | - $sales = ( $sales / $months ); |
|
523 | + if ($months > 0) { |
|
524 | + $sales = ($sales / $months); |
|
526 | 525 | } |
527 | 526 | |
528 | 527 | return $sales; |
@@ -538,16 +537,16 @@ discard block |
||
538 | 537 | * |
539 | 538 | * @return float $earnings Average monthly earnings |
540 | 539 | */ |
541 | -function give_get_average_monthly_form_earnings( $form_id = 0 ) { |
|
542 | - $earnings = give_get_form_earnings_stats( $form_id ); |
|
543 | - $release_date = get_post_field( 'post_date', $form_id ); |
|
540 | +function give_get_average_monthly_form_earnings($form_id = 0) { |
|
541 | + $earnings = give_get_form_earnings_stats($form_id); |
|
542 | + $release_date = get_post_field('post_date', $form_id); |
|
544 | 543 | |
545 | - $diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) ); |
|
544 | + $diff = abs(current_time('timestamp') - strtotime($release_date)); |
|
546 | 545 | |
547 | - $months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication |
|
546 | + $months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication |
|
548 | 547 | |
549 | - if ( $months > 0 ) { |
|
550 | - $earnings = ( $earnings / $months ); |
|
548 | + if ($months > 0) { |
|
549 | + $earnings = ($earnings / $months); |
|
551 | 550 | } |
552 | 551 | |
553 | 552 | return $earnings < 0 ? 0 : $earnings; |
@@ -568,34 +567,34 @@ discard block |
||
568 | 567 | * |
569 | 568 | * @return string $price_name Name of the price option |
570 | 569 | */ |
571 | -function give_get_price_option_name( $form_id = 0, $price_id = 0, $payment_id = 0, $use_fallback = true ) { |
|
570 | +function give_get_price_option_name($form_id = 0, $price_id = 0, $payment_id = 0, $use_fallback = true) { |
|
572 | 571 | |
573 | - $prices = give_get_variable_prices( $form_id ); |
|
572 | + $prices = give_get_variable_prices($form_id); |
|
574 | 573 | $price_name = ''; |
575 | 574 | |
576 | - if ( false === $prices ) { |
|
575 | + if (false === $prices) { |
|
577 | 576 | return $price_name; |
578 | 577 | } |
579 | 578 | |
580 | - foreach ( $prices as $price ) { |
|
579 | + foreach ($prices as $price) { |
|
581 | 580 | |
582 | - if ( intval( $price['_give_id']['level_id'] ) === intval( $price_id ) ) { |
|
581 | + if (intval($price['_give_id']['level_id']) === intval($price_id)) { |
|
583 | 582 | |
584 | - $price_text = isset( $price['_give_text'] ) ? $price['_give_text'] : ''; |
|
583 | + $price_text = isset($price['_give_text']) ? $price['_give_text'] : ''; |
|
585 | 584 | $price_fallback = $use_fallback ? |
586 | 585 | give_currency_filter( |
587 | 586 | give_format_amount( |
588 | 587 | $price['_give_amount'], |
589 | - array( 'sanitize' => false ) |
|
588 | + array('sanitize' => false) |
|
590 | 589 | ), |
591 | - array( 'decode_currency' => true ) |
|
590 | + array('decode_currency' => true) |
|
592 | 591 | ) : ''; |
593 | - $price_name = ! empty( $price_text ) ? $price_text : $price_fallback; |
|
592 | + $price_name = ! empty($price_text) ? $price_text : $price_fallback; |
|
594 | 593 | |
595 | 594 | } |
596 | 595 | } |
597 | 596 | |
598 | - return apply_filters( 'give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id ); |
|
597 | + return apply_filters('give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id); |
|
599 | 598 | } |
600 | 599 | |
601 | 600 | |
@@ -609,25 +608,25 @@ discard block |
||
609 | 608 | * |
610 | 609 | * @return string $range A fully formatted price range |
611 | 610 | */ |
612 | -function give_price_range( $form_id = 0, $formatted = true ) { |
|
613 | - $low = give_get_lowest_price_option( $form_id ); |
|
614 | - $high = give_get_highest_price_option( $form_id ); |
|
615 | - $order_type = ! empty( $_REQUEST['order'] ) ? $_REQUEST['order'] : 'asc'; |
|
611 | +function give_price_range($form_id = 0, $formatted = true) { |
|
612 | + $low = give_get_lowest_price_option($form_id); |
|
613 | + $high = give_get_highest_price_option($form_id); |
|
614 | + $order_type = ! empty($_REQUEST['order']) ? $_REQUEST['order'] : 'asc'; |
|
616 | 615 | |
617 | 616 | $range = sprintf( |
618 | 617 | '<span class="give_price_range_%1$s">%2$s</span><span class="give_price_range_sep"> – </span><span class="give_price_range_%3$s">%4$s</span>', |
619 | 618 | 'asc' === $order_type ? 'low' : 'high', |
620 | - 'asc' === $order_type ? give_currency_filter( give_format_amount( $low, array( 'sanitize' => false ) ) ) : give_currency_filter( give_format_amount( $high, array( 'sanitize' => false ) ) ), |
|
619 | + 'asc' === $order_type ? give_currency_filter(give_format_amount($low, array('sanitize' => false))) : give_currency_filter(give_format_amount($high, array('sanitize' => false))), |
|
621 | 620 | 'asc' === $order_type ? 'high' : 'low', |
622 | - 'asc' === $order_type ? give_currency_filter( give_format_amount( $high, array( 'sanitize' => false ) ) ) : give_currency_filter( give_format_amount( $low, array( 'sanitize' => false ) ) ) |
|
621 | + 'asc' === $order_type ? give_currency_filter(give_format_amount($high, array('sanitize' => false))) : give_currency_filter(give_format_amount($low, array('sanitize' => false))) |
|
623 | 622 | |
624 | 623 | ); |
625 | 624 | |
626 | - if ( ! $formatted ) { |
|
627 | - $range = wp_strip_all_tags( $range ); |
|
625 | + if ( ! $formatted) { |
|
626 | + $range = wp_strip_all_tags($range); |
|
628 | 627 | } |
629 | 628 | |
630 | - return apply_filters( 'give_price_range', $range, $form_id, $low, $high ); |
|
629 | + return apply_filters('give_price_range', $range, $form_id, $low, $high); |
|
631 | 630 | } |
632 | 631 | |
633 | 632 | |
@@ -642,35 +641,35 @@ discard block |
||
642 | 641 | * |
643 | 642 | * @return int ID of the lowest price |
644 | 643 | */ |
645 | -function give_get_lowest_price_id( $form_id = 0 ) { |
|
644 | +function give_get_lowest_price_id($form_id = 0) { |
|
646 | 645 | |
647 | - if ( empty( $form_id ) ) { |
|
646 | + if (empty($form_id)) { |
|
648 | 647 | $form_id = get_the_ID(); |
649 | 648 | } |
650 | 649 | |
651 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
652 | - return give_get_form_price( $form_id ); |
|
650 | + if ( ! give_has_variable_prices($form_id)) { |
|
651 | + return give_get_form_price($form_id); |
|
653 | 652 | } |
654 | 653 | |
655 | - $prices = give_get_variable_prices( $form_id ); |
|
654 | + $prices = give_get_variable_prices($form_id); |
|
656 | 655 | |
657 | 656 | $min = $min_id = 0; |
658 | 657 | |
659 | - if ( ! empty( $prices ) ) { |
|
658 | + if ( ! empty($prices)) { |
|
660 | 659 | |
661 | - foreach ( $prices as $key => $price ) { |
|
660 | + foreach ($prices as $key => $price) { |
|
662 | 661 | |
663 | - if ( empty( $price['_give_amount'] ) ) { |
|
662 | + if (empty($price['_give_amount'])) { |
|
664 | 663 | continue; |
665 | 664 | } |
666 | 665 | |
667 | - if ( ! isset( $min ) ) { |
|
666 | + if ( ! isset($min)) { |
|
668 | 667 | $min = $price['_give_amount']; |
669 | 668 | } else { |
670 | - $min = min( $min, $price['_give_amount'] ); |
|
669 | + $min = min($min, $price['_give_amount']); |
|
671 | 670 | } |
672 | 671 | |
673 | - if ( $price['_give_amount'] == $min ) { |
|
672 | + if ($price['_give_amount'] == $min) { |
|
674 | 673 | $min_id = $price['_give_id']['level_id']; |
675 | 674 | } |
676 | 675 | } |
@@ -688,22 +687,22 @@ discard block |
||
688 | 687 | * |
689 | 688 | * @return float Amount of the lowest price |
690 | 689 | */ |
691 | -function give_get_lowest_price_option( $form_id = 0 ) { |
|
692 | - if ( empty( $form_id ) ) { |
|
690 | +function give_get_lowest_price_option($form_id = 0) { |
|
691 | + if (empty($form_id)) { |
|
693 | 692 | $form_id = get_the_ID(); |
694 | 693 | } |
695 | 694 | |
696 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
697 | - return give_get_form_price( $form_id ); |
|
695 | + if ( ! give_has_variable_prices($form_id)) { |
|
696 | + return give_get_form_price($form_id); |
|
698 | 697 | } |
699 | 698 | |
700 | - if ( ! ( $low = get_post_meta( $form_id, '_give_levels_minimum_amount', true ) ) ) { |
|
699 | + if ( ! ($low = get_post_meta($form_id, '_give_levels_minimum_amount', true))) { |
|
701 | 700 | // Backward compatibility. |
702 | - $prices = wp_list_pluck( give_get_variable_prices( $form_id ), '_give_amount' ); |
|
703 | - $low = ! empty( $prices ) ? min( $prices ) : 0; |
|
701 | + $prices = wp_list_pluck(give_get_variable_prices($form_id), '_give_amount'); |
|
702 | + $low = ! empty($prices) ? min($prices) : 0; |
|
704 | 703 | } |
705 | 704 | |
706 | - return give_maybe_sanitize_amount( $low ); |
|
705 | + return give_maybe_sanitize_amount($low); |
|
707 | 706 | } |
708 | 707 | |
709 | 708 | /** |
@@ -715,23 +714,23 @@ discard block |
||
715 | 714 | * |
716 | 715 | * @return float Amount of the highest price |
717 | 716 | */ |
718 | -function give_get_highest_price_option( $form_id = 0 ) { |
|
717 | +function give_get_highest_price_option($form_id = 0) { |
|
719 | 718 | |
720 | - if ( empty( $form_id ) ) { |
|
719 | + if (empty($form_id)) { |
|
721 | 720 | $form_id = get_the_ID(); |
722 | 721 | } |
723 | 722 | |
724 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
725 | - return give_get_form_price( $form_id ); |
|
723 | + if ( ! give_has_variable_prices($form_id)) { |
|
724 | + return give_get_form_price($form_id); |
|
726 | 725 | } |
727 | 726 | |
728 | - if ( ! ( $high = get_post_meta( $form_id, '_give_levels_maximum_amount', true ) ) ) { |
|
727 | + if ( ! ($high = get_post_meta($form_id, '_give_levels_maximum_amount', true))) { |
|
729 | 728 | // Backward compatibility. |
730 | - $prices = wp_list_pluck( give_get_variable_prices( $form_id ), '_give_amount' ); |
|
731 | - $high = ! empty( $prices ) ? max( $prices ) : 0; |
|
729 | + $prices = wp_list_pluck(give_get_variable_prices($form_id), '_give_amount'); |
|
730 | + $high = ! empty($prices) ? max($prices) : 0; |
|
732 | 731 | } |
733 | 732 | |
734 | - return give_maybe_sanitize_amount( $high ); |
|
733 | + return give_maybe_sanitize_amount($high); |
|
735 | 734 | } |
736 | 735 | |
737 | 736 | /** |
@@ -743,15 +742,15 @@ discard block |
||
743 | 742 | * |
744 | 743 | * @return mixed string|int Price of the form |
745 | 744 | */ |
746 | -function give_get_form_price( $form_id = 0 ) { |
|
745 | +function give_get_form_price($form_id = 0) { |
|
747 | 746 | |
748 | - if ( empty( $form_id ) ) { |
|
747 | + if (empty($form_id)) { |
|
749 | 748 | return false; |
750 | 749 | } |
751 | 750 | |
752 | - $form = new Give_Donate_Form( $form_id ); |
|
751 | + $form = new Give_Donate_Form($form_id); |
|
753 | 752 | |
754 | - return $form->__get( 'price' ); |
|
753 | + return $form->__get('price'); |
|
755 | 754 | } |
756 | 755 | |
757 | 756 | /** |
@@ -763,13 +762,13 @@ discard block |
||
763 | 762 | * |
764 | 763 | * @return mixed string|int Minimum price of the form |
765 | 764 | */ |
766 | -function give_get_form_minimum_price( $form_id = 0 ) { |
|
765 | +function give_get_form_minimum_price($form_id = 0) { |
|
767 | 766 | |
768 | - if ( empty( $form_id ) ) { |
|
767 | + if (empty($form_id)) { |
|
769 | 768 | return false; |
770 | 769 | } |
771 | 770 | |
772 | - $form = new Give_Donate_Form( $form_id ); |
|
771 | + $form = new Give_Donate_Form($form_id); |
|
773 | 772 | |
774 | 773 | return $form->get_minimum_price(); |
775 | 774 | |
@@ -784,13 +783,13 @@ discard block |
||
784 | 783 | * |
785 | 784 | * @return bool|float |
786 | 785 | */ |
787 | -function give_get_form_maximum_price( $form_id = 0 ) { |
|
786 | +function give_get_form_maximum_price($form_id = 0) { |
|
788 | 787 | |
789 | - if ( empty( $form_id ) ) { |
|
788 | + if (empty($form_id)) { |
|
790 | 789 | return false; |
791 | 790 | } |
792 | 791 | |
793 | - $form = new Give_Donate_Form( $form_id ); |
|
792 | + $form = new Give_Donate_Form($form_id); |
|
794 | 793 | |
795 | 794 | return $form->get_maximum_price(); |
796 | 795 | } |
@@ -806,48 +805,48 @@ discard block |
||
806 | 805 | * |
807 | 806 | * @return int $formatted_price |
808 | 807 | */ |
809 | -function give_price( $form_id = 0, $echo = true, $price_id = false ) { |
|
808 | +function give_price($form_id = 0, $echo = true, $price_id = false) { |
|
810 | 809 | $price = 0; |
811 | 810 | |
812 | - if ( empty( $form_id ) ) { |
|
811 | + if (empty($form_id)) { |
|
813 | 812 | $form_id = get_the_ID(); |
814 | 813 | } |
815 | 814 | |
816 | - if ( give_has_variable_prices( $form_id ) ) { |
|
815 | + if (give_has_variable_prices($form_id)) { |
|
817 | 816 | |
818 | - $prices = give_get_variable_prices( $form_id ); |
|
817 | + $prices = give_get_variable_prices($form_id); |
|
819 | 818 | |
820 | - if ( false !== $price_id ) { |
|
819 | + if (false !== $price_id) { |
|
821 | 820 | |
822 | 821 | // loop through multi-prices to see which is default |
823 | - foreach ( $prices as $price ) { |
|
822 | + foreach ($prices as $price) { |
|
824 | 823 | // this is the default price |
825 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
824 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
826 | 825 | $price = (float) $price['_give_amount']; |
827 | 826 | }; |
828 | 827 | } |
829 | 828 | } else { |
830 | 829 | |
831 | - $price = give_get_lowest_price_option( $form_id ); |
|
830 | + $price = give_get_lowest_price_option($form_id); |
|
832 | 831 | } |
833 | 832 | } else { |
834 | 833 | |
835 | - $price = give_get_form_price( $form_id ); |
|
834 | + $price = give_get_form_price($form_id); |
|
836 | 835 | } |
837 | 836 | |
838 | - $price = apply_filters( 'give_form_price', give_maybe_sanitize_amount( $price ), $form_id ); |
|
839 | - $formatted_price = '<span class="give_price" id="give_price_' . $form_id . '">' . $price . '</span>'; |
|
840 | - $formatted_price = apply_filters( 'give_form_price_after_html', $formatted_price, $form_id, $price ); |
|
837 | + $price = apply_filters('give_form_price', give_maybe_sanitize_amount($price), $form_id); |
|
838 | + $formatted_price = '<span class="give_price" id="give_price_'.$form_id.'">'.$price.'</span>'; |
|
839 | + $formatted_price = apply_filters('give_form_price_after_html', $formatted_price, $form_id, $price); |
|
841 | 840 | |
842 | - if ( $echo ) { |
|
841 | + if ($echo) { |
|
843 | 842 | echo $formatted_price; |
844 | 843 | } else { |
845 | 844 | return $formatted_price; |
846 | 845 | } |
847 | 846 | } |
848 | 847 | |
849 | -add_filter( 'give_form_price', 'give_format_amount', 10 ); |
|
850 | -add_filter( 'give_form_price', 'give_currency_filter', 20 ); |
|
848 | +add_filter('give_form_price', 'give_format_amount', 10); |
|
849 | +add_filter('give_form_price', 'give_currency_filter', 20); |
|
851 | 850 | |
852 | 851 | |
853 | 852 | /** |
@@ -860,19 +859,19 @@ discard block |
||
860 | 859 | * |
861 | 860 | * @return float $amount Amount of the price option |
862 | 861 | */ |
863 | -function give_get_price_option_amount( $form_id = 0, $price_id = 0 ) { |
|
864 | - $prices = give_get_variable_prices( $form_id ); |
|
862 | +function give_get_price_option_amount($form_id = 0, $price_id = 0) { |
|
863 | + $prices = give_get_variable_prices($form_id); |
|
865 | 864 | |
866 | 865 | $amount = 0.00; |
867 | 866 | |
868 | - foreach ( $prices as $price ) { |
|
869 | - if ( isset( $price['_give_id']['level_id'] ) && $price['_give_id']['level_id'] == $price_id ) { |
|
870 | - $amount = isset( $price['_give_amount'] ) ? $price['_give_amount'] : 0.00; |
|
867 | + foreach ($prices as $price) { |
|
868 | + if (isset($price['_give_id']['level_id']) && $price['_give_id']['level_id'] == $price_id) { |
|
869 | + $amount = isset($price['_give_amount']) ? $price['_give_amount'] : 0.00; |
|
871 | 870 | break; |
872 | 871 | }; |
873 | 872 | } |
874 | 873 | |
875 | - return apply_filters( 'give_get_price_option_amount', give_maybe_sanitize_amount( $amount ), $form_id, $price_id ); |
|
874 | + return apply_filters('give_get_price_option_amount', give_maybe_sanitize_amount($amount), $form_id, $price_id); |
|
876 | 875 | } |
877 | 876 | |
878 | 877 | /** |
@@ -884,13 +883,13 @@ discard block |
||
884 | 883 | * |
885 | 884 | * @return mixed string|int Goal of the form |
886 | 885 | */ |
887 | -function give_get_form_goal( $form_id = 0 ) { |
|
886 | +function give_get_form_goal($form_id = 0) { |
|
888 | 887 | |
889 | - if ( empty( $form_id ) ) { |
|
888 | + if (empty($form_id)) { |
|
890 | 889 | return false; |
891 | 890 | } |
892 | 891 | |
893 | - $form = new Give_Donate_Form( $form_id ); |
|
892 | + $form = new Give_Donate_Form($form_id); |
|
894 | 893 | |
895 | 894 | return $form->goal; |
896 | 895 | |
@@ -905,13 +904,13 @@ discard block |
||
905 | 904 | * |
906 | 905 | * @return mixed string|int Goal of the form |
907 | 906 | */ |
908 | -function give_get_form_goal_format( $form_id = 0 ) { |
|
907 | +function give_get_form_goal_format($form_id = 0) { |
|
909 | 908 | |
910 | - if ( empty( $form_id ) ) { |
|
909 | + if (empty($form_id)) { |
|
911 | 910 | return false; |
912 | 911 | } |
913 | 912 | |
914 | - return give_get_meta( $form_id, '_give_goal_format', true ); |
|
913 | + return give_get_meta($form_id, '_give_goal_format', true); |
|
915 | 914 | |
916 | 915 | } |
917 | 916 | |
@@ -925,19 +924,19 @@ discard block |
||
925 | 924 | * |
926 | 925 | * @return string $formatted_goal |
927 | 926 | */ |
928 | -function give_goal( $form_id = 0, $echo = true ) { |
|
927 | +function give_goal($form_id = 0, $echo = true) { |
|
929 | 928 | |
930 | - if ( empty( $form_id ) ) { |
|
929 | + if (empty($form_id)) { |
|
931 | 930 | $form_id = get_the_ID(); |
932 | 931 | } |
933 | 932 | |
934 | - $goal = give_get_form_goal( $form_id ); |
|
935 | - $goal_format = give_get_form_goal_format( $form_id ); |
|
933 | + $goal = give_get_form_goal($form_id); |
|
934 | + $goal_format = give_get_form_goal_format($form_id); |
|
936 | 935 | |
937 | - if ( 'donation' === $goal_format ) { |
|
936 | + if ('donation' === $goal_format) { |
|
938 | 937 | $goal = "{$goal} donations"; |
939 | 938 | } else { |
940 | - $goal = apply_filters( 'give_form_goal', give_maybe_sanitize_amount( $goal ), $form_id ); |
|
939 | + $goal = apply_filters('give_form_goal', give_maybe_sanitize_amount($goal), $form_id); |
|
941 | 940 | } |
942 | 941 | |
943 | 942 | $formatted_goal = sprintf( |
@@ -945,17 +944,17 @@ discard block |
||
945 | 944 | $form_id, |
946 | 945 | $goal |
947 | 946 | ); |
948 | - $formatted_goal = apply_filters( 'give_form_price_after_html', $formatted_goal, $form_id, $goal ); |
|
947 | + $formatted_goal = apply_filters('give_form_price_after_html', $formatted_goal, $form_id, $goal); |
|
949 | 948 | |
950 | - if ( $echo ) { |
|
949 | + if ($echo) { |
|
951 | 950 | echo $formatted_goal; |
952 | 951 | } else { |
953 | 952 | return $formatted_goal; |
954 | 953 | } |
955 | 954 | } |
956 | 955 | |
957 | -add_filter( 'give_form_goal', 'give_format_amount', 10 ); |
|
958 | -add_filter( 'give_form_goal', 'give_currency_filter', 20 ); |
|
956 | +add_filter('give_form_goal', 'give_format_amount', 10); |
|
957 | +add_filter('give_form_goal', 'give_currency_filter', 20); |
|
959 | 958 | |
960 | 959 | |
961 | 960 | /** |
@@ -967,15 +966,15 @@ discard block |
||
967 | 966 | * |
968 | 967 | * @return bool $ret Whether or not the logged_in_only setting is set |
969 | 968 | */ |
970 | -function give_logged_in_only( $form_id ) { |
|
969 | +function give_logged_in_only($form_id) { |
|
971 | 970 | // If _give_logged_in_only is set to enable then guest can donate from that specific form. |
972 | 971 | // Otherwise it is member only donation form. |
973 | - $val = give_get_meta( $form_id, '_give_logged_in_only', true ); |
|
974 | - $val = ! empty( $val ) ? $val : 'enabled'; |
|
972 | + $val = give_get_meta($form_id, '_give_logged_in_only', true); |
|
973 | + $val = ! empty($val) ? $val : 'enabled'; |
|
975 | 974 | |
976 | - $ret = ! give_is_setting_enabled( $val ); |
|
975 | + $ret = ! give_is_setting_enabled($val); |
|
977 | 976 | |
978 | - return (bool) apply_filters( 'give_logged_in_only', $ret, $form_id ); |
|
977 | + return (bool) apply_filters('give_logged_in_only', $ret, $form_id); |
|
979 | 978 | } |
980 | 979 | |
981 | 980 | |
@@ -988,11 +987,11 @@ discard block |
||
988 | 987 | * |
989 | 988 | * @return string |
990 | 989 | */ |
991 | -function give_show_login_register_option( $form_id ) { |
|
990 | +function give_show_login_register_option($form_id) { |
|
992 | 991 | |
993 | - $show_register_form = give_get_meta( $form_id, '_give_show_register_form', true ); |
|
992 | + $show_register_form = give_get_meta($form_id, '_give_show_register_form', true); |
|
994 | 993 | |
995 | - return apply_filters( 'give_show_register_form', $show_register_form, $form_id ); |
|
994 | + return apply_filters('give_show_register_form', $show_register_form, $form_id); |
|
996 | 995 | |
997 | 996 | } |
998 | 997 | |
@@ -1008,12 +1007,12 @@ discard block |
||
1008 | 1007 | * |
1009 | 1008 | * @return array |
1010 | 1009 | */ |
1011 | -function _give_get_prefill_form_field_values( $form_id ) { |
|
1010 | +function _give_get_prefill_form_field_values($form_id) { |
|
1012 | 1011 | $logged_in_donor_info = array(); |
1013 | 1012 | |
1014 | - if ( is_user_logged_in() ) : |
|
1015 | - $donor_data = get_userdata( get_current_user_id() ); |
|
1016 | - $donor = new Give_Donor( get_current_user_id(), true ); |
|
1013 | + if (is_user_logged_in()) : |
|
1014 | + $donor_data = get_userdata(get_current_user_id()); |
|
1015 | + $donor = new Give_Donor(get_current_user_id(), true); |
|
1017 | 1016 | $donor_address = $donor->get_donor_address(); |
1018 | 1017 | $company_name = $donor->get_company_name(); |
1019 | 1018 | |
@@ -1025,7 +1024,7 @@ discard block |
||
1025 | 1024 | 'give_last' => $donor_data->last_name, |
1026 | 1025 | |
1027 | 1026 | // Title Prefix. |
1028 | - 'give_title' => $donor->get_meta( '_give_donor_title_prefix', true ), |
|
1027 | + 'give_title' => $donor->get_meta('_give_donor_title_prefix', true), |
|
1029 | 1028 | |
1030 | 1029 | // Company name. |
1031 | 1030 | 'company_name' => $company_name, |
@@ -1055,23 +1054,23 @@ discard block |
||
1055 | 1054 | |
1056 | 1055 | // Bailout: Auto fill form field values only form form which donor is donating. |
1057 | 1056 | if ( |
1058 | - empty( $_GET['form-id'] ) |
|
1057 | + empty($_GET['form-id']) |
|
1059 | 1058 | || ! $form_id |
1060 | - || ( $form_id !== absint( $_GET['form-id'] ) ) |
|
1059 | + || ($form_id !== absint($_GET['form-id'])) |
|
1061 | 1060 | ) { |
1062 | 1061 | return $logged_in_donor_info; |
1063 | 1062 | } |
1064 | 1063 | |
1065 | 1064 | // Get purchase data. |
1066 | - $give_purchase_data = Give()->session->get( 'give_purchase' ); |
|
1065 | + $give_purchase_data = Give()->session->get('give_purchase'); |
|
1067 | 1066 | |
1068 | 1067 | // Get donor info from form data. |
1069 | - $give_donor_info_in_session = empty( $give_purchase_data['post_data'] ) |
|
1068 | + $give_donor_info_in_session = empty($give_purchase_data['post_data']) |
|
1070 | 1069 | ? array() |
1071 | 1070 | : $give_purchase_data['post_data']; |
1072 | 1071 | |
1073 | 1072 | // Output. |
1074 | - return wp_parse_args( $give_donor_info_in_session, $logged_in_donor_info ); |
|
1073 | + return wp_parse_args($give_donor_info_in_session, $logged_in_donor_info); |
|
1075 | 1074 | } |
1076 | 1075 | |
1077 | 1076 | /** |
@@ -1084,13 +1083,13 @@ discard block |
||
1084 | 1083 | * |
1085 | 1084 | * @return int |
1086 | 1085 | */ |
1087 | -function give_get_form_donor_count( $form_id, $args = array() ) { |
|
1086 | +function give_get_form_donor_count($form_id, $args = array()) { |
|
1088 | 1087 | global $wpdb; |
1089 | 1088 | |
1090 | - $cache_key = Give_Cache::get_key( "form_donor_count_{$form_id}", $args, false ); |
|
1091 | - $donor_count = absint( Give_Cache::get_db_query( $cache_key ) ); |
|
1089 | + $cache_key = Give_Cache::get_key("form_donor_count_{$form_id}", $args, false); |
|
1090 | + $donor_count = absint(Give_Cache::get_db_query($cache_key)); |
|
1092 | 1091 | |
1093 | - if ( $form_id && ! $donor_count ) { |
|
1092 | + if ($form_id && ! $donor_count) { |
|
1094 | 1093 | // Set arguments. |
1095 | 1094 | $args = wp_parse_args( |
1096 | 1095 | $args, |
@@ -1100,7 +1099,7 @@ discard block |
||
1100 | 1099 | ); |
1101 | 1100 | |
1102 | 1101 | $donation_meta_table = Give()->payment_meta->table_name; |
1103 | - $donation_id_col_name = Give()->payment_meta->get_meta_type() . '_id'; |
|
1102 | + $donation_id_col_name = Give()->payment_meta->get_meta_type().'_id'; |
|
1104 | 1103 | |
1105 | 1104 | $distinct = $args['unique'] ? 'DISTINCT meta_value' : 'meta_value'; |
1106 | 1105 | |
@@ -1125,7 +1124,7 @@ discard block |
||
1125 | 1124 | 'publish' |
1126 | 1125 | ); |
1127 | 1126 | |
1128 | - $donor_count = absint( $wpdb->get_var( $query ) ); |
|
1127 | + $donor_count = absint($wpdb->get_var($query)); |
|
1129 | 1128 | } |
1130 | 1129 | |
1131 | 1130 | |
@@ -1134,7 +1133,7 @@ discard block |
||
1134 | 1133 | * |
1135 | 1134 | * @since 2.1.0 |
1136 | 1135 | */ |
1137 | - $donor_count = apply_filters( 'give_get_form_donor_count', $donor_count, $form_id, $args ); |
|
1136 | + $donor_count = apply_filters('give_get_form_donor_count', $donor_count, $form_id, $args); |
|
1138 | 1137 | |
1139 | 1138 | return $donor_count; |
1140 | 1139 | } |
@@ -1148,33 +1147,33 @@ discard block |
||
1148 | 1147 | * |
1149 | 1148 | * @return void |
1150 | 1149 | */ |
1151 | -function give_set_form_closed_status( $form_id ) { |
|
1150 | +function give_set_form_closed_status($form_id) { |
|
1152 | 1151 | |
1153 | 1152 | // Bailout. |
1154 | - if ( empty( $form_id ) ) { |
|
1153 | + if (empty($form_id)) { |
|
1155 | 1154 | return; |
1156 | 1155 | } |
1157 | 1156 | |
1158 | 1157 | $open_form = false; |
1159 | - $is_goal_enabled = give_is_setting_enabled( give_get_meta( $form_id, '_give_goal_option', true, 'disabled' ) ); |
|
1158 | + $is_goal_enabled = give_is_setting_enabled(give_get_meta($form_id, '_give_goal_option', true, 'disabled')); |
|
1160 | 1159 | |
1161 | 1160 | // Proceed, if the form goal is enabled. |
1162 | - if ( $is_goal_enabled ) { |
|
1161 | + if ($is_goal_enabled) { |
|
1163 | 1162 | |
1164 | - $close_form_when_goal_achieved = give_is_setting_enabled( give_get_meta( $form_id, '_give_close_form_when_goal_achieved', true, 'disabled' ) ); |
|
1163 | + $close_form_when_goal_achieved = give_is_setting_enabled(give_get_meta($form_id, '_give_close_form_when_goal_achieved', true, 'disabled')); |
|
1165 | 1164 | |
1166 | 1165 | // Proceed, if close form when goal achieved option is enabled. |
1167 | - if ( $close_form_when_goal_achieved ) { |
|
1166 | + if ($close_form_when_goal_achieved) { |
|
1168 | 1167 | |
1169 | - $form = new Give_Donate_Form( $form_id ); |
|
1170 | - $goal_progress_stats = give_goal_progress_stats( $form ); |
|
1168 | + $form = new Give_Donate_Form($form_id); |
|
1169 | + $goal_progress_stats = give_goal_progress_stats($form); |
|
1171 | 1170 | |
1172 | 1171 | // Verify whether the form is closed or not after processing data. |
1173 | 1172 | $closed = $goal_progress_stats['raw_goal'] <= $goal_progress_stats['raw_actual']; |
1174 | 1173 | |
1175 | 1174 | // Update form meta if verified that the form is closed. |
1176 | - if ( $closed ) { |
|
1177 | - give_update_meta( $form_id, '_give_form_status', 'closed' ); |
|
1175 | + if ($closed) { |
|
1176 | + give_update_meta($form_id, '_give_form_status', 'closed'); |
|
1178 | 1177 | } else { |
1179 | 1178 | $open_form = true; |
1180 | 1179 | } |
@@ -1186,8 +1185,8 @@ discard block |
||
1186 | 1185 | } |
1187 | 1186 | |
1188 | 1187 | // If $open_form is true, then update form status to open. |
1189 | - if ( $open_form ) { |
|
1190 | - give_update_meta( $form_id, '_give_form_status', 'open' ); |
|
1188 | + if ($open_form) { |
|
1189 | + give_update_meta($form_id, '_give_form_status', 'open'); |
|
1191 | 1190 | } |
1192 | 1191 | } |
1193 | 1192 | |
@@ -1200,32 +1199,31 @@ discard block |
||
1200 | 1199 | * |
1201 | 1200 | * @return string |
1202 | 1201 | */ |
1203 | -function give_admin_form_goal_stats( $form_id ) { |
|
1202 | +function give_admin_form_goal_stats($form_id) { |
|
1204 | 1203 | |
1205 | 1204 | $html = ''; |
1206 | - $goal_stats = give_goal_progress_stats( $form_id ); |
|
1207 | - $percent_complete = round( ( $goal_stats['raw_actual'] / $goal_stats['raw_goal'] ), 3 ) * 100; |
|
1205 | + $goal_stats = give_goal_progress_stats($form_id); |
|
1206 | + $percent_complete = round(($goal_stats['raw_actual'] / $goal_stats['raw_goal']), 3) * 100; |
|
1208 | 1207 | |
1209 | 1208 | $html .= sprintf( |
1210 | 1209 | '<div class="give-admin-progress-bar" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="%1$s"> |
1211 | 1210 | <span style="width:%1$s%%;"></span> |
1212 | 1211 | </div>', |
1213 | - esc_attr( $goal_stats['progress'] ) |
|
1212 | + esc_attr($goal_stats['progress']) |
|
1214 | 1213 | ); |
1215 | 1214 | |
1216 | 1215 | $html .= sprintf( |
1217 | - ( 'percentage' !== $goal_stats['format'] ) ? |
|
1218 | - '<div class="give-goal-text"><span>%1$s</span> %2$s <a href="%3$s">%4$s</a> %5$s ' : |
|
1219 | - '<div class="give-goal-text"><a href="%3$s">%1$s </a>', |
|
1220 | - ( 'percentage' !== $goal_stats['format'] ) ? $goal_stats['actual'] : $percent_complete . '%', |
|
1221 | - ( 'percentage' !== $goal_stats['format'] ) ? __( 'of', 'give' ) : '', |
|
1222 | - esc_url( admin_url( "post.php?post={$form_id}&action=edit&give_tab=donation_goal_options" ) ), |
|
1216 | + ('percentage' !== $goal_stats['format']) ? |
|
1217 | + '<div class="give-goal-text"><span>%1$s</span> %2$s <a href="%3$s">%4$s</a> %5$s ' : '<div class="give-goal-text"><a href="%3$s">%1$s </a>', |
|
1218 | + ('percentage' !== $goal_stats['format']) ? $goal_stats['actual'] : $percent_complete.'%', |
|
1219 | + ('percentage' !== $goal_stats['format']) ? __('of', 'give') : '', |
|
1220 | + esc_url(admin_url("post.php?post={$form_id}&action=edit&give_tab=donation_goal_options")), |
|
1223 | 1221 | $goal_stats['goal'], |
1224 | - ( 'donors' === $goal_stats['format'] ? __( 'Donors', 'give' ) : ( 'donation' === $goal_stats['format'] ? __( 'Donations', 'give' ) : '' ) ) |
|
1222 | + ('donors' === $goal_stats['format'] ? __('Donors', 'give') : ('donation' === $goal_stats['format'] ? __('Donations', 'give') : '')) |
|
1225 | 1223 | ); |
1226 | 1224 | |
1227 | - if ( $goal_stats['raw_actual'] >= $goal_stats['raw_goal'] ) { |
|
1228 | - $html .= sprintf( '<span class="give-admin-goal-achieved"><span class="dashicons dashicons-star-filled"></span> %s</span>', __( 'Goal achieved', 'give' ) ); |
|
1225 | + if ($goal_stats['raw_actual'] >= $goal_stats['raw_goal']) { |
|
1226 | + $html .= sprintf('<span class="give-admin-goal-achieved"><span class="dashicons dashicons-star-filled"></span> %s</span>', __('Goal achieved', 'give')); |
|
1229 | 1227 | } |
1230 | 1228 | |
1231 | 1229 | $html .= '</div>'; |
@@ -1243,11 +1241,11 @@ discard block |
||
1243 | 1241 | * |
1244 | 1242 | * @return null | array |
1245 | 1243 | */ |
1246 | -function give_form_get_default_level( $form_id ) { |
|
1244 | +function give_form_get_default_level($form_id) { |
|
1247 | 1245 | $default_level = null; |
1248 | 1246 | |
1249 | 1247 | // If donation form has variable prices. |
1250 | - if ( give_has_variable_prices( $form_id ) ) { |
|
1248 | + if (give_has_variable_prices($form_id)) { |
|
1251 | 1249 | /** |
1252 | 1250 | * Filter the variable pricing |
1253 | 1251 | * |
@@ -1259,12 +1257,12 @@ discard block |
||
1259 | 1257 | * @param array $prices Array of variable prices. |
1260 | 1258 | * @param int $form Form ID. |
1261 | 1259 | */ |
1262 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
1260 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
1263 | 1261 | |
1264 | 1262 | // Go through each of the level and get the default level id. |
1265 | - foreach ( $prices as $level ) { |
|
1263 | + foreach ($prices as $level) { |
|
1266 | 1264 | if ( |
1267 | - isset( $level['_give_default'] ) |
|
1265 | + isset($level['_give_default']) |
|
1268 | 1266 | && $level['_give_default'] === 'default' |
1269 | 1267 | ) { |
1270 | 1268 | $default_level = $level; |
@@ -1280,7 +1278,7 @@ discard block |
||
1280 | 1278 | * @param array $default_level Default level price data. |
1281 | 1279 | * @param integer $form_id Donation form ID. |
1282 | 1280 | */ |
1283 | - return apply_filters( 'give_form_get_default_level', $default_level, $form_id ); |
|
1281 | + return apply_filters('give_form_get_default_level', $default_level, $form_id); |
|
1284 | 1282 | } |
1285 | 1283 | |
1286 | 1284 | /** |
@@ -1293,21 +1291,21 @@ discard block |
||
1293 | 1291 | * |
1294 | 1292 | * @return boolean |
1295 | 1293 | */ |
1296 | -function give_is_default_level_id( $price_or_level_id, $form_id = 0 ) { |
|
1294 | +function give_is_default_level_id($price_or_level_id, $form_id = 0) { |
|
1297 | 1295 | $is_default = false; |
1298 | 1296 | |
1299 | 1297 | if ( |
1300 | - ! empty( $form_id ) |
|
1301 | - && is_numeric( $price_or_level_id ) |
|
1298 | + ! empty($form_id) |
|
1299 | + && is_numeric($price_or_level_id) |
|
1302 | 1300 | ) { |
1303 | 1301 | // Get default level id. |
1304 | - $form_price_data = give_form_get_default_level( $form_id ); |
|
1302 | + $form_price_data = give_form_get_default_level($form_id); |
|
1305 | 1303 | |
1306 | - $is_default = ! is_null( $form_price_data ) && ( $price_or_level_id === absint( $form_price_data['_give_id']['level_id'] ) ); |
|
1304 | + $is_default = ! is_null($form_price_data) && ($price_or_level_id === absint($form_price_data['_give_id']['level_id'])); |
|
1307 | 1305 | } |
1308 | 1306 | |
1309 | - $is_default = false === $is_default && is_array( $price_or_level_id ) ? |
|
1310 | - ( isset( $price_or_level_id['_give_default'] ) && $price_or_level_id['_give_default'] === 'default' ) |
|
1307 | + $is_default = false === $is_default && is_array($price_or_level_id) ? |
|
1308 | + (isset($price_or_level_id['_give_default']) && $price_or_level_id['_give_default'] === 'default') |
|
1311 | 1309 | : $is_default; |
1312 | 1310 | |
1313 | 1311 | /** |
@@ -1318,7 +1316,7 @@ discard block |
||
1318 | 1316 | * @param bool $is_default True if it is default price level id otherwise false. |
1319 | 1317 | * @param array|integer $price_or_level_id Price Data. |
1320 | 1318 | */ |
1321 | - return apply_filters( 'give_is_default_level_id', $is_default, $price_or_level_id ); |
|
1319 | + return apply_filters('give_is_default_level_id', $is_default, $price_or_level_id); |
|
1322 | 1320 | } |
1323 | 1321 | |
1324 | 1322 | |
@@ -1331,20 +1329,20 @@ discard block |
||
1331 | 1329 | * |
1332 | 1330 | * @return mixed |
1333 | 1331 | */ |
1334 | -function give_get_name_title_prefixes( $form_id = 0 ) { |
|
1332 | +function give_get_name_title_prefixes($form_id = 0) { |
|
1335 | 1333 | |
1336 | - $name_title_prefix = give_is_name_title_prefix_enabled( $form_id ); |
|
1337 | - $title_prefixes = give_get_option( 'title_prefixes', give_get_default_title_prefixes() ); |
|
1334 | + $name_title_prefix = give_is_name_title_prefix_enabled($form_id); |
|
1335 | + $title_prefixes = give_get_option('title_prefixes', give_get_default_title_prefixes()); |
|
1338 | 1336 | |
1339 | 1337 | // If form id exists, then fetch form specific title prefixes. |
1340 | - if ( intval( $form_id ) > 0 && $name_title_prefix ) { |
|
1338 | + if (intval($form_id) > 0 && $name_title_prefix) { |
|
1341 | 1339 | |
1342 | - $form_title_prefix = give_get_meta( $form_id, '_give_name_title_prefix', true ); |
|
1343 | - if ( 'global' !== $form_title_prefix ) { |
|
1344 | - $form_title_prefixes = give_get_meta( $form_id, '_give_title_prefixes', true, give_get_default_title_prefixes() ); |
|
1340 | + $form_title_prefix = give_get_meta($form_id, '_give_name_title_prefix', true); |
|
1341 | + if ('global' !== $form_title_prefix) { |
|
1342 | + $form_title_prefixes = give_get_meta($form_id, '_give_title_prefixes', true, give_get_default_title_prefixes()); |
|
1345 | 1343 | |
1346 | 1344 | // Check whether the form based title prefixes exists or not. |
1347 | - if ( is_array( $form_title_prefixes ) && count( $form_title_prefixes ) > 0 ) { |
|
1345 | + if (is_array($form_title_prefixes) && count($form_title_prefixes) > 0) { |
|
1348 | 1346 | $title_prefixes = $form_title_prefixes; |
1349 | 1347 | } |
1350 | 1348 | } |
@@ -1363,22 +1361,22 @@ discard block |
||
1363 | 1361 | * |
1364 | 1362 | * @return bool |
1365 | 1363 | */ |
1366 | -function give_is_name_title_prefix_enabled( $form_id = 0, $status = '' ) { |
|
1367 | - if ( empty( $status ) ) { |
|
1368 | - $status = array( 'required', 'optional' ); |
|
1364 | +function give_is_name_title_prefix_enabled($form_id = 0, $status = '') { |
|
1365 | + if (empty($status)) { |
|
1366 | + $status = array('required', 'optional'); |
|
1369 | 1367 | } else { |
1370 | - $status = array( $status ); |
|
1368 | + $status = array($status); |
|
1371 | 1369 | } |
1372 | 1370 | |
1373 | - $title_prefix_status = give_is_setting_enabled( give_get_option( 'name_title_prefix' ), $status ); |
|
1371 | + $title_prefix_status = give_is_setting_enabled(give_get_option('name_title_prefix'), $status); |
|
1374 | 1372 | |
1375 | - if ( intval( $form_id ) > 0 ) { |
|
1376 | - $form_title_prefix = give_get_meta( $form_id, '_give_name_title_prefix', true ); |
|
1373 | + if (intval($form_id) > 0) { |
|
1374 | + $form_title_prefix = give_get_meta($form_id, '_give_name_title_prefix', true); |
|
1377 | 1375 | |
1378 | - if ( 'disabled' === $form_title_prefix ) { |
|
1376 | + if ('disabled' === $form_title_prefix) { |
|
1379 | 1377 | $title_prefix_status = false; |
1380 | - } elseif ( in_array( $form_title_prefix, $status, true ) ) { |
|
1381 | - $title_prefix_status = give_is_setting_enabled( $form_title_prefix, $status ); |
|
1378 | + } elseif (in_array($form_title_prefix, $status, true)) { |
|
1379 | + $title_prefix_status = give_is_setting_enabled($form_title_prefix, $status); |
|
1382 | 1380 | } |
1383 | 1381 | } |
1384 | 1382 | |
@@ -1395,18 +1393,18 @@ discard block |
||
1395 | 1393 | * |
1396 | 1394 | * @return object |
1397 | 1395 | */ |
1398 | -function give_get_name_with_title_prefixes( $donor ) { |
|
1396 | +function give_get_name_with_title_prefixes($donor) { |
|
1399 | 1397 | |
1400 | 1398 | // Prepare Give_Donor object, if $donor is numeric. |
1401 | - if ( is_numeric( $donor ) ) { |
|
1402 | - $donor = new Give_Donor( $donor ); |
|
1399 | + if (is_numeric($donor)) { |
|
1400 | + $donor = new Give_Donor($donor); |
|
1403 | 1401 | } |
1404 | 1402 | |
1405 | - $title_prefix = Give()->donor_meta->get_meta( $donor->id, '_give_donor_title_prefix', true ); |
|
1403 | + $title_prefix = Give()->donor_meta->get_meta($donor->id, '_give_donor_title_prefix', true); |
|
1406 | 1404 | |
1407 | 1405 | // Update Donor name, if non empty title prefix. |
1408 | - if ( ! empty( $title_prefix ) ) { |
|
1409 | - $donor->name = give_get_donor_name_with_title_prefixes( $title_prefix, $donor->name ); |
|
1406 | + if ( ! empty($title_prefix)) { |
|
1407 | + $donor->name = give_get_donor_name_with_title_prefixes($title_prefix, $donor->name); |
|
1410 | 1408 | } |
1411 | 1409 | |
1412 | 1410 | return $donor; |
@@ -1422,15 +1420,15 @@ discard block |
||
1422 | 1420 | * |
1423 | 1421 | * @return string |
1424 | 1422 | */ |
1425 | -function give_get_donor_name_with_title_prefixes( $title_prefix, $name ) { |
|
1423 | +function give_get_donor_name_with_title_prefixes($title_prefix, $name) { |
|
1426 | 1424 | |
1427 | 1425 | $donor_name = $name; |
1428 | 1426 | |
1429 | - if ( ! empty( $title_prefix ) && ! empty( $name ) ) { |
|
1427 | + if ( ! empty($title_prefix) && ! empty($name)) { |
|
1430 | 1428 | $donor_name = "{$title_prefix} {$name}"; |
1431 | 1429 | } |
1432 | 1430 | |
1433 | - return trim( $donor_name ); |
|
1431 | + return trim($donor_name); |
|
1434 | 1432 | } |
1435 | 1433 | |
1436 | 1434 | /** |
@@ -1450,9 +1448,9 @@ discard block |
||
1450 | 1448 | return apply_filters( |
1451 | 1449 | 'give_get_default_title_prefixes', |
1452 | 1450 | array( |
1453 | - 'Mr.' => __( 'Mr.', 'give' ), |
|
1454 | - 'Mrs.' => __( 'Mrs.', 'give' ), |
|
1455 | - 'Ms.' => __( 'Ms.', 'give' ), |
|
1451 | + 'Mr.' => __('Mr.', 'give'), |
|
1452 | + 'Mrs.' => __('Mrs.', 'give'), |
|
1453 | + 'Ms.' => __('Ms.', 'give'), |
|
1456 | 1454 | ) |
1457 | 1455 | ); |
1458 | 1456 | } |
@@ -1466,25 +1464,25 @@ discard block |
||
1466 | 1464 | * |
1467 | 1465 | * @return bool |
1468 | 1466 | */ |
1469 | -function give_is_name_title_prefix_required( $form_id = 0 ) { |
|
1467 | +function give_is_name_title_prefix_required($form_id = 0) { |
|
1470 | 1468 | |
1471 | 1469 | // Bail out, if name title prefix is not enabled. |
1472 | - if ( ! give_is_name_title_prefix_enabled( $form_id ) ) { |
|
1470 | + if ( ! give_is_name_title_prefix_enabled($form_id)) { |
|
1473 | 1471 | return false; |
1474 | 1472 | } |
1475 | 1473 | |
1476 | - $status = array( 'optional' ); |
|
1477 | - $is_optional = give_is_setting_enabled( give_get_option( 'name_title_prefix' ), $status ); |
|
1474 | + $status = array('optional'); |
|
1475 | + $is_optional = give_is_setting_enabled(give_get_option('name_title_prefix'), $status); |
|
1478 | 1476 | |
1479 | - if ( intval( $form_id ) > 0 ) { |
|
1480 | - $form_title_prefix = give_get_meta( $form_id, '_give_name_title_prefix', true ); |
|
1477 | + if (intval($form_id) > 0) { |
|
1478 | + $form_title_prefix = give_get_meta($form_id, '_give_name_title_prefix', true); |
|
1481 | 1479 | |
1482 | - if ( 'required' === $form_title_prefix ) { |
|
1480 | + if ('required' === $form_title_prefix) { |
|
1483 | 1481 | $is_optional = false; |
1484 | - } elseif ( 'optional' === $form_title_prefix ) { |
|
1482 | + } elseif ('optional' === $form_title_prefix) { |
|
1485 | 1483 | $is_optional = true; |
1486 | 1484 | } |
1487 | 1485 | } |
1488 | 1486 | |
1489 | - return ( ! $is_optional ); |
|
1487 | + return ( ! $is_optional); |
|
1490 | 1488 | } |