@@ -697,7 +697,7 @@ discard block |
||
697 | 697 | * @param int $year Year number. Default is null. |
698 | 698 | * @param int $hour Hour number. Default is null. |
699 | 699 | * |
700 | - * @return int $earnings Earnings |
|
700 | + * @return double $earnings Earnings |
|
701 | 701 | */ |
702 | 702 | function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) { |
703 | 703 | |
@@ -986,7 +986,7 @@ discard block |
||
986 | 986 | * |
987 | 987 | * @param int $payment_id Payment ID. |
988 | 988 | * |
989 | - * @return array $user_info User Info Meta Values. |
|
989 | + * @return string $user_info User Info Meta Values. |
|
990 | 990 | */ |
991 | 991 | function give_get_payment_meta_user_info( $payment_id ) { |
992 | 992 | $payment = new Give_Payment( $payment_id ); |
@@ -1003,7 +1003,7 @@ discard block |
||
1003 | 1003 | * |
1004 | 1004 | * @param int $payment_id Payment ID. |
1005 | 1005 | * |
1006 | - * @return int $form_id Form ID. |
|
1006 | + * @return string $form_id Form ID. |
|
1007 | 1007 | */ |
1008 | 1008 | function give_get_payment_form_id( $payment_id ) { |
1009 | 1009 | $payment = new Give_Payment( $payment_id ); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -43,15 +43,15 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @return array $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 | }// End switch(). |
118 | 118 | |
119 | - if ( $payment ) { |
|
119 | + if ($payment) { |
|
120 | 120 | return $payment; |
121 | 121 | } |
122 | 122 | |
@@ -132,29 +132,29 @@ 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 = give_get_payment_meta_price_id( $payment_data ); |
|
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 = give_get_payment_meta_price_id($payment_data); |
|
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; |
155 | 155 | $payment->form_id = $form_id; |
156 | 156 | $payment->price_id = $price_id; |
157 | - $payment->donor_id = ( ! empty( $payment_data['donor_id'] ) ? $payment_data['donor_id'] : '' ); |
|
157 | + $payment->donor_id = ( ! empty($payment_data['donor_id']) ? $payment_data['donor_id'] : ''); |
|
158 | 158 | $payment->user_id = $payment_data['user_info']['id']; |
159 | 159 | $payment->email = $payment_data['user_email']; |
160 | 160 | $payment->first_name = $payment_data['user_info']['first_name']; |
@@ -162,8 +162,8 @@ discard block |
||
162 | 162 | $payment->email = $payment_data['user_info']['email']; |
163 | 163 | $payment->ip = give_get_ip(); |
164 | 164 | $payment->key = $payment_data['purchase_key']; |
165 | - $payment->mode = ( ! empty( $payment_data['mode'] ) ? (string) $payment_data['mode'] : ( give_is_test_mode() ? 'test' : 'live' ) ); |
|
166 | - $payment->parent_payment = ! empty( $payment_data['parent'] ) ? absint( $payment_data['parent'] ) : ''; |
|
165 | + $payment->mode = ( ! empty($payment_data['mode']) ? (string) $payment_data['mode'] : (give_is_test_mode() ? 'test' : 'live')); |
|
166 | + $payment->parent_payment = ! empty($payment_data['parent']) ? absint($payment_data['parent']) : ''; |
|
167 | 167 | |
168 | 168 | // Add the donation. |
169 | 169 | $args = array( |
@@ -171,19 +171,19 @@ discard block |
||
171 | 171 | 'price_id' => $payment->price_id, |
172 | 172 | ); |
173 | 173 | |
174 | - $payment->add_donation( $payment->form_id, $args ); |
|
174 | + $payment->add_donation($payment->form_id, $args); |
|
175 | 175 | |
176 | 176 | |
177 | 177 | // Set date if present. |
178 | - if ( isset( $payment_data['post_date'] ) ) { |
|
178 | + if (isset($payment_data['post_date'])) { |
|
179 | 179 | $payment->date = $payment_data['post_date']; |
180 | 180 | } |
181 | 181 | |
182 | 182 | // Handle sequential payments. |
183 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
183 | + if (give_get_option('enable_sequential')) { |
|
184 | 184 | $number = give_get_next_payment_number(); |
185 | - $payment->number = give_format_payment_number( $number ); |
|
186 | - update_option( 'give_last_payment_number', $number ); |
|
185 | + $payment->number = give_format_payment_number($number); |
|
186 | + update_option('give_last_payment_number', $number); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | // Save payment. |
@@ -197,10 +197,10 @@ discard block |
||
197 | 197 | * @param int $payment_id The payment ID. |
198 | 198 | * @param array $payment_data Arguments passed. |
199 | 199 | */ |
200 | - do_action( 'give_insert_payment', $payment->ID, $payment_data ); |
|
200 | + do_action('give_insert_payment', $payment->ID, $payment_data); |
|
201 | 201 | |
202 | 202 | // Return payment ID upon success. |
203 | - if ( ! empty( $payment->ID ) ) { |
|
203 | + if ( ! empty($payment->ID)) { |
|
204 | 204 | return $payment->ID; |
205 | 205 | } |
206 | 206 | |
@@ -216,10 +216,10 @@ discard block |
||
216 | 216 | * |
217 | 217 | * @return bool|int |
218 | 218 | */ |
219 | -function give_create_payment( $payment_data ) { |
|
219 | +function give_create_payment($payment_data) { |
|
220 | 220 | |
221 | - $form_id = intval( $payment_data['post_data']['give-form-id'] ); |
|
222 | - $price_id = isset( $payment_data['post_data']['give-price-id'] ) ? $payment_data['post_data']['give-price-id'] : ''; |
|
221 | + $form_id = intval($payment_data['post_data']['give-form-id']); |
|
222 | + $price_id = isset($payment_data['post_data']['give-price-id']) ? $payment_data['post_data']['give-price-id'] : ''; |
|
223 | 223 | |
224 | 224 | // Collect payment data. |
225 | 225 | $insert_payment_data = array( |
@@ -243,10 +243,10 @@ discard block |
||
243 | 243 | * |
244 | 244 | * @param array $insert_payment_data |
245 | 245 | */ |
246 | - $insert_payment_data = apply_filters( 'give_create_payment', $insert_payment_data ); |
|
246 | + $insert_payment_data = apply_filters('give_create_payment', $insert_payment_data); |
|
247 | 247 | |
248 | 248 | // Record the pending payment. |
249 | - return give_insert_payment( $insert_payment_data ); |
|
249 | + return give_insert_payment($insert_payment_data); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
@@ -259,12 +259,12 @@ discard block |
||
259 | 259 | * |
260 | 260 | * @return bool |
261 | 261 | */ |
262 | -function give_update_payment_status( $payment_id, $new_status = 'publish' ) { |
|
262 | +function give_update_payment_status($payment_id, $new_status = 'publish') { |
|
263 | 263 | |
264 | 264 | $updated = false; |
265 | - $payment = new Give_Payment( $payment_id ); |
|
265 | + $payment = new Give_Payment($payment_id); |
|
266 | 266 | |
267 | - if ( $payment && $payment->ID > 0 ) { |
|
267 | + if ($payment && $payment->ID > 0) { |
|
268 | 268 | |
269 | 269 | $payment->status = $new_status; |
270 | 270 | $updated = $payment->save(); |
@@ -286,38 +286,38 @@ discard block |
||
286 | 286 | * |
287 | 287 | * @return void |
288 | 288 | */ |
289 | -function give_delete_donation( $payment_id = 0, $update_donor = true ) { |
|
289 | +function give_delete_donation($payment_id = 0, $update_donor = true) { |
|
290 | 290 | global $give_logs; |
291 | 291 | |
292 | - $payment = new Give_Payment( $payment_id ); |
|
293 | - $amount = give_get_payment_amount( $payment_id ); |
|
292 | + $payment = new Give_Payment($payment_id); |
|
293 | + $amount = give_get_payment_amount($payment_id); |
|
294 | 294 | $status = $payment->post_status; |
295 | - $donor_id = give_get_payment_donor_id( $payment_id ); |
|
296 | - $donor = new Give_Donor( $donor_id ); |
|
295 | + $donor_id = give_get_payment_donor_id($payment_id); |
|
296 | + $donor = new Give_Donor($donor_id); |
|
297 | 297 | |
298 | 298 | // Only undo donations that aren't these statuses. |
299 | - $dont_undo_statuses = apply_filters( 'give_undo_donation_statuses', array( |
|
299 | + $dont_undo_statuses = apply_filters('give_undo_donation_statuses', array( |
|
300 | 300 | 'pending', |
301 | 301 | 'cancelled', |
302 | - ) ); |
|
302 | + )); |
|
303 | 303 | |
304 | - if ( ! in_array( $status, $dont_undo_statuses ) ) { |
|
305 | - give_undo_donation( $payment_id ); |
|
304 | + if ( ! in_array($status, $dont_undo_statuses)) { |
|
305 | + give_undo_donation($payment_id); |
|
306 | 306 | } |
307 | 307 | |
308 | - if ( $status == 'publish' ) { |
|
308 | + if ($status == 'publish') { |
|
309 | 309 | |
310 | 310 | // Only decrease earnings if they haven't already been decreased (or were never increased for this payment). |
311 | - give_decrease_total_earnings( $amount ); |
|
311 | + give_decrease_total_earnings($amount); |
|
312 | 312 | |
313 | 313 | // @todo: Refresh only range related stat cache |
314 | 314 | give_delete_donation_stats(); |
315 | 315 | |
316 | - if ( $donor->id && $update_donor ) { |
|
316 | + if ($donor->id && $update_donor) { |
|
317 | 317 | |
318 | 318 | // Decrement the stats for the donor. |
319 | 319 | $donor->decrease_donation_count(); |
320 | - $donor->decrease_value( $amount ); |
|
320 | + $donor->decrease_value($amount); |
|
321 | 321 | |
322 | 322 | } |
323 | 323 | } |
@@ -329,25 +329,25 @@ discard block |
||
329 | 329 | * |
330 | 330 | * @param int $payment_id Payment ID. |
331 | 331 | */ |
332 | - do_action( 'give_payment_delete', $payment_id ); |
|
332 | + do_action('give_payment_delete', $payment_id); |
|
333 | 333 | |
334 | - if ( $donor->id && $update_donor ) { |
|
334 | + if ($donor->id && $update_donor) { |
|
335 | 335 | |
336 | 336 | // Remove the payment ID from the donor. |
337 | - $donor->remove_payment( $payment_id ); |
|
337 | + $donor->remove_payment($payment_id); |
|
338 | 338 | |
339 | 339 | } |
340 | 340 | |
341 | 341 | // Remove the payment. |
342 | - wp_delete_post( $payment_id, true ); |
|
342 | + wp_delete_post($payment_id, true); |
|
343 | 343 | |
344 | 344 | // Remove related sale log entries. |
345 | - $give_logs->delete_logs( null, 'sale', array( |
|
345 | + $give_logs->delete_logs(null, 'sale', array( |
|
346 | 346 | array( |
347 | 347 | 'key' => '_give_log_payment_id', |
348 | 348 | 'value' => $payment_id, |
349 | 349 | ), |
350 | - ) ); |
|
350 | + )); |
|
351 | 351 | |
352 | 352 | /** |
353 | 353 | * Fires after payment deleted. |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | * |
357 | 357 | * @param int $payment_id Payment ID. |
358 | 358 | */ |
359 | - do_action( 'give_payment_deleted', $payment_id ); |
|
359 | + do_action('give_payment_deleted', $payment_id); |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | /** |
@@ -371,20 +371,20 @@ discard block |
||
371 | 371 | * |
372 | 372 | * @return void |
373 | 373 | */ |
374 | -function give_undo_donation( $payment_id ) { |
|
374 | +function give_undo_donation($payment_id) { |
|
375 | 375 | |
376 | - $payment = new Give_Payment( $payment_id ); |
|
376 | + $payment = new Give_Payment($payment_id); |
|
377 | 377 | |
378 | - $maybe_decrease_earnings = apply_filters( 'give_decrease_earnings_on_undo', true, $payment, $payment->form_id ); |
|
379 | - if ( true === $maybe_decrease_earnings ) { |
|
378 | + $maybe_decrease_earnings = apply_filters('give_decrease_earnings_on_undo', true, $payment, $payment->form_id); |
|
379 | + if (true === $maybe_decrease_earnings) { |
|
380 | 380 | // Decrease earnings. |
381 | - give_decrease_earnings( $payment->form_id, $payment->total ); |
|
381 | + give_decrease_earnings($payment->form_id, $payment->total); |
|
382 | 382 | } |
383 | 383 | |
384 | - $maybe_decrease_donations = apply_filters( 'give_decrease_donations_on_undo', true, $payment, $payment->form_id ); |
|
385 | - if ( true === $maybe_decrease_donations ) { |
|
384 | + $maybe_decrease_donations = apply_filters('give_decrease_donations_on_undo', true, $payment, $payment->form_id); |
|
385 | + if (true === $maybe_decrease_donations) { |
|
386 | 386 | // Decrease donation count. |
387 | - give_decrease_donation_count( $payment->form_id ); |
|
387 | + give_decrease_donation_count($payment->form_id); |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | } |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | * |
402 | 402 | * @return object $stats Contains the number of payments per payment status. |
403 | 403 | */ |
404 | -function give_count_payments( $args = array() ) { |
|
404 | +function give_count_payments($args = array()) { |
|
405 | 405 | |
406 | 406 | global $wpdb; |
407 | 407 | |
@@ -413,18 +413,18 @@ discard block |
||
413 | 413 | 'form_id' => null, |
414 | 414 | ); |
415 | 415 | |
416 | - $args = wp_parse_args( $args, $defaults ); |
|
416 | + $args = wp_parse_args($args, $defaults); |
|
417 | 417 | |
418 | 418 | $select = 'SELECT p.post_status,count( * ) AS num_posts'; |
419 | 419 | $join = ''; |
420 | - $where = "WHERE p.post_type = 'give_payment' AND p.post_status IN ('" . implode( "','", give_get_payment_status_keys() ) . "')"; |
|
420 | + $where = "WHERE p.post_type = 'give_payment' AND p.post_status IN ('".implode("','", give_get_payment_status_keys())."')"; |
|
421 | 421 | |
422 | 422 | // Count payments for a specific user. |
423 | - if ( ! empty( $args['user'] ) ) { |
|
423 | + if ( ! empty($args['user'])) { |
|
424 | 424 | |
425 | - if ( is_email( $args['user'] ) ) { |
|
425 | + if (is_email($args['user'])) { |
|
426 | 426 | $field = 'email'; |
427 | - } elseif ( is_numeric( $args['user'] ) ) { |
|
427 | + } elseif (is_numeric($args['user'])) { |
|
428 | 428 | $field = 'id'; |
429 | 429 | } else { |
430 | 430 | $field = ''; |
@@ -432,107 +432,107 @@ discard block |
||
432 | 432 | |
433 | 433 | $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
434 | 434 | |
435 | - if ( ! empty( $field ) ) { |
|
435 | + if ( ! empty($field)) { |
|
436 | 436 | $where .= " |
437 | 437 | AND m.meta_key = '_give_payment_user_{$field}' |
438 | 438 | AND m.meta_value = '{$args['user']}'"; |
439 | 439 | } |
440 | - } elseif ( ! empty( $args['donor'] ) ) { |
|
440 | + } elseif ( ! empty($args['donor'])) { |
|
441 | 441 | |
442 | - $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
|
442 | + $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
|
443 | 443 | $where .= " |
444 | 444 | AND m.meta_key = '_give_payment_customer_id' |
445 | 445 | AND m.meta_value = '{$args['donor']}'"; |
446 | 446 | |
447 | 447 | // Count payments for a search. |
448 | - } elseif ( ! empty( $args['s'] ) ) { |
|
448 | + } elseif ( ! empty($args['s'])) { |
|
449 | 449 | |
450 | - if ( is_email( $args['s'] ) || strlen( $args['s'] ) == 32 ) { |
|
450 | + if (is_email($args['s']) || strlen($args['s']) == 32) { |
|
451 | 451 | |
452 | - if ( is_email( $args['s'] ) ) { |
|
452 | + if (is_email($args['s'])) { |
|
453 | 453 | $field = '_give_payment_user_email'; |
454 | 454 | } else { |
455 | 455 | $field = '_give_payment_purchase_key'; |
456 | 456 | } |
457 | 457 | |
458 | - $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
|
459 | - $where .= $wpdb->prepare( ' |
|
458 | + $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
|
459 | + $where .= $wpdb->prepare(' |
|
460 | 460 | AND m.meta_key = %s |
461 | - AND m.meta_value = %s', $field, $args['s'] ); |
|
461 | + AND m.meta_value = %s', $field, $args['s']); |
|
462 | 462 | |
463 | - } elseif ( '#' == substr( $args['s'], 0, 1 ) ) { |
|
463 | + } elseif ('#' == substr($args['s'], 0, 1)) { |
|
464 | 464 | |
465 | - $search = str_replace( '#:', '', $args['s'] ); |
|
466 | - $search = str_replace( '#', '', $search ); |
|
465 | + $search = str_replace('#:', '', $args['s']); |
|
466 | + $search = str_replace('#', '', $search); |
|
467 | 467 | |
468 | 468 | $select = 'SELECT p.post_status,count( * ) AS num_posts '; |
469 | 469 | $join = ''; |
470 | - $where = $wpdb->prepare( 'WHERE p.post_type=%s AND p.ID = %d ', 'give_payment', $search ); |
|
470 | + $where = $wpdb->prepare('WHERE p.post_type=%s AND p.ID = %d ', 'give_payment', $search); |
|
471 | 471 | |
472 | - } elseif ( is_numeric( $args['s'] ) ) { |
|
472 | + } elseif (is_numeric($args['s'])) { |
|
473 | 473 | |
474 | - $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
|
475 | - $where .= $wpdb->prepare( " |
|
474 | + $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
|
475 | + $where .= $wpdb->prepare(" |
|
476 | 476 | AND m.meta_key = '_give_payment_user_id' |
477 | - AND m.meta_value = %d", $args['s'] ); |
|
477 | + AND m.meta_value = %d", $args['s']); |
|
478 | 478 | |
479 | 479 | } else { |
480 | - $search = $wpdb->esc_like( $args['s'] ); |
|
481 | - $search = '%' . $search . '%'; |
|
480 | + $search = $wpdb->esc_like($args['s']); |
|
481 | + $search = '%'.$search.'%'; |
|
482 | 482 | |
483 | - $where .= $wpdb->prepare( 'AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search ); |
|
483 | + $where .= $wpdb->prepare('AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search); |
|
484 | 484 | }// End if(). |
485 | 485 | }// End if(). |
486 | 486 | |
487 | - if ( ! empty( $args['form_id'] ) && is_numeric( $args['form_id'] ) ) { |
|
487 | + if ( ! empty($args['form_id']) && is_numeric($args['form_id'])) { |
|
488 | 488 | |
489 | - $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
|
490 | - $where .= $wpdb->prepare( ' |
|
489 | + $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
|
490 | + $where .= $wpdb->prepare(' |
|
491 | 491 | AND m.meta_key = %s |
492 | - AND m.meta_value = %s', '_give_payment_form_id', $args['form_id'] ); |
|
492 | + AND m.meta_value = %s', '_give_payment_form_id', $args['form_id']); |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | // Limit payments count by date. |
496 | - if ( ! empty( $args['start-date'] ) && false !== strpos( $args['start-date'], '/' ) ) { |
|
496 | + if ( ! empty($args['start-date']) && false !== strpos($args['start-date'], '/')) { |
|
497 | 497 | |
498 | - $date_parts = explode( '/', $args['start-date'] ); |
|
499 | - $month = ! empty( $date_parts[0] ) && is_numeric( $date_parts[0] ) ? $date_parts[0] : 0; |
|
500 | - $day = ! empty( $date_parts[1] ) && is_numeric( $date_parts[1] ) ? $date_parts[1] : 0; |
|
501 | - $year = ! empty( $date_parts[2] ) && is_numeric( $date_parts[2] ) ? $date_parts[2] : 0; |
|
498 | + $date_parts = explode('/', $args['start-date']); |
|
499 | + $month = ! empty($date_parts[0]) && is_numeric($date_parts[0]) ? $date_parts[0] : 0; |
|
500 | + $day = ! empty($date_parts[1]) && is_numeric($date_parts[1]) ? $date_parts[1] : 0; |
|
501 | + $year = ! empty($date_parts[2]) && is_numeric($date_parts[2]) ? $date_parts[2] : 0; |
|
502 | 502 | |
503 | - $is_date = checkdate( $month, $day, $year ); |
|
504 | - if ( false !== $is_date ) { |
|
503 | + $is_date = checkdate($month, $day, $year); |
|
504 | + if (false !== $is_date) { |
|
505 | 505 | |
506 | - $date = new DateTime( $args['start-date'] ); |
|
507 | - $where .= $wpdb->prepare( " AND p.post_date >= '%s'", $date->format( 'Y-m-d' ) ); |
|
506 | + $date = new DateTime($args['start-date']); |
|
507 | + $where .= $wpdb->prepare(" AND p.post_date >= '%s'", $date->format('Y-m-d')); |
|
508 | 508 | |
509 | 509 | } |
510 | 510 | |
511 | 511 | // Fixes an issue with the payments list table counts when no end date is specified (with stats class). |
512 | - if ( empty( $args['end-date'] ) ) { |
|
512 | + if (empty($args['end-date'])) { |
|
513 | 513 | $args['end-date'] = $args['start-date']; |
514 | 514 | } |
515 | 515 | } |
516 | 516 | |
517 | - if ( ! empty( $args['end-date'] ) && false !== strpos( $args['end-date'], '/' ) ) { |
|
517 | + if ( ! empty($args['end-date']) && false !== strpos($args['end-date'], '/')) { |
|
518 | 518 | |
519 | - $date_parts = explode( '/', $args['end-date'] ); |
|
519 | + $date_parts = explode('/', $args['end-date']); |
|
520 | 520 | |
521 | - $month = ! empty( $date_parts[0] ) ? $date_parts[0] : 0; |
|
522 | - $day = ! empty( $date_parts[1] ) ? $date_parts[1] : 0; |
|
523 | - $year = ! empty( $date_parts[2] ) ? $date_parts[2] : 0; |
|
521 | + $month = ! empty($date_parts[0]) ? $date_parts[0] : 0; |
|
522 | + $day = ! empty($date_parts[1]) ? $date_parts[1] : 0; |
|
523 | + $year = ! empty($date_parts[2]) ? $date_parts[2] : 0; |
|
524 | 524 | |
525 | - $is_date = checkdate( $month, $day, $year ); |
|
526 | - if ( false !== $is_date ) { |
|
525 | + $is_date = checkdate($month, $day, $year); |
|
526 | + if (false !== $is_date) { |
|
527 | 527 | |
528 | - $date = new DateTime( $args['end-date'] ); |
|
529 | - $where .= $wpdb->prepare( " AND p.post_date <= '%s'", $date->format( 'Y-m-d' ) ); |
|
528 | + $date = new DateTime($args['end-date']); |
|
529 | + $where .= $wpdb->prepare(" AND p.post_date <= '%s'", $date->format('Y-m-d')); |
|
530 | 530 | |
531 | 531 | } |
532 | 532 | } |
533 | 533 | |
534 | - $where = apply_filters( 'give_count_payments_where', $where ); |
|
535 | - $join = apply_filters( 'give_count_payments_join', $join ); |
|
534 | + $where = apply_filters('give_count_payments_where', $where); |
|
535 | + $join = apply_filters('give_count_payments_join', $join); |
|
536 | 536 | |
537 | 537 | $query = "$select |
538 | 538 | FROM $wpdb->posts p |
@@ -541,36 +541,36 @@ discard block |
||
541 | 541 | GROUP BY p.post_status |
542 | 542 | "; |
543 | 543 | |
544 | - $cache_key = md5( $query ); |
|
544 | + $cache_key = md5($query); |
|
545 | 545 | |
546 | - $count = wp_cache_get( $cache_key, 'counts' ); |
|
547 | - if ( false !== $count ) { |
|
546 | + $count = wp_cache_get($cache_key, 'counts'); |
|
547 | + if (false !== $count) { |
|
548 | 548 | return $count; |
549 | 549 | } |
550 | 550 | |
551 | - $count = $wpdb->get_results( $query, ARRAY_A ); |
|
551 | + $count = $wpdb->get_results($query, ARRAY_A); |
|
552 | 552 | |
553 | 553 | $stats = array(); |
554 | 554 | $statuses = get_post_stati(); |
555 | - if ( isset( $statuses['private'] ) && empty( $args['s'] ) ) { |
|
556 | - unset( $statuses['private'] ); |
|
555 | + if (isset($statuses['private']) && empty($args['s'])) { |
|
556 | + unset($statuses['private']); |
|
557 | 557 | } |
558 | 558 | |
559 | - foreach ( $statuses as $state ) { |
|
560 | - $stats[ $state ] = 0; |
|
559 | + foreach ($statuses as $state) { |
|
560 | + $stats[$state] = 0; |
|
561 | 561 | } |
562 | 562 | |
563 | - foreach ( (array) $count as $row ) { |
|
563 | + foreach ((array) $count as $row) { |
|
564 | 564 | |
565 | - if ( 'private' == $row['post_status'] && empty( $args['s'] ) ) { |
|
565 | + if ('private' == $row['post_status'] && empty($args['s'])) { |
|
566 | 566 | continue; |
567 | 567 | } |
568 | 568 | |
569 | - $stats[ $row['post_status'] ] = $row['num_posts']; |
|
569 | + $stats[$row['post_status']] = $row['num_posts']; |
|
570 | 570 | } |
571 | 571 | |
572 | 572 | $stats = (object) $stats; |
573 | - wp_cache_set( $cache_key, $stats, 'counts' ); |
|
573 | + wp_cache_set($cache_key, $stats, 'counts'); |
|
574 | 574 | |
575 | 575 | return $stats; |
576 | 576 | } |
@@ -585,11 +585,11 @@ discard block |
||
585 | 585 | * |
586 | 586 | * @return bool $exists True if payment exists, false otherwise. |
587 | 587 | */ |
588 | -function give_check_for_existing_payment( $payment_id ) { |
|
588 | +function give_check_for_existing_payment($payment_id) { |
|
589 | 589 | $exists = false; |
590 | - $payment = new Give_Payment( $payment_id ); |
|
590 | + $payment = new Give_Payment($payment_id); |
|
591 | 591 | |
592 | - if ( $payment_id === $payment->ID && 'publish' === $payment->status ) { |
|
592 | + if ($payment_id === $payment->ID && 'publish' === $payment->status) { |
|
593 | 593 | $exists = true; |
594 | 594 | } |
595 | 595 | |
@@ -607,41 +607,41 @@ discard block |
||
607 | 607 | * |
608 | 608 | * @return bool|mixed True if payment status exists, false otherwise. |
609 | 609 | */ |
610 | -function give_get_payment_status( $payment, $return_label = false ) { |
|
610 | +function give_get_payment_status($payment, $return_label = false) { |
|
611 | 611 | |
612 | - if ( is_numeric( $payment ) ) { |
|
612 | + if (is_numeric($payment)) { |
|
613 | 613 | |
614 | - $payment = new Give_Payment( $payment ); |
|
614 | + $payment = new Give_Payment($payment); |
|
615 | 615 | |
616 | - if ( ! $payment->ID > 0 ) { |
|
616 | + if ( ! $payment->ID > 0) { |
|
617 | 617 | return false; |
618 | 618 | } |
619 | 619 | |
620 | 620 | } |
621 | 621 | |
622 | - if ( ! is_object( $payment ) || ! isset( $payment->post_status ) ) { |
|
622 | + if ( ! is_object($payment) || ! isset($payment->post_status)) { |
|
623 | 623 | return false; |
624 | 624 | } |
625 | 625 | |
626 | 626 | $statuses = give_get_payment_statuses(); |
627 | 627 | |
628 | - if ( ! is_array( $statuses ) || empty( $statuses ) ) { |
|
628 | + if ( ! is_array($statuses) || empty($statuses)) { |
|
629 | 629 | return false; |
630 | 630 | } |
631 | 631 | |
632 | 632 | // Get payment object if not already given. |
633 | - $payment = $payment instanceof Give_Payment ? $payment : new Give_Payment( $payment->ID ); |
|
633 | + $payment = $payment instanceof Give_Payment ? $payment : new Give_Payment($payment->ID); |
|
634 | 634 | |
635 | - if ( array_key_exists( $payment->status, $statuses ) ) { |
|
636 | - if ( true === $return_label ) { |
|
635 | + if (array_key_exists($payment->status, $statuses)) { |
|
636 | + if (true === $return_label) { |
|
637 | 637 | // Return translated status label. |
638 | - return $statuses[ $payment->status ]; |
|
638 | + return $statuses[$payment->status]; |
|
639 | 639 | } else { |
640 | 640 | // Account that our 'publish' status is labeled 'Complete' |
641 | 641 | $post_status = 'publish' == $payment->status ? 'Complete' : $payment->post_status; |
642 | 642 | |
643 | 643 | // Make sure we're matching cases, since they matter |
644 | - return array_search( strtolower( $post_status ), array_map( 'strtolower', $statuses ) ); |
|
644 | + return array_search(strtolower($post_status), array_map('strtolower', $statuses)); |
|
645 | 645 | } |
646 | 646 | } |
647 | 647 | |
@@ -657,18 +657,18 @@ discard block |
||
657 | 657 | */ |
658 | 658 | function give_get_payment_statuses() { |
659 | 659 | $payment_statuses = array( |
660 | - 'pending' => __( 'Pending', 'give' ), |
|
661 | - 'publish' => __( 'Complete', 'give' ), |
|
662 | - 'refunded' => __( 'Refunded', 'give' ), |
|
663 | - 'failed' => __( 'Failed', 'give' ), |
|
664 | - 'cancelled' => __( 'Cancelled', 'give' ), |
|
665 | - 'abandoned' => __( 'Abandoned', 'give' ), |
|
666 | - 'preapproval' => __( 'Pre-Approved', 'give' ), |
|
667 | - 'processing' => __( 'Processing', 'give' ), |
|
668 | - 'revoked' => __( 'Revoked', 'give' ), |
|
660 | + 'pending' => __('Pending', 'give'), |
|
661 | + 'publish' => __('Complete', 'give'), |
|
662 | + 'refunded' => __('Refunded', 'give'), |
|
663 | + 'failed' => __('Failed', 'give'), |
|
664 | + 'cancelled' => __('Cancelled', 'give'), |
|
665 | + 'abandoned' => __('Abandoned', 'give'), |
|
666 | + 'preapproval' => __('Pre-Approved', 'give'), |
|
667 | + 'processing' => __('Processing', 'give'), |
|
668 | + 'revoked' => __('Revoked', 'give'), |
|
669 | 669 | ); |
670 | 670 | |
671 | - return apply_filters( 'give_payment_statuses', $payment_statuses ); |
|
671 | + return apply_filters('give_payment_statuses', $payment_statuses); |
|
672 | 672 | } |
673 | 673 | |
674 | 674 | /** |
@@ -681,10 +681,10 @@ discard block |
||
681 | 681 | * @return array $payment_status All the available payment statuses. |
682 | 682 | */ |
683 | 683 | function give_get_payment_status_keys() { |
684 | - $statuses = array_keys( give_get_payment_statuses() ); |
|
685 | - asort( $statuses ); |
|
684 | + $statuses = array_keys(give_get_payment_statuses()); |
|
685 | + asort($statuses); |
|
686 | 686 | |
687 | - return array_values( $statuses ); |
|
687 | + return array_values($statuses); |
|
688 | 688 | } |
689 | 689 | |
690 | 690 | /** |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | * |
700 | 700 | * @return int $earnings Earnings |
701 | 701 | */ |
702 | -function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) { |
|
702 | +function give_get_earnings_by_date($day = null, $month_num, $year = null, $hour = null) { |
|
703 | 703 | |
704 | 704 | // This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead. |
705 | 705 | global $wpdb; |
@@ -709,41 +709,41 @@ discard block |
||
709 | 709 | 'nopaging' => true, |
710 | 710 | 'year' => $year, |
711 | 711 | 'monthnum' => $month_num, |
712 | - 'post_status' => array( 'publish' ), |
|
712 | + 'post_status' => array('publish'), |
|
713 | 713 | 'fields' => 'ids', |
714 | 714 | 'update_post_term_cache' => false, |
715 | 715 | ); |
716 | - if ( ! empty( $day ) ) { |
|
716 | + if ( ! empty($day)) { |
|
717 | 717 | $args['day'] = $day; |
718 | 718 | } |
719 | 719 | |
720 | - if ( ! empty( $hour ) ) { |
|
720 | + if ( ! empty($hour)) { |
|
721 | 721 | $args['hour'] = $hour; |
722 | 722 | } |
723 | 723 | |
724 | - $args = apply_filters( 'give_get_earnings_by_date_args', $args ); |
|
725 | - $key = Give_Cache::get_key( 'give_stats', $args ); |
|
724 | + $args = apply_filters('give_get_earnings_by_date_args', $args); |
|
725 | + $key = Give_Cache::get_key('give_stats', $args); |
|
726 | 726 | |
727 | - if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) { |
|
727 | + if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) { |
|
728 | 728 | $earnings = false; |
729 | 729 | } else { |
730 | - $earnings = Give_Cache::get( $key ); |
|
730 | + $earnings = Give_Cache::get($key); |
|
731 | 731 | } |
732 | 732 | |
733 | - if ( false === $earnings ) { |
|
734 | - $donations = get_posts( $args ); |
|
733 | + if (false === $earnings) { |
|
734 | + $donations = get_posts($args); |
|
735 | 735 | $earnings = 0; |
736 | - if ( $donations ) { |
|
737 | - $donations = implode( ',', $donations ); |
|
736 | + if ($donations) { |
|
737 | + $donations = implode(',', $donations); |
|
738 | 738 | |
739 | - $earnings = $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$donations})" ); |
|
739 | + $earnings = $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$donations})"); |
|
740 | 740 | |
741 | 741 | } |
742 | 742 | // Cache the results for one hour. |
743 | - Give_Cache::set( $key, $earnings, HOUR_IN_SECONDS ); |
|
743 | + Give_Cache::set($key, $earnings, HOUR_IN_SECONDS); |
|
744 | 744 | } |
745 | 745 | |
746 | - return round( $earnings, 2 ); |
|
746 | + return round($earnings, 2); |
|
747 | 747 | } |
748 | 748 | |
749 | 749 | /** |
@@ -758,7 +758,7 @@ discard block |
||
758 | 758 | * |
759 | 759 | * @return int $count Sales |
760 | 760 | */ |
761 | -function give_get_sales_by_date( $day = null, $month_num = null, $year = null, $hour = null ) { |
|
761 | +function give_get_sales_by_date($day = null, $month_num = null, $year = null, $hour = null) { |
|
762 | 762 | |
763 | 763 | // This is getting deprecated soon. Use Give_Payment_Stats with the get_sales() method instead. |
764 | 764 | $args = array( |
@@ -766,14 +766,14 @@ discard block |
||
766 | 766 | 'nopaging' => true, |
767 | 767 | 'year' => $year, |
768 | 768 | 'fields' => 'ids', |
769 | - 'post_status' => array( 'publish' ), |
|
769 | + 'post_status' => array('publish'), |
|
770 | 770 | 'update_post_meta_cache' => false, |
771 | 771 | 'update_post_term_cache' => false, |
772 | 772 | ); |
773 | 773 | |
774 | - $show_free = apply_filters( 'give_sales_by_date_show_free', true, $args ); |
|
774 | + $show_free = apply_filters('give_sales_by_date_show_free', true, $args); |
|
775 | 775 | |
776 | - if ( false === $show_free ) { |
|
776 | + if (false === $show_free) { |
|
777 | 777 | $args['meta_query'] = array( |
778 | 778 | array( |
779 | 779 | 'key' => '_give_payment_total', |
@@ -784,33 +784,33 @@ discard block |
||
784 | 784 | ); |
785 | 785 | } |
786 | 786 | |
787 | - if ( ! empty( $month_num ) ) { |
|
787 | + if ( ! empty($month_num)) { |
|
788 | 788 | $args['monthnum'] = $month_num; |
789 | 789 | } |
790 | 790 | |
791 | - if ( ! empty( $day ) ) { |
|
791 | + if ( ! empty($day)) { |
|
792 | 792 | $args['day'] = $day; |
793 | 793 | } |
794 | 794 | |
795 | - if ( ! empty( $hour ) ) { |
|
795 | + if ( ! empty($hour)) { |
|
796 | 796 | $args['hour'] = $hour; |
797 | 797 | } |
798 | 798 | |
799 | - $args = apply_filters( 'give_get_sales_by_date_args', $args ); |
|
799 | + $args = apply_filters('give_get_sales_by_date_args', $args); |
|
800 | 800 | |
801 | - $key = Give_Cache::get_key( 'give_stats', $args ); |
|
801 | + $key = Give_Cache::get_key('give_stats', $args); |
|
802 | 802 | |
803 | - if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) { |
|
803 | + if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) { |
|
804 | 804 | $count = false; |
805 | 805 | } else { |
806 | - $count = Give_Cache::get( $key ); |
|
806 | + $count = Give_Cache::get($key); |
|
807 | 807 | } |
808 | 808 | |
809 | - if ( false === $count ) { |
|
810 | - $donations = new WP_Query( $args ); |
|
809 | + if (false === $count) { |
|
810 | + $donations = new WP_Query($args); |
|
811 | 811 | $count = (int) $donations->post_count; |
812 | 812 | // Cache the results for one hour. |
813 | - Give_Cache::set( $key, $count, HOUR_IN_SECONDS ); |
|
813 | + Give_Cache::set($key, $count, HOUR_IN_SECONDS); |
|
814 | 814 | } |
815 | 815 | |
816 | 816 | return $count; |
@@ -825,19 +825,19 @@ discard block |
||
825 | 825 | * |
826 | 826 | * @return bool $ret True if complete, false otherwise. |
827 | 827 | */ |
828 | -function give_is_payment_complete( $payment_id ) { |
|
829 | - $payment = new Give_Payment( $payment_id ); |
|
828 | +function give_is_payment_complete($payment_id) { |
|
829 | + $payment = new Give_Payment($payment_id); |
|
830 | 830 | |
831 | 831 | $ret = false; |
832 | 832 | |
833 | - if ( $payment->ID > 0 ) { |
|
833 | + if ($payment->ID > 0) { |
|
834 | 834 | |
835 | - if ( (int) $payment_id === (int) $payment->ID && 'publish' == $payment->status ) { |
|
835 | + if ((int) $payment_id === (int) $payment->ID && 'publish' == $payment->status) { |
|
836 | 836 | $ret = true; |
837 | 837 | } |
838 | 838 | } |
839 | 839 | |
840 | - return apply_filters( 'give_is_payment_complete', $ret, $payment_id, $payment->post_status ); |
|
840 | + return apply_filters('give_is_payment_complete', $ret, $payment_id, $payment->post_status); |
|
841 | 841 | } |
842 | 842 | |
843 | 843 | /** |
@@ -863,49 +863,49 @@ discard block |
||
863 | 863 | * |
864 | 864 | * @return float $total Total earnings. |
865 | 865 | */ |
866 | -function give_get_total_earnings( $recalculate = false ) { |
|
866 | +function give_get_total_earnings($recalculate = false) { |
|
867 | 867 | |
868 | - $total = get_option( 'give_earnings_total', 0 ); |
|
868 | + $total = get_option('give_earnings_total', 0); |
|
869 | 869 | |
870 | 870 | // Calculate total earnings. |
871 | - if ( ! $total || $recalculate ) { |
|
871 | + if ( ! $total || $recalculate) { |
|
872 | 872 | global $wpdb; |
873 | 873 | |
874 | 874 | $total = (float) 0; |
875 | 875 | |
876 | - $args = apply_filters( 'give_get_total_earnings_args', array( |
|
876 | + $args = apply_filters('give_get_total_earnings_args', array( |
|
877 | 877 | 'offset' => 0, |
878 | - 'number' => - 1, |
|
879 | - 'status' => array( 'publish' ), |
|
878 | + 'number' => -1, |
|
879 | + 'status' => array('publish'), |
|
880 | 880 | 'fields' => 'ids', |
881 | - ) ); |
|
881 | + )); |
|
882 | 882 | |
883 | - $payments = give_get_payments( $args ); |
|
884 | - if ( $payments ) { |
|
883 | + $payments = give_get_payments($args); |
|
884 | + if ($payments) { |
|
885 | 885 | |
886 | 886 | /** |
887 | 887 | * If performing a donation, we need to skip the very last payment in the database, |
888 | 888 | * since it calls give_increase_total_earnings() on completion, |
889 | 889 | * which results in duplicated earnings for the very first donation. |
890 | 890 | */ |
891 | - if ( did_action( 'give_update_payment_status' ) ) { |
|
892 | - array_pop( $payments ); |
|
891 | + if (did_action('give_update_payment_status')) { |
|
892 | + array_pop($payments); |
|
893 | 893 | } |
894 | 894 | |
895 | - if ( ! empty( $payments ) ) { |
|
896 | - $payments = implode( ',', $payments ); |
|
897 | - $total += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})" ); |
|
895 | + if ( ! empty($payments)) { |
|
896 | + $payments = implode(',', $payments); |
|
897 | + $total += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})"); |
|
898 | 898 | } |
899 | 899 | } |
900 | 900 | |
901 | - update_option( 'give_earnings_total', $total, 'no' ); |
|
901 | + update_option('give_earnings_total', $total, 'no'); |
|
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 array $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 $payment->customer_id Donor ID. |
1068 | 1068 | */ |
1069 | -function give_get_payment_donor_id( $payment_id ) { |
|
1070 | - $payment = new Give_Payment( $payment_id ); |
|
1069 | +function give_get_payment_donor_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 | }// End if(). |
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 | |
@@ -1315,10 +1315,10 @@ discard block |
||
1315 | 1315 | * |
1316 | 1316 | * @return string $amount Fully formatted payment amount. |
1317 | 1317 | */ |
1318 | -function give_payment_amount( $payment_id = 0 ) { |
|
1319 | - $amount = give_get_payment_amount( $payment_id ); |
|
1318 | +function give_payment_amount($payment_id = 0) { |
|
1319 | + $amount = give_get_payment_amount($payment_id); |
|
1320 | 1320 | |
1321 | - return give_currency_filter( give_format_amount( $amount, array( 'sanitize' => false ) ), give_get_payment_currency_code( $payment_id ) ); |
|
1321 | + return give_currency_filter(give_format_amount($amount, array('sanitize' => false)), give_get_payment_currency_code($payment_id)); |
|
1322 | 1322 | } |
1323 | 1323 | |
1324 | 1324 | /** |
@@ -1331,11 +1331,11 @@ discard block |
||
1331 | 1331 | * |
1332 | 1332 | * @return mixed |
1333 | 1333 | */ |
1334 | -function give_get_payment_amount( $payment_id ) { |
|
1334 | +function give_get_payment_amount($payment_id) { |
|
1335 | 1335 | |
1336 | - $payment = new Give_Payment( $payment_id ); |
|
1336 | + $payment = new Give_Payment($payment_id); |
|
1337 | 1337 | |
1338 | - return apply_filters( 'give_payment_amount', floatval( $payment->total ), $payment_id ); |
|
1338 | + return apply_filters('give_payment_amount', floatval($payment->total), $payment_id); |
|
1339 | 1339 | } |
1340 | 1340 | |
1341 | 1341 | /** |
@@ -1352,10 +1352,10 @@ discard block |
||
1352 | 1352 | * |
1353 | 1353 | * @return array Fully formatted payment subtotal. |
1354 | 1354 | */ |
1355 | -function give_payment_subtotal( $payment_id = 0 ) { |
|
1356 | - $subtotal = give_get_payment_subtotal( $payment_id ); |
|
1355 | +function give_payment_subtotal($payment_id = 0) { |
|
1356 | + $subtotal = give_get_payment_subtotal($payment_id); |
|
1357 | 1357 | |
1358 | - return give_currency_filter( give_format_amount( $subtotal, array( 'sanitize' => false ) ), give_get_payment_currency_code( $payment_id ) ); |
|
1358 | + return give_currency_filter(give_format_amount($subtotal, array('sanitize' => false)), give_get_payment_currency_code($payment_id)); |
|
1359 | 1359 | } |
1360 | 1360 | |
1361 | 1361 | /** |
@@ -1369,8 +1369,8 @@ discard block |
||
1369 | 1369 | * |
1370 | 1370 | * @return float $subtotal Subtotal for payment (non formatted). |
1371 | 1371 | */ |
1372 | -function give_get_payment_subtotal( $payment_id = 0 ) { |
|
1373 | - $payment = new Give_Payment( $payment_id ); |
|
1372 | +function give_get_payment_subtotal($payment_id = 0) { |
|
1373 | + $payment = new Give_Payment($payment_id); |
|
1374 | 1374 | |
1375 | 1375 | return $payment->subtotal; |
1376 | 1376 | } |
@@ -1384,8 +1384,8 @@ discard block |
||
1384 | 1384 | * |
1385 | 1385 | * @return string The donation ID. |
1386 | 1386 | */ |
1387 | -function give_get_payment_transaction_id( $payment_id = 0 ) { |
|
1388 | - $payment = new Give_Payment( $payment_id ); |
|
1387 | +function give_get_payment_transaction_id($payment_id = 0) { |
|
1388 | + $payment = new Give_Payment($payment_id); |
|
1389 | 1389 | |
1390 | 1390 | return $payment->transaction_id; |
1391 | 1391 | } |
@@ -1400,15 +1400,15 @@ discard block |
||
1400 | 1400 | * |
1401 | 1401 | * @return bool|mixed |
1402 | 1402 | */ |
1403 | -function give_set_payment_transaction_id( $payment_id = 0, $transaction_id = '' ) { |
|
1403 | +function give_set_payment_transaction_id($payment_id = 0, $transaction_id = '') { |
|
1404 | 1404 | |
1405 | - if ( empty( $payment_id ) || empty( $transaction_id ) ) { |
|
1405 | + if (empty($payment_id) || empty($transaction_id)) { |
|
1406 | 1406 | return false; |
1407 | 1407 | } |
1408 | 1408 | |
1409 | - $transaction_id = apply_filters( 'give_set_payment_transaction_id', $transaction_id, $payment_id ); |
|
1409 | + $transaction_id = apply_filters('give_set_payment_transaction_id', $transaction_id, $payment_id); |
|
1410 | 1410 | |
1411 | - return give_update_payment_meta( $payment_id, '_give_payment_transaction_id', $transaction_id ); |
|
1411 | + return give_update_payment_meta($payment_id, '_give_payment_transaction_id', $transaction_id); |
|
1412 | 1412 | } |
1413 | 1413 | |
1414 | 1414 | /** |
@@ -1421,12 +1421,12 @@ discard block |
||
1421 | 1421 | * |
1422 | 1422 | * @return int $purchase Donation ID. |
1423 | 1423 | */ |
1424 | -function give_get_purchase_id_by_key( $key ) { |
|
1424 | +function give_get_purchase_id_by_key($key) { |
|
1425 | 1425 | global $wpdb; |
1426 | 1426 | |
1427 | - $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 ) ); |
|
1427 | + $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)); |
|
1428 | 1428 | |
1429 | - if ( $purchase != null ) { |
|
1429 | + if ($purchase != null) { |
|
1430 | 1430 | return $purchase; |
1431 | 1431 | } |
1432 | 1432 | |
@@ -1444,12 +1444,12 @@ discard block |
||
1444 | 1444 | * |
1445 | 1445 | * @return int $purchase Donation ID. |
1446 | 1446 | */ |
1447 | -function give_get_purchase_id_by_transaction_id( $key ) { |
|
1447 | +function give_get_purchase_id_by_transaction_id($key) { |
|
1448 | 1448 | global $wpdb; |
1449 | 1449 | |
1450 | - $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 ) ); |
|
1450 | + $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)); |
|
1451 | 1451 | |
1452 | - if ( $purchase != null ) { |
|
1452 | + if ($purchase != null) { |
|
1453 | 1453 | return $purchase; |
1454 | 1454 | } |
1455 | 1455 | |
@@ -1466,23 +1466,23 @@ discard block |
||
1466 | 1466 | * |
1467 | 1467 | * @return array $notes Donation Notes |
1468 | 1468 | */ |
1469 | -function give_get_payment_notes( $payment_id = 0, $search = '' ) { |
|
1469 | +function give_get_payment_notes($payment_id = 0, $search = '') { |
|
1470 | 1470 | |
1471 | - if ( empty( $payment_id ) && empty( $search ) ) { |
|
1471 | + if (empty($payment_id) && empty($search)) { |
|
1472 | 1472 | return false; |
1473 | 1473 | } |
1474 | 1474 | |
1475 | - remove_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
1476 | - remove_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10 ); |
|
1475 | + remove_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
1476 | + remove_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10); |
|
1477 | 1477 | |
1478 | - $notes = get_comments( array( |
|
1478 | + $notes = get_comments(array( |
|
1479 | 1479 | 'post_id' => $payment_id, |
1480 | 1480 | 'order' => 'ASC', |
1481 | 1481 | 'search' => $search, |
1482 | - ) ); |
|
1482 | + )); |
|
1483 | 1483 | |
1484 | - add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
1485 | - add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 ); |
|
1484 | + add_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
1485 | + add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2); |
|
1486 | 1486 | |
1487 | 1487 | return $notes; |
1488 | 1488 | } |
@@ -1498,8 +1498,8 @@ discard block |
||
1498 | 1498 | * |
1499 | 1499 | * @return int The new note ID |
1500 | 1500 | */ |
1501 | -function give_insert_payment_note( $payment_id = 0, $note = '' ) { |
|
1502 | - if ( empty( $payment_id ) ) { |
|
1501 | +function give_insert_payment_note($payment_id = 0, $note = '') { |
|
1502 | + if (empty($payment_id)) { |
|
1503 | 1503 | return false; |
1504 | 1504 | } |
1505 | 1505 | |
@@ -1511,14 +1511,14 @@ discard block |
||
1511 | 1511 | * @param int $payment_id Payment ID. |
1512 | 1512 | * @param string $note The note. |
1513 | 1513 | */ |
1514 | - do_action( 'give_pre_insert_payment_note', $payment_id, $note ); |
|
1514 | + do_action('give_pre_insert_payment_note', $payment_id, $note); |
|
1515 | 1515 | |
1516 | - $note_id = wp_insert_comment( wp_filter_comment( array( |
|
1516 | + $note_id = wp_insert_comment(wp_filter_comment(array( |
|
1517 | 1517 | 'comment_post_ID' => $payment_id, |
1518 | 1518 | 'comment_content' => $note, |
1519 | 1519 | 'user_id' => is_admin() ? get_current_user_id() : 0, |
1520 | - 'comment_date' => current_time( 'mysql' ), |
|
1521 | - 'comment_date_gmt' => current_time( 'mysql', 1 ), |
|
1520 | + 'comment_date' => current_time('mysql'), |
|
1521 | + 'comment_date_gmt' => current_time('mysql', 1), |
|
1522 | 1522 | 'comment_approved' => 1, |
1523 | 1523 | 'comment_parent' => 0, |
1524 | 1524 | 'comment_author' => '', |
@@ -1527,7 +1527,7 @@ discard block |
||
1527 | 1527 | 'comment_author_email' => '', |
1528 | 1528 | 'comment_type' => 'give_payment_note', |
1529 | 1529 | |
1530 | - ) ) ); |
|
1530 | + ))); |
|
1531 | 1531 | |
1532 | 1532 | /** |
1533 | 1533 | * Fires after payment note inserted. |
@@ -1538,7 +1538,7 @@ discard block |
||
1538 | 1538 | * @param int $payment_id Payment ID. |
1539 | 1539 | * @param string $note The note. |
1540 | 1540 | */ |
1541 | - do_action( 'give_insert_payment_note', $note_id, $payment_id, $note ); |
|
1541 | + do_action('give_insert_payment_note', $note_id, $payment_id, $note); |
|
1542 | 1542 | |
1543 | 1543 | return $note_id; |
1544 | 1544 | } |
@@ -1553,8 +1553,8 @@ discard block |
||
1553 | 1553 | * |
1554 | 1554 | * @return bool True on success, false otherwise. |
1555 | 1555 | */ |
1556 | -function give_delete_payment_note( $comment_id = 0, $payment_id = 0 ) { |
|
1557 | - if ( empty( $comment_id ) ) { |
|
1556 | +function give_delete_payment_note($comment_id = 0, $payment_id = 0) { |
|
1557 | + if (empty($comment_id)) { |
|
1558 | 1558 | return false; |
1559 | 1559 | } |
1560 | 1560 | |
@@ -1566,9 +1566,9 @@ discard block |
||
1566 | 1566 | * @param int $comment_id Note ID. |
1567 | 1567 | * @param int $payment_id Payment ID. |
1568 | 1568 | */ |
1569 | - do_action( 'give_pre_delete_payment_note', $comment_id, $payment_id ); |
|
1569 | + do_action('give_pre_delete_payment_note', $comment_id, $payment_id); |
|
1570 | 1570 | |
1571 | - $ret = wp_delete_comment( $comment_id, true ); |
|
1571 | + $ret = wp_delete_comment($comment_id, true); |
|
1572 | 1572 | |
1573 | 1573 | /** |
1574 | 1574 | * Fires after donation note deleted. |
@@ -1578,7 +1578,7 @@ discard block |
||
1578 | 1578 | * @param int $comment_id Note ID. |
1579 | 1579 | * @param int $payment_id Payment ID. |
1580 | 1580 | */ |
1581 | - do_action( 'give_post_delete_payment_note', $comment_id, $payment_id ); |
|
1581 | + do_action('give_post_delete_payment_note', $comment_id, $payment_id); |
|
1582 | 1582 | |
1583 | 1583 | return $ret; |
1584 | 1584 | } |
@@ -1593,32 +1593,32 @@ discard block |
||
1593 | 1593 | * |
1594 | 1594 | * @return string |
1595 | 1595 | */ |
1596 | -function give_get_payment_note_html( $note, $payment_id = 0 ) { |
|
1596 | +function give_get_payment_note_html($note, $payment_id = 0) { |
|
1597 | 1597 | |
1598 | - if ( is_numeric( $note ) ) { |
|
1599 | - $note = get_comment( $note ); |
|
1598 | + if (is_numeric($note)) { |
|
1599 | + $note = get_comment($note); |
|
1600 | 1600 | } |
1601 | 1601 | |
1602 | - if ( ! empty( $note->user_id ) ) { |
|
1603 | - $user = get_userdata( $note->user_id ); |
|
1602 | + if ( ! empty($note->user_id)) { |
|
1603 | + $user = get_userdata($note->user_id); |
|
1604 | 1604 | $user = $user->display_name; |
1605 | 1605 | } else { |
1606 | - $user = esc_html__( 'System', 'give' ); |
|
1606 | + $user = esc_html__('System', 'give'); |
|
1607 | 1607 | } |
1608 | 1608 | |
1609 | - $date_format = give_date_format() . ', ' . get_option( 'time_format' ); |
|
1609 | + $date_format = give_date_format().', '.get_option('time_format'); |
|
1610 | 1610 | |
1611 | - $delete_note_url = wp_nonce_url( add_query_arg( array( |
|
1611 | + $delete_note_url = wp_nonce_url(add_query_arg(array( |
|
1612 | 1612 | 'give-action' => 'delete_payment_note', |
1613 | 1613 | 'note_id' => $note->comment_ID, |
1614 | 1614 | 'payment_id' => $payment_id, |
1615 | - ) ), 'give_delete_payment_note_' . $note->comment_ID ); |
|
1615 | + )), 'give_delete_payment_note_'.$note->comment_ID); |
|
1616 | 1616 | |
1617 | - $note_html = '<div class="give-payment-note" id="give-payment-note-' . $note->comment_ID . '">'; |
|
1617 | + $note_html = '<div class="give-payment-note" id="give-payment-note-'.$note->comment_ID.'">'; |
|
1618 | 1618 | $note_html .= '<p>'; |
1619 | - $note_html .= '<strong>' . $user . '</strong> – <span style="color:#aaa;font-style:italic;">' . date_i18n( $date_format, strtotime( $note->comment_date ) ) . '</span><br/>'; |
|
1619 | + $note_html .= '<strong>'.$user.'</strong> – <span style="color:#aaa;font-style:italic;">'.date_i18n($date_format, strtotime($note->comment_date)).'</span><br/>'; |
|
1620 | 1620 | $note_html .= $note->comment_content; |
1621 | - $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>'; |
|
1621 | + $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>'; |
|
1622 | 1622 | $note_html .= '</p>'; |
1623 | 1623 | $note_html .= '</div>'; |
1624 | 1624 | |
@@ -1636,18 +1636,18 @@ discard block |
||
1636 | 1636 | * |
1637 | 1637 | * @return void |
1638 | 1638 | */ |
1639 | -function give_hide_payment_notes( $query ) { |
|
1640 | - if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '>=' ) ) { |
|
1641 | - $types = isset( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array(); |
|
1642 | - if ( ! is_array( $types ) ) { |
|
1643 | - $types = array( $types ); |
|
1639 | +function give_hide_payment_notes($query) { |
|
1640 | + if (version_compare(floatval(get_bloginfo('version')), '4.1', '>=')) { |
|
1641 | + $types = isset($query->query_vars['type__not_in']) ? $query->query_vars['type__not_in'] : array(); |
|
1642 | + if ( ! is_array($types)) { |
|
1643 | + $types = array($types); |
|
1644 | 1644 | } |
1645 | 1645 | $types[] = 'give_payment_note'; |
1646 | 1646 | $query->query_vars['type__not_in'] = $types; |
1647 | 1647 | } |
1648 | 1648 | } |
1649 | 1649 | |
1650 | -add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
1650 | +add_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
1651 | 1651 | |
1652 | 1652 | /** |
1653 | 1653 | * Exclude notes (comments) on give_payment post type from showing in Recent Comments widgets |
@@ -1659,15 +1659,15 @@ discard block |
||
1659 | 1659 | * |
1660 | 1660 | * @return array $clauses Updated comment clauses. |
1661 | 1661 | */ |
1662 | -function give_hide_payment_notes_pre_41( $clauses, $wp_comment_query ) { |
|
1663 | - if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '<' ) ) { |
|
1662 | +function give_hide_payment_notes_pre_41($clauses, $wp_comment_query) { |
|
1663 | + if (version_compare(floatval(get_bloginfo('version')), '4.1', '<')) { |
|
1664 | 1664 | $clauses['where'] .= ' AND comment_type != "give_payment_note"'; |
1665 | 1665 | } |
1666 | 1666 | |
1667 | 1667 | return $clauses; |
1668 | 1668 | } |
1669 | 1669 | |
1670 | -add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 ); |
|
1670 | +add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2); |
|
1671 | 1671 | |
1672 | 1672 | |
1673 | 1673 | /** |
@@ -1680,15 +1680,15 @@ discard block |
||
1680 | 1680 | * |
1681 | 1681 | * @return string $where |
1682 | 1682 | */ |
1683 | -function give_hide_payment_notes_from_feeds( $where, $wp_comment_query ) { |
|
1683 | +function give_hide_payment_notes_from_feeds($where, $wp_comment_query) { |
|
1684 | 1684 | global $wpdb; |
1685 | 1685 | |
1686 | - $where .= $wpdb->prepare( ' AND comment_type != %s', 'give_payment_note' ); |
|
1686 | + $where .= $wpdb->prepare(' AND comment_type != %s', 'give_payment_note'); |
|
1687 | 1687 | |
1688 | 1688 | return $where; |
1689 | 1689 | } |
1690 | 1690 | |
1691 | -add_filter( 'comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2 ); |
|
1691 | +add_filter('comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2); |
|
1692 | 1692 | |
1693 | 1693 | |
1694 | 1694 | /** |
@@ -1702,32 +1702,32 @@ discard block |
||
1702 | 1702 | * |
1703 | 1703 | * @return array Array of comment counts. |
1704 | 1704 | */ |
1705 | -function give_remove_payment_notes_in_comment_counts( $stats, $post_id ) { |
|
1705 | +function give_remove_payment_notes_in_comment_counts($stats, $post_id) { |
|
1706 | 1706 | global $wpdb, $pagenow; |
1707 | 1707 | |
1708 | - if ( 'index.php' != $pagenow ) { |
|
1708 | + if ('index.php' != $pagenow) { |
|
1709 | 1709 | return $stats; |
1710 | 1710 | } |
1711 | 1711 | |
1712 | 1712 | $post_id = (int) $post_id; |
1713 | 1713 | |
1714 | - if ( apply_filters( 'give_count_payment_notes_in_comments', false ) ) { |
|
1714 | + if (apply_filters('give_count_payment_notes_in_comments', false)) { |
|
1715 | 1715 | return $stats; |
1716 | 1716 | } |
1717 | 1717 | |
1718 | - $stats = wp_cache_get( "comments-{$post_id}", 'counts' ); |
|
1718 | + $stats = wp_cache_get("comments-{$post_id}", 'counts'); |
|
1719 | 1719 | |
1720 | - if ( false !== $stats ) { |
|
1720 | + if (false !== $stats) { |
|
1721 | 1721 | return $stats; |
1722 | 1722 | } |
1723 | 1723 | |
1724 | 1724 | $where = 'WHERE comment_type != "give_payment_note"'; |
1725 | 1725 | |
1726 | - if ( $post_id > 0 ) { |
|
1727 | - $where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id ); |
|
1726 | + if ($post_id > 0) { |
|
1727 | + $where .= $wpdb->prepare(' AND comment_post_ID = %d', $post_id); |
|
1728 | 1728 | } |
1729 | 1729 | |
1730 | - $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A ); |
|
1730 | + $count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A); |
|
1731 | 1731 | |
1732 | 1732 | $total = 0; |
1733 | 1733 | $approved = array( |
@@ -1737,30 +1737,30 @@ discard block |
||
1737 | 1737 | 'trash' => 'trash', |
1738 | 1738 | 'post-trashed' => 'post-trashed', |
1739 | 1739 | ); |
1740 | - foreach ( (array) $count as $row ) { |
|
1740 | + foreach ((array) $count as $row) { |
|
1741 | 1741 | // Don't count post-trashed toward totals. |
1742 | - if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) { |
|
1742 | + if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) { |
|
1743 | 1743 | $total += $row['num_comments']; |
1744 | 1744 | } |
1745 | - if ( isset( $approved[ $row['comment_approved'] ] ) ) { |
|
1746 | - $stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments']; |
|
1745 | + if (isset($approved[$row['comment_approved']])) { |
|
1746 | + $stats[$approved[$row['comment_approved']]] = $row['num_comments']; |
|
1747 | 1747 | } |
1748 | 1748 | } |
1749 | 1749 | |
1750 | 1750 | $stats['total_comments'] = $total; |
1751 | - foreach ( $approved as $key ) { |
|
1752 | - if ( empty( $stats[ $key ] ) ) { |
|
1753 | - $stats[ $key ] = 0; |
|
1751 | + foreach ($approved as $key) { |
|
1752 | + if (empty($stats[$key])) { |
|
1753 | + $stats[$key] = 0; |
|
1754 | 1754 | } |
1755 | 1755 | } |
1756 | 1756 | |
1757 | 1757 | $stats = (object) $stats; |
1758 | - wp_cache_set( "comments-{$post_id}", $stats, 'counts' ); |
|
1758 | + wp_cache_set("comments-{$post_id}", $stats, 'counts'); |
|
1759 | 1759 | |
1760 | 1760 | return $stats; |
1761 | 1761 | } |
1762 | 1762 | |
1763 | -add_filter( 'wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2 ); |
|
1763 | +add_filter('wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2); |
|
1764 | 1764 | |
1765 | 1765 | |
1766 | 1766 | /** |
@@ -1773,9 +1773,9 @@ discard block |
||
1773 | 1773 | * |
1774 | 1774 | * @return string $where Modified where clause. |
1775 | 1775 | */ |
1776 | -function give_filter_where_older_than_week( $where = '' ) { |
|
1776 | +function give_filter_where_older_than_week($where = '') { |
|
1777 | 1777 | // Payments older than one week. |
1778 | - $start = date( 'Y-m-d', strtotime( '-7 days' ) ); |
|
1778 | + $start = date('Y-m-d', strtotime('-7 days')); |
|
1779 | 1779 | $where .= " AND post_date <= '{$start}'"; |
1780 | 1780 | |
1781 | 1781 | return $where; |
@@ -1795,38 +1795,38 @@ discard block |
||
1795 | 1795 | * |
1796 | 1796 | * @return string $form_title Returns the full title if $only_level is false, otherwise returns the levels title. |
1797 | 1797 | */ |
1798 | -function give_get_payment_form_title( $payment_meta, $only_level = false, $separator = '' ) { |
|
1798 | +function give_get_payment_form_title($payment_meta, $only_level = false, $separator = '') { |
|
1799 | 1799 | |
1800 | - $form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0; |
|
1801 | - $price_id = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null; |
|
1802 | - $form_title = isset( $payment_meta['form_title'] ) ? $payment_meta['form_title'] : ''; |
|
1800 | + $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0; |
|
1801 | + $price_id = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null; |
|
1802 | + $form_title = isset($payment_meta['form_title']) ? $payment_meta['form_title'] : ''; |
|
1803 | 1803 | |
1804 | - if ( $only_level == true ) { |
|
1804 | + if ($only_level == true) { |
|
1805 | 1805 | $form_title = ''; |
1806 | 1806 | } |
1807 | 1807 | |
1808 | 1808 | // If multi-level, append to the form title. |
1809 | - if ( give_has_variable_prices( $form_id ) ) { |
|
1809 | + if (give_has_variable_prices($form_id)) { |
|
1810 | 1810 | |
1811 | 1811 | // Only add separator if there is a form title. |
1812 | - if ( ! empty( $form_title ) ) { |
|
1813 | - $form_title .= ' ' . $separator . ' '; |
|
1812 | + if ( ! empty($form_title)) { |
|
1813 | + $form_title .= ' '.$separator.' '; |
|
1814 | 1814 | } |
1815 | 1815 | |
1816 | 1816 | $form_title .= '<span class="donation-level-text-wrap">'; |
1817 | 1817 | |
1818 | - if ( $price_id == 'custom' ) { |
|
1819 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
1820 | - $form_title .= ! empty( $custom_amount_text ) ? $custom_amount_text : __( 'Custom Amount', 'give' ); |
|
1818 | + if ($price_id == 'custom') { |
|
1819 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
1820 | + $form_title .= ! empty($custom_amount_text) ? $custom_amount_text : __('Custom Amount', 'give'); |
|
1821 | 1821 | } else { |
1822 | - $form_title .= give_get_price_option_name( $form_id, $price_id ); |
|
1822 | + $form_title .= give_get_price_option_name($form_id, $price_id); |
|
1823 | 1823 | } |
1824 | 1824 | |
1825 | 1825 | $form_title .= '</span>'; |
1826 | 1826 | |
1827 | 1827 | } |
1828 | 1828 | |
1829 | - return apply_filters( 'give_get_payment_form_title', $form_title, $payment_meta ); |
|
1829 | + return apply_filters('give_get_payment_form_title', $form_title, $payment_meta); |
|
1830 | 1830 | |
1831 | 1831 | } |
1832 | 1832 | |
@@ -1840,19 +1840,19 @@ discard block |
||
1840 | 1840 | * |
1841 | 1841 | * @return string $price_id |
1842 | 1842 | */ |
1843 | -function give_get_price_id( $form_id, $price ) { |
|
1843 | +function give_get_price_id($form_id, $price) { |
|
1844 | 1844 | $price_id = null; |
1845 | 1845 | |
1846 | - if ( give_has_variable_prices( $form_id ) ) { |
|
1846 | + if (give_has_variable_prices($form_id)) { |
|
1847 | 1847 | |
1848 | - $levels = give_get_meta( $form_id, '_give_donation_levels', true ); |
|
1848 | + $levels = give_get_meta($form_id, '_give_donation_levels', true); |
|
1849 | 1849 | |
1850 | - foreach ( $levels as $level ) { |
|
1850 | + foreach ($levels as $level) { |
|
1851 | 1851 | |
1852 | - $level_amount = give_maybe_sanitize_amount( $level['_give_amount'] ); |
|
1852 | + $level_amount = give_maybe_sanitize_amount($level['_give_amount']); |
|
1853 | 1853 | |
1854 | 1854 | // Check that this indeed the recurring price. |
1855 | - if ( $level_amount == $price ) { |
|
1855 | + if ($level_amount == $price) { |
|
1856 | 1856 | |
1857 | 1857 | $price_id = $level['_give_id']['level_id']; |
1858 | 1858 | break; |
@@ -1860,13 +1860,13 @@ discard block |
||
1860 | 1860 | } |
1861 | 1861 | } |
1862 | 1862 | |
1863 | - if( is_null( $price_id ) && give_is_custom_price_mode( $form_id ) ) { |
|
1863 | + if (is_null($price_id) && give_is_custom_price_mode($form_id)) { |
|
1864 | 1864 | $price_id = 'custom'; |
1865 | 1865 | } |
1866 | 1866 | } |
1867 | 1867 | |
1868 | 1868 | // Price ID must be numeric or string. |
1869 | - $price_id = ! is_numeric( $price_id ) && ! is_string( $price_id ) ? 0 : $price_id; |
|
1869 | + $price_id = ! is_numeric($price_id) && ! is_string($price_id) ? 0 : $price_id; |
|
1870 | 1870 | |
1871 | 1871 | return $price_id; |
1872 | 1872 | } |
@@ -1884,10 +1884,10 @@ discard block |
||
1884 | 1884 | * |
1885 | 1885 | * @return string |
1886 | 1886 | */ |
1887 | -function give_get_form_dropdown( $args = array(), $echo = false ) { |
|
1888 | - $form_dropdown_html = Give()->html->forms_dropdown( $args ); |
|
1887 | +function give_get_form_dropdown($args = array(), $echo = false) { |
|
1888 | + $form_dropdown_html = Give()->html->forms_dropdown($args); |
|
1889 | 1889 | |
1890 | - if ( ! $echo ) { |
|
1890 | + if ( ! $echo) { |
|
1891 | 1891 | return $form_dropdown_html; |
1892 | 1892 | } |
1893 | 1893 | |
@@ -1904,17 +1904,17 @@ discard block |
||
1904 | 1904 | * |
1905 | 1905 | * @return string|bool |
1906 | 1906 | */ |
1907 | -function give_get_form_variable_price_dropdown( $args = array(), $echo = false ) { |
|
1907 | +function give_get_form_variable_price_dropdown($args = array(), $echo = false) { |
|
1908 | 1908 | |
1909 | 1909 | // Check for give form id. |
1910 | - if ( empty( $args['id'] ) ) { |
|
1910 | + if (empty($args['id'])) { |
|
1911 | 1911 | return false; |
1912 | 1912 | } |
1913 | 1913 | |
1914 | - $form = new Give_Donate_Form( $args['id'] ); |
|
1914 | + $form = new Give_Donate_Form($args['id']); |
|
1915 | 1915 | |
1916 | 1916 | // Check if form has variable prices or not. |
1917 | - if ( ! $form->ID || ! $form->has_variable_prices() ) { |
|
1917 | + if ( ! $form->ID || ! $form->has_variable_prices()) { |
|
1918 | 1918 | return false; |
1919 | 1919 | } |
1920 | 1920 | |
@@ -1922,24 +1922,24 @@ discard block |
||
1922 | 1922 | $variable_price_options = array(); |
1923 | 1923 | |
1924 | 1924 | // Check if multi donation form support custom donation or not. |
1925 | - if ( $form->is_custom_price_mode() ) { |
|
1926 | - $variable_price_options['custom'] = _x( 'Custom', 'custom donation dropdown item', 'give' ); |
|
1925 | + if ($form->is_custom_price_mode()) { |
|
1926 | + $variable_price_options['custom'] = _x('Custom', 'custom donation dropdown item', 'give'); |
|
1927 | 1927 | } |
1928 | 1928 | |
1929 | 1929 | // Get variable price and ID from variable price array. |
1930 | - foreach ( $variable_prices as $variable_price ) { |
|
1931 | - $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'], array( 'sanitize' => false ) ) ); |
|
1930 | + foreach ($variable_prices as $variable_price) { |
|
1931 | + $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'], array('sanitize' => false))); |
|
1932 | 1932 | } |
1933 | 1933 | |
1934 | 1934 | // Update options. |
1935 | - $args = array_merge( $args, array( |
|
1935 | + $args = array_merge($args, array( |
|
1936 | 1936 | 'options' => $variable_price_options, |
1937 | - ) ); |
|
1937 | + )); |
|
1938 | 1938 | |
1939 | 1939 | // Generate select html. |
1940 | - $form_dropdown_html = Give()->html->select( $args ); |
|
1940 | + $form_dropdown_html = Give()->html->select($args); |
|
1941 | 1941 | |
1942 | - if ( ! $echo ) { |
|
1942 | + if ( ! $echo) { |
|
1943 | 1943 | return $form_dropdown_html; |
1944 | 1944 | } |
1945 | 1945 | |
@@ -1958,16 +1958,16 @@ discard block |
||
1958 | 1958 | * |
1959 | 1959 | * @return string |
1960 | 1960 | */ |
1961 | -function give_get_payment_meta_price_id( $payment_meta ) { |
|
1961 | +function give_get_payment_meta_price_id($payment_meta) { |
|
1962 | 1962 | |
1963 | - if ( isset( $payment_meta['give_price_id'] ) ) { |
|
1963 | + if (isset($payment_meta['give_price_id'])) { |
|
1964 | 1964 | $price_id = $payment_meta['give_price_id']; |
1965 | - } elseif ( isset( $payment_meta['price_id'] ) ) { |
|
1965 | + } elseif (isset($payment_meta['price_id'])) { |
|
1966 | 1966 | $price_id = $payment_meta['price_id']; |
1967 | 1967 | } else { |
1968 | - $price_id = give_get_price_id( $payment_meta['give_form_id'], $payment_meta['price'] ); |
|
1968 | + $price_id = give_get_price_id($payment_meta['give_form_id'], $payment_meta['price']); |
|
1969 | 1969 | } |
1970 | 1970 | |
1971 | - return apply_filters( 'give_get_payment_meta_price_id', $price_id ); |
|
1971 | + return apply_filters('give_get_payment_meta_price_id', $price_id); |
|
1972 | 1972 | |
1973 | 1973 | } |
@@ -671,7 +671,7 @@ |
||
671 | 671 | /** |
672 | 672 | * This function will check whether the donor email is primary or additional. |
673 | 673 | * |
674 | - * @param $email Donor Email. |
|
674 | + * @param string $email Donor Email. |
|
675 | 675 | * |
676 | 676 | * @since 1.8.13 |
677 | 677 | * |
@@ -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 | |
@@ -30,54 +30,54 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @return bool|array List of all user donations. |
32 | 32 | */ |
33 | -function give_get_users_donations( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) { |
|
33 | +function give_get_users_donations($user = 0, $number = 20, $pagination = false, $status = 'complete') { |
|
34 | 34 | |
35 | - if ( empty( $user ) ) { |
|
35 | + if (empty($user)) { |
|
36 | 36 | $user = get_current_user_id(); |
37 | 37 | } |
38 | 38 | |
39 | - if ( 0 === $user && ! Give()->email_access->token_exists ) { |
|
39 | + if (0 === $user && ! Give()->email_access->token_exists) { |
|
40 | 40 | return false; |
41 | 41 | } |
42 | 42 | |
43 | 43 | $status = $status === 'complete' ? 'publish' : $status; |
44 | 44 | $paged = 1; |
45 | 45 | |
46 | - if ( $pagination ) { |
|
47 | - if ( get_query_var( 'paged' ) ) { |
|
48 | - $paged = get_query_var( 'paged' ); |
|
49 | - } elseif ( get_query_var( 'page' ) ) { |
|
50 | - $paged = get_query_var( 'page' ); |
|
46 | + if ($pagination) { |
|
47 | + if (get_query_var('paged')) { |
|
48 | + $paged = get_query_var('paged'); |
|
49 | + } elseif (get_query_var('page')) { |
|
50 | + $paged = get_query_var('page'); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
54 | - $args = apply_filters( 'give_get_users_donations_args', array( |
|
54 | + $args = apply_filters('give_get_users_donations_args', array( |
|
55 | 55 | 'user' => $user, |
56 | 56 | 'number' => $number, |
57 | 57 | 'status' => $status, |
58 | 58 | 'orderby' => 'date', |
59 | - ) ); |
|
59 | + )); |
|
60 | 60 | |
61 | - if ( $pagination ) { |
|
61 | + if ($pagination) { |
|
62 | 62 | $args['page'] = $paged; |
63 | 63 | } else { |
64 | 64 | $args['nopaging'] = true; |
65 | 65 | } |
66 | 66 | |
67 | - $by_user_id = is_numeric( $user ) ? true : false; |
|
68 | - $donor = new Give_Donor( $user, $by_user_id ); |
|
67 | + $by_user_id = is_numeric($user) ? true : false; |
|
68 | + $donor = new Give_Donor($user, $by_user_id); |
|
69 | 69 | |
70 | - if ( ! empty( $donor->payment_ids ) ) { |
|
70 | + if ( ! empty($donor->payment_ids)) { |
|
71 | 71 | |
72 | - unset( $args['user'] ); |
|
73 | - $args['post__in'] = array_map( 'absint', explode( ',', $donor->payment_ids ) ); |
|
72 | + unset($args['user']); |
|
73 | + $args['post__in'] = array_map('absint', explode(',', $donor->payment_ids)); |
|
74 | 74 | |
75 | 75 | } |
76 | 76 | |
77 | - $donations = give_get_payments( apply_filters( 'give_get_users_donations_args', $args ) ); |
|
77 | + $donations = give_get_payments(apply_filters('give_get_users_donations_args', $args)); |
|
78 | 78 | |
79 | 79 | // No donations |
80 | - if ( ! $donations ) { |
|
80 | + if ( ! $donations) { |
|
81 | 81 | return false; |
82 | 82 | } |
83 | 83 | |
@@ -96,65 +96,65 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @return bool|object List of unique forms donated by user |
98 | 98 | */ |
99 | -function give_get_users_completed_donations( $user = 0, $status = 'complete' ) { |
|
100 | - if ( empty( $user ) ) { |
|
99 | +function give_get_users_completed_donations($user = 0, $status = 'complete') { |
|
100 | + if (empty($user)) { |
|
101 | 101 | $user = get_current_user_id(); |
102 | 102 | } |
103 | 103 | |
104 | - if ( empty( $user ) ) { |
|
104 | + if (empty($user)) { |
|
105 | 105 | return false; |
106 | 106 | } |
107 | 107 | |
108 | - $by_user_id = is_numeric( $user ) ? true : false; |
|
108 | + $by_user_id = is_numeric($user) ? true : false; |
|
109 | 109 | |
110 | - $donor = new Give_Donor( $user, $by_user_id ); |
|
110 | + $donor = new Give_Donor($user, $by_user_id); |
|
111 | 111 | |
112 | - if ( empty( $donor->payment_ids ) ) { |
|
112 | + if (empty($donor->payment_ids)) { |
|
113 | 113 | return false; |
114 | 114 | } |
115 | 115 | |
116 | 116 | // Get all the items donated. |
117 | - $payment_ids = array_reverse( explode( ',', $donor->payment_ids ) ); |
|
118 | - $limit_payments = apply_filters( 'give_users_completed_donations_payments', 50 ); |
|
119 | - if ( ! empty( $limit_payments ) ) { |
|
120 | - $payment_ids = array_slice( $payment_ids, 0, $limit_payments ); |
|
117 | + $payment_ids = array_reverse(explode(',', $donor->payment_ids)); |
|
118 | + $limit_payments = apply_filters('give_users_completed_donations_payments', 50); |
|
119 | + if ( ! empty($limit_payments)) { |
|
120 | + $payment_ids = array_slice($payment_ids, 0, $limit_payments); |
|
121 | 121 | } |
122 | 122 | $donation_data = array(); |
123 | - foreach ( $payment_ids as $payment_id ) { |
|
124 | - $donation_data[] = give_get_payment_meta( $payment_id ); |
|
123 | + foreach ($payment_ids as $payment_id) { |
|
124 | + $donation_data[] = give_get_payment_meta($payment_id); |
|
125 | 125 | } |
126 | 126 | |
127 | - if ( empty( $donation_data ) ) { |
|
127 | + if (empty($donation_data)) { |
|
128 | 128 | return false; |
129 | 129 | } |
130 | 130 | |
131 | 131 | // Grab only the post ids "form_id" of the forms donated on this order |
132 | 132 | $completed_donations_ids = array(); |
133 | - foreach ( $donation_data as $donation_meta ) { |
|
134 | - $completed_donations_ids[] = isset( $donation_meta['form_id'] ) ? $donation_meta['form_id'] : ''; |
|
133 | + foreach ($donation_data as $donation_meta) { |
|
134 | + $completed_donations_ids[] = isset($donation_meta['form_id']) ? $donation_meta['form_id'] : ''; |
|
135 | 135 | } |
136 | 136 | |
137 | - if ( empty( $completed_donations_ids ) ) { |
|
137 | + if (empty($completed_donations_ids)) { |
|
138 | 138 | return false; |
139 | 139 | } |
140 | 140 | |
141 | 141 | // Only include each donation once |
142 | - $form_ids = array_unique( $completed_donations_ids ); |
|
142 | + $form_ids = array_unique($completed_donations_ids); |
|
143 | 143 | |
144 | 144 | // Make sure we still have some products and a first item |
145 | - if ( empty( $form_ids ) || ! isset( $form_ids[0] ) ) { |
|
145 | + if (empty($form_ids) || ! isset($form_ids[0])) { |
|
146 | 146 | return false; |
147 | 147 | } |
148 | 148 | |
149 | - $post_type = get_post_type( $form_ids[0] ); |
|
149 | + $post_type = get_post_type($form_ids[0]); |
|
150 | 150 | |
151 | - $args = apply_filters( 'give_get_users_completed_donations_args', array( |
|
151 | + $args = apply_filters('give_get_users_completed_donations_args', array( |
|
152 | 152 | 'include' => $form_ids, |
153 | 153 | 'post_type' => $post_type, |
154 | - 'posts_per_page' => - 1, |
|
155 | - ) ); |
|
154 | + 'posts_per_page' => -1, |
|
155 | + )); |
|
156 | 156 | |
157 | - return apply_filters( 'give_users_completed_donations_list', get_posts( $args ) ); |
|
157 | + return apply_filters('give_users_completed_donations_list', get_posts($args)); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | |
@@ -170,12 +170,12 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @return bool True if has donated, false other wise. |
172 | 172 | */ |
173 | -function give_has_donations( $user_id = null ) { |
|
174 | - if ( empty( $user_id ) ) { |
|
173 | +function give_has_donations($user_id = null) { |
|
174 | + if (empty($user_id)) { |
|
175 | 175 | $user_id = get_current_user_id(); |
176 | 176 | } |
177 | 177 | |
178 | - if ( give_get_users_donations( $user_id, 1 ) ) { |
|
178 | + if (give_get_users_donations($user_id, 1)) { |
|
179 | 179 | return true; // User has at least one donation. |
180 | 180 | } |
181 | 181 | |
@@ -196,23 +196,23 @@ discard block |
||
196 | 196 | * |
197 | 197 | * @return array |
198 | 198 | */ |
199 | -function give_get_donation_stats_by_user( $user = '' ) { |
|
199 | +function give_get_donation_stats_by_user($user = '') { |
|
200 | 200 | |
201 | 201 | $field = ''; |
202 | 202 | |
203 | - if ( is_email( $user ) ) { |
|
203 | + if (is_email($user)) { |
|
204 | 204 | $field = 'email'; |
205 | - } elseif ( is_numeric( $user ) ) { |
|
205 | + } elseif (is_numeric($user)) { |
|
206 | 206 | $field = 'user_id'; |
207 | 207 | } |
208 | 208 | |
209 | - $stats = array(); |
|
210 | - $donor = Give()->donors->get_donor_by( $field, $user ); |
|
209 | + $stats = array(); |
|
210 | + $donor = Give()->donors->get_donor_by($field, $user); |
|
211 | 211 | |
212 | - if ( $donor ) { |
|
213 | - $donor = new Give_Donor( $donor->id ); |
|
214 | - $stats['purchases'] = absint( $donor->purchase_count ); |
|
215 | - $stats['total_spent'] = give_maybe_sanitize_amount( $donor->purchase_value ); |
|
212 | + if ($donor) { |
|
213 | + $donor = new Give_Donor($donor->id); |
|
214 | + $stats['purchases'] = absint($donor->purchase_count); |
|
215 | + $stats['total_spent'] = give_maybe_sanitize_amount($donor->purchase_value); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * |
221 | 221 | * @since 1.7 |
222 | 222 | */ |
223 | - $stats = (array) apply_filters( 'give_donation_stats_by_user', $stats, $user ); |
|
223 | + $stats = (array) apply_filters('give_donation_stats_by_user', $stats, $user); |
|
224 | 224 | |
225 | 225 | return $stats; |
226 | 226 | } |
@@ -238,21 +238,21 @@ discard block |
||
238 | 238 | * |
239 | 239 | * @return int The total number of donations. |
240 | 240 | */ |
241 | -function give_count_donations_of_donor( $user = null ) { |
|
241 | +function give_count_donations_of_donor($user = null) { |
|
242 | 242 | |
243 | 243 | // Logged in? |
244 | - if ( empty( $user ) ) { |
|
244 | + if (empty($user)) { |
|
245 | 245 | $user = get_current_user_id(); |
246 | 246 | } |
247 | 247 | |
248 | 248 | // Email access? |
249 | - if ( empty( $user ) && Give()->email_access->token_email ) { |
|
249 | + if (empty($user) && Give()->email_access->token_email) { |
|
250 | 250 | $user = Give()->email_access->token_email; |
251 | 251 | } |
252 | 252 | |
253 | - $stats = ! empty( $user ) ? give_get_donation_stats_by_user( $user ) : false; |
|
253 | + $stats = ! empty($user) ? give_get_donation_stats_by_user($user) : false; |
|
254 | 254 | |
255 | - return isset( $stats['purchases'] ) ? $stats['purchases'] : 0; |
|
255 | + return isset($stats['purchases']) ? $stats['purchases'] : 0; |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
@@ -265,9 +265,9 @@ discard block |
||
265 | 265 | * |
266 | 266 | * @return float The total amount the user has spent |
267 | 267 | */ |
268 | -function give_donation_total_of_user( $user = null ) { |
|
268 | +function give_donation_total_of_user($user = null) { |
|
269 | 269 | |
270 | - $stats = give_get_donation_stats_by_user( $user ); |
|
270 | + $stats = give_get_donation_stats_by_user($user); |
|
271 | 271 | |
272 | 272 | return $stats['total_spent']; |
273 | 273 | } |
@@ -283,40 +283,40 @@ discard block |
||
283 | 283 | * |
284 | 284 | * @return bool |
285 | 285 | */ |
286 | -function give_validate_username( $username, $form_id = 0 ) { |
|
286 | +function give_validate_username($username, $form_id = 0) { |
|
287 | 287 | $valid = true; |
288 | 288 | |
289 | 289 | // Validate username. |
290 | - if ( ! empty( $username ) ) { |
|
290 | + if ( ! empty($username)) { |
|
291 | 291 | |
292 | 292 | // Sanitize username. |
293 | - $sanitized_user_name = sanitize_user( $username, false ); |
|
293 | + $sanitized_user_name = sanitize_user($username, false); |
|
294 | 294 | |
295 | 295 | // We have an user name, check if it already exists. |
296 | - if ( username_exists( $username ) ) { |
|
296 | + if (username_exists($username)) { |
|
297 | 297 | // Username already registered. |
298 | - give_set_error( 'username_unavailable', __( 'Username already taken.', 'give' ) ); |
|
298 | + give_set_error('username_unavailable', __('Username already taken.', 'give')); |
|
299 | 299 | $valid = false; |
300 | 300 | |
301 | 301 | // Check if it's valid. |
302 | - } elseif ( $sanitized_user_name !== $username ) { |
|
302 | + } elseif ($sanitized_user_name !== $username) { |
|
303 | 303 | // Invalid username. |
304 | - if ( is_multisite() ) { |
|
305 | - give_set_error( 'username_invalid', __( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ) ); |
|
304 | + if (is_multisite()) { |
|
305 | + give_set_error('username_invalid', __('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give')); |
|
306 | 306 | $valid = false; |
307 | 307 | } else { |
308 | - give_set_error( 'username_invalid', __( 'Invalid username.', 'give' ) ); |
|
308 | + give_set_error('username_invalid', __('Invalid username.', 'give')); |
|
309 | 309 | $valid = false; |
310 | 310 | } |
311 | 311 | } |
312 | 312 | } else { |
313 | 313 | // Username is empty. |
314 | - give_set_error( 'username_empty', __( 'Enter a username.', 'give' ) ); |
|
314 | + give_set_error('username_empty', __('Enter a username.', 'give')); |
|
315 | 315 | $valid = false; |
316 | 316 | |
317 | 317 | // Check if guest checkout is disable for form. |
318 | - if ( $form_id && give_logged_in_only( $form_id ) ) { |
|
319 | - give_set_error( 'registration_required', __( 'You must register or login to complete your donation.', 'give' ) ); |
|
318 | + if ($form_id && give_logged_in_only($form_id)) { |
|
319 | + give_set_error('registration_required', __('You must register or login to complete your donation.', 'give')); |
|
320 | 320 | $valid = false; |
321 | 321 | } |
322 | 322 | } |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | * @param string $username |
331 | 331 | * @param bool $form_id |
332 | 332 | */ |
333 | - $valid = (bool) apply_filters( 'give_validate_username', $valid, $username, $form_id ); |
|
333 | + $valid = (bool) apply_filters('give_validate_username', $valid, $username, $form_id); |
|
334 | 334 | |
335 | 335 | return $valid; |
336 | 336 | } |
@@ -346,25 +346,25 @@ discard block |
||
346 | 346 | * |
347 | 347 | * @return bool |
348 | 348 | */ |
349 | -function give_validate_user_email( $email, $registering_new_user = false ) { |
|
349 | +function give_validate_user_email($email, $registering_new_user = false) { |
|
350 | 350 | $valid = true; |
351 | 351 | |
352 | - if ( empty( $email ) ) { |
|
352 | + if (empty($email)) { |
|
353 | 353 | // No email. |
354 | - give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) ); |
|
354 | + give_set_error('email_empty', __('Enter an email.', 'give')); |
|
355 | 355 | $valid = false; |
356 | 356 | |
357 | - } elseif ( ! is_email( $email ) ) { |
|
357 | + } elseif ( ! is_email($email)) { |
|
358 | 358 | // Validate email. |
359 | - give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) ); |
|
359 | + give_set_error('email_invalid', __('Invalid email.', 'give')); |
|
360 | 360 | $valid = false; |
361 | 361 | |
362 | - } elseif ( $registering_new_user ) { |
|
362 | + } elseif ($registering_new_user) { |
|
363 | 363 | |
364 | 364 | // If donor email is not primary |
365 | - if ( ! email_exists( $email ) && give_donor_email_exists( $email ) && give_is_additional_email( $email ) ) { |
|
365 | + if ( ! email_exists($email) && give_donor_email_exists($email) && give_is_additional_email($email)) { |
|
366 | 366 | // Check if email exists. |
367 | - give_set_error( 'email_used', __( 'The email address provided is already active for another user.', 'give' ) ); |
|
367 | + give_set_error('email_used', __('The email address provided is already active for another user.', 'give')); |
|
368 | 368 | $valid = false; |
369 | 369 | } |
370 | 370 | } |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | * @param string $email |
379 | 379 | * @param bool $registering_new_user |
380 | 380 | */ |
381 | - $valid = (bool) apply_filters( 'give_validate_user_email', $valid, $email, $registering_new_user ); |
|
381 | + $valid = (bool) apply_filters('give_validate_user_email', $valid, $email, $registering_new_user); |
|
382 | 382 | |
383 | 383 | return $valid; |
384 | 384 | } |
@@ -394,34 +394,34 @@ discard block |
||
394 | 394 | * |
395 | 395 | * @return bool |
396 | 396 | */ |
397 | -function give_validate_user_password( $password = '', $confirm_password = '', $registering_new_user = false ) { |
|
397 | +function give_validate_user_password($password = '', $confirm_password = '', $registering_new_user = false) { |
|
398 | 398 | $valid = true; |
399 | 399 | |
400 | 400 | // Passwords Validation For New Donors Only |
401 | - if ( $registering_new_user ) { |
|
401 | + if ($registering_new_user) { |
|
402 | 402 | // Password or confirmation missing. |
403 | - if ( ! $password ) { |
|
403 | + if ( ! $password) { |
|
404 | 404 | // The password is invalid. |
405 | - give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) ); |
|
405 | + give_set_error('password_empty', __('Enter a password.', 'give')); |
|
406 | 406 | $valid = false; |
407 | - } elseif ( ! $confirm_password ) { |
|
407 | + } elseif ( ! $confirm_password) { |
|
408 | 408 | // Confirmation password is invalid. |
409 | - give_set_error( 'confirmation_empty', __( 'Enter the password confirmation.', 'give' ) ); |
|
409 | + give_set_error('confirmation_empty', __('Enter the password confirmation.', 'give')); |
|
410 | 410 | $valid = false; |
411 | 411 | } |
412 | 412 | } |
413 | 413 | // Passwords Validation For New Donors as well as Existing Donors |
414 | - if ( $password || $confirm_password ) { |
|
415 | - if ( strlen( $password ) < 6 || strlen( $confirm_password ) < 6 ) { |
|
414 | + if ($password || $confirm_password) { |
|
415 | + if (strlen($password) < 6 || strlen($confirm_password) < 6) { |
|
416 | 416 | // Seems Weak Password |
417 | - give_set_error( 'password_weak', __( 'Passwords should have at least 6 characters.', 'give' ) ); |
|
417 | + give_set_error('password_weak', __('Passwords should have at least 6 characters.', 'give')); |
|
418 | 418 | $valid = false; |
419 | 419 | } |
420 | - if ( $password && $confirm_password ) { |
|
420 | + if ($password && $confirm_password) { |
|
421 | 421 | // Verify confirmation matches. |
422 | - if ( $password != $confirm_password ) { |
|
422 | + if ($password != $confirm_password) { |
|
423 | 423 | // Passwords do not match |
424 | - give_set_error( 'password_mismatch', __( 'Passwords you entered do not match. Please try again.', 'give' ) ); |
|
424 | + give_set_error('password_mismatch', __('Passwords you entered do not match. Please try again.', 'give')); |
|
425 | 425 | $valid = false; |
426 | 426 | } |
427 | 427 | } |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | * @param string $confirm_password |
438 | 438 | * @param bool $registering_new_user |
439 | 439 | */ |
440 | - $valid = (bool) apply_filters( 'give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user ); |
|
440 | + $valid = (bool) apply_filters('give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user); |
|
441 | 441 | |
442 | 442 | return $valid; |
443 | 443 | } |
@@ -455,20 +455,20 @@ discard block |
||
455 | 455 | * |
456 | 456 | * @return void |
457 | 457 | */ |
458 | -function give_add_past_donations_to_new_user( $user_id ) { |
|
458 | +function give_add_past_donations_to_new_user($user_id) { |
|
459 | 459 | |
460 | - $email = get_the_author_meta( 'user_email', $user_id ); |
|
460 | + $email = get_the_author_meta('user_email', $user_id); |
|
461 | 461 | |
462 | - $payments = give_get_payments( array( |
|
462 | + $payments = give_get_payments(array( |
|
463 | 463 | 'output' => 'payments', |
464 | 464 | 's' => $email, |
465 | - ) ); |
|
465 | + )); |
|
466 | 466 | |
467 | - if ( $payments ) { |
|
468 | - foreach ( $payments as $payment ) { |
|
467 | + if ($payments) { |
|
468 | + foreach ($payments as $payment) { |
|
469 | 469 | /* @var $payment \Give_Payment */ |
470 | 470 | |
471 | - if ( intval( give_get_payment_user_id( $payment->ID ) ) > 0 ) { |
|
471 | + if (intval(give_get_payment_user_id($payment->ID)) > 0) { |
|
472 | 472 | continue; |
473 | 473 | } |
474 | 474 | |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | |
481 | 481 | } |
482 | 482 | |
483 | -add_action( 'user_register', 'give_add_past_donations_to_new_user' ); |
|
483 | +add_action('user_register', 'give_add_past_donations_to_new_user'); |
|
484 | 484 | |
485 | 485 | |
486 | 486 | /** |
@@ -506,34 +506,34 @@ discard block |
||
506 | 506 | * |
507 | 507 | * @return array The donor's address, if any |
508 | 508 | */ |
509 | -function give_get_donor_address( $user_id = 0 ) { |
|
510 | - if ( empty( $user_id ) ) { |
|
509 | +function give_get_donor_address($user_id = 0) { |
|
510 | + if (empty($user_id)) { |
|
511 | 511 | $user_id = get_current_user_id(); |
512 | 512 | } |
513 | 513 | |
514 | - $address = (array) get_user_meta( $user_id, '_give_user_address', true ); |
|
514 | + $address = (array) get_user_meta($user_id, '_give_user_address', true); |
|
515 | 515 | |
516 | - if ( ! isset( $address['line1'] ) ) { |
|
516 | + if ( ! isset($address['line1'])) { |
|
517 | 517 | $address['line1'] = ''; |
518 | 518 | } |
519 | 519 | |
520 | - if ( ! isset( $address['line2'] ) ) { |
|
520 | + if ( ! isset($address['line2'])) { |
|
521 | 521 | $address['line2'] = ''; |
522 | 522 | } |
523 | 523 | |
524 | - if ( ! isset( $address['city'] ) ) { |
|
524 | + if ( ! isset($address['city'])) { |
|
525 | 525 | $address['city'] = ''; |
526 | 526 | } |
527 | 527 | |
528 | - if ( ! isset( $address['zip'] ) ) { |
|
528 | + if ( ! isset($address['zip'])) { |
|
529 | 529 | $address['zip'] = ''; |
530 | 530 | } |
531 | 531 | |
532 | - if ( ! isset( $address['country'] ) ) { |
|
532 | + if ( ! isset($address['country'])) { |
|
533 | 533 | $address['country'] = ''; |
534 | 534 | } |
535 | 535 | |
536 | - if ( ! isset( $address['state'] ) ) { |
|
536 | + if ( ! isset($address['state'])) { |
|
537 | 537 | $address['state'] = ''; |
538 | 538 | } |
539 | 539 | |
@@ -553,53 +553,53 @@ discard block |
||
553 | 553 | * |
554 | 554 | * @return void |
555 | 555 | */ |
556 | -function give_new_user_notification( $user_id = 0, $user_data = array() ) { |
|
556 | +function give_new_user_notification($user_id = 0, $user_data = array()) { |
|
557 | 557 | |
558 | - if ( empty( $user_id ) || empty( $user_data ) ) { |
|
558 | + if (empty($user_id) || empty($user_data)) { |
|
559 | 559 | return; |
560 | 560 | } |
561 | - $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); |
|
561 | + $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
|
562 | 562 | |
563 | 563 | // New User Registration: Email sends to the site admin. |
564 | 564 | $emails = Give()->emails; |
565 | - $emails->__set( 'heading', esc_html__( 'New User Registration', 'give' ) ); |
|
565 | + $emails->__set('heading', esc_html__('New User Registration', 'give')); |
|
566 | 566 | |
567 | 567 | /* translators: %s: site name */ |
568 | - $message = sprintf( esc_attr__( 'A new user has registered on %s:', 'give' ), $blogname ) . "\r\n\r\n"; |
|
568 | + $message = sprintf(esc_attr__('A new user has registered on %s:', 'give'), $blogname)."\r\n\r\n"; |
|
569 | 569 | /* translators: %s: user login */ |
570 | - $message .= '<strong>' . esc_attr__( 'Username:', 'give' ) . '</strong> ' . $user_data['user_login'] . "\r\n"; |
|
570 | + $message .= '<strong>'.esc_attr__('Username:', 'give').'</strong> '.$user_data['user_login']."\r\n"; |
|
571 | 571 | /* translators: %s: user email */ |
572 | - $message .= '<strong>' . esc_attr__( 'E-mail:', 'give' ) . '</strong> ' . $user_data['user_email'] . "\r\n\r\n"; |
|
572 | + $message .= '<strong>'.esc_attr__('E-mail:', 'give').'</strong> '.$user_data['user_email']."\r\n\r\n"; |
|
573 | 573 | |
574 | - $message .= '<a href="' . admin_url( 'user-edit.php?user_id=' . $user_id ) . '" target="_blank"> ' . esc_attr__( 'Click here to view »', 'give' ) . '</a>' . "\r\n"; |
|
574 | + $message .= '<a href="'.admin_url('user-edit.php?user_id='.$user_id).'" target="_blank"> '.esc_attr__('Click here to view »', 'give').'</a>'."\r\n"; |
|
575 | 575 | |
576 | 576 | $emails->send( |
577 | - get_option( 'admin_email' ), |
|
577 | + get_option('admin_email'), |
|
578 | 578 | sprintf( |
579 | 579 | /* translators: %s: site name */ |
580 | - esc_attr__( '[%s] New User Registration', 'give' ), |
|
580 | + esc_attr__('[%s] New User Registration', 'give'), |
|
581 | 581 | $blogname |
582 | 582 | ), |
583 | 583 | $message |
584 | 584 | ); |
585 | 585 | |
586 | 586 | // Account Information: Email sends to donor who registered. |
587 | - $emails->__set( 'heading', esc_html__( 'Account Information', 'give' ) ); |
|
587 | + $emails->__set('heading', esc_html__('Account Information', 'give')); |
|
588 | 588 | |
589 | - $message = sprintf( esc_attr__( 'The following email contains your account information for %s:', 'give' ), $blogname ) . "\r\n\r\n"; |
|
589 | + $message = sprintf(esc_attr__('The following email contains your account information for %s:', 'give'), $blogname)."\r\n\r\n"; |
|
590 | 590 | |
591 | 591 | /* translators: %s: user login */ |
592 | - $message .= '<strong>' . esc_attr__( 'Username:', 'give' ) . '</strong> ' . $user_data['user_login'] . "\r\n"; |
|
592 | + $message .= '<strong>'.esc_attr__('Username:', 'give').'</strong> '.$user_data['user_login']."\r\n"; |
|
593 | 593 | /* translators: %s: password */ |
594 | - $message .= '<strong>' . esc_attr__( 'Password:', 'give' ) . '</strong> ' . esc_attr__( '[Password entered during donation]', 'give' ) . "\r\n\r\n"; |
|
594 | + $message .= '<strong>'.esc_attr__('Password:', 'give').'</strong> '.esc_attr__('[Password entered during donation]', 'give')."\r\n\r\n"; |
|
595 | 595 | |
596 | - $message .= '<a href="' . wp_login_url() . '" target="_blank"> ' . esc_attr__( 'Click here to login »', 'give' ) . '</a>' . "\r\n"; |
|
596 | + $message .= '<a href="'.wp_login_url().'" target="_blank"> '.esc_attr__('Click here to login »', 'give').'</a>'."\r\n"; |
|
597 | 597 | |
598 | 598 | $emails->send( |
599 | 599 | $user_data['user_email'], |
600 | 600 | sprintf( |
601 | 601 | /* translators: %s: site name */ |
602 | - esc_attr__( '[%s] Your username and password', 'give' ), |
|
602 | + esc_attr__('[%s] Your username and password', 'give'), |
|
603 | 603 | $blogname |
604 | 604 | ), |
605 | 605 | $message |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | |
608 | 608 | } |
609 | 609 | |
610 | -add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 ); |
|
610 | +add_action('give_insert_user', 'give_new_user_notification', 10, 2); |
|
611 | 611 | |
612 | 612 | |
613 | 613 | /** |
@@ -623,34 +623,34 @@ discard block |
||
623 | 623 | * |
624 | 624 | * @return string |
625 | 625 | */ |
626 | -function give_get_donor_name_by( $id = 0, $from = 'donation' ) { |
|
626 | +function give_get_donor_name_by($id = 0, $from = 'donation') { |
|
627 | 627 | |
628 | 628 | // ID shouldn't be empty |
629 | - if ( empty( $id ) ) { |
|
629 | + if (empty($id)) { |
|
630 | 630 | return; |
631 | 631 | } |
632 | 632 | |
633 | 633 | $name = ''; |
634 | 634 | |
635 | - switch ( $from ) { |
|
635 | + switch ($from) { |
|
636 | 636 | |
637 | 637 | case 'donation': |
638 | 638 | |
639 | - $user_info = give_get_payment_meta_user_info( $id ); |
|
640 | - $name = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
639 | + $user_info = give_get_payment_meta_user_info($id); |
|
640 | + $name = $user_info['first_name'].' '.$user_info['last_name']; |
|
641 | 641 | |
642 | 642 | break; |
643 | 643 | |
644 | 644 | case 'donor': |
645 | 645 | |
646 | - $donor = new Give_Donor( $id ); |
|
646 | + $donor = new Give_Donor($id); |
|
647 | 647 | $name = $donor->name; |
648 | 648 | |
649 | 649 | break; |
650 | 650 | |
651 | 651 | } |
652 | 652 | |
653 | - return trim( $name ); |
|
653 | + return trim($name); |
|
654 | 654 | |
655 | 655 | } |
656 | 656 | |
@@ -662,8 +662,8 @@ discard block |
||
662 | 662 | * @param string $email Donor Email. |
663 | 663 | * @return boolean The user's ID on success, and false on failure. |
664 | 664 | */ |
665 | -function give_donor_email_exists( $email ) { |
|
666 | - if ( Give()->donors->get_donor_by( 'email', $email ) ) { |
|
665 | +function give_donor_email_exists($email) { |
|
666 | + if (Give()->donors->get_donor_by('email', $email)) { |
|
667 | 667 | return true; |
668 | 668 | } |
669 | 669 | return false; |
@@ -678,12 +678,12 @@ discard block |
||
678 | 678 | * |
679 | 679 | * @return bool |
680 | 680 | */ |
681 | -function give_is_additional_email( $email ) { |
|
681 | +function give_is_additional_email($email) { |
|
682 | 682 | global $wpdb; |
683 | - $meta_table = Give()->donor_meta->table_name; |
|
684 | - $donor_id = $wpdb->get_var( $wpdb->prepare( "SELECT customer_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $email ) ); |
|
683 | + $meta_table = Give()->donor_meta->table_name; |
|
684 | + $donor_id = $wpdb->get_var($wpdb->prepare("SELECT customer_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $email)); |
|
685 | 685 | |
686 | - if ( empty( $donor_id ) ) { |
|
686 | + if (empty($donor_id)) { |
|
687 | 687 | return false; |
688 | 688 | } |
689 | 689 | return true; |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @return mixed array if errors are present, false if none found |
26 | 26 | */ |
27 | 27 | function give_get_errors() { |
28 | - return Give()->session->get( 'give_errors' ); |
|
28 | + return Give()->session->get('give_errors'); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
@@ -42,23 +42,23 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @return void |
44 | 44 | */ |
45 | -function give_set_error( $error_id, $error_message, $notice_args = array() ) { |
|
45 | +function give_set_error($error_id, $error_message, $notice_args = array()) { |
|
46 | 46 | $errors = give_get_errors(); |
47 | - if ( ! $errors ) { |
|
47 | + if ( ! $errors) { |
|
48 | 48 | $errors = array(); |
49 | 49 | } |
50 | 50 | |
51 | - if( is_array( $notice_args ) && ! empty( $notice_args ) ) { |
|
52 | - $errors[ $error_id ] = array( |
|
51 | + if (is_array($notice_args) && ! empty($notice_args)) { |
|
52 | + $errors[$error_id] = array( |
|
53 | 53 | 'message' => $error_message, |
54 | 54 | 'notice_args' => $notice_args, |
55 | 55 | ); |
56 | 56 | } else { |
57 | 57 | // Backward compatibility v<1.8.11. |
58 | - $errors[ $error_id ] = $error_message; |
|
58 | + $errors[$error_id] = $error_message; |
|
59 | 59 | } |
60 | 60 | |
61 | - Give()->session->set( 'give_errors', $errors ); |
|
61 | + Give()->session->set('give_errors', $errors); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @return void |
70 | 70 | */ |
71 | 71 | function give_clear_errors() { |
72 | - Give()->session->set( 'give_errors', null ); |
|
72 | + Give()->session->set('give_errors', null); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
@@ -82,19 +82,19 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @return void |
84 | 84 | */ |
85 | -function give_unset_error( $error_id ) { |
|
85 | +function give_unset_error($error_id) { |
|
86 | 86 | $errors = give_get_errors(); |
87 | - if ( $errors ) { |
|
87 | + if ($errors) { |
|
88 | 88 | /** |
89 | 89 | * Check If $error_id exists in the array. |
90 | 90 | * If exists then unset it. |
91 | 91 | * |
92 | 92 | * @since 1.8.13 |
93 | 93 | */ |
94 | - if ( isset( $errors[ $error_id ] ) ) { |
|
95 | - unset( $errors[ $error_id ] ); |
|
94 | + if (isset($errors[$error_id])) { |
|
95 | + unset($errors[$error_id]); |
|
96 | 96 | } |
97 | - Give()->session->set( 'give_errors', $errors ); |
|
97 | + Give()->session->set('give_errors', $errors); |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @return string |
106 | 106 | */ |
107 | 107 | function _give_die_handler() { |
108 | - if ( defined( 'GIVE_UNIT_TESTS' ) ) { |
|
108 | + if (defined('GIVE_UNIT_TESTS')) { |
|
109 | 109 | return '_give_die_handler'; |
110 | 110 | } else { |
111 | 111 | die(); |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | * |
126 | 126 | * @return void |
127 | 127 | */ |
128 | -function give_die( $message = '', $title = '', $status = 400 ) { |
|
129 | - add_filter( 'wp_die_ajax_handler', '_give_die_handler', 10, 3 ); |
|
130 | - add_filter( 'wp_die_handler', '_give_die_handler', 10, 3 ); |
|
131 | - wp_die( $message, $title, array( 'response' => $status ) ); |
|
128 | +function give_die($message = '', $title = '', $status = 400) { |
|
129 | + add_filter('wp_die_ajax_handler', '_give_die_handler', 10, 3); |
|
130 | + add_filter('wp_die_handler', '_give_die_handler', 10, 3); |
|
131 | + wp_die($message, $title, array('response' => $status)); |
|
132 | 132 | } |
@@ -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 | |
@@ -139,32 +139,32 @@ discard block |
||
139 | 139 | * @param bool $_id_or_email |
140 | 140 | * @param bool $by_user_id |
141 | 141 | */ |
142 | - public function __construct( $_id_or_email = false, $by_user_id = false ) { |
|
142 | + public function __construct($_id_or_email = false, $by_user_id = false) { |
|
143 | 143 | |
144 | 144 | $this->db = Give()->donors; |
145 | 145 | |
146 | 146 | if ( |
147 | 147 | false === $_id_or_email |
148 | - || ( is_numeric( $_id_or_email ) && (int) $_id_or_email !== absint( $_id_or_email ) ) |
|
148 | + || (is_numeric($_id_or_email) && (int) $_id_or_email !== absint($_id_or_email)) |
|
149 | 149 | ) { |
150 | 150 | return false; |
151 | 151 | } |
152 | 152 | |
153 | - $by_user_id = is_bool( $by_user_id ) ? $by_user_id : false; |
|
153 | + $by_user_id = is_bool($by_user_id) ? $by_user_id : false; |
|
154 | 154 | |
155 | - if ( is_numeric( $_id_or_email ) ) { |
|
155 | + if (is_numeric($_id_or_email)) { |
|
156 | 156 | $field = $by_user_id ? 'user_id' : 'id'; |
157 | 157 | } else { |
158 | 158 | $field = 'email'; |
159 | 159 | } |
160 | 160 | |
161 | - $donor = $this->db->get_donor_by( $field, $_id_or_email ); |
|
161 | + $donor = $this->db->get_donor_by($field, $_id_or_email); |
|
162 | 162 | |
163 | - if ( empty( $donor ) || ! is_object( $donor ) ) { |
|
163 | + if (empty($donor) || ! is_object($donor)) { |
|
164 | 164 | return false; |
165 | 165 | } |
166 | 166 | |
167 | - $this->setup_donor( $donor ); |
|
167 | + $this->setup_donor($donor); |
|
168 | 168 | |
169 | 169 | } |
170 | 170 | |
@@ -180,15 +180,15 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @return bool If the setup was successful or not. |
182 | 182 | */ |
183 | - private function setup_donor( $donor ) { |
|
183 | + private function setup_donor($donor) { |
|
184 | 184 | |
185 | - if ( ! is_object( $donor ) ) { |
|
185 | + if ( ! is_object($donor)) { |
|
186 | 186 | return false; |
187 | 187 | } |
188 | 188 | |
189 | - foreach ( $donor as $key => $value ) { |
|
189 | + foreach ($donor as $key => $value) { |
|
190 | 190 | |
191 | - switch ( $key ) { |
|
191 | + switch ($key) { |
|
192 | 192 | |
193 | 193 | case 'notes': |
194 | 194 | $this->$key = $this->get_notes(); |
@@ -202,11 +202,11 @@ discard block |
||
202 | 202 | } |
203 | 203 | |
204 | 204 | // Get donor's all email including primary email. |
205 | - $this->emails = (array) $this->get_meta( 'additional_email', false ); |
|
206 | - $this->emails = array( 'primary' => $this->email ) + $this->emails; |
|
205 | + $this->emails = (array) $this->get_meta('additional_email', false); |
|
206 | + $this->emails = array('primary' => $this->email) + $this->emails; |
|
207 | 207 | |
208 | 208 | // Donor ID and email are the only things that are necessary, make sure they exist. |
209 | - if ( ! empty( $this->id ) && ! empty( $this->email ) ) { |
|
209 | + if ( ! empty($this->id) && ! empty($this->email)) { |
|
210 | 210 | return true; |
211 | 211 | } |
212 | 212 | |
@@ -223,16 +223,16 @@ discard block |
||
223 | 223 | * |
224 | 224 | * @return mixed|\WP_Error |
225 | 225 | */ |
226 | - public function __get( $key ) { |
|
226 | + public function __get($key) { |
|
227 | 227 | |
228 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
228 | + if (method_exists($this, 'get_'.$key)) { |
|
229 | 229 | |
230 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
230 | + return call_user_func(array($this, 'get_'.$key)); |
|
231 | 231 | |
232 | 232 | } else { |
233 | 233 | |
234 | 234 | /* translators: %s: property key */ |
235 | - return new WP_Error( 'give-donor-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) ); |
|
235 | + return new WP_Error('give-donor-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key)); |
|
236 | 236 | |
237 | 237 | } |
238 | 238 | |
@@ -248,9 +248,9 @@ discard block |
||
248 | 248 | * |
249 | 249 | * @return bool|int False if not a valid creation, donor ID if user is found or valid creation. |
250 | 250 | */ |
251 | - public function create( $data = array() ) { |
|
251 | + public function create($data = array()) { |
|
252 | 252 | |
253 | - if ( $this->id != 0 || empty( $data ) ) { |
|
253 | + if ($this->id != 0 || empty($data)) { |
|
254 | 254 | return false; |
255 | 255 | } |
256 | 256 | |
@@ -258,15 +258,15 @@ discard block |
||
258 | 258 | 'payment_ids' => '', |
259 | 259 | ); |
260 | 260 | |
261 | - $args = wp_parse_args( $data, $defaults ); |
|
262 | - $args = $this->sanitize_columns( $args ); |
|
261 | + $args = wp_parse_args($data, $defaults); |
|
262 | + $args = $this->sanitize_columns($args); |
|
263 | 263 | |
264 | - if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) { |
|
264 | + if (empty($args['email']) || ! is_email($args['email'])) { |
|
265 | 265 | return false; |
266 | 266 | } |
267 | 267 | |
268 | - if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) { |
|
269 | - $args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) ); |
|
268 | + if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) { |
|
269 | + $args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids']))); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | /** |
@@ -276,18 +276,18 @@ discard block |
||
276 | 276 | * |
277 | 277 | * @param array $args Donor attributes. |
278 | 278 | */ |
279 | - do_action( 'give_donor_pre_create', $args ); |
|
279 | + do_action('give_donor_pre_create', $args); |
|
280 | 280 | |
281 | 281 | $created = false; |
282 | 282 | |
283 | 283 | // The DB class 'add' implies an update if the donor being asked to be created already exists |
284 | - if ( $this->db->add( $data ) ) { |
|
284 | + if ($this->db->add($data)) { |
|
285 | 285 | |
286 | 286 | // We've successfully added/updated the donor, reset the class vars with the new data |
287 | - $donor = $this->db->get_donor_by( 'email', $args['email'] ); |
|
287 | + $donor = $this->db->get_donor_by('email', $args['email']); |
|
288 | 288 | |
289 | 289 | // Setup the donor data with the values from DB |
290 | - $this->setup_donor( $donor ); |
|
290 | + $this->setup_donor($donor); |
|
291 | 291 | |
292 | 292 | $created = $this->id; |
293 | 293 | } |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | * @param bool|int $created False if not a valid creation, donor ID if user is found or valid creation. |
301 | 301 | * @param array $args Customer attributes. |
302 | 302 | */ |
303 | - do_action( 'give_donor_post_create', $created, $args ); |
|
303 | + do_action('give_donor_post_create', $created, $args); |
|
304 | 304 | |
305 | 305 | return $created; |
306 | 306 | |
@@ -316,13 +316,13 @@ discard block |
||
316 | 316 | * |
317 | 317 | * @return bool If the update was successful or not. |
318 | 318 | */ |
319 | - public function update( $data = array() ) { |
|
319 | + public function update($data = array()) { |
|
320 | 320 | |
321 | - if ( empty( $data ) ) { |
|
321 | + if (empty($data)) { |
|
322 | 322 | return false; |
323 | 323 | } |
324 | 324 | |
325 | - $data = $this->sanitize_columns( $data ); |
|
325 | + $data = $this->sanitize_columns($data); |
|
326 | 326 | |
327 | 327 | /** |
328 | 328 | * Fires before updating donors. |
@@ -332,14 +332,14 @@ discard block |
||
332 | 332 | * @param int $donor_id Donor id. |
333 | 333 | * @param array $data Donor attributes. |
334 | 334 | */ |
335 | - do_action( 'give_donor_pre_update', $this->id, $data ); |
|
335 | + do_action('give_donor_pre_update', $this->id, $data); |
|
336 | 336 | |
337 | 337 | $updated = false; |
338 | 338 | |
339 | - if ( $this->db->update( $this->id, $data ) ) { |
|
339 | + if ($this->db->update($this->id, $data)) { |
|
340 | 340 | |
341 | - $donor = $this->db->get_donor_by( 'id', $this->id ); |
|
342 | - $this->setup_donor( $donor ); |
|
341 | + $donor = $this->db->get_donor_by('id', $this->id); |
|
342 | + $this->setup_donor($donor); |
|
343 | 343 | |
344 | 344 | $updated = true; |
345 | 345 | } |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | * @param int $donor_id Donor id. |
354 | 354 | * @param array $data Donor attributes. |
355 | 355 | */ |
356 | - do_action( 'give_donor_post_update', $updated, $this->id, $data ); |
|
356 | + do_action('give_donor_post_update', $updated, $this->id, $data); |
|
357 | 357 | |
358 | 358 | return $updated; |
359 | 359 | } |
@@ -371,27 +371,27 @@ discard block |
||
371 | 371 | * |
372 | 372 | * @return bool If the attachment was successfully. |
373 | 373 | */ |
374 | - public function attach_payment( $payment_id = 0, $update_stats = true ) { |
|
374 | + public function attach_payment($payment_id = 0, $update_stats = true) { |
|
375 | 375 | |
376 | - if ( empty( $payment_id ) ) { |
|
376 | + if (empty($payment_id)) { |
|
377 | 377 | return false; |
378 | 378 | } |
379 | 379 | |
380 | - if ( empty( $this->payment_ids ) ) { |
|
380 | + if (empty($this->payment_ids)) { |
|
381 | 381 | |
382 | 382 | $new_payment_ids = $payment_id; |
383 | 383 | |
384 | 384 | } else { |
385 | 385 | |
386 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
386 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
387 | 387 | |
388 | - if ( in_array( $payment_id, $payment_ids ) ) { |
|
388 | + if (in_array($payment_id, $payment_ids)) { |
|
389 | 389 | $update_stats = false; |
390 | 390 | } |
391 | 391 | |
392 | 392 | $payment_ids[] = $payment_id; |
393 | 393 | |
394 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
394 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
395 | 395 | |
396 | 396 | } |
397 | 397 | |
@@ -403,20 +403,20 @@ discard block |
||
403 | 403 | * @param int $payment_id Payment id. |
404 | 404 | * @param int $donor_id Customer id. |
405 | 405 | */ |
406 | - do_action( 'give_donor_pre_attach_payment', $payment_id, $this->id ); |
|
406 | + do_action('give_donor_pre_attach_payment', $payment_id, $this->id); |
|
407 | 407 | |
408 | - $payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
408 | + $payment_added = $this->update(array('payment_ids' => $new_payment_ids)); |
|
409 | 409 | |
410 | - if ( $payment_added ) { |
|
410 | + if ($payment_added) { |
|
411 | 411 | |
412 | 412 | $this->payment_ids = $new_payment_ids; |
413 | 413 | |
414 | 414 | // We added this payment successfully, increment the stats |
415 | - if ( $update_stats ) { |
|
416 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
415 | + if ($update_stats) { |
|
416 | + $payment_amount = give_get_payment_amount($payment_id); |
|
417 | 417 | |
418 | - if ( ! empty( $payment_amount ) ) { |
|
419 | - $this->increase_value( $payment_amount ); |
|
418 | + if ( ! empty($payment_amount)) { |
|
419 | + $this->increase_value($payment_amount); |
|
420 | 420 | } |
421 | 421 | |
422 | 422 | $this->increase_purchase_count(); |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | * @param int $payment_id Payment id. |
433 | 433 | * @param int $donor_id Donor id. |
434 | 434 | */ |
435 | - do_action( 'give_donor_post_attach_payment', $payment_added, $payment_id, $this->id ); |
|
435 | + do_action('give_donor_post_attach_payment', $payment_added, $payment_id, $this->id); |
|
436 | 436 | |
437 | 437 | return $payment_added; |
438 | 438 | } |
@@ -450,33 +450,33 @@ discard block |
||
450 | 450 | * |
451 | 451 | * @return boolean If the removal was successful. |
452 | 452 | */ |
453 | - public function remove_payment( $payment_id = 0, $update_stats = true ) { |
|
453 | + public function remove_payment($payment_id = 0, $update_stats = true) { |
|
454 | 454 | |
455 | - if ( empty( $payment_id ) ) { |
|
455 | + if (empty($payment_id)) { |
|
456 | 456 | return false; |
457 | 457 | } |
458 | 458 | |
459 | - $payment = new Give_Payment( $payment_id ); |
|
459 | + $payment = new Give_Payment($payment_id); |
|
460 | 460 | |
461 | - if ( 'publish' !== $payment->status && 'revoked' !== $payment->status ) { |
|
461 | + if ('publish' !== $payment->status && 'revoked' !== $payment->status) { |
|
462 | 462 | $update_stats = false; |
463 | 463 | } |
464 | 464 | |
465 | 465 | $new_payment_ids = ''; |
466 | 466 | |
467 | - if ( ! empty( $this->payment_ids ) ) { |
|
467 | + if ( ! empty($this->payment_ids)) { |
|
468 | 468 | |
469 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
469 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
470 | 470 | |
471 | - $pos = array_search( $payment_id, $payment_ids ); |
|
472 | - if ( false === $pos ) { |
|
471 | + $pos = array_search($payment_id, $payment_ids); |
|
472 | + if (false === $pos) { |
|
473 | 473 | return false; |
474 | 474 | } |
475 | 475 | |
476 | - unset( $payment_ids[ $pos ] ); |
|
477 | - $payment_ids = array_filter( $payment_ids ); |
|
476 | + unset($payment_ids[$pos]); |
|
477 | + $payment_ids = array_filter($payment_ids); |
|
478 | 478 | |
479 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
479 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
480 | 480 | |
481 | 481 | } |
482 | 482 | |
@@ -488,20 +488,20 @@ discard block |
||
488 | 488 | * @param int $payment_id Payment id. |
489 | 489 | * @param int $donor_id Customer id. |
490 | 490 | */ |
491 | - do_action( 'give_donor_pre_remove_payment', $payment_id, $this->id ); |
|
491 | + do_action('give_donor_pre_remove_payment', $payment_id, $this->id); |
|
492 | 492 | |
493 | - $payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
493 | + $payment_removed = $this->update(array('payment_ids' => $new_payment_ids)); |
|
494 | 494 | |
495 | - if ( $payment_removed ) { |
|
495 | + if ($payment_removed) { |
|
496 | 496 | |
497 | 497 | $this->payment_ids = $new_payment_ids; |
498 | 498 | |
499 | - if ( $update_stats ) { |
|
499 | + if ($update_stats) { |
|
500 | 500 | // We removed this payment successfully, decrement the stats |
501 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
501 | + $payment_amount = give_get_payment_amount($payment_id); |
|
502 | 502 | |
503 | - if ( ! empty( $payment_amount ) ) { |
|
504 | - $this->decrease_value( $payment_amount ); |
|
503 | + if ( ! empty($payment_amount)) { |
|
504 | + $this->decrease_value($payment_amount); |
|
505 | 505 | } |
506 | 506 | |
507 | 507 | $this->decrease_donation_count(); |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | * @param int $payment_id Payment id. |
518 | 518 | * @param int $donor_id Donor id. |
519 | 519 | */ |
520 | - do_action( 'give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id ); |
|
520 | + do_action('give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id); |
|
521 | 521 | |
522 | 522 | return $payment_removed; |
523 | 523 | |
@@ -533,10 +533,10 @@ discard block |
||
533 | 533 | * |
534 | 534 | * @return int The donation count. |
535 | 535 | */ |
536 | - public function increase_purchase_count( $count = 1 ) { |
|
536 | + public function increase_purchase_count($count = 1) { |
|
537 | 537 | |
538 | 538 | // Make sure it's numeric and not negative. |
539 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
539 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
540 | 540 | return false; |
541 | 541 | } |
542 | 542 | |
@@ -550,9 +550,9 @@ discard block |
||
550 | 550 | * @param int $count The number to increase by. |
551 | 551 | * @param int $donor_id Donor id. |
552 | 552 | */ |
553 | - do_action( 'give_donor_pre_increase_donation_count', $count, $this->id ); |
|
553 | + do_action('give_donor_pre_increase_donation_count', $count, $this->id); |
|
554 | 554 | |
555 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
555 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
556 | 556 | $this->purchase_count = $new_total; |
557 | 557 | } |
558 | 558 | |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | * @param int $count The number increased by. |
566 | 566 | * @param int $donor_id Donor id. |
567 | 567 | */ |
568 | - do_action( 'give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id ); |
|
568 | + do_action('give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id); |
|
569 | 569 | |
570 | 570 | return $this->purchase_count; |
571 | 571 | } |
@@ -580,16 +580,16 @@ discard block |
||
580 | 580 | * |
581 | 581 | * @return mixed If successful, the new count, otherwise false. |
582 | 582 | */ |
583 | - public function decrease_donation_count( $count = 1 ) { |
|
583 | + public function decrease_donation_count($count = 1) { |
|
584 | 584 | |
585 | 585 | // Make sure it's numeric and not negative |
586 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
586 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
587 | 587 | return false; |
588 | 588 | } |
589 | 589 | |
590 | 590 | $new_total = (int) $this->purchase_count - (int) $count; |
591 | 591 | |
592 | - if ( $new_total < 0 ) { |
|
592 | + if ($new_total < 0) { |
|
593 | 593 | $new_total = 0; |
594 | 594 | } |
595 | 595 | |
@@ -601,9 +601,9 @@ discard block |
||
601 | 601 | * @param int $count The number to decrease by. |
602 | 602 | * @param int $donor_id Customer id. |
603 | 603 | */ |
604 | - do_action( 'give_donor_pre_decrease_donation_count', $count, $this->id ); |
|
604 | + do_action('give_donor_pre_decrease_donation_count', $count, $this->id); |
|
605 | 605 | |
606 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
606 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
607 | 607 | $this->purchase_count = $new_total; |
608 | 608 | } |
609 | 609 | |
@@ -616,7 +616,7 @@ discard block |
||
616 | 616 | * @param int $count The number decreased by. |
617 | 617 | * @param int $donor_id Donor id. |
618 | 618 | */ |
619 | - do_action( 'give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id ); |
|
619 | + do_action('give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id); |
|
620 | 620 | |
621 | 621 | return $this->purchase_count; |
622 | 622 | } |
@@ -631,9 +631,9 @@ discard block |
||
631 | 631 | * |
632 | 632 | * @return mixed If successful, the new value, otherwise false. |
633 | 633 | */ |
634 | - public function increase_value( $value = 0.00 ) { |
|
634 | + public function increase_value($value = 0.00) { |
|
635 | 635 | |
636 | - $new_value = floatval( $this->purchase_value ) + $value; |
|
636 | + $new_value = floatval($this->purchase_value) + $value; |
|
637 | 637 | |
638 | 638 | /** |
639 | 639 | * Fires before increasing donor lifetime value. |
@@ -643,9 +643,9 @@ discard block |
||
643 | 643 | * @param float $value The value to increase by. |
644 | 644 | * @param int $donor_id Customer id. |
645 | 645 | */ |
646 | - do_action( 'give_donor_pre_increase_value', $value, $this->id ); |
|
646 | + do_action('give_donor_pre_increase_value', $value, $this->id); |
|
647 | 647 | |
648 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
648 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
649 | 649 | $this->purchase_value = $new_value; |
650 | 650 | } |
651 | 651 | |
@@ -658,7 +658,7 @@ discard block |
||
658 | 658 | * @param float $value The value increased by. |
659 | 659 | * @param int $donor_id Donor id. |
660 | 660 | */ |
661 | - do_action( 'give_donor_post_increase_value', $this->purchase_value, $value, $this->id ); |
|
661 | + do_action('give_donor_post_increase_value', $this->purchase_value, $value, $this->id); |
|
662 | 662 | |
663 | 663 | return $this->purchase_value; |
664 | 664 | } |
@@ -673,11 +673,11 @@ discard block |
||
673 | 673 | * |
674 | 674 | * @return mixed If successful, the new value, otherwise false. |
675 | 675 | */ |
676 | - public function decrease_value( $value = 0.00 ) { |
|
676 | + public function decrease_value($value = 0.00) { |
|
677 | 677 | |
678 | - $new_value = floatval( $this->purchase_value ) - $value; |
|
678 | + $new_value = floatval($this->purchase_value) - $value; |
|
679 | 679 | |
680 | - if ( $new_value < 0 ) { |
|
680 | + if ($new_value < 0) { |
|
681 | 681 | $new_value = 0.00; |
682 | 682 | } |
683 | 683 | |
@@ -689,9 +689,9 @@ discard block |
||
689 | 689 | * @param float $value The value to decrease by. |
690 | 690 | * @param int $donor_id Donor id. |
691 | 691 | */ |
692 | - do_action( 'give_donor_pre_decrease_value', $value, $this->id ); |
|
692 | + do_action('give_donor_pre_decrease_value', $value, $this->id); |
|
693 | 693 | |
694 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
694 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
695 | 695 | $this->purchase_value = $new_value; |
696 | 696 | } |
697 | 697 | |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | * @param float $value The value decreased by. |
705 | 705 | * @param int $donor_id Donor id. |
706 | 706 | */ |
707 | - do_action( 'give_donor_post_decrease_value', $this->purchase_value, $value, $this->id ); |
|
707 | + do_action('give_donor_post_decrease_value', $this->purchase_value, $value, $this->id); |
|
708 | 708 | |
709 | 709 | return $this->purchase_value; |
710 | 710 | } |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | * |
724 | 724 | * @return mixed If successful, the new donation stat value, otherwise false. |
725 | 725 | */ |
726 | - public function update_donation_value( $curr_amount, $new_amount ) { |
|
726 | + public function update_donation_value($curr_amount, $new_amount) { |
|
727 | 727 | /** |
728 | 728 | * Payment total difference value can be: |
729 | 729 | * zero (in case amount not change) |
@@ -733,15 +733,15 @@ discard block |
||
733 | 733 | $payment_total_diff = $new_amount - $curr_amount; |
734 | 734 | |
735 | 735 | // We do not need to update donation stat if donation did not change. |
736 | - if ( ! $payment_total_diff ) { |
|
736 | + if ( ! $payment_total_diff) { |
|
737 | 737 | return false; |
738 | 738 | } |
739 | 739 | |
740 | - if ( $payment_total_diff > 0 ) { |
|
741 | - $this->increase_value( $payment_total_diff ); |
|
740 | + if ($payment_total_diff > 0) { |
|
741 | + $this->increase_value($payment_total_diff); |
|
742 | 742 | } else { |
743 | 743 | // Pass payment total difference as +ve value to decrease amount from user lifetime stat. |
744 | - $this->decrease_value( - $payment_total_diff ); |
|
744 | + $this->decrease_value( -$payment_total_diff ); |
|
745 | 745 | } |
746 | 746 | |
747 | 747 | return $this->purchase_value; |
@@ -758,15 +758,15 @@ discard block |
||
758 | 758 | * |
759 | 759 | * @return array The notes requested. |
760 | 760 | */ |
761 | - public function get_notes( $length = 20, $paged = 1 ) { |
|
761 | + public function get_notes($length = 20, $paged = 1) { |
|
762 | 762 | |
763 | - $length = is_numeric( $length ) ? $length : 20; |
|
764 | - $offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0; |
|
763 | + $length = is_numeric($length) ? $length : 20; |
|
764 | + $offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0; |
|
765 | 765 | |
766 | 766 | $all_notes = $this->get_raw_notes(); |
767 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
767 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
768 | 768 | |
769 | - $desired_notes = array_slice( $notes_array, $offset, $length ); |
|
769 | + $desired_notes = array_slice($notes_array, $offset, $length); |
|
770 | 770 | |
771 | 771 | return $desired_notes; |
772 | 772 | |
@@ -783,9 +783,9 @@ discard block |
||
783 | 783 | public function get_notes_count() { |
784 | 784 | |
785 | 785 | $all_notes = $this->get_raw_notes(); |
786 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
786 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
787 | 787 | |
788 | - return count( $notes_array ); |
|
788 | + return count($notes_array); |
|
789 | 789 | |
790 | 790 | } |
791 | 791 | |
@@ -799,22 +799,22 @@ discard block |
||
799 | 799 | * |
800 | 800 | * @return string|boolean The new note if added successfully, false otherwise. |
801 | 801 | */ |
802 | - public function add_note( $note = '' ) { |
|
802 | + public function add_note($note = '') { |
|
803 | 803 | |
804 | - $note = trim( $note ); |
|
805 | - if ( empty( $note ) ) { |
|
804 | + $note = trim($note); |
|
805 | + if (empty($note)) { |
|
806 | 806 | return false; |
807 | 807 | } |
808 | 808 | |
809 | 809 | $notes = $this->get_raw_notes(); |
810 | 810 | |
811 | - if ( empty( $notes ) ) { |
|
811 | + if (empty($notes)) { |
|
812 | 812 | $notes = ''; |
813 | 813 | } |
814 | 814 | |
815 | - $note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note; |
|
816 | - $new_note = apply_filters( 'give_customer_add_note_string', $note_string ); |
|
817 | - $notes .= "\n\n" . $new_note; |
|
815 | + $note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note; |
|
816 | + $new_note = apply_filters('give_customer_add_note_string', $note_string); |
|
817 | + $notes .= "\n\n".$new_note; |
|
818 | 818 | |
819 | 819 | /** |
820 | 820 | * Fires before donor note is added. |
@@ -824,11 +824,11 @@ discard block |
||
824 | 824 | * @param string $new_note New note to add. |
825 | 825 | * @param int $donor_id Donor id. |
826 | 826 | */ |
827 | - do_action( 'give_donor_pre_add_note', $new_note, $this->id ); |
|
827 | + do_action('give_donor_pre_add_note', $new_note, $this->id); |
|
828 | 828 | |
829 | - $updated = $this->update( array( 'notes' => $notes ) ); |
|
829 | + $updated = $this->update(array('notes' => $notes)); |
|
830 | 830 | |
831 | - if ( $updated ) { |
|
831 | + if ($updated) { |
|
832 | 832 | $this->notes = $this->get_notes(); |
833 | 833 | } |
834 | 834 | |
@@ -841,7 +841,7 @@ discard block |
||
841 | 841 | * @param string $new_note New note added. |
842 | 842 | * @param int $donor_id Donor id. |
843 | 843 | */ |
844 | - do_action( 'give_donor_post_add_note', $this->notes, $new_note, $this->id ); |
|
844 | + do_action('give_donor_post_add_note', $this->notes, $new_note, $this->id); |
|
845 | 845 | |
846 | 846 | // Return the formatted note, so we can test, as well as update any displays |
847 | 847 | return $new_note; |
@@ -858,7 +858,7 @@ discard block |
||
858 | 858 | */ |
859 | 859 | private function get_raw_notes() { |
860 | 860 | |
861 | - $all_notes = $this->db->get_column( 'notes', $this->id ); |
|
861 | + $all_notes = $this->db->get_column('notes', $this->id); |
|
862 | 862 | |
863 | 863 | return $all_notes; |
864 | 864 | |
@@ -875,8 +875,8 @@ discard block |
||
875 | 875 | * |
876 | 876 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single is true. |
877 | 877 | */ |
878 | - public function get_meta( $meta_key = '', $single = true ) { |
|
879 | - return Give()->donor_meta->get_meta( $this->id, $meta_key, $single ); |
|
878 | + public function get_meta($meta_key = '', $single = true) { |
|
879 | + return Give()->donor_meta->get_meta($this->id, $meta_key, $single); |
|
880 | 880 | } |
881 | 881 | |
882 | 882 | /** |
@@ -891,8 +891,8 @@ discard block |
||
891 | 891 | * |
892 | 892 | * @return bool False for failure. True for success. |
893 | 893 | */ |
894 | - public function add_meta( $meta_key = '', $meta_value, $unique = false ) { |
|
895 | - return Give()->donor_meta->add_meta( $this->id, $meta_key, $meta_value, $unique ); |
|
894 | + public function add_meta($meta_key = '', $meta_value, $unique = false) { |
|
895 | + return Give()->donor_meta->add_meta($this->id, $meta_key, $meta_value, $unique); |
|
896 | 896 | } |
897 | 897 | |
898 | 898 | /** |
@@ -907,8 +907,8 @@ discard block |
||
907 | 907 | * |
908 | 908 | * @return bool False on failure, true if success. |
909 | 909 | */ |
910 | - public function update_meta( $meta_key = '', $meta_value, $prev_value = '' ) { |
|
911 | - return Give()->donor_meta->update_meta( $this->id, $meta_key, $meta_value, $prev_value ); |
|
910 | + public function update_meta($meta_key = '', $meta_value, $prev_value = '') { |
|
911 | + return Give()->donor_meta->update_meta($this->id, $meta_key, $meta_value, $prev_value); |
|
912 | 912 | } |
913 | 913 | |
914 | 914 | /** |
@@ -922,8 +922,8 @@ discard block |
||
922 | 922 | * |
923 | 923 | * @return bool False for failure. True for success. |
924 | 924 | */ |
925 | - public function delete_meta( $meta_key = '', $meta_value = '' ) { |
|
926 | - return Give()->donor_meta->delete_meta( $this->id, $meta_key, $meta_value ); |
|
925 | + public function delete_meta($meta_key = '', $meta_value = '') { |
|
926 | + return Give()->donor_meta->delete_meta($this->id, $meta_key, $meta_value); |
|
927 | 927 | } |
928 | 928 | |
929 | 929 | /** |
@@ -936,51 +936,51 @@ discard block |
||
936 | 936 | * |
937 | 937 | * @return array The sanitized data, based off column defaults. |
938 | 938 | */ |
939 | - private function sanitize_columns( $data ) { |
|
939 | + private function sanitize_columns($data) { |
|
940 | 940 | |
941 | 941 | $columns = $this->db->get_columns(); |
942 | 942 | $default_values = $this->db->get_column_defaults(); |
943 | 943 | |
944 | - foreach ( $columns as $key => $type ) { |
|
944 | + foreach ($columns as $key => $type) { |
|
945 | 945 | |
946 | 946 | // Only sanitize data that we were provided |
947 | - if ( ! array_key_exists( $key, $data ) ) { |
|
947 | + if ( ! array_key_exists($key, $data)) { |
|
948 | 948 | continue; |
949 | 949 | } |
950 | 950 | |
951 | - switch ( $type ) { |
|
951 | + switch ($type) { |
|
952 | 952 | |
953 | 953 | case '%s': |
954 | - if ( 'email' == $key ) { |
|
955 | - $data[ $key ] = sanitize_email( $data[ $key ] ); |
|
956 | - } elseif ( 'notes' == $key ) { |
|
957 | - $data[ $key ] = strip_tags( $data[ $key ] ); |
|
954 | + if ('email' == $key) { |
|
955 | + $data[$key] = sanitize_email($data[$key]); |
|
956 | + } elseif ('notes' == $key) { |
|
957 | + $data[$key] = strip_tags($data[$key]); |
|
958 | 958 | } else { |
959 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
959 | + $data[$key] = sanitize_text_field($data[$key]); |
|
960 | 960 | } |
961 | 961 | break; |
962 | 962 | |
963 | 963 | case '%d': |
964 | - if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) { |
|
965 | - $data[ $key ] = $default_values[ $key ]; |
|
964 | + if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) { |
|
965 | + $data[$key] = $default_values[$key]; |
|
966 | 966 | } else { |
967 | - $data[ $key ] = absint( $data[ $key ] ); |
|
967 | + $data[$key] = absint($data[$key]); |
|
968 | 968 | } |
969 | 969 | break; |
970 | 970 | |
971 | 971 | case '%f': |
972 | 972 | // Convert what was given to a float |
973 | - $value = floatval( $data[ $key ] ); |
|
973 | + $value = floatval($data[$key]); |
|
974 | 974 | |
975 | - if ( ! is_float( $value ) ) { |
|
976 | - $data[ $key ] = $default_values[ $key ]; |
|
975 | + if ( ! is_float($value)) { |
|
976 | + $data[$key] = $default_values[$key]; |
|
977 | 977 | } else { |
978 | - $data[ $key ] = $value; |
|
978 | + $data[$key] = $value; |
|
979 | 979 | } |
980 | 980 | break; |
981 | 981 | |
982 | 982 | default: |
983 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
983 | + $data[$key] = sanitize_text_field($data[$key]); |
|
984 | 984 | break; |
985 | 985 | |
986 | 986 | } |
@@ -1000,33 +1000,33 @@ discard block |
||
1000 | 1000 | * |
1001 | 1001 | * @return bool If the email was added successfully |
1002 | 1002 | */ |
1003 | - public function add_email( $email = '', $primary = false ) { |
|
1004 | - if ( ! is_email( $email ) ) { |
|
1003 | + public function add_email($email = '', $primary = false) { |
|
1004 | + if ( ! is_email($email)) { |
|
1005 | 1005 | return false; |
1006 | 1006 | } |
1007 | - $existing = new Give_Donor( $email ); |
|
1007 | + $existing = new Give_Donor($email); |
|
1008 | 1008 | |
1009 | - if ( $existing->id > 0 ) { |
|
1009 | + if ($existing->id > 0) { |
|
1010 | 1010 | // Email address already belongs to another donor |
1011 | 1011 | return false; |
1012 | 1012 | } |
1013 | 1013 | |
1014 | - if ( email_exists( $email ) ) { |
|
1015 | - $user = get_user_by( 'email', $email ); |
|
1016 | - if ( $user->ID != $this->user_id ) { |
|
1014 | + if (email_exists($email)) { |
|
1015 | + $user = get_user_by('email', $email); |
|
1016 | + if ($user->ID != $this->user_id) { |
|
1017 | 1017 | return false; |
1018 | 1018 | } |
1019 | 1019 | } |
1020 | 1020 | |
1021 | - do_action( 'give_donor_pre_add_email', $email, $this->id, $this ); |
|
1021 | + do_action('give_donor_pre_add_email', $email, $this->id, $this); |
|
1022 | 1022 | |
1023 | 1023 | // Add is used to ensure duplicate emails are not added |
1024 | - $ret = (bool) $this->add_meta( 'additional_email', $email ); |
|
1024 | + $ret = (bool) $this->add_meta('additional_email', $email); |
|
1025 | 1025 | |
1026 | - do_action( 'give_donor_post_add_email', $email, $this->id, $this ); |
|
1026 | + do_action('give_donor_post_add_email', $email, $this->id, $this); |
|
1027 | 1027 | |
1028 | - if ( $ret && true === $primary ) { |
|
1029 | - $this->set_primary_email( $email ); |
|
1028 | + if ($ret && true === $primary) { |
|
1029 | + $this->set_primary_email($email); |
|
1030 | 1030 | } |
1031 | 1031 | |
1032 | 1032 | return $ret; |
@@ -1042,16 +1042,16 @@ discard block |
||
1042 | 1042 | * |
1043 | 1043 | * @return bool If the email was removed successfully. |
1044 | 1044 | */ |
1045 | - public function remove_email( $email = '' ) { |
|
1046 | - if ( ! is_email( $email ) ) { |
|
1045 | + public function remove_email($email = '') { |
|
1046 | + if ( ! is_email($email)) { |
|
1047 | 1047 | return false; |
1048 | 1048 | } |
1049 | 1049 | |
1050 | - do_action( 'give_donor_pre_remove_email', $email, $this->id, $this ); |
|
1050 | + do_action('give_donor_pre_remove_email', $email, $this->id, $this); |
|
1051 | 1051 | |
1052 | - $ret = (bool) $this->delete_meta( 'additional_email', $email ); |
|
1052 | + $ret = (bool) $this->delete_meta('additional_email', $email); |
|
1053 | 1053 | |
1054 | - do_action( 'give_donor_post_remove_email', $email, $this->id, $this ); |
|
1054 | + do_action('give_donor_post_remove_email', $email, $this->id, $this); |
|
1055 | 1055 | |
1056 | 1056 | return $ret; |
1057 | 1057 | } |
@@ -1068,16 +1068,16 @@ discard block |
||
1068 | 1068 | * |
1069 | 1069 | * @return bool If the email was set as primary successfully. |
1070 | 1070 | */ |
1071 | - public function set_primary_email( $new_primary_email = '' ) { |
|
1072 | - if ( ! is_email( $new_primary_email ) ) { |
|
1071 | + public function set_primary_email($new_primary_email = '') { |
|
1072 | + if ( ! is_email($new_primary_email)) { |
|
1073 | 1073 | return false; |
1074 | 1074 | } |
1075 | 1075 | |
1076 | - do_action( 'give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this ); |
|
1076 | + do_action('give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this); |
|
1077 | 1077 | |
1078 | - $existing = new Give_Donor( $new_primary_email ); |
|
1078 | + $existing = new Give_Donor($new_primary_email); |
|
1079 | 1079 | |
1080 | - if ( $existing->id > 0 && (int) $existing->id !== (int) $this->id ) { |
|
1080 | + if ($existing->id > 0 && (int) $existing->id !== (int) $this->id) { |
|
1081 | 1081 | // This email belongs to another donor. |
1082 | 1082 | return false; |
1083 | 1083 | } |
@@ -1085,21 +1085,21 @@ discard block |
||
1085 | 1085 | $old_email = $this->email; |
1086 | 1086 | |
1087 | 1087 | // Update donor record with new email. |
1088 | - $update = $this->update( array( 'email' => $new_primary_email ) ); |
|
1088 | + $update = $this->update(array('email' => $new_primary_email)); |
|
1089 | 1089 | |
1090 | 1090 | // Remove new primary from list of additional emails. |
1091 | - $remove = $this->remove_email( $new_primary_email ); |
|
1091 | + $remove = $this->remove_email($new_primary_email); |
|
1092 | 1092 | |
1093 | 1093 | // Add old email to additional emails list. |
1094 | - $add = $this->add_email( $old_email ); |
|
1094 | + $add = $this->add_email($old_email); |
|
1095 | 1095 | |
1096 | 1096 | $ret = $update && $remove && $add; |
1097 | 1097 | |
1098 | - if ( $ret ) { |
|
1098 | + if ($ret) { |
|
1099 | 1099 | $this->email = $new_primary_email; |
1100 | 1100 | } |
1101 | 1101 | |
1102 | - do_action( 'give_donor_post_set_primary_email', $new_primary_email, $this->id, $this ); |
|
1102 | + do_action('give_donor_post_set_primary_email', $new_primary_email, $this->id, $this); |
|
1103 | 1103 | |
1104 | 1104 | return $ret; |
1105 | 1105 | } |
@@ -902,7 +902,7 @@ discard block |
||
902 | 902 | * @access public |
903 | 903 | * |
904 | 904 | * @param string $meta_key Metadata key. Default is empty. |
905 | - * @param mixed $meta_value Metadata value. |
|
905 | + * @param integer $meta_value Metadata value. |
|
906 | 906 | * @param mixed $prev_value Optional. Previous value to check before removing. Default is empty. |
907 | 907 | * |
908 | 908 | * @return bool False on failure, true if success. |
@@ -918,7 +918,7 @@ discard block |
||
918 | 918 | * @access public |
919 | 919 | * |
920 | 920 | * @param string $meta_key Metadata name. Default is empty. |
921 | - * @param mixed $meta_value Optional. Metadata value. Default is empty. |
|
921 | + * @param string $meta_value Optional. Metadata value. Default is empty. |
|
922 | 922 | * |
923 | 923 | * @return bool False for failure. True for success. |
924 | 924 | */ |
@@ -165,16 +165,16 @@ discard block |
||
165 | 165 | * |
166 | 166 | * @since 1.0 |
167 | 167 | * @access public |
168 | - * |
|
169 | - * @param int $column Column ID. |
|
170 | - * @param string $column_where Column name. |
|
171 | - * @param string $column_value Column value. |
|
172 | - * |
|
168 | + * |
|
169 | + * @param int $column Column ID. |
|
170 | + * @param string $column_where Column name. |
|
171 | + * @param string $column_value Column value. |
|
172 | + * |
|
173 | 173 | * @return string |
174 | 174 | */ |
175 | 175 | public function get_column_by( $column, $column_where, $column_value ) { |
176 | - /* @var WPDB $wpdb */ |
|
177 | - global $wpdb; |
|
176 | + /* @var WPDB $wpdb */ |
|
177 | + global $wpdb; |
|
178 | 178 | |
179 | 179 | // Bailout. |
180 | 180 | if ( empty( $column ) || empty( $column_where ) || empty( $column_value ) ) { |
@@ -191,15 +191,15 @@ discard block |
||
191 | 191 | * |
192 | 192 | * @since 1.0 |
193 | 193 | * @access public |
194 | - * |
|
195 | - * @param array $data |
|
196 | - * @param string $type |
|
197 | - * |
|
194 | + * |
|
195 | + * @param array $data |
|
196 | + * @param string $type |
|
197 | + * |
|
198 | 198 | * @return int |
199 | 199 | */ |
200 | 200 | public function insert( $data, $type = '' ) { |
201 | - /* @var WPDB $wpdb */ |
|
202 | - global $wpdb; |
|
201 | + /* @var WPDB $wpdb */ |
|
202 | + global $wpdb; |
|
203 | 203 | |
204 | 204 | // Set default values. |
205 | 205 | $data = wp_parse_args( $data, $this->get_column_defaults() ); |
@@ -246,16 +246,16 @@ discard block |
||
246 | 246 | * |
247 | 247 | * @since 1.0 |
248 | 248 | * @access public |
249 | - * |
|
250 | - * @param int $row_id Column ID |
|
251 | - * @param array $data |
|
252 | - * @param string $where Column value |
|
253 | - * |
|
249 | + * |
|
250 | + * @param int $row_id Column ID |
|
251 | + * @param array $data |
|
252 | + * @param string $where Column value |
|
253 | + * |
|
254 | 254 | * @return bool |
255 | 255 | */ |
256 | 256 | public function update( $row_id, $data = array(), $where = '' ) { |
257 | - /* @var WPDB $wpdb */ |
|
258 | - global $wpdb; |
|
257 | + /* @var WPDB $wpdb */ |
|
258 | + global $wpdb; |
|
259 | 259 | |
260 | 260 | // Row ID must be positive integer |
261 | 261 | $row_id = absint( $row_id ); |
@@ -293,14 +293,14 @@ discard block |
||
293 | 293 | * |
294 | 294 | * @since 1.0 |
295 | 295 | * @access public |
296 | - * |
|
297 | - * @param int $row_id Column ID. |
|
298 | - * |
|
296 | + * |
|
297 | + * @param int $row_id Column ID. |
|
298 | + * |
|
299 | 299 | * @return bool |
300 | 300 | */ |
301 | 301 | public function delete( $row_id = 0 ) { |
302 | - /* @var WPDB $wpdb */ |
|
303 | - global $wpdb; |
|
302 | + /* @var WPDB $wpdb */ |
|
303 | + global $wpdb; |
|
304 | 304 | |
305 | 305 | // Row ID must be positive integer |
306 | 306 | $row_id = absint( $row_id ); |
@@ -321,13 +321,13 @@ discard block |
||
321 | 321 | * |
322 | 322 | * @since 1.3.2 |
323 | 323 | * @access public |
324 | - * |
|
324 | + * |
|
325 | 325 | * @param string $table The table name. |
326 | - * |
|
326 | + * |
|
327 | 327 | * @return bool If the table name exists. |
328 | 328 | */ |
329 | 329 | public function table_exists( $table ) { |
330 | - /* @var WPDB $wpdb */ |
|
330 | + /* @var WPDB $wpdb */ |
|
331 | 331 | global $wpdb; |
332 | 332 | |
333 | 333 | $table = sanitize_text_field( $table ); |
@@ -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 | |
@@ -98,16 +98,16 @@ discard block |
||
98 | 98 | * |
99 | 99 | * @return object |
100 | 100 | */ |
101 | - public function get( $row_id ) { |
|
101 | + public function get($row_id) { |
|
102 | 102 | /* @var WPDB $wpdb */ |
103 | 103 | global $wpdb; |
104 | 104 | |
105 | 105 | // Bailout. |
106 | - if ( empty( $row_id ) ) { |
|
106 | + if (empty($row_id)) { |
|
107 | 107 | return null; |
108 | 108 | } |
109 | 109 | |
110 | - return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
110 | + return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id)); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -121,18 +121,18 @@ discard block |
||
121 | 121 | * |
122 | 122 | * @return object |
123 | 123 | */ |
124 | - public function get_by( $column, $row_id ) { |
|
124 | + public function get_by($column, $row_id) { |
|
125 | 125 | /* @var WPDB $wpdb */ |
126 | 126 | global $wpdb; |
127 | 127 | |
128 | 128 | // Bailout. |
129 | - if ( empty( $column ) || empty( $row_id ) ) { |
|
129 | + if (empty($column) || empty($row_id)) { |
|
130 | 130 | return null; |
131 | 131 | } |
132 | 132 | |
133 | - $column = esc_sql( $column ); |
|
133 | + $column = esc_sql($column); |
|
134 | 134 | |
135 | - return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) ); |
|
135 | + return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id)); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -146,18 +146,18 @@ discard block |
||
146 | 146 | * |
147 | 147 | * @return string Column value. |
148 | 148 | */ |
149 | - public function get_column( $column, $row_id ) { |
|
149 | + public function get_column($column, $row_id) { |
|
150 | 150 | /* @var WPDB $wpdb */ |
151 | 151 | global $wpdb; |
152 | 152 | |
153 | 153 | // Bailout. |
154 | - if ( empty( $column ) || empty( $row_id ) ) { |
|
154 | + if (empty($column) || empty($row_id)) { |
|
155 | 155 | return null; |
156 | 156 | } |
157 | 157 | |
158 | - $column = esc_sql( $column ); |
|
158 | + $column = esc_sql($column); |
|
159 | 159 | |
160 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
160 | + return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id)); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -172,18 +172,18 @@ discard block |
||
172 | 172 | * |
173 | 173 | * @return string |
174 | 174 | */ |
175 | - public function get_column_by( $column, $column_where, $column_value ) { |
|
175 | + public function get_column_by($column, $column_where, $column_value) { |
|
176 | 176 | /* @var WPDB $wpdb */ |
177 | 177 | global $wpdb; |
178 | 178 | |
179 | 179 | // Bailout. |
180 | - if ( empty( $column ) || empty( $column_where ) || empty( $column_value ) ) { |
|
180 | + if (empty($column) || empty($column_where) || empty($column_value)) { |
|
181 | 181 | return null; |
182 | 182 | } |
183 | 183 | |
184 | - $column_where = esc_sql( $column_where ); |
|
185 | - $column = esc_sql( $column ); |
|
186 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value ) ); |
|
184 | + $column_where = esc_sql($column_where); |
|
185 | + $column = esc_sql($column); |
|
186 | + return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value)); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | /** |
@@ -197,12 +197,12 @@ discard block |
||
197 | 197 | * |
198 | 198 | * @return int |
199 | 199 | */ |
200 | - public function insert( $data, $type = '' ) { |
|
200 | + public function insert($data, $type = '') { |
|
201 | 201 | /* @var WPDB $wpdb */ |
202 | 202 | global $wpdb; |
203 | 203 | |
204 | 204 | // Set default values. |
205 | - $data = wp_parse_args( $data, $this->get_column_defaults() ); |
|
205 | + $data = wp_parse_args($data, $this->get_column_defaults()); |
|
206 | 206 | |
207 | 207 | /** |
208 | 208 | * Fires before inserting data to the database. |
@@ -211,22 +211,22 @@ discard block |
||
211 | 211 | * |
212 | 212 | * @param array $data |
213 | 213 | */ |
214 | - do_action( "give_pre_insert_{$type}", $data ); |
|
214 | + do_action("give_pre_insert_{$type}", $data); |
|
215 | 215 | |
216 | 216 | // Initialise column format array |
217 | 217 | $column_formats = $this->get_columns(); |
218 | 218 | |
219 | 219 | // Force fields to lower case |
220 | - $data = array_change_key_case( $data ); |
|
220 | + $data = array_change_key_case($data); |
|
221 | 221 | |
222 | 222 | // White list columns |
223 | - $data = array_intersect_key( $data, $column_formats ); |
|
223 | + $data = array_intersect_key($data, $column_formats); |
|
224 | 224 | |
225 | 225 | // Reorder $column_formats to match the order of columns given in $data |
226 | - $data_keys = array_keys( $data ); |
|
227 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
226 | + $data_keys = array_keys($data); |
|
227 | + $column_formats = array_merge(array_flip($data_keys), $column_formats); |
|
228 | 228 | |
229 | - $wpdb->insert( $this->table_name, $data, $column_formats ); |
|
229 | + $wpdb->insert($this->table_name, $data, $column_formats); |
|
230 | 230 | |
231 | 231 | /** |
232 | 232 | * Fires after inserting data to the database. |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | * @param int $insert_id |
237 | 237 | * @param array $data |
238 | 238 | */ |
239 | - do_action( "give_post_insert_{$type}", $wpdb->insert_id, $data ); |
|
239 | + do_action("give_post_insert_{$type}", $wpdb->insert_id, $data); |
|
240 | 240 | |
241 | 241 | return $wpdb->insert_id; |
242 | 242 | } |
@@ -253,18 +253,18 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @return bool |
255 | 255 | */ |
256 | - public function update( $row_id, $data = array(), $where = '' ) { |
|
256 | + public function update($row_id, $data = array(), $where = '') { |
|
257 | 257 | /* @var WPDB $wpdb */ |
258 | 258 | global $wpdb; |
259 | 259 | |
260 | 260 | // Row ID must be positive integer |
261 | - $row_id = absint( $row_id ); |
|
261 | + $row_id = absint($row_id); |
|
262 | 262 | |
263 | - if ( empty( $row_id ) ) { |
|
263 | + if (empty($row_id)) { |
|
264 | 264 | return false; |
265 | 265 | } |
266 | 266 | |
267 | - if ( empty( $where ) ) { |
|
267 | + if (empty($where)) { |
|
268 | 268 | $where = $this->primary_key; |
269 | 269 | } |
270 | 270 | |
@@ -272,16 +272,16 @@ discard block |
||
272 | 272 | $column_formats = $this->get_columns(); |
273 | 273 | |
274 | 274 | // Force fields to lower case |
275 | - $data = array_change_key_case( $data ); |
|
275 | + $data = array_change_key_case($data); |
|
276 | 276 | |
277 | 277 | // White list columns |
278 | - $data = array_intersect_key( $data, $column_formats ); |
|
278 | + $data = array_intersect_key($data, $column_formats); |
|
279 | 279 | |
280 | 280 | // Reorder $column_formats to match the order of columns given in $data |
281 | - $data_keys = array_keys( $data ); |
|
282 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
281 | + $data_keys = array_keys($data); |
|
282 | + $column_formats = array_merge(array_flip($data_keys), $column_formats); |
|
283 | 283 | |
284 | - if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) { |
|
284 | + if (false === $wpdb->update($this->table_name, $data, array($where => $row_id), $column_formats)) { |
|
285 | 285 | return false; |
286 | 286 | } |
287 | 287 | |
@@ -298,18 +298,18 @@ discard block |
||
298 | 298 | * |
299 | 299 | * @return bool |
300 | 300 | */ |
301 | - public function delete( $row_id = 0 ) { |
|
301 | + public function delete($row_id = 0) { |
|
302 | 302 | /* @var WPDB $wpdb */ |
303 | 303 | global $wpdb; |
304 | 304 | |
305 | 305 | // Row ID must be positive integer |
306 | - $row_id = absint( $row_id ); |
|
306 | + $row_id = absint($row_id); |
|
307 | 307 | |
308 | - if ( empty( $row_id ) ) { |
|
308 | + if (empty($row_id)) { |
|
309 | 309 | return false; |
310 | 310 | } |
311 | 311 | |
312 | - if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) { |
|
312 | + if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id))) { |
|
313 | 313 | return false; |
314 | 314 | } |
315 | 315 | |
@@ -326,13 +326,13 @@ discard block |
||
326 | 326 | * |
327 | 327 | * @return bool If the table name exists. |
328 | 328 | */ |
329 | - public function table_exists( $table ) { |
|
329 | + public function table_exists($table) { |
|
330 | 330 | /* @var WPDB $wpdb */ |
331 | 331 | global $wpdb; |
332 | 332 | |
333 | - $table = sanitize_text_field( $table ); |
|
333 | + $table = sanitize_text_field($table); |
|
334 | 334 | |
335 | - return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table; |
|
335 | + return $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE '%s'", $table)) === $table; |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | /** |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | * @return bool Returns if the customers table was installed and upgrade routine run. |
345 | 345 | */ |
346 | 346 | public function installed() { |
347 | - return $this->table_exists( $this->table_name ); |
|
347 | + return $this->table_exists($this->table_name); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | /** |
@@ -354,8 +354,8 @@ discard block |
||
354 | 354 | * @access public |
355 | 355 | */ |
356 | 356 | public function register_table() { |
357 | - $current_version = get_option( $this->table_name . '_db_version' ); |
|
358 | - if ( ! $current_version || version_compare( $current_version, $this->version, '<' ) ) { |
|
357 | + $current_version = get_option($this->table_name.'_db_version'); |
|
358 | + if ( ! $current_version || version_compare($current_version, $this->version, '<')) { |
|
359 | 359 | $this->create_table(); |
360 | 360 | } |
361 | 361 | } |
@@ -366,5 +366,5 @@ discard block |
||
366 | 366 | * @since 1.8.9 |
367 | 367 | * @access public |
368 | 368 | */ |
369 | - public function create_table(){} |
|
369 | + public function create_table() {} |
|
370 | 370 | } |
@@ -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 | |
@@ -74,57 +74,57 @@ discard block |
||
74 | 74 | public function __construct() { |
75 | 75 | |
76 | 76 | $this->use_php_sessions = $this->use_php_sessions(); |
77 | - $this->exp_option = give_get_option( 'session_lifetime' ); |
|
77 | + $this->exp_option = give_get_option('session_lifetime'); |
|
78 | 78 | |
79 | 79 | // PHP Sessions. |
80 | - if ( $this->use_php_sessions ) { |
|
80 | + if ($this->use_php_sessions) { |
|
81 | 81 | |
82 | - if ( is_multisite() ) { |
|
82 | + if (is_multisite()) { |
|
83 | 83 | |
84 | - $this->prefix = '_' . get_current_blog_id(); |
|
84 | + $this->prefix = '_'.get_current_blog_id(); |
|
85 | 85 | |
86 | 86 | } |
87 | 87 | |
88 | - add_action( 'init', array( $this, 'maybe_start_session' ), - 2 ); |
|
88 | + add_action('init', array($this, 'maybe_start_session'), - 2); |
|
89 | 89 | |
90 | 90 | } else { |
91 | 91 | |
92 | - if ( ! $this->should_start_session() ) { |
|
92 | + if ( ! $this->should_start_session()) { |
|
93 | 93 | return; |
94 | 94 | } |
95 | 95 | |
96 | 96 | // Use WP_Session. |
97 | - if ( ! defined( 'WP_SESSION_COOKIE' ) ) { |
|
98 | - define( 'WP_SESSION_COOKIE', 'give_wp_session' ); |
|
97 | + if ( ! defined('WP_SESSION_COOKIE')) { |
|
98 | + define('WP_SESSION_COOKIE', 'give_wp_session'); |
|
99 | 99 | } |
100 | 100 | |
101 | - if ( ! class_exists( 'Recursive_ArrayAccess' ) ) { |
|
102 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-recursive-arrayaccess.php'; |
|
101 | + if ( ! class_exists('Recursive_ArrayAccess')) { |
|
102 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-recursive-arrayaccess.php'; |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | // Include utilities class |
106 | - if ( ! class_exists( 'WP_Session_Utils' ) ) { |
|
107 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-wp-session-utils.php'; |
|
106 | + if ( ! class_exists('WP_Session_Utils')) { |
|
107 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-wp-session-utils.php'; |
|
108 | 108 | } |
109 | - if ( ! class_exists( 'WP_Session' ) ) { |
|
110 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-wp-session.php'; |
|
111 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/wp-session.php'; |
|
109 | + if ( ! class_exists('WP_Session')) { |
|
110 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-wp-session.php'; |
|
111 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/wp-session.php'; |
|
112 | 112 | } |
113 | 113 | |
114 | - add_filter( 'wp_session_expiration_variant', array( $this, 'set_expiration_variant_time' ), 99999 ); |
|
115 | - add_filter( 'wp_session_expiration', array( $this, 'set_expiration_time' ), 99999 ); |
|
114 | + add_filter('wp_session_expiration_variant', array($this, 'set_expiration_variant_time'), 99999); |
|
115 | + add_filter('wp_session_expiration', array($this, 'set_expiration_time'), 99999); |
|
116 | 116 | |
117 | 117 | } |
118 | 118 | |
119 | 119 | // Init Session. |
120 | - if ( empty( $this->session ) && ! $this->use_php_sessions ) { |
|
121 | - add_action( 'plugins_loaded', array( $this, 'init' ), 9999 ); |
|
120 | + if (empty($this->session) && ! $this->use_php_sessions) { |
|
121 | + add_action('plugins_loaded', array($this, 'init'), 9999); |
|
122 | 122 | } else { |
123 | - add_action( 'init', array( $this, 'init' ), - 1 ); |
|
123 | + add_action('init', array($this, 'init'), - 1); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | // Set cookie on Donation Completion page. |
127 | - add_action( 'give_pre_process_donation', array( $this, 'set_session_cookies' ) ); |
|
127 | + add_action('give_pre_process_donation', array($this, 'set_session_cookies')); |
|
128 | 128 | |
129 | 129 | } |
130 | 130 | |
@@ -140,8 +140,8 @@ discard block |
||
140 | 140 | */ |
141 | 141 | public function init() { |
142 | 142 | |
143 | - if ( $this->use_php_sessions ) { |
|
144 | - $this->session = isset( $_SESSION[ 'give' . $this->prefix ] ) && is_array( $_SESSION[ 'give' . $this->prefix ] ) ? $_SESSION[ 'give' . $this->prefix ] : array(); |
|
143 | + if ($this->use_php_sessions) { |
|
144 | + $this->session = isset($_SESSION['give'.$this->prefix]) && is_array($_SESSION['give'.$this->prefix]) ? $_SESSION['give'.$this->prefix] : array(); |
|
145 | 145 | } else { |
146 | 146 | $this->session = WP_Session::get_instance(); |
147 | 147 | } |
@@ -176,37 +176,37 @@ discard block |
||
176 | 176 | * |
177 | 177 | * @return string|array Session variable. |
178 | 178 | */ |
179 | - public function get( $key ) { |
|
180 | - $key = sanitize_key( $key ); |
|
179 | + public function get($key) { |
|
180 | + $key = sanitize_key($key); |
|
181 | 181 | $return = false; |
182 | 182 | |
183 | - if ( isset( $this->session[ $key ] ) && ! empty( $this->session[ $key ] ) ) { |
|
183 | + if (isset($this->session[$key]) && ! empty($this->session[$key])) { |
|
184 | 184 | |
185 | - preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $this->session[ $key ], $matches ); |
|
186 | - if ( ! empty( $matches ) ) { |
|
187 | - $this->set( $key, null ); |
|
185 | + preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $this->session[$key], $matches); |
|
186 | + if ( ! empty($matches)) { |
|
187 | + $this->set($key, null); |
|
188 | 188 | |
189 | 189 | return false; |
190 | 190 | } |
191 | 191 | |
192 | - if ( is_numeric( $this->session[ $key ] ) ) { |
|
193 | - $return = $this->session[ $key ]; |
|
192 | + if (is_numeric($this->session[$key])) { |
|
193 | + $return = $this->session[$key]; |
|
194 | 194 | } else { |
195 | 195 | |
196 | - $maybe_json = json_decode( $this->session[ $key ] ); |
|
196 | + $maybe_json = json_decode($this->session[$key]); |
|
197 | 197 | |
198 | 198 | // Since json_last_error is PHP 5.3+, we have to rely on a `null` value for failing to parse JSON. |
199 | - if ( is_null( $maybe_json ) ) { |
|
200 | - $is_serialized = is_serialized( $this->session[ $key ] ); |
|
201 | - if ( $is_serialized ) { |
|
202 | - $value = @unserialize( $this->session[ $key ] ); |
|
203 | - $this->set( $key, (array) $value ); |
|
199 | + if (is_null($maybe_json)) { |
|
200 | + $is_serialized = is_serialized($this->session[$key]); |
|
201 | + if ($is_serialized) { |
|
202 | + $value = @unserialize($this->session[$key]); |
|
203 | + $this->set($key, (array) $value); |
|
204 | 204 | $return = $value; |
205 | 205 | } else { |
206 | - $return = $this->session[ $key ]; |
|
206 | + $return = $this->session[$key]; |
|
207 | 207 | } |
208 | 208 | } else { |
209 | - $return = json_decode( $this->session[ $key ], true ); |
|
209 | + $return = json_decode($this->session[$key], true); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | } |
@@ -229,21 +229,21 @@ discard block |
||
229 | 229 | * |
230 | 230 | * @return string Session variable. |
231 | 231 | */ |
232 | - public function set( $key, $value ) { |
|
232 | + public function set($key, $value) { |
|
233 | 233 | |
234 | - $key = sanitize_key( $key ); |
|
234 | + $key = sanitize_key($key); |
|
235 | 235 | |
236 | - if ( is_array( $value ) ) { |
|
237 | - $this->session[ $key ] = wp_json_encode( $value ); |
|
236 | + if (is_array($value)) { |
|
237 | + $this->session[$key] = wp_json_encode($value); |
|
238 | 238 | } else { |
239 | - $this->session[ $key ] = esc_attr( $value ); |
|
239 | + $this->session[$key] = esc_attr($value); |
|
240 | 240 | } |
241 | 241 | |
242 | - if ( $this->use_php_sessions ) { |
|
243 | - $_SESSION[ 'give' . $this->prefix ] = $this->session; |
|
242 | + if ($this->use_php_sessions) { |
|
243 | + $_SESSION['give'.$this->prefix] = $this->session; |
|
244 | 244 | } |
245 | 245 | |
246 | - return $this->session[ $key ]; |
|
246 | + return $this->session[$key]; |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
@@ -258,10 +258,10 @@ discard block |
||
258 | 258 | * @hook |
259 | 259 | */ |
260 | 260 | public function set_session_cookies() { |
261 | - if ( ! headers_sent() ) { |
|
262 | - $lifetime = current_time( 'timestamp' ) + $this->set_expiration_time(); |
|
263 | - @setcookie( session_name(), session_id(), $lifetime, COOKIEPATH, COOKIE_DOMAIN, false ); |
|
264 | - @setcookie( session_name() . '_expiration', $lifetime, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false ); |
|
261 | + if ( ! headers_sent()) { |
|
262 | + $lifetime = current_time('timestamp') + $this->set_expiration_time(); |
|
263 | + @setcookie(session_name(), session_id(), $lifetime, COOKIEPATH, COOKIE_DOMAIN, false); |
|
264 | + @setcookie(session_name().'_expiration', $lifetime, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false); |
|
265 | 265 | } |
266 | 266 | } |
267 | 267 | |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | */ |
278 | 278 | public function set_expiration_variant_time() { |
279 | 279 | |
280 | - return ( ! empty( $this->exp_option ) ? ( intval( $this->exp_option ) - 3600 ) : 30 * 60 * 23 ); |
|
280 | + return ( ! empty($this->exp_option) ? (intval($this->exp_option) - 3600) : 30 * 60 * 23); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | /** |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | */ |
293 | 293 | public function set_expiration_time() { |
294 | 294 | |
295 | - return ( ! empty( $this->exp_option ) ? intval( $this->exp_option ) : 30 * 60 * 24 ); |
|
295 | + return ( ! empty($this->exp_option) ? intval($this->exp_option) : 30 * 60 * 24); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | /** |
@@ -310,21 +310,21 @@ discard block |
||
310 | 310 | $ret = false; |
311 | 311 | |
312 | 312 | // If the database variable is already set, no need to run auto detection. |
313 | - $give_use_php_sessions = (bool) get_option( 'give_use_php_sessions' ); |
|
313 | + $give_use_php_sessions = (bool) get_option('give_use_php_sessions'); |
|
314 | 314 | |
315 | - if ( ! $give_use_php_sessions ) { |
|
315 | + if ( ! $give_use_php_sessions) { |
|
316 | 316 | |
317 | 317 | // Attempt to detect if the server supports PHP sessions. |
318 | - if ( function_exists( 'session_start' ) && ! ini_get( 'safe_mode' ) ) { |
|
318 | + if (function_exists('session_start') && ! ini_get('safe_mode')) { |
|
319 | 319 | |
320 | - $this->set( 'give_use_php_sessions', 1 ); |
|
320 | + $this->set('give_use_php_sessions', 1); |
|
321 | 321 | |
322 | - if ( $this->get( 'give_use_php_sessions' ) ) { |
|
322 | + if ($this->get('give_use_php_sessions')) { |
|
323 | 323 | |
324 | 324 | $ret = true; |
325 | 325 | |
326 | 326 | // Set the database option. |
327 | - update_option( 'give_use_php_sessions', true ); |
|
327 | + update_option('give_use_php_sessions', true); |
|
328 | 328 | |
329 | 329 | } |
330 | 330 | } |
@@ -334,13 +334,13 @@ discard block |
||
334 | 334 | } |
335 | 335 | |
336 | 336 | // Enable or disable PHP Sessions based on the GIVE_USE_PHP_SESSIONS constant. |
337 | - if ( defined( 'GIVE_USE_PHP_SESSIONS' ) && GIVE_USE_PHP_SESSIONS ) { |
|
337 | + if (defined('GIVE_USE_PHP_SESSIONS') && GIVE_USE_PHP_SESSIONS) { |
|
338 | 338 | $ret = true; |
339 | - } elseif ( defined( 'GIVE_USE_PHP_SESSIONS' ) && ! GIVE_USE_PHP_SESSIONS ) { |
|
339 | + } elseif (defined('GIVE_USE_PHP_SESSIONS') && ! GIVE_USE_PHP_SESSIONS) { |
|
340 | 340 | $ret = false; |
341 | 341 | } |
342 | 342 | |
343 | - return (bool) apply_filters( 'give_use_php_sessions', $ret ); |
|
343 | + return (bool) apply_filters('give_use_php_sessions', $ret); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | /** |
@@ -357,9 +357,9 @@ discard block |
||
357 | 357 | |
358 | 358 | $start_session = true; |
359 | 359 | |
360 | - if ( ! empty( $_SERVER['REQUEST_URI'] ) ) { |
|
360 | + if ( ! empty($_SERVER['REQUEST_URI'])) { |
|
361 | 361 | |
362 | - $blacklist = apply_filters( 'give_session_start_uri_blacklist', array( |
|
362 | + $blacklist = apply_filters('give_session_start_uri_blacklist', array( |
|
363 | 363 | 'feed', |
364 | 364 | 'feed', |
365 | 365 | 'feed/rss', |
@@ -367,21 +367,21 @@ discard block |
||
367 | 367 | 'feed/rdf', |
368 | 368 | 'feed/atom', |
369 | 369 | 'comments/feed/', |
370 | - ) ); |
|
371 | - $uri = ltrim( $_SERVER['REQUEST_URI'], '/' ); |
|
372 | - $uri = untrailingslashit( $uri ); |
|
373 | - if ( in_array( $uri, $blacklist ) ) { |
|
370 | + )); |
|
371 | + $uri = ltrim($_SERVER['REQUEST_URI'], '/'); |
|
372 | + $uri = untrailingslashit($uri); |
|
373 | + if (in_array($uri, $blacklist)) { |
|
374 | 374 | $start_session = false; |
375 | 375 | } |
376 | - if ( false !== strpos( $uri, 'feed=' ) ) { |
|
376 | + if (false !== strpos($uri, 'feed=')) { |
|
377 | 377 | $start_session = false; |
378 | 378 | } |
379 | - if ( is_admin() ) { |
|
379 | + if (is_admin()) { |
|
380 | 380 | $start_session = false; |
381 | 381 | } |
382 | 382 | } |
383 | 383 | |
384 | - return apply_filters( 'give_start_session', $start_session ); |
|
384 | + return apply_filters('give_start_session', $start_session); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | /** |
@@ -397,11 +397,11 @@ discard block |
||
397 | 397 | */ |
398 | 398 | public function maybe_start_session() { |
399 | 399 | |
400 | - if ( ! $this->should_start_session() ) { |
|
400 | + if ( ! $this->should_start_session()) { |
|
401 | 401 | return; |
402 | 402 | } |
403 | 403 | |
404 | - if ( ! session_id() && ! headers_sent() ) { |
|
404 | + if ( ! session_id() && ! headers_sent()) { |
|
405 | 405 | session_start(); |
406 | 406 | } |
407 | 407 | |
@@ -420,9 +420,9 @@ discard block |
||
420 | 420 | |
421 | 421 | $expiration = false; |
422 | 422 | |
423 | - if ( session_id() && isset( $_COOKIE[ session_name() . '_expiration' ] ) ) { |
|
423 | + if (session_id() && isset($_COOKIE[session_name().'_expiration'])) { |
|
424 | 424 | |
425 | - $expiration = date( 'D, d M Y h:i:s', intval( $_COOKIE[ session_name() . '_expiration' ] ) ); |
|
425 | + $expiration = date('D, d M Y h:i:s', intval($_COOKIE[session_name().'_expiration'])); |
|
426 | 426 | |
427 | 427 | } |
428 | 428 |
@@ -70,24 +70,24 @@ discard block |
||
70 | 70 | * |
71 | 71 | * @param array $args |
72 | 72 | */ |
73 | - public function register( $args ) { |
|
73 | + public function register($args) { |
|
74 | 74 | $args_default = array( |
75 | 75 | 'id' => '', |
76 | 76 | 'version' => '', |
77 | 77 | 'callback' => '', |
78 | 78 | ); |
79 | 79 | |
80 | - $args = wp_parse_args( $args, $args_default ); |
|
80 | + $args = wp_parse_args($args, $args_default); |
|
81 | 81 | |
82 | 82 | // You can only register database upgrade. |
83 | 83 | $args['type'] = 'database'; |
84 | 84 | |
85 | 85 | // Bailout. |
86 | - if ( empty( $args['id'] ) || empty( $args['version'] ) || empty( $args['callback'] ) || ! is_callable( $args['callback'] ) ) { |
|
86 | + if (empty($args['id']) || empty($args['version']) || empty($args['callback']) || ! is_callable($args['callback'])) { |
|
87 | 87 | return; |
88 | 88 | } |
89 | 89 | |
90 | - $this->updates[ $args['type'] ][] = $args; |
|
90 | + $this->updates[$args['type']][] = $args; |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | |
@@ -102,32 +102,32 @@ discard block |
||
102 | 102 | * |
103 | 103 | * @return array |
104 | 104 | */ |
105 | - public function get_updates( $update_type = '', $status = 'all' ) { |
|
105 | + public function get_updates($update_type = '', $status = 'all') { |
|
106 | 106 | // return all updates. |
107 | - if ( empty( $update_type ) ) { |
|
107 | + if (empty($update_type)) { |
|
108 | 108 | return $this->updates; |
109 | 109 | } |
110 | 110 | |
111 | 111 | // Get specific update. |
112 | - $updates = ! empty( $this->updates[ $update_type ] ) ? $this->updates[ $update_type ] : array(); |
|
112 | + $updates = ! empty($this->updates[$update_type]) ? $this->updates[$update_type] : array(); |
|
113 | 113 | |
114 | 114 | // Bailout. |
115 | - if ( empty( $updates ) ) { |
|
115 | + if (empty($updates)) { |
|
116 | 116 | return $updates; |
117 | 117 | } |
118 | 118 | |
119 | - switch ( $status ) { |
|
119 | + switch ($status) { |
|
120 | 120 | case 'new': |
121 | 121 | // Remove already completed updates. |
122 | 122 | $completed_updates = give_get_completed_upgrades(); |
123 | 123 | |
124 | - if ( ! empty( $completed_updates ) ) { |
|
125 | - foreach ( $updates as $index => $update ) { |
|
126 | - if ( in_array( $update['id'], $completed_updates ) ) { |
|
127 | - unset( $updates[ $index ] ); |
|
124 | + if ( ! empty($completed_updates)) { |
|
125 | + foreach ($updates as $index => $update) { |
|
126 | + if (in_array($update['id'], $completed_updates)) { |
|
127 | + unset($updates[$index]); |
|
128 | 128 | } |
129 | 129 | } |
130 | - $updates = array_values( $updates ); |
|
130 | + $updates = array_values($updates); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | break; |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * @return static |
145 | 145 | */ |
146 | 146 | static function get_instance() { |
147 | - if ( is_null( self::$instance ) ) { |
|
147 | + if (is_null(self::$instance)) { |
|
148 | 148 | self::$instance = new self(); |
149 | 149 | } |
150 | 150 | |
@@ -162,16 +162,16 @@ discard block |
||
162 | 162 | /** |
163 | 163 | * Setup hooks. |
164 | 164 | */ |
165 | - add_action( 'init', array( $this, '__register_upgrade' ), 9999 ); |
|
166 | - add_action( 'admin_init', array( $this, '__change_donations_label' ), 9999 ); |
|
167 | - add_action( 'admin_menu', array( $this, '__register_menu' ), 9999 ); |
|
168 | - add_action( 'give_set_upgrade_completed', array( $this, '__flush_resume_updates' ), 9999 ); |
|
169 | - add_action( 'wp_ajax_give_do_ajax_updates', array( $this, '__give_ajax_updates' ) ); |
|
165 | + add_action('init', array($this, '__register_upgrade'), 9999); |
|
166 | + add_action('admin_init', array($this, '__change_donations_label'), 9999); |
|
167 | + add_action('admin_menu', array($this, '__register_menu'), 9999); |
|
168 | + add_action('give_set_upgrade_completed', array($this, '__flush_resume_updates'), 9999); |
|
169 | + add_action('wp_ajax_give_do_ajax_updates', array($this, '__give_ajax_updates')); |
|
170 | 170 | |
171 | 171 | /** |
172 | 172 | * Load file |
173 | 173 | */ |
174 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
174 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -184,12 +184,12 @@ discard block |
||
184 | 184 | $addons = give_get_plugins(); |
185 | 185 | $plugin_updates = get_plugin_updates(); |
186 | 186 | |
187 | - foreach ( $addons as $key => $info ) { |
|
188 | - if ( 'active' != $info['Status'] || 'add-on' != $info['Type'] || empty( $plugin_updates[ $key ] ) ) { |
|
187 | + foreach ($addons as $key => $info) { |
|
188 | + if ('active' != $info['Status'] || 'add-on' != $info['Type'] || empty($plugin_updates[$key])) { |
|
189 | 189 | continue; |
190 | 190 | } |
191 | 191 | |
192 | - $this->updates['plugin'][] = array_merge( $info, (array) $plugin_updates[ $key ] ); |
|
192 | + $this->updates['plugin'][] = array_merge($info, (array) $plugin_updates[$key]); |
|
193 | 193 | } |
194 | 194 | } |
195 | 195 | |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | * @access public |
202 | 202 | */ |
203 | 203 | public function __register_upgrade() { |
204 | - if ( ! is_admin() ) { |
|
204 | + if ( ! is_admin()) { |
|
205 | 205 | return; |
206 | 206 | } |
207 | 207 | |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | * |
211 | 211 | * @since 1.8.12 |
212 | 212 | */ |
213 | - do_action( 'give_register_updates', $this ); |
|
213 | + do_action('give_register_updates', $this); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | /** |
@@ -224,17 +224,17 @@ discard block |
||
224 | 224 | global $submenu; |
225 | 225 | |
226 | 226 | // Bailout. |
227 | - if ( empty( $menu ) || ! $this->get_update_count() ) { |
|
227 | + if (empty($menu) || ! $this->get_update_count()) { |
|
228 | 228 | return; |
229 | 229 | } |
230 | 230 | |
231 | - foreach ( $menu as $index => $menu_item ) { |
|
232 | - if ( 'edit.php?post_type=give_forms' !== $menu_item[2] ) { |
|
231 | + foreach ($menu as $index => $menu_item) { |
|
232 | + if ('edit.php?post_type=give_forms' !== $menu_item[2]) { |
|
233 | 233 | continue; |
234 | 234 | } |
235 | 235 | |
236 | - $menu[ $index ][0] = sprintf( |
|
237 | - __( 'Donations %s', 'give' ), |
|
236 | + $menu[$index][0] = sprintf( |
|
237 | + __('Donations %s', 'give'), |
|
238 | 238 | sprintf( |
239 | 239 | '<span class="update-plugins count-%1$d"><span class="plugin-count">%1$d</span></span>', |
240 | 240 | $this->get_update_count() |
@@ -259,15 +259,15 @@ discard block |
||
259 | 259 | // Bailout. |
260 | 260 | if ( ! $this->get_update_count()) { |
261 | 261 | // Show complete update message if still on update setting page. |
262 | - if ( isset($_GET['page']) && 'give-updates' === $_GET['page'] ) { |
|
262 | + if (isset($_GET['page']) && 'give-updates' === $_GET['page']) { |
|
263 | 263 | // Upgrades |
264 | 264 | add_submenu_page( |
265 | 265 | 'edit.php?post_type=give_forms', |
266 | - esc_html__( 'Give Updates Complete', 'give' ), |
|
267 | - __( 'Updates', 'give' ), |
|
266 | + esc_html__('Give Updates Complete', 'give'), |
|
267 | + __('Updates', 'give'), |
|
268 | 268 | 'manage_give_settings', |
269 | 269 | 'give-updates', |
270 | - array( $this, 'render_complete_page' ) |
|
270 | + array($this, 'render_complete_page') |
|
271 | 271 | ); |
272 | 272 | } |
273 | 273 | |
@@ -277,15 +277,15 @@ discard block |
||
277 | 277 | // Upgrades |
278 | 278 | add_submenu_page( |
279 | 279 | 'edit.php?post_type=give_forms', |
280 | - esc_html__( 'Give Updates', 'give' ), |
|
280 | + esc_html__('Give Updates', 'give'), |
|
281 | 281 | sprintf( |
282 | 282 | '%1$s <span class="update-plugins count-%2$d"><span class="plugin-count">%2$d</span></span>', |
283 | - __( 'Updates', 'give' ), |
|
283 | + __('Updates', 'give'), |
|
284 | 284 | $this->get_update_count() |
285 | 285 | ), |
286 | 286 | 'manage_give_settings', |
287 | 287 | 'give-updates', |
288 | - array( $this, 'render_page' ) |
|
288 | + array($this, 'render_page') |
|
289 | 289 | ); |
290 | 290 | } |
291 | 291 | |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | * @return int |
298 | 298 | */ |
299 | 299 | public function get_db_update_count() { |
300 | - return count( $this->get_updates( 'database', 'new' ) ); |
|
300 | + return count($this->get_updates('database', 'new')); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | /** |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | * @access public |
308 | 308 | */ |
309 | 309 | public function render_complete_page() { |
310 | - include_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/upgrades-complete.php'; |
|
310 | + include_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/views/upgrades-complete.php'; |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | /** |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | * @access public |
318 | 318 | */ |
319 | 319 | public function render_page() { |
320 | - include_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/upgrades.php'; |
|
320 | + include_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/views/upgrades.php'; |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | /** |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | * @return int |
329 | 329 | */ |
330 | 330 | public function get_plugin_update_count() { |
331 | - return count( $this->get_updates( 'plugin' ) ); |
|
331 | + return count($this->get_updates('plugin')); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | /** |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | $db_update_count = $this->get_db_update_count(); |
344 | 344 | $plugin_update_count = $this->get_plugin_update_count(); |
345 | 345 | |
346 | - return ( $db_update_count + $plugin_update_count ); |
|
346 | + return ($db_update_count + $plugin_update_count); |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | |
@@ -354,12 +354,12 @@ discard block |
||
354 | 354 | * @access public |
355 | 355 | */ |
356 | 356 | public function __flush_resume_updates() { |
357 | - delete_option( 'give_doing_upgrade' ); |
|
358 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
357 | + delete_option('give_doing_upgrade'); |
|
358 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
359 | 359 | |
360 | 360 | // Reset counter. |
361 | 361 | $this->step = $this->percentage = 0; |
362 | - ++ $this->update; |
|
362 | + ++$this->update; |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | /** |
@@ -370,24 +370,24 @@ discard block |
||
370 | 370 | */ |
371 | 371 | public function __give_ajax_updates() { |
372 | 372 | // Check permission. |
373 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
373 | + if ( ! current_user_can('manage_give_settings')) { |
|
374 | 374 | $this->send_ajax_response( |
375 | 375 | array( |
376 | - 'message' => esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), |
|
376 | + 'message' => esc_html__('You do not have permission to do Give upgrades.', 'give'), |
|
377 | 377 | ), |
378 | 378 | 'error' |
379 | 379 | ); |
380 | 380 | } |
381 | 381 | |
382 | 382 | // Set params. |
383 | - $this->step = absint( $_POST['step'] ); |
|
384 | - $this->update = absint( $_POST['update'] ); |
|
383 | + $this->step = absint($_POST['step']); |
|
384 | + $this->update = absint($_POST['update']); |
|
385 | 385 | |
386 | 386 | // Bailout: step and update must be positive and greater then zero. |
387 | - if ( ! $this->step ) { |
|
387 | + if ( ! $this->step) { |
|
388 | 388 | $this->send_ajax_response( |
389 | 389 | array( |
390 | - 'message' => __( 'Please reload this page and try again', 'give' ), |
|
390 | + 'message' => __('Please reload this page and try again', 'give'), |
|
391 | 391 | 'heading' => '', |
392 | 392 | 'percentage' => 0, |
393 | 393 | ), |
@@ -396,14 +396,14 @@ discard block |
||
396 | 396 | } |
397 | 397 | |
398 | 398 | // Get updates. |
399 | - $updates = $this->get_updates( 'database', 'new' ); |
|
399 | + $updates = $this->get_updates('database', 'new'); |
|
400 | 400 | |
401 | 401 | // Bailout if we do not have nay updates. |
402 | - if ( empty( $updates ) ) { |
|
402 | + if (empty($updates)) { |
|
403 | 403 | $this->send_ajax_response( |
404 | 404 | array( |
405 | - 'message' => __( 'The database is already up to date.', 'give' ), |
|
406 | - 'heading' => __( 'Updates Completed.', 'give' ), |
|
405 | + 'message' => __('The database is already up to date.', 'give'), |
|
406 | + 'heading' => __('Updates Completed.', 'give'), |
|
407 | 407 | 'percentage' => 0, |
408 | 408 | ), |
409 | 409 | 'success' |
@@ -411,26 +411,26 @@ discard block |
||
411 | 411 | } |
412 | 412 | |
413 | 413 | // Process update. |
414 | - foreach ( $updates as $index => $update ) { |
|
414 | + foreach ($updates as $index => $update) { |
|
415 | 415 | // Check if update depend upon any other update. |
416 | - if ( ! empty( $update['depend'] ) && ! give_has_upgrade_completed( $update['depend'] ) ) { |
|
416 | + if ( ! empty($update['depend']) && ! give_has_upgrade_completed($update['depend'])) { |
|
417 | 417 | continue; |
418 | 418 | } |
419 | 419 | |
420 | 420 | // Run update. |
421 | - if ( is_array( $update['callback'] ) ) { |
|
421 | + if (is_array($update['callback'])) { |
|
422 | 422 | $update['callback'][0]->$update['callback'][1](); |
423 | 423 | } else { |
424 | 424 | $update['callback'](); |
425 | 425 | } |
426 | 426 | |
427 | 427 | // Check if current update completed or not. |
428 | - if ( give_has_upgrade_completed( $update['id'] ) ) { |
|
429 | - if ( 1 === count( $updates ) ) { |
|
428 | + if (give_has_upgrade_completed($update['id'])) { |
|
429 | + if (1 === count($updates)) { |
|
430 | 430 | $this->send_ajax_response( |
431 | 431 | array( |
432 | - 'message' => __( 'Database updated successfully.', 'give' ), |
|
433 | - 'heading' => __( 'Updates Completed.', 'give' ), |
|
432 | + 'message' => __('Database updated successfully.', 'give'), |
|
433 | + 'heading' => __('Updates Completed.', 'give'), |
|
434 | 434 | 'percentage' => 0, |
435 | 435 | ), |
436 | 436 | 'success' |
@@ -440,16 +440,16 @@ discard block |
||
440 | 440 | |
441 | 441 | $doing_upgrade_args = array( |
442 | 442 | 'update_info' => $update, |
443 | - 'step' => ++ $this->step, |
|
443 | + 'step' => ++$this->step, |
|
444 | 444 | 'update' => $this->update, |
445 | - 'heading' => sprintf( 'Update %s of {update_count}', $this->update ), |
|
445 | + 'heading' => sprintf('Update %s of {update_count}', $this->update), |
|
446 | 446 | 'percentage' => $this->percentage, |
447 | 447 | ); |
448 | 448 | |
449 | 449 | // Cache upgrade. |
450 | - update_option( 'give_doing_upgrade', $doing_upgrade_args ); |
|
450 | + update_option('give_doing_upgrade', $doing_upgrade_args); |
|
451 | 451 | |
452 | - $this->send_ajax_response( $doing_upgrade_args ); |
|
452 | + $this->send_ajax_response($doing_upgrade_args); |
|
453 | 453 | }// End foreach(). |
454 | 454 | } |
455 | 455 | |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | * @param $data |
463 | 463 | * @param string $type |
464 | 464 | */ |
465 | - public function send_ajax_response( $data, $type = '' ) { |
|
465 | + public function send_ajax_response($data, $type = '') { |
|
466 | 466 | $default = array( |
467 | 467 | 'message' => '', |
468 | 468 | 'heading' => '', |
@@ -472,21 +472,21 @@ discard block |
||
472 | 472 | ); |
473 | 473 | |
474 | 474 | // Set data. |
475 | - $data = wp_parse_args( $data, $default ); |
|
475 | + $data = wp_parse_args($data, $default); |
|
476 | 476 | |
477 | - switch ( $type ) { |
|
477 | + switch ($type) { |
|
478 | 478 | case 'success': |
479 | - wp_send_json_success( $data ); |
|
479 | + wp_send_json_success($data); |
|
480 | 480 | break; |
481 | 481 | |
482 | 482 | case 'error': |
483 | - wp_send_json_error( $data ); |
|
483 | + wp_send_json_error($data); |
|
484 | 484 | break; |
485 | 485 | |
486 | 486 | default: |
487 | - wp_send_json( array( |
|
487 | + wp_send_json(array( |
|
488 | 488 | 'data' => $data, |
489 | - ) ); |
|
489 | + )); |
|
490 | 490 | break; |
491 | 491 | } |
492 | 492 | } |
@@ -503,8 +503,8 @@ discard block |
||
503 | 503 | public function resume_updates() { |
504 | 504 | $status = false; |
505 | 505 | |
506 | - if ( $update = get_option( 'give_doing_upgrade' ) ) { |
|
507 | - $status = ! empty( $update['step'] ) ? $update['step'] : $status; |
|
506 | + if ($update = get_option('give_doing_upgrade')) { |
|
507 | + $status = ! empty($update['step']) ? $update['step'] : $status; |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | return $status; |
@@ -520,12 +520,12 @@ discard block |
||
520 | 520 | * @param $total |
521 | 521 | * @param $current_total |
522 | 522 | */ |
523 | - public function set_percentage( $total, $current_total ) { |
|
523 | + public function set_percentage($total, $current_total) { |
|
524 | 524 | // Set percentage. |
525 | - $this->percentage = $total ? ( ( $current_total ) / $total ) * 100 : 0; |
|
525 | + $this->percentage = $total ? (($current_total) / $total) * 100 : 0; |
|
526 | 526 | |
527 | 527 | // Verify percentage. |
528 | - $this->percentage = ( 100 < $this->percentage ) ? 100 : $this->percentage; |
|
528 | + $this->percentage = (100 < $this->percentage) ? 100 : $this->percentage; |
|
529 | 529 | } |
530 | 530 | } |
531 | 531 |
@@ -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 | |
@@ -25,56 +25,56 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_do_automatic_upgrades() { |
27 | 27 | $did_upgrade = false; |
28 | - $give_version = preg_replace( '/[^0-9.].*/', '', get_option( 'give_version' ) ); |
|
28 | + $give_version = preg_replace('/[^0-9.].*/', '', get_option('give_version')); |
|
29 | 29 | |
30 | - if ( ! $give_version ) { |
|
30 | + if ( ! $give_version) { |
|
31 | 31 | // 1.0 is the first version to use this option so we must add it. |
32 | 32 | $give_version = '1.0'; |
33 | 33 | } |
34 | 34 | |
35 | - switch ( true ) { |
|
35 | + switch (true) { |
|
36 | 36 | |
37 | - case version_compare( $give_version, '1.6', '<' ) : |
|
37 | + case version_compare($give_version, '1.6', '<') : |
|
38 | 38 | give_v16_upgrades(); |
39 | 39 | $did_upgrade = true; |
40 | 40 | |
41 | - case version_compare( $give_version, '1.7', '<' ) : |
|
41 | + case version_compare($give_version, '1.7', '<') : |
|
42 | 42 | give_v17_upgrades(); |
43 | 43 | $did_upgrade = true; |
44 | 44 | |
45 | - case version_compare( $give_version, '1.8', '<' ) : |
|
45 | + case version_compare($give_version, '1.8', '<') : |
|
46 | 46 | give_v18_upgrades(); |
47 | 47 | $did_upgrade = true; |
48 | 48 | |
49 | - case version_compare( $give_version, '1.8.7', '<' ) : |
|
49 | + case version_compare($give_version, '1.8.7', '<') : |
|
50 | 50 | give_v187_upgrades(); |
51 | 51 | $did_upgrade = true; |
52 | 52 | |
53 | - case version_compare( $give_version, '1.8.8', '<' ) : |
|
53 | + case version_compare($give_version, '1.8.8', '<') : |
|
54 | 54 | give_v188_upgrades(); |
55 | 55 | $did_upgrade = true; |
56 | 56 | |
57 | - case version_compare( $give_version, '1.8.9', '<' ) : |
|
57 | + case version_compare($give_version, '1.8.9', '<') : |
|
58 | 58 | give_v189_upgrades(); |
59 | 59 | $did_upgrade = true; |
60 | 60 | |
61 | - case version_compare( $give_version, '1.8.12', '<' ) : |
|
61 | + case version_compare($give_version, '1.8.12', '<') : |
|
62 | 62 | give_v1812_upgrades(); |
63 | 63 | $did_upgrade = true; |
64 | 64 | |
65 | - case version_compare( $give_version, '1.8.13', '<' ) : |
|
65 | + case version_compare($give_version, '1.8.13', '<') : |
|
66 | 66 | give_v1813_upgrades(); |
67 | 67 | $did_upgrade = true; |
68 | 68 | |
69 | 69 | } |
70 | 70 | |
71 | - if ( $did_upgrade ) { |
|
72 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
71 | + if ($did_upgrade) { |
|
72 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
76 | -add_action( 'admin_init', 'give_do_automatic_upgrades' ); |
|
77 | -add_action( 'give_upgrades', 'give_do_automatic_upgrades' ); |
|
76 | +add_action('admin_init', 'give_do_automatic_upgrades'); |
|
77 | +add_action('give_upgrades', 'give_do_automatic_upgrades'); |
|
78 | 78 | |
79 | 79 | /** |
80 | 80 | * Display Upgrade Notices |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @return void |
88 | 88 | */ |
89 | -function give_show_upgrade_notices( $give_updates ) { |
|
89 | +function give_show_upgrade_notices($give_updates) { |
|
90 | 90 | // v1.3.2 Upgrades |
91 | 91 | $give_updates->register( |
92 | 92 | array( |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | ); |
153 | 153 | } |
154 | 154 | |
155 | -add_action( 'give_register_updates', 'give_show_upgrade_notices' ); |
|
155 | +add_action('give_register_updates', 'give_show_upgrade_notices'); |
|
156 | 156 | |
157 | 157 | /** |
158 | 158 | * Triggers all upgrade functions |
@@ -164,29 +164,29 @@ discard block |
||
164 | 164 | */ |
165 | 165 | function give_trigger_upgrades() { |
166 | 166 | |
167 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
168 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
167 | + if ( ! current_user_can('manage_give_settings')) { |
|
168 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
169 | 169 | 'response' => 403, |
170 | - ) ); |
|
170 | + )); |
|
171 | 171 | } |
172 | 172 | |
173 | - $give_version = get_option( 'give_version' ); |
|
173 | + $give_version = get_option('give_version'); |
|
174 | 174 | |
175 | - if ( ! $give_version ) { |
|
175 | + if ( ! $give_version) { |
|
176 | 176 | // 1.0 is the first version to use this option so we must add it. |
177 | 177 | $give_version = '1.0'; |
178 | - add_option( 'give_version', $give_version ); |
|
178 | + add_option('give_version', $give_version); |
|
179 | 179 | } |
180 | 180 | |
181 | - update_option( 'give_version', GIVE_VERSION ); |
|
182 | - delete_option( 'give_doing_upgrade' ); |
|
181 | + update_option('give_version', GIVE_VERSION); |
|
182 | + delete_option('give_doing_upgrade'); |
|
183 | 183 | |
184 | - if ( DOING_AJAX ) { |
|
185 | - die( 'complete' ); |
|
184 | + if (DOING_AJAX) { |
|
185 | + die('complete'); |
|
186 | 186 | } // End if(). |
187 | 187 | } |
188 | 188 | |
189 | -add_action( 'wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades' ); |
|
189 | +add_action('wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades'); |
|
190 | 190 | |
191 | 191 | |
192 | 192 | /** |
@@ -202,24 +202,24 @@ discard block |
||
202 | 202 | /* @var Give_Updates $give_updates */ |
203 | 203 | $give_updates = Give_Updates::get_instance(); |
204 | 204 | |
205 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
206 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
205 | + if ( ! current_user_can('manage_give_settings')) { |
|
206 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
207 | 207 | 'response' => 403, |
208 | - ) ); |
|
208 | + )); |
|
209 | 209 | } |
210 | 210 | |
211 | - ignore_user_abort( true ); |
|
211 | + ignore_user_abort(true); |
|
212 | 212 | |
213 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
214 | - @set_time_limit( 0 ); |
|
213 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
214 | + @set_time_limit(0); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | // UPDATE DB METAKEYS. |
218 | 218 | $sql = "UPDATE $wpdb->postmeta SET meta_key = '_give_payment_customer_id' WHERE meta_key = '_give_payment_donor_id'"; |
219 | - $query = $wpdb->query( $sql ); |
|
219 | + $query = $wpdb->query($sql); |
|
220 | 220 | |
221 | 221 | $give_updates->percentage = 100; |
222 | - give_set_upgrade_complete( 'upgrade_give_payment_customer_id' ); |
|
222 | + give_set_upgrade_complete('upgrade_give_payment_customer_id'); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | |
@@ -243,24 +243,24 @@ discard block |
||
243 | 243 | $where .= "AND ( p.post_status = 'abandoned' )"; |
244 | 244 | $where .= "AND ( m.meta_key = '_give_payment_gateway' AND m.meta_value = 'offline' )"; |
245 | 245 | |
246 | - $sql = $select . $join . $where; |
|
247 | - $found_payments = $wpdb->get_col( $sql ); |
|
246 | + $sql = $select.$join.$where; |
|
247 | + $found_payments = $wpdb->get_col($sql); |
|
248 | 248 | |
249 | - foreach ( $found_payments as $payment ) { |
|
249 | + foreach ($found_payments as $payment) { |
|
250 | 250 | |
251 | 251 | // Only change ones marked abandoned since our release last week because the admin may have marked some abandoned themselves. |
252 | - $modified_time = get_post_modified_time( 'U', false, $payment ); |
|
252 | + $modified_time = get_post_modified_time('U', false, $payment); |
|
253 | 253 | |
254 | 254 | // 1450124863 = 12/10/2015 20:42:25. |
255 | - if ( $modified_time >= 1450124863 ) { |
|
255 | + if ($modified_time >= 1450124863) { |
|
256 | 256 | |
257 | - give_update_payment_status( $payment, 'pending' ); |
|
257 | + give_update_payment_status($payment, 'pending'); |
|
258 | 258 | |
259 | 259 | } |
260 | 260 | } |
261 | 261 | |
262 | 262 | $give_updates->percentage = 100; |
263 | - give_set_upgrade_complete( 'upgrade_give_offline_status' ); |
|
263 | + give_set_upgrade_complete('upgrade_give_offline_status'); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | |
@@ -273,17 +273,17 @@ discard block |
||
273 | 273 | */ |
274 | 274 | function give_v152_cleanup_users() { |
275 | 275 | |
276 | - $give_version = get_option( 'give_version' ); |
|
276 | + $give_version = get_option('give_version'); |
|
277 | 277 | |
278 | - if ( ! $give_version ) { |
|
278 | + if ( ! $give_version) { |
|
279 | 279 | // 1.0 is the first version to use this option so we must add it. |
280 | 280 | $give_version = '1.0'; |
281 | 281 | } |
282 | 282 | |
283 | - $give_version = preg_replace( '/[^0-9.].*/', '', $give_version ); |
|
283 | + $give_version = preg_replace('/[^0-9.].*/', '', $give_version); |
|
284 | 284 | |
285 | 285 | // v1.5.2 Upgrades |
286 | - if ( version_compare( $give_version, '1.5.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_user_caps_cleanup' ) ) { |
|
286 | + if (version_compare($give_version, '1.5.2', '<') || ! give_has_upgrade_completed('upgrade_give_user_caps_cleanup')) { |
|
287 | 287 | |
288 | 288 | // Delete all caps with "ss". |
289 | 289 | // Also delete all unused "campaign" roles. |
@@ -330,9 +330,9 @@ discard block |
||
330 | 330 | ); |
331 | 331 | |
332 | 332 | global $wp_roles; |
333 | - foreach ( $delete_caps as $cap ) { |
|
334 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
335 | - $wp_roles->remove_cap( $role, $cap ); |
|
333 | + foreach ($delete_caps as $cap) { |
|
334 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
335 | + $wp_roles->remove_cap($role, $cap); |
|
336 | 336 | } |
337 | 337 | } |
338 | 338 | |
@@ -342,15 +342,15 @@ discard block |
||
342 | 342 | $roles->add_caps(); |
343 | 343 | |
344 | 344 | // The Update Ran. |
345 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
346 | - give_set_upgrade_complete( 'upgrade_give_user_caps_cleanup' ); |
|
347 | - delete_option( 'give_doing_upgrade' ); |
|
345 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
346 | + give_set_upgrade_complete('upgrade_give_user_caps_cleanup'); |
|
347 | + delete_option('give_doing_upgrade'); |
|
348 | 348 | |
349 | 349 | }// End if(). |
350 | 350 | |
351 | 351 | } |
352 | 352 | |
353 | -add_action( 'admin_init', 'give_v152_cleanup_users' ); |
|
353 | +add_action('admin_init', 'give_v152_cleanup_users'); |
|
354 | 354 | |
355 | 355 | /** |
356 | 356 | * 1.6 Upgrade routine to create the customer meta table. |
@@ -393,53 +393,53 @@ discard block |
||
393 | 393 | |
394 | 394 | // Get addons license key. |
395 | 395 | $addons = array(); |
396 | - foreach ( $give_options as $key => $value ) { |
|
397 | - if ( false !== strpos( $key, '_license_key' ) ) { |
|
398 | - $addons[ $key ] = $value; |
|
396 | + foreach ($give_options as $key => $value) { |
|
397 | + if (false !== strpos($key, '_license_key')) { |
|
398 | + $addons[$key] = $value; |
|
399 | 399 | } |
400 | 400 | } |
401 | 401 | |
402 | 402 | // Bailout: We do not have any addon license data to upgrade. |
403 | - if ( empty( $addons ) ) { |
|
403 | + if (empty($addons)) { |
|
404 | 404 | return false; |
405 | 405 | } |
406 | 406 | |
407 | - foreach ( $addons as $key => $addon_license ) { |
|
407 | + foreach ($addons as $key => $addon_license) { |
|
408 | 408 | |
409 | 409 | // Get addon shortname. |
410 | - $shortname = str_replace( '_license_key', '', $key ); |
|
410 | + $shortname = str_replace('_license_key', '', $key); |
|
411 | 411 | |
412 | 412 | // Addon license option name. |
413 | - $addon_license_option_name = $shortname . '_license_active'; |
|
413 | + $addon_license_option_name = $shortname.'_license_active'; |
|
414 | 414 | |
415 | 415 | // bailout if license is empty. |
416 | - if ( empty( $addon_license ) ) { |
|
417 | - delete_option( $addon_license_option_name ); |
|
416 | + if (empty($addon_license)) { |
|
417 | + delete_option($addon_license_option_name); |
|
418 | 418 | continue; |
419 | 419 | } |
420 | 420 | |
421 | 421 | // Get addon name. |
422 | 422 | $addon_name = array(); |
423 | - $addon_name_parts = explode( '_', str_replace( 'give_', '', $shortname ) ); |
|
424 | - foreach ( $addon_name_parts as $name_part ) { |
|
423 | + $addon_name_parts = explode('_', str_replace('give_', '', $shortname)); |
|
424 | + foreach ($addon_name_parts as $name_part) { |
|
425 | 425 | |
426 | 426 | // Fix addon name |
427 | - switch ( $name_part ) { |
|
427 | + switch ($name_part) { |
|
428 | 428 | case 'authorizenet' : |
429 | 429 | $name_part = 'authorize.net'; |
430 | 430 | break; |
431 | 431 | } |
432 | 432 | |
433 | - $addon_name[] = ucfirst( $name_part ); |
|
433 | + $addon_name[] = ucfirst($name_part); |
|
434 | 434 | } |
435 | 435 | |
436 | - $addon_name = implode( ' ', $addon_name ); |
|
436 | + $addon_name = implode(' ', $addon_name); |
|
437 | 437 | |
438 | 438 | // Data to send to the API |
439 | 439 | $api_params = array( |
440 | 440 | 'edd_action' => 'activate_license', // never change from "edd_" to "give_"! |
441 | 441 | 'license' => $addon_license, |
442 | - 'item_name' => urlencode( $addon_name ), |
|
442 | + 'item_name' => urlencode($addon_name), |
|
443 | 443 | 'url' => home_url(), |
444 | 444 | ); |
445 | 445 | |
@@ -454,17 +454,17 @@ discard block |
||
454 | 454 | ); |
455 | 455 | |
456 | 456 | // Make sure there are no errors. |
457 | - if ( is_wp_error( $response ) ) { |
|
458 | - delete_option( $addon_license_option_name ); |
|
457 | + if (is_wp_error($response)) { |
|
458 | + delete_option($addon_license_option_name); |
|
459 | 459 | continue; |
460 | 460 | } |
461 | 461 | |
462 | 462 | // Tell WordPress to look for updates. |
463 | - set_site_transient( 'update_plugins', null ); |
|
463 | + set_site_transient('update_plugins', null); |
|
464 | 464 | |
465 | 465 | // Decode license data. |
466 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
467 | - update_option( $addon_license_option_name, $license_data ); |
|
466 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
467 | + update_option($addon_license_option_name, $license_data); |
|
468 | 468 | }// End foreach(). |
469 | 469 | } |
470 | 470 | |
@@ -494,9 +494,9 @@ discard block |
||
494 | 494 | ); |
495 | 495 | |
496 | 496 | global $wp_roles; |
497 | - foreach ( $delete_caps as $cap ) { |
|
498 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
499 | - $wp_roles->remove_cap( $role, $cap ); |
|
497 | + foreach ($delete_caps as $cap) { |
|
498 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
499 | + $wp_roles->remove_cap($role, $cap); |
|
500 | 500 | } |
501 | 501 | } |
502 | 502 | |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | function give_v18_upgrades_core_setting() { |
531 | 531 | // Core settings which changes from checkbox to radio. |
532 | 532 | $core_setting_names = array_merge( |
533 | - array_keys( give_v18_renamed_core_settings() ), |
|
533 | + array_keys(give_v18_renamed_core_settings()), |
|
534 | 534 | array( |
535 | 535 | 'uninstall_on_delete', |
536 | 536 | 'scripts_footer', |
@@ -542,48 +542,48 @@ discard block |
||
542 | 542 | ); |
543 | 543 | |
544 | 544 | // Bailout: If not any setting define. |
545 | - if ( $give_settings = get_option( 'give_settings' ) ) { |
|
545 | + if ($give_settings = get_option('give_settings')) { |
|
546 | 546 | |
547 | 547 | $setting_changed = false; |
548 | 548 | |
549 | 549 | // Loop: check each setting field. |
550 | - foreach ( $core_setting_names as $setting_name ) { |
|
550 | + foreach ($core_setting_names as $setting_name) { |
|
551 | 551 | // New setting name. |
552 | - $new_setting_name = preg_replace( '/^(enable_|disable_)/', '', $setting_name ); |
|
552 | + $new_setting_name = preg_replace('/^(enable_|disable_)/', '', $setting_name); |
|
553 | 553 | |
554 | 554 | // Continue: If setting already set. |
555 | 555 | if ( |
556 | - array_key_exists( $new_setting_name, $give_settings ) |
|
557 | - && in_array( $give_settings[ $new_setting_name ], array( 'enabled', 'disabled' ) ) |
|
556 | + array_key_exists($new_setting_name, $give_settings) |
|
557 | + && in_array($give_settings[$new_setting_name], array('enabled', 'disabled')) |
|
558 | 558 | ) { |
559 | 559 | continue; |
560 | 560 | } |
561 | 561 | |
562 | 562 | // Set checkbox value to radio value. |
563 | - $give_settings[ $setting_name ] = ( ! empty( $give_settings[ $setting_name ] ) && 'on' === $give_settings[ $setting_name ] ? 'enabled' : 'disabled' ); |
|
563 | + $give_settings[$setting_name] = ( ! empty($give_settings[$setting_name]) && 'on' === $give_settings[$setting_name] ? 'enabled' : 'disabled'); |
|
564 | 564 | |
565 | 565 | // @see https://github.com/WordImpress/Give/issues/1063 |
566 | - if ( false !== strpos( $setting_name, 'disable_' ) ) { |
|
566 | + if (false !== strpos($setting_name, 'disable_')) { |
|
567 | 567 | |
568 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'disabled' : 'enabled' ); |
|
569 | - } elseif ( false !== strpos( $setting_name, 'enable_' ) ) { |
|
568 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'disabled' : 'enabled'); |
|
569 | + } elseif (false !== strpos($setting_name, 'enable_')) { |
|
570 | 570 | |
571 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'enabled' : 'disabled' ); |
|
571 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'enabled' : 'disabled'); |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | // Tell bot to update core setting to db. |
575 | - if ( ! $setting_changed ) { |
|
575 | + if ( ! $setting_changed) { |
|
576 | 576 | $setting_changed = true; |
577 | 577 | } |
578 | 578 | } |
579 | 579 | |
580 | 580 | // Update setting only if they changed. |
581 | - if ( $setting_changed ) { |
|
582 | - update_option( 'give_settings', $give_settings ); |
|
581 | + if ($setting_changed) { |
|
582 | + update_option('give_settings', $give_settings); |
|
583 | 583 | } |
584 | 584 | }// End if(). |
585 | 585 | |
586 | - give_set_upgrade_complete( 'v18_upgrades_core_setting' ); |
|
586 | + give_set_upgrade_complete('v18_upgrades_core_setting'); |
|
587 | 587 | } |
588 | 588 | |
589 | 589 | /** |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | $give_updates = Give_Updates::get_instance(); |
598 | 598 | |
599 | 599 | // form query |
600 | - $forms = new WP_Query( array( |
|
600 | + $forms = new WP_Query(array( |
|
601 | 601 | 'paged' => $give_updates->step, |
602 | 602 | 'status' => 'any', |
603 | 603 | 'order' => 'ASC', |
@@ -606,41 +606,41 @@ discard block |
||
606 | 606 | ) |
607 | 607 | ); |
608 | 608 | |
609 | - if ( $forms->have_posts() ) { |
|
610 | - $give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 20 ) ); |
|
609 | + if ($forms->have_posts()) { |
|
610 | + $give_updates->set_percentage($forms->found_posts, ($give_updates->step * 20)); |
|
611 | 611 | |
612 | - while ( $forms->have_posts() ) { |
|
612 | + while ($forms->have_posts()) { |
|
613 | 613 | $forms->the_post(); |
614 | 614 | |
615 | 615 | // Form content. |
616 | 616 | // Note in version 1.8 display content setting split into display content and content placement setting. |
617 | 617 | // You can delete _give_content_option in future |
618 | - $show_content = give_get_meta( get_the_ID(), '_give_content_option', true ); |
|
619 | - if ( $show_content && ! give_get_meta( get_the_ID(), '_give_display_content', true ) ) { |
|
620 | - $field_value = ( 'none' !== $show_content ? 'enabled' : 'disabled' ); |
|
621 | - give_update_meta( get_the_ID(), '_give_display_content', $field_value ); |
|
618 | + $show_content = give_get_meta(get_the_ID(), '_give_content_option', true); |
|
619 | + if ($show_content && ! give_get_meta(get_the_ID(), '_give_display_content', true)) { |
|
620 | + $field_value = ('none' !== $show_content ? 'enabled' : 'disabled'); |
|
621 | + give_update_meta(get_the_ID(), '_give_display_content', $field_value); |
|
622 | 622 | |
623 | - $field_value = ( 'none' !== $show_content ? $show_content : 'give_pre_form' ); |
|
624 | - give_update_meta( get_the_ID(), '_give_content_placement', $field_value ); |
|
623 | + $field_value = ('none' !== $show_content ? $show_content : 'give_pre_form'); |
|
624 | + give_update_meta(get_the_ID(), '_give_content_placement', $field_value); |
|
625 | 625 | } |
626 | 626 | |
627 | 627 | // "Disable" Guest Donation. Checkbox |
628 | 628 | // See: https://github.com/WordImpress/Give/issues/1470 |
629 | - $guest_donation = give_get_meta( get_the_ID(), '_give_logged_in_only', true ); |
|
630 | - $guest_donation_newval = ( in_array( $guest_donation, array( 'yes', 'on' ) ) ? 'disabled' : 'enabled' ); |
|
631 | - give_update_meta( get_the_ID(), '_give_logged_in_only', $guest_donation_newval ); |
|
629 | + $guest_donation = give_get_meta(get_the_ID(), '_give_logged_in_only', true); |
|
630 | + $guest_donation_newval = (in_array($guest_donation, array('yes', 'on')) ? 'disabled' : 'enabled'); |
|
631 | + give_update_meta(get_the_ID(), '_give_logged_in_only', $guest_donation_newval); |
|
632 | 632 | |
633 | 633 | // Offline Donations |
634 | 634 | // See: https://github.com/WordImpress/Give/issues/1579 |
635 | - $offline_donation = give_get_meta( get_the_ID(), '_give_customize_offline_donations', true ); |
|
636 | - if ( 'no' === $offline_donation ) { |
|
635 | + $offline_donation = give_get_meta(get_the_ID(), '_give_customize_offline_donations', true); |
|
636 | + if ('no' === $offline_donation) { |
|
637 | 637 | $offline_donation_newval = 'global'; |
638 | - } elseif ( 'yes' === $offline_donation ) { |
|
638 | + } elseif ('yes' === $offline_donation) { |
|
639 | 639 | $offline_donation_newval = 'enabled'; |
640 | 640 | } else { |
641 | 641 | $offline_donation_newval = 'disabled'; |
642 | 642 | } |
643 | - give_update_meta( get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval ); |
|
643 | + give_update_meta(get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval); |
|
644 | 644 | |
645 | 645 | // Convert yes/no setting field to enabled/disabled. |
646 | 646 | $form_radio_settings = array( |
@@ -660,15 +660,15 @@ discard block |
||
660 | 660 | '_give_offline_donation_enable_billing_fields_single', |
661 | 661 | ); |
662 | 662 | |
663 | - foreach ( $form_radio_settings as $meta_key ) { |
|
663 | + foreach ($form_radio_settings as $meta_key) { |
|
664 | 664 | // Get value. |
665 | - $field_value = give_get_meta( get_the_ID(), $meta_key, true ); |
|
665 | + $field_value = give_get_meta(get_the_ID(), $meta_key, true); |
|
666 | 666 | |
667 | 667 | // Convert meta value only if it is in yes/no/none. |
668 | - if ( in_array( $field_value, array( 'yes', 'on', 'no', 'none' ) ) ) { |
|
668 | + if (in_array($field_value, array('yes', 'on', 'no', 'none'))) { |
|
669 | 669 | |
670 | - $field_value = ( in_array( $field_value, array( 'yes', 'on' ) ) ? 'enabled' : 'disabled' ); |
|
671 | - give_update_meta( get_the_ID(), $meta_key, $field_value ); |
|
670 | + $field_value = (in_array($field_value, array('yes', 'on')) ? 'enabled' : 'disabled'); |
|
671 | + give_update_meta(get_the_ID(), $meta_key, $field_value); |
|
672 | 672 | } |
673 | 673 | } |
674 | 674 | }// End while(). |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | |
678 | 678 | } else { |
679 | 679 | // No more forms found, finish up. |
680 | - give_set_upgrade_complete( 'v18_upgrades_form_metadata' ); |
|
680 | + give_set_upgrade_complete('v18_upgrades_form_metadata'); |
|
681 | 681 | } |
682 | 682 | } |
683 | 683 | |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | '_transient_give_stats_', |
727 | 727 | 'give_cache', |
728 | 728 | '_transient_give_add_ons_feed', |
729 | - '_transient__give_ajax_works' . |
|
729 | + '_transient__give_ajax_works'. |
|
730 | 730 | '_transient_give_total_api_keys', |
731 | 731 | '_transient_give_i18n_give_promo_hide', |
732 | 732 | '_transient_give_contributors', |
@@ -753,24 +753,24 @@ discard block |
||
753 | 753 | ARRAY_A |
754 | 754 | ); |
755 | 755 | |
756 | - if ( ! empty( $user_apikey_options ) ) { |
|
757 | - foreach ( $user_apikey_options as $user ) { |
|
758 | - $cached_options[] = '_transient_' . md5( 'give_api_user_' . $user['meta_key'] ); |
|
759 | - $cached_options[] = '_transient_' . md5( 'give_api_user_public_key' . $user['user_id'] ); |
|
760 | - $cached_options[] = '_transient_' . md5( 'give_api_user_secret_key' . $user['user_id'] ); |
|
756 | + if ( ! empty($user_apikey_options)) { |
|
757 | + foreach ($user_apikey_options as $user) { |
|
758 | + $cached_options[] = '_transient_'.md5('give_api_user_'.$user['meta_key']); |
|
759 | + $cached_options[] = '_transient_'.md5('give_api_user_public_key'.$user['user_id']); |
|
760 | + $cached_options[] = '_transient_'.md5('give_api_user_secret_key'.$user['user_id']); |
|
761 | 761 | } |
762 | 762 | } |
763 | 763 | |
764 | - if ( ! empty( $cached_options ) ) { |
|
765 | - foreach ( $cached_options as $option ) { |
|
766 | - switch ( true ) { |
|
767 | - case ( false !== strpos( $option, 'transient' ) ): |
|
768 | - $option = str_replace( '_transient_', '', $option ); |
|
769 | - delete_transient( $option ); |
|
764 | + if ( ! empty($cached_options)) { |
|
765 | + foreach ($cached_options as $option) { |
|
766 | + switch (true) { |
|
767 | + case (false !== strpos($option, 'transient')): |
|
768 | + $option = str_replace('_transient_', '', $option); |
|
769 | + delete_transient($option); |
|
770 | 770 | break; |
771 | 771 | |
772 | 772 | default: |
773 | - delete_option( $option ); |
|
773 | + delete_option($option); |
|
774 | 774 | } |
775 | 775 | } |
776 | 776 | } |
@@ -788,7 +788,7 @@ discard block |
||
788 | 788 | global $wp_roles; |
789 | 789 | |
790 | 790 | // Get the role object. |
791 | - $give_worker = get_role( 'give_worker' ); |
|
791 | + $give_worker = get_role('give_worker'); |
|
792 | 792 | |
793 | 793 | // A list of capabilities to add for give workers. |
794 | 794 | $caps_to_add = array( |
@@ -796,9 +796,9 @@ discard block |
||
796 | 796 | 'edit_pages', |
797 | 797 | ); |
798 | 798 | |
799 | - foreach ( $caps_to_add as $cap ) { |
|
799 | + foreach ($caps_to_add as $cap) { |
|
800 | 800 | // Add the capability. |
801 | - $give_worker->add_cap( $cap ); |
|
801 | + $give_worker->add_cap($cap); |
|
802 | 802 | } |
803 | 803 | |
804 | 804 | } |
@@ -815,7 +815,7 @@ discard block |
||
815 | 815 | $give_updates = Give_Updates::get_instance(); |
816 | 816 | |
817 | 817 | // form query |
818 | - $donation_forms = new WP_Query( array( |
|
818 | + $donation_forms = new WP_Query(array( |
|
819 | 819 | 'paged' => $give_updates->step, |
820 | 820 | 'status' => 'any', |
821 | 821 | 'order' => 'ASC', |
@@ -824,10 +824,10 @@ discard block |
||
824 | 824 | ) |
825 | 825 | ); |
826 | 826 | |
827 | - if ( $donation_forms->have_posts() ) { |
|
828 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
827 | + if ($donation_forms->have_posts()) { |
|
828 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
829 | 829 | |
830 | - while ( $donation_forms->have_posts() ) { |
|
830 | + while ($donation_forms->have_posts()) { |
|
831 | 831 | $donation_forms->the_post(); |
832 | 832 | $form_id = get_the_ID(); |
833 | 833 | |
@@ -835,41 +835,41 @@ discard block |
||
835 | 835 | update_post_meta( |
836 | 836 | $form_id, |
837 | 837 | '_give_set_price', |
838 | - give_sanitize_amount( get_post_meta( $form_id, '_give_set_price', true ) ) |
|
838 | + give_sanitize_amount(get_post_meta($form_id, '_give_set_price', true)) |
|
839 | 839 | ); |
840 | 840 | |
841 | 841 | // Remove formatting from _give_custom_amount_minimum |
842 | 842 | update_post_meta( |
843 | 843 | $form_id, |
844 | 844 | '_give_custom_amount_minimum', |
845 | - give_sanitize_amount( get_post_meta( $form_id, '_give_custom_amount_minimum', true ) ) |
|
845 | + give_sanitize_amount(get_post_meta($form_id, '_give_custom_amount_minimum', true)) |
|
846 | 846 | ); |
847 | 847 | |
848 | 848 | // Bailout. |
849 | - if ( 'set' === get_post_meta( $form_id, '_give_price_option', true ) ) { |
|
849 | + if ('set' === get_post_meta($form_id, '_give_price_option', true)) { |
|
850 | 850 | continue; |
851 | 851 | } |
852 | 852 | |
853 | - $donation_levels = get_post_meta( $form_id, '_give_donation_levels', true ); |
|
853 | + $donation_levels = get_post_meta($form_id, '_give_donation_levels', true); |
|
854 | 854 | |
855 | - if ( ! empty( $donation_levels ) ) { |
|
855 | + if ( ! empty($donation_levels)) { |
|
856 | 856 | |
857 | - foreach ( $donation_levels as $index => $donation_level ) { |
|
858 | - if ( isset( $donation_level['_give_amount'] ) ) { |
|
859 | - $donation_levels[ $index ]['_give_amount'] = give_sanitize_amount( $donation_level['_give_amount'] ); |
|
857 | + foreach ($donation_levels as $index => $donation_level) { |
|
858 | + if (isset($donation_level['_give_amount'])) { |
|
859 | + $donation_levels[$index]['_give_amount'] = give_sanitize_amount($donation_level['_give_amount']); |
|
860 | 860 | } |
861 | 861 | } |
862 | 862 | |
863 | - update_post_meta( $form_id, '_give_donation_levels', $donation_levels ); |
|
863 | + update_post_meta($form_id, '_give_donation_levels', $donation_levels); |
|
864 | 864 | |
865 | - $donation_levels_amounts = wp_list_pluck( $donation_levels, '_give_amount' ); |
|
865 | + $donation_levels_amounts = wp_list_pluck($donation_levels, '_give_amount'); |
|
866 | 866 | |
867 | - $min_amount = min( $donation_levels_amounts ); |
|
868 | - $max_amount = max( $donation_levels_amounts ); |
|
867 | + $min_amount = min($donation_levels_amounts); |
|
868 | + $max_amount = max($donation_levels_amounts); |
|
869 | 869 | |
870 | 870 | // Set Minimum and Maximum amount for Multi Level Donation Forms |
871 | - give_update_meta( $form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount( $min_amount ) : 0 ); |
|
872 | - give_update_meta( $form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount( $max_amount ) : 0 ); |
|
871 | + give_update_meta($form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount($min_amount) : 0); |
|
872 | + give_update_meta($form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount($max_amount) : 0); |
|
873 | 873 | } |
874 | 874 | |
875 | 875 | } |
@@ -878,7 +878,7 @@ discard block |
||
878 | 878 | wp_reset_postdata(); |
879 | 879 | } else { |
880 | 880 | // The Update Ran. |
881 | - give_set_upgrade_complete( 'v189_upgrades_levels_post_meta' ); |
|
881 | + give_set_upgrade_complete('v189_upgrades_levels_post_meta'); |
|
882 | 882 | } |
883 | 883 | |
884 | 884 | } |
@@ -934,22 +934,22 @@ discard block |
||
934 | 934 | $give_settings = give_get_settings(); |
935 | 935 | $give_setting_updated = false; |
936 | 936 | |
937 | - if ( $give_settings['thousands_separator'] === $give_settings['decimal_separator'] ) { |
|
937 | + if ($give_settings['thousands_separator'] === $give_settings['decimal_separator']) { |
|
938 | 938 | $give_settings['number_decimals'] = 0; |
939 | 939 | $give_settings['decimal_separator'] = ''; |
940 | 940 | $give_setting_updated = true; |
941 | 941 | |
942 | - } elseif ( empty( $give_settings['decimal_separator'] ) ) { |
|
942 | + } elseif (empty($give_settings['decimal_separator'])) { |
|
943 | 943 | $give_settings['number_decimals'] = 0; |
944 | 944 | $give_setting_updated = true; |
945 | 945 | |
946 | - } elseif ( 6 < absint( $give_settings['number_decimals'] ) ) { |
|
946 | + } elseif (6 < absint($give_settings['number_decimals'])) { |
|
947 | 947 | $give_settings['number_decimals'] = 5; |
948 | 948 | $give_setting_updated = true; |
949 | 949 | } |
950 | 950 | |
951 | - if ( $give_setting_updated ) { |
|
952 | - update_option( 'give_settings', $give_settings ); |
|
951 | + if ($give_setting_updated) { |
|
952 | + update_option('give_settings', $give_settings); |
|
953 | 953 | } |
954 | 954 | } |
955 | 955 | |
@@ -968,70 +968,70 @@ discard block |
||
968 | 968 | $give_updates = Give_Updates::get_instance(); |
969 | 969 | |
970 | 970 | // form query |
971 | - $donation_forms = new WP_Query( array( |
|
971 | + $donation_forms = new WP_Query(array( |
|
972 | 972 | 'paged' => $give_updates->step, |
973 | 973 | 'status' => 'any', |
974 | 974 | 'order' => 'ASC', |
975 | - 'post_type' => array( 'give_forms', 'give_payment' ), |
|
975 | + 'post_type' => array('give_forms', 'give_payment'), |
|
976 | 976 | 'posts_per_page' => 20, |
977 | 977 | ) |
978 | 978 | ); |
979 | 979 | |
980 | - if ( $donation_forms->have_posts() ) { |
|
981 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
980 | + if ($donation_forms->have_posts()) { |
|
981 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
982 | 982 | |
983 | - while ( $donation_forms->have_posts() ) { |
|
983 | + while ($donation_forms->have_posts()) { |
|
984 | 984 | $donation_forms->the_post(); |
985 | 985 | global $post; |
986 | 986 | |
987 | - $meta = get_post_meta( $post->ID ); |
|
987 | + $meta = get_post_meta($post->ID); |
|
988 | 988 | |
989 | - switch ( $post->post_type ) { |
|
989 | + switch ($post->post_type) { |
|
990 | 990 | case 'give_forms': |
991 | 991 | // _give_set_price |
992 | - if ( ! empty( $meta['_give_set_price'][0] ) ) { |
|
993 | - update_post_meta( $post->ID, '_give_set_price', give_sanitize_amount_for_db( $meta['_give_set_price'][0] ) ); |
|
992 | + if ( ! empty($meta['_give_set_price'][0])) { |
|
993 | + update_post_meta($post->ID, '_give_set_price', give_sanitize_amount_for_db($meta['_give_set_price'][0])); |
|
994 | 994 | } |
995 | 995 | |
996 | 996 | // _give_custom_amount_minimum |
997 | - if ( ! empty( $meta['_give_custom_amount_minimum'][0] ) ) { |
|
998 | - update_post_meta( $post->ID, '_give_custom_amount_minimum', give_sanitize_amount_for_db( $meta['_give_custom_amount_minimum'][0] ) ); |
|
997 | + if ( ! empty($meta['_give_custom_amount_minimum'][0])) { |
|
998 | + update_post_meta($post->ID, '_give_custom_amount_minimum', give_sanitize_amount_for_db($meta['_give_custom_amount_minimum'][0])); |
|
999 | 999 | } |
1000 | 1000 | |
1001 | 1001 | // _give_levels_minimum_amount |
1002 | - if ( ! empty( $meta['_give_levels_minimum_amount'][0] ) ) { |
|
1003 | - update_post_meta( $post->ID, '_give_levels_minimum_amount', give_sanitize_amount_for_db( $meta['_give_levels_minimum_amount'][0] ) ); |
|
1002 | + if ( ! empty($meta['_give_levels_minimum_amount'][0])) { |
|
1003 | + update_post_meta($post->ID, '_give_levels_minimum_amount', give_sanitize_amount_for_db($meta['_give_levels_minimum_amount'][0])); |
|
1004 | 1004 | } |
1005 | 1005 | |
1006 | 1006 | // _give_levels_maximum_amount |
1007 | - if ( ! empty( $meta['_give_levels_maximum_amount'][0] ) ) { |
|
1008 | - update_post_meta( $post->ID, '_give_levels_maximum_amount', give_sanitize_amount_for_db( $meta['_give_levels_maximum_amount'][0] ) ); |
|
1007 | + if ( ! empty($meta['_give_levels_maximum_amount'][0])) { |
|
1008 | + update_post_meta($post->ID, '_give_levels_maximum_amount', give_sanitize_amount_for_db($meta['_give_levels_maximum_amount'][0])); |
|
1009 | 1009 | } |
1010 | 1010 | |
1011 | 1011 | // _give_set_goal |
1012 | - if ( ! empty( $meta['_give_set_goal'][0] ) ) { |
|
1013 | - update_post_meta( $post->ID, '_give_set_goal', give_sanitize_amount_for_db( $meta['_give_set_goal'][0] ) ); |
|
1012 | + if ( ! empty($meta['_give_set_goal'][0])) { |
|
1013 | + update_post_meta($post->ID, '_give_set_goal', give_sanitize_amount_for_db($meta['_give_set_goal'][0])); |
|
1014 | 1014 | } |
1015 | 1015 | |
1016 | 1016 | // _give_form_earnings |
1017 | - if ( ! empty( $meta['_give_form_earnings'][0] ) ) { |
|
1018 | - update_post_meta( $post->ID, '_give_form_earnings', give_sanitize_amount_for_db( $meta['_give_form_earnings'][0] ) ); |
|
1017 | + if ( ! empty($meta['_give_form_earnings'][0])) { |
|
1018 | + update_post_meta($post->ID, '_give_form_earnings', give_sanitize_amount_for_db($meta['_give_form_earnings'][0])); |
|
1019 | 1019 | } |
1020 | 1020 | |
1021 | 1021 | // _give_custom_amount_minimum |
1022 | - if ( ! empty( $meta['_give_donation_levels'][0] ) ) { |
|
1023 | - $donation_levels = unserialize( $meta['_give_donation_levels'][0] ); |
|
1022 | + if ( ! empty($meta['_give_donation_levels'][0])) { |
|
1023 | + $donation_levels = unserialize($meta['_give_donation_levels'][0]); |
|
1024 | 1024 | |
1025 | - foreach ( $donation_levels as $index => $level ) { |
|
1026 | - if ( empty( $level['_give_amount'] ) ) { |
|
1025 | + foreach ($donation_levels as $index => $level) { |
|
1026 | + if (empty($level['_give_amount'])) { |
|
1027 | 1027 | continue; |
1028 | 1028 | } |
1029 | 1029 | |
1030 | - $donation_levels[ $index ]['_give_amount'] = give_sanitize_amount_for_db( $level['_give_amount'] ); |
|
1030 | + $donation_levels[$index]['_give_amount'] = give_sanitize_amount_for_db($level['_give_amount']); |
|
1031 | 1031 | } |
1032 | 1032 | |
1033 | 1033 | $meta['_give_donation_levels'] = $donation_levels; |
1034 | - update_post_meta( $post->ID, '_give_donation_levels', $meta['_give_donation_levels'] ); |
|
1034 | + update_post_meta($post->ID, '_give_donation_levels', $meta['_give_donation_levels']); |
|
1035 | 1035 | } |
1036 | 1036 | |
1037 | 1037 | |
@@ -1039,8 +1039,8 @@ discard block |
||
1039 | 1039 | |
1040 | 1040 | case 'give_payment': |
1041 | 1041 | // _give_payment_total |
1042 | - if ( ! empty( $meta['_give_payment_total'][0] ) ) { |
|
1043 | - update_post_meta( $post->ID, '_give_payment_total', give_sanitize_amount_for_db( $meta['_give_payment_total'][0] ) ); |
|
1042 | + if ( ! empty($meta['_give_payment_total'][0])) { |
|
1043 | + update_post_meta($post->ID, '_give_payment_total', give_sanitize_amount_for_db($meta['_give_payment_total'][0])); |
|
1044 | 1044 | } |
1045 | 1045 | |
1046 | 1046 | break; |
@@ -1051,7 +1051,7 @@ discard block |
||
1051 | 1051 | wp_reset_postdata(); |
1052 | 1052 | } else { |
1053 | 1053 | // The Update Ran. |
1054 | - give_set_upgrade_complete( 'v1812_update_amount_values' ); |
|
1054 | + give_set_upgrade_complete('v1812_update_amount_values'); |
|
1055 | 1055 | } |
1056 | 1056 | } |
1057 | 1057 | |
@@ -1071,22 +1071,22 @@ discard block |
||
1071 | 1071 | $offset = 1 === $give_updates->step ? 0 : $give_updates->step * 20; |
1072 | 1072 | |
1073 | 1073 | // form query |
1074 | - $donors = Give()->donors->get_donors( array( |
|
1074 | + $donors = Give()->donors->get_donors(array( |
|
1075 | 1075 | 'number' => 20, |
1076 | 1076 | 'offset' => $offset, |
1077 | 1077 | ) |
1078 | 1078 | ); |
1079 | 1079 | |
1080 | - if ( ! empty( $donors ) ) { |
|
1081 | - $give_updates->set_percentage( Give()->donors->count(), ( $give_updates->step * 20 ) ); |
|
1080 | + if ( ! empty($donors)) { |
|
1081 | + $give_updates->set_percentage(Give()->donors->count(), ($give_updates->step * 20)); |
|
1082 | 1082 | |
1083 | 1083 | /* @var Object $donor */ |
1084 | - foreach ( $donors as $donor ) { |
|
1085 | - Give()->donors->update( $donor->id, array( 'purchase_value' => give_sanitize_amount_for_db( $donor->purchase_value ) ) ); |
|
1084 | + foreach ($donors as $donor) { |
|
1085 | + Give()->donors->update($donor->id, array('purchase_value' => give_sanitize_amount_for_db($donor->purchase_value))); |
|
1086 | 1086 | } |
1087 | 1087 | } else { |
1088 | 1088 | // The Update Ran. |
1089 | - give_set_upgrade_complete( 'v1812_update_donor_purchase_values' ); |
|
1089 | + give_set_upgrade_complete('v1812_update_donor_purchase_values'); |
|
1090 | 1090 | } |
1091 | 1091 | } |
1092 | 1092 | |
@@ -1101,25 +1101,25 @@ discard block |
||
1101 | 1101 | $offset = 1 === $give_updates->step ? 0 : $give_updates->step * 20; |
1102 | 1102 | |
1103 | 1103 | // Fetch all the existing donors. |
1104 | - $donors = Give()->donors->get_donors( array( |
|
1104 | + $donors = Give()->donors->get_donors(array( |
|
1105 | 1105 | 'number' => 20, |
1106 | 1106 | 'offset' => $offset, |
1107 | 1107 | ) |
1108 | 1108 | ); |
1109 | 1109 | |
1110 | - if ( ! empty( $donors ) ) { |
|
1111 | - $give_updates->set_percentage( Give()->donors->count(), ( $give_updates->step * 20 ) ); |
|
1110 | + if ( ! empty($donors)) { |
|
1111 | + $give_updates->set_percentage(Give()->donors->count(), ($give_updates->step * 20)); |
|
1112 | 1112 | |
1113 | 1113 | /* @var Object $donor */ |
1114 | - foreach ( $donors as $donor ) { |
|
1114 | + foreach ($donors as $donor) { |
|
1115 | 1115 | $user_id = $donor->user_id; |
1116 | 1116 | |
1117 | 1117 | // Proceed, if donor is attached with user. |
1118 | - if ( $user_id ) { |
|
1119 | - $user = get_userdata( $user_id ); |
|
1118 | + if ($user_id) { |
|
1119 | + $user = get_userdata($user_id); |
|
1120 | 1120 | |
1121 | 1121 | // Update user role, if user has subscriber role. |
1122 | - if ( is_array( $user->roles ) && in_array( 'subscriber', $user->roles ) ) { |
|
1122 | + if (is_array($user->roles) && in_array('subscriber', $user->roles)) { |
|
1123 | 1123 | wp_update_user( |
1124 | 1124 | array( |
1125 | 1125 | 'ID' => $user_id, |
@@ -1131,7 +1131,7 @@ discard block |
||
1131 | 1131 | } |
1132 | 1132 | } else { |
1133 | 1133 | // The Update Ran. |
1134 | - give_set_upgrade_complete( 'v1813_update_donor_user_roles' ); |
|
1134 | + give_set_upgrade_complete('v1813_update_donor_user_roles'); |
|
1135 | 1135 | } |
1136 | 1136 | } |
1137 | 1137 | |
@@ -1143,7 +1143,7 @@ discard block |
||
1143 | 1143 | */ |
1144 | 1144 | function give_v1813_upgrades() { |
1145 | 1145 | // Update admin setting. |
1146 | - give_update_option( 'donor_default_user_role', 'give_donor' ); |
|
1146 | + give_update_option('donor_default_user_role', 'give_donor'); |
|
1147 | 1147 | |
1148 | 1148 | // Update Give roles. |
1149 | 1149 | $roles = new Give_Roles(); |
@@ -46,24 +46,24 @@ discard block |
||
46 | 46 | */ |
47 | 47 | function __construct() { |
48 | 48 | $this->metabox_id = 'give-metabox-form-data'; |
49 | - $this->metabox_label = __( 'Donation Form Options', 'give' ); |
|
49 | + $this->metabox_label = __('Donation Form Options', 'give'); |
|
50 | 50 | |
51 | 51 | // Setup. |
52 | - add_action( 'admin_init', array( $this, 'setup' ) ); |
|
52 | + add_action('admin_init', array($this, 'setup')); |
|
53 | 53 | |
54 | 54 | // Add metabox. |
55 | - add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ), 10 ); |
|
55 | + add_action('add_meta_boxes', array($this, 'add_meta_box'), 10); |
|
56 | 56 | |
57 | 57 | // Save form meta. |
58 | - add_action( 'save_post_give_forms', array( $this, 'save' ), 10, 2 ); |
|
58 | + add_action('save_post_give_forms', array($this, 'save'), 10, 2); |
|
59 | 59 | |
60 | 60 | // cmb2 old setting loaders. |
61 | 61 | // add_filter( 'give_metabox_form_data_settings', array( $this, 'cmb2_metabox_settings' ) ); |
62 | 62 | // Add offline donations options. |
63 | - add_filter( 'give_metabox_form_data_settings', array( $this, 'add_offline_donations_setting_tab' ), 0, 1 ); |
|
63 | + add_filter('give_metabox_form_data_settings', array($this, 'add_offline_donations_setting_tab'), 0, 1); |
|
64 | 64 | |
65 | 65 | // Maintain active tab query parameter after save. |
66 | - add_filter( 'redirect_post_location', array( $this, 'maintain_active_tab' ), 10, 2 ); |
|
66 | + add_filter('redirect_post_location', array($this, 'maintain_active_tab'), 10, 2); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -85,24 +85,24 @@ discard block |
||
85 | 85 | */ |
86 | 86 | function get_settings() { |
87 | 87 | $post_id = give_get_admin_post_id(); |
88 | - $price = give_get_form_price( $post_id ); |
|
89 | - $custom_amount_minimum = give_get_form_minimum_price( $post_id ); |
|
90 | - $goal = give_format_amount( give_get_form_goal( $post_id ), array( 'sanitize' => false ) ); |
|
91 | - $price_placeholder = give_format_decimal( '1.00', false, false ); |
|
88 | + $price = give_get_form_price($post_id); |
|
89 | + $custom_amount_minimum = give_get_form_minimum_price($post_id); |
|
90 | + $goal = give_format_amount(give_get_form_goal($post_id), array('sanitize' => false)); |
|
91 | + $price_placeholder = give_format_decimal('1.00', false, false); |
|
92 | 92 | |
93 | 93 | // No empty prices - min. 1.00 for new forms |
94 | - if ( empty( $price ) && is_null( $post_id ) ) { |
|
94 | + if (empty($price) && is_null($post_id)) { |
|
95 | 95 | $price = '1.00'; |
96 | 96 | } |
97 | 97 | |
98 | 98 | // Min. $1.00 for new forms |
99 | - if ( empty( $custom_amount_minimum ) ) { |
|
99 | + if (empty($custom_amount_minimum)) { |
|
100 | 100 | $custom_amount_minimum = '1.00'; |
101 | 101 | } |
102 | 102 | |
103 | 103 | // Format amounts. |
104 | - $price = give_format_amount( $price, array( 'sanitize' => false ) ); |
|
105 | - $custom_amount_minimum = give_format_amount( $custom_amount_minimum, array( 'sanitize' => false ) ); |
|
104 | + $price = give_format_amount($price, array('sanitize' => false)); |
|
105 | + $custom_amount_minimum = give_format_amount($custom_amount_minimum, array('sanitize' => false)); |
|
106 | 106 | |
107 | 107 | // Start with an underscore to hide fields from custom fields list |
108 | 108 | $prefix = '_give_'; |
@@ -111,27 +111,27 @@ discard block |
||
111 | 111 | /** |
112 | 112 | * Repeatable Field Groups |
113 | 113 | */ |
114 | - 'form_field_options' => apply_filters( 'give_forms_field_options', array( |
|
114 | + 'form_field_options' => apply_filters('give_forms_field_options', array( |
|
115 | 115 | 'id' => 'form_field_options', |
116 | - 'title' => __( 'Donation Options', 'give' ), |
|
116 | + 'title' => __('Donation Options', 'give'), |
|
117 | 117 | 'icon-html' => '<span class="give-icon give-icon-heart"></span>', |
118 | - 'fields' => apply_filters( 'give_forms_donation_form_metabox_fields', array( |
|
118 | + 'fields' => apply_filters('give_forms_donation_form_metabox_fields', array( |
|
119 | 119 | // Donation Option |
120 | 120 | array( |
121 | - 'name' => __( 'Donation Option', 'give' ), |
|
122 | - 'description' => __( 'Do you want this form to have one set donation price or multiple levels (for example, $10, $20, $50)?', 'give' ), |
|
123 | - 'id' => $prefix . 'price_option', |
|
121 | + 'name' => __('Donation Option', 'give'), |
|
122 | + 'description' => __('Do you want this form to have one set donation price or multiple levels (for example, $10, $20, $50)?', 'give'), |
|
123 | + 'id' => $prefix.'price_option', |
|
124 | 124 | 'type' => 'radio_inline', |
125 | 125 | 'default' => 'set', |
126 | - 'options' => apply_filters( 'give_forms_price_options', array( |
|
127 | - 'set' => __( 'Set Donation', 'give' ), |
|
128 | - 'multi' => __( 'Multi-level Donation', 'give' ), |
|
129 | - ) ), |
|
126 | + 'options' => apply_filters('give_forms_price_options', array( |
|
127 | + 'set' => __('Set Donation', 'give'), |
|
128 | + 'multi' => __('Multi-level Donation', 'give'), |
|
129 | + )), |
|
130 | 130 | ), |
131 | 131 | array( |
132 | - 'name' => __( 'Set Donation', 'give' ), |
|
133 | - 'description' => __( 'This is the set donation amount for this form. If you have a "Custom Amount Minimum" set, make sure it is less than this amount.', 'give' ), |
|
134 | - 'id' => $prefix . 'set_price', |
|
132 | + 'name' => __('Set Donation', 'give'), |
|
133 | + 'description' => __('This is the set donation amount for this form. If you have a "Custom Amount Minimum" set, make sure it is less than this amount.', 'give'), |
|
134 | + 'id' => $prefix.'set_price', |
|
135 | 135 | 'type' => 'text_small', |
136 | 136 | 'data_type' => 'price', |
137 | 137 | 'attributes' => array( |
@@ -142,34 +142,34 @@ discard block |
||
142 | 142 | ), |
143 | 143 | // Display Style |
144 | 144 | array( |
145 | - 'name' => __( 'Display Style', 'give' ), |
|
146 | - 'description' => __( 'Set how the donations levels will display on the form.', 'give' ), |
|
147 | - 'id' => $prefix . 'display_style', |
|
145 | + 'name' => __('Display Style', 'give'), |
|
146 | + 'description' => __('Set how the donations levels will display on the form.', 'give'), |
|
147 | + 'id' => $prefix.'display_style', |
|
148 | 148 | 'type' => 'radio_inline', |
149 | 149 | 'default' => 'buttons', |
150 | 150 | 'options' => array( |
151 | - 'buttons' => __( 'Buttons', 'give' ), |
|
152 | - 'radios' => __( 'Radios', 'give' ), |
|
153 | - 'dropdown' => __( 'Dropdown', 'give' ), |
|
151 | + 'buttons' => __('Buttons', 'give'), |
|
152 | + 'radios' => __('Radios', 'give'), |
|
153 | + 'dropdown' => __('Dropdown', 'give'), |
|
154 | 154 | ), |
155 | 155 | 'wrapper_class' => 'give-hidden', |
156 | 156 | ), |
157 | 157 | // Custom Amount |
158 | 158 | array( |
159 | - 'name' => __( 'Custom Amount', 'give' ), |
|
160 | - 'description' => __( 'Do you want the user to be able to input their own donation amount?', 'give' ), |
|
161 | - 'id' => $prefix . 'custom_amount', |
|
159 | + 'name' => __('Custom Amount', 'give'), |
|
160 | + 'description' => __('Do you want the user to be able to input their own donation amount?', 'give'), |
|
161 | + 'id' => $prefix.'custom_amount', |
|
162 | 162 | 'type' => 'radio_inline', |
163 | 163 | 'default' => 'disabled', |
164 | 164 | 'options' => array( |
165 | - 'enabled' => __( 'Enabled', 'give' ), |
|
166 | - 'disabled' => __( 'Disabled', 'give' ), |
|
165 | + 'enabled' => __('Enabled', 'give'), |
|
166 | + 'disabled' => __('Disabled', 'give'), |
|
167 | 167 | ), |
168 | 168 | ), |
169 | 169 | array( |
170 | - 'name' => __( 'Minimum Amount', 'give' ), |
|
171 | - 'description' => __( 'Enter the minimum custom donation amount.', 'give' ), |
|
172 | - 'id' => $prefix . 'custom_amount_minimum', |
|
170 | + 'name' => __('Minimum Amount', 'give'), |
|
171 | + 'description' => __('Enter the minimum custom donation amount.', 'give'), |
|
172 | + 'id' => $prefix.'custom_amount_minimum', |
|
173 | 173 | 'type' => 'text_small', |
174 | 174 | 'data_type' => 'price', |
175 | 175 | 'attributes' => array( |
@@ -180,37 +180,37 @@ discard block |
||
180 | 180 | 'wrapper_class' => 'give-hidden', |
181 | 181 | ), |
182 | 182 | array( |
183 | - 'name' => __( 'Custom Amount Text', 'give' ), |
|
184 | - 'description' => __( 'This text appears as a label below the custom amount field for set donation forms. For multi-level forms the text will appear as it\'s own level (ie button, radio, or select option).', 'give' ), |
|
185 | - 'id' => $prefix . 'custom_amount_text', |
|
183 | + 'name' => __('Custom Amount Text', 'give'), |
|
184 | + 'description' => __('This text appears as a label below the custom amount field for set donation forms. For multi-level forms the text will appear as it\'s own level (ie button, radio, or select option).', 'give'), |
|
185 | + 'id' => $prefix.'custom_amount_text', |
|
186 | 186 | 'type' => 'text_medium', |
187 | 187 | 'attributes' => array( |
188 | 188 | 'rows' => 3, |
189 | - 'placeholder' => esc_attr__( 'Give a Custom Amount', 'give' ), |
|
189 | + 'placeholder' => esc_attr__('Give a Custom Amount', 'give'), |
|
190 | 190 | ), |
191 | 191 | 'wrapper_class' => 'give-hidden', |
192 | 192 | ), |
193 | 193 | // Donation Levels: Repeatable CMB2 Group |
194 | 194 | array( |
195 | - 'id' => $prefix . 'donation_levels', |
|
195 | + 'id' => $prefix.'donation_levels', |
|
196 | 196 | 'type' => 'group', |
197 | 197 | 'options' => array( |
198 | - 'add_button' => __( 'Add Level', 'give' ), |
|
199 | - 'header_title' => __( 'Donation Level', 'give' ), |
|
198 | + 'add_button' => __('Add Level', 'give'), |
|
199 | + 'header_title' => __('Donation Level', 'give'), |
|
200 | 200 | 'remove_button' => '<span class="dashicons dashicons-no"></span>', |
201 | 201 | ), |
202 | 202 | 'wrapper_class' => 'give-hidden', |
203 | 203 | // Fields array works the same, except id's only need to be unique for this group. |
204 | 204 | // Prefix is not needed. |
205 | - 'fields' => apply_filters( 'give_donation_levels_table_row', array( |
|
205 | + 'fields' => apply_filters('give_donation_levels_table_row', array( |
|
206 | 206 | array( |
207 | - 'name' => __( 'ID', 'give' ), |
|
208 | - 'id' => $prefix . 'id', |
|
207 | + 'name' => __('ID', 'give'), |
|
208 | + 'id' => $prefix.'id', |
|
209 | 209 | 'type' => 'levels_id', |
210 | 210 | ), |
211 | 211 | array( |
212 | - 'name' => __( 'Amount', 'give' ), |
|
213 | - 'id' => $prefix . 'amount', |
|
212 | + 'name' => __('Amount', 'give'), |
|
213 | + 'id' => $prefix.'amount', |
|
214 | 214 | 'type' => 'text_small', |
215 | 215 | 'data_type' => 'price', |
216 | 216 | 'attributes' => array( |
@@ -219,112 +219,112 @@ discard block |
||
219 | 219 | ), |
220 | 220 | ), |
221 | 221 | array( |
222 | - 'name' => __( 'Text', 'give' ), |
|
223 | - 'id' => $prefix . 'text', |
|
222 | + 'name' => __('Text', 'give'), |
|
223 | + 'id' => $prefix.'text', |
|
224 | 224 | 'type' => 'text', |
225 | 225 | 'attributes' => array( |
226 | - 'placeholder' => __( 'Donation Level', 'give' ), |
|
226 | + 'placeholder' => __('Donation Level', 'give'), |
|
227 | 227 | 'class' => 'give-multilevel-text-field', |
228 | 228 | ), |
229 | 229 | ), |
230 | 230 | array( |
231 | - 'name' => __( 'Default', 'give' ), |
|
232 | - 'id' => $prefix . 'default', |
|
231 | + 'name' => __('Default', 'give'), |
|
232 | + 'id' => $prefix.'default', |
|
233 | 233 | 'type' => 'give_default_radio_inline', |
234 | 234 | ), |
235 | - ) ), |
|
235 | + )), |
|
236 | 236 | ), |
237 | 237 | array( |
238 | 238 | 'name' => 'donation_options_docs', |
239 | 239 | 'type' => 'docs_link', |
240 | 240 | 'url' => 'http://docs.givewp.com/form-donation-options', |
241 | - 'title' => __( 'Donation Options', 'give' ), |
|
241 | + 'title' => __('Donation Options', 'give'), |
|
242 | 242 | ), |
243 | 243 | ), |
244 | 244 | $post_id |
245 | 245 | ), |
246 | - ) ), |
|
246 | + )), |
|
247 | 247 | |
248 | 248 | /** |
249 | 249 | * Display Options |
250 | 250 | */ |
251 | - 'form_display_options' => apply_filters( 'give_form_display_options', array( |
|
251 | + 'form_display_options' => apply_filters('give_form_display_options', array( |
|
252 | 252 | 'id' => 'form_display_options', |
253 | - 'title' => __( 'Form Display', 'give' ), |
|
253 | + 'title' => __('Form Display', 'give'), |
|
254 | 254 | 'icon-html' => '<span class="give-icon give-icon-display"></span>', |
255 | - 'fields' => apply_filters( 'give_forms_display_options_metabox_fields', array( |
|
255 | + 'fields' => apply_filters('give_forms_display_options_metabox_fields', array( |
|
256 | 256 | array( |
257 | - 'name' => __( 'Display Options', 'give' ), |
|
258 | - 'desc' => sprintf( __( 'How would you like to display donation information for this form?', 'give' ), '#' ), |
|
259 | - 'id' => $prefix . 'payment_display', |
|
257 | + 'name' => __('Display Options', 'give'), |
|
258 | + 'desc' => sprintf(__('How would you like to display donation information for this form?', 'give'), '#'), |
|
259 | + 'id' => $prefix.'payment_display', |
|
260 | 260 | 'type' => 'radio_inline', |
261 | 261 | 'options' => array( |
262 | - 'onpage' => __( 'All Fields', 'give' ), |
|
263 | - 'modal' => __( 'Modal', 'give' ), |
|
264 | - 'reveal' => __( 'Reveal', 'give' ), |
|
265 | - 'button' => __( 'Button', 'give' ), |
|
262 | + 'onpage' => __('All Fields', 'give'), |
|
263 | + 'modal' => __('Modal', 'give'), |
|
264 | + 'reveal' => __('Reveal', 'give'), |
|
265 | + 'button' => __('Button', 'give'), |
|
266 | 266 | ), |
267 | 267 | 'default' => 'onpage', |
268 | 268 | ), |
269 | 269 | array( |
270 | - 'id' => $prefix . 'reveal_label', |
|
271 | - 'name' => __( 'Continue Button', 'give' ), |
|
272 | - 'desc' => __( 'The button label for displaying the additional payment fields.', 'give' ), |
|
270 | + 'id' => $prefix.'reveal_label', |
|
271 | + 'name' => __('Continue Button', 'give'), |
|
272 | + 'desc' => __('The button label for displaying the additional payment fields.', 'give'), |
|
273 | 273 | 'type' => 'text_small', |
274 | 274 | 'attributes' => array( |
275 | - 'placeholder' => esc_attr__( 'Donate Now', 'give' ), |
|
275 | + 'placeholder' => esc_attr__('Donate Now', 'give'), |
|
276 | 276 | ), |
277 | 277 | 'wrapper_class' => 'give-hidden', |
278 | 278 | ), |
279 | 279 | array( |
280 | - 'id' => $prefix . 'checkout_label', |
|
281 | - 'name' => __( 'Submit Button', 'give' ), |
|
282 | - 'desc' => __( 'The button label for completing a donation.', 'give' ), |
|
280 | + 'id' => $prefix.'checkout_label', |
|
281 | + 'name' => __('Submit Button', 'give'), |
|
282 | + 'desc' => __('The button label for completing a donation.', 'give'), |
|
283 | 283 | 'type' => 'text_small', |
284 | 284 | 'attributes' => array( |
285 | - 'placeholder' => __( 'Donate Now', 'give' ), |
|
285 | + 'placeholder' => __('Donate Now', 'give'), |
|
286 | 286 | ), |
287 | 287 | ), |
288 | 288 | array( |
289 | - 'name' => __( 'Default Gateway', 'give' ), |
|
290 | - 'desc' => __( 'By default, the gateway for this form will inherit the global default gateway (set under Give > Settings > Payment Gateways). This option allows you to customize the default gateway for this form only.', 'give' ), |
|
291 | - 'id' => $prefix . 'default_gateway', |
|
289 | + 'name' => __('Default Gateway', 'give'), |
|
290 | + 'desc' => __('By default, the gateway for this form will inherit the global default gateway (set under Give > Settings > Payment Gateways). This option allows you to customize the default gateway for this form only.', 'give'), |
|
291 | + 'id' => $prefix.'default_gateway', |
|
292 | 292 | 'type' => 'default_gateway', |
293 | 293 | ), |
294 | 294 | array( |
295 | - 'name' => __( 'Guest Donations', 'give' ), |
|
296 | - 'desc' => __( 'Do you want to allow non-logged-in users to make donations?', 'give' ), |
|
297 | - 'id' => $prefix . 'logged_in_only', |
|
295 | + 'name' => __('Guest Donations', 'give'), |
|
296 | + 'desc' => __('Do you want to allow non-logged-in users to make donations?', 'give'), |
|
297 | + 'id' => $prefix.'logged_in_only', |
|
298 | 298 | 'type' => 'radio_inline', |
299 | 299 | 'default' => 'enabled', |
300 | 300 | 'options' => array( |
301 | - 'enabled' => __( 'Enabled', 'give' ), |
|
302 | - 'disabled' => __( 'Disabled', 'give' ), |
|
301 | + 'enabled' => __('Enabled', 'give'), |
|
302 | + 'disabled' => __('Disabled', 'give'), |
|
303 | 303 | ), |
304 | 304 | ), |
305 | 305 | array( |
306 | - 'name' => __( 'Registration', 'give' ), |
|
307 | - 'desc' => __( 'Display the registration and login forms in the payment section for non-logged-in users.', 'give' ), |
|
308 | - 'id' => $prefix . 'show_register_form', |
|
306 | + 'name' => __('Registration', 'give'), |
|
307 | + 'desc' => __('Display the registration and login forms in the payment section for non-logged-in users.', 'give'), |
|
308 | + 'id' => $prefix.'show_register_form', |
|
309 | 309 | 'type' => 'radio', |
310 | 310 | 'options' => array( |
311 | - 'none' => __( 'None', 'give' ), |
|
312 | - 'registration' => __( 'Registration', 'give' ), |
|
313 | - 'login' => __( 'Login', 'give' ), |
|
314 | - 'both' => __( 'Registration + Login', 'give' ), |
|
311 | + 'none' => __('None', 'give'), |
|
312 | + 'registration' => __('Registration', 'give'), |
|
313 | + 'login' => __('Login', 'give'), |
|
314 | + 'both' => __('Registration + Login', 'give'), |
|
315 | 315 | ), |
316 | 316 | 'default' => 'none', |
317 | 317 | ), |
318 | 318 | array( |
319 | - 'name' => __( 'Floating Labels', 'give' ), |
|
319 | + 'name' => __('Floating Labels', 'give'), |
|
320 | 320 | /* translators: %s: forms http://docs.givewp.com/form-floating-labels */ |
321 | - 'desc' => sprintf( __( 'Select the <a href="%s" target="_blank">floating labels</a> setting for this Give form. Be aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give' ), esc_url( 'http://docs.givewp.com/form-floating-labels' ) ), |
|
322 | - 'id' => $prefix . 'form_floating_labels', |
|
321 | + 'desc' => sprintf(__('Select the <a href="%s" target="_blank">floating labels</a> setting for this Give form. Be aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give'), esc_url('http://docs.givewp.com/form-floating-labels')), |
|
322 | + 'id' => $prefix.'form_floating_labels', |
|
323 | 323 | 'type' => 'radio_inline', |
324 | 324 | 'options' => array( |
325 | - 'global' => __( 'Global Option', 'give' ), |
|
326 | - 'enabled' => __( 'Enabled', 'give' ), |
|
327 | - 'disabled' => __( 'Disabled', 'give' ), |
|
325 | + 'global' => __('Global Option', 'give'), |
|
326 | + 'enabled' => __('Enabled', 'give'), |
|
327 | + 'disabled' => __('Disabled', 'give'), |
|
328 | 328 | ), |
329 | 329 | 'default' => 'global', |
330 | 330 | ), |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | 'name' => 'form_display_docs', |
333 | 333 | 'type' => 'docs_link', |
334 | 334 | 'url' => 'http://docs.givewp.com/form-display-options', |
335 | - 'title' => __( 'Form Display', 'give' ), |
|
335 | + 'title' => __('Form Display', 'give'), |
|
336 | 336 | ), |
337 | 337 | ), |
338 | 338 | $post_id |
@@ -343,31 +343,31 @@ discard block |
||
343 | 343 | /** |
344 | 344 | * Donation Goals |
345 | 345 | */ |
346 | - 'donation_goal_options' => apply_filters( 'give_donation_goal_options', array( |
|
346 | + 'donation_goal_options' => apply_filters('give_donation_goal_options', array( |
|
347 | 347 | 'id' => 'donation_goal_options', |
348 | - 'title' => __( 'Donation Goal', 'give' ), |
|
348 | + 'title' => __('Donation Goal', 'give'), |
|
349 | 349 | 'icon-html' => '<span class="give-icon give-icon-target"></span>', |
350 | - 'fields' => apply_filters( 'give_forms_donation_goal_metabox_fields', array( |
|
350 | + 'fields' => apply_filters('give_forms_donation_goal_metabox_fields', array( |
|
351 | 351 | // Goals |
352 | 352 | array( |
353 | - 'name' => __( 'Donation Goal', 'give' ), |
|
354 | - 'description' => __( 'Do you want to set a donation goal for this form?', 'give' ), |
|
355 | - 'id' => $prefix . 'goal_option', |
|
353 | + 'name' => __('Donation Goal', 'give'), |
|
354 | + 'description' => __('Do you want to set a donation goal for this form?', 'give'), |
|
355 | + 'id' => $prefix.'goal_option', |
|
356 | 356 | 'type' => 'radio_inline', |
357 | 357 | 'default' => 'disabled', |
358 | 358 | 'options' => array( |
359 | - 'enabled' => __( 'Enabled', 'give' ), |
|
360 | - 'disabled' => __( 'Disabled', 'give' ), |
|
359 | + 'enabled' => __('Enabled', 'give'), |
|
360 | + 'disabled' => __('Disabled', 'give'), |
|
361 | 361 | ), |
362 | 362 | ), |
363 | 363 | array( |
364 | - 'name' => __( 'Goal Amount', 'give' ), |
|
365 | - 'description' => __( 'This is the monetary goal amount you want to reach for this form.', 'give' ), |
|
366 | - 'id' => $prefix . 'set_goal', |
|
364 | + 'name' => __('Goal Amount', 'give'), |
|
365 | + 'description' => __('This is the monetary goal amount you want to reach for this form.', 'give'), |
|
366 | + 'id' => $prefix.'set_goal', |
|
367 | 367 | 'type' => 'text_small', |
368 | 368 | 'data_type' => 'price', |
369 | 369 | 'attributes' => array( |
370 | - 'placeholder' => give_format_decimal( '0.00', false, false ), |
|
370 | + 'placeholder' => give_format_decimal('0.00', false, false), |
|
371 | 371 | 'value' => $goal, |
372 | 372 | 'class' => 'give-money-field', |
373 | 373 | ), |
@@ -375,97 +375,97 @@ discard block |
||
375 | 375 | ), |
376 | 376 | |
377 | 377 | array( |
378 | - 'name' => __( 'Goal Format', 'give' ), |
|
379 | - 'description' => __( 'Do you want to display the total amount raised based on your monetary goal or a percentage? For instance, "$500 of $1,000 raised" or "50% funded".', 'give' ), |
|
380 | - 'id' => $prefix . 'goal_format', |
|
378 | + 'name' => __('Goal Format', 'give'), |
|
379 | + 'description' => __('Do you want to display the total amount raised based on your monetary goal or a percentage? For instance, "$500 of $1,000 raised" or "50% funded".', 'give'), |
|
380 | + 'id' => $prefix.'goal_format', |
|
381 | 381 | 'type' => 'radio_inline', |
382 | 382 | 'default' => 'amount', |
383 | 383 | 'options' => array( |
384 | - 'amount' => __( 'Amount', 'give' ), |
|
385 | - 'percentage' => __( 'Percentage', 'give' ), |
|
384 | + 'amount' => __('Amount', 'give'), |
|
385 | + 'percentage' => __('Percentage', 'give'), |
|
386 | 386 | ), |
387 | 387 | 'wrapper_class' => 'give-hidden', |
388 | 388 | ), |
389 | 389 | array( |
390 | - 'name' => __( 'Progress Bar Color', 'give' ), |
|
391 | - 'desc' => __( 'Customize the color of the goal progress bar.', 'give' ), |
|
392 | - 'id' => $prefix . 'goal_color', |
|
390 | + 'name' => __('Progress Bar Color', 'give'), |
|
391 | + 'desc' => __('Customize the color of the goal progress bar.', 'give'), |
|
392 | + 'id' => $prefix.'goal_color', |
|
393 | 393 | 'type' => 'colorpicker', |
394 | 394 | 'default' => '#2bc253', |
395 | 395 | 'wrapper_class' => 'give-hidden', |
396 | 396 | ), |
397 | 397 | |
398 | 398 | array( |
399 | - 'name' => __( 'Close Form', 'give' ), |
|
400 | - 'desc' => __( 'Do you want to close the donation forms and stop accepting donations once this goal has been met?', 'give' ), |
|
401 | - 'id' => $prefix . 'close_form_when_goal_achieved', |
|
399 | + 'name' => __('Close Form', 'give'), |
|
400 | + 'desc' => __('Do you want to close the donation forms and stop accepting donations once this goal has been met?', 'give'), |
|
401 | + 'id' => $prefix.'close_form_when_goal_achieved', |
|
402 | 402 | 'type' => 'radio_inline', |
403 | 403 | 'default' => 'disabled', |
404 | 404 | 'options' => array( |
405 | - 'enabled' => __( 'Enabled', 'give' ), |
|
406 | - 'disabled' => __( 'Disabled', 'give' ), |
|
405 | + 'enabled' => __('Enabled', 'give'), |
|
406 | + 'disabled' => __('Disabled', 'give'), |
|
407 | 407 | ), |
408 | 408 | 'wrapper_class' => 'give-hidden', |
409 | 409 | ), |
410 | 410 | array( |
411 | - 'name' => __( 'Goal Achieved Message', 'give' ), |
|
412 | - 'desc' => __( 'Do you want to display a custom message when the goal is closed?', 'give' ), |
|
413 | - 'id' => $prefix . 'form_goal_achieved_message', |
|
411 | + 'name' => __('Goal Achieved Message', 'give'), |
|
412 | + 'desc' => __('Do you want to display a custom message when the goal is closed?', 'give'), |
|
413 | + 'id' => $prefix.'form_goal_achieved_message', |
|
414 | 414 | 'type' => 'wysiwyg', |
415 | - 'default' => __( 'Thank you to all our donors, we have met our fundraising goal.', 'give' ), |
|
415 | + 'default' => __('Thank you to all our donors, we have met our fundraising goal.', 'give'), |
|
416 | 416 | 'wrapper_class' => 'give-hidden', |
417 | 417 | ), |
418 | 418 | array( |
419 | 419 | 'name' => 'donation_goal_docs', |
420 | 420 | 'type' => 'docs_link', |
421 | 421 | 'url' => 'http://docs.givewp.com/form-donation-goal', |
422 | - 'title' => __( 'Donation Goal', 'give' ), |
|
422 | + 'title' => __('Donation Goal', 'give'), |
|
423 | 423 | ), |
424 | 424 | ), |
425 | 425 | $post_id |
426 | 426 | ), |
427 | - ) ), |
|
427 | + )), |
|
428 | 428 | |
429 | 429 | /** |
430 | 430 | * Content Field |
431 | 431 | */ |
432 | - 'form_content_options' => apply_filters( 'give_forms_content_options', array( |
|
432 | + 'form_content_options' => apply_filters('give_forms_content_options', array( |
|
433 | 433 | 'id' => 'form_content_options', |
434 | - 'title' => __( 'Form Content', 'give' ), |
|
434 | + 'title' => __('Form Content', 'give'), |
|
435 | 435 | 'icon-html' => '<span class="give-icon give-icon-edit"></span>', |
436 | - 'fields' => apply_filters( 'give_forms_content_options_metabox_fields', array( |
|
436 | + 'fields' => apply_filters('give_forms_content_options_metabox_fields', array( |
|
437 | 437 | |
438 | 438 | // Donation content. |
439 | 439 | array( |
440 | - 'name' => __( 'Display Content', 'give' ), |
|
441 | - 'description' => __( 'Do you want to add custom content to this form?', 'give' ), |
|
442 | - 'id' => $prefix . 'display_content', |
|
440 | + 'name' => __('Display Content', 'give'), |
|
441 | + 'description' => __('Do you want to add custom content to this form?', 'give'), |
|
442 | + 'id' => $prefix.'display_content', |
|
443 | 443 | 'type' => 'radio_inline', |
444 | 444 | 'options' => array( |
445 | - 'enabled' => __( 'Enabled', 'give' ), |
|
446 | - 'disabled' => __( 'Disabled', 'give' ), |
|
445 | + 'enabled' => __('Enabled', 'give'), |
|
446 | + 'disabled' => __('Disabled', 'give'), |
|
447 | 447 | ), |
448 | 448 | 'default' => 'disabled', |
449 | 449 | ), |
450 | 450 | |
451 | 451 | // Content placement. |
452 | 452 | array( |
453 | - 'name' => __( 'Content Placement', 'give' ), |
|
454 | - 'description' => __( 'This option controls where the content appears within the donation form.', 'give' ), |
|
455 | - 'id' => $prefix . 'content_placement', |
|
453 | + 'name' => __('Content Placement', 'give'), |
|
454 | + 'description' => __('This option controls where the content appears within the donation form.', 'give'), |
|
455 | + 'id' => $prefix.'content_placement', |
|
456 | 456 | 'type' => 'radio_inline', |
457 | - 'options' => apply_filters( 'give_forms_content_options_select', array( |
|
458 | - 'give_pre_form' => __( 'Above fields', 'give' ), |
|
459 | - 'give_post_form' => __( 'Below fields', 'give' ), |
|
457 | + 'options' => apply_filters('give_forms_content_options_select', array( |
|
458 | + 'give_pre_form' => __('Above fields', 'give'), |
|
459 | + 'give_post_form' => __('Below fields', 'give'), |
|
460 | 460 | ) |
461 | 461 | ), |
462 | 462 | 'default' => 'give_pre_form', |
463 | 463 | 'wrapper_class' => 'give-hidden', |
464 | 464 | ), |
465 | 465 | array( |
466 | - 'name' => __( 'Content', 'give' ), |
|
467 | - 'description' => __( 'This content will display on the single give form page.', 'give' ), |
|
468 | - 'id' => $prefix . 'form_content', |
|
466 | + 'name' => __('Content', 'give'), |
|
467 | + 'description' => __('This content will display on the single give form page.', 'give'), |
|
468 | + 'id' => $prefix.'form_content', |
|
469 | 469 | 'type' => 'wysiwyg', |
470 | 470 | 'wrapper_class' => 'give-hidden', |
471 | 471 | ), |
@@ -473,51 +473,51 @@ discard block |
||
473 | 473 | 'name' => 'form_content_docs', |
474 | 474 | 'type' => 'docs_link', |
475 | 475 | 'url' => 'http://docs.givewp.com/form-content', |
476 | - 'title' => __( 'Form Content', 'give' ), |
|
476 | + 'title' => __('Form Content', 'give'), |
|
477 | 477 | ), |
478 | 478 | ), |
479 | 479 | $post_id |
480 | 480 | ), |
481 | - ) ), |
|
481 | + )), |
|
482 | 482 | |
483 | 483 | /** |
484 | 484 | * Terms & Conditions |
485 | 485 | */ |
486 | - 'form_terms_options' => apply_filters( 'give_forms_terms_options', array( |
|
486 | + 'form_terms_options' => apply_filters('give_forms_terms_options', array( |
|
487 | 487 | 'id' => 'form_terms_options', |
488 | - 'title' => __( 'Terms & Conditions', 'give' ), |
|
488 | + 'title' => __('Terms & Conditions', 'give'), |
|
489 | 489 | 'icon-html' => '<span class="give-icon give-icon-checklist"></span>', |
490 | - 'fields' => apply_filters( 'give_forms_terms_options_metabox_fields', array( |
|
490 | + 'fields' => apply_filters('give_forms_terms_options_metabox_fields', array( |
|
491 | 491 | // Donation Option |
492 | 492 | array( |
493 | - 'name' => __( 'Terms and Conditions', 'give' ), |
|
494 | - 'description' => __( 'Do you want to require the donor to accept terms prior to being able to complete their donation?', 'give' ), |
|
495 | - 'id' => $prefix . 'terms_option', |
|
493 | + 'name' => __('Terms and Conditions', 'give'), |
|
494 | + 'description' => __('Do you want to require the donor to accept terms prior to being able to complete their donation?', 'give'), |
|
495 | + 'id' => $prefix.'terms_option', |
|
496 | 496 | 'type' => 'radio_inline', |
497 | - 'options' => apply_filters( 'give_forms_content_options_select', array( |
|
498 | - 'global' => __( 'Global Option', 'give' ), |
|
499 | - 'enabled' => __( 'Customize', 'give' ), |
|
500 | - 'disabled' => __( 'Disable', 'give' ), |
|
497 | + 'options' => apply_filters('give_forms_content_options_select', array( |
|
498 | + 'global' => __('Global Option', 'give'), |
|
499 | + 'enabled' => __('Customize', 'give'), |
|
500 | + 'disabled' => __('Disable', 'give'), |
|
501 | 501 | ) |
502 | 502 | ), |
503 | 503 | 'default' => 'global', |
504 | 504 | ), |
505 | 505 | array( |
506 | - 'id' => $prefix . 'agree_label', |
|
507 | - 'name' => __( 'Agreement Label', 'give' ), |
|
508 | - 'desc' => __( 'The label shown next to the agree to terms check box. Add your own to customize or leave blank to use the default text placeholder.', 'give' ), |
|
506 | + 'id' => $prefix.'agree_label', |
|
507 | + 'name' => __('Agreement Label', 'give'), |
|
508 | + 'desc' => __('The label shown next to the agree to terms check box. Add your own to customize or leave blank to use the default text placeholder.', 'give'), |
|
509 | 509 | 'type' => 'text', |
510 | 510 | 'size' => 'regular', |
511 | 511 | 'attributes' => array( |
512 | - 'placeholder' => esc_attr__( 'Agree to Terms?', 'give' ), |
|
512 | + 'placeholder' => esc_attr__('Agree to Terms?', 'give'), |
|
513 | 513 | ), |
514 | 514 | 'wrapper_class' => 'give-hidden', |
515 | 515 | ), |
516 | 516 | array( |
517 | - 'id' => $prefix . 'agree_text', |
|
518 | - 'name' => __( 'Agreement Text', 'give' ), |
|
519 | - 'desc' => __( 'This is the actual text which the user will have to agree to in order to make a donation.', 'give' ), |
|
520 | - 'default' => give_get_option( 'agreement_text' ), |
|
517 | + 'id' => $prefix.'agree_text', |
|
518 | + 'name' => __('Agreement Text', 'give'), |
|
519 | + 'desc' => __('This is the actual text which the user will have to agree to in order to make a donation.', 'give'), |
|
520 | + 'default' => give_get_option('agreement_text'), |
|
521 | 521 | 'type' => 'wysiwyg', |
522 | 522 | 'wrapper_class' => 'give-hidden', |
523 | 523 | ), |
@@ -525,18 +525,18 @@ discard block |
||
525 | 525 | 'name' => 'terms_docs', |
526 | 526 | 'type' => 'docs_link', |
527 | 527 | 'url' => 'http://docs.givewp.com/form-terms', |
528 | - 'title' => __( 'Terms and Conditions', 'give' ), |
|
528 | + 'title' => __('Terms and Conditions', 'give'), |
|
529 | 529 | ), |
530 | 530 | ), |
531 | 531 | $post_id |
532 | 532 | ), |
533 | - ) ), |
|
533 | + )), |
|
534 | 534 | ); |
535 | 535 | |
536 | 536 | /** |
537 | 537 | * Filter the metabox tabbed panel settings. |
538 | 538 | */ |
539 | - $settings = apply_filters( 'give_metabox_form_data_settings', $settings, $post_id ); |
|
539 | + $settings = apply_filters('give_metabox_form_data_settings', $settings, $post_id); |
|
540 | 540 | |
541 | 541 | // Output. |
542 | 542 | return $settings; |
@@ -552,8 +552,8 @@ discard block |
||
552 | 552 | add_meta_box( |
553 | 553 | $this->get_metabox_ID(), |
554 | 554 | $this->get_metabox_label(), |
555 | - array( $this, 'output' ), |
|
556 | - array( 'give_forms' ), |
|
555 | + array($this, 'output'), |
|
556 | + array('give_forms'), |
|
557 | 557 | 'normal', |
558 | 558 | 'high' |
559 | 559 | ); |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | function enqueue_script() { |
570 | 570 | global $post; |
571 | 571 | |
572 | - if ( is_object( $post ) && 'give_forms' === $post->post_type ) { |
|
572 | + if (is_object($post) && 'give_forms' === $post->post_type) { |
|
573 | 573 | |
574 | 574 | } |
575 | 575 | } |
@@ -604,32 +604,32 @@ discard block |
||
604 | 604 | public function get_tabs() { |
605 | 605 | $tabs = array(); |
606 | 606 | |
607 | - if ( ! empty( $this->settings ) ) { |
|
608 | - foreach ( $this->settings as $setting ) { |
|
609 | - if ( ! isset( $setting['id'] ) || ! isset( $setting['title'] ) ) { |
|
607 | + if ( ! empty($this->settings)) { |
|
608 | + foreach ($this->settings as $setting) { |
|
609 | + if ( ! isset($setting['id']) || ! isset($setting['title'])) { |
|
610 | 610 | continue; |
611 | 611 | } |
612 | 612 | $tab = array( |
613 | 613 | 'id' => $setting['id'], |
614 | 614 | 'label' => $setting['title'], |
615 | - 'icon-html' => ( ! empty( $setting['icon-html'] ) ? $setting['icon-html'] : '' ), |
|
615 | + 'icon-html' => ( ! empty($setting['icon-html']) ? $setting['icon-html'] : ''), |
|
616 | 616 | ); |
617 | 617 | |
618 | - if ( $this->has_sub_tab( $setting ) ) { |
|
619 | - if ( empty( $setting['sub-fields'] ) ) { |
|
618 | + if ($this->has_sub_tab($setting)) { |
|
619 | + if (empty($setting['sub-fields'])) { |
|
620 | 620 | $tab = array(); |
621 | 621 | } else { |
622 | - foreach ( $setting['sub-fields'] as $sub_fields ) { |
|
622 | + foreach ($setting['sub-fields'] as $sub_fields) { |
|
623 | 623 | $tab['sub-fields'][] = array( |
624 | 624 | 'id' => $sub_fields['id'], |
625 | 625 | 'label' => $sub_fields['title'], |
626 | - 'icon-html' => ( ! empty( $sub_fields['icon-html'] ) ? $sub_fields['icon-html'] : '' ), |
|
626 | + 'icon-html' => ( ! empty($sub_fields['icon-html']) ? $sub_fields['icon-html'] : ''), |
|
627 | 627 | ); |
628 | 628 | } |
629 | 629 | } |
630 | 630 | } |
631 | 631 | |
632 | - if ( ! empty( $tab ) ) { |
|
632 | + if ( ! empty($tab)) { |
|
633 | 633 | $tabs[] = $tab; |
634 | 634 | } |
635 | 635 | } |
@@ -646,33 +646,33 @@ discard block |
||
646 | 646 | */ |
647 | 647 | public function output() { |
648 | 648 | // Bailout. |
649 | - if ( $form_data_tabs = $this->get_tabs() ) : |
|
650 | - $active_tab = ! empty( $_GET['give_tab'] ) ? give_clean( $_GET['give_tab'] ) : 'form_field_options'; |
|
651 | - wp_nonce_field( 'give_save_form_meta', 'give_form_meta_nonce' ); |
|
649 | + if ($form_data_tabs = $this->get_tabs()) : |
|
650 | + $active_tab = ! empty($_GET['give_tab']) ? give_clean($_GET['give_tab']) : 'form_field_options'; |
|
651 | + wp_nonce_field('give_save_form_meta', 'give_form_meta_nonce'); |
|
652 | 652 | ?> |
653 | 653 | <input id="give_form_active_tab" type="hidden" name="give_form_active_tab"> |
654 | 654 | <div class="give-metabox-panel-wrap"> |
655 | 655 | <ul class="give-form-data-tabs give-metabox-tabs"> |
656 | - <?php foreach ( $form_data_tabs as $index => $form_data_tab ) : ?> |
|
656 | + <?php foreach ($form_data_tabs as $index => $form_data_tab) : ?> |
|
657 | 657 | <?php |
658 | 658 | // Determine if current tab is active. |
659 | 659 | $is_active = $active_tab === $form_data_tab['id'] ? true : false; |
660 | 660 | ?> |
661 | - <li class="<?php echo "{$form_data_tab['id']}_tab" . ( $is_active ? ' active' : '' ) . ( $this->has_sub_tab( $form_data_tab ) ? ' has-sub-fields' : '' ); ?>"> |
|
661 | + <li class="<?php echo "{$form_data_tab['id']}_tab".($is_active ? ' active' : '').($this->has_sub_tab($form_data_tab) ? ' has-sub-fields' : ''); ?>"> |
|
662 | 662 | <a href="#<?php echo $form_data_tab['id']; ?>" data-tab-id="<?php echo $form_data_tab['id']; ?>"> |
663 | - <?php if ( ! empty( $form_data_tab['icon-html'] ) ) : ?> |
|
663 | + <?php if ( ! empty($form_data_tab['icon-html'])) : ?> |
|
664 | 664 | <?php echo $form_data_tab['icon-html']; ?> |
665 | 665 | <?php else : ?> |
666 | 666 | <span class="give-icon give-icon-default"></span> |
667 | 667 | <?php endif; ?> |
668 | 668 | <span class="give-label"><?php echo $form_data_tab['label']; ?></span> |
669 | 669 | </a> |
670 | - <?php if ( $this->has_sub_tab( $form_data_tab ) ) : ?> |
|
670 | + <?php if ($this->has_sub_tab($form_data_tab)) : ?> |
|
671 | 671 | <ul class="give-metabox-sub-tabs give-hidden"> |
672 | - <?php foreach ( $form_data_tab['sub-fields'] as $sub_tab ) : ?> |
|
672 | + <?php foreach ($form_data_tab['sub-fields'] as $sub_tab) : ?> |
|
673 | 673 | <li class="<?php echo "{$sub_tab['id']}_tab"; ?>"> |
674 | 674 | <a href="#<?php echo $sub_tab['id']; ?>" data-tab-id="<?php echo $sub_tab['id']; ?>"> |
675 | - <?php if ( ! empty( $sub_tab['icon-html'] ) ) : ?> |
|
675 | + <?php if ( ! empty($sub_tab['icon-html'])) : ?> |
|
676 | 676 | <?php echo $sub_tab['icon-html']; ?> |
677 | 677 | <?php else : ?> |
678 | 678 | <span class="give-icon give-icon-default"></span> |
@@ -687,30 +687,30 @@ discard block |
||
687 | 687 | <?php endforeach; ?> |
688 | 688 | </ul> |
689 | 689 | |
690 | - <?php foreach ( $this->settings as $setting ) : ?> |
|
691 | - <?php if ( ! $this->has_sub_tab( $setting ) ) : ?> |
|
692 | - <?php do_action( "give_before_{$setting['id']}_settings" ); ?> |
|
690 | + <?php foreach ($this->settings as $setting) : ?> |
|
691 | + <?php if ( ! $this->has_sub_tab($setting)) : ?> |
|
692 | + <?php do_action("give_before_{$setting['id']}_settings"); ?> |
|
693 | 693 | <?php |
694 | 694 | // Determine if current panel is active. |
695 | 695 | $is_active = $active_tab === $setting['id'] ? true : false; |
696 | 696 | ?> |
697 | - <div id="<?php echo $setting['id']; ?>" class="panel give_options_panel<?php echo( $is_active ? ' active' : '' ); ?>"> |
|
698 | - <?php if ( ! empty( $setting['fields'] ) ) : ?> |
|
699 | - <?php foreach ( $setting['fields'] as $field ) : ?> |
|
700 | - <?php give_render_field( $field ); ?> |
|
697 | + <div id="<?php echo $setting['id']; ?>" class="panel give_options_panel<?php echo($is_active ? ' active' : ''); ?>"> |
|
698 | + <?php if ( ! empty($setting['fields'])) : ?> |
|
699 | + <?php foreach ($setting['fields'] as $field) : ?> |
|
700 | + <?php give_render_field($field); ?> |
|
701 | 701 | <?php endforeach; ?> |
702 | 702 | <?php endif; ?> |
703 | 703 | </div> |
704 | 704 | |
705 | - <?php do_action( "give_after_{$setting['id']}_settings" ); ?> |
|
705 | + <?php do_action("give_after_{$setting['id']}_settings"); ?> |
|
706 | 706 | <?php else : ?> |
707 | - <?php if ( $this->has_sub_tab( $setting ) ) : ?> |
|
708 | - <?php if ( ! empty( $setting['sub-fields'] ) ) : ?> |
|
709 | - <?php foreach ( $setting['sub-fields'] as $index => $sub_fields ) : ?> |
|
707 | + <?php if ($this->has_sub_tab($setting)) : ?> |
|
708 | + <?php if ( ! empty($setting['sub-fields'])) : ?> |
|
709 | + <?php foreach ($setting['sub-fields'] as $index => $sub_fields) : ?> |
|
710 | 710 | <div id="<?php echo $sub_fields['id']; ?>" class="panel give_options_panel give-hidden"> |
711 | - <?php if ( ! empty( $sub_fields['fields'] ) ) : ?> |
|
712 | - <?php foreach ( $sub_fields['fields'] as $sub_field ) : ?> |
|
713 | - <?php give_render_field( $sub_field ); ?> |
|
711 | + <?php if ( ! empty($sub_fields['fields'])) : ?> |
|
712 | + <?php foreach ($sub_fields['fields'] as $sub_field) : ?> |
|
713 | + <?php give_render_field($sub_field); ?> |
|
714 | 714 | <?php endforeach; ?> |
715 | 715 | <?php endif; ?> |
716 | 716 | </div> |
@@ -734,9 +734,9 @@ discard block |
||
734 | 734 | * |
735 | 735 | * @return bool |
736 | 736 | */ |
737 | - private function has_sub_tab( $field_setting ) { |
|
737 | + private function has_sub_tab($field_setting) { |
|
738 | 738 | $has_sub_tab = false; |
739 | - if ( array_key_exists( 'sub-fields', $field_setting ) ) { |
|
739 | + if (array_key_exists('sub-fields', $field_setting)) { |
|
740 | 740 | $has_sub_tab = true; |
741 | 741 | } |
742 | 742 | |
@@ -750,13 +750,13 @@ discard block |
||
750 | 750 | * @return array |
751 | 751 | */ |
752 | 752 | function cmb2_metabox_settings() { |
753 | - $all_cmb2_settings = apply_filters( 'cmb2_meta_boxes', array() ); |
|
753 | + $all_cmb2_settings = apply_filters('cmb2_meta_boxes', array()); |
|
754 | 754 | $give_forms_settings = $all_cmb2_settings; |
755 | 755 | |
756 | 756 | // Filter settings: Use only give forms related settings. |
757 | - foreach ( $all_cmb2_settings as $index => $setting ) { |
|
758 | - if ( ! in_array( 'give_forms', $setting['object_types'] ) ) { |
|
759 | - unset( $give_forms_settings[ $index ] ); |
|
757 | + foreach ($all_cmb2_settings as $index => $setting) { |
|
758 | + if ( ! in_array('give_forms', $setting['object_types'])) { |
|
759 | + unset($give_forms_settings[$index]); |
|
760 | 760 | } |
761 | 761 | } |
762 | 762 | |
@@ -774,96 +774,96 @@ discard block |
||
774 | 774 | * |
775 | 775 | * @return void |
776 | 776 | */ |
777 | - public function save( $post_id, $post ) { |
|
777 | + public function save($post_id, $post) { |
|
778 | 778 | |
779 | 779 | // $post_id and $post are required. |
780 | - if ( empty( $post_id ) || empty( $post ) ) { |
|
780 | + if (empty($post_id) || empty($post)) { |
|
781 | 781 | return; |
782 | 782 | } |
783 | 783 | |
784 | 784 | // Don't save meta boxes for revisions or autosaves. |
785 | - if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
785 | + if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) { |
|
786 | 786 | return; |
787 | 787 | } |
788 | 788 | |
789 | 789 | // Check the nonce. |
790 | - if ( empty( $_POST['give_form_meta_nonce'] ) || ! wp_verify_nonce( $_POST['give_form_meta_nonce'], 'give_save_form_meta' ) ) { |
|
790 | + if (empty($_POST['give_form_meta_nonce']) || ! wp_verify_nonce($_POST['give_form_meta_nonce'], 'give_save_form_meta')) { |
|
791 | 791 | return; |
792 | 792 | } |
793 | 793 | |
794 | 794 | // Check the post being saved == the $post_id to prevent triggering this call for other save_post events. |
795 | - if ( empty( $_POST['post_ID'] ) || $_POST['post_ID'] != $post_id ) { |
|
795 | + if (empty($_POST['post_ID']) || $_POST['post_ID'] != $post_id) { |
|
796 | 796 | return; |
797 | 797 | } |
798 | 798 | |
799 | 799 | // Check user has permission to edit. |
800 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
800 | + if ( ! current_user_can('edit_post', $post_id)) { |
|
801 | 801 | return; |
802 | 802 | } |
803 | 803 | |
804 | 804 | // Fire action before saving form meta. |
805 | - do_action( 'give_pre_process_give_forms_meta', $post_id, $post ); |
|
805 | + do_action('give_pre_process_give_forms_meta', $post_id, $post); |
|
806 | 806 | |
807 | 807 | /** |
808 | 808 | * Filter the meta key to save. |
809 | 809 | * Third party addon developer can remove there meta keys from this array to handle saving data on there own. |
810 | 810 | */ |
811 | - $form_meta_keys = apply_filters( 'give_process_form_meta_keys', $this->get_meta_keys_from_settings() ); |
|
811 | + $form_meta_keys = apply_filters('give_process_form_meta_keys', $this->get_meta_keys_from_settings()); |
|
812 | 812 | |
813 | 813 | // Save form meta data. |
814 | - if ( ! empty( $form_meta_keys ) ) { |
|
815 | - foreach ( $form_meta_keys as $form_meta_key ) { |
|
814 | + if ( ! empty($form_meta_keys)) { |
|
815 | + foreach ($form_meta_keys as $form_meta_key) { |
|
816 | 816 | |
817 | 817 | // Set default value for checkbox fields. |
818 | 818 | if ( |
819 | - ! isset( $_POST[ $form_meta_key ] ) |
|
820 | - && ( 'checkbox' === $this->get_field_type( $form_meta_key ) ) |
|
819 | + ! isset($_POST[$form_meta_key]) |
|
820 | + && ('checkbox' === $this->get_field_type($form_meta_key)) |
|
821 | 821 | ) { |
822 | - $_POST[ $form_meta_key ] = ''; |
|
822 | + $_POST[$form_meta_key] = ''; |
|
823 | 823 | } |
824 | 824 | |
825 | - if ( isset( $_POST[ $form_meta_key ] ) ) { |
|
826 | - $setting_field = $this->get_setting_field( $form_meta_key ); |
|
827 | - if ( ! empty( $setting_field['type'] ) ) { |
|
828 | - switch ( $setting_field['type'] ) { |
|
825 | + if (isset($_POST[$form_meta_key])) { |
|
826 | + $setting_field = $this->get_setting_field($form_meta_key); |
|
827 | + if ( ! empty($setting_field['type'])) { |
|
828 | + switch ($setting_field['type']) { |
|
829 | 829 | case 'textarea': |
830 | 830 | case 'wysiwyg': |
831 | - $form_meta_value = wp_kses_post( $_POST[ $form_meta_key ] ); |
|
831 | + $form_meta_value = wp_kses_post($_POST[$form_meta_key]); |
|
832 | 832 | break; |
833 | 833 | |
834 | 834 | case 'group': |
835 | 835 | $form_meta_value = array(); |
836 | 836 | |
837 | - foreach ( $_POST[ $form_meta_key ] as $index => $group ) { |
|
837 | + foreach ($_POST[$form_meta_key] as $index => $group) { |
|
838 | 838 | |
839 | 839 | // Do not save template input field values. |
840 | - if ( '{{row-count-placeholder}}' === $index ) { |
|
840 | + if ('{{row-count-placeholder}}' === $index) { |
|
841 | 841 | continue; |
842 | 842 | } |
843 | 843 | |
844 | 844 | $group_meta_value = array(); |
845 | - foreach ( $group as $field_id => $field_value ) { |
|
846 | - switch ( $this->get_field_type( $field_id, $form_meta_key ) ) { |
|
845 | + foreach ($group as $field_id => $field_value) { |
|
846 | + switch ($this->get_field_type($field_id, $form_meta_key)) { |
|
847 | 847 | case 'wysiwyg': |
848 | - $group_meta_value[ $field_id ] = wp_kses_post( $field_value ); |
|
848 | + $group_meta_value[$field_id] = wp_kses_post($field_value); |
|
849 | 849 | break; |
850 | 850 | |
851 | 851 | default: |
852 | - $group_meta_value[ $field_id ] = give_clean( $field_value ); |
|
852 | + $group_meta_value[$field_id] = give_clean($field_value); |
|
853 | 853 | } |
854 | 854 | } |
855 | 855 | |
856 | - if ( ! empty( $group_meta_value ) ) { |
|
857 | - $form_meta_value[ $index ] = $group_meta_value; |
|
856 | + if ( ! empty($group_meta_value)) { |
|
857 | + $form_meta_value[$index] = $group_meta_value; |
|
858 | 858 | } |
859 | 859 | } |
860 | 860 | |
861 | 861 | // Arrange repeater field keys in order. |
862 | - $form_meta_value = array_values( $form_meta_value ); |
|
862 | + $form_meta_value = array_values($form_meta_value); |
|
863 | 863 | break; |
864 | 864 | |
865 | 865 | default: |
866 | - $form_meta_value = give_clean( $_POST[ $form_meta_key ] ); |
|
866 | + $form_meta_value = give_clean($_POST[$form_meta_key]); |
|
867 | 867 | }// End switch(). |
868 | 868 | |
869 | 869 | /** |
@@ -873,24 +873,24 @@ discard block |
||
873 | 873 | */ |
874 | 874 | $form_meta_value = apply_filters( |
875 | 875 | 'give_pre_save_form_meta_value', |
876 | - $this->sanitize_form_meta( $form_meta_value, $setting_field ), |
|
876 | + $this->sanitize_form_meta($form_meta_value, $setting_field), |
|
877 | 877 | $form_meta_key, |
878 | 878 | $this, |
879 | 879 | $post_id |
880 | 880 | ); |
881 | 881 | |
882 | 882 | // Save data. |
883 | - give_update_meta( $post_id, $form_meta_key, $form_meta_value ); |
|
883 | + give_update_meta($post_id, $form_meta_key, $form_meta_value); |
|
884 | 884 | |
885 | 885 | // Fire after saving form meta key. |
886 | - do_action( "give_save_{$form_meta_key}", $form_meta_key, $form_meta_value, $post_id, $post ); |
|
886 | + do_action("give_save_{$form_meta_key}", $form_meta_key, $form_meta_value, $post_id, $post); |
|
887 | 887 | }// End if(). |
888 | 888 | }// End if(). |
889 | 889 | }// End foreach(). |
890 | 890 | }// End if(). |
891 | 891 | |
892 | 892 | // Fire action after saving form meta. |
893 | - do_action( 'give_post_process_give_forms_meta', $post_id, $post ); |
|
893 | + do_action('give_post_process_give_forms_meta', $post_id, $post); |
|
894 | 894 | } |
895 | 895 | |
896 | 896 | |
@@ -903,10 +903,10 @@ discard block |
||
903 | 903 | * |
904 | 904 | * @return string |
905 | 905 | */ |
906 | - private function get_field_id( $field ) { |
|
906 | + private function get_field_id($field) { |
|
907 | 907 | $field_id = ''; |
908 | 908 | |
909 | - if ( array_key_exists( 'id', $field ) ) { |
|
909 | + if (array_key_exists('id', $field)) { |
|
910 | 910 | $field_id = $field['id']; |
911 | 911 | |
912 | 912 | } |
@@ -923,12 +923,12 @@ discard block |
||
923 | 923 | * |
924 | 924 | * @return array |
925 | 925 | */ |
926 | - private function get_fields_id( $setting ) { |
|
926 | + private function get_fields_id($setting) { |
|
927 | 927 | $meta_keys = array(); |
928 | 928 | |
929 | - if ( ! empty( $setting ) ) { |
|
930 | - foreach ( $setting['fields'] as $field ) { |
|
931 | - if ( $field_id = $this->get_field_id( $field ) ) { |
|
929 | + if ( ! empty($setting)) { |
|
930 | + foreach ($setting['fields'] as $field) { |
|
931 | + if ($field_id = $this->get_field_id($field)) { |
|
932 | 932 | $meta_keys[] = $field_id; |
933 | 933 | } |
934 | 934 | } |
@@ -946,14 +946,14 @@ discard block |
||
946 | 946 | * |
947 | 947 | * @return array |
948 | 948 | */ |
949 | - private function get_sub_fields_id( $setting ) { |
|
949 | + private function get_sub_fields_id($setting) { |
|
950 | 950 | $meta_keys = array(); |
951 | 951 | |
952 | - if ( $this->has_sub_tab( $setting ) && ! empty( $setting['sub-fields'] ) ) { |
|
953 | - foreach ( $setting['sub-fields'] as $fields ) { |
|
954 | - if ( ! empty( $fields['fields'] ) ) { |
|
955 | - foreach ( $fields['fields'] as $field ) { |
|
956 | - if ( $field_id = $this->get_field_id( $field ) ) { |
|
952 | + if ($this->has_sub_tab($setting) && ! empty($setting['sub-fields'])) { |
|
953 | + foreach ($setting['sub-fields'] as $fields) { |
|
954 | + if ( ! empty($fields['fields'])) { |
|
955 | + foreach ($fields['fields'] as $field) { |
|
956 | + if ($field_id = $this->get_field_id($field)) { |
|
957 | 957 | $meta_keys[] = $field_id; |
958 | 958 | } |
959 | 959 | } |
@@ -974,14 +974,14 @@ discard block |
||
974 | 974 | private function get_meta_keys_from_settings() { |
975 | 975 | $meta_keys = array(); |
976 | 976 | |
977 | - foreach ( $this->settings as $setting ) { |
|
978 | - if ( $this->has_sub_tab( $setting ) ) { |
|
979 | - $meta_key = $this->get_sub_fields_id( $setting ); |
|
977 | + foreach ($this->settings as $setting) { |
|
978 | + if ($this->has_sub_tab($setting)) { |
|
979 | + $meta_key = $this->get_sub_fields_id($setting); |
|
980 | 980 | } else { |
981 | - $meta_key = $this->get_fields_id( $setting ); |
|
981 | + $meta_key = $this->get_fields_id($setting); |
|
982 | 982 | } |
983 | 983 | |
984 | - $meta_keys = array_merge( $meta_keys, $meta_key ); |
|
984 | + $meta_keys = array_merge($meta_keys, $meta_key); |
|
985 | 985 | } |
986 | 986 | |
987 | 987 | return $meta_keys; |
@@ -998,10 +998,10 @@ discard block |
||
998 | 998 | * |
999 | 999 | * @return string |
1000 | 1000 | */ |
1001 | - function get_field_type( $field_id, $group_id = '' ) { |
|
1002 | - $field = $this->get_setting_field( $field_id, $group_id ); |
|
1001 | + function get_field_type($field_id, $group_id = '') { |
|
1002 | + $field = $this->get_setting_field($field_id, $group_id); |
|
1003 | 1003 | |
1004 | - $type = array_key_exists( 'type', $field ) |
|
1004 | + $type = array_key_exists('type', $field) |
|
1005 | 1005 | ? $field['type'] |
1006 | 1006 | : ''; |
1007 | 1007 | |
@@ -1019,12 +1019,12 @@ discard block |
||
1019 | 1019 | * |
1020 | 1020 | * @return array |
1021 | 1021 | */ |
1022 | - private function get_field( $setting, $field_id ) { |
|
1022 | + private function get_field($setting, $field_id) { |
|
1023 | 1023 | $setting_field = array(); |
1024 | 1024 | |
1025 | - if ( ! empty( $setting['fields'] ) ) { |
|
1026 | - foreach ( $setting['fields'] as $field ) { |
|
1027 | - if ( array_key_exists( 'id', $field ) && $field['id'] === $field_id ) { |
|
1025 | + if ( ! empty($setting['fields'])) { |
|
1026 | + foreach ($setting['fields'] as $field) { |
|
1027 | + if (array_key_exists('id', $field) && $field['id'] === $field_id) { |
|
1028 | 1028 | $setting_field = $field; |
1029 | 1029 | break; |
1030 | 1030 | } |
@@ -1044,12 +1044,12 @@ discard block |
||
1044 | 1044 | * |
1045 | 1045 | * @return array |
1046 | 1046 | */ |
1047 | - private function get_sub_field( $setting, $field_id ) { |
|
1047 | + private function get_sub_field($setting, $field_id) { |
|
1048 | 1048 | $setting_field = array(); |
1049 | 1049 | |
1050 | - if ( ! empty( $setting['sub-fields'] ) ) { |
|
1051 | - foreach ( $setting['sub-fields'] as $fields ) { |
|
1052 | - if ( $field = $this->get_field( $fields, $field_id ) ) { |
|
1050 | + if ( ! empty($setting['sub-fields'])) { |
|
1051 | + foreach ($setting['sub-fields'] as $fields) { |
|
1052 | + if ($field = $this->get_field($fields, $field_id)) { |
|
1053 | 1053 | $setting_field = $field; |
1054 | 1054 | break; |
1055 | 1055 | } |
@@ -1069,17 +1069,17 @@ discard block |
||
1069 | 1069 | * |
1070 | 1070 | * @return array |
1071 | 1071 | */ |
1072 | - function get_setting_field( $field_id, $group_id = '' ) { |
|
1072 | + function get_setting_field($field_id, $group_id = '') { |
|
1073 | 1073 | $setting_field = array(); |
1074 | 1074 | |
1075 | 1075 | $_field_id = $field_id; |
1076 | - $field_id = empty( $group_id ) ? $field_id : $group_id; |
|
1076 | + $field_id = empty($group_id) ? $field_id : $group_id; |
|
1077 | 1077 | |
1078 | - if ( ! empty( $this->settings ) ) { |
|
1079 | - foreach ( $this->settings as $setting ) { |
|
1078 | + if ( ! empty($this->settings)) { |
|
1079 | + foreach ($this->settings as $setting) { |
|
1080 | 1080 | if ( |
1081 | - ( $this->has_sub_tab( $setting ) && ( $setting_field = $this->get_sub_field( $setting, $field_id ) ) ) |
|
1082 | - || ( $setting_field = $this->get_field( $setting, $field_id ) ) |
|
1081 | + ($this->has_sub_tab($setting) && ($setting_field = $this->get_sub_field($setting, $field_id))) |
|
1082 | + || ($setting_field = $this->get_field($setting, $field_id)) |
|
1083 | 1083 | ) { |
1084 | 1084 | break; |
1085 | 1085 | } |
@@ -1087,9 +1087,9 @@ discard block |
||
1087 | 1087 | } |
1088 | 1088 | |
1089 | 1089 | // Get field from group. |
1090 | - if ( ! empty( $group_id ) ) { |
|
1091 | - foreach ( $setting_field['fields'] as $field ) { |
|
1092 | - if ( array_key_exists( 'id', $field ) && $field['id'] === $_field_id ) { |
|
1090 | + if ( ! empty($group_id)) { |
|
1091 | + foreach ($setting_field['fields'] as $field) { |
|
1092 | + if (array_key_exists('id', $field) && $field['id'] === $_field_id) { |
|
1093 | 1093 | $setting_field = $field; |
1094 | 1094 | } |
1095 | 1095 | } |
@@ -1108,14 +1108,14 @@ discard block |
||
1108 | 1108 | * |
1109 | 1109 | * @return mixed |
1110 | 1110 | */ |
1111 | - function add_offline_donations_setting_tab( $settings ) { |
|
1112 | - if ( give_is_gateway_active( 'offline' ) ) { |
|
1113 | - $settings['offline_donations_options'] = apply_filters( 'give_forms_offline_donations_options', array( |
|
1111 | + function add_offline_donations_setting_tab($settings) { |
|
1112 | + if (give_is_gateway_active('offline')) { |
|
1113 | + $settings['offline_donations_options'] = apply_filters('give_forms_offline_donations_options', array( |
|
1114 | 1114 | 'id' => 'offline_donations_options', |
1115 | - 'title' => __( 'Offline Donations', 'give' ), |
|
1115 | + 'title' => __('Offline Donations', 'give'), |
|
1116 | 1116 | 'icon-html' => '<span class="give-icon give-icon-purse"></span>', |
1117 | - 'fields' => apply_filters( 'give_forms_offline_donations_metabox_fields', array() ), |
|
1118 | - ) ); |
|
1117 | + 'fields' => apply_filters('give_forms_offline_donations_metabox_fields', array()), |
|
1118 | + )); |
|
1119 | 1119 | } |
1120 | 1120 | |
1121 | 1121 | return $settings; |
@@ -1133,22 +1133,22 @@ discard block |
||
1133 | 1133 | * |
1134 | 1134 | * @return mixed |
1135 | 1135 | */ |
1136 | - function sanitize_form_meta( $meta_value, $setting_field ) { |
|
1137 | - switch ( $setting_field['type'] ) { |
|
1136 | + function sanitize_form_meta($meta_value, $setting_field) { |
|
1137 | + switch ($setting_field['type']) { |
|
1138 | 1138 | case 'group': |
1139 | - if ( ! empty( $setting_field['fields'] ) ) { |
|
1140 | - foreach ( $setting_field['fields'] as $field ) { |
|
1141 | - if ( empty( $field['data_type'] ) || 'price' !== $field['data_type'] ) { |
|
1139 | + if ( ! empty($setting_field['fields'])) { |
|
1140 | + foreach ($setting_field['fields'] as $field) { |
|
1141 | + if (empty($field['data_type']) || 'price' !== $field['data_type']) { |
|
1142 | 1142 | continue; |
1143 | 1143 | } |
1144 | 1144 | |
1145 | - foreach ( $meta_value as $index => $meta_data ) { |
|
1146 | - if ( ! isset( $meta_value[ $index ][ $field['id'] ] ) ) { |
|
1145 | + foreach ($meta_value as $index => $meta_data) { |
|
1146 | + if ( ! isset($meta_value[$index][$field['id']])) { |
|
1147 | 1147 | continue; |
1148 | 1148 | } |
1149 | 1149 | |
1150 | - $meta_value[ $index ][ $field['id'] ] = ! empty( $meta_value[ $index ][ $field['id'] ] ) |
|
1151 | - ? give_sanitize_amount_for_db( $meta_value[ $index ][ $field['id'] ] ) |
|
1150 | + $meta_value[$index][$field['id']] = ! empty($meta_value[$index][$field['id']]) |
|
1151 | + ? give_sanitize_amount_for_db($meta_value[$index][$field['id']]) |
|
1152 | 1152 | : 0; |
1153 | 1153 | } |
1154 | 1154 | } |
@@ -1156,8 +1156,8 @@ discard block |
||
1156 | 1156 | break; |
1157 | 1157 | |
1158 | 1158 | default: |
1159 | - if ( ! empty( $setting_field['data_type'] ) && 'price' === $setting_field['data_type'] ) { |
|
1160 | - $meta_value = $meta_value ? give_sanitize_amount_for_db( $meta_value ) : 0; |
|
1159 | + if ( ! empty($setting_field['data_type']) && 'price' === $setting_field['data_type']) { |
|
1160 | + $meta_value = $meta_value ? give_sanitize_amount_for_db($meta_value) : 0; |
|
1161 | 1161 | } |
1162 | 1162 | } |
1163 | 1163 | |
@@ -1175,12 +1175,12 @@ discard block |
||
1175 | 1175 | * |
1176 | 1176 | * @return string The URL after redirect. |
1177 | 1177 | */ |
1178 | - public function maintain_active_tab( $location, $post_id ) { |
|
1178 | + public function maintain_active_tab($location, $post_id) { |
|
1179 | 1179 | if ( |
1180 | - 'give_forms' === get_post_type( $post_id ) && |
|
1181 | - ! empty( $_POST['give_form_active_tab'] ) |
|
1180 | + 'give_forms' === get_post_type($post_id) && |
|
1181 | + ! empty($_POST['give_form_active_tab']) |
|
1182 | 1182 | ) { |
1183 | - $location = add_query_arg( 'give_tab', give_clean( $_POST['give_form_active_tab'] ), $location ); |
|
1183 | + $location = add_query_arg('give_tab', give_clean($_POST['give_form_active_tab']), $location); |
|
1184 | 1184 | } |
1185 | 1185 | |
1186 | 1186 | return $location; |
@@ -662,9 +662,12 @@ discard block |
||
662 | 662 | <a href="#<?php echo $form_data_tab['id']; ?>" data-tab-id="<?php echo $form_data_tab['id']; ?>"> |
663 | 663 | <?php if ( ! empty( $form_data_tab['icon-html'] ) ) : ?> |
664 | 664 | <?php echo $form_data_tab['icon-html']; ?> |
665 | - <?php else : ?> |
|
665 | + <?php else { |
|
666 | + : ?> |
|
666 | 667 | <span class="give-icon give-icon-default"></span> |
667 | - <?php endif; ?> |
|
668 | + <?php endif; |
|
669 | +} |
|
670 | +?> |
|
668 | 671 | <span class="give-label"><?php echo $form_data_tab['label']; ?></span> |
669 | 672 | </a> |
670 | 673 | <?php if ( $this->has_sub_tab( $form_data_tab ) ) : ?> |
@@ -674,9 +677,12 @@ discard block |
||
674 | 677 | <a href="#<?php echo $sub_tab['id']; ?>" data-tab-id="<?php echo $sub_tab['id']; ?>"> |
675 | 678 | <?php if ( ! empty( $sub_tab['icon-html'] ) ) : ?> |
676 | 679 | <?php echo $sub_tab['icon-html']; ?> |
677 | - <?php else : ?> |
|
680 | + <?php else { |
|
681 | + : ?> |
|
678 | 682 | <span class="give-icon give-icon-default"></span> |
679 | - <?php endif; ?> |
|
683 | + <?php endif; |
|
684 | +} |
|
685 | +?> |
|
680 | 686 | <span class="give-label"><?php echo $sub_tab['label']; ?></span> |
681 | 687 | </a> |
682 | 688 | </li> |
@@ -703,11 +709,14 @@ discard block |
||
703 | 709 | </div> |
704 | 710 | |
705 | 711 | <?php do_action( "give_after_{$setting['id']}_settings" ); ?> |
706 | - <?php else : ?> |
|
712 | + <?php else { |
|
713 | + : ?> |
|
707 | 714 | <?php if ( $this->has_sub_tab( $setting ) ) : ?> |
708 | 715 | <?php if ( ! empty( $setting['sub-fields'] ) ) : ?> |
709 | 716 | <?php foreach ( $setting['sub-fields'] as $index => $sub_fields ) : ?> |
710 | - <div id="<?php echo $sub_fields['id']; ?>" class="panel give_options_panel give-hidden"> |
|
717 | + <div id="<?php echo $sub_fields['id']; |
|
718 | +} |
|
719 | +?>" class="panel give_options_panel give-hidden"> |
|
711 | 720 | <?php if ( ! empty( $sub_fields['fields'] ) ) : ?> |
712 | 721 | <?php foreach ( $sub_fields['fields'] as $sub_field ) : ?> |
713 | 722 | <?php give_render_field( $sub_field ); ?> |