@@ -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 ) || ( '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 | /** |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | */ |
120 | 120 | function give_is_success_page() { |
121 | 121 | $give_options = give_get_settings(); |
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 | |
@@ -161,20 +161,20 @@ discard block |
||
161 | 161 | * @since 1.0 |
162 | 162 | * @return Void |
163 | 163 | */ |
164 | -function give_send_back_to_checkout( $args = array() ) { |
|
164 | +function give_send_back_to_checkout($args = array()) { |
|
165 | 165 | |
166 | - $url = isset( $_POST['give-current-url'] ) ? sanitize_text_field( $_POST['give-current-url'] ) : ''; |
|
166 | + $url = isset($_POST['give-current-url']) ? sanitize_text_field($_POST['give-current-url']) : ''; |
|
167 | 167 | |
168 | 168 | // Set the form_id. |
169 | - if ( isset( $_POST['give-form-id'] ) ) { |
|
170 | - $form_id = sanitize_text_field( $_POST['give-form-id'] ); |
|
169 | + if (isset($_POST['give-form-id'])) { |
|
170 | + $form_id = sanitize_text_field($_POST['give-form-id']); |
|
171 | 171 | } else { |
172 | 172 | $form_id = 0; |
173 | 173 | } |
174 | 174 | |
175 | 175 | // Need a URL to continue. If none, redirect back to single form. |
176 | - if ( empty( $url ) ) { |
|
177 | - wp_safe_redirect( get_permalink( $form_id ) ); |
|
176 | + if (empty($url)) { |
|
177 | + wp_safe_redirect(get_permalink($form_id)); |
|
178 | 178 | give_die(); |
179 | 179 | } |
180 | 180 | |
@@ -183,36 +183,36 @@ discard block |
||
183 | 183 | ); |
184 | 184 | |
185 | 185 | // Check for backward compatibility. |
186 | - if ( is_string( $args ) ) { |
|
187 | - $args = str_replace( '?', '', $args ); |
|
186 | + if (is_string($args)) { |
|
187 | + $args = str_replace('?', '', $args); |
|
188 | 188 | } |
189 | 189 | |
190 | - $args = wp_parse_args( $args, $defaults ); |
|
190 | + $args = wp_parse_args($args, $defaults); |
|
191 | 191 | |
192 | 192 | // Merge URL query with $args to maintain third-party URL parameters after redirect. |
193 | - $url_data = wp_parse_url( $url ); |
|
193 | + $url_data = wp_parse_url($url); |
|
194 | 194 | |
195 | 195 | // Check if an array to prevent notices before parsing. |
196 | - if ( isset( $url_data['query'] ) && ! empty( $url_data['query'] ) ) { |
|
197 | - parse_str( $url_data['query'], $query ); |
|
196 | + if (isset($url_data['query']) && ! empty($url_data['query'])) { |
|
197 | + parse_str($url_data['query'], $query); |
|
198 | 198 | |
199 | 199 | // Precaution: don't allow any CC info. |
200 | - unset( $query['card_number'] ); |
|
201 | - unset( $query['card_cvc'] ); |
|
200 | + unset($query['card_number']); |
|
201 | + unset($query['card_cvc']); |
|
202 | 202 | |
203 | 203 | } else { |
204 | 204 | // No $url_data so pass empty array. |
205 | 205 | $query = array(); |
206 | 206 | } |
207 | 207 | |
208 | - $new_query = array_merge( $args, $query ); |
|
209 | - $new_query_string = http_build_query( $new_query ); |
|
208 | + $new_query = array_merge($args, $query); |
|
209 | + $new_query_string = http_build_query($new_query); |
|
210 | 210 | |
211 | 211 | // Assemble URL parts. |
212 | - $redirect = home_url( '/' . $url_data['path'] . '?' . $new_query_string . '#give-form-' . $form_id . '-wrap' ); |
|
212 | + $redirect = home_url('/'.$url_data['path'].'?'.$new_query_string.'#give-form-'.$form_id.'-wrap'); |
|
213 | 213 | |
214 | 214 | // Redirect them. |
215 | - wp_safe_redirect( apply_filters( 'give_send_back_to_checkout', $redirect, $args ) ); |
|
215 | + wp_safe_redirect(apply_filters('give_send_back_to_checkout', $redirect, $args)); |
|
216 | 216 | give_die(); |
217 | 217 | |
218 | 218 | } |
@@ -228,16 +228,16 @@ discard block |
||
228 | 228 | * @since 1.0 |
229 | 229 | * @return string |
230 | 230 | */ |
231 | -function give_get_success_page_url( $query_string = null ) { |
|
231 | +function give_get_success_page_url($query_string = null) { |
|
232 | 232 | |
233 | - $success_page = give_get_option( 'success_page', 0 ); |
|
234 | - $success_page = get_permalink( $success_page ); |
|
233 | + $success_page = give_get_option('success_page', 0); |
|
234 | + $success_page = get_permalink($success_page); |
|
235 | 235 | |
236 | - if ( $query_string ) { |
|
236 | + if ($query_string) { |
|
237 | 237 | $success_page .= $query_string; |
238 | 238 | } |
239 | 239 | |
240 | - return apply_filters( 'give_success_page_url', $success_page ); |
|
240 | + return apply_filters('give_success_page_url', $success_page); |
|
241 | 241 | |
242 | 242 | } |
243 | 243 | |
@@ -250,15 +250,15 @@ discard block |
||
250 | 250 | * |
251 | 251 | * @return mixed|void Full URL to the Failed Donation Page, if present, home page if it doesn't exist |
252 | 252 | */ |
253 | -function give_get_failed_transaction_uri( $extras = false ) { |
|
253 | +function give_get_failed_transaction_uri($extras = false) { |
|
254 | 254 | $give_options = give_get_settings(); |
255 | 255 | |
256 | - $uri = ! empty( $give_options['failure_page'] ) ? trailingslashit( get_permalink( $give_options['failure_page'] ) ) : home_url(); |
|
257 | - if ( $extras ) { |
|
256 | + $uri = ! empty($give_options['failure_page']) ? trailingslashit(get_permalink($give_options['failure_page'])) : home_url(); |
|
257 | + if ($extras) { |
|
258 | 258 | $uri .= $extras; |
259 | 259 | } |
260 | 260 | |
261 | - return apply_filters( 'give_get_failed_transaction_uri', $uri ); |
|
261 | + return apply_filters('give_get_failed_transaction_uri', $uri); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
@@ -269,9 +269,9 @@ discard block |
||
269 | 269 | */ |
270 | 270 | function give_is_failed_transaction_page() { |
271 | 271 | $give_options = give_get_settings(); |
272 | - $ret = isset( $give_options['failure_page'] ) ? is_page( $give_options['failure_page'] ) : false; |
|
272 | + $ret = isset($give_options['failure_page']) ? is_page($give_options['failure_page']) : false; |
|
273 | 273 | |
274 | - return apply_filters( 'give_is_failure_page', $ret ); |
|
274 | + return apply_filters('give_is_failure_page', $ret); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | /** |
@@ -283,18 +283,18 @@ discard block |
||
283 | 283 | */ |
284 | 284 | function give_listen_for_failed_payments() { |
285 | 285 | |
286 | - $failed_page = give_get_option( 'failure_page', 0 ); |
|
286 | + $failed_page = give_get_option('failure_page', 0); |
|
287 | 287 | |
288 | - if ( ! empty( $failed_page ) && is_page( $failed_page ) && ! empty( $_GET['payment-id'] ) ) { |
|
288 | + if ( ! empty($failed_page) && is_page($failed_page) && ! empty($_GET['payment-id'])) { |
|
289 | 289 | |
290 | - $payment_id = absint( $_GET['payment-id'] ); |
|
291 | - give_update_payment_status( $payment_id, 'failed' ); |
|
290 | + $payment_id = absint($_GET['payment-id']); |
|
291 | + give_update_payment_status($payment_id, 'failed'); |
|
292 | 292 | |
293 | 293 | } |
294 | 294 | |
295 | 295 | } |
296 | 296 | |
297 | -add_action( 'template_redirect', 'give_listen_for_failed_payments' ); |
|
297 | +add_action('template_redirect', 'give_listen_for_failed_payments'); |
|
298 | 298 | |
299 | 299 | /** |
300 | 300 | * Retrieve the Donation History page URI |
@@ -307,9 +307,9 @@ discard block |
||
307 | 307 | function give_get_history_page_uri() { |
308 | 308 | $give_options = give_get_settings(); |
309 | 309 | |
310 | - $history_page = isset( $give_options['history_page'] ) ? get_permalink( absint( $give_options['history_page'] ) ) : get_bloginfo( 'url' ); |
|
310 | + $history_page = isset($give_options['history_page']) ? get_permalink(absint($give_options['history_page'])) : get_bloginfo('url'); |
|
311 | 311 | |
312 | - return apply_filters( 'give_get_history_page_uri', $history_page ); |
|
312 | + return apply_filters('give_get_history_page_uri', $history_page); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | /** |
@@ -322,11 +322,11 @@ discard block |
||
322 | 322 | * @since 1.0 |
323 | 323 | * @return bool |
324 | 324 | */ |
325 | -function give_field_is_required( $field = '', $form_id ) { |
|
325 | +function give_field_is_required($field = '', $form_id) { |
|
326 | 326 | |
327 | - $required_fields = give_get_required_fields( $form_id ); |
|
327 | + $required_fields = give_get_required_fields($form_id); |
|
328 | 328 | |
329 | - return array_key_exists( $field, $required_fields ); |
|
329 | + return array_key_exists($field, $required_fields); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | /** |
@@ -344,14 +344,14 @@ discard block |
||
344 | 344 | * |
345 | 345 | * @return void |
346 | 346 | */ |
347 | -function give_record_sale_in_log( $give_form_id = 0, $payment_id, $price_id = false, $sale_date = null ) { |
|
347 | +function give_record_sale_in_log($give_form_id = 0, $payment_id, $price_id = false, $sale_date = null) { |
|
348 | 348 | global $give_logs; |
349 | 349 | |
350 | 350 | $log_data = array( |
351 | 351 | 'post_parent' => $give_form_id, |
352 | 352 | 'log_type' => 'sale', |
353 | - 'post_date' => isset( $sale_date ) ? $sale_date : null, |
|
354 | - 'post_date_gmt' => isset( $sale_date ) ? $sale_date : null, |
|
353 | + 'post_date' => isset($sale_date) ? $sale_date : null, |
|
354 | + 'post_date_gmt' => isset($sale_date) ? $sale_date : null, |
|
355 | 355 | ); |
356 | 356 | |
357 | 357 | $log_meta = array( |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | 'price_id' => (int) $price_id, |
360 | 360 | ); |
361 | 361 | |
362 | - $give_logs->insert_log( $log_data, $log_meta ); |
|
362 | + $give_logs->insert_log($log_data, $log_meta); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | |
@@ -373,11 +373,11 @@ discard block |
||
373 | 373 | * |
374 | 374 | * @return bool|int |
375 | 375 | */ |
376 | -function give_increase_purchase_count( $form_id = 0, $quantity = 1 ) { |
|
376 | +function give_increase_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->increase_sales( $quantity ); |
|
380 | + return $form->increase_sales($quantity); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | /** |
@@ -390,11 +390,11 @@ discard block |
||
390 | 390 | * |
391 | 391 | * @return bool|int |
392 | 392 | */ |
393 | -function give_decrease_purchase_count( $form_id = 0, $quantity = 1 ) { |
|
393 | +function give_decrease_purchase_count($form_id = 0, $quantity = 1) { |
|
394 | 394 | $quantity = (int) $quantity; |
395 | - $form = new Give_Donate_Form( $form_id ); |
|
395 | + $form = new Give_Donate_Form($form_id); |
|
396 | 396 | |
397 | - return $form->decrease_sales( $quantity ); |
|
397 | + return $form->decrease_sales($quantity); |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | /** |
@@ -407,10 +407,10 @@ discard block |
||
407 | 407 | * |
408 | 408 | * @return bool|int |
409 | 409 | */ |
410 | -function give_increase_earnings( $give_form_id = 0, $amount ) { |
|
411 | - $form = new Give_Donate_Form( $give_form_id ); |
|
410 | +function give_increase_earnings($give_form_id = 0, $amount) { |
|
411 | + $form = new Give_Donate_Form($give_form_id); |
|
412 | 412 | |
413 | - return $form->increase_earnings( $amount ); |
|
413 | + return $form->increase_earnings($amount); |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | /** |
@@ -423,10 +423,10 @@ discard block |
||
423 | 423 | * |
424 | 424 | * @return bool|int |
425 | 425 | */ |
426 | -function give_decrease_earnings( $form_id = 0, $amount ) { |
|
427 | - $form = new Give_Donate_Form( $form_id ); |
|
426 | +function give_decrease_earnings($form_id = 0, $amount) { |
|
427 | + $form = new Give_Donate_Form($form_id); |
|
428 | 428 | |
429 | - return $form->decrease_earnings( $amount ); |
|
429 | + return $form->decrease_earnings($amount); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | |
@@ -439,8 +439,8 @@ discard block |
||
439 | 439 | * |
440 | 440 | * @return int $earnings Earnings for a certain form |
441 | 441 | */ |
442 | -function give_get_form_earnings_stats( $form_id = 0 ) { |
|
443 | - $give_form = new Give_Donate_Form( $form_id ); |
|
442 | +function give_get_form_earnings_stats($form_id = 0) { |
|
443 | + $give_form = new Give_Donate_Form($form_id); |
|
444 | 444 | |
445 | 445 | return $give_form->earnings; |
446 | 446 | } |
@@ -455,8 +455,8 @@ discard block |
||
455 | 455 | * |
456 | 456 | * @return int $sales Amount of sales for a certain form |
457 | 457 | */ |
458 | -function give_get_form_sales_stats( $give_form_id = 0 ) { |
|
459 | - $give_form = new Give_Donate_Form( $give_form_id ); |
|
458 | +function give_get_form_sales_stats($give_form_id = 0) { |
|
459 | + $give_form = new Give_Donate_Form($give_form_id); |
|
460 | 460 | |
461 | 461 | return $give_form->sales; |
462 | 462 | } |
@@ -471,16 +471,16 @@ discard block |
||
471 | 471 | * |
472 | 472 | * @return float $sales Average monthly sales |
473 | 473 | */ |
474 | -function give_get_average_monthly_form_sales( $form_id = 0 ) { |
|
475 | - $sales = give_get_form_sales_stats( $form_id ); |
|
476 | - $release_date = get_post_field( 'post_date', $form_id ); |
|
474 | +function give_get_average_monthly_form_sales($form_id = 0) { |
|
475 | + $sales = give_get_form_sales_stats($form_id); |
|
476 | + $release_date = get_post_field('post_date', $form_id); |
|
477 | 477 | |
478 | - $diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) ); |
|
478 | + $diff = abs(current_time('timestamp') - strtotime($release_date)); |
|
479 | 479 | |
480 | - $months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication |
|
480 | + $months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication |
|
481 | 481 | |
482 | - if ( $months > 0 ) { |
|
483 | - $sales = ( $sales / $months ); |
|
482 | + if ($months > 0) { |
|
483 | + $sales = ($sales / $months); |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | return $sales; |
@@ -496,16 +496,16 @@ discard block |
||
496 | 496 | * |
497 | 497 | * @return float $earnings Average monthly earnings |
498 | 498 | */ |
499 | -function give_get_average_monthly_form_earnings( $form_id = 0 ) { |
|
500 | - $earnings = give_get_form_earnings_stats( $form_id ); |
|
501 | - $release_date = get_post_field( 'post_date', $form_id ); |
|
499 | +function give_get_average_monthly_form_earnings($form_id = 0) { |
|
500 | + $earnings = give_get_form_earnings_stats($form_id); |
|
501 | + $release_date = get_post_field('post_date', $form_id); |
|
502 | 502 | |
503 | - $diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) ); |
|
503 | + $diff = abs(current_time('timestamp') - strtotime($release_date)); |
|
504 | 504 | |
505 | - $months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication |
|
505 | + $months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication |
|
506 | 506 | |
507 | - if ( $months > 0 ) { |
|
508 | - $earnings = ( $earnings / $months ); |
|
507 | + if ($months > 0) { |
|
508 | + $earnings = ($earnings / $months); |
|
509 | 509 | } |
510 | 510 | |
511 | 511 | return $earnings < 0 ? 0 : $earnings; |
@@ -525,23 +525,23 @@ discard block |
||
525 | 525 | * |
526 | 526 | * @return string $price_name Name of the price option |
527 | 527 | */ |
528 | -function give_get_price_option_name( $form_id = 0, $price_id = 0, $payment_id = 0 ) { |
|
528 | +function give_get_price_option_name($form_id = 0, $price_id = 0, $payment_id = 0) { |
|
529 | 529 | |
530 | - $prices = give_get_variable_prices( $form_id ); |
|
530 | + $prices = give_get_variable_prices($form_id); |
|
531 | 531 | $price_name = ''; |
532 | 532 | |
533 | - foreach ( $prices as $price ) { |
|
533 | + foreach ($prices as $price) { |
|
534 | 534 | |
535 | - if ( intval( $price['_give_id']['level_id'] ) == intval( $price_id ) ) { |
|
535 | + if (intval($price['_give_id']['level_id']) == intval($price_id)) { |
|
536 | 536 | |
537 | - $price_text = isset( $price['_give_text'] ) ? $price['_give_text'] : ''; |
|
538 | - $price_fallback = give_currency_filter( give_format_amount( $price['_give_amount'] ) ); |
|
539 | - $price_name = ! empty( $price_text ) ? $price_text : $price_fallback; |
|
537 | + $price_text = isset($price['_give_text']) ? $price['_give_text'] : ''; |
|
538 | + $price_fallback = give_currency_filter(give_format_amount($price['_give_amount'])); |
|
539 | + $price_name = ! empty($price_text) ? $price_text : $price_fallback; |
|
540 | 540 | |
541 | 541 | } |
542 | 542 | } |
543 | 543 | |
544 | - return apply_filters( 'give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id ); |
|
544 | + return apply_filters('give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id); |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | |
@@ -554,14 +554,14 @@ discard block |
||
554 | 554 | * |
555 | 555 | * @return string $range A fully formatted price range |
556 | 556 | */ |
557 | -function give_price_range( $form_id = 0 ) { |
|
558 | - $low = give_get_lowest_price_option( $form_id ); |
|
559 | - $high = give_get_highest_price_option( $form_id ); |
|
560 | - $range = '<span class="give_price_range_low">' . give_currency_filter( give_format_amount( $low ) ) . '</span>'; |
|
557 | +function give_price_range($form_id = 0) { |
|
558 | + $low = give_get_lowest_price_option($form_id); |
|
559 | + $high = give_get_highest_price_option($form_id); |
|
560 | + $range = '<span class="give_price_range_low">'.give_currency_filter(give_format_amount($low)).'</span>'; |
|
561 | 561 | $range .= '<span class="give_price_range_sep"> – </span>'; |
562 | - $range .= '<span class="give_price_range_high">' . give_currency_filter( give_format_amount( $high ) ) . '</span>'; |
|
562 | + $range .= '<span class="give_price_range_high">'.give_currency_filter(give_format_amount($high)).'</span>'; |
|
563 | 563 | |
564 | - return apply_filters( 'give_price_range', $range, $form_id, $low, $high ); |
|
564 | + return apply_filters('give_price_range', $range, $form_id, $low, $high); |
|
565 | 565 | } |
566 | 566 | |
567 | 567 | |
@@ -576,35 +576,35 @@ discard block |
||
576 | 576 | * |
577 | 577 | * @return int ID of the lowest price |
578 | 578 | */ |
579 | -function give_get_lowest_price_id( $form_id = 0 ) { |
|
579 | +function give_get_lowest_price_id($form_id = 0) { |
|
580 | 580 | |
581 | - if ( empty( $form_id ) ) { |
|
581 | + if (empty($form_id)) { |
|
582 | 582 | $form_id = get_the_ID(); |
583 | 583 | } |
584 | 584 | |
585 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
586 | - return give_get_form_price( $form_id ); |
|
585 | + if ( ! give_has_variable_prices($form_id)) { |
|
586 | + return give_get_form_price($form_id); |
|
587 | 587 | } |
588 | 588 | |
589 | - $prices = give_get_variable_prices( $form_id ); |
|
589 | + $prices = give_get_variable_prices($form_id); |
|
590 | 590 | |
591 | 591 | $min = $min_id = 0; |
592 | 592 | |
593 | - if ( ! empty( $prices ) ) { |
|
593 | + if ( ! empty($prices)) { |
|
594 | 594 | |
595 | - foreach ( $prices as $key => $price ) { |
|
595 | + foreach ($prices as $key => $price) { |
|
596 | 596 | |
597 | - if ( empty( $price['_give_amount'] ) ) { |
|
597 | + if (empty($price['_give_amount'])) { |
|
598 | 598 | continue; |
599 | 599 | } |
600 | 600 | |
601 | - if ( ! isset( $min ) ) { |
|
601 | + if ( ! isset($min)) { |
|
602 | 602 | $min = $price['_give_amount']; |
603 | 603 | } else { |
604 | - $min = min( $min, $price['_give_amount'] ); |
|
604 | + $min = min($min, $price['_give_amount']); |
|
605 | 605 | } |
606 | 606 | |
607 | - if ( $price['_give_amount'] == $min ) { |
|
607 | + if ($price['_give_amount'] == $min) { |
|
608 | 608 | $min_id = $price['_give_id']['level_id']; |
609 | 609 | } |
610 | 610 | } |
@@ -622,45 +622,45 @@ discard block |
||
622 | 622 | * |
623 | 623 | * @return float Amount of the lowest price |
624 | 624 | */ |
625 | -function give_get_lowest_price_option( $form_id = 0 ) { |
|
626 | - if ( empty( $form_id ) ) { |
|
625 | +function give_get_lowest_price_option($form_id = 0) { |
|
626 | + if (empty($form_id)) { |
|
627 | 627 | $form_id = get_the_ID(); |
628 | 628 | } |
629 | 629 | |
630 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
631 | - return give_get_form_price( $form_id ); |
|
630 | + if ( ! give_has_variable_prices($form_id)) { |
|
631 | + return give_get_form_price($form_id); |
|
632 | 632 | } |
633 | 633 | |
634 | - $prices = give_get_variable_prices( $form_id ); |
|
634 | + $prices = give_get_variable_prices($form_id); |
|
635 | 635 | |
636 | 636 | $low = 0; |
637 | 637 | |
638 | - if ( ! empty( $prices ) ) { |
|
638 | + if ( ! empty($prices)) { |
|
639 | 639 | |
640 | 640 | $min = $min_id = 0; |
641 | 641 | |
642 | - foreach ( $prices as $key => $price ) { |
|
642 | + foreach ($prices as $key => $price) { |
|
643 | 643 | |
644 | - if ( empty( $price['_give_amount'] ) ) { |
|
644 | + if (empty($price['_give_amount'])) { |
|
645 | 645 | continue; |
646 | 646 | } |
647 | 647 | |
648 | - if ( ! isset( $min ) ) { |
|
648 | + if ( ! isset($min)) { |
|
649 | 649 | $min = $price['_give_amount']; |
650 | 650 | } else { |
651 | - $min = min( $min, give_sanitize_amount( $price['_give_amount'] ) ); |
|
651 | + $min = min($min, give_sanitize_amount($price['_give_amount'])); |
|
652 | 652 | } |
653 | 653 | |
654 | - if ( $price['_give_amount'] == $min ) { |
|
654 | + if ($price['_give_amount'] == $min) { |
|
655 | 655 | $min_id = $key; |
656 | 656 | } |
657 | 657 | } |
658 | 658 | |
659 | - $low = $prices[ $min_id ]['_give_amount']; |
|
659 | + $low = $prices[$min_id]['_give_amount']; |
|
660 | 660 | |
661 | 661 | } |
662 | 662 | |
663 | - return give_sanitize_amount( $low ); |
|
663 | + return give_sanitize_amount($low); |
|
664 | 664 | } |
665 | 665 | |
666 | 666 | /** |
@@ -672,41 +672,41 @@ discard block |
||
672 | 672 | * |
673 | 673 | * @return float Amount of the highest price |
674 | 674 | */ |
675 | -function give_get_highest_price_option( $form_id = 0 ) { |
|
675 | +function give_get_highest_price_option($form_id = 0) { |
|
676 | 676 | |
677 | - if ( empty( $form_id ) ) { |
|
677 | + if (empty($form_id)) { |
|
678 | 678 | $form_id = get_the_ID(); |
679 | 679 | } |
680 | 680 | |
681 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
682 | - return give_get_form_price( $form_id ); |
|
681 | + if ( ! give_has_variable_prices($form_id)) { |
|
682 | + return give_get_form_price($form_id); |
|
683 | 683 | } |
684 | 684 | |
685 | - $prices = give_get_variable_prices( $form_id ); |
|
685 | + $prices = give_get_variable_prices($form_id); |
|
686 | 686 | |
687 | 687 | $high = 0.00; |
688 | 688 | |
689 | - if ( ! empty( $prices ) ) { |
|
689 | + if ( ! empty($prices)) { |
|
690 | 690 | |
691 | 691 | $max_id = $max = 0; |
692 | 692 | |
693 | - foreach ( $prices as $key => $price ) { |
|
694 | - if ( empty( $price['_give_amount'] ) ) { |
|
693 | + foreach ($prices as $key => $price) { |
|
694 | + if (empty($price['_give_amount'])) { |
|
695 | 695 | continue; |
696 | 696 | } |
697 | - $give_amount = give_sanitize_amount( $price['_give_amount'] ); |
|
697 | + $give_amount = give_sanitize_amount($price['_give_amount']); |
|
698 | 698 | |
699 | - $max = max( $max, $give_amount ); |
|
699 | + $max = max($max, $give_amount); |
|
700 | 700 | |
701 | - if ( $give_amount == $max ) { |
|
701 | + if ($give_amount == $max) { |
|
702 | 702 | $max_id = $key; |
703 | 703 | } |
704 | 704 | } |
705 | 705 | |
706 | - $high = $prices[ $max_id ]['_give_amount']; |
|
706 | + $high = $prices[$max_id]['_give_amount']; |
|
707 | 707 | } |
708 | 708 | |
709 | - return give_sanitize_amount( $high ); |
|
709 | + return give_sanitize_amount($high); |
|
710 | 710 | } |
711 | 711 | |
712 | 712 | /** |
@@ -718,15 +718,15 @@ discard block |
||
718 | 718 | * |
719 | 719 | * @return mixed string|int Price of the form |
720 | 720 | */ |
721 | -function give_get_form_price( $form_id = 0 ) { |
|
721 | +function give_get_form_price($form_id = 0) { |
|
722 | 722 | |
723 | - if ( empty( $form_id ) ) { |
|
723 | + if (empty($form_id)) { |
|
724 | 724 | return false; |
725 | 725 | } |
726 | 726 | |
727 | - $form = new Give_Donate_Form( $form_id ); |
|
727 | + $form = new Give_Donate_Form($form_id); |
|
728 | 728 | |
729 | - return $form->__get( 'price' ); |
|
729 | + return $form->__get('price'); |
|
730 | 730 | } |
731 | 731 | |
732 | 732 | /** |
@@ -738,15 +738,15 @@ discard block |
||
738 | 738 | * |
739 | 739 | * @return mixed string|int Minimum price of the form |
740 | 740 | */ |
741 | -function give_get_form_minimum_price( $form_id = 0 ) { |
|
741 | +function give_get_form_minimum_price($form_id = 0) { |
|
742 | 742 | |
743 | - if ( empty( $form_id ) ) { |
|
743 | + if (empty($form_id)) { |
|
744 | 744 | return false; |
745 | 745 | } |
746 | 746 | |
747 | - $form = new Give_Donate_Form( $form_id ); |
|
747 | + $form = new Give_Donate_Form($form_id); |
|
748 | 748 | |
749 | - return $form->__get( 'minimum_price' ); |
|
749 | + return $form->__get('minimum_price'); |
|
750 | 750 | |
751 | 751 | } |
752 | 752 | |
@@ -761,51 +761,51 @@ discard block |
||
761 | 761 | * |
762 | 762 | * @return int $formatted_price |
763 | 763 | */ |
764 | -function give_price( $form_id = 0, $echo = true, $price_id = false ) { |
|
764 | +function give_price($form_id = 0, $echo = true, $price_id = false) { |
|
765 | 765 | |
766 | - if ( empty( $form_id ) ) { |
|
766 | + if (empty($form_id)) { |
|
767 | 767 | $form_id = get_the_ID(); |
768 | 768 | } |
769 | 769 | |
770 | - if ( give_has_variable_prices( $form_id ) ) { |
|
770 | + if (give_has_variable_prices($form_id)) { |
|
771 | 771 | |
772 | - $prices = give_get_variable_prices( $form_id ); |
|
772 | + $prices = give_get_variable_prices($form_id); |
|
773 | 773 | |
774 | - if ( false !== $price_id ) { |
|
774 | + if (false !== $price_id) { |
|
775 | 775 | |
776 | 776 | // loop through multi-prices to see which is default |
777 | - foreach ( $prices as $price ) { |
|
777 | + foreach ($prices as $price) { |
|
778 | 778 | // this is the default price |
779 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
779 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
780 | 780 | $price = (float) $price['_give_amount']; |
781 | 781 | }; |
782 | 782 | } |
783 | 783 | } else { |
784 | 784 | |
785 | - $price = give_get_lowest_price_option( $form_id ); |
|
785 | + $price = give_get_lowest_price_option($form_id); |
|
786 | 786 | } |
787 | 787 | |
788 | - $price = give_sanitize_amount( $price ); |
|
788 | + $price = give_sanitize_amount($price); |
|
789 | 789 | |
790 | 790 | } else { |
791 | 791 | |
792 | - $price = give_get_form_price( $form_id ); |
|
792 | + $price = give_get_form_price($form_id); |
|
793 | 793 | |
794 | 794 | } |
795 | 795 | |
796 | - $price = apply_filters( 'give_form_price', give_sanitize_amount( $price ), $form_id ); |
|
797 | - $formatted_price = '<span class="give_price" id="give_price_' . $form_id . '">' . $price . '</span>'; |
|
798 | - $formatted_price = apply_filters( 'give_form_price_after_html', $formatted_price, $form_id, $price ); |
|
796 | + $price = apply_filters('give_form_price', give_sanitize_amount($price), $form_id); |
|
797 | + $formatted_price = '<span class="give_price" id="give_price_'.$form_id.'">'.$price.'</span>'; |
|
798 | + $formatted_price = apply_filters('give_form_price_after_html', $formatted_price, $form_id, $price); |
|
799 | 799 | |
800 | - if ( $echo ) { |
|
800 | + if ($echo) { |
|
801 | 801 | echo $formatted_price; |
802 | 802 | } else { |
803 | 803 | return $formatted_price; |
804 | 804 | } |
805 | 805 | } |
806 | 806 | |
807 | -add_filter( 'give_form_price', 'give_format_amount', 10 ); |
|
808 | -add_filter( 'give_form_price', 'give_currency_filter', 20 ); |
|
807 | +add_filter('give_form_price', 'give_format_amount', 10); |
|
808 | +add_filter('give_form_price', 'give_currency_filter', 20); |
|
809 | 809 | |
810 | 810 | |
811 | 811 | /** |
@@ -818,19 +818,19 @@ discard block |
||
818 | 818 | * |
819 | 819 | * @return float $amount Amount of the price option |
820 | 820 | */ |
821 | -function give_get_price_option_amount( $form_id = 0, $price_id = 0 ) { |
|
822 | - $prices = give_get_variable_prices( $form_id ); |
|
821 | +function give_get_price_option_amount($form_id = 0, $price_id = 0) { |
|
822 | + $prices = give_get_variable_prices($form_id); |
|
823 | 823 | |
824 | 824 | $amount = 0.00; |
825 | 825 | |
826 | - foreach ( $prices as $price ) { |
|
827 | - if ( isset( $price['_give_id']['level_id'] ) && $price['_give_id']['level_id'] == $price_id ) { |
|
828 | - $amount = isset( $price['_give_amount'] ) ? $price['_give_amount'] : 0.00; |
|
826 | + foreach ($prices as $price) { |
|
827 | + if (isset($price['_give_id']['level_id']) && $price['_give_id']['level_id'] == $price_id) { |
|
828 | + $amount = isset($price['_give_amount']) ? $price['_give_amount'] : 0.00; |
|
829 | 829 | break; |
830 | 830 | }; |
831 | 831 | } |
832 | 832 | |
833 | - return apply_filters( 'give_get_price_option_amount', give_sanitize_amount( $amount ), $form_id, $price_id ); |
|
833 | + return apply_filters('give_get_price_option_amount', give_sanitize_amount($amount), $form_id, $price_id); |
|
834 | 834 | } |
835 | 835 | |
836 | 836 | /** |
@@ -842,13 +842,13 @@ discard block |
||
842 | 842 | * |
843 | 843 | * @return mixed string|int Goal of the form |
844 | 844 | */ |
845 | -function give_get_form_goal( $form_id = 0 ) { |
|
845 | +function give_get_form_goal($form_id = 0) { |
|
846 | 846 | |
847 | - if ( empty( $form_id ) ) { |
|
847 | + if (empty($form_id)) { |
|
848 | 848 | return false; |
849 | 849 | } |
850 | 850 | |
851 | - $form = new Give_Donate_Form( $form_id ); |
|
851 | + $form = new Give_Donate_Form($form_id); |
|
852 | 852 | |
853 | 853 | return $form->goal; |
854 | 854 | |
@@ -864,27 +864,27 @@ discard block |
||
864 | 864 | * |
865 | 865 | * @return string $formatted_goal |
866 | 866 | */ |
867 | -function give_goal( $form_id = 0, $echo = true ) { |
|
867 | +function give_goal($form_id = 0, $echo = true) { |
|
868 | 868 | |
869 | - if ( empty( $form_id ) ) { |
|
869 | + if (empty($form_id)) { |
|
870 | 870 | $form_id = get_the_ID(); |
871 | 871 | } |
872 | 872 | |
873 | - $goal = give_get_form_goal( $form_id ); |
|
873 | + $goal = give_get_form_goal($form_id); |
|
874 | 874 | |
875 | - $goal = apply_filters( 'give_form_goal', give_sanitize_amount( $goal ), $form_id ); |
|
876 | - $formatted_goal = '<span class="give_price" id="give_price_' . $form_id . '">' . $goal . '</span>'; |
|
877 | - $formatted_goal = apply_filters( 'give_form_price_after_html', $formatted_goal, $form_id, $goal ); |
|
875 | + $goal = apply_filters('give_form_goal', give_sanitize_amount($goal), $form_id); |
|
876 | + $formatted_goal = '<span class="give_price" id="give_price_'.$form_id.'">'.$goal.'</span>'; |
|
877 | + $formatted_goal = apply_filters('give_form_price_after_html', $formatted_goal, $form_id, $goal); |
|
878 | 878 | |
879 | - if ( $echo ) { |
|
879 | + if ($echo) { |
|
880 | 880 | echo $formatted_goal; |
881 | 881 | } else { |
882 | 882 | return $formatted_goal; |
883 | 883 | } |
884 | 884 | } |
885 | 885 | |
886 | -add_filter( 'give_form_goal', 'give_format_amount', 10 ); |
|
887 | -add_filter( 'give_form_goal', 'give_currency_filter', 20 ); |
|
886 | +add_filter('give_form_goal', 'give_format_amount', 10); |
|
887 | +add_filter('give_form_goal', 'give_currency_filter', 20); |
|
888 | 888 | |
889 | 889 | |
890 | 890 | /** |
@@ -896,12 +896,12 @@ discard block |
||
896 | 896 | * |
897 | 897 | * @return bool $ret Whether or not the logged_in_only setting is set |
898 | 898 | */ |
899 | -function give_logged_in_only( $form_id ) { |
|
899 | +function give_logged_in_only($form_id) { |
|
900 | 900 | // If _give_logged_in_only is set to enable then guest can donate from that specific form. |
901 | 901 | // Other wise it is member only donation form. |
902 | - $ret = ! give_is_setting_enabled( get_post_meta( $form_id, '_give_logged_in_only', true ) ); |
|
902 | + $ret = ! give_is_setting_enabled(get_post_meta($form_id, '_give_logged_in_only', true)); |
|
903 | 903 | |
904 | - return (bool) apply_filters( 'give_logged_in_only', $ret, $form_id ); |
|
904 | + return (bool) apply_filters('give_logged_in_only', $ret, $form_id); |
|
905 | 905 | } |
906 | 906 | |
907 | 907 | |
@@ -914,11 +914,11 @@ discard block |
||
914 | 914 | * |
915 | 915 | * @return string |
916 | 916 | */ |
917 | -function give_show_login_register_option( $form_id ) { |
|
917 | +function give_show_login_register_option($form_id) { |
|
918 | 918 | |
919 | - $show_register_form = get_post_meta( $form_id, '_give_show_register_form', true ); |
|
919 | + $show_register_form = get_post_meta($form_id, '_give_show_register_form', true); |
|
920 | 920 | |
921 | - return apply_filters( 'give_show_register_form', $show_register_form, $form_id ); |
|
921 | + return apply_filters('give_show_register_form', $show_register_form, $form_id); |
|
922 | 922 | |
923 | 923 | } |
924 | 924 | |
@@ -934,12 +934,12 @@ discard block |
||
934 | 934 | * |
935 | 935 | * @return array |
936 | 936 | */ |
937 | -function _give_get_prefill_form_field_values( $form_id ) { |
|
937 | +function _give_get_prefill_form_field_values($form_id) { |
|
938 | 938 | $logged_in_donor_info = array(); |
939 | 939 | |
940 | - if ( is_user_logged_in() ) : |
|
941 | - $donor_data = get_userdata( get_current_user_id() ); |
|
942 | - $donor_address = get_user_meta( get_current_user_id(), '_give_user_address', true ); |
|
940 | + if (is_user_logged_in()) : |
|
941 | + $donor_data = get_userdata(get_current_user_id()); |
|
942 | + $donor_address = get_user_meta(get_current_user_id(), '_give_user_address', true); |
|
943 | 943 | |
944 | 944 | $logged_in_donor_info = array( |
945 | 945 | // First name. |
@@ -952,42 +952,42 @@ discard block |
||
952 | 952 | 'give_email' => $donor_data->user_email, |
953 | 953 | |
954 | 954 | // Street address 1. |
955 | - 'card_address' => ( ! empty( $donor_address['line1'] ) ? $donor_address['line1'] : '' ), |
|
955 | + 'card_address' => ( ! empty($donor_address['line1']) ? $donor_address['line1'] : ''), |
|
956 | 956 | |
957 | 957 | // Street address 2. |
958 | - 'card_address_2' => ( ! empty( $donor_address['line2'] ) ? $donor_address['line2'] : '' ), |
|
958 | + 'card_address_2' => ( ! empty($donor_address['line2']) ? $donor_address['line2'] : ''), |
|
959 | 959 | |
960 | 960 | // Country. |
961 | - 'billing_country' => ( ! empty( $donor_address['country'] ) ? $donor_address['country'] : '' ), |
|
961 | + 'billing_country' => ( ! empty($donor_address['country']) ? $donor_address['country'] : ''), |
|
962 | 962 | |
963 | 963 | // State. |
964 | - 'card_state' => ( ! empty( $donor_address['state'] ) ? $donor_address['state'] : '' ), |
|
964 | + 'card_state' => ( ! empty($donor_address['state']) ? $donor_address['state'] : ''), |
|
965 | 965 | |
966 | 966 | // City. |
967 | - 'card_city' => ( ! empty( $donor_address['city'] ) ? $donor_address['city'] : '' ), |
|
967 | + 'card_city' => ( ! empty($donor_address['city']) ? $donor_address['city'] : ''), |
|
968 | 968 | |
969 | 969 | // Zipcode |
970 | - 'card_zip' => ( ! empty( $donor_address['zip'] ) ? $donor_address['zip'] : '' ), |
|
970 | + 'card_zip' => ( ! empty($donor_address['zip']) ? $donor_address['zip'] : ''), |
|
971 | 971 | ); |
972 | 972 | endif; |
973 | 973 | |
974 | 974 | // Bailout: Auto fill form field values only form form which donor is donating. |
975 | 975 | if ( |
976 | - empty( $_GET['form-id'] ) |
|
976 | + empty($_GET['form-id']) |
|
977 | 977 | || ! $form_id |
978 | - || ( $form_id !== absint( $_GET['form-id'] ) ) |
|
978 | + || ($form_id !== absint($_GET['form-id'])) |
|
979 | 979 | ) { |
980 | 980 | return $logged_in_donor_info; |
981 | 981 | } |
982 | 982 | |
983 | 983 | // Get purchase data. |
984 | - $give_purchase_data = Give()->session->get( 'give_purchase' ); |
|
984 | + $give_purchase_data = Give()->session->get('give_purchase'); |
|
985 | 985 | |
986 | 986 | // Get donor info from form data. |
987 | - $give_donor_info_in_session = empty( $give_purchase_data['post_data'] ) |
|
987 | + $give_donor_info_in_session = empty($give_purchase_data['post_data']) |
|
988 | 988 | ? array() |
989 | 989 | : $give_purchase_data['post_data']; |
990 | 990 | |
991 | 991 | // Output. |
992 | - return wp_parse_args( $give_donor_info_in_session, $logged_in_donor_info ); |
|
992 | + return wp_parse_args($give_donor_info_in_session, $logged_in_donor_info); |
|
993 | 993 | } |
@@ -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 | |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | * |
20 | 20 | * @since 1.0 |
21 | 21 | */ |
22 | -class Give_Forms_Widget extends WP_Widget{ |
|
22 | +class Give_Forms_Widget extends WP_Widget { |
|
23 | 23 | /** |
24 | 24 | * The widget class name |
25 | 25 | * |
@@ -30,19 +30,19 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * Instantiate the class |
32 | 32 | */ |
33 | - public function __construct(){ |
|
34 | - $this->self = get_class( $this ); |
|
33 | + public function __construct() { |
|
34 | + $this->self = get_class($this); |
|
35 | 35 | |
36 | 36 | parent::__construct( |
37 | - strtolower( $this->self ), |
|
38 | - esc_html__( 'Give - Donation Form', 'give' ), |
|
37 | + strtolower($this->self), |
|
38 | + esc_html__('Give - Donation Form', 'give'), |
|
39 | 39 | array( |
40 | - 'description' => esc_html__( 'Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give' ) |
|
40 | + 'description' => esc_html__('Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give') |
|
41 | 41 | ) |
42 | 42 | ); |
43 | 43 | |
44 | - add_action( 'widgets_init', array( $this, 'widget_init' ) ); |
|
45 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_widget_scripts' ) ); |
|
44 | + add_action('widgets_init', array($this, 'widget_init')); |
|
45 | + add_action('admin_enqueue_scripts', array($this, 'admin_widget_scripts')); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -52,23 +52,23 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return void |
54 | 54 | */ |
55 | - public function admin_widget_scripts( $hook ){ |
|
55 | + public function admin_widget_scripts($hook) { |
|
56 | 56 | // Directories of assets |
57 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/admin/'; |
|
58 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
59 | - $css_dir = GIVE_PLUGIN_URL . 'assets/css/'; |
|
57 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/admin/'; |
|
58 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
59 | + $css_dir = GIVE_PLUGIN_URL.'assets/css/'; |
|
60 | 60 | |
61 | 61 | // Use minified libraries if SCRIPT_DEBUG is turned off |
62 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
62 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
63 | 63 | |
64 | 64 | // Widget Script |
65 | - if ( $hook == 'widgets.php' ) { |
|
65 | + if ($hook == 'widgets.php') { |
|
66 | 66 | |
67 | - wp_enqueue_style( 'give-qtip-css', $css_dir . 'jquery.qtip' . $suffix . '.css' ); |
|
67 | + wp_enqueue_style('give-qtip-css', $css_dir.'jquery.qtip'.$suffix.'.css'); |
|
68 | 68 | |
69 | - wp_enqueue_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION ); |
|
69 | + wp_enqueue_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION); |
|
70 | 70 | |
71 | - wp_enqueue_script( 'give-admin-widgets-scripts', $js_dir . 'admin-widgets' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
71 | + wp_enqueue_script('give-admin-widgets-scripts', $js_dir.'admin-widgets'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | * before_widget, and after_widget. |
80 | 80 | * @param array $instance The settings for the particular instance of the widget. |
81 | 81 | */ |
82 | - public function widget( $args, $instance ){ |
|
83 | - $title = !empty( $instance['title'] ) ? $instance['title'] : ''; |
|
84 | - $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); |
|
82 | + public function widget($args, $instance) { |
|
83 | + $title = ! empty($instance['title']) ? $instance['title'] : ''; |
|
84 | + $title = apply_filters('widget_title', $title, $instance, $this->id_base); |
|
85 | 85 | |
86 | 86 | echo $args['before_widget']; |
87 | 87 | |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @since 1.0 |
92 | 92 | */ |
93 | - do_action( 'give_before_forms_widget' ); |
|
93 | + do_action('give_before_forms_widget'); |
|
94 | 94 | |
95 | - echo $title ? $args['before_title'] . $title . $args['after_title'] : ''; |
|
95 | + echo $title ? $args['before_title'].$title.$args['after_title'] : ''; |
|
96 | 96 | |
97 | - give_get_donation_form( $instance ); |
|
97 | + give_get_donation_form($instance); |
|
98 | 98 | |
99 | 99 | echo $args['after_widget']; |
100 | 100 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * |
104 | 104 | * @since 1.0 |
105 | 105 | */ |
106 | - do_action( 'give_after_forms_widget' ); |
|
106 | + do_action('give_after_forms_widget'); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return string |
115 | 115 | */ |
116 | - public function form( $instance ){ |
|
116 | + public function form($instance) { |
|
117 | 117 | $defaults = array( |
118 | 118 | 'title' => '', |
119 | 119 | 'id' => '', |
@@ -122,77 +122,77 @@ discard block |
||
122 | 122 | 'show_content' => 'none', |
123 | 123 | ); |
124 | 124 | |
125 | - $instance = wp_parse_args( (array) $instance, $defaults ); |
|
125 | + $instance = wp_parse_args((array) $instance, $defaults); |
|
126 | 126 | |
127 | 127 | // Backward compatibility: Set float labels as default if, it was set as empty previous. |
128 | - $instance['float_labels'] = empty( $instance['float_labels'] ) ? 'global' : $instance['float_labels']; |
|
128 | + $instance['float_labels'] = empty($instance['float_labels']) ? 'global' : $instance['float_labels']; |
|
129 | 129 | |
130 | 130 | // Query Give Forms |
131 | 131 | $args = array( |
132 | 132 | 'post_type' => 'give_forms', |
133 | - 'posts_per_page' => - 1, |
|
133 | + 'posts_per_page' => -1, |
|
134 | 134 | 'post_status' => 'publish', |
135 | 135 | ); |
136 | 136 | |
137 | - $give_forms = get_posts( $args ); |
|
137 | + $give_forms = get_posts($args); |
|
138 | 138 | |
139 | 139 | // Widget: Title |
140 | 140 | |
141 | 141 | ?><p> |
142 | - <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'give' ); ?></label> |
|
143 | - <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php esc_attr_e( $instance['title'] ); ?>" /><br> |
|
144 | - <small class="give-field-description"><?php esc_html_e( 'Leave blank to hide the widget title.', 'give' ); ?></small> |
|
142 | + <label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('Title:', 'give'); ?></label> |
|
143 | + <input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php esc_attr_e($instance['title']); ?>" /><br> |
|
144 | + <small class="give-field-description"><?php esc_html_e('Leave blank to hide the widget title.', 'give'); ?></small> |
|
145 | 145 | </p><?php |
146 | 146 | |
147 | 147 | // Widget: Give Form |
148 | 148 | |
149 | 149 | ?><p> |
150 | - <label for="<?php echo esc_attr( $this->get_field_id( 'id' ) ); ?>"><?php esc_html_e( 'Give Form:', 'give' ); ?></label> |
|
151 | - <select class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'id' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'id' ) ); ?>"> |
|
152 | - <option value="current"><?php esc_html_e( '- Select -', 'give' ); ?></option> |
|
153 | - <?php foreach ( $give_forms as $give_form ) { ?> |
|
154 | - <?php $form_title = empty( $give_form->post_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $give_form->ID ) : $give_form->post_title; ?> |
|
155 | - <option <?php selected( absint( $instance['id'] ), $give_form->ID ); ?> value="<?php echo esc_attr( $give_form->ID ); ?>"><?php echo $form_title; ?></option> |
|
150 | + <label for="<?php echo esc_attr($this->get_field_id('id')); ?>"><?php esc_html_e('Give Form:', 'give'); ?></label> |
|
151 | + <select class="widefat" name="<?php echo esc_attr($this->get_field_name('id')); ?>" id="<?php echo esc_attr($this->get_field_id('id')); ?>"> |
|
152 | + <option value="current"><?php esc_html_e('- Select -', 'give'); ?></option> |
|
153 | + <?php foreach ($give_forms as $give_form) { ?> |
|
154 | + <?php $form_title = empty($give_form->post_title) ? sprintf(__('Untitled (#%s)', 'give'), $give_form->ID) : $give_form->post_title; ?> |
|
155 | + <option <?php selected(absint($instance['id']), $give_form->ID); ?> value="<?php echo esc_attr($give_form->ID); ?>"><?php echo $form_title; ?></option> |
|
156 | 156 | <?php } ?> |
157 | 157 | </select><br> |
158 | - <small class="give-field-description"><?php esc_html_e( 'Select a Give Form to embed in this widget.', 'give' ); ?></small> |
|
158 | + <small class="give-field-description"><?php esc_html_e('Select a Give Form to embed in this widget.', 'give'); ?></small> |
|
159 | 159 | </p> |
160 | 160 | |
161 | 161 | <?php // Widget: Display Style ?> |
162 | 162 | <p> |
163 | - <label for="<?php echo esc_attr( $this->get_field_id( 'display_style' ) ); ?>"><?php esc_html_e( 'Display Style:', 'give' ); ?></label><br> |
|
164 | - <label for="<?php echo $this->get_field_id( 'display_style' ); ?>-onpage"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-onpage" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="onpage" <?php checked( $instance['display_style'], 'onpage' ); ?>> <?php echo esc_html__( 'All Fields', 'give' ); ?></label> |
|
165 | - <label for="<?php echo $this->get_field_id( 'display_style' ); ?>-reveal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-reveal" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="reveal" <?php checked( $instance['display_style'], 'reveal' ); ?>> <?php echo esc_html__( 'Reveal', 'give' ); ?></label> |
|
166 | - <label for="<?php echo $this->get_field_id( 'display_style' ); ?>-modal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-modal" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="modal" <?php checked( $instance['display_style'], 'modal' ); ?>> <?php echo esc_html__( 'Modal', 'give' ); ?></label> |
|
167 | - <label for="<?php echo $this->get_field_id( 'display_style' ); ?>-button"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-button" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="button" <?php checked( $instance['display_style'], 'button' ); ?>> <?php echo esc_html__( 'Button', 'give' ); ?></label><br> |
|
163 | + <label for="<?php echo esc_attr($this->get_field_id('display_style')); ?>"><?php esc_html_e('Display Style:', 'give'); ?></label><br> |
|
164 | + <label for="<?php echo $this->get_field_id('display_style'); ?>-onpage"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-onpage" name="<?php echo $this->get_field_name('display_style'); ?>" value="onpage" <?php checked($instance['display_style'], 'onpage'); ?>> <?php echo esc_html__('All Fields', 'give'); ?></label> |
|
165 | + <label for="<?php echo $this->get_field_id('display_style'); ?>-reveal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-reveal" name="<?php echo $this->get_field_name('display_style'); ?>" value="reveal" <?php checked($instance['display_style'], 'reveal'); ?>> <?php echo esc_html__('Reveal', 'give'); ?></label> |
|
166 | + <label for="<?php echo $this->get_field_id('display_style'); ?>-modal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-modal" name="<?php echo $this->get_field_name('display_style'); ?>" value="modal" <?php checked($instance['display_style'], 'modal'); ?>> <?php echo esc_html__('Modal', 'give'); ?></label> |
|
167 | + <label for="<?php echo $this->get_field_id('display_style'); ?>-button"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-button" name="<?php echo $this->get_field_name('display_style'); ?>" value="button" <?php checked($instance['display_style'], 'button'); ?>> <?php echo esc_html__('Button', 'give'); ?></label><br> |
|
168 | 168 | <small class="give-field-description"> |
169 | - <?php echo esc_html__( 'Select a Give Form style.', 'give' ); ?> |
|
169 | + <?php echo esc_html__('Select a Give Form style.', 'give'); ?> |
|
170 | 170 | </small> |
171 | 171 | </p> |
172 | 172 | |
173 | 173 | <?php // Widget: Floating Labels ?> |
174 | 174 | <p> |
175 | - <label for="<?php echo esc_attr( $this->get_field_id( 'float_labels' ) ); ?>"><?php esc_html_e( 'Floating Labels (optional):', 'give' ); ?></label><br> |
|
176 | - <label for="<?php echo $this->get_field_id( 'float_labels' ); ?>-global"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'float_labels' ); ?>-global" name="<?php echo $this->get_field_name( 'float_labels' ); ?>" value="global" <?php checked( $instance['float_labels'], 'global' ); ?>> <?php echo esc_html__( 'Global Option', 'give' ); ?></label> |
|
177 | - <label for="<?php echo $this->get_field_id( 'float_labels' ); ?>-enabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'float_labels' ); ?>-enabled" name="<?php echo $this->get_field_name( 'float_labels' ); ?>" value="enabled" <?php checked( $instance['float_labels'], 'enabled' ); ?>> <?php echo esc_html__( 'Yes', 'give' ); ?></label> |
|
178 | - <label for="<?php echo $this->get_field_id( 'float_labels' ); ?>-disabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'float_labels' ); ?>-disabled" name="<?php echo $this->get_field_name( 'float_labels' ); ?>" value="disabled" <?php checked( $instance['float_labels'], 'disabled' ); ?>> <?php echo esc_html__( 'No', 'give' ); ?></label><br> |
|
175 | + <label for="<?php echo esc_attr($this->get_field_id('float_labels')); ?>"><?php esc_html_e('Floating Labels (optional):', 'give'); ?></label><br> |
|
176 | + <label for="<?php echo $this->get_field_id('float_labels'); ?>-global"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('float_labels'); ?>-global" name="<?php echo $this->get_field_name('float_labels'); ?>" value="global" <?php checked($instance['float_labels'], 'global'); ?>> <?php echo esc_html__('Global Option', 'give'); ?></label> |
|
177 | + <label for="<?php echo $this->get_field_id('float_labels'); ?>-enabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('float_labels'); ?>-enabled" name="<?php echo $this->get_field_name('float_labels'); ?>" value="enabled" <?php checked($instance['float_labels'], 'enabled'); ?>> <?php echo esc_html__('Yes', 'give'); ?></label> |
|
178 | + <label for="<?php echo $this->get_field_id('float_labels'); ?>-disabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('float_labels'); ?>-disabled" name="<?php echo $this->get_field_name('float_labels'); ?>" value="disabled" <?php checked($instance['float_labels'], 'disabled'); ?>> <?php echo esc_html__('No', 'give'); ?></label><br> |
|
179 | 179 | <small class="give-field-description"> |
180 | 180 | <?php |
181 | 181 | printf( |
182 | 182 | /* translators: %s: https://givewp.com/documentation/core/give-forms/creating-give-forms/#floating-labels */ |
183 | - __( 'Override the <a href="%s" target="_blank">floating labels</a> setting for this Give form.', 'give' ), |
|
184 | - esc_url( 'https://givewp.com/documentation/core/give-forms/creating-give-forms/#floating-labels' ) |
|
183 | + __('Override the <a href="%s" target="_blank">floating labels</a> setting for this Give form.', 'give'), |
|
184 | + esc_url('https://givewp.com/documentation/core/give-forms/creating-give-forms/#floating-labels') |
|
185 | 185 | ); |
186 | 186 | ?></small> |
187 | 187 | </p> |
188 | 188 | |
189 | 189 | <?php // Widget: Display Content ?> |
190 | 190 | <p> |
191 | - <label for="<?php echo esc_attr( $this->get_field_id( 'show_content' ) ); ?>"><?php esc_html_e( 'Display Content (optional):', 'give' ); ?></label><br> |
|
192 | - <label for="<?php echo $this->get_field_id( 'show_content' ); ?>-none"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'show_content' ); ?>-none" name="<?php echo $this->get_field_name( 'show_content' ); ?>" value="none" <?php checked( $instance['show_content'], 'none' ); ?>> <?php echo esc_html__( 'None', 'give' ); ?></label> |
|
193 | - <label for="<?php echo $this->get_field_id( 'show_content' ); ?>-above"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'show_content' ); ?>-above" name="<?php echo $this->get_field_name( 'show_content' ); ?>" value="above" <?php checked( $instance['show_content'], 'above' ); ?>> <?php echo esc_html__( 'Above', 'give' ); ?></label> |
|
194 | - <label for="<?php echo $this->get_field_id( 'show_content' ); ?>-below"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'show_content' ); ?>-below" name="<?php echo $this->get_field_name( 'show_content' ); ?>" value="below" <?php checked( $instance['show_content'], 'below' ); ?>> <?php echo esc_html__( 'Below', 'give' ); ?></label><br> |
|
195 | - <small class="give-field-description"><?php esc_html_e( 'Override the display content setting for this Give form.', 'give' ); ?></small> |
|
191 | + <label for="<?php echo esc_attr($this->get_field_id('show_content')); ?>"><?php esc_html_e('Display Content (optional):', 'give'); ?></label><br> |
|
192 | + <label for="<?php echo $this->get_field_id('show_content'); ?>-none"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('show_content'); ?>-none" name="<?php echo $this->get_field_name('show_content'); ?>" value="none" <?php checked($instance['show_content'], 'none'); ?>> <?php echo esc_html__('None', 'give'); ?></label> |
|
193 | + <label for="<?php echo $this->get_field_id('show_content'); ?>-above"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('show_content'); ?>-above" name="<?php echo $this->get_field_name('show_content'); ?>" value="above" <?php checked($instance['show_content'], 'above'); ?>> <?php echo esc_html__('Above', 'give'); ?></label> |
|
194 | + <label for="<?php echo $this->get_field_id('show_content'); ?>-below"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('show_content'); ?>-below" name="<?php echo $this->get_field_name('show_content'); ?>" value="below" <?php checked($instance['show_content'], 'below'); ?>> <?php echo esc_html__('Below', 'give'); ?></label><br> |
|
195 | + <small class="give-field-description"><?php esc_html_e('Override the display content setting for this Give form.', 'give'); ?></small> |
|
196 | 196 | <?php |
197 | 197 | } |
198 | 198 | |
@@ -201,8 +201,8 @@ discard block |
||
201 | 201 | * |
202 | 202 | * @return void |
203 | 203 | */ |
204 | - function widget_init(){ |
|
205 | - register_widget( $this->self ); |
|
204 | + function widget_init() { |
|
205 | + register_widget($this->self); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | /** |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | * |
214 | 214 | * @return array |
215 | 215 | */ |
216 | - public function update( $new_instance, $old_instance ){ |
|
216 | + public function update($new_instance, $old_instance) { |
|
217 | 217 | $this->flush_widget_cache(); |
218 | 218 | |
219 | 219 | return $new_instance; |
@@ -224,8 +224,8 @@ discard block |
||
224 | 224 | * |
225 | 225 | * @return void |
226 | 226 | */ |
227 | - public function flush_widget_cache(){ |
|
228 | - wp_cache_delete( $this->self, 'widget' ); |
|
227 | + public function flush_widget_cache() { |
|
228 | + wp_cache_delete($this->self, 'widget'); |
|
229 | 229 | } |
230 | 230 | } |
231 | 231 |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -27,15 +27,15 @@ discard block |
||
27 | 27 | * |
28 | 28 | * @return bool $ret True if guest checkout is enabled, false otherwise |
29 | 29 | */ |
30 | -function give_no_guest_checkout( $form_id ) { |
|
30 | +function give_no_guest_checkout($form_id) { |
|
31 | 31 | |
32 | 32 | $backtrace = debug_backtrace(); |
33 | 33 | |
34 | - _give_deprecated_function( __FUNCTION__, '1.4.1', null, $backtrace ); |
|
34 | + _give_deprecated_function(__FUNCTION__, '1.4.1', null, $backtrace); |
|
35 | 35 | |
36 | - $ret = get_post_meta( $form_id, '_give_logged_in_only', true ); |
|
36 | + $ret = get_post_meta($form_id, '_give_logged_in_only', true); |
|
37 | 37 | |
38 | - return (bool) apply_filters( 'give_no_guest_checkout', give_is_setting_enabled( $ret ) ); |
|
38 | + return (bool) apply_filters('give_no_guest_checkout', give_is_setting_enabled($ret)); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | |
@@ -50,15 +50,15 @@ discard block |
||
50 | 50 | |
51 | 51 | $backtrace = debug_backtrace(); |
52 | 52 | |
53 | - _give_deprecated_function( __FUNCTION__, '1.8', null, $backtrace ); |
|
53 | + _give_deprecated_function(__FUNCTION__, '1.8', null, $backtrace); |
|
54 | 54 | |
55 | 55 | $views = array( |
56 | - 'sales' => esc_html__( 'Donations', 'give' ), |
|
57 | - 'gateway_errors' => esc_html__( 'Payment Errors', 'give' ), |
|
58 | - 'api_requests' => esc_html__( 'API Requests', 'give' ), |
|
56 | + 'sales' => esc_html__('Donations', 'give'), |
|
57 | + 'gateway_errors' => esc_html__('Payment Errors', 'give'), |
|
58 | + 'api_requests' => esc_html__('API Requests', 'give'), |
|
59 | 59 | ); |
60 | 60 | |
61 | - $views = apply_filters( 'give_log_views', $views ); |
|
61 | + $views = apply_filters('give_log_views', $views); |
|
62 | 62 | |
63 | 63 | return $views; |
64 | 64 | } |
65 | 65 | \ No newline at end of file |
@@ -4,8 +4,8 @@ discard block |
||
4 | 4 | */ |
5 | 5 | $give_map_deprecated_filters = give_deprecated_filters(); |
6 | 6 | |
7 | -foreach ( $give_map_deprecated_filters as $new => $old ) { |
|
8 | - add_filter( $new, 'give_deprecated_filter_mapping', 10, 4 ); |
|
7 | +foreach ($give_map_deprecated_filters as $new => $old) { |
|
8 | + add_filter($new, 'give_deprecated_filter_mapping', 10, 4); |
|
9 | 9 | } |
10 | 10 | |
11 | 11 | /** |
@@ -41,20 +41,20 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @return mixed |
43 | 43 | */ |
44 | -function give_deprecated_filter_mapping( $data, $arg_1 = '', $arg_2 = '', $arg_3 = '' ) { |
|
44 | +function give_deprecated_filter_mapping($data, $arg_1 = '', $arg_2 = '', $arg_3 = '') { |
|
45 | 45 | $give_map_deprecated_filters = give_deprecated_filters(); |
46 | 46 | $filter = current_filter(); |
47 | 47 | |
48 | - if ( isset( $give_map_deprecated_filters[ $filter ] ) ) { |
|
49 | - if ( has_filter( $give_map_deprecated_filters[ $filter ] ) ) { |
|
50 | - $data = apply_filters( $give_map_deprecated_filters[ $filter ], $data, $arg_1, $arg_2, $arg_3 ); |
|
48 | + if (isset($give_map_deprecated_filters[$filter])) { |
|
49 | + if (has_filter($give_map_deprecated_filters[$filter])) { |
|
50 | + $data = apply_filters($give_map_deprecated_filters[$filter], $data, $arg_1, $arg_2, $arg_3); |
|
51 | 51 | |
52 | - if ( ! defined( 'DOING_AJAX' ) ) { |
|
52 | + if ( ! defined('DOING_AJAX')) { |
|
53 | 53 | _give_deprecated_function( |
54 | 54 | sprintf( |
55 | 55 | /* translators: %s: filter name */ |
56 | - __( 'The %s filter' ), |
|
57 | - $give_map_deprecated_filters[ $filter ] |
|
56 | + __('The %s filter'), |
|
57 | + $give_map_deprecated_filters[$filter] |
|
58 | 58 | ), |
59 | 59 | '1.7', |
60 | 60 | $filter |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -24,16 +24,16 @@ discard block |
||
24 | 24 | // Default, built-in gateways |
25 | 25 | $gateways = array( |
26 | 26 | 'paypal' => array( |
27 | - 'admin_label' => __( 'PayPal Standard', 'give' ), |
|
28 | - 'checkout_label' => __( 'PayPal', 'give' ), |
|
27 | + 'admin_label' => __('PayPal Standard', 'give'), |
|
28 | + 'checkout_label' => __('PayPal', 'give'), |
|
29 | 29 | ), |
30 | 30 | 'manual' => array( |
31 | - 'admin_label' => __( 'Test Donation', 'give' ), |
|
32 | - 'checkout_label' => __( 'Test Donation', 'give' ) |
|
31 | + 'admin_label' => __('Test Donation', 'give'), |
|
32 | + 'checkout_label' => __('Test Donation', 'give') |
|
33 | 33 | ), |
34 | 34 | ); |
35 | 35 | |
36 | - return apply_filters( 'give_payment_gateways', $gateways ); |
|
36 | + return apply_filters('give_payment_gateways', $gateways); |
|
37 | 37 | |
38 | 38 | } |
39 | 39 | |
@@ -46,24 +46,24 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @return array $gateway_list All the available gateways |
48 | 48 | */ |
49 | -function give_get_enabled_payment_gateways( $form_id = 0 ) { |
|
49 | +function give_get_enabled_payment_gateways($form_id = 0) { |
|
50 | 50 | |
51 | 51 | $gateways = give_get_payment_gateways(); |
52 | 52 | |
53 | - $enabled = isset( $_POST['gateways'] ) ? $_POST['gateways'] : give_get_option( 'gateways' ); |
|
53 | + $enabled = isset($_POST['gateways']) ? $_POST['gateways'] : give_get_option('gateways'); |
|
54 | 54 | |
55 | 55 | $gateway_list = array(); |
56 | 56 | |
57 | - foreach ( $gateways as $key => $gateway ) { |
|
58 | - if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) { |
|
59 | - $gateway_list[ $key ] = $gateway; |
|
57 | + foreach ($gateways as $key => $gateway) { |
|
58 | + if (isset($enabled[$key]) && $enabled[$key] == 1) { |
|
59 | + $gateway_list[$key] = $gateway; |
|
60 | 60 | } |
61 | 61 | } |
62 | 62 | |
63 | 63 | // Set order of payment gateway in list. |
64 | - $gateway_list = give_get_ordered_payment_gateways( $gateway_list ); |
|
64 | + $gateway_list = give_get_ordered_payment_gateways($gateway_list); |
|
65 | 65 | |
66 | - return apply_filters( 'give_enabled_payment_gateways', $gateway_list, $form_id ); |
|
66 | + return apply_filters('give_enabled_payment_gateways', $gateway_list, $form_id); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -75,12 +75,12 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @return boolean true if enabled, false otherwise |
77 | 77 | */ |
78 | -function give_is_gateway_active( $gateway ) { |
|
78 | +function give_is_gateway_active($gateway) { |
|
79 | 79 | $gateways = give_get_enabled_payment_gateways(); |
80 | 80 | |
81 | - $ret = array_key_exists( $gateway, $gateways ); |
|
81 | + $ret = array_key_exists($gateway, $gateways); |
|
82 | 82 | |
83 | - return apply_filters( 'give_is_gateway_active', $ret, $gateway, $gateways ); |
|
83 | + return apply_filters('give_is_gateway_active', $ret, $gateway, $gateways); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -92,23 +92,23 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @return string Gateway ID |
94 | 94 | */ |
95 | -function give_get_default_gateway( $form_id ) { |
|
95 | +function give_get_default_gateway($form_id) { |
|
96 | 96 | |
97 | 97 | $give_options = give_get_settings(); |
98 | - $default = isset( $give_options['default_gateway'] ) && give_is_gateway_active( $give_options['default_gateway'] ) ? $give_options['default_gateway'] : 'paypal'; |
|
99 | - $form_default = get_post_meta( $form_id, '_give_default_gateway', true ); |
|
98 | + $default = isset($give_options['default_gateway']) && give_is_gateway_active($give_options['default_gateway']) ? $give_options['default_gateway'] : 'paypal'; |
|
99 | + $form_default = get_post_meta($form_id, '_give_default_gateway', true); |
|
100 | 100 | |
101 | 101 | // Single Form settings varies compared to the Global default settings. |
102 | - if ( ! empty( $form_default ) && |
|
102 | + if ( ! empty($form_default) && |
|
103 | 103 | $form_id !== null && |
104 | 104 | $default !== $form_default && |
105 | 105 | $form_default !== 'global' && |
106 | - give_is_gateway_active( $form_default ) |
|
106 | + give_is_gateway_active($form_default) |
|
107 | 107 | ) { |
108 | 108 | $default = $form_default; |
109 | 109 | } |
110 | 110 | |
111 | - return apply_filters( 'give_default_gateway', $default ); |
|
111 | + return apply_filters('give_default_gateway', $default); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -120,18 +120,18 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @return string Gateway admin label |
122 | 122 | */ |
123 | -function give_get_gateway_admin_label( $gateway ) { |
|
123 | +function give_get_gateway_admin_label($gateway) { |
|
124 | 124 | $gateways = give_get_payment_gateways(); |
125 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway; |
|
126 | - $payment = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : false; |
|
125 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway; |
|
126 | + $payment = isset($_GET['id']) ? absint($_GET['id']) : false; |
|
127 | 127 | |
128 | - if ( $gateway == 'manual' && $payment ) { |
|
129 | - if ( give_get_payment_amount( $payment ) == 0 ) { |
|
130 | - $label = __( 'Test Donation', 'give' ); |
|
128 | + if ($gateway == 'manual' && $payment) { |
|
129 | + if (give_get_payment_amount($payment) == 0) { |
|
130 | + $label = __('Test Donation', 'give'); |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | |
134 | - return apply_filters( 'give_gateway_admin_label', $label, $gateway ); |
|
134 | + return apply_filters('give_gateway_admin_label', $label, $gateway); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -143,15 +143,15 @@ discard block |
||
143 | 143 | * |
144 | 144 | * @return string Checkout label for the gateway |
145 | 145 | */ |
146 | -function give_get_gateway_checkout_label( $gateway ) { |
|
146 | +function give_get_gateway_checkout_label($gateway) { |
|
147 | 147 | $gateways = give_get_payment_gateways(); |
148 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway; |
|
148 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway; |
|
149 | 149 | |
150 | - if ( $gateway == 'manual' ) { |
|
151 | - $label = __( 'Test Donation', 'give' ); |
|
150 | + if ($gateway == 'manual') { |
|
151 | + $label = __('Test Donation', 'give'); |
|
152 | 152 | } |
153 | 153 | |
154 | - return apply_filters( 'give_gateway_checkout_label', $label, $gateway ); |
|
154 | + return apply_filters('give_gateway_checkout_label', $label, $gateway); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -163,11 +163,11 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @return array Options the gateway supports |
165 | 165 | */ |
166 | -function give_get_gateway_supports( $gateway ) { |
|
166 | +function give_get_gateway_supports($gateway) { |
|
167 | 167 | $gateways = give_get_enabled_payment_gateways(); |
168 | - $supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array(); |
|
168 | + $supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array(); |
|
169 | 169 | |
170 | - return apply_filters( 'give_gateway_supports', $supports, $gateway ); |
|
170 | + return apply_filters('give_gateway_supports', $supports, $gateway); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
@@ -180,9 +180,9 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @return void |
182 | 182 | */ |
183 | -function give_send_to_gateway( $gateway, $payment_data ) { |
|
183 | +function give_send_to_gateway($gateway, $payment_data) { |
|
184 | 184 | |
185 | - $payment_data['gateway_nonce'] = wp_create_nonce( 'give-gateway' ); |
|
185 | + $payment_data['gateway_nonce'] = wp_create_nonce('give-gateway'); |
|
186 | 186 | |
187 | 187 | /** |
188 | 188 | * Fires while loading payment gateway via AJAX. |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | * |
194 | 194 | * @param array $payment_data All the payment data to be sent to the gateway. |
195 | 195 | */ |
196 | - do_action( "give_gateway_{$gateway}", $payment_data ); |
|
196 | + do_action("give_gateway_{$gateway}", $payment_data); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | |
@@ -207,34 +207,34 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @return string $enabled_gateway The slug of the gateway |
209 | 209 | */ |
210 | -function give_get_chosen_gateway( $form_id ) { |
|
210 | +function give_get_chosen_gateway($form_id) { |
|
211 | 211 | |
212 | - $request_form_id = isset( $_REQUEST['give_form_id'] ) ? $_REQUEST['give_form_id'] : 0; |
|
212 | + $request_form_id = isset($_REQUEST['give_form_id']) ? $_REQUEST['give_form_id'] : 0; |
|
213 | 213 | |
214 | 214 | // Back to check if 'form-id' is present. |
215 | - if ( empty( $request_form_id ) ) { |
|
216 | - $request_form_id = isset( $_REQUEST['form-id'] ) ? $_REQUEST['form-id'] : 0; |
|
215 | + if (empty($request_form_id)) { |
|
216 | + $request_form_id = isset($_REQUEST['form-id']) ? $_REQUEST['form-id'] : 0; |
|
217 | 217 | } |
218 | 218 | |
219 | - $request_payment_mode = isset( $_REQUEST['payment-mode'] ) ? $_REQUEST['payment-mode'] : ''; |
|
219 | + $request_payment_mode = isset($_REQUEST['payment-mode']) ? $_REQUEST['payment-mode'] : ''; |
|
220 | 220 | $chosen = false; |
221 | 221 | |
222 | 222 | // If both 'payment-mode' and 'form-id' then set for only this form. |
223 | - if ( ! empty( $request_form_id ) && $form_id == $request_form_id ) { |
|
223 | + if ( ! empty($request_form_id) && $form_id == $request_form_id) { |
|
224 | 224 | $chosen = $request_payment_mode; |
225 | - } elseif ( empty( $request_form_id ) && $request_payment_mode ) { |
|
225 | + } elseif (empty($request_form_id) && $request_payment_mode) { |
|
226 | 226 | // If no 'form-id' but there is 'payment-mode'. |
227 | 227 | $chosen = $request_payment_mode; |
228 | 228 | } |
229 | 229 | |
230 | 230 | // Get the enable gateway based of chosen var. |
231 | - if ( $chosen && give_is_gateway_active( $chosen ) ) { |
|
232 | - $enabled_gateway = urldecode( $chosen ); |
|
231 | + if ($chosen && give_is_gateway_active($chosen)) { |
|
232 | + $enabled_gateway = urldecode($chosen); |
|
233 | 233 | } else { |
234 | - $enabled_gateway = give_get_default_gateway( $form_id ); |
|
234 | + $enabled_gateway = give_get_default_gateway($form_id); |
|
235 | 235 | } |
236 | 236 | |
237 | - return apply_filters( 'give_chosen_gateway', $enabled_gateway ); |
|
237 | + return apply_filters('give_chosen_gateway', $enabled_gateway); |
|
238 | 238 | |
239 | 239 | } |
240 | 240 | |
@@ -252,8 +252,8 @@ discard block |
||
252 | 252 | * |
253 | 253 | * @return int ID of the new log entry |
254 | 254 | */ |
255 | -function give_record_gateway_error( $title = '', $message = '', $parent = 0 ) { |
|
256 | - return give_record_log( $title, $message, $parent, 'gateway_error' ); |
|
255 | +function give_record_gateway_error($title = '', $message = '', $parent = 0) { |
|
256 | + return give_record_log($title, $message, $parent, 'gateway_error'); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | * |
267 | 267 | * @return int |
268 | 268 | */ |
269 | -function give_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) { |
|
269 | +function give_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') { |
|
270 | 270 | |
271 | 271 | $ret = 0; |
272 | 272 | $args = array( |
@@ -278,9 +278,9 @@ discard block |
||
278 | 278 | 'fields' => 'ids', |
279 | 279 | ); |
280 | 280 | |
281 | - $payments = new WP_Query( $args ); |
|
281 | + $payments = new WP_Query($args); |
|
282 | 282 | |
283 | - if ( $payments ) { |
|
283 | + if ($payments) { |
|
284 | 284 | $ret = $payments->post_count; |
285 | 285 | } |
286 | 286 | |
@@ -297,27 +297,27 @@ discard block |
||
297 | 297 | * |
298 | 298 | * @return array $gateways All the available gateways |
299 | 299 | */ |
300 | -function give_get_ordered_payment_gateways( $gateways ) { |
|
300 | +function give_get_ordered_payment_gateways($gateways) { |
|
301 | 301 | |
302 | 302 | // Get gateways setting. |
303 | - $gateways_setting = isset( $_POST['gateways'] ) ? $_POST['gateways'] : give_get_option( 'gateways' ); |
|
303 | + $gateways_setting = isset($_POST['gateways']) ? $_POST['gateways'] : give_get_option('gateways'); |
|
304 | 304 | |
305 | 305 | // Return from here if we do not have gateways setting. |
306 | - if ( empty( $gateways_setting ) ) { |
|
306 | + if (empty($gateways_setting)) { |
|
307 | 307 | return $gateways; |
308 | 308 | } |
309 | 309 | |
310 | 310 | // Reverse array to order payment gateways. |
311 | - $gateways_setting = array_reverse( $gateways_setting ); |
|
311 | + $gateways_setting = array_reverse($gateways_setting); |
|
312 | 312 | |
313 | 313 | // Reorder gateways array |
314 | - foreach ( $gateways_setting as $gateway_key => $value ) { |
|
314 | + foreach ($gateways_setting as $gateway_key => $value) { |
|
315 | 315 | |
316 | - $new_gateway_value = isset( $gateways[ $gateway_key ] ) ? $gateways[ $gateway_key ] : ''; |
|
317 | - unset( $gateways[ $gateway_key ] ); |
|
316 | + $new_gateway_value = isset($gateways[$gateway_key]) ? $gateways[$gateway_key] : ''; |
|
317 | + unset($gateways[$gateway_key]); |
|
318 | 318 | |
319 | - if ( ! empty( $new_gateway_value ) ) { |
|
320 | - $gateways = array_merge( array( $gateway_key => $new_gateway_value ), $gateways ); |
|
319 | + if ( ! empty($new_gateway_value)) { |
|
320 | + $gateways = array_merge(array($gateway_key => $new_gateway_value), $gateways); |
|
321 | 321 | } |
322 | 322 | } |
323 | 323 | |
@@ -328,5 +328,5 @@ discard block |
||
328 | 328 | * |
329 | 329 | * @param array $gateways All the available gateways |
330 | 330 | */ |
331 | - return apply_filters( 'give_payment_gateways_order', $gateways ); |
|
331 | + return apply_filters('give_payment_gateways_order', $gateways); |
|
332 | 332 | } |
333 | 333 | \ No newline at end of file |
@@ -18,17 +18,17 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @return array |
20 | 20 | */ |
21 | -function give_offline_register_gateway( $gateways ) { |
|
21 | +function give_offline_register_gateway($gateways) { |
|
22 | 22 | // Format: ID => Name |
23 | 23 | $gateways['offline'] = array( |
24 | - 'admin_label' => esc_attr__( 'Offline Donation', 'give' ), |
|
25 | - 'checkout_label' => esc_attr__( 'Offline Donation', 'give' ) |
|
24 | + 'admin_label' => esc_attr__('Offline Donation', 'give'), |
|
25 | + 'checkout_label' => esc_attr__('Offline Donation', 'give') |
|
26 | 26 | ); |
27 | 27 | |
28 | 28 | return $gateways; |
29 | 29 | } |
30 | 30 | |
31 | -add_filter( 'give_payment_gateways', 'give_offline_register_gateway', 1 ); |
|
31 | +add_filter('give_payment_gateways', 'give_offline_register_gateway', 1); |
|
32 | 32 | |
33 | 33 | |
34 | 34 | /** |
@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @return void |
42 | 42 | */ |
43 | -function give_offline_payment_cc_form( $form_id ) { |
|
43 | +function give_offline_payment_cc_form($form_id) { |
|
44 | 44 | // Get offline payment instruction. |
45 | - $offline_instructions = give_get_offline_payment_instruction( $form_id, true ); |
|
45 | + $offline_instructions = give_get_offline_payment_instruction($form_id, true); |
|
46 | 46 | |
47 | 47 | ob_start(); |
48 | 48 | |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | * |
54 | 54 | * @param int $form_id Give form id. |
55 | 55 | */ |
56 | - do_action( 'give_before_offline_info_fields', $form_id ); |
|
56 | + do_action('give_before_offline_info_fields', $form_id); |
|
57 | 57 | ?> |
58 | 58 | <fieldset id="give_offline_payment_info"> |
59 | - <?php echo stripslashes( $offline_instructions ); ?> |
|
59 | + <?php echo stripslashes($offline_instructions); ?> |
|
60 | 60 | </fieldset> |
61 | 61 | <?php |
62 | 62 | /** |
@@ -66,35 +66,35 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @param int $form_id Give form id. |
68 | 68 | */ |
69 | - do_action( 'give_after_offline_info_fields', $form_id ); |
|
69 | + do_action('give_after_offline_info_fields', $form_id); |
|
70 | 70 | |
71 | 71 | echo ob_get_clean(); |
72 | 72 | } |
73 | 73 | |
74 | -add_action( 'give_offline_cc_form', 'give_offline_payment_cc_form' ); |
|
74 | +add_action('give_offline_cc_form', 'give_offline_payment_cc_form'); |
|
75 | 75 | |
76 | 76 | /** |
77 | 77 | * Give Offline Billing Field |
78 | 78 | * |
79 | 79 | * @param $form_id |
80 | 80 | */ |
81 | -function give_offline_billing_fields( $form_id ) { |
|
81 | +function give_offline_billing_fields($form_id) { |
|
82 | 82 | //Enable Default CC fields (billing info) |
83 | - $post_offline_cc_fields = get_post_meta( $form_id, '_give_offline_donation_enable_billing_fields_single', true ); |
|
84 | - $post_offline_customize_option = get_post_meta( $form_id, '_give_customize_offline_donations', true ); |
|
83 | + $post_offline_cc_fields = get_post_meta($form_id, '_give_offline_donation_enable_billing_fields_single', true); |
|
84 | + $post_offline_customize_option = get_post_meta($form_id, '_give_customize_offline_donations', true); |
|
85 | 85 | |
86 | - $global_offline_cc_fields = give_get_option( 'give_offline_donation_enable_billing_fields' ); |
|
86 | + $global_offline_cc_fields = give_get_option('give_offline_donation_enable_billing_fields'); |
|
87 | 87 | |
88 | 88 | //Output CC Address fields if global option is on and user hasn't elected to customize this form's offline donation options |
89 | 89 | if ( |
90 | - ( give_is_setting_enabled( $post_offline_customize_option, 'global' ) && give_is_setting_enabled( $global_offline_cc_fields ) ) |
|
91 | - || ( give_is_setting_enabled( $post_offline_customize_option, 'enabled' ) && give_is_setting_enabled( $post_offline_cc_fields ) ) |
|
90 | + (give_is_setting_enabled($post_offline_customize_option, 'global') && give_is_setting_enabled($global_offline_cc_fields)) |
|
91 | + || (give_is_setting_enabled($post_offline_customize_option, 'enabled') && give_is_setting_enabled($post_offline_cc_fields)) |
|
92 | 92 | ) { |
93 | - give_default_cc_address_fields( $form_id ); |
|
93 | + give_default_cc_address_fields($form_id); |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 | |
97 | -add_action( 'give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1 ); |
|
97 | +add_action('give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1); |
|
98 | 98 | |
99 | 99 | /** |
100 | 100 | * Process the payment |
@@ -105,16 +105,16 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @return void |
107 | 107 | */ |
108 | -function give_offline_process_payment( $purchase_data ) { |
|
108 | +function give_offline_process_payment($purchase_data) { |
|
109 | 109 | |
110 | - $purchase_summary = give_get_purchase_summary( $purchase_data ); |
|
110 | + $purchase_summary = give_get_purchase_summary($purchase_data); |
|
111 | 111 | |
112 | 112 | // setup the payment details |
113 | 113 | $payment_data = array( |
114 | 114 | 'price' => $purchase_data['price'], |
115 | 115 | 'give_form_title' => $purchase_data['post_data']['give-form-title'], |
116 | - 'give_form_id' => intval( $purchase_data['post_data']['give-form-id'] ), |
|
117 | - 'give_price_id' => isset( $purchase_data['post_data']['give-price-id'] ) ? $purchase_data['post_data']['give-price-id'] : '', |
|
116 | + 'give_form_id' => intval($purchase_data['post_data']['give-form-id']), |
|
117 | + 'give_price_id' => isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '', |
|
118 | 118 | 'date' => $purchase_data['date'], |
119 | 119 | 'user_email' => $purchase_data['user_email'], |
120 | 120 | 'purchase_key' => $purchase_data['purchase_key'], |
@@ -126,20 +126,20 @@ discard block |
||
126 | 126 | |
127 | 127 | |
128 | 128 | // record the pending payment |
129 | - $payment = give_insert_payment( $payment_data ); |
|
129 | + $payment = give_insert_payment($payment_data); |
|
130 | 130 | |
131 | - if ( $payment ) { |
|
132 | - give_offline_send_admin_notice( $payment ); |
|
133 | - give_offline_send_donor_instructions( $payment ); |
|
131 | + if ($payment) { |
|
132 | + give_offline_send_admin_notice($payment); |
|
133 | + give_offline_send_donor_instructions($payment); |
|
134 | 134 | give_send_to_success_page(); |
135 | 135 | } else { |
136 | 136 | // if errors are present, send the user back to the donation form so they can be corrected |
137 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
137 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | } |
141 | 141 | |
142 | -add_action( 'give_gateway_offline', 'give_offline_process_payment' ); |
|
142 | +add_action('give_gateway_offline', 'give_offline_process_payment'); |
|
143 | 143 | |
144 | 144 | |
145 | 145 | /** |
@@ -152,59 +152,59 @@ discard block |
||
152 | 152 | * @since 1.0 |
153 | 153 | * @return void |
154 | 154 | */ |
155 | -function give_offline_send_donor_instructions( $payment_id = 0 ) { |
|
155 | +function give_offline_send_donor_instructions($payment_id = 0) { |
|
156 | 156 | |
157 | - $payment_data = give_get_payment_meta( $payment_id ); |
|
158 | - $post_offline_customization_option = get_post_meta( $payment_data['form_id'], '_give_customize_offline_donations', true ); |
|
157 | + $payment_data = give_get_payment_meta($payment_id); |
|
158 | + $post_offline_customization_option = get_post_meta($payment_data['form_id'], '_give_customize_offline_donations', true); |
|
159 | 159 | |
160 | 160 | //Customize email content depending on whether the single form has been customized |
161 | - $email_content = give_get_option( 'global_offline_donation_email' ); |
|
161 | + $email_content = give_get_option('global_offline_donation_email'); |
|
162 | 162 | |
163 | - if ( give_is_setting_enabled( $post_offline_customization_option, 'enabled' ) ) { |
|
164 | - $email_content = get_post_meta( $payment_data['form_id'], '_give_offline_donation_email', true ); |
|
163 | + if (give_is_setting_enabled($post_offline_customization_option, 'enabled')) { |
|
164 | + $email_content = get_post_meta($payment_data['form_id'], '_give_offline_donation_email', true); |
|
165 | 165 | } |
166 | 166 | |
167 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
167 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
168 | 168 | |
169 | 169 | /** |
170 | 170 | * Filters the from name. |
171 | 171 | * |
172 | 172 | * @since 1.7 |
173 | 173 | */ |
174 | - $from_name = apply_filters( 'give_donation_from_name', $from_name, $payment_id, $payment_data ); |
|
174 | + $from_name = apply_filters('give_donation_from_name', $from_name, $payment_id, $payment_data); |
|
175 | 175 | |
176 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
176 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
177 | 177 | |
178 | 178 | /** |
179 | 179 | * Filters the from email. |
180 | 180 | * |
181 | 181 | * @since 1.7 |
182 | 182 | */ |
183 | - $from_email = apply_filters( 'give_donation_from_address', $from_email, $payment_id, $payment_data ); |
|
183 | + $from_email = apply_filters('give_donation_from_address', $from_email, $payment_id, $payment_data); |
|
184 | 184 | |
185 | - $to_email = give_get_payment_user_email( $payment_id ); |
|
185 | + $to_email = give_get_payment_user_email($payment_id); |
|
186 | 186 | |
187 | - $subject = give_get_option( 'offline_donation_subject', __( 'Offline Donation Instructions', 'give' ) ); |
|
188 | - if ( give_is_setting_enabled( $post_offline_customization_option, 'enabled' ) ) { |
|
189 | - $subject = get_post_meta( $payment_data['form_id'], '_give_offline_donation_subject', true ); |
|
187 | + $subject = give_get_option('offline_donation_subject', __('Offline Donation Instructions', 'give')); |
|
188 | + if (give_is_setting_enabled($post_offline_customization_option, 'enabled')) { |
|
189 | + $subject = get_post_meta($payment_data['form_id'], '_give_offline_donation_subject', true); |
|
190 | 190 | } |
191 | 191 | |
192 | - $subject = apply_filters( 'give_offline_donation_subject', wp_strip_all_tags( $subject ), $payment_id ); |
|
193 | - $subject = give_do_email_tags( $subject, $payment_id ); |
|
192 | + $subject = apply_filters('give_offline_donation_subject', wp_strip_all_tags($subject), $payment_id); |
|
193 | + $subject = give_do_email_tags($subject, $payment_id); |
|
194 | 194 | |
195 | - $attachments = apply_filters( 'give_offline_donation_attachments', array(), $payment_id, $payment_data ); |
|
196 | - $message = give_do_email_tags( $email_content, $payment_id ); |
|
195 | + $attachments = apply_filters('give_offline_donation_attachments', array(), $payment_id, $payment_data); |
|
196 | + $message = give_do_email_tags($email_content, $payment_id); |
|
197 | 197 | |
198 | 198 | $emails = Give()->emails; |
199 | 199 | |
200 | - $emails->__set( 'from_name', $from_name ); |
|
201 | - $emails->__set( 'from_email', $from_email ); |
|
202 | - $emails->__set( 'heading', __( 'Offline Donation Instructions', 'give' ) ); |
|
200 | + $emails->__set('from_name', $from_name); |
|
201 | + $emails->__set('from_email', $from_email); |
|
202 | + $emails->__set('heading', __('Offline Donation Instructions', 'give')); |
|
203 | 203 | |
204 | - $headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data ); |
|
205 | - $emails->__set( 'headers', $headers ); |
|
204 | + $headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data); |
|
205 | + $emails->__set('headers', $headers); |
|
206 | 206 | |
207 | - $emails->send( $to_email, $subject, $message, $attachments ); |
|
207 | + $emails->send($to_email, $subject, $message, $attachments); |
|
208 | 208 | |
209 | 209 | } |
210 | 210 | |
@@ -221,52 +221,52 @@ discard block |
||
221 | 221 | * @return void |
222 | 222 | * |
223 | 223 | */ |
224 | -function give_offline_send_admin_notice( $payment_id = 0 ) { |
|
224 | +function give_offline_send_admin_notice($payment_id = 0) { |
|
225 | 225 | |
226 | 226 | /* Send an email notification to the admin */ |
227 | 227 | $admin_email = give_get_admin_notice_emails(); |
228 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
228 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
229 | 229 | |
230 | - if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) { |
|
231 | - $user_data = get_userdata( $user_info['id'] ); |
|
230 | + if (isset($user_info['id']) && $user_info['id'] > 0) { |
|
231 | + $user_data = get_userdata($user_info['id']); |
|
232 | 232 | $name = $user_data->display_name; |
233 | - } elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) { |
|
234 | - $name = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
233 | + } elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) { |
|
234 | + $name = $user_info['first_name'].' '.$user_info['last_name']; |
|
235 | 235 | } else { |
236 | 236 | $name = $user_info['email']; |
237 | 237 | } |
238 | 238 | |
239 | - $amount = give_currency_filter( give_format_amount( give_get_payment_amount( $payment_id ) ) ); |
|
239 | + $amount = give_currency_filter(give_format_amount(give_get_payment_amount($payment_id))); |
|
240 | 240 | |
241 | - $admin_subject = apply_filters( 'give_offline_admin_donation_notification_subject', __( 'New Pending Donation', 'give' ), $payment_id ); |
|
241 | + $admin_subject = apply_filters('give_offline_admin_donation_notification_subject', __('New Pending Donation', 'give'), $payment_id); |
|
242 | 242 | |
243 | - $admin_message = __( 'Dear Admin,', 'give' ) . "\n\n"; |
|
244 | - $admin_message .= __( 'An offline donation has been made on your website:', 'give' ) . ' ' . get_bloginfo( 'name' ) . ' '; |
|
245 | - $admin_message .= __( 'Hooray! The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give' ) . "\n\n"; |
|
243 | + $admin_message = __('Dear Admin,', 'give')."\n\n"; |
|
244 | + $admin_message .= __('An offline donation has been made on your website:', 'give').' '.get_bloginfo('name').' '; |
|
245 | + $admin_message .= __('Hooray! The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give')."\n\n"; |
|
246 | 246 | |
247 | 247 | |
248 | - $admin_message .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n"; |
|
249 | - $admin_message .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n\n"; |
|
248 | + $admin_message .= '<strong>'.__('Donor:', 'give').'</strong> {fullname}'."\n"; |
|
249 | + $admin_message .= '<strong>'.__('Amount:', 'give').'</strong> {amount}'."\n\n"; |
|
250 | 250 | |
251 | 251 | $admin_message .= sprintf( |
252 | 252 | '<a href="%1$s">%2$s</a>', |
253 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $payment_id ), |
|
254 | - __( 'Click Here to View and/or Update Donation Details', 'give' ) |
|
255 | - ) . "\n\n"; |
|
253 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id='.$payment_id), |
|
254 | + __('Click Here to View and/or Update Donation Details', 'give') |
|
255 | + )."\n\n"; |
|
256 | 256 | |
257 | - $admin_message = apply_filters( 'give_offline_admin_donation_notification', $admin_message, $payment_id ); |
|
258 | - $admin_message = give_do_email_tags( $admin_message, $payment_id ); |
|
257 | + $admin_message = apply_filters('give_offline_admin_donation_notification', $admin_message, $payment_id); |
|
258 | + $admin_message = give_do_email_tags($admin_message, $payment_id); |
|
259 | 259 | |
260 | - $attachments = apply_filters( 'give_offline_admin_donation_notification_attachments', array(), $payment_id ); |
|
261 | - $admin_headers = apply_filters( 'give_offline_admin_donation_notification_headers', array(), $payment_id ); |
|
260 | + $attachments = apply_filters('give_offline_admin_donation_notification_attachments', array(), $payment_id); |
|
261 | + $admin_headers = apply_filters('give_offline_admin_donation_notification_headers', array(), $payment_id); |
|
262 | 262 | |
263 | 263 | //Send Email |
264 | 264 | $emails = Give()->emails; |
265 | - if ( ! empty( $admin_headers ) ) { |
|
266 | - $emails->__set( 'headers', $admin_headers ); |
|
265 | + if ( ! empty($admin_headers)) { |
|
266 | + $emails->__set('headers', $admin_headers); |
|
267 | 267 | } |
268 | 268 | |
269 | - $emails->send( $admin_email, $admin_subject, $admin_message, $attachments ); |
|
269 | + $emails->send($admin_email, $admin_subject, $admin_message, $attachments); |
|
270 | 270 | |
271 | 271 | } |
272 | 272 | |
@@ -278,20 +278,20 @@ discard block |
||
278 | 278 | * |
279 | 279 | * @return array |
280 | 280 | */ |
281 | -function give_offline_add_settings( $settings ) { |
|
281 | +function give_offline_add_settings($settings) { |
|
282 | 282 | |
283 | 283 | // Bailout: Do not show offline gateways setting in to metabox if its disabled globally. |
284 | - if ( in_array( 'offline', give_get_option( 'gateways' ) ) ) { |
|
284 | + if (in_array('offline', give_get_option('gateways'))) { |
|
285 | 285 | return $settings; |
286 | 286 | } |
287 | 287 | |
288 | 288 | //Vars |
289 | 289 | $prefix = '_give_'; |
290 | 290 | |
291 | - $is_gateway_active = give_is_gateway_active( 'offline' ); |
|
291 | + $is_gateway_active = give_is_gateway_active('offline'); |
|
292 | 292 | |
293 | 293 | //this gateway isn't active |
294 | - if ( ! $is_gateway_active ) { |
|
294 | + if ( ! $is_gateway_active) { |
|
295 | 295 | //return settings and bounce |
296 | 296 | return $settings; |
297 | 297 | } |
@@ -300,34 +300,34 @@ discard block |
||
300 | 300 | $check_settings = array( |
301 | 301 | |
302 | 302 | array( |
303 | - 'name' => __( 'Offline Donations', 'give' ), |
|
304 | - 'desc' => __( 'Do you want to customize the donation instructions for this form?', 'give' ), |
|
305 | - 'id' => $prefix . 'customize_offline_donations', |
|
303 | + 'name' => __('Offline Donations', 'give'), |
|
304 | + 'desc' => __('Do you want to customize the donation instructions for this form?', 'give'), |
|
305 | + 'id' => $prefix.'customize_offline_donations', |
|
306 | 306 | 'type' => 'radio_inline', |
307 | 307 | 'default' => 'global', |
308 | - 'options' => apply_filters( 'give_forms_content_options_select', array( |
|
309 | - 'global' => __( 'Global Options', 'give' ), |
|
310 | - 'enabled' => __( 'Customize', 'give' ), |
|
311 | - 'disabled' => __( 'Disable', 'give' ), |
|
308 | + 'options' => apply_filters('give_forms_content_options_select', array( |
|
309 | + 'global' => __('Global Options', 'give'), |
|
310 | + 'enabled' => __('Customize', 'give'), |
|
311 | + 'disabled' => __('Disable', 'give'), |
|
312 | 312 | ) |
313 | 313 | ), |
314 | 314 | ), |
315 | 315 | array( |
316 | - 'name' => __( 'Billing Fields', 'give' ), |
|
317 | - 'desc' => __( 'This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give' ), |
|
318 | - 'id' => $prefix . 'offline_donation_enable_billing_fields_single', |
|
316 | + 'name' => __('Billing Fields', 'give'), |
|
317 | + 'desc' => __('This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give'), |
|
318 | + 'id' => $prefix.'offline_donation_enable_billing_fields_single', |
|
319 | 319 | 'row_classes' => 'give-subfield', |
320 | 320 | 'type' => 'radio_inline', |
321 | 321 | 'default' => 'disabled', |
322 | 322 | 'options' => array( |
323 | - 'enabled' => __( 'Enabled', 'give' ), |
|
324 | - 'disabled' => __( 'Disabled', 'give' ), |
|
323 | + 'enabled' => __('Enabled', 'give'), |
|
324 | + 'disabled' => __('Disabled', 'give'), |
|
325 | 325 | ), |
326 | 326 | ), |
327 | 327 | array( |
328 | - 'id' => $prefix . 'offline_checkout_notes', |
|
329 | - 'name' => __( 'Donation Instructions', 'give' ), |
|
330 | - 'desc' => __( 'Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ), |
|
328 | + 'id' => $prefix.'offline_checkout_notes', |
|
329 | + 'name' => __('Donation Instructions', 'give'), |
|
330 | + 'desc' => __('Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give'), |
|
331 | 331 | 'default' => give_get_default_offline_donation_content(), |
332 | 332 | 'type' => 'wysiwyg', |
333 | 333 | 'row_classes' => 'give-subfield', |
@@ -336,17 +336,17 @@ discard block |
||
336 | 336 | ) |
337 | 337 | ), |
338 | 338 | array( |
339 | - 'id' => $prefix . 'offline_donation_subject', |
|
340 | - 'name' => __( 'Email Subject', 'give' ), |
|
341 | - 'desc' => __( 'Enter the subject line for the donation receipt email.', 'give' ), |
|
342 | - 'default' => __( '{form_title} - Offline Donation Instructions', 'give' ), |
|
339 | + 'id' => $prefix.'offline_donation_subject', |
|
340 | + 'name' => __('Email Subject', 'give'), |
|
341 | + 'desc' => __('Enter the subject line for the donation receipt email.', 'give'), |
|
342 | + 'default' => __('{form_title} - Offline Donation Instructions', 'give'), |
|
343 | 343 | 'row_classes' => 'give-subfield', |
344 | 344 | 'type' => 'text' |
345 | 345 | ), |
346 | 346 | array( |
347 | - 'id' => $prefix . 'offline_donation_email', |
|
348 | - 'name' => __( 'Email Instructions', 'give' ), |
|
349 | - 'desc' => __( 'Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ), |
|
347 | + 'id' => $prefix.'offline_donation_email', |
|
348 | + 'name' => __('Email Instructions', 'give'), |
|
349 | + 'desc' => __('Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give'), |
|
350 | 350 | 'default' => give_get_default_offline_donation_email_content(), |
351 | 351 | 'type' => 'wysiwyg', |
352 | 352 | 'row_classes' => 'give-subfield', |
@@ -362,10 +362,10 @@ discard block |
||
362 | 362 | ), |
363 | 363 | ); |
364 | 364 | |
365 | - return array_merge( $settings, $check_settings ); |
|
365 | + return array_merge($settings, $check_settings); |
|
366 | 366 | } |
367 | 367 | |
368 | -add_filter( 'give_forms_offline_donations_metabox_fields', 'give_offline_add_settings' ); |
|
368 | +add_filter('give_forms_offline_donations_metabox_fields', 'give_offline_add_settings'); |
|
369 | 369 | |
370 | 370 | |
371 | 371 | /** |
@@ -377,32 +377,32 @@ discard block |
||
377 | 377 | */ |
378 | 378 | function give_get_default_offline_donation_content() { |
379 | 379 | |
380 | - $sitename = get_bloginfo( 'sitename' ); |
|
380 | + $sitename = get_bloginfo('sitename'); |
|
381 | 381 | |
382 | - $default_text = '<p>' . __( 'In order to make an offline donation we ask that you please follow these instructions', 'give' ) . ': </p>'; |
|
382 | + $default_text = '<p>'.__('In order to make an offline donation we ask that you please follow these instructions', 'give').': </p>'; |
|
383 | 383 | $default_text .= '<ol>'; |
384 | 384 | $default_text .= '<li>'; |
385 | 385 | $default_text .= sprintf( |
386 | 386 | /* translators: %s: site name */ |
387 | - __( 'Make a check payable to "%s"', 'give' ), |
|
387 | + __('Make a check payable to "%s"', 'give'), |
|
388 | 388 | $sitename |
389 | 389 | ); |
390 | 390 | $default_text .= '</li>'; |
391 | 391 | $default_text .= '<li>'; |
392 | 392 | $default_text .= sprintf( |
393 | 393 | /* translators: %s: site name */ |
394 | - __( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ), |
|
394 | + __('On the memo line of the check, please indicate that the donation is for "%s"', 'give'), |
|
395 | 395 | $sitename |
396 | 396 | ); |
397 | 397 | $default_text .= '</li>'; |
398 | - $default_text .= '<li>' . __( 'Please mail your check to:', 'give' ) . '</li>'; |
|
398 | + $default_text .= '<li>'.__('Please mail your check to:', 'give').'</li>'; |
|
399 | 399 | $default_text .= '</ol>'; |
400 | - $default_text .= ' <em>' . $sitename . '</em><br>'; |
|
400 | + $default_text .= ' <em>'.$sitename.'</em><br>'; |
|
401 | 401 | $default_text .= ' <em>123 G Street </em><br>'; |
402 | 402 | $default_text .= ' <em>San Diego, CA 92101 </em><br>'; |
403 | - $default_text .= '<p>' . __( 'All contributions will be gratefully acknowledged and are tax deductible.', 'give' ) . '</p>'; |
|
403 | + $default_text .= '<p>'.__('All contributions will be gratefully acknowledged and are tax deductible.', 'give').'</p>'; |
|
404 | 404 | |
405 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
405 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
406 | 406 | |
407 | 407 | } |
408 | 408 | |
@@ -415,34 +415,34 @@ discard block |
||
415 | 415 | */ |
416 | 416 | function give_get_default_offline_donation_email_content() { |
417 | 417 | |
418 | - $sitename = get_bloginfo( 'sitename' ); |
|
419 | - $default_text = '<p>' . __( 'Dear {name},', 'give' ) . '</p>'; |
|
420 | - $default_text .= '<p>' . __( 'Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions:', 'give' ) . '</p>'; |
|
418 | + $sitename = get_bloginfo('sitename'); |
|
419 | + $default_text = '<p>'.__('Dear {name},', 'give').'</p>'; |
|
420 | + $default_text .= '<p>'.__('Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions:', 'give').'</p>'; |
|
421 | 421 | $default_text .= '<ol>'; |
422 | 422 | $default_text .= '<li>'; |
423 | 423 | $default_text .= sprintf( |
424 | 424 | /* translators: %s: site name */ |
425 | - __( 'Make a check payable to "%s"', 'give' ), |
|
425 | + __('Make a check payable to "%s"', 'give'), |
|
426 | 426 | $sitename |
427 | 427 | ); |
428 | 428 | $default_text .= '</li>'; |
429 | 429 | $default_text .= '<li>'; |
430 | 430 | $default_text .= sprintf( |
431 | 431 | /* translators: %s: site name */ |
432 | - __( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ), |
|
432 | + __('On the memo line of the check, please indicate that the donation is for "%s"', 'give'), |
|
433 | 433 | $sitename |
434 | 434 | ); |
435 | 435 | $default_text .= '</li>'; |
436 | - $default_text .= '<li>' . __( 'Please mail your check to:', 'give' ) . '</li>'; |
|
436 | + $default_text .= '<li>'.__('Please mail your check to:', 'give').'</li>'; |
|
437 | 437 | $default_text .= '</ol>'; |
438 | - $default_text .= ' <em>' . $sitename . '</em><br>'; |
|
438 | + $default_text .= ' <em>'.$sitename.'</em><br>'; |
|
439 | 439 | $default_text .= ' <em>123 G Street </em><br>'; |
440 | 440 | $default_text .= ' <em>San Diego, CA 92101 </em><br>'; |
441 | - $default_text .= '<p>' . __( 'Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give' ) . '</p>'; |
|
442 | - $default_text .= '<p>' . __( 'Sincerely,', 'give' ) . '</p>'; |
|
443 | - $default_text .= '<p>' . $sitename . '</p>'; |
|
441 | + $default_text .= '<p>'.__('Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give').'</p>'; |
|
442 | + $default_text .= '<p>'.__('Sincerely,', 'give').'</p>'; |
|
443 | + $default_text .= '<p>'.$sitename.'</p>'; |
|
444 | 444 | |
445 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
445 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
446 | 446 | |
447 | 447 | } |
448 | 448 | |
@@ -456,17 +456,17 @@ discard block |
||
456 | 456 | * |
457 | 457 | * @return string |
458 | 458 | */ |
459 | -function give_offline_donation_receipt_status_notice( $notice, $id ) { |
|
460 | - $payment = new Give_Payment( $id ); |
|
459 | +function give_offline_donation_receipt_status_notice($notice, $id) { |
|
460 | + $payment = new Give_Payment($id); |
|
461 | 461 | |
462 | - if ( 'offline' !== $payment->gateway ) { |
|
462 | + if ('offline' !== $payment->gateway) { |
|
463 | 463 | return $notice; |
464 | 464 | } |
465 | 465 | |
466 | - return give_output_error( __('Payment Pending: Please follow the instructions below to complete your donation.', 'give'), false, 'warning' ); |
|
466 | + return give_output_error(__('Payment Pending: Please follow the instructions below to complete your donation.', 'give'), false, 'warning'); |
|
467 | 467 | } |
468 | 468 | |
469 | -add_filter( 'give_receipt_status_notice', 'give_offline_donation_receipt_status_notice', 10, 2 ); |
|
469 | +add_filter('give_receipt_status_notice', 'give_offline_donation_receipt_status_notice', 10, 2); |
|
470 | 470 | |
471 | 471 | /** |
472 | 472 | * Add offline payment instruction on payment receipt. |
@@ -477,26 +477,26 @@ discard block |
||
477 | 477 | * |
478 | 478 | * @return mixed |
479 | 479 | */ |
480 | -function give_offline_payment_receipt_after( $payment ) { |
|
480 | +function give_offline_payment_receipt_after($payment) { |
|
481 | 481 | // Get payment object. |
482 | - $payment = new Give_Payment( $payment->ID ); |
|
482 | + $payment = new Give_Payment($payment->ID); |
|
483 | 483 | |
484 | 484 | // Bailout. |
485 | - if ( 'offline' !== $payment->gateway ) { |
|
485 | + if ('offline' !== $payment->gateway) { |
|
486 | 486 | return false; |
487 | 487 | } |
488 | 488 | |
489 | 489 | ?> |
490 | 490 | <tr> |
491 | - <td scope="row"><strong><?php esc_html_e( 'Offline Payment Instruction:', 'give' ); ?></strong></td> |
|
491 | + <td scope="row"><strong><?php esc_html_e('Offline Payment Instruction:', 'give'); ?></strong></td> |
|
492 | 492 | <td> |
493 | - <?php echo give_get_offline_payment_instruction( $payment->form_id, true ); ?> |
|
493 | + <?php echo give_get_offline_payment_instruction($payment->form_id, true); ?> |
|
494 | 494 | </td> |
495 | 495 | </tr> |
496 | 496 | <?php |
497 | 497 | } |
498 | 498 | |
499 | -add_filter( 'give_payment_receipt_after', 'give_offline_payment_receipt_after' ); |
|
499 | +add_filter('give_payment_receipt_after', 'give_offline_payment_receipt_after'); |
|
500 | 500 | |
501 | 501 | /** |
502 | 502 | * Get offline payment instructions. |
@@ -508,27 +508,27 @@ discard block |
||
508 | 508 | * |
509 | 509 | * @return string |
510 | 510 | */ |
511 | -function give_get_offline_payment_instruction( $form_id, $wpautop = false ) { |
|
511 | +function give_get_offline_payment_instruction($form_id, $wpautop = false) { |
|
512 | 512 | // Bailout. |
513 | - if ( ! $form_id ) { |
|
513 | + if ( ! $form_id) { |
|
514 | 514 | return ''; |
515 | 515 | } |
516 | 516 | |
517 | - $post_offline_customization_option = get_post_meta( $form_id, '_give_customize_offline_donations', true ); |
|
518 | - $post_offline_instructions = get_post_meta( $form_id, '_give_offline_checkout_notes', true ); |
|
519 | - $global_offline_instruction = give_get_option( 'global_offline_donation_content' ); |
|
517 | + $post_offline_customization_option = get_post_meta($form_id, '_give_customize_offline_donations', true); |
|
518 | + $post_offline_instructions = get_post_meta($form_id, '_give_offline_checkout_notes', true); |
|
519 | + $global_offline_instruction = give_get_option('global_offline_donation_content'); |
|
520 | 520 | $offline_instructions = $global_offline_instruction; |
521 | 521 | |
522 | - if ( $post_offline_customization_option == 'yes' ) { |
|
522 | + if ($post_offline_customization_option == 'yes') { |
|
523 | 523 | $offline_instructions = $post_offline_instructions; |
524 | 524 | } |
525 | 525 | |
526 | - $settings_url = admin_url( 'post.php?post=' . $form_id . '&action=edit&message=1' ); |
|
526 | + $settings_url = admin_url('post.php?post='.$form_id.'&action=edit&message=1'); |
|
527 | 527 | |
528 | 528 | /* translators: %s: form settings url */ |
529 | - $offline_instructions = ! empty( $offline_instructions ) ? $offline_instructions : sprintf( __( 'Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give' ), $settings_url ); |
|
529 | + $offline_instructions = ! empty($offline_instructions) ? $offline_instructions : sprintf(__('Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give'), $settings_url); |
|
530 | 530 | |
531 | - return ( $wpautop ? wpautop( $offline_instructions ) : $offline_instructions ); |
|
531 | + return ($wpautop ? wpautop($offline_instructions) : $offline_instructions); |
|
532 | 532 | } |
533 | 533 | |
534 | 534 | |
@@ -542,16 +542,16 @@ discard block |
||
542 | 542 | * |
543 | 543 | * @return array |
544 | 544 | */ |
545 | -function give_filter_offline_gateway( $gateway_list, $form_id ) { |
|
546 | - if ( $form_id && ! give_is_setting_enabled( get_post_meta( $form_id, '_give_customize_offline_donations', true ), array( 'enabled', 'global' ) ) ) { |
|
547 | - unset( $gateway_list['offline'] ); |
|
545 | +function give_filter_offline_gateway($gateway_list, $form_id) { |
|
546 | + if ($form_id && ! give_is_setting_enabled(get_post_meta($form_id, '_give_customize_offline_donations', true), array('enabled', 'global'))) { |
|
547 | + unset($gateway_list['offline']); |
|
548 | 548 | } |
549 | 549 | |
550 | 550 | // Output. |
551 | 551 | return $gateway_list; |
552 | 552 | } |
553 | 553 | |
554 | -add_filter( 'give_enabled_payment_gateways', 'give_filter_offline_gateway', 10, 2 ); |
|
554 | +add_filter('give_enabled_payment_gateways', 'give_filter_offline_gateway', 10, 2); |
|
555 | 555 | |
556 | 556 | /** |
557 | 557 | * Set default gateway to global default payment gateway |
@@ -565,10 +565,10 @@ discard block |
||
565 | 565 | * |
566 | 566 | * @return void |
567 | 567 | */ |
568 | -function _give_customize_offline_donations_on_save_callback( $meta_key, $meta_value, $postid ) { |
|
569 | - if ( ( 'no' === $meta_value ) && ( 'offline' === get_post_meta( $postid, '_give_default_gateway', true ) ) ) { |
|
570 | - update_post_meta( $postid, '_give_default_gateway', 'global' ); |
|
568 | +function _give_customize_offline_donations_on_save_callback($meta_key, $meta_value, $postid) { |
|
569 | + if (('no' === $meta_value) && ('offline' === get_post_meta($postid, '_give_default_gateway', true))) { |
|
570 | + update_post_meta($postid, '_give_default_gateway', 'global'); |
|
571 | 571 | } |
572 | 572 | } |
573 | 573 | |
574 | -add_filter( 'give_save__give_customize_offline_donations', '_give_customize_offline_donations_on_save_callback', 10, 3 ); |
|
574 | +add_filter('give_save__give_customize_offline_donations', '_give_customize_offline_donations_on_save_callback', 10, 3); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -26,26 +26,26 @@ discard block |
||
26 | 26 | function give_test_ajax_works() { |
27 | 27 | |
28 | 28 | // Check if the Airplane Mode plugin is installed |
29 | - if ( class_exists( 'Airplane_Mode_Core' ) ) { |
|
29 | + if (class_exists('Airplane_Mode_Core')) { |
|
30 | 30 | |
31 | 31 | $airplane = Airplane_Mode_Core::getInstance(); |
32 | 32 | |
33 | - if ( method_exists( $airplane, 'enabled' ) ) { |
|
33 | + if (method_exists($airplane, 'enabled')) { |
|
34 | 34 | |
35 | - if ( $airplane->enabled() ) { |
|
35 | + if ($airplane->enabled()) { |
|
36 | 36 | return true; |
37 | 37 | } |
38 | 38 | } else { |
39 | 39 | |
40 | - if ( $airplane->check_status() == 'on' ) { |
|
40 | + if ($airplane->check_status() == 'on') { |
|
41 | 41 | return true; |
42 | 42 | } |
43 | 43 | } |
44 | 44 | } |
45 | 45 | |
46 | - add_filter( 'block_local_requests', '__return_false' ); |
|
46 | + add_filter('block_local_requests', '__return_false'); |
|
47 | 47 | |
48 | - if ( get_transient( '_give_ajax_works' ) ) { |
|
48 | + if (get_transient('_give_ajax_works')) { |
|
49 | 49 | return true; |
50 | 50 | } |
51 | 51 | |
@@ -57,35 +57,35 @@ discard block |
||
57 | 57 | ), |
58 | 58 | ); |
59 | 59 | |
60 | - $ajax = wp_remote_post( give_get_ajax_url(), $params ); |
|
60 | + $ajax = wp_remote_post(give_get_ajax_url(), $params); |
|
61 | 61 | |
62 | 62 | $works = true; |
63 | 63 | |
64 | - if ( is_wp_error( $ajax ) ) { |
|
64 | + if (is_wp_error($ajax)) { |
|
65 | 65 | |
66 | 66 | $works = false; |
67 | 67 | |
68 | 68 | } else { |
69 | 69 | |
70 | - if ( empty( $ajax['response'] ) ) { |
|
70 | + if (empty($ajax['response'])) { |
|
71 | 71 | $works = false; |
72 | 72 | } |
73 | 73 | |
74 | - if ( empty( $ajax['response']['code'] ) || 200 !== (int) $ajax['response']['code'] ) { |
|
74 | + if (empty($ajax['response']['code']) || 200 !== (int) $ajax['response']['code']) { |
|
75 | 75 | $works = false; |
76 | 76 | } |
77 | 77 | |
78 | - if ( empty( $ajax['response']['message'] ) || 'OK' !== $ajax['response']['message'] ) { |
|
78 | + if (empty($ajax['response']['message']) || 'OK' !== $ajax['response']['message']) { |
|
79 | 79 | $works = false; |
80 | 80 | } |
81 | 81 | |
82 | - if ( ! isset( $ajax['body'] ) || 0 !== (int) $ajax['body'] ) { |
|
82 | + if ( ! isset($ajax['body']) || 0 !== (int) $ajax['body']) { |
|
83 | 83 | $works = false; |
84 | 84 | } |
85 | 85 | } |
86 | 86 | |
87 | - if ( $works ) { |
|
88 | - set_transient( '_give_ajax_works', '1', DAY_IN_SECONDS ); |
|
87 | + if ($works) { |
|
88 | + set_transient('_give_ajax_works', '1', DAY_IN_SECONDS); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | return $works; |
@@ -100,16 +100,16 @@ discard block |
||
100 | 100 | * @return string |
101 | 101 | */ |
102 | 102 | function give_get_ajax_url() { |
103 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
103 | + $scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
104 | 104 | |
105 | 105 | $current_url = give_get_current_page_url(); |
106 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
106 | + $ajax_url = admin_url('admin-ajax.php', $scheme); |
|
107 | 107 | |
108 | - if ( preg_match( '/^https/', $current_url ) && ! preg_match( '/^https/', $ajax_url ) ) { |
|
109 | - $ajax_url = preg_replace( '/^http/', 'https', $ajax_url ); |
|
108 | + if (preg_match('/^https/', $current_url) && ! preg_match('/^https/', $ajax_url)) { |
|
109 | + $ajax_url = preg_replace('/^http/', 'https', $ajax_url); |
|
110 | 110 | } |
111 | 111 | |
112 | - return apply_filters( 'give_ajax_url', $ajax_url ); |
|
112 | + return apply_filters('give_ajax_url', $ajax_url); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -125,12 +125,12 @@ discard block |
||
125 | 125 | * |
126 | 126 | * @since 1.7 |
127 | 127 | */ |
128 | - do_action( 'give_donation_form_login_fields' ); |
|
128 | + do_action('give_donation_form_login_fields'); |
|
129 | 129 | |
130 | 130 | give_die(); |
131 | 131 | } |
132 | 132 | |
133 | -add_action( 'wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields' ); |
|
133 | +add_action('wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields'); |
|
134 | 134 | |
135 | 135 | /** |
136 | 136 | * Load Checkout Fields |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @return void |
141 | 141 | */ |
142 | 142 | function give_load_checkout_fields() { |
143 | - $form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : ''; |
|
143 | + $form_id = isset($_POST['form_id']) ? $_POST['form_id'] : ''; |
|
144 | 144 | |
145 | 145 | ob_start(); |
146 | 146 | |
@@ -149,18 +149,18 @@ discard block |
||
149 | 149 | * |
150 | 150 | * @since 1.7 |
151 | 151 | */ |
152 | - do_action( 'give_donation_form_register_login_fields', $form_id ); |
|
152 | + do_action('give_donation_form_register_login_fields', $form_id); |
|
153 | 153 | |
154 | 154 | $fields = ob_get_clean(); |
155 | 155 | |
156 | - wp_send_json( array( |
|
157 | - 'fields' => wp_json_encode( $fields ), |
|
158 | - 'submit' => wp_json_encode( give_checkout_button_purchase( $form_id ) ), |
|
159 | - ) ); |
|
156 | + wp_send_json(array( |
|
157 | + 'fields' => wp_json_encode($fields), |
|
158 | + 'submit' => wp_json_encode(give_checkout_button_purchase($form_id)), |
|
159 | + )); |
|
160 | 160 | } |
161 | 161 | |
162 | -add_action( 'wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields' ); |
|
163 | -add_action( 'wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields' ); |
|
162 | +add_action('wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields'); |
|
163 | +add_action('wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields'); |
|
164 | 164 | |
165 | 165 | /** |
166 | 166 | * Get Form Title via AJAX (used only in WordPress Admin) |
@@ -170,9 +170,9 @@ discard block |
||
170 | 170 | * @return void |
171 | 171 | */ |
172 | 172 | function give_ajax_get_form_title() { |
173 | - if ( isset( $_POST['form_id'] ) ) { |
|
174 | - $title = get_the_title( $_POST['form_id'] ); |
|
175 | - if ( $title ) { |
|
173 | + if (isset($_POST['form_id'])) { |
|
174 | + $title = get_the_title($_POST['form_id']); |
|
175 | + if ($title) { |
|
176 | 176 | echo $title; |
177 | 177 | } else { |
178 | 178 | echo 'fail'; |
@@ -181,8 +181,8 @@ discard block |
||
181 | 181 | give_die(); |
182 | 182 | } |
183 | 183 | |
184 | -add_action( 'wp_ajax_give_get_form_title', 'give_ajax_get_form_title' ); |
|
185 | -add_action( 'wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title' ); |
|
184 | +add_action('wp_ajax_give_get_form_title', 'give_ajax_get_form_title'); |
|
185 | +add_action('wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title'); |
|
186 | 186 | |
187 | 187 | /** |
188 | 188 | * Retrieve a states drop down |
@@ -193,23 +193,23 @@ discard block |
||
193 | 193 | */ |
194 | 194 | function give_ajax_get_states_field() { |
195 | 195 | |
196 | - if ( empty( $_POST['country'] ) ) { |
|
196 | + if (empty($_POST['country'])) { |
|
197 | 197 | $_POST['country'] = give_get_country(); |
198 | 198 | } |
199 | - $states = give_get_states( $_POST['country'] ); |
|
199 | + $states = give_get_states($_POST['country']); |
|
200 | 200 | |
201 | - if ( ! empty( $states ) ) { |
|
201 | + if ( ! empty($states)) { |
|
202 | 202 | |
203 | 203 | $args = array( |
204 | 204 | 'name' => $_POST['field_name'], |
205 | 205 | 'id' => $_POST['field_name'], |
206 | - 'class' => $_POST['field_name'] . ' give-select', |
|
207 | - 'options' => give_get_states( $_POST['country'] ), |
|
206 | + 'class' => $_POST['field_name'].' give-select', |
|
207 | + 'options' => give_get_states($_POST['country']), |
|
208 | 208 | 'show_option_all' => false, |
209 | 209 | 'show_option_none' => false, |
210 | 210 | ); |
211 | 211 | |
212 | - $response = Give()->html->select( $args ); |
|
212 | + $response = Give()->html->select($args); |
|
213 | 213 | |
214 | 214 | } else { |
215 | 215 | |
@@ -221,8 +221,8 @@ discard block |
||
221 | 221 | give_die(); |
222 | 222 | } |
223 | 223 | |
224 | -add_action( 'wp_ajax_give_get_states', 'give_ajax_get_states_field' ); |
|
225 | -add_action( 'wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field' ); |
|
224 | +add_action('wp_ajax_give_get_states', 'give_ajax_get_states_field'); |
|
225 | +add_action('wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field'); |
|
226 | 226 | |
227 | 227 | /** |
228 | 228 | * Retrieve a states drop down |
@@ -234,17 +234,17 @@ discard block |
||
234 | 234 | function give_ajax_form_search() { |
235 | 235 | global $wpdb; |
236 | 236 | |
237 | - $search = esc_sql( sanitize_text_field( $_GET['s'] ) ); |
|
237 | + $search = esc_sql(sanitize_text_field($_GET['s'])); |
|
238 | 238 | $results = array(); |
239 | - if ( current_user_can( 'edit_give_forms' ) ) { |
|
240 | - $items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50" ); |
|
239 | + if (current_user_can('edit_give_forms')) { |
|
240 | + $items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50"); |
|
241 | 241 | } else { |
242 | - $items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50" ); |
|
242 | + $items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50"); |
|
243 | 243 | } |
244 | 244 | |
245 | - if ( $items ) { |
|
245 | + if ($items) { |
|
246 | 246 | |
247 | - foreach ( $items as $item ) { |
|
247 | + foreach ($items as $item) { |
|
248 | 248 | |
249 | 249 | $results[] = array( |
250 | 250 | 'id' => $item->ID, |
@@ -255,18 +255,18 @@ discard block |
||
255 | 255 | |
256 | 256 | $items[] = array( |
257 | 257 | 'id' => 0, |
258 | - 'name' => esc_html__( 'No forms found.', 'give' ), |
|
258 | + 'name' => esc_html__('No forms found.', 'give'), |
|
259 | 259 | ); |
260 | 260 | |
261 | 261 | } |
262 | 262 | |
263 | - echo json_encode( $results ); |
|
263 | + echo json_encode($results); |
|
264 | 264 | |
265 | 265 | give_die(); |
266 | 266 | } |
267 | 267 | |
268 | -add_action( 'wp_ajax_give_form_search', 'give_ajax_form_search' ); |
|
269 | -add_action( 'wp_ajax_nopriv_give_form_search', 'give_ajax_form_search' ); |
|
268 | +add_action('wp_ajax_give_form_search', 'give_ajax_form_search'); |
|
269 | +add_action('wp_ajax_nopriv_give_form_search', 'give_ajax_form_search'); |
|
270 | 270 | |
271 | 271 | /** |
272 | 272 | * Search the donors database via Ajax |
@@ -278,38 +278,38 @@ discard block |
||
278 | 278 | function give_ajax_donor_search() { |
279 | 279 | global $wpdb; |
280 | 280 | |
281 | - $search = esc_sql( sanitize_text_field( $_GET['s'] ) ); |
|
281 | + $search = esc_sql(sanitize_text_field($_GET['s'])); |
|
282 | 282 | $results = array(); |
283 | - if ( ! current_user_can( 'view_give_reports' ) ) { |
|
283 | + if ( ! current_user_can('view_give_reports')) { |
|
284 | 284 | $donors = array(); |
285 | 285 | } else { |
286 | - $donors = $wpdb->get_results( "SELECT id,name,email FROM {$wpdb->prefix}give_donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50" ); |
|
286 | + $donors = $wpdb->get_results("SELECT id,name,email FROM {$wpdb->prefix}give_donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50"); |
|
287 | 287 | } |
288 | 288 | |
289 | - if ( $donors ) { |
|
289 | + if ($donors) { |
|
290 | 290 | |
291 | - foreach ( $donors as $donor ) { |
|
291 | + foreach ($donors as $donor) { |
|
292 | 292 | |
293 | 293 | $results[] = array( |
294 | 294 | 'id' => $donor->id, |
295 | - 'name' => $donor->name . '(' . $donor->email . ')', |
|
295 | + 'name' => $donor->name.'('.$donor->email.')', |
|
296 | 296 | ); |
297 | 297 | } |
298 | 298 | } else { |
299 | 299 | |
300 | 300 | $donors[] = array( |
301 | 301 | 'id' => 0, |
302 | - 'name' => esc_html__( 'No donors found.', 'give' ), |
|
302 | + 'name' => esc_html__('No donors found.', 'give'), |
|
303 | 303 | ); |
304 | 304 | |
305 | 305 | } |
306 | 306 | |
307 | - echo json_encode( $results ); |
|
307 | + echo json_encode($results); |
|
308 | 308 | |
309 | 309 | give_die(); |
310 | 310 | } |
311 | 311 | |
312 | -add_action( 'wp_ajax_give_donor_search', 'give_ajax_donor_search' ); |
|
312 | +add_action('wp_ajax_give_donor_search', 'give_ajax_donor_search'); |
|
313 | 313 | |
314 | 314 | |
315 | 315 | /** |
@@ -321,42 +321,42 @@ discard block |
||
321 | 321 | */ |
322 | 322 | function give_ajax_search_users() { |
323 | 323 | |
324 | - if ( current_user_can( 'manage_give_settings' ) ) { |
|
324 | + if (current_user_can('manage_give_settings')) { |
|
325 | 325 | |
326 | - $search_query = trim( $_POST['user_name'] ); |
|
327 | - $exclude = trim( $_POST['exclude'] ); |
|
326 | + $search_query = trim($_POST['user_name']); |
|
327 | + $exclude = trim($_POST['exclude']); |
|
328 | 328 | |
329 | 329 | $get_users_args = array( |
330 | 330 | 'number' => 9999, |
331 | - 'search' => $search_query . '*', |
|
331 | + 'search' => $search_query.'*', |
|
332 | 332 | ); |
333 | 333 | |
334 | - if ( ! empty( $exclude ) ) { |
|
335 | - $exclude_array = explode( ',', $exclude ); |
|
334 | + if ( ! empty($exclude)) { |
|
335 | + $exclude_array = explode(',', $exclude); |
|
336 | 336 | $get_users_args['exclude'] = $exclude_array; |
337 | 337 | } |
338 | 338 | |
339 | - $get_users_args = apply_filters( 'give_search_users_args', $get_users_args ); |
|
339 | + $get_users_args = apply_filters('give_search_users_args', $get_users_args); |
|
340 | 340 | |
341 | - $found_users = apply_filters( 'give_ajax_found_users', get_users( $get_users_args ), $search_query ); |
|
341 | + $found_users = apply_filters('give_ajax_found_users', get_users($get_users_args), $search_query); |
|
342 | 342 | |
343 | 343 | $user_list = '<ul>'; |
344 | - if ( $found_users ) { |
|
345 | - foreach ( $found_users as $user ) { |
|
346 | - $user_list .= '<li><a href="#" data-userid="' . esc_attr( $user->ID ) . '" data-login="' . esc_attr( $user->user_login ) . '">' . esc_html( $user->user_login ) . '</a></li>'; |
|
344 | + if ($found_users) { |
|
345 | + foreach ($found_users as $user) { |
|
346 | + $user_list .= '<li><a href="#" data-userid="'.esc_attr($user->ID).'" data-login="'.esc_attr($user->user_login).'">'.esc_html($user->user_login).'</a></li>'; |
|
347 | 347 | } |
348 | 348 | } else { |
349 | - $user_list .= '<li>' . esc_html__( 'No users found.', 'give' ) . '</li>'; |
|
349 | + $user_list .= '<li>'.esc_html__('No users found.', 'give').'</li>'; |
|
350 | 350 | } |
351 | 351 | $user_list .= '</ul>'; |
352 | 352 | |
353 | - echo json_encode( array( 'results' => $user_list ) ); |
|
353 | + echo json_encode(array('results' => $user_list)); |
|
354 | 354 | |
355 | 355 | } |
356 | 356 | die(); |
357 | 357 | } |
358 | 358 | |
359 | -add_action( 'wp_ajax_give_search_users', 'give_ajax_search_users' ); |
|
359 | +add_action('wp_ajax_give_search_users', 'give_ajax_search_users'); |
|
360 | 360 | |
361 | 361 | |
362 | 362 | /** |
@@ -368,32 +368,32 @@ discard block |
||
368 | 368 | */ |
369 | 369 | function give_check_for_form_price_variations() { |
370 | 370 | |
371 | - if ( ! current_user_can( 'edit_give_forms', get_current_user_id() ) ) { |
|
372 | - die( '-1' ); |
|
371 | + if ( ! current_user_can('edit_give_forms', get_current_user_id())) { |
|
372 | + die('-1'); |
|
373 | 373 | } |
374 | 374 | |
375 | - $form_id = intval( $_POST['form_id'] ); |
|
376 | - $form = get_post( $form_id ); |
|
375 | + $form_id = intval($_POST['form_id']); |
|
376 | + $form = get_post($form_id); |
|
377 | 377 | |
378 | - if ( 'give_forms' != $form->post_type ) { |
|
379 | - die( '-2' ); |
|
378 | + if ('give_forms' != $form->post_type) { |
|
379 | + die('-2'); |
|
380 | 380 | } |
381 | 381 | |
382 | - if ( give_has_variable_prices( $form_id ) ) { |
|
383 | - $variable_prices = give_get_variable_prices( $form_id ); |
|
382 | + if (give_has_variable_prices($form_id)) { |
|
383 | + $variable_prices = give_get_variable_prices($form_id); |
|
384 | 384 | |
385 | - if ( $variable_prices ) { |
|
385 | + if ($variable_prices) { |
|
386 | 386 | $ajax_response = '<select class="give_price_options_select give-select give-select" name="give_price_option">'; |
387 | 387 | |
388 | - if ( isset( $_POST['all_prices'] ) ) { |
|
389 | - $ajax_response .= '<option value="">' . esc_html__( 'All Levels', 'give' ) . '</option>'; |
|
388 | + if (isset($_POST['all_prices'])) { |
|
389 | + $ajax_response .= '<option value="">'.esc_html__('All Levels', 'give').'</option>'; |
|
390 | 390 | } |
391 | 391 | |
392 | - foreach ( $variable_prices as $key => $price ) { |
|
392 | + foreach ($variable_prices as $key => $price) { |
|
393 | 393 | |
394 | - $level_text = ! empty( $price['_give_text'] ) ? esc_html( $price['_give_text'] ) : give_currency_filter( give_format_amount( $price['_give_amount'] ) ); |
|
394 | + $level_text = ! empty($price['_give_text']) ? esc_html($price['_give_text']) : give_currency_filter(give_format_amount($price['_give_amount'])); |
|
395 | 395 | |
396 | - $ajax_response .= '<option value="' . esc_attr( $price['_give_id']['level_id'] ) . '">' . $level_text . '</option>'; |
|
396 | + $ajax_response .= '<option value="'.esc_attr($price['_give_id']['level_id']).'">'.$level_text.'</option>'; |
|
397 | 397 | } |
398 | 398 | $ajax_response .= '</select>'; |
399 | 399 | echo $ajax_response; |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | give_die(); |
404 | 404 | } |
405 | 405 | |
406 | -add_action( 'wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations' ); |
|
406 | +add_action('wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations'); |
|
407 | 407 | |
408 | 408 | |
409 | 409 | /** |
@@ -414,29 +414,29 @@ discard block |
||
414 | 414 | * @return void |
415 | 415 | */ |
416 | 416 | function give_check_for_form_price_variations_html() { |
417 | - if ( ! current_user_can( 'edit_give_payments', get_current_user_id() ) ) { |
|
417 | + if ( ! current_user_can('edit_give_payments', get_current_user_id())) { |
|
418 | 418 | wp_die(); |
419 | 419 | } |
420 | 420 | |
421 | - $form_id = intval( $_POST['form_id'] ); |
|
422 | - $payment_id = intval( $_POST['payment_id'] ); |
|
423 | - $form = get_post( $form_id ); |
|
421 | + $form_id = intval($_POST['form_id']); |
|
422 | + $payment_id = intval($_POST['payment_id']); |
|
423 | + $form = get_post($form_id); |
|
424 | 424 | |
425 | - if ( 'give_forms' != $form->post_type ) { |
|
425 | + if ('give_forms' != $form->post_type) { |
|
426 | 426 | wp_die(); |
427 | 427 | } |
428 | 428 | |
429 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
430 | - esc_html_e( 'n/a', 'give' ); |
|
429 | + if ( ! give_has_variable_prices($form_id)) { |
|
430 | + esc_html_e('n/a', 'give'); |
|
431 | 431 | } else { |
432 | 432 | // Payment object. |
433 | - $payment = new Give_Payment( $payment_id ); |
|
433 | + $payment = new Give_Payment($payment_id); |
|
434 | 434 | |
435 | 435 | |
436 | 436 | $prices_atts = ''; |
437 | - if( $variable_prices = give_get_variable_prices( $form_id ) ) { |
|
438 | - foreach ( $variable_prices as $variable_price ) { |
|
439 | - $prices_atts[$variable_price['_give_id']['level_id']] = give_format_amount( $variable_price['_give_amount'] ); |
|
437 | + if ($variable_prices = give_get_variable_prices($form_id)) { |
|
438 | + foreach ($variable_prices as $variable_price) { |
|
439 | + $prices_atts[$variable_price['_give_id']['level_id']] = give_format_amount($variable_price['_give_amount']); |
|
440 | 440 | } |
441 | 441 | } |
442 | 442 | |
@@ -451,15 +451,15 @@ discard block |
||
451 | 451 | 'chosen' => true, |
452 | 452 | 'show_option_all' => '', |
453 | 453 | 'show_option_none' => '', |
454 | - 'select_atts' => 'data-prices=' . esc_attr( json_encode( $prices_atts ) ), |
|
454 | + 'select_atts' => 'data-prices='.esc_attr(json_encode($prices_atts)), |
|
455 | 455 | 'selected' => $payment_meta['price_id'], |
456 | 456 | ); |
457 | 457 | |
458 | 458 | // Render variable prices select tag html. |
459 | - give_get_form_variable_price_dropdown( $variable_price_dropdown_option, true ); |
|
459 | + give_get_form_variable_price_dropdown($variable_price_dropdown_option, true); |
|
460 | 460 | } |
461 | 461 | |
462 | 462 | give_die(); |
463 | 463 | } |
464 | 464 | |
465 | -add_action( 'wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html' ); |
|
465 | +add_action('wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html'); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -43,15 +43,15 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @return object $payments Payments retrieved from the database |
45 | 45 | */ |
46 | -function give_get_payments( $args = array() ) { |
|
46 | +function give_get_payments($args = array()) { |
|
47 | 47 | |
48 | 48 | // Fallback to post objects to ensure backwards compatibility. |
49 | - if ( ! isset( $args['output'] ) ) { |
|
49 | + if ( ! isset($args['output'])) { |
|
50 | 50 | $args['output'] = 'posts'; |
51 | 51 | } |
52 | 52 | |
53 | - $args = apply_filters( 'give_get_payments_args', $args ); |
|
54 | - $payments = new Give_Payments_Query( $args ); |
|
53 | + $args = apply_filters('give_get_payments_args', $args); |
|
54 | + $payments = new Give_Payments_Query($args); |
|
55 | 55 | |
56 | 56 | return $payments->get_payments(); |
57 | 57 | } |
@@ -66,48 +66,48 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @return mixed |
68 | 68 | */ |
69 | -function give_get_payment_by( $field = '', $value = '' ) { |
|
69 | +function give_get_payment_by($field = '', $value = '') { |
|
70 | 70 | |
71 | - if ( empty( $field ) || empty( $value ) ) { |
|
71 | + if (empty($field) || empty($value)) { |
|
72 | 72 | return false; |
73 | 73 | } |
74 | 74 | |
75 | - switch ( strtolower( $field ) ) { |
|
75 | + switch (strtolower($field)) { |
|
76 | 76 | |
77 | 77 | case 'id': |
78 | - $payment = new Give_Payment( $value ); |
|
78 | + $payment = new Give_Payment($value); |
|
79 | 79 | $id = $payment->ID; |
80 | 80 | |
81 | - if ( empty( $id ) ) { |
|
81 | + if (empty($id)) { |
|
82 | 82 | return false; |
83 | 83 | } |
84 | 84 | |
85 | 85 | break; |
86 | 86 | |
87 | 87 | case 'key': |
88 | - $payment = give_get_payments( array( |
|
88 | + $payment = give_get_payments(array( |
|
89 | 89 | 'meta_key' => '_give_payment_purchase_key', |
90 | 90 | 'meta_value' => $value, |
91 | 91 | 'posts_per_page' => 1, |
92 | 92 | 'fields' => 'ids', |
93 | - ) ); |
|
93 | + )); |
|
94 | 94 | |
95 | - if ( $payment ) { |
|
96 | - $payment = new Give_Payment( $payment[0] ); |
|
95 | + if ($payment) { |
|
96 | + $payment = new Give_Payment($payment[0]); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | break; |
100 | 100 | |
101 | 101 | case 'payment_number': |
102 | - $payment = give_get_payments( array( |
|
102 | + $payment = give_get_payments(array( |
|
103 | 103 | 'meta_key' => '_give_payment_number', |
104 | 104 | 'meta_value' => $value, |
105 | 105 | 'posts_per_page' => 1, |
106 | 106 | 'fields' => 'ids', |
107 | - ) ); |
|
107 | + )); |
|
108 | 108 | |
109 | - if ( $payment ) { |
|
110 | - $payment = new Give_Payment( $payment[0] ); |
|
109 | + if ($payment) { |
|
110 | + $payment = new Give_Payment($payment[0]); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | break; |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | return false; |
117 | 117 | } |
118 | 118 | |
119 | - if ( $payment ) { |
|
119 | + if ($payment) { |
|
120 | 120 | return $payment; |
121 | 121 | } |
122 | 122 | |
@@ -132,23 +132,23 @@ discard block |
||
132 | 132 | * |
133 | 133 | * @return int|bool Payment ID if payment is inserted, false otherwise. |
134 | 134 | */ |
135 | -function give_insert_payment( $payment_data = array() ) { |
|
135 | +function give_insert_payment($payment_data = array()) { |
|
136 | 136 | |
137 | - if ( empty( $payment_data ) ) { |
|
137 | + if (empty($payment_data)) { |
|
138 | 138 | return false; |
139 | 139 | } |
140 | 140 | |
141 | 141 | $payment = new Give_Payment(); |
142 | - $gateway = ! empty( $payment_data['gateway'] ) ? $payment_data['gateway'] : ''; |
|
143 | - $gateway = empty( $gateway ) && isset( $_POST['give-gateway'] ) ? $_POST['give-gateway'] : $gateway; |
|
144 | - $form_id = isset( $payment_data['give_form_id'] ) ? $payment_data['give_form_id'] : 0; |
|
145 | - $price_id = isset( $payment_data['give_price_id'] ) ? $payment_data['give_price_id'] : give_get_price_id( $payment_data['give_form_id'], $payment_data['price'] ); |
|
146 | - $form_title = isset( $payment_data['give_form_title'] ) ? $payment_data['give_form_title'] : get_the_title( $form_id ); |
|
142 | + $gateway = ! empty($payment_data['gateway']) ? $payment_data['gateway'] : ''; |
|
143 | + $gateway = empty($gateway) && isset($_POST['give-gateway']) ? $_POST['give-gateway'] : $gateway; |
|
144 | + $form_id = isset($payment_data['give_form_id']) ? $payment_data['give_form_id'] : 0; |
|
145 | + $price_id = isset($payment_data['give_price_id']) ? $payment_data['give_price_id'] : give_get_price_id($payment_data['give_form_id'], $payment_data['price']); |
|
146 | + $form_title = isset($payment_data['give_form_title']) ? $payment_data['give_form_title'] : get_the_title($form_id); |
|
147 | 147 | |
148 | 148 | // Set properties. |
149 | 149 | $payment->total = $payment_data['price']; |
150 | - $payment->status = ! empty( $payment_data['status'] ) ? $payment_data['status'] : 'pending'; |
|
151 | - $payment->currency = ! empty( $payment_data['currency'] ) ? $payment_data['currency'] : give_get_currency(); |
|
150 | + $payment->status = ! empty($payment_data['status']) ? $payment_data['status'] : 'pending'; |
|
151 | + $payment->currency = ! empty($payment_data['currency']) ? $payment_data['currency'] : give_get_currency(); |
|
152 | 152 | $payment->user_info = $payment_data['user_info']; |
153 | 153 | $payment->gateway = $gateway; |
154 | 154 | $payment->form_title = $form_title; |
@@ -162,31 +162,31 @@ discard block |
||
162 | 162 | $payment->ip = give_get_ip(); |
163 | 163 | $payment->key = $payment_data['purchase_key']; |
164 | 164 | $payment->mode = give_is_test_mode() ? 'test' : 'live'; |
165 | - $payment->parent_payment = ! empty( $payment_data['parent'] ) ? absint( $payment_data['parent'] ) : ''; |
|
165 | + $payment->parent_payment = ! empty($payment_data['parent']) ? absint($payment_data['parent']) : ''; |
|
166 | 166 | |
167 | 167 | // Add the donation. |
168 | 168 | $args = array( |
169 | 169 | 'price' => $payment->total, |
170 | 170 | 'price_id' => $payment->price_id, |
171 | - 'fees' => isset( $payment_data['fees'] ) ? $payment_data['fees'] : array(), |
|
171 | + 'fees' => isset($payment_data['fees']) ? $payment_data['fees'] : array(), |
|
172 | 172 | ); |
173 | 173 | |
174 | - $payment->add_donation( $payment->form_id, $args ); |
|
174 | + $payment->add_donation($payment->form_id, $args); |
|
175 | 175 | |
176 | 176 | // Set date if present. |
177 | - if ( isset( $payment_data['post_date'] ) ) { |
|
177 | + if (isset($payment_data['post_date'])) { |
|
178 | 178 | $payment->date = $payment_data['post_date']; |
179 | 179 | } |
180 | 180 | |
181 | 181 | // Handle sequential payments. |
182 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
182 | + if (give_get_option('enable_sequential')) { |
|
183 | 183 | $number = give_get_next_payment_number(); |
184 | - $payment->number = give_format_payment_number( $number ); |
|
185 | - update_option( 'give_last_payment_number', $number ); |
|
184 | + $payment->number = give_format_payment_number($number); |
|
185 | + update_option('give_last_payment_number', $number); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | // Clear the user's donation cache. |
189 | - delete_transient( 'give_user_' . $payment_data['user_info']['id'] . '_purchases' ); |
|
189 | + delete_transient('give_user_'.$payment_data['user_info']['id'].'_purchases'); |
|
190 | 190 | |
191 | 191 | // Save payment. |
192 | 192 | $payment->save(); |
@@ -199,10 +199,10 @@ discard block |
||
199 | 199 | * @param int $payment_id The payment ID. |
200 | 200 | * @param array $payment_data Arguments passed. |
201 | 201 | */ |
202 | - do_action( 'give_insert_payment', $payment->ID, $payment_data ); |
|
202 | + do_action('give_insert_payment', $payment->ID, $payment_data); |
|
203 | 203 | |
204 | 204 | // Return payment ID upon success. |
205 | - if ( ! empty( $payment->ID ) ) { |
|
205 | + if ( ! empty($payment->ID)) { |
|
206 | 206 | return $payment->ID; |
207 | 207 | } |
208 | 208 | |
@@ -218,10 +218,10 @@ discard block |
||
218 | 218 | * |
219 | 219 | * @return bool|int |
220 | 220 | */ |
221 | -function give_create_payment( $payment_data ) { |
|
221 | +function give_create_payment($payment_data) { |
|
222 | 222 | |
223 | - $form_id = intval( $payment_data['post_data']['give-form-id'] ); |
|
224 | - $price_id = isset( $payment_data['post_data']['give-price-id'] ) ? $payment_data['post_data']['give-price-id'] : ''; |
|
223 | + $form_id = intval($payment_data['post_data']['give-form-id']); |
|
224 | + $price_id = isset($payment_data['post_data']['give-price-id']) ? $payment_data['post_data']['give-price-id'] : ''; |
|
225 | 225 | |
226 | 226 | // Collect payment data. |
227 | 227 | $insert_payment_data = array( |
@@ -245,10 +245,10 @@ discard block |
||
245 | 245 | * |
246 | 246 | * @param array $insert_payment_data |
247 | 247 | */ |
248 | - $insert_payment_data = apply_filters( 'give_create_payment', $insert_payment_data ); |
|
248 | + $insert_payment_data = apply_filters('give_create_payment', $insert_payment_data); |
|
249 | 249 | |
250 | 250 | // Record the pending payment. |
251 | - return give_insert_payment( $insert_payment_data ); |
|
251 | + return give_insert_payment($insert_payment_data); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | /** |
@@ -261,9 +261,9 @@ discard block |
||
261 | 261 | * |
262 | 262 | * @return bool |
263 | 263 | */ |
264 | -function give_update_payment_status( $payment_id, $new_status = 'publish' ) { |
|
264 | +function give_update_payment_status($payment_id, $new_status = 'publish') { |
|
265 | 265 | |
266 | - $payment = new Give_Payment( $payment_id ); |
|
266 | + $payment = new Give_Payment($payment_id); |
|
267 | 267 | $payment->status = $new_status; |
268 | 268 | $updated = $payment->save(); |
269 | 269 | |
@@ -282,37 +282,37 @@ discard block |
||
282 | 282 | * |
283 | 283 | * @return void |
284 | 284 | */ |
285 | -function give_delete_purchase( $payment_id = 0, $update_customer = true ) { |
|
285 | +function give_delete_purchase($payment_id = 0, $update_customer = true) { |
|
286 | 286 | global $give_logs; |
287 | 287 | |
288 | - $payment = new Give_Payment( $payment_id ); |
|
289 | - $amount = give_get_payment_amount( $payment_id ); |
|
288 | + $payment = new Give_Payment($payment_id); |
|
289 | + $amount = give_get_payment_amount($payment_id); |
|
290 | 290 | $status = $payment->post_status; |
291 | - $customer_id = give_get_payment_customer_id( $payment_id ); |
|
292 | - $customer = new Give_Customer( $customer_id ); |
|
291 | + $customer_id = give_get_payment_customer_id($payment_id); |
|
292 | + $customer = new Give_Customer($customer_id); |
|
293 | 293 | |
294 | 294 | // Only undo donations that aren't these statuses. |
295 | - $dont_undo_statuses = apply_filters( 'give_undo_purchase_statuses', array( |
|
295 | + $dont_undo_statuses = apply_filters('give_undo_purchase_statuses', array( |
|
296 | 296 | 'pending', |
297 | 297 | 'cancelled', |
298 | - ) ); |
|
298 | + )); |
|
299 | 299 | |
300 | - if ( ! in_array( $status, $dont_undo_statuses ) ) { |
|
301 | - give_undo_purchase( false, $payment_id ); |
|
300 | + if ( ! in_array($status, $dont_undo_statuses)) { |
|
301 | + give_undo_purchase(false, $payment_id); |
|
302 | 302 | } |
303 | 303 | |
304 | - if ( $status == 'publish' ) { |
|
304 | + if ($status == 'publish') { |
|
305 | 305 | |
306 | 306 | // Only decrease earnings if they haven't already been decreased (or were never increased for this payment). |
307 | - give_decrease_total_earnings( $amount ); |
|
307 | + give_decrease_total_earnings($amount); |
|
308 | 308 | // Clear the This Month earnings (this_monththis_month is NOT a typo). |
309 | - delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
309 | + delete_transient(md5('give_earnings_this_monththis_month')); |
|
310 | 310 | |
311 | - if ( $customer->id && $update_customer ) { |
|
311 | + if ($customer->id && $update_customer) { |
|
312 | 312 | |
313 | 313 | // Decrement the stats for the donor. |
314 | 314 | $customer->decrease_purchase_count(); |
315 | - $customer->decrease_value( $amount ); |
|
315 | + $customer->decrease_value($amount); |
|
316 | 316 | |
317 | 317 | } |
318 | 318 | } |
@@ -324,17 +324,17 @@ discard block |
||
324 | 324 | * |
325 | 325 | * @param int $payment_id Payment ID. |
326 | 326 | */ |
327 | - do_action( 'give_payment_delete', $payment_id ); |
|
327 | + do_action('give_payment_delete', $payment_id); |
|
328 | 328 | |
329 | - if ( $customer->id && $update_customer ) { |
|
329 | + if ($customer->id && $update_customer) { |
|
330 | 330 | |
331 | 331 | // Remove the payment ID from the donor. |
332 | - $customer->remove_payment( $payment_id ); |
|
332 | + $customer->remove_payment($payment_id); |
|
333 | 333 | |
334 | 334 | } |
335 | 335 | |
336 | 336 | // Remove the payment. |
337 | - wp_delete_post( $payment_id, true ); |
|
337 | + wp_delete_post($payment_id, true); |
|
338 | 338 | |
339 | 339 | // Remove related sale log entries. |
340 | 340 | $give_logs->delete_logs( |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | * |
356 | 356 | * @param int $payment_id Payment ID. |
357 | 357 | */ |
358 | - do_action( 'give_payment_deleted', $payment_id ); |
|
358 | + do_action('give_payment_deleted', $payment_id); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | /** |
@@ -371,25 +371,25 @@ discard block |
||
371 | 371 | * |
372 | 372 | * @return void |
373 | 373 | */ |
374 | -function give_undo_purchase( $form_id = false, $payment_id ) { |
|
374 | +function give_undo_purchase($form_id = false, $payment_id) { |
|
375 | 375 | |
376 | - if ( ! empty( $form_id ) ) { |
|
376 | + if ( ! empty($form_id)) { |
|
377 | 377 | $form_id = false; |
378 | - _give_deprected_argument( 'form_id', 'give_undo_purchase', '1.5' ); |
|
378 | + _give_deprected_argument('form_id', 'give_undo_purchase', '1.5'); |
|
379 | 379 | } |
380 | 380 | |
381 | - $payment = new Give_Payment( $payment_id ); |
|
381 | + $payment = new Give_Payment($payment_id); |
|
382 | 382 | |
383 | - $maybe_decrease_earnings = apply_filters( 'give_decrease_earnings_on_undo', true, $payment, $payment->form_id ); |
|
384 | - if ( true === $maybe_decrease_earnings ) { |
|
383 | + $maybe_decrease_earnings = apply_filters('give_decrease_earnings_on_undo', true, $payment, $payment->form_id); |
|
384 | + if (true === $maybe_decrease_earnings) { |
|
385 | 385 | // Decrease earnings. |
386 | - give_decrease_earnings( $payment->form_id, $payment->total ); |
|
386 | + give_decrease_earnings($payment->form_id, $payment->total); |
|
387 | 387 | } |
388 | 388 | |
389 | - $maybe_decrease_sales = apply_filters( 'give_decrease_sales_on_undo', true, $payment, $payment->form_id ); |
|
390 | - if ( true === $maybe_decrease_sales ) { |
|
389 | + $maybe_decrease_sales = apply_filters('give_decrease_sales_on_undo', true, $payment, $payment->form_id); |
|
390 | + if (true === $maybe_decrease_sales) { |
|
391 | 391 | // Decrease donation count. |
392 | - give_decrease_purchase_count( $payment->form_id ); |
|
392 | + give_decrease_purchase_count($payment->form_id); |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | } |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | * |
407 | 407 | * @return array $count Number of payments sorted by payment status. |
408 | 408 | */ |
409 | -function give_count_payments( $args = array() ) { |
|
409 | +function give_count_payments($args = array()) { |
|
410 | 410 | |
411 | 411 | global $wpdb; |
412 | 412 | |
@@ -418,18 +418,18 @@ discard block |
||
418 | 418 | 'form_id' => null, |
419 | 419 | ); |
420 | 420 | |
421 | - $args = wp_parse_args( $args, $defaults ); |
|
421 | + $args = wp_parse_args($args, $defaults); |
|
422 | 422 | |
423 | 423 | $select = 'SELECT p.post_status,count( * ) AS num_posts'; |
424 | 424 | $join = ''; |
425 | 425 | $where = "WHERE p.post_type = 'give_payment'"; |
426 | 426 | |
427 | 427 | // Count payments for a specific user. |
428 | - if ( ! empty( $args['user'] ) ) { |
|
428 | + if ( ! empty($args['user'])) { |
|
429 | 429 | |
430 | - if ( is_email( $args['user'] ) ) { |
|
430 | + if (is_email($args['user'])) { |
|
431 | 431 | $field = 'email'; |
432 | - } elseif ( is_numeric( $args['user'] ) ) { |
|
432 | + } elseif (is_numeric($args['user'])) { |
|
433 | 433 | $field = 'id'; |
434 | 434 | } else { |
435 | 435 | $field = ''; |
@@ -437,105 +437,105 @@ discard block |
||
437 | 437 | |
438 | 438 | $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
439 | 439 | |
440 | - if ( ! empty( $field ) ) { |
|
440 | + if ( ! empty($field)) { |
|
441 | 441 | $where .= " |
442 | 442 | AND m.meta_key = '_give_payment_user_{$field}' |
443 | 443 | AND m.meta_value = '{$args['user']}'"; |
444 | 444 | } |
445 | 445 | |
446 | 446 | // Count payments for a search. |
447 | - } elseif ( ! empty( $args['s'] ) ) { |
|
447 | + } elseif ( ! empty($args['s'])) { |
|
448 | 448 | |
449 | - if ( is_email( $args['s'] ) || strlen( $args['s'] ) == 32 ) { |
|
449 | + if (is_email($args['s']) || strlen($args['s']) == 32) { |
|
450 | 450 | |
451 | - if ( is_email( $args['s'] ) ) { |
|
451 | + if (is_email($args['s'])) { |
|
452 | 452 | $field = '_give_payment_user_email'; |
453 | 453 | } else { |
454 | 454 | $field = '_give_payment_purchase_key'; |
455 | 455 | } |
456 | 456 | |
457 | 457 | $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
458 | - $where .= $wpdb->prepare( ' |
|
458 | + $where .= $wpdb->prepare(' |
|
459 | 459 | AND m.meta_key = %s |
460 | 460 | AND m.meta_value = %s', |
461 | 461 | $field, |
462 | 462 | $args['s'] |
463 | 463 | ); |
464 | 464 | |
465 | - } elseif ( '#' == substr( $args['s'], 0, 1 ) ) { |
|
465 | + } elseif ('#' == substr($args['s'], 0, 1)) { |
|
466 | 466 | |
467 | - $search = str_replace( '#:', '', $args['s'] ); |
|
468 | - $search = str_replace( '#', '', $search ); |
|
467 | + $search = str_replace('#:', '', $args['s']); |
|
468 | + $search = str_replace('#', '', $search); |
|
469 | 469 | |
470 | 470 | $select = 'SELECT p2.post_status,count( * ) AS num_posts '; |
471 | 471 | $join = "LEFT JOIN $wpdb->postmeta m ON m.meta_key = '_give_log_payment_id' AND m.post_id = p.ID "; |
472 | 472 | $join .= "INNER JOIN $wpdb->posts p2 ON m.meta_value = p2.ID "; |
473 | 473 | $where = "WHERE p.post_type = 'give_log' "; |
474 | - $where .= $wpdb->prepare( 'AND p.post_parent = %d} ', $search ); |
|
474 | + $where .= $wpdb->prepare('AND p.post_parent = %d} ', $search); |
|
475 | 475 | |
476 | - } elseif ( is_numeric( $args['s'] ) ) { |
|
476 | + } elseif (is_numeric($args['s'])) { |
|
477 | 477 | |
478 | 478 | $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
479 | - $where .= $wpdb->prepare( " |
|
479 | + $where .= $wpdb->prepare(" |
|
480 | 480 | AND m.meta_key = '_give_payment_user_id' |
481 | 481 | AND m.meta_value = %d", |
482 | 482 | $args['s'] |
483 | 483 | ); |
484 | 484 | |
485 | 485 | } else { |
486 | - $search = $wpdb->esc_like( $args['s'] ); |
|
487 | - $search = '%' . $search . '%'; |
|
486 | + $search = $wpdb->esc_like($args['s']); |
|
487 | + $search = '%'.$search.'%'; |
|
488 | 488 | |
489 | - $where .= $wpdb->prepare( 'AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search ); |
|
489 | + $where .= $wpdb->prepare('AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search); |
|
490 | 490 | } |
491 | 491 | } |
492 | 492 | |
493 | - if ( ! empty( $args['form_id'] ) && is_numeric( $args['form_id'] ) ) { |
|
493 | + if ( ! empty($args['form_id']) && is_numeric($args['form_id'])) { |
|
494 | 494 | |
495 | - $where .= $wpdb->prepare( ' AND p.post_parent = %d', $args['form_id'] ); |
|
495 | + $where .= $wpdb->prepare(' AND p.post_parent = %d', $args['form_id']); |
|
496 | 496 | |
497 | 497 | } |
498 | 498 | // Limit payments count by date. |
499 | - if ( ! empty( $args['start-date'] ) && false !== strpos( $args['start-date'], '/' ) ) { |
|
499 | + if ( ! empty($args['start-date']) && false !== strpos($args['start-date'], '/')) { |
|
500 | 500 | |
501 | - $date_parts = explode( '/', $args['start-date'] ); |
|
502 | - $month = ! empty( $date_parts[0] ) && is_numeric( $date_parts[0] ) ? $date_parts[0] : 0; |
|
503 | - $day = ! empty( $date_parts[1] ) && is_numeric( $date_parts[1] ) ? $date_parts[1] : 0; |
|
504 | - $year = ! empty( $date_parts[2] ) && is_numeric( $date_parts[2] ) ? $date_parts[2] : 0; |
|
501 | + $date_parts = explode('/', $args['start-date']); |
|
502 | + $month = ! empty($date_parts[0]) && is_numeric($date_parts[0]) ? $date_parts[0] : 0; |
|
503 | + $day = ! empty($date_parts[1]) && is_numeric($date_parts[1]) ? $date_parts[1] : 0; |
|
504 | + $year = ! empty($date_parts[2]) && is_numeric($date_parts[2]) ? $date_parts[2] : 0; |
|
505 | 505 | |
506 | - $is_date = checkdate( $month, $day, $year ); |
|
507 | - if ( false !== $is_date ) { |
|
506 | + $is_date = checkdate($month, $day, $year); |
|
507 | + if (false !== $is_date) { |
|
508 | 508 | |
509 | - $date = new DateTime( $args['start-date'] ); |
|
510 | - $where .= $wpdb->prepare( " AND p.post_date >= '%s'", $date->format( 'Y-m-d' ) ); |
|
509 | + $date = new DateTime($args['start-date']); |
|
510 | + $where .= $wpdb->prepare(" AND p.post_date >= '%s'", $date->format('Y-m-d')); |
|
511 | 511 | |
512 | 512 | } |
513 | 513 | |
514 | 514 | // Fixes an issue with the payments list table counts when no end date is specified (partiy with stats class). |
515 | - if ( empty( $args['end-date'] ) ) { |
|
515 | + if (empty($args['end-date'])) { |
|
516 | 516 | $args['end-date'] = $args['start-date']; |
517 | 517 | } |
518 | 518 | } |
519 | 519 | |
520 | - if ( ! empty( $args['end-date'] ) && false !== strpos( $args['end-date'], '/' ) ) { |
|
520 | + if ( ! empty($args['end-date']) && false !== strpos($args['end-date'], '/')) { |
|
521 | 521 | |
522 | - $date_parts = explode( '/', $args['end-date'] ); |
|
522 | + $date_parts = explode('/', $args['end-date']); |
|
523 | 523 | |
524 | - $month = ! empty( $date_parts[0] ) ? $date_parts[0] : 0; |
|
525 | - $day = ! empty( $date_parts[1] ) ? $date_parts[1] : 0; |
|
526 | - $year = ! empty( $date_parts[2] ) ? $date_parts[2] : 0; |
|
524 | + $month = ! empty($date_parts[0]) ? $date_parts[0] : 0; |
|
525 | + $day = ! empty($date_parts[1]) ? $date_parts[1] : 0; |
|
526 | + $year = ! empty($date_parts[2]) ? $date_parts[2] : 0; |
|
527 | 527 | |
528 | - $is_date = checkdate( $month, $day, $year ); |
|
529 | - if ( false !== $is_date ) { |
|
528 | + $is_date = checkdate($month, $day, $year); |
|
529 | + if (false !== $is_date) { |
|
530 | 530 | |
531 | - $date = new DateTime( $args['end-date'] ); |
|
532 | - $where .= $wpdb->prepare( " AND p.post_date <= '%s'", $date->format( 'Y-m-d' ) ); |
|
531 | + $date = new DateTime($args['end-date']); |
|
532 | + $where .= $wpdb->prepare(" AND p.post_date <= '%s'", $date->format('Y-m-d')); |
|
533 | 533 | |
534 | 534 | } |
535 | 535 | } |
536 | 536 | |
537 | - $where = apply_filters( 'give_count_payments_where', $where ); |
|
538 | - $join = apply_filters( 'give_count_payments_join', $join ); |
|
537 | + $where = apply_filters('give_count_payments_where', $where); |
|
538 | + $join = apply_filters('give_count_payments_join', $join); |
|
539 | 539 | |
540 | 540 | $query = "$select |
541 | 541 | FROM $wpdb->posts p |
@@ -544,36 +544,36 @@ discard block |
||
544 | 544 | GROUP BY p.post_status |
545 | 545 | "; |
546 | 546 | |
547 | - $cache_key = md5( $query ); |
|
547 | + $cache_key = md5($query); |
|
548 | 548 | |
549 | - $count = wp_cache_get( $cache_key, 'counts' ); |
|
550 | - if ( false !== $count ) { |
|
549 | + $count = wp_cache_get($cache_key, 'counts'); |
|
550 | + if (false !== $count) { |
|
551 | 551 | return $count; |
552 | 552 | } |
553 | 553 | |
554 | - $count = $wpdb->get_results( $query, ARRAY_A ); |
|
554 | + $count = $wpdb->get_results($query, ARRAY_A); |
|
555 | 555 | |
556 | 556 | $stats = array(); |
557 | 557 | $statuses = get_post_stati(); |
558 | - if ( isset( $statuses['private'] ) && empty( $args['s'] ) ) { |
|
559 | - unset( $statuses['private'] ); |
|
558 | + if (isset($statuses['private']) && empty($args['s'])) { |
|
559 | + unset($statuses['private']); |
|
560 | 560 | } |
561 | 561 | |
562 | - foreach ( $statuses as $state ) { |
|
563 | - $stats[ $state ] = 0; |
|
562 | + foreach ($statuses as $state) { |
|
563 | + $stats[$state] = 0; |
|
564 | 564 | } |
565 | 565 | |
566 | - foreach ( (array) $count as $row ) { |
|
566 | + foreach ((array) $count as $row) { |
|
567 | 567 | |
568 | - if ( 'private' == $row['post_status'] && empty( $args['s'] ) ) { |
|
568 | + if ('private' == $row['post_status'] && empty($args['s'])) { |
|
569 | 569 | continue; |
570 | 570 | } |
571 | 571 | |
572 | - $stats[ $row['post_status'] ] = $row['num_posts']; |
|
572 | + $stats[$row['post_status']] = $row['num_posts']; |
|
573 | 573 | } |
574 | 574 | |
575 | 575 | $stats = (object) $stats; |
576 | - wp_cache_set( $cache_key, $stats, 'counts' ); |
|
576 | + wp_cache_set($cache_key, $stats, 'counts'); |
|
577 | 577 | |
578 | 578 | return $stats; |
579 | 579 | } |
@@ -588,11 +588,11 @@ discard block |
||
588 | 588 | * |
589 | 589 | * @return bool $exists True if payment exists, false otherwise. |
590 | 590 | */ |
591 | -function give_check_for_existing_payment( $payment_id ) { |
|
591 | +function give_check_for_existing_payment($payment_id) { |
|
592 | 592 | $exists = false; |
593 | - $payment = new Give_Payment( $payment_id ); |
|
593 | + $payment = new Give_Payment($payment_id); |
|
594 | 594 | |
595 | - if ( $payment_id === $payment->ID && 'publish' === $payment->status ) { |
|
595 | + if ($payment_id === $payment->ID && 'publish' === $payment->status) { |
|
596 | 596 | $exists = true; |
597 | 597 | } |
598 | 598 | |
@@ -610,31 +610,31 @@ discard block |
||
610 | 610 | * |
611 | 611 | * @return bool|mixed True if payment status exists, false otherwise. |
612 | 612 | */ |
613 | -function give_get_payment_status( $payment, $return_label = false ) { |
|
613 | +function give_get_payment_status($payment, $return_label = false) { |
|
614 | 614 | |
615 | - if ( ! is_object( $payment ) || ! isset( $payment->post_status ) ) { |
|
615 | + if ( ! is_object($payment) || ! isset($payment->post_status)) { |
|
616 | 616 | return false; |
617 | 617 | } |
618 | 618 | |
619 | 619 | $statuses = give_get_payment_statuses(); |
620 | 620 | |
621 | - if ( ! is_array( $statuses ) || empty( $statuses ) ) { |
|
621 | + if ( ! is_array($statuses) || empty($statuses)) { |
|
622 | 622 | return false; |
623 | 623 | } |
624 | 624 | |
625 | 625 | // Get payment object if no already given. |
626 | - $payment = $payment instanceof Give_Payment ? $payment : new Give_Payment( $payment->ID ); |
|
626 | + $payment = $payment instanceof Give_Payment ? $payment : new Give_Payment($payment->ID); |
|
627 | 627 | |
628 | - if ( array_key_exists( $payment->status, $statuses ) ) { |
|
629 | - if ( true === $return_label ) { |
|
628 | + if (array_key_exists($payment->status, $statuses)) { |
|
629 | + if (true === $return_label) { |
|
630 | 630 | // Return translated status label. |
631 | - return $statuses[ $payment->status ]; |
|
631 | + return $statuses[$payment->status]; |
|
632 | 632 | } else { |
633 | 633 | // Account that our 'publish' status is labeled 'Complete' |
634 | 634 | $post_status = 'publish' == $payment->status ? 'Complete' : $payment->post_status; |
635 | 635 | |
636 | 636 | // Make sure we're matching cases, since they matter |
637 | - return array_search( strtolower( $post_status ), array_map( 'strtolower', $statuses ) ); |
|
637 | + return array_search(strtolower($post_status), array_map('strtolower', $statuses)); |
|
638 | 638 | } |
639 | 639 | } |
640 | 640 | |
@@ -650,17 +650,17 @@ discard block |
||
650 | 650 | */ |
651 | 651 | function give_get_payment_statuses() { |
652 | 652 | $payment_statuses = array( |
653 | - 'pending' => __( 'Pending', 'give' ), |
|
654 | - 'publish' => __( 'Complete', 'give' ), |
|
655 | - 'refunded' => __( 'Refunded', 'give' ), |
|
656 | - 'failed' => __( 'Failed', 'give' ), |
|
657 | - 'cancelled' => __( 'Cancelled', 'give' ), |
|
658 | - 'abandoned' => __( 'Abandoned', 'give' ), |
|
659 | - 'preapproval' => __( 'Pre-Approved', 'give' ), |
|
660 | - 'revoked' => __( 'Revoked', 'give' ), |
|
653 | + 'pending' => __('Pending', 'give'), |
|
654 | + 'publish' => __('Complete', 'give'), |
|
655 | + 'refunded' => __('Refunded', 'give'), |
|
656 | + 'failed' => __('Failed', 'give'), |
|
657 | + 'cancelled' => __('Cancelled', 'give'), |
|
658 | + 'abandoned' => __('Abandoned', 'give'), |
|
659 | + 'preapproval' => __('Pre-Approved', 'give'), |
|
660 | + 'revoked' => __('Revoked', 'give'), |
|
661 | 661 | ); |
662 | 662 | |
663 | - return apply_filters( 'give_payment_statuses', $payment_statuses ); |
|
663 | + return apply_filters('give_payment_statuses', $payment_statuses); |
|
664 | 664 | } |
665 | 665 | |
666 | 666 | /** |
@@ -673,10 +673,10 @@ discard block |
||
673 | 673 | * @return array $payment_status All the available payment statuses. |
674 | 674 | */ |
675 | 675 | function give_get_payment_status_keys() { |
676 | - $statuses = array_keys( give_get_payment_statuses() ); |
|
677 | - asort( $statuses ); |
|
676 | + $statuses = array_keys(give_get_payment_statuses()); |
|
677 | + asort($statuses); |
|
678 | 678 | |
679 | - return array_values( $statuses ); |
|
679 | + return array_values($statuses); |
|
680 | 680 | } |
681 | 681 | |
682 | 682 | /** |
@@ -691,7 +691,7 @@ discard block |
||
691 | 691 | * |
692 | 692 | * @return int $earnings Earnings |
693 | 693 | */ |
694 | -function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) { |
|
694 | +function give_get_earnings_by_date($day = null, $month_num, $year = null, $hour = null) { |
|
695 | 695 | |
696 | 696 | // This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead. |
697 | 697 | global $wpdb; |
@@ -701,41 +701,41 @@ discard block |
||
701 | 701 | 'nopaging' => true, |
702 | 702 | 'year' => $year, |
703 | 703 | 'monthnum' => $month_num, |
704 | - 'post_status' => array( 'publish' ), |
|
704 | + 'post_status' => array('publish'), |
|
705 | 705 | 'fields' => 'ids', |
706 | 706 | 'update_post_term_cache' => false, |
707 | 707 | ); |
708 | - if ( ! empty( $day ) ) { |
|
708 | + if ( ! empty($day)) { |
|
709 | 709 | $args['day'] = $day; |
710 | 710 | } |
711 | 711 | |
712 | - if ( ! empty( $hour ) ) { |
|
712 | + if ( ! empty($hour)) { |
|
713 | 713 | $args['hour'] = $hour; |
714 | 714 | } |
715 | 715 | |
716 | - $args = apply_filters( 'give_get_earnings_by_date_args', $args ); |
|
717 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
716 | + $args = apply_filters('give_get_earnings_by_date_args', $args); |
|
717 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
718 | 718 | |
719 | - if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) { |
|
719 | + if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) { |
|
720 | 720 | $earnings = false; |
721 | 721 | } else { |
722 | - $earnings = get_transient( $key ); |
|
722 | + $earnings = get_transient($key); |
|
723 | 723 | } |
724 | 724 | |
725 | - if ( false === $earnings ) { |
|
726 | - $sales = get_posts( $args ); |
|
725 | + if (false === $earnings) { |
|
726 | + $sales = get_posts($args); |
|
727 | 727 | $earnings = 0; |
728 | - if ( $sales ) { |
|
729 | - $sales = implode( ',', $sales ); |
|
728 | + if ($sales) { |
|
729 | + $sales = implode(',', $sales); |
|
730 | 730 | |
731 | - $earnings = $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$sales})" ); |
|
731 | + $earnings = $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$sales})"); |
|
732 | 732 | |
733 | 733 | } |
734 | 734 | // Cache the results for one hour. |
735 | - set_transient( $key, $earnings, HOUR_IN_SECONDS ); |
|
735 | + set_transient($key, $earnings, HOUR_IN_SECONDS); |
|
736 | 736 | } |
737 | 737 | |
738 | - return round( $earnings, 2 ); |
|
738 | + return round($earnings, 2); |
|
739 | 739 | } |
740 | 740 | |
741 | 741 | /** |
@@ -750,7 +750,7 @@ discard block |
||
750 | 750 | * |
751 | 751 | * @return int $count Sales |
752 | 752 | */ |
753 | -function give_get_sales_by_date( $day = null, $month_num = null, $year = null, $hour = null ) { |
|
753 | +function give_get_sales_by_date($day = null, $month_num = null, $year = null, $hour = null) { |
|
754 | 754 | |
755 | 755 | // This is getting deprecated soon. Use Give_Payment_Stats with the get_sales() method instead. |
756 | 756 | $args = array( |
@@ -758,14 +758,14 @@ discard block |
||
758 | 758 | 'nopaging' => true, |
759 | 759 | 'year' => $year, |
760 | 760 | 'fields' => 'ids', |
761 | - 'post_status' => array( 'publish' ), |
|
761 | + 'post_status' => array('publish'), |
|
762 | 762 | 'update_post_meta_cache' => false, |
763 | 763 | 'update_post_term_cache' => false, |
764 | 764 | ); |
765 | 765 | |
766 | - $show_free = apply_filters( 'give_sales_by_date_show_free', true, $args ); |
|
766 | + $show_free = apply_filters('give_sales_by_date_show_free', true, $args); |
|
767 | 767 | |
768 | - if ( false === $show_free ) { |
|
768 | + if (false === $show_free) { |
|
769 | 769 | $args['meta_query'] = array( |
770 | 770 | array( |
771 | 771 | 'key' => '_give_payment_total', |
@@ -776,33 +776,33 @@ discard block |
||
776 | 776 | ); |
777 | 777 | } |
778 | 778 | |
779 | - if ( ! empty( $month_num ) ) { |
|
779 | + if ( ! empty($month_num)) { |
|
780 | 780 | $args['monthnum'] = $month_num; |
781 | 781 | } |
782 | 782 | |
783 | - if ( ! empty( $day ) ) { |
|
783 | + if ( ! empty($day)) { |
|
784 | 784 | $args['day'] = $day; |
785 | 785 | } |
786 | 786 | |
787 | - if ( ! empty( $hour ) ) { |
|
787 | + if ( ! empty($hour)) { |
|
788 | 788 | $args['hour'] = $hour; |
789 | 789 | } |
790 | 790 | |
791 | - $args = apply_filters( 'give_get_sales_by_date_args', $args ); |
|
791 | + $args = apply_filters('give_get_sales_by_date_args', $args); |
|
792 | 792 | |
793 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
793 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
794 | 794 | |
795 | - if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) { |
|
795 | + if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) { |
|
796 | 796 | $count = false; |
797 | 797 | } else { |
798 | - $count = get_transient( $key ); |
|
798 | + $count = get_transient($key); |
|
799 | 799 | } |
800 | 800 | |
801 | - if ( false === $count ) { |
|
802 | - $sales = new WP_Query( $args ); |
|
801 | + if (false === $count) { |
|
802 | + $sales = new WP_Query($args); |
|
803 | 803 | $count = (int) $sales->post_count; |
804 | 804 | // Cache the results for one hour. |
805 | - set_transient( $key, $count, HOUR_IN_SECONDS ); |
|
805 | + set_transient($key, $count, HOUR_IN_SECONDS); |
|
806 | 806 | } |
807 | 807 | |
808 | 808 | return $count; |
@@ -817,19 +817,19 @@ discard block |
||
817 | 817 | * |
818 | 818 | * @return bool $ret True if complete, false otherwise. |
819 | 819 | */ |
820 | -function give_is_payment_complete( $payment_id ) { |
|
821 | - $payment = new Give_Payment( $payment_id ); |
|
820 | +function give_is_payment_complete($payment_id) { |
|
821 | + $payment = new Give_Payment($payment_id); |
|
822 | 822 | |
823 | 823 | $ret = false; |
824 | 824 | |
825 | - if ( $payment->ID > 0 ) { |
|
825 | + if ($payment->ID > 0) { |
|
826 | 826 | |
827 | - if ( (int) $payment_id === (int) $payment->ID && 'publish' == $payment->status ) { |
|
827 | + if ((int) $payment_id === (int) $payment->ID && 'publish' == $payment->status) { |
|
828 | 828 | $ret = true; |
829 | 829 | } |
830 | 830 | } |
831 | 831 | |
832 | - return apply_filters( 'give_is_payment_complete', $ret, $payment_id, $payment->post_status ); |
|
832 | + return apply_filters('give_is_payment_complete', $ret, $payment_id, $payment->post_status); |
|
833 | 833 | } |
834 | 834 | |
835 | 835 | /** |
@@ -855,57 +855,57 @@ discard block |
||
855 | 855 | */ |
856 | 856 | function give_get_total_earnings() { |
857 | 857 | |
858 | - $total = get_option( 'give_earnings_total', false ); |
|
858 | + $total = get_option('give_earnings_total', false); |
|
859 | 859 | |
860 | 860 | // If no total stored in DB, use old method of calculating total earnings. |
861 | - if ( false === $total ) { |
|
861 | + if (false === $total) { |
|
862 | 862 | |
863 | 863 | global $wpdb; |
864 | 864 | |
865 | - $total = get_transient( 'give_earnings_total' ); |
|
865 | + $total = get_transient('give_earnings_total'); |
|
866 | 866 | |
867 | - if ( false === $total ) { |
|
867 | + if (false === $total) { |
|
868 | 868 | |
869 | 869 | $total = (float) 0; |
870 | 870 | |
871 | - $args = apply_filters( 'give_get_total_earnings_args', array( |
|
871 | + $args = apply_filters('give_get_total_earnings_args', array( |
|
872 | 872 | 'offset' => 0, |
873 | - 'number' => - 1, |
|
874 | - 'status' => array( 'publish' ), |
|
873 | + 'number' => -1, |
|
874 | + 'status' => array('publish'), |
|
875 | 875 | 'fields' => 'ids', |
876 | - ) ); |
|
876 | + )); |
|
877 | 877 | |
878 | - $payments = give_get_payments( $args ); |
|
879 | - if ( $payments ) { |
|
878 | + $payments = give_get_payments($args); |
|
879 | + if ($payments) { |
|
880 | 880 | |
881 | 881 | /** |
882 | 882 | * If performing a donation, we need to skip the very last payment in the database, |
883 | 883 | * since it calls give_increase_total_earnings() on completion, |
884 | 884 | * which results in duplicated earnings for the very first donation. |
885 | 885 | */ |
886 | - if ( did_action( 'give_update_payment_status' ) ) { |
|
887 | - array_pop( $payments ); |
|
886 | + if (did_action('give_update_payment_status')) { |
|
887 | + array_pop($payments); |
|
888 | 888 | } |
889 | 889 | |
890 | - if ( ! empty( $payments ) ) { |
|
891 | - $payments = implode( ',', $payments ); |
|
892 | - $total += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})" ); |
|
890 | + if ( ! empty($payments)) { |
|
891 | + $payments = implode(',', $payments); |
|
892 | + $total += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})"); |
|
893 | 893 | } |
894 | 894 | } |
895 | 895 | |
896 | 896 | // Cache results for 1 day. This cache is cleared automatically when a payment is made. |
897 | - set_transient( 'give_earnings_total', $total, 86400 ); |
|
897 | + set_transient('give_earnings_total', $total, 86400); |
|
898 | 898 | |
899 | 899 | // Store the total for the first time. |
900 | - update_option( 'give_earnings_total', $total ); |
|
900 | + update_option('give_earnings_total', $total); |
|
901 | 901 | } |
902 | 902 | } |
903 | 903 | |
904 | - if ( $total < 0 ) { |
|
904 | + if ($total < 0) { |
|
905 | 905 | $total = 0; // Don't ever show negative earnings. |
906 | 906 | } |
907 | 907 | |
908 | - return apply_filters( 'give_total_earnings', round( $total, give_currency_decimal_filter() ) ); |
|
908 | + return apply_filters('give_total_earnings', round($total, give_currency_decimal_filter())); |
|
909 | 909 | } |
910 | 910 | |
911 | 911 | /** |
@@ -918,10 +918,10 @@ discard block |
||
918 | 918 | * |
919 | 919 | * @return float $total Total earnings. |
920 | 920 | */ |
921 | -function give_increase_total_earnings( $amount = 0 ) { |
|
921 | +function give_increase_total_earnings($amount = 0) { |
|
922 | 922 | $total = give_get_total_earnings(); |
923 | 923 | $total += $amount; |
924 | - update_option( 'give_earnings_total', $total ); |
|
924 | + update_option('give_earnings_total', $total); |
|
925 | 925 | |
926 | 926 | return $total; |
927 | 927 | } |
@@ -935,13 +935,13 @@ discard block |
||
935 | 935 | * |
936 | 936 | * @return float $total Total earnings. |
937 | 937 | */ |
938 | -function give_decrease_total_earnings( $amount = 0 ) { |
|
938 | +function give_decrease_total_earnings($amount = 0) { |
|
939 | 939 | $total = give_get_total_earnings(); |
940 | 940 | $total -= $amount; |
941 | - if ( $total < 0 ) { |
|
941 | + if ($total < 0) { |
|
942 | 942 | $total = 0; |
943 | 943 | } |
944 | - update_option( 'give_earnings_total', $total ); |
|
944 | + update_option('give_earnings_total', $total); |
|
945 | 945 | |
946 | 946 | return $total; |
947 | 947 | } |
@@ -957,10 +957,10 @@ discard block |
||
957 | 957 | * |
958 | 958 | * @return mixed $meta Payment Meta. |
959 | 959 | */ |
960 | -function give_get_payment_meta( $payment_id = 0, $meta_key = '_give_payment_meta', $single = true ) { |
|
961 | - $payment = new Give_Payment( $payment_id ); |
|
960 | +function give_get_payment_meta($payment_id = 0, $meta_key = '_give_payment_meta', $single = true) { |
|
961 | + $payment = new Give_Payment($payment_id); |
|
962 | 962 | |
963 | - return $payment->get_meta( $meta_key, $single ); |
|
963 | + return $payment->get_meta($meta_key, $single); |
|
964 | 964 | } |
965 | 965 | |
966 | 966 | /** |
@@ -973,10 +973,10 @@ discard block |
||
973 | 973 | * |
974 | 974 | * @return mixed Meta ID if successful, false if unsuccessful. |
975 | 975 | */ |
976 | -function give_update_payment_meta( $payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '' ) { |
|
977 | - $payment = new Give_Payment( $payment_id ); |
|
976 | +function give_update_payment_meta($payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '') { |
|
977 | + $payment = new Give_Payment($payment_id); |
|
978 | 978 | |
979 | - return $payment->update_meta( $meta_key, $meta_value, $prev_value ); |
|
979 | + return $payment->update_meta($meta_key, $meta_value, $prev_value); |
|
980 | 980 | } |
981 | 981 | |
982 | 982 | /** |
@@ -988,8 +988,8 @@ discard block |
||
988 | 988 | * |
989 | 989 | * @return string $user_info User Info Meta Values. |
990 | 990 | */ |
991 | -function give_get_payment_meta_user_info( $payment_id ) { |
|
992 | - $payment = new Give_Payment( $payment_id ); |
|
991 | +function give_get_payment_meta_user_info($payment_id) { |
|
992 | + $payment = new Give_Payment($payment_id); |
|
993 | 993 | |
994 | 994 | return $payment->user_info; |
995 | 995 | } |
@@ -1005,8 +1005,8 @@ discard block |
||
1005 | 1005 | * |
1006 | 1006 | * @return int $form_id Form ID. |
1007 | 1007 | */ |
1008 | -function give_get_payment_form_id( $payment_id ) { |
|
1009 | - $payment = new Give_Payment( $payment_id ); |
|
1008 | +function give_get_payment_form_id($payment_id) { |
|
1009 | + $payment = new Give_Payment($payment_id); |
|
1010 | 1010 | |
1011 | 1011 | return $payment->form_id; |
1012 | 1012 | } |
@@ -1020,8 +1020,8 @@ discard block |
||
1020 | 1020 | * |
1021 | 1021 | * @return string $email User email. |
1022 | 1022 | */ |
1023 | -function give_get_payment_user_email( $payment_id ) { |
|
1024 | - $payment = new Give_Payment( $payment_id ); |
|
1023 | +function give_get_payment_user_email($payment_id) { |
|
1024 | + $payment = new Give_Payment($payment_id); |
|
1025 | 1025 | |
1026 | 1026 | return $payment->email; |
1027 | 1027 | } |
@@ -1035,11 +1035,11 @@ discard block |
||
1035 | 1035 | * |
1036 | 1036 | * @return bool $is_guest_payment If the payment is associated with a user (false) or not (true) |
1037 | 1037 | */ |
1038 | -function give_is_guest_payment( $payment_id ) { |
|
1039 | - $payment_user_id = give_get_payment_user_id( $payment_id ); |
|
1040 | - $is_guest_payment = ! empty( $payment_user_id ) && $payment_user_id > 0 ? false : true; |
|
1038 | +function give_is_guest_payment($payment_id) { |
|
1039 | + $payment_user_id = give_get_payment_user_id($payment_id); |
|
1040 | + $is_guest_payment = ! empty($payment_user_id) && $payment_user_id > 0 ? false : true; |
|
1041 | 1041 | |
1042 | - return (bool) apply_filters( 'give_is_guest_payment', $is_guest_payment, $payment_id ); |
|
1042 | + return (bool) apply_filters('give_is_guest_payment', $is_guest_payment, $payment_id); |
|
1043 | 1043 | } |
1044 | 1044 | |
1045 | 1045 | /** |
@@ -1051,8 +1051,8 @@ discard block |
||
1051 | 1051 | * |
1052 | 1052 | * @return int $user_id User ID. |
1053 | 1053 | */ |
1054 | -function give_get_payment_user_id( $payment_id ) { |
|
1055 | - $payment = new Give_Payment( $payment_id ); |
|
1054 | +function give_get_payment_user_id($payment_id) { |
|
1055 | + $payment = new Give_Payment($payment_id); |
|
1056 | 1056 | |
1057 | 1057 | return $payment->user_id; |
1058 | 1058 | } |
@@ -1066,8 +1066,8 @@ discard block |
||
1066 | 1066 | * |
1067 | 1067 | * @return int $customer_id Customer ID. |
1068 | 1068 | */ |
1069 | -function give_get_payment_customer_id( $payment_id ) { |
|
1070 | - $payment = new Give_Payment( $payment_id ); |
|
1069 | +function give_get_payment_customer_id($payment_id) { |
|
1070 | + $payment = new Give_Payment($payment_id); |
|
1071 | 1071 | |
1072 | 1072 | return $payment->customer_id; |
1073 | 1073 | } |
@@ -1081,8 +1081,8 @@ discard block |
||
1081 | 1081 | * |
1082 | 1082 | * @return string $ip User IP. |
1083 | 1083 | */ |
1084 | -function give_get_payment_user_ip( $payment_id ) { |
|
1085 | - $payment = new Give_Payment( $payment_id ); |
|
1084 | +function give_get_payment_user_ip($payment_id) { |
|
1085 | + $payment = new Give_Payment($payment_id); |
|
1086 | 1086 | |
1087 | 1087 | return $payment->ip; |
1088 | 1088 | } |
@@ -1096,8 +1096,8 @@ discard block |
||
1096 | 1096 | * |
1097 | 1097 | * @return string $date The date the payment was completed. |
1098 | 1098 | */ |
1099 | -function give_get_payment_completed_date( $payment_id = 0 ) { |
|
1100 | - $payment = new Give_Payment( $payment_id ); |
|
1099 | +function give_get_payment_completed_date($payment_id = 0) { |
|
1100 | + $payment = new Give_Payment($payment_id); |
|
1101 | 1101 | |
1102 | 1102 | return $payment->completed_date; |
1103 | 1103 | } |
@@ -1111,8 +1111,8 @@ discard block |
||
1111 | 1111 | * |
1112 | 1112 | * @return string $gateway Gateway. |
1113 | 1113 | */ |
1114 | -function give_get_payment_gateway( $payment_id ) { |
|
1115 | - $payment = new Give_Payment( $payment_id ); |
|
1114 | +function give_get_payment_gateway($payment_id) { |
|
1115 | + $payment = new Give_Payment($payment_id); |
|
1116 | 1116 | |
1117 | 1117 | return $payment->gateway; |
1118 | 1118 | } |
@@ -1126,8 +1126,8 @@ discard block |
||
1126 | 1126 | * |
1127 | 1127 | * @return string $currency The currency code. |
1128 | 1128 | */ |
1129 | -function give_get_payment_currency_code( $payment_id = 0 ) { |
|
1130 | - $payment = new Give_Payment( $payment_id ); |
|
1129 | +function give_get_payment_currency_code($payment_id = 0) { |
|
1130 | + $payment = new Give_Payment($payment_id); |
|
1131 | 1131 | |
1132 | 1132 | return $payment->currency; |
1133 | 1133 | } |
@@ -1141,10 +1141,10 @@ discard block |
||
1141 | 1141 | * |
1142 | 1142 | * @return string $currency The currency name. |
1143 | 1143 | */ |
1144 | -function give_get_payment_currency( $payment_id = 0 ) { |
|
1145 | - $currency = give_get_payment_currency_code( $payment_id ); |
|
1144 | +function give_get_payment_currency($payment_id = 0) { |
|
1145 | + $currency = give_get_payment_currency_code($payment_id); |
|
1146 | 1146 | |
1147 | - return apply_filters( 'give_payment_currency', give_get_currency_name( $currency ), $payment_id ); |
|
1147 | + return apply_filters('give_payment_currency', give_get_currency_name($currency), $payment_id); |
|
1148 | 1148 | } |
1149 | 1149 | |
1150 | 1150 | /** |
@@ -1156,8 +1156,8 @@ discard block |
||
1156 | 1156 | * |
1157 | 1157 | * @return string $key Donation key. |
1158 | 1158 | */ |
1159 | -function give_get_payment_key( $payment_id = 0 ) { |
|
1160 | - $payment = new Give_Payment( $payment_id ); |
|
1159 | +function give_get_payment_key($payment_id = 0) { |
|
1160 | + $payment = new Give_Payment($payment_id); |
|
1161 | 1161 | |
1162 | 1162 | return $payment->key; |
1163 | 1163 | } |
@@ -1173,8 +1173,8 @@ discard block |
||
1173 | 1173 | * |
1174 | 1174 | * @return string $number Payment order number. |
1175 | 1175 | */ |
1176 | -function give_get_payment_number( $payment_id = 0 ) { |
|
1177 | - $payment = new Give_Payment( $payment_id ); |
|
1176 | +function give_get_payment_number($payment_id = 0) { |
|
1177 | + $payment = new Give_Payment($payment_id); |
|
1178 | 1178 | |
1179 | 1179 | return $payment->number; |
1180 | 1180 | } |
@@ -1188,23 +1188,23 @@ discard block |
||
1188 | 1188 | * |
1189 | 1189 | * @return string The formatted payment number. |
1190 | 1190 | */ |
1191 | -function give_format_payment_number( $number ) { |
|
1191 | +function give_format_payment_number($number) { |
|
1192 | 1192 | |
1193 | - if ( ! give_get_option( 'enable_sequential' ) ) { |
|
1193 | + if ( ! give_get_option('enable_sequential')) { |
|
1194 | 1194 | return $number; |
1195 | 1195 | } |
1196 | 1196 | |
1197 | - if ( ! is_numeric( $number ) ) { |
|
1197 | + if ( ! is_numeric($number)) { |
|
1198 | 1198 | return $number; |
1199 | 1199 | } |
1200 | 1200 | |
1201 | - $prefix = give_get_option( 'sequential_prefix' ); |
|
1202 | - $number = absint( $number ); |
|
1203 | - $postfix = give_get_option( 'sequential_postfix' ); |
|
1201 | + $prefix = give_get_option('sequential_prefix'); |
|
1202 | + $number = absint($number); |
|
1203 | + $postfix = give_get_option('sequential_postfix'); |
|
1204 | 1204 | |
1205 | - $formatted_number = $prefix . $number . $postfix; |
|
1205 | + $formatted_number = $prefix.$number.$postfix; |
|
1206 | 1206 | |
1207 | - return apply_filters( 'give_format_payment_number', $formatted_number, $prefix, $number, $postfix ); |
|
1207 | + return apply_filters('give_format_payment_number', $formatted_number, $prefix, $number, $postfix); |
|
1208 | 1208 | } |
1209 | 1209 | |
1210 | 1210 | /** |
@@ -1217,17 +1217,17 @@ discard block |
||
1217 | 1217 | */ |
1218 | 1218 | function give_get_next_payment_number() { |
1219 | 1219 | |
1220 | - if ( ! give_get_option( 'enable_sequential' ) ) { |
|
1220 | + if ( ! give_get_option('enable_sequential')) { |
|
1221 | 1221 | return false; |
1222 | 1222 | } |
1223 | 1223 | |
1224 | - $number = get_option( 'give_last_payment_number' ); |
|
1225 | - $start = give_get_option( 'sequential_start', 1 ); |
|
1224 | + $number = get_option('give_last_payment_number'); |
|
1225 | + $start = give_get_option('sequential_start', 1); |
|
1226 | 1226 | $increment_number = true; |
1227 | 1227 | |
1228 | - if ( false !== $number ) { |
|
1228 | + if (false !== $number) { |
|
1229 | 1229 | |
1230 | - if ( empty( $number ) ) { |
|
1230 | + if (empty($number)) { |
|
1231 | 1231 | |
1232 | 1232 | $number = $start; |
1233 | 1233 | $increment_number = false; |
@@ -1236,24 +1236,24 @@ discard block |
||
1236 | 1236 | } else { |
1237 | 1237 | |
1238 | 1238 | // This case handles the first addition of the new option, as well as if it get's deleted for any reason. |
1239 | - $payments = new Give_Payments_Query( array( |
|
1239 | + $payments = new Give_Payments_Query(array( |
|
1240 | 1240 | 'number' => 1, |
1241 | 1241 | 'order' => 'DESC', |
1242 | 1242 | 'orderby' => 'ID', |
1243 | 1243 | 'output' => 'posts', |
1244 | 1244 | 'fields' => 'ids', |
1245 | - ) ); |
|
1245 | + )); |
|
1246 | 1246 | $last_payment = $payments->get_payments(); |
1247 | 1247 | |
1248 | - if ( ! empty( $last_payment ) ) { |
|
1248 | + if ( ! empty($last_payment)) { |
|
1249 | 1249 | |
1250 | - $number = give_get_payment_number( $last_payment[0] ); |
|
1250 | + $number = give_get_payment_number($last_payment[0]); |
|
1251 | 1251 | |
1252 | 1252 | } |
1253 | 1253 | |
1254 | - if ( ! empty( $number ) && $number !== (int) $last_payment[0] ) { |
|
1254 | + if ( ! empty($number) && $number !== (int) $last_payment[0]) { |
|
1255 | 1255 | |
1256 | - $number = give_remove_payment_prefix_postfix( $number ); |
|
1256 | + $number = give_remove_payment_prefix_postfix($number); |
|
1257 | 1257 | |
1258 | 1258 | } else { |
1259 | 1259 | |
@@ -1262,13 +1262,13 @@ discard block |
||
1262 | 1262 | } |
1263 | 1263 | } |
1264 | 1264 | |
1265 | - $increment_number = apply_filters( 'give_increment_payment_number', $increment_number, $number ); |
|
1265 | + $increment_number = apply_filters('give_increment_payment_number', $increment_number, $number); |
|
1266 | 1266 | |
1267 | - if ( $increment_number ) { |
|
1268 | - $number ++; |
|
1267 | + if ($increment_number) { |
|
1268 | + $number++; |
|
1269 | 1269 | } |
1270 | 1270 | |
1271 | - return apply_filters( 'give_get_next_payment_number', $number ); |
|
1271 | + return apply_filters('give_get_next_payment_number', $number); |
|
1272 | 1272 | } |
1273 | 1273 | |
1274 | 1274 | /** |
@@ -1280,25 +1280,25 @@ discard block |
||
1280 | 1280 | * |
1281 | 1281 | * @return string The new Payment number without prefix and postfix. |
1282 | 1282 | */ |
1283 | -function give_remove_payment_prefix_postfix( $number ) { |
|
1283 | +function give_remove_payment_prefix_postfix($number) { |
|
1284 | 1284 | |
1285 | - $prefix = give_get_option( 'sequential_prefix' ); |
|
1286 | - $postfix = give_get_option( 'sequential_postfix' ); |
|
1285 | + $prefix = give_get_option('sequential_prefix'); |
|
1286 | + $postfix = give_get_option('sequential_postfix'); |
|
1287 | 1287 | |
1288 | 1288 | // Remove prefix. |
1289 | - $number = preg_replace( '/' . $prefix . '/', '', $number, 1 ); |
|
1289 | + $number = preg_replace('/'.$prefix.'/', '', $number, 1); |
|
1290 | 1290 | |
1291 | 1291 | // Remove the postfix. |
1292 | - $length = strlen( $number ); |
|
1293 | - $postfix_pos = strrpos( $number, $postfix ); |
|
1294 | - if ( false !== $postfix_pos ) { |
|
1295 | - $number = substr_replace( $number, '', $postfix_pos, $length ); |
|
1292 | + $length = strlen($number); |
|
1293 | + $postfix_pos = strrpos($number, $postfix); |
|
1294 | + if (false !== $postfix_pos) { |
|
1295 | + $number = substr_replace($number, '', $postfix_pos, $length); |
|
1296 | 1296 | } |
1297 | 1297 | |
1298 | 1298 | // Ensure it's a whole number. |
1299 | - $number = intval( $number ); |
|
1299 | + $number = intval($number); |
|
1300 | 1300 | |
1301 | - return apply_filters( 'give_remove_payment_prefix_postfix', $number, $prefix, $postfix ); |
|
1301 | + return apply_filters('give_remove_payment_prefix_postfix', $number, $prefix, $postfix); |
|
1302 | 1302 | |
1303 | 1303 | } |
1304 | 1304 | |
@@ -1314,10 +1314,10 @@ discard block |
||
1314 | 1314 | * |
1315 | 1315 | * @return string $amount Fully formatted payment amount. |
1316 | 1316 | */ |
1317 | -function give_payment_amount( $payment_id = 0 ) { |
|
1318 | - $amount = give_get_payment_amount( $payment_id ); |
|
1317 | +function give_payment_amount($payment_id = 0) { |
|
1318 | + $amount = give_get_payment_amount($payment_id); |
|
1319 | 1319 | |
1320 | - return give_currency_filter( give_format_amount( $amount ), give_get_payment_currency_code( $payment_id ) ); |
|
1320 | + return give_currency_filter(give_format_amount($amount), give_get_payment_currency_code($payment_id)); |
|
1321 | 1321 | } |
1322 | 1322 | |
1323 | 1323 | /** |
@@ -1330,11 +1330,11 @@ discard block |
||
1330 | 1330 | * |
1331 | 1331 | * @return mixed|void |
1332 | 1332 | */ |
1333 | -function give_get_payment_amount( $payment_id ) { |
|
1333 | +function give_get_payment_amount($payment_id) { |
|
1334 | 1334 | |
1335 | - $payment = new Give_Payment( $payment_id ); |
|
1335 | + $payment = new Give_Payment($payment_id); |
|
1336 | 1336 | |
1337 | - return apply_filters( 'give_payment_amount', floatval( $payment->total ), $payment_id ); |
|
1337 | + return apply_filters('give_payment_amount', floatval($payment->total), $payment_id); |
|
1338 | 1338 | } |
1339 | 1339 | |
1340 | 1340 | /** |
@@ -1350,10 +1350,10 @@ discard block |
||
1350 | 1350 | * |
1351 | 1351 | * @return array Fully formatted payment subtotal. |
1352 | 1352 | */ |
1353 | -function give_payment_subtotal( $payment_id = 0 ) { |
|
1354 | - $subtotal = give_get_payment_subtotal( $payment_id ); |
|
1353 | +function give_payment_subtotal($payment_id = 0) { |
|
1354 | + $subtotal = give_get_payment_subtotal($payment_id); |
|
1355 | 1355 | |
1356 | - return give_currency_filter( give_format_amount( $subtotal ), give_get_payment_currency_code( $payment_id ) ); |
|
1356 | + return give_currency_filter(give_format_amount($subtotal), give_get_payment_currency_code($payment_id)); |
|
1357 | 1357 | } |
1358 | 1358 | |
1359 | 1359 | /** |
@@ -1367,8 +1367,8 @@ discard block |
||
1367 | 1367 | * |
1368 | 1368 | * @return float $subtotal Subtotal for payment (non formatted). |
1369 | 1369 | */ |
1370 | -function give_get_payment_subtotal( $payment_id = 0 ) { |
|
1371 | - $payment = new G_Payment( $payment_id ); |
|
1370 | +function give_get_payment_subtotal($payment_id = 0) { |
|
1371 | + $payment = new G_Payment($payment_id); |
|
1372 | 1372 | |
1373 | 1373 | return $payment->subtotal; |
1374 | 1374 | } |
@@ -1383,10 +1383,10 @@ discard block |
||
1383 | 1383 | * |
1384 | 1384 | * @return mixed array if payment fees found, false otherwise. |
1385 | 1385 | */ |
1386 | -function give_get_payment_fees( $payment_id = 0, $type = 'all' ) { |
|
1387 | - $payment = new Give_Payment( $payment_id ); |
|
1386 | +function give_get_payment_fees($payment_id = 0, $type = 'all') { |
|
1387 | + $payment = new Give_Payment($payment_id); |
|
1388 | 1388 | |
1389 | - return $payment->get_fees( $type ); |
|
1389 | + return $payment->get_fees($type); |
|
1390 | 1390 | } |
1391 | 1391 | |
1392 | 1392 | /** |
@@ -1398,8 +1398,8 @@ discard block |
||
1398 | 1398 | * |
1399 | 1399 | * @return string The donation ID. |
1400 | 1400 | */ |
1401 | -function give_get_payment_transaction_id( $payment_id = 0 ) { |
|
1402 | - $payment = new Give_Payment( $payment_id ); |
|
1401 | +function give_get_payment_transaction_id($payment_id = 0) { |
|
1402 | + $payment = new Give_Payment($payment_id); |
|
1403 | 1403 | |
1404 | 1404 | return $payment->transaction_id; |
1405 | 1405 | } |
@@ -1414,15 +1414,15 @@ discard block |
||
1414 | 1414 | * |
1415 | 1415 | * @return bool|mixed |
1416 | 1416 | */ |
1417 | -function give_set_payment_transaction_id( $payment_id = 0, $transaction_id = '' ) { |
|
1417 | +function give_set_payment_transaction_id($payment_id = 0, $transaction_id = '') { |
|
1418 | 1418 | |
1419 | - if ( empty( $payment_id ) || empty( $transaction_id ) ) { |
|
1419 | + if (empty($payment_id) || empty($transaction_id)) { |
|
1420 | 1420 | return false; |
1421 | 1421 | } |
1422 | 1422 | |
1423 | - $transaction_id = apply_filters( 'give_set_payment_transaction_id', $transaction_id, $payment_id ); |
|
1423 | + $transaction_id = apply_filters('give_set_payment_transaction_id', $transaction_id, $payment_id); |
|
1424 | 1424 | |
1425 | - return give_update_payment_meta( $payment_id, '_give_payment_transaction_id', $transaction_id ); |
|
1425 | + return give_update_payment_meta($payment_id, '_give_payment_transaction_id', $transaction_id); |
|
1426 | 1426 | } |
1427 | 1427 | |
1428 | 1428 | /** |
@@ -1435,12 +1435,12 @@ discard block |
||
1435 | 1435 | * |
1436 | 1436 | * @return int $purchase Donation ID. |
1437 | 1437 | */ |
1438 | -function give_get_purchase_id_by_key( $key ) { |
|
1438 | +function give_get_purchase_id_by_key($key) { |
|
1439 | 1439 | global $wpdb; |
1440 | 1440 | |
1441 | - $purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key ) ); |
|
1441 | + $purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key)); |
|
1442 | 1442 | |
1443 | - if ( $purchase != null ) { |
|
1443 | + if ($purchase != null) { |
|
1444 | 1444 | return $purchase; |
1445 | 1445 | } |
1446 | 1446 | |
@@ -1458,12 +1458,12 @@ discard block |
||
1458 | 1458 | * |
1459 | 1459 | * @return int $purchase Donation ID. |
1460 | 1460 | */ |
1461 | -function give_get_purchase_id_by_transaction_id( $key ) { |
|
1461 | +function give_get_purchase_id_by_transaction_id($key) { |
|
1462 | 1462 | global $wpdb; |
1463 | 1463 | |
1464 | - $purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key ) ); |
|
1464 | + $purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key)); |
|
1465 | 1465 | |
1466 | - if ( $purchase != null ) { |
|
1466 | + if ($purchase != null) { |
|
1467 | 1467 | return $purchase; |
1468 | 1468 | } |
1469 | 1469 | |
@@ -1480,19 +1480,19 @@ discard block |
||
1480 | 1480 | * |
1481 | 1481 | * @return array $notes Donation Notes |
1482 | 1482 | */ |
1483 | -function give_get_payment_notes( $payment_id = 0, $search = '' ) { |
|
1483 | +function give_get_payment_notes($payment_id = 0, $search = '') { |
|
1484 | 1484 | |
1485 | - if ( empty( $payment_id ) && empty( $search ) ) { |
|
1485 | + if (empty($payment_id) && empty($search)) { |
|
1486 | 1486 | return false; |
1487 | 1487 | } |
1488 | 1488 | |
1489 | - remove_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
1490 | - remove_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10 ); |
|
1489 | + remove_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
1490 | + remove_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10); |
|
1491 | 1491 | |
1492 | - $notes = get_comments( array( 'post_id' => $payment_id, 'order' => 'ASC', 'search' => $search ) ); |
|
1492 | + $notes = get_comments(array('post_id' => $payment_id, 'order' => 'ASC', 'search' => $search)); |
|
1493 | 1493 | |
1494 | - add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
1495 | - add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 ); |
|
1494 | + add_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
1495 | + add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2); |
|
1496 | 1496 | |
1497 | 1497 | return $notes; |
1498 | 1498 | } |
@@ -1508,8 +1508,8 @@ discard block |
||
1508 | 1508 | * |
1509 | 1509 | * @return int The new note ID |
1510 | 1510 | */ |
1511 | -function give_insert_payment_note( $payment_id = 0, $note = '' ) { |
|
1512 | - if ( empty( $payment_id ) ) { |
|
1511 | +function give_insert_payment_note($payment_id = 0, $note = '') { |
|
1512 | + if (empty($payment_id)) { |
|
1513 | 1513 | return false; |
1514 | 1514 | } |
1515 | 1515 | |
@@ -1521,14 +1521,14 @@ discard block |
||
1521 | 1521 | * @param int $payment_id Payment ID. |
1522 | 1522 | * @param string $note The note. |
1523 | 1523 | */ |
1524 | - do_action( 'give_pre_insert_payment_note', $payment_id, $note ); |
|
1524 | + do_action('give_pre_insert_payment_note', $payment_id, $note); |
|
1525 | 1525 | |
1526 | - $note_id = wp_insert_comment( wp_filter_comment( array( |
|
1526 | + $note_id = wp_insert_comment(wp_filter_comment(array( |
|
1527 | 1527 | 'comment_post_ID' => $payment_id, |
1528 | 1528 | 'comment_content' => $note, |
1529 | 1529 | 'user_id' => is_admin() ? get_current_user_id() : 0, |
1530 | - 'comment_date' => current_time( 'mysql' ), |
|
1531 | - 'comment_date_gmt' => current_time( 'mysql', 1 ), |
|
1530 | + 'comment_date' => current_time('mysql'), |
|
1531 | + 'comment_date_gmt' => current_time('mysql', 1), |
|
1532 | 1532 | 'comment_approved' => 1, |
1533 | 1533 | 'comment_parent' => 0, |
1534 | 1534 | 'comment_author' => '', |
@@ -1537,7 +1537,7 @@ discard block |
||
1537 | 1537 | 'comment_author_email' => '', |
1538 | 1538 | 'comment_type' => 'give_payment_note', |
1539 | 1539 | |
1540 | - ) ) ); |
|
1540 | + ))); |
|
1541 | 1541 | |
1542 | 1542 | /** |
1543 | 1543 | * Fires after payment note inserted. |
@@ -1548,7 +1548,7 @@ discard block |
||
1548 | 1548 | * @param int $payment_id Payment ID. |
1549 | 1549 | * @param string $note The note. |
1550 | 1550 | */ |
1551 | - do_action( 'give_insert_payment_note', $note_id, $payment_id, $note ); |
|
1551 | + do_action('give_insert_payment_note', $note_id, $payment_id, $note); |
|
1552 | 1552 | |
1553 | 1553 | return $note_id; |
1554 | 1554 | } |
@@ -1563,8 +1563,8 @@ discard block |
||
1563 | 1563 | * |
1564 | 1564 | * @return bool True on success, false otherwise. |
1565 | 1565 | */ |
1566 | -function give_delete_payment_note( $comment_id = 0, $payment_id = 0 ) { |
|
1567 | - if ( empty( $comment_id ) ) { |
|
1566 | +function give_delete_payment_note($comment_id = 0, $payment_id = 0) { |
|
1567 | + if (empty($comment_id)) { |
|
1568 | 1568 | return false; |
1569 | 1569 | } |
1570 | 1570 | |
@@ -1576,9 +1576,9 @@ discard block |
||
1576 | 1576 | * @param int $comment_id Note ID. |
1577 | 1577 | * @param int $payment_id Payment ID. |
1578 | 1578 | */ |
1579 | - do_action( 'give_pre_delete_payment_note', $comment_id, $payment_id ); |
|
1579 | + do_action('give_pre_delete_payment_note', $comment_id, $payment_id); |
|
1580 | 1580 | |
1581 | - $ret = wp_delete_comment( $comment_id, true ); |
|
1581 | + $ret = wp_delete_comment($comment_id, true); |
|
1582 | 1582 | |
1583 | 1583 | /** |
1584 | 1584 | * Fires after donation note deleted. |
@@ -1588,7 +1588,7 @@ discard block |
||
1588 | 1588 | * @param int $comment_id Note ID. |
1589 | 1589 | * @param int $payment_id Payment ID. |
1590 | 1590 | */ |
1591 | - do_action( 'give_post_delete_payment_note', $comment_id, $payment_id ); |
|
1591 | + do_action('give_post_delete_payment_note', $comment_id, $payment_id); |
|
1592 | 1592 | |
1593 | 1593 | return $ret; |
1594 | 1594 | } |
@@ -1603,34 +1603,34 @@ discard block |
||
1603 | 1603 | * |
1604 | 1604 | * @return string |
1605 | 1605 | */ |
1606 | -function give_get_payment_note_html( $note, $payment_id = 0 ) { |
|
1606 | +function give_get_payment_note_html($note, $payment_id = 0) { |
|
1607 | 1607 | |
1608 | - if ( is_numeric( $note ) ) { |
|
1609 | - $note = get_comment( $note ); |
|
1608 | + if (is_numeric($note)) { |
|
1609 | + $note = get_comment($note); |
|
1610 | 1610 | } |
1611 | 1611 | |
1612 | - if ( ! empty( $note->user_id ) ) { |
|
1613 | - $user = get_userdata( $note->user_id ); |
|
1612 | + if ( ! empty($note->user_id)) { |
|
1613 | + $user = get_userdata($note->user_id); |
|
1614 | 1614 | $user = $user->display_name; |
1615 | 1615 | } else { |
1616 | - $user = esc_html__( 'System', 'give' ); |
|
1616 | + $user = esc_html__('System', 'give'); |
|
1617 | 1617 | } |
1618 | 1618 | |
1619 | - $date_format = give_date_format() . ', ' . get_option( 'time_format' ); |
|
1619 | + $date_format = give_date_format().', '.get_option('time_format'); |
|
1620 | 1620 | |
1621 | - $delete_note_url = wp_nonce_url( add_query_arg( array( |
|
1621 | + $delete_note_url = wp_nonce_url(add_query_arg(array( |
|
1622 | 1622 | 'give-action' => 'delete_payment_note', |
1623 | 1623 | 'note_id' => $note->comment_ID, |
1624 | 1624 | 'payment_id' => $payment_id, |
1625 | - ) ), |
|
1626 | - 'give_delete_payment_note_' . $note->comment_ID |
|
1625 | + )), |
|
1626 | + 'give_delete_payment_note_'.$note->comment_ID |
|
1627 | 1627 | ); |
1628 | 1628 | |
1629 | - $note_html = '<div class="give-payment-note" id="give-payment-note-' . $note->comment_ID . '">'; |
|
1629 | + $note_html = '<div class="give-payment-note" id="give-payment-note-'.$note->comment_ID.'">'; |
|
1630 | 1630 | $note_html .= '<p>'; |
1631 | - $note_html .= '<strong>' . $user . '</strong> – <span style="color:#aaa;font-style:italic;">' . date_i18n( $date_format, strtotime( $note->comment_date ) ) . '</span><br/>'; |
|
1631 | + $note_html .= '<strong>'.$user.'</strong> – <span style="color:#aaa;font-style:italic;">'.date_i18n($date_format, strtotime($note->comment_date)).'</span><br/>'; |
|
1632 | 1632 | $note_html .= $note->comment_content; |
1633 | - $note_html .= ' – <a href="' . esc_url( $delete_note_url ) . '" class="give-delete-payment-note" data-note-id="' . absint( $note->comment_ID ) . '" data-payment-id="' . absint( $payment_id ) . '" aria-label="' . esc_attr__( 'Delete this donation note.', 'give' ) . '">' . esc_html__( 'Delete', 'give' ) . '</a>'; |
|
1633 | + $note_html .= ' – <a href="'.esc_url($delete_note_url).'" class="give-delete-payment-note" data-note-id="'.absint($note->comment_ID).'" data-payment-id="'.absint($payment_id).'" aria-label="'.esc_attr__('Delete this donation note.', 'give').'">'.esc_html__('Delete', 'give').'</a>'; |
|
1634 | 1634 | $note_html .= '</p>'; |
1635 | 1635 | $note_html .= '</div>'; |
1636 | 1636 | |
@@ -1648,18 +1648,18 @@ discard block |
||
1648 | 1648 | * |
1649 | 1649 | * @return void |
1650 | 1650 | */ |
1651 | -function give_hide_payment_notes( $query ) { |
|
1652 | - if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '>=' ) ) { |
|
1653 | - $types = isset( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array(); |
|
1654 | - if ( ! is_array( $types ) ) { |
|
1655 | - $types = array( $types ); |
|
1651 | +function give_hide_payment_notes($query) { |
|
1652 | + if (version_compare(floatval(get_bloginfo('version')), '4.1', '>=')) { |
|
1653 | + $types = isset($query->query_vars['type__not_in']) ? $query->query_vars['type__not_in'] : array(); |
|
1654 | + if ( ! is_array($types)) { |
|
1655 | + $types = array($types); |
|
1656 | 1656 | } |
1657 | 1657 | $types[] = 'give_payment_note'; |
1658 | 1658 | $query->query_vars['type__not_in'] = $types; |
1659 | 1659 | } |
1660 | 1660 | } |
1661 | 1661 | |
1662 | -add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
1662 | +add_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
1663 | 1663 | |
1664 | 1664 | /** |
1665 | 1665 | * Exclude notes (comments) on give_payment post type from showing in Recent Comments widgets |
@@ -1671,15 +1671,15 @@ discard block |
||
1671 | 1671 | * |
1672 | 1672 | * @return array $clauses Updated comment clauses. |
1673 | 1673 | */ |
1674 | -function give_hide_payment_notes_pre_41( $clauses, $wp_comment_query ) { |
|
1675 | - if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '<' ) ) { |
|
1674 | +function give_hide_payment_notes_pre_41($clauses, $wp_comment_query) { |
|
1675 | + if (version_compare(floatval(get_bloginfo('version')), '4.1', '<')) { |
|
1676 | 1676 | $clauses['where'] .= ' AND comment_type != "give_payment_note"'; |
1677 | 1677 | } |
1678 | 1678 | |
1679 | 1679 | return $clauses; |
1680 | 1680 | } |
1681 | 1681 | |
1682 | -add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 ); |
|
1682 | +add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2); |
|
1683 | 1683 | |
1684 | 1684 | |
1685 | 1685 | /** |
@@ -1692,15 +1692,15 @@ discard block |
||
1692 | 1692 | * |
1693 | 1693 | * @return string $where |
1694 | 1694 | */ |
1695 | -function give_hide_payment_notes_from_feeds( $where, $wp_comment_query ) { |
|
1695 | +function give_hide_payment_notes_from_feeds($where, $wp_comment_query) { |
|
1696 | 1696 | global $wpdb; |
1697 | 1697 | |
1698 | - $where .= $wpdb->prepare( ' AND comment_type != %s', 'give_payment_note' ); |
|
1698 | + $where .= $wpdb->prepare(' AND comment_type != %s', 'give_payment_note'); |
|
1699 | 1699 | |
1700 | 1700 | return $where; |
1701 | 1701 | } |
1702 | 1702 | |
1703 | -add_filter( 'comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2 ); |
|
1703 | +add_filter('comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2); |
|
1704 | 1704 | |
1705 | 1705 | |
1706 | 1706 | /** |
@@ -1714,32 +1714,32 @@ discard block |
||
1714 | 1714 | * |
1715 | 1715 | * @return array Array of comment counts. |
1716 | 1716 | */ |
1717 | -function give_remove_payment_notes_in_comment_counts( $stats, $post_id ) { |
|
1717 | +function give_remove_payment_notes_in_comment_counts($stats, $post_id) { |
|
1718 | 1718 | global $wpdb, $pagenow; |
1719 | 1719 | |
1720 | - if ( 'index.php' != $pagenow ) { |
|
1720 | + if ('index.php' != $pagenow) { |
|
1721 | 1721 | return $stats; |
1722 | 1722 | } |
1723 | 1723 | |
1724 | 1724 | $post_id = (int) $post_id; |
1725 | 1725 | |
1726 | - if ( apply_filters( 'give_count_payment_notes_in_comments', false ) ) { |
|
1726 | + if (apply_filters('give_count_payment_notes_in_comments', false)) { |
|
1727 | 1727 | return $stats; |
1728 | 1728 | } |
1729 | 1729 | |
1730 | - $stats = wp_cache_get( "comments-{$post_id}", 'counts' ); |
|
1730 | + $stats = wp_cache_get("comments-{$post_id}", 'counts'); |
|
1731 | 1731 | |
1732 | - if ( false !== $stats ) { |
|
1732 | + if (false !== $stats) { |
|
1733 | 1733 | return $stats; |
1734 | 1734 | } |
1735 | 1735 | |
1736 | 1736 | $where = 'WHERE comment_type != "give_payment_note"'; |
1737 | 1737 | |
1738 | - if ( $post_id > 0 ) { |
|
1739 | - $where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id ); |
|
1738 | + if ($post_id > 0) { |
|
1739 | + $where .= $wpdb->prepare(' AND comment_post_ID = %d', $post_id); |
|
1740 | 1740 | } |
1741 | 1741 | |
1742 | - $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A ); |
|
1742 | + $count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A); |
|
1743 | 1743 | |
1744 | 1744 | $total = 0; |
1745 | 1745 | $approved = array( |
@@ -1749,30 +1749,30 @@ discard block |
||
1749 | 1749 | 'trash' => 'trash', |
1750 | 1750 | 'post-trashed' => 'post-trashed', |
1751 | 1751 | ); |
1752 | - foreach ( (array) $count as $row ) { |
|
1752 | + foreach ((array) $count as $row) { |
|
1753 | 1753 | // Don't count post-trashed toward totals. |
1754 | - if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) { |
|
1754 | + if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) { |
|
1755 | 1755 | $total += $row['num_comments']; |
1756 | 1756 | } |
1757 | - if ( isset( $approved[ $row['comment_approved'] ] ) ) { |
|
1758 | - $stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments']; |
|
1757 | + if (isset($approved[$row['comment_approved']])) { |
|
1758 | + $stats[$approved[$row['comment_approved']]] = $row['num_comments']; |
|
1759 | 1759 | } |
1760 | 1760 | } |
1761 | 1761 | |
1762 | 1762 | $stats['total_comments'] = $total; |
1763 | - foreach ( $approved as $key ) { |
|
1764 | - if ( empty( $stats[ $key ] ) ) { |
|
1765 | - $stats[ $key ] = 0; |
|
1763 | + foreach ($approved as $key) { |
|
1764 | + if (empty($stats[$key])) { |
|
1765 | + $stats[$key] = 0; |
|
1766 | 1766 | } |
1767 | 1767 | } |
1768 | 1768 | |
1769 | 1769 | $stats = (object) $stats; |
1770 | - wp_cache_set( "comments-{$post_id}", $stats, 'counts' ); |
|
1770 | + wp_cache_set("comments-{$post_id}", $stats, 'counts'); |
|
1771 | 1771 | |
1772 | 1772 | return $stats; |
1773 | 1773 | } |
1774 | 1774 | |
1775 | -add_filter( 'wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2 ); |
|
1775 | +add_filter('wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2); |
|
1776 | 1776 | |
1777 | 1777 | |
1778 | 1778 | /** |
@@ -1785,9 +1785,9 @@ discard block |
||
1785 | 1785 | * |
1786 | 1786 | * @return string $where Modified where clause. |
1787 | 1787 | */ |
1788 | -function give_filter_where_older_than_week( $where = '' ) { |
|
1788 | +function give_filter_where_older_than_week($where = '') { |
|
1789 | 1789 | // Payments older than one week. |
1790 | - $start = date( 'Y-m-d', strtotime( '-7 days' ) ); |
|
1790 | + $start = date('Y-m-d', strtotime('-7 days')); |
|
1791 | 1791 | $where .= " AND post_date <= '{$start}'"; |
1792 | 1792 | |
1793 | 1793 | return $where; |
@@ -1807,38 +1807,38 @@ discard block |
||
1807 | 1807 | * |
1808 | 1808 | * @return string $form_title Returns the full title if $only_level is false, otherwise returns the levels title. |
1809 | 1809 | */ |
1810 | -function give_get_payment_form_title( $payment_meta, $only_level = false, $separator = '' ) { |
|
1810 | +function give_get_payment_form_title($payment_meta, $only_level = false, $separator = '') { |
|
1811 | 1811 | |
1812 | - $form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0; |
|
1813 | - $price_id = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null; |
|
1814 | - $form_title = isset( $payment_meta['form_title'] ) ? $payment_meta['form_title'] : ''; |
|
1812 | + $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0; |
|
1813 | + $price_id = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null; |
|
1814 | + $form_title = isset($payment_meta['form_title']) ? $payment_meta['form_title'] : ''; |
|
1815 | 1815 | |
1816 | - if ( $only_level == true ) { |
|
1816 | + if ($only_level == true) { |
|
1817 | 1817 | $form_title = ''; |
1818 | 1818 | } |
1819 | 1819 | |
1820 | 1820 | //If multi-level, append to the form title. |
1821 | - if ( give_has_variable_prices( $form_id ) ) { |
|
1821 | + if (give_has_variable_prices($form_id)) { |
|
1822 | 1822 | |
1823 | 1823 | //Only add separator if there is a form title. |
1824 | - if ( ! empty( $form_title ) ) { |
|
1825 | - $form_title .= ' ' . $separator . ' '; |
|
1824 | + if ( ! empty($form_title)) { |
|
1825 | + $form_title .= ' '.$separator.' '; |
|
1826 | 1826 | } |
1827 | 1827 | |
1828 | 1828 | $form_title .= '<span class="donation-level-text-wrap">'; |
1829 | 1829 | |
1830 | - if ( $price_id == 'custom' ) { |
|
1831 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
1832 | - $form_title .= ! empty( $custom_amount_text ) ? $custom_amount_text : __( 'Custom Amount', 'give' ); |
|
1830 | + if ($price_id == 'custom') { |
|
1831 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
1832 | + $form_title .= ! empty($custom_amount_text) ? $custom_amount_text : __('Custom Amount', 'give'); |
|
1833 | 1833 | } else { |
1834 | - $form_title .= give_get_price_option_name( $form_id, $price_id ); |
|
1834 | + $form_title .= give_get_price_option_name($form_id, $price_id); |
|
1835 | 1835 | } |
1836 | 1836 | |
1837 | 1837 | $form_title .= '</span>'; |
1838 | 1838 | |
1839 | 1839 | } |
1840 | 1840 | |
1841 | - return apply_filters( 'give_get_payment_form_title', $form_title, $payment_meta ); |
|
1841 | + return apply_filters('give_get_payment_form_title', $form_title, $payment_meta); |
|
1842 | 1842 | |
1843 | 1843 | } |
1844 | 1844 | |
@@ -1852,20 +1852,20 @@ discard block |
||
1852 | 1852 | * |
1853 | 1853 | * @return string $price_id |
1854 | 1854 | */ |
1855 | -function give_get_price_id( $form_id, $price ) { |
|
1855 | +function give_get_price_id($form_id, $price) { |
|
1856 | 1856 | |
1857 | 1857 | $price_id = 0; |
1858 | 1858 | |
1859 | - if ( give_has_variable_prices( $form_id ) ) { |
|
1859 | + if (give_has_variable_prices($form_id)) { |
|
1860 | 1860 | |
1861 | - $levels = maybe_unserialize( get_post_meta( $form_id, '_give_donation_levels', true ) ); |
|
1861 | + $levels = maybe_unserialize(get_post_meta($form_id, '_give_donation_levels', true)); |
|
1862 | 1862 | |
1863 | - foreach ( $levels as $level ) { |
|
1863 | + foreach ($levels as $level) { |
|
1864 | 1864 | |
1865 | - $level_amount = (float) give_sanitize_amount( $level['_give_amount'] ); |
|
1865 | + $level_amount = (float) give_sanitize_amount($level['_give_amount']); |
|
1866 | 1866 | |
1867 | 1867 | // Check that this indeed the recurring price. |
1868 | - if ( $level_amount == $price ) { |
|
1868 | + if ($level_amount == $price) { |
|
1869 | 1869 | |
1870 | 1870 | $price_id = $level['_give_id']['level_id']; |
1871 | 1871 | |
@@ -1890,10 +1890,10 @@ discard block |
||
1890 | 1890 | * |
1891 | 1891 | * @return string|void |
1892 | 1892 | */ |
1893 | -function give_get_form_dropdown( $args = array(), $echo = false ) { |
|
1894 | - $form_dropdown_html = Give()->html->forms_dropdown( $args ); |
|
1893 | +function give_get_form_dropdown($args = array(), $echo = false) { |
|
1894 | + $form_dropdown_html = Give()->html->forms_dropdown($args); |
|
1895 | 1895 | |
1896 | - if ( ! $echo ) { |
|
1896 | + if ( ! $echo) { |
|
1897 | 1897 | return $form_dropdown_html; |
1898 | 1898 | } |
1899 | 1899 | |
@@ -1910,17 +1910,17 @@ discard block |
||
1910 | 1910 | * |
1911 | 1911 | * @return string|bool |
1912 | 1912 | */ |
1913 | -function give_get_form_variable_price_dropdown( $args = array(), $echo = false ) { |
|
1913 | +function give_get_form_variable_price_dropdown($args = array(), $echo = false) { |
|
1914 | 1914 | |
1915 | 1915 | // Check for give form id. |
1916 | - if ( empty( $args['id'] ) ) { |
|
1916 | + if (empty($args['id'])) { |
|
1917 | 1917 | return false; |
1918 | 1918 | } |
1919 | 1919 | |
1920 | - $form = new Give_Donate_Form( $args['id'] ); |
|
1920 | + $form = new Give_Donate_Form($args['id']); |
|
1921 | 1921 | |
1922 | 1922 | // Check if form has variable prices or not. |
1923 | - if ( ! $form->ID || ! $form->has_variable_prices() ) { |
|
1923 | + if ( ! $form->ID || ! $form->has_variable_prices()) { |
|
1924 | 1924 | return false; |
1925 | 1925 | } |
1926 | 1926 | |
@@ -1928,22 +1928,22 @@ discard block |
||
1928 | 1928 | $variable_price_options = array(); |
1929 | 1929 | |
1930 | 1930 | // Check if multi donation form support custom donation or not. |
1931 | - if ( $form->is_custom_price_mode() ) { |
|
1932 | - $variable_price_options['custom'] = _x( 'Custom', 'custom donation dropdown item', 'give' ); |
|
1931 | + if ($form->is_custom_price_mode()) { |
|
1932 | + $variable_price_options['custom'] = _x('Custom', 'custom donation dropdown item', 'give'); |
|
1933 | 1933 | } |
1934 | 1934 | |
1935 | 1935 | // Get variable price and ID from variable price array. |
1936 | - foreach ( $variable_prices as $variable_price ) { |
|
1937 | - $variable_price_options[ $variable_price['_give_id']['level_id'] ] = ! empty( $variable_price['_give_text'] ) ? $variable_price['_give_text'] : give_currency_filter( give_format_amount( $variable_price['_give_amount'] ) ); |
|
1936 | + foreach ($variable_prices as $variable_price) { |
|
1937 | + $variable_price_options[$variable_price['_give_id']['level_id']] = ! empty($variable_price['_give_text']) ? $variable_price['_give_text'] : give_currency_filter(give_format_amount($variable_price['_give_amount'])); |
|
1938 | 1938 | } |
1939 | 1939 | |
1940 | 1940 | // Update options. |
1941 | - $args = array_merge( $args, array( 'options' => $variable_price_options ) ); |
|
1941 | + $args = array_merge($args, array('options' => $variable_price_options)); |
|
1942 | 1942 | |
1943 | 1943 | // Generate select html. |
1944 | - $form_dropdown_html = Give()->html->select( $args ); |
|
1944 | + $form_dropdown_html = Give()->html->select($args); |
|
1945 | 1945 | |
1946 | - if ( ! $echo ) { |
|
1946 | + if ( ! $echo) { |
|
1947 | 1947 | return $form_dropdown_html; |
1948 | 1948 | } |
1949 | 1949 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -26,15 +26,15 @@ discard block |
||
26 | 26 | * @global $wpdb |
27 | 27 | * @return void |
28 | 28 | */ |
29 | -function give_install( $network_wide = false ) { |
|
29 | +function give_install($network_wide = false) { |
|
30 | 30 | |
31 | 31 | global $wpdb; |
32 | 32 | |
33 | - if ( is_multisite() && $network_wide ) { |
|
33 | + if (is_multisite() && $network_wide) { |
|
34 | 34 | |
35 | - foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) { |
|
35 | + foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs LIMIT 100") as $blog_id) { |
|
36 | 36 | |
37 | - switch_to_blog( $blog_id ); |
|
37 | + switch_to_blog($blog_id); |
|
38 | 38 | give_run_install(); |
39 | 39 | restore_current_blog(); |
40 | 40 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | |
49 | 49 | } |
50 | 50 | |
51 | -register_activation_hook( GIVE_PLUGIN_FILE, 'give_install' ); |
|
51 | +register_activation_hook(GIVE_PLUGIN_FILE, 'give_install'); |
|
52 | 52 | |
53 | 53 | /** |
54 | 54 | * Run the Give Install process. |
@@ -64,24 +64,24 @@ discard block |
||
64 | 64 | give_setup_post_types(); |
65 | 65 | |
66 | 66 | // Clear the permalinks. |
67 | - flush_rewrite_rules( false ); |
|
67 | + flush_rewrite_rules(false); |
|
68 | 68 | |
69 | 69 | // Add Upgraded From Option. |
70 | - $current_version = get_option( 'give_version' ); |
|
71 | - if ( $current_version ) { |
|
72 | - update_option( 'give_version_upgraded_from', $current_version ); |
|
70 | + $current_version = get_option('give_version'); |
|
71 | + if ($current_version) { |
|
72 | + update_option('give_version_upgraded_from', $current_version); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | // Setup some default options. |
76 | 76 | $options = array(); |
77 | 77 | |
78 | 78 | // Checks if the Success Page option exists AND that the page exists. |
79 | - if ( ! get_post( give_get_option( 'success_page' ) ) ) { |
|
79 | + if ( ! get_post(give_get_option('success_page'))) { |
|
80 | 80 | |
81 | 81 | // Donation Confirmation (Success) Page |
82 | 82 | $success = wp_insert_post( |
83 | 83 | array( |
84 | - 'post_title' => esc_html__( 'Donation Confirmation', 'give' ), |
|
84 | + 'post_title' => esc_html__('Donation Confirmation', 'give'), |
|
85 | 85 | 'post_content' => '[give_receipt]', |
86 | 86 | 'post_status' => 'publish', |
87 | 87 | 'post_author' => 1, |
@@ -95,13 +95,13 @@ discard block |
||
95 | 95 | } |
96 | 96 | |
97 | 97 | // Checks if the Failure Page option exists AND that the page exists. |
98 | - if ( ! get_post( give_get_option( 'failure_page' ) ) ) { |
|
98 | + if ( ! get_post(give_get_option('failure_page'))) { |
|
99 | 99 | |
100 | 100 | // Failed Donation Page |
101 | 101 | $failed = wp_insert_post( |
102 | 102 | array( |
103 | - 'post_title' => esc_html__( 'Donation Failed', 'give' ), |
|
104 | - 'post_content' => esc_html__( 'We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give' ), |
|
103 | + 'post_title' => esc_html__('Donation Failed', 'give'), |
|
104 | + 'post_content' => esc_html__('We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give'), |
|
105 | 105 | 'post_status' => 'publish', |
106 | 106 | 'post_author' => 1, |
107 | 107 | 'post_type' => 'page', |
@@ -113,11 +113,11 @@ discard block |
||
113 | 113 | } |
114 | 114 | |
115 | 115 | // Checks if the History Page option exists AND that the page exists. |
116 | - if ( ! get_post( give_get_option( 'history_page' ) ) ) { |
|
116 | + if ( ! get_post(give_get_option('history_page'))) { |
|
117 | 117 | // Donation History Page |
118 | 118 | $history = wp_insert_post( |
119 | 119 | array( |
120 | - 'post_title' => esc_html__( 'Donation History', 'give' ), |
|
120 | + 'post_title' => esc_html__('Donation History', 'give'), |
|
121 | 121 | 'post_content' => '[donation_history]', |
122 | 122 | 'post_status' => 'publish', |
123 | 123 | 'post_author' => 1, |
@@ -130,13 +130,13 @@ discard block |
||
130 | 130 | } |
131 | 131 | |
132 | 132 | //Fresh Install? Setup Test Mode, Base Country (US), Test Gateway, Currency. |
133 | - if ( empty( $current_version ) ) { |
|
133 | + if (empty($current_version)) { |
|
134 | 134 | |
135 | 135 | // General. |
136 | 136 | $options['base_country'] = 'US'; |
137 | 137 | $options['test_mode'] = 'enabled'; |
138 | 138 | $options['currency'] = 'USD'; |
139 | - $options['currency_position'] = 'before'; |
|
139 | + $options['currency_position'] = 'before'; |
|
140 | 140 | $options['session_lifetime'] = '604800'; |
141 | 141 | $options['email_access'] = 'disabled'; |
142 | 142 | $options['number_decimals'] = 2; |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | $options['scripts_footer'] = 'disabled'; |
160 | 160 | |
161 | 161 | // Paypal IPN verification. |
162 | - $options['paypal_verification'] = 'enabled'; |
|
162 | + $options['paypal_verification'] = 'enabled'; |
|
163 | 163 | |
164 | 164 | // Default is manual gateway. |
165 | 165 | $options['gateways']['manual'] = 1; |
@@ -181,8 +181,8 @@ discard block |
||
181 | 181 | } |
182 | 182 | |
183 | 183 | // Populate the default values. |
184 | - update_option( 'give_settings', array_merge( $give_options, $options ) ); |
|
185 | - update_option( 'give_version', GIVE_VERSION ); |
|
184 | + update_option('give_settings', array_merge($give_options, $options)); |
|
185 | + update_option('give_version', GIVE_VERSION); |
|
186 | 186 | |
187 | 187 | // Create Give roles. |
188 | 188 | $roles = new Give_Roles(); |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | $roles->add_caps(); |
191 | 191 | |
192 | 192 | $api = new Give_API(); |
193 | - update_option( 'give_default_api_version', 'v' . $api->get_version() ); |
|
193 | + update_option('give_default_api_version', 'v'.$api->get_version()); |
|
194 | 194 | |
195 | 195 | // Create the customers databases. |
196 | 196 | @Give()->customers->create_table(); |
@@ -200,11 +200,11 @@ discard block |
||
200 | 200 | Give()->session->use_php_sessions(); |
201 | 201 | |
202 | 202 | // Add a temporary option to note that Give pages have been created. |
203 | - set_transient( '_give_installed', $options, 30 ); |
|
203 | + set_transient('_give_installed', $options, 30); |
|
204 | 204 | |
205 | - if ( ! $current_version ) { |
|
205 | + if ( ! $current_version) { |
|
206 | 206 | |
207 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
207 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
208 | 208 | |
209 | 209 | // When new upgrade routines are added, mark them as complete on fresh install. |
210 | 210 | $upgrade_routines = array( |
@@ -213,22 +213,22 @@ discard block |
||
213 | 213 | 'upgrade_give_offline_status' |
214 | 214 | ); |
215 | 215 | |
216 | - foreach ( $upgrade_routines as $upgrade ) { |
|
217 | - give_set_upgrade_complete( $upgrade ); |
|
216 | + foreach ($upgrade_routines as $upgrade) { |
|
217 | + give_set_upgrade_complete($upgrade); |
|
218 | 218 | } |
219 | 219 | } |
220 | 220 | |
221 | 221 | // Bail if activating from network, or bulk. |
222 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
222 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
223 | 223 | return; |
224 | 224 | } |
225 | 225 | |
226 | 226 | // Add the transient to redirect. |
227 | - set_transient( '_give_activation_redirect', true, 30 ); |
|
227 | + set_transient('_give_activation_redirect', true, 30); |
|
228 | 228 | |
229 | 229 | } |
230 | 230 | |
231 | -register_activation_hook( GIVE_PLUGIN_FILE, 'give_install' ); |
|
231 | +register_activation_hook(GIVE_PLUGIN_FILE, 'give_install'); |
|
232 | 232 | |
233 | 233 | /** |
234 | 234 | * Network Activated New Site Setup. |
@@ -244,11 +244,11 @@ discard block |
||
244 | 244 | * @param int $site_id The Site ID. |
245 | 245 | * @param array $meta Blog Meta. |
246 | 246 | */ |
247 | -function on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) { |
|
247 | +function on_create_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) { |
|
248 | 248 | |
249 | - if ( is_plugin_active_for_network( GIVE_PLUGIN_BASENAME ) ) { |
|
249 | + if (is_plugin_active_for_network(GIVE_PLUGIN_BASENAME)) { |
|
250 | 250 | |
251 | - switch_to_blog( $blog_id ); |
|
251 | + switch_to_blog($blog_id); |
|
252 | 252 | give_install(); |
253 | 253 | restore_current_blog(); |
254 | 254 | |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | |
257 | 257 | } |
258 | 258 | |
259 | -add_action( 'wpmu_new_blog', 'on_create_blog', 10, 6 ); |
|
259 | +add_action('wpmu_new_blog', 'on_create_blog', 10, 6); |
|
260 | 260 | |
261 | 261 | |
262 | 262 | /** |
@@ -269,13 +269,13 @@ discard block |
||
269 | 269 | * |
270 | 270 | * @return array The tables to drop. |
271 | 271 | */ |
272 | -function give_wpmu_drop_tables( $tables, $blog_id ) { |
|
272 | +function give_wpmu_drop_tables($tables, $blog_id) { |
|
273 | 273 | |
274 | - switch_to_blog( $blog_id ); |
|
274 | + switch_to_blog($blog_id); |
|
275 | 275 | $customers_db = new Give_DB_Customers(); |
276 | 276 | $customer_meta_db = new Give_DB_Customer_Meta(); |
277 | 277 | |
278 | - if ( $customers_db->installed() ) { |
|
278 | + if ($customers_db->installed()) { |
|
279 | 279 | $tables[] = $customers_db->table_name; |
280 | 280 | $tables[] = $customer_meta_db->table_name; |
281 | 281 | } |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | |
286 | 286 | } |
287 | 287 | |
288 | -add_filter( 'wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2 ); |
|
288 | +add_filter('wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2); |
|
289 | 289 | |
290 | 290 | /** |
291 | 291 | * Post-installation |
@@ -297,16 +297,16 @@ discard block |
||
297 | 297 | */ |
298 | 298 | function give_after_install() { |
299 | 299 | |
300 | - if ( ! is_admin() ) { |
|
300 | + if ( ! is_admin()) { |
|
301 | 301 | return; |
302 | 302 | } |
303 | 303 | |
304 | - $give_options = get_transient( '_give_installed' ); |
|
305 | - $give_table_check = get_option( '_give_table_check', false ); |
|
304 | + $give_options = get_transient('_give_installed'); |
|
305 | + $give_table_check = get_option('_give_table_check', false); |
|
306 | 306 | |
307 | - if ( false === $give_table_check || current_time( 'timestamp' ) > $give_table_check ) { |
|
307 | + if (false === $give_table_check || current_time('timestamp') > $give_table_check) { |
|
308 | 308 | |
309 | - if ( ! @Give()->customer_meta->installed() ) { |
|
309 | + if ( ! @Give()->customer_meta->installed()) { |
|
310 | 310 | |
311 | 311 | // Create the customer meta database |
312 | 312 | // (this ensures it creates it on multisite instances where it is network activated). |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | |
315 | 315 | } |
316 | 316 | |
317 | - if ( ! @Give()->customers->installed() ) { |
|
317 | + if ( ! @Give()->customers->installed()) { |
|
318 | 318 | // Create the customers database |
319 | 319 | // (this ensures it creates it on multisite instances where it is network activated). |
320 | 320 | @Give()->customers->create_table(); |
@@ -326,22 +326,22 @@ discard block |
||
326 | 326 | * |
327 | 327 | * @param array $give_options Give plugin options. |
328 | 328 | */ |
329 | - do_action( 'give_after_install', $give_options ); |
|
329 | + do_action('give_after_install', $give_options); |
|
330 | 330 | } |
331 | 331 | |
332 | - update_option( '_give_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ) ); |
|
332 | + update_option('_give_table_check', (current_time('timestamp') + WEEK_IN_SECONDS)); |
|
333 | 333 | |
334 | 334 | } |
335 | 335 | |
336 | 336 | // Delete the transient |
337 | - if ( false !== $give_options ) { |
|
338 | - delete_transient( '_give_installed' ); |
|
337 | + if (false !== $give_options) { |
|
338 | + delete_transient('_give_installed'); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | |
342 | 342 | } |
343 | 343 | |
344 | -add_action( 'admin_init', 'give_after_install' ); |
|
344 | +add_action('admin_init', 'give_after_install'); |
|
345 | 345 | |
346 | 346 | |
347 | 347 | /** |
@@ -356,11 +356,11 @@ discard block |
||
356 | 356 | |
357 | 357 | global $wp_roles; |
358 | 358 | |
359 | - if ( ! is_object( $wp_roles ) ) { |
|
359 | + if ( ! is_object($wp_roles)) { |
|
360 | 360 | return; |
361 | 361 | } |
362 | 362 | |
363 | - if ( ! array_key_exists( 'give_manager', $wp_roles->roles ) ) { |
|
363 | + if ( ! array_key_exists('give_manager', $wp_roles->roles)) { |
|
364 | 364 | |
365 | 365 | // Create Give plugin roles |
366 | 366 | $roles = new Give_Roles(); |
@@ -371,4 +371,4 @@ discard block |
||
371 | 371 | |
372 | 372 | } |
373 | 373 | |
374 | -add_action( 'admin_init', 'give_install_roles_on_network' ); |
|
374 | +add_action('admin_init', 'give_install_roles_on_network'); |