@@ -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 | |
@@ -337,11 +337,11 @@ discard block |
||
337 | 337 | * @param bool $_id Post id. Default is false. |
338 | 338 | * @param array $_args Arguments passed. |
339 | 339 | */ |
340 | - public function __construct( $_id = false, $_args = array() ) { |
|
340 | + public function __construct($_id = false, $_args = array()) { |
|
341 | 341 | |
342 | - $donation_form = WP_Post::get_instance( $_id ); |
|
342 | + $donation_form = WP_Post::get_instance($_id); |
|
343 | 343 | |
344 | - return $this->setup_donation_form( $donation_form ); |
|
344 | + return $this->setup_donation_form($donation_form); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | /** |
@@ -354,23 +354,23 @@ discard block |
||
354 | 354 | * |
355 | 355 | * @return bool If the setup was successful or not. |
356 | 356 | */ |
357 | - private function setup_donation_form( $donation_form ) { |
|
357 | + private function setup_donation_form($donation_form) { |
|
358 | 358 | |
359 | - if ( ! is_object( $donation_form ) ) { |
|
359 | + if ( ! is_object($donation_form)) { |
|
360 | 360 | return false; |
361 | 361 | } |
362 | 362 | |
363 | - if ( ! is_a( $donation_form, 'WP_Post' ) ) { |
|
363 | + if ( ! is_a($donation_form, 'WP_Post')) { |
|
364 | 364 | return false; |
365 | 365 | } |
366 | 366 | |
367 | - if ( 'give_forms' !== $donation_form->post_type ) { |
|
367 | + if ('give_forms' !== $donation_form->post_type) { |
|
368 | 368 | return false; |
369 | 369 | } |
370 | 370 | |
371 | - foreach ( $donation_form as $key => $value ) { |
|
371 | + foreach ($donation_form as $key => $value) { |
|
372 | 372 | |
373 | - switch ( $key ) { |
|
373 | + switch ($key) { |
|
374 | 374 | |
375 | 375 | default: |
376 | 376 | $this->$key = $value; |
@@ -394,16 +394,16 @@ discard block |
||
394 | 394 | * |
395 | 395 | * @return mixed |
396 | 396 | */ |
397 | - public function __get( $key ) { |
|
397 | + public function __get($key) { |
|
398 | 398 | |
399 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
399 | + if (method_exists($this, 'get_'.$key)) { |
|
400 | 400 | |
401 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
401 | + return call_user_func(array($this, 'get_'.$key)); |
|
402 | 402 | |
403 | 403 | } else { |
404 | 404 | |
405 | 405 | /* translators: %s: property key */ |
406 | - return new WP_Error( 'give-form-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) ); |
|
406 | + return new WP_Error('give-form-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key)); |
|
407 | 407 | |
408 | 408 | } |
409 | 409 | |
@@ -419,30 +419,30 @@ discard block |
||
419 | 419 | * |
420 | 420 | * @return bool|int False if data isn't passed and class not instantiated for creation, or New Form ID. |
421 | 421 | */ |
422 | - public function create( $data = array() ) { |
|
422 | + public function create($data = array()) { |
|
423 | 423 | |
424 | - if ( $this->id != 0 ) { |
|
424 | + if ($this->id != 0) { |
|
425 | 425 | return false; |
426 | 426 | } |
427 | 427 | |
428 | 428 | $defaults = array( |
429 | 429 | 'post_type' => 'give_forms', |
430 | 430 | 'post_status' => 'draft', |
431 | - 'post_title' => __( 'New Donation Form', 'give' ), |
|
431 | + 'post_title' => __('New Donation Form', 'give'), |
|
432 | 432 | ); |
433 | 433 | |
434 | - $args = wp_parse_args( $data, $defaults ); |
|
434 | + $args = wp_parse_args($data, $defaults); |
|
435 | 435 | |
436 | 436 | /** |
437 | 437 | * Fired before a donation form is created |
438 | 438 | * |
439 | 439 | * @param array $args The post object arguments used for creation. |
440 | 440 | */ |
441 | - do_action( 'give_form_pre_create', $args ); |
|
441 | + do_action('give_form_pre_create', $args); |
|
442 | 442 | |
443 | - $id = wp_insert_post( $args, true ); |
|
443 | + $id = wp_insert_post($args, true); |
|
444 | 444 | |
445 | - $donation_form = WP_Post::get_instance( $id ); |
|
445 | + $donation_form = WP_Post::get_instance($id); |
|
446 | 446 | |
447 | 447 | /** |
448 | 448 | * Fired after a donation form is created |
@@ -450,9 +450,9 @@ discard block |
||
450 | 450 | * @param int $id The post ID of the created item. |
451 | 451 | * @param array $args The post object arguments used for creation. |
452 | 452 | */ |
453 | - do_action( 'give_form_post_create', $id, $args ); |
|
453 | + do_action('give_form_post_create', $id, $args); |
|
454 | 454 | |
455 | - return $this->setup_donation_form( $donation_form ); |
|
455 | + return $this->setup_donation_form($donation_form); |
|
456 | 456 | |
457 | 457 | } |
458 | 458 | |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | * @return string Donation form name. |
478 | 478 | */ |
479 | 479 | public function get_name() { |
480 | - return get_the_title( $this->ID ); |
|
480 | + return get_the_title($this->ID); |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | /** |
@@ -490,13 +490,13 @@ discard block |
||
490 | 490 | */ |
491 | 491 | public function get_price() { |
492 | 492 | |
493 | - if ( ! isset( $this->price ) ) { |
|
493 | + if ( ! isset($this->price)) { |
|
494 | 494 | |
495 | - $this->price = get_post_meta( $this->ID, '_give_set_price', true ); |
|
495 | + $this->price = get_post_meta($this->ID, '_give_set_price', true); |
|
496 | 496 | |
497 | - if ( $this->price ) { |
|
497 | + if ($this->price) { |
|
498 | 498 | |
499 | - $this->price = give_sanitize_amount( $this->price ); |
|
499 | + $this->price = give_sanitize_amount($this->price); |
|
500 | 500 | |
501 | 501 | } else { |
502 | 502 | |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | * @param string $price The donation form price. |
515 | 515 | * @param string|int $id The form ID. |
516 | 516 | */ |
517 | - return apply_filters( 'give_get_set_price', $this->price, $this->ID ); |
|
517 | + return apply_filters('give_get_set_price', $this->price, $this->ID); |
|
518 | 518 | } |
519 | 519 | |
520 | 520 | /** |
@@ -527,14 +527,14 @@ discard block |
||
527 | 527 | */ |
528 | 528 | public function get_minimum_price() { |
529 | 529 | |
530 | - if ( ! isset( $this->minimum_price ) ) { |
|
530 | + if ( ! isset($this->minimum_price)) { |
|
531 | 531 | |
532 | - $allow_custom_amount = get_post_meta( $this->ID, '_give_custom_amount', true ); |
|
533 | - $this->minimum_price = get_post_meta( $this->ID, '_give_custom_amount_minimum', true ); |
|
532 | + $allow_custom_amount = get_post_meta($this->ID, '_give_custom_amount', true); |
|
533 | + $this->minimum_price = get_post_meta($this->ID, '_give_custom_amount_minimum', true); |
|
534 | 534 | |
535 | - if ( give_is_setting_enabled( $allow_custom_amount ) && $this->minimum_price ) { |
|
535 | + if (give_is_setting_enabled($allow_custom_amount) && $this->minimum_price) { |
|
536 | 536 | |
537 | - $this->minimum_price = give_sanitize_amount( $this->minimum_price ); |
|
537 | + $this->minimum_price = give_sanitize_amount($this->minimum_price); |
|
538 | 538 | |
539 | 539 | } else { |
540 | 540 | |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | |
545 | 545 | } |
546 | 546 | |
547 | - return apply_filters( 'give_get_set_minimum_price', $this->minimum_price, $this->ID ); |
|
547 | + return apply_filters('give_get_set_minimum_price', $this->minimum_price, $this->ID); |
|
548 | 548 | } |
549 | 549 | |
550 | 550 | /** |
@@ -557,9 +557,9 @@ discard block |
||
557 | 557 | */ |
558 | 558 | public function get_prices() { |
559 | 559 | |
560 | - if ( ! isset( $this->prices ) ) { |
|
560 | + if ( ! isset($this->prices)) { |
|
561 | 561 | |
562 | - $this->prices = get_post_meta( $this->ID, '_give_donation_levels', true ); |
|
562 | + $this->prices = get_post_meta($this->ID, '_give_donation_levels', true); |
|
563 | 563 | |
564 | 564 | } |
565 | 565 | |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | * @param array $prices The array of mulit-level prices. |
572 | 572 | * @param int|string $ID The ID of the form. |
573 | 573 | */ |
574 | - return apply_filters( 'give_get_donation_levels', $this->prices, $this->ID ); |
|
574 | + return apply_filters('give_get_donation_levels', $this->prices, $this->ID); |
|
575 | 575 | |
576 | 576 | } |
577 | 577 | |
@@ -585,13 +585,13 @@ discard block |
||
585 | 585 | */ |
586 | 586 | public function get_goal() { |
587 | 587 | |
588 | - if ( ! isset( $this->goal ) ) { |
|
588 | + if ( ! isset($this->goal)) { |
|
589 | 589 | |
590 | - $this->goal = get_post_meta( $this->ID, '_give_set_goal', true ); |
|
590 | + $this->goal = get_post_meta($this->ID, '_give_set_goal', true); |
|
591 | 591 | |
592 | - if ( $this->goal ) { |
|
592 | + if ($this->goal) { |
|
593 | 593 | |
594 | - $this->goal = give_sanitize_amount( $this->goal ); |
|
594 | + $this->goal = give_sanitize_amount($this->goal); |
|
595 | 595 | |
596 | 596 | } else { |
597 | 597 | |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | |
602 | 602 | } |
603 | 603 | |
604 | - return apply_filters( 'give_get_set_goal', $this->goal, $this->ID ); |
|
604 | + return apply_filters('give_get_set_goal', $this->goal, $this->ID); |
|
605 | 605 | |
606 | 606 | } |
607 | 607 | |
@@ -615,10 +615,10 @@ discard block |
||
615 | 615 | */ |
616 | 616 | public function is_single_price_mode() { |
617 | 617 | |
618 | - $option = get_post_meta( $this->ID, '_give_price_option', true ); |
|
618 | + $option = get_post_meta($this->ID, '_give_price_option', true); |
|
619 | 619 | $ret = 0; |
620 | 620 | |
621 | - if ( empty( $option ) || $option === 'set' ) { |
|
621 | + if (empty($option) || $option === 'set') { |
|
622 | 622 | $ret = 1; |
623 | 623 | } |
624 | 624 | |
@@ -630,7 +630,7 @@ discard block |
||
630 | 630 | * @param bool $ret Is donation form in single price mode? |
631 | 631 | * @param int|string $ID The ID of the donation form. |
632 | 632 | */ |
633 | - return (bool) apply_filters( 'give_single_price_option_mode', $ret, $this->ID ); |
|
633 | + return (bool) apply_filters('give_single_price_option_mode', $ret, $this->ID); |
|
634 | 634 | |
635 | 635 | } |
636 | 636 | |
@@ -644,10 +644,10 @@ discard block |
||
644 | 644 | */ |
645 | 645 | public function is_custom_price_mode() { |
646 | 646 | |
647 | - $option = get_post_meta( $this->ID, '_give_custom_amount', true ); |
|
647 | + $option = get_post_meta($this->ID, '_give_custom_amount', true); |
|
648 | 648 | $ret = 0; |
649 | 649 | |
650 | - if ( give_is_setting_enabled( $option ) ) { |
|
650 | + if (give_is_setting_enabled($option)) { |
|
651 | 651 | $ret = 1; |
652 | 652 | } |
653 | 653 | |
@@ -659,7 +659,7 @@ discard block |
||
659 | 659 | * @param bool $ret Is donation form in custom price mode? |
660 | 660 | * @param int|string $ID The ID of the donation form. |
661 | 661 | */ |
662 | - return (bool) apply_filters( 'give_custom_price_option_mode', $ret, $this->ID ); |
|
662 | + return (bool) apply_filters('give_custom_price_option_mode', $ret, $this->ID); |
|
663 | 663 | |
664 | 664 | } |
665 | 665 | |
@@ -675,10 +675,10 @@ discard block |
||
675 | 675 | */ |
676 | 676 | public function has_variable_prices() { |
677 | 677 | |
678 | - $option = get_post_meta( $this->ID, '_give_price_option', true ); |
|
678 | + $option = get_post_meta($this->ID, '_give_price_option', true); |
|
679 | 679 | $ret = 0; |
680 | 680 | |
681 | - if ( $option === 'multi' ) { |
|
681 | + if ($option === 'multi') { |
|
682 | 682 | $ret = 1; |
683 | 683 | } |
684 | 684 | |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | * @param bool $ret Does donation form have variable prices? |
689 | 689 | * @param int|string $ID The ID of the donation form. |
690 | 690 | */ |
691 | - return (bool) apply_filters( 'give_has_variable_prices', $ret, $this->ID ); |
|
691 | + return (bool) apply_filters('give_has_variable_prices', $ret, $this->ID); |
|
692 | 692 | |
693 | 693 | } |
694 | 694 | |
@@ -702,17 +702,17 @@ discard block |
||
702 | 702 | */ |
703 | 703 | public function get_type() { |
704 | 704 | |
705 | - if ( ! isset( $this->type ) ) { |
|
705 | + if ( ! isset($this->type)) { |
|
706 | 706 | |
707 | - $this->type = get_post_meta( $this->ID, '_give_price_option', true ); |
|
707 | + $this->type = get_post_meta($this->ID, '_give_price_option', true); |
|
708 | 708 | |
709 | - if ( empty( $this->type ) ) { |
|
709 | + if (empty($this->type)) { |
|
710 | 710 | $this->type = 'set'; |
711 | 711 | } |
712 | 712 | |
713 | 713 | } |
714 | 714 | |
715 | - return apply_filters( 'give_get_form_type', $this->type, $this->ID ); |
|
715 | + return apply_filters('give_get_form_type', $this->type, $this->ID); |
|
716 | 716 | |
717 | 717 | } |
718 | 718 | |
@@ -728,23 +728,23 @@ discard block |
||
728 | 728 | * |
729 | 729 | * @return string |
730 | 730 | */ |
731 | - public function get_form_classes( $args ) { |
|
731 | + public function get_form_classes($args) { |
|
732 | 732 | |
733 | - $float_labels_option = give_is_float_labels_enabled( $args ) |
|
733 | + $float_labels_option = give_is_float_labels_enabled($args) |
|
734 | 734 | ? 'float-labels-enabled' |
735 | 735 | : ''; |
736 | 736 | |
737 | - $form_classes_array = apply_filters( 'give_form_classes', array( |
|
737 | + $form_classes_array = apply_filters('give_form_classes', array( |
|
738 | 738 | 'give-form', |
739 | - 'give-form-' . $this->ID, |
|
740 | - 'give-form-type-' . $this->get_type(), |
|
739 | + 'give-form-'.$this->ID, |
|
740 | + 'give-form-type-'.$this->get_type(), |
|
741 | 741 | $float_labels_option, |
742 | - ), $this->ID, $args ); |
|
742 | + ), $this->ID, $args); |
|
743 | 743 | |
744 | 744 | // Remove empty class names. |
745 | - $form_classes_array = array_filter( $form_classes_array ); |
|
745 | + $form_classes_array = array_filter($form_classes_array); |
|
746 | 746 | |
747 | - return implode( ' ', $form_classes_array ); |
|
747 | + return implode(' ', $form_classes_array); |
|
748 | 748 | |
749 | 749 | } |
750 | 750 | |
@@ -759,24 +759,24 @@ discard block |
||
759 | 759 | * |
760 | 760 | * @return string |
761 | 761 | */ |
762 | - public function get_form_wrap_classes( $args ) { |
|
762 | + public function get_form_wrap_classes($args) { |
|
763 | 763 | |
764 | - $display_option = ( isset( $args['display_style'] ) && ! empty( $args['display_style'] ) ) |
|
764 | + $display_option = (isset($args['display_style']) && ! empty($args['display_style'])) |
|
765 | 765 | ? $args['display_style'] |
766 | - : get_post_meta( $this->ID, '_give_payment_display', true ); |
|
766 | + : get_post_meta($this->ID, '_give_payment_display', true); |
|
767 | 767 | |
768 | 768 | // If admin want to show only button for form then user inbuilt modal functionality. |
769 | - if( 'button' === $display_option ) { |
|
769 | + if ('button' === $display_option) { |
|
770 | 770 | $display_option = 'modal give-display-button-only'; |
771 | 771 | } |
772 | 772 | |
773 | - $form_wrap_classes_array = apply_filters( 'give_form_wrap_classes', array( |
|
773 | + $form_wrap_classes_array = apply_filters('give_form_wrap_classes', array( |
|
774 | 774 | 'give-form-wrap', |
775 | - 'give-display-' . $display_option, |
|
776 | - ), $this->ID, $args ); |
|
775 | + 'give-display-'.$display_option, |
|
776 | + ), $this->ID, $args); |
|
777 | 777 | |
778 | 778 | |
779 | - return implode( ' ', $form_wrap_classes_array ); |
|
779 | + return implode(' ', $form_wrap_classes_array); |
|
780 | 780 | |
781 | 781 | } |
782 | 782 | |
@@ -791,7 +791,7 @@ discard block |
||
791 | 791 | public function is_set_type_donation_form() { |
792 | 792 | $form_type = $this->get_type(); |
793 | 793 | |
794 | - return ( 'set' === $form_type ? true : false ); |
|
794 | + return ('set' === $form_type ? true : false); |
|
795 | 795 | } |
796 | 796 | |
797 | 797 | /** |
@@ -805,7 +805,7 @@ discard block |
||
805 | 805 | public function is_multi_type_donation_form() { |
806 | 806 | $form_type = $this->get_type(); |
807 | 807 | |
808 | - return ( 'multi' === $form_type ? true : false ); |
|
808 | + return ('multi' === $form_type ? true : false); |
|
809 | 809 | |
810 | 810 | } |
811 | 811 | |
@@ -819,15 +819,15 @@ discard block |
||
819 | 819 | */ |
820 | 820 | public function get_sales() { |
821 | 821 | |
822 | - if ( ! isset( $this->sales ) ) { |
|
822 | + if ( ! isset($this->sales)) { |
|
823 | 823 | |
824 | - if ( '' == get_post_meta( $this->ID, '_give_form_sales', true ) ) { |
|
825 | - add_post_meta( $this->ID, '_give_form_sales', 0 ); |
|
824 | + if ('' == get_post_meta($this->ID, '_give_form_sales', true)) { |
|
825 | + add_post_meta($this->ID, '_give_form_sales', 0); |
|
826 | 826 | } // End if |
827 | 827 | |
828 | - $this->sales = get_post_meta( $this->ID, '_give_form_sales', true ); |
|
828 | + $this->sales = get_post_meta($this->ID, '_give_form_sales', true); |
|
829 | 829 | |
830 | - if ( $this->sales < 0 ) { |
|
830 | + if ($this->sales < 0) { |
|
831 | 831 | // Never let sales be less than zero |
832 | 832 | $this->sales = 0; |
833 | 833 | } |
@@ -848,13 +848,13 @@ discard block |
||
848 | 848 | * |
849 | 849 | * @return int|false New number of total sales. |
850 | 850 | */ |
851 | - public function increase_sales( $quantity = 1 ) { |
|
851 | + public function increase_sales($quantity = 1) { |
|
852 | 852 | |
853 | - $sales = give_get_form_sales_stats( $this->ID ); |
|
854 | - $quantity = absint( $quantity ); |
|
853 | + $sales = give_get_form_sales_stats($this->ID); |
|
854 | + $quantity = absint($quantity); |
|
855 | 855 | $total_sales = $sales + $quantity; |
856 | 856 | |
857 | - if ( $this->update_meta( '_give_form_sales', $total_sales ) ) { |
|
857 | + if ($this->update_meta('_give_form_sales', $total_sales)) { |
|
858 | 858 | |
859 | 859 | $this->sales = $total_sales; |
860 | 860 | |
@@ -875,17 +875,17 @@ discard block |
||
875 | 875 | * |
876 | 876 | * @return int|false New number of total sales. |
877 | 877 | */ |
878 | - public function decrease_sales( $quantity = 1 ) { |
|
878 | + public function decrease_sales($quantity = 1) { |
|
879 | 879 | |
880 | - $sales = give_get_form_sales_stats( $this->ID ); |
|
880 | + $sales = give_get_form_sales_stats($this->ID); |
|
881 | 881 | |
882 | 882 | // Only decrease if not already zero |
883 | - if ( $sales > 0 ) { |
|
883 | + if ($sales > 0) { |
|
884 | 884 | |
885 | - $quantity = absint( $quantity ); |
|
885 | + $quantity = absint($quantity); |
|
886 | 886 | $total_sales = $sales - $quantity; |
887 | 887 | |
888 | - if ( $this->update_meta( '_give_form_sales', $total_sales ) ) { |
|
888 | + if ($this->update_meta('_give_form_sales', $total_sales)) { |
|
889 | 889 | |
890 | 890 | $this->sales = $sales; |
891 | 891 | |
@@ -909,15 +909,15 @@ discard block |
||
909 | 909 | */ |
910 | 910 | public function get_earnings() { |
911 | 911 | |
912 | - if ( ! isset( $this->earnings ) ) { |
|
912 | + if ( ! isset($this->earnings)) { |
|
913 | 913 | |
914 | - if ( '' == get_post_meta( $this->ID, '_give_form_earnings', true ) ) { |
|
915 | - add_post_meta( $this->ID, '_give_form_earnings', 0 ); |
|
914 | + if ('' == get_post_meta($this->ID, '_give_form_earnings', true)) { |
|
915 | + add_post_meta($this->ID, '_give_form_earnings', 0); |
|
916 | 916 | } |
917 | 917 | |
918 | - $this->earnings = get_post_meta( $this->ID, '_give_form_earnings', true ); |
|
918 | + $this->earnings = get_post_meta($this->ID, '_give_form_earnings', true); |
|
919 | 919 | |
920 | - if ( $this->earnings < 0 ) { |
|
920 | + if ($this->earnings < 0) { |
|
921 | 921 | // Never let earnings be less than zero |
922 | 922 | $this->earnings = 0; |
923 | 923 | } |
@@ -938,12 +938,12 @@ discard block |
||
938 | 938 | * |
939 | 939 | * @return float|false |
940 | 940 | */ |
941 | - public function increase_earnings( $amount = 0 ) { |
|
941 | + public function increase_earnings($amount = 0) { |
|
942 | 942 | |
943 | - $earnings = give_get_form_earnings_stats( $this->ID ); |
|
943 | + $earnings = give_get_form_earnings_stats($this->ID); |
|
944 | 944 | $new_amount = $earnings + (float) $amount; |
945 | 945 | |
946 | - if ( $this->update_meta( '_give_form_earnings', $new_amount ) ) { |
|
946 | + if ($this->update_meta('_give_form_earnings', $new_amount)) { |
|
947 | 947 | |
948 | 948 | $this->earnings = $new_amount; |
949 | 949 | |
@@ -965,16 +965,16 @@ discard block |
||
965 | 965 | * |
966 | 966 | * @return float|false |
967 | 967 | */ |
968 | - public function decrease_earnings( $amount ) { |
|
968 | + public function decrease_earnings($amount) { |
|
969 | 969 | |
970 | - $earnings = give_get_form_earnings_stats( $this->ID ); |
|
970 | + $earnings = give_get_form_earnings_stats($this->ID); |
|
971 | 971 | |
972 | - if ( $earnings > 0 ) { |
|
972 | + if ($earnings > 0) { |
|
973 | 973 | // Only decrease if greater than zero |
974 | 974 | $new_amount = $earnings - (float) $amount; |
975 | 975 | |
976 | 976 | |
977 | - if ( $this->update_meta( '_give_form_earnings', $new_amount ) ) { |
|
977 | + if ($this->update_meta('_give_form_earnings', $new_amount)) { |
|
978 | 978 | |
979 | 979 | $this->earnings = $new_amount; |
980 | 980 | |
@@ -998,22 +998,22 @@ discard block |
||
998 | 998 | * |
999 | 999 | * @return bool |
1000 | 1000 | */ |
1001 | - public function is_free( $price_id = false ) { |
|
1001 | + public function is_free($price_id = false) { |
|
1002 | 1002 | |
1003 | 1003 | $is_free = false; |
1004 | - $variable_pricing = give_has_variable_prices( $this->ID ); |
|
1004 | + $variable_pricing = give_has_variable_prices($this->ID); |
|
1005 | 1005 | |
1006 | - if ( $variable_pricing && ! is_null( $price_id ) && $price_id !== false ) { |
|
1007 | - $price = give_get_price_option_amount( $this->ID, $price_id ); |
|
1008 | - } elseif ( ! $variable_pricing ) { |
|
1009 | - $price = get_post_meta( $this->ID, '_give_set_price', true ); |
|
1006 | + if ($variable_pricing && ! is_null($price_id) && $price_id !== false) { |
|
1007 | + $price = give_get_price_option_amount($this->ID, $price_id); |
|
1008 | + } elseif ( ! $variable_pricing) { |
|
1009 | + $price = get_post_meta($this->ID, '_give_set_price', true); |
|
1010 | 1010 | } |
1011 | 1011 | |
1012 | - if ( isset( $price ) && (float) $price == 0 ) { |
|
1012 | + if (isset($price) && (float) $price == 0) { |
|
1013 | 1013 | $is_free = true; |
1014 | 1014 | } |
1015 | 1015 | |
1016 | - return (bool) apply_filters( 'give_is_free_donation', $is_free, $this->ID, $price_id ); |
|
1016 | + return (bool) apply_filters('give_is_free_donation', $is_free, $this->ID, $price_id); |
|
1017 | 1017 | |
1018 | 1018 | } |
1019 | 1019 | |
@@ -1040,9 +1040,9 @@ discard block |
||
1040 | 1040 | $is_close_form = apply_filters( |
1041 | 1041 | 'give_is_close_donation_form', |
1042 | 1042 | ( |
1043 | - give_is_setting_enabled( get_post_meta( $this->ID, '_give_goal_option', true ) ) ) |
|
1044 | - && give_is_setting_enabled( get_post_meta( $this->ID, '_give_close_form_when_goal_achieved', true ) ) |
|
1045 | - && ( $this->get_goal() <= $this->get_earnings() |
|
1043 | + give_is_setting_enabled(get_post_meta($this->ID, '_give_goal_option', true)) ) |
|
1044 | + && give_is_setting_enabled(get_post_meta($this->ID, '_give_close_form_when_goal_achieved', true)) |
|
1045 | + && ($this->get_goal() <= $this->get_earnings() |
|
1046 | 1046 | ), |
1047 | 1047 | $this->ID |
1048 | 1048 | ); |
@@ -1061,29 +1061,29 @@ discard block |
||
1061 | 1061 | * |
1062 | 1062 | * @return bool The result of the update query. |
1063 | 1063 | */ |
1064 | - private function update_meta( $meta_key = '', $meta_value = '' ) { |
|
1064 | + private function update_meta($meta_key = '', $meta_value = '') { |
|
1065 | 1065 | |
1066 | 1066 | /* @var WPDB $wpdb */ |
1067 | 1067 | global $wpdb; |
1068 | 1068 | |
1069 | - if ( empty( $meta_key ) ) { |
|
1069 | + if (empty($meta_key)) { |
|
1070 | 1070 | return false; |
1071 | 1071 | } |
1072 | 1072 | |
1073 | 1073 | // Make sure if it needs to be serialized, we do |
1074 | - $meta_value = maybe_serialize( $meta_value ); |
|
1074 | + $meta_value = maybe_serialize($meta_value); |
|
1075 | 1075 | |
1076 | - if ( is_numeric( $meta_value ) ) { |
|
1077 | - $value_type = is_float( $meta_value ) ? '%f' : '%d'; |
|
1076 | + if (is_numeric($meta_value)) { |
|
1077 | + $value_type = is_float($meta_value) ? '%f' : '%d'; |
|
1078 | 1078 | } else { |
1079 | 1079 | $value_type = "'%s'"; |
1080 | 1080 | } |
1081 | 1081 | |
1082 | - $sql = $wpdb->prepare( "UPDATE $wpdb->postmeta SET meta_value = $value_type WHERE post_id = $this->ID AND meta_key = '%s'", $meta_value, $meta_key ); |
|
1082 | + $sql = $wpdb->prepare("UPDATE $wpdb->postmeta SET meta_value = $value_type WHERE post_id = $this->ID AND meta_key = '%s'", $meta_value, $meta_key); |
|
1083 | 1083 | |
1084 | - if ( $wpdb->query( $sql ) ) { |
|
1084 | + if ($wpdb->query($sql)) { |
|
1085 | 1085 | |
1086 | - clean_post_cache( $this->ID ); |
|
1086 | + clean_post_cache($this->ID); |
|
1087 | 1087 | |
1088 | 1088 | return true; |
1089 | 1089 |
@@ -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,36 +23,36 @@ discard block |
||
23 | 23 | function give_setup_post_types() { |
24 | 24 | |
25 | 25 | // Give Forms single post and archive options. |
26 | - $give_forms_singular = give_is_setting_enabled( give_get_option( 'forms_singular' ) ); |
|
27 | - $give_forms_archives = give_is_setting_enabled( give_get_option( 'forms_archives' ) ); |
|
26 | + $give_forms_singular = give_is_setting_enabled(give_get_option('forms_singular')); |
|
27 | + $give_forms_archives = give_is_setting_enabled(give_get_option('forms_archives')); |
|
28 | 28 | |
29 | - $give_forms_slug = defined( 'GIVE_SLUG' ) ? GIVE_SLUG : 'donations'; |
|
29 | + $give_forms_slug = defined('GIVE_SLUG') ? GIVE_SLUG : 'donations'; |
|
30 | 30 | // Support for old 'GIVE_FORMS_SLUG' constant |
31 | - if ( defined( 'GIVE_FORMS_SLUG' ) ) { |
|
31 | + if (defined('GIVE_FORMS_SLUG')) { |
|
32 | 32 | $give_forms_slug = GIVE_FORMS_SLUG; |
33 | 33 | } |
34 | 34 | |
35 | - $give_forms_rewrite = defined( 'GIVE_DISABLE_FORMS_REWRITE' ) && GIVE_DISABLE_FORMS_REWRITE ? false : array( |
|
35 | + $give_forms_rewrite = defined('GIVE_DISABLE_FORMS_REWRITE') && GIVE_DISABLE_FORMS_REWRITE ? false : array( |
|
36 | 36 | 'slug' => $give_forms_slug, |
37 | 37 | 'with_front' => false, |
38 | 38 | ); |
39 | 39 | |
40 | - $give_forms_labels = apply_filters( 'give_forms_labels', array( |
|
41 | - 'name' => esc_html__( 'Donation Forms', 'give' ), |
|
42 | - 'singular_name' => esc_html__( 'Form', 'give' ), |
|
43 | - 'add_new' => esc_html__( 'Add Form', 'give' ), |
|
44 | - 'add_new_item' => esc_html__( 'Add New Donation Form', 'give' ), |
|
45 | - 'edit_item' => esc_html__( 'Edit Donation Form', 'give' ), |
|
46 | - 'new_item' => esc_html__( 'New Form', 'give' ), |
|
47 | - 'all_items' => esc_html__( 'All Forms', 'give' ), |
|
48 | - 'view_item' => esc_html__( 'View Form', 'give' ), |
|
49 | - 'search_items' => esc_html__( 'Search Forms', 'give' ), |
|
50 | - 'not_found' => esc_html__( 'No forms found.', 'give' ), |
|
51 | - 'not_found_in_trash' => esc_html__( 'No forms found in Trash.', 'give' ), |
|
40 | + $give_forms_labels = apply_filters('give_forms_labels', array( |
|
41 | + 'name' => esc_html__('Donation Forms', 'give'), |
|
42 | + 'singular_name' => esc_html__('Form', 'give'), |
|
43 | + 'add_new' => esc_html__('Add Form', 'give'), |
|
44 | + 'add_new_item' => esc_html__('Add New Donation Form', 'give'), |
|
45 | + 'edit_item' => esc_html__('Edit Donation Form', 'give'), |
|
46 | + 'new_item' => esc_html__('New Form', 'give'), |
|
47 | + 'all_items' => esc_html__('All Forms', 'give'), |
|
48 | + 'view_item' => esc_html__('View Form', 'give'), |
|
49 | + 'search_items' => esc_html__('Search Forms', 'give'), |
|
50 | + 'not_found' => esc_html__('No forms found.', 'give'), |
|
51 | + 'not_found_in_trash' => esc_html__('No forms found in Trash.', 'give'), |
|
52 | 52 | 'parent_item_colon' => '', |
53 | - 'menu_name' => apply_filters( 'give_menu_name', esc_html__( 'Donations', 'give' ) ), |
|
54 | - 'name_admin_bar' => apply_filters( 'give_name_admin_bar_name', esc_html__( 'Donation Form', 'give' ) ), |
|
55 | - ) ); |
|
53 | + 'menu_name' => apply_filters('give_menu_name', esc_html__('Donations', 'give')), |
|
54 | + 'name_admin_bar' => apply_filters('give_name_admin_bar_name', esc_html__('Donation Form', 'give')), |
|
55 | + )); |
|
56 | 56 | |
57 | 57 | // Default give_forms supports. |
58 | 58 | $give_form_supports = array( |
@@ -64,14 +64,14 @@ discard block |
||
64 | 64 | ); |
65 | 65 | |
66 | 66 | // Has the user disabled the excerpt? |
67 | - if ( ! give_is_setting_enabled( give_get_option( 'forms_excerpt' ) ) ) { |
|
68 | - unset( $give_form_supports[2] ); |
|
67 | + if ( ! give_is_setting_enabled(give_get_option('forms_excerpt'))) { |
|
68 | + unset($give_form_supports[2]); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | // Has user disabled the featured image? |
72 | - if ( ! give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) { |
|
73 | - unset( $give_form_supports[1] ); |
|
74 | - remove_action( 'give_before_single_form_summary', 'give_show_form_images' ); |
|
72 | + if ( ! give_is_setting_enabled(give_get_option('form_featured_img'))) { |
|
73 | + unset($give_form_supports[1]); |
|
74 | + remove_action('give_before_single_form_summary', 'give_show_form_images'); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | $give_forms_args = array( |
@@ -87,42 +87,42 @@ discard block |
||
87 | 87 | 'has_archive' => $give_forms_archives, |
88 | 88 | 'menu_icon' => 'dashicons-give', |
89 | 89 | 'hierarchical' => false, |
90 | - 'supports' => apply_filters( 'give_forms_supports', $give_form_supports ), |
|
90 | + 'supports' => apply_filters('give_forms_supports', $give_form_supports), |
|
91 | 91 | ); |
92 | - register_post_type( 'give_forms', apply_filters( 'give_forms_post_type_args', $give_forms_args ) ); |
|
92 | + register_post_type('give_forms', apply_filters('give_forms_post_type_args', $give_forms_args)); |
|
93 | 93 | |
94 | 94 | /** Donation Post Type */ |
95 | 95 | $payment_labels = array( |
96 | - 'name' => _x( 'Donations', 'post type general name', 'give' ), |
|
97 | - 'singular_name' => _x( 'Donation', 'post type singular name', 'give' ), |
|
98 | - 'add_new' => esc_html__( 'Add New', 'give' ), |
|
99 | - 'add_new_item' => esc_html__( 'Add New Donation', 'give' ), |
|
100 | - 'edit_item' => esc_html__( 'Edit Donation', 'give' ), |
|
101 | - 'new_item' => esc_html__( 'New Donation', 'give' ), |
|
102 | - 'all_items' => esc_html__( 'All Donations', 'give' ), |
|
103 | - 'view_item' => esc_html__( 'View Donation', 'give' ), |
|
104 | - 'search_items' => esc_html__( 'Search Donations', 'give' ), |
|
105 | - 'not_found' => esc_html__( 'No donations found.', 'give' ), |
|
106 | - 'not_found_in_trash' => esc_html__( 'No donations found in Trash.', 'give' ), |
|
96 | + 'name' => _x('Donations', 'post type general name', 'give'), |
|
97 | + 'singular_name' => _x('Donation', 'post type singular name', 'give'), |
|
98 | + 'add_new' => esc_html__('Add New', 'give'), |
|
99 | + 'add_new_item' => esc_html__('Add New Donation', 'give'), |
|
100 | + 'edit_item' => esc_html__('Edit Donation', 'give'), |
|
101 | + 'new_item' => esc_html__('New Donation', 'give'), |
|
102 | + 'all_items' => esc_html__('All Donations', 'give'), |
|
103 | + 'view_item' => esc_html__('View Donation', 'give'), |
|
104 | + 'search_items' => esc_html__('Search Donations', 'give'), |
|
105 | + 'not_found' => esc_html__('No donations found.', 'give'), |
|
106 | + 'not_found_in_trash' => esc_html__('No donations found in Trash.', 'give'), |
|
107 | 107 | 'parent_item_colon' => '', |
108 | - 'menu_name' => esc_html__( 'Donations', 'give' ), |
|
108 | + 'menu_name' => esc_html__('Donations', 'give'), |
|
109 | 109 | ); |
110 | 110 | |
111 | 111 | $payment_args = array( |
112 | - 'labels' => apply_filters( 'give_payment_labels', $payment_labels ), |
|
112 | + 'labels' => apply_filters('give_payment_labels', $payment_labels), |
|
113 | 113 | 'public' => false, |
114 | 114 | 'query_var' => false, |
115 | 115 | 'rewrite' => false, |
116 | 116 | 'map_meta_cap' => true, |
117 | 117 | 'capability_type' => 'give_payment', |
118 | - 'supports' => array( 'title' ), |
|
118 | + 'supports' => array('title'), |
|
119 | 119 | 'can_export' => true, |
120 | 120 | ); |
121 | - register_post_type( 'give_payment', $payment_args ); |
|
121 | + register_post_type('give_payment', $payment_args); |
|
122 | 122 | |
123 | 123 | } |
124 | 124 | |
125 | -add_action( 'init', 'give_setup_post_types', 1 ); |
|
125 | +add_action('init', 'give_setup_post_types', 1); |
|
126 | 126 | |
127 | 127 | |
128 | 128 | /** |
@@ -135,30 +135,30 @@ discard block |
||
135 | 135 | */ |
136 | 136 | function give_setup_taxonomies() { |
137 | 137 | |
138 | - $slug = defined( 'GIVE_FORMS_SLUG' ) ? GIVE_FORMS_SLUG : 'donations'; |
|
138 | + $slug = defined('GIVE_FORMS_SLUG') ? GIVE_FORMS_SLUG : 'donations'; |
|
139 | 139 | |
140 | 140 | /** Categories */ |
141 | 141 | $category_labels = array( |
142 | - 'name' => _x( 'Form Categories', 'taxonomy general name', 'give' ), |
|
143 | - 'singular_name' => _x( 'Category', 'taxonomy singular name', 'give' ), |
|
144 | - 'search_items' => esc_html__( 'Search Categories', 'give' ), |
|
145 | - 'all_items' => esc_html__( 'All Categories', 'give' ), |
|
146 | - 'parent_item' => esc_html__( 'Parent Category', 'give' ), |
|
147 | - 'parent_item_colon' => esc_html__( 'Parent Category:', 'give' ), |
|
148 | - 'edit_item' => esc_html__( 'Edit Category', 'give' ), |
|
149 | - 'update_item' => esc_html__( 'Update Category', 'give' ), |
|
150 | - 'add_new_item' => esc_html__( 'Add New Category', 'give' ), |
|
151 | - 'new_item_name' => esc_html__( 'New Category Name', 'give' ), |
|
152 | - 'menu_name' => esc_html__( 'Categories', 'give' ), |
|
142 | + 'name' => _x('Form Categories', 'taxonomy general name', 'give'), |
|
143 | + 'singular_name' => _x('Category', 'taxonomy singular name', 'give'), |
|
144 | + 'search_items' => esc_html__('Search Categories', 'give'), |
|
145 | + 'all_items' => esc_html__('All Categories', 'give'), |
|
146 | + 'parent_item' => esc_html__('Parent Category', 'give'), |
|
147 | + 'parent_item_colon' => esc_html__('Parent Category:', 'give'), |
|
148 | + 'edit_item' => esc_html__('Edit Category', 'give'), |
|
149 | + 'update_item' => esc_html__('Update Category', 'give'), |
|
150 | + 'add_new_item' => esc_html__('Add New Category', 'give'), |
|
151 | + 'new_item_name' => esc_html__('New Category Name', 'give'), |
|
152 | + 'menu_name' => esc_html__('Categories', 'give'), |
|
153 | 153 | ); |
154 | 154 | |
155 | - $category_args = apply_filters( 'give_forms_category_args', array( |
|
155 | + $category_args = apply_filters('give_forms_category_args', array( |
|
156 | 156 | 'hierarchical' => true, |
157 | - 'labels' => apply_filters( 'give_forms_category_labels', $category_labels ), |
|
157 | + 'labels' => apply_filters('give_forms_category_labels', $category_labels), |
|
158 | 158 | 'show_ui' => true, |
159 | 159 | 'query_var' => 'give_forms_category', |
160 | 160 | 'rewrite' => array( |
161 | - 'slug' => $slug . '/category', |
|
161 | + 'slug' => $slug.'/category', |
|
162 | 162 | 'with_front' => false, |
163 | 163 | 'hierarchical' => true, |
164 | 164 | ), |
@@ -172,33 +172,33 @@ discard block |
||
172 | 172 | ); |
173 | 173 | |
174 | 174 | // Does the user want categories? |
175 | - if ( give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ) ) { |
|
176 | - register_taxonomy( 'give_forms_category', array( 'give_forms' ), $category_args ); |
|
177 | - register_taxonomy_for_object_type( 'give_forms_category', 'give_forms' ); |
|
175 | + if (give_is_setting_enabled(give_get_option('categories', 'disabled'))) { |
|
176 | + register_taxonomy('give_forms_category', array('give_forms'), $category_args); |
|
177 | + register_taxonomy_for_object_type('give_forms_category', 'give_forms'); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | /** Tags */ |
181 | 181 | $tag_labels = array( |
182 | - 'name' => _x( 'Form Tags', 'taxonomy general name', 'give' ), |
|
183 | - 'singular_name' => _x( 'Tag', 'taxonomy singular name', 'give' ), |
|
184 | - 'search_items' => esc_html__( 'Search Tags', 'give' ), |
|
185 | - 'all_items' => esc_html__( 'All Tags', 'give' ), |
|
186 | - 'parent_item' => esc_html__( 'Parent Tag', 'give' ), |
|
187 | - 'parent_item_colon' => esc_html__( 'Parent Tag:', 'give' ), |
|
188 | - 'edit_item' => esc_html__( 'Edit Tag', 'give' ), |
|
189 | - 'update_item' => esc_html__( 'Update Tag', 'give' ), |
|
190 | - 'add_new_item' => esc_html__( 'Add New Tag', 'give' ), |
|
191 | - 'new_item_name' => esc_html__( 'New Tag Name', 'give' ), |
|
192 | - 'menu_name' => esc_html__( 'Tags', 'give' ), |
|
193 | - 'choose_from_most_used' => esc_html__( 'Choose from most used tags.', 'give' ), |
|
182 | + 'name' => _x('Form Tags', 'taxonomy general name', 'give'), |
|
183 | + 'singular_name' => _x('Tag', 'taxonomy singular name', 'give'), |
|
184 | + 'search_items' => esc_html__('Search Tags', 'give'), |
|
185 | + 'all_items' => esc_html__('All Tags', 'give'), |
|
186 | + 'parent_item' => esc_html__('Parent Tag', 'give'), |
|
187 | + 'parent_item_colon' => esc_html__('Parent Tag:', 'give'), |
|
188 | + 'edit_item' => esc_html__('Edit Tag', 'give'), |
|
189 | + 'update_item' => esc_html__('Update Tag', 'give'), |
|
190 | + 'add_new_item' => esc_html__('Add New Tag', 'give'), |
|
191 | + 'new_item_name' => esc_html__('New Tag Name', 'give'), |
|
192 | + 'menu_name' => esc_html__('Tags', 'give'), |
|
193 | + 'choose_from_most_used' => esc_html__('Choose from most used tags.', 'give'), |
|
194 | 194 | ); |
195 | 195 | |
196 | - $tag_args = apply_filters( 'give_forms_tag_args', array( |
|
196 | + $tag_args = apply_filters('give_forms_tag_args', array( |
|
197 | 197 | 'hierarchical' => false, |
198 | - 'labels' => apply_filters( 'give_forms_tag_labels', $tag_labels ), |
|
198 | + 'labels' => apply_filters('give_forms_tag_labels', $tag_labels), |
|
199 | 199 | 'show_ui' => true, |
200 | 200 | 'query_var' => 'give_forms_tag', |
201 | - 'rewrite' => array( 'slug' => $slug . '/tag', 'with_front' => false, 'hierarchical' => true ), |
|
201 | + 'rewrite' => array('slug' => $slug.'/tag', 'with_front' => false, 'hierarchical' => true), |
|
202 | 202 | 'capabilities' => array( |
203 | 203 | 'manage_terms' => 'manage_give_form_terms', |
204 | 204 | 'edit_terms' => 'edit_give_form_terms', |
@@ -208,14 +208,14 @@ discard block |
||
208 | 208 | ) |
209 | 209 | ); |
210 | 210 | |
211 | - if ( give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ) ) { |
|
212 | - register_taxonomy( 'give_forms_tag', array( 'give_forms' ), $tag_args ); |
|
213 | - register_taxonomy_for_object_type( 'give_forms_tag', 'give_forms' ); |
|
211 | + if (give_is_setting_enabled(give_get_option('tags', 'disabled'))) { |
|
212 | + register_taxonomy('give_forms_tag', array('give_forms'), $tag_args); |
|
213 | + register_taxonomy_for_object_type('give_forms_tag', 'give_forms'); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | } |
217 | 217 | |
218 | -add_action( 'init', 'give_setup_taxonomies', 0 ); |
|
218 | +add_action('init', 'give_setup_taxonomies', 0); |
|
219 | 219 | |
220 | 220 | |
221 | 221 | /** |
@@ -226,11 +226,11 @@ discard block |
||
226 | 226 | */ |
227 | 227 | function give_get_default_form_labels() { |
228 | 228 | $defaults = array( |
229 | - 'singular' => esc_html__( 'Form', 'give' ), |
|
230 | - 'plural' => esc_html__( 'Forms', 'give' ), |
|
229 | + 'singular' => esc_html__('Form', 'give'), |
|
230 | + 'plural' => esc_html__('Forms', 'give'), |
|
231 | 231 | ); |
232 | 232 | |
233 | - return apply_filters( 'give_default_form_name', $defaults ); |
|
233 | + return apply_filters('give_default_form_name', $defaults); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | /** |
@@ -242,10 +242,10 @@ discard block |
||
242 | 242 | * |
243 | 243 | * @return string $defaults['singular'] Singular label |
244 | 244 | */ |
245 | -function give_get_forms_label_singular( $lowercase = false ) { |
|
245 | +function give_get_forms_label_singular($lowercase = false) { |
|
246 | 246 | $defaults = give_get_default_form_labels(); |
247 | 247 | |
248 | - return ( $lowercase ) ? strtolower( $defaults['singular'] ) : $defaults['singular']; |
|
248 | + return ($lowercase) ? strtolower($defaults['singular']) : $defaults['singular']; |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | /** |
@@ -254,10 +254,10 @@ discard block |
||
254 | 254 | * @since 1.0 |
255 | 255 | * @return string $defaults['plural'] Plural label |
256 | 256 | */ |
257 | -function give_get_forms_label_plural( $lowercase = false ) { |
|
257 | +function give_get_forms_label_plural($lowercase = false) { |
|
258 | 258 | $defaults = give_get_default_form_labels(); |
259 | 259 | |
260 | - return ( $lowercase ) ? strtolower( $defaults['plural'] ) : $defaults['plural']; |
|
260 | + return ($lowercase) ? strtolower($defaults['plural']) : $defaults['plural']; |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | /** |
@@ -269,24 +269,24 @@ discard block |
||
269 | 269 | * |
270 | 270 | * @return string $title New placeholder text |
271 | 271 | */ |
272 | -function give_change_default_title( $title ) { |
|
272 | +function give_change_default_title($title) { |
|
273 | 273 | // If a frontend plugin uses this filter (check extensions before changing this function) |
274 | - if ( ! is_admin() ) { |
|
275 | - $title = esc_html__( 'Enter form title here', 'give' ); |
|
274 | + if ( ! is_admin()) { |
|
275 | + $title = esc_html__('Enter form title here', 'give'); |
|
276 | 276 | |
277 | 277 | return $title; |
278 | 278 | } |
279 | 279 | |
280 | 280 | $screen = get_current_screen(); |
281 | 281 | |
282 | - if ( 'give_forms' == $screen->post_type ) { |
|
283 | - $title = esc_html__( 'Enter form title here', 'give' ); |
|
282 | + if ('give_forms' == $screen->post_type) { |
|
283 | + $title = esc_html__('Enter form title here', 'give'); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | return $title; |
287 | 287 | } |
288 | 288 | |
289 | -add_filter( 'enter_title_here', 'give_change_default_title' ); |
|
289 | +add_filter('enter_title_here', 'give_change_default_title'); |
|
290 | 290 | |
291 | 291 | /** |
292 | 292 | * Registers Custom Post Statuses which are used by the Payments |
@@ -296,50 +296,50 @@ discard block |
||
296 | 296 | */ |
297 | 297 | function give_register_post_type_statuses() { |
298 | 298 | // Payment Statuses |
299 | - register_post_status( 'refunded', array( |
|
300 | - 'label' => esc_html__( 'Refunded', 'give' ), |
|
299 | + register_post_status('refunded', array( |
|
300 | + 'label' => esc_html__('Refunded', 'give'), |
|
301 | 301 | 'public' => true, |
302 | 302 | 'exclude_from_search' => false, |
303 | 303 | 'show_in_admin_all_list' => true, |
304 | 304 | 'show_in_admin_status_list' => true, |
305 | - 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give' ), |
|
306 | - ) ); |
|
307 | - register_post_status( 'failed', array( |
|
308 | - 'label' => esc_html__( 'Failed', 'give' ), |
|
305 | + 'label_count' => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give'), |
|
306 | + )); |
|
307 | + register_post_status('failed', array( |
|
308 | + 'label' => esc_html__('Failed', 'give'), |
|
309 | 309 | 'public' => true, |
310 | 310 | 'exclude_from_search' => false, |
311 | 311 | 'show_in_admin_all_list' => true, |
312 | 312 | 'show_in_admin_status_list' => true, |
313 | - 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give' ), |
|
314 | - ) ); |
|
315 | - register_post_status( 'revoked', array( |
|
316 | - 'label' => esc_html__( 'Revoked', 'give' ), |
|
313 | + 'label_count' => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give'), |
|
314 | + )); |
|
315 | + register_post_status('revoked', array( |
|
316 | + 'label' => esc_html__('Revoked', 'give'), |
|
317 | 317 | 'public' => true, |
318 | 318 | 'exclude_from_search' => false, |
319 | 319 | 'show_in_admin_all_list' => true, |
320 | 320 | 'show_in_admin_status_list' => true, |
321 | - 'label_count' => _n_noop( 'Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give' ), |
|
322 | - ) ); |
|
323 | - register_post_status( 'cancelled', array( |
|
324 | - 'label' => esc_html__( 'Cancelled', 'give' ), |
|
321 | + 'label_count' => _n_noop('Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give'), |
|
322 | + )); |
|
323 | + register_post_status('cancelled', array( |
|
324 | + 'label' => esc_html__('Cancelled', 'give'), |
|
325 | 325 | 'public' => true, |
326 | 326 | 'exclude_from_search' => false, |
327 | 327 | 'show_in_admin_all_list' => true, |
328 | 328 | 'show_in_admin_status_list' => true, |
329 | - 'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give' ), |
|
330 | - ) ); |
|
331 | - register_post_status( 'abandoned', array( |
|
332 | - 'label' => esc_html__( 'Abandoned', 'give' ), |
|
329 | + 'label_count' => _n_noop('Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give'), |
|
330 | + )); |
|
331 | + register_post_status('abandoned', array( |
|
332 | + 'label' => esc_html__('Abandoned', 'give'), |
|
333 | 333 | 'public' => true, |
334 | 334 | 'exclude_from_search' => false, |
335 | 335 | 'show_in_admin_all_list' => true, |
336 | 336 | 'show_in_admin_status_list' => true, |
337 | - 'label_count' => _n_noop( 'Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give' ), |
|
338 | - ) ); |
|
337 | + 'label_count' => _n_noop('Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give'), |
|
338 | + )); |
|
339 | 339 | |
340 | 340 | } |
341 | 341 | |
342 | -add_action( 'init', 'give_register_post_type_statuses' ); |
|
342 | +add_action('init', 'give_register_post_type_statuses'); |
|
343 | 343 | |
344 | 344 | /** |
345 | 345 | * Updated Messages |
@@ -352,27 +352,27 @@ discard block |
||
352 | 352 | * |
353 | 353 | * @return array $messages New post updated messages |
354 | 354 | */ |
355 | -function give_updated_messages( $messages ) { |
|
355 | +function give_updated_messages($messages) { |
|
356 | 356 | global $post, $post_ID; |
357 | 357 | |
358 | - if ( give_is_setting_enabled( give_get_option( 'forms_singular' ) ) ) { |
|
358 | + if (give_is_setting_enabled(give_get_option('forms_singular'))) { |
|
359 | 359 | |
360 | 360 | $messages['give_forms'] = array( |
361 | - 1 => esc_html__( 'Form updated.', 'give' ), |
|
362 | - 4 => esc_html__( 'Form updated.', 'give' ), |
|
363 | - 6 => esc_html__( 'Form published.', 'give' ), |
|
364 | - 7 => esc_html__( 'Form saved.', 'give' ), |
|
365 | - 8 => esc_html__( 'Form submitted.', 'give' ), |
|
361 | + 1 => esc_html__('Form updated.', 'give'), |
|
362 | + 4 => esc_html__('Form updated.', 'give'), |
|
363 | + 6 => esc_html__('Form published.', 'give'), |
|
364 | + 7 => esc_html__('Form saved.', 'give'), |
|
365 | + 8 => esc_html__('Form submitted.', 'give'), |
|
366 | 366 | ); |
367 | 367 | |
368 | 368 | } else { |
369 | 369 | |
370 | 370 | $messages['give_forms'] = array( |
371 | - 1 => sprintf( '%1$s <a href="%2$s">%3$s</a>', esc_html__( 'Form updated.', 'give' ), get_permalink( $post_ID ), esc_html__( 'View Form', 'give' ) ), |
|
372 | - 4 => sprintf( '%1$s <a href="%2$s">%3$s</a>', esc_html__( 'Form updated.', 'give' ), get_permalink( $post_ID ), esc_html__( 'View Form', 'give' ) ), |
|
373 | - 6 => sprintf( '%1$s <a href="%2$s">%3$s</a>', esc_html__( 'Form published.', 'give' ), get_permalink( $post_ID ), esc_html__( 'View Form', 'give' ) ), |
|
374 | - 7 => sprintf( '%1$s <a href="%2$s">%3$s</a>', esc_html__( 'Form saved.', 'give' ), get_permalink( $post_ID ), esc_html__( 'View Form', 'give' ) ), |
|
375 | - 8 => sprintf( '%1$s <a href="%2$s">%3$s</a>', esc_html__( 'Form submitted.', 'give' ), get_permalink( $post_ID ), esc_html__( 'View Form', 'give' ) ), |
|
371 | + 1 => sprintf('%1$s <a href="%2$s">%3$s</a>', esc_html__('Form updated.', 'give'), get_permalink($post_ID), esc_html__('View Form', 'give')), |
|
372 | + 4 => sprintf('%1$s <a href="%2$s">%3$s</a>', esc_html__('Form updated.', 'give'), get_permalink($post_ID), esc_html__('View Form', 'give')), |
|
373 | + 6 => sprintf('%1$s <a href="%2$s">%3$s</a>', esc_html__('Form published.', 'give'), get_permalink($post_ID), esc_html__('View Form', 'give')), |
|
374 | + 7 => sprintf('%1$s <a href="%2$s">%3$s</a>', esc_html__('Form saved.', 'give'), get_permalink($post_ID), esc_html__('View Form', 'give')), |
|
375 | + 8 => sprintf('%1$s <a href="%2$s">%3$s</a>', esc_html__('Form submitted.', 'give'), get_permalink($post_ID), esc_html__('View Form', 'give')), |
|
376 | 376 | ); |
377 | 377 | |
378 | 378 | } |
@@ -380,27 +380,27 @@ discard block |
||
380 | 380 | return $messages; |
381 | 381 | } |
382 | 382 | |
383 | -add_filter( 'post_updated_messages', 'give_updated_messages' ); |
|
383 | +add_filter('post_updated_messages', 'give_updated_messages'); |
|
384 | 384 | |
385 | 385 | |
386 | 386 | /** |
387 | 387 | * Setup Post Type Images |
388 | 388 | */ |
389 | -add_action( 'after_setup_theme', 'give_add_thumbnail_support', 10 ); |
|
389 | +add_action('after_setup_theme', 'give_add_thumbnail_support', 10); |
|
390 | 390 | |
391 | 391 | /** |
392 | 392 | * Ensure post thumbnail support is turned on |
393 | 393 | */ |
394 | 394 | function give_add_thumbnail_support() { |
395 | - if ( ! give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) { |
|
395 | + if ( ! give_is_setting_enabled(give_get_option('form_featured_img'))) { |
|
396 | 396 | return; |
397 | 397 | } |
398 | 398 | |
399 | - if ( ! current_theme_supports( 'post-thumbnails' ) ) { |
|
400 | - add_theme_support( 'post-thumbnails' ); |
|
399 | + if ( ! current_theme_supports('post-thumbnails')) { |
|
400 | + add_theme_support('post-thumbnails'); |
|
401 | 401 | } |
402 | 402 | |
403 | - add_post_type_support( 'give_forms', 'thumbnail' ); |
|
403 | + add_post_type_support('give_forms', 'thumbnail'); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | /** |
@@ -412,21 +412,21 @@ discard block |
||
412 | 412 | |
413 | 413 | // Single Give Forms (disabled if single turned off in settings) |
414 | 414 | if ( |
415 | - give_is_setting_enabled( give_get_option( 'forms_singular' ) ) |
|
416 | - && give_is_setting_enabled( give_get_option( 'form_sidebar' ) ) |
|
415 | + give_is_setting_enabled(give_get_option('forms_singular')) |
|
416 | + && give_is_setting_enabled(give_get_option('form_sidebar')) |
|
417 | 417 | ) { |
418 | 418 | |
419 | - register_sidebar( apply_filters( 'give_forms_single_sidebar', array( |
|
420 | - 'name' => esc_html__( 'Give Single Form Sidebar', 'give' ), |
|
419 | + register_sidebar(apply_filters('give_forms_single_sidebar', array( |
|
420 | + 'name' => esc_html__('Give Single Form Sidebar', 'give'), |
|
421 | 421 | 'id' => 'give-forms-sidebar', |
422 | - 'description' => esc_html__( 'Widgets in this area will be shown on the single Give forms aside area. This sidebar will not display for embedded forms.', 'give' ), |
|
422 | + 'description' => esc_html__('Widgets in this area will be shown on the single Give forms aside area. This sidebar will not display for embedded forms.', 'give'), |
|
423 | 423 | 'before_widget' => '<div id="%1$s" class="widget %2$s">', |
424 | 424 | 'after_widget' => '</div>', |
425 | 425 | 'before_title' => '<h3 class="widgettitle widget-title">', |
426 | 426 | 'after_title' => '</h3>', |
427 | - ) ) ); |
|
427 | + ))); |
|
428 | 428 | |
429 | 429 | } |
430 | 430 | } |
431 | 431 | |
432 | -add_action( 'widgets_init', 'give_widgets_init', 999 ); |
|
432 | +add_action('widgets_init', 'give_widgets_init', 999); |
@@ -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 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | public function __construct() { |
97 | 97 | |
98 | 98 | // get it started |
99 | - add_action( 'init', array( $this, 'init' ) ); |
|
99 | + add_action('init', array($this, 'init')); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -111,30 +111,30 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function init() { |
113 | 113 | |
114 | - $is_enabled = give_get_option( 'email_access' ); |
|
114 | + $is_enabled = give_get_option('email_access'); |
|
115 | 115 | |
116 | 116 | //Non-logged in users only |
117 | - if ( is_user_logged_in() || give_is_setting_enabled( $is_enabled ) || is_admin() ) { |
|
117 | + if (is_user_logged_in() || give_is_setting_enabled($is_enabled) || is_admin()) { |
|
118 | 118 | return; |
119 | 119 | } |
120 | 120 | |
121 | 121 | //Are db columns setup? |
122 | - $is_setup = give_get_option( 'email_access_installed' ); |
|
123 | - if ( empty( $is_setup ) ) { |
|
122 | + $is_setup = give_get_option('email_access_installed'); |
|
123 | + if (empty($is_setup)) { |
|
124 | 124 | $this->create_columns(); |
125 | 125 | } |
126 | 126 | |
127 | 127 | // Timeouts |
128 | - $this->verify_throttle = apply_filters( 'give_nl_verify_throttle', 300 ); |
|
129 | - $this->token_expiration = apply_filters( 'give_nl_token_expiration', 7200 ); |
|
128 | + $this->verify_throttle = apply_filters('give_nl_verify_throttle', 300); |
|
129 | + $this->token_expiration = apply_filters('give_nl_token_expiration', 7200); |
|
130 | 130 | |
131 | 131 | // Setup login |
132 | 132 | $this->check_for_token(); |
133 | 133 | |
134 | - if ( $this->token_exists ) { |
|
135 | - add_filter( 'give_can_view_receipt', '__return_true' ); |
|
136 | - add_filter( 'give_user_pending_verification', '__return_false' ); |
|
137 | - add_filter( 'give_get_users_donations_args', array( $this, 'users_donations_args' ) ); |
|
134 | + if ($this->token_exists) { |
|
135 | + add_filter('give_can_view_receipt', '__return_true'); |
|
136 | + add_filter('give_user_pending_verification', '__return_false'); |
|
137 | + add_filter('give_get_users_donations_args', array($this, 'users_donations_args')); |
|
138 | 138 | } |
139 | 139 | } |
140 | 140 | |
@@ -148,25 +148,25 @@ discard block |
||
148 | 148 | * |
149 | 149 | * @return bool |
150 | 150 | */ |
151 | - public function can_send_email( $customer_id ) { |
|
151 | + public function can_send_email($customer_id) { |
|
152 | 152 | /* @var WPDB $wpdb */ |
153 | 153 | global $wpdb; |
154 | 154 | |
155 | 155 | // Prevent multiple emails within X minutes |
156 | - $throttle = date( 'Y-m-d H:i:s', time() - $this->verify_throttle ); |
|
156 | + $throttle = date('Y-m-d H:i:s', time() - $this->verify_throttle); |
|
157 | 157 | |
158 | 158 | // Does a user row exist? |
159 | 159 | $exists = (int) $wpdb->get_var( |
160 | - $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->prefix}give_customers WHERE id = %d", $customer_id ) |
|
160 | + $wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->prefix}give_customers WHERE id = %d", $customer_id) |
|
161 | 161 | ); |
162 | 162 | |
163 | - if ( 0 < $exists ) { |
|
163 | + if (0 < $exists) { |
|
164 | 164 | $row_id = (int) $wpdb->get_var( |
165 | - $wpdb->prepare( "SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d AND (verify_throttle < %s OR verify_key = '') LIMIT 1", $customer_id, $throttle ) |
|
165 | + $wpdb->prepare("SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d AND (verify_throttle < %s OR verify_key = '') LIMIT 1", $customer_id, $throttle) |
|
166 | 166 | ); |
167 | 167 | |
168 | - if ( $row_id < 1 ) { |
|
169 | - give_set_error( 'give_email_access_attempts_exhausted', esc_html__( 'Please wait a few minutes before requesting a new email access link.', 'give' ) ); |
|
168 | + if ($row_id < 1) { |
|
169 | + give_set_error('give_email_access_attempts_exhausted', esc_html__('Please wait a few minutes before requesting a new email access link.', 'give')); |
|
170 | 170 | |
171 | 171 | return false; |
172 | 172 | } |
@@ -186,34 +186,34 @@ discard block |
||
186 | 186 | * |
187 | 187 | * @return void |
188 | 188 | */ |
189 | - public function send_email( $customer_id, $email ) { |
|
189 | + public function send_email($customer_id, $email) { |
|
190 | 190 | |
191 | - $verify_key = wp_generate_password( 20, false ); |
|
191 | + $verify_key = wp_generate_password(20, false); |
|
192 | 192 | |
193 | 193 | // Generate a new verify key |
194 | - $this->set_verify_key( $customer_id, $email, $verify_key ); |
|
194 | + $this->set_verify_key($customer_id, $email, $verify_key); |
|
195 | 195 | |
196 | 196 | // Get the donation history page |
197 | - $page_id = give_get_option( 'history_page' ); |
|
197 | + $page_id = give_get_option('history_page'); |
|
198 | 198 | |
199 | - $access_url = add_query_arg( array( |
|
199 | + $access_url = add_query_arg(array( |
|
200 | 200 | 'give_nl' => $verify_key, |
201 | - ), get_permalink( $page_id ) ); |
|
201 | + ), get_permalink($page_id)); |
|
202 | 202 | |
203 | 203 | //Nice subject and message |
204 | - $subject = apply_filters( 'give_email_access_token_subject', sprintf( esc_html__( 'Your Access Link to %s', 'give' ), get_bloginfo( 'name' ) ) ); |
|
204 | + $subject = apply_filters('give_email_access_token_subject', sprintf(esc_html__('Your Access Link to %s', 'give'), get_bloginfo('name'))); |
|
205 | 205 | |
206 | - $message = esc_html__( 'You or someone in your organization requested an access link be sent to this email address. This is a temporary access link for you to view your donation information. Click on the link below to view:', 'give' ) . "\n\n"; |
|
207 | - $message .= '<a href="' . esc_url( $access_url ) . '" target="_blank">' . esc_html__( 'Access My Donation Details »', 'give' ) . '</a>' . "\n\n"; |
|
206 | + $message = esc_html__('You or someone in your organization requested an access link be sent to this email address. This is a temporary access link for you to view your donation information. Click on the link below to view:', 'give')."\n\n"; |
|
207 | + $message .= '<a href="'.esc_url($access_url).'" target="_blank">'.esc_html__('Access My Donation Details »', 'give').'</a>'."\n\n"; |
|
208 | 208 | $message .= "\n\n"; |
209 | - $message .= esc_html__( 'Sincerely,', 'give' ) . "\n"; |
|
210 | - $message .= get_bloginfo( 'name' ) . "\n"; |
|
209 | + $message .= esc_html__('Sincerely,', 'give')."\n"; |
|
210 | + $message .= get_bloginfo('name')."\n"; |
|
211 | 211 | |
212 | - $message = apply_filters( 'give_email_access_token_message', $message ); |
|
212 | + $message = apply_filters('give_email_access_token_message', $message); |
|
213 | 213 | |
214 | 214 | // Send the email |
215 | - Give()->emails->__set( 'heading', apply_filters( 'give_email_access_token_heading', esc_html__( 'Your Access Link', 'give' ) ) ); |
|
216 | - Give()->emails->send( $email, $subject, $message ); |
|
215 | + Give()->emails->__set('heading', apply_filters('give_email_access_token_heading', esc_html__('Your Access Link', 'give'))); |
|
216 | + Give()->emails->send($email, $subject, $message); |
|
217 | 217 | |
218 | 218 | } |
219 | 219 | |
@@ -227,24 +227,24 @@ discard block |
||
227 | 227 | */ |
228 | 228 | public function check_for_token() { |
229 | 229 | |
230 | - $token = isset( $_GET['give_nl'] ) ? $_GET['give_nl'] : ''; |
|
230 | + $token = isset($_GET['give_nl']) ? $_GET['give_nl'] : ''; |
|
231 | 231 | |
232 | 232 | // Check for cookie |
233 | - if ( empty( $token ) ) { |
|
234 | - $token = isset( $_COOKIE['give_nl'] ) ? $_COOKIE['give_nl'] : ''; |
|
233 | + if (empty($token)) { |
|
234 | + $token = isset($_COOKIE['give_nl']) ? $_COOKIE['give_nl'] : ''; |
|
235 | 235 | } |
236 | 236 | |
237 | - if ( ! empty( $token ) ) { |
|
238 | - if ( ! $this->is_valid_token( $token ) ) { |
|
239 | - if ( ! $this->is_valid_verify_key( $token ) ) { |
|
237 | + if ( ! empty($token)) { |
|
238 | + if ( ! $this->is_valid_token($token)) { |
|
239 | + if ( ! $this->is_valid_verify_key($token)) { |
|
240 | 240 | return; |
241 | 241 | } |
242 | 242 | } |
243 | 243 | |
244 | 244 | $this->token_exists = true; |
245 | 245 | // Set cookie |
246 | - $lifetime = current_time( 'timestamp' ) + Give()->session->set_expiration_time(); |
|
247 | - @setcookie( 'give_nl', $token, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false ); |
|
246 | + $lifetime = current_time('timestamp') + Give()->session->set_expiration_time(); |
|
247 | + @setcookie('give_nl', $token, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false); |
|
248 | 248 | } |
249 | 249 | } |
250 | 250 | |
@@ -258,18 +258,18 @@ discard block |
||
258 | 258 | * |
259 | 259 | * @return bool |
260 | 260 | */ |
261 | - public function is_valid_token( $token ) { |
|
261 | + public function is_valid_token($token) { |
|
262 | 262 | |
263 | 263 | global $wpdb; |
264 | 264 | |
265 | 265 | // Make sure token isn't expired |
266 | - $expires = date( 'Y-m-d H:i:s', time() - $this->token_expiration ); |
|
266 | + $expires = date('Y-m-d H:i:s', time() - $this->token_expiration); |
|
267 | 267 | |
268 | 268 | $email = $wpdb->get_var( |
269 | - $wpdb->prepare( "SELECT email FROM {$wpdb->prefix}give_customers WHERE token = %s AND verify_throttle >= %s LIMIT 1", $token, $expires ) |
|
269 | + $wpdb->prepare("SELECT email FROM {$wpdb->prefix}give_customers WHERE token = %s AND verify_throttle >= %s LIMIT 1", $token, $expires) |
|
270 | 270 | ); |
271 | 271 | |
272 | - if ( ! empty( $email ) ) { |
|
272 | + if ( ! empty($email)) { |
|
273 | 273 | $this->token_email = $email; |
274 | 274 | $this->token = $token; |
275 | 275 | |
@@ -277,8 +277,8 @@ discard block |
||
277 | 277 | } |
278 | 278 | |
279 | 279 | //Set error only if email access form isn't being submitted |
280 | - if ( ! isset( $_POST['give_email'] ) && ! isset( $_POST['_wpnonce'] ) ) { |
|
281 | - give_set_error( 'give_email_token_expired', apply_filters( 'give_email_token_expired_message', esc_html__( 'Your access token has expired. Please request a new one below:', 'give' ) ) ); |
|
280 | + if ( ! isset($_POST['give_email']) && ! isset($_POST['_wpnonce'])) { |
|
281 | + give_set_error('give_email_token_expired', apply_filters('give_email_token_expired_message', esc_html__('Your access token has expired. Please request a new one below:', 'give'))); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | return false; |
@@ -297,25 +297,25 @@ discard block |
||
297 | 297 | * |
298 | 298 | * @return void |
299 | 299 | */ |
300 | - public function set_verify_key( $customer_id, $email, $verify_key ) { |
|
300 | + public function set_verify_key($customer_id, $email, $verify_key) { |
|
301 | 301 | global $wpdb; |
302 | 302 | |
303 | - $now = date( 'Y-m-d H:i:s' ); |
|
303 | + $now = date('Y-m-d H:i:s'); |
|
304 | 304 | |
305 | 305 | // Insert or update? |
306 | 306 | $row_id = (int) $wpdb->get_var( |
307 | - $wpdb->prepare( "SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d LIMIT 1", $customer_id ) |
|
307 | + $wpdb->prepare("SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d LIMIT 1", $customer_id) |
|
308 | 308 | ); |
309 | 309 | |
310 | 310 | // Update |
311 | - if ( ! empty( $row_id ) ) { |
|
311 | + if ( ! empty($row_id)) { |
|
312 | 312 | $wpdb->query( |
313 | - $wpdb->prepare( "UPDATE {$wpdb->prefix}give_customers SET verify_key = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $verify_key, $now, $row_id ) |
|
313 | + $wpdb->prepare("UPDATE {$wpdb->prefix}give_customers SET verify_key = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $verify_key, $now, $row_id) |
|
314 | 314 | ); |
315 | 315 | } // Insert |
316 | 316 | else { |
317 | 317 | $wpdb->query( |
318 | - $wpdb->prepare( "INSERT INTO {$wpdb->prefix}give_customers ( verify_key, verify_throttle) VALUES (%s, %s)", $verify_key, $now ) |
|
318 | + $wpdb->prepare("INSERT INTO {$wpdb->prefix}give_customers ( verify_key, verify_throttle) VALUES (%s, %s)", $verify_key, $now) |
|
319 | 319 | ); |
320 | 320 | } |
321 | 321 | } |
@@ -330,21 +330,21 @@ discard block |
||
330 | 330 | * |
331 | 331 | * @return bool |
332 | 332 | */ |
333 | - public function is_valid_verify_key( $token ) { |
|
333 | + public function is_valid_verify_key($token) { |
|
334 | 334 | /* @var WPDB $wpdb */ |
335 | 335 | global $wpdb; |
336 | 336 | |
337 | 337 | // See if the verify_key exists |
338 | 338 | $row = $wpdb->get_row( |
339 | - $wpdb->prepare( "SELECT id, email FROM {$wpdb->prefix}give_customers WHERE verify_key = %s LIMIT 1", $token ) |
|
339 | + $wpdb->prepare("SELECT id, email FROM {$wpdb->prefix}give_customers WHERE verify_key = %s LIMIT 1", $token) |
|
340 | 340 | ); |
341 | 341 | |
342 | - $now = date( 'Y-m-d H:i:s' ); |
|
342 | + $now = date('Y-m-d H:i:s'); |
|
343 | 343 | |
344 | 344 | // Set token |
345 | - if ( ! empty( $row ) ) { |
|
345 | + if ( ! empty($row)) { |
|
346 | 346 | $wpdb->query( |
347 | - $wpdb->prepare( "UPDATE {$wpdb->prefix}give_customers SET verify_key = '', token = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $token, $now, $row->id ) |
|
347 | + $wpdb->prepare("UPDATE {$wpdb->prefix}give_customers SET verify_key = '', token = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $token, $now, $row->id) |
|
348 | 348 | ); |
349 | 349 | |
350 | 350 | $this->token_email = $row->email; |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | * |
369 | 369 | * @return mixed |
370 | 370 | */ |
371 | - public function users_donations_args( $args ) { |
|
371 | + public function users_donations_args($args) { |
|
372 | 372 | $args['user'] = $this->token_email; |
373 | 373 | |
374 | 374 | return $args; |
@@ -389,11 +389,11 @@ discard block |
||
389 | 389 | global $wpdb; |
390 | 390 | |
391 | 391 | //Create columns in customers table |
392 | - $query = $wpdb->query( "ALTER TABLE {$wpdb->prefix}give_customers ADD `token` VARCHAR(255) CHARACTER SET utf8 NOT NULL, ADD `verify_key` VARCHAR(255) CHARACTER SET utf8 NOT NULL AFTER `token`, ADD `verify_throttle` DATETIME NOT NULL AFTER `verify_key`" ); |
|
392 | + $query = $wpdb->query("ALTER TABLE {$wpdb->prefix}give_customers ADD `token` VARCHAR(255) CHARACTER SET utf8 NOT NULL, ADD `verify_key` VARCHAR(255) CHARACTER SET utf8 NOT NULL AFTER `token`, ADD `verify_throttle` DATETIME NOT NULL AFTER `verify_key`"); |
|
393 | 393 | |
394 | 394 | //Columns added properly |
395 | - if ( $query ) { |
|
396 | - give_update_option( 'email_access_installed', 1 ); |
|
395 | + if ($query) { |
|
396 | + give_update_option('email_access_installed', 1); |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -26,36 +26,36 @@ discard block |
||
26 | 26 | function give_donation_history() { |
27 | 27 | |
28 | 28 | // If payment_key query arg exists, return receipt instead of donation history. |
29 | - if ( isset( $_GET['payment_key'] ) ) { |
|
29 | + if (isset($_GET['payment_key'])) { |
|
30 | 30 | ob_start(); |
31 | - echo give_receipt_shortcode( array() ); |
|
32 | - echo '<a href="' . esc_url( give_get_history_page_uri() ) . '">« ' . esc_html__( 'Return to All Donations', 'give' ) . '</a>'; |
|
31 | + echo give_receipt_shortcode(array()); |
|
32 | + echo '<a href="'.esc_url(give_get_history_page_uri()).'">« '.esc_html__('Return to All Donations', 'give').'</a>'; |
|
33 | 33 | |
34 | 34 | return ob_get_clean(); |
35 | 35 | } |
36 | 36 | |
37 | - $email_access = give_get_option( 'email_access' ); |
|
37 | + $email_access = give_get_option('email_access'); |
|
38 | 38 | |
39 | 39 | //Is user logged in? Does a session exist? Does an email-access token exist? |
40 | - if ( is_user_logged_in() || Give()->session->get_session_expiration() !== false || ( $email_access == 'on' && Give()->email_access->token_exists ) ) { |
|
40 | + if (is_user_logged_in() || Give()->session->get_session_expiration() !== false || ($email_access == 'on' && Give()->email_access->token_exists)) { |
|
41 | 41 | ob_start(); |
42 | - give_get_template_part( 'history', 'donations' ); |
|
42 | + give_get_template_part('history', 'donations'); |
|
43 | 43 | |
44 | 44 | return ob_get_clean(); |
45 | 45 | } //Is Email-based access enabled? |
46 | - elseif ( give_is_setting_enabled( $email_access ) ) { |
|
46 | + elseif (give_is_setting_enabled($email_access)) { |
|
47 | 47 | |
48 | 48 | ob_start(); |
49 | - give_get_template_part( 'email', 'login-form' ); |
|
49 | + give_get_template_part('email', 'login-form'); |
|
50 | 50 | |
51 | 51 | return ob_get_clean(); |
52 | 52 | } else { |
53 | - $message = esc_html__( 'You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give' ); |
|
54 | - echo apply_filters( 'give_donation_history_nonuser_message', give_output_error( $message, false ), $message ); |
|
53 | + $message = esc_html__('You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give'); |
|
54 | + echo apply_filters('give_donation_history_nonuser_message', give_output_error($message, false), $message); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
58 | -add_shortcode( 'donation_history', 'give_donation_history' ); |
|
58 | +add_shortcode('donation_history', 'give_donation_history'); |
|
59 | 59 | |
60 | 60 | /** |
61 | 61 | * Donation Form Shortcode |
@@ -68,29 +68,29 @@ discard block |
||
68 | 68 | * |
69 | 69 | * @return string |
70 | 70 | */ |
71 | -function give_form_shortcode( $atts ) { |
|
72 | - $atts = shortcode_atts( array( |
|
71 | +function give_form_shortcode($atts) { |
|
72 | + $atts = shortcode_atts(array( |
|
73 | 73 | 'id' => '', |
74 | 74 | 'show_title' => true, |
75 | 75 | 'show_goal' => true, |
76 | 76 | 'show_content' => '', |
77 | 77 | 'float_labels' => '', |
78 | 78 | 'display_style' => '', |
79 | - ), $atts, 'give_form' ); |
|
79 | + ), $atts, 'give_form'); |
|
80 | 80 | |
81 | 81 | // Convert string to bool. |
82 | - $atts['show_title'] = filter_var( $atts['show_title'], FILTER_VALIDATE_BOOLEAN ); |
|
83 | - $atts['show_goal'] = filter_var( $atts['show_goal'], FILTER_VALIDATE_BOOLEAN ); |
|
82 | + $atts['show_title'] = filter_var($atts['show_title'], FILTER_VALIDATE_BOOLEAN); |
|
83 | + $atts['show_goal'] = filter_var($atts['show_goal'], FILTER_VALIDATE_BOOLEAN); |
|
84 | 84 | |
85 | 85 | //get the Give Form |
86 | 86 | ob_start(); |
87 | - give_get_donation_form( $atts ); |
|
87 | + give_get_donation_form($atts); |
|
88 | 88 | $final_output = ob_get_clean(); |
89 | 89 | |
90 | - return apply_filters( 'give_donate_form', $final_output, $atts ); |
|
90 | + return apply_filters('give_donate_form', $final_output, $atts); |
|
91 | 91 | } |
92 | 92 | |
93 | -add_shortcode( 'give_form', 'give_form_shortcode' ); |
|
93 | +add_shortcode('give_form', 'give_form_shortcode'); |
|
94 | 94 | |
95 | 95 | /** |
96 | 96 | * Donation Form Goal Shortcode. |
@@ -103,37 +103,37 @@ discard block |
||
103 | 103 | * |
104 | 104 | * @return string |
105 | 105 | */ |
106 | -function give_goal_shortcode( $atts ) { |
|
107 | - $atts = shortcode_atts( array( |
|
106 | +function give_goal_shortcode($atts) { |
|
107 | + $atts = shortcode_atts(array( |
|
108 | 108 | 'id' => '', |
109 | 109 | 'show_text' => true, |
110 | 110 | 'show_bar' => true, |
111 | - ), $atts, 'give_goal' ); |
|
111 | + ), $atts, 'give_goal'); |
|
112 | 112 | |
113 | 113 | |
114 | 114 | //get the Give Form. |
115 | 115 | ob_start(); |
116 | 116 | |
117 | 117 | //Sanity check 1: ensure there is an ID Provided. |
118 | - if ( empty( $atts['id'] ) ) { |
|
119 | - give_output_error( esc_html__( 'The shortcode is missing Donation Form ID attribute.', 'give' ), true ); |
|
118 | + if (empty($atts['id'])) { |
|
119 | + give_output_error(esc_html__('The shortcode is missing Donation Form ID attribute.', 'give'), true); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | //Sanity check 2: Check the form even has Goals enabled. |
123 | - if ( ! give_is_setting_enabled( get_post_meta( $atts['id'], '_give_goal_option', true ) ) ) { |
|
123 | + if ( ! give_is_setting_enabled(get_post_meta($atts['id'], '_give_goal_option', true))) { |
|
124 | 124 | |
125 | - give_output_error( esc_html__( 'The form does not have Goals enabled.', 'give' ), true ); |
|
125 | + give_output_error(esc_html__('The form does not have Goals enabled.', 'give'), true); |
|
126 | 126 | } else { |
127 | 127 | //Passed all sanity checks: output Goal. |
128 | - give_show_goal_progress( $atts['id'], $atts ); |
|
128 | + give_show_goal_progress($atts['id'], $atts); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | $final_output = ob_get_clean(); |
132 | 132 | |
133 | - return apply_filters( 'give_goal_shortcode_output', $final_output, $atts ); |
|
133 | + return apply_filters('give_goal_shortcode_output', $final_output, $atts); |
|
134 | 134 | } |
135 | 135 | |
136 | -add_shortcode( 'give_goal', 'give_goal_shortcode' ); |
|
136 | +add_shortcode('give_goal', 'give_goal_shortcode'); |
|
137 | 137 | |
138 | 138 | |
139 | 139 | /** |
@@ -150,22 +150,22 @@ discard block |
||
150 | 150 | * |
151 | 151 | * @return string |
152 | 152 | */ |
153 | -function give_login_form_shortcode( $atts ) { |
|
154 | - $atts = shortcode_atts( array( |
|
153 | +function give_login_form_shortcode($atts) { |
|
154 | + $atts = shortcode_atts(array( |
|
155 | 155 | // Add backward compatibility for redirect attribute. |
156 | 156 | 'redirect' => '', |
157 | 157 | |
158 | 158 | 'login-redirect' => '', |
159 | 159 | 'logout-redirect' => '', |
160 | - ), $atts, 'give_login' ); |
|
160 | + ), $atts, 'give_login'); |
|
161 | 161 | |
162 | 162 | // Check login-redirect attribute first, if it empty or not found then check for redirect attribute and add value of this to login-redirect attribute. |
163 | - $atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect'] ) ? $atts['redirect'] : '' ); |
|
163 | + $atts['login-redirect'] = ! empty($atts['login-redirect']) ? $atts['login-redirect'] : ( ! empty($atts['redirect']) ? $atts['redirect'] : ''); |
|
164 | 164 | |
165 | - return give_login_form( $atts['login-redirect'], $atts['logout-redirect'] ); |
|
165 | + return give_login_form($atts['login-redirect'], $atts['logout-redirect']); |
|
166 | 166 | } |
167 | 167 | |
168 | -add_shortcode( 'give_login', 'give_login_form_shortcode' ); |
|
168 | +add_shortcode('give_login', 'give_login_form_shortcode'); |
|
169 | 169 | |
170 | 170 | /** |
171 | 171 | * Register Shortcode. |
@@ -180,15 +180,15 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @return string |
182 | 182 | */ |
183 | -function give_register_form_shortcode( $atts ) { |
|
184 | - $atts = shortcode_atts( array( |
|
183 | +function give_register_form_shortcode($atts) { |
|
184 | + $atts = shortcode_atts(array( |
|
185 | 185 | 'redirect' => '', |
186 | - ), $atts, 'give_register' ); |
|
186 | + ), $atts, 'give_register'); |
|
187 | 187 | |
188 | - return give_register_form( $atts['redirect'] ); |
|
188 | + return give_register_form($atts['redirect']); |
|
189 | 189 | } |
190 | 190 | |
191 | -add_shortcode( 'give_register', 'give_register_form_shortcode' ); |
|
191 | +add_shortcode('give_register', 'give_register_form_shortcode'); |
|
192 | 192 | |
193 | 193 | /** |
194 | 194 | * Receipt Shortcode. |
@@ -201,12 +201,12 @@ discard block |
||
201 | 201 | * |
202 | 202 | * @return string |
203 | 203 | */ |
204 | -function give_receipt_shortcode( $atts ) { |
|
204 | +function give_receipt_shortcode($atts) { |
|
205 | 205 | |
206 | 206 | global $give_receipt_args, $payment; |
207 | 207 | |
208 | - $give_receipt_args = shortcode_atts( array( |
|
209 | - 'error' => esc_html__( 'You are missing the payment key to view this donation receipt.', 'give' ), |
|
208 | + $give_receipt_args = shortcode_atts(array( |
|
209 | + 'error' => esc_html__('You are missing the payment key to view this donation receipt.', 'give'), |
|
210 | 210 | 'price' => true, |
211 | 211 | 'donor' => true, |
212 | 212 | 'date' => true, |
@@ -215,50 +215,50 @@ discard block |
||
215 | 215 | 'payment_id' => true, |
216 | 216 | 'payment_status' => false, |
217 | 217 | 'status_notice' => true, |
218 | - ), $atts, 'give_receipt' ); |
|
218 | + ), $atts, 'give_receipt'); |
|
219 | 219 | |
220 | 220 | //set $session var |
221 | 221 | $session = give_get_purchase_session(); |
222 | 222 | |
223 | 223 | //set payment key var |
224 | - if ( isset( $_GET['payment_key'] ) ) { |
|
225 | - $payment_key = urldecode( $_GET['payment_key'] ); |
|
226 | - } elseif ( $session ) { |
|
224 | + if (isset($_GET['payment_key'])) { |
|
225 | + $payment_key = urldecode($_GET['payment_key']); |
|
226 | + } elseif ($session) { |
|
227 | 227 | $payment_key = $session['purchase_key']; |
228 | - } elseif ( $give_receipt_args['payment_key'] ) { |
|
228 | + } elseif ($give_receipt_args['payment_key']) { |
|
229 | 229 | $payment_key = $give_receipt_args['payment_key']; |
230 | 230 | } |
231 | 231 | |
232 | - $email_access = give_get_option( 'email_access' ); |
|
232 | + $email_access = give_get_option('email_access'); |
|
233 | 233 | |
234 | 234 | // No payment_key found & Email Access is Turned on: |
235 | - if ( ! isset( $payment_key ) && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) { |
|
235 | + if ( ! isset($payment_key) && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) { |
|
236 | 236 | |
237 | 237 | ob_start(); |
238 | 238 | |
239 | - give_get_template_part( 'email-login-form' ); |
|
239 | + give_get_template_part('email-login-form'); |
|
240 | 240 | |
241 | 241 | return ob_get_clean(); |
242 | 242 | |
243 | - } elseif ( ! isset( $payment_key ) ) { |
|
243 | + } elseif ( ! isset($payment_key)) { |
|
244 | 244 | |
245 | - return give_output_error( $give_receipt_args['error'], false, 'error' ); |
|
245 | + return give_output_error($give_receipt_args['error'], false, 'error'); |
|
246 | 246 | |
247 | 247 | } |
248 | 248 | |
249 | - $payment_id = give_get_purchase_id_by_key( $payment_key ); |
|
250 | - $user_can_view = give_can_view_receipt( $payment_key ); |
|
249 | + $payment_id = give_get_purchase_id_by_key($payment_key); |
|
250 | + $user_can_view = give_can_view_receipt($payment_key); |
|
251 | 251 | |
252 | 252 | // Key was provided, but user is logged out. Offer them the ability to login and view the receipt. |
253 | - if ( ! $user_can_view && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) { |
|
253 | + if ( ! $user_can_view && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) { |
|
254 | 254 | |
255 | 255 | ob_start(); |
256 | 256 | |
257 | - give_get_template_part( 'email-login-form' ); |
|
257 | + give_get_template_part('email-login-form'); |
|
258 | 258 | |
259 | 259 | return ob_get_clean(); |
260 | 260 | |
261 | - } elseif ( ! $user_can_view ) { |
|
261 | + } elseif ( ! $user_can_view) { |
|
262 | 262 | |
263 | 263 | global $give_login_redirect; |
264 | 264 | |
@@ -266,9 +266,9 @@ discard block |
||
266 | 266 | |
267 | 267 | ob_start(); |
268 | 268 | |
269 | - give_output_error( apply_filters( 'give_must_be_logged_in_error_message', esc_html__( 'You must be logged in to view this donation receipt.', 'give' ) ) ); |
|
269 | + give_output_error(apply_filters('give_must_be_logged_in_error_message', esc_html__('You must be logged in to view this donation receipt.', 'give'))); |
|
270 | 270 | |
271 | - give_get_template_part( 'shortcode', 'login' ); |
|
271 | + give_get_template_part('shortcode', 'login'); |
|
272 | 272 | |
273 | 273 | $login_form = ob_get_clean(); |
274 | 274 | |
@@ -283,20 +283,20 @@ discard block |
||
283 | 283 | * or if user is logged in and the user can view sensitive shop data. |
284 | 284 | * |
285 | 285 | */ |
286 | - if ( ! apply_filters( 'give_user_can_view_receipt', $user_can_view, $give_receipt_args ) ) { |
|
287 | - return give_output_error( $give_receipt_args['error'], false, 'error' ); |
|
286 | + if ( ! apply_filters('give_user_can_view_receipt', $user_can_view, $give_receipt_args)) { |
|
287 | + return give_output_error($give_receipt_args['error'], false, 'error'); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | ob_start(); |
291 | 291 | |
292 | - give_get_template_part( 'shortcode', 'receipt' ); |
|
292 | + give_get_template_part('shortcode', 'receipt'); |
|
293 | 293 | |
294 | 294 | $display = ob_get_clean(); |
295 | 295 | |
296 | 296 | return $display; |
297 | 297 | } |
298 | 298 | |
299 | -add_shortcode( 'give_receipt', 'give_receipt_shortcode' ); |
|
299 | +add_shortcode('give_receipt', 'give_receipt_shortcode'); |
|
300 | 300 | |
301 | 301 | /** |
302 | 302 | * Profile Editor Shortcode. |
@@ -315,18 +315,18 @@ discard block |
||
315 | 315 | * |
316 | 316 | * @return string Output generated from the profile editor |
317 | 317 | */ |
318 | -function give_profile_editor_shortcode( $atts ) { |
|
318 | +function give_profile_editor_shortcode($atts) { |
|
319 | 319 | |
320 | 320 | ob_start(); |
321 | 321 | |
322 | - give_get_template_part( 'shortcode', 'profile-editor' ); |
|
322 | + give_get_template_part('shortcode', 'profile-editor'); |
|
323 | 323 | |
324 | 324 | $display = ob_get_clean(); |
325 | 325 | |
326 | 326 | return $display; |
327 | 327 | } |
328 | 328 | |
329 | -add_shortcode( 'give_profile_editor', 'give_profile_editor_shortcode' ); |
|
329 | +add_shortcode('give_profile_editor', 'give_profile_editor_shortcode'); |
|
330 | 330 | |
331 | 331 | /** |
332 | 332 | * Process Profile Updater Form. |
@@ -339,30 +339,30 @@ discard block |
||
339 | 339 | * |
340 | 340 | * @return bool |
341 | 341 | */ |
342 | -function give_process_profile_editor_updates( $data ) { |
|
342 | +function give_process_profile_editor_updates($data) { |
|
343 | 343 | // Profile field change request |
344 | - if ( empty( $_POST['give_profile_editor_submit'] ) && ! is_user_logged_in() ) { |
|
344 | + if (empty($_POST['give_profile_editor_submit']) && ! is_user_logged_in()) { |
|
345 | 345 | return false; |
346 | 346 | } |
347 | 347 | |
348 | 348 | // Nonce security |
349 | - if ( ! wp_verify_nonce( $data['give_profile_editor_nonce'], 'give-profile-editor-nonce' ) ) { |
|
349 | + if ( ! wp_verify_nonce($data['give_profile_editor_nonce'], 'give-profile-editor-nonce')) { |
|
350 | 350 | return false; |
351 | 351 | } |
352 | 352 | |
353 | 353 | $user_id = get_current_user_id(); |
354 | - $old_user_data = get_userdata( $user_id ); |
|
355 | - |
|
356 | - $display_name = isset( $data['give_display_name'] ) ? sanitize_text_field( $data['give_display_name'] ) : $old_user_data->display_name; |
|
357 | - $first_name = isset( $data['give_first_name'] ) ? sanitize_text_field( $data['give_first_name'] ) : $old_user_data->first_name; |
|
358 | - $last_name = isset( $data['give_last_name'] ) ? sanitize_text_field( $data['give_last_name'] ) : $old_user_data->last_name; |
|
359 | - $email = isset( $data['give_email'] ) ? sanitize_email( $data['give_email'] ) : $old_user_data->user_email; |
|
360 | - $line1 = ( isset( $data['give_address_line1'] ) ? sanitize_text_field( $data['give_address_line1'] ) : '' ); |
|
361 | - $line2 = ( isset( $data['give_address_line2'] ) ? sanitize_text_field( $data['give_address_line2'] ) : '' ); |
|
362 | - $city = ( isset( $data['give_address_city'] ) ? sanitize_text_field( $data['give_address_city'] ) : '' ); |
|
363 | - $state = ( isset( $data['give_address_state'] ) ? sanitize_text_field( $data['give_address_state'] ) : '' ); |
|
364 | - $zip = ( isset( $data['give_address_zip'] ) ? sanitize_text_field( $data['give_address_zip'] ) : '' ); |
|
365 | - $country = ( isset( $data['give_address_country'] ) ? sanitize_text_field( $data['give_address_country'] ) : '' ); |
|
354 | + $old_user_data = get_userdata($user_id); |
|
355 | + |
|
356 | + $display_name = isset($data['give_display_name']) ? sanitize_text_field($data['give_display_name']) : $old_user_data->display_name; |
|
357 | + $first_name = isset($data['give_first_name']) ? sanitize_text_field($data['give_first_name']) : $old_user_data->first_name; |
|
358 | + $last_name = isset($data['give_last_name']) ? sanitize_text_field($data['give_last_name']) : $old_user_data->last_name; |
|
359 | + $email = isset($data['give_email']) ? sanitize_email($data['give_email']) : $old_user_data->user_email; |
|
360 | + $line1 = (isset($data['give_address_line1']) ? sanitize_text_field($data['give_address_line1']) : ''); |
|
361 | + $line2 = (isset($data['give_address_line2']) ? sanitize_text_field($data['give_address_line2']) : ''); |
|
362 | + $city = (isset($data['give_address_city']) ? sanitize_text_field($data['give_address_city']) : ''); |
|
363 | + $state = (isset($data['give_address_state']) ? sanitize_text_field($data['give_address_state']) : ''); |
|
364 | + $zip = (isset($data['give_address_zip']) ? sanitize_text_field($data['give_address_zip']) : ''); |
|
365 | + $country = (isset($data['give_address_country']) ? sanitize_text_field($data['give_address_country']) : ''); |
|
366 | 366 | |
367 | 367 | $userdata = array( |
368 | 368 | 'ID' => $user_id, |
@@ -390,46 +390,46 @@ discard block |
||
390 | 390 | * @param int $user_id The ID of the user. |
391 | 391 | * @param array $userdata User info, including ID, first name, last name, display name and email. |
392 | 392 | */ |
393 | - do_action( 'give_pre_update_user_profile', $user_id, $userdata ); |
|
393 | + do_action('give_pre_update_user_profile', $user_id, $userdata); |
|
394 | 394 | |
395 | 395 | // New password |
396 | - if ( ! empty( $data['give_new_user_pass1'] ) ) { |
|
397 | - if ( $data['give_new_user_pass1'] !== $data['give_new_user_pass2'] ) { |
|
398 | - give_set_error( 'password_mismatch', esc_html__( 'The passwords you entered do not match. Please try again.', 'give' ) ); |
|
396 | + if ( ! empty($data['give_new_user_pass1'])) { |
|
397 | + if ($data['give_new_user_pass1'] !== $data['give_new_user_pass2']) { |
|
398 | + give_set_error('password_mismatch', esc_html__('The passwords you entered do not match. Please try again.', 'give')); |
|
399 | 399 | } else { |
400 | 400 | $userdata['user_pass'] = $data['give_new_user_pass1']; |
401 | 401 | } |
402 | 402 | } |
403 | 403 | |
404 | - if ( empty( $email ) ) { |
|
404 | + if (empty($email)) { |
|
405 | 405 | // Make sure email should not be empty. |
406 | - give_set_error( 'email_empty', esc_html__( 'The email you entered is empty.', 'give' ) ); |
|
406 | + give_set_error('email_empty', esc_html__('The email you entered is empty.', 'give')); |
|
407 | 407 | |
408 | - } else if ( ! is_email( $email ) ) { |
|
408 | + } else if ( ! is_email($email)) { |
|
409 | 409 | // Make sure email should be valid. |
410 | - give_set_error( 'email_not_valid', esc_html__( 'The email you entered is not valid. Please use another', 'give' ) ); |
|
410 | + give_set_error('email_not_valid', esc_html__('The email you entered is not valid. Please use another', 'give')); |
|
411 | 411 | |
412 | - } else if ( $email != $old_user_data->user_email ) { |
|
412 | + } else if ($email != $old_user_data->user_email) { |
|
413 | 413 | // Make sure the new email doesn't belong to another user |
414 | - if ( email_exists( $email ) ) { |
|
415 | - give_set_error( 'email_exists', esc_html__( 'The email you entered belongs to another user. Please use another.', 'give' ) ); |
|
414 | + if (email_exists($email)) { |
|
415 | + give_set_error('email_exists', esc_html__('The email you entered belongs to another user. Please use another.', 'give')); |
|
416 | 416 | } |
417 | 417 | } |
418 | 418 | |
419 | 419 | // Check for errors |
420 | 420 | $errors = give_get_errors(); |
421 | 421 | |
422 | - if ( $errors ) { |
|
422 | + if ($errors) { |
|
423 | 423 | // Send back to the profile editor if there are errors |
424 | - wp_redirect( $data['give_redirect'] ); |
|
424 | + wp_redirect($data['give_redirect']); |
|
425 | 425 | give_die(); |
426 | 426 | } |
427 | 427 | |
428 | 428 | // Update the user |
429 | - $meta = update_user_meta( $user_id, '_give_user_address', $address ); |
|
430 | - $updated = wp_update_user( $userdata ); |
|
429 | + $meta = update_user_meta($user_id, '_give_user_address', $address); |
|
430 | + $updated = wp_update_user($userdata); |
|
431 | 431 | |
432 | - if ( $updated ) { |
|
432 | + if ($updated) { |
|
433 | 433 | |
434 | 434 | /** |
435 | 435 | * Fires after updating user profile. |
@@ -439,12 +439,12 @@ discard block |
||
439 | 439 | * @param int $user_id The ID of the user. |
440 | 440 | * @param array $userdata User info, including ID, first name, last name, display name and email. |
441 | 441 | */ |
442 | - do_action( 'give_user_profile_updated', $user_id, $userdata ); |
|
443 | - wp_redirect( add_query_arg( 'updated', 'true', $data['give_redirect'] ) ); |
|
442 | + do_action('give_user_profile_updated', $user_id, $userdata); |
|
443 | + wp_redirect(add_query_arg('updated', 'true', $data['give_redirect'])); |
|
444 | 444 | give_die(); |
445 | 445 | } |
446 | 446 | |
447 | 447 | return false; |
448 | 448 | } |
449 | 449 | |
450 | -add_action( 'give_edit_user_profile', 'give_process_profile_editor_updates' ); |
|
450 | +add_action('give_edit_user_profile', 'give_process_profile_editor_updates'); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -25,25 +25,25 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_load_scripts() { |
27 | 27 | |
28 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/frontend/'; |
|
29 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
30 | - $scripts_footer = ( give_is_setting_enabled( give_get_option( 'scripts_footer' ) ) ) ? true : false; |
|
28 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/frontend/'; |
|
29 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
30 | + $scripts_footer = (give_is_setting_enabled(give_get_option('scripts_footer'))) ? true : false; |
|
31 | 31 | |
32 | 32 | // Use minified libraries if SCRIPT_DEBUG is turned off. |
33 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
33 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
34 | 34 | |
35 | 35 | // Localize / PHP to AJAX vars. |
36 | - $localize_give_vars = apply_filters( 'give_global_script_vars', array( |
|
36 | + $localize_give_vars = apply_filters('give_global_script_vars', array( |
|
37 | 37 | 'ajaxurl' => give_get_ajax_url(), |
38 | - 'checkout_nonce' => wp_create_nonce( 'give_checkout_nonce' ), |
|
39 | - 'currency_sign' => give_currency_filter( '' ), |
|
38 | + 'checkout_nonce' => wp_create_nonce('give_checkout_nonce'), |
|
39 | + 'currency_sign' => give_currency_filter(''), |
|
40 | 40 | 'currency_pos' => give_get_currency_position(), |
41 | 41 | 'thousands_separator' => give_get_price_thousand_separator(), |
42 | 42 | 'decimal_separator' => give_get_price_decimal_separator(), |
43 | - 'no_gateway' => __( 'Please select a payment method.', 'give' ), |
|
44 | - 'bad_minimum' => __( 'The minimum donation amount for this form is', 'give' ), |
|
45 | - 'general_loading' => __( 'Loading...', 'give' ), |
|
46 | - 'purchase_loading' => __( 'Please Wait...', 'give' ), |
|
43 | + 'no_gateway' => __('Please select a payment method.', 'give'), |
|
44 | + 'bad_minimum' => __('The minimum donation amount for this form is', 'give'), |
|
45 | + 'general_loading' => __('Loading...', 'give'), |
|
46 | + 'purchase_loading' => __('Please Wait...', 'give'), |
|
47 | 47 | 'number_decimals' => give_get_price_decimals(), |
48 | 48 | 'give_version' => GIVE_VERSION, |
49 | 49 | 'magnific_options' => apply_filters( |
@@ -57,81 +57,81 @@ discard block |
||
57 | 57 | 'give_form_translation_js', |
58 | 58 | array( |
59 | 59 | // Field name Validation message. |
60 | - 'payment-mode' => __( 'Please select payment mode.', 'give' ), |
|
61 | - 'give_first' => __( 'Please enter your first name.', 'give' ), |
|
62 | - 'give_email' => __( 'Please enter a valid email address.', 'give' ), |
|
63 | - 'give_user_login' => __( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ), |
|
64 | - 'give_user_pass' => __( 'Enter a password.', 'give' ), |
|
65 | - 'give_user_pass_confirm' => __( 'Enter the password confirmation.', 'give' ), |
|
66 | - 'give_agree_to_terms' => __( 'You must agree to the terms and conditions.', 'give' ), |
|
60 | + 'payment-mode' => __('Please select payment mode.', 'give'), |
|
61 | + 'give_first' => __('Please enter your first name.', 'give'), |
|
62 | + 'give_email' => __('Please enter a valid email address.', 'give'), |
|
63 | + 'give_user_login' => __('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give'), |
|
64 | + 'give_user_pass' => __('Enter a password.', 'give'), |
|
65 | + 'give_user_pass_confirm' => __('Enter the password confirmation.', 'give'), |
|
66 | + 'give_agree_to_terms' => __('You must agree to the terms and conditions.', 'give'), |
|
67 | 67 | ) |
68 | 68 | ), |
69 | - ) ); |
|
69 | + )); |
|
70 | 70 | |
71 | - $localize_give_ajax = apply_filters( 'give_global_ajax_vars', array( |
|
71 | + $localize_give_ajax = apply_filters('give_global_ajax_vars', array( |
|
72 | 72 | 'ajaxurl' => give_get_ajax_url(), |
73 | - 'loading' => __( 'Loading', 'give' ), |
|
73 | + 'loading' => __('Loading', 'give'), |
|
74 | 74 | // General loading message. |
75 | - 'select_option' => __( 'Please select an option', 'give' ), |
|
75 | + 'select_option' => __('Please select an option', 'give'), |
|
76 | 76 | // Variable pricing error with multi-donation option enabled. |
77 | - 'default_gateway' => give_get_default_gateway( null ), |
|
78 | - 'permalinks' => get_option( 'permalink_structure' ) ? '1' : '0', |
|
77 | + 'default_gateway' => give_get_default_gateway(null), |
|
78 | + 'permalinks' => get_option('permalink_structure') ? '1' : '0', |
|
79 | 79 | 'number_decimals' => give_get_price_decimals(), |
80 | - ) ); |
|
80 | + )); |
|
81 | 81 | |
82 | 82 | // DEBUG is On. |
83 | - if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) { |
|
83 | + if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) { |
|
84 | 84 | |
85 | - if ( give_is_cc_verify_enabled() ) { |
|
86 | - wp_register_script( 'give-cc-validator', $js_plugins . 'jquery.payment' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
87 | - wp_enqueue_script( 'give-cc-validator' ); |
|
85 | + if (give_is_cc_verify_enabled()) { |
|
86 | + wp_register_script('give-cc-validator', $js_plugins.'jquery.payment'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
87 | + wp_enqueue_script('give-cc-validator'); |
|
88 | 88 | } |
89 | 89 | |
90 | - wp_register_script( 'give-float-labels', $js_plugins . 'float-labels' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
91 | - wp_enqueue_script( 'give-float-labels' ); |
|
90 | + wp_register_script('give-float-labels', $js_plugins.'float-labels'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
91 | + wp_enqueue_script('give-float-labels'); |
|
92 | 92 | |
93 | - wp_register_script( 'give-blockui', $js_plugins . 'jquery.blockUI' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
94 | - wp_enqueue_script( 'give-blockui' ); |
|
93 | + wp_register_script('give-blockui', $js_plugins.'jquery.blockUI'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
94 | + wp_enqueue_script('give-blockui'); |
|
95 | 95 | |
96 | - wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
97 | - wp_enqueue_script( 'give-qtip' ); |
|
96 | + wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
97 | + wp_enqueue_script('give-qtip'); |
|
98 | 98 | |
99 | - wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
100 | - wp_enqueue_script( 'give-accounting' ); |
|
99 | + wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
100 | + wp_enqueue_script('give-accounting'); |
|
101 | 101 | |
102 | - wp_register_script( 'give-magnific', $js_plugins . 'jquery.magnific-popup' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
103 | - wp_enqueue_script( 'give-magnific' ); |
|
102 | + wp_register_script('give-magnific', $js_plugins.'jquery.magnific-popup'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
103 | + wp_enqueue_script('give-magnific'); |
|
104 | 104 | |
105 | - wp_register_script( 'give-checkout-global', $js_dir . 'give-checkout-global' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
106 | - wp_enqueue_script( 'give-checkout-global' ); |
|
105 | + wp_register_script('give-checkout-global', $js_dir.'give-checkout-global'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
106 | + wp_enqueue_script('give-checkout-global'); |
|
107 | 107 | |
108 | 108 | // General scripts. |
109 | - wp_register_script( 'give-scripts', $js_dir . 'give' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
110 | - wp_enqueue_script( 'give-scripts' ); |
|
109 | + wp_register_script('give-scripts', $js_dir.'give'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
110 | + wp_enqueue_script('give-scripts'); |
|
111 | 111 | |
112 | 112 | // Load AJAX scripts, if enabled. |
113 | - wp_register_script( 'give-ajax', $js_dir . 'give-ajax' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
114 | - wp_enqueue_script( 'give-ajax' ); |
|
113 | + wp_register_script('give-ajax', $js_dir.'give-ajax'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
114 | + wp_enqueue_script('give-ajax'); |
|
115 | 115 | |
116 | 116 | // Localize / Pass AJAX vars from PHP, |
117 | - wp_localize_script( 'give-checkout-global', 'give_global_vars', $localize_give_vars ); |
|
118 | - wp_localize_script( 'give-ajax', 'give_scripts', $localize_give_ajax ); |
|
117 | + wp_localize_script('give-checkout-global', 'give_global_vars', $localize_give_vars); |
|
118 | + wp_localize_script('give-ajax', 'give_scripts', $localize_give_ajax); |
|
119 | 119 | |
120 | 120 | } else { |
121 | 121 | |
122 | 122 | // DEBUG is OFF (one JS file to rule them all!). |
123 | - wp_register_script( 'give', $js_dir . 'give.all.min.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
124 | - wp_enqueue_script( 'give' ); |
|
123 | + wp_register_script('give', $js_dir.'give.all.min.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
124 | + wp_enqueue_script('give'); |
|
125 | 125 | |
126 | 126 | // Localize / Pass AJAX vars from PHP. |
127 | - wp_localize_script( 'give', 'give_global_vars', $localize_give_vars ); |
|
128 | - wp_localize_script( 'give', 'give_scripts', $localize_give_ajax ); |
|
127 | + wp_localize_script('give', 'give_global_vars', $localize_give_vars); |
|
128 | + wp_localize_script('give', 'give_scripts', $localize_give_ajax); |
|
129 | 129 | |
130 | 130 | } |
131 | 131 | |
132 | 132 | } |
133 | 133 | |
134 | -add_action( 'wp_enqueue_scripts', 'give_load_scripts' ); |
|
134 | +add_action('wp_enqueue_scripts', 'give_load_scripts'); |
|
135 | 135 | |
136 | 136 | /** |
137 | 137 | * Register styles. |
@@ -144,16 +144,16 @@ discard block |
||
144 | 144 | */ |
145 | 145 | function give_register_styles() { |
146 | 146 | |
147 | - if ( ! give_is_setting_enabled( give_get_option( 'css' ) ) ) { |
|
147 | + if ( ! give_is_setting_enabled(give_get_option('css'))) { |
|
148 | 148 | return; |
149 | 149 | } |
150 | 150 | |
151 | - wp_register_style( 'give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all' ); |
|
152 | - wp_enqueue_style( 'give-styles' ); |
|
151 | + wp_register_style('give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all'); |
|
152 | + wp_enqueue_style('give-styles'); |
|
153 | 153 | |
154 | 154 | } |
155 | 155 | |
156 | -add_action( 'wp_enqueue_scripts', 'give_register_styles' ); |
|
156 | +add_action('wp_enqueue_scripts', 'give_register_styles'); |
|
157 | 157 | |
158 | 158 | |
159 | 159 | /** |
@@ -166,19 +166,19 @@ discard block |
||
166 | 166 | function give_get_stylesheet_uri() { |
167 | 167 | |
168 | 168 | // Use minified libraries if SCRIPT_DEBUG is turned off. |
169 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
169 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
170 | 170 | |
171 | 171 | // LTR or RTL files. |
172 | - $direction = ( is_rtl() ) ? '-rtl' : ''; |
|
172 | + $direction = (is_rtl()) ? '-rtl' : ''; |
|
173 | 173 | |
174 | - $file = 'give' . $direction . $suffix . '.css'; |
|
174 | + $file = 'give'.$direction.$suffix.'.css'; |
|
175 | 175 | $templates_dir = give_get_theme_template_dir_name(); |
176 | 176 | |
177 | - $child_theme_style_sheet = trailingslashit( get_stylesheet_directory() ) . $templates_dir . $file; |
|
178 | - $child_theme_style_sheet_2 = trailingslashit( get_stylesheet_directory() ) . $templates_dir . 'give' . $direction . '.css'; |
|
179 | - $parent_theme_style_sheet = trailingslashit( get_template_directory() ) . $templates_dir . $file; |
|
180 | - $parent_theme_style_sheet_2 = trailingslashit( get_template_directory() ) . $templates_dir . 'give' . $direction . '.css'; |
|
181 | - $give_plugin_style_sheet = trailingslashit( give_get_templates_dir() ) . $file; |
|
177 | + $child_theme_style_sheet = trailingslashit(get_stylesheet_directory()).$templates_dir.$file; |
|
178 | + $child_theme_style_sheet_2 = trailingslashit(get_stylesheet_directory()).$templates_dir.'give'.$direction.'.css'; |
|
179 | + $parent_theme_style_sheet = trailingslashit(get_template_directory()).$templates_dir.$file; |
|
180 | + $parent_theme_style_sheet_2 = trailingslashit(get_template_directory()).$templates_dir.'give'.$direction.'.css'; |
|
181 | + $give_plugin_style_sheet = trailingslashit(give_get_templates_dir()).$file; |
|
182 | 182 | |
183 | 183 | $uri = false; |
184 | 184 | |
@@ -188,23 +188,23 @@ discard block |
||
188 | 188 | * followed by non minified version, even if SCRIPT_DEBUG is not enabled. |
189 | 189 | * This allows users to copy just give.css to their theme. |
190 | 190 | */ |
191 | - if ( file_exists( $child_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $child_theme_style_sheet_2 ) ) ) ) { |
|
192 | - if ( ! empty( $nonmin ) ) { |
|
193 | - $uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . 'give' . $direction . '.css'; |
|
191 | + if (file_exists($child_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($child_theme_style_sheet_2)))) { |
|
192 | + if ( ! empty($nonmin)) { |
|
193 | + $uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.'give'.$direction.'.css'; |
|
194 | 194 | } else { |
195 | - $uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . $file; |
|
195 | + $uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.$file; |
|
196 | 196 | } |
197 | - } elseif ( file_exists( $parent_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $parent_theme_style_sheet_2 ) ) ) ) { |
|
198 | - if ( ! empty( $nonmin ) ) { |
|
199 | - $uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . 'give' . $direction . '.css'; |
|
197 | + } elseif (file_exists($parent_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($parent_theme_style_sheet_2)))) { |
|
198 | + if ( ! empty($nonmin)) { |
|
199 | + $uri = trailingslashit(get_template_directory_uri()).$templates_dir.'give'.$direction.'.css'; |
|
200 | 200 | } else { |
201 | - $uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . $file; |
|
201 | + $uri = trailingslashit(get_template_directory_uri()).$templates_dir.$file; |
|
202 | 202 | } |
203 | - } elseif ( file_exists( $give_plugin_style_sheet ) || file_exists( $give_plugin_style_sheet ) ) { |
|
204 | - $uri = trailingslashit( give_get_templates_url() ) . $file; |
|
203 | + } elseif (file_exists($give_plugin_style_sheet) || file_exists($give_plugin_style_sheet)) { |
|
204 | + $uri = trailingslashit(give_get_templates_url()).$file; |
|
205 | 205 | } |
206 | 206 | |
207 | - return apply_filters( 'give_get_stylesheet_uri', $uri ); |
|
207 | + return apply_filters('give_get_stylesheet_uri', $uri); |
|
208 | 208 | |
209 | 209 | } |
210 | 210 | |
@@ -221,73 +221,73 @@ discard block |
||
221 | 221 | * |
222 | 222 | * @return void |
223 | 223 | */ |
224 | -function give_load_admin_scripts( $hook ) { |
|
224 | +function give_load_admin_scripts($hook) { |
|
225 | 225 | |
226 | 226 | global $post, $post_type; |
227 | 227 | |
228 | 228 | $give_options = give_get_settings(); |
229 | 229 | |
230 | 230 | // Directories of assets. |
231 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/admin/'; |
|
232 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
233 | - $css_dir = GIVE_PLUGIN_URL . 'assets/css/'; |
|
231 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/admin/'; |
|
232 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
233 | + $css_dir = GIVE_PLUGIN_URL.'assets/css/'; |
|
234 | 234 | |
235 | 235 | // Use minified libraries if SCRIPT_DEBUG is turned off. |
236 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
236 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
237 | 237 | |
238 | 238 | // LTR or RTL files. |
239 | - $direction = ( is_rtl() ) ? '-rtl' : ''; |
|
239 | + $direction = (is_rtl()) ? '-rtl' : ''; |
|
240 | 240 | |
241 | 241 | // Global Admin. |
242 | - wp_register_style( 'give-admin-bar-notification', $css_dir . 'adminbar-style.css' ); |
|
243 | - wp_enqueue_style( 'give-admin-bar-notification' ); |
|
242 | + wp_register_style('give-admin-bar-notification', $css_dir.'adminbar-style.css'); |
|
243 | + wp_enqueue_style('give-admin-bar-notification'); |
|
244 | 244 | |
245 | 245 | // Give Admin Only. |
246 | - if ( ! apply_filters( 'give_load_admin_scripts', give_is_admin_page(), $hook ) ) { |
|
246 | + if ( ! apply_filters('give_load_admin_scripts', give_is_admin_page(), $hook)) { |
|
247 | 247 | return; |
248 | 248 | } |
249 | 249 | |
250 | 250 | // CSS. |
251 | - wp_register_style( 'jquery-ui-css', $css_dir . 'jquery-ui-fresh' . $suffix . '.css' ); |
|
252 | - wp_enqueue_style( 'jquery-ui-css' ); |
|
253 | - wp_register_style( 'give-admin', $css_dir . 'give-admin' . $direction . $suffix . '.css', array(), GIVE_VERSION ); |
|
254 | - wp_enqueue_style( 'give-admin' ); |
|
255 | - wp_register_style( 'jquery-chosen', $css_dir . 'chosen' . $suffix . '.css', array(), GIVE_VERSION ); |
|
256 | - wp_enqueue_style( 'jquery-chosen' ); |
|
257 | - wp_enqueue_style( 'thickbox' ); |
|
251 | + wp_register_style('jquery-ui-css', $css_dir.'jquery-ui-fresh'.$suffix.'.css'); |
|
252 | + wp_enqueue_style('jquery-ui-css'); |
|
253 | + wp_register_style('give-admin', $css_dir.'give-admin'.$direction.$suffix.'.css', array(), GIVE_VERSION); |
|
254 | + wp_enqueue_style('give-admin'); |
|
255 | + wp_register_style('jquery-chosen', $css_dir.'chosen'.$suffix.'.css', array(), GIVE_VERSION); |
|
256 | + wp_enqueue_style('jquery-chosen'); |
|
257 | + wp_enqueue_style('thickbox'); |
|
258 | 258 | |
259 | 259 | // JS. |
260 | - wp_register_script( 'jquery-chosen', $js_plugins . 'chosen.jquery' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION ); |
|
261 | - wp_enqueue_script( 'jquery-chosen' ); |
|
260 | + wp_register_script('jquery-chosen', $js_plugins.'chosen.jquery'.$suffix.'.js', array('jquery'), GIVE_VERSION); |
|
261 | + wp_enqueue_script('jquery-chosen'); |
|
262 | 262 | |
263 | - wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
264 | - wp_enqueue_script( 'give-accounting' ); |
|
263 | + wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
264 | + wp_enqueue_script('give-accounting'); |
|
265 | 265 | |
266 | - wp_register_script( 'give-admin-scripts', $js_dir . 'admin-scripts' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
267 | - wp_enqueue_script( 'give-admin-scripts' ); |
|
266 | + wp_register_script('give-admin-scripts', $js_dir.'admin-scripts'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
267 | + wp_enqueue_script('give-admin-scripts'); |
|
268 | 268 | |
269 | - wp_register_script( 'jquery-flot', $js_plugins . 'jquery.flot' . $suffix . '.js' ); |
|
270 | - wp_enqueue_script( 'jquery-flot' ); |
|
269 | + wp_register_script('jquery-flot', $js_plugins.'jquery.flot'.$suffix.'.js'); |
|
270 | + wp_enqueue_script('jquery-flot'); |
|
271 | 271 | |
272 | - wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
273 | - wp_enqueue_script( 'give-qtip' ); |
|
272 | + wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
273 | + wp_enqueue_script('give-qtip'); |
|
274 | 274 | |
275 | - wp_register_script( 'give-repeatable-fields', $js_plugins . 'repeatable-fields' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
276 | - wp_enqueue_script( 'give-repeatable-fields' ); |
|
275 | + wp_register_script('give-repeatable-fields', $js_plugins.'repeatable-fields'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
276 | + wp_enqueue_script('give-repeatable-fields'); |
|
277 | 277 | |
278 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
279 | - wp_enqueue_script( 'thickbox' ); |
|
278 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
279 | + wp_enqueue_script('thickbox'); |
|
280 | 280 | |
281 | 281 | // Forms CPT Script. |
282 | - if ( $post_type === 'give_forms' ) { |
|
283 | - wp_register_script( 'give-admin-forms-scripts', $js_dir . 'admin-forms' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
284 | - wp_enqueue_script( 'give-admin-forms-scripts' ); |
|
282 | + if ($post_type === 'give_forms') { |
|
283 | + wp_register_script('give-admin-forms-scripts', $js_dir.'admin-forms'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
284 | + wp_enqueue_script('give-admin-forms-scripts'); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | // Settings Scripts. |
288 | - if ( isset( $_GET['page'] ) && $_GET['page'] == 'give-settings' ) { |
|
289 | - wp_register_script( 'give-admin-settings-scripts', $js_dir . 'admin-settings' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
290 | - wp_enqueue_script( 'give-admin-settings-scripts' ); |
|
288 | + if (isset($_GET['page']) && $_GET['page'] == 'give-settings') { |
|
289 | + wp_register_script('give-admin-settings-scripts', $js_dir.'admin-settings'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
290 | + wp_enqueue_script('give-admin-settings-scripts'); |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | // Price Separators. |
@@ -295,60 +295,60 @@ discard block |
||
295 | 295 | $decimal_separator = give_get_price_decimal_separator(); |
296 | 296 | |
297 | 297 | // Localize strings & variables for JS. |
298 | - wp_localize_script( 'give-admin-scripts', 'give_vars', array( |
|
299 | - 'post_id' => isset( $post->ID ) ? $post->ID : null, |
|
298 | + wp_localize_script('give-admin-scripts', 'give_vars', array( |
|
299 | + 'post_id' => isset($post->ID) ? $post->ID : null, |
|
300 | 300 | 'give_version' => GIVE_VERSION, |
301 | 301 | 'thousands_separator' => $thousand_separator, |
302 | 302 | 'decimal_separator' => $decimal_separator, |
303 | - 'quick_edit_warning' => __( 'Not available for variable priced forms.', 'give' ), |
|
304 | - 'delete_payment' => __( 'Are you sure you wish to delete this payment?', 'give' ), |
|
305 | - 'delete_payment_note' => __( 'Are you sure you wish to delete this note?', 'give' ), |
|
306 | - 'revoke_api_key' => __( 'Are you sure you wish to revoke this API key?', 'give' ), |
|
307 | - 'regenerate_api_key' => __( 'Are you sure you wish to regenerate this API key?', 'give' ), |
|
308 | - 'resend_receipt' => __( 'Are you sure you wish to resend the donation receipt?', 'give' ), |
|
309 | - 'logo' => __( 'Logo', 'give' ), |
|
310 | - 'use_this_image' => __( 'Use this image', 'give' ), |
|
311 | - 'one_option' => __( 'Choose a form', 'give' ), |
|
312 | - 'one_or_more_option' => __( 'Choose one or more forms', 'give' ), |
|
313 | - 'currency_sign' => give_currency_filter( '' ), |
|
314 | - 'currency_pos' => isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before', |
|
315 | - 'currency_decimals' => give_currency_decimal_filter( give_get_price_decimals() ), |
|
316 | - 'batch_export_no_class' => __( 'You must choose a method.', 'give' ), |
|
317 | - 'batch_export_no_reqs' => __( 'Required fields not completed.', 'give' ), |
|
318 | - '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' ), |
|
319 | - 'price_format_guide' => sprintf( __( 'Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give' ), $decimal_separator, $thousand_separator ), |
|
303 | + 'quick_edit_warning' => __('Not available for variable priced forms.', 'give'), |
|
304 | + 'delete_payment' => __('Are you sure you wish to delete this payment?', 'give'), |
|
305 | + 'delete_payment_note' => __('Are you sure you wish to delete this note?', 'give'), |
|
306 | + 'revoke_api_key' => __('Are you sure you wish to revoke this API key?', 'give'), |
|
307 | + 'regenerate_api_key' => __('Are you sure you wish to regenerate this API key?', 'give'), |
|
308 | + 'resend_receipt' => __('Are you sure you wish to resend the donation receipt?', 'give'), |
|
309 | + 'logo' => __('Logo', 'give'), |
|
310 | + 'use_this_image' => __('Use this image', 'give'), |
|
311 | + 'one_option' => __('Choose a form', 'give'), |
|
312 | + 'one_or_more_option' => __('Choose one or more forms', 'give'), |
|
313 | + 'currency_sign' => give_currency_filter(''), |
|
314 | + 'currency_pos' => isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before', |
|
315 | + 'currency_decimals' => give_currency_decimal_filter(give_get_price_decimals()), |
|
316 | + 'batch_export_no_class' => __('You must choose a method.', 'give'), |
|
317 | + 'batch_export_no_reqs' => __('Required fields not completed.', 'give'), |
|
318 | + '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'), |
|
319 | + 'price_format_guide' => sprintf(__('Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give'), $decimal_separator, $thousand_separator), |
|
320 | 320 | /* translators : %s: Donation form options metabox */ |
321 | - 'confirm_before_remove_row_text' => __( 'Do you want to delete this level?', 'give' ), |
|
322 | - 'matched_success_failure_page' => __( 'You cannot set the success and failed pages to the same page', 'give' ), |
|
323 | - 'dismiss_notice_text' => __( 'Dismiss this notice.', 'give' ), |
|
321 | + 'confirm_before_remove_row_text' => __('Do you want to delete this level?', 'give'), |
|
322 | + 'matched_success_failure_page' => __('You cannot set the success and failed pages to the same page', 'give'), |
|
323 | + 'dismiss_notice_text' => __('Dismiss this notice.', 'give'), |
|
324 | 324 | 'bulk_action' => array( |
325 | 325 | 'delete' => array( |
326 | - 'zero_payment_selected' => __( 'You must choose at least one or more payments to delete.', 'give' ), |
|
327 | - 'delete_payment' => __( 'Are you sure you want to permanently delete this donation?', 'give' ), |
|
328 | - 'delete_payments' => __( 'Are you sure you want to permanently delete the selected {payment_count} donations?', 'give' ), |
|
326 | + 'zero_payment_selected' => __('You must choose at least one or more payments to delete.', 'give'), |
|
327 | + 'delete_payment' => __('Are you sure you want to permanently delete this donation?', 'give'), |
|
328 | + 'delete_payments' => __('Are you sure you want to permanently delete the selected {payment_count} donations?', 'give'), |
|
329 | 329 | ), |
330 | 330 | 'resend_receipt' => array( |
331 | - 'zero_recipient_selected' => __( 'You must choose at least one or more recipients to resend the email receipt.', 'give' ), |
|
332 | - 'resend_receipt' => __( 'Are you sure you want to resend the email receipt to this recipient?', 'give' ), |
|
333 | - 'resend_receipts' => __( 'Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give' ), |
|
331 | + 'zero_recipient_selected' => __('You must choose at least one or more recipients to resend the email receipt.', 'give'), |
|
332 | + 'resend_receipt' => __('Are you sure you want to resend the email receipt to this recipient?', 'give'), |
|
333 | + 'resend_receipts' => __('Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give'), |
|
334 | 334 | ), |
335 | 335 | ), |
336 | - 'upgrade_confirmation' => __( 'Please make sure to create a database backup before initiating the upgrade.', 'give' ), |
|
336 | + 'upgrade_confirmation' => __('Please make sure to create a database backup before initiating the upgrade.', 'give'), |
|
337 | 337 | 'metabox_fields' => array( |
338 | 338 | 'media' => array( |
339 | - 'button_title' => esc_html__( 'Choose Attachment', 'give' ), |
|
339 | + 'button_title' => esc_html__('Choose Attachment', 'give'), |
|
340 | 340 | ) |
341 | 341 | ) |
342 | - ) ); |
|
342 | + )); |
|
343 | 343 | |
344 | - if ( function_exists( 'wp_enqueue_media' ) && version_compare( get_bloginfo( 'version' ), '3.5', '>=' ) ) { |
|
344 | + if (function_exists('wp_enqueue_media') && version_compare(get_bloginfo('version'), '3.5', '>=')) { |
|
345 | 345 | // call for new media manager. |
346 | 346 | wp_enqueue_media(); |
347 | 347 | } |
348 | 348 | |
349 | 349 | } |
350 | 350 | |
351 | -add_action( 'admin_enqueue_scripts', 'give_load_admin_scripts', 100 ); |
|
351 | +add_action('admin_enqueue_scripts', 'give_load_admin_scripts', 100); |
|
352 | 352 | |
353 | 353 | /** |
354 | 354 | * Admin Give Icon |
@@ -363,13 +363,13 @@ discard block |
||
363 | 363 | ?> |
364 | 364 | <style type="text/css" media="screen"> |
365 | 365 | |
366 | - <?php if ( version_compare( get_bloginfo( 'version' ), '3.8-RC', '>=' ) || version_compare( get_bloginfo( 'version' ), '3.8', '>=' ) ) { ?> |
|
366 | + <?php if (version_compare(get_bloginfo('version'), '3.8-RC', '>=') || version_compare(get_bloginfo('version'), '3.8', '>=')) { ?> |
|
367 | 367 | @font-face { |
368 | 368 | font-family: 'give-icomoon'; |
369 | - src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?-ngjl88'; ?>'); |
|
370 | - src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?#iefix-ngjl88'?>') format('embedded-opentype'), |
|
371 | - url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.woff?-ngjl88'; ?>') format('woff'), |
|
372 | - url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.svg?-ngjl88#icomoon'; ?>') format('svg'); |
|
369 | + src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?-ngjl88'; ?>'); |
|
370 | + src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?#iefix-ngjl88'?>') format('embedded-opentype'), |
|
371 | + url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.woff?-ngjl88'; ?>') format('woff'), |
|
372 | + url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.svg?-ngjl88#icomoon'; ?>') format('svg'); |
|
373 | 373 | font-weight: normal; |
374 | 374 | font-style: normal; |
375 | 375 | } |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | <?php |
389 | 389 | } |
390 | 390 | |
391 | -add_action( 'admin_head', 'give_admin_icon' ); |
|
391 | +add_action('admin_head', 'give_admin_icon'); |
|
392 | 392 | |
393 | 393 | /** |
394 | 394 | * Admin js code |
@@ -418,4 +418,4 @@ discard block |
||
418 | 418 | <?php |
419 | 419 | } |
420 | 420 | |
421 | -add_action( 'admin_head', 'give_admin_hide_notice_shortly_js' ); |
|
421 | +add_action('admin_head', 'give_admin_hide_notice_shortly_js'); |