@@ -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 | |
@@ -149,32 +149,32 @@ discard block |
||
149 | 149 | * @param int|bool $_id_or_email |
150 | 150 | * @param bool $by_user_id |
151 | 151 | */ |
152 | - public function __construct( $_id_or_email = false, $by_user_id = false ) { |
|
152 | + public function __construct($_id_or_email = false, $by_user_id = false) { |
|
153 | 153 | |
154 | 154 | $this->db = Give()->donors; |
155 | 155 | |
156 | 156 | if ( |
157 | 157 | false === $_id_or_email |
158 | - || ( is_numeric( $_id_or_email ) && (int) $_id_or_email !== absint( $_id_or_email ) ) |
|
158 | + || (is_numeric($_id_or_email) && (int) $_id_or_email !== absint($_id_or_email)) |
|
159 | 159 | ) { |
160 | 160 | return false; |
161 | 161 | } |
162 | 162 | |
163 | - $by_user_id = is_bool( $by_user_id ) ? $by_user_id : false; |
|
163 | + $by_user_id = is_bool($by_user_id) ? $by_user_id : false; |
|
164 | 164 | |
165 | - if ( is_numeric( $_id_or_email ) ) { |
|
165 | + if (is_numeric($_id_or_email)) { |
|
166 | 166 | $field = $by_user_id ? 'user_id' : 'id'; |
167 | 167 | } else { |
168 | 168 | $field = 'email'; |
169 | 169 | } |
170 | 170 | |
171 | - $donor = $this->db->get_donor_by( $field, $_id_or_email ); |
|
171 | + $donor = $this->db->get_donor_by($field, $_id_or_email); |
|
172 | 172 | |
173 | - if ( empty( $donor ) || ! is_object( $donor ) ) { |
|
173 | + if (empty($donor) || ! is_object($donor)) { |
|
174 | 174 | return false; |
175 | 175 | } |
176 | 176 | |
177 | - $this->setup_donor( $donor ); |
|
177 | + $this->setup_donor($donor); |
|
178 | 178 | |
179 | 179 | } |
180 | 180 | |
@@ -190,19 +190,19 @@ discard block |
||
190 | 190 | * |
191 | 191 | * @return bool If the setup was successful or not. |
192 | 192 | */ |
193 | - private function setup_donor( $donor ) { |
|
193 | + private function setup_donor($donor) { |
|
194 | 194 | |
195 | - if ( ! is_object( $donor ) ) { |
|
195 | + if ( ! is_object($donor)) { |
|
196 | 196 | return false; |
197 | 197 | } |
198 | 198 | |
199 | 199 | // Get cached donors. |
200 | - $donor_vars = Give_Cache::get_group( $donor->id, 'give-donors' ); |
|
200 | + $donor_vars = Give_Cache::get_group($donor->id, 'give-donors'); |
|
201 | 201 | |
202 | - if( is_null( $donor_vars ) ){ |
|
203 | - foreach ( $donor as $key => $value ) { |
|
202 | + if (is_null($donor_vars)) { |
|
203 | + foreach ($donor as $key => $value) { |
|
204 | 204 | |
205 | - switch ( $key ) { |
|
205 | + switch ($key) { |
|
206 | 206 | |
207 | 207 | case 'notes': |
208 | 208 | $this->$key = $this->get_notes(); |
@@ -216,20 +216,20 @@ discard block |
||
216 | 216 | } |
217 | 217 | |
218 | 218 | // Get donor's all email including primary email. |
219 | - $this->emails = (array) $this->get_meta( 'additional_email', false ); |
|
220 | - $this->emails = array( 'primary' => $this->email ) + $this->emails; |
|
219 | + $this->emails = (array) $this->get_meta('additional_email', false); |
|
220 | + $this->emails = array('primary' => $this->email) + $this->emails; |
|
221 | 221 | |
222 | 222 | $this->setup_address(); |
223 | 223 | |
224 | - Give_Cache::set_group( $donor->id, get_object_vars( $this ), 'give-donors' ); |
|
225 | - } else{ |
|
226 | - foreach ( $donor_vars as $donor_var => $value ) { |
|
224 | + Give_Cache::set_group($donor->id, get_object_vars($this), 'give-donors'); |
|
225 | + } else { |
|
226 | + foreach ($donor_vars as $donor_var => $value) { |
|
227 | 227 | $this->$donor_var = $value; |
228 | 228 | } |
229 | 229 | } |
230 | 230 | |
231 | 231 | // Donor ID and email are the only things that are necessary, make sure they exist. |
232 | - if ( ! empty( $this->id ) && ! empty( $this->email ) ) { |
|
232 | + if ( ! empty($this->id) && ! empty($this->email)) { |
|
233 | 233 | return true; |
234 | 234 | } |
235 | 235 | |
@@ -262,18 +262,18 @@ discard block |
||
262 | 262 | ARRAY_N |
263 | 263 | ); |
264 | 264 | |
265 | - if ( empty( $addresses ) ) { |
|
265 | + if (empty($addresses)) { |
|
266 | 266 | return $this->address; |
267 | 267 | } |
268 | 268 | |
269 | - foreach ( $addresses as $address ) { |
|
270 | - $address[0] = str_replace( '_give_donor_address_', '', $address[0] ); |
|
271 | - $address[0] = explode( '_', $address[0] ); |
|
269 | + foreach ($addresses as $address) { |
|
270 | + $address[0] = str_replace('_give_donor_address_', '', $address[0]); |
|
271 | + $address[0] = explode('_', $address[0]); |
|
272 | 272 | |
273 | - if ( 3 === count( $address[0] ) ) { |
|
274 | - $this->address[ $address[0][0] ][ $address[0][2] ][ $address[0][1] ] = $address[1]; |
|
273 | + if (3 === count($address[0])) { |
|
274 | + $this->address[$address[0][0]][$address[0][2]][$address[0][1]] = $address[1]; |
|
275 | 275 | } else { |
276 | - $this->address[ $address[0][0] ][ $address[0][1] ] = $address[1]; |
|
276 | + $this->address[$address[0][0]][$address[0][1]] = $address[1]; |
|
277 | 277 | } |
278 | 278 | } |
279 | 279 | } |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | * |
290 | 290 | * @return array The donor's address, if any |
291 | 291 | */ |
292 | - public function get_donor_address( $args = array() ) { |
|
292 | + public function get_donor_address($args = array()) { |
|
293 | 293 | $args = wp_parse_args( |
294 | 294 | $args, |
295 | 295 | array( |
@@ -307,24 +307,24 @@ discard block |
||
307 | 307 | ); |
308 | 308 | |
309 | 309 | // Backward compatibility. |
310 | - if ( ! give_has_upgrade_completed( 'v20_upgrades_user_address' ) ) { |
|
310 | + if ( ! give_has_upgrade_completed('v20_upgrades_user_address')) { |
|
311 | 311 | |
312 | 312 | // Backward compatibility for user id param. |
313 | - return wp_parse_args( (array) get_user_meta( $this->user_id, '_give_user_address', true ), $default_address ); |
|
313 | + return wp_parse_args((array) get_user_meta($this->user_id, '_give_user_address', true), $default_address); |
|
314 | 314 | |
315 | 315 | } |
316 | 316 | |
317 | - if ( ! $this->id || empty( $this->address ) || ! array_key_exists( $args['address_type'], $this->address ) ) { |
|
317 | + if ( ! $this->id || empty($this->address) || ! array_key_exists($args['address_type'], $this->address)) { |
|
318 | 318 | return $default_address; |
319 | 319 | } |
320 | 320 | |
321 | - switch ( true ) { |
|
322 | - case is_string( end( $this->address[ $args['address_type'] ] ) ): |
|
323 | - $address = wp_parse_args( $this->address[ $args['address_type'] ], $default_address ); |
|
321 | + switch (true) { |
|
322 | + case is_string(end($this->address[$args['address_type']])): |
|
323 | + $address = wp_parse_args($this->address[$args['address_type']], $default_address); |
|
324 | 324 | break; |
325 | 325 | |
326 | - case is_array( end( $this->address[ $args['address_type'] ] ) ): |
|
327 | - $address = wp_parse_args( array_shift( $this->address[ $args['address_type'] ] ), $default_address ); |
|
326 | + case is_array(end($this->address[$args['address_type']])): |
|
327 | + $address = wp_parse_args(array_shift($this->address[$args['address_type']]), $default_address); |
|
328 | 328 | break; |
329 | 329 | } |
330 | 330 | |
@@ -340,16 +340,16 @@ discard block |
||
340 | 340 | * |
341 | 341 | * @return mixed|\WP_Error |
342 | 342 | */ |
343 | - public function __get( $key ) { |
|
343 | + public function __get($key) { |
|
344 | 344 | |
345 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
345 | + if (method_exists($this, 'get_'.$key)) { |
|
346 | 346 | |
347 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
347 | + return call_user_func(array($this, 'get_'.$key)); |
|
348 | 348 | |
349 | 349 | } else { |
350 | 350 | |
351 | 351 | /* translators: %s: property key */ |
352 | - return new WP_Error( 'give-donor-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) ); |
|
352 | + return new WP_Error('give-donor-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key)); |
|
353 | 353 | |
354 | 354 | } |
355 | 355 | |
@@ -365,9 +365,9 @@ discard block |
||
365 | 365 | * |
366 | 366 | * @return bool|int False if not a valid creation, donor ID if user is found or valid creation. |
367 | 367 | */ |
368 | - public function create( $data = array() ) { |
|
368 | + public function create($data = array()) { |
|
369 | 369 | |
370 | - if ( $this->id != 0 || empty( $data ) ) { |
|
370 | + if ($this->id != 0 || empty($data)) { |
|
371 | 371 | return false; |
372 | 372 | } |
373 | 373 | |
@@ -375,15 +375,15 @@ discard block |
||
375 | 375 | 'payment_ids' => '', |
376 | 376 | ); |
377 | 377 | |
378 | - $args = wp_parse_args( $data, $defaults ); |
|
379 | - $args = $this->sanitize_columns( $args ); |
|
378 | + $args = wp_parse_args($data, $defaults); |
|
379 | + $args = $this->sanitize_columns($args); |
|
380 | 380 | |
381 | - if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) { |
|
381 | + if (empty($args['email']) || ! is_email($args['email'])) { |
|
382 | 382 | return false; |
383 | 383 | } |
384 | 384 | |
385 | - if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) { |
|
386 | - $args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) ); |
|
385 | + if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) { |
|
386 | + $args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids']))); |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | /** |
@@ -393,18 +393,18 @@ discard block |
||
393 | 393 | * |
394 | 394 | * @param array $args Donor attributes. |
395 | 395 | */ |
396 | - do_action( 'give_donor_pre_create', $args ); |
|
396 | + do_action('give_donor_pre_create', $args); |
|
397 | 397 | |
398 | 398 | $created = false; |
399 | 399 | |
400 | 400 | // The DB class 'add' implies an update if the donor being asked to be created already exists |
401 | - if ( $this->db->add( $data ) ) { |
|
401 | + if ($this->db->add($data)) { |
|
402 | 402 | |
403 | 403 | // We've successfully added/updated the donor, reset the class vars with the new data |
404 | - $donor = $this->db->get_donor_by( 'email', $args['email'] ); |
|
404 | + $donor = $this->db->get_donor_by('email', $args['email']); |
|
405 | 405 | |
406 | 406 | // Setup the donor data with the values from DB |
407 | - $this->setup_donor( $donor ); |
|
407 | + $this->setup_donor($donor); |
|
408 | 408 | |
409 | 409 | $created = $this->id; |
410 | 410 | } |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | * @param bool|int $created False if not a valid creation, donor ID if user is found or valid creation. |
418 | 418 | * @param array $args Customer attributes. |
419 | 419 | */ |
420 | - do_action( 'give_donor_post_create', $created, $args ); |
|
420 | + do_action('give_donor_post_create', $created, $args); |
|
421 | 421 | |
422 | 422 | return $created; |
423 | 423 | |
@@ -433,13 +433,13 @@ discard block |
||
433 | 433 | * |
434 | 434 | * @return bool If the update was successful or not. |
435 | 435 | */ |
436 | - public function update( $data = array() ) { |
|
436 | + public function update($data = array()) { |
|
437 | 437 | |
438 | - if ( empty( $data ) ) { |
|
438 | + if (empty($data)) { |
|
439 | 439 | return false; |
440 | 440 | } |
441 | 441 | |
442 | - $data = $this->sanitize_columns( $data ); |
|
442 | + $data = $this->sanitize_columns($data); |
|
443 | 443 | |
444 | 444 | /** |
445 | 445 | * Fires before updating donors. |
@@ -449,15 +449,15 @@ discard block |
||
449 | 449 | * @param int $donor_id Donor id. |
450 | 450 | * @param array $data Donor attributes. |
451 | 451 | */ |
452 | - do_action( 'give_donor_pre_update', $this->id, $data ); |
|
452 | + do_action('give_donor_pre_update', $this->id, $data); |
|
453 | 453 | |
454 | 454 | $updated = false; |
455 | 455 | |
456 | - if ( $this->db->update( $this->id, $data ) ) { |
|
456 | + if ($this->db->update($this->id, $data)) { |
|
457 | 457 | |
458 | - $donor = $this->db->get_donor_by( 'id', $this->id ); |
|
458 | + $donor = $this->db->get_donor_by('id', $this->id); |
|
459 | 459 | |
460 | - $this->setup_donor( $donor ); |
|
460 | + $this->setup_donor($donor); |
|
461 | 461 | |
462 | 462 | $updated = true; |
463 | 463 | } |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | * @param int $donor_id Donor id. |
472 | 472 | * @param array $data Donor attributes. |
473 | 473 | */ |
474 | - do_action( 'give_donor_post_update', $updated, $this->id, $data ); |
|
474 | + do_action('give_donor_post_update', $updated, $this->id, $data); |
|
475 | 475 | |
476 | 476 | return $updated; |
477 | 477 | } |
@@ -489,27 +489,27 @@ discard block |
||
489 | 489 | * |
490 | 490 | * @return bool If the attachment was successfully. |
491 | 491 | */ |
492 | - public function attach_payment( $payment_id = 0, $update_stats = true ) { |
|
492 | + public function attach_payment($payment_id = 0, $update_stats = true) { |
|
493 | 493 | |
494 | - if ( empty( $payment_id ) ) { |
|
494 | + if (empty($payment_id)) { |
|
495 | 495 | return false; |
496 | 496 | } |
497 | 497 | |
498 | - if ( empty( $this->payment_ids ) ) { |
|
498 | + if (empty($this->payment_ids)) { |
|
499 | 499 | |
500 | 500 | $new_payment_ids = $payment_id; |
501 | 501 | |
502 | 502 | } else { |
503 | 503 | |
504 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
504 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
505 | 505 | |
506 | - if ( in_array( $payment_id, $payment_ids ) ) { |
|
506 | + if (in_array($payment_id, $payment_ids)) { |
|
507 | 507 | $update_stats = false; |
508 | 508 | } |
509 | 509 | |
510 | 510 | $payment_ids[] = $payment_id; |
511 | 511 | |
512 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
512 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
513 | 513 | |
514 | 514 | } |
515 | 515 | |
@@ -521,20 +521,20 @@ discard block |
||
521 | 521 | * @param int $payment_id Payment id. |
522 | 522 | * @param int $donor_id Customer id. |
523 | 523 | */ |
524 | - do_action( 'give_donor_pre_attach_payment', $payment_id, $this->id ); |
|
524 | + do_action('give_donor_pre_attach_payment', $payment_id, $this->id); |
|
525 | 525 | |
526 | - $payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
526 | + $payment_added = $this->update(array('payment_ids' => $new_payment_ids)); |
|
527 | 527 | |
528 | - if ( $payment_added ) { |
|
528 | + if ($payment_added) { |
|
529 | 529 | |
530 | 530 | $this->payment_ids = $new_payment_ids; |
531 | 531 | |
532 | 532 | // We added this payment successfully, increment the stats |
533 | - if ( $update_stats ) { |
|
534 | - $payment_amount = give_donation_amount( $payment_id, array( 'type' => 'stats' ) ); |
|
533 | + if ($update_stats) { |
|
534 | + $payment_amount = give_donation_amount($payment_id, array('type' => 'stats')); |
|
535 | 535 | |
536 | - if ( ! empty( $payment_amount ) ) { |
|
537 | - $this->increase_value( $payment_amount ); |
|
536 | + if ( ! empty($payment_amount)) { |
|
537 | + $this->increase_value($payment_amount); |
|
538 | 538 | } |
539 | 539 | |
540 | 540 | $this->increase_purchase_count(); |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | * @param int $payment_id Payment id. |
551 | 551 | * @param int $donor_id Donor id. |
552 | 552 | */ |
553 | - do_action( 'give_donor_post_attach_payment', $payment_added, $payment_id, $this->id ); |
|
553 | + do_action('give_donor_post_attach_payment', $payment_added, $payment_id, $this->id); |
|
554 | 554 | |
555 | 555 | return $payment_added; |
556 | 556 | } |
@@ -568,33 +568,33 @@ discard block |
||
568 | 568 | * |
569 | 569 | * @return boolean If the removal was successful. |
570 | 570 | */ |
571 | - public function remove_payment( $payment_id = 0, $update_stats = true ) { |
|
571 | + public function remove_payment($payment_id = 0, $update_stats = true) { |
|
572 | 572 | |
573 | - if ( empty( $payment_id ) ) { |
|
573 | + if (empty($payment_id)) { |
|
574 | 574 | return false; |
575 | 575 | } |
576 | 576 | |
577 | - $payment = new Give_Payment( $payment_id ); |
|
577 | + $payment = new Give_Payment($payment_id); |
|
578 | 578 | |
579 | - if ( 'publish' !== $payment->status && 'revoked' !== $payment->status ) { |
|
579 | + if ('publish' !== $payment->status && 'revoked' !== $payment->status) { |
|
580 | 580 | $update_stats = false; |
581 | 581 | } |
582 | 582 | |
583 | 583 | $new_payment_ids = ''; |
584 | 584 | |
585 | - if ( ! empty( $this->payment_ids ) ) { |
|
585 | + if ( ! empty($this->payment_ids)) { |
|
586 | 586 | |
587 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
587 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
588 | 588 | |
589 | - $pos = array_search( $payment_id, $payment_ids ); |
|
590 | - if ( false === $pos ) { |
|
589 | + $pos = array_search($payment_id, $payment_ids); |
|
590 | + if (false === $pos) { |
|
591 | 591 | return false; |
592 | 592 | } |
593 | 593 | |
594 | - unset( $payment_ids[ $pos ] ); |
|
595 | - $payment_ids = array_filter( $payment_ids ); |
|
594 | + unset($payment_ids[$pos]); |
|
595 | + $payment_ids = array_filter($payment_ids); |
|
596 | 596 | |
597 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
597 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
598 | 598 | |
599 | 599 | } |
600 | 600 | |
@@ -606,20 +606,20 @@ discard block |
||
606 | 606 | * @param int $payment_id Payment id. |
607 | 607 | * @param int $donor_id Customer id. |
608 | 608 | */ |
609 | - do_action( 'give_donor_pre_remove_payment', $payment_id, $this->id ); |
|
609 | + do_action('give_donor_pre_remove_payment', $payment_id, $this->id); |
|
610 | 610 | |
611 | - $payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
611 | + $payment_removed = $this->update(array('payment_ids' => $new_payment_ids)); |
|
612 | 612 | |
613 | - if ( $payment_removed ) { |
|
613 | + if ($payment_removed) { |
|
614 | 614 | |
615 | 615 | $this->payment_ids = $new_payment_ids; |
616 | 616 | |
617 | - if ( $update_stats ) { |
|
617 | + if ($update_stats) { |
|
618 | 618 | // We removed this payment successfully, decrement the stats |
619 | - $payment_amount = give_donation_amount( $payment_id ); |
|
619 | + $payment_amount = give_donation_amount($payment_id); |
|
620 | 620 | |
621 | - if ( ! empty( $payment_amount ) ) { |
|
622 | - $this->decrease_value( $payment_amount ); |
|
621 | + if ( ! empty($payment_amount)) { |
|
622 | + $this->decrease_value($payment_amount); |
|
623 | 623 | } |
624 | 624 | |
625 | 625 | $this->decrease_donation_count(); |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | * @param int $payment_id Payment id. |
636 | 636 | * @param int $donor_id Donor id. |
637 | 637 | */ |
638 | - do_action( 'give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id ); |
|
638 | + do_action('give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id); |
|
639 | 639 | |
640 | 640 | return $payment_removed; |
641 | 641 | |
@@ -651,10 +651,10 @@ discard block |
||
651 | 651 | * |
652 | 652 | * @return int The donation count. |
653 | 653 | */ |
654 | - public function increase_purchase_count( $count = 1 ) { |
|
654 | + public function increase_purchase_count($count = 1) { |
|
655 | 655 | |
656 | 656 | // Make sure it's numeric and not negative. |
657 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
657 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
658 | 658 | return false; |
659 | 659 | } |
660 | 660 | |
@@ -668,9 +668,9 @@ discard block |
||
668 | 668 | * @param int $count The number to increase by. |
669 | 669 | * @param int $donor_id Donor id. |
670 | 670 | */ |
671 | - do_action( 'give_donor_pre_increase_donation_count', $count, $this->id ); |
|
671 | + do_action('give_donor_pre_increase_donation_count', $count, $this->id); |
|
672 | 672 | |
673 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
673 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
674 | 674 | $this->purchase_count = $new_total; |
675 | 675 | } |
676 | 676 | |
@@ -683,7 +683,7 @@ discard block |
||
683 | 683 | * @param int $count The number increased by. |
684 | 684 | * @param int $donor_id Donor id. |
685 | 685 | */ |
686 | - do_action( 'give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id ); |
|
686 | + do_action('give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id); |
|
687 | 687 | |
688 | 688 | return $this->purchase_count; |
689 | 689 | } |
@@ -698,16 +698,16 @@ discard block |
||
698 | 698 | * |
699 | 699 | * @return mixed If successful, the new count, otherwise false. |
700 | 700 | */ |
701 | - public function decrease_donation_count( $count = 1 ) { |
|
701 | + public function decrease_donation_count($count = 1) { |
|
702 | 702 | |
703 | 703 | // Make sure it's numeric and not negative |
704 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
704 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
705 | 705 | return false; |
706 | 706 | } |
707 | 707 | |
708 | 708 | $new_total = (int) $this->purchase_count - (int) $count; |
709 | 709 | |
710 | - if ( $new_total < 0 ) { |
|
710 | + if ($new_total < 0) { |
|
711 | 711 | $new_total = 0; |
712 | 712 | } |
713 | 713 | |
@@ -719,9 +719,9 @@ discard block |
||
719 | 719 | * @param int $count The number to decrease by. |
720 | 720 | * @param int $donor_id Customer id. |
721 | 721 | */ |
722 | - do_action( 'give_donor_pre_decrease_donation_count', $count, $this->id ); |
|
722 | + do_action('give_donor_pre_decrease_donation_count', $count, $this->id); |
|
723 | 723 | |
724 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
724 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
725 | 725 | $this->purchase_count = $new_total; |
726 | 726 | } |
727 | 727 | |
@@ -734,7 +734,7 @@ discard block |
||
734 | 734 | * @param int $count The number decreased by. |
735 | 735 | * @param int $donor_id Donor id. |
736 | 736 | */ |
737 | - do_action( 'give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id ); |
|
737 | + do_action('give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id); |
|
738 | 738 | |
739 | 739 | return $this->purchase_count; |
740 | 740 | } |
@@ -749,9 +749,9 @@ discard block |
||
749 | 749 | * |
750 | 750 | * @return mixed If successful, the new value, otherwise false. |
751 | 751 | */ |
752 | - public function increase_value( $value = 0.00 ) { |
|
752 | + public function increase_value($value = 0.00) { |
|
753 | 753 | |
754 | - $new_value = floatval( $this->purchase_value ) + $value; |
|
754 | + $new_value = floatval($this->purchase_value) + $value; |
|
755 | 755 | |
756 | 756 | /** |
757 | 757 | * Fires before increasing donor lifetime value. |
@@ -761,9 +761,9 @@ discard block |
||
761 | 761 | * @param float $value The value to increase by. |
762 | 762 | * @param int $donor_id Customer id. |
763 | 763 | */ |
764 | - do_action( 'give_donor_pre_increase_value', $value, $this->id ); |
|
764 | + do_action('give_donor_pre_increase_value', $value, $this->id); |
|
765 | 765 | |
766 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
766 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
767 | 767 | $this->purchase_value = $new_value; |
768 | 768 | } |
769 | 769 | |
@@ -776,7 +776,7 @@ discard block |
||
776 | 776 | * @param float $value The value increased by. |
777 | 777 | * @param int $donor_id Donor id. |
778 | 778 | */ |
779 | - do_action( 'give_donor_post_increase_value', $this->purchase_value, $value, $this->id ); |
|
779 | + do_action('give_donor_post_increase_value', $this->purchase_value, $value, $this->id); |
|
780 | 780 | |
781 | 781 | return $this->purchase_value; |
782 | 782 | } |
@@ -791,11 +791,11 @@ discard block |
||
791 | 791 | * |
792 | 792 | * @return mixed If successful, the new value, otherwise false. |
793 | 793 | */ |
794 | - public function decrease_value( $value = 0.00 ) { |
|
794 | + public function decrease_value($value = 0.00) { |
|
795 | 795 | |
796 | - $new_value = floatval( $this->purchase_value ) - $value; |
|
796 | + $new_value = floatval($this->purchase_value) - $value; |
|
797 | 797 | |
798 | - if ( $new_value < 0 ) { |
|
798 | + if ($new_value < 0) { |
|
799 | 799 | $new_value = 0.00; |
800 | 800 | } |
801 | 801 | |
@@ -807,9 +807,9 @@ discard block |
||
807 | 807 | * @param float $value The value to decrease by. |
808 | 808 | * @param int $donor_id Donor id. |
809 | 809 | */ |
810 | - do_action( 'give_donor_pre_decrease_value', $value, $this->id ); |
|
810 | + do_action('give_donor_pre_decrease_value', $value, $this->id); |
|
811 | 811 | |
812 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
812 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
813 | 813 | $this->purchase_value = $new_value; |
814 | 814 | } |
815 | 815 | |
@@ -822,7 +822,7 @@ discard block |
||
822 | 822 | * @param float $value The value decreased by. |
823 | 823 | * @param int $donor_id Donor id. |
824 | 824 | */ |
825 | - do_action( 'give_donor_post_decrease_value', $this->purchase_value, $value, $this->id ); |
|
825 | + do_action('give_donor_post_decrease_value', $this->purchase_value, $value, $this->id); |
|
826 | 826 | |
827 | 827 | return $this->purchase_value; |
828 | 828 | } |
@@ -841,7 +841,7 @@ discard block |
||
841 | 841 | * |
842 | 842 | * @return mixed If successful, the new donation stat value, otherwise false. |
843 | 843 | */ |
844 | - public function update_donation_value( $curr_amount, $new_amount ) { |
|
844 | + public function update_donation_value($curr_amount, $new_amount) { |
|
845 | 845 | /** |
846 | 846 | * Payment total difference value can be: |
847 | 847 | * zero (in case amount not change) |
@@ -851,15 +851,15 @@ discard block |
||
851 | 851 | $payment_total_diff = $new_amount - $curr_amount; |
852 | 852 | |
853 | 853 | // We do not need to update donation stat if donation did not change. |
854 | - if ( ! $payment_total_diff ) { |
|
854 | + if ( ! $payment_total_diff) { |
|
855 | 855 | return false; |
856 | 856 | } |
857 | 857 | |
858 | - if ( $payment_total_diff > 0 ) { |
|
859 | - $this->increase_value( $payment_total_diff ); |
|
858 | + if ($payment_total_diff > 0) { |
|
859 | + $this->increase_value($payment_total_diff); |
|
860 | 860 | } else { |
861 | 861 | // Pass payment total difference as +ve value to decrease amount from user lifetime stat. |
862 | - $this->decrease_value( - $payment_total_diff ); |
|
862 | + $this->decrease_value( -$payment_total_diff ); |
|
863 | 863 | } |
864 | 864 | |
865 | 865 | return $this->purchase_value; |
@@ -876,15 +876,15 @@ discard block |
||
876 | 876 | * |
877 | 877 | * @return array The notes requested. |
878 | 878 | */ |
879 | - public function get_notes( $length = 20, $paged = 1 ) { |
|
879 | + public function get_notes($length = 20, $paged = 1) { |
|
880 | 880 | |
881 | - $length = is_numeric( $length ) ? $length : 20; |
|
882 | - $offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0; |
|
881 | + $length = is_numeric($length) ? $length : 20; |
|
882 | + $offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0; |
|
883 | 883 | |
884 | 884 | $all_notes = $this->get_raw_notes(); |
885 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
885 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
886 | 886 | |
887 | - $desired_notes = array_slice( $notes_array, $offset, $length ); |
|
887 | + $desired_notes = array_slice($notes_array, $offset, $length); |
|
888 | 888 | |
889 | 889 | return $desired_notes; |
890 | 890 | |
@@ -901,9 +901,9 @@ discard block |
||
901 | 901 | public function get_notes_count() { |
902 | 902 | |
903 | 903 | $all_notes = $this->get_raw_notes(); |
904 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
904 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
905 | 905 | |
906 | - return count( $notes_array ); |
|
906 | + return count($notes_array); |
|
907 | 907 | |
908 | 908 | } |
909 | 909 | |
@@ -916,7 +916,7 @@ discard block |
||
916 | 916 | * |
917 | 917 | * @return string|float |
918 | 918 | */ |
919 | - public function get_total_donation_amount( $args = array() ) { |
|
919 | + public function get_total_donation_amount($args = array()) { |
|
920 | 920 | |
921 | 921 | /** |
922 | 922 | * Filter total donation amount. |
@@ -927,7 +927,7 @@ discard block |
||
927 | 927 | * @param integer $donor_id Donor ID. |
928 | 928 | * @param array $args Pass additional data. |
929 | 929 | */ |
930 | - return apply_filters( 'give_get_total_donation_amount', $this->purchase_value, $this->id, $args ); |
|
930 | + return apply_filters('give_get_total_donation_amount', $this->purchase_value, $this->id, $args); |
|
931 | 931 | } |
932 | 932 | |
933 | 933 | /** |
@@ -940,22 +940,22 @@ discard block |
||
940 | 940 | * |
941 | 941 | * @return string|boolean The new note if added successfully, false otherwise. |
942 | 942 | */ |
943 | - public function add_note( $note = '' ) { |
|
943 | + public function add_note($note = '') { |
|
944 | 944 | |
945 | - $note = trim( $note ); |
|
946 | - if ( empty( $note ) ) { |
|
945 | + $note = trim($note); |
|
946 | + if (empty($note)) { |
|
947 | 947 | return false; |
948 | 948 | } |
949 | 949 | |
950 | 950 | $notes = $this->get_raw_notes(); |
951 | 951 | |
952 | - if ( empty( $notes ) ) { |
|
952 | + if (empty($notes)) { |
|
953 | 953 | $notes = ''; |
954 | 954 | } |
955 | 955 | |
956 | - $note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note; |
|
957 | - $new_note = apply_filters( 'give_customer_add_note_string', $note_string ); |
|
958 | - $notes .= "\n\n" . $new_note; |
|
956 | + $note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note; |
|
957 | + $new_note = apply_filters('give_customer_add_note_string', $note_string); |
|
958 | + $notes .= "\n\n".$new_note; |
|
959 | 959 | |
960 | 960 | /** |
961 | 961 | * Fires before donor note is added. |
@@ -965,11 +965,11 @@ discard block |
||
965 | 965 | * @param string $new_note New note to add. |
966 | 966 | * @param int $donor_id Donor id. |
967 | 967 | */ |
968 | - do_action( 'give_donor_pre_add_note', $new_note, $this->id ); |
|
968 | + do_action('give_donor_pre_add_note', $new_note, $this->id); |
|
969 | 969 | |
970 | - $updated = $this->update( array( 'notes' => $notes ) ); |
|
970 | + $updated = $this->update(array('notes' => $notes)); |
|
971 | 971 | |
972 | - if ( $updated ) { |
|
972 | + if ($updated) { |
|
973 | 973 | $this->notes = $this->get_notes(); |
974 | 974 | } |
975 | 975 | |
@@ -982,7 +982,7 @@ discard block |
||
982 | 982 | * @param string $new_note New note added. |
983 | 983 | * @param int $donor_id Donor id. |
984 | 984 | */ |
985 | - do_action( 'give_donor_post_add_note', $this->notes, $new_note, $this->id ); |
|
985 | + do_action('give_donor_post_add_note', $this->notes, $new_note, $this->id); |
|
986 | 986 | |
987 | 987 | // Return the formatted note, so we can test, as well as update any displays |
988 | 988 | return $new_note; |
@@ -999,7 +999,7 @@ discard block |
||
999 | 999 | */ |
1000 | 1000 | private function get_raw_notes() { |
1001 | 1001 | |
1002 | - $all_notes = $this->db->get_column( 'notes', $this->id ); |
|
1002 | + $all_notes = $this->db->get_column('notes', $this->id); |
|
1003 | 1003 | |
1004 | 1004 | return $all_notes; |
1005 | 1005 | |
@@ -1016,8 +1016,8 @@ discard block |
||
1016 | 1016 | * |
1017 | 1017 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single is true. |
1018 | 1018 | */ |
1019 | - public function get_meta( $meta_key = '', $single = true ) { |
|
1020 | - return Give()->donor_meta->get_meta( $this->id, $meta_key, $single ); |
|
1019 | + public function get_meta($meta_key = '', $single = true) { |
|
1020 | + return Give()->donor_meta->get_meta($this->id, $meta_key, $single); |
|
1021 | 1021 | } |
1022 | 1022 | |
1023 | 1023 | /** |
@@ -1032,8 +1032,8 @@ discard block |
||
1032 | 1032 | * |
1033 | 1033 | * @return bool False for failure. True for success. |
1034 | 1034 | */ |
1035 | - public function add_meta( $meta_key = '', $meta_value, $unique = false ) { |
|
1036 | - return Give()->donor_meta->add_meta( $this->id, $meta_key, $meta_value, $unique ); |
|
1035 | + public function add_meta($meta_key = '', $meta_value, $unique = false) { |
|
1036 | + return Give()->donor_meta->add_meta($this->id, $meta_key, $meta_value, $unique); |
|
1037 | 1037 | } |
1038 | 1038 | |
1039 | 1039 | /** |
@@ -1048,8 +1048,8 @@ discard block |
||
1048 | 1048 | * |
1049 | 1049 | * @return bool False on failure, true if success. |
1050 | 1050 | */ |
1051 | - public function update_meta( $meta_key = '', $meta_value, $prev_value = '' ) { |
|
1052 | - return Give()->donor_meta->update_meta( $this->id, $meta_key, $meta_value, $prev_value ); |
|
1051 | + public function update_meta($meta_key = '', $meta_value, $prev_value = '') { |
|
1052 | + return Give()->donor_meta->update_meta($this->id, $meta_key, $meta_value, $prev_value); |
|
1053 | 1053 | } |
1054 | 1054 | |
1055 | 1055 | /** |
@@ -1063,8 +1063,8 @@ discard block |
||
1063 | 1063 | * |
1064 | 1064 | * @return bool False for failure. True for success. |
1065 | 1065 | */ |
1066 | - public function delete_meta( $meta_key = '', $meta_value = '' ) { |
|
1067 | - return Give()->donor_meta->delete_meta( $this->id, $meta_key, $meta_value ); |
|
1066 | + public function delete_meta($meta_key = '', $meta_value = '') { |
|
1067 | + return Give()->donor_meta->delete_meta($this->id, $meta_key, $meta_value); |
|
1068 | 1068 | } |
1069 | 1069 | |
1070 | 1070 | /** |
@@ -1077,51 +1077,51 @@ discard block |
||
1077 | 1077 | * |
1078 | 1078 | * @return array The sanitized data, based off column defaults. |
1079 | 1079 | */ |
1080 | - private function sanitize_columns( $data ) { |
|
1080 | + private function sanitize_columns($data) { |
|
1081 | 1081 | |
1082 | 1082 | $columns = $this->db->get_columns(); |
1083 | 1083 | $default_values = $this->db->get_column_defaults(); |
1084 | 1084 | |
1085 | - foreach ( $columns as $key => $type ) { |
|
1085 | + foreach ($columns as $key => $type) { |
|
1086 | 1086 | |
1087 | 1087 | // Only sanitize data that we were provided |
1088 | - if ( ! array_key_exists( $key, $data ) ) { |
|
1088 | + if ( ! array_key_exists($key, $data)) { |
|
1089 | 1089 | continue; |
1090 | 1090 | } |
1091 | 1091 | |
1092 | - switch ( $type ) { |
|
1092 | + switch ($type) { |
|
1093 | 1093 | |
1094 | 1094 | case '%s': |
1095 | - if ( 'email' == $key ) { |
|
1096 | - $data[ $key ] = sanitize_email( $data[ $key ] ); |
|
1097 | - } elseif ( 'notes' == $key ) { |
|
1098 | - $data[ $key ] = strip_tags( $data[ $key ] ); |
|
1095 | + if ('email' == $key) { |
|
1096 | + $data[$key] = sanitize_email($data[$key]); |
|
1097 | + } elseif ('notes' == $key) { |
|
1098 | + $data[$key] = strip_tags($data[$key]); |
|
1099 | 1099 | } else { |
1100 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
1100 | + $data[$key] = sanitize_text_field($data[$key]); |
|
1101 | 1101 | } |
1102 | 1102 | break; |
1103 | 1103 | |
1104 | 1104 | case '%d': |
1105 | - if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) { |
|
1106 | - $data[ $key ] = $default_values[ $key ]; |
|
1105 | + if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) { |
|
1106 | + $data[$key] = $default_values[$key]; |
|
1107 | 1107 | } else { |
1108 | - $data[ $key ] = absint( $data[ $key ] ); |
|
1108 | + $data[$key] = absint($data[$key]); |
|
1109 | 1109 | } |
1110 | 1110 | break; |
1111 | 1111 | |
1112 | 1112 | case '%f': |
1113 | 1113 | // Convert what was given to a float |
1114 | - $value = floatval( $data[ $key ] ); |
|
1114 | + $value = floatval($data[$key]); |
|
1115 | 1115 | |
1116 | - if ( ! is_float( $value ) ) { |
|
1117 | - $data[ $key ] = $default_values[ $key ]; |
|
1116 | + if ( ! is_float($value)) { |
|
1117 | + $data[$key] = $default_values[$key]; |
|
1118 | 1118 | } else { |
1119 | - $data[ $key ] = $value; |
|
1119 | + $data[$key] = $value; |
|
1120 | 1120 | } |
1121 | 1121 | break; |
1122 | 1122 | |
1123 | 1123 | default: |
1124 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
1124 | + $data[$key] = sanitize_text_field($data[$key]); |
|
1125 | 1125 | break; |
1126 | 1126 | |
1127 | 1127 | } |
@@ -1141,33 +1141,33 @@ discard block |
||
1141 | 1141 | * |
1142 | 1142 | * @return bool If the email was added successfully |
1143 | 1143 | */ |
1144 | - public function add_email( $email = '', $primary = false ) { |
|
1145 | - if ( ! is_email( $email ) ) { |
|
1144 | + public function add_email($email = '', $primary = false) { |
|
1145 | + if ( ! is_email($email)) { |
|
1146 | 1146 | return false; |
1147 | 1147 | } |
1148 | - $existing = new Give_Donor( $email ); |
|
1148 | + $existing = new Give_Donor($email); |
|
1149 | 1149 | |
1150 | - if ( $existing->id > 0 ) { |
|
1150 | + if ($existing->id > 0) { |
|
1151 | 1151 | // Email address already belongs to another donor |
1152 | 1152 | return false; |
1153 | 1153 | } |
1154 | 1154 | |
1155 | - if ( email_exists( $email ) ) { |
|
1156 | - $user = get_user_by( 'email', $email ); |
|
1157 | - if ( $user->ID != $this->user_id ) { |
|
1155 | + if (email_exists($email)) { |
|
1156 | + $user = get_user_by('email', $email); |
|
1157 | + if ($user->ID != $this->user_id) { |
|
1158 | 1158 | return false; |
1159 | 1159 | } |
1160 | 1160 | } |
1161 | 1161 | |
1162 | - do_action( 'give_donor_pre_add_email', $email, $this->id, $this ); |
|
1162 | + do_action('give_donor_pre_add_email', $email, $this->id, $this); |
|
1163 | 1163 | |
1164 | 1164 | // Add is used to ensure duplicate emails are not added |
1165 | - $ret = (bool) $this->add_meta( 'additional_email', $email ); |
|
1165 | + $ret = (bool) $this->add_meta('additional_email', $email); |
|
1166 | 1166 | |
1167 | - do_action( 'give_donor_post_add_email', $email, $this->id, $this ); |
|
1167 | + do_action('give_donor_post_add_email', $email, $this->id, $this); |
|
1168 | 1168 | |
1169 | - if ( $ret && true === $primary ) { |
|
1170 | - $this->set_primary_email( $email ); |
|
1169 | + if ($ret && true === $primary) { |
|
1170 | + $this->set_primary_email($email); |
|
1171 | 1171 | } |
1172 | 1172 | |
1173 | 1173 | return $ret; |
@@ -1183,16 +1183,16 @@ discard block |
||
1183 | 1183 | * |
1184 | 1184 | * @return bool If the email was removed successfully. |
1185 | 1185 | */ |
1186 | - public function remove_email( $email = '' ) { |
|
1187 | - if ( ! is_email( $email ) ) { |
|
1186 | + public function remove_email($email = '') { |
|
1187 | + if ( ! is_email($email)) { |
|
1188 | 1188 | return false; |
1189 | 1189 | } |
1190 | 1190 | |
1191 | - do_action( 'give_donor_pre_remove_email', $email, $this->id, $this ); |
|
1191 | + do_action('give_donor_pre_remove_email', $email, $this->id, $this); |
|
1192 | 1192 | |
1193 | - $ret = (bool) $this->delete_meta( 'additional_email', $email ); |
|
1193 | + $ret = (bool) $this->delete_meta('additional_email', $email); |
|
1194 | 1194 | |
1195 | - do_action( 'give_donor_post_remove_email', $email, $this->id, $this ); |
|
1195 | + do_action('give_donor_post_remove_email', $email, $this->id, $this); |
|
1196 | 1196 | |
1197 | 1197 | return $ret; |
1198 | 1198 | } |
@@ -1209,16 +1209,16 @@ discard block |
||
1209 | 1209 | * |
1210 | 1210 | * @return bool If the email was set as primary successfully. |
1211 | 1211 | */ |
1212 | - public function set_primary_email( $new_primary_email = '' ) { |
|
1213 | - if ( ! is_email( $new_primary_email ) ) { |
|
1212 | + public function set_primary_email($new_primary_email = '') { |
|
1213 | + if ( ! is_email($new_primary_email)) { |
|
1214 | 1214 | return false; |
1215 | 1215 | } |
1216 | 1216 | |
1217 | - do_action( 'give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this ); |
|
1217 | + do_action('give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this); |
|
1218 | 1218 | |
1219 | - $existing = new Give_Donor( $new_primary_email ); |
|
1219 | + $existing = new Give_Donor($new_primary_email); |
|
1220 | 1220 | |
1221 | - if ( $existing->id > 0 && (int) $existing->id !== (int) $this->id ) { |
|
1221 | + if ($existing->id > 0 && (int) $existing->id !== (int) $this->id) { |
|
1222 | 1222 | // This email belongs to another donor. |
1223 | 1223 | return false; |
1224 | 1224 | } |
@@ -1226,21 +1226,21 @@ discard block |
||
1226 | 1226 | $old_email = $this->email; |
1227 | 1227 | |
1228 | 1228 | // Update donor record with new email. |
1229 | - $update = $this->update( array( 'email' => $new_primary_email ) ); |
|
1229 | + $update = $this->update(array('email' => $new_primary_email)); |
|
1230 | 1230 | |
1231 | 1231 | // Remove new primary from list of additional emails. |
1232 | - $remove = $this->remove_email( $new_primary_email ); |
|
1232 | + $remove = $this->remove_email($new_primary_email); |
|
1233 | 1233 | |
1234 | 1234 | // Add old email to additional emails list. |
1235 | - $add = $this->add_email( $old_email ); |
|
1235 | + $add = $this->add_email($old_email); |
|
1236 | 1236 | |
1237 | 1237 | $ret = $update && $remove && $add; |
1238 | 1238 | |
1239 | - if ( $ret ) { |
|
1239 | + if ($ret) { |
|
1240 | 1240 | $this->email = $new_primary_email; |
1241 | 1241 | } |
1242 | 1242 | |
1243 | - do_action( 'give_donor_post_set_primary_email', $new_primary_email, $this->id, $this ); |
|
1243 | + do_action('give_donor_post_set_primary_email', $new_primary_email, $this->id, $this); |
|
1244 | 1244 | |
1245 | 1245 | return $ret; |
1246 | 1246 | } |
@@ -1255,17 +1255,17 @@ discard block |
||
1255 | 1255 | * |
1256 | 1256 | * @return bool |
1257 | 1257 | */ |
1258 | - private function is_valid_address( $address ) { |
|
1258 | + private function is_valid_address($address) { |
|
1259 | 1259 | $is_valid_address = true; |
1260 | 1260 | |
1261 | 1261 | // Address ready to process even if only one value set. |
1262 | - foreach ( $address as $address_type => $value ) { |
|
1262 | + foreach ($address as $address_type => $value) { |
|
1263 | 1263 | // @todo: Handle state field validation on basis of country. |
1264 | - if( in_array( $address_type, array( 'line2', 'state' )) ) { |
|
1264 | + if (in_array($address_type, array('line2', 'state'))) { |
|
1265 | 1265 | continue; |
1266 | 1266 | } |
1267 | 1267 | |
1268 | - if ( empty( $value ) ) { |
|
1268 | + if (empty($value)) { |
|
1269 | 1269 | $is_valid_address = false; |
1270 | 1270 | break; |
1271 | 1271 | } |
@@ -1292,30 +1292,27 @@ discard block |
||
1292 | 1292 | * |
1293 | 1293 | * @return bool |
1294 | 1294 | */ |
1295 | - public function add_address( $address_type, $address ) { |
|
1295 | + public function add_address($address_type, $address) { |
|
1296 | 1296 | // Bailout. |
1297 | - if ( empty( $address_type ) || ! $this->is_valid_address( $address ) || ! $this->id ) { |
|
1297 | + if (empty($address_type) || ! $this->is_valid_address($address) || ! $this->id) { |
|
1298 | 1298 | return false; |
1299 | 1299 | } |
1300 | 1300 | |
1301 | 1301 | // Check if multiple address exist or not and set params. |
1302 | 1302 | $multi_address_id = null; |
1303 | - if( $is_multi_address = ( false !== strpos( $address_type, '[]' ) ) ) { |
|
1304 | - $address_type = $is_multi_address ? |
|
1305 | - str_replace( '[]', '', $address_type ) : |
|
1306 | - $address_type; |
|
1307 | - } elseif ( $is_multi_address = ( false !== strpos( $address_type, '_' ) ) ){ |
|
1308 | - $multi_address_id = $is_multi_address ? |
|
1309 | - array_pop( explode( '_', $address_type ) ) : |
|
1310 | - $address_type; |
|
1303 | + if ($is_multi_address = (false !== strpos($address_type, '[]'))) { |
|
1304 | + $address_type = $is_multi_address ? |
|
1305 | + str_replace('[]', '', $address_type) : $address_type; |
|
1306 | + } elseif ($is_multi_address = (false !== strpos($address_type, '_'))) { |
|
1307 | + $multi_address_id = $is_multi_address ? |
|
1308 | + array_pop(explode('_', $address_type)) : $address_type; |
|
1311 | 1309 | |
1312 | - $address_type = $is_multi_address ? |
|
1313 | - array_shift( explode( '_', $address_type ) ) : |
|
1314 | - $address_type; |
|
1310 | + $address_type = $is_multi_address ? |
|
1311 | + array_shift(explode('_', $address_type)) : $address_type; |
|
1315 | 1312 | } |
1316 | 1313 | |
1317 | 1314 | // Bailout: do not save duplicate orders |
1318 | - if( $this->is_address_exist( $address_type, $address ) ) { |
|
1315 | + if ($this->is_address_exist($address_type, $address)) { |
|
1319 | 1316 | return false; |
1320 | 1317 | } |
1321 | 1318 | |
@@ -1337,8 +1334,8 @@ discard block |
||
1337 | 1334 | $meta_key_prefix = "_give_donor_address_{$address_type}_{address_name}"; |
1338 | 1335 | $meta_type = Give()->donor_meta->meta_type; |
1339 | 1336 | |
1340 | - if ( $is_multi_address ) { |
|
1341 | - if ( is_null( $multi_address_id ) ) { |
|
1337 | + if ($is_multi_address) { |
|
1338 | + if (is_null($multi_address_id)) { |
|
1342 | 1339 | // Get latest address key to set multi address id. |
1343 | 1340 | $multi_address_id = $wpdb->get_var( |
1344 | 1341 | $wpdb->prepare( |
@@ -1355,10 +1352,10 @@ discard block |
||
1355 | 1352 | ) |
1356 | 1353 | ); |
1357 | 1354 | |
1358 | - if( ! empty( $multi_address_id ) ) { |
|
1359 | - $multi_address_id = absint( substr( strrchr( $multi_address_id, '_' ), 1 ) ); |
|
1355 | + if ( ! empty($multi_address_id)) { |
|
1356 | + $multi_address_id = absint(substr(strrchr($multi_address_id, '_'), 1)); |
|
1360 | 1357 | $multi_address_id++; |
1361 | - } else{ |
|
1358 | + } else { |
|
1362 | 1359 | $multi_address_id = 0; |
1363 | 1360 | } |
1364 | 1361 | } |
@@ -1367,9 +1364,9 @@ discard block |
||
1367 | 1364 | } |
1368 | 1365 | |
1369 | 1366 | // Save donor address. |
1370 | - foreach ( $address as $type => $value ) { |
|
1371 | - $meta_key = str_replace( '{address_name}', $type, $meta_key_prefix ); |
|
1372 | - Give()->donor_meta->update_meta( $this->id, $meta_key, $value ); |
|
1367 | + foreach ($address as $type => $value) { |
|
1368 | + $meta_key = str_replace('{address_name}', $type, $meta_key_prefix); |
|
1369 | + Give()->donor_meta->update_meta($this->id, $meta_key, $value); |
|
1373 | 1370 | } |
1374 | 1371 | |
1375 | 1372 | $this->setup_address(); |
@@ -1388,23 +1385,21 @@ discard block |
||
1388 | 1385 | * |
1389 | 1386 | * @return bool |
1390 | 1387 | */ |
1391 | - public function remove_address( $address_id ) { |
|
1388 | + public function remove_address($address_id) { |
|
1392 | 1389 | global $wpdb; |
1393 | 1390 | |
1394 | 1391 | // Get address type. |
1395 | - $is_multi_address = false !== strpos( $address_id, '_' ) ? true : false; |
|
1392 | + $is_multi_address = false !== strpos($address_id, '_') ? true : false; |
|
1396 | 1393 | |
1397 | - $address_type = false !== strpos( $address_id, '_' ) ? |
|
1398 | - array_shift( explode( '_', $address_id ) ) : |
|
1399 | - $address_id; |
|
1394 | + $address_type = false !== strpos($address_id, '_') ? |
|
1395 | + array_shift(explode('_', $address_id)) : $address_id; |
|
1400 | 1396 | |
1401 | - $address_count = false !== strpos( $address_id, '_' ) ? |
|
1402 | - array_pop( explode( '_', $address_id ) ) : |
|
1403 | - null; |
|
1397 | + $address_count = false !== strpos($address_id, '_') ? |
|
1398 | + array_pop(explode('_', $address_id)) : null; |
|
1404 | 1399 | |
1405 | 1400 | // Set meta key prefix. |
1406 | 1401 | $meta_key_prefix = "_give_donor_address_{$address_type}_%"; |
1407 | - if ( $is_multi_address && is_numeric( $address_count ) ) { |
|
1402 | + if ($is_multi_address && is_numeric($address_count)) { |
|
1408 | 1403 | $meta_key_prefix .= "_{$address_count}"; |
1409 | 1404 | } |
1410 | 1405 | |
@@ -1441,23 +1436,21 @@ discard block |
||
1441 | 1436 | * |
1442 | 1437 | * @return bool |
1443 | 1438 | */ |
1444 | - public function update_address( $address_id, $address ) { |
|
1439 | + public function update_address($address_id, $address) { |
|
1445 | 1440 | global $wpdb; |
1446 | 1441 | |
1447 | 1442 | // Get address type. |
1448 | - $is_multi_address = false !== strpos( $address_id, '_' ) ? true : false; |
|
1443 | + $is_multi_address = false !== strpos($address_id, '_') ? true : false; |
|
1449 | 1444 | |
1450 | - $address_type = false !== strpos( $address_id, '_' ) ? |
|
1451 | - array_shift( explode( '_', $address_id ) ) : |
|
1452 | - $address_id; |
|
1445 | + $address_type = false !== strpos($address_id, '_') ? |
|
1446 | + array_shift(explode('_', $address_id)) : $address_id; |
|
1453 | 1447 | |
1454 | - $address_count = false !== strpos( $address_id, '_' ) ? |
|
1455 | - array_pop( explode( '_', $address_id ) ) : |
|
1456 | - null; |
|
1448 | + $address_count = false !== strpos($address_id, '_') ? |
|
1449 | + array_pop(explode('_', $address_id)) : null; |
|
1457 | 1450 | |
1458 | 1451 | // Set meta key prefix. |
1459 | 1452 | $meta_key_prefix = "_give_donor_address_{$address_type}_%"; |
1460 | - if ( $is_multi_address && is_numeric( $address_count ) ) { |
|
1453 | + if ($is_multi_address && is_numeric($address_count)) { |
|
1461 | 1454 | $meta_key_prefix .= "_{$address_count}"; |
1462 | 1455 | } |
1463 | 1456 | |
@@ -1478,12 +1471,12 @@ discard block |
||
1478 | 1471 | ); |
1479 | 1472 | |
1480 | 1473 | // Return result. |
1481 | - if( ! count( $row_affected ) ) { |
|
1474 | + if ( ! count($row_affected)) { |
|
1482 | 1475 | return false; |
1483 | 1476 | } |
1484 | 1477 | |
1485 | 1478 | // Update address. |
1486 | - if( ! $this->add_address( $address_id, $address ) ) { |
|
1479 | + if ( ! $this->add_address($address_id, $address)) { |
|
1487 | 1480 | return false; |
1488 | 1481 | } |
1489 | 1482 | |
@@ -1502,39 +1495,39 @@ discard block |
||
1502 | 1495 | * |
1503 | 1496 | * @return bool|null |
1504 | 1497 | */ |
1505 | - public function is_address_exist( $current_address_type, $current_address ) { |
|
1498 | + public function is_address_exist($current_address_type, $current_address) { |
|
1506 | 1499 | $status = false; |
1507 | 1500 | |
1508 | 1501 | // Bailout. |
1509 | - if( empty( $current_address_type ) || empty( $current_address ) ) { |
|
1502 | + if (empty($current_address_type) || empty($current_address)) { |
|
1510 | 1503 | return null; |
1511 | 1504 | } |
1512 | 1505 | |
1513 | 1506 | // Bailout. |
1514 | - if( empty( $this->address ) || empty( $this->address[ $current_address_type ] ) ) { |
|
1507 | + if (empty($this->address) || empty($this->address[$current_address_type])) { |
|
1515 | 1508 | return $status; |
1516 | 1509 | } |
1517 | 1510 | |
1518 | 1511 | // Get address. |
1519 | - $address = $this->address[ $current_address_type ]; |
|
1512 | + $address = $this->address[$current_address_type]; |
|
1520 | 1513 | |
1521 | - switch ( true ){ |
|
1514 | + switch (true) { |
|
1522 | 1515 | |
1523 | 1516 | // Single address. |
1524 | - case is_string( end( $address ) ) : |
|
1525 | - $status = $this->is_address_match( $current_address, $address ); |
|
1517 | + case is_string(end($address)) : |
|
1518 | + $status = $this->is_address_match($current_address, $address); |
|
1526 | 1519 | break; |
1527 | 1520 | |
1528 | 1521 | // Multi address. |
1529 | - case is_array( end( $address ) ): |
|
1522 | + case is_array(end($address)): |
|
1530 | 1523 | // Compare address. |
1531 | - foreach ( $address as $saved_address ) { |
|
1532 | - if( empty( $saved_address ) ) { |
|
1524 | + foreach ($address as $saved_address) { |
|
1525 | + if (empty($saved_address)) { |
|
1533 | 1526 | continue; |
1534 | 1527 | } |
1535 | 1528 | |
1536 | 1529 | // Exit loop immediately if address exist. |
1537 | - if( $status = $this->is_address_match( $current_address, $saved_address ) ) { |
|
1530 | + if ($status = $this->is_address_match($current_address, $saved_address)) { |
|
1538 | 1531 | break; |
1539 | 1532 | } |
1540 | 1533 | } |
@@ -1555,10 +1548,10 @@ discard block |
||
1555 | 1548 | * |
1556 | 1549 | * @return bool |
1557 | 1550 | */ |
1558 | - private function is_address_match( $address_1, $address_2 ) { |
|
1559 | - $result = array_diff( $address_1, $address_2 ); |
|
1551 | + private function is_address_match($address_1, $address_2) { |
|
1552 | + $result = array_diff($address_1, $address_2); |
|
1560 | 1553 | |
1561 | - return empty( $result ); |
|
1554 | + return empty($result); |
|
1562 | 1555 | } |
1563 | 1556 | |
1564 | 1557 | /** |
@@ -1568,22 +1561,22 @@ discard block |
||
1568 | 1561 | * @since 2.0 |
1569 | 1562 | * @return object |
1570 | 1563 | */ |
1571 | - public function split_donor_name( $id ) { |
|
1572 | - $first_name = $last_name = ''; |
|
1573 | - $donor = new Give_Donor( $id ); |
|
1564 | + public function split_donor_name($id) { |
|
1565 | + $first_name = $last_name = ''; |
|
1566 | + $donor = new Give_Donor($id); |
|
1574 | 1567 | |
1575 | - $split_donor_name = explode( ' ', $donor->name, 2 ); |
|
1568 | + $split_donor_name = explode(' ', $donor->name, 2); |
|
1576 | 1569 | |
1577 | 1570 | // Check for existence of first name after split of donor name. |
1578 | - if( is_array( $split_donor_name ) && ! empty( $split_donor_name[0] ) ) { |
|
1571 | + if (is_array($split_donor_name) && ! empty($split_donor_name[0])) { |
|
1579 | 1572 | $first_name = $split_donor_name[0]; |
1580 | 1573 | } |
1581 | 1574 | |
1582 | 1575 | // Check for existence of last name after split of donor name. |
1583 | - if( is_array( $split_donor_name ) && ! empty( $split_donor_name[1] ) ) { |
|
1576 | + if (is_array($split_donor_name) && ! empty($split_donor_name[1])) { |
|
1584 | 1577 | $last_name = $split_donor_name[1]; |
1585 | 1578 | } |
1586 | - return (object) array( 'first_name' => $first_name, 'last_name' => $last_name ); |
|
1579 | + return (object) array('first_name' => $first_name, 'last_name' => $last_name); |
|
1587 | 1580 | } |
1588 | 1581 | |
1589 | 1582 | /** |
@@ -1593,9 +1586,9 @@ discard block |
||
1593 | 1586 | * @return string |
1594 | 1587 | */ |
1595 | 1588 | public function get_first_name() { |
1596 | - $first_name = $this->get_meta( '_give_donor_first_name'); |
|
1597 | - if( ! $first_name ) { |
|
1598 | - $first_name = $this->split_donor_name( $this->id )->first_name; |
|
1589 | + $first_name = $this->get_meta('_give_donor_first_name'); |
|
1590 | + if ( ! $first_name) { |
|
1591 | + $first_name = $this->split_donor_name($this->id)->first_name; |
|
1599 | 1592 | } |
1600 | 1593 | |
1601 | 1594 | return $first_name; |
@@ -1608,15 +1601,15 @@ discard block |
||
1608 | 1601 | * @return string |
1609 | 1602 | */ |
1610 | 1603 | public function get_last_name() { |
1611 | - $first_name = $this->get_meta( '_give_donor_first_name'); |
|
1612 | - $last_name = $this->get_meta( '_give_donor_last_name'); |
|
1604 | + $first_name = $this->get_meta('_give_donor_first_name'); |
|
1605 | + $last_name = $this->get_meta('_give_donor_last_name'); |
|
1613 | 1606 | |
1614 | 1607 | // This condition will prevent unnecessary splitting of donor name to fetch last name. |
1615 | - if( ! $first_name && ! $last_name ) { |
|
1616 | - $last_name = $this->split_donor_name( $this->id )->last_name; |
|
1608 | + if ( ! $first_name && ! $last_name) { |
|
1609 | + $last_name = $this->split_donor_name($this->id)->last_name; |
|
1617 | 1610 | } |
1618 | 1611 | |
1619 | - return ( $last_name ) ? $last_name : ''; |
|
1612 | + return ($last_name) ? $last_name : ''; |
|
1620 | 1613 | } |
1621 | 1614 | |
1622 | 1615 | /** |
@@ -1627,7 +1620,7 @@ discard block |
||
1627 | 1620 | * @return string $company_name Donor Company Name |
1628 | 1621 | */ |
1629 | 1622 | public function get_company_name() { |
1630 | - $company_name = $this->get_meta( '_give_donor_company' ); |
|
1623 | + $company_name = $this->get_meta('_give_donor_company'); |
|
1631 | 1624 | |
1632 | 1625 | return $company_name; |
1633 | 1626 | } |
@@ -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 | - $status = ( 'complete' === $status ) ? 'publish' : $status; |
|
43 | + $status = ('complete' === $status) ? '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->get_total_donation_amount() ); |
|
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->get_total_donation_amount()); |
|
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 | * |
331 | 331 | * @since 1.8 |
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,30 +346,30 @@ 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 ( email_exists( $email ) ) { |
|
357 | + } elseif (email_exists($email)) { |
|
358 | 358 | // Email already exists. |
359 | - give_set_error( 'email_exists', __( 'Email already exists.', 'give' ) ); |
|
359 | + give_set_error('email_exists', __('Email already exists.', 'give')); |
|
360 | 360 | $valid = false; |
361 | 361 | |
362 | - } elseif ( ! is_email( $email ) ) { |
|
362 | + } elseif ( ! is_email($email)) { |
|
363 | 363 | // Validate email. |
364 | - give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) ); |
|
364 | + give_set_error('email_invalid', __('Invalid email.', 'give')); |
|
365 | 365 | $valid = false; |
366 | 366 | |
367 | - } elseif ( $registering_new_user ) { |
|
367 | + } elseif ($registering_new_user) { |
|
368 | 368 | |
369 | 369 | // If donor email is not primary. |
370 | - if ( ! email_exists( $email ) && give_donor_email_exists( $email ) && give_is_additional_email( $email ) ) { |
|
370 | + if ( ! email_exists($email) && give_donor_email_exists($email) && give_is_additional_email($email)) { |
|
371 | 371 | // Check if email exists. |
372 | - give_set_error( 'email_used', __( 'The email address provided is already active for another user.', 'give' ) ); |
|
372 | + give_set_error('email_used', __('The email address provided is already active for another user.', 'give')); |
|
373 | 373 | $valid = false; |
374 | 374 | } |
375 | 375 | } |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | * |
384 | 384 | * @since 1.8 |
385 | 385 | */ |
386 | - $valid = (bool) apply_filters( 'give_validate_user_email', $valid, $email, $registering_new_user ); |
|
386 | + $valid = (bool) apply_filters('give_validate_user_email', $valid, $email, $registering_new_user); |
|
387 | 387 | |
388 | 388 | return $valid; |
389 | 389 | } |
@@ -399,34 +399,34 @@ discard block |
||
399 | 399 | * |
400 | 400 | * @return bool |
401 | 401 | */ |
402 | -function give_validate_user_password( $password = '', $confirm_password = '', $registering_new_user = false ) { |
|
402 | +function give_validate_user_password($password = '', $confirm_password = '', $registering_new_user = false) { |
|
403 | 403 | $valid = true; |
404 | 404 | |
405 | 405 | // Passwords Validation For New Donors Only. |
406 | - if ( $registering_new_user ) { |
|
406 | + if ($registering_new_user) { |
|
407 | 407 | // Password or confirmation missing. |
408 | - if ( ! $password ) { |
|
408 | + if ( ! $password) { |
|
409 | 409 | // The password is invalid. |
410 | - give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) ); |
|
410 | + give_set_error('password_empty', __('Enter a password.', 'give')); |
|
411 | 411 | $valid = false; |
412 | - } elseif ( ! $confirm_password ) { |
|
412 | + } elseif ( ! $confirm_password) { |
|
413 | 413 | // Confirmation password is invalid. |
414 | - give_set_error( 'confirmation_empty', __( 'Enter the password confirmation.', 'give' ) ); |
|
414 | + give_set_error('confirmation_empty', __('Enter the password confirmation.', 'give')); |
|
415 | 415 | $valid = false; |
416 | 416 | } |
417 | 417 | } |
418 | 418 | // Passwords Validation For New Donors as well as Existing Donors. |
419 | - if ( $password || $confirm_password ) { |
|
420 | - if ( strlen( $password ) < 6 || strlen( $confirm_password ) < 6 ) { |
|
419 | + if ($password || $confirm_password) { |
|
420 | + if (strlen($password) < 6 || strlen($confirm_password) < 6) { |
|
421 | 421 | // Seems Weak Password. |
422 | - give_set_error( 'password_weak', __( 'Passwords should have at least 6 characters.', 'give' ) ); |
|
422 | + give_set_error('password_weak', __('Passwords should have at least 6 characters.', 'give')); |
|
423 | 423 | $valid = false; |
424 | 424 | } |
425 | - if ( $password && $confirm_password ) { |
|
425 | + if ($password && $confirm_password) { |
|
426 | 426 | // Verify confirmation matches. |
427 | - if ( $password !== $confirm_password ) { |
|
427 | + if ($password !== $confirm_password) { |
|
428 | 428 | // Passwords do not match. |
429 | - give_set_error( 'password_mismatch', __( 'Passwords you entered do not match. Please try again.', 'give' ) ); |
|
429 | + give_set_error('password_mismatch', __('Passwords you entered do not match. Please try again.', 'give')); |
|
430 | 430 | $valid = false; |
431 | 431 | } |
432 | 432 | } |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | * |
443 | 443 | * @since 1.8 |
444 | 444 | */ |
445 | - $valid = (bool) apply_filters( 'give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user ); |
|
445 | + $valid = (bool) apply_filters('give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user); |
|
446 | 446 | |
447 | 447 | return $valid; |
448 | 448 | } |
@@ -470,8 +470,8 @@ discard block |
||
470 | 470 | * |
471 | 471 | * @return array The donor's address, if any |
472 | 472 | */ |
473 | -function give_get_donor_address( $donor_id = null, $args = array() ) { |
|
474 | - if ( empty( $donor_id ) ) { |
|
473 | +function give_get_donor_address($donor_id = null, $args = array()) { |
|
474 | + if (empty($donor_id)) { |
|
475 | 475 | $donor_id = get_current_user_id(); |
476 | 476 | } |
477 | 477 | |
@@ -493,33 +493,33 @@ discard block |
||
493 | 493 | |
494 | 494 | |
495 | 495 | // Backward compatibility for user id param. |
496 | - $by_user_id = get_user_by( 'id', $donor_id ) ? true : false; |
|
496 | + $by_user_id = get_user_by('id', $donor_id) ? true : false; |
|
497 | 497 | |
498 | 498 | // Backward compatibility. |
499 | - if ( ! give_has_upgrade_completed( 'v20_upgrades_user_address' ) && $by_user_id ) { |
|
499 | + if ( ! give_has_upgrade_completed('v20_upgrades_user_address') && $by_user_id) { |
|
500 | 500 | return wp_parse_args( |
501 | - (array) get_user_meta( $donor_id, '_give_user_address', true ), |
|
501 | + (array) get_user_meta($donor_id, '_give_user_address', true), |
|
502 | 502 | $default_address |
503 | 503 | ); |
504 | 504 | } |
505 | 505 | |
506 | - $donor = new Give_Donor( $donor_id, $by_user_id ); |
|
506 | + $donor = new Give_Donor($donor_id, $by_user_id); |
|
507 | 507 | |
508 | 508 | if ( |
509 | 509 | ! $donor->id || |
510 | - empty( $donor->address ) || |
|
511 | - ! array_key_exists( $args['address_type'], $donor->address ) |
|
510 | + empty($donor->address) || |
|
511 | + ! array_key_exists($args['address_type'], $donor->address) |
|
512 | 512 | ) { |
513 | 513 | return $default_address; |
514 | 514 | } |
515 | 515 | |
516 | - switch ( true ) { |
|
517 | - case is_string( end( $donor->address[ $args['address_type'] ] ) ): |
|
518 | - $address = wp_parse_args( $donor->address[ $args['address_type'] ], $default_address ); |
|
516 | + switch (true) { |
|
517 | + case is_string(end($donor->address[$args['address_type']])): |
|
518 | + $address = wp_parse_args($donor->address[$args['address_type']], $default_address); |
|
519 | 519 | break; |
520 | 520 | |
521 | - case is_array( end( $donor->address[ $args['address_type'] ] ) ): |
|
522 | - $address = wp_parse_args( array_shift( $donor->address[ $args['address_type'] ] ), $default_address ); |
|
521 | + case is_array(end($donor->address[$args['address_type']])): |
|
522 | + $address = wp_parse_args(array_shift($donor->address[$args['address_type']]), $default_address); |
|
523 | 523 | break; |
524 | 524 | } |
525 | 525 | |
@@ -539,17 +539,17 @@ discard block |
||
539 | 539 | * |
540 | 540 | * @return void |
541 | 541 | */ |
542 | -function give_new_user_notification( $user_id = 0, $user_data = array() ) { |
|
542 | +function give_new_user_notification($user_id = 0, $user_data = array()) { |
|
543 | 543 | // Bailout. |
544 | - if ( empty( $user_id ) || empty( $user_data ) ) { |
|
544 | + if (empty($user_id) || empty($user_data)) { |
|
545 | 545 | return; |
546 | 546 | } |
547 | 547 | |
548 | - do_action( 'give_new-donor-register_email_notification', $user_id, $user_data ); |
|
549 | - do_action( 'give_donor-register_email_notification', $user_id, $user_data ); |
|
548 | + do_action('give_new-donor-register_email_notification', $user_id, $user_data); |
|
549 | + do_action('give_donor-register_email_notification', $user_id, $user_data); |
|
550 | 550 | } |
551 | 551 | |
552 | -add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 ); |
|
552 | +add_action('give_insert_user', 'give_new_user_notification', 10, 2); |
|
553 | 553 | |
554 | 554 | |
555 | 555 | /** |
@@ -565,33 +565,33 @@ discard block |
||
565 | 565 | * |
566 | 566 | * @return string |
567 | 567 | */ |
568 | -function give_get_donor_name_by( $id = 0, $from = 'donation' ) { |
|
568 | +function give_get_donor_name_by($id = 0, $from = 'donation') { |
|
569 | 569 | |
570 | 570 | // ID shouldn't be empty. |
571 | - if ( empty( $id ) ) { |
|
571 | + if (empty($id)) { |
|
572 | 572 | return ''; |
573 | 573 | } |
574 | 574 | |
575 | 575 | $name = ''; |
576 | 576 | |
577 | - switch ( $from ) { |
|
577 | + switch ($from) { |
|
578 | 578 | |
579 | 579 | case 'donation': |
580 | - $first_name = give_get_meta( $id, '_give_donor_billing_first_name', true ); |
|
581 | - $last_name = give_get_meta( $id, '_give_donor_billing_last_name', true ); |
|
580 | + $first_name = give_get_meta($id, '_give_donor_billing_first_name', true); |
|
581 | + $last_name = give_get_meta($id, '_give_donor_billing_last_name', true); |
|
582 | 582 | |
583 | - $name = trim( "{$first_name} {$last_name}" ); |
|
583 | + $name = trim("{$first_name} {$last_name}"); |
|
584 | 584 | |
585 | 585 | break; |
586 | 586 | |
587 | 587 | case 'donor': |
588 | - $name = Give()->donors->get_column( 'name', $id ); |
|
588 | + $name = Give()->donors->get_column('name', $id); |
|
589 | 589 | |
590 | 590 | break; |
591 | 591 | |
592 | 592 | } |
593 | 593 | |
594 | - return trim( $name ); |
|
594 | + return trim($name); |
|
595 | 595 | |
596 | 596 | } |
597 | 597 | |
@@ -604,8 +604,8 @@ discard block |
||
604 | 604 | * |
605 | 605 | * @return boolean The user's ID on success, and false on failure. |
606 | 606 | */ |
607 | -function give_donor_email_exists( $email ) { |
|
608 | - if ( Give()->donors->get_donor_by( 'email', $email ) ) { |
|
607 | +function give_donor_email_exists($email) { |
|
608 | + if (Give()->donors->get_donor_by('email', $email)) { |
|
609 | 609 | return true; |
610 | 610 | } |
611 | 611 | return false; |
@@ -620,14 +620,14 @@ discard block |
||
620 | 620 | * |
621 | 621 | * @return bool |
622 | 622 | */ |
623 | -function give_is_additional_email( $email ) { |
|
623 | +function give_is_additional_email($email) { |
|
624 | 624 | global $wpdb; |
625 | 625 | |
626 | 626 | $meta_table = Give()->donor_meta->table_name; |
627 | 627 | $meta_type = Give()->donor_meta->meta_type; |
628 | - $donor_id = $wpdb->get_var( $wpdb->prepare( "SELECT {$meta_type}_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $email ) ); |
|
628 | + $donor_id = $wpdb->get_var($wpdb->prepare("SELECT {$meta_type}_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $email)); |
|
629 | 629 | |
630 | - if ( empty( $donor_id ) ) { |
|
630 | + if (empty($donor_id)) { |
|
631 | 631 | return false; |
632 | 632 | } |
633 | 633 |
@@ -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 | |
@@ -28,15 +28,15 @@ discard block |
||
28 | 28 | * @global $wpdb |
29 | 29 | * @return void |
30 | 30 | */ |
31 | -function give_install( $network_wide = false ) { |
|
31 | +function give_install($network_wide = false) { |
|
32 | 32 | |
33 | 33 | global $wpdb; |
34 | 34 | |
35 | - if ( is_multisite() && $network_wide ) { |
|
35 | + if (is_multisite() && $network_wide) { |
|
36 | 36 | |
37 | - foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) { |
|
37 | + foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs LIMIT 100") as $blog_id) { |
|
38 | 38 | |
39 | - switch_to_blog( $blog_id ); |
|
39 | + switch_to_blog($blog_id); |
|
40 | 40 | give_run_install(); |
41 | 41 | restore_current_blog(); |
42 | 42 | |
@@ -63,31 +63,31 @@ discard block |
||
63 | 63 | give_setup_post_types(); |
64 | 64 | |
65 | 65 | // Add Upgraded From Option. |
66 | - $current_version = get_option( 'give_version' ); |
|
67 | - if ( $current_version ) { |
|
68 | - update_option( 'give_version_upgraded_from', $current_version ); |
|
66 | + $current_version = get_option('give_version'); |
|
67 | + if ($current_version) { |
|
68 | + update_option('give_version_upgraded_from', $current_version); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | // Setup some default options. |
72 | 72 | $options = array(); |
73 | 73 | |
74 | 74 | //Fresh Install? Setup Test Mode, Base Country (US), Test Gateway, Currency. |
75 | - if ( empty( $current_version ) ) { |
|
76 | - $options = array_merge( $options, give_get_default_settings() ); |
|
75 | + if (empty($current_version)) { |
|
76 | + $options = array_merge($options, give_get_default_settings()); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | // Populate the default values. |
80 | - update_option( 'give_settings', array_merge( $give_options, $options ) ); |
|
80 | + update_option('give_settings', array_merge($give_options, $options)); |
|
81 | 81 | |
82 | 82 | /** |
83 | 83 | * Run plugin upgrades. |
84 | 84 | * |
85 | 85 | * @since 1.8 |
86 | 86 | */ |
87 | - do_action( 'give_upgrades' ); |
|
87 | + do_action('give_upgrades'); |
|
88 | 88 | |
89 | - if ( GIVE_VERSION !== get_option( 'give_version' ) ) { |
|
90 | - update_option( 'give_version', GIVE_VERSION ); |
|
89 | + if (GIVE_VERSION !== get_option('give_version')) { |
|
90 | + update_option('give_version', GIVE_VERSION); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | // Create Give roles. |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | // Set api version, end point and refresh permalink. |
99 | 99 | $api = new Give_API(); |
100 | 100 | $api->add_endpoint(); |
101 | - update_option( 'give_default_api_version', 'v' . $api->get_version() ); |
|
101 | + update_option('give_default_api_version', 'v'.$api->get_version()); |
|
102 | 102 | |
103 | 103 | flush_rewrite_rules(); |
104 | 104 | |
@@ -113,11 +113,11 @@ discard block |
||
113 | 113 | $give_sessions->use_php_sessions(); |
114 | 114 | |
115 | 115 | // Add a temporary option to note that Give pages have been created. |
116 | - Give_Cache::set( '_give_installed', $options, 30, true ); |
|
116 | + Give_Cache::set('_give_installed', $options, 30, true); |
|
117 | 117 | |
118 | - if ( ! $current_version ) { |
|
118 | + if ( ! $current_version) { |
|
119 | 119 | |
120 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
120 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
121 | 121 | |
122 | 122 | // When new upgrade routines are added, mark them as complete on fresh install. |
123 | 123 | $upgrade_routines = array( |
@@ -150,18 +150,18 @@ discard block |
||
150 | 150 | 'v213_delete_donation_meta' |
151 | 151 | ); |
152 | 152 | |
153 | - foreach ( $upgrade_routines as $upgrade ) { |
|
154 | - give_set_upgrade_complete( $upgrade ); |
|
153 | + foreach ($upgrade_routines as $upgrade) { |
|
154 | + give_set_upgrade_complete($upgrade); |
|
155 | 155 | } |
156 | 156 | } |
157 | 157 | |
158 | 158 | // Bail if activating from network, or bulk. |
159 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
159 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
160 | 160 | return; |
161 | 161 | } |
162 | 162 | |
163 | 163 | // Add the transient to redirect. |
164 | - Give_Cache::set( '_give_activation_redirect', true, 30, true ); |
|
164 | + Give_Cache::set('_give_activation_redirect', true, 30, true); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -179,11 +179,11 @@ discard block |
||
179 | 179 | * @param int $site_id The Site ID. |
180 | 180 | * @param array $meta Blog Meta. |
181 | 181 | */ |
182 | -function give_on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) { |
|
182 | +function give_on_create_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) { |
|
183 | 183 | |
184 | - if ( is_plugin_active_for_network( GIVE_PLUGIN_BASENAME ) ) { |
|
184 | + if (is_plugin_active_for_network(GIVE_PLUGIN_BASENAME)) { |
|
185 | 185 | |
186 | - switch_to_blog( $blog_id ); |
|
186 | + switch_to_blog($blog_id); |
|
187 | 187 | give_install(); |
188 | 188 | restore_current_blog(); |
189 | 189 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | |
192 | 192 | } |
193 | 193 | |
194 | -add_action( 'wpmu_new_blog', 'give_on_create_blog', 10, 6 ); |
|
194 | +add_action('wpmu_new_blog', 'give_on_create_blog', 10, 6); |
|
195 | 195 | |
196 | 196 | |
197 | 197 | /** |
@@ -204,13 +204,13 @@ discard block |
||
204 | 204 | * |
205 | 205 | * @return array The tables to drop. |
206 | 206 | */ |
207 | -function give_wpmu_drop_tables( $tables, $blog_id ) { |
|
207 | +function give_wpmu_drop_tables($tables, $blog_id) { |
|
208 | 208 | |
209 | - switch_to_blog( $blog_id ); |
|
209 | + switch_to_blog($blog_id); |
|
210 | 210 | $donors_db = new Give_DB_Donors(); |
211 | 211 | $donor_meta_db = new Give_DB_Donor_Meta(); |
212 | 212 | |
213 | - if ( $donors_db->installed() ) { |
|
213 | + if ($donors_db->installed()) { |
|
214 | 214 | $tables[] = $donors_db->table_name; |
215 | 215 | $tables[] = $donor_meta_db->table_name; |
216 | 216 | } |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | |
221 | 221 | } |
222 | 222 | |
223 | -add_filter( 'wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2 ); |
|
223 | +add_filter('wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2); |
|
224 | 224 | |
225 | 225 | /** |
226 | 226 | * Post-installation |
@@ -232,16 +232,16 @@ discard block |
||
232 | 232 | */ |
233 | 233 | function give_after_install() { |
234 | 234 | |
235 | - if ( ! is_admin() ) { |
|
235 | + if ( ! is_admin()) { |
|
236 | 236 | return; |
237 | 237 | } |
238 | 238 | |
239 | - $give_options = Give_Cache::get( '_give_installed', true ); |
|
240 | - $give_table_check = get_option( '_give_table_check', false ); |
|
239 | + $give_options = Give_Cache::get('_give_installed', true); |
|
240 | + $give_table_check = get_option('_give_table_check', false); |
|
241 | 241 | |
242 | - if ( false === $give_table_check || current_time( 'timestamp' ) > $give_table_check ) { |
|
242 | + if (false === $give_table_check || current_time('timestamp') > $give_table_check) { |
|
243 | 243 | |
244 | - if ( ! @Give()->donor_meta->installed() ) { |
|
244 | + if ( ! @Give()->donor_meta->installed()) { |
|
245 | 245 | |
246 | 246 | // Create the donor meta database. |
247 | 247 | // (this ensures it creates it on multisite instances where it is network activated). |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | |
250 | 250 | } |
251 | 251 | |
252 | - if ( ! @Give()->donors->installed() ) { |
|
252 | + if ( ! @Give()->donors->installed()) { |
|
253 | 253 | // Create the donor database. |
254 | 254 | // (this ensures it creates it on multisite instances where it is network activated). |
255 | 255 | @Give()->donors->create_table(); |
@@ -261,22 +261,22 @@ discard block |
||
261 | 261 | * |
262 | 262 | * @param array $give_options Give plugin options. |
263 | 263 | */ |
264 | - do_action( 'give_after_install', $give_options ); |
|
264 | + do_action('give_after_install', $give_options); |
|
265 | 265 | } |
266 | 266 | |
267 | - update_option( '_give_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ) ); |
|
267 | + update_option('_give_table_check', (current_time('timestamp') + WEEK_IN_SECONDS)); |
|
268 | 268 | |
269 | 269 | } |
270 | 270 | |
271 | 271 | // Delete the transient |
272 | - if ( false !== $give_options ) { |
|
273 | - Give_Cache::delete( Give_Cache::get_key( '_give_installed' ) ); |
|
272 | + if (false !== $give_options) { |
|
273 | + Give_Cache::delete(Give_Cache::get_key('_give_installed')); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | |
277 | 277 | } |
278 | 278 | |
279 | -add_action( 'admin_init', 'give_after_install' ); |
|
279 | +add_action('admin_init', 'give_after_install'); |
|
280 | 280 | |
281 | 281 | |
282 | 282 | /** |
@@ -291,11 +291,11 @@ discard block |
||
291 | 291 | |
292 | 292 | global $wp_roles; |
293 | 293 | |
294 | - if ( ! is_object( $wp_roles ) ) { |
|
294 | + if ( ! is_object($wp_roles)) { |
|
295 | 295 | return; |
296 | 296 | } |
297 | 297 | |
298 | - if ( ! array_key_exists( 'give_manager', $wp_roles->roles ) ) { |
|
298 | + if ( ! array_key_exists('give_manager', $wp_roles->roles)) { |
|
299 | 299 | |
300 | 300 | // Create Give plugin roles |
301 | 301 | $roles = new Give_Roles(); |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | |
307 | 307 | } |
308 | 308 | |
309 | -add_action( 'admin_init', 'give_install_roles_on_network' ); |
|
309 | +add_action('admin_init', 'give_install_roles_on_network'); |
|
310 | 310 | |
311 | 311 | /** |
312 | 312 | * Default core setting values. |
@@ -347,14 +347,14 @@ discard block |
||
347 | 347 | 'uninstall_on_delete' => 'disabled', |
348 | 348 | 'the_content_filter' => 'enabled', |
349 | 349 | 'scripts_footer' => 'disabled', |
350 | - 'agree_to_terms_label' => __( 'Agree to Terms?', 'give' ), |
|
350 | + 'agree_to_terms_label' => __('Agree to Terms?', 'give'), |
|
351 | 351 | 'agreement_text' => give_get_default_agreement_text(), |
352 | 352 | |
353 | 353 | // Paypal IPN verification. |
354 | 354 | 'paypal_verification' => 'enabled', |
355 | 355 | |
356 | 356 | // Default is manual gateway. |
357 | - 'gateways' => array( 'manual' => 1, 'offline' => 1 ), |
|
357 | + 'gateways' => array('manual' => 1, 'offline' => 1), |
|
358 | 358 | 'default_gateway' => 'manual', |
359 | 359 | |
360 | 360 | // Offline gateway setup. |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | */ |
383 | 383 | function give_get_default_agreement_text() { |
384 | 384 | |
385 | - $org_name = get_bloginfo( 'name' ); |
|
385 | + $org_name = get_bloginfo('name'); |
|
386 | 386 | |
387 | 387 | $agreement = sprintf( |
388 | 388 | '<p>Acceptance of any contribution, gift or grant is at the discretion of the %1$s. The %1$s will not accept any gift unless it can be used or expended consistently with the purpose and mission of the %1$s.</p> |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | $org_name |
397 | 397 | ); |
398 | 398 | |
399 | - return apply_filters( 'give_get_default_agreement_text', $agreement, $org_name ); |
|
399 | + return apply_filters('give_get_default_agreement_text', $agreement, $org_name); |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | |
@@ -410,19 +410,19 @@ discard block |
||
410 | 410 | function give_create_pages() { |
411 | 411 | |
412 | 412 | // Bailout if pages already created. |
413 | - if ( get_option( 'give_install_pages_created' ) ) { |
|
413 | + if (get_option('give_install_pages_created')) { |
|
414 | 414 | return false; |
415 | 415 | } |
416 | 416 | |
417 | 417 | $options = array(); |
418 | 418 | |
419 | 419 | // Checks if the Success Page option exists AND that the page exists. |
420 | - if ( ! get_post( give_get_option( 'success_page' ) ) ) { |
|
420 | + if ( ! get_post(give_get_option('success_page'))) { |
|
421 | 421 | |
422 | 422 | // Donation Confirmation (Success) Page |
423 | 423 | $success = wp_insert_post( |
424 | 424 | array( |
425 | - 'post_title' => esc_html__( 'Donation Confirmation', 'give' ), |
|
425 | + 'post_title' => esc_html__('Donation Confirmation', 'give'), |
|
426 | 426 | 'post_content' => '[give_receipt]', |
427 | 427 | 'post_status' => 'publish', |
428 | 428 | 'post_author' => 1, |
@@ -436,13 +436,13 @@ discard block |
||
436 | 436 | } |
437 | 437 | |
438 | 438 | // Checks if the Failure Page option exists AND that the page exists. |
439 | - if ( ! get_post( give_get_option( 'failure_page' ) ) ) { |
|
439 | + if ( ! get_post(give_get_option('failure_page'))) { |
|
440 | 440 | |
441 | 441 | // Failed Donation Page |
442 | 442 | $failed = wp_insert_post( |
443 | 443 | array( |
444 | - 'post_title' => esc_html__( 'Donation Failed', 'give' ), |
|
445 | - 'post_content' => esc_html__( 'We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give' ), |
|
444 | + 'post_title' => esc_html__('Donation Failed', 'give'), |
|
445 | + 'post_content' => esc_html__('We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give'), |
|
446 | 446 | 'post_status' => 'publish', |
447 | 447 | 'post_author' => 1, |
448 | 448 | 'post_type' => 'page', |
@@ -454,11 +454,11 @@ discard block |
||
454 | 454 | } |
455 | 455 | |
456 | 456 | // Checks if the History Page option exists AND that the page exists. |
457 | - if ( ! get_post( give_get_option( 'history_page' ) ) ) { |
|
457 | + if ( ! get_post(give_get_option('history_page'))) { |
|
458 | 458 | // Donation History Page |
459 | 459 | $history = wp_insert_post( |
460 | 460 | array( |
461 | - 'post_title' => esc_html__( 'Donation History', 'give' ), |
|
461 | + 'post_title' => esc_html__('Donation History', 'give'), |
|
462 | 462 | 'post_content' => '[donation_history]', |
463 | 463 | 'post_status' => 'publish', |
464 | 464 | 'post_author' => 1, |
@@ -470,11 +470,11 @@ discard block |
||
470 | 470 | $options['history_page'] = $history; |
471 | 471 | } |
472 | 472 | |
473 | - if ( ! empty( $options ) ) { |
|
474 | - update_option( 'give_settings', array_merge( give_get_settings(), $options ) ); |
|
473 | + if ( ! empty($options)) { |
|
474 | + update_option('give_settings', array_merge(give_get_settings(), $options)); |
|
475 | 475 | } |
476 | 476 | |
477 | - add_option( 'give_install_pages_created', 1, '', 'no' ); |
|
477 | + add_option('give_install_pages_created', 1, '', 'no'); |
|
478 | 478 | } |
479 | 479 | |
480 | -add_action( 'admin_init', 'give_create_pages', - 1 ); |
|
480 | +add_action('admin_init', 'give_create_pages', - 1); |
@@ -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 | |
@@ -21,14 +21,14 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param $data |
23 | 23 | */ |
24 | -function give_process_gateway_select( $data ) { |
|
25 | - if ( isset( $_POST['gateway_submit'] ) ) { |
|
26 | - wp_redirect( esc_url( add_query_arg( 'payment-mode', $_POST['payment-mode'] ) ) ); |
|
24 | +function give_process_gateway_select($data) { |
|
25 | + if (isset($_POST['gateway_submit'])) { |
|
26 | + wp_redirect(esc_url(add_query_arg('payment-mode', $_POST['payment-mode']))); |
|
27 | 27 | exit; |
28 | 28 | } |
29 | 29 | } |
30 | 30 | |
31 | -add_action( 'give_gateway_select', 'give_process_gateway_select' ); |
|
31 | +add_action('give_gateway_select', 'give_process_gateway_select'); |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Loads a payment gateway via AJAX. |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | */ |
40 | 40 | function give_load_ajax_gateway() { |
41 | 41 | |
42 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, CSRF ok. |
|
42 | + $post_data = give_clean($_POST); // WPCS: input var ok, CSRF ok. |
|
43 | 43 | |
44 | - if ( isset( $post_data['give_payment_mode'] ) ) { |
|
44 | + if (isset($post_data['give_payment_mode'])) { |
|
45 | 45 | |
46 | - $form_id_prefix = ! empty( $post_data['give_form_id_prefix'] ) ? $post_data['give_form_id_prefix'] : ''; |
|
46 | + $form_id_prefix = ! empty($post_data['give_form_id_prefix']) ? $post_data['give_form_id_prefix'] : ''; |
|
47 | 47 | |
48 | 48 | $args = array( |
49 | 49 | 'id_prefix' => $form_id_prefix, |
@@ -54,14 +54,14 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @since 1.7 |
56 | 56 | */ |
57 | - do_action( 'give_donation_form', $post_data['give_form_id'], $args ); |
|
57 | + do_action('give_donation_form', $post_data['give_form_id'], $args); |
|
58 | 58 | |
59 | 59 | exit(); |
60 | 60 | } |
61 | 61 | } |
62 | 62 | |
63 | -add_action( 'wp_ajax_give_load_gateway', 'give_load_ajax_gateway' ); |
|
64 | -add_action( 'wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway' ); |
|
63 | +add_action('wp_ajax_give_load_gateway', 'give_load_ajax_gateway'); |
|
64 | +add_action('wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway'); |
|
65 | 65 | |
66 | 66 | /** |
67 | 67 | * Create wp nonce using Ajax call. |
@@ -73,18 +73,18 @@ discard block |
||
73 | 73 | * @return void |
74 | 74 | */ |
75 | 75 | function give_donation_form_nonce() { |
76 | - if ( isset( $_POST['give_form_id'] ) ) { |
|
76 | + if (isset($_POST['give_form_id'])) { |
|
77 | 77 | |
78 | 78 | // Get donation form id. |
79 | - $form_id = is_numeric( $_POST['give_form_id'] ) ? absint( $_POST['give_form_id'] ) : 0; |
|
79 | + $form_id = is_numeric($_POST['give_form_id']) ? absint($_POST['give_form_id']) : 0; |
|
80 | 80 | |
81 | 81 | // Send nonce json data. |
82 | - wp_send_json_success( wp_create_nonce( "give_donation_form_nonce_{$form_id}" ) ); |
|
82 | + wp_send_json_success(wp_create_nonce("give_donation_form_nonce_{$form_id}")); |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
86 | -add_action( 'wp_ajax_give_donation_form_nonce', 'give_donation_form_nonce' ); |
|
87 | -add_action( 'wp_ajax_nopriv_give_donation_form_nonce', 'give_donation_form_nonce' ); |
|
86 | +add_action('wp_ajax_give_donation_form_nonce', 'give_donation_form_nonce'); |
|
87 | +add_action('wp_ajax_nopriv_give_donation_form_nonce', 'give_donation_form_nonce'); |
|
88 | 88 | |
89 | 89 | /** |
90 | 90 | * Sets an error within the donation form if no gateways are enabled. |
@@ -97,11 +97,11 @@ discard block |
||
97 | 97 | function give_no_gateway_error() { |
98 | 98 | $gateways = give_get_enabled_payment_gateways(); |
99 | 99 | |
100 | - if ( empty( $gateways ) ) { |
|
101 | - give_set_error( 'no_gateways', esc_html__( 'You must enable a payment gateway to use Give.', 'give' ) ); |
|
100 | + if (empty($gateways)) { |
|
101 | + give_set_error('no_gateways', esc_html__('You must enable a payment gateway to use Give.', 'give')); |
|
102 | 102 | } else { |
103 | - give_unset_error( 'no_gateways' ); |
|
103 | + give_unset_error('no_gateways'); |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | -add_action( 'init', 'give_no_gateway_error' ); |
|
107 | +add_action('init', 'give_no_gateway_error'); |
@@ -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 | |
@@ -141,27 +141,27 @@ discard block |
||
141 | 141 | 'v1' => 'GIVE_API_V1', |
142 | 142 | ); |
143 | 143 | |
144 | - foreach ( $this->get_versions() as $version => $class ) { |
|
145 | - require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api-' . $version . '.php'; |
|
144 | + foreach ($this->get_versions() as $version => $class) { |
|
145 | + require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api-'.$version.'.php'; |
|
146 | 146 | } |
147 | 147 | |
148 | - add_action( 'init', array( $this, 'add_endpoint' ) ); |
|
149 | - add_action( 'wp', array( $this, 'process_query' ), - 1 ); |
|
150 | - add_filter( 'query_vars', array( $this, 'query_vars' ) ); |
|
151 | - add_action( 'show_user_profile', array( $this, 'user_key_field' ) ); |
|
152 | - add_action( 'edit_user_profile', array( $this, 'user_key_field' ) ); |
|
153 | - add_action( 'personal_options_update', array( $this, 'generate_api_key' ) ); |
|
154 | - add_action( 'edit_user_profile_update', array( $this, 'generate_api_key' ) ); |
|
155 | - add_action( 'give_process_api_key', array( $this, 'process_api_key' ) ); |
|
148 | + add_action('init', array($this, 'add_endpoint')); |
|
149 | + add_action('wp', array($this, 'process_query'), - 1); |
|
150 | + add_filter('query_vars', array($this, 'query_vars')); |
|
151 | + add_action('show_user_profile', array($this, 'user_key_field')); |
|
152 | + add_action('edit_user_profile', array($this, 'user_key_field')); |
|
153 | + add_action('personal_options_update', array($this, 'generate_api_key')); |
|
154 | + add_action('edit_user_profile_update', array($this, 'generate_api_key')); |
|
155 | + add_action('give_process_api_key', array($this, 'process_api_key')); |
|
156 | 156 | |
157 | 157 | // Setup a backwards compatibility check for user API Keys |
158 | - add_filter( 'get_user_metadata', array( $this, 'api_key_backwards_compat' ), 10, 4 ); |
|
158 | + add_filter('get_user_metadata', array($this, 'api_key_backwards_compat'), 10, 4); |
|
159 | 159 | |
160 | 160 | // Determine if JSON_PRETTY_PRINT is available |
161 | - $this->pretty_print = defined( 'JSON_PRETTY_PRINT' ) ? JSON_PRETTY_PRINT : null; |
|
161 | + $this->pretty_print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : null; |
|
162 | 162 | |
163 | 163 | // Allow API request logging to be turned off |
164 | - $this->log_requests = apply_filters( 'give_api_log_requests', $this->log_requests ); |
|
164 | + $this->log_requests = apply_filters('give_api_log_requests', $this->log_requests); |
|
165 | 165 | |
166 | 166 | // Setup Give_Payment_Stats instance |
167 | 167 | $this->stats = new Give_Payment_Stats(); |
@@ -179,17 +179,17 @@ discard block |
||
179 | 179 | * |
180 | 180 | * @return mixed |
181 | 181 | */ |
182 | - public function __call( $name, $arguments ) { |
|
182 | + public function __call($name, $arguments) { |
|
183 | 183 | $deprecated_function_arr = array( |
184 | 184 | 'get_customers', |
185 | 185 | ); |
186 | 186 | |
187 | - if ( in_array( $name, $deprecated_function_arr, true ) ) { |
|
188 | - switch ( $name ) { |
|
187 | + if (in_array($name, $deprecated_function_arr, true)) { |
|
188 | + switch ($name) { |
|
189 | 189 | case 'get_customers': |
190 | - $args = ! empty( $arguments[0] ) ? $arguments[0] : array(); |
|
190 | + $args = ! empty($arguments[0]) ? $arguments[0] : array(); |
|
191 | 191 | |
192 | - return $this->get_donors( $args ); |
|
192 | + return $this->get_donors($args); |
|
193 | 193 | } |
194 | 194 | } |
195 | 195 | } |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | * @since 1.1 |
203 | 203 | */ |
204 | 204 | public function add_endpoint() { |
205 | - add_rewrite_endpoint( 'give-api', EP_ALL ); |
|
205 | + add_rewrite_endpoint('give-api', EP_ALL); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | /** |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | * |
216 | 216 | * @return string[] $vars New query vars |
217 | 217 | */ |
218 | - public function query_vars( $vars ) { |
|
218 | + public function query_vars($vars) { |
|
219 | 219 | |
220 | 220 | $vars[] = 'token'; |
221 | 221 | $vars[] = 'key'; |
@@ -266,11 +266,11 @@ discard block |
||
266 | 266 | */ |
267 | 267 | public function get_default_version() { |
268 | 268 | |
269 | - $version = get_option( 'give_default_api_version' ); |
|
269 | + $version = get_option('give_default_api_version'); |
|
270 | 270 | |
271 | - if ( defined( 'GIVE_API_VERSION' ) ) { |
|
271 | + if (defined('GIVE_API_VERSION')) { |
|
272 | 272 | $version = GIVE_API_VERSION; |
273 | - } elseif ( ! $version ) { |
|
273 | + } elseif ( ! $version) { |
|
274 | 274 | $version = 'v1'; |
275 | 275 | } |
276 | 276 | |
@@ -291,14 +291,14 @@ discard block |
||
291 | 291 | |
292 | 292 | $version = $wp_query->query_vars['give-api']; |
293 | 293 | |
294 | - if ( strpos( $version, '/' ) ) { |
|
294 | + if (strpos($version, '/')) { |
|
295 | 295 | |
296 | - $version = explode( '/', $version ); |
|
297 | - $version = strtolower( $version[0] ); |
|
296 | + $version = explode('/', $version); |
|
297 | + $version = strtolower($version[0]); |
|
298 | 298 | |
299 | - $wp_query->query_vars['give-api'] = str_replace( $version . '/', '', $wp_query->query_vars['give-api'] ); |
|
299 | + $wp_query->query_vars['give-api'] = str_replace($version.'/', '', $wp_query->query_vars['give-api']); |
|
300 | 300 | |
301 | - if ( array_key_exists( $version, $this->versions ) ) { |
|
301 | + if (array_key_exists($version, $this->versions)) { |
|
302 | 302 | |
303 | 303 | $this->queried_version = $version; |
304 | 304 | |
@@ -334,16 +334,16 @@ discard block |
||
334 | 334 | $this->override = false; |
335 | 335 | |
336 | 336 | // Make sure we have both user and api key |
337 | - if ( ! empty( $wp_query->query_vars['give-api'] ) && ( $wp_query->query_vars['give-api'] !== 'forms' || ! empty( $wp_query->query_vars['token'] ) ) ) { |
|
337 | + if ( ! empty($wp_query->query_vars['give-api']) && ($wp_query->query_vars['give-api'] !== 'forms' || ! empty($wp_query->query_vars['token']))) { |
|
338 | 338 | |
339 | - if ( empty( $wp_query->query_vars['token'] ) || empty( $wp_query->query_vars['key'] ) ) { |
|
339 | + if (empty($wp_query->query_vars['token']) || empty($wp_query->query_vars['key'])) { |
|
340 | 340 | $this->missing_auth(); |
341 | 341 | |
342 | 342 | return false; |
343 | 343 | } |
344 | 344 | |
345 | 345 | // Retrieve the user by public API key and ensure they exist |
346 | - if ( ! ( $user = $this->get_user( $wp_query->query_vars['key'] ) ) ) { |
|
346 | + if ( ! ($user = $this->get_user($wp_query->query_vars['key']))) { |
|
347 | 347 | |
348 | 348 | $this->invalid_key(); |
349 | 349 | |
@@ -351,11 +351,11 @@ discard block |
||
351 | 351 | |
352 | 352 | } else { |
353 | 353 | |
354 | - $token = urldecode( $wp_query->query_vars['token'] ); |
|
355 | - $secret = $this->get_user_secret_key( $user ); |
|
356 | - $public = urldecode( $wp_query->query_vars['key'] ); |
|
354 | + $token = urldecode($wp_query->query_vars['token']); |
|
355 | + $secret = $this->get_user_secret_key($user); |
|
356 | + $public = urldecode($wp_query->query_vars['key']); |
|
357 | 357 | |
358 | - if ( hash_equals( md5( $secret . $public ), $token ) ) { |
|
358 | + if (hash_equals(md5($secret.$public), $token)) { |
|
359 | 359 | $this->is_valid_request = true; |
360 | 360 | } else { |
361 | 361 | $this->invalid_auth(); |
@@ -364,9 +364,9 @@ discard block |
||
364 | 364 | } |
365 | 365 | |
366 | 366 | } |
367 | - } elseif ( ! empty( $wp_query->query_vars['give-api'] ) && $wp_query->query_vars['give-api'] === 'forms' ) { |
|
367 | + } elseif ( ! empty($wp_query->query_vars['give-api']) && $wp_query->query_vars['give-api'] === 'forms') { |
|
368 | 368 | $this->is_valid_request = true; |
369 | - $wp_query->set( 'key', 'public' ); |
|
369 | + $wp_query->set('key', 'public'); |
|
370 | 370 | } |
371 | 371 | } |
372 | 372 | |
@@ -382,25 +382,25 @@ discard block |
||
382 | 382 | * |
383 | 383 | * @return bool if user ID is found, false otherwise |
384 | 384 | */ |
385 | - public function get_user( $key = '' ) { |
|
385 | + public function get_user($key = '') { |
|
386 | 386 | global $wpdb, $wp_query; |
387 | 387 | |
388 | - if ( empty( $key ) ) { |
|
389 | - $key = urldecode( $wp_query->query_vars['key'] ); |
|
388 | + if (empty($key)) { |
|
389 | + $key = urldecode($wp_query->query_vars['key']); |
|
390 | 390 | } |
391 | 391 | |
392 | - if ( empty( $key ) ) { |
|
392 | + if (empty($key)) { |
|
393 | 393 | return false; |
394 | 394 | } |
395 | 395 | |
396 | - $user = Give_Cache::get( md5( 'give_api_user_' . $key ), true ); |
|
396 | + $user = Give_Cache::get(md5('give_api_user_'.$key), true); |
|
397 | 397 | |
398 | - if ( false === $user ) { |
|
399 | - $user = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key ) ); |
|
400 | - Give_Cache::set( md5( 'give_api_user_' . $key ), $user, DAY_IN_SECONDS, true ); |
|
398 | + if (false === $user) { |
|
399 | + $user = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key)); |
|
400 | + Give_Cache::set(md5('give_api_user_'.$key), $user, DAY_IN_SECONDS, true); |
|
401 | 401 | } |
402 | 402 | |
403 | - if ( $user != null ) { |
|
403 | + if ($user != null) { |
|
404 | 404 | $this->user_id = $user; |
405 | 405 | |
406 | 406 | return $user; |
@@ -416,19 +416,19 @@ discard block |
||
416 | 416 | * |
417 | 417 | * @return mixed|null|string |
418 | 418 | */ |
419 | - public function get_user_public_key( $user_id = 0 ) { |
|
419 | + public function get_user_public_key($user_id = 0) { |
|
420 | 420 | global $wpdb; |
421 | 421 | |
422 | - if ( empty( $user_id ) ) { |
|
422 | + if (empty($user_id)) { |
|
423 | 423 | return ''; |
424 | 424 | } |
425 | 425 | |
426 | - $cache_key = md5( 'give_api_user_public_key' . $user_id ); |
|
427 | - $user_public_key = Give_Cache::get( $cache_key, true ); |
|
426 | + $cache_key = md5('give_api_user_public_key'.$user_id); |
|
427 | + $user_public_key = Give_Cache::get($cache_key, true); |
|
428 | 428 | |
429 | - if ( empty( $user_public_key ) ) { |
|
430 | - $user_public_key = $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_public_key' AND user_id = %d", $user_id ) ); |
|
431 | - Give_Cache::set( $cache_key, $user_public_key, HOUR_IN_SECONDS, true ); |
|
429 | + if (empty($user_public_key)) { |
|
430 | + $user_public_key = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_public_key' AND user_id = %d", $user_id)); |
|
431 | + Give_Cache::set($cache_key, $user_public_key, HOUR_IN_SECONDS, true); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | return $user_public_key; |
@@ -441,19 +441,19 @@ discard block |
||
441 | 441 | * |
442 | 442 | * @return mixed|null|string |
443 | 443 | */ |
444 | - public function get_user_secret_key( $user_id = 0 ) { |
|
444 | + public function get_user_secret_key($user_id = 0) { |
|
445 | 445 | global $wpdb; |
446 | 446 | |
447 | - if ( empty( $user_id ) ) { |
|
447 | + if (empty($user_id)) { |
|
448 | 448 | return ''; |
449 | 449 | } |
450 | 450 | |
451 | - $cache_key = md5( 'give_api_user_secret_key' . $user_id ); |
|
452 | - $user_secret_key = Give_Cache::get( $cache_key, true ); |
|
451 | + $cache_key = md5('give_api_user_secret_key'.$user_id); |
|
452 | + $user_secret_key = Give_Cache::get($cache_key, true); |
|
453 | 453 | |
454 | - if ( empty( $user_secret_key ) ) { |
|
455 | - $user_secret_key = $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_secret_key' AND user_id = %d", $user_id ) ); |
|
456 | - Give_Cache::set( $cache_key, $user_secret_key, HOUR_IN_SECONDS, true ); |
|
454 | + if (empty($user_secret_key)) { |
|
455 | + $user_secret_key = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_secret_key' AND user_id = %d", $user_id)); |
|
456 | + Give_Cache::set($cache_key, $user_secret_key, HOUR_IN_SECONDS, true); |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | return $user_secret_key; |
@@ -469,10 +469,10 @@ discard block |
||
469 | 469 | */ |
470 | 470 | private function missing_auth() { |
471 | 471 | $error = array(); |
472 | - $error['error'] = __( 'You must specify both a token and API key.', 'give' ); |
|
472 | + $error['error'] = __('You must specify both a token and API key.', 'give'); |
|
473 | 473 | |
474 | 474 | $this->data = $error; |
475 | - $this->output( 401 ); |
|
475 | + $this->output(401); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | /** |
@@ -486,10 +486,10 @@ discard block |
||
486 | 486 | */ |
487 | 487 | private function invalid_auth() { |
488 | 488 | $error = array(); |
489 | - $error['error'] = __( 'Your request could not be authenticated.', 'give' ); |
|
489 | + $error['error'] = __('Your request could not be authenticated.', 'give'); |
|
490 | 490 | |
491 | 491 | $this->data = $error; |
492 | - $this->output( 403 ); |
|
492 | + $this->output(403); |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | /** |
@@ -503,10 +503,10 @@ discard block |
||
503 | 503 | */ |
504 | 504 | private function invalid_key() { |
505 | 505 | $error = array(); |
506 | - $error['error'] = __( 'Invalid API key.', 'give' ); |
|
506 | + $error['error'] = __('Invalid API key.', 'give'); |
|
507 | 507 | |
508 | 508 | $this->data = $error; |
509 | - $this->output( 403 ); |
|
509 | + $this->output(403); |
|
510 | 510 | } |
511 | 511 | |
512 | 512 | /** |
@@ -519,10 +519,10 @@ discard block |
||
519 | 519 | */ |
520 | 520 | private function invalid_version() { |
521 | 521 | $error = array(); |
522 | - $error['error'] = __( 'Invalid API version.', 'give' ); |
|
522 | + $error['error'] = __('Invalid API version.', 'give'); |
|
523 | 523 | |
524 | 524 | $this->data = $error; |
525 | - $this->output( 404 ); |
|
525 | + $this->output(404); |
|
526 | 526 | } |
527 | 527 | |
528 | 528 | /** |
@@ -538,10 +538,10 @@ discard block |
||
538 | 538 | global $wp_query; |
539 | 539 | |
540 | 540 | // Start logging how long the request takes for logging |
541 | - $before = microtime( true ); |
|
541 | + $before = microtime(true); |
|
542 | 542 | |
543 | 543 | // Check for give-api var. Get out if not present |
544 | - if ( empty( $wp_query->query_vars['give-api'] ) ) { |
|
544 | + if (empty($wp_query->query_vars['give-api'])) { |
|
545 | 545 | return; |
546 | 546 | } |
547 | 547 | |
@@ -555,45 +555,45 @@ discard block |
||
555 | 555 | $this->validate_request(); |
556 | 556 | |
557 | 557 | // Only proceed if no errors have been noted |
558 | - if ( ! $this->is_valid_request ) { |
|
558 | + if ( ! $this->is_valid_request) { |
|
559 | 559 | return; |
560 | 560 | } |
561 | 561 | |
562 | - if ( ! defined( 'GIVE_DOING_API' ) ) { |
|
563 | - define( 'GIVE_DOING_API', true ); |
|
562 | + if ( ! defined('GIVE_DOING_API')) { |
|
563 | + define('GIVE_DOING_API', true); |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | $data = array(); |
567 | 567 | $this->routes = new $this->versions[$this->get_queried_version()]; |
568 | 568 | $this->routes->validate_request(); |
569 | 569 | |
570 | - switch ( $this->endpoint ) : |
|
570 | + switch ($this->endpoint) : |
|
571 | 571 | |
572 | 572 | case 'stats' : |
573 | 573 | |
574 | - $data = $this->routes->get_stats( array( |
|
575 | - 'type' => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null, |
|
576 | - 'form' => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null, |
|
577 | - 'date' => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null, |
|
578 | - 'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null, |
|
579 | - 'enddate' => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null, |
|
580 | - ) ); |
|
574 | + $data = $this->routes->get_stats(array( |
|
575 | + 'type' => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null, |
|
576 | + 'form' => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null, |
|
577 | + 'date' => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null, |
|
578 | + 'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null, |
|
579 | + 'enddate' => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null, |
|
580 | + )); |
|
581 | 581 | |
582 | 582 | break; |
583 | 583 | |
584 | 584 | case 'forms' : |
585 | 585 | |
586 | - $form = isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null; |
|
586 | + $form = isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null; |
|
587 | 587 | |
588 | - $data = $this->routes->get_forms( $form ); |
|
588 | + $data = $this->routes->get_forms($form); |
|
589 | 589 | |
590 | 590 | break; |
591 | 591 | |
592 | 592 | case 'donors' : |
593 | 593 | |
594 | - $donor = isset( $wp_query->query_vars['donor'] ) ? $wp_query->query_vars['donor'] : null; |
|
594 | + $donor = isset($wp_query->query_vars['donor']) ? $wp_query->query_vars['donor'] : null; |
|
595 | 595 | |
596 | - $data = $this->routes->get_donors( $donor ); |
|
596 | + $data = $this->routes->get_donors($donor); |
|
597 | 597 | |
598 | 598 | break; |
599 | 599 | |
@@ -606,26 +606,26 @@ discard block |
||
606 | 606 | * @params date startdate | required when date = range and format to be YYYYMMDD (i.e. 20170524) |
607 | 607 | * @params date enddate | required when date = range and format to be YYYYMMDD (i.e. 20170524) |
608 | 608 | */ |
609 | - $data = $this->routes->get_recent_donations( array( |
|
610 | - 'id' => isset( $wp_query->query_vars['id'] ) ? $wp_query->query_vars['id'] : null, |
|
611 | - 'date' => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null, |
|
612 | - 'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null, |
|
613 | - 'enddate' => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null, |
|
614 | - ) ); |
|
609 | + $data = $this->routes->get_recent_donations(array( |
|
610 | + 'id' => isset($wp_query->query_vars['id']) ? $wp_query->query_vars['id'] : null, |
|
611 | + 'date' => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null, |
|
612 | + 'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null, |
|
613 | + 'enddate' => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null, |
|
614 | + )); |
|
615 | 615 | |
616 | 616 | break; |
617 | 617 | |
618 | 618 | endswitch; |
619 | 619 | |
620 | 620 | // Allow extensions to setup their own return data |
621 | - $this->data = apply_filters( 'give_api_output_data', $data, $this->endpoint, $this ); |
|
621 | + $this->data = apply_filters('give_api_output_data', $data, $this->endpoint, $this); |
|
622 | 622 | |
623 | - $after = microtime( true ); |
|
624 | - $request_time = ( $after - $before ); |
|
623 | + $after = microtime(true); |
|
624 | + $request_time = ($after - $before); |
|
625 | 625 | $this->data['request_speed'] = $request_time; |
626 | 626 | |
627 | 627 | // Log this API request, if enabled. We log it here because we have access to errors. |
628 | - $this->log_request( $this->data ); |
|
628 | + $this->log_request($this->data); |
|
629 | 629 | |
630 | 630 | // Send out data to the output function |
631 | 631 | $this->output(); |
@@ -655,25 +655,25 @@ discard block |
||
655 | 655 | global $wp_query; |
656 | 656 | |
657 | 657 | // Whitelist our query options |
658 | - $accepted = apply_filters( 'give_api_valid_query_modes', array( |
|
658 | + $accepted = apply_filters('give_api_valid_query_modes', array( |
|
659 | 659 | 'stats', |
660 | 660 | 'forms', |
661 | 661 | 'donors', |
662 | 662 | 'donations', |
663 | - ) ); |
|
663 | + )); |
|
664 | 664 | |
665 | - $query = isset( $wp_query->query_vars['give-api'] ) ? $wp_query->query_vars['give-api'] : null; |
|
666 | - $query = str_replace( $this->queried_version . '/', '', $query ); |
|
665 | + $query = isset($wp_query->query_vars['give-api']) ? $wp_query->query_vars['give-api'] : null; |
|
666 | + $query = str_replace($this->queried_version.'/', '', $query); |
|
667 | 667 | |
668 | 668 | $error = array(); |
669 | 669 | |
670 | 670 | // Make sure our query is valid |
671 | - if ( ! in_array( $query, $accepted ) ) { |
|
672 | - $error['error'] = __( 'Invalid query.', 'give' ); |
|
671 | + if ( ! in_array($query, $accepted)) { |
|
672 | + $error['error'] = __('Invalid query.', 'give'); |
|
673 | 673 | |
674 | 674 | $this->data = $error; |
675 | 675 | // 400 is Bad Request |
676 | - $this->output( 400 ); |
|
676 | + $this->output(400); |
|
677 | 677 | } |
678 | 678 | |
679 | 679 | $this->endpoint = $query; |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | public function get_paged() { |
691 | 691 | global $wp_query; |
692 | 692 | |
693 | - return isset( $wp_query->query_vars['page'] ) ? $wp_query->query_vars['page'] : 1; |
|
693 | + return isset($wp_query->query_vars['page']) ? $wp_query->query_vars['page'] : 1; |
|
694 | 694 | } |
695 | 695 | |
696 | 696 | |
@@ -705,13 +705,13 @@ discard block |
||
705 | 705 | public function per_page() { |
706 | 706 | global $wp_query; |
707 | 707 | |
708 | - $per_page = isset( $wp_query->query_vars['number'] ) ? $wp_query->query_vars['number'] : 10; |
|
708 | + $per_page = isset($wp_query->query_vars['number']) ? $wp_query->query_vars['number'] : 10; |
|
709 | 709 | |
710 | - if ( $per_page < 0 && $this->get_query_mode() == 'donors' ) { |
|
710 | + if ($per_page < 0 && $this->get_query_mode() == 'donors') { |
|
711 | 711 | $per_page = 99999999; |
712 | 712 | } // End if(). |
713 | 713 | |
714 | - return apply_filters( 'give_api_results_per_page', $per_page ); |
|
714 | + return apply_filters('give_api_results_per_page', $per_page); |
|
715 | 715 | } |
716 | 716 | |
717 | 717 | /** |
@@ -724,7 +724,7 @@ discard block |
||
724 | 724 | * |
725 | 725 | * @return array $dates |
726 | 726 | */ |
727 | - public function get_dates( $args = array() ) { |
|
727 | + public function get_dates($args = array()) { |
|
728 | 728 | $dates = array(); |
729 | 729 | |
730 | 730 | $defaults = array( |
@@ -735,60 +735,60 @@ discard block |
||
735 | 735 | 'enddate' => null, |
736 | 736 | ); |
737 | 737 | |
738 | - $args = wp_parse_args( $args, $defaults ); |
|
738 | + $args = wp_parse_args($args, $defaults); |
|
739 | 739 | |
740 | - $current_time = current_time( 'timestamp' ); |
|
740 | + $current_time = current_time('timestamp'); |
|
741 | 741 | |
742 | - if ( 'range' === $args['date'] ) { |
|
743 | - $startdate = strtotime( $args['startdate'] ); |
|
744 | - $enddate = strtotime( $args['enddate'] ); |
|
745 | - $dates['day_start'] = date( 'd', $startdate ); |
|
746 | - $dates['day_end'] = date( 'd', $enddate ); |
|
747 | - $dates['m_start'] = date( 'n', $startdate ); |
|
748 | - $dates['m_end'] = date( 'n', $enddate ); |
|
749 | - $dates['year'] = date( 'Y', $startdate ); |
|
750 | - $dates['year_end'] = date( 'Y', $enddate ); |
|
742 | + if ('range' === $args['date']) { |
|
743 | + $startdate = strtotime($args['startdate']); |
|
744 | + $enddate = strtotime($args['enddate']); |
|
745 | + $dates['day_start'] = date('d', $startdate); |
|
746 | + $dates['day_end'] = date('d', $enddate); |
|
747 | + $dates['m_start'] = date('n', $startdate); |
|
748 | + $dates['m_end'] = date('n', $enddate); |
|
749 | + $dates['year'] = date('Y', $startdate); |
|
750 | + $dates['year_end'] = date('Y', $enddate); |
|
751 | 751 | } else { |
752 | 752 | // Modify dates based on predefined ranges |
753 | - switch ( $args['date'] ) : |
|
753 | + switch ($args['date']) : |
|
754 | 754 | |
755 | 755 | case 'this_month' : |
756 | 756 | $dates['day'] = null; |
757 | - $dates['m_start'] = date( 'n', $current_time ); |
|
758 | - $dates['m_end'] = date( 'n', $current_time ); |
|
759 | - $dates['year'] = date( 'Y', $current_time ); |
|
757 | + $dates['m_start'] = date('n', $current_time); |
|
758 | + $dates['m_end'] = date('n', $current_time); |
|
759 | + $dates['year'] = date('Y', $current_time); |
|
760 | 760 | break; |
761 | 761 | |
762 | 762 | case 'last_month' : |
763 | 763 | $dates['day'] = null; |
764 | - $dates['m_start'] = date( 'n', $current_time ) == 1 ? 12 : date( 'n', $current_time ) - 1; |
|
764 | + $dates['m_start'] = date('n', $current_time) == 1 ? 12 : date('n', $current_time) - 1; |
|
765 | 765 | $dates['m_end'] = $dates['m_start']; |
766 | - $dates['year'] = date( 'n', $current_time ) == 1 ? date( 'Y', $current_time ) - 1 : date( 'Y', $current_time ); |
|
766 | + $dates['year'] = date('n', $current_time) == 1 ? date('Y', $current_time) - 1 : date('Y', $current_time); |
|
767 | 767 | break; |
768 | 768 | |
769 | 769 | case 'today' : |
770 | - $dates['day'] = date( 'd', $current_time ); |
|
771 | - $dates['m_start'] = date( 'n', $current_time ); |
|
772 | - $dates['m_end'] = date( 'n', $current_time ); |
|
773 | - $dates['year'] = date( 'Y', $current_time ); |
|
770 | + $dates['day'] = date('d', $current_time); |
|
771 | + $dates['m_start'] = date('n', $current_time); |
|
772 | + $dates['m_end'] = date('n', $current_time); |
|
773 | + $dates['year'] = date('Y', $current_time); |
|
774 | 774 | break; |
775 | 775 | |
776 | 776 | case 'yesterday' : |
777 | 777 | |
778 | - $year = date( 'Y', $current_time ); |
|
779 | - $month = date( 'n', $current_time ); |
|
780 | - $day = date( 'd', $current_time ); |
|
778 | + $year = date('Y', $current_time); |
|
779 | + $month = date('n', $current_time); |
|
780 | + $day = date('d', $current_time); |
|
781 | 781 | |
782 | - if ( $month == 1 && $day == 1 ) { |
|
782 | + if ($month == 1 && $day == 1) { |
|
783 | 783 | |
784 | - $year -= 1; |
|
784 | + $year -= 1; |
|
785 | 785 | $month = 12; |
786 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
786 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
787 | 787 | |
788 | - } elseif ( $month > 1 && $day == 1 ) { |
|
788 | + } elseif ($month > 1 && $day == 1) { |
|
789 | 789 | |
790 | 790 | $month -= 1; |
791 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
791 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
792 | 792 | |
793 | 793 | } else { |
794 | 794 | |
@@ -804,65 +804,65 @@ discard block |
||
804 | 804 | break; |
805 | 805 | |
806 | 806 | case 'this_quarter' : |
807 | - $month_now = date( 'n', $current_time ); |
|
807 | + $month_now = date('n', $current_time); |
|
808 | 808 | |
809 | 809 | $dates['day'] = null; |
810 | 810 | |
811 | - if ( $month_now <= 3 ) { |
|
811 | + if ($month_now <= 3) { |
|
812 | 812 | |
813 | 813 | $dates['m_start'] = 1; |
814 | 814 | $dates['m_end'] = 3; |
815 | - $dates['year'] = date( 'Y', $current_time ); |
|
815 | + $dates['year'] = date('Y', $current_time); |
|
816 | 816 | |
817 | - } elseif ( $month_now <= 6 ) { |
|
817 | + } elseif ($month_now <= 6) { |
|
818 | 818 | |
819 | 819 | $dates['m_start'] = 4; |
820 | 820 | $dates['m_end'] = 6; |
821 | - $dates['year'] = date( 'Y', $current_time ); |
|
821 | + $dates['year'] = date('Y', $current_time); |
|
822 | 822 | |
823 | - } elseif ( $month_now <= 9 ) { |
|
823 | + } elseif ($month_now <= 9) { |
|
824 | 824 | |
825 | 825 | $dates['m_start'] = 7; |
826 | 826 | $dates['m_end'] = 9; |
827 | - $dates['year'] = date( 'Y', $current_time ); |
|
827 | + $dates['year'] = date('Y', $current_time); |
|
828 | 828 | |
829 | 829 | } else { |
830 | 830 | |
831 | 831 | $dates['m_start'] = 10; |
832 | 832 | $dates['m_end'] = 12; |
833 | - $dates['year'] = date( 'Y', $current_time ); |
|
833 | + $dates['year'] = date('Y', $current_time); |
|
834 | 834 | |
835 | 835 | } |
836 | 836 | break; |
837 | 837 | |
838 | 838 | case 'last_quarter' : |
839 | - $month_now = date( 'n', $current_time ); |
|
839 | + $month_now = date('n', $current_time); |
|
840 | 840 | |
841 | 841 | $dates['day'] = null; |
842 | 842 | |
843 | - if ( $month_now <= 3 ) { |
|
843 | + if ($month_now <= 3) { |
|
844 | 844 | |
845 | 845 | $dates['m_start'] = 10; |
846 | 846 | $dates['m_end'] = 12; |
847 | - $dates['year'] = date( 'Y', $current_time ) - 1; // Previous year |
|
847 | + $dates['year'] = date('Y', $current_time) - 1; // Previous year |
|
848 | 848 | |
849 | - } elseif ( $month_now <= 6 ) { |
|
849 | + } elseif ($month_now <= 6) { |
|
850 | 850 | |
851 | 851 | $dates['m_start'] = 1; |
852 | 852 | $dates['m_end'] = 3; |
853 | - $dates['year'] = date( 'Y', $current_time ); |
|
853 | + $dates['year'] = date('Y', $current_time); |
|
854 | 854 | |
855 | - } elseif ( $month_now <= 9 ) { |
|
855 | + } elseif ($month_now <= 9) { |
|
856 | 856 | |
857 | 857 | $dates['m_start'] = 4; |
858 | 858 | $dates['m_end'] = 6; |
859 | - $dates['year'] = date( 'Y', $current_time ); |
|
859 | + $dates['year'] = date('Y', $current_time); |
|
860 | 860 | |
861 | 861 | } else { |
862 | 862 | |
863 | 863 | $dates['m_start'] = 7; |
864 | 864 | $dates['m_end'] = 9; |
865 | - $dates['year'] = date( 'Y', $current_time ); |
|
865 | + $dates['year'] = date('Y', $current_time); |
|
866 | 866 | |
867 | 867 | } |
868 | 868 | break; |
@@ -871,14 +871,14 @@ discard block |
||
871 | 871 | $dates['day'] = null; |
872 | 872 | $dates['m_start'] = null; |
873 | 873 | $dates['m_end'] = null; |
874 | - $dates['year'] = date( 'Y', $current_time ); |
|
874 | + $dates['year'] = date('Y', $current_time); |
|
875 | 875 | break; |
876 | 876 | |
877 | 877 | case 'last_year' : |
878 | 878 | $dates['day'] = null; |
879 | 879 | $dates['m_start'] = null; |
880 | 880 | $dates['m_end'] = null; |
881 | - $dates['year'] = date( 'Y', $current_time ) - 1; |
|
881 | + $dates['year'] = date('Y', $current_time) - 1; |
|
882 | 882 | break; |
883 | 883 | |
884 | 884 | endswitch; |
@@ -891,7 +891,7 @@ discard block |
||
891 | 891 | * |
892 | 892 | * @param array $dates The dates used for retrieving earnings. |
893 | 893 | */ |
894 | - return apply_filters( 'give_api_stat_dates', $dates ); |
|
894 | + return apply_filters('give_api_stat_dates', $dates); |
|
895 | 895 | } |
896 | 896 | |
897 | 897 | /** |
@@ -905,84 +905,84 @@ discard block |
||
905 | 905 | * |
906 | 906 | * @return array $donors Multidimensional array of the donors. |
907 | 907 | */ |
908 | - public function get_donors( $donor = null ) { |
|
908 | + public function get_donors($donor = null) { |
|
909 | 909 | |
910 | 910 | $donors = array(); |
911 | 911 | $error = array(); |
912 | - if ( ! user_can( $this->user_id, 'view_give_sensitive_data' ) && ! $this->override ) { |
|
912 | + if ( ! user_can($this->user_id, 'view_give_sensitive_data') && ! $this->override) { |
|
913 | 913 | return $donors; |
914 | 914 | } |
915 | 915 | |
916 | 916 | $paged = $this->get_paged(); |
917 | 917 | $per_page = $this->per_page(); |
918 | - $offset = $per_page * ( $paged - 1 ); |
|
918 | + $offset = $per_page * ($paged - 1); |
|
919 | 919 | |
920 | - if ( is_numeric( $donor ) ) { |
|
920 | + if (is_numeric($donor)) { |
|
921 | 921 | $field = 'id'; |
922 | 922 | } else { |
923 | 923 | $field = 'email'; |
924 | 924 | } |
925 | 925 | |
926 | - $donor_query = Give()->donors->get_donors( array( |
|
926 | + $donor_query = Give()->donors->get_donors(array( |
|
927 | 927 | 'number' => $per_page, |
928 | 928 | 'offset' => $offset, |
929 | 929 | $field => $donor, |
930 | - ) ); |
|
930 | + )); |
|
931 | 931 | $donor_count = 0; |
932 | 932 | |
933 | - if ( $donor_query ) { |
|
933 | + if ($donor_query) { |
|
934 | 934 | |
935 | - foreach ( $donor_query as $donor_obj ) { |
|
935 | + foreach ($donor_query as $donor_obj) { |
|
936 | 936 | |
937 | - $names = explode( ' ', $donor_obj->name ); |
|
938 | - $first_name = ! empty( $names[0] ) ? $names[0] : ''; |
|
937 | + $names = explode(' ', $donor_obj->name); |
|
938 | + $first_name = ! empty($names[0]) ? $names[0] : ''; |
|
939 | 939 | $last_name = ''; |
940 | - if ( ! empty( $names[1] ) ) { |
|
941 | - unset( $names[0] ); |
|
942 | - $last_name = implode( ' ', $names ); |
|
940 | + if ( ! empty($names[1])) { |
|
941 | + unset($names[0]); |
|
942 | + $last_name = implode(' ', $names); |
|
943 | 943 | } |
944 | 944 | |
945 | - $donors['donors'][ $donor_count ]['info']['user_id'] = ''; |
|
946 | - $donors['donors'][ $donor_count ]['info']['username'] = ''; |
|
947 | - $donors['donors'][ $donor_count ]['info']['display_name'] = ''; |
|
948 | - $donors['donors'][ $donor_count ]['info']['donor_id'] = $donor_obj->id; |
|
949 | - $donors['donors'][ $donor_count ]['info']['first_name'] = $first_name; |
|
950 | - $donors['donors'][ $donor_count ]['info']['last_name'] = $last_name; |
|
951 | - $donors['donors'][ $donor_count ]['info']['email'] = $donor_obj->email; |
|
945 | + $donors['donors'][$donor_count]['info']['user_id'] = ''; |
|
946 | + $donors['donors'][$donor_count]['info']['username'] = ''; |
|
947 | + $donors['donors'][$donor_count]['info']['display_name'] = ''; |
|
948 | + $donors['donors'][$donor_count]['info']['donor_id'] = $donor_obj->id; |
|
949 | + $donors['donors'][$donor_count]['info']['first_name'] = $first_name; |
|
950 | + $donors['donors'][$donor_count]['info']['last_name'] = $last_name; |
|
951 | + $donors['donors'][$donor_count]['info']['email'] = $donor_obj->email; |
|
952 | 952 | |
953 | - if ( ! empty( $donor_obj->user_id ) ) { |
|
953 | + if ( ! empty($donor_obj->user_id)) { |
|
954 | 954 | |
955 | - $user_data = get_userdata( $donor_obj->user_id ); |
|
955 | + $user_data = get_userdata($donor_obj->user_id); |
|
956 | 956 | |
957 | 957 | // Donor with registered account. |
958 | - $donors['donors'][ $donor_count ]['info']['user_id'] = $donor_obj->user_id; |
|
959 | - $donors['donors'][ $donor_count ]['info']['username'] = $user_data->user_login; |
|
960 | - $donors['donors'][ $donor_count ]['info']['display_name'] = $user_data->display_name; |
|
958 | + $donors['donors'][$donor_count]['info']['user_id'] = $donor_obj->user_id; |
|
959 | + $donors['donors'][$donor_count]['info']['username'] = $user_data->user_login; |
|
960 | + $donors['donors'][$donor_count]['info']['display_name'] = $user_data->display_name; |
|
961 | 961 | |
962 | 962 | } |
963 | 963 | |
964 | - $donors['donors'][ $donor_count ]['stats']['total_donations'] = $donor_obj->purchase_count; |
|
965 | - $donors['donors'][ $donor_count ]['stats']['total_spent'] = $donor_obj->purchase_value; |
|
964 | + $donors['donors'][$donor_count]['stats']['total_donations'] = $donor_obj->purchase_count; |
|
965 | + $donors['donors'][$donor_count]['stats']['total_spent'] = $donor_obj->purchase_value; |
|
966 | 966 | |
967 | 967 | /** @var $donor \Give_Donor */ |
968 | - $donor = new Give_Donor( $donor_obj->id ); |
|
968 | + $donor = new Give_Donor($donor_obj->id); |
|
969 | 969 | |
970 | 970 | // Get donor's addresses. |
971 | - $donors['donors'][ $donor_count ]['address'] = $donor->address; |
|
971 | + $donors['donors'][$donor_count]['address'] = $donor->address; |
|
972 | 972 | |
973 | - $donor_count ++; |
|
973 | + $donor_count++; |
|
974 | 974 | |
975 | 975 | } |
976 | - } elseif ( $donor ) { |
|
976 | + } elseif ($donor) { |
|
977 | 977 | |
978 | 978 | $error['error'] = sprintf( /* translators: %s: donor */ |
979 | - __( 'Donor %s not found.', 'give' ), $donor ); |
|
979 | + __('Donor %s not found.', 'give'), $donor ); |
|
980 | 980 | |
981 | 981 | return $error; |
982 | 982 | |
983 | 983 | } else { |
984 | 984 | |
985 | - $error['error'] = __( 'No donors found.', 'give' ); |
|
985 | + $error['error'] = __('No donors found.', 'give'); |
|
986 | 986 | |
987 | 987 | return $error; |
988 | 988 | |
@@ -1001,37 +1001,37 @@ discard block |
||
1001 | 1001 | * |
1002 | 1002 | * @return array $donors Multidimensional array of the forms. |
1003 | 1003 | */ |
1004 | - public function get_forms( $form = null ) { |
|
1004 | + public function get_forms($form = null) { |
|
1005 | 1005 | |
1006 | 1006 | $forms = array(); |
1007 | 1007 | $error = array(); |
1008 | 1008 | |
1009 | - if ( $form == null ) { |
|
1009 | + if ($form == null) { |
|
1010 | 1010 | $forms['forms'] = array(); |
1011 | 1011 | |
1012 | - $form_list = get_posts( array( |
|
1012 | + $form_list = get_posts(array( |
|
1013 | 1013 | 'post_type' => 'give_forms', |
1014 | 1014 | 'posts_per_page' => $this->per_page(), |
1015 | 1015 | 'suppress_filters' => true, |
1016 | 1016 | 'paged' => $this->get_paged(), |
1017 | - ) ); |
|
1017 | + )); |
|
1018 | 1018 | |
1019 | - if ( $form_list ) { |
|
1019 | + if ($form_list) { |
|
1020 | 1020 | $i = 0; |
1021 | - foreach ( $form_list as $form_info ) { |
|
1022 | - $forms['forms'][ $i ] = $this->get_form_data( $form_info ); |
|
1023 | - $i ++; |
|
1021 | + foreach ($form_list as $form_info) { |
|
1022 | + $forms['forms'][$i] = $this->get_form_data($form_info); |
|
1023 | + $i++; |
|
1024 | 1024 | } |
1025 | 1025 | } |
1026 | 1026 | } else { |
1027 | - if ( get_post_type( $form ) == 'give_forms' ) { |
|
1028 | - $form_info = get_post( $form ); |
|
1027 | + if (get_post_type($form) == 'give_forms') { |
|
1028 | + $form_info = get_post($form); |
|
1029 | 1029 | |
1030 | - $forms['forms'][0] = $this->get_form_data( $form_info ); |
|
1030 | + $forms['forms'][0] = $this->get_form_data($form_info); |
|
1031 | 1031 | |
1032 | 1032 | } else { |
1033 | 1033 | $error['error'] = sprintf( /* translators: %s: form */ |
1034 | - __( 'Form %s not found.', 'give' ), $form ); |
|
1034 | + __('Form %s not found.', 'give'), $form ); |
|
1035 | 1035 | |
1036 | 1036 | return $error; |
1037 | 1037 | } |
@@ -1049,7 +1049,7 @@ discard block |
||
1049 | 1049 | * |
1050 | 1050 | * @return array Array of post data to return back in the API. |
1051 | 1051 | */ |
1052 | - private function get_form_data( $form_info ) { |
|
1052 | + private function get_form_data($form_info) { |
|
1053 | 1053 | |
1054 | 1054 | $form = array(); |
1055 | 1055 | |
@@ -1059,60 +1059,60 @@ discard block |
||
1059 | 1059 | $form['info']['create_date'] = $form_info->post_date; |
1060 | 1060 | $form['info']['modified_date'] = $form_info->post_modified; |
1061 | 1061 | $form['info']['status'] = $form_info->post_status; |
1062 | - $form['info']['link'] = html_entity_decode( $form_info->guid ); |
|
1063 | - $form['info']['content'] = give_get_meta( $form_info->ID, '_give_form_content', true ); |
|
1064 | - $form['info']['thumbnail'] = wp_get_attachment_url( get_post_thumbnail_id( $form_info->ID ) ); |
|
1062 | + $form['info']['link'] = html_entity_decode($form_info->guid); |
|
1063 | + $form['info']['content'] = give_get_meta($form_info->ID, '_give_form_content', true); |
|
1064 | + $form['info']['thumbnail'] = wp_get_attachment_url(get_post_thumbnail_id($form_info->ID)); |
|
1065 | 1065 | |
1066 | - if ( give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ) ) { |
|
1067 | - $form['info']['category'] = get_the_terms( $form_info, 'give_forms_category' ); |
|
1068 | - $form['info']['tags'] = get_the_terms( $form_info, 'give_forms_tag' ); |
|
1066 | + if (give_is_setting_enabled(give_get_option('categories', 'disabled'))) { |
|
1067 | + $form['info']['category'] = get_the_terms($form_info, 'give_forms_category'); |
|
1068 | + $form['info']['tags'] = get_the_terms($form_info, 'give_forms_tag'); |
|
1069 | 1069 | } |
1070 | - if ( give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ) ) { |
|
1071 | - $form['info']['tags'] = get_the_terms( $form_info, 'give_forms_tag' ); |
|
1070 | + if (give_is_setting_enabled(give_get_option('tags', 'disabled'))) { |
|
1071 | + $form['info']['tags'] = get_the_terms($form_info, 'give_forms_tag'); |
|
1072 | 1072 | } |
1073 | 1073 | |
1074 | 1074 | // Check whether any goal is to be achieved for the donation form. |
1075 | - $goal_option = give_get_meta( $form_info->ID, '_give_goal_option', true ); |
|
1076 | - $goal_amount = give_get_meta( $form_info->ID, '_give_set_goal', true ); |
|
1077 | - if ( give_is_setting_enabled( $goal_option ) && $goal_amount ) { |
|
1078 | - $total_income = give_get_form_earnings_stats( $form_info->ID ); |
|
1079 | - $goal_percentage_completed = ( $total_income < $goal_amount ) ? round( ( $total_income / $goal_amount ) * 100, 2 ) : 100; |
|
1080 | - $form['goal']['amount'] = isset( $goal_amount ) ? $goal_amount : ''; |
|
1081 | - $form['goal']['percentage_completed'] = isset( $goal_percentage_completed ) ? $goal_percentage_completed : ''; |
|
1075 | + $goal_option = give_get_meta($form_info->ID, '_give_goal_option', true); |
|
1076 | + $goal_amount = give_get_meta($form_info->ID, '_give_set_goal', true); |
|
1077 | + if (give_is_setting_enabled($goal_option) && $goal_amount) { |
|
1078 | + $total_income = give_get_form_earnings_stats($form_info->ID); |
|
1079 | + $goal_percentage_completed = ($total_income < $goal_amount) ? round(($total_income / $goal_amount) * 100, 2) : 100; |
|
1080 | + $form['goal']['amount'] = isset($goal_amount) ? $goal_amount : ''; |
|
1081 | + $form['goal']['percentage_completed'] = isset($goal_percentage_completed) ? $goal_percentage_completed : ''; |
|
1082 | 1082 | } |
1083 | 1083 | |
1084 | - if ( user_can( $this->user_id, 'view_give_reports' ) || $this->override ) { |
|
1085 | - $form['stats']['total']['donations'] = give_get_form_sales_stats( $form_info->ID ); |
|
1086 | - $form['stats']['total']['earnings'] = give_get_form_earnings_stats( $form_info->ID ); |
|
1087 | - $form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales( $form_info->ID ); |
|
1088 | - $form['stats']['monthly_average']['earnings'] = give_get_average_monthly_form_earnings( $form_info->ID ); |
|
1084 | + if (user_can($this->user_id, 'view_give_reports') || $this->override) { |
|
1085 | + $form['stats']['total']['donations'] = give_get_form_sales_stats($form_info->ID); |
|
1086 | + $form['stats']['total']['earnings'] = give_get_form_earnings_stats($form_info->ID); |
|
1087 | + $form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales($form_info->ID); |
|
1088 | + $form['stats']['monthly_average']['earnings'] = give_get_average_monthly_form_earnings($form_info->ID); |
|
1089 | 1089 | } |
1090 | 1090 | |
1091 | 1091 | $counter = 0; |
1092 | - if ( give_has_variable_prices( $form_info->ID ) ) { |
|
1093 | - foreach ( give_get_variable_prices( $form_info->ID ) as $price ) { |
|
1094 | - $counter ++; |
|
1092 | + if (give_has_variable_prices($form_info->ID)) { |
|
1093 | + foreach (give_get_variable_prices($form_info->ID) as $price) { |
|
1094 | + $counter++; |
|
1095 | 1095 | // multi-level item |
1096 | - $level = isset( $price['_give_text'] ) ? $price['_give_text'] : 'level-' . $counter; |
|
1097 | - $form['pricing'][ sanitize_key( $level ) ] = $price['_give_amount']; |
|
1096 | + $level = isset($price['_give_text']) ? $price['_give_text'] : 'level-'.$counter; |
|
1097 | + $form['pricing'][sanitize_key($level)] = $price['_give_amount']; |
|
1098 | 1098 | |
1099 | 1099 | } |
1100 | 1100 | } else { |
1101 | - $form['pricing']['amount'] = give_get_form_price( $form_info->ID ); |
|
1101 | + $form['pricing']['amount'] = give_get_form_price($form_info->ID); |
|
1102 | 1102 | } |
1103 | 1103 | |
1104 | - if ( user_can( $this->user_id, 'view_give_sensitive_data' ) || $this->override ) { |
|
1104 | + if (user_can($this->user_id, 'view_give_sensitive_data') || $this->override) { |
|
1105 | 1105 | |
1106 | 1106 | /** |
1107 | 1107 | * Fires when generating API sensitive data. |
1108 | 1108 | * |
1109 | 1109 | * @since 1.1 |
1110 | 1110 | */ |
1111 | - do_action( 'give_api_sensitive_data' ); |
|
1111 | + do_action('give_api_sensitive_data'); |
|
1112 | 1112 | |
1113 | 1113 | } |
1114 | 1114 | |
1115 | - return apply_filters( 'give_api_forms_form', $form ); |
|
1115 | + return apply_filters('give_api_forms_form', $form); |
|
1116 | 1116 | |
1117 | 1117 | } |
1118 | 1118 | |
@@ -1127,7 +1127,7 @@ discard block |
||
1127 | 1127 | * |
1128 | 1128 | * @return array |
1129 | 1129 | */ |
1130 | - public function get_stats( $args = array() ) { |
|
1130 | + public function get_stats($args = array()) { |
|
1131 | 1131 | $defaults = array( |
1132 | 1132 | 'type' => null, |
1133 | 1133 | 'form' => null, |
@@ -1136,9 +1136,9 @@ discard block |
||
1136 | 1136 | 'enddate' => null, |
1137 | 1137 | ); |
1138 | 1138 | |
1139 | - $args = wp_parse_args( $args, $defaults ); |
|
1139 | + $args = wp_parse_args($args, $defaults); |
|
1140 | 1140 | |
1141 | - $dates = $this->get_dates( $args ); |
|
1141 | + $dates = $this->get_dates($args); |
|
1142 | 1142 | |
1143 | 1143 | $stats = array(); |
1144 | 1144 | $earnings = array( |
@@ -1149,40 +1149,40 @@ discard block |
||
1149 | 1149 | ); |
1150 | 1150 | $error = array(); |
1151 | 1151 | |
1152 | - if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) { |
|
1152 | + if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) { |
|
1153 | 1153 | return $stats; |
1154 | 1154 | } |
1155 | 1155 | |
1156 | - if ( $args['type'] == 'donations' ) { |
|
1156 | + if ($args['type'] == 'donations') { |
|
1157 | 1157 | |
1158 | - if ( $args['form'] == null ) { |
|
1159 | - if ( $args['date'] == null ) { |
|
1158 | + if ($args['form'] == null) { |
|
1159 | + if ($args['date'] == null) { |
|
1160 | 1160 | $donations = $this->get_default_sales_stats(); |
1161 | - } elseif ( $args['date'] === 'range' ) { |
|
1161 | + } elseif ($args['date'] === 'range') { |
|
1162 | 1162 | // Return donations for a date range. |
1163 | 1163 | // Ensure the end date is later than the start date. |
1164 | - if ( $args['enddate'] < $args['startdate'] ) { |
|
1165 | - $error['error'] = __( 'The end date must be later than the start date.', 'give' ); |
|
1164 | + if ($args['enddate'] < $args['startdate']) { |
|
1165 | + $error['error'] = __('The end date must be later than the start date.', 'give'); |
|
1166 | 1166 | } |
1167 | 1167 | |
1168 | 1168 | // Ensure both the start and end date are specified |
1169 | - if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) { |
|
1170 | - $error['error'] = __( 'Invalid or no date range specified.', 'give' ); |
|
1169 | + if (empty($args['startdate']) || empty($args['enddate'])) { |
|
1170 | + $error['error'] = __('Invalid or no date range specified.', 'give'); |
|
1171 | 1171 | } |
1172 | 1172 | |
1173 | 1173 | $total = 0; |
1174 | 1174 | |
1175 | 1175 | // Loop through the years |
1176 | 1176 | $y = $dates['year']; |
1177 | - while ( $y <= $dates['year_end'] ) : |
|
1177 | + while ($y <= $dates['year_end']) : |
|
1178 | 1178 | |
1179 | - if ( $dates['year'] == $dates['year_end'] ) { |
|
1179 | + if ($dates['year'] == $dates['year_end']) { |
|
1180 | 1180 | $month_start = $dates['m_start']; |
1181 | 1181 | $month_end = $dates['m_end']; |
1182 | - } elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) { |
|
1182 | + } elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) { |
|
1183 | 1183 | $month_start = $dates['m_start']; |
1184 | 1184 | $month_end = 12; |
1185 | - } elseif ( $y == $dates['year_end'] ) { |
|
1185 | + } elseif ($y == $dates['year_end']) { |
|
1186 | 1186 | $month_start = 1; |
1187 | 1187 | $month_end = $dates['m_end']; |
1188 | 1188 | } else { |
@@ -1191,116 +1191,116 @@ discard block |
||
1191 | 1191 | } |
1192 | 1192 | |
1193 | 1193 | $i = $month_start; |
1194 | - while ( $i <= $month_end ) : |
|
1194 | + while ($i <= $month_end) : |
|
1195 | 1195 | |
1196 | - if ( $i == $dates['m_start'] ) { |
|
1196 | + if ($i == $dates['m_start']) { |
|
1197 | 1197 | $d = $dates['day_start']; |
1198 | 1198 | } else { |
1199 | 1199 | $d = 1; |
1200 | 1200 | } |
1201 | 1201 | |
1202 | - if ( $i == $dates['m_end'] ) { |
|
1202 | + if ($i == $dates['m_end']) { |
|
1203 | 1203 | $num_of_days = $dates['day_end']; |
1204 | 1204 | } else { |
1205 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
1205 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
1206 | 1206 | } |
1207 | 1207 | |
1208 | - while ( $d <= $num_of_days ) : |
|
1209 | - $sale_count = give_get_sales_by_date( $d, $i, $y ); |
|
1210 | - $date_key = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) ); |
|
1211 | - if ( ! isset( $donations['sales'][ $date_key ] ) ) { |
|
1212 | - $donations['sales'][ $date_key ] = 0; |
|
1208 | + while ($d <= $num_of_days) : |
|
1209 | + $sale_count = give_get_sales_by_date($d, $i, $y); |
|
1210 | + $date_key = date('Ymd', strtotime($y.'/'.$i.'/'.$d)); |
|
1211 | + if ( ! isset($donations['sales'][$date_key])) { |
|
1212 | + $donations['sales'][$date_key] = 0; |
|
1213 | 1213 | } |
1214 | - $donations['sales'][ $date_key ] += $sale_count; |
|
1214 | + $donations['sales'][$date_key] += $sale_count; |
|
1215 | 1215 | $total += $sale_count; |
1216 | - $d ++; |
|
1216 | + $d++; |
|
1217 | 1217 | endwhile; |
1218 | - $i ++; |
|
1218 | + $i++; |
|
1219 | 1219 | endwhile; |
1220 | 1220 | |
1221 | - $y ++; |
|
1221 | + $y++; |
|
1222 | 1222 | endwhile; |
1223 | 1223 | |
1224 | 1224 | $donations['totals'] = $total; |
1225 | 1225 | } else { |
1226 | - if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) { |
|
1226 | + if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') { |
|
1227 | 1227 | $donations_count = 0; |
1228 | 1228 | |
1229 | 1229 | // Loop through the months |
1230 | 1230 | $month = $dates['m_start']; |
1231 | 1231 | |
1232 | - while ( $month <= $dates['m_end'] ) : |
|
1233 | - $donations_count += give_get_sales_by_date( null, $month, $dates['year'] ); |
|
1234 | - $month ++; |
|
1232 | + while ($month <= $dates['m_end']) : |
|
1233 | + $donations_count += give_get_sales_by_date(null, $month, $dates['year']); |
|
1234 | + $month++; |
|
1235 | 1235 | endwhile; |
1236 | 1236 | |
1237 | - $donations['donations'][ $args['date'] ] = $donations_count; |
|
1237 | + $donations['donations'][$args['date']] = $donations_count; |
|
1238 | 1238 | } else { |
1239 | - $donations['donations'][ $args['date'] ] = give_get_sales_by_date( $dates['day'], $dates['m_start'], $dates['year'] ); |
|
1239 | + $donations['donations'][$args['date']] = give_get_sales_by_date($dates['day'], $dates['m_start'], $dates['year']); |
|
1240 | 1240 | } |
1241 | 1241 | }// End if(). |
1242 | - } elseif ( $args['form'] == 'all' ) { |
|
1243 | - $forms = get_posts( array( |
|
1242 | + } elseif ($args['form'] == 'all') { |
|
1243 | + $forms = get_posts(array( |
|
1244 | 1244 | 'post_type' => 'give_forms', |
1245 | 1245 | 'nopaging' => true, |
1246 | - ) ); |
|
1247 | - $i = 0; |
|
1248 | - foreach ( $forms as $form_info ) { |
|
1249 | - $donations['donations'][ $i ] = array( |
|
1250 | - $form_info->post_name => give_get_form_sales_stats( $form_info->ID ), |
|
1246 | + )); |
|
1247 | + $i = 0; |
|
1248 | + foreach ($forms as $form_info) { |
|
1249 | + $donations['donations'][$i] = array( |
|
1250 | + $form_info->post_name => give_get_form_sales_stats($form_info->ID), |
|
1251 | 1251 | ); |
1252 | - $i ++; |
|
1252 | + $i++; |
|
1253 | 1253 | } |
1254 | 1254 | } else { |
1255 | - if ( get_post_type( $args['form'] ) == 'give_forms' ) { |
|
1256 | - $form_info = get_post( $args['form'] ); |
|
1255 | + if (get_post_type($args['form']) == 'give_forms') { |
|
1256 | + $form_info = get_post($args['form']); |
|
1257 | 1257 | $donations['donations'][0] = array( |
1258 | - $form_info->post_name => give_get_form_sales_stats( $args['form'] ), |
|
1258 | + $form_info->post_name => give_get_form_sales_stats($args['form']), |
|
1259 | 1259 | ); |
1260 | 1260 | } else { |
1261 | 1261 | $error['error'] = sprintf( /* translators: %s: form */ |
1262 | - __( 'Form %s not found.', 'give' ), $args['form'] ); |
|
1262 | + __('Form %s not found.', 'give'), $args['form'] ); |
|
1263 | 1263 | } |
1264 | 1264 | }// End if(). |
1265 | 1265 | |
1266 | - if ( ! empty( $error ) ) { |
|
1266 | + if ( ! empty($error)) { |
|
1267 | 1267 | return $error; |
1268 | 1268 | } |
1269 | 1269 | |
1270 | 1270 | return $donations; |
1271 | 1271 | |
1272 | - } elseif ( $args['type'] == 'earnings' ) { |
|
1273 | - if ( $args['form'] == null ) { |
|
1274 | - if ( $args['date'] == null ) { |
|
1272 | + } elseif ($args['type'] == 'earnings') { |
|
1273 | + if ($args['form'] == null) { |
|
1274 | + if ($args['date'] == null) { |
|
1275 | 1275 | $earnings = $this->get_default_earnings_stats(); |
1276 | - } elseif ( $args['date'] === 'range' ) { |
|
1276 | + } elseif ($args['date'] === 'range') { |
|
1277 | 1277 | // Return sales for a date range |
1278 | 1278 | // Ensure the end date is later than the start date |
1279 | - if ( $args['enddate'] < $args['startdate'] ) { |
|
1280 | - $error['error'] = __( 'The end date must be later than the start date.', 'give' ); |
|
1279 | + if ($args['enddate'] < $args['startdate']) { |
|
1280 | + $error['error'] = __('The end date must be later than the start date.', 'give'); |
|
1281 | 1281 | } |
1282 | 1282 | |
1283 | 1283 | // Ensure both the start and end date are specified |
1284 | - if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) { |
|
1285 | - $error['error'] = __( 'Invalid or no date range specified.', 'give' ); |
|
1284 | + if (empty($args['startdate']) || empty($args['enddate'])) { |
|
1285 | + $error['error'] = __('Invalid or no date range specified.', 'give'); |
|
1286 | 1286 | } |
1287 | 1287 | |
1288 | 1288 | $total = (float) 0.00; |
1289 | 1289 | |
1290 | 1290 | // Loop through the years |
1291 | 1291 | $y = $dates['year']; |
1292 | - if ( ! isset( $earnings['earnings'] ) ) { |
|
1292 | + if ( ! isset($earnings['earnings'])) { |
|
1293 | 1293 | $earnings['earnings'] = array(); |
1294 | 1294 | } |
1295 | - while ( $y <= $dates['year_end'] ) : |
|
1295 | + while ($y <= $dates['year_end']) : |
|
1296 | 1296 | |
1297 | - if ( $dates['year'] == $dates['year_end'] ) { |
|
1297 | + if ($dates['year'] == $dates['year_end']) { |
|
1298 | 1298 | $month_start = $dates['m_start']; |
1299 | 1299 | $month_end = $dates['m_end']; |
1300 | - } elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) { |
|
1300 | + } elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) { |
|
1301 | 1301 | $month_start = $dates['m_start']; |
1302 | 1302 | $month_end = 12; |
1303 | - } elseif ( $y == $dates['year_end'] ) { |
|
1303 | + } elseif ($y == $dates['year_end']) { |
|
1304 | 1304 | $month_start = 1; |
1305 | 1305 | $month_end = $dates['m_end']; |
1306 | 1306 | } else { |
@@ -1309,102 +1309,102 @@ discard block |
||
1309 | 1309 | } |
1310 | 1310 | |
1311 | 1311 | $i = $month_start; |
1312 | - while ( $i <= $month_end ) : |
|
1312 | + while ($i <= $month_end) : |
|
1313 | 1313 | |
1314 | - if ( $i == $dates['m_start'] ) { |
|
1314 | + if ($i == $dates['m_start']) { |
|
1315 | 1315 | $d = $dates['day_start']; |
1316 | 1316 | } else { |
1317 | 1317 | $d = 1; |
1318 | 1318 | } |
1319 | 1319 | |
1320 | - if ( $i == $dates['m_end'] ) { |
|
1320 | + if ($i == $dates['m_end']) { |
|
1321 | 1321 | $num_of_days = $dates['day_end']; |
1322 | 1322 | } else { |
1323 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
1323 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
1324 | 1324 | } |
1325 | 1325 | |
1326 | - while ( $d <= $num_of_days ) : |
|
1327 | - $earnings_stat = give_get_earnings_by_date( $d, $i, $y ); |
|
1328 | - $date_key = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) ); |
|
1329 | - if ( ! isset( $earnings['earnings'][ $date_key ] ) ) { |
|
1330 | - $earnings['earnings'][ $date_key ] = 0; |
|
1326 | + while ($d <= $num_of_days) : |
|
1327 | + $earnings_stat = give_get_earnings_by_date($d, $i, $y); |
|
1328 | + $date_key = date('Ymd', strtotime($y.'/'.$i.'/'.$d)); |
|
1329 | + if ( ! isset($earnings['earnings'][$date_key])) { |
|
1330 | + $earnings['earnings'][$date_key] = 0; |
|
1331 | 1331 | } |
1332 | - $earnings['earnings'][ $date_key ] += $earnings_stat; |
|
1332 | + $earnings['earnings'][$date_key] += $earnings_stat; |
|
1333 | 1333 | $total += $earnings_stat; |
1334 | - $d ++; |
|
1334 | + $d++; |
|
1335 | 1335 | endwhile; |
1336 | 1336 | |
1337 | - $i ++; |
|
1337 | + $i++; |
|
1338 | 1338 | endwhile; |
1339 | 1339 | |
1340 | - $y ++; |
|
1340 | + $y++; |
|
1341 | 1341 | endwhile; |
1342 | 1342 | |
1343 | 1343 | $earnings['totals'] = $total; |
1344 | 1344 | } else { |
1345 | - if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) { |
|
1345 | + if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') { |
|
1346 | 1346 | $earnings_count = (float) 0.00; |
1347 | 1347 | |
1348 | 1348 | // Loop through the months |
1349 | 1349 | $month = $dates['m_start']; |
1350 | 1350 | |
1351 | - while ( $month <= $dates['m_end'] ) : |
|
1352 | - $earnings_count += give_get_earnings_by_date( null, $month, $dates['year'] ); |
|
1353 | - $month ++; |
|
1351 | + while ($month <= $dates['m_end']) : |
|
1352 | + $earnings_count += give_get_earnings_by_date(null, $month, $dates['year']); |
|
1353 | + $month++; |
|
1354 | 1354 | endwhile; |
1355 | 1355 | |
1356 | - $earnings['earnings'][ $args['date'] ] = $earnings_count; |
|
1356 | + $earnings['earnings'][$args['date']] = $earnings_count; |
|
1357 | 1357 | } else { |
1358 | - $earnings['earnings'][ $args['date'] ] = give_get_earnings_by_date( $dates['day'], $dates['m_start'], $dates['year'] ); |
|
1358 | + $earnings['earnings'][$args['date']] = give_get_earnings_by_date($dates['day'], $dates['m_start'], $dates['year']); |
|
1359 | 1359 | } |
1360 | 1360 | }// End if(). |
1361 | - } elseif ( $args['form'] == 'all' ) { |
|
1362 | - $forms = get_posts( array( |
|
1361 | + } elseif ($args['form'] == 'all') { |
|
1362 | + $forms = get_posts(array( |
|
1363 | 1363 | 'post_type' => 'give_forms', |
1364 | 1364 | 'nopaging' => true, |
1365 | - ) ); |
|
1365 | + )); |
|
1366 | 1366 | |
1367 | 1367 | $i = 0; |
1368 | - foreach ( $forms as $form_info ) { |
|
1369 | - $earnings['earnings'][ $i ] = array( |
|
1370 | - $form_info->post_name => give_get_form_earnings_stats( $form_info->ID ), |
|
1368 | + foreach ($forms as $form_info) { |
|
1369 | + $earnings['earnings'][$i] = array( |
|
1370 | + $form_info->post_name => give_get_form_earnings_stats($form_info->ID), |
|
1371 | 1371 | ); |
1372 | - $i ++; |
|
1372 | + $i++; |
|
1373 | 1373 | } |
1374 | 1374 | } else { |
1375 | - if ( get_post_type( $args['form'] ) == 'give_forms' ) { |
|
1376 | - $form_info = get_post( $args['form'] ); |
|
1375 | + if (get_post_type($args['form']) == 'give_forms') { |
|
1376 | + $form_info = get_post($args['form']); |
|
1377 | 1377 | $earnings['earnings'][0] = array( |
1378 | 1378 | $form_info->post_name => $this->stats->get_earnings( |
1379 | 1379 | $args['form'], |
1380 | - is_numeric( $args['startdate'] ) |
|
1381 | - ? strtotime( $args['startdate'] ) |
|
1380 | + is_numeric($args['startdate']) |
|
1381 | + ? strtotime($args['startdate']) |
|
1382 | 1382 | : $args['startdate'], |
1383 | - is_numeric( $args['enddate'] ) |
|
1384 | - ? strtotime( $args['enddate'] ) |
|
1383 | + is_numeric($args['enddate']) |
|
1384 | + ? strtotime($args['enddate']) |
|
1385 | 1385 | : $args['enddate'] |
1386 | 1386 | ), |
1387 | 1387 | ); |
1388 | 1388 | } else { |
1389 | 1389 | $error['error'] = sprintf( /* translators: %s: form */ |
1390 | - __( 'Form %s not found.', 'give' ), $args['form'] ); |
|
1390 | + __('Form %s not found.', 'give'), $args['form'] ); |
|
1391 | 1391 | } |
1392 | 1392 | }// End if(). |
1393 | 1393 | |
1394 | - if ( ! empty( $error ) ) { |
|
1394 | + if ( ! empty($error)) { |
|
1395 | 1395 | return $error; |
1396 | 1396 | } |
1397 | 1397 | |
1398 | 1398 | return $earnings; |
1399 | - } elseif ( $args['type'] == 'donors' ) { |
|
1399 | + } elseif ($args['type'] == 'donors') { |
|
1400 | 1400 | $donors = new Give_DB_Donors(); |
1401 | 1401 | $stats['donations']['total_donors'] = $donors->count(); |
1402 | 1402 | |
1403 | 1403 | return $stats; |
1404 | 1404 | |
1405 | - } elseif ( empty( $args['type'] ) ) { |
|
1406 | - $stats = array_merge( $stats, $this->get_default_sales_stats() ); |
|
1407 | - $stats = array_merge( $stats, $this->get_default_earnings_stats() ); |
|
1405 | + } elseif (empty($args['type'])) { |
|
1406 | + $stats = array_merge($stats, $this->get_default_sales_stats()); |
|
1407 | + $stats = array_merge($stats, $this->get_default_earnings_stats()); |
|
1408 | 1408 | |
1409 | 1409 | return array( |
1410 | 1410 | 'stats' => $stats, |
@@ -1422,7 +1422,7 @@ discard block |
||
1422 | 1422 | * |
1423 | 1423 | * @return array |
1424 | 1424 | */ |
1425 | - public function get_recent_donations( $args = array() ) { |
|
1425 | + public function get_recent_donations($args = array()) { |
|
1426 | 1426 | global $wp_query; |
1427 | 1427 | |
1428 | 1428 | $defaults = array( |
@@ -1432,33 +1432,33 @@ discard block |
||
1432 | 1432 | 'enddate' => null, |
1433 | 1433 | ); |
1434 | 1434 | |
1435 | - $args = wp_parse_args( $args, $defaults ); |
|
1435 | + $args = wp_parse_args($args, $defaults); |
|
1436 | 1436 | |
1437 | 1437 | $donations = array(); |
1438 | 1438 | |
1439 | - if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) { |
|
1439 | + if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) { |
|
1440 | 1440 | return $donations; |
1441 | 1441 | } |
1442 | 1442 | |
1443 | - if ( isset( $wp_query->query_vars['id'] ) ) { |
|
1443 | + if (isset($wp_query->query_vars['id'])) { |
|
1444 | 1444 | $query = array(); |
1445 | - $query[] = new Give_Payment( $wp_query->query_vars['id'] ); |
|
1446 | - } elseif ( isset( $wp_query->query_vars['purchasekey'] ) ) { |
|
1445 | + $query[] = new Give_Payment($wp_query->query_vars['id']); |
|
1446 | + } elseif (isset($wp_query->query_vars['purchasekey'])) { |
|
1447 | 1447 | $query = array(); |
1448 | - $query[] = give_get_payment_by( 'key', $wp_query->query_vars['purchasekey'] ); |
|
1449 | - } elseif ( isset( $wp_query->query_vars['email'] ) ) { |
|
1450 | - $args = array( |
|
1448 | + $query[] = give_get_payment_by('key', $wp_query->query_vars['purchasekey']); |
|
1449 | + } elseif (isset($wp_query->query_vars['email'])) { |
|
1450 | + $args = array( |
|
1451 | 1451 | 'fields' => 'ids', |
1452 | 1452 | 'meta_key' => '_give_payment_donor_email', |
1453 | 1453 | 'meta_value' => $wp_query->query_vars['email'], |
1454 | 1454 | 'number' => $this->per_page(), |
1455 | 1455 | 'page' => $this->get_paged(), |
1456 | 1456 | ); |
1457 | - $query = give_get_payments( $args ); |
|
1458 | - } elseif ( isset( $wp_query->query_vars['date'] ) ) { |
|
1457 | + $query = give_get_payments($args); |
|
1458 | + } elseif (isset($wp_query->query_vars['date'])) { |
|
1459 | 1459 | |
1460 | - $current_time = current_time( 'timestamp' ); |
|
1461 | - $dates = $this->get_dates( $args ); |
|
1460 | + $current_time = current_time('timestamp'); |
|
1461 | + $dates = $this->get_dates($args); |
|
1462 | 1462 | $start_date = ''; |
1463 | 1463 | $end_date = ''; |
1464 | 1464 | |
@@ -1471,27 +1471,27 @@ discard block |
||
1471 | 1471 | * @params date startdate | required when date = range and format to be YYYYMMDD (i.e. 20170524) |
1472 | 1472 | * @params date enddate | required when date = range and format to be YYYYMMDD (i.e. 20170524) |
1473 | 1473 | */ |
1474 | - switch ( $wp_query->query_vars['date'] ) { |
|
1474 | + switch ($wp_query->query_vars['date']) { |
|
1475 | 1475 | |
1476 | 1476 | case 'today': |
1477 | 1477 | |
1478 | 1478 | // Set and Format Start and End Date to be date of today. |
1479 | - $start_date = $end_date = date( 'Y/m/d', $current_time ); |
|
1479 | + $start_date = $end_date = date('Y/m/d', $current_time); |
|
1480 | 1480 | |
1481 | 1481 | break; |
1482 | 1482 | |
1483 | 1483 | case 'yesterday': |
1484 | 1484 | |
1485 | 1485 | // Set and Format Start and End Date to be date of yesterday. |
1486 | - $start_date = $end_date = date( 'Y/m', $current_time ) . '/' . ( date( 'd', $current_time ) - 1 ); |
|
1486 | + $start_date = $end_date = date('Y/m', $current_time).'/'.(date('d', $current_time) - 1); |
|
1487 | 1487 | |
1488 | 1488 | break; |
1489 | 1489 | |
1490 | 1490 | case 'range': |
1491 | 1491 | |
1492 | 1492 | // Format Start Date and End Date for filtering payment based on date range. |
1493 | - $start_date = $dates['year'] . '/' . $dates['m_start'] . '/' . $dates['day_start']; |
|
1494 | - $end_date = $dates['year_end'] . '/' . $dates['m_end'] . '/' . $dates['day_end']; |
|
1493 | + $start_date = $dates['year'].'/'.$dates['m_start'].'/'.$dates['day_start']; |
|
1494 | + $end_date = $dates['year_end'].'/'.$dates['m_end'].'/'.$dates['day_end']; |
|
1495 | 1495 | |
1496 | 1496 | break; |
1497 | 1497 | |
@@ -1505,22 +1505,22 @@ discard block |
||
1505 | 1505 | 'page' => $this->get_paged(), |
1506 | 1506 | ); |
1507 | 1507 | |
1508 | - $query = give_get_payments( $args ); |
|
1508 | + $query = give_get_payments($args); |
|
1509 | 1509 | } else { |
1510 | 1510 | $args = array( |
1511 | 1511 | 'fields' => 'ids', |
1512 | 1512 | 'number' => $this->per_page(), |
1513 | 1513 | 'page' => $this->get_paged(), |
1514 | 1514 | ); |
1515 | - $query = give_get_payments( $args ); |
|
1515 | + $query = give_get_payments($args); |
|
1516 | 1516 | }// End if(). |
1517 | 1517 | |
1518 | - if ( $query ) { |
|
1518 | + if ($query) { |
|
1519 | 1519 | $i = 0; |
1520 | - foreach ( $query as $payment ) { |
|
1520 | + foreach ($query as $payment) { |
|
1521 | 1521 | |
1522 | - if ( is_numeric( $payment ) ) { |
|
1523 | - $payment = new Give_Payment( $payment ); |
|
1522 | + if (is_numeric($payment)) { |
|
1523 | + $payment = new Give_Payment($payment); |
|
1524 | 1524 | $payment_meta = $payment->get_meta(); |
1525 | 1525 | $user_info = $payment->user_info; |
1526 | 1526 | } |
@@ -1528,44 +1528,44 @@ discard block |
||
1528 | 1528 | $payment_meta = $payment->get_meta(); |
1529 | 1529 | $user_info = $payment->user_info; |
1530 | 1530 | |
1531 | - $first_name = isset( $user_info['first_name'] ) ? $user_info['first_name'] : ''; |
|
1532 | - $last_name = isset( $user_info['last_name'] ) ? $user_info['last_name'] : ''; |
|
1533 | - |
|
1534 | - $donations['donations'][ $i ]['ID'] = $payment->ID; |
|
1535 | - $donations['donations'][ $i ]['number'] = $payment->number; |
|
1536 | - $donations['donations'][ $i ]['transaction_id'] = $payment->transaction_id; |
|
1537 | - $donations['donations'][ $i ]['key'] = $payment->key; |
|
1538 | - $donations['donations'][ $i ]['total'] = $payment->total; |
|
1539 | - $donations['donations'][ $i ]['status'] = give_get_payment_status( $payment, true ); |
|
1540 | - $donations['donations'][ $i ]['gateway'] = $payment->gateway; |
|
1541 | - $donations['donations'][ $i ]['name'] = $first_name . ' ' . $last_name; |
|
1542 | - $donations['donations'][ $i ]['fname'] = $first_name; |
|
1543 | - $donations['donations'][ $i ]['lname'] = $last_name; |
|
1544 | - $donations['donations'][ $i ]['email'] = $payment->email; |
|
1545 | - $donations['donations'][ $i ]['date'] = $payment->date; |
|
1546 | - $donations['donations'][ $i ]['payment_meta'] = array(); |
|
1547 | - |
|
1548 | - $form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : $payment_meta; |
|
1549 | - $price = isset( $payment_meta['form_id'] ) ? give_get_form_price( $payment_meta['form_id'] ) : false; |
|
1550 | - $price_id = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null; |
|
1551 | - |
|
1552 | - $donations['donations'][ $i ]['form']['id'] = $form_id; |
|
1553 | - $donations['donations'][ $i ]['form']['name'] = get_the_title( $payment_meta['form_id'] ); |
|
1554 | - $donations['donations'][ $i ]['form']['price'] = $price; |
|
1555 | - |
|
1556 | - if ( give_has_variable_prices( $form_id ) ) { |
|
1557 | - if ( isset( $payment_meta['price_id'] ) ) { |
|
1558 | - $price_name = give_get_price_option_name( $form_id, $payment_meta['price_id'], $payment->ID ); |
|
1559 | - $donations['donations'][ $i ]['form']['price_name'] = $price_name; |
|
1560 | - $donations['donations'][ $i ]['form']['price_id'] = $price_id; |
|
1561 | - $donations['donations'][ $i ]['form']['price'] = give_get_price_option_amount( $form_id, $price_id ); |
|
1531 | + $first_name = isset($user_info['first_name']) ? $user_info['first_name'] : ''; |
|
1532 | + $last_name = isset($user_info['last_name']) ? $user_info['last_name'] : ''; |
|
1533 | + |
|
1534 | + $donations['donations'][$i]['ID'] = $payment->ID; |
|
1535 | + $donations['donations'][$i]['number'] = $payment->number; |
|
1536 | + $donations['donations'][$i]['transaction_id'] = $payment->transaction_id; |
|
1537 | + $donations['donations'][$i]['key'] = $payment->key; |
|
1538 | + $donations['donations'][$i]['total'] = $payment->total; |
|
1539 | + $donations['donations'][$i]['status'] = give_get_payment_status($payment, true); |
|
1540 | + $donations['donations'][$i]['gateway'] = $payment->gateway; |
|
1541 | + $donations['donations'][$i]['name'] = $first_name.' '.$last_name; |
|
1542 | + $donations['donations'][$i]['fname'] = $first_name; |
|
1543 | + $donations['donations'][$i]['lname'] = $last_name; |
|
1544 | + $donations['donations'][$i]['email'] = $payment->email; |
|
1545 | + $donations['donations'][$i]['date'] = $payment->date; |
|
1546 | + $donations['donations'][$i]['payment_meta'] = array(); |
|
1547 | + |
|
1548 | + $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : $payment_meta; |
|
1549 | + $price = isset($payment_meta['form_id']) ? give_get_form_price($payment_meta['form_id']) : false; |
|
1550 | + $price_id = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null; |
|
1551 | + |
|
1552 | + $donations['donations'][$i]['form']['id'] = $form_id; |
|
1553 | + $donations['donations'][$i]['form']['name'] = get_the_title($payment_meta['form_id']); |
|
1554 | + $donations['donations'][$i]['form']['price'] = $price; |
|
1555 | + |
|
1556 | + if (give_has_variable_prices($form_id)) { |
|
1557 | + if (isset($payment_meta['price_id'])) { |
|
1558 | + $price_name = give_get_price_option_name($form_id, $payment_meta['price_id'], $payment->ID); |
|
1559 | + $donations['donations'][$i]['form']['price_name'] = $price_name; |
|
1560 | + $donations['donations'][$i]['form']['price_id'] = $price_id; |
|
1561 | + $donations['donations'][$i]['form']['price'] = give_get_price_option_amount($form_id, $price_id); |
|
1562 | 1562 | |
1563 | 1563 | } |
1564 | 1564 | } |
1565 | 1565 | |
1566 | - if( ! empty( $payment_meta ) ) { |
|
1566 | + if ( ! empty($payment_meta)) { |
|
1567 | 1567 | // Add custom meta to API |
1568 | - foreach ( $payment_meta as $meta_key => $meta_value ) { |
|
1568 | + foreach ($payment_meta as $meta_key => $meta_value) { |
|
1569 | 1569 | |
1570 | 1570 | $exceptions = array( |
1571 | 1571 | 'form_title', |
@@ -1578,20 +1578,20 @@ discard block |
||
1578 | 1578 | ); |
1579 | 1579 | |
1580 | 1580 | // Don't clutter up results with dupes |
1581 | - if ( in_array( $meta_key, $exceptions ) ) { |
|
1581 | + if (in_array($meta_key, $exceptions)) { |
|
1582 | 1582 | continue; |
1583 | 1583 | } |
1584 | 1584 | |
1585 | - $donations['donations'][ $i ]['payment_meta'][ $meta_key ] = $meta_value; |
|
1585 | + $donations['donations'][$i]['payment_meta'][$meta_key] = $meta_value; |
|
1586 | 1586 | |
1587 | 1587 | } |
1588 | 1588 | } |
1589 | 1589 | |
1590 | - $i ++; |
|
1590 | + $i++; |
|
1591 | 1591 | }// End foreach(). |
1592 | 1592 | }// End if(). |
1593 | 1593 | |
1594 | - return apply_filters( 'give_api_donations_endpoint', $donations ); |
|
1594 | + return apply_filters('give_api_donations_endpoint', $donations); |
|
1595 | 1595 | } |
1596 | 1596 | |
1597 | 1597 | /** |
@@ -1607,9 +1607,9 @@ discard block |
||
1607 | 1607 | public function get_output_format() { |
1608 | 1608 | global $wp_query; |
1609 | 1609 | |
1610 | - $format = isset( $wp_query->query_vars['format'] ) ? $wp_query->query_vars['format'] : 'json'; |
|
1610 | + $format = isset($wp_query->query_vars['format']) ? $wp_query->query_vars['format'] : 'json'; |
|
1611 | 1611 | |
1612 | - return apply_filters( 'give_api_output_format', $format ); |
|
1612 | + return apply_filters('give_api_output_format', $format); |
|
1613 | 1613 | } |
1614 | 1614 | |
1615 | 1615 | |
@@ -1625,8 +1625,8 @@ discard block |
||
1625 | 1625 | * |
1626 | 1626 | * @return void |
1627 | 1627 | */ |
1628 | - private function log_request( $data = array() ) { |
|
1629 | - if ( ! $this->log_requests ) { |
|
1628 | + private function log_request($data = array()) { |
|
1629 | + if ( ! $this->log_requests) { |
|
1630 | 1630 | return; |
1631 | 1631 | } |
1632 | 1632 | |
@@ -1637,37 +1637,37 @@ discard block |
||
1637 | 1637 | |
1638 | 1638 | $query = array( |
1639 | 1639 | 'give-api' => $wp_query->query_vars['give-api'], |
1640 | - 'key' => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null, |
|
1641 | - 'token' => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null, |
|
1642 | - 'query' => isset( $wp_query->query_vars['query'] ) ? $wp_query->query_vars['query'] : null, |
|
1643 | - 'type' => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null, |
|
1644 | - 'form' => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null, |
|
1645 | - 'donor' => isset( $wp_query->query_vars['donor'] ) ? $wp_query->query_vars['donor'] : null, |
|
1646 | - 'date' => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null, |
|
1647 | - 'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null, |
|
1648 | - 'enddate' => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null, |
|
1649 | - 'id' => isset( $wp_query->query_vars['id'] ) ? $wp_query->query_vars['id'] : null, |
|
1650 | - 'purchasekey' => isset( $wp_query->query_vars['purchasekey'] ) ? $wp_query->query_vars['purchasekey'] : null, |
|
1651 | - 'email' => isset( $wp_query->query_vars['email'] ) ? $wp_query->query_vars['email'] : null, |
|
1640 | + 'key' => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null, |
|
1641 | + 'token' => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null, |
|
1642 | + 'query' => isset($wp_query->query_vars['query']) ? $wp_query->query_vars['query'] : null, |
|
1643 | + 'type' => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null, |
|
1644 | + 'form' => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null, |
|
1645 | + 'donor' => isset($wp_query->query_vars['donor']) ? $wp_query->query_vars['donor'] : null, |
|
1646 | + 'date' => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null, |
|
1647 | + 'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null, |
|
1648 | + 'enddate' => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null, |
|
1649 | + 'id' => isset($wp_query->query_vars['id']) ? $wp_query->query_vars['id'] : null, |
|
1650 | + 'purchasekey' => isset($wp_query->query_vars['purchasekey']) ? $wp_query->query_vars['purchasekey'] : null, |
|
1651 | + 'email' => isset($wp_query->query_vars['email']) ? $wp_query->query_vars['email'] : null, |
|
1652 | 1652 | ); |
1653 | 1653 | |
1654 | 1654 | $log_data = array( |
1655 | 1655 | 'log_type' => 'api_request', |
1656 | - 'post_excerpt' => http_build_query( $query ), |
|
1657 | - 'post_content' => ! empty( $data['error'] ) ? $data['error'] : '', |
|
1656 | + 'post_excerpt' => http_build_query($query), |
|
1657 | + 'post_content' => ! empty($data['error']) ? $data['error'] : '', |
|
1658 | 1658 | ); |
1659 | 1659 | |
1660 | 1660 | $log_meta = array( |
1661 | - 'api_query' => http_build_query( $query ), |
|
1661 | + 'api_query' => http_build_query($query), |
|
1662 | 1662 | 'request_ip' => give_get_ip(), |
1663 | 1663 | 'user' => $this->user_id, |
1664 | - 'key' => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null, |
|
1665 | - 'token' => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null, |
|
1664 | + 'key' => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null, |
|
1665 | + 'token' => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null, |
|
1666 | 1666 | 'time' => $data['request_speed'], |
1667 | 1667 | 'version' => $this->get_queried_version(), |
1668 | 1668 | ); |
1669 | 1669 | |
1670 | - Give()->logs->insert_log( $log_data, $log_meta ); |
|
1670 | + Give()->logs->insert_log($log_data, $log_meta); |
|
1671 | 1671 | } |
1672 | 1672 | |
1673 | 1673 | |
@@ -1691,11 +1691,11 @@ discard block |
||
1691 | 1691 | * |
1692 | 1692 | * @param int $status_code |
1693 | 1693 | */ |
1694 | - public function output( $status_code = 200 ) { |
|
1694 | + public function output($status_code = 200) { |
|
1695 | 1695 | |
1696 | 1696 | $format = $this->get_output_format(); |
1697 | 1697 | |
1698 | - status_header( $status_code ); |
|
1698 | + status_header($status_code); |
|
1699 | 1699 | |
1700 | 1700 | /** |
1701 | 1701 | * Fires before outputting the API. |
@@ -1706,25 +1706,25 @@ discard block |
||
1706 | 1706 | * @param Give_API $this The Give_API object. |
1707 | 1707 | * @param string $format Output format, XML or JSON. Default is JSON. |
1708 | 1708 | */ |
1709 | - do_action( 'give_api_output_before', $this->data, $this, $format ); |
|
1709 | + do_action('give_api_output_before', $this->data, $this, $format); |
|
1710 | 1710 | |
1711 | - switch ( $format ) : |
|
1711 | + switch ($format) : |
|
1712 | 1712 | |
1713 | 1713 | case 'xml' : |
1714 | 1714 | |
1715 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/array2xml.php'; |
|
1716 | - $xml = Array2XML::createXML( 'give', $this->data ); |
|
1715 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/array2xml.php'; |
|
1716 | + $xml = Array2XML::createXML('give', $this->data); |
|
1717 | 1717 | echo $xml->saveXML(); |
1718 | 1718 | |
1719 | 1719 | break; |
1720 | 1720 | |
1721 | 1721 | case 'json' : |
1722 | 1722 | |
1723 | - header( 'Content-Type: application/json' ); |
|
1724 | - if ( ! empty( $this->pretty_print ) ) { |
|
1725 | - echo json_encode( $this->data, $this->pretty_print ); |
|
1723 | + header('Content-Type: application/json'); |
|
1724 | + if ( ! empty($this->pretty_print)) { |
|
1725 | + echo json_encode($this->data, $this->pretty_print); |
|
1726 | 1726 | } else { |
1727 | - echo json_encode( $this->data ); |
|
1727 | + echo json_encode($this->data); |
|
1728 | 1728 | } |
1729 | 1729 | |
1730 | 1730 | break; |
@@ -1739,7 +1739,7 @@ discard block |
||
1739 | 1739 | * @param array $data Response data to return. |
1740 | 1740 | * @param Give_API $this The Give_API object. |
1741 | 1741 | */ |
1742 | - do_action( "give_api_output_{$format}", $this->data, $this ); |
|
1742 | + do_action("give_api_output_{$format}", $this->data, $this); |
|
1743 | 1743 | |
1744 | 1744 | break; |
1745 | 1745 | |
@@ -1754,7 +1754,7 @@ discard block |
||
1754 | 1754 | * @param Give_API $this The Give_API object. |
1755 | 1755 | * @param string $format Output format, XML or JSON. Default is JSON. |
1756 | 1756 | */ |
1757 | - do_action( 'give_api_output_after', $this->data, $this, $format ); |
|
1757 | + do_action('give_api_output_after', $this->data, $this, $format); |
|
1758 | 1758 | |
1759 | 1759 | give_die(); |
1760 | 1760 | } |
@@ -1771,41 +1771,41 @@ discard block |
||
1771 | 1771 | * |
1772 | 1772 | * @return void |
1773 | 1773 | */ |
1774 | - function user_key_field( $user ) { |
|
1774 | + function user_key_field($user) { |
|
1775 | 1775 | |
1776 | - if ( ( give_get_option( 'api_allow_user_keys', false ) || current_user_can( 'manage_give_settings' ) ) && current_user_can( 'edit_user', $user->ID ) ) { |
|
1776 | + if ((give_get_option('api_allow_user_keys', false) || current_user_can('manage_give_settings')) && current_user_can('edit_user', $user->ID)) { |
|
1777 | 1777 | |
1778 | - $user = get_userdata( $user->ID ); |
|
1778 | + $user = get_userdata($user->ID); |
|
1779 | 1779 | ?> |
1780 | 1780 | <table class="form-table"> |
1781 | 1781 | <tbody> |
1782 | 1782 | <tr> |
1783 | 1783 | <th> |
1784 | - <?php _e( 'Give API Keys', 'give' ); ?> |
|
1784 | + <?php _e('Give API Keys', 'give'); ?> |
|
1785 | 1785 | </th> |
1786 | 1786 | <td> |
1787 | 1787 | <?php |
1788 | - $public_key = $this->get_user_public_key( $user->ID ); |
|
1789 | - $secret_key = $this->get_user_secret_key( $user->ID ); |
|
1788 | + $public_key = $this->get_user_public_key($user->ID); |
|
1789 | + $secret_key = $this->get_user_secret_key($user->ID); |
|
1790 | 1790 | ?> |
1791 | - <?php if ( empty( $user->give_user_public_key ) ) { ?> |
|
1791 | + <?php if (empty($user->give_user_public_key)) { ?> |
|
1792 | 1792 | <input name="give_set_api_key" type="checkbox" id="give_set_api_key" /> |
1793 | - <span class="description"><?php _e( 'Generate API Key', 'give' ); ?></span> |
|
1793 | + <span class="description"><?php _e('Generate API Key', 'give'); ?></span> |
|
1794 | 1794 | <?php } else { ?> |
1795 | - <strong style="display:inline-block; width: 125px;"><?php _e( 'Public key:', 'give' ); ?> |
|
1795 | + <strong style="display:inline-block; width: 125px;"><?php _e('Public key:', 'give'); ?> |
|
1796 | 1796 | </strong> |
1797 | - <input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr( $public_key ); ?>" /> |
|
1797 | + <input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr($public_key); ?>" /> |
|
1798 | 1798 | <br /> |
1799 | - <strong style="display:inline-block; width: 125px;"><?php _e( 'Secret key:', 'give' ); ?> |
|
1799 | + <strong style="display:inline-block; width: 125px;"><?php _e('Secret key:', 'give'); ?> |
|
1800 | 1800 | </strong> |
1801 | - <input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr( $secret_key ); ?>" /> |
|
1801 | + <input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr($secret_key); ?>" /> |
|
1802 | 1802 | <br /> |
1803 | - <strong style="display:inline-block; width: 125px;"><?php _e( 'Token:', 'give' ); ?> |
|
1803 | + <strong style="display:inline-block; width: 125px;"><?php _e('Token:', 'give'); ?> |
|
1804 | 1804 | </strong> |
1805 | - <input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr( $this->get_token( $user->ID ) ); ?>" /> |
|
1805 | + <input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr($this->get_token($user->ID)); ?>" /> |
|
1806 | 1806 | <br /> |
1807 | 1807 | <input name="give_revoke_api_key" type="checkbox" id="give_revoke_api_key" /> |
1808 | - <span class="description"><label for="give_revoke_api_key"><?php _e( 'Revoke API Keys', 'give' ); ?></label></span> |
|
1808 | + <span class="description"><label for="give_revoke_api_key"><?php _e('Revoke API Keys', 'give'); ?></label></span> |
|
1809 | 1809 | <?php } ?> |
1810 | 1810 | </td> |
1811 | 1811 | </tr> |
@@ -1824,61 +1824,61 @@ discard block |
||
1824 | 1824 | * |
1825 | 1825 | * @return void |
1826 | 1826 | */ |
1827 | - public function process_api_key( $args ) { |
|
1827 | + public function process_api_key($args) { |
|
1828 | 1828 | |
1829 | - if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'give-api-nonce' ) ) { |
|
1830 | - wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array( |
|
1829 | + if ( ! wp_verify_nonce($_REQUEST['_wpnonce'], 'give-api-nonce')) { |
|
1830 | + wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'), array( |
|
1831 | 1831 | 'response' => 403, |
1832 | - ) ); |
|
1832 | + )); |
|
1833 | 1833 | } |
1834 | 1834 | |
1835 | - if ( empty( $args['user_id'] ) ) { |
|
1836 | - wp_die( __( 'User ID Required.', 'give' ), __( 'Error', 'give' ), array( |
|
1835 | + if (empty($args['user_id'])) { |
|
1836 | + wp_die(__('User ID Required.', 'give'), __('Error', 'give'), array( |
|
1837 | 1837 | 'response' => 401, |
1838 | - ) ); |
|
1838 | + )); |
|
1839 | 1839 | } |
1840 | 1840 | |
1841 | - if ( is_numeric( $args['user_id'] ) ) { |
|
1842 | - $user_id = isset( $args['user_id'] ) ? absint( $args['user_id'] ) : get_current_user_id(); |
|
1841 | + if (is_numeric($args['user_id'])) { |
|
1842 | + $user_id = isset($args['user_id']) ? absint($args['user_id']) : get_current_user_id(); |
|
1843 | 1843 | } else { |
1844 | - $userdata = get_user_by( 'login', $args['user_id'] ); |
|
1844 | + $userdata = get_user_by('login', $args['user_id']); |
|
1845 | 1845 | $user_id = $userdata->ID; |
1846 | 1846 | } |
1847 | - $process = isset( $args['give_api_process'] ) ? strtolower( $args['give_api_process'] ) : false; |
|
1847 | + $process = isset($args['give_api_process']) ? strtolower($args['give_api_process']) : false; |
|
1848 | 1848 | |
1849 | - if ( $user_id == get_current_user_id() && ! give_get_option( 'allow_user_api_keys' ) && ! current_user_can( 'manage_give_settings' ) ) { |
|
1850 | - wp_die( sprintf( /* translators: %s: process */ |
|
1851 | - __( 'You do not have permission to %s API keys for this user.', 'give' ), $process ), __( 'Error', 'give' ), array( |
|
1849 | + if ($user_id == get_current_user_id() && ! give_get_option('allow_user_api_keys') && ! current_user_can('manage_give_settings')) { |
|
1850 | + wp_die(sprintf( /* translators: %s: process */ |
|
1851 | + __('You do not have permission to %s API keys for this user.', 'give'), $process ), __('Error', 'give'), array( |
|
1852 | 1852 | 'response' => 403, |
1853 | - ) ); |
|
1854 | - } elseif ( ! current_user_can( 'manage_give_settings' ) ) { |
|
1855 | - wp_die( sprintf( /* translators: %s: process */ |
|
1856 | - __( 'You do not have permission to %s API keys for this user.', 'give' ), $process ), __( 'Error', 'give' ), array( |
|
1853 | + )); |
|
1854 | + } elseif ( ! current_user_can('manage_give_settings')) { |
|
1855 | + wp_die(sprintf( /* translators: %s: process */ |
|
1856 | + __('You do not have permission to %s API keys for this user.', 'give'), $process ), __('Error', 'give'), array( |
|
1857 | 1857 | 'response' => 403, |
1858 | - ) ); |
|
1858 | + )); |
|
1859 | 1859 | } |
1860 | 1860 | |
1861 | - switch ( $process ) { |
|
1861 | + switch ($process) { |
|
1862 | 1862 | case 'generate': |
1863 | - if ( $this->generate_api_key( $user_id ) ) { |
|
1864 | - Give_Cache::delete( Give_Cache::get_key( 'give_total_api_keys' ) ); |
|
1865 | - wp_redirect( add_query_arg( 'give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) ); |
|
1863 | + if ($this->generate_api_key($user_id)) { |
|
1864 | + Give_Cache::delete(Give_Cache::get_key('give_total_api_keys')); |
|
1865 | + wp_redirect(add_query_arg('give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-tools&tab=api')); |
|
1866 | 1866 | exit(); |
1867 | 1867 | } else { |
1868 | - wp_redirect( add_query_arg( 'give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) ); |
|
1868 | + wp_redirect(add_query_arg('give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-tools&tab=api')); |
|
1869 | 1869 | exit(); |
1870 | 1870 | } |
1871 | 1871 | break; |
1872 | 1872 | case 'regenerate': |
1873 | - $this->generate_api_key( $user_id, true ); |
|
1874 | - Give_Cache::delete( Give_Cache::get_key( 'give_total_api_keys' ) ); |
|
1875 | - wp_redirect( add_query_arg( 'give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) ); |
|
1873 | + $this->generate_api_key($user_id, true); |
|
1874 | + Give_Cache::delete(Give_Cache::get_key('give_total_api_keys')); |
|
1875 | + wp_redirect(add_query_arg('give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-tools&tab=api')); |
|
1876 | 1876 | exit(); |
1877 | 1877 | break; |
1878 | 1878 | case 'revoke': |
1879 | - $this->revoke_api_key( $user_id ); |
|
1880 | - Give_Cache::delete( Give_Cache::get_key( 'give_total_api_keys' ) ); |
|
1881 | - wp_redirect( add_query_arg( 'give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) ); |
|
1879 | + $this->revoke_api_key($user_id); |
|
1880 | + Give_Cache::delete(Give_Cache::get_key('give_total_api_keys')); |
|
1881 | + wp_redirect(add_query_arg('give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-tools&tab=api')); |
|
1882 | 1882 | exit(); |
1883 | 1883 | break; |
1884 | 1884 | default; |
@@ -1897,59 +1897,59 @@ discard block |
||
1897 | 1897 | * |
1898 | 1898 | * @return boolean True if (re)generated successfully, false otherwise. |
1899 | 1899 | */ |
1900 | - public function generate_api_key( $user_id = 0, $regenerate = false ) { |
|
1900 | + public function generate_api_key($user_id = 0, $regenerate = false) { |
|
1901 | 1901 | |
1902 | 1902 | // Bail out, if user doesn't exists. |
1903 | - if ( empty( $user_id ) ) { |
|
1903 | + if (empty($user_id)) { |
|
1904 | 1904 | return false; |
1905 | 1905 | } |
1906 | 1906 | |
1907 | - $user = get_userdata( $user_id ); |
|
1907 | + $user = get_userdata($user_id); |
|
1908 | 1908 | |
1909 | 1909 | // Bail Out, if user object doesn't exists. |
1910 | - if ( ! $user ) { |
|
1910 | + if ( ! $user) { |
|
1911 | 1911 | return false; |
1912 | 1912 | } |
1913 | 1913 | |
1914 | 1914 | $new_public_key = ''; |
1915 | 1915 | $new_secret_key = ''; |
1916 | 1916 | |
1917 | - if( ! empty( $_POST['from'] ) && 'profile' === $_POST['from'] ) { |
|
1917 | + if ( ! empty($_POST['from']) && 'profile' === $_POST['from']) { |
|
1918 | 1918 | // For User Profile Page. |
1919 | - if( ! empty( $_POST['give_set_api_key'] ) ) { |
|
1919 | + if ( ! empty($_POST['give_set_api_key'])) { |
|
1920 | 1920 | // Generate API Key from User Profile page. |
1921 | - $new_public_key = $this->generate_public_key( $user->user_email ); |
|
1922 | - $new_secret_key = $this->generate_private_key( $user->ID ); |
|
1923 | - } elseif ( ! empty( $_POST['give_revoke_api_key'] ) ) { |
|
1921 | + $new_public_key = $this->generate_public_key($user->user_email); |
|
1922 | + $new_secret_key = $this->generate_private_key($user->ID); |
|
1923 | + } elseif ( ! empty($_POST['give_revoke_api_key'])) { |
|
1924 | 1924 | // Revoke API Key from User Profile page. |
1925 | - $this->revoke_api_key( $user->ID ); |
|
1925 | + $this->revoke_api_key($user->ID); |
|
1926 | 1926 | } else { |
1927 | 1927 | return false; |
1928 | 1928 | } |
1929 | 1929 | } else { |
1930 | 1930 | // For Tools > API page. |
1931 | - $public_key = $this->get_user_public_key( $user_id ); |
|
1931 | + $public_key = $this->get_user_public_key($user_id); |
|
1932 | 1932 | |
1933 | - if ( empty( $public_key ) && ! $regenerate ) { |
|
1933 | + if (empty($public_key) && ! $regenerate) { |
|
1934 | 1934 | // Generating API for first time. |
1935 | - $new_public_key = $this->generate_public_key( $user->user_email ); |
|
1936 | - $new_secret_key = $this->generate_private_key( $user->ID ); |
|
1937 | - } elseif ( $public_key && $regenerate ) { |
|
1935 | + $new_public_key = $this->generate_public_key($user->user_email); |
|
1936 | + $new_secret_key = $this->generate_private_key($user->ID); |
|
1937 | + } elseif ($public_key && $regenerate) { |
|
1938 | 1938 | // API Key already exists and Regenerating API Key. |
1939 | - $this->revoke_api_key( $user->ID ); |
|
1940 | - $new_public_key = $this->generate_public_key( $user->user_email ); |
|
1941 | - $new_secret_key = $this->generate_private_key( $user->ID ); |
|
1942 | - } elseif ( ! empty( $public_key ) && ! $regenerate ) { |
|
1939 | + $this->revoke_api_key($user->ID); |
|
1940 | + $new_public_key = $this->generate_public_key($user->user_email); |
|
1941 | + $new_secret_key = $this->generate_private_key($user->ID); |
|
1942 | + } elseif ( ! empty($public_key) && ! $regenerate) { |
|
1943 | 1943 | // Doing nothing, when API Key exists but still try to generate again instead of regenerating. |
1944 | 1944 | return false; |
1945 | 1945 | } else { |
1946 | 1946 | // Revoke API Key. |
1947 | - $this->revoke_api_key( $user->ID ); |
|
1947 | + $this->revoke_api_key($user->ID); |
|
1948 | 1948 | } |
1949 | 1949 | } |
1950 | 1950 | |
1951 | - update_user_meta( $user_id, $new_public_key, 'give_user_public_key' ); |
|
1952 | - update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' ); |
|
1951 | + update_user_meta($user_id, $new_public_key, 'give_user_public_key'); |
|
1952 | + update_user_meta($user_id, $new_secret_key, 'give_user_secret_key'); |
|
1953 | 1953 | |
1954 | 1954 | return true; |
1955 | 1955 | } |
@@ -1964,26 +1964,26 @@ discard block |
||
1964 | 1964 | * |
1965 | 1965 | * @return bool |
1966 | 1966 | */ |
1967 | - public function revoke_api_key( $user_id = 0 ) { |
|
1967 | + public function revoke_api_key($user_id = 0) { |
|
1968 | 1968 | |
1969 | - if ( empty( $user_id ) ) { |
|
1969 | + if (empty($user_id)) { |
|
1970 | 1970 | return false; |
1971 | 1971 | } |
1972 | 1972 | |
1973 | - $user = get_userdata( $user_id ); |
|
1973 | + $user = get_userdata($user_id); |
|
1974 | 1974 | |
1975 | - if ( ! $user ) { |
|
1975 | + if ( ! $user) { |
|
1976 | 1976 | return false; |
1977 | 1977 | } |
1978 | 1978 | |
1979 | - $public_key = $this->get_user_public_key( $user_id ); |
|
1980 | - $secret_key = $this->get_user_secret_key( $user_id ); |
|
1981 | - if ( ! empty( $public_key ) ) { |
|
1982 | - Give_Cache::delete( Give_Cache::get_key( md5( 'give_api_user_' . $public_key ) ) ); |
|
1983 | - Give_Cache::delete( Give_Cache::get_key( md5( 'give_api_user_public_key' . $user_id ) ) ); |
|
1984 | - Give_Cache::delete( Give_Cache::get_key( md5( 'give_api_user_secret_key' . $user_id ) ) ); |
|
1985 | - delete_user_meta( $user_id, $public_key ); |
|
1986 | - delete_user_meta( $user_id, $secret_key ); |
|
1979 | + $public_key = $this->get_user_public_key($user_id); |
|
1980 | + $secret_key = $this->get_user_secret_key($user_id); |
|
1981 | + if ( ! empty($public_key)) { |
|
1982 | + Give_Cache::delete(Give_Cache::get_key(md5('give_api_user_'.$public_key))); |
|
1983 | + Give_Cache::delete(Give_Cache::get_key(md5('give_api_user_public_key'.$user_id))); |
|
1984 | + Give_Cache::delete(Give_Cache::get_key(md5('give_api_user_secret_key'.$user_id))); |
|
1985 | + delete_user_meta($user_id, $public_key); |
|
1986 | + delete_user_meta($user_id, $secret_key); |
|
1987 | 1987 | } else { |
1988 | 1988 | return false; |
1989 | 1989 | } |
@@ -2005,9 +2005,9 @@ discard block |
||
2005 | 2005 | * |
2006 | 2006 | * @return string |
2007 | 2007 | */ |
2008 | - private function generate_public_key( $user_email = '' ) { |
|
2009 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
2010 | - $public = hash( 'md5', $user_email . $auth_key . date( 'U' ) ); |
|
2008 | + private function generate_public_key($user_email = '') { |
|
2009 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
2010 | + $public = hash('md5', $user_email.$auth_key.date('U')); |
|
2011 | 2011 | |
2012 | 2012 | return $public; |
2013 | 2013 | } |
@@ -2022,9 +2022,9 @@ discard block |
||
2022 | 2022 | * |
2023 | 2023 | * @return string |
2024 | 2024 | */ |
2025 | - private function generate_private_key( $user_id = 0 ) { |
|
2026 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
2027 | - $secret = hash( 'md5', $user_id . $auth_key . date( 'U' ) ); |
|
2025 | + private function generate_private_key($user_id = 0) { |
|
2026 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
2027 | + $secret = hash('md5', $user_id.$auth_key.date('U')); |
|
2028 | 2028 | |
2029 | 2029 | return $secret; |
2030 | 2030 | } |
@@ -2039,8 +2039,8 @@ discard block |
||
2039 | 2039 | * |
2040 | 2040 | * @return string |
2041 | 2041 | */ |
2042 | - public function get_token( $user_id = 0 ) { |
|
2043 | - return hash( 'md5', $this->get_user_secret_key( $user_id ) . $this->get_user_public_key( $user_id ) ); |
|
2042 | + public function get_token($user_id = 0) { |
|
2043 | + return hash('md5', $this->get_user_secret_key($user_id).$this->get_user_public_key($user_id)); |
|
2044 | 2044 | } |
2045 | 2045 | |
2046 | 2046 | /** |
@@ -2054,9 +2054,9 @@ discard block |
||
2054 | 2054 | |
2055 | 2055 | // Default sales return |
2056 | 2056 | $donations = array(); |
2057 | - $donations['donations']['today'] = $this->stats->get_sales( 0, 'today' ); |
|
2058 | - $donations['donations']['current_month'] = $this->stats->get_sales( 0, 'this_month' ); |
|
2059 | - $donations['donations']['last_month'] = $this->stats->get_sales( 0, 'last_month' ); |
|
2057 | + $donations['donations']['today'] = $this->stats->get_sales(0, 'today'); |
|
2058 | + $donations['donations']['current_month'] = $this->stats->get_sales(0, 'this_month'); |
|
2059 | + $donations['donations']['last_month'] = $this->stats->get_sales(0, 'last_month'); |
|
2060 | 2060 | $donations['donations']['totals'] = give_get_total_donations(); |
2061 | 2061 | |
2062 | 2062 | return $donations; |
@@ -2073,9 +2073,9 @@ discard block |
||
2073 | 2073 | |
2074 | 2074 | // Default earnings return |
2075 | 2075 | $earnings = array(); |
2076 | - $earnings['earnings']['today'] = $this->stats->get_earnings( 0, 'today' ); |
|
2077 | - $earnings['earnings']['current_month'] = $this->stats->get_earnings( 0, 'this_month' ); |
|
2078 | - $earnings['earnings']['last_month'] = $this->stats->get_earnings( 0, 'last_month' ); |
|
2076 | + $earnings['earnings']['today'] = $this->stats->get_earnings(0, 'today'); |
|
2077 | + $earnings['earnings']['current_month'] = $this->stats->get_earnings(0, 'this_month'); |
|
2078 | + $earnings['earnings']['last_month'] = $this->stats->get_earnings(0, 'last_month'); |
|
2079 | 2079 | $earnings['earnings']['totals'] = give_get_total_earnings(); |
2080 | 2080 | |
2081 | 2081 | return $earnings; |
@@ -2095,25 +2095,25 @@ discard block |
||
2095 | 2095 | * |
2096 | 2096 | * @return string The API key/secret for the user supplied |
2097 | 2097 | */ |
2098 | - public function api_key_backwards_compat( $check, $object_id, $meta_key, $single ) { |
|
2098 | + public function api_key_backwards_compat($check, $object_id, $meta_key, $single) { |
|
2099 | 2099 | |
2100 | - if ( $meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key' ) { |
|
2100 | + if ($meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key') { |
|
2101 | 2101 | return $check; |
2102 | 2102 | } |
2103 | 2103 | |
2104 | 2104 | $return = $check; |
2105 | 2105 | |
2106 | - switch ( $meta_key ) { |
|
2106 | + switch ($meta_key) { |
|
2107 | 2107 | case 'give_user_public_key': |
2108 | - $return = Give()->api->get_user_public_key( $object_id ); |
|
2108 | + $return = Give()->api->get_user_public_key($object_id); |
|
2109 | 2109 | break; |
2110 | 2110 | case 'give_user_secret_key': |
2111 | - $return = Give()->api->get_user_secret_key( $object_id ); |
|
2111 | + $return = Give()->api->get_user_secret_key($object_id); |
|
2112 | 2112 | break; |
2113 | 2113 | } |
2114 | 2114 | |
2115 | - if ( ! $single ) { |
|
2116 | - $return = array( $return ); |
|
2115 | + if ( ! $single) { |
|
2116 | + $return = array($return); |
|
2117 | 2117 | } |
2118 | 2118 | |
2119 | 2119 | return $return; |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | * @since 2.1.0 |
38 | 38 | */ |
39 | 39 | public function __construct() { |
40 | - $this->direction = ( is_rtl() || isset( $_GET['d'] ) && 'rtl' === $_GET['d'] ) ? '.rtl' : ''; |
|
41 | - $this->scripts_footer = give_is_setting_enabled( give_get_option( 'scripts_footer' ) ) ? true : false; |
|
40 | + $this->direction = (is_rtl() || isset($_GET['d']) && 'rtl' === $_GET['d']) ? '.rtl' : ''; |
|
41 | + $this->scripts_footer = give_is_setting_enabled(give_get_option('scripts_footer')) ? true : false; |
|
42 | 42 | $this->init(); |
43 | 43 | } |
44 | 44 | |
@@ -49,20 +49,20 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function init() { |
51 | 51 | |
52 | - add_action( 'admin_enqueue_scripts', array( $this, 'register_styles' ) ); |
|
53 | - add_action( 'admin_enqueue_scripts', array( $this, 'register_scripts' ) ); |
|
54 | - add_action( 'wp_enqueue_scripts', array( $this, 'register_styles' ) ); |
|
55 | - add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) ); |
|
52 | + add_action('admin_enqueue_scripts', array($this, 'register_styles')); |
|
53 | + add_action('admin_enqueue_scripts', array($this, 'register_scripts')); |
|
54 | + add_action('wp_enqueue_scripts', array($this, 'register_styles')); |
|
55 | + add_action('wp_enqueue_scripts', array($this, 'register_scripts')); |
|
56 | 56 | |
57 | - if ( is_admin() ) { |
|
58 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) ); |
|
59 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_styles' ) ); |
|
60 | - add_action( 'enqueue_block_editor_assets', array( $this, 'gutenberg_admin_scripts' ) ); |
|
61 | - add_action( 'admin_head', array( $this, 'global_admin_head' ) ); |
|
57 | + if (is_admin()) { |
|
58 | + add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts')); |
|
59 | + add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_styles')); |
|
60 | + add_action('enqueue_block_editor_assets', array($this, 'gutenberg_admin_scripts')); |
|
61 | + add_action('admin_head', array($this, 'global_admin_head')); |
|
62 | 62 | |
63 | 63 | } else { |
64 | - add_action( 'wp_enqueue_scripts', array( $this, 'public_enqueue_styles' ) ); |
|
65 | - add_action( 'wp_enqueue_scripts', array( $this, 'public_enqueue_scripts' ) ); |
|
64 | + add_action('wp_enqueue_scripts', array($this, 'public_enqueue_styles')); |
|
65 | + add_action('wp_enqueue_scripts', array($this, 'public_enqueue_scripts')); |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
@@ -74,11 +74,11 @@ discard block |
||
74 | 74 | public function register_styles() { |
75 | 75 | |
76 | 76 | // WP-admin. |
77 | - wp_register_style( 'give-admin-styles', GIVE_PLUGIN_URL . 'assets/dist/css/admin' . $this->direction . '.css', array(), GIVE_VERSION ); |
|
77 | + wp_register_style('give-admin-styles', GIVE_PLUGIN_URL.'assets/dist/css/admin'.$this->direction.'.css', array(), GIVE_VERSION); |
|
78 | 78 | |
79 | 79 | // Frontend. |
80 | - if ( give_is_setting_enabled( give_get_option( 'css' ) ) ) { |
|
81 | - wp_register_style( 'give-styles', $this->get_frontend_stylesheet_uri(), array(), GIVE_VERSION, 'all' ); |
|
80 | + if (give_is_setting_enabled(give_get_option('css'))) { |
|
81 | + wp_register_style('give-styles', $this->get_frontend_stylesheet_uri(), array(), GIVE_VERSION, 'all'); |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
@@ -90,15 +90,15 @@ discard block |
||
90 | 90 | public function register_scripts() { |
91 | 91 | |
92 | 92 | // WP-Admin. |
93 | - wp_register_script( 'give-admin-scripts', GIVE_PLUGIN_URL . 'assets/dist/js/admin.js', array( |
|
93 | + wp_register_script('give-admin-scripts', GIVE_PLUGIN_URL.'assets/dist/js/admin.js', array( |
|
94 | 94 | 'jquery', |
95 | 95 | 'jquery-ui-datepicker', |
96 | 96 | 'wp-color-picker', |
97 | 97 | 'jquery-query', |
98 | - ), GIVE_VERSION ); |
|
98 | + ), GIVE_VERSION); |
|
99 | 99 | |
100 | 100 | // Frontend. |
101 | - wp_register_script( 'give', GIVE_PLUGIN_URL . 'assets/dist/js/give.js', array( 'jquery' ), GIVE_VERSION, $this->scripts_footer ); |
|
101 | + wp_register_script('give', GIVE_PLUGIN_URL.'assets/dist/js/give.js', array('jquery'), GIVE_VERSION, $this->scripts_footer); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -108,20 +108,20 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @param string $hook Page hook. |
110 | 110 | */ |
111 | - public function admin_enqueue_styles( $hook ) { |
|
111 | + public function admin_enqueue_styles($hook) { |
|
112 | 112 | |
113 | 113 | // Give Admin Only. |
114 | - if ( ! apply_filters( 'give_load_admin_styles', give_is_admin_page(), $hook ) ) { |
|
114 | + if ( ! apply_filters('give_load_admin_styles', give_is_admin_page(), $hook)) { |
|
115 | 115 | return; |
116 | 116 | } |
117 | 117 | |
118 | 118 | // Give enqueues. |
119 | - wp_enqueue_style( 'give-admin-styles' ); |
|
120 | - wp_enqueue_style( 'give-admin-bar-notification' ); |
|
119 | + wp_enqueue_style('give-admin-styles'); |
|
120 | + wp_enqueue_style('give-admin-bar-notification'); |
|
121 | 121 | |
122 | 122 | // WP Core enqueues. |
123 | - wp_enqueue_style( 'wp-color-picker' ); |
|
124 | - wp_enqueue_style( 'thickbox' ); // @TODO remove once we have modal API. |
|
123 | + wp_enqueue_style('wp-color-picker'); |
|
124 | + wp_enqueue_style('thickbox'); // @TODO remove once we have modal API. |
|
125 | 125 | |
126 | 126 | } |
127 | 127 | |
@@ -132,21 +132,21 @@ discard block |
||
132 | 132 | * |
133 | 133 | * @param string $hook Page hook. |
134 | 134 | */ |
135 | - public function admin_enqueue_scripts( $hook ) { |
|
135 | + public function admin_enqueue_scripts($hook) { |
|
136 | 136 | |
137 | 137 | // Give Admin Only. |
138 | - if ( ! apply_filters( 'give_load_admin_scripts', give_is_admin_page(), $hook ) ) { |
|
138 | + if ( ! apply_filters('give_load_admin_scripts', give_is_admin_page(), $hook)) { |
|
139 | 139 | return; |
140 | 140 | } |
141 | 141 | |
142 | 142 | // WP Scripts. |
143 | - wp_enqueue_script( 'wp-color-picker' ); |
|
144 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
145 | - wp_enqueue_script( 'thickbox' ); |
|
143 | + wp_enqueue_script('wp-color-picker'); |
|
144 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
145 | + wp_enqueue_script('thickbox'); |
|
146 | 146 | wp_enqueue_media(); |
147 | 147 | |
148 | 148 | // Give admin scripts. |
149 | - wp_enqueue_script( 'give-admin-scripts' ); |
|
149 | + wp_enqueue_script('give-admin-scripts'); |
|
150 | 150 | |
151 | 151 | // Localize admin scripts |
152 | 152 | $this->admin_localize_scripts(); |
@@ -166,111 +166,111 @@ discard block |
||
166 | 166 | $decimal_separator = give_get_price_decimal_separator(); |
167 | 167 | |
168 | 168 | // Localize strings & variables for JS. |
169 | - wp_localize_script( 'give-admin-scripts', 'give_vars', array( |
|
170 | - 'post_id' => isset( $post->ID ) ? $post->ID : null, |
|
169 | + wp_localize_script('give-admin-scripts', 'give_vars', array( |
|
170 | + 'post_id' => isset($post->ID) ? $post->ID : null, |
|
171 | 171 | 'give_version' => GIVE_VERSION, |
172 | 172 | 'thousands_separator' => $thousand_separator, |
173 | 173 | 'decimal_separator' => $decimal_separator, |
174 | - 'quick_edit_warning' => __( 'Not available for variable priced forms.', 'give' ), |
|
175 | - 'delete_payment' => __( 'Are you sure you want to <strong>permanently</strong> delete this donation?', 'give' ), |
|
176 | - 'delete_payment_note' => __( 'Are you sure you want to delete this note?', 'give' ), |
|
177 | - 'revoke_api_key' => __( 'Are you sure you want to revoke this API key?', 'give' ), |
|
178 | - 'regenerate_api_key' => __( 'Are you sure you want to regenerate this API key?', 'give' ), |
|
179 | - 'resend_receipt' => __( 'Are you sure you want to resend the donation receipt?', 'give' ), |
|
180 | - 'disconnect_user' => __( 'Are you sure you want to disconnect the user from this donor?', 'give' ), |
|
181 | - 'one_option' => __( 'Choose a form', 'give' ), |
|
182 | - 'one_or_more_option' => __( 'Choose one or more forms', 'give' ), |
|
183 | - 'currency_sign' => give_currency_filter( '' ), |
|
184 | - 'currency_pos' => isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before', |
|
174 | + 'quick_edit_warning' => __('Not available for variable priced forms.', 'give'), |
|
175 | + 'delete_payment' => __('Are you sure you want to <strong>permanently</strong> delete this donation?', 'give'), |
|
176 | + 'delete_payment_note' => __('Are you sure you want to delete this note?', 'give'), |
|
177 | + 'revoke_api_key' => __('Are you sure you want to revoke this API key?', 'give'), |
|
178 | + 'regenerate_api_key' => __('Are you sure you want to regenerate this API key?', 'give'), |
|
179 | + 'resend_receipt' => __('Are you sure you want to resend the donation receipt?', 'give'), |
|
180 | + 'disconnect_user' => __('Are you sure you want to disconnect the user from this donor?', 'give'), |
|
181 | + 'one_option' => __('Choose a form', 'give'), |
|
182 | + 'one_or_more_option' => __('Choose one or more forms', 'give'), |
|
183 | + 'currency_sign' => give_currency_filter(''), |
|
184 | + 'currency_pos' => isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before', |
|
185 | 185 | 'currency_decimals' => give_get_price_decimals(), |
186 | - 'ok' => __( 'Ok', 'give' ), |
|
187 | - 'cancel' => __( 'Cancel', 'give' ), |
|
188 | - 'close' => __( 'Close', 'give' ), |
|
189 | - 'confirm' => __( 'Confirm', 'give' ), |
|
190 | - 'confirm_action' => __( 'Confirm Action', 'give' ), |
|
191 | - 'confirm_deletion' => __( 'Confirm Deletion', 'give' ), |
|
192 | - 'confirm_delete_donation' => __( 'Confirm Delete Donation', 'give' ), |
|
193 | - 'confirm_resend' => __( 'Confirm re-send', 'give' ), |
|
194 | - 'confirm_bulk_action' => __( 'Confirm bulk action', 'give' ), |
|
195 | - 'restart_upgrade' => __( 'Do you want to restart the update process?', 'give' ), |
|
196 | - 'restart_update' => __( 'It is recommended that you backup your database before proceeding. Do you want to run the update now?', 'give' ), |
|
197 | - 'stop_upgrade' => __( 'Do you want to stop the update process now?', 'give' ), |
|
198 | - 'import_failed' => __( 'Import failed', 'give' ), |
|
199 | - 'flush_success' => __( 'Flush success', 'give' ), |
|
200 | - 'flush_error' => __( 'Flush error', 'give' ), |
|
201 | - 'batch_export_no_class' => __( 'You must choose a method.', 'give' ), |
|
202 | - 'batch_export_no_reqs' => __( 'Required fields not completed.', 'give' ), |
|
203 | - 'reset_stats_warn' => __( 'Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give' ), |
|
204 | - 'delete_test_donor' => __( 'Are you sure you want to delete all the test donors? This process will also delete test donations as well.', 'give' ), |
|
205 | - 'delete_import_donor' => __( 'Are you sure you want to delete all the imported donors? This process will also delete imported donations as well.', 'give' ), |
|
206 | - 'price_format_guide' => sprintf( __( 'Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give' ), $decimal_separator, $thousand_separator ), |
|
186 | + 'ok' => __('Ok', 'give'), |
|
187 | + 'cancel' => __('Cancel', 'give'), |
|
188 | + 'close' => __('Close', 'give'), |
|
189 | + 'confirm' => __('Confirm', 'give'), |
|
190 | + 'confirm_action' => __('Confirm Action', 'give'), |
|
191 | + 'confirm_deletion' => __('Confirm Deletion', 'give'), |
|
192 | + 'confirm_delete_donation' => __('Confirm Delete Donation', 'give'), |
|
193 | + 'confirm_resend' => __('Confirm re-send', 'give'), |
|
194 | + 'confirm_bulk_action' => __('Confirm bulk action', 'give'), |
|
195 | + 'restart_upgrade' => __('Do you want to restart the update process?', 'give'), |
|
196 | + 'restart_update' => __('It is recommended that you backup your database before proceeding. Do you want to run the update now?', 'give'), |
|
197 | + 'stop_upgrade' => __('Do you want to stop the update process now?', 'give'), |
|
198 | + 'import_failed' => __('Import failed', 'give'), |
|
199 | + 'flush_success' => __('Flush success', 'give'), |
|
200 | + 'flush_error' => __('Flush error', 'give'), |
|
201 | + 'batch_export_no_class' => __('You must choose a method.', 'give'), |
|
202 | + 'batch_export_no_reqs' => __('Required fields not completed.', 'give'), |
|
203 | + 'reset_stats_warn' => __('Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give'), |
|
204 | + 'delete_test_donor' => __('Are you sure you want to delete all the test donors? This process will also delete test donations as well.', 'give'), |
|
205 | + 'delete_import_donor' => __('Are you sure you want to delete all the imported donors? This process will also delete imported donations as well.', 'give'), |
|
206 | + 'price_format_guide' => sprintf(__('Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give'), $decimal_separator, $thousand_separator), |
|
207 | 207 | /* translators : %s: Donation form options metabox */ |
208 | - 'confirm_before_remove_row_text' => __( 'Do you want to delete this item?', 'give' ), |
|
209 | - 'matched_success_failure_page' => __( 'You cannot set the success and failed pages to the same page', 'give' ), |
|
210 | - 'dismiss_notice_text' => __( 'Dismiss this notice.', 'give' ), |
|
211 | - 'search_placeholder' => __( 'Type to search all forms', 'give' ), |
|
212 | - 'search_placeholder_donor' => __( 'Type to search all donors', 'give' ), |
|
213 | - 'search_placeholder_country' => __( 'Type to search all countries', 'give' ), |
|
214 | - 'search_placeholder_state' => __( 'Type to search all states/provinces', 'give' ), |
|
215 | - 'unlock_donor_fields_title' => __( 'Action forbidden', 'give' ), |
|
216 | - 'unlock_donor_fields_message' => __( 'To edit first name and last name, please go to user profile of the donor.', 'give' ), |
|
217 | - 'remove_from_bulk_delete' => __( 'Remove from Bulk Delete', 'give' ), |
|
208 | + 'confirm_before_remove_row_text' => __('Do you want to delete this item?', 'give'), |
|
209 | + 'matched_success_failure_page' => __('You cannot set the success and failed pages to the same page', 'give'), |
|
210 | + 'dismiss_notice_text' => __('Dismiss this notice.', 'give'), |
|
211 | + 'search_placeholder' => __('Type to search all forms', 'give'), |
|
212 | + 'search_placeholder_donor' => __('Type to search all donors', 'give'), |
|
213 | + 'search_placeholder_country' => __('Type to search all countries', 'give'), |
|
214 | + 'search_placeholder_state' => __('Type to search all states/provinces', 'give'), |
|
215 | + 'unlock_donor_fields_title' => __('Action forbidden', 'give'), |
|
216 | + 'unlock_donor_fields_message' => __('To edit first name and last name, please go to user profile of the donor.', 'give'), |
|
217 | + 'remove_from_bulk_delete' => __('Remove from Bulk Delete', 'give'), |
|
218 | 218 | 'donors_bulk_action' => array( |
219 | 219 | 'no_donor_selected' => array( |
220 | - 'title' => __( 'No donors selected', 'give' ), |
|
221 | - 'desc' => __( 'You must choose at least one or more donors to delete.', 'give' ) |
|
220 | + 'title' => __('No donors selected', 'give'), |
|
221 | + 'desc' => __('You must choose at least one or more donors to delete.', 'give') |
|
222 | 222 | ), |
223 | 223 | 'no_action_selected' => array( |
224 | - 'title' => __( 'No action selected', 'give' ), |
|
225 | - 'desc' => __( 'You must select a bulk action to proceed.', 'give' ), |
|
224 | + 'title' => __('No action selected', 'give'), |
|
225 | + 'desc' => __('You must select a bulk action to proceed.', 'give'), |
|
226 | 226 | ), |
227 | 227 | ), |
228 | 228 | 'donations_bulk_action' => array( |
229 | 229 | 'titles' => array( |
230 | - 'zero' => __( 'No payments selected', 'give' ), |
|
230 | + 'zero' => __('No payments selected', 'give'), |
|
231 | 231 | ), |
232 | 232 | 'delete' => array( |
233 | - 'zero' => __( 'You must choose at least one or more donations to delete.', 'give' ), |
|
234 | - 'single' => __( 'Are you sure you want to permanently delete this donation?', 'give' ), |
|
235 | - 'multiple' => __( 'Are you sure you want to permanently delete the selected {payment_count} donations?', 'give' ), |
|
233 | + 'zero' => __('You must choose at least one or more donations to delete.', 'give'), |
|
234 | + 'single' => __('Are you sure you want to permanently delete this donation?', 'give'), |
|
235 | + 'multiple' => __('Are you sure you want to permanently delete the selected {payment_count} donations?', 'give'), |
|
236 | 236 | ), |
237 | 237 | 'resend-receipt' => array( |
238 | - 'zero' => __( 'You must choose at least one or more recipients to resend the email receipt.', 'give' ), |
|
239 | - 'single' => __( 'Are you sure you want to resend the email receipt to this recipient?', 'give' ), |
|
240 | - 'multiple' => __( 'Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give' ), |
|
238 | + 'zero' => __('You must choose at least one or more recipients to resend the email receipt.', 'give'), |
|
239 | + 'single' => __('Are you sure you want to resend the email receipt to this recipient?', 'give'), |
|
240 | + 'multiple' => __('Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give'), |
|
241 | 241 | ), |
242 | 242 | 'set-to-status' => array( |
243 | - 'zero' => __( 'You must choose at least one or more donations to set status to {status}.', 'give' ), |
|
244 | - 'single' => __( 'Are you sure you want to set status of this donation to {status}?', 'give' ), |
|
245 | - 'multiple' => __( 'Are you sure you want to set status of {payment_count} donations to {status}?', 'give' ), |
|
243 | + 'zero' => __('You must choose at least one or more donations to set status to {status}.', 'give'), |
|
244 | + 'single' => __('Are you sure you want to set status of this donation to {status}?', 'give'), |
|
245 | + 'multiple' => __('Are you sure you want to set status of {payment_count} donations to {status}?', 'give'), |
|
246 | 246 | ), |
247 | 247 | ), |
248 | 248 | 'updates' => array( |
249 | - 'ajax_error' => __( 'Please reload this page and try again', 'give' ), |
|
249 | + 'ajax_error' => __('Please reload this page and try again', 'give'), |
|
250 | 250 | ), |
251 | 251 | 'metabox_fields' => array( |
252 | 252 | 'media' => array( |
253 | - 'button_title' => __( 'Choose Image', 'give' ), |
|
253 | + 'button_title' => __('Choose Image', 'give'), |
|
254 | 254 | ), |
255 | 255 | 'file' => array( |
256 | - 'button_title' => __( 'Choose File', 'give' ), |
|
256 | + 'button_title' => __('Choose File', 'give'), |
|
257 | 257 | ), |
258 | 258 | ), |
259 | 259 | 'chosen' => array( |
260 | - 'no_results_msg' => __( 'No results match {search_term}', 'give' ), |
|
261 | - 'ajax_search_msg' => __( 'Searching results for match {search_term}', 'give' ), |
|
260 | + 'no_results_msg' => __('No results match {search_term}', 'give'), |
|
261 | + 'ajax_search_msg' => __('Searching results for match {search_term}', 'give'), |
|
262 | 262 | ), |
263 | - 'db_update_confirmation_msg_button' => __( 'Run Updates', 'give' ), |
|
264 | - 'db_update_confirmation_msg' => __( 'The following process will make updates to your site\'s database. Please create a database backup before proceeding with updates.', 'give' ), |
|
265 | - 'error_message' => __( 'Something went wrong kindly try again!', 'give' ), |
|
263 | + 'db_update_confirmation_msg_button' => __('Run Updates', 'give'), |
|
264 | + 'db_update_confirmation_msg' => __('The following process will make updates to your site\'s database. Please create a database backup before proceeding with updates.', 'give'), |
|
265 | + 'error_message' => __('Something went wrong kindly try again!', 'give'), |
|
266 | 266 | 'give_donation_import' => 'give_donation_import', |
267 | 267 | 'core_settings_import' => 'give_core_settings_import', |
268 | - 'setting_not_save_message' => __( 'Changes you made may not be saved.', 'give' ), |
|
268 | + 'setting_not_save_message' => __('Changes you made may not be saved.', 'give'), |
|
269 | 269 | 'give_donation_amounts' => array( |
270 | - 'minimum' => apply_filters( 'give_donation_minimum_limit', 1 ), |
|
271 | - 'maximum' => apply_filters( 'give_donation_maximum_limit', 999999.99 ), |
|
270 | + 'minimum' => apply_filters('give_donation_minimum_limit', 1), |
|
271 | + 'maximum' => apply_filters('give_donation_maximum_limit', 999999.99), |
|
272 | 272 | ), |
273 | - ) ); |
|
273 | + )); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | /** |
@@ -281,10 +281,10 @@ discard block |
||
281 | 281 | <style type="text/css" media="screen"> |
282 | 282 | @font-face { |
283 | 283 | font-family: 'give-icomoon'; |
284 | - src: url('<?php echo GIVE_PLUGIN_URL . 'assets/dist/fonts/icomoon.eot?ngjl88'; ?>'); |
|
285 | - src: url('<?php echo GIVE_PLUGIN_URL . 'assets/dist/fonts/icomoon.eot?#iefixngjl88'?>') format('embedded-opentype'), |
|
286 | - url('<?php echo GIVE_PLUGIN_URL . 'assets/dist/fonts/icomoon.woff?ngjl88'; ?>') format('woff'), |
|
287 | - url('<?php echo GIVE_PLUGIN_URL . 'assets/dist/fonts/icomoon.svg?ngjl88#icomoon'; ?>') format('svg'); |
|
284 | + src: url('<?php echo GIVE_PLUGIN_URL.'assets/dist/fonts/icomoon.eot?ngjl88'; ?>'); |
|
285 | + src: url('<?php echo GIVE_PLUGIN_URL.'assets/dist/fonts/icomoon.eot?#iefixngjl88'?>') format('embedded-opentype'), |
|
286 | + url('<?php echo GIVE_PLUGIN_URL.'assets/dist/fonts/icomoon.woff?ngjl88'; ?>') format('woff'), |
|
287 | + url('<?php echo GIVE_PLUGIN_URL.'assets/dist/fonts/icomoon.svg?ngjl88#icomoon'; ?>') format('svg'); |
|
288 | 288 | font-weight: normal; |
289 | 289 | font-style: normal; |
290 | 290 | } |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | * @since 2.1.0 |
308 | 308 | */ |
309 | 309 | public function public_enqueue_styles() { |
310 | - wp_enqueue_style( 'give-styles' ); |
|
310 | + wp_enqueue_style('give-styles'); |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | * @since 2.1.0 |
318 | 318 | */ |
319 | 319 | public function public_enqueue_scripts() { |
320 | - wp_enqueue_script( 'give' ); |
|
320 | + wp_enqueue_script('give'); |
|
321 | 321 | |
322 | 322 | $this->public_localize_scripts(); |
323 | 323 | } |
@@ -336,22 +336,22 @@ discard block |
||
336 | 336 | * |
337 | 337 | * @return string $message Send notice message for email access. |
338 | 338 | */ |
339 | - $message = (string) apply_filters( 'give_email_access_mail_send_notice', __( 'Please check your email and click on the link to access your complete donation history.', 'give' ) ); |
|
339 | + $message = (string) apply_filters('give_email_access_mail_send_notice', __('Please check your email and click on the link to access your complete donation history.', 'give')); |
|
340 | 340 | |
341 | - $localize_give_vars = apply_filters( 'give_global_script_vars', array( |
|
341 | + $localize_give_vars = apply_filters('give_global_script_vars', array( |
|
342 | 342 | 'ajaxurl' => give_get_ajax_url(), |
343 | - 'checkout_nonce' => wp_create_nonce( 'give_checkout_nonce' ), |
|
343 | + 'checkout_nonce' => wp_create_nonce('give_checkout_nonce'), |
|
344 | 344 | // Do not use this nonce. Its deprecated. |
345 | 345 | 'currency' => give_get_currency(), |
346 | - 'currency_sign' => give_currency_filter( '' ), |
|
346 | + 'currency_sign' => give_currency_filter(''), |
|
347 | 347 | 'currency_pos' => give_get_currency_position(), |
348 | 348 | 'thousands_separator' => give_get_price_thousand_separator(), |
349 | 349 | 'decimal_separator' => give_get_price_decimal_separator(), |
350 | - 'no_gateway' => __( 'Please select a payment method.', 'give' ), |
|
351 | - 'bad_minimum' => __( 'The minimum custom donation amount for this form is', 'give' ), |
|
352 | - 'bad_maximum' => __( 'The maximum custom donation amount for this form is', 'give' ), |
|
353 | - 'general_loading' => __( 'Loading...', 'give' ), |
|
354 | - 'purchase_loading' => __( 'Please Wait...', 'give' ), |
|
350 | + 'no_gateway' => __('Please select a payment method.', 'give'), |
|
351 | + 'bad_minimum' => __('The minimum custom donation amount for this form is', 'give'), |
|
352 | + 'bad_maximum' => __('The maximum custom donation amount for this form is', 'give'), |
|
353 | + 'general_loading' => __('Loading...', 'give'), |
|
354 | + 'purchase_loading' => __('Please Wait...', 'give'), |
|
355 | 355 | 'number_decimals' => give_get_price_decimals(), |
356 | 356 | 'give_version' => GIVE_VERSION, |
357 | 357 | 'magnific_options' => apply_filters( |
@@ -365,30 +365,30 @@ discard block |
||
365 | 365 | 'give_form_translation_js', |
366 | 366 | array( |
367 | 367 | // Field name Validation message. |
368 | - 'payment-mode' => __( 'Please select payment mode.', 'give' ), |
|
369 | - 'give_first' => __( 'Please enter your first name.', 'give' ), |
|
370 | - 'give_email' => __( 'Please enter a valid email address.', 'give' ), |
|
371 | - 'give_user_login' => __( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ), |
|
372 | - 'give_user_pass' => __( 'Enter a password.', 'give' ), |
|
373 | - 'give_user_pass_confirm' => __( 'Enter the password confirmation.', 'give' ), |
|
374 | - 'give_agree_to_terms' => __( 'You must agree to the terms and conditions.', 'give' ), |
|
368 | + 'payment-mode' => __('Please select payment mode.', 'give'), |
|
369 | + 'give_first' => __('Please enter your first name.', 'give'), |
|
370 | + 'give_email' => __('Please enter a valid email address.', 'give'), |
|
371 | + 'give_user_login' => __('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give'), |
|
372 | + 'give_user_pass' => __('Enter a password.', 'give'), |
|
373 | + 'give_user_pass_confirm' => __('Enter the password confirmation.', 'give'), |
|
374 | + 'give_agree_to_terms' => __('You must agree to the terms and conditions.', 'give'), |
|
375 | 375 | ) |
376 | 376 | ), |
377 | 377 | 'confirm_email_sent_message' => $message, |
378 | - 'ajax_vars' => apply_filters( 'give_global_ajax_vars', array( |
|
378 | + 'ajax_vars' => apply_filters('give_global_ajax_vars', array( |
|
379 | 379 | 'ajaxurl' => give_get_ajax_url(), |
380 | - 'ajaxNonce' => wp_create_nonce( 'give_ajax_nonce' ), |
|
381 | - 'loading' => __( 'Loading', 'give' ), |
|
380 | + 'ajaxNonce' => wp_create_nonce('give_ajax_nonce'), |
|
381 | + 'loading' => __('Loading', 'give'), |
|
382 | 382 | // General loading message. |
383 | - 'select_option' => __( 'Please select an option', 'give' ), |
|
383 | + 'select_option' => __('Please select an option', 'give'), |
|
384 | 384 | // Variable pricing error with multi-donation option enabled. |
385 | - 'default_gateway' => give_get_default_gateway( null ), |
|
386 | - 'permalinks' => get_option( 'permalink_structure' ) ? '1' : '0', |
|
385 | + 'default_gateway' => give_get_default_gateway(null), |
|
386 | + 'permalinks' => get_option('permalink_structure') ? '1' : '0', |
|
387 | 387 | 'number_decimals' => give_get_price_decimals(), |
388 | - ) ), |
|
389 | - ) ); |
|
388 | + )), |
|
389 | + )); |
|
390 | 390 | |
391 | - wp_localize_script( 'give', 'give_global_vars', $localize_give_vars ); |
|
391 | + wp_localize_script('give', 'give_global_vars', $localize_give_vars); |
|
392 | 392 | |
393 | 393 | } |
394 | 394 | |
@@ -402,15 +402,15 @@ discard block |
||
402 | 402 | */ |
403 | 403 | public function get_frontend_stylesheet_uri() { |
404 | 404 | |
405 | - $file = 'give' . $this->direction . '.css'; |
|
405 | + $file = 'give'.$this->direction.'.css'; |
|
406 | 406 | $templates_dir = give_get_theme_template_dir_name(); |
407 | 407 | |
408 | 408 | // Directory paths to CSS files to support checking via file_exists(). |
409 | - $child_theme_style_sheet = trailingslashit( get_stylesheet_directory() ) . $templates_dir . $file; |
|
410 | - $child_theme_style_sheet_2 = trailingslashit( get_stylesheet_directory() ) . $templates_dir . 'give' . $this->direction . '.css'; |
|
411 | - $parent_theme_style_sheet = trailingslashit( get_template_directory() ) . $templates_dir . $file; |
|
412 | - $parent_theme_style_sheet_2 = trailingslashit( get_template_directory() ) . $templates_dir . 'give' . $this->direction . '.css'; |
|
413 | - $give_plugin_style_sheet = trailingslashit( GIVE_PLUGIN_DIR ) . 'assets/dist/css/' . $file; |
|
409 | + $child_theme_style_sheet = trailingslashit(get_stylesheet_directory()).$templates_dir.$file; |
|
410 | + $child_theme_style_sheet_2 = trailingslashit(get_stylesheet_directory()).$templates_dir.'give'.$this->direction.'.css'; |
|
411 | + $parent_theme_style_sheet = trailingslashit(get_template_directory()).$templates_dir.$file; |
|
412 | + $parent_theme_style_sheet_2 = trailingslashit(get_template_directory()).$templates_dir.'give'.$this->direction.'.css'; |
|
413 | + $give_plugin_style_sheet = trailingslashit(GIVE_PLUGIN_DIR).'assets/dist/css/'.$file; |
|
414 | 414 | $uri = false; |
415 | 415 | |
416 | 416 | /** |
@@ -421,23 +421,23 @@ discard block |
||
421 | 421 | * c. followed by non minified version, even if SCRIPT_DEBUG is not enabled. This allows users to copy just give.css to their theme. |
422 | 422 | * d. Finally, fallback to the standard Give version. This is the default styles included within the plugin. |
423 | 423 | */ |
424 | - if ( file_exists( $child_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $child_theme_style_sheet_2 ) ) ) ) { |
|
425 | - if ( ! empty( $nonmin ) ) { |
|
426 | - $uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . 'give' . $this->direction . '.css'; |
|
424 | + if (file_exists($child_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($child_theme_style_sheet_2)))) { |
|
425 | + if ( ! empty($nonmin)) { |
|
426 | + $uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.'give'.$this->direction.'.css'; |
|
427 | 427 | } else { |
428 | - $uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . $file; |
|
428 | + $uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.$file; |
|
429 | 429 | } |
430 | - } elseif ( file_exists( $parent_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $parent_theme_style_sheet_2 ) ) ) ) { |
|
431 | - if ( ! empty( $nonmin ) ) { |
|
432 | - $uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . 'give' . $this->direction . '.css'; |
|
430 | + } elseif (file_exists($parent_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($parent_theme_style_sheet_2)))) { |
|
431 | + if ( ! empty($nonmin)) { |
|
432 | + $uri = trailingslashit(get_template_directory_uri()).$templates_dir.'give'.$this->direction.'.css'; |
|
433 | 433 | } else { |
434 | - $uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . $file; |
|
434 | + $uri = trailingslashit(get_template_directory_uri()).$templates_dir.$file; |
|
435 | 435 | } |
436 | - } elseif ( file_exists( $give_plugin_style_sheet ) ) { |
|
437 | - $uri = trailingslashit( GIVE_PLUGIN_URL ) . 'assets/dist/css/' . $file; |
|
436 | + } elseif (file_exists($give_plugin_style_sheet)) { |
|
437 | + $uri = trailingslashit(GIVE_PLUGIN_URL).'assets/dist/css/'.$file; |
|
438 | 438 | } |
439 | 439 | |
440 | - return apply_filters( 'give_get_stylesheet_uri', $uri ); |
|
440 | + return apply_filters('give_get_stylesheet_uri', $uri); |
|
441 | 441 | |
442 | 442 | } |
443 | 443 | |
@@ -449,19 +449,19 @@ discard block |
||
449 | 449 | // Enqueue the bundled block JS file |
450 | 450 | wp_enqueue_script( |
451 | 451 | 'give-blocks-js', |
452 | - GIVE_PLUGIN_URL . 'assets/dist/js/gutenberg.js', |
|
453 | - array( 'wp-i18n', 'wp-element', 'wp-blocks', 'wp-components', 'wp-api' ), |
|
452 | + GIVE_PLUGIN_URL.'assets/dist/js/gutenberg.js', |
|
453 | + array('wp-i18n', 'wp-element', 'wp-blocks', 'wp-components', 'wp-api'), |
|
454 | 454 | GIVE_VERSION |
455 | 455 | ); |
456 | 456 | |
457 | 457 | // Enqueue public styles |
458 | - wp_enqueue_style( 'give-styles' ); |
|
458 | + wp_enqueue_style('give-styles'); |
|
459 | 459 | |
460 | 460 | // Enqueue the bundled block css file |
461 | 461 | wp_enqueue_style( |
462 | 462 | 'give-blocks-css', |
463 | - GIVE_PLUGIN_URL . 'assets/dist/css/gutenberg.css', |
|
464 | - array( 'wp-blocks' ), |
|
463 | + GIVE_PLUGIN_URL.'assets/dist/css/gutenberg.css', |
|
464 | + array('wp-blocks'), |
|
465 | 465 | GIVE_VERSION |
466 | 466 | ); |
467 | 467 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -23,35 +23,35 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return string Donation form. |
25 | 25 | */ |
26 | -function give_get_donation_form( $args = array() ) { |
|
26 | +function give_get_donation_form($args = array()) { |
|
27 | 27 | |
28 | 28 | global $post; |
29 | 29 | static $count = 1; |
30 | 30 | |
31 | - $form_id = is_object( $post ) ? $post->ID : 0; |
|
31 | + $form_id = is_object($post) ? $post->ID : 0; |
|
32 | 32 | |
33 | - if ( isset( $args['id'] ) ) { |
|
33 | + if (isset($args['id'])) { |
|
34 | 34 | $form_id = $args['id']; |
35 | 35 | } |
36 | 36 | |
37 | - $defaults = apply_filters( 'give_form_args_defaults', array( |
|
37 | + $defaults = apply_filters('give_form_args_defaults', array( |
|
38 | 38 | 'form_id' => $form_id, |
39 | - ) ); |
|
39 | + )); |
|
40 | 40 | |
41 | - $args = wp_parse_args( $args, $defaults ); |
|
41 | + $args = wp_parse_args($args, $defaults); |
|
42 | 42 | |
43 | - $form = new Give_Donate_Form( $args['form_id'] ); |
|
43 | + $form = new Give_Donate_Form($args['form_id']); |
|
44 | 44 | |
45 | 45 | // Bail out, if no form ID. |
46 | - if ( empty( $form->ID ) ) { |
|
46 | + if (empty($form->ID)) { |
|
47 | 47 | return false; |
48 | 48 | } |
49 | 49 | |
50 | 50 | $args['id_prefix'] = "{$form_id}-{$count}"; |
51 | - $payment_mode = give_get_chosen_gateway( $form->ID ); |
|
51 | + $payment_mode = give_get_chosen_gateway($form->ID); |
|
52 | 52 | |
53 | 53 | $form_action = add_query_arg( |
54 | - apply_filters( 'give_form_action_args', array( |
|
54 | + apply_filters('give_form_action_args', array( |
|
55 | 55 | 'payment-mode' => $payment_mode, |
56 | 56 | ) |
57 | 57 | ), |
@@ -60,17 +60,17 @@ discard block |
||
60 | 60 | |
61 | 61 | // Sanity Check: Donation form not published or user doesn't have permission to view drafts. |
62 | 62 | if ( |
63 | - ( 'publish' !== $form->post_status && ! current_user_can( 'edit_give_forms', $form->ID ) ) |
|
64 | - || ( 'trash' === $form->post_status ) |
|
63 | + ('publish' !== $form->post_status && ! current_user_can('edit_give_forms', $form->ID)) |
|
64 | + || ('trash' === $form->post_status) |
|
65 | 65 | ) { |
66 | 66 | return false; |
67 | 67 | } |
68 | 68 | |
69 | 69 | // Get the form wrap CSS classes. |
70 | - $form_wrap_classes = $form->get_form_wrap_classes( $args ); |
|
70 | + $form_wrap_classes = $form->get_form_wrap_classes($args); |
|
71 | 71 | |
72 | 72 | // Get the <form> tag wrap CSS classes. |
73 | - $form_classes = $form->get_form_classes( $args ); |
|
73 | + $form_classes = $form->get_form_classes($args); |
|
74 | 74 | |
75 | 75 | ob_start(); |
76 | 76 | |
@@ -82,21 +82,21 @@ discard block |
||
82 | 82 | * @param int $form_id The form ID. |
83 | 83 | * @param array $args An array of form arguments. |
84 | 84 | */ |
85 | - do_action( 'give_pre_form_output', $form->ID, $args, $form ); |
|
85 | + do_action('give_pre_form_output', $form->ID, $args, $form); |
|
86 | 86 | |
87 | 87 | ?> |
88 | 88 | <div id="give-form-<?php echo $form->ID; ?>-wrap" class="<?php echo $form_wrap_classes; ?>"> |
89 | 89 | <?php |
90 | - if ( $form->is_close_donation_form() ) { |
|
90 | + if ($form->is_close_donation_form()) { |
|
91 | 91 | |
92 | - $form_title = ! is_singular( 'give_forms' ) ? apply_filters( 'give_form_title', '<h2 class="give-form-title">' . get_the_title( $form_id ) . '</h2>' ) : ''; |
|
92 | + $form_title = ! is_singular('give_forms') ? apply_filters('give_form_title', '<h2 class="give-form-title">'.get_the_title($form_id).'</h2>') : ''; |
|
93 | 93 | |
94 | 94 | // Get Goal thank you message. |
95 | - $goal_achieved_message = get_post_meta( $form->ID, '_give_form_goal_achieved_message', true ); |
|
96 | - $goal_achieved_message = ! empty( $goal_achieved_message ) ? $form_title . apply_filters( 'the_content', $goal_achieved_message ) : ''; |
|
95 | + $goal_achieved_message = get_post_meta($form->ID, '_give_form_goal_achieved_message', true); |
|
96 | + $goal_achieved_message = ! empty($goal_achieved_message) ? $form_title.apply_filters('the_content', $goal_achieved_message) : ''; |
|
97 | 97 | |
98 | 98 | // Print thank you message. |
99 | - echo apply_filters( 'give_goal_closed_output', $goal_achieved_message, $form->ID, $form ); |
|
99 | + echo apply_filters('give_goal_closed_output', $goal_achieved_message, $form->ID, $form); |
|
100 | 100 | |
101 | 101 | } else { |
102 | 102 | /** |
@@ -104,13 +104,13 @@ discard block |
||
104 | 104 | * 1. if show_title params set to true |
105 | 105 | * 2. if admin set form display_style to button |
106 | 106 | */ |
107 | - $form_title = apply_filters( 'give_form_title', '<h2 class="give-form-title">' . get_the_title( $form_id ) . '</h2>' ); |
|
107 | + $form_title = apply_filters('give_form_title', '<h2 class="give-form-title">'.get_the_title($form_id).'</h2>'); |
|
108 | 108 | if ( |
109 | 109 | ( |
110 | - ( isset( $args['show_title'] ) && $args['show_title'] == true ) |
|
111 | - || ( 'button' === get_post_meta( $form_id, '_give_payment_display', true ) ) |
|
110 | + (isset($args['show_title']) && $args['show_title'] == true) |
|
111 | + || ('button' === get_post_meta($form_id, '_give_payment_display', true)) |
|
112 | 112 | ) |
113 | - && ! doing_action( 'give_single_form_summary' ) |
|
113 | + && ! doing_action('give_single_form_summary') |
|
114 | 114 | ) { |
115 | 115 | echo $form_title; |
116 | 116 | } |
@@ -124,13 +124,13 @@ discard block |
||
124 | 124 | * @param array $args An array of form arguments. |
125 | 125 | * @param Give_Donate_Form $form Form object. |
126 | 126 | */ |
127 | - do_action( 'give_pre_form', $form->ID, $args, $form ); |
|
127 | + do_action('give_pre_form', $form->ID, $args, $form); |
|
128 | 128 | |
129 | 129 | // Set form html tags. |
130 | 130 | $form_html_tags = array( |
131 | 131 | 'id' => "give-form-{$args['id_prefix']}", |
132 | 132 | 'class' => $form_classes, |
133 | - 'action' => esc_url_raw( $form_action ), |
|
133 | + 'action' => esc_url_raw($form_action), |
|
134 | 134 | 'data-id' => $args['id_prefix'], |
135 | 135 | ); |
136 | 136 | |
@@ -142,9 +142,9 @@ discard block |
||
142 | 142 | * @param array $form_html_tags Array of form html tags. |
143 | 143 | * @param Give_Donate_Form $form Form object. |
144 | 144 | */ |
145 | - $form_html_tags = apply_filters( 'give_form_html_tags', (array) $form_html_tags, $form ); |
|
145 | + $form_html_tags = apply_filters('give_form_html_tags', (array) $form_html_tags, $form); |
|
146 | 146 | ?> |
147 | - <form <?php echo give_get_attribute_str( $form_html_tags ); ?> method="post"> |
|
147 | + <form <?php echo give_get_attribute_str($form_html_tags); ?> method="post"> |
|
148 | 148 | <!-- The following field is for robots only, invisible to humans: --> |
149 | 149 | <span class="give-hidden" style="display: none !important;"> |
150 | 150 | <label for="give-form-honeypot-<?php echo $form_id; ?>"></label> |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | * @param array $args An array of form arguments. |
163 | 163 | * @param Give_Donate_Form $form Form object. |
164 | 164 | */ |
165 | - do_action( 'give_donation_form_top', $form->ID, $args, $form ); |
|
165 | + do_action('give_donation_form_top', $form->ID, $args, $form); |
|
166 | 166 | |
167 | 167 | /** |
168 | 168 | * Fires while outputting donation form, for payment gateway fields. |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * @param array $args An array of form arguments. |
174 | 174 | * @param Give_Donate_Form $form Form object. |
175 | 175 | */ |
176 | - do_action( 'give_payment_mode_select', $form->ID, $args, $form ); |
|
176 | + do_action('give_payment_mode_select', $form->ID, $args, $form); |
|
177 | 177 | |
178 | 178 | /** |
179 | 179 | * Fires while outputting donation form, after all other fields. |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | * @param array $args An array of form arguments. |
185 | 185 | * @param Give_Donate_Form $form Form object. |
186 | 186 | */ |
187 | - do_action( 'give_donation_form_bottom', $form->ID, $args, $form ); |
|
187 | + do_action('give_donation_form_bottom', $form->ID, $args, $form); |
|
188 | 188 | |
189 | 189 | ?> |
190 | 190 | </form> |
@@ -199,12 +199,12 @@ discard block |
||
199 | 199 | * @param array $args An array of form arguments. |
200 | 200 | * @param Give_Donate_Form $form Form object. |
201 | 201 | */ |
202 | - do_action( 'give_post_form', $form->ID, $args, $form ); |
|
202 | + do_action('give_post_form', $form->ID, $args, $form); |
|
203 | 203 | |
204 | 204 | } |
205 | 205 | ?> |
206 | 206 | |
207 | - </div><!--end #give-form-<?php echo absint( $form->ID ); ?>--> |
|
207 | + </div><!--end #give-form-<?php echo absint($form->ID); ?>--> |
|
208 | 208 | <?php |
209 | 209 | |
210 | 210 | /** |
@@ -215,12 +215,12 @@ discard block |
||
215 | 215 | * @param int $form_id The form ID. |
216 | 216 | * @param array $args An array of form arguments. |
217 | 217 | */ |
218 | - do_action( 'give_post_form_output', $form->ID, $args ); |
|
218 | + do_action('give_post_form_output', $form->ID, $args); |
|
219 | 219 | |
220 | 220 | $final_output = ob_get_clean(); |
221 | - $count ++; |
|
221 | + $count++; |
|
222 | 222 | |
223 | - echo apply_filters( 'give_donate_form', $final_output, $args ); |
|
223 | + echo apply_filters('give_donate_form', $final_output, $args); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | /** |
@@ -237,11 +237,11 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @return string |
239 | 239 | */ |
240 | -function give_show_purchase_form( $form_id, $args ) { |
|
240 | +function give_show_purchase_form($form_id, $args) { |
|
241 | 241 | |
242 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
242 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
243 | 243 | |
244 | - if ( ! isset( $form_id ) && isset( $_POST['give_form_id'] ) ) { |
|
244 | + if ( ! isset($form_id) && isset($_POST['give_form_id'])) { |
|
245 | 245 | $form_id = $_POST['give_form_id']; |
246 | 246 | } |
247 | 247 | |
@@ -250,33 +250,33 @@ discard block |
||
250 | 250 | * |
251 | 251 | * @since 1.7 |
252 | 252 | */ |
253 | - do_action( 'give_payment_fields_top', $form_id ); |
|
253 | + do_action('give_payment_fields_top', $form_id); |
|
254 | 254 | |
255 | - if ( give_can_checkout() && isset( $form_id ) ) { |
|
255 | + if (give_can_checkout() && isset($form_id)) { |
|
256 | 256 | |
257 | 257 | /** |
258 | 258 | * Fires while displaying donation form, before registration login. |
259 | 259 | * |
260 | 260 | * @since 1.7 |
261 | 261 | */ |
262 | - do_action( 'give_donation_form_before_register_login', $form_id ); |
|
262 | + do_action('give_donation_form_before_register_login', $form_id); |
|
263 | 263 | |
264 | 264 | /** |
265 | 265 | * Fire when register/login form fields render. |
266 | 266 | * |
267 | 267 | * @since 1.7 |
268 | 268 | */ |
269 | - do_action( 'give_donation_form_register_login_fields', $form_id ); |
|
269 | + do_action('give_donation_form_register_login_fields', $form_id); |
|
270 | 270 | |
271 | 271 | /** |
272 | 272 | * Fire when credit card form fields render. |
273 | 273 | * |
274 | 274 | * @since 1.7 |
275 | 275 | */ |
276 | - do_action( 'give_donation_form_before_cc_form', $form_id ); |
|
276 | + do_action('give_donation_form_before_cc_form', $form_id); |
|
277 | 277 | |
278 | 278 | // Load the credit card form and allow gateways to load their own if they wish. |
279 | - if ( has_action( 'give_' . $payment_mode . '_cc_form' ) ) { |
|
279 | + if (has_action('give_'.$payment_mode.'_cc_form')) { |
|
280 | 280 | /** |
281 | 281 | * Fires while displaying donation form, credit card form fields for a given gateway. |
282 | 282 | * |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | * |
285 | 285 | * @param int $form_id The form ID. |
286 | 286 | */ |
287 | - do_action( "give_{$payment_mode}_cc_form", $form_id, $args ); |
|
287 | + do_action("give_{$payment_mode}_cc_form", $form_id, $args); |
|
288 | 288 | } else { |
289 | 289 | /** |
290 | 290 | * Fires while displaying donation form, credit card form fields. |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | * |
294 | 294 | * @param int $form_id The form ID. |
295 | 295 | */ |
296 | - do_action( 'give_cc_form', $form_id ); |
|
296 | + do_action('give_cc_form', $form_id); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | /** |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * |
302 | 302 | * @since 1.7 |
303 | 303 | */ |
304 | - do_action( 'give_donation_form_after_cc_form', $form_id ); |
|
304 | + do_action('give_donation_form_after_cc_form', $form_id); |
|
305 | 305 | |
306 | 306 | } else { |
307 | 307 | /** |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | * |
310 | 310 | * @since 1.7 |
311 | 311 | */ |
312 | - do_action( 'give_donation_form_no_access', $form_id ); |
|
312 | + do_action('give_donation_form_no_access', $form_id); |
|
313 | 313 | |
314 | 314 | } |
315 | 315 | |
@@ -318,10 +318,10 @@ discard block |
||
318 | 318 | * |
319 | 319 | * @since 1.7 |
320 | 320 | */ |
321 | - do_action( 'give_payment_fields_bottom', $form_id ); |
|
321 | + do_action('give_payment_fields_bottom', $form_id); |
|
322 | 322 | } |
323 | 323 | |
324 | -add_action( 'give_donation_form', 'give_show_purchase_form', 10, 2 ); |
|
324 | +add_action('give_donation_form', 'give_show_purchase_form', 10, 2); |
|
325 | 325 | |
326 | 326 | /** |
327 | 327 | * Give Show Login/Register Form Fields. |
@@ -332,11 +332,11 @@ discard block |
||
332 | 332 | * |
333 | 333 | * @return void |
334 | 334 | */ |
335 | -function give_show_register_login_fields( $form_id ) { |
|
335 | +function give_show_register_login_fields($form_id) { |
|
336 | 336 | |
337 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
337 | + $show_register_form = give_show_login_register_option($form_id); |
|
338 | 338 | |
339 | - if ( ( $show_register_form === 'registration' || ( $show_register_form === 'both' && ! isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : |
|
339 | + if (($show_register_form === 'registration' || ($show_register_form === 'both' && ! isset($_GET['login']))) && ! is_user_logged_in()) : |
|
340 | 340 | ?> |
341 | 341 | <div id="give-checkout-login-register-<?php echo $form_id; ?>"> |
342 | 342 | <?php |
@@ -345,11 +345,11 @@ discard block |
||
345 | 345 | * |
346 | 346 | * @since 1.7 |
347 | 347 | */ |
348 | - do_action( 'give_donation_form_register_fields', $form_id ); |
|
348 | + do_action('give_donation_form_register_fields', $form_id); |
|
349 | 349 | ?> |
350 | 350 | </div> |
351 | 351 | <?php |
352 | - elseif ( ( $show_register_form === 'login' || ( $show_register_form === 'both' && isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : |
|
352 | + elseif (($show_register_form === 'login' || ($show_register_form === 'both' && isset($_GET['login']))) && ! is_user_logged_in()) : |
|
353 | 353 | ?> |
354 | 354 | <div id="give-checkout-login-register-<?php echo $form_id; ?>"> |
355 | 355 | <?php |
@@ -358,23 +358,23 @@ discard block |
||
358 | 358 | * |
359 | 359 | * @since 1.7 |
360 | 360 | */ |
361 | - do_action( 'give_donation_form_login_fields', $form_id ); |
|
361 | + do_action('give_donation_form_login_fields', $form_id); |
|
362 | 362 | ?> |
363 | 363 | </div> |
364 | 364 | <?php |
365 | 365 | endif; |
366 | 366 | |
367 | - if ( ( ! isset( $_GET['login'] ) && is_user_logged_in() ) || ! isset( $show_register_form ) || 'none' === $show_register_form || 'login' === $show_register_form ) { |
|
367 | + if (( ! isset($_GET['login']) && is_user_logged_in()) || ! isset($show_register_form) || 'none' === $show_register_form || 'login' === $show_register_form) { |
|
368 | 368 | /** |
369 | 369 | * Fire when user info render. |
370 | 370 | * |
371 | 371 | * @since 1.7 |
372 | 372 | */ |
373 | - do_action( 'give_donation_form_after_user_info', $form_id ); |
|
373 | + do_action('give_donation_form_after_user_info', $form_id); |
|
374 | 374 | } |
375 | 375 | } |
376 | 376 | |
377 | -add_action( 'give_donation_form_register_login_fields', 'give_show_register_login_fields' ); |
|
377 | +add_action('give_donation_form_register_login_fields', 'give_show_register_login_fields'); |
|
378 | 378 | |
379 | 379 | /** |
380 | 380 | * Donation Amount Field. |
@@ -389,16 +389,16 @@ discard block |
||
389 | 389 | * |
390 | 390 | * @return void |
391 | 391 | */ |
392 | -function give_output_donation_amount_top( $form_id = 0, $args = array() ) { |
|
392 | +function give_output_donation_amount_top($form_id = 0, $args = array()) { |
|
393 | 393 | |
394 | 394 | $give_options = give_get_settings(); |
395 | - $variable_pricing = give_has_variable_prices( $form_id ); |
|
396 | - $allow_custom_amount = give_get_meta( $form_id, '_give_custom_amount', true ); |
|
397 | - $currency_position = isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before'; |
|
398 | - $symbol = give_currency_symbol( give_get_currency( $form_id, $args ) ); |
|
399 | - $currency_output = '<span class="give-currency-symbol give-currency-position-' . $currency_position . '">' . $symbol . '</span>'; |
|
400 | - $default_amount = give_format_amount( give_get_default_form_amount( $form_id ), array( 'sanitize' => false, 'currency' => give_get_currency( $form_id ) ) ); |
|
401 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
395 | + $variable_pricing = give_has_variable_prices($form_id); |
|
396 | + $allow_custom_amount = give_get_meta($form_id, '_give_custom_amount', true); |
|
397 | + $currency_position = isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before'; |
|
398 | + $symbol = give_currency_symbol(give_get_currency($form_id, $args)); |
|
399 | + $currency_output = '<span class="give-currency-symbol give-currency-position-'.$currency_position.'">'.$symbol.'</span>'; |
|
400 | + $default_amount = give_format_amount(give_get_default_form_amount($form_id), array('sanitize' => false, 'currency' => give_get_currency($form_id))); |
|
401 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
402 | 402 | |
403 | 403 | /** |
404 | 404 | * Fires while displaying donation form, before donation level fields. |
@@ -408,20 +408,20 @@ discard block |
||
408 | 408 | * @param int $form_id The form ID. |
409 | 409 | * @param array $args An array of form arguments. |
410 | 410 | */ |
411 | - do_action( 'give_before_donation_levels', $form_id, $args ); |
|
411 | + do_action('give_before_donation_levels', $form_id, $args); |
|
412 | 412 | |
413 | 413 | //Set Price, No Custom Amount Allowed means hidden price field |
414 | - if ( ! give_is_setting_enabled( $allow_custom_amount ) ) { |
|
414 | + if ( ! give_is_setting_enabled($allow_custom_amount)) { |
|
415 | 415 | ?> |
416 | - <label class="give-hidden" for="give-amount-hidden"><?php esc_html_e( 'Donation Amount:', 'give' ); ?></label> |
|
416 | + <label class="give-hidden" for="give-amount-hidden"><?php esc_html_e('Donation Amount:', 'give'); ?></label> |
|
417 | 417 | <input id="give-amount" class="give-amount-hidden" type="hidden" name="give-amount" |
418 | 418 | value="<?php echo $default_amount; ?>" required aria-required="true"/> |
419 | 419 | <div class="set-price give-donation-amount form-row-wide"> |
420 | - <?php if ( $currency_position == 'before' ) { |
|
420 | + <?php if ($currency_position == 'before') { |
|
421 | 421 | echo $currency_output; |
422 | 422 | } ?> |
423 | 423 | <span id="give-amount-text" class="give-text-input give-amount-top"><?php echo $default_amount; ?></span> |
424 | - <?php if ( $currency_position == 'after' ) { |
|
424 | + <?php if ($currency_position == 'after') { |
|
425 | 425 | echo $currency_output; |
426 | 426 | } ?> |
427 | 427 | </div> |
@@ -431,13 +431,13 @@ discard block |
||
431 | 431 | ?> |
432 | 432 | <div class="give-total-wrap"> |
433 | 433 | <div class="give-donation-amount form-row-wide"> |
434 | - <?php if ( $currency_position == 'before' ) { |
|
434 | + <?php if ($currency_position == 'before') { |
|
435 | 435 | echo $currency_output; |
436 | 436 | } ?> |
437 | - <label class="give-hidden" for="give-amount"><?php esc_html_e( 'Donation Amount:', 'give' ); ?></label> |
|
437 | + <label class="give-hidden" for="give-amount"><?php esc_html_e('Donation Amount:', 'give'); ?></label> |
|
438 | 438 | <input class="give-text-input give-amount-top" id="give-amount" name="give-amount" type="tel" |
439 | 439 | placeholder="" value="<?php echo $default_amount; ?>" autocomplete="off"> |
440 | - <?php if ( $currency_position == 'after' ) { |
|
440 | + <?php if ($currency_position == 'after') { |
|
441 | 441 | echo $currency_output; |
442 | 442 | } ?> |
443 | 443 | </div> |
@@ -452,16 +452,16 @@ discard block |
||
452 | 452 | * @param int $form_id The form ID. |
453 | 453 | * @param array $args An array of form arguments. |
454 | 454 | */ |
455 | - do_action( 'give_after_donation_amount', $form_id, $args ); |
|
455 | + do_action('give_after_donation_amount', $form_id, $args); |
|
456 | 456 | |
457 | 457 | //Custom Amount Text |
458 | - if ( ! $variable_pricing && give_is_setting_enabled( $allow_custom_amount ) && ! empty( $custom_amount_text ) ) { ?> |
|
458 | + if ( ! $variable_pricing && give_is_setting_enabled($allow_custom_amount) && ! empty($custom_amount_text)) { ?> |
|
459 | 459 | <p class="give-custom-amount-text"><?php echo $custom_amount_text; ?></p> |
460 | 460 | <?php } |
461 | 461 | |
462 | 462 | //Output Variable Pricing Levels. |
463 | - if ( $variable_pricing ) { |
|
464 | - give_output_levels( $form_id ); |
|
463 | + if ($variable_pricing) { |
|
464 | + give_output_levels($form_id); |
|
465 | 465 | } |
466 | 466 | |
467 | 467 | /** |
@@ -472,10 +472,10 @@ discard block |
||
472 | 472 | * @param int $form_id The form ID. |
473 | 473 | * @param array $args An array of form arguments. |
474 | 474 | */ |
475 | - do_action( 'give_after_donation_levels', $form_id, $args ); |
|
475 | + do_action('give_after_donation_levels', $form_id, $args); |
|
476 | 476 | } |
477 | 477 | |
478 | -add_action( 'give_donation_form_top', 'give_output_donation_amount_top', 10, 2 ); |
|
478 | +add_action('give_donation_form_top', 'give_output_donation_amount_top', 10, 2); |
|
479 | 479 | |
480 | 480 | /** |
481 | 481 | * Outputs the Donation Levels in various formats such as dropdown, radios, and buttons. |
@@ -486,33 +486,33 @@ discard block |
||
486 | 486 | * |
487 | 487 | * @return string Donation levels. |
488 | 488 | */ |
489 | -function give_output_levels( $form_id ) { |
|
489 | +function give_output_levels($form_id) { |
|
490 | 490 | |
491 | 491 | //Get variable pricing. |
492 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
493 | - $display_style = give_get_meta( $form_id, '_give_display_style', true ); |
|
494 | - $custom_amount = give_get_meta( $form_id, '_give_custom_amount', true ); |
|
495 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
492 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
493 | + $display_style = give_get_meta($form_id, '_give_display_style', true); |
|
494 | + $custom_amount = give_get_meta($form_id, '_give_custom_amount', true); |
|
495 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
496 | 496 | |
497 | - if ( empty( $custom_amount_text ) ) { |
|
498 | - $custom_amount_text = esc_html__( 'Give a Custom Amount', 'give' ); |
|
497 | + if (empty($custom_amount_text)) { |
|
498 | + $custom_amount_text = esc_html__('Give a Custom Amount', 'give'); |
|
499 | 499 | } |
500 | 500 | |
501 | 501 | $output = ''; |
502 | 502 | |
503 | - switch ( $display_style ) { |
|
503 | + switch ($display_style) { |
|
504 | 504 | case 'buttons': |
505 | 505 | |
506 | 506 | $output .= '<ul id="give-donation-level-button-wrap" class="give-donation-levels-wrap give-list-inline">'; |
507 | 507 | |
508 | - foreach ( $prices as $price ) { |
|
509 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) ), $form_id, $price ); |
|
510 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-donation-level-btn give-btn give-btn-level-' . $price['_give_id']['level_id'] . ' ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'give-default-level' : '' ), $form_id, $price ); |
|
508 | + foreach ($prices as $price) { |
|
509 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false))), $form_id, $price); |
|
510 | + $level_classes = apply_filters('give_form_level_classes', 'give-donation-level-btn give-btn give-btn-level-'.$price['_give_id']['level_id'].' '.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'give-default-level' : ''), $form_id, $price); |
|
511 | 511 | |
512 | - $formatted_amount = give_format_amount( $price['_give_amount'], array( |
|
512 | + $formatted_amount = give_format_amount($price['_give_amount'], array( |
|
513 | 513 | 'sanitize' => false, |
514 | - 'currency' => give_get_currency( $form_id ), |
|
515 | - ) ); |
|
514 | + 'currency' => give_get_currency($form_id), |
|
515 | + )); |
|
516 | 516 | |
517 | 517 | $output .= sprintf( |
518 | 518 | '<li><button type="button" data-price-id="%1$s" class="%2$s" value="%3$s">%4$s</button></li>', |
@@ -525,8 +525,8 @@ discard block |
||
525 | 525 | |
526 | 526 | //Custom Amount. |
527 | 527 | if ( |
528 | - give_is_setting_enabled( $custom_amount ) |
|
529 | - && ! empty( $custom_amount_text ) |
|
528 | + give_is_setting_enabled($custom_amount) |
|
529 | + && ! empty($custom_amount_text) |
|
530 | 530 | ) { |
531 | 531 | |
532 | 532 | $output .= sprintf( |
@@ -543,29 +543,29 @@ discard block |
||
543 | 543 | |
544 | 544 | $output .= '<ul id="give-donation-level-radio-list" class="give-donation-levels-wrap">'; |
545 | 545 | |
546 | - foreach ( $prices as $price ) { |
|
547 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) ), $form_id, $price ); |
|
548 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-radio-input give-radio-input-level give-radio-level-' . $price['_give_id']['level_id'] . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? ' give-default-level' : '' ), $form_id, $price ); |
|
546 | + foreach ($prices as $price) { |
|
547 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false))), $form_id, $price); |
|
548 | + $level_classes = apply_filters('give_form_level_classes', 'give-radio-input give-radio-input-level give-radio-level-'.$price['_give_id']['level_id'].((isset($price['_give_default']) && $price['_give_default'] === 'default') ? ' give-default-level' : ''), $form_id, $price); |
|
549 | 549 | |
550 | - $formatted_amount = give_format_amount( $price['_give_amount'], array( |
|
550 | + $formatted_amount = give_format_amount($price['_give_amount'], array( |
|
551 | 551 | 'sanitize' => false, |
552 | - 'currency' => give_get_currency( $form_id ), |
|
553 | - ) ); |
|
552 | + 'currency' => give_get_currency($form_id), |
|
553 | + )); |
|
554 | 554 | |
555 | 555 | $output .= sprintf( |
556 | 556 | '<li><input type="radio" data-price-id="%1$s" class="%2$s" value="%3$s" name="give-radio-donation-level" id="give-radio-level-%1$s" %4$s ><label for="give-radio-level-%1$s">%5$s</label></li>', |
557 | 557 | $price['_give_id']['level_id'], |
558 | 558 | $level_classes, |
559 | 559 | $formatted_amount, |
560 | - ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'checked="checked"' : '' ), |
|
560 | + ((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'checked="checked"' : ''), |
|
561 | 561 | $level_text |
562 | 562 | ); |
563 | 563 | } |
564 | 564 | |
565 | 565 | //Custom Amount. |
566 | 566 | if ( |
567 | - give_is_setting_enabled( $custom_amount ) |
|
568 | - && ! empty( $custom_amount_text ) |
|
567 | + give_is_setting_enabled($custom_amount) |
|
568 | + && ! empty($custom_amount_text) |
|
569 | 569 | ) { |
570 | 570 | $output .= sprintf( |
571 | 571 | '<li><input type="radio" data-price-id="custom" class="give-radio-input give-radio-input-level give-radio-level-custom" name="give-radio-donation-level" id="give-radio-level-custom" value="custom"><label for="give-radio-level-custom">%1$s</label></li>', |
@@ -579,31 +579,31 @@ discard block |
||
579 | 579 | |
580 | 580 | case 'dropdown': |
581 | 581 | |
582 | - $output .= '<label for="give-donation-level-select-' . $form_id . '" class="give-hidden">' . esc_html__( 'Choose Your Donation Amount', 'give' ) . ':</label>'; |
|
583 | - $output .= '<select id="give-donation-level-select-' . $form_id . '" class="give-select give-select-level give-donation-levels-wrap">'; |
|
582 | + $output .= '<label for="give-donation-level-select-'.$form_id.'" class="give-hidden">'.esc_html__('Choose Your Donation Amount', 'give').':</label>'; |
|
583 | + $output .= '<select id="give-donation-level-select-'.$form_id.'" class="give-select give-select-level give-donation-levels-wrap">'; |
|
584 | 584 | |
585 | 585 | //first loop through prices. |
586 | - foreach ( $prices as $price ) { |
|
587 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) ), $form_id, $price ); |
|
588 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-donation-level-' . $price['_give_id']['level_id'] . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? ' give-default-level' : '' ), $form_id, $price ); |
|
586 | + foreach ($prices as $price) { |
|
587 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false))), $form_id, $price); |
|
588 | + $level_classes = apply_filters('give_form_level_classes', 'give-donation-level-'.$price['_give_id']['level_id'].((isset($price['_give_default']) && $price['_give_default'] === 'default') ? ' give-default-level' : ''), $form_id, $price); |
|
589 | 589 | |
590 | - $formatted_amount = give_format_amount( $price['_give_amount'], array( |
|
590 | + $formatted_amount = give_format_amount($price['_give_amount'], array( |
|
591 | 591 | 'sanitize' => false, |
592 | - 'currency' => give_get_currency( $form_id ), |
|
593 | - ) ); |
|
592 | + 'currency' => give_get_currency($form_id), |
|
593 | + )); |
|
594 | 594 | |
595 | 595 | $output .= sprintf( |
596 | 596 | '<option data-price-id="%1$s" class="%2$s" value="%3$s" %4$s >%5$s</option>', |
597 | 597 | $price['_give_id']['level_id'], |
598 | 598 | $level_classes, |
599 | 599 | $formatted_amount, |
600 | - ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'selected="selected"' : '' ), |
|
600 | + ((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'selected="selected"' : ''), |
|
601 | 601 | $level_text |
602 | 602 | ); |
603 | 603 | } |
604 | 604 | |
605 | 605 | //Custom Amount. |
606 | - if ( give_is_setting_enabled( $custom_amount ) && ! empty( $custom_amount_text ) ) { |
|
606 | + if (give_is_setting_enabled($custom_amount) && ! empty($custom_amount_text)) { |
|
607 | 607 | $output .= sprintf( |
608 | 608 | '<option data-price-id="custom" class="give-donation-level-custom" value="custom">%1$s</option>', |
609 | 609 | $custom_amount_text |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | break; |
616 | 616 | } |
617 | 617 | |
618 | - echo apply_filters( 'give_form_level_output', $output, $form_id ); |
|
618 | + echo apply_filters('give_form_level_output', $output, $form_id); |
|
619 | 619 | } |
620 | 620 | |
621 | 621 | /** |
@@ -630,27 +630,27 @@ discard block |
||
630 | 630 | * |
631 | 631 | * @return string Checkout button. |
632 | 632 | */ |
633 | -function give_display_checkout_button( $form_id, $args ) { |
|
633 | +function give_display_checkout_button($form_id, $args) { |
|
634 | 634 | |
635 | - $display_option = ( isset( $args['display_style'] ) && ! empty( $args['display_style'] ) ) |
|
635 | + $display_option = (isset($args['display_style']) && ! empty($args['display_style'])) |
|
636 | 636 | ? $args['display_style'] |
637 | - : give_get_meta( $form_id, '_give_payment_display', true ); |
|
637 | + : give_get_meta($form_id, '_give_payment_display', true); |
|
638 | 638 | |
639 | - if ( 'button' === $display_option ) { |
|
639 | + if ('button' === $display_option) { |
|
640 | 640 | $display_option = 'modal'; |
641 | - } elseif ( $display_option === 'onpage' ) { |
|
641 | + } elseif ($display_option === 'onpage') { |
|
642 | 642 | return ''; |
643 | 643 | } |
644 | 644 | |
645 | - $display_label_field = give_get_meta( $form_id, '_give_reveal_label', true ); |
|
646 | - $display_label = ! empty( $args['continue_button_title'] ) ? $args['continue_button_title'] : ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) ); |
|
645 | + $display_label_field = give_get_meta($form_id, '_give_reveal_label', true); |
|
646 | + $display_label = ! empty($args['continue_button_title']) ? $args['continue_button_title'] : ( ! empty($display_label_field) ? $display_label_field : esc_html__('Donate Now', 'give')); |
|
647 | 647 | |
648 | - $output = '<button type="button" class="give-btn give-btn-' . $display_option . '">' . $display_label . '</button>'; |
|
648 | + $output = '<button type="button" class="give-btn give-btn-'.$display_option.'">'.$display_label.'</button>'; |
|
649 | 649 | |
650 | - echo apply_filters( 'give_display_checkout_button', $output ); |
|
650 | + echo apply_filters('give_display_checkout_button', $output); |
|
651 | 651 | } |
652 | 652 | |
653 | -add_action( 'give_after_donation_levels', 'give_display_checkout_button', 10, 2 ); |
|
653 | +add_action('give_after_donation_levels', 'give_display_checkout_button', 10, 2); |
|
654 | 654 | |
655 | 655 | /** |
656 | 656 | * Shows the User Info fields in the Personal Info box, more fields can be added via the hooks provided. |
@@ -663,79 +663,79 @@ discard block |
||
663 | 663 | * |
664 | 664 | * @return void |
665 | 665 | */ |
666 | -function give_user_info_fields( $form_id ) { |
|
666 | +function give_user_info_fields($form_id) { |
|
667 | 667 | // Get user info. |
668 | - $give_user_info = _give_get_prefill_form_field_values( $form_id ); |
|
668 | + $give_user_info = _give_get_prefill_form_field_values($form_id); |
|
669 | 669 | |
670 | 670 | /** |
671 | 671 | * Fire before user personal information fields |
672 | 672 | * |
673 | 673 | * @since 1.7 |
674 | 674 | */ |
675 | - do_action( 'give_donation_form_before_personal_info', $form_id ); |
|
675 | + do_action('give_donation_form_before_personal_info', $form_id); |
|
676 | 676 | ?> |
677 | 677 | <fieldset id="give_checkout_user_info"> |
678 | - <legend><?php echo apply_filters( 'give_checkout_personal_info_text', __( 'Personal Info', 'give' ) ); ?></legend> |
|
678 | + <legend><?php echo apply_filters('give_checkout_personal_info_text', __('Personal Info', 'give')); ?></legend> |
|
679 | 679 | <p id="give-first-name-wrap" class="form-row form-row-first form-row-responsive"> |
680 | 680 | <label class="give-label" for="give-first"> |
681 | - <?php _e( 'First Name', 'give' ); ?> |
|
682 | - <?php if ( give_field_is_required( 'give_first', $form_id ) ) : ?> |
|
681 | + <?php _e('First Name', 'give'); ?> |
|
682 | + <?php if (give_field_is_required('give_first', $form_id)) : ?> |
|
683 | 683 | <span class="give-required-indicator">*</span> |
684 | 684 | <?php endif ?> |
685 | - <?php echo Give()->tooltips->render_help( __( 'We will use this to personalize your account experience.', 'give' ) ); ?> |
|
685 | + <?php echo Give()->tooltips->render_help(__('We will use this to personalize your account experience.', 'give')); ?> |
|
686 | 686 | </label> |
687 | 687 | <input |
688 | 688 | class="give-input required" |
689 | 689 | type="text" |
690 | 690 | name="give_first" |
691 | 691 | autocomplete="given-name" |
692 | - placeholder="<?php _e( 'First Name', 'give' ); ?>" |
|
692 | + placeholder="<?php _e('First Name', 'give'); ?>" |
|
693 | 693 | id="give-first" |
694 | - value="<?php echo isset( $give_user_info['give_first'] ) ? $give_user_info['give_first'] : ''; ?>" |
|
695 | - <?php echo( give_field_is_required( 'give_first', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
694 | + value="<?php echo isset($give_user_info['give_first']) ? $give_user_info['give_first'] : ''; ?>" |
|
695 | + <?php echo(give_field_is_required('give_first', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
696 | 696 | /> |
697 | 697 | </p> |
698 | 698 | |
699 | 699 | <p id="give-last-name-wrap" class="form-row form-row-last form-row-responsive"> |
700 | 700 | <label class="give-label" for="give-last"> |
701 | - <?php _e( 'Last Name', 'give' ); ?> |
|
702 | - <?php if ( give_field_is_required( 'give_last', $form_id ) ) : ?> |
|
701 | + <?php _e('Last Name', 'give'); ?> |
|
702 | + <?php if (give_field_is_required('give_last', $form_id)) : ?> |
|
703 | 703 | <span class="give-required-indicator">*</span> |
704 | 704 | <?php endif ?> |
705 | - <?php echo Give()->tooltips->render_help( __( 'We will use this as well to personalize your account experience.', 'give' ) ); ?> |
|
705 | + <?php echo Give()->tooltips->render_help(__('We will use this as well to personalize your account experience.', 'give')); ?> |
|
706 | 706 | </label> |
707 | 707 | |
708 | 708 | <input |
709 | - class="give-input<?php echo( give_field_is_required( 'give_last', $form_id ) ? ' required' : '' ); ?>" |
|
709 | + class="give-input<?php echo(give_field_is_required('give_last', $form_id) ? ' required' : ''); ?>" |
|
710 | 710 | type="text" |
711 | 711 | name="give_last" |
712 | 712 | autocomplete="family-name" |
713 | 713 | id="give-last" |
714 | - placeholder="<?php _e( 'Last Name', 'give' ); ?>" |
|
715 | - value="<?php echo isset( $give_user_info['give_last'] ) ? $give_user_info['give_last'] : ''; ?>" |
|
716 | - <?php echo( give_field_is_required( 'give_last', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
714 | + placeholder="<?php _e('Last Name', 'give'); ?>" |
|
715 | + value="<?php echo isset($give_user_info['give_last']) ? $give_user_info['give_last'] : ''; ?>" |
|
716 | + <?php echo(give_field_is_required('give_last', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
717 | 717 | /> |
718 | 718 | </p> |
719 | 719 | |
720 | - <?php if ( give_is_company_field_enabled( $form_id ) ) : ?> |
|
721 | - <?php $give_company = give_field_is_required( 'give_company_name', $form_id ); ?> |
|
720 | + <?php if (give_is_company_field_enabled($form_id)) : ?> |
|
721 | + <?php $give_company = give_field_is_required('give_company_name', $form_id); ?> |
|
722 | 722 | <p id="give-company-wrap" class="form-row form-row-wide"> |
723 | 723 | <label class="give-label" for="give-company"> |
724 | - <?php _e( 'Company Name', 'give' ); ?> |
|
725 | - <?php if ( $give_company ) : ?> |
|
724 | + <?php _e('Company Name', 'give'); ?> |
|
725 | + <?php if ($give_company) : ?> |
|
726 | 726 | <span class="give-required-indicator">*</span> |
727 | 727 | <?php endif; ?> |
728 | - <?php echo Give()->tooltips->render_help( __( 'Donate on behalf of Company', 'give' ) ); ?> |
|
728 | + <?php echo Give()->tooltips->render_help(__('Donate on behalf of Company', 'give')); ?> |
|
729 | 729 | </label> |
730 | 730 | |
731 | 731 | <input |
732 | - class="give-input<?php echo( $give_company ? ' required' : '' ); ?>" |
|
732 | + class="give-input<?php echo($give_company ? ' required' : ''); ?>" |
|
733 | 733 | type="text" |
734 | 734 | name="give_company_name" |
735 | - placeholder="<?php _e( 'Company Name', 'give' ); ?>" |
|
735 | + placeholder="<?php _e('Company Name', 'give'); ?>" |
|
736 | 736 | id="give-company" |
737 | - value="<?php echo isset( $give_user_info['company_name'] ) ? $give_user_info['company_name'] : ''; ?>" |
|
738 | - <?php echo( $give_company ? ' required aria-required="true" ' : '' ); ?> |
|
737 | + value="<?php echo isset($give_user_info['company_name']) ? $give_user_info['company_name'] : ''; ?>" |
|
738 | + <?php echo($give_company ? ' required aria-required="true" ' : ''); ?> |
|
739 | 739 | /> |
740 | 740 | |
741 | 741 | </p> |
@@ -747,15 +747,15 @@ discard block |
||
747 | 747 | * |
748 | 748 | * @since 1.7 |
749 | 749 | */ |
750 | - do_action( 'give_donation_form_before_email', $form_id ); |
|
750 | + do_action('give_donation_form_before_email', $form_id); |
|
751 | 751 | ?> |
752 | 752 | <p id="give-email-wrap" class="form-row form-row-wide"> |
753 | 753 | <label class="give-label" for="give-email"> |
754 | - <?php _e( 'Email Address', 'give' ); ?> |
|
755 | - <?php if ( give_field_is_required( 'give_email', $form_id ) ) { ?> |
|
754 | + <?php _e('Email Address', 'give'); ?> |
|
755 | + <?php if (give_field_is_required('give_email', $form_id)) { ?> |
|
756 | 756 | <span class="give-required-indicator">*</span> |
757 | 757 | <?php } ?> |
758 | - <?php echo Give()->tooltips->render_help( __( 'We will send the donation receipt to this address.', 'give' ) ); ?> |
|
758 | + <?php echo Give()->tooltips->render_help(__('We will send the donation receipt to this address.', 'give')); ?> |
|
759 | 759 | </label> |
760 | 760 | |
761 | 761 | <input |
@@ -763,10 +763,10 @@ discard block |
||
763 | 763 | type="email" |
764 | 764 | name="give_email" |
765 | 765 | autocomplete="email" |
766 | - placeholder="<?php _e( 'Email Address', 'give' ); ?>" |
|
766 | + placeholder="<?php _e('Email Address', 'give'); ?>" |
|
767 | 767 | id="give-email" |
768 | - value="<?php echo isset( $give_user_info['give_email'] ) ? $give_user_info['give_email'] : ''; ?>" |
|
769 | - <?php echo( give_field_is_required( 'give_email', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
768 | + value="<?php echo isset($give_user_info['give_email']) ? $give_user_info['give_email'] : ''; ?>" |
|
769 | + <?php echo(give_field_is_required('give_email', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
770 | 770 | /> |
771 | 771 | |
772 | 772 | </p> |
@@ -776,14 +776,14 @@ discard block |
||
776 | 776 | * |
777 | 777 | * @since 1.7 |
778 | 778 | */ |
779 | - do_action( 'give_donation_form_after_email', $form_id ); |
|
779 | + do_action('give_donation_form_after_email', $form_id); |
|
780 | 780 | |
781 | 781 | /** |
782 | 782 | * Fire after personal email field |
783 | 783 | * |
784 | 784 | * @since 1.7 |
785 | 785 | */ |
786 | - do_action( 'give_donation_form_user_info', $form_id ); |
|
786 | + do_action('give_donation_form_user_info', $form_id); |
|
787 | 787 | ?> |
788 | 788 | </fieldset> |
789 | 789 | <?php |
@@ -792,11 +792,11 @@ discard block |
||
792 | 792 | * |
793 | 793 | * @since 1.7 |
794 | 794 | */ |
795 | - do_action( 'give_donation_form_after_personal_info', $form_id ); |
|
795 | + do_action('give_donation_form_after_personal_info', $form_id); |
|
796 | 796 | } |
797 | 797 | |
798 | -add_action( 'give_donation_form_after_user_info', 'give_user_info_fields' ); |
|
799 | -add_action( 'give_register_fields_before', 'give_user_info_fields' ); |
|
798 | +add_action('give_donation_form_after_user_info', 'give_user_info_fields'); |
|
799 | +add_action('give_register_fields_before', 'give_user_info_fields'); |
|
800 | 800 | |
801 | 801 | /** |
802 | 802 | * Renders the credit card info form. |
@@ -807,7 +807,7 @@ discard block |
||
807 | 807 | * |
808 | 808 | * @return void |
809 | 809 | */ |
810 | -function give_get_cc_form( $form_id ) { |
|
810 | +function give_get_cc_form($form_id) { |
|
811 | 811 | |
812 | 812 | ob_start(); |
813 | 813 | |
@@ -818,50 +818,50 @@ discard block |
||
818 | 818 | * |
819 | 819 | * @param int $form_id The form ID. |
820 | 820 | */ |
821 | - do_action( 'give_before_cc_fields', $form_id ); |
|
821 | + do_action('give_before_cc_fields', $form_id); |
|
822 | 822 | ?> |
823 | 823 | <fieldset id="give_cc_fields-<?php echo $form_id ?>" class="give-do-validate"> |
824 | - <legend><?php echo apply_filters( 'give_credit_card_fieldset_heading', esc_html__( 'Credit Card Info', 'give' ) ); ?></legend> |
|
825 | - <?php if ( is_ssl() ) : ?> |
|
824 | + <legend><?php echo apply_filters('give_credit_card_fieldset_heading', esc_html__('Credit Card Info', 'give')); ?></legend> |
|
825 | + <?php if (is_ssl()) : ?> |
|
826 | 826 | <div id="give_secure_site_wrapper-<?php echo $form_id ?>"> |
827 | 827 | <span class="give-icon padlock"></span> |
828 | - <span><?php _e( 'This is a secure SSL encrypted payment.', 'give' ); ?></span> |
|
828 | + <span><?php _e('This is a secure SSL encrypted payment.', 'give'); ?></span> |
|
829 | 829 | </div> |
830 | 830 | <?php endif; ?> |
831 | 831 | <p id="give-card-number-wrap-<?php echo $form_id ?>" class="form-row form-row-two-thirds form-row-responsive"> |
832 | 832 | <label for="card_number-<?php echo $form_id ?>" class="give-label"> |
833 | - <?php _e( 'Card Number', 'give' ); ?> |
|
833 | + <?php _e('Card Number', 'give'); ?> |
|
834 | 834 | <span class="give-required-indicator">*</span> |
835 | - <?php echo Give()->tooltips->render_help( __( 'The (typically) 16 digits on the front of your credit card.', 'give' ) ); ?> |
|
835 | + <?php echo Give()->tooltips->render_help(__('The (typically) 16 digits on the front of your credit card.', 'give')); ?> |
|
836 | 836 | <span class="card-type"></span> |
837 | 837 | </label> |
838 | 838 | |
839 | 839 | <input type="tel" autocomplete="off" name="card_number" id="card_number-<?php echo $form_id ?>" |
840 | - class="card-number give-input required" placeholder="<?php _e( 'Card number', 'give' ); ?>" |
|
840 | + class="card-number give-input required" placeholder="<?php _e('Card number', 'give'); ?>" |
|
841 | 841 | required aria-required="true"/> |
842 | 842 | </p> |
843 | 843 | |
844 | 844 | <p id="give-card-cvc-wrap-<?php echo $form_id ?>" class="form-row form-row-one-third form-row-responsive"> |
845 | 845 | <label for="card_cvc-<?php echo $form_id ?>" class="give-label"> |
846 | - <?php _e( 'CVC', 'give' ); ?> |
|
846 | + <?php _e('CVC', 'give'); ?> |
|
847 | 847 | <span class="give-required-indicator">*</span> |
848 | - <?php echo Give()->tooltips->render_help( __( 'The 3 digit (back) or 4 digit (front) value on your card.', 'give' ) ); ?> |
|
848 | + <?php echo Give()->tooltips->render_help(__('The 3 digit (back) or 4 digit (front) value on your card.', 'give')); ?> |
|
849 | 849 | </label> |
850 | 850 | |
851 | 851 | <input type="tel" size="4" autocomplete="off" name="card_cvc" id="card_cvc-<?php echo $form_id ?>" |
852 | - class="card-cvc give-input required" placeholder="<?php _e( 'Security code', 'give' ); ?>" |
|
852 | + class="card-cvc give-input required" placeholder="<?php _e('Security code', 'give'); ?>" |
|
853 | 853 | required aria-required="true"/> |
854 | 854 | </p> |
855 | 855 | |
856 | 856 | <p id="give-card-name-wrap-<?php echo $form_id ?>" class="form-row form-row-two-thirds form-row-responsive"> |
857 | 857 | <label for="card_name-<?php echo $form_id ?>" class="give-label"> |
858 | - <?php _e( 'Name on the Card', 'give' ); ?> |
|
858 | + <?php _e('Name on the Card', 'give'); ?> |
|
859 | 859 | <span class="give-required-indicator">*</span> |
860 | - <?php echo Give()->tooltips->render_help( __( 'The name printed on the front of your credit card.', 'give' ) ); ?> |
|
860 | + <?php echo Give()->tooltips->render_help(__('The name printed on the front of your credit card.', 'give')); ?> |
|
861 | 861 | </label> |
862 | 862 | |
863 | 863 | <input type="text" autocomplete="off" name="card_name" id="card_name-<?php echo $form_id ?>" |
864 | - class="card-name give-input required" placeholder="<?php esc_attr_e( 'Card name', 'give' ); ?>" |
|
864 | + class="card-name give-input required" placeholder="<?php esc_attr_e('Card name', 'give'); ?>" |
|
865 | 865 | required aria-required="true"/> |
866 | 866 | </p> |
867 | 867 | <?php |
@@ -872,19 +872,19 @@ discard block |
||
872 | 872 | * |
873 | 873 | * @param int $form_id The form ID. |
874 | 874 | */ |
875 | - do_action( 'give_before_cc_expiration' ); |
|
875 | + do_action('give_before_cc_expiration'); |
|
876 | 876 | ?> |
877 | 877 | <p class="card-expiration form-row form-row-one-third form-row-responsive"> |
878 | 878 | <label for="card_expiry-<?php echo $form_id ?>" class="give-label"> |
879 | - <?php _e( 'Expiration', 'give' ); ?> |
|
879 | + <?php _e('Expiration', 'give'); ?> |
|
880 | 880 | <span class="give-required-indicator">*</span> |
881 | - <?php echo Give()->tooltips->render_help( __( 'The date your credit card expires, typically on the front of the card.', 'give' ) ); ?> |
|
881 | + <?php echo Give()->tooltips->render_help(__('The date your credit card expires, typically on the front of the card.', 'give')); ?> |
|
882 | 882 | </label> |
883 | 883 | |
884 | 884 | <input type="hidden" id="card_exp_month-<?php echo $form_id ?>" name="card_exp_month" class="card-expiry-month"/> |
885 | 885 | <input type="hidden" id="card_exp_year-<?php echo $form_id ?>" name="card_exp_year" class="card-expiry-year"/> |
886 | 886 | |
887 | - <input type="tel" autocomplete="off" name="card_expiry" id="card_expiry-<?php echo $form_id ?>" class="card-expiry give-input required" placeholder="<?php esc_attr_e( 'MM / YY', 'give' ); ?>" required aria-required="true"/> |
|
887 | + <input type="tel" autocomplete="off" name="card_expiry" id="card_expiry-<?php echo $form_id ?>" class="card-expiry give-input required" placeholder="<?php esc_attr_e('MM / YY', 'give'); ?>" required aria-required="true"/> |
|
888 | 888 | </p> |
889 | 889 | <?php |
890 | 890 | /** |
@@ -894,7 +894,7 @@ discard block |
||
894 | 894 | * |
895 | 895 | * @param int $form_id The form ID. |
896 | 896 | */ |
897 | - do_action( 'give_after_cc_expiration', $form_id ); |
|
897 | + do_action('give_after_cc_expiration', $form_id); |
|
898 | 898 | ?> |
899 | 899 | </fieldset> |
900 | 900 | <?php |
@@ -905,12 +905,12 @@ discard block |
||
905 | 905 | * |
906 | 906 | * @param int $form_id The form ID. |
907 | 907 | */ |
908 | - do_action( 'give_after_cc_fields', $form_id ); |
|
908 | + do_action('give_after_cc_fields', $form_id); |
|
909 | 909 | |
910 | 910 | echo ob_get_clean(); |
911 | 911 | } |
912 | 912 | |
913 | -add_action( 'give_cc_form', 'give_get_cc_form' ); |
|
913 | +add_action('give_cc_form', 'give_get_cc_form'); |
|
914 | 914 | |
915 | 915 | /** |
916 | 916 | * Outputs the default credit card address fields. |
@@ -921,20 +921,20 @@ discard block |
||
921 | 921 | * |
922 | 922 | * @return void |
923 | 923 | */ |
924 | -function give_default_cc_address_fields( $form_id ) { |
|
924 | +function give_default_cc_address_fields($form_id) { |
|
925 | 925 | // Get user info. |
926 | - $give_user_info = _give_get_prefill_form_field_values( $form_id ); |
|
926 | + $give_user_info = _give_get_prefill_form_field_values($form_id); |
|
927 | 927 | |
928 | 928 | $logged_in = is_user_logged_in(); |
929 | 929 | |
930 | - if ( $logged_in ) { |
|
931 | - $user_address = give_get_donor_address( get_current_user_id() ); |
|
930 | + if ($logged_in) { |
|
931 | + $user_address = give_get_donor_address(get_current_user_id()); |
|
932 | 932 | } |
933 | 933 | |
934 | 934 | ob_start(); |
935 | 935 | ?> |
936 | 936 | <fieldset id="give_cc_address" class="cc-address"> |
937 | - <legend><?php echo apply_filters( 'give_billing_details_fieldset_heading', esc_html__( 'Billing Details', 'give' ) ); ?></legend> |
|
937 | + <legend><?php echo apply_filters('give_billing_details_fieldset_heading', esc_html__('Billing Details', 'give')); ?></legend> |
|
938 | 938 | <?php |
939 | 939 | /** |
940 | 940 | * Fires while rendering credit card billing form, before address fields. |
@@ -943,36 +943,36 @@ discard block |
||
943 | 943 | * |
944 | 944 | * @param int $form_id The form ID. |
945 | 945 | */ |
946 | - do_action( 'give_cc_billing_top' ); |
|
946 | + do_action('give_cc_billing_top'); |
|
947 | 947 | |
948 | 948 | // For Country. |
949 | 949 | $selected_country = give_get_country(); |
950 | - if ( ! empty( $give_user_info['billing_country'] ) && '*' !== $give_user_info['billing_country'] ) { |
|
950 | + if ( ! empty($give_user_info['billing_country']) && '*' !== $give_user_info['billing_country']) { |
|
951 | 951 | $selected_country = $give_user_info['billing_country']; |
952 | 952 | } |
953 | 953 | $countries = give_get_country_list(); |
954 | 954 | |
955 | 955 | // For state |
956 | 956 | $selected_state = ''; |
957 | - if ( $selected_country === give_get_country() ) { |
|
957 | + if ($selected_country === give_get_country()) { |
|
958 | 958 | // Get defalut selected state by admin. |
959 | 959 | $selected_state = give_get_state(); |
960 | 960 | } |
961 | 961 | // Get the last payment made by user states. |
962 | - if ( ! empty( $give_user_info['card_state'] ) && '*' !== $give_user_info['card_state'] ) { |
|
962 | + if ( ! empty($give_user_info['card_state']) && '*' !== $give_user_info['card_state']) { |
|
963 | 963 | $selected_state = $give_user_info['card_state']; |
964 | 964 | } |
965 | 965 | // Get the country code |
966 | - if ( ! empty( $give_user_info['billing_country'] ) && '*' !== $give_user_info['billing_country'] ) { |
|
966 | + if ( ! empty($give_user_info['billing_country']) && '*' !== $give_user_info['billing_country']) { |
|
967 | 967 | $selected_country = $give_user_info['billing_country']; |
968 | 968 | } |
969 | - $label = __( 'State', 'give' ); |
|
969 | + $label = __('State', 'give'); |
|
970 | 970 | $states_label = give_get_states_label(); |
971 | 971 | // Check if $country code exists in the array key for states label. |
972 | - if ( array_key_exists( $selected_country, $states_label ) ) { |
|
973 | - $label = $states_label[ $selected_country ]; |
|
972 | + if (array_key_exists($selected_country, $states_label)) { |
|
973 | + $label = $states_label[$selected_country]; |
|
974 | 974 | } |
975 | - $states = give_get_states( $selected_country ); |
|
975 | + $states = give_get_states($selected_country); |
|
976 | 976 | // Get the country list that do not have any states init. |
977 | 977 | $no_states_country = give_no_states_country_list(); |
978 | 978 | // Get the country list that does not require states. |
@@ -980,24 +980,24 @@ discard block |
||
980 | 980 | ?> |
981 | 981 | <p id="give-card-country-wrap" class="form-row form-row-wide"> |
982 | 982 | <label for="billing_country" class="give-label"> |
983 | - <?php esc_html_e( 'Country', 'give' ); ?> |
|
984 | - <?php if ( give_field_is_required( 'billing_country', $form_id ) ) : ?> |
|
983 | + <?php esc_html_e('Country', 'give'); ?> |
|
984 | + <?php if (give_field_is_required('billing_country', $form_id)) : ?> |
|
985 | 985 | <span class="give-required-indicator">*</span> |
986 | 986 | <?php endif; ?> |
987 | 987 | <span class="give-tooltip give-icon give-icon-question" |
988 | - data-tooltip="<?php esc_attr_e( 'The country for your billing address.', 'give' ); ?>"></span> |
|
988 | + data-tooltip="<?php esc_attr_e('The country for your billing address.', 'give'); ?>"></span> |
|
989 | 989 | </label> |
990 | 990 | |
991 | 991 | <select |
992 | 992 | name="billing_country" |
993 | 993 | autocomplete="country-name" |
994 | 994 | id="billing_country" |
995 | - class="billing-country billing_country give-select<?php echo( give_field_is_required( 'billing_country', $form_id ) ? ' required' : '' ); ?>" |
|
996 | - <?php echo( give_field_is_required( 'billing_country', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
995 | + class="billing-country billing_country give-select<?php echo(give_field_is_required('billing_country', $form_id) ? ' required' : ''); ?>" |
|
996 | + <?php echo(give_field_is_required('billing_country', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
997 | 997 | > |
998 | 998 | <?php |
999 | - foreach ( $countries as $country_code => $country ) { |
|
1000 | - echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>'; |
|
999 | + foreach ($countries as $country_code => $country) { |
|
1000 | + echo '<option value="'.esc_attr($country_code).'"'.selected($country_code, $selected_country, false).'>'.$country.'</option>'; |
|
1001 | 1001 | } |
1002 | 1002 | ?> |
1003 | 1003 | </select> |
@@ -1005,12 +1005,12 @@ discard block |
||
1005 | 1005 | |
1006 | 1006 | <p id="give-card-address-wrap" class="form-row form-row-wide"> |
1007 | 1007 | <label for="card_address" class="give-label"> |
1008 | - <?php _e( 'Address 1', 'give' ); ?> |
|
1008 | + <?php _e('Address 1', 'give'); ?> |
|
1009 | 1009 | <?php |
1010 | - if ( give_field_is_required( 'card_address', $form_id ) ) : ?> |
|
1010 | + if (give_field_is_required('card_address', $form_id)) : ?> |
|
1011 | 1011 | <span class="give-required-indicator">*</span> |
1012 | 1012 | <?php endif; ?> |
1013 | - <?php echo Give()->tooltips->render_help( __( 'The primary billing address for your credit card.', 'give' ) ); ?> |
|
1013 | + <?php echo Give()->tooltips->render_help(__('The primary billing address for your credit card.', 'give')); ?> |
|
1014 | 1014 | </label> |
1015 | 1015 | |
1016 | 1016 | <input |
@@ -1018,20 +1018,20 @@ discard block |
||
1018 | 1018 | id="card_address" |
1019 | 1019 | name="card_address" |
1020 | 1020 | autocomplete="address-line1" |
1021 | - class="card-address give-input<?php echo( give_field_is_required( 'card_address', $form_id ) ? ' required' : '' ); ?>" |
|
1022 | - placeholder="<?php _e( 'Address line 1', 'give' ); ?>" |
|
1023 | - value="<?php echo isset( $give_user_info['card_address'] ) ? $give_user_info['card_address'] : ''; ?>" |
|
1024 | - <?php echo( give_field_is_required( 'card_address', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
1021 | + class="card-address give-input<?php echo(give_field_is_required('card_address', $form_id) ? ' required' : ''); ?>" |
|
1022 | + placeholder="<?php _e('Address line 1', 'give'); ?>" |
|
1023 | + value="<?php echo isset($give_user_info['card_address']) ? $give_user_info['card_address'] : ''; ?>" |
|
1024 | + <?php echo(give_field_is_required('card_address', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
1025 | 1025 | /> |
1026 | 1026 | </p> |
1027 | 1027 | |
1028 | 1028 | <p id="give-card-address-2-wrap" class="form-row form-row-wide"> |
1029 | 1029 | <label for="card_address_2" class="give-label"> |
1030 | - <?php _e( 'Address 2', 'give' ); ?> |
|
1031 | - <?php if ( give_field_is_required( 'card_address_2', $form_id ) ) : ?> |
|
1030 | + <?php _e('Address 2', 'give'); ?> |
|
1031 | + <?php if (give_field_is_required('card_address_2', $form_id)) : ?> |
|
1032 | 1032 | <span class="give-required-indicator">*</span> |
1033 | 1033 | <?php endif; ?> |
1034 | - <?php echo Give()->tooltips->render_help( __( '(optional) The suite, apartment number, post office box (etc) associated with your billing address.', 'give' ) ); ?> |
|
1034 | + <?php echo Give()->tooltips->render_help(__('(optional) The suite, apartment number, post office box (etc) associated with your billing address.', 'give')); ?> |
|
1035 | 1035 | </label> |
1036 | 1036 | |
1037 | 1037 | <input |
@@ -1039,56 +1039,56 @@ discard block |
||
1039 | 1039 | id="card_address_2" |
1040 | 1040 | name="card_address_2" |
1041 | 1041 | autocomplete="address-line2" |
1042 | - class="card-address-2 give-input<?php echo( give_field_is_required( 'card_address_2', $form_id ) ? ' required' : '' ); ?>" |
|
1043 | - placeholder="<?php _e( 'Address line 2', 'give' ); ?>" |
|
1044 | - value="<?php echo isset( $give_user_info['card_address_2'] ) ? $give_user_info['card_address_2'] : ''; ?>" |
|
1045 | - <?php echo( give_field_is_required( 'card_address_2', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
1042 | + class="card-address-2 give-input<?php echo(give_field_is_required('card_address_2', $form_id) ? ' required' : ''); ?>" |
|
1043 | + placeholder="<?php _e('Address line 2', 'give'); ?>" |
|
1044 | + value="<?php echo isset($give_user_info['card_address_2']) ? $give_user_info['card_address_2'] : ''; ?>" |
|
1045 | + <?php echo(give_field_is_required('card_address_2', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
1046 | 1046 | /> |
1047 | 1047 | </p> |
1048 | 1048 | |
1049 | 1049 | <p id="give-card-city-wrap" class="form-row form-row-wide"> |
1050 | 1050 | <label for="card_city" class="give-label"> |
1051 | - <?php _e( 'City', 'give' ); ?> |
|
1052 | - <?php if ( give_field_is_required( 'card_city', $form_id ) ) : ?> |
|
1051 | + <?php _e('City', 'give'); ?> |
|
1052 | + <?php if (give_field_is_required('card_city', $form_id)) : ?> |
|
1053 | 1053 | <span class="give-required-indicator">*</span> |
1054 | 1054 | <?php endif; ?> |
1055 | - <?php echo Give()->tooltips->render_help( __( 'The city for your billing address.', 'give' ) ); ?> |
|
1055 | + <?php echo Give()->tooltips->render_help(__('The city for your billing address.', 'give')); ?> |
|
1056 | 1056 | </label> |
1057 | 1057 | <input |
1058 | 1058 | type="text" |
1059 | 1059 | id="card_city" |
1060 | 1060 | name="card_city" |
1061 | 1061 | autocomplete="address-level3" |
1062 | - class="card-city give-input<?php echo( give_field_is_required( 'card_city', $form_id ) ? ' required' : '' ); ?>" |
|
1063 | - placeholder="<?php _e( 'City', 'give' ); ?>" |
|
1064 | - value="<?php echo isset( $give_user_info['card_city'] ) ? $give_user_info['card_city'] : ''; ?>" |
|
1065 | - <?php echo( give_field_is_required( 'card_city', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
1062 | + class="card-city give-input<?php echo(give_field_is_required('card_city', $form_id) ? ' required' : ''); ?>" |
|
1063 | + placeholder="<?php _e('City', 'give'); ?>" |
|
1064 | + value="<?php echo isset($give_user_info['card_city']) ? $give_user_info['card_city'] : ''; ?>" |
|
1065 | + <?php echo(give_field_is_required('card_city', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
1066 | 1066 | /> |
1067 | 1067 | </p> |
1068 | 1068 | |
1069 | 1069 | <p id="give-card-state-wrap" |
1070 | - class="form-row form-row-first form-row-responsive <?php echo ( ! empty( $selected_country ) && array_key_exists( $selected_country, $no_states_country ) ) ? 'give-hidden' : ''; ?> "> |
|
1070 | + class="form-row form-row-first form-row-responsive <?php echo ( ! empty($selected_country) && array_key_exists($selected_country, $no_states_country)) ? 'give-hidden' : ''; ?> "> |
|
1071 | 1071 | <label for="card_state" class="give-label"> |
1072 | 1072 | <span class="state-label-text"><?php echo $label; ?></span> |
1073 | - <?php if ( give_field_is_required( 'card_state', $form_id ) ) : |
|
1073 | + <?php if (give_field_is_required('card_state', $form_id)) : |
|
1074 | 1074 | ?> |
1075 | - <span class="give-required-indicator <?php echo( array_key_exists( $selected_country, $states_not_required_country_list ) ? 'give-hidden' : '' ) ?> ">*</span> |
|
1075 | + <span class="give-required-indicator <?php echo(array_key_exists($selected_country, $states_not_required_country_list) ? 'give-hidden' : '') ?> ">*</span> |
|
1076 | 1076 | <?php endif; ?> |
1077 | 1077 | <span class="give-tooltip give-icon give-icon-question" |
1078 | - data-tooltip="<?php esc_attr_e( 'The state, province, or county for your billing address.', 'give' ); ?>"></span> |
|
1078 | + data-tooltip="<?php esc_attr_e('The state, province, or county for your billing address.', 'give'); ?>"></span> |
|
1079 | 1079 | </label> |
1080 | 1080 | <?php |
1081 | 1081 | |
1082 | - if ( ! empty( $states ) ) : ?> |
|
1082 | + if ( ! empty($states)) : ?> |
|
1083 | 1083 | <select |
1084 | 1084 | name="card_state" |
1085 | 1085 | autocomplete="address-level4" |
1086 | 1086 | id="card_state" |
1087 | - class="card_state give-select<?php echo( give_field_is_required( 'card_state', $form_id ) ? ' required' : '' ); ?>" |
|
1088 | - <?php echo( give_field_is_required( 'card_state', $form_id ) ? ' required aria-required="true" ' : '' ); ?>> |
|
1087 | + class="card_state give-select<?php echo(give_field_is_required('card_state', $form_id) ? ' required' : ''); ?>" |
|
1088 | + <?php echo(give_field_is_required('card_state', $form_id) ? ' required aria-required="true" ' : ''); ?>> |
|
1089 | 1089 | <?php |
1090 | - foreach ( $states as $state_code => $state ) { |
|
1091 | - echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>'; |
|
1090 | + foreach ($states as $state_code => $state) { |
|
1091 | + echo '<option value="'.$state_code.'"'.selected($state_code, $selected_state, false).'>'.$state.'</option>'; |
|
1092 | 1092 | } |
1093 | 1093 | ?> |
1094 | 1094 | </select> |
@@ -1100,11 +1100,11 @@ discard block |
||
1100 | 1100 | |
1101 | 1101 | <p id="give-card-zip-wrap" class="form-row form-row-last form-row-responsive"> |
1102 | 1102 | <label for="card_zip" class="give-label"> |
1103 | - <?php _e( 'Zip / Postal Code', 'give' ); ?> |
|
1104 | - <?php if ( give_field_is_required( 'card_zip', $form_id ) ) : ?> |
|
1103 | + <?php _e('Zip / Postal Code', 'give'); ?> |
|
1104 | + <?php if (give_field_is_required('card_zip', $form_id)) : ?> |
|
1105 | 1105 | <span class="give-required-indicator">*</span> |
1106 | 1106 | <?php endif; ?> |
1107 | - <?php echo Give()->tooltips->render_help( __( 'The ZIP Code or postal code for your billing address.', 'give' ) ); ?> |
|
1107 | + <?php echo Give()->tooltips->render_help(__('The ZIP Code or postal code for your billing address.', 'give')); ?> |
|
1108 | 1108 | </label> |
1109 | 1109 | |
1110 | 1110 | <input |
@@ -1113,10 +1113,10 @@ discard block |
||
1113 | 1113 | id="card_zip" |
1114 | 1114 | name="card_zip" |
1115 | 1115 | autocomplete="postal-code" |
1116 | - class="card-zip give-input<?php echo( give_field_is_required( 'card_zip', $form_id ) ? ' required' : '' ); ?>" |
|
1117 | - placeholder="<?php _e( 'Zip / Postal Code', 'give' ); ?>" |
|
1118 | - value="<?php echo isset( $give_user_info['card_zip'] ) ? $give_user_info['card_zip'] : ''; ?>" |
|
1119 | - <?php echo( give_field_is_required( 'card_zip', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
1116 | + class="card-zip give-input<?php echo(give_field_is_required('card_zip', $form_id) ? ' required' : ''); ?>" |
|
1117 | + placeholder="<?php _e('Zip / Postal Code', 'give'); ?>" |
|
1118 | + value="<?php echo isset($give_user_info['card_zip']) ? $give_user_info['card_zip'] : ''; ?>" |
|
1119 | + <?php echo(give_field_is_required('card_zip', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
1120 | 1120 | /> |
1121 | 1121 | </p> |
1122 | 1122 | <?php |
@@ -1127,14 +1127,14 @@ discard block |
||
1127 | 1127 | * |
1128 | 1128 | * @param int $form_id The form ID. |
1129 | 1129 | */ |
1130 | - do_action( 'give_cc_billing_bottom' ); |
|
1130 | + do_action('give_cc_billing_bottom'); |
|
1131 | 1131 | ?> |
1132 | 1132 | </fieldset> |
1133 | 1133 | <?php |
1134 | 1134 | echo ob_get_clean(); |
1135 | 1135 | } |
1136 | 1136 | |
1137 | -add_action( 'give_after_cc_fields', 'give_default_cc_address_fields' ); |
|
1137 | +add_action('give_after_cc_fields', 'give_default_cc_address_fields'); |
|
1138 | 1138 | |
1139 | 1139 | |
1140 | 1140 | /** |
@@ -1147,15 +1147,15 @@ discard block |
||
1147 | 1147 | * |
1148 | 1148 | * @return string |
1149 | 1149 | */ |
1150 | -function give_get_register_fields( $form_id ) { |
|
1150 | +function give_get_register_fields($form_id) { |
|
1151 | 1151 | |
1152 | 1152 | global $user_ID; |
1153 | 1153 | |
1154 | - if ( is_user_logged_in() ) { |
|
1155 | - $user_data = get_userdata( $user_ID ); |
|
1154 | + if (is_user_logged_in()) { |
|
1155 | + $user_data = get_userdata($user_ID); |
|
1156 | 1156 | } |
1157 | 1157 | |
1158 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
1158 | + $show_register_form = give_show_login_register_option($form_id); |
|
1159 | 1159 | |
1160 | 1160 | ob_start(); ?> |
1161 | 1161 | <fieldset id="give-register-fields-<?php echo $form_id; ?>"> |
@@ -1168,7 +1168,7 @@ discard block |
||
1168 | 1168 | * |
1169 | 1169 | * @param int $form_id The form ID. |
1170 | 1170 | */ |
1171 | - do_action( 'give_register_fields_before', $form_id ); |
|
1171 | + do_action('give_register_fields_before', $form_id); |
|
1172 | 1172 | ?> |
1173 | 1173 | |
1174 | 1174 | <fieldset id="give-register-account-fields-<?php echo $form_id; ?>"> |
@@ -1180,22 +1180,22 @@ discard block |
||
1180 | 1180 | * |
1181 | 1181 | * @param int $form_id The form ID. |
1182 | 1182 | */ |
1183 | - do_action( 'give_register_account_fields_before', $form_id ); |
|
1183 | + do_action('give_register_account_fields_before', $form_id); |
|
1184 | 1184 | ?> |
1185 | 1185 | <div id="give-create-account-wrap-<?php echo $form_id; ?>" class="form-row form-row-first form-row-responsive"> |
1186 | 1186 | <label for="give-create-account-<?php echo $form_id; ?>"> |
1187 | 1187 | <?php |
1188 | 1188 | // Add attributes to checkbox, if Guest Checkout is disabled. |
1189 | - $is_guest_checkout = give_get_meta( $form_id, '_give_logged_in_only', true ); |
|
1190 | - $id = 'give-create-account-' . $form_id; |
|
1191 | - if ( ! give_is_setting_enabled( $is_guest_checkout ) ) { |
|
1189 | + $is_guest_checkout = give_get_meta($form_id, '_give_logged_in_only', true); |
|
1190 | + $id = 'give-create-account-'.$form_id; |
|
1191 | + if ( ! give_is_setting_enabled($is_guest_checkout)) { |
|
1192 | 1192 | echo Give()->tooltips->render( |
1193 | 1193 | array( |
1194 | 1194 | 'tag_content' => sprintf( |
1195 | 1195 | '<input type="checkbox" name="give_create_account" value="on" id="%s" class="give-input give-disabled" checked />', |
1196 | 1196 | $id |
1197 | 1197 | ), |
1198 | - 'label' => __( 'Registration is required to donate.', 'give' ), |
|
1198 | + 'label' => __('Registration is required to donate.', 'give'), |
|
1199 | 1199 | ) ); |
1200 | 1200 | } else { |
1201 | 1201 | ?> |
@@ -1203,17 +1203,17 @@ discard block |
||
1203 | 1203 | <?php |
1204 | 1204 | } |
1205 | 1205 | ?> |
1206 | - <?php _e( 'Create an account', 'give' ); ?> |
|
1207 | - <?php echo Give()->tooltips->render_help( __( 'Create an account on the site to see and manage donation history.', 'give' ) ); ?> |
|
1208 | - <?php wp_nonce_field( 'give_form_create_user_nonce', 'give-form-user-register-hash', false, true );?> |
|
1206 | + <?php _e('Create an account', 'give'); ?> |
|
1207 | + <?php echo Give()->tooltips->render_help(__('Create an account on the site to see and manage donation history.', 'give')); ?> |
|
1208 | + <?php wp_nonce_field('give_form_create_user_nonce', 'give-form-user-register-hash', false, true); ?> |
|
1209 | 1209 | </label> |
1210 | 1210 | </div> |
1211 | 1211 | |
1212 | - <?php if ( 'both' === $show_register_form ) { ?> |
|
1212 | + <?php if ('both' === $show_register_form) { ?> |
|
1213 | 1213 | <div class="give-login-account-wrap form-row form-row-last form-row-responsive"> |
1214 | - <p class="give-login-message"><?php esc_html_e( 'Already have an account?', 'give' ); ?> |
|
1215 | - <a href="<?php echo esc_url( add_query_arg( 'login', 1 ) ); ?>" class="give-checkout-login" |
|
1216 | - data-action="give_checkout_login"><?php esc_html_e( 'Login', 'give' ); ?></a> |
|
1214 | + <p class="give-login-message"><?php esc_html_e('Already have an account?', 'give'); ?> |
|
1215 | + <a href="<?php echo esc_url(add_query_arg('login', 1)); ?>" class="give-checkout-login" |
|
1216 | + data-action="give_checkout_login"><?php esc_html_e('Login', 'give'); ?></a> |
|
1217 | 1217 | </p> |
1218 | 1218 | <p class="give-loading-text"> |
1219 | 1219 | <span class="give-loading-animation"></span> |
@@ -1229,7 +1229,7 @@ discard block |
||
1229 | 1229 | * |
1230 | 1230 | * @param int $form_id The form ID. |
1231 | 1231 | */ |
1232 | - do_action( 'give_register_account_fields_after', $form_id ); |
|
1232 | + do_action('give_register_account_fields_after', $form_id); |
|
1233 | 1233 | ?> |
1234 | 1234 | </fieldset> |
1235 | 1235 | |
@@ -1241,7 +1241,7 @@ discard block |
||
1241 | 1241 | * |
1242 | 1242 | * @param int $form_id The form ID. |
1243 | 1243 | */ |
1244 | - do_action( 'give_register_fields_after', $form_id ); |
|
1244 | + do_action('give_register_fields_after', $form_id); |
|
1245 | 1245 | ?> |
1246 | 1246 | |
1247 | 1247 | <input type="hidden" name="give-purchase-var" value="needs-to-register"/> |
@@ -1252,7 +1252,7 @@ discard block |
||
1252 | 1252 | * |
1253 | 1253 | * @since 1.7 |
1254 | 1254 | */ |
1255 | - do_action( 'give_donation_form_user_info', $form_id ); |
|
1255 | + do_action('give_donation_form_user_info', $form_id); |
|
1256 | 1256 | ?> |
1257 | 1257 | |
1258 | 1258 | </fieldset> |
@@ -1260,7 +1260,7 @@ discard block |
||
1260 | 1260 | echo ob_get_clean(); |
1261 | 1261 | } |
1262 | 1262 | |
1263 | -add_action( 'give_donation_form_register_fields', 'give_get_register_fields' ); |
|
1263 | +add_action('give_donation_form_register_fields', 'give_get_register_fields'); |
|
1264 | 1264 | |
1265 | 1265 | /** |
1266 | 1266 | * Gets the login fields for the login form on the checkout. This function hooks |
@@ -1273,28 +1273,28 @@ discard block |
||
1273 | 1273 | * |
1274 | 1274 | * @return string |
1275 | 1275 | */ |
1276 | -function give_get_login_fields( $form_id ) { |
|
1276 | +function give_get_login_fields($form_id) { |
|
1277 | 1277 | |
1278 | - $form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : $form_id; |
|
1279 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
1278 | + $form_id = isset($_POST['form_id']) ? $_POST['form_id'] : $form_id; |
|
1279 | + $show_register_form = give_show_login_register_option($form_id); |
|
1280 | 1280 | |
1281 | 1281 | ob_start(); |
1282 | 1282 | ?> |
1283 | 1283 | <fieldset id="give-login-fields-<?php echo $form_id; ?>"> |
1284 | - <legend><?php echo apply_filters( 'give_account_login_fieldset_heading', __( 'Login to Your Account', 'give' ) ); |
|
1285 | - if ( ! give_logged_in_only( $form_id ) ) { |
|
1286 | - echo ' <span class="sub-text">' . __( '(optional)', 'give' ) . '</span>'; |
|
1284 | + <legend><?php echo apply_filters('give_account_login_fieldset_heading', __('Login to Your Account', 'give')); |
|
1285 | + if ( ! give_logged_in_only($form_id)) { |
|
1286 | + echo ' <span class="sub-text">'.__('(optional)', 'give').'</span>'; |
|
1287 | 1287 | } ?> |
1288 | 1288 | </legend> |
1289 | - <?php if ( $show_register_form == 'both' ) { ?> |
|
1289 | + <?php if ($show_register_form == 'both') { ?> |
|
1290 | 1290 | <p class="give-new-account-link"> |
1291 | - <?php _e( 'Don\'t have an account?', 'give' ); ?> |
|
1292 | - <a href="<?php echo remove_query_arg( 'login' ); ?>" class="give-checkout-register-cancel" |
|
1291 | + <?php _e('Don\'t have an account?', 'give'); ?> |
|
1292 | + <a href="<?php echo remove_query_arg('login'); ?>" class="give-checkout-register-cancel" |
|
1293 | 1293 | data-action="give_checkout_register"> |
1294 | - <?php if ( give_logged_in_only( $form_id ) ) { |
|
1295 | - _e( 'Register as a part of your donation »', 'give' ); |
|
1294 | + <?php if (give_logged_in_only($form_id)) { |
|
1295 | + _e('Register as a part of your donation »', 'give'); |
|
1296 | 1296 | } else { |
1297 | - _e( 'Register or donate as a guest »', 'give' ); |
|
1297 | + _e('Register or donate as a guest »', 'give'); |
|
1298 | 1298 | } ?> |
1299 | 1299 | </a> |
1300 | 1300 | </p> |
@@ -1310,49 +1310,49 @@ discard block |
||
1310 | 1310 | * |
1311 | 1311 | * @param int $form_id The form ID. |
1312 | 1312 | */ |
1313 | - do_action( 'give_checkout_login_fields_before', $form_id ); |
|
1313 | + do_action('give_checkout_login_fields_before', $form_id); |
|
1314 | 1314 | ?> |
1315 | 1315 | <div id="give-user-login-wrap-<?php echo $form_id; ?>" class="form-row form-row-first form-row-responsive"> |
1316 | 1316 | <label class="give-label" for="give-user-login-<?php echo $form_id; ?>"> |
1317 | - <?php _e( 'Username', 'give' ); ?> |
|
1318 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
1317 | + <?php _e('Username', 'give'); ?> |
|
1318 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
1319 | 1319 | <span class="give-required-indicator">*</span> |
1320 | 1320 | <?php } ?> |
1321 | 1321 | </label> |
1322 | 1322 | |
1323 | - <input class="give-input<?php echo ( give_logged_in_only( $form_id ) ) ? ' required' : ''; ?>" type="text" |
|
1323 | + <input class="give-input<?php echo (give_logged_in_only($form_id)) ? ' required' : ''; ?>" type="text" |
|
1324 | 1324 | name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" value="" |
1325 | - placeholder="<?php _e( 'Your username', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
1325 | + placeholder="<?php _e('Your username', 'give'); ?>"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
1326 | 1326 | </div> |
1327 | 1327 | |
1328 | 1328 | <div id="give-user-pass-wrap-<?php echo $form_id; ?>" |
1329 | 1329 | class="give_login_password form-row form-row-last form-row-responsive"> |
1330 | 1330 | <label class="give-label" for="give-user-pass-<?php echo $form_id; ?>"> |
1331 | - <?php _e( 'Password', 'give' ); ?> |
|
1332 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
1331 | + <?php _e('Password', 'give'); ?> |
|
1332 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
1333 | 1333 | <span class="give-required-indicator">*</span> |
1334 | 1334 | <?php } ?> |
1335 | 1335 | </label> |
1336 | - <input class="give-input<?php echo ( give_logged_in_only( $form_id ) ) ? ' required' : ''; ?>" |
|
1336 | + <input class="give-input<?php echo (give_logged_in_only($form_id)) ? ' required' : ''; ?>" |
|
1337 | 1337 | type="password" name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" |
1338 | - placeholder="<?php _e( 'Your password', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
1338 | + placeholder="<?php _e('Your password', 'give'); ?>"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
1339 | 1339 | <input type="hidden" name="give-purchase-var" value="needs-to-login"/> |
1340 | 1340 | </div> |
1341 | 1341 | |
1342 | 1342 | <div id="give-forgot-password-wrap-<?php echo $form_id; ?>" class="give_login_forgot_password"> |
1343 | 1343 | <span class="give-forgot-password "> |
1344 | 1344 | <a href="<?php echo wp_lostpassword_url() ?>" |
1345 | - target="_blank"><?php _e( 'Reset Password', 'give' ) ?></a> |
|
1345 | + target="_blank"><?php _e('Reset Password', 'give') ?></a> |
|
1346 | 1346 | </span> |
1347 | 1347 | </div> |
1348 | 1348 | |
1349 | 1349 | <div id="give-user-login-submit-<?php echo $form_id; ?>" class="give-clearfix"> |
1350 | 1350 | <input type="submit" class="give-submit give-btn button" name="give_login_submit" |
1351 | - value="<?php _e( 'Login', 'give' ); ?>"/> |
|
1352 | - <?php if ( $show_register_form !== 'login' ) { ?> |
|
1351 | + value="<?php _e('Login', 'give'); ?>"/> |
|
1352 | + <?php if ($show_register_form !== 'login') { ?> |
|
1353 | 1353 | <input type="button" data-action="give_cancel_login" |
1354 | 1354 | class="give-cancel-login give-checkout-register-cancel give-btn button" name="give_login_cancel" |
1355 | - value="<?php _e( 'Cancel', 'give' ); ?>"/> |
|
1355 | + value="<?php _e('Cancel', 'give'); ?>"/> |
|
1356 | 1356 | <?php } ?> |
1357 | 1357 | <span class="give-loading-animation"></span> |
1358 | 1358 | </div> |
@@ -1364,14 +1364,14 @@ discard block |
||
1364 | 1364 | * |
1365 | 1365 | * @param int $form_id The form ID. |
1366 | 1366 | */ |
1367 | - do_action( 'give_checkout_login_fields_after', $form_id ); |
|
1367 | + do_action('give_checkout_login_fields_after', $form_id); |
|
1368 | 1368 | ?> |
1369 | 1369 | </fieldset><!--end #give-login-fields--> |
1370 | 1370 | <?php |
1371 | 1371 | echo ob_get_clean(); |
1372 | 1372 | } |
1373 | 1373 | |
1374 | -add_action( 'give_donation_form_login_fields', 'give_get_login_fields', 10, 1 ); |
|
1374 | +add_action('give_donation_form_login_fields', 'give_get_login_fields', 10, 1); |
|
1375 | 1375 | |
1376 | 1376 | /** |
1377 | 1377 | * Payment Mode Select. |
@@ -1387,10 +1387,10 @@ discard block |
||
1387 | 1387 | * |
1388 | 1388 | * @return void |
1389 | 1389 | */ |
1390 | -function give_payment_mode_select( $form_id, $args ) { |
|
1390 | +function give_payment_mode_select($form_id, $args) { |
|
1391 | 1391 | |
1392 | - $gateways = give_get_enabled_payment_gateways( $form_id ); |
|
1393 | - $id_prefix = ! empty( $args['id_prefix'] ) ? $args['id_prefix'] : ''; |
|
1392 | + $gateways = give_get_enabled_payment_gateways($form_id); |
|
1393 | + $id_prefix = ! empty($args['id_prefix']) ? $args['id_prefix'] : ''; |
|
1394 | 1394 | |
1395 | 1395 | /** |
1396 | 1396 | * Fires while selecting payment gateways, before the fields. |
@@ -1399,10 +1399,10 @@ discard block |
||
1399 | 1399 | * |
1400 | 1400 | * @param int $form_id The form ID. |
1401 | 1401 | */ |
1402 | - do_action( 'give_payment_mode_top', $form_id ); |
|
1402 | + do_action('give_payment_mode_top', $form_id); |
|
1403 | 1403 | ?> |
1404 | 1404 | |
1405 | - <fieldset id="give-payment-mode-select" <?php if ( count( $gateways ) <= 1 ) { |
|
1405 | + <fieldset id="give-payment-mode-select" <?php if (count($gateways) <= 1) { |
|
1406 | 1406 | echo 'style="display: none;"'; |
1407 | 1407 | } ?>> |
1408 | 1408 | <?php |
@@ -1413,10 +1413,10 @@ discard block |
||
1413 | 1413 | * |
1414 | 1414 | * @param int $form_id The form ID. |
1415 | 1415 | */ |
1416 | - do_action( 'give_payment_mode_before_gateways_wrap' ); |
|
1416 | + do_action('give_payment_mode_before_gateways_wrap'); |
|
1417 | 1417 | ?> |
1418 | 1418 | <legend |
1419 | - class="give-payment-mode-label"><?php echo apply_filters( 'give_checkout_payment_method_text', esc_html__( 'Select Payment Method', 'give' ) ); ?> |
|
1419 | + class="give-payment-mode-label"><?php echo apply_filters('give_checkout_payment_method_text', esc_html__('Select Payment Method', 'give')); ?> |
|
1420 | 1420 | <span class="give-loading-text"><span |
1421 | 1421 | class="give-loading-animation"></span> |
1422 | 1422 | </span> |
@@ -1429,37 +1429,36 @@ discard block |
||
1429 | 1429 | * |
1430 | 1430 | * @since 1.7 |
1431 | 1431 | */ |
1432 | - do_action( 'give_payment_mode_before_gateways' ) |
|
1432 | + do_action('give_payment_mode_before_gateways') |
|
1433 | 1433 | ?> |
1434 | 1434 | <ul id="give-gateway-radio-list"> |
1435 | 1435 | <?php |
1436 | 1436 | /** |
1437 | 1437 | * Loop through the active payment gateways. |
1438 | 1438 | */ |
1439 | - $selected_gateway = give_get_chosen_gateway( $form_id ); |
|
1439 | + $selected_gateway = give_get_chosen_gateway($form_id); |
|
1440 | 1440 | $give_settings = give_get_settings(); |
1441 | - $gateways_label = array_key_exists( 'gateways_label', $give_settings ) ? |
|
1442 | - $give_settings['gateways_label'] : |
|
1443 | - array(); |
|
1441 | + $gateways_label = array_key_exists('gateways_label', $give_settings) ? |
|
1442 | + $give_settings['gateways_label'] : array(); |
|
1444 | 1443 | |
1445 | - foreach ( $gateways as $gateway_id => $gateway ) : |
|
1444 | + foreach ($gateways as $gateway_id => $gateway) : |
|
1446 | 1445 | //Determine the default gateway. |
1447 | - $checked = checked( $gateway_id, $selected_gateway, false ); |
|
1446 | + $checked = checked($gateway_id, $selected_gateway, false); |
|
1448 | 1447 | $checked_class = $checked ? ' class="give-gateway-option-selected"' : ''; ?> |
1449 | 1448 | <li<?php echo $checked_class ?>> |
1450 | 1449 | <input type="radio" name="payment-mode" class="give-gateway" |
1451 | - id="give-gateway-<?php echo esc_attr( $gateway_id . '-' . $id_prefix ); ?>" |
|
1452 | - value="<?php echo esc_attr( $gateway_id ); ?>"<?php echo $checked; ?>> |
|
1450 | + id="give-gateway-<?php echo esc_attr($gateway_id.'-'.$id_prefix); ?>" |
|
1451 | + value="<?php echo esc_attr($gateway_id); ?>"<?php echo $checked; ?>> |
|
1453 | 1452 | |
1454 | 1453 | <?php |
1455 | 1454 | $label = $gateway['checkout_label']; |
1456 | - if ( ! empty( $gateways_label[ $gateway_id ] ) ) { |
|
1457 | - $label = $gateways_label[ $gateway_id ]; |
|
1455 | + if ( ! empty($gateways_label[$gateway_id])) { |
|
1456 | + $label = $gateways_label[$gateway_id]; |
|
1458 | 1457 | } |
1459 | 1458 | ?> |
1460 | - <label for="give-gateway-<?php echo esc_attr( $gateway_id . '-' . $id_prefix ); ?>" |
|
1459 | + <label for="give-gateway-<?php echo esc_attr($gateway_id.'-'.$id_prefix); ?>" |
|
1461 | 1460 | class="give-gateway-option" |
1462 | - id="give-gateway-option-<?php echo esc_attr( $gateway_id ); ?>"> <?php echo esc_html( $label ); ?></label> |
|
1461 | + id="give-gateway-option-<?php echo esc_attr($gateway_id); ?>"> <?php echo esc_html($label); ?></label> |
|
1463 | 1462 | </li> |
1464 | 1463 | <?php |
1465 | 1464 | endforeach; |
@@ -1471,7 +1470,7 @@ discard block |
||
1471 | 1470 | * |
1472 | 1471 | * @since 1.7 |
1473 | 1472 | */ |
1474 | - do_action( 'give_payment_mode_after_gateways' ); |
|
1473 | + do_action('give_payment_mode_after_gateways'); |
|
1475 | 1474 | ?> |
1476 | 1475 | </div> |
1477 | 1476 | <?php |
@@ -1482,7 +1481,7 @@ discard block |
||
1482 | 1481 | * |
1483 | 1482 | * @param int $form_id The form ID. |
1484 | 1483 | */ |
1485 | - do_action( 'give_payment_mode_after_gateways_wrap' ); |
|
1484 | + do_action('give_payment_mode_after_gateways_wrap'); |
|
1486 | 1485 | ?> |
1487 | 1486 | </fieldset> |
1488 | 1487 | |
@@ -1494,7 +1493,7 @@ discard block |
||
1494 | 1493 | * |
1495 | 1494 | * @param int $form_id The form ID. |
1496 | 1495 | */ |
1497 | - do_action( 'give_payment_mode_bottom', $form_id ); |
|
1496 | + do_action('give_payment_mode_bottom', $form_id); |
|
1498 | 1497 | ?> |
1499 | 1498 | |
1500 | 1499 | <div id="give_purchase_form_wrap"> |
@@ -1505,7 +1504,7 @@ discard block |
||
1505 | 1504 | * |
1506 | 1505 | * @since 1.7 |
1507 | 1506 | */ |
1508 | - do_action( 'give_donation_form', $form_id, $args ); |
|
1507 | + do_action('give_donation_form', $form_id, $args); |
|
1509 | 1508 | ?> |
1510 | 1509 | |
1511 | 1510 | </div> |
@@ -1516,10 +1515,10 @@ discard block |
||
1516 | 1515 | * |
1517 | 1516 | * @since 1.7 |
1518 | 1517 | */ |
1519 | - do_action( 'give_donation_form_wrap_bottom', $form_id ); |
|
1518 | + do_action('give_donation_form_wrap_bottom', $form_id); |
|
1520 | 1519 | } |
1521 | 1520 | |
1522 | -add_action( 'give_payment_mode_select', 'give_payment_mode_select', 10, 2 ); |
|
1521 | +add_action('give_payment_mode_select', 'give_payment_mode_select', 10, 2); |
|
1523 | 1522 | |
1524 | 1523 | /** |
1525 | 1524 | * Renders the Checkout Agree to Terms, this displays a checkbox for users to |
@@ -1532,31 +1531,31 @@ discard block |
||
1532 | 1531 | * |
1533 | 1532 | * @return bool |
1534 | 1533 | */ |
1535 | -function give_terms_agreement( $form_id ) { |
|
1536 | - $form_option = give_get_meta( $form_id, '_give_terms_option', true ); |
|
1534 | +function give_terms_agreement($form_id) { |
|
1535 | + $form_option = give_get_meta($form_id, '_give_terms_option', true); |
|
1537 | 1536 | |
1538 | 1537 | // Bailout if per form and global term and conditions is not setup. |
1539 | 1538 | if ( |
1540 | - give_is_setting_enabled( $form_option, 'global' ) |
|
1541 | - && give_is_setting_enabled( give_get_option( 'terms' ) ) |
|
1539 | + give_is_setting_enabled($form_option, 'global') |
|
1540 | + && give_is_setting_enabled(give_get_option('terms')) |
|
1542 | 1541 | ) { |
1543 | - $label = give_get_option( 'agree_to_terms_label', esc_html__( 'Agree to Terms?', 'give' ) ); |
|
1544 | - $terms = $terms = give_get_option( 'agreement_text', '' ); |
|
1545 | - $edit_term_url = admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=display§ion=term-and-conditions' ); |
|
1542 | + $label = give_get_option('agree_to_terms_label', esc_html__('Agree to Terms?', 'give')); |
|
1543 | + $terms = $terms = give_get_option('agreement_text', ''); |
|
1544 | + $edit_term_url = admin_url('edit.php?post_type=give_forms&page=give-settings&tab=display§ion=term-and-conditions'); |
|
1546 | 1545 | |
1547 | - } elseif ( give_is_setting_enabled( $form_option ) ) { |
|
1548 | - $label = ( $label = give_get_meta( $form_id, '_give_agree_label', true ) ) ? stripslashes( $label ) : esc_html__( 'Agree to Terms?', 'give' ); |
|
1549 | - $terms = give_get_meta( $form_id, '_give_agree_text', true ); |
|
1550 | - $edit_term_url = admin_url( 'post.php?post=' . $form_id . '&action=edit#form_terms_options' ); |
|
1546 | + } elseif (give_is_setting_enabled($form_option)) { |
|
1547 | + $label = ($label = give_get_meta($form_id, '_give_agree_label', true)) ? stripslashes($label) : esc_html__('Agree to Terms?', 'give'); |
|
1548 | + $terms = give_get_meta($form_id, '_give_agree_text', true); |
|
1549 | + $edit_term_url = admin_url('post.php?post='.$form_id.'&action=edit#form_terms_options'); |
|
1551 | 1550 | |
1552 | 1551 | } else { |
1553 | 1552 | return false; |
1554 | 1553 | } |
1555 | 1554 | |
1556 | 1555 | // Bailout: Check if term and conditions text is empty or not. |
1557 | - if ( empty( $terms ) ) { |
|
1558 | - if ( is_user_logged_in() && current_user_can( 'edit_give_forms' ) ) { |
|
1559 | - echo sprintf( __( 'Please enter valid terms and conditions in <a href="%s">this form\'s settings</a>.', 'give' ), $edit_term_url ); |
|
1556 | + if (empty($terms)) { |
|
1557 | + if (is_user_logged_in() && current_user_can('edit_give_forms')) { |
|
1558 | + echo sprintf(__('Please enter valid terms and conditions in <a href="%s">this form\'s settings</a>.', 'give'), $edit_term_url); |
|
1560 | 1559 | } |
1561 | 1560 | |
1562 | 1561 | return false; |
@@ -1564,7 +1563,7 @@ discard block |
||
1564 | 1563 | |
1565 | 1564 | ?> |
1566 | 1565 | <fieldset id="give_terms_agreement"> |
1567 | - <legend><?php echo apply_filters( 'give_terms_agreement_text', esc_html__( 'Terms', 'give' ) ); ?></legend> |
|
1566 | + <legend><?php echo apply_filters('give_terms_agreement_text', esc_html__('Terms', 'give')); ?></legend> |
|
1568 | 1567 | <div id="give_terms" class="give_terms-<?php echo $form_id; ?>" style="display:none;"> |
1569 | 1568 | <?php |
1570 | 1569 | /** |
@@ -1572,22 +1571,22 @@ discard block |
||
1572 | 1571 | * |
1573 | 1572 | * @since 1.0 |
1574 | 1573 | */ |
1575 | - do_action( 'give_before_terms' ); |
|
1574 | + do_action('give_before_terms'); |
|
1576 | 1575 | |
1577 | - echo wpautop( stripslashes( $terms ) ); |
|
1576 | + echo wpautop(stripslashes($terms)); |
|
1578 | 1577 | /** |
1579 | 1578 | * Fires while rendering terms of agreement, after the fields. |
1580 | 1579 | * |
1581 | 1580 | * @since 1.0 |
1582 | 1581 | */ |
1583 | - do_action( 'give_after_terms' ); |
|
1582 | + do_action('give_after_terms'); |
|
1584 | 1583 | ?> |
1585 | 1584 | </div> |
1586 | 1585 | <div id="give_show_terms"> |
1587 | 1586 | <a href="#" class="give_terms_links give_terms_links-<?php echo $form_id; ?>" role="button" |
1588 | - aria-controls="give_terms"><?php esc_html_e( 'Show Terms', 'give' ); ?></a> |
|
1587 | + aria-controls="give_terms"><?php esc_html_e('Show Terms', 'give'); ?></a> |
|
1589 | 1588 | <a href="#" class="give_terms_links give_terms_links-<?php echo $form_id; ?>" role="button" |
1590 | - aria-controls="give_terms" style="display:none;"><?php esc_html_e( 'Hide Terms', 'give' ); ?></a> |
|
1589 | + aria-controls="give_terms" style="display:none;"><?php esc_html_e('Hide Terms', 'give'); ?></a> |
|
1591 | 1590 | </div> |
1592 | 1591 | |
1593 | 1592 | <input name="give_agree_to_terms" class="required" type="checkbox" |
@@ -1598,7 +1597,7 @@ discard block |
||
1598 | 1597 | <?php |
1599 | 1598 | } |
1600 | 1599 | |
1601 | -add_action( 'give_donation_form_after_cc_form', 'give_terms_agreement', 8888, 1 ); |
|
1600 | +add_action('give_donation_form_after_cc_form', 'give_terms_agreement', 8888, 1); |
|
1602 | 1601 | |
1603 | 1602 | /** |
1604 | 1603 | * Checkout Final Total. |
@@ -1611,15 +1610,14 @@ discard block |
||
1611 | 1610 | * |
1612 | 1611 | * @return void |
1613 | 1612 | */ |
1614 | -function give_checkout_final_total( $form_id ) { |
|
1613 | +function give_checkout_final_total($form_id) { |
|
1615 | 1614 | |
1616 | - $total = isset( $_POST['give_total'] ) ? |
|
1617 | - apply_filters( 'give_donation_total', give_maybe_sanitize_amount( $_POST['give_total'] ) ) : |
|
1618 | - give_get_default_form_amount( $form_id ); |
|
1615 | + $total = isset($_POST['give_total']) ? |
|
1616 | + apply_filters('give_donation_total', give_maybe_sanitize_amount($_POST['give_total'])) : give_get_default_form_amount($form_id); |
|
1619 | 1617 | |
1620 | 1618 | |
1621 | 1619 | // Only proceed if give_total available. |
1622 | - if ( empty( $total ) ) { |
|
1620 | + if (empty($total)) { |
|
1623 | 1621 | return; |
1624 | 1622 | } |
1625 | 1623 | ?> |
@@ -1630,19 +1628,19 @@ discard block |
||
1630 | 1628 | * |
1631 | 1629 | * @since 2.0.5 |
1632 | 1630 | */ |
1633 | - do_action( 'give_donation_final_total_label_before', $form_id ); |
|
1631 | + do_action('give_donation_final_total_label_before', $form_id); |
|
1634 | 1632 | ?> |
1635 | 1633 | <span class="give-donation-total-label"> |
1636 | - <?php echo apply_filters( 'give_donation_total_label', esc_html__( 'Donation Total:', 'give' ) ); ?> |
|
1634 | + <?php echo apply_filters('give_donation_total_label', esc_html__('Donation Total:', 'give')); ?> |
|
1637 | 1635 | </span> |
1638 | 1636 | <span class="give-final-total-amount" |
1639 | - data-total="<?php echo give_format_amount( $total, array( 'sanitize' => false ) ); ?>"> |
|
1637 | + data-total="<?php echo give_format_amount($total, array('sanitize' => false)); ?>"> |
|
1640 | 1638 | <?php |
1641 | 1639 | |
1642 | - echo give_currency_filter( give_format_amount( $total, array( |
|
1640 | + echo give_currency_filter(give_format_amount($total, array( |
|
1643 | 1641 | 'sanitize' => false, |
1644 | - 'currency' => give_get_currency( $form_id ), |
|
1645 | - ) ), array( 'currency_code' => give_get_currency( $form_id ) ) ); ?> |
|
1642 | + 'currency' => give_get_currency($form_id), |
|
1643 | + )), array('currency_code' => give_get_currency($form_id))); ?> |
|
1646 | 1644 | </span> |
1647 | 1645 | <?php |
1648 | 1646 | /** |
@@ -1650,13 +1648,13 @@ discard block |
||
1650 | 1648 | * |
1651 | 1649 | * @since 2.0.5 |
1652 | 1650 | */ |
1653 | - do_action( 'give_donation_final_total_label_after', $form_id ); |
|
1651 | + do_action('give_donation_final_total_label_after', $form_id); |
|
1654 | 1652 | ?> |
1655 | 1653 | </p> |
1656 | 1654 | <?php |
1657 | 1655 | } |
1658 | 1656 | |
1659 | -add_action( 'give_donation_form_before_submit', 'give_checkout_final_total', 999 ); |
|
1657 | +add_action('give_donation_form_before_submit', 'give_checkout_final_total', 999); |
|
1660 | 1658 | |
1661 | 1659 | /** |
1662 | 1660 | * Renders the Checkout Submit section. |
@@ -1667,7 +1665,7 @@ discard block |
||
1667 | 1665 | * |
1668 | 1666 | * @return void |
1669 | 1667 | */ |
1670 | -function give_checkout_submit( $form_id ) { |
|
1668 | +function give_checkout_submit($form_id) { |
|
1671 | 1669 | ?> |
1672 | 1670 | <fieldset id="give_purchase_submit" class="give-donation-submit"> |
1673 | 1671 | <?php |
@@ -1676,24 +1674,24 @@ discard block |
||
1676 | 1674 | * |
1677 | 1675 | * @since 1.7 |
1678 | 1676 | */ |
1679 | - do_action( 'give_donation_form_before_submit', $form_id ); |
|
1677 | + do_action('give_donation_form_before_submit', $form_id); |
|
1680 | 1678 | |
1681 | - give_checkout_hidden_fields( $form_id ); |
|
1679 | + give_checkout_hidden_fields($form_id); |
|
1682 | 1680 | |
1683 | - echo give_get_donation_form_submit_button( $form_id ); |
|
1681 | + echo give_get_donation_form_submit_button($form_id); |
|
1684 | 1682 | |
1685 | 1683 | /** |
1686 | 1684 | * Fire after donation form submit. |
1687 | 1685 | * |
1688 | 1686 | * @since 1.7 |
1689 | 1687 | */ |
1690 | - do_action( 'give_donation_form_after_submit', $form_id ); |
|
1688 | + do_action('give_donation_form_after_submit', $form_id); |
|
1691 | 1689 | ?> |
1692 | 1690 | </fieldset> |
1693 | 1691 | <?php |
1694 | 1692 | } |
1695 | 1693 | |
1696 | -add_action( 'give_donation_form_after_cc_form', 'give_checkout_submit', 9999 ); |
|
1694 | +add_action('give_donation_form_after_cc_form', 'give_checkout_submit', 9999); |
|
1697 | 1695 | |
1698 | 1696 | /** |
1699 | 1697 | * Give Donation form submit button. |
@@ -1704,10 +1702,10 @@ discard block |
||
1704 | 1702 | * |
1705 | 1703 | * @return string |
1706 | 1704 | */ |
1707 | -function give_get_donation_form_submit_button( $form_id ) { |
|
1705 | +function give_get_donation_form_submit_button($form_id) { |
|
1708 | 1706 | |
1709 | - $display_label_field = give_get_meta( $form_id, '_give_checkout_label', true ); |
|
1710 | - $display_label = ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) ); |
|
1707 | + $display_label_field = give_get_meta($form_id, '_give_checkout_label', true); |
|
1708 | + $display_label = ( ! empty($display_label_field) ? $display_label_field : esc_html__('Donate Now', 'give')); |
|
1711 | 1709 | ob_start(); |
1712 | 1710 | ?> |
1713 | 1711 | <div class="give-submit-button-wrap give-clearfix"> |
@@ -1716,7 +1714,7 @@ discard block |
||
1716 | 1714 | <span class="give-loading-animation"></span> |
1717 | 1715 | </div> |
1718 | 1716 | <?php |
1719 | - return apply_filters( 'give_donation_form_submit_button', ob_get_clean(), $form_id ); |
|
1717 | + return apply_filters('give_donation_form_submit_button', ob_get_clean(), $form_id); |
|
1720 | 1718 | } |
1721 | 1719 | |
1722 | 1720 | /** |
@@ -1731,22 +1729,22 @@ discard block |
||
1731 | 1729 | * |
1732 | 1730 | * @return mixed |
1733 | 1731 | */ |
1734 | -function give_show_goal_progress( $form_id, $args = array() ) { |
|
1732 | +function give_show_goal_progress($form_id, $args = array()) { |
|
1735 | 1733 | |
1736 | 1734 | ob_start(); |
1737 | - give_get_template( 'shortcode-goal', array( 'form_id' => $form_id, 'args' => $args ) ); |
|
1735 | + give_get_template('shortcode-goal', array('form_id' => $form_id, 'args' => $args)); |
|
1738 | 1736 | |
1739 | 1737 | /** |
1740 | 1738 | * Filter progress bar output |
1741 | 1739 | * |
1742 | 1740 | * @since 2.0 |
1743 | 1741 | */ |
1744 | - echo apply_filters( 'give_goal_output', ob_get_clean(), $form_id, $args ); |
|
1742 | + echo apply_filters('give_goal_output', ob_get_clean(), $form_id, $args); |
|
1745 | 1743 | |
1746 | 1744 | return true; |
1747 | 1745 | } |
1748 | 1746 | |
1749 | -add_action( 'give_pre_form', 'give_show_goal_progress', 10, 2 ); |
|
1747 | +add_action('give_pre_form', 'give_show_goal_progress', 10, 2); |
|
1750 | 1748 | |
1751 | 1749 | /** |
1752 | 1750 | * Show Give Totals Progress. |
@@ -1758,22 +1756,22 @@ discard block |
||
1758 | 1756 | * |
1759 | 1757 | * @return mixed |
1760 | 1758 | */ |
1761 | -function give_show_goal_totals_progress( $total, $total_goal ) { |
|
1759 | +function give_show_goal_totals_progress($total, $total_goal) { |
|
1762 | 1760 | |
1763 | 1761 | // Bail out if total goal is set as an array. |
1764 | - if ( isset( $total_goal ) && is_array( $total_goal ) ) { |
|
1762 | + if (isset($total_goal) && is_array($total_goal)) { |
|
1765 | 1763 | return false; |
1766 | 1764 | } |
1767 | 1765 | |
1768 | 1766 | ob_start(); |
1769 | - give_get_template( 'shortcode-totals-progress', array( 'total' => $total, 'total_goal' => $total_goal ) ); |
|
1767 | + give_get_template('shortcode-totals-progress', array('total' => $total, 'total_goal' => $total_goal)); |
|
1770 | 1768 | |
1771 | - echo apply_filters( 'give_total_progress_output', ob_get_clean() ); |
|
1769 | + echo apply_filters('give_total_progress_output', ob_get_clean()); |
|
1772 | 1770 | |
1773 | 1771 | return true; |
1774 | 1772 | } |
1775 | 1773 | |
1776 | -add_action( 'give_pre_form', 'give_show_goal_totals_progress', 10, 2 ); |
|
1774 | +add_action('give_pre_form', 'give_show_goal_totals_progress', 10, 2); |
|
1777 | 1775 | |
1778 | 1776 | /** |
1779 | 1777 | * Get form content position. |
@@ -1785,10 +1783,10 @@ discard block |
||
1785 | 1783 | * |
1786 | 1784 | * @return mixed|string |
1787 | 1785 | */ |
1788 | -function give_get_form_content_placement( $form_id, $args ) { |
|
1786 | +function give_get_form_content_placement($form_id, $args) { |
|
1789 | 1787 | $show_content = ''; |
1790 | 1788 | |
1791 | - if ( isset( $args['show_content'] ) && ! empty( $args['show_content'] ) ) { |
|
1789 | + if (isset($args['show_content']) && ! empty($args['show_content'])) { |
|
1792 | 1790 | // Content positions. |
1793 | 1791 | $content_placement = array( |
1794 | 1792 | 'above' => 'give_pre_form', |
@@ -1796,18 +1794,18 @@ discard block |
||
1796 | 1794 | ); |
1797 | 1795 | |
1798 | 1796 | // Check if content position already decoded. |
1799 | - if ( in_array( $args['show_content'], $content_placement ) ) { |
|
1797 | + if (in_array($args['show_content'], $content_placement)) { |
|
1800 | 1798 | return $args['show_content']; |
1801 | 1799 | } |
1802 | 1800 | |
1803 | - $show_content = ( 'none' !== $args['show_content'] ? $content_placement[ $args['show_content'] ] : '' ); |
|
1801 | + $show_content = ('none' !== $args['show_content'] ? $content_placement[$args['show_content']] : ''); |
|
1804 | 1802 | |
1805 | - } elseif ( give_is_setting_enabled( give_get_meta( $form_id, '_give_display_content', true ) ) ) { |
|
1806 | - $show_content = give_get_meta( $form_id, '_give_content_placement', true ); |
|
1803 | + } elseif (give_is_setting_enabled(give_get_meta($form_id, '_give_display_content', true))) { |
|
1804 | + $show_content = give_get_meta($form_id, '_give_content_placement', true); |
|
1807 | 1805 | |
1808 | - } elseif ( 'none' !== give_get_meta( $form_id, '_give_content_option', true ) ) { |
|
1806 | + } elseif ('none' !== give_get_meta($form_id, '_give_content_option', true)) { |
|
1809 | 1807 | // Backward compatibility for _give_content_option for v18. |
1810 | - $show_content = give_get_meta( $form_id, '_give_content_option', true ); |
|
1808 | + $show_content = give_get_meta($form_id, '_give_content_option', true); |
|
1811 | 1809 | } |
1812 | 1810 | |
1813 | 1811 | return $show_content; |
@@ -1823,20 +1821,20 @@ discard block |
||
1823 | 1821 | * |
1824 | 1822 | * @return void|bool |
1825 | 1823 | */ |
1826 | -function give_form_content( $form_id, $args ) { |
|
1824 | +function give_form_content($form_id, $args) { |
|
1827 | 1825 | |
1828 | - $show_content = give_get_form_content_placement( $form_id, $args ); |
|
1826 | + $show_content = give_get_form_content_placement($form_id, $args); |
|
1829 | 1827 | |
1830 | 1828 | // Bailout. |
1831 | - if ( empty( $show_content ) ) { |
|
1829 | + if (empty($show_content)) { |
|
1832 | 1830 | return false; |
1833 | 1831 | } |
1834 | 1832 | |
1835 | 1833 | // Add action according to value. |
1836 | - add_action( $show_content, 'give_form_display_content', 10, 2 ); |
|
1834 | + add_action($show_content, 'give_form_display_content', 10, 2); |
|
1837 | 1835 | } |
1838 | 1836 | |
1839 | -add_action( 'give_pre_form_output', 'give_form_content', 10, 2 ); |
|
1837 | +add_action('give_pre_form_output', 'give_form_content', 10, 2); |
|
1840 | 1838 | |
1841 | 1839 | /** |
1842 | 1840 | * Renders Post Form Content. |
@@ -1850,22 +1848,22 @@ discard block |
||
1850 | 1848 | * |
1851 | 1849 | * @return void |
1852 | 1850 | */ |
1853 | -function give_form_display_content( $form_id, $args ) { |
|
1851 | +function give_form_display_content($form_id, $args) { |
|
1854 | 1852 | |
1855 | - $content = wpautop( give_get_meta( $form_id, '_give_form_content', true ) ); |
|
1856 | - $show_content = give_get_form_content_placement( $form_id, $args ); |
|
1853 | + $content = wpautop(give_get_meta($form_id, '_give_form_content', true)); |
|
1854 | + $show_content = give_get_form_content_placement($form_id, $args); |
|
1857 | 1855 | |
1858 | - if ( give_is_setting_enabled( give_get_option( 'the_content_filter' ) ) ) { |
|
1859 | - $content = apply_filters( 'the_content', $content ); |
|
1856 | + if (give_is_setting_enabled(give_get_option('the_content_filter'))) { |
|
1857 | + $content = apply_filters('the_content', $content); |
|
1860 | 1858 | } |
1861 | 1859 | |
1862 | - $output = '<div id="give-form-content-' . $form_id . '" class="give-form-content-wrap ' . $show_content . '-content">' . $content . '</div>'; |
|
1860 | + $output = '<div id="give-form-content-'.$form_id.'" class="give-form-content-wrap '.$show_content.'-content">'.$content.'</div>'; |
|
1863 | 1861 | |
1864 | - echo apply_filters( 'give_form_content_output', $output ); |
|
1862 | + echo apply_filters('give_form_content_output', $output); |
|
1865 | 1863 | |
1866 | 1864 | // remove action to prevent content output on addition forms on page. |
1867 | 1865 | // @see: https://github.com/WordImpress/Give/issues/634. |
1868 | - remove_action( $show_content, 'give_form_display_content' ); |
|
1866 | + remove_action($show_content, 'give_form_display_content'); |
|
1869 | 1867 | } |
1870 | 1868 | |
1871 | 1869 | /** |
@@ -1877,7 +1875,7 @@ discard block |
||
1877 | 1875 | * |
1878 | 1876 | * @return void |
1879 | 1877 | */ |
1880 | -function give_checkout_hidden_fields( $form_id ) { |
|
1878 | +function give_checkout_hidden_fields($form_id) { |
|
1881 | 1879 | |
1882 | 1880 | /** |
1883 | 1881 | * Fires while rendering hidden checkout fields, before the fields. |
@@ -1886,13 +1884,13 @@ discard block |
||
1886 | 1884 | * |
1887 | 1885 | * @param int $form_id The form ID. |
1888 | 1886 | */ |
1889 | - do_action( 'give_hidden_fields_before', $form_id ); |
|
1887 | + do_action('give_hidden_fields_before', $form_id); |
|
1890 | 1888 | |
1891 | - if ( is_user_logged_in() ) { ?> |
|
1889 | + if (is_user_logged_in()) { ?> |
|
1892 | 1890 | <input type="hidden" name="give-user-id" value="<?php echo get_current_user_id(); ?>"/> |
1893 | 1891 | <?php } ?> |
1894 | 1892 | <input type="hidden" name="give_action" value="purchase"/> |
1895 | - <input type="hidden" name="give-gateway" value="<?php echo give_get_chosen_gateway( $form_id ); ?>"/> |
|
1893 | + <input type="hidden" name="give-gateway" value="<?php echo give_get_chosen_gateway($form_id); ?>"/> |
|
1896 | 1894 | <?php |
1897 | 1895 | /** |
1898 | 1896 | * Fires while rendering hidden checkout fields, after the fields. |
@@ -1901,7 +1899,7 @@ discard block |
||
1901 | 1899 | * |
1902 | 1900 | * @param int $form_id The form ID. |
1903 | 1901 | */ |
1904 | - do_action( 'give_hidden_fields_after', $form_id ); |
|
1902 | + do_action('give_hidden_fields_after', $form_id); |
|
1905 | 1903 | |
1906 | 1904 | } |
1907 | 1905 | |
@@ -1916,20 +1914,20 @@ discard block |
||
1916 | 1914 | * |
1917 | 1915 | * @return string $content Filtered content. |
1918 | 1916 | */ |
1919 | -function give_filter_success_page_content( $content ) { |
|
1917 | +function give_filter_success_page_content($content) { |
|
1920 | 1918 | |
1921 | 1919 | $give_options = give_get_settings(); |
1922 | 1920 | |
1923 | - if ( isset( $give_options['success_page'] ) && isset( $_GET['payment-confirmation'] ) && is_page( $give_options['success_page'] ) ) { |
|
1924 | - if ( has_filter( 'give_payment_confirm_' . $_GET['payment-confirmation'] ) ) { |
|
1925 | - $content = apply_filters( 'give_payment_confirm_' . $_GET['payment-confirmation'], $content ); |
|
1921 | + if (isset($give_options['success_page']) && isset($_GET['payment-confirmation']) && is_page($give_options['success_page'])) { |
|
1922 | + if (has_filter('give_payment_confirm_'.$_GET['payment-confirmation'])) { |
|
1923 | + $content = apply_filters('give_payment_confirm_'.$_GET['payment-confirmation'], $content); |
|
1926 | 1924 | } |
1927 | 1925 | } |
1928 | 1926 | |
1929 | 1927 | return $content; |
1930 | 1928 | } |
1931 | 1929 | |
1932 | -add_filter( 'the_content', 'give_filter_success_page_content' ); |
|
1930 | +add_filter('the_content', 'give_filter_success_page_content'); |
|
1933 | 1931 | |
1934 | 1932 | /** |
1935 | 1933 | * Test Mode Frontend Warning. |
@@ -1940,12 +1938,12 @@ discard block |
||
1940 | 1938 | */ |
1941 | 1939 | function give_test_mode_frontend_warning() { |
1942 | 1940 | |
1943 | - if ( give_is_test_mode() ) { |
|
1944 | - echo '<div class="give_error give_warning" id="give_error_test_mode"><p><strong>' . esc_html__( 'Notice:', 'give' ) . '</strong> ' . esc_html__( 'Test mode is enabled. While in test mode no live donations are processed.', 'give' ) . '</p></div>'; |
|
1941 | + if (give_is_test_mode()) { |
|
1942 | + echo '<div class="give_error give_warning" id="give_error_test_mode"><p><strong>'.esc_html__('Notice:', 'give').'</strong> '.esc_html__('Test mode is enabled. While in test mode no live donations are processed.', 'give').'</p></div>'; |
|
1945 | 1943 | } |
1946 | 1944 | } |
1947 | 1945 | |
1948 | -add_action( 'give_pre_form', 'give_test_mode_frontend_warning', 10 ); |
|
1946 | +add_action('give_pre_form', 'give_test_mode_frontend_warning', 10); |
|
1949 | 1947 | |
1950 | 1948 | /** |
1951 | 1949 | * Members-only Form. |
@@ -1959,21 +1957,21 @@ discard block |
||
1959 | 1957 | * |
1960 | 1958 | * @return string |
1961 | 1959 | */ |
1962 | -function give_members_only_form( $final_output, $args ) { |
|
1960 | +function give_members_only_form($final_output, $args) { |
|
1963 | 1961 | |
1964 | - $form_id = isset( $args['form_id'] ) ? $args['form_id'] : 0; |
|
1962 | + $form_id = isset($args['form_id']) ? $args['form_id'] : 0; |
|
1965 | 1963 | |
1966 | 1964 | //Sanity Check: Must have form_id & not be logged in. |
1967 | - if ( empty( $form_id ) || is_user_logged_in() ) { |
|
1965 | + if (empty($form_id) || is_user_logged_in()) { |
|
1968 | 1966 | return $final_output; |
1969 | 1967 | } |
1970 | 1968 | |
1971 | 1969 | //Logged in only and Register / Login set to none. |
1972 | - if ( give_logged_in_only( $form_id ) && give_show_login_register_option( $form_id ) == 'none' ) { |
|
1970 | + if (give_logged_in_only($form_id) && give_show_login_register_option($form_id) == 'none') { |
|
1973 | 1971 | |
1974 | - $final_output = Give()->notices->print_frontend_notice( esc_html__( 'Please log in in order to complete your donation.', 'give' ), false ); |
|
1972 | + $final_output = Give()->notices->print_frontend_notice(esc_html__('Please log in in order to complete your donation.', 'give'), false); |
|
1975 | 1973 | |
1976 | - return apply_filters( 'give_members_only_output', $final_output, $form_id ); |
|
1974 | + return apply_filters('give_members_only_output', $final_output, $form_id); |
|
1977 | 1975 | |
1978 | 1976 | } |
1979 | 1977 | |
@@ -1981,7 +1979,7 @@ discard block |
||
1981 | 1979 | |
1982 | 1980 | } |
1983 | 1981 | |
1984 | -add_filter( 'give_donate_form', 'give_members_only_form', 10, 2 ); |
|
1982 | +add_filter('give_donate_form', 'give_members_only_form', 10, 2); |
|
1985 | 1983 | |
1986 | 1984 | |
1987 | 1985 | /** |
@@ -1993,45 +1991,45 @@ discard block |
||
1993 | 1991 | * @param array $args |
1994 | 1992 | * @param Give_Donate_Form $form |
1995 | 1993 | */ |
1996 | -function __give_form_add_donation_hidden_field( $form_id, $args, $form ) { |
|
1997 | - $id_prefix = ! empty( $args['id_prefix'] ) ? $args['id_prefix'] : ''; |
|
1994 | +function __give_form_add_donation_hidden_field($form_id, $args, $form) { |
|
1995 | + $id_prefix = ! empty($args['id_prefix']) ? $args['id_prefix'] : ''; |
|
1998 | 1996 | ?> |
1999 | 1997 | <input type="hidden" name="give-form-id-prefix" value="<?php echo $id_prefix; ?>"/> |
2000 | - <input type="hidden" name="give-form-id" value="<?php echo intval( $form_id ); ?>"/> |
|
2001 | - <input type="hidden" name="give-form-title" value="<?php echo esc_html( $form->post_title ); ?>"/> |
|
2002 | - <input type="hidden" name="give-current-url" value="<?php echo esc_url( give_get_current_page_url() ); ?>"/> |
|
2003 | - <input type="hidden" name="give-form-url" value="<?php echo esc_url( give_get_current_page_url() ); ?>"/> |
|
1998 | + <input type="hidden" name="give-form-id" value="<?php echo intval($form_id); ?>"/> |
|
1999 | + <input type="hidden" name="give-form-title" value="<?php echo esc_html($form->post_title); ?>"/> |
|
2000 | + <input type="hidden" name="give-current-url" value="<?php echo esc_url(give_get_current_page_url()); ?>"/> |
|
2001 | + <input type="hidden" name="give-form-url" value="<?php echo esc_url(give_get_current_page_url()); ?>"/> |
|
2004 | 2002 | <?php |
2005 | 2003 | // Get the custom option amount. |
2006 | - $custom_amount = give_get_meta( $form_id, '_give_custom_amount', true ); |
|
2004 | + $custom_amount = give_get_meta($form_id, '_give_custom_amount', true); |
|
2007 | 2005 | |
2008 | 2006 | // If custom amount enabled. |
2009 | - if ( give_is_setting_enabled( $custom_amount ) ) { |
|
2007 | + if (give_is_setting_enabled($custom_amount)) { |
|
2010 | 2008 | ?> |
2011 | 2009 | <input type="hidden" name="give-form-minimum" |
2012 | - value="<?php echo give_maybe_sanitize_amount( give_get_form_minimum_price( $form_id ) ); ?>"/> |
|
2010 | + value="<?php echo give_maybe_sanitize_amount(give_get_form_minimum_price($form_id)); ?>"/> |
|
2013 | 2011 | <input type="hidden" name="give-form-maximum" |
2014 | - value="<?php echo give_maybe_sanitize_amount( give_get_form_maximum_price( $form_id ) ); ?>"/> |
|
2012 | + value="<?php echo give_maybe_sanitize_amount(give_get_form_maximum_price($form_id)); ?>"/> |
|
2015 | 2013 | <?php |
2016 | 2014 | } |
2017 | 2015 | |
2018 | 2016 | // WP nonce field. |
2019 | 2017 | echo str_replace( |
2020 | 2018 | '/>', |
2021 | - 'data-time="' . time() . '" data-nonce-life="' . give_get_nonce_life() . '"/>', |
|
2022 | - give_get_nonce_field( "give_donation_form_nonce_{$form_id}", 'give-form-hash', false ) |
|
2019 | + 'data-time="'.time().'" data-nonce-life="'.give_get_nonce_life().'"/>', |
|
2020 | + give_get_nonce_field("give_donation_form_nonce_{$form_id}", 'give-form-hash', false) |
|
2023 | 2021 | ); |
2024 | 2022 | |
2025 | 2023 | // Price ID hidden field for variable (multi-level) donation forms. |
2026 | - if ( give_has_variable_prices( $form_id ) ) { |
|
2024 | + if (give_has_variable_prices($form_id)) { |
|
2027 | 2025 | |
2028 | 2026 | // Get default selected price ID. |
2029 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
2027 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
2030 | 2028 | $price_id = 0; |
2031 | 2029 | |
2032 | 2030 | // Loop through prices. |
2033 | - foreach ( $prices as $price ) { |
|
2034 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
2031 | + foreach ($prices as $price) { |
|
2032 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
2035 | 2033 | $price_id = $price['_give_id']['level_id']; |
2036 | 2034 | }; |
2037 | 2035 | } |
@@ -2044,7 +2042,7 @@ discard block |
||
2044 | 2042 | } |
2045 | 2043 | } |
2046 | 2044 | |
2047 | -add_action( 'give_donation_form_top', '__give_form_add_donation_hidden_field', 0, 3 ); |
|
2045 | +add_action('give_donation_form_top', '__give_form_add_donation_hidden_field', 0, 3); |
|
2048 | 2046 | |
2049 | 2047 | /** |
2050 | 2048 | * Add currency settings on donation form. |
@@ -2056,20 +2054,20 @@ discard block |
||
2056 | 2054 | * |
2057 | 2055 | * @return array |
2058 | 2056 | */ |
2059 | -function __give_form_add_currency_settings( $form_html_tags, $form ) { |
|
2060 | - $form_currency = give_get_currency( $form->ID ); |
|
2061 | - $currency_settings = give_get_currency_formatting_settings( $form_currency ); |
|
2057 | +function __give_form_add_currency_settings($form_html_tags, $form) { |
|
2058 | + $form_currency = give_get_currency($form->ID); |
|
2059 | + $currency_settings = give_get_currency_formatting_settings($form_currency); |
|
2062 | 2060 | |
2063 | 2061 | // Check if currency exist. |
2064 | - if ( empty( $currency_settings ) ) { |
|
2062 | + if (empty($currency_settings)) { |
|
2065 | 2063 | return $form_html_tags; |
2066 | 2064 | } |
2067 | 2065 | |
2068 | - $form_html_tags['data-currency_symbol'] = give_currency_symbol( $form_currency ); |
|
2066 | + $form_html_tags['data-currency_symbol'] = give_currency_symbol($form_currency); |
|
2069 | 2067 | $form_html_tags['data-currency_code'] = $form_currency; |
2070 | 2068 | |
2071 | - if ( ! empty( $currency_settings ) ) { |
|
2072 | - foreach ( $currency_settings as $key => $value ) { |
|
2069 | + if ( ! empty($currency_settings)) { |
|
2070 | + foreach ($currency_settings as $key => $value) { |
|
2073 | 2071 | $form_html_tags["data-{$key}"] = $value; |
2074 | 2072 | } |
2075 | 2073 | } |
@@ -2077,7 +2075,7 @@ discard block |
||
2077 | 2075 | return $form_html_tags; |
2078 | 2076 | } |
2079 | 2077 | |
2080 | -add_filter( 'give_form_html_tags', '__give_form_add_currency_settings', 0, 2 ); |
|
2078 | +add_filter('give_form_html_tags', '__give_form_add_currency_settings', 0, 2); |
|
2081 | 2079 | |
2082 | 2080 | /** |
2083 | 2081 | * Adds classes to progress bar container. |
@@ -2088,7 +2086,7 @@ discard block |
||
2088 | 2086 | * |
2089 | 2087 | * @return string |
2090 | 2088 | */ |
2091 | -function add_give_goal_progress_class( $class_goal ) { |
|
2089 | +function add_give_goal_progress_class($class_goal) { |
|
2092 | 2090 | $class_goal = 'progress progress-striped active'; |
2093 | 2091 | |
2094 | 2092 | return $class_goal; |
@@ -2103,7 +2101,7 @@ discard block |
||
2103 | 2101 | * |
2104 | 2102 | * @return string |
2105 | 2103 | */ |
2106 | -function add_give_goal_progress_bar_class( $class_bar ) { |
|
2104 | +function add_give_goal_progress_bar_class($class_bar) { |
|
2107 | 2105 | $class_bar = 'bar'; |
2108 | 2106 | |
2109 | 2107 | return $class_bar; |
@@ -2120,7 +2118,7 @@ discard block |
||
2120 | 2118 | * |
2121 | 2119 | * @return array |
2122 | 2120 | */ |
2123 | -function add_class_for_form_grid( $class, $id, $args ) { |
|
2121 | +function add_class_for_form_grid($class, $id, $args) { |
|
2124 | 2122 | $class[] = 'give-form-grid-wrap'; |
2125 | 2123 | |
2126 | 2124 | return $class; |
@@ -2135,7 +2133,7 @@ discard block |
||
2135 | 2133 | * |
2136 | 2134 | * @since 2.1 |
2137 | 2135 | */ |
2138 | -function give_is_form_grid_page_hidden_field( $id, $args, $form ) { |
|
2136 | +function give_is_form_grid_page_hidden_field($id, $args, $form) { |
|
2139 | 2137 | echo '<input type="hidden" name="is-form-grid" value="true" />'; |
2140 | 2138 | } |
2141 | 2139 | |
@@ -2150,28 +2148,28 @@ discard block |
||
2150 | 2148 | * @since 2.1 |
2151 | 2149 | * @return string |
2152 | 2150 | */ |
2153 | -function give_redirect_and_popup_form( $redirect, $args ) { |
|
2151 | +function give_redirect_and_popup_form($redirect, $args) { |
|
2154 | 2152 | |
2155 | 2153 | // Check the page has Form Grid. |
2156 | - $is_form_grid = isset( $_POST['is-form-grid'] ) ? give_clean( $_POST['is-form-grid'] ) : ''; |
|
2154 | + $is_form_grid = isset($_POST['is-form-grid']) ? give_clean($_POST['is-form-grid']) : ''; |
|
2157 | 2155 | |
2158 | - if ( 'true' === $is_form_grid ) { |
|
2156 | + if ('true' === $is_form_grid) { |
|
2159 | 2157 | |
2160 | - $payment_mode = give_clean( $_POST['payment-mode'] ); |
|
2158 | + $payment_mode = give_clean($_POST['payment-mode']); |
|
2161 | 2159 | $form_id = $args['form-id']; |
2162 | 2160 | |
2163 | 2161 | // Get the URL without Query parameters. |
2164 | - $redirect = strtok( $redirect, '?' ); |
|
2162 | + $redirect = strtok($redirect, '?'); |
|
2165 | 2163 | |
2166 | 2164 | // Add query parameters 'form-id' and 'payment-mode'. |
2167 | - $redirect = add_query_arg( array( |
|
2165 | + $redirect = add_query_arg(array( |
|
2168 | 2166 | 'form-id' => $form_id, |
2169 | 2167 | 'payment-mode' => $payment_mode, |
2170 | - ), $redirect ); |
|
2168 | + ), $redirect); |
|
2171 | 2169 | } |
2172 | 2170 | |
2173 | 2171 | // Return the modified URL. |
2174 | 2172 | return $redirect; |
2175 | 2173 | } |
2176 | 2174 | |
2177 | -add_filter( 'give_send_back_to_checkout', 'give_redirect_and_popup_form', 10, 2 ); |
|
2175 | +add_filter('give_send_back_to_checkout', 'give_redirect_and_popup_form', 10, 2); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -23,14 +23,14 @@ discard block |
||
23 | 23 | |
24 | 24 | global $typenow; |
25 | 25 | |
26 | - if ( $typenow != 'give_forms' ) { |
|
26 | + if ($typenow != 'give_forms') { |
|
27 | 27 | return true; |
28 | 28 | } |
29 | 29 | |
30 | 30 | return false; |
31 | 31 | } |
32 | 32 | |
33 | -add_filter( 'give_shortcode_button_condition', 'give_shortcode_button_condition' ); |
|
33 | +add_filter('give_shortcode_button_condition', 'give_shortcode_button_condition'); |
|
34 | 34 | |
35 | 35 | |
36 | 36 | /** |
@@ -40,11 +40,11 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @return int|false |
42 | 42 | */ |
43 | -function get_form_id_from_args( $args ) { |
|
43 | +function get_form_id_from_args($args) { |
|
44 | 44 | |
45 | - if ( isset( $args['form_id'] ) && $args['form_id'] != 0 ) { |
|
45 | + if (isset($args['form_id']) && $args['form_id'] != 0) { |
|
46 | 46 | |
47 | - return intval( $args['form_id'] ); |
|
47 | + return intval($args['form_id']); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | return false; |
@@ -59,23 +59,23 @@ discard block |
||
59 | 59 | * |
60 | 60 | * @return bool |
61 | 61 | */ |
62 | -function give_is_float_labels_enabled( $args ) { |
|
62 | +function give_is_float_labels_enabled($args) { |
|
63 | 63 | |
64 | 64 | $float_labels = ''; |
65 | 65 | |
66 | - if ( ! empty( $args['float_labels'] ) ) { |
|
66 | + if ( ! empty($args['float_labels'])) { |
|
67 | 67 | $float_labels = $args['float_labels']; |
68 | 68 | } |
69 | 69 | |
70 | - if ( empty( $float_labels ) ) { |
|
71 | - $float_labels = give_get_meta( $args['form_id'], '_give_form_floating_labels', true ); |
|
70 | + if (empty($float_labels)) { |
|
71 | + $float_labels = give_get_meta($args['form_id'], '_give_form_floating_labels', true); |
|
72 | 72 | } |
73 | 73 | |
74 | - if ( empty( $float_labels ) || ( 'global' === $float_labels ) ) { |
|
75 | - $float_labels = give_get_option( 'floatlabels', 'disabled' ); |
|
74 | + if (empty($float_labels) || ('global' === $float_labels)) { |
|
75 | + $float_labels = give_get_option('floatlabels', 'disabled'); |
|
76 | 76 | } |
77 | 77 | |
78 | - return give_is_setting_enabled( $float_labels ); |
|
78 | + return give_is_setting_enabled($float_labels); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | $can_checkout = true; |
93 | 93 | |
94 | - return (bool) apply_filters( 'give_can_checkout', $can_checkout ); |
|
94 | + return (bool) apply_filters('give_can_checkout', $can_checkout); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | function give_get_success_page_uri() { |
106 | 106 | $give_options = give_get_settings(); |
107 | 107 | |
108 | - $success_page = isset( $give_options['success_page'] ) ? get_permalink( absint( $give_options['success_page'] ) ) : get_bloginfo( 'url' ); |
|
108 | + $success_page = isset($give_options['success_page']) ? get_permalink(absint($give_options['success_page'])) : get_bloginfo('url'); |
|
109 | 109 | |
110 | - return apply_filters( 'give_get_success_page_uri', $success_page ); |
|
110 | + return apply_filters('give_get_success_page_uri', $success_page); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | */ |
120 | 120 | function give_is_success_page() { |
121 | 121 | $give_options = give_get_settings(); |
122 | - $is_success_page = isset( $give_options['success_page'] ) ? is_page( $give_options['success_page'] ) : false; |
|
122 | + $is_success_page = isset($give_options['success_page']) ? is_page($give_options['success_page']) : false; |
|
123 | 123 | |
124 | - return apply_filters( 'give_is_success_page', $is_success_page ); |
|
124 | + return apply_filters('give_is_success_page', $is_success_page); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -135,17 +135,17 @@ discard block |
||
135 | 135 | * @since 1.0 |
136 | 136 | * @return void |
137 | 137 | */ |
138 | -function give_send_to_success_page( $query_string = null ) { |
|
138 | +function give_send_to_success_page($query_string = null) { |
|
139 | 139 | |
140 | 140 | $redirect = give_get_success_page_uri(); |
141 | 141 | |
142 | - if ( $query_string ) { |
|
142 | + if ($query_string) { |
|
143 | 143 | $redirect .= $query_string; |
144 | 144 | } |
145 | 145 | |
146 | - $gateway = isset( $_REQUEST['give-gateway'] ) ? $_REQUEST['give-gateway'] : ''; |
|
146 | + $gateway = isset($_REQUEST['give-gateway']) ? $_REQUEST['give-gateway'] : ''; |
|
147 | 147 | |
148 | - wp_redirect( apply_filters( 'give_success_page_redirect', $redirect, $gateway, $query_string ) ); |
|
148 | + wp_redirect(apply_filters('give_success_page_redirect', $redirect, $gateway, $query_string)); |
|
149 | 149 | give_die(); |
150 | 150 | } |
151 | 151 | |
@@ -161,19 +161,19 @@ discard block |
||
161 | 161 | * @since 1.0 |
162 | 162 | * @return Void |
163 | 163 | */ |
164 | -function give_send_back_to_checkout( $args = array() ) { |
|
164 | +function give_send_back_to_checkout($args = array()) { |
|
165 | 165 | |
166 | - $url = isset( $_POST['give-current-url'] ) ? sanitize_text_field( $_POST['give-current-url'] ) : ''; |
|
166 | + $url = isset($_POST['give-current-url']) ? sanitize_text_field($_POST['give-current-url']) : ''; |
|
167 | 167 | $form_id = 0; |
168 | 168 | |
169 | 169 | // Set the form_id. |
170 | - if ( isset( $_POST['give-form-id'] ) ) { |
|
171 | - $form_id = sanitize_text_field( $_POST['give-form-id'] ); |
|
170 | + if (isset($_POST['give-form-id'])) { |
|
171 | + $form_id = sanitize_text_field($_POST['give-form-id']); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | // Need a URL to continue. If none, redirect back to single form. |
175 | - if ( empty( $url ) ) { |
|
176 | - wp_safe_redirect( get_permalink( $form_id ) ); |
|
175 | + if (empty($url)) { |
|
176 | + wp_safe_redirect(get_permalink($form_id)); |
|
177 | 177 | give_die(); |
178 | 178 | } |
179 | 179 | |
@@ -182,41 +182,41 @@ discard block |
||
182 | 182 | ); |
183 | 183 | |
184 | 184 | // Set the $level_id. |
185 | - if ( isset( $_POST['give-price-id'] ) ) { |
|
186 | - $defaults['level-id'] = sanitize_text_field( $_POST['give-price-id'] ); |
|
185 | + if (isset($_POST['give-price-id'])) { |
|
186 | + $defaults['level-id'] = sanitize_text_field($_POST['give-price-id']); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | // Check for backward compatibility. |
190 | - if ( is_string( $args ) ) { |
|
191 | - $args = str_replace( '?', '', $args ); |
|
190 | + if (is_string($args)) { |
|
191 | + $args = str_replace('?', '', $args); |
|
192 | 192 | } |
193 | 193 | |
194 | - $args = wp_parse_args( $args, $defaults ); |
|
194 | + $args = wp_parse_args($args, $defaults); |
|
195 | 195 | |
196 | 196 | // Merge URL query with $args to maintain third-party URL parameters after redirect. |
197 | - $url_data = wp_parse_url( $url ); |
|
197 | + $url_data = wp_parse_url($url); |
|
198 | 198 | |
199 | 199 | // Check if an array to prevent notices before parsing. |
200 | - if ( isset( $url_data['query'] ) && ! empty( $url_data['query'] ) ) { |
|
201 | - parse_str( $url_data['query'], $query ); |
|
200 | + if (isset($url_data['query']) && ! empty($url_data['query'])) { |
|
201 | + parse_str($url_data['query'], $query); |
|
202 | 202 | |
203 | 203 | // Precaution: don't allow any CC info. |
204 | - unset( $query['card_number'] ); |
|
205 | - unset( $query['card_cvc'] ); |
|
204 | + unset($query['card_number']); |
|
205 | + unset($query['card_cvc']); |
|
206 | 206 | |
207 | 207 | } else { |
208 | 208 | // No $url_data so pass empty array. |
209 | 209 | $query = array(); |
210 | 210 | } |
211 | 211 | |
212 | - $new_query = array_merge( $args, $query ); |
|
213 | - $new_query_string = http_build_query( $new_query ); |
|
212 | + $new_query = array_merge($args, $query); |
|
213 | + $new_query_string = http_build_query($new_query); |
|
214 | 214 | |
215 | 215 | // Assemble URL parts. |
216 | - $redirect = home_url( '/' . $url_data['path'] . '?' . $new_query_string . '#give-form-' . $form_id . '-wrap' ); |
|
216 | + $redirect = home_url('/'.$url_data['path'].'?'.$new_query_string.'#give-form-'.$form_id.'-wrap'); |
|
217 | 217 | |
218 | 218 | // Redirect them. |
219 | - wp_safe_redirect( apply_filters( 'give_send_back_to_checkout', $redirect, $args ) ); |
|
219 | + wp_safe_redirect(apply_filters('give_send_back_to_checkout', $redirect, $args)); |
|
220 | 220 | give_die(); |
221 | 221 | |
222 | 222 | } |
@@ -232,16 +232,16 @@ discard block |
||
232 | 232 | * @since 1.0 |
233 | 233 | * @return string |
234 | 234 | */ |
235 | -function give_get_success_page_url( $query_string = null ) { |
|
235 | +function give_get_success_page_url($query_string = null) { |
|
236 | 236 | |
237 | - $success_page = give_get_option( 'success_page', 0 ); |
|
238 | - $success_page = get_permalink( $success_page ); |
|
237 | + $success_page = give_get_option('success_page', 0); |
|
238 | + $success_page = get_permalink($success_page); |
|
239 | 239 | |
240 | - if ( $query_string ) { |
|
240 | + if ($query_string) { |
|
241 | 241 | $success_page .= $query_string; |
242 | 242 | } |
243 | 243 | |
244 | - return apply_filters( 'give_success_page_url', $success_page ); |
|
244 | + return apply_filters('give_success_page_url', $success_page); |
|
245 | 245 | |
246 | 246 | } |
247 | 247 | |
@@ -254,32 +254,31 @@ discard block |
||
254 | 254 | * |
255 | 255 | * @return mixed Full URL to the Failed Donation Page, if present, home page if it doesn't exist. |
256 | 256 | */ |
257 | -function give_get_failed_transaction_uri( $extras = false ) { |
|
257 | +function give_get_failed_transaction_uri($extras = false) { |
|
258 | 258 | $give_options = give_get_settings(); |
259 | 259 | |
260 | 260 | // Remove question mark. |
261 | - if ( 0 === strpos( $extras, '?' ) ) { |
|
262 | - $extras = substr( $extras, 1 ); |
|
261 | + if (0 === strpos($extras, '?')) { |
|
262 | + $extras = substr($extras, 1); |
|
263 | 263 | } |
264 | 264 | |
265 | - $extras_args = wp_parse_args( $extras ); |
|
265 | + $extras_args = wp_parse_args($extras); |
|
266 | 266 | |
267 | 267 | // Set nonce if payment id exist in extra params. |
268 | - if ( array_key_exists( 'payment-id', $extras_args ) ) { |
|
269 | - $extras_args['_wpnonce'] = wp_create_nonce( "give-failed-donation-{$extras_args['payment-id']}" ); |
|
270 | - $extras = http_build_query( $extras_args ); |
|
268 | + if (array_key_exists('payment-id', $extras_args)) { |
|
269 | + $extras_args['_wpnonce'] = wp_create_nonce("give-failed-donation-{$extras_args['payment-id']}"); |
|
270 | + $extras = http_build_query($extras_args); |
|
271 | 271 | } |
272 | 272 | |
273 | - $uri = ! empty( $give_options['failure_page'] ) ? |
|
274 | - trailingslashit( get_permalink( $give_options['failure_page'] ) ) : |
|
275 | - home_url(); |
|
273 | + $uri = ! empty($give_options['failure_page']) ? |
|
274 | + trailingslashit(get_permalink($give_options['failure_page'])) : home_url(); |
|
276 | 275 | |
277 | 276 | |
278 | - if ( $extras ) { |
|
277 | + if ($extras) { |
|
279 | 278 | $uri .= "?{$extras}"; |
280 | 279 | } |
281 | 280 | |
282 | - return apply_filters( 'give_get_failed_transaction_uri', $uri ); |
|
281 | + return apply_filters('give_get_failed_transaction_uri', $uri); |
|
283 | 282 | } |
284 | 283 | |
285 | 284 | /** |
@@ -290,9 +289,9 @@ discard block |
||
290 | 289 | */ |
291 | 290 | function give_is_failed_transaction_page() { |
292 | 291 | $give_options = give_get_settings(); |
293 | - $ret = isset( $give_options['failure_page'] ) ? is_page( $give_options['failure_page'] ) : false; |
|
292 | + $ret = isset($give_options['failure_page']) ? is_page($give_options['failure_page']) : false; |
|
294 | 293 | |
295 | - return apply_filters( 'give_is_failure_page', $ret ); |
|
294 | + return apply_filters('give_is_failure_page', $ret); |
|
296 | 295 | } |
297 | 296 | |
298 | 297 | /** |
@@ -305,25 +304,25 @@ discard block |
||
305 | 304 | */ |
306 | 305 | function give_listen_for_failed_payments() { |
307 | 306 | |
308 | - $failed_page = give_get_option( 'failure_page', 0 ); |
|
309 | - $payment_id = ! empty( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : 0; |
|
310 | - $nonce = ! empty( $_GET['_wpnonce'] ) ? give_clean( $_GET['_wpnonce'] ) : false; |
|
307 | + $failed_page = give_get_option('failure_page', 0); |
|
308 | + $payment_id = ! empty($_GET['payment-id']) ? absint($_GET['payment-id']) : 0; |
|
309 | + $nonce = ! empty($_GET['_wpnonce']) ? give_clean($_GET['_wpnonce']) : false; |
|
311 | 310 | |
312 | 311 | // Bailout. |
313 | - if ( ! $failed_page || ! is_page( $failed_page ) || ! $payment_id || ! $nonce ) { |
|
312 | + if ( ! $failed_page || ! is_page($failed_page) || ! $payment_id || ! $nonce) { |
|
314 | 313 | return false; |
315 | 314 | } |
316 | 315 | |
317 | 316 | // Security check. |
318 | - if ( ! wp_verify_nonce( $nonce, "give-failed-donation-{$payment_id}" ) ) { |
|
319 | - wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ) ); |
|
317 | + if ( ! wp_verify_nonce($nonce, "give-failed-donation-{$payment_id}")) { |
|
318 | + wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give')); |
|
320 | 319 | } |
321 | 320 | |
322 | 321 | // Set payment status to failure |
323 | - give_update_payment_status( $payment_id, 'failed' ); |
|
322 | + give_update_payment_status($payment_id, 'failed'); |
|
324 | 323 | } |
325 | 324 | |
326 | -add_action( 'template_redirect', 'give_listen_for_failed_payments' ); |
|
325 | +add_action('template_redirect', 'give_listen_for_failed_payments'); |
|
327 | 326 | |
328 | 327 | /** |
329 | 328 | * Retrieve the Donation History page URI |
@@ -336,9 +335,9 @@ discard block |
||
336 | 335 | function give_get_history_page_uri() { |
337 | 336 | $give_options = give_get_settings(); |
338 | 337 | |
339 | - $history_page = isset( $give_options['history_page'] ) ? get_permalink( absint( $give_options['history_page'] ) ) : get_bloginfo( 'url' ); |
|
338 | + $history_page = isset($give_options['history_page']) ? get_permalink(absint($give_options['history_page'])) : get_bloginfo('url'); |
|
340 | 339 | |
341 | - return apply_filters( 'give_get_history_page_uri', $history_page ); |
|
340 | + return apply_filters('give_get_history_page_uri', $history_page); |
|
342 | 341 | } |
343 | 342 | |
344 | 343 | /** |
@@ -351,11 +350,11 @@ discard block |
||
351 | 350 | * @since 1.0 |
352 | 351 | * @return bool |
353 | 352 | */ |
354 | -function give_field_is_required( $field = '', $form_id ) { |
|
353 | +function give_field_is_required($field = '', $form_id) { |
|
355 | 354 | |
356 | - $required_fields = give_get_required_fields( $form_id ); |
|
355 | + $required_fields = give_get_required_fields($form_id); |
|
357 | 356 | |
358 | - return array_key_exists( $field, $required_fields ); |
|
357 | + return array_key_exists($field, $required_fields); |
|
359 | 358 | } |
360 | 359 | |
361 | 360 | /** |
@@ -372,12 +371,12 @@ discard block |
||
372 | 371 | * |
373 | 372 | * @return void |
374 | 373 | */ |
375 | -function give_record_donation_in_log( $give_form_id = 0, $payment_id, $price_id = false, $donation_date = null ) { |
|
374 | +function give_record_donation_in_log($give_form_id = 0, $payment_id, $price_id = false, $donation_date = null) { |
|
376 | 375 | $log_data = array( |
377 | 376 | 'log_parent' => $payment_id, |
378 | 377 | 'log_type' => 'sale', |
379 | - 'log_date' => isset( $donation_date ) ? $donation_date : null, |
|
380 | - 'log_date_gmt' => isset( $donation_date ) ? $donation_date : null, |
|
378 | + 'log_date' => isset($donation_date) ? $donation_date : null, |
|
379 | + 'log_date_gmt' => isset($donation_date) ? $donation_date : null, |
|
381 | 380 | ); |
382 | 381 | |
383 | 382 | $log_meta = array( |
@@ -385,7 +384,7 @@ discard block |
||
385 | 384 | 'price_id' => (int) $price_id, |
386 | 385 | ); |
387 | 386 | |
388 | - Give()->logs->insert_log( $log_data, $log_meta ); |
|
387 | + Give()->logs->insert_log($log_data, $log_meta); |
|
389 | 388 | } |
390 | 389 | |
391 | 390 | |
@@ -399,13 +398,13 @@ discard block |
||
399 | 398 | * |
400 | 399 | * @return bool|int |
401 | 400 | */ |
402 | -function give_increase_donation_count( $form_id = 0, $quantity = 1 ) { |
|
401 | +function give_increase_donation_count($form_id = 0, $quantity = 1) { |
|
403 | 402 | $quantity = (int) $quantity; |
404 | 403 | |
405 | 404 | /** @var \Give_Donate_Form $form */ |
406 | - $form = new Give_Donate_Form( $form_id ); |
|
405 | + $form = new Give_Donate_Form($form_id); |
|
407 | 406 | |
408 | - return $form->increase_sales( $quantity ); |
|
407 | + return $form->increase_sales($quantity); |
|
409 | 408 | } |
410 | 409 | |
411 | 410 | /** |
@@ -418,13 +417,13 @@ discard block |
||
418 | 417 | * |
419 | 418 | * @return bool|int |
420 | 419 | */ |
421 | -function give_decrease_donation_count( $form_id = 0, $quantity = 1 ) { |
|
420 | +function give_decrease_donation_count($form_id = 0, $quantity = 1) { |
|
422 | 421 | $quantity = (int) $quantity; |
423 | 422 | |
424 | 423 | /** @var \Give_Donate_Form $form */ |
425 | - $form = new Give_Donate_Form( $form_id ); |
|
424 | + $form = new Give_Donate_Form($form_id); |
|
426 | 425 | |
427 | - return $form->decrease_sales( $quantity ); |
|
426 | + return $form->decrease_sales($quantity); |
|
428 | 427 | } |
429 | 428 | |
430 | 429 | /** |
@@ -440,11 +439,11 @@ discard block |
||
440 | 439 | * |
441 | 440 | * @return bool|int |
442 | 441 | */ |
443 | -function give_increase_earnings( $give_form_id = 0, $amount, $payment_id = 0 ) { |
|
442 | +function give_increase_earnings($give_form_id = 0, $amount, $payment_id = 0) { |
|
444 | 443 | /** @var \Give_Donate_Form $form */ |
445 | - $form = new Give_Donate_Form( $give_form_id ); |
|
444 | + $form = new Give_Donate_Form($give_form_id); |
|
446 | 445 | |
447 | - return $form->increase_earnings( $amount, $payment_id ); |
|
446 | + return $form->increase_earnings($amount, $payment_id); |
|
448 | 447 | } |
449 | 448 | |
450 | 449 | /** |
@@ -462,11 +461,11 @@ discard block |
||
462 | 461 | * |
463 | 462 | * @return bool|int |
464 | 463 | */ |
465 | -function give_decrease_form_earnings( $form_id = 0, $amount, $payment_id = 0 ) { |
|
464 | +function give_decrease_form_earnings($form_id = 0, $amount, $payment_id = 0) { |
|
466 | 465 | /** @var \Give_Donate_Form $form */ |
467 | - $form = new Give_Donate_Form( $form_id ); |
|
466 | + $form = new Give_Donate_Form($form_id); |
|
468 | 467 | |
469 | - return $form->decrease_earnings( $amount, $payment_id ); |
|
468 | + return $form->decrease_earnings($amount, $payment_id); |
|
470 | 469 | } |
471 | 470 | |
472 | 471 | |
@@ -479,15 +478,15 @@ discard block |
||
479 | 478 | * |
480 | 479 | * @return int $earnings Earnings for a certain form |
481 | 480 | */ |
482 | -function give_get_form_earnings_stats( $form_id = 0 ) { |
|
483 | - $give_form = new Give_Donate_Form( $form_id ); |
|
481 | +function give_get_form_earnings_stats($form_id = 0) { |
|
482 | + $give_form = new Give_Donate_Form($form_id); |
|
484 | 483 | |
485 | 484 | /** |
486 | 485 | * Filter the form earnings |
487 | 486 | * |
488 | 487 | * @since 1.8.17 |
489 | 488 | */ |
490 | - return apply_filters( 'give_get_form_earnings_stats', $give_form->earnings, $form_id, $give_form ); |
|
489 | + return apply_filters('give_get_form_earnings_stats', $give_form->earnings, $form_id, $give_form); |
|
491 | 490 | } |
492 | 491 | |
493 | 492 | |
@@ -500,8 +499,8 @@ discard block |
||
500 | 499 | * |
501 | 500 | * @return int $sales Amount of sales for a certain form |
502 | 501 | */ |
503 | -function give_get_form_sales_stats( $give_form_id = 0 ) { |
|
504 | - $give_form = new Give_Donate_Form( $give_form_id ); |
|
502 | +function give_get_form_sales_stats($give_form_id = 0) { |
|
503 | + $give_form = new Give_Donate_Form($give_form_id); |
|
505 | 504 | |
506 | 505 | return $give_form->sales; |
507 | 506 | } |
@@ -516,16 +515,16 @@ discard block |
||
516 | 515 | * |
517 | 516 | * @return float $sales Average monthly sales |
518 | 517 | */ |
519 | -function give_get_average_monthly_form_sales( $form_id = 0 ) { |
|
520 | - $sales = give_get_form_sales_stats( $form_id ); |
|
521 | - $release_date = get_post_field( 'post_date', $form_id ); |
|
518 | +function give_get_average_monthly_form_sales($form_id = 0) { |
|
519 | + $sales = give_get_form_sales_stats($form_id); |
|
520 | + $release_date = get_post_field('post_date', $form_id); |
|
522 | 521 | |
523 | - $diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) ); |
|
522 | + $diff = abs(current_time('timestamp') - strtotime($release_date)); |
|
524 | 523 | |
525 | - $months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication |
|
524 | + $months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication |
|
526 | 525 | |
527 | - if ( $months > 0 ) { |
|
528 | - $sales = ( $sales / $months ); |
|
526 | + if ($months > 0) { |
|
527 | + $sales = ($sales / $months); |
|
529 | 528 | } |
530 | 529 | |
531 | 530 | return $sales; |
@@ -541,16 +540,16 @@ discard block |
||
541 | 540 | * |
542 | 541 | * @return float $earnings Average monthly earnings |
543 | 542 | */ |
544 | -function give_get_average_monthly_form_earnings( $form_id = 0 ) { |
|
545 | - $earnings = give_get_form_earnings_stats( $form_id ); |
|
546 | - $release_date = get_post_field( 'post_date', $form_id ); |
|
543 | +function give_get_average_monthly_form_earnings($form_id = 0) { |
|
544 | + $earnings = give_get_form_earnings_stats($form_id); |
|
545 | + $release_date = get_post_field('post_date', $form_id); |
|
547 | 546 | |
548 | - $diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) ); |
|
547 | + $diff = abs(current_time('timestamp') - strtotime($release_date)); |
|
549 | 548 | |
550 | - $months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication |
|
549 | + $months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication |
|
551 | 550 | |
552 | - if ( $months > 0 ) { |
|
553 | - $earnings = ( $earnings / $months ); |
|
551 | + if ($months > 0) { |
|
552 | + $earnings = ($earnings / $months); |
|
554 | 553 | } |
555 | 554 | |
556 | 555 | return $earnings < 0 ? 0 : $earnings; |
@@ -571,34 +570,34 @@ discard block |
||
571 | 570 | * |
572 | 571 | * @return string $price_name Name of the price option |
573 | 572 | */ |
574 | -function give_get_price_option_name( $form_id = 0, $price_id = 0, $payment_id = 0, $use_fallback = true ) { |
|
573 | +function give_get_price_option_name($form_id = 0, $price_id = 0, $payment_id = 0, $use_fallback = true) { |
|
575 | 574 | |
576 | - $prices = give_get_variable_prices( $form_id ); |
|
575 | + $prices = give_get_variable_prices($form_id); |
|
577 | 576 | $price_name = ''; |
578 | 577 | |
579 | - if ( false === $prices ) { |
|
578 | + if (false === $prices) { |
|
580 | 579 | return $price_name; |
581 | 580 | } |
582 | 581 | |
583 | - foreach ( $prices as $price ) { |
|
582 | + foreach ($prices as $price) { |
|
584 | 583 | |
585 | - if ( intval( $price['_give_id']['level_id'] ) === intval( $price_id ) ) { |
|
584 | + if (intval($price['_give_id']['level_id']) === intval($price_id)) { |
|
586 | 585 | |
587 | - $price_text = isset( $price['_give_text'] ) ? $price['_give_text'] : ''; |
|
586 | + $price_text = isset($price['_give_text']) ? $price['_give_text'] : ''; |
|
588 | 587 | $price_fallback = $use_fallback ? |
589 | 588 | give_currency_filter( |
590 | 589 | give_format_amount( |
591 | 590 | $price['_give_amount'], |
592 | - array( 'sanitize' => false ) |
|
591 | + array('sanitize' => false) |
|
593 | 592 | ), |
594 | - array( 'decode_currency' => true ) |
|
593 | + array('decode_currency' => true) |
|
595 | 594 | ) : ''; |
596 | - $price_name = ! empty( $price_text ) ? $price_text : $price_fallback; |
|
595 | + $price_name = ! empty($price_text) ? $price_text : $price_fallback; |
|
597 | 596 | |
598 | 597 | } |
599 | 598 | } |
600 | 599 | |
601 | - return apply_filters( 'give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id ); |
|
600 | + return apply_filters('give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id); |
|
602 | 601 | } |
603 | 602 | |
604 | 603 | |
@@ -612,25 +611,25 @@ discard block |
||
612 | 611 | * |
613 | 612 | * @return string $range A fully formatted price range |
614 | 613 | */ |
615 | -function give_price_range( $form_id = 0, $formatted = true ) { |
|
616 | - $low = give_get_lowest_price_option( $form_id ); |
|
617 | - $high = give_get_highest_price_option( $form_id ); |
|
618 | - $order_type = ! empty( $_REQUEST['order'] ) ? $_REQUEST['order'] : 'asc'; |
|
614 | +function give_price_range($form_id = 0, $formatted = true) { |
|
615 | + $low = give_get_lowest_price_option($form_id); |
|
616 | + $high = give_get_highest_price_option($form_id); |
|
617 | + $order_type = ! empty($_REQUEST['order']) ? $_REQUEST['order'] : 'asc'; |
|
619 | 618 | |
620 | 619 | $range = sprintf( |
621 | 620 | '<span class="give_price_range_%1$s">%2$s</span><span class="give_price_range_sep"> – </span><span class="give_price_range_%3$s">%4$s</span>', |
622 | 621 | 'asc' === $order_type ? 'low' : 'high', |
623 | - 'asc' === $order_type ? give_currency_filter( give_format_amount( $low, array( 'sanitize' => false ) ) ) : give_currency_filter( give_format_amount( $high, array( 'sanitize' => false ) ) ), |
|
622 | + 'asc' === $order_type ? give_currency_filter(give_format_amount($low, array('sanitize' => false))) : give_currency_filter(give_format_amount($high, array('sanitize' => false))), |
|
624 | 623 | 'asc' === $order_type ? 'high' : 'low', |
625 | - 'asc' === $order_type ? give_currency_filter( give_format_amount( $high, array( 'sanitize' => false ) ) ) : give_currency_filter( give_format_amount( $low, array( 'sanitize' => false ) ) ) |
|
624 | + 'asc' === $order_type ? give_currency_filter(give_format_amount($high, array('sanitize' => false))) : give_currency_filter(give_format_amount($low, array('sanitize' => false))) |
|
626 | 625 | |
627 | 626 | ); |
628 | 627 | |
629 | - if ( ! $formatted ) { |
|
630 | - $range = wp_strip_all_tags( $range ); |
|
628 | + if ( ! $formatted) { |
|
629 | + $range = wp_strip_all_tags($range); |
|
631 | 630 | } |
632 | 631 | |
633 | - return apply_filters( 'give_price_range', $range, $form_id, $low, $high ); |
|
632 | + return apply_filters('give_price_range', $range, $form_id, $low, $high); |
|
634 | 633 | } |
635 | 634 | |
636 | 635 | |
@@ -645,35 +644,35 @@ discard block |
||
645 | 644 | * |
646 | 645 | * @return int ID of the lowest price |
647 | 646 | */ |
648 | -function give_get_lowest_price_id( $form_id = 0 ) { |
|
647 | +function give_get_lowest_price_id($form_id = 0) { |
|
649 | 648 | |
650 | - if ( empty( $form_id ) ) { |
|
649 | + if (empty($form_id)) { |
|
651 | 650 | $form_id = get_the_ID(); |
652 | 651 | } |
653 | 652 | |
654 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
655 | - return give_get_form_price( $form_id ); |
|
653 | + if ( ! give_has_variable_prices($form_id)) { |
|
654 | + return give_get_form_price($form_id); |
|
656 | 655 | } |
657 | 656 | |
658 | - $prices = give_get_variable_prices( $form_id ); |
|
657 | + $prices = give_get_variable_prices($form_id); |
|
659 | 658 | |
660 | 659 | $min = $min_id = 0; |
661 | 660 | |
662 | - if ( ! empty( $prices ) ) { |
|
661 | + if ( ! empty($prices)) { |
|
663 | 662 | |
664 | - foreach ( $prices as $key => $price ) { |
|
663 | + foreach ($prices as $key => $price) { |
|
665 | 664 | |
666 | - if ( empty( $price['_give_amount'] ) ) { |
|
665 | + if (empty($price['_give_amount'])) { |
|
667 | 666 | continue; |
668 | 667 | } |
669 | 668 | |
670 | - if ( ! isset( $min ) ) { |
|
669 | + if ( ! isset($min)) { |
|
671 | 670 | $min = $price['_give_amount']; |
672 | 671 | } else { |
673 | - $min = min( $min, $price['_give_amount'] ); |
|
672 | + $min = min($min, $price['_give_amount']); |
|
674 | 673 | } |
675 | 674 | |
676 | - if ( $price['_give_amount'] == $min ) { |
|
675 | + if ($price['_give_amount'] == $min) { |
|
677 | 676 | $min_id = $price['_give_id']['level_id']; |
678 | 677 | } |
679 | 678 | } |
@@ -691,22 +690,22 @@ discard block |
||
691 | 690 | * |
692 | 691 | * @return float Amount of the lowest price |
693 | 692 | */ |
694 | -function give_get_lowest_price_option( $form_id = 0 ) { |
|
695 | - if ( empty( $form_id ) ) { |
|
693 | +function give_get_lowest_price_option($form_id = 0) { |
|
694 | + if (empty($form_id)) { |
|
696 | 695 | $form_id = get_the_ID(); |
697 | 696 | } |
698 | 697 | |
699 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
700 | - return give_get_form_price( $form_id ); |
|
698 | + if ( ! give_has_variable_prices($form_id)) { |
|
699 | + return give_get_form_price($form_id); |
|
701 | 700 | } |
702 | 701 | |
703 | - if ( ! ( $low = get_post_meta( $form_id, '_give_levels_minimum_amount', true ) ) ) { |
|
702 | + if ( ! ($low = get_post_meta($form_id, '_give_levels_minimum_amount', true))) { |
|
704 | 703 | // Backward compatibility. |
705 | - $prices = wp_list_pluck( give_get_variable_prices( $form_id ), '_give_amount' ); |
|
706 | - $low = ! empty( $prices ) ? min( $prices ) : 0; |
|
704 | + $prices = wp_list_pluck(give_get_variable_prices($form_id), '_give_amount'); |
|
705 | + $low = ! empty($prices) ? min($prices) : 0; |
|
707 | 706 | } |
708 | 707 | |
709 | - return give_maybe_sanitize_amount( $low ); |
|
708 | + return give_maybe_sanitize_amount($low); |
|
710 | 709 | } |
711 | 710 | |
712 | 711 | /** |
@@ -718,23 +717,23 @@ discard block |
||
718 | 717 | * |
719 | 718 | * @return float Amount of the highest price |
720 | 719 | */ |
721 | -function give_get_highest_price_option( $form_id = 0 ) { |
|
720 | +function give_get_highest_price_option($form_id = 0) { |
|
722 | 721 | |
723 | - if ( empty( $form_id ) ) { |
|
722 | + if (empty($form_id)) { |
|
724 | 723 | $form_id = get_the_ID(); |
725 | 724 | } |
726 | 725 | |
727 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
728 | - return give_get_form_price( $form_id ); |
|
726 | + if ( ! give_has_variable_prices($form_id)) { |
|
727 | + return give_get_form_price($form_id); |
|
729 | 728 | } |
730 | 729 | |
731 | - if ( ! ( $high = get_post_meta( $form_id, '_give_levels_maximum_amount', true ) ) ) { |
|
730 | + if ( ! ($high = get_post_meta($form_id, '_give_levels_maximum_amount', true))) { |
|
732 | 731 | // Backward compatibility. |
733 | - $prices = wp_list_pluck( give_get_variable_prices( $form_id ), '_give_amount' ); |
|
734 | - $high = ! empty( $prices ) ? max( $prices ) : 0; |
|
732 | + $prices = wp_list_pluck(give_get_variable_prices($form_id), '_give_amount'); |
|
733 | + $high = ! empty($prices) ? max($prices) : 0; |
|
735 | 734 | } |
736 | 735 | |
737 | - return give_maybe_sanitize_amount( $high ); |
|
736 | + return give_maybe_sanitize_amount($high); |
|
738 | 737 | } |
739 | 738 | |
740 | 739 | /** |
@@ -746,15 +745,15 @@ discard block |
||
746 | 745 | * |
747 | 746 | * @return mixed string|int Price of the form |
748 | 747 | */ |
749 | -function give_get_form_price( $form_id = 0 ) { |
|
748 | +function give_get_form_price($form_id = 0) { |
|
750 | 749 | |
751 | - if ( empty( $form_id ) ) { |
|
750 | + if (empty($form_id)) { |
|
752 | 751 | return false; |
753 | 752 | } |
754 | 753 | |
755 | - $form = new Give_Donate_Form( $form_id ); |
|
754 | + $form = new Give_Donate_Form($form_id); |
|
756 | 755 | |
757 | - return $form->__get( 'price' ); |
|
756 | + return $form->__get('price'); |
|
758 | 757 | } |
759 | 758 | |
760 | 759 | /** |
@@ -766,13 +765,13 @@ discard block |
||
766 | 765 | * |
767 | 766 | * @return mixed string|int Minimum price of the form |
768 | 767 | */ |
769 | -function give_get_form_minimum_price( $form_id = 0 ) { |
|
768 | +function give_get_form_minimum_price($form_id = 0) { |
|
770 | 769 | |
771 | - if ( empty( $form_id ) ) { |
|
770 | + if (empty($form_id)) { |
|
772 | 771 | return false; |
773 | 772 | } |
774 | 773 | |
775 | - $form = new Give_Donate_Form( $form_id ); |
|
774 | + $form = new Give_Donate_Form($form_id); |
|
776 | 775 | |
777 | 776 | return $form->get_minimum_price(); |
778 | 777 | |
@@ -787,13 +786,13 @@ discard block |
||
787 | 786 | * |
788 | 787 | * @return bool|float |
789 | 788 | */ |
790 | -function give_get_form_maximum_price( $form_id = 0 ) { |
|
789 | +function give_get_form_maximum_price($form_id = 0) { |
|
791 | 790 | |
792 | - if ( empty( $form_id ) ) { |
|
791 | + if (empty($form_id)) { |
|
793 | 792 | return false; |
794 | 793 | } |
795 | 794 | |
796 | - $form = new Give_Donate_Form( $form_id ); |
|
795 | + $form = new Give_Donate_Form($form_id); |
|
797 | 796 | |
798 | 797 | return $form->get_maximum_price(); |
799 | 798 | } |
@@ -809,48 +808,48 @@ discard block |
||
809 | 808 | * |
810 | 809 | * @return int $formatted_price |
811 | 810 | */ |
812 | -function give_price( $form_id = 0, $echo = true, $price_id = false ) { |
|
811 | +function give_price($form_id = 0, $echo = true, $price_id = false) { |
|
813 | 812 | $price = 0; |
814 | 813 | |
815 | - if ( empty( $form_id ) ) { |
|
814 | + if (empty($form_id)) { |
|
816 | 815 | $form_id = get_the_ID(); |
817 | 816 | } |
818 | 817 | |
819 | - if ( give_has_variable_prices( $form_id ) ) { |
|
818 | + if (give_has_variable_prices($form_id)) { |
|
820 | 819 | |
821 | - $prices = give_get_variable_prices( $form_id ); |
|
820 | + $prices = give_get_variable_prices($form_id); |
|
822 | 821 | |
823 | - if ( false !== $price_id ) { |
|
822 | + if (false !== $price_id) { |
|
824 | 823 | |
825 | 824 | // loop through multi-prices to see which is default |
826 | - foreach ( $prices as $price ) { |
|
825 | + foreach ($prices as $price) { |
|
827 | 826 | // this is the default price |
828 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
827 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
829 | 828 | $price = (float) $price['_give_amount']; |
830 | 829 | }; |
831 | 830 | } |
832 | 831 | } else { |
833 | 832 | |
834 | - $price = give_get_lowest_price_option( $form_id ); |
|
833 | + $price = give_get_lowest_price_option($form_id); |
|
835 | 834 | } |
836 | 835 | } else { |
837 | 836 | |
838 | - $price = give_get_form_price( $form_id ); |
|
837 | + $price = give_get_form_price($form_id); |
|
839 | 838 | } |
840 | 839 | |
841 | - $price = apply_filters( 'give_form_price', give_maybe_sanitize_amount( $price ), $form_id ); |
|
842 | - $formatted_price = '<span class="give_price" id="give_price_' . $form_id . '">' . $price . '</span>'; |
|
843 | - $formatted_price = apply_filters( 'give_form_price_after_html', $formatted_price, $form_id, $price ); |
|
840 | + $price = apply_filters('give_form_price', give_maybe_sanitize_amount($price), $form_id); |
|
841 | + $formatted_price = '<span class="give_price" id="give_price_'.$form_id.'">'.$price.'</span>'; |
|
842 | + $formatted_price = apply_filters('give_form_price_after_html', $formatted_price, $form_id, $price); |
|
844 | 843 | |
845 | - if ( $echo ) { |
|
844 | + if ($echo) { |
|
846 | 845 | echo $formatted_price; |
847 | 846 | } else { |
848 | 847 | return $formatted_price; |
849 | 848 | } |
850 | 849 | } |
851 | 850 | |
852 | -add_filter( 'give_form_price', 'give_format_amount', 10 ); |
|
853 | -add_filter( 'give_form_price', 'give_currency_filter', 20 ); |
|
851 | +add_filter('give_form_price', 'give_format_amount', 10); |
|
852 | +add_filter('give_form_price', 'give_currency_filter', 20); |
|
854 | 853 | |
855 | 854 | |
856 | 855 | /** |
@@ -863,19 +862,19 @@ discard block |
||
863 | 862 | * |
864 | 863 | * @return float $amount Amount of the price option |
865 | 864 | */ |
866 | -function give_get_price_option_amount( $form_id = 0, $price_id = 0 ) { |
|
867 | - $prices = give_get_variable_prices( $form_id ); |
|
865 | +function give_get_price_option_amount($form_id = 0, $price_id = 0) { |
|
866 | + $prices = give_get_variable_prices($form_id); |
|
868 | 867 | |
869 | 868 | $amount = 0.00; |
870 | 869 | |
871 | - foreach ( $prices as $price ) { |
|
872 | - if ( isset( $price['_give_id']['level_id'] ) && $price['_give_id']['level_id'] == $price_id ) { |
|
873 | - $amount = isset( $price['_give_amount'] ) ? $price['_give_amount'] : 0.00; |
|
870 | + foreach ($prices as $price) { |
|
871 | + if (isset($price['_give_id']['level_id']) && $price['_give_id']['level_id'] == $price_id) { |
|
872 | + $amount = isset($price['_give_amount']) ? $price['_give_amount'] : 0.00; |
|
874 | 873 | break; |
875 | 874 | }; |
876 | 875 | } |
877 | 876 | |
878 | - return apply_filters( 'give_get_price_option_amount', give_maybe_sanitize_amount( $amount ), $form_id, $price_id ); |
|
877 | + return apply_filters('give_get_price_option_amount', give_maybe_sanitize_amount($amount), $form_id, $price_id); |
|
879 | 878 | } |
880 | 879 | |
881 | 880 | /** |
@@ -887,13 +886,13 @@ discard block |
||
887 | 886 | * |
888 | 887 | * @return mixed string|int Goal of the form |
889 | 888 | */ |
890 | -function give_get_form_goal( $form_id = 0 ) { |
|
889 | +function give_get_form_goal($form_id = 0) { |
|
891 | 890 | |
892 | - if ( empty( $form_id ) ) { |
|
891 | + if (empty($form_id)) { |
|
893 | 892 | return false; |
894 | 893 | } |
895 | 894 | |
896 | - $form = new Give_Donate_Form( $form_id ); |
|
895 | + $form = new Give_Donate_Form($form_id); |
|
897 | 896 | |
898 | 897 | return $form->goal; |
899 | 898 | |
@@ -908,13 +907,13 @@ discard block |
||
908 | 907 | * |
909 | 908 | * @return mixed string|int Goal of the form |
910 | 909 | */ |
911 | -function give_get_form_goal_format( $form_id = 0 ) { |
|
910 | +function give_get_form_goal_format($form_id = 0) { |
|
912 | 911 | |
913 | - if ( empty( $form_id ) ) { |
|
912 | + if (empty($form_id)) { |
|
914 | 913 | return false; |
915 | 914 | } |
916 | 915 | |
917 | - return give_get_meta( $form_id, '_give_goal_format', true ); |
|
916 | + return give_get_meta($form_id, '_give_goal_format', true); |
|
918 | 917 | |
919 | 918 | } |
920 | 919 | |
@@ -928,19 +927,19 @@ discard block |
||
928 | 927 | * |
929 | 928 | * @return string $formatted_goal |
930 | 929 | */ |
931 | -function give_goal( $form_id = 0, $echo = true ) { |
|
930 | +function give_goal($form_id = 0, $echo = true) { |
|
932 | 931 | |
933 | - if ( empty( $form_id ) ) { |
|
932 | + if (empty($form_id)) { |
|
934 | 933 | $form_id = get_the_ID(); |
935 | 934 | } |
936 | 935 | |
937 | - $goal = give_get_form_goal( $form_id ); |
|
938 | - $goal_format = give_get_form_goal_format( $form_id ); |
|
936 | + $goal = give_get_form_goal($form_id); |
|
937 | + $goal_format = give_get_form_goal_format($form_id); |
|
939 | 938 | |
940 | - if ( 'donation' === $goal_format ) { |
|
939 | + if ('donation' === $goal_format) { |
|
941 | 940 | $goal = "{$goal} donations"; |
942 | 941 | } else { |
943 | - $goal = apply_filters( 'give_form_goal', give_maybe_sanitize_amount( $goal ), $form_id ); |
|
942 | + $goal = apply_filters('give_form_goal', give_maybe_sanitize_amount($goal), $form_id); |
|
944 | 943 | } |
945 | 944 | |
946 | 945 | $formatted_goal = sprintf( |
@@ -948,17 +947,17 @@ discard block |
||
948 | 947 | $form_id, |
949 | 948 | $goal |
950 | 949 | ); |
951 | - $formatted_goal = apply_filters( 'give_form_price_after_html', $formatted_goal, $form_id, $goal ); |
|
950 | + $formatted_goal = apply_filters('give_form_price_after_html', $formatted_goal, $form_id, $goal); |
|
952 | 951 | |
953 | - if ( $echo ) { |
|
952 | + if ($echo) { |
|
954 | 953 | echo $formatted_goal; |
955 | 954 | } else { |
956 | 955 | return $formatted_goal; |
957 | 956 | } |
958 | 957 | } |
959 | 958 | |
960 | -add_filter( 'give_form_goal', 'give_format_amount', 10 ); |
|
961 | -add_filter( 'give_form_goal', 'give_currency_filter', 20 ); |
|
959 | +add_filter('give_form_goal', 'give_format_amount', 10); |
|
960 | +add_filter('give_form_goal', 'give_currency_filter', 20); |
|
962 | 961 | |
963 | 962 | |
964 | 963 | /** |
@@ -970,15 +969,15 @@ discard block |
||
970 | 969 | * |
971 | 970 | * @return bool $ret Whether or not the logged_in_only setting is set |
972 | 971 | */ |
973 | -function give_logged_in_only( $form_id ) { |
|
972 | +function give_logged_in_only($form_id) { |
|
974 | 973 | // If _give_logged_in_only is set to enable then guest can donate from that specific form. |
975 | 974 | // Otherwise it is member only donation form. |
976 | - $val = give_get_meta( $form_id, '_give_logged_in_only', true ); |
|
977 | - $val = ! empty( $val ) ? $val : 'enabled'; |
|
975 | + $val = give_get_meta($form_id, '_give_logged_in_only', true); |
|
976 | + $val = ! empty($val) ? $val : 'enabled'; |
|
978 | 977 | |
979 | - $ret = ! give_is_setting_enabled( $val ); |
|
978 | + $ret = ! give_is_setting_enabled($val); |
|
980 | 979 | |
981 | - return (bool) apply_filters( 'give_logged_in_only', $ret, $form_id ); |
|
980 | + return (bool) apply_filters('give_logged_in_only', $ret, $form_id); |
|
982 | 981 | } |
983 | 982 | |
984 | 983 | |
@@ -991,11 +990,11 @@ discard block |
||
991 | 990 | * |
992 | 991 | * @return string |
993 | 992 | */ |
994 | -function give_show_login_register_option( $form_id ) { |
|
993 | +function give_show_login_register_option($form_id) { |
|
995 | 994 | |
996 | - $show_register_form = give_get_meta( $form_id, '_give_show_register_form', true ); |
|
995 | + $show_register_form = give_get_meta($form_id, '_give_show_register_form', true); |
|
997 | 996 | |
998 | - return apply_filters( 'give_show_register_form', $show_register_form, $form_id ); |
|
997 | + return apply_filters('give_show_register_form', $show_register_form, $form_id); |
|
999 | 998 | |
1000 | 999 | } |
1001 | 1000 | |
@@ -1011,12 +1010,12 @@ discard block |
||
1011 | 1010 | * |
1012 | 1011 | * @return array |
1013 | 1012 | */ |
1014 | -function _give_get_prefill_form_field_values( $form_id ) { |
|
1013 | +function _give_get_prefill_form_field_values($form_id) { |
|
1015 | 1014 | $logged_in_donor_info = array(); |
1016 | 1015 | |
1017 | - if ( is_user_logged_in() ) : |
|
1018 | - $donor_data = get_userdata( get_current_user_id() ); |
|
1019 | - $donor = new Give_Donor( get_current_user_id(), true ); |
|
1016 | + if (is_user_logged_in()) : |
|
1017 | + $donor_data = get_userdata(get_current_user_id()); |
|
1018 | + $donor = new Give_Donor(get_current_user_id(), true); |
|
1020 | 1019 | $donor_address = $donor->get_donor_address(); |
1021 | 1020 | $company_name = $donor->get_company_name(); |
1022 | 1021 | |
@@ -1055,23 +1054,23 @@ discard block |
||
1055 | 1054 | |
1056 | 1055 | // Bailout: Auto fill form field values only form form which donor is donating. |
1057 | 1056 | if ( |
1058 | - empty( $_GET['form-id'] ) |
|
1057 | + empty($_GET['form-id']) |
|
1059 | 1058 | || ! $form_id |
1060 | - || ( $form_id !== absint( $_GET['form-id'] ) ) |
|
1059 | + || ($form_id !== absint($_GET['form-id'])) |
|
1061 | 1060 | ) { |
1062 | 1061 | return $logged_in_donor_info; |
1063 | 1062 | } |
1064 | 1063 | |
1065 | 1064 | // Get purchase data. |
1066 | - $give_purchase_data = Give()->session->get( 'give_purchase' ); |
|
1065 | + $give_purchase_data = Give()->session->get('give_purchase'); |
|
1067 | 1066 | |
1068 | 1067 | // Get donor info from form data. |
1069 | - $give_donor_info_in_session = empty( $give_purchase_data['post_data'] ) |
|
1068 | + $give_donor_info_in_session = empty($give_purchase_data['post_data']) |
|
1070 | 1069 | ? array() |
1071 | 1070 | : $give_purchase_data['post_data']; |
1072 | 1071 | |
1073 | 1072 | // Output. |
1074 | - return wp_parse_args( $give_donor_info_in_session, $logged_in_donor_info ); |
|
1073 | + return wp_parse_args($give_donor_info_in_session, $logged_in_donor_info); |
|
1075 | 1074 | } |
1076 | 1075 | |
1077 | 1076 | /** |
@@ -1084,13 +1083,13 @@ discard block |
||
1084 | 1083 | * |
1085 | 1084 | * @return int |
1086 | 1085 | */ |
1087 | -function give_get_form_donor_count( $form_id, $args = array() ) { |
|
1086 | +function give_get_form_donor_count($form_id, $args = array()) { |
|
1088 | 1087 | global $wpdb; |
1089 | 1088 | |
1090 | - $cache_key = Give_Cache::get_key( "form_donor_count_{$form_id}", $args, false ); |
|
1091 | - $donor_count = absint( Give_Cache::get_db_query( $cache_key ) ); |
|
1089 | + $cache_key = Give_Cache::get_key("form_donor_count_{$form_id}", $args, false); |
|
1090 | + $donor_count = absint(Give_Cache::get_db_query($cache_key)); |
|
1092 | 1091 | |
1093 | - if ( $form_id && ! $donor_count ) { |
|
1092 | + if ($form_id && ! $donor_count) { |
|
1094 | 1093 | // Set arguments. |
1095 | 1094 | $args = wp_parse_args( |
1096 | 1095 | $args, |
@@ -1124,7 +1123,7 @@ discard block |
||
1124 | 1123 | 'publish' |
1125 | 1124 | ); |
1126 | 1125 | |
1127 | - $donor_count = absint( $wpdb->get_var( $query ) ); |
|
1126 | + $donor_count = absint($wpdb->get_var($query)); |
|
1128 | 1127 | } |
1129 | 1128 | |
1130 | 1129 | |
@@ -1133,9 +1132,9 @@ discard block |
||
1133 | 1132 | * |
1134 | 1133 | * @since 2.1.0 |
1135 | 1134 | */ |
1136 | - $donor_count = apply_filters( 'give_get_form_donor_count', $donor_count, $form_id, $args ); |
|
1135 | + $donor_count = apply_filters('give_get_form_donor_count', $donor_count, $form_id, $args); |
|
1137 | 1136 | |
1138 | - Give_Cache::set_db_query( $cache_key, $donor_count ); |
|
1137 | + Give_Cache::set_db_query($cache_key, $donor_count); |
|
1139 | 1138 | |
1140 | 1139 | return $donor_count; |
1141 | 1140 | } |
@@ -1149,33 +1148,33 @@ discard block |
||
1149 | 1148 | * |
1150 | 1149 | * @return void |
1151 | 1150 | */ |
1152 | -function give_set_form_closed_status( $form_id ) { |
|
1151 | +function give_set_form_closed_status($form_id) { |
|
1153 | 1152 | |
1154 | 1153 | // Bailout. |
1155 | - if ( empty( $form_id ) ) { |
|
1154 | + if (empty($form_id)) { |
|
1156 | 1155 | return; |
1157 | 1156 | } |
1158 | 1157 | |
1159 | 1158 | $open_form = false; |
1160 | - $is_goal_enabled = give_is_setting_enabled( give_get_meta( $form_id, '_give_goal_option', true, 'disabled' ) ); |
|
1159 | + $is_goal_enabled = give_is_setting_enabled(give_get_meta($form_id, '_give_goal_option', true, 'disabled')); |
|
1161 | 1160 | |
1162 | 1161 | // Proceed, if the form goal is enabled. |
1163 | - if ( $is_goal_enabled ) { |
|
1162 | + if ($is_goal_enabled) { |
|
1164 | 1163 | |
1165 | - $close_form_when_goal_achieved = give_is_setting_enabled( give_get_meta( $form_id, '_give_close_form_when_goal_achieved', true, 'disabled' ) ); |
|
1164 | + $close_form_when_goal_achieved = give_is_setting_enabled(give_get_meta($form_id, '_give_close_form_when_goal_achieved', true, 'disabled')); |
|
1166 | 1165 | |
1167 | 1166 | // Proceed, if close form when goal achieved option is enabled. |
1168 | - if ( $close_form_when_goal_achieved ) { |
|
1167 | + if ($close_form_when_goal_achieved) { |
|
1169 | 1168 | |
1170 | - $form = new Give_Donate_Form( $form_id ); |
|
1171 | - $goal_progress_stats = give_goal_progress_stats( $form ); |
|
1169 | + $form = new Give_Donate_Form($form_id); |
|
1170 | + $goal_progress_stats = give_goal_progress_stats($form); |
|
1172 | 1171 | |
1173 | 1172 | // Verify whether the form is closed or not after processing data. |
1174 | 1173 | $closed = $goal_progress_stats['raw_goal'] <= $goal_progress_stats['raw_actual']; |
1175 | 1174 | |
1176 | 1175 | // Update form meta if verified that the form is closed. |
1177 | - if ( $closed ) { |
|
1178 | - give_update_meta( $form_id, '_give_form_status', 'closed' ); |
|
1176 | + if ($closed) { |
|
1177 | + give_update_meta($form_id, '_give_form_status', 'closed'); |
|
1179 | 1178 | } else { |
1180 | 1179 | $open_form = true; |
1181 | 1180 | } |
@@ -1187,8 +1186,8 @@ discard block |
||
1187 | 1186 | } |
1188 | 1187 | |
1189 | 1188 | // If $open_form is true, then update form status to open. |
1190 | - if ( $open_form ) { |
|
1191 | - give_update_meta( $form_id, '_give_form_status', 'open' ); |
|
1189 | + if ($open_form) { |
|
1190 | + give_update_meta($form_id, '_give_form_status', 'open'); |
|
1192 | 1191 | } |
1193 | 1192 | } |
1194 | 1193 | |
@@ -1201,32 +1200,31 @@ discard block |
||
1201 | 1200 | * |
1202 | 1201 | * @return string |
1203 | 1202 | */ |
1204 | -function give_admin_form_goal_stats( $form_id ) { |
|
1203 | +function give_admin_form_goal_stats($form_id) { |
|
1205 | 1204 | |
1206 | 1205 | $html = ''; |
1207 | - $goal_stats = give_goal_progress_stats( $form_id ); |
|
1208 | - $percent_complete = round( ( $goal_stats['raw_actual'] / $goal_stats['raw_goal'] ), 3 ) * 100; |
|
1206 | + $goal_stats = give_goal_progress_stats($form_id); |
|
1207 | + $percent_complete = round(($goal_stats['raw_actual'] / $goal_stats['raw_goal']), 3) * 100; |
|
1209 | 1208 | |
1210 | 1209 | $html .= sprintf( |
1211 | 1210 | '<div class="give-admin-progress-bar" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="%1$s"> |
1212 | 1211 | <span style="width:%1$s%%;"></span> |
1213 | 1212 | </div>', |
1214 | - esc_attr( $goal_stats['progress'] ) |
|
1213 | + esc_attr($goal_stats['progress']) |
|
1215 | 1214 | ); |
1216 | 1215 | |
1217 | 1216 | $html .= sprintf( |
1218 | - ( 'percentage' !== $goal_stats['format'] ) ? |
|
1219 | - '<div class="give-goal-text"><span>%1$s</span> %2$s <a href="%3$s">%4$s</a> %5$s ' : |
|
1220 | - '<div class="give-goal-text"><a href="%3$s">%1$s </a>', |
|
1221 | - ( 'percentage' !== $goal_stats['format'] ) ? $goal_stats['actual'] : $percent_complete . '%', |
|
1222 | - ( 'percentage' !== $goal_stats['format'] ) ? __( 'of', 'give' ) : '', |
|
1223 | - esc_url( admin_url( "post.php?post={$form_id}&action=edit&give_tab=donation_goal_options" ) ), |
|
1217 | + ('percentage' !== $goal_stats['format']) ? |
|
1218 | + '<div class="give-goal-text"><span>%1$s</span> %2$s <a href="%3$s">%4$s</a> %5$s ' : '<div class="give-goal-text"><a href="%3$s">%1$s </a>', |
|
1219 | + ('percentage' !== $goal_stats['format']) ? $goal_stats['actual'] : $percent_complete.'%', |
|
1220 | + ('percentage' !== $goal_stats['format']) ? __('of', 'give') : '', |
|
1221 | + esc_url(admin_url("post.php?post={$form_id}&action=edit&give_tab=donation_goal_options")), |
|
1224 | 1222 | $goal_stats['goal'], |
1225 | - ( 'donors' === $goal_stats['format'] ? __( 'Donors', 'give' ) : ( 'donation' === $goal_stats['format'] ? __( 'Donations', 'give' ) : '' ) ) |
|
1223 | + ('donors' === $goal_stats['format'] ? __('Donors', 'give') : ('donation' === $goal_stats['format'] ? __('Donations', 'give') : '')) |
|
1226 | 1224 | ); |
1227 | 1225 | |
1228 | - if ( $goal_stats['raw_actual'] >= $goal_stats['raw_goal'] ) { |
|
1229 | - $html .= sprintf( '<span class="give-admin-goal-achieved"><span class="dashicons dashicons-star-filled"></span> %s</span>', __( 'Goal achieved', 'give' ) ); |
|
1226 | + if ($goal_stats['raw_actual'] >= $goal_stats['raw_goal']) { |
|
1227 | + $html .= sprintf('<span class="give-admin-goal-achieved"><span class="dashicons dashicons-star-filled"></span> %s</span>', __('Goal achieved', 'give')); |
|
1230 | 1228 | } |
1231 | 1229 | |
1232 | 1230 | $html .= '</div>'; |
@@ -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 | |
@@ -77,40 +77,40 @@ discard block |
||
77 | 77 | parent::__construct(); |
78 | 78 | |
79 | 79 | // Bailout. |
80 | - if ( empty( $this->supports ) || ! $this->is_custom_meta_table_active() ) { |
|
80 | + if (empty($this->supports) || ! $this->is_custom_meta_table_active()) { |
|
81 | 81 | return; |
82 | 82 | } |
83 | 83 | |
84 | - if ( in_array( 'add_post_metadata', $this->supports ) ) { |
|
85 | - add_filter( 'add_post_metadata', array( $this, '__add_meta' ), 0, 5 ); |
|
84 | + if (in_array('add_post_metadata', $this->supports)) { |
|
85 | + add_filter('add_post_metadata', array($this, '__add_meta'), 0, 5); |
|
86 | 86 | } |
87 | 87 | |
88 | - if ( in_array( 'get_post_metadata', $this->supports ) ) { |
|
89 | - add_filter( 'get_post_metadata', array( $this, '__get_meta' ), 0, 4 ); |
|
88 | + if (in_array('get_post_metadata', $this->supports)) { |
|
89 | + add_filter('get_post_metadata', array($this, '__get_meta'), 0, 4); |
|
90 | 90 | } |
91 | 91 | |
92 | - if ( in_array( 'update_post_metadata', $this->supports ) ) { |
|
93 | - add_filter( 'update_post_metadata', array( $this, '__update_meta' ), 0, 5 ); |
|
92 | + if (in_array('update_post_metadata', $this->supports)) { |
|
93 | + add_filter('update_post_metadata', array($this, '__update_meta'), 0, 5); |
|
94 | 94 | } |
95 | 95 | |
96 | - if ( in_array( 'delete_post_metadata', $this->supports ) ) { |
|
97 | - add_filter( 'delete_post_metadata', array( $this, '__delete_meta' ), 0, 5 ); |
|
96 | + if (in_array('delete_post_metadata', $this->supports)) { |
|
97 | + add_filter('delete_post_metadata', array($this, '__delete_meta'), 0, 5); |
|
98 | 98 | } |
99 | 99 | |
100 | - if ( in_array( 'posts_where', $this->supports ) ) { |
|
101 | - add_filter( 'posts_where', array( $this, '__rename_meta_table_name_in_query' ), 99999, 2 ); |
|
100 | + if (in_array('posts_where', $this->supports)) { |
|
101 | + add_filter('posts_where', array($this, '__rename_meta_table_name_in_query'), 99999, 2); |
|
102 | 102 | } |
103 | 103 | |
104 | - if ( in_array( 'posts_join', $this->supports ) ) { |
|
105 | - add_filter( 'posts_join', array( $this, '__rename_meta_table_name_in_query' ), 99999, 2 ); |
|
104 | + if (in_array('posts_join', $this->supports)) { |
|
105 | + add_filter('posts_join', array($this, '__rename_meta_table_name_in_query'), 99999, 2); |
|
106 | 106 | } |
107 | 107 | |
108 | - if ( in_array( 'posts_groupby', $this->supports ) ) { |
|
109 | - add_filter( 'posts_groupby', array( $this, '__rename_meta_table_name_in_query' ), 99999, 2 ); |
|
108 | + if (in_array('posts_groupby', $this->supports)) { |
|
109 | + add_filter('posts_groupby', array($this, '__rename_meta_table_name_in_query'), 99999, 2); |
|
110 | 110 | } |
111 | 111 | |
112 | - if ( in_array( 'posts_orderby', $this->supports ) ) { |
|
113 | - add_filter( 'posts_orderby', array( $this, '__rename_meta_table_name_in_query' ), 99999, 2 ); |
|
112 | + if (in_array('posts_orderby', $this->supports)) { |
|
113 | + add_filter('posts_orderby', array($this, '__rename_meta_table_name_in_query'), 99999, 2); |
|
114 | 114 | } |
115 | 115 | } |
116 | 116 | |
@@ -128,16 +128,16 @@ discard block |
||
128 | 128 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single |
129 | 129 | * is true. |
130 | 130 | */ |
131 | - public function get_meta( $id = 0, $meta_key = '', $single = false ) { |
|
132 | - $id = $this->sanitize_id( $id ); |
|
131 | + public function get_meta($id = 0, $meta_key = '', $single = false) { |
|
132 | + $id = $this->sanitize_id($id); |
|
133 | 133 | |
134 | 134 | // Bailout. |
135 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
135 | + if ( ! $this->is_valid_post_type($id)) { |
|
136 | 136 | return $this->check; |
137 | 137 | } |
138 | 138 | |
139 | - if ( $this->raw_result ) { |
|
140 | - if ( ! ( $value = get_metadata( $this->meta_type, $id, $meta_key, false ) ) ) { |
|
139 | + if ($this->raw_result) { |
|
140 | + if ( ! ($value = get_metadata($this->meta_type, $id, $meta_key, false))) { |
|
141 | 141 | $value = ''; |
142 | 142 | } |
143 | 143 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | $this->raw_result = false; |
146 | 146 | |
147 | 147 | } else { |
148 | - $value = get_metadata( $this->meta_type, $id, $meta_key, $single ); |
|
148 | + $value = get_metadata($this->meta_type, $id, $meta_key, $single); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | return $value; |
@@ -167,18 +167,18 @@ discard block |
||
167 | 167 | * |
168 | 168 | * @return int|bool False for failure. True for success. |
169 | 169 | */ |
170 | - public function add_meta( $id = 0, $meta_key = '', $meta_value, $unique = false ) { |
|
171 | - $id = $this->sanitize_id( $id ); |
|
170 | + public function add_meta($id = 0, $meta_key = '', $meta_value, $unique = false) { |
|
171 | + $id = $this->sanitize_id($id); |
|
172 | 172 | |
173 | 173 | // Bailout. |
174 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
174 | + if ( ! $this->is_valid_post_type($id)) { |
|
175 | 175 | return $this->check; |
176 | 176 | } |
177 | 177 | |
178 | - $meta_id = add_metadata( $this->meta_type, $id, $meta_key, $meta_value, $unique ); |
|
178 | + $meta_id = add_metadata($this->meta_type, $id, $meta_key, $meta_value, $unique); |
|
179 | 179 | |
180 | - if ( $meta_id ) { |
|
181 | - $this->delete_cache( $id ); |
|
180 | + if ($meta_id) { |
|
181 | + $this->delete_cache($id); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | return $meta_id; |
@@ -204,18 +204,18 @@ discard block |
||
204 | 204 | * |
205 | 205 | * @return int|bool False on failure, true if success. |
206 | 206 | */ |
207 | - public function update_meta( $id = 0, $meta_key = '', $meta_value, $prev_value = '' ) { |
|
208 | - $id = $this->sanitize_id( $id ); |
|
207 | + public function update_meta($id = 0, $meta_key = '', $meta_value, $prev_value = '') { |
|
208 | + $id = $this->sanitize_id($id); |
|
209 | 209 | |
210 | 210 | // Bailout. |
211 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
211 | + if ( ! $this->is_valid_post_type($id)) { |
|
212 | 212 | return $this->check; |
213 | 213 | } |
214 | 214 | |
215 | - $meta_id = update_metadata( $this->meta_type, $id, $meta_key, $meta_value, $prev_value ); |
|
215 | + $meta_id = update_metadata($this->meta_type, $id, $meta_key, $meta_value, $prev_value); |
|
216 | 216 | |
217 | - if ( $meta_id ) { |
|
218 | - $this->delete_cache( $id ); |
|
217 | + if ($meta_id) { |
|
218 | + $this->delete_cache($id); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | return $meta_id; |
@@ -238,18 +238,18 @@ discard block |
||
238 | 238 | * |
239 | 239 | * @return bool False for failure. True for success. |
240 | 240 | */ |
241 | - public function delete_meta( $id = 0, $meta_key = '', $meta_value = '', $delete_all = '' ) { |
|
242 | - $id = $this->sanitize_id( $id ); |
|
241 | + public function delete_meta($id = 0, $meta_key = '', $meta_value = '', $delete_all = '') { |
|
242 | + $id = $this->sanitize_id($id); |
|
243 | 243 | |
244 | 244 | // Bailout. |
245 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
245 | + if ( ! $this->is_valid_post_type($id)) { |
|
246 | 246 | return $this->check; |
247 | 247 | } |
248 | 248 | |
249 | - $is_meta_deleted = delete_metadata( $this->meta_type, $id, $meta_key, $meta_value, $delete_all ); |
|
249 | + $is_meta_deleted = delete_metadata($this->meta_type, $id, $meta_key, $meta_value, $delete_all); |
|
250 | 250 | |
251 | - if ( $is_meta_deleted ) { |
|
252 | - $this->delete_cache( $id ); |
|
251 | + if ($is_meta_deleted) { |
|
252 | + $this->delete_cache($id); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | return $is_meta_deleted; |
@@ -266,10 +266,10 @@ discard block |
||
266 | 266 | * |
267 | 267 | * @return string |
268 | 268 | */ |
269 | - public function __rename_meta_table_name_in_query( $clause, $wp_query ) { |
|
269 | + public function __rename_meta_table_name_in_query($clause, $wp_query) { |
|
270 | 270 | // Add new table to sql query. |
271 | - if ( $this->is_post_type_query( $wp_query ) && ! empty( $wp_query->meta_query->queries ) ) { |
|
272 | - $clause = $this->__rename_meta_table_name( $clause, current_filter() ); |
|
271 | + if ($this->is_post_type_query($wp_query) && ! empty($wp_query->meta_query->queries)) { |
|
272 | + $clause = $this->__rename_meta_table_name($clause, current_filter()); |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | return $clause; |
@@ -284,39 +284,39 @@ discard block |
||
284 | 284 | * |
285 | 285 | * @return mixed |
286 | 286 | */ |
287 | - public function __rename_meta_table_name( $clause, $filter ){ |
|
287 | + public function __rename_meta_table_name($clause, $filter) { |
|
288 | 288 | global $wpdb; |
289 | 289 | |
290 | - $clause = str_replace( "{$wpdb->postmeta}.post_id", "{$this->table_name}.{$this->meta_type}_id", $clause ); |
|
291 | - $clause = str_replace( $wpdb->postmeta, $this->table_name, $clause ); |
|
290 | + $clause = str_replace("{$wpdb->postmeta}.post_id", "{$this->table_name}.{$this->meta_type}_id", $clause); |
|
291 | + $clause = str_replace($wpdb->postmeta, $this->table_name, $clause); |
|
292 | 292 | |
293 | - switch( $filter ) { |
|
293 | + switch ($filter) { |
|
294 | 294 | case 'posts_join': |
295 | - $joins = array( 'INNER JOIN', 'LEFT JOIN' ); |
|
295 | + $joins = array('INNER JOIN', 'LEFT JOIN'); |
|
296 | 296 | |
297 | - foreach ( $joins as $join ) { |
|
298 | - if( false !== strpos( $clause, $join ) ) { |
|
299 | - $clause = explode( $join, $clause ); |
|
297 | + foreach ($joins as $join) { |
|
298 | + if (false !== strpos($clause, $join)) { |
|
299 | + $clause = explode($join, $clause); |
|
300 | 300 | |
301 | - foreach ( $clause as $key => $clause_part ) { |
|
302 | - if( empty( $clause_part ) ) { |
|
301 | + foreach ($clause as $key => $clause_part) { |
|
302 | + if (empty($clause_part)) { |
|
303 | 303 | continue; |
304 | 304 | } |
305 | 305 | |
306 | - preg_match( '/' . $wpdb->prefix . 'give_' . $this->meta_type . 'meta AS (.*) ON/', $clause_part, $alias_table_name ); |
|
306 | + preg_match('/'.$wpdb->prefix.'give_'.$this->meta_type.'meta AS (.*) ON/', $clause_part, $alias_table_name); |
|
307 | 307 | |
308 | - if( isset( $alias_table_name[1] ) ) { |
|
309 | - $clause[$key] = str_replace( "{$alias_table_name[1]}.post_id", "{$alias_table_name[1]}.{$this->meta_type}_id", $clause_part ); |
|
308 | + if (isset($alias_table_name[1])) { |
|
309 | + $clause[$key] = str_replace("{$alias_table_name[1]}.post_id", "{$alias_table_name[1]}.{$this->meta_type}_id", $clause_part); |
|
310 | 310 | } |
311 | 311 | } |
312 | 312 | |
313 | - $clause = implode( "{$join} ", $clause ); |
|
313 | + $clause = implode("{$join} ", $clause); |
|
314 | 314 | } |
315 | 315 | } |
316 | 316 | break; |
317 | 317 | |
318 | 318 | case 'posts_where': |
319 | - $clause = str_replace( array( 'mt2.post_id', 'mt1.post_id' ), array( "mt2.{$this->meta_type}_id", "mt1.{$this->meta_type}_id" ), $clause ); |
|
319 | + $clause = str_replace(array('mt2.post_id', 'mt1.post_id'), array("mt2.{$this->meta_type}_id", "mt1.{$this->meta_type}_id"), $clause); |
|
320 | 320 | break; |
321 | 321 | } |
322 | 322 | |
@@ -334,19 +334,19 @@ discard block |
||
334 | 334 | * |
335 | 335 | * @return bool |
336 | 336 | */ |
337 | - protected function is_post_type_query( $wp_query ) { |
|
337 | + protected function is_post_type_query($wp_query) { |
|
338 | 338 | $status = false; |
339 | 339 | |
340 | 340 | // Check if it is payment query. |
341 | - if ( ! empty( $wp_query->query['post_type'] ) ) { |
|
341 | + if ( ! empty($wp_query->query['post_type'])) { |
|
342 | 342 | if ( |
343 | - is_string( $wp_query->query['post_type'] ) && |
|
343 | + is_string($wp_query->query['post_type']) && |
|
344 | 344 | $this->post_type === $wp_query->query['post_type'] |
345 | 345 | ) { |
346 | 346 | $status = true; |
347 | 347 | } elseif ( |
348 | - is_array( $wp_query->query['post_type'] ) && |
|
349 | - in_array( $this->post_type, $wp_query->query['post_type'] ) |
|
348 | + is_array($wp_query->query['post_type']) && |
|
349 | + in_array($this->post_type, $wp_query->query['post_type']) |
|
350 | 350 | ) { |
351 | 351 | $status = true; |
352 | 352 | } |
@@ -365,8 +365,8 @@ discard block |
||
365 | 365 | * |
366 | 366 | * @return bool |
367 | 367 | */ |
368 | - protected function is_valid_post_type( $ID ) { |
|
369 | - return $ID && ( $this->post_type === get_post_type( $ID ) ); |
|
368 | + protected function is_valid_post_type($ID) { |
|
369 | + return $ID && ($this->post_type === get_post_type($ID)); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | /** |
@@ -392,8 +392,8 @@ discard block |
||
392 | 392 | * |
393 | 393 | * @return void |
394 | 394 | */ |
395 | - private function delete_cache( $id, $meta_type = '' ) { |
|
396 | - $meta_type = empty( $meta_type ) ? $this->meta_type : $meta_type; |
|
395 | + private function delete_cache($id, $meta_type = '') { |
|
396 | + $meta_type = empty($meta_type) ? $this->meta_type : $meta_type; |
|
397 | 397 | |
398 | 398 | $group = array( |
399 | 399 | // 'form' => 'give-forms', |
@@ -403,8 +403,8 @@ discard block |
||
403 | 403 | // 'log' => 'give-logs', |
404 | 404 | ); |
405 | 405 | |
406 | - if ( array_key_exists( $meta_type, $group ) ) { |
|
407 | - Give_Cache::delete_group( $id, $group[ $meta_type ] ); |
|
406 | + if (array_key_exists($meta_type, $group)) { |
|
407 | + Give_Cache::delete_group($id, $group[$meta_type]); |
|
408 | 408 | } |
409 | 409 | } |
410 | 410 | |
@@ -419,8 +419,8 @@ discard block |
||
419 | 419 | * |
420 | 420 | * @return mixed |
421 | 421 | */ |
422 | - public function __call( $name, $arguments ) { |
|
423 | - switch ( $name ) { |
|
422 | + public function __call($name, $arguments) { |
|
423 | + switch ($name) { |
|
424 | 424 | case '__add_meta': |
425 | 425 | $this->check = $arguments[0]; |
426 | 426 | $id = $arguments[1]; |
@@ -429,11 +429,11 @@ discard block |
||
429 | 429 | $unique = $arguments[4]; |
430 | 430 | |
431 | 431 | // Bailout. |
432 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
432 | + if ( ! $this->is_valid_post_type($id)) { |
|
433 | 433 | return $this->check; |
434 | 434 | } |
435 | 435 | |
436 | - return $this->add_meta( $id, $meta_key, $meta_value, $unique ); |
|
436 | + return $this->add_meta($id, $meta_key, $meta_value, $unique); |
|
437 | 437 | |
438 | 438 | case '__get_meta': |
439 | 439 | $this->check = $arguments[0]; |
@@ -442,13 +442,13 @@ discard block |
||
442 | 442 | $single = $arguments[3]; |
443 | 443 | |
444 | 444 | // Bailout. |
445 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
445 | + if ( ! $this->is_valid_post_type($id)) { |
|
446 | 446 | return $this->check; |
447 | 447 | } |
448 | 448 | |
449 | 449 | $this->raw_result = true; |
450 | 450 | |
451 | - return $this->get_meta( $id, $meta_key, $single ); |
|
451 | + return $this->get_meta($id, $meta_key, $single); |
|
452 | 452 | |
453 | 453 | case '__update_meta': |
454 | 454 | $this->check = $arguments[0]; |
@@ -457,11 +457,11 @@ discard block |
||
457 | 457 | $meta_value = $arguments[3]; |
458 | 458 | |
459 | 459 | // Bailout. |
460 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
460 | + if ( ! $this->is_valid_post_type($id)) { |
|
461 | 461 | return $this->check; |
462 | 462 | } |
463 | 463 | |
464 | - return $this->update_meta( $id, $meta_key, $meta_value ); |
|
464 | + return $this->update_meta($id, $meta_key, $meta_value); |
|
465 | 465 | |
466 | 466 | case '__delete_meta': |
467 | 467 | $this->check = $arguments[0]; |
@@ -471,11 +471,11 @@ discard block |
||
471 | 471 | $delete_all = $arguments[3]; |
472 | 472 | |
473 | 473 | // Bailout. |
474 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
474 | + if ( ! $this->is_valid_post_type($id)) { |
|
475 | 475 | return $this->check; |
476 | 476 | } |
477 | 477 | |
478 | - return $this->delete_meta( $id, $meta_key, $meta_value, $delete_all ); |
|
478 | + return $this->delete_meta($id, $meta_key, $meta_value, $delete_all); |
|
479 | 479 | } |
480 | 480 | } |
481 | 481 | |
@@ -500,10 +500,10 @@ discard block |
||
500 | 500 | KEY meta_key (meta_key({$this->min_index_length})) |
501 | 501 | ) {$charset_collate};"; |
502 | 502 | |
503 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
504 | - dbDelta( $sql ); |
|
503 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
504 | + dbDelta($sql); |
|
505 | 505 | |
506 | - update_option( $this->table_name . '_db_version', $this->version ); |
|
506 | + update_option($this->table_name.'_db_version', $this->version); |
|
507 | 507 | } |
508 | 508 | |
509 | 509 | |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | * |
516 | 516 | * @return string |
517 | 517 | */ |
518 | - public function get_meta_type(){ |
|
518 | + public function get_meta_type() { |
|
519 | 519 | return $this->meta_type; |
520 | 520 | } |
521 | 521 | |
@@ -529,12 +529,12 @@ discard block |
||
529 | 529 | * |
530 | 530 | * @return bool False for failure. True for success. |
531 | 531 | */ |
532 | - public function delete_all_meta( $id = 0 ) { |
|
532 | + public function delete_all_meta($id = 0) { |
|
533 | 533 | global $wpdb; |
534 | - $status = $wpdb->delete( $this->table_name, array( "{$this->meta_type}_id" => $id ), array( '%d' ) ); |
|
534 | + $status = $wpdb->delete($this->table_name, array("{$this->meta_type}_id" => $id), array('%d')); |
|
535 | 535 | |
536 | - if ( $status ) { |
|
537 | - $this->delete_cache( $id, $this->meta_type ); |
|
536 | + if ($status) { |
|
537 | + $this->delete_cache($id, $this->meta_type); |
|
538 | 538 | } |
539 | 539 | |
540 | 540 | return $status; |