@@ -7,12 +7,12 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 | |
14 | 14 | <div class='form-group'> |
15 | - <label :for="active_form_element.id + '_edit'"><?php esc_html_e( 'Enter your text', 'invoicing' ) ?></label> |
|
15 | + <label :for="active_form_element.id + '_edit'"><?php esc_html_e('Enter your text', 'invoicing') ?></label> |
|
16 | 16 | <textarea :id="active_form_element.id + '_edit'" v-model='active_form_element.text' class='form-control' rows='3'></textarea> |
17 | - <small class="form-text text-muted"><?php _e( 'HTML is allowed', 'invoicing' ); ?></small> |
|
17 | + <small class="form-text text-muted"><?php _e('HTML is allowed', 'invoicing'); ?></small> |
|
18 | 18 | </div> |
@@ -7,54 +7,54 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 | |
14 | 14 | <small class='form-text text-muted mb-2'> |
15 | - <?php esc_html_e( 'This amount will be added to the total amount for this form', 'invoicing' ); ?> |
|
15 | + <?php esc_html_e('This amount will be added to the total amount for this form', 'invoicing'); ?> |
|
16 | 16 | </small> |
17 | 17 | |
18 | 18 | <div class='form-group'> |
19 | 19 | <label class="d-block"> |
20 | - <span><?php esc_html_e( 'Field Label', 'invoicing' ); ?></span> |
|
20 | + <span><?php esc_html_e('Field Label', 'invoicing'); ?></span> |
|
21 | 21 | <input v-model='active_form_element.label' class='form-control' /> |
22 | 22 | </label> |
23 | 23 | </div> |
24 | 24 | |
25 | 25 | <div class='form-group' v-if="active_form_element.select_type=='select'"> |
26 | 26 | <label class="d-block"> |
27 | - <span><?php esc_html_e( 'Placeholder text', 'invoicing' ); ?></span> |
|
27 | + <span><?php esc_html_e('Placeholder text', 'invoicing'); ?></span> |
|
28 | 28 | <input v-model='active_form_element.placeholder' class='form-control' /> |
29 | 29 | </label> |
30 | 30 | </div> |
31 | 31 | |
32 | 32 | <div class='form-group'> |
33 | 33 | <label class="d-block"> |
34 | - <span><?php esc_html_e( 'Select Type', 'invoicing' ); ?></span> |
|
34 | + <span><?php esc_html_e('Select Type', 'invoicing'); ?></span> |
|
35 | 35 | <select class='form-control custom-select' v-model='active_form_element.select_type'> |
36 | - <option value='select'><?php esc_html_e( 'Dropdown', 'invoicing' ) ?></option> |
|
37 | - <option value='checkboxes'><?php esc_html_e( 'Checkboxes', 'invoicing' ) ?></option> |
|
38 | - <option value='radios'><?php esc_html_e( 'Radio Buttons', 'invoicing' ) ?></option> |
|
39 | - <option value='buttons'><?php esc_html_e( 'Buttons', 'invoicing' ) ?></option> |
|
40 | - <option value='circles'><?php esc_html_e( 'Circles', 'invoicing' ) ?></option> |
|
36 | + <option value='select'><?php esc_html_e('Dropdown', 'invoicing') ?></option> |
|
37 | + <option value='checkboxes'><?php esc_html_e('Checkboxes', 'invoicing') ?></option> |
|
38 | + <option value='radios'><?php esc_html_e('Radio Buttons', 'invoicing') ?></option> |
|
39 | + <option value='buttons'><?php esc_html_e('Buttons', 'invoicing') ?></option> |
|
40 | + <option value='circles'><?php esc_html_e('Circles', 'invoicing') ?></option> |
|
41 | 41 | </select> |
42 | 42 | </label> |
43 | 43 | </div> |
44 | 44 | |
45 | 45 | <div class='form-group'> |
46 | 46 | <label class="d-block"> |
47 | - <span><?php esc_html_e( 'Options', 'invoicing' ); ?></span> |
|
47 | + <span><?php esc_html_e('Options', 'invoicing'); ?></span> |
|
48 | 48 | <textarea placeholder='Basic|10,Pro|99,Business|199' v-model='active_form_element.options' class='form-control' rows='3'></textarea> |
49 | - <small class='form-text text-muted mb-2'><?php esc_html_e( 'Use commas to separate options and pipes to separate a label and its price. Do not include a currency symbol in the price.', 'invoicing' ); ?></small> |
|
49 | + <small class='form-text text-muted mb-2'><?php esc_html_e('Use commas to separate options and pipes to separate a label and its price. Do not include a currency symbol in the price.', 'invoicing'); ?></small> |
|
50 | 50 | </label> |
51 | 51 | </div> |
52 | 52 | |
53 | 53 | <div class='form-group'> |
54 | 54 | <label class="d-block"> |
55 | - <span><?php esc_html_e( 'Help Text', 'invoicing' ); ?></span> |
|
56 | - <textarea placeholder='<?php esc_attr_e( 'Add some help text for this field', 'invoicing' ); ?>' v-model='active_form_element.description' class='form-control' rows='3'></textarea> |
|
57 | - <small class="form-text text-muted"><?php _e( 'HTML is allowed', 'invoicing' ); ?></small> |
|
55 | + <span><?php esc_html_e('Help Text', 'invoicing'); ?></span> |
|
56 | + <textarea placeholder='<?php esc_attr_e('Add some help text for this field', 'invoicing'); ?>' v-model='active_form_element.description' class='form-control' rows='3'></textarea> |
|
57 | + <small class="form-text text-muted"><?php _e('HTML is allowed', 'invoicing'); ?></small> |
|
58 | 58 | </label> |
59 | 59 | </div> |
60 | 60 | |
@@ -62,9 +62,9 @@ discard block |
||
62 | 62 | |
63 | 63 | <div class='form-group'> |
64 | 64 | <label class="d-block"> |
65 | - <span><?php esc_html_e( 'Email Merge Tag', 'invoicing' ); ?></span> |
|
65 | + <span><?php esc_html_e('Email Merge Tag', 'invoicing'); ?></span> |
|
66 | 66 | <input :value='active_form_element.label | formatMergeTag' class='form-control bg-white' type="text" readonly onclick="this.select()" /> |
67 | - <span class="form-text text-muted"><?php esc_html_e( 'You can use this merge tag in notification emails', 'invoicing' ); ?></span> |
|
67 | + <span class="form-text text-muted"><?php esc_html_e('You can use this merge tag in notification emails', 'invoicing'); ?></span> |
|
68 | 68 | </label> |
69 | 69 | </div> |
70 | 70 |
@@ -7,47 +7,47 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 | |
14 | 14 | <small class='form-text text-muted mb-2'> |
15 | - <?php esc_html_e( 'The amount that users add to this field will be added to the total amount for this form', 'invoicing' ); ?> |
|
15 | + <?php esc_html_e('The amount that users add to this field will be added to the total amount for this form', 'invoicing'); ?> |
|
16 | 16 | </small> |
17 | 17 | |
18 | 18 | <div class='form-group'> |
19 | 19 | <label class="d-block"> |
20 | - <span><?php esc_html_e( 'Field Label', 'invoicing' ); ?></span> |
|
20 | + <span><?php esc_html_e('Field Label', 'invoicing'); ?></span> |
|
21 | 21 | <input v-model='active_form_element.label' class='form-control' type="text"/> |
22 | 22 | </label> |
23 | 23 | </div> |
24 | 24 | |
25 | 25 | <div class='form-group'> |
26 | 26 | <label class="d-block"> |
27 | - <span><?php esc_html_e( 'Default Amount', 'invoicing' ); ?></span> |
|
27 | + <span><?php esc_html_e('Default Amount', 'invoicing'); ?></span> |
|
28 | 28 | <input v-model='active_form_element.value' class='form-control' type="text"/> |
29 | 29 | </label> |
30 | 30 | </div> |
31 | 31 | |
32 | 32 | <div class='form-group'> |
33 | 33 | <label class="d-block"> |
34 | - <span><?php esc_html_e( 'Minimum Amount', 'invoicing' ); ?></span> |
|
34 | + <span><?php esc_html_e('Minimum Amount', 'invoicing'); ?></span> |
|
35 | 35 | <input v-model='active_form_element.minimum' class='form-control' type="text"/> |
36 | 36 | </label> |
37 | 37 | </div> |
38 | 38 | |
39 | 39 | <div class='form-group'> |
40 | 40 | <label class="d-block"> |
41 | - <span><?php esc_html_e( 'Placeholder text', 'invoicing' ); ?></span> |
|
41 | + <span><?php esc_html_e('Placeholder text', 'invoicing'); ?></span> |
|
42 | 42 | <input v-model='active_form_element.placeholder' class='form-control' type="text"/> |
43 | 43 | </label> |
44 | 44 | </div> |
45 | 45 | |
46 | 46 | <div class='form-group'> |
47 | 47 | <label class="d-block"> |
48 | - <span><?php esc_html_e( 'Help Text', 'invoicing' ); ?></span> |
|
49 | - <textarea placeholder='<?php esc_attr_e( 'Add some help text for this field', 'invoicing' ); ?>' v-model='active_form_element.description' class='form-control' rows='3'></textarea> |
|
50 | - <small class="form-text text-muted"><?php _e( 'HTML is allowed', 'invoicing' ); ?></small> |
|
48 | + <span><?php esc_html_e('Help Text', 'invoicing'); ?></span> |
|
49 | + <textarea placeholder='<?php esc_attr_e('Add some help text for this field', 'invoicing'); ?>' v-model='active_form_element.description' class='form-control' rows='3'></textarea> |
|
50 | + <small class="form-text text-muted"><?php _e('HTML is allowed', 'invoicing'); ?></small> |
|
51 | 51 | </label> |
52 | 52 | </div> |
53 | 53 | |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | |
56 | 56 | <div class='form-group'> |
57 | 57 | <label class="d-block"> |
58 | - <span><?php esc_html_e( 'Email Merge Tag', 'invoicing' ); ?></span> |
|
58 | + <span><?php esc_html_e('Email Merge Tag', 'invoicing'); ?></span> |
|
59 | 59 | <input :value='active_form_element.label | formatMergeTag' class='form-control bg-white' type="text" readonly onclick="this.select()" /> |
60 | - <span class="form-text text-muted"><?php esc_html_e( 'You can use this merge tag in notification emails', 'invoicing' ); ?></span> |
|
60 | + <span class="form-text text-muted"><?php esc_html_e('You can use this merge tag in notification emails', 'invoicing'); ?></span> |
|
61 | 61 | </label> |
62 | 62 | </div> |
63 | 63 |
@@ -4,29 +4,29 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | $gateways = wpinv_get_payment_gateways(); |
10 | -ksort( $gateways ); |
|
10 | +ksort($gateways); |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 | <div class="table-responsive"> |
14 | 14 | <table id="wpinv_gateways_select" class="table border bg-white form-table"> |
15 | - <caption><?php echo esc_html_e( 'This table displays installed payment methods.', 'invoicing' ); ?></caption> |
|
15 | + <caption><?php echo esc_html_e('This table displays installed payment methods.', 'invoicing'); ?></caption> |
|
16 | 16 | |
17 | 17 | <thead> |
18 | 18 | <tr class="table-light"> |
19 | 19 | |
20 | 20 | <th scope="col" class="border-bottom border-top text-left"> |
21 | - <?php _e( 'Payment Method', 'invoicing' ); ?> |
|
21 | + <?php _e('Payment Method', 'invoicing'); ?> |
|
22 | 22 | </th> |
23 | 23 | |
24 | 24 | <th scope="col" class="border-bottom border-top text-center"> |
25 | - <?php _e( 'Enabled', 'invoicing' ); ?> |
|
25 | + <?php _e('Enabled', 'invoicing'); ?> |
|
26 | 26 | </th> |
27 | 27 | |
28 | 28 | <th scope="col" class="border-bottom border-top text-center"> |
29 | - <?php _e( 'Supports Subscriptions', 'invoicing' ); ?> |
|
29 | + <?php _e('Supports Subscriptions', 'invoicing'); ?> |
|
30 | 30 | </th> |
31 | 31 | |
32 | 32 | <th scope="col" class="border-bottom border-top text-right" style="width:32px"> </th> |
@@ -35,15 +35,15 @@ discard block |
||
35 | 35 | </thead> |
36 | 36 | |
37 | 37 | <tbody> |
38 | - <?php foreach ( $gateways as $id => $gateway ) : ?> |
|
38 | + <?php foreach ($gateways as $id => $gateway) : ?> |
|
39 | 39 | <tr> |
40 | 40 | <td class="getpaid-payment-method text-left"> |
41 | - <a style="color: #0073aa;" href="<?php echo esc_url( add_query_arg( 'section', $id ) ); ?>" class="font-weight-bold"><?php echo sanitize_text_field( $gateway['admin_label'] ); ?></a> |
|
41 | + <a style="color: #0073aa;" href="<?php echo esc_url(add_query_arg('section', $id)); ?>" class="font-weight-bold"><?php echo sanitize_text_field($gateway['admin_label']); ?></a> |
|
42 | 42 | </td> |
43 | 43 | <td class="getpaid-payment-method-enabled text-center"> |
44 | 44 | <?php |
45 | 45 | |
46 | - if ( wpinv_is_gateway_active( $id ) ) { |
|
46 | + if (wpinv_is_gateway_active($id)) { |
|
47 | 47 | echo "<i class='text-success fa fa-check'></i>"; |
48 | 48 | } else { |
49 | 49 | echo "<i class='text-dark fa fa-times'></i>"; |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | <td class="getpaid-payment-method-subscription text-center"> |
55 | 55 | <?php |
56 | 56 | |
57 | - $supports = apply_filters( "wpinv_{$id}_support_subscription", false ); |
|
58 | - $supports = apply_filters( 'getapid_gateway_supports_subscription', $supports, $id ); |
|
57 | + $supports = apply_filters("wpinv_{$id}_support_subscription", false); |
|
58 | + $supports = apply_filters('getapid_gateway_supports_subscription', $supports, $id); |
|
59 | 59 | |
60 | - if ( $supports ) { |
|
60 | + if ($supports) { |
|
61 | 61 | echo "<i class='text-success fa fa-check'></i>"; |
62 | 62 | } else { |
63 | 63 | echo "<i class='text-dark fa fa-times'></i>"; |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | </td> |
68 | 68 | |
69 | 69 | <td class="getpaid-payment-method-action text-right"> |
70 | - <a class="button button-secondary" href="<?php echo esc_url( add_query_arg( 'section', $id ) ); ?>"><?php _e( 'Manage', 'invoicing' ); ?></a> |
|
70 | + <a class="button button-secondary" href="<?php echo esc_url(add_query_arg('section', $id)); ?>"><?php _e('Manage', 'invoicing'); ?></a> |
|
71 | 71 | </td> |
72 | 72 | |
73 | 73 | </tr> |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | <tfoot> |
78 | 78 | <tr class="table-light"> |
79 | 79 | <td colspan="4" class="border-top"> |
80 | - <a class="button button-secondary getpaid-install-gateways" href="<?php echo esc_url( admin_url( 'admin.php?page=wpi-addons&tab=gateways' ) ); ?>"> |
|
81 | - <span><?php _e( 'Add Payment Methods', 'invoicing' ); ?></span> |
|
80 | + <a class="button button-secondary getpaid-install-gateways" href="<?php echo esc_url(admin_url('admin.php?page=wpi-addons&tab=gateways')); ?>"> |
|
81 | + <span><?php _e('Add Payment Methods', 'invoicing'); ?></span> |
|
82 | 82 | </a> |
83 | 83 | </td> |
84 | 84 | </tr> |
@@ -13,464 +13,464 @@ discard block |
||
13 | 13 | */ |
14 | 14 | abstract class GetPaid_Payment_Gateway { |
15 | 15 | |
16 | - /** |
|
17 | - * Set if the place checkout button should be renamed on selection. |
|
18 | - * |
|
19 | - * @var string |
|
20 | - */ |
|
21 | - public $checkout_button_text; |
|
22 | - |
|
23 | - /** |
|
24 | - * Boolean whether the method is enabled. |
|
25 | - * |
|
26 | - * @var bool |
|
27 | - */ |
|
28 | - public $enabled = true; |
|
29 | - |
|
30 | - /** |
|
31 | - * Payment method id. |
|
32 | - * |
|
33 | - * @var string |
|
34 | - */ |
|
35 | - public $id; |
|
36 | - |
|
37 | - /** |
|
38 | - * Payment method order. |
|
39 | - * |
|
40 | - * @var int |
|
41 | - */ |
|
42 | - public $order = 10; |
|
43 | - |
|
44 | - /** |
|
45 | - * Payment method title for the frontend. |
|
46 | - * |
|
47 | - * @var string |
|
48 | - */ |
|
49 | - public $title; |
|
50 | - |
|
51 | - /** |
|
52 | - * Payment method description for the frontend. |
|
53 | - * |
|
54 | - * @var string |
|
55 | - */ |
|
56 | - public $description; |
|
57 | - |
|
58 | - /** |
|
59 | - * Gateway title. |
|
60 | - * |
|
61 | - * @var string |
|
62 | - */ |
|
63 | - public $method_title = ''; |
|
64 | - |
|
65 | - /** |
|
66 | - * Gateway description. |
|
67 | - * |
|
68 | - * @var string |
|
69 | - */ |
|
70 | - public $method_description = ''; |
|
71 | - |
|
72 | - /** |
|
73 | - * Countries this gateway is allowed for. |
|
74 | - * |
|
75 | - * @var array |
|
76 | - */ |
|
77 | - public $countries; |
|
78 | - |
|
79 | - /** |
|
80 | - * Currencies this gateway is allowed for. |
|
81 | - * |
|
82 | - * @var array |
|
83 | - */ |
|
84 | - public $currencies; |
|
85 | - |
|
86 | - /** |
|
87 | - * Currencies this gateway is not allowed for. |
|
88 | - * |
|
89 | - * @var array |
|
90 | - */ |
|
91 | - public $exclude_currencies; |
|
92 | - |
|
93 | - /** |
|
94 | - * Maximum transaction amount, zero does not define a maximum. |
|
95 | - * |
|
96 | - * @var int |
|
97 | - */ |
|
98 | - public $max_amount = 0; |
|
99 | - |
|
100 | - /** |
|
101 | - * Optional URL to view a transaction. |
|
102 | - * |
|
103 | - * @var string |
|
104 | - */ |
|
105 | - public $view_transaction_url = ''; |
|
106 | - |
|
107 | - /** |
|
108 | - * Optional URL to view a subscription. |
|
109 | - * |
|
110 | - * @var string |
|
111 | - */ |
|
112 | - public $view_subscription_url = ''; |
|
113 | - |
|
114 | - /** |
|
115 | - * Optional label to show for "new payment method" in the payment |
|
116 | - * method/token selection radio selection. |
|
117 | - * |
|
118 | - * @var string |
|
119 | - */ |
|
120 | - public $new_method_label = ''; |
|
121 | - |
|
122 | - /** |
|
123 | - * Contains a user's saved tokens for this gateway. |
|
124 | - * |
|
125 | - * @var array |
|
126 | - */ |
|
127 | - protected $tokens = array(); |
|
128 | - |
|
129 | - /** |
|
130 | - * An array of features that this gateway supports. |
|
131 | - * |
|
132 | - * @var array |
|
133 | - */ |
|
134 | - protected $supports = array(); |
|
135 | - |
|
136 | - /** |
|
137 | - * Class constructor. |
|
138 | - */ |
|
139 | - public function __construct() { |
|
140 | - |
|
141 | - // Register gateway. |
|
142 | - add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) ); |
|
143 | - |
|
144 | - $this->enabled = wpinv_is_gateway_active( $this->id ); |
|
145 | - |
|
146 | - // Add support for various features. |
|
147 | - foreach ( $this->supports as $feature ) { |
|
148 | - add_filter( "wpinv_{$this->id}_support_{$feature}", '__return_true' ); |
|
149 | - add_filter( "getpaid_{$this->id}_support_{$feature}", '__return_true' ); |
|
150 | - add_filter( "getpaid_{$this->id}_supports_{$feature}", '__return_true' ); |
|
151 | - } |
|
152 | - |
|
153 | - // Invoice addons. |
|
154 | - if ( $this->supports( 'addons' ) ) { |
|
155 | - add_action( "getpaid_process_{$this->id}_invoice_addons", array( $this, 'process_addons' ), 10, 2 ); |
|
156 | - } |
|
157 | - |
|
158 | - // Gateway settings. |
|
159 | - add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) ); |
|
16 | + /** |
|
17 | + * Set if the place checkout button should be renamed on selection. |
|
18 | + * |
|
19 | + * @var string |
|
20 | + */ |
|
21 | + public $checkout_button_text; |
|
22 | + |
|
23 | + /** |
|
24 | + * Boolean whether the method is enabled. |
|
25 | + * |
|
26 | + * @var bool |
|
27 | + */ |
|
28 | + public $enabled = true; |
|
29 | + |
|
30 | + /** |
|
31 | + * Payment method id. |
|
32 | + * |
|
33 | + * @var string |
|
34 | + */ |
|
35 | + public $id; |
|
36 | + |
|
37 | + /** |
|
38 | + * Payment method order. |
|
39 | + * |
|
40 | + * @var int |
|
41 | + */ |
|
42 | + public $order = 10; |
|
43 | + |
|
44 | + /** |
|
45 | + * Payment method title for the frontend. |
|
46 | + * |
|
47 | + * @var string |
|
48 | + */ |
|
49 | + public $title; |
|
50 | + |
|
51 | + /** |
|
52 | + * Payment method description for the frontend. |
|
53 | + * |
|
54 | + * @var string |
|
55 | + */ |
|
56 | + public $description; |
|
57 | + |
|
58 | + /** |
|
59 | + * Gateway title. |
|
60 | + * |
|
61 | + * @var string |
|
62 | + */ |
|
63 | + public $method_title = ''; |
|
64 | + |
|
65 | + /** |
|
66 | + * Gateway description. |
|
67 | + * |
|
68 | + * @var string |
|
69 | + */ |
|
70 | + public $method_description = ''; |
|
71 | + |
|
72 | + /** |
|
73 | + * Countries this gateway is allowed for. |
|
74 | + * |
|
75 | + * @var array |
|
76 | + */ |
|
77 | + public $countries; |
|
78 | + |
|
79 | + /** |
|
80 | + * Currencies this gateway is allowed for. |
|
81 | + * |
|
82 | + * @var array |
|
83 | + */ |
|
84 | + public $currencies; |
|
85 | + |
|
86 | + /** |
|
87 | + * Currencies this gateway is not allowed for. |
|
88 | + * |
|
89 | + * @var array |
|
90 | + */ |
|
91 | + public $exclude_currencies; |
|
92 | + |
|
93 | + /** |
|
94 | + * Maximum transaction amount, zero does not define a maximum. |
|
95 | + * |
|
96 | + * @var int |
|
97 | + */ |
|
98 | + public $max_amount = 0; |
|
99 | + |
|
100 | + /** |
|
101 | + * Optional URL to view a transaction. |
|
102 | + * |
|
103 | + * @var string |
|
104 | + */ |
|
105 | + public $view_transaction_url = ''; |
|
106 | + |
|
107 | + /** |
|
108 | + * Optional URL to view a subscription. |
|
109 | + * |
|
110 | + * @var string |
|
111 | + */ |
|
112 | + public $view_subscription_url = ''; |
|
113 | + |
|
114 | + /** |
|
115 | + * Optional label to show for "new payment method" in the payment |
|
116 | + * method/token selection radio selection. |
|
117 | + * |
|
118 | + * @var string |
|
119 | + */ |
|
120 | + public $new_method_label = ''; |
|
121 | + |
|
122 | + /** |
|
123 | + * Contains a user's saved tokens for this gateway. |
|
124 | + * |
|
125 | + * @var array |
|
126 | + */ |
|
127 | + protected $tokens = array(); |
|
128 | + |
|
129 | + /** |
|
130 | + * An array of features that this gateway supports. |
|
131 | + * |
|
132 | + * @var array |
|
133 | + */ |
|
134 | + protected $supports = array(); |
|
135 | + |
|
136 | + /** |
|
137 | + * Class constructor. |
|
138 | + */ |
|
139 | + public function __construct() { |
|
140 | + |
|
141 | + // Register gateway. |
|
142 | + add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) ); |
|
143 | + |
|
144 | + $this->enabled = wpinv_is_gateway_active( $this->id ); |
|
145 | + |
|
146 | + // Add support for various features. |
|
147 | + foreach ( $this->supports as $feature ) { |
|
148 | + add_filter( "wpinv_{$this->id}_support_{$feature}", '__return_true' ); |
|
149 | + add_filter( "getpaid_{$this->id}_support_{$feature}", '__return_true' ); |
|
150 | + add_filter( "getpaid_{$this->id}_supports_{$feature}", '__return_true' ); |
|
151 | + } |
|
152 | + |
|
153 | + // Invoice addons. |
|
154 | + if ( $this->supports( 'addons' ) ) { |
|
155 | + add_action( "getpaid_process_{$this->id}_invoice_addons", array( $this, 'process_addons' ), 10, 2 ); |
|
156 | + } |
|
157 | + |
|
158 | + // Gateway settings. |
|
159 | + add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) ); |
|
160 | 160 | |
161 | 161 | |
162 | - // Gateway checkout fiellds. |
|
163 | - add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 ); |
|
164 | - |
|
165 | - // Process payment. |
|
166 | - add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 ); |
|
167 | - |
|
168 | - // Change the checkout button text. |
|
169 | - if ( ! empty( $this->checkout_button_text ) ) { |
|
170 | - add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) ); |
|
171 | - } |
|
172 | - |
|
173 | - // Check if a gateway is valid for a given currency. |
|
174 | - add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 ); |
|
175 | - |
|
176 | - // Generate the transaction url. |
|
177 | - add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 ); |
|
178 | - |
|
179 | - // Generate the subscription url. |
|
180 | - add_filter( 'getpaid_remote_subscription_profile_url', array( $this, 'generate_subscription_url' ), 10, 2 ); |
|
181 | - |
|
182 | - // Confirm payments. |
|
183 | - add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 ); |
|
184 | - |
|
185 | - // Verify IPNs. |
|
186 | - add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) ); |
|
187 | - |
|
188 | - } |
|
189 | - |
|
190 | - /** |
|
191 | - * Checks if this gateway is a given gateway. |
|
192 | - * |
|
193 | - * @since 1.0.19 |
|
194 | - * @return bool |
|
195 | - */ |
|
196 | - public function is( $gateway ) { |
|
197 | - return $gateway == $this->id; |
|
198 | - } |
|
199 | - |
|
200 | - /** |
|
201 | - * Returns a users saved tokens for this gateway. |
|
202 | - * |
|
203 | - * @since 1.0.19 |
|
204 | - * @return array |
|
205 | - */ |
|
206 | - public function get_tokens( $sandbox = null ) { |
|
207 | - |
|
208 | - if ( is_user_logged_in() && $this->supports( 'tokens' ) && 0 == count( $this->tokens ) ) { |
|
209 | - $tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true ); |
|
210 | - |
|
211 | - if ( is_array( $tokens ) ) { |
|
212 | - $this->tokens = $tokens; |
|
213 | - } |
|
214 | - |
|
215 | - } |
|
216 | - |
|
217 | - if ( ! is_bool( $sandbox ) ) { |
|
218 | - return $this->tokens; |
|
219 | - } |
|
220 | - |
|
221 | - // Filter tokens. |
|
222 | - $args = array( 'type' => $sandbox ? 'sandbox' : 'live' ); |
|
223 | - return wp_list_filter( $this->tokens, $args ); |
|
224 | - |
|
225 | - } |
|
226 | - |
|
227 | - /** |
|
228 | - * Saves a token for this gateway. |
|
229 | - * |
|
230 | - * @since 1.0.19 |
|
231 | - */ |
|
232 | - public function save_token( $token ) { |
|
233 | - |
|
234 | - $tokens = $this->get_tokens(); |
|
235 | - $tokens[] = $token; |
|
236 | - |
|
237 | - update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens ); |
|
238 | - |
|
239 | - $this->tokens = $tokens; |
|
240 | - |
|
241 | - } |
|
242 | - |
|
243 | - /** |
|
244 | - * Return the title for admin screens. |
|
245 | - * |
|
246 | - * @return string |
|
247 | - */ |
|
248 | - public function get_method_title() { |
|
249 | - return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this ); |
|
250 | - } |
|
251 | - |
|
252 | - /** |
|
253 | - * Return the description for admin screens. |
|
254 | - * |
|
255 | - * @return string |
|
256 | - */ |
|
257 | - public function get_method_description() { |
|
258 | - return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this ); |
|
259 | - } |
|
260 | - |
|
261 | - /** |
|
262 | - * Get the success url. |
|
263 | - * |
|
264 | - * @param WPInv_Invoice $invoice Invoice object. |
|
265 | - * @return string |
|
266 | - */ |
|
267 | - public function get_return_url( $invoice ) { |
|
268 | - |
|
269 | - // Payment success url |
|
270 | - $return_url = add_query_arg( |
|
271 | - array( |
|
272 | - 'payment-confirm' => $this->id, |
|
273 | - 'invoice_key' => $invoice->get_key(), |
|
274 | - 'utm_nooverride' => 1 |
|
275 | - ), |
|
276 | - wpinv_get_success_page_uri() |
|
277 | - ); |
|
278 | - |
|
279 | - return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this ); |
|
280 | - } |
|
281 | - |
|
282 | - /** |
|
283 | - * Confirms payments when rendering the success page. |
|
284 | - * |
|
285 | - * @param string $content Success page content. |
|
286 | - * @return string |
|
287 | - */ |
|
288 | - public function confirm_payment( $content ) { |
|
289 | - |
|
290 | - // Retrieve the invoice. |
|
291 | - $invoice_id = getpaid_get_current_invoice_id(); |
|
292 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
293 | - |
|
294 | - // Ensure that it exists and that it is pending payment. |
|
295 | - if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) { |
|
296 | - return $content; |
|
297 | - } |
|
298 | - |
|
299 | - // Can the user view this invoice?? |
|
300 | - if ( ! wpinv_user_can_view_invoice( $invoice ) ) { |
|
301 | - return $content; |
|
302 | - } |
|
303 | - |
|
304 | - // Show payment processing indicator. |
|
305 | - return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) ); |
|
306 | - } |
|
307 | - |
|
308 | - /** |
|
309 | - * Processes ipns and marks payments as complete. |
|
310 | - * |
|
311 | - * @return void |
|
312 | - */ |
|
313 | - public function verify_ipn() {} |
|
314 | - |
|
315 | - /** |
|
316 | - * Processes invoice addons. |
|
317 | - * |
|
318 | - * @param WPInv_Invoice $invoice |
|
319 | - * @param GetPaid_Form_Item[] $items |
|
320 | - * @return WPInv_Invoice |
|
321 | - */ |
|
322 | - public function process_addons( $invoice, $items ) { |
|
323 | - |
|
324 | - } |
|
325 | - |
|
326 | - /** |
|
327 | - * Get a link to the transaction on the 3rd party gateway site (if applicable). |
|
328 | - * |
|
329 | - * @param string $transaction_url transaction url. |
|
330 | - * @param WPInv_Invoice $invoice Invoice object. |
|
331 | - * @return string transaction URL, or empty string. |
|
332 | - */ |
|
333 | - public function filter_transaction_url( $transaction_url, $invoice ) { |
|
334 | - |
|
335 | - $transaction_id = $invoice->get_transaction_id(); |
|
336 | - |
|
337 | - if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) { |
|
338 | - $transaction_url = sprintf( $this->view_transaction_url, $transaction_id ); |
|
339 | - $replace = $this->is_sandbox( $invoice ) ? 'sandbox' : ''; |
|
340 | - $transaction_url = str_replace( '{sandbox}', $replace, $transaction_url ); |
|
341 | - } |
|
342 | - |
|
343 | - return $transaction_url; |
|
344 | - } |
|
345 | - |
|
346 | - /** |
|
347 | - * Get a link to the subscription on the 3rd party gateway site (if applicable). |
|
348 | - * |
|
349 | - * @param string $subscription_url transaction url. |
|
350 | - * @param WPInv_Subscription $subscription Subscription objectt. |
|
351 | - * @return string subscription URL, or empty string. |
|
352 | - */ |
|
353 | - public function generate_subscription_url( $subscription_url, $subscription ) { |
|
354 | - |
|
355 | - $profile_id = $subscription->get_profile_id(); |
|
356 | - |
|
357 | - if ( $this->id == $subscription->get_gateway() && ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) { |
|
358 | - |
|
359 | - $subscription_url = sprintf( $this->view_subscription_url, $profile_id ); |
|
360 | - $replace = $this->is_sandbox( $subscription->get_parent_invoice() ) ? 'sandbox' : ''; |
|
361 | - $subscription_url = str_replace( '{sandbox}', $replace, $subscription_url ); |
|
362 | - |
|
363 | - } |
|
364 | - |
|
365 | - return $subscription_url; |
|
366 | - } |
|
367 | - |
|
368 | - /** |
|
369 | - * Check if the gateway is available for use. |
|
370 | - * |
|
371 | - * @return bool |
|
372 | - */ |
|
373 | - public function is_available() { |
|
374 | - return ! empty( $this->enabled ); |
|
375 | - } |
|
376 | - |
|
377 | - /** |
|
378 | - * Return the gateway's title. |
|
379 | - * |
|
380 | - * @return string |
|
381 | - */ |
|
382 | - public function get_title() { |
|
383 | - return apply_filters( 'getpaid_gateway_title', $this->title, $this ); |
|
384 | - } |
|
385 | - |
|
386 | - /** |
|
387 | - * Return the gateway's description. |
|
388 | - * |
|
389 | - * @return string |
|
390 | - */ |
|
391 | - public function get_description() { |
|
392 | - return apply_filters( 'getpaid_gateway_description', $this->description, $this ); |
|
393 | - } |
|
394 | - |
|
395 | - /** |
|
396 | - * Process Payment. |
|
397 | - * |
|
398 | - * |
|
399 | - * @param WPInv_Invoice $invoice Invoice. |
|
400 | - * @param array $submission_data Posted checkout fields. |
|
401 | - * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
402 | - * @return void |
|
403 | - */ |
|
404 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
405 | - // Process the payment then either redirect to the success page or the gateway. |
|
406 | - do_action( 'getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission ); |
|
407 | - } |
|
408 | - |
|
409 | - /** |
|
410 | - * Process refund. |
|
411 | - * |
|
412 | - * If the gateway declares 'refunds' support, this will allow it to refund. |
|
413 | - * a passed in amount. |
|
414 | - * |
|
415 | - * @param WPInv_Invoice $invoice Invoice. |
|
416 | - * @param float $amount Refund amount. |
|
417 | - * @param string $reason Refund reason. |
|
418 | - * @return WP_Error|bool True or false based on success, or a WP_Error object. |
|
419 | - */ |
|
420 | - public function process_refund( $invoice, $amount = null, $reason = '' ) { |
|
421 | - return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason ); |
|
422 | - } |
|
423 | - |
|
424 | - /** |
|
425 | - * Displays the payment fields, credit cards etc. |
|
426 | - * |
|
427 | - * @param int $invoice_id 0 or invoice id. |
|
428 | - * @param GetPaid_Payment_Form $form Current payment form. |
|
429 | - */ |
|
430 | - public function payment_fields( $invoice_id, $form ) { |
|
431 | - do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form ); |
|
432 | - } |
|
433 | - |
|
434 | - /** |
|
435 | - * Filters the gateway settings. |
|
436 | - * |
|
437 | - * @param array $admin_settings |
|
438 | - */ |
|
439 | - public function admin_settings( $admin_settings ) { |
|
440 | - return $admin_settings; |
|
441 | - } |
|
442 | - |
|
443 | - /** |
|
444 | - * Retrieves the value of a gateway setting. |
|
445 | - * |
|
446 | - * @param string $option |
|
447 | - */ |
|
448 | - public function get_option( $option, $default = false ) { |
|
449 | - return wpinv_get_option( $this->id . '_' . $option, $default ); |
|
450 | - } |
|
451 | - |
|
452 | - /** |
|
453 | - * Check if a gateway supports a given feature. |
|
454 | - * |
|
455 | - * Gateways should override this to declare support (or lack of support) for a feature. |
|
456 | - * For backward compatibility, gateways support 'products' by default, but nothing else. |
|
457 | - * |
|
458 | - * @param string $feature string The name of a feature to test support for. |
|
459 | - * @return bool True if the gateway supports the feature, false otherwise. |
|
460 | - * @since 1.0.19 |
|
461 | - */ |
|
462 | - public function supports( $feature ) { |
|
463 | - return getpaid_payment_gateway_supports( $this->id, $feature ); |
|
464 | - } |
|
465 | - |
|
466 | - /** |
|
467 | - * Returns the credit card form html. |
|
468 | - * |
|
469 | - * @param bool $save whether or not to display the save button. |
|
470 | - */ |
|
162 | + // Gateway checkout fiellds. |
|
163 | + add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 ); |
|
164 | + |
|
165 | + // Process payment. |
|
166 | + add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 ); |
|
167 | + |
|
168 | + // Change the checkout button text. |
|
169 | + if ( ! empty( $this->checkout_button_text ) ) { |
|
170 | + add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) ); |
|
171 | + } |
|
172 | + |
|
173 | + // Check if a gateway is valid for a given currency. |
|
174 | + add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 ); |
|
175 | + |
|
176 | + // Generate the transaction url. |
|
177 | + add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 ); |
|
178 | + |
|
179 | + // Generate the subscription url. |
|
180 | + add_filter( 'getpaid_remote_subscription_profile_url', array( $this, 'generate_subscription_url' ), 10, 2 ); |
|
181 | + |
|
182 | + // Confirm payments. |
|
183 | + add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 ); |
|
184 | + |
|
185 | + // Verify IPNs. |
|
186 | + add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) ); |
|
187 | + |
|
188 | + } |
|
189 | + |
|
190 | + /** |
|
191 | + * Checks if this gateway is a given gateway. |
|
192 | + * |
|
193 | + * @since 1.0.19 |
|
194 | + * @return bool |
|
195 | + */ |
|
196 | + public function is( $gateway ) { |
|
197 | + return $gateway == $this->id; |
|
198 | + } |
|
199 | + |
|
200 | + /** |
|
201 | + * Returns a users saved tokens for this gateway. |
|
202 | + * |
|
203 | + * @since 1.0.19 |
|
204 | + * @return array |
|
205 | + */ |
|
206 | + public function get_tokens( $sandbox = null ) { |
|
207 | + |
|
208 | + if ( is_user_logged_in() && $this->supports( 'tokens' ) && 0 == count( $this->tokens ) ) { |
|
209 | + $tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true ); |
|
210 | + |
|
211 | + if ( is_array( $tokens ) ) { |
|
212 | + $this->tokens = $tokens; |
|
213 | + } |
|
214 | + |
|
215 | + } |
|
216 | + |
|
217 | + if ( ! is_bool( $sandbox ) ) { |
|
218 | + return $this->tokens; |
|
219 | + } |
|
220 | + |
|
221 | + // Filter tokens. |
|
222 | + $args = array( 'type' => $sandbox ? 'sandbox' : 'live' ); |
|
223 | + return wp_list_filter( $this->tokens, $args ); |
|
224 | + |
|
225 | + } |
|
226 | + |
|
227 | + /** |
|
228 | + * Saves a token for this gateway. |
|
229 | + * |
|
230 | + * @since 1.0.19 |
|
231 | + */ |
|
232 | + public function save_token( $token ) { |
|
233 | + |
|
234 | + $tokens = $this->get_tokens(); |
|
235 | + $tokens[] = $token; |
|
236 | + |
|
237 | + update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens ); |
|
238 | + |
|
239 | + $this->tokens = $tokens; |
|
240 | + |
|
241 | + } |
|
242 | + |
|
243 | + /** |
|
244 | + * Return the title for admin screens. |
|
245 | + * |
|
246 | + * @return string |
|
247 | + */ |
|
248 | + public function get_method_title() { |
|
249 | + return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this ); |
|
250 | + } |
|
251 | + |
|
252 | + /** |
|
253 | + * Return the description for admin screens. |
|
254 | + * |
|
255 | + * @return string |
|
256 | + */ |
|
257 | + public function get_method_description() { |
|
258 | + return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this ); |
|
259 | + } |
|
260 | + |
|
261 | + /** |
|
262 | + * Get the success url. |
|
263 | + * |
|
264 | + * @param WPInv_Invoice $invoice Invoice object. |
|
265 | + * @return string |
|
266 | + */ |
|
267 | + public function get_return_url( $invoice ) { |
|
268 | + |
|
269 | + // Payment success url |
|
270 | + $return_url = add_query_arg( |
|
271 | + array( |
|
272 | + 'payment-confirm' => $this->id, |
|
273 | + 'invoice_key' => $invoice->get_key(), |
|
274 | + 'utm_nooverride' => 1 |
|
275 | + ), |
|
276 | + wpinv_get_success_page_uri() |
|
277 | + ); |
|
278 | + |
|
279 | + return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this ); |
|
280 | + } |
|
281 | + |
|
282 | + /** |
|
283 | + * Confirms payments when rendering the success page. |
|
284 | + * |
|
285 | + * @param string $content Success page content. |
|
286 | + * @return string |
|
287 | + */ |
|
288 | + public function confirm_payment( $content ) { |
|
289 | + |
|
290 | + // Retrieve the invoice. |
|
291 | + $invoice_id = getpaid_get_current_invoice_id(); |
|
292 | + $invoice = wpinv_get_invoice( $invoice_id ); |
|
293 | + |
|
294 | + // Ensure that it exists and that it is pending payment. |
|
295 | + if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) { |
|
296 | + return $content; |
|
297 | + } |
|
298 | + |
|
299 | + // Can the user view this invoice?? |
|
300 | + if ( ! wpinv_user_can_view_invoice( $invoice ) ) { |
|
301 | + return $content; |
|
302 | + } |
|
303 | + |
|
304 | + // Show payment processing indicator. |
|
305 | + return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) ); |
|
306 | + } |
|
307 | + |
|
308 | + /** |
|
309 | + * Processes ipns and marks payments as complete. |
|
310 | + * |
|
311 | + * @return void |
|
312 | + */ |
|
313 | + public function verify_ipn() {} |
|
314 | + |
|
315 | + /** |
|
316 | + * Processes invoice addons. |
|
317 | + * |
|
318 | + * @param WPInv_Invoice $invoice |
|
319 | + * @param GetPaid_Form_Item[] $items |
|
320 | + * @return WPInv_Invoice |
|
321 | + */ |
|
322 | + public function process_addons( $invoice, $items ) { |
|
323 | + |
|
324 | + } |
|
325 | + |
|
326 | + /** |
|
327 | + * Get a link to the transaction on the 3rd party gateway site (if applicable). |
|
328 | + * |
|
329 | + * @param string $transaction_url transaction url. |
|
330 | + * @param WPInv_Invoice $invoice Invoice object. |
|
331 | + * @return string transaction URL, or empty string. |
|
332 | + */ |
|
333 | + public function filter_transaction_url( $transaction_url, $invoice ) { |
|
334 | + |
|
335 | + $transaction_id = $invoice->get_transaction_id(); |
|
336 | + |
|
337 | + if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) { |
|
338 | + $transaction_url = sprintf( $this->view_transaction_url, $transaction_id ); |
|
339 | + $replace = $this->is_sandbox( $invoice ) ? 'sandbox' : ''; |
|
340 | + $transaction_url = str_replace( '{sandbox}', $replace, $transaction_url ); |
|
341 | + } |
|
342 | + |
|
343 | + return $transaction_url; |
|
344 | + } |
|
345 | + |
|
346 | + /** |
|
347 | + * Get a link to the subscription on the 3rd party gateway site (if applicable). |
|
348 | + * |
|
349 | + * @param string $subscription_url transaction url. |
|
350 | + * @param WPInv_Subscription $subscription Subscription objectt. |
|
351 | + * @return string subscription URL, or empty string. |
|
352 | + */ |
|
353 | + public function generate_subscription_url( $subscription_url, $subscription ) { |
|
354 | + |
|
355 | + $profile_id = $subscription->get_profile_id(); |
|
356 | + |
|
357 | + if ( $this->id == $subscription->get_gateway() && ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) { |
|
358 | + |
|
359 | + $subscription_url = sprintf( $this->view_subscription_url, $profile_id ); |
|
360 | + $replace = $this->is_sandbox( $subscription->get_parent_invoice() ) ? 'sandbox' : ''; |
|
361 | + $subscription_url = str_replace( '{sandbox}', $replace, $subscription_url ); |
|
362 | + |
|
363 | + } |
|
364 | + |
|
365 | + return $subscription_url; |
|
366 | + } |
|
367 | + |
|
368 | + /** |
|
369 | + * Check if the gateway is available for use. |
|
370 | + * |
|
371 | + * @return bool |
|
372 | + */ |
|
373 | + public function is_available() { |
|
374 | + return ! empty( $this->enabled ); |
|
375 | + } |
|
376 | + |
|
377 | + /** |
|
378 | + * Return the gateway's title. |
|
379 | + * |
|
380 | + * @return string |
|
381 | + */ |
|
382 | + public function get_title() { |
|
383 | + return apply_filters( 'getpaid_gateway_title', $this->title, $this ); |
|
384 | + } |
|
385 | + |
|
386 | + /** |
|
387 | + * Return the gateway's description. |
|
388 | + * |
|
389 | + * @return string |
|
390 | + */ |
|
391 | + public function get_description() { |
|
392 | + return apply_filters( 'getpaid_gateway_description', $this->description, $this ); |
|
393 | + } |
|
394 | + |
|
395 | + /** |
|
396 | + * Process Payment. |
|
397 | + * |
|
398 | + * |
|
399 | + * @param WPInv_Invoice $invoice Invoice. |
|
400 | + * @param array $submission_data Posted checkout fields. |
|
401 | + * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
402 | + * @return void |
|
403 | + */ |
|
404 | + public function process_payment( $invoice, $submission_data, $submission ) { |
|
405 | + // Process the payment then either redirect to the success page or the gateway. |
|
406 | + do_action( 'getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission ); |
|
407 | + } |
|
408 | + |
|
409 | + /** |
|
410 | + * Process refund. |
|
411 | + * |
|
412 | + * If the gateway declares 'refunds' support, this will allow it to refund. |
|
413 | + * a passed in amount. |
|
414 | + * |
|
415 | + * @param WPInv_Invoice $invoice Invoice. |
|
416 | + * @param float $amount Refund amount. |
|
417 | + * @param string $reason Refund reason. |
|
418 | + * @return WP_Error|bool True or false based on success, or a WP_Error object. |
|
419 | + */ |
|
420 | + public function process_refund( $invoice, $amount = null, $reason = '' ) { |
|
421 | + return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason ); |
|
422 | + } |
|
423 | + |
|
424 | + /** |
|
425 | + * Displays the payment fields, credit cards etc. |
|
426 | + * |
|
427 | + * @param int $invoice_id 0 or invoice id. |
|
428 | + * @param GetPaid_Payment_Form $form Current payment form. |
|
429 | + */ |
|
430 | + public function payment_fields( $invoice_id, $form ) { |
|
431 | + do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form ); |
|
432 | + } |
|
433 | + |
|
434 | + /** |
|
435 | + * Filters the gateway settings. |
|
436 | + * |
|
437 | + * @param array $admin_settings |
|
438 | + */ |
|
439 | + public function admin_settings( $admin_settings ) { |
|
440 | + return $admin_settings; |
|
441 | + } |
|
442 | + |
|
443 | + /** |
|
444 | + * Retrieves the value of a gateway setting. |
|
445 | + * |
|
446 | + * @param string $option |
|
447 | + */ |
|
448 | + public function get_option( $option, $default = false ) { |
|
449 | + return wpinv_get_option( $this->id . '_' . $option, $default ); |
|
450 | + } |
|
451 | + |
|
452 | + /** |
|
453 | + * Check if a gateway supports a given feature. |
|
454 | + * |
|
455 | + * Gateways should override this to declare support (or lack of support) for a feature. |
|
456 | + * For backward compatibility, gateways support 'products' by default, but nothing else. |
|
457 | + * |
|
458 | + * @param string $feature string The name of a feature to test support for. |
|
459 | + * @return bool True if the gateway supports the feature, false otherwise. |
|
460 | + * @since 1.0.19 |
|
461 | + */ |
|
462 | + public function supports( $feature ) { |
|
463 | + return getpaid_payment_gateway_supports( $this->id, $feature ); |
|
464 | + } |
|
465 | + |
|
466 | + /** |
|
467 | + * Returns the credit card form html. |
|
468 | + * |
|
469 | + * @param bool $save whether or not to display the save button. |
|
470 | + */ |
|
471 | 471 | public function get_cc_form( $save = false ) { |
472 | 472 | |
473 | - ob_start(); |
|
473 | + ob_start(); |
|
474 | 474 | |
475 | 475 | $id_prefix = esc_attr( uniqid( $this->id ) ); |
476 | 476 | |
@@ -565,11 +565,11 @@ discard block |
||
565 | 565 | 'name' => $this->id . '[cc_cvv2]', |
566 | 566 | 'id' => "$id_prefix-cc-cvv2", |
567 | 567 | 'label' => __( 'CCV', 'invoicing' ), |
568 | - 'label_type' => 'vertical', |
|
569 | - 'class' => 'form-control-sm', |
|
570 | - 'extra_attributes' => array( |
|
571 | - 'autocomplete' => "cc-csc", |
|
572 | - ), |
|
568 | + 'label_type' => 'vertical', |
|
569 | + 'class' => 'form-control-sm', |
|
570 | + 'extra_attributes' => array( |
|
571 | + 'autocomplete' => "cc-csc", |
|
572 | + ), |
|
573 | 573 | ) |
574 | 574 | ); |
575 | 575 | ?> |
@@ -579,192 +579,192 @@ discard block |
||
579 | 579 | |
580 | 580 | <?php |
581 | 581 | |
582 | - if ( $save ) { |
|
583 | - echo $this->save_payment_method_checkbox(); |
|
584 | - } |
|
582 | + if ( $save ) { |
|
583 | + echo $this->save_payment_method_checkbox(); |
|
584 | + } |
|
585 | 585 | |
586 | - ?> |
|
586 | + ?> |
|
587 | 587 | </div> |
588 | 588 | |
589 | 589 | </div> |
590 | 590 | <?php |
591 | 591 | |
592 | - return ob_get_clean(); |
|
592 | + return ob_get_clean(); |
|
593 | + |
|
594 | + } |
|
593 | 595 | |
596 | + /** |
|
597 | + * Displays a new payment method entry form. |
|
598 | + * |
|
599 | + * @since 1.0.19 |
|
600 | + */ |
|
601 | + public function new_payment_method_entry( $form ) { |
|
602 | + echo "<div class='getpaid-new-payment-method-form' style='display:none;'>$form</div>"; |
|
594 | 603 | } |
595 | 604 | |
596 | - /** |
|
597 | - * Displays a new payment method entry form. |
|
598 | - * |
|
599 | - * @since 1.0.19 |
|
600 | - */ |
|
601 | - public function new_payment_method_entry( $form ) { |
|
602 | - echo "<div class='getpaid-new-payment-method-form' style='display:none;'>$form</div>"; |
|
603 | - } |
|
604 | - |
|
605 | - /** |
|
606 | - * Grab and display our saved payment methods. |
|
607 | - * |
|
608 | - * @since 1.0.19 |
|
609 | - */ |
|
610 | - public function saved_payment_methods() { |
|
611 | - $html = '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr( count( $this->get_tokens( $this->is_sandbox() ) ) ) . '">'; |
|
612 | - |
|
613 | - foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) { |
|
614 | - $html .= $this->get_saved_payment_method_option_html( $token ); |
|
615 | - } |
|
616 | - |
|
617 | - $html .= $this->get_new_payment_method_option_html(); |
|
618 | - $html .= '</ul>'; |
|
619 | - |
|
620 | - echo apply_filters( 'getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this ); |
|
621 | - } |
|
622 | - |
|
623 | - /** |
|
624 | - * Gets saved payment method HTML from a token. |
|
625 | - * |
|
626 | - * @since 1.0.19 |
|
627 | - * @param array $token Payment Token. |
|
628 | - * @return string Generated payment method HTML |
|
629 | - */ |
|
630 | - public function get_saved_payment_method_option_html( $token ) { |
|
631 | - |
|
632 | - return sprintf( |
|
633 | - '<li class="getpaid-payment-method form-group"> |
|
605 | + /** |
|
606 | + * Grab and display our saved payment methods. |
|
607 | + * |
|
608 | + * @since 1.0.19 |
|
609 | + */ |
|
610 | + public function saved_payment_methods() { |
|
611 | + $html = '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr( count( $this->get_tokens( $this->is_sandbox() ) ) ) . '">'; |
|
612 | + |
|
613 | + foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) { |
|
614 | + $html .= $this->get_saved_payment_method_option_html( $token ); |
|
615 | + } |
|
616 | + |
|
617 | + $html .= $this->get_new_payment_method_option_html(); |
|
618 | + $html .= '</ul>'; |
|
619 | + |
|
620 | + echo apply_filters( 'getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this ); |
|
621 | + } |
|
622 | + |
|
623 | + /** |
|
624 | + * Gets saved payment method HTML from a token. |
|
625 | + * |
|
626 | + * @since 1.0.19 |
|
627 | + * @param array $token Payment Token. |
|
628 | + * @return string Generated payment method HTML |
|
629 | + */ |
|
630 | + public function get_saved_payment_method_option_html( $token ) { |
|
631 | + |
|
632 | + return sprintf( |
|
633 | + '<li class="getpaid-payment-method form-group"> |
|
634 | 634 | <label> |
635 | 635 | <input name="getpaid-%1$s-payment-method" type="radio" value="%2$s" data-currency="%5$s" style="width:auto;" class="getpaid-saved-payment-method-token-input" %4$s /> |
636 | 636 | <span>%3$s</span> |
637 | 637 | </label> |
638 | 638 | </li>', |
639 | - esc_attr( $this->id ), |
|
640 | - esc_attr( $token['id'] ), |
|
641 | - esc_html( $token['name'] ), |
|
642 | - checked( empty( $token['default'] ), false, false ), |
|
643 | - empty( $token['currency'] ) ? 'none' : esc_attr( $token['currency'] ) |
|
644 | - ); |
|
645 | - |
|
646 | - } |
|
647 | - |
|
648 | - /** |
|
649 | - * Displays a radio button for entering a new payment method (new CC details) instead of using a saved method. |
|
650 | - * |
|
651 | - * @since 1.0.19 |
|
652 | - */ |
|
653 | - public function get_new_payment_method_option_html() { |
|
654 | - |
|
655 | - $label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this ); |
|
656 | - |
|
657 | - return sprintf( |
|
658 | - '<li class="getpaid-new-payment-method"> |
|
639 | + esc_attr( $this->id ), |
|
640 | + esc_attr( $token['id'] ), |
|
641 | + esc_html( $token['name'] ), |
|
642 | + checked( empty( $token['default'] ), false, false ), |
|
643 | + empty( $token['currency'] ) ? 'none' : esc_attr( $token['currency'] ) |
|
644 | + ); |
|
645 | + |
|
646 | + } |
|
647 | + |
|
648 | + /** |
|
649 | + * Displays a radio button for entering a new payment method (new CC details) instead of using a saved method. |
|
650 | + * |
|
651 | + * @since 1.0.19 |
|
652 | + */ |
|
653 | + public function get_new_payment_method_option_html() { |
|
654 | + |
|
655 | + $label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this ); |
|
656 | + |
|
657 | + return sprintf( |
|
658 | + '<li class="getpaid-new-payment-method"> |
|
659 | 659 | <label> |
660 | 660 | <input name="getpaid-%1$s-payment-method" type="radio" data-currency="none" value="new" style="width:auto;" /> |
661 | 661 | <span>%2$s</span> |
662 | 662 | </label> |
663 | 663 | </li>', |
664 | - esc_attr( $this->id ), |
|
665 | - esc_html( $label ) |
|
666 | - ); |
|
667 | - |
|
668 | - } |
|
669 | - |
|
670 | - /** |
|
671 | - * Outputs a checkbox for saving a new payment method to the database. |
|
672 | - * |
|
673 | - * @since 1.0.19 |
|
674 | - */ |
|
675 | - public function save_payment_method_checkbox() { |
|
676 | - |
|
677 | - return aui()->input( |
|
678 | - array( |
|
679 | - 'type' => 'checkbox', |
|
680 | - 'name' => esc_attr( "getpaid-$this->id-new-payment-method" ), |
|
681 | - 'id' => esc_attr( uniqid( $this->id ) ), |
|
682 | - 'required' => false, |
|
683 | - 'label' => esc_html__( 'Save payment method', 'invoicing' ), |
|
684 | - 'value' => 'true', |
|
685 | - 'checked' => true, |
|
686 | - 'wrap_class' => 'getpaid-save-payment-method pt-1 pb-1', |
|
687 | - ) |
|
688 | - ); |
|
689 | - |
|
690 | - } |
|
691 | - |
|
692 | - /** |
|
693 | - * Registers the gateway. |
|
694 | - * |
|
695 | - * @return array |
|
696 | - */ |
|
697 | - public function register_gateway( $gateways ) { |
|
698 | - |
|
699 | - $gateways[ $this->id ] = array( |
|
700 | - |
|
701 | - 'admin_label' => $this->method_title, |
|
664 | + esc_attr( $this->id ), |
|
665 | + esc_html( $label ) |
|
666 | + ); |
|
667 | + |
|
668 | + } |
|
669 | + |
|
670 | + /** |
|
671 | + * Outputs a checkbox for saving a new payment method to the database. |
|
672 | + * |
|
673 | + * @since 1.0.19 |
|
674 | + */ |
|
675 | + public function save_payment_method_checkbox() { |
|
676 | + |
|
677 | + return aui()->input( |
|
678 | + array( |
|
679 | + 'type' => 'checkbox', |
|
680 | + 'name' => esc_attr( "getpaid-$this->id-new-payment-method" ), |
|
681 | + 'id' => esc_attr( uniqid( $this->id ) ), |
|
682 | + 'required' => false, |
|
683 | + 'label' => esc_html__( 'Save payment method', 'invoicing' ), |
|
684 | + 'value' => 'true', |
|
685 | + 'checked' => true, |
|
686 | + 'wrap_class' => 'getpaid-save-payment-method pt-1 pb-1', |
|
687 | + ) |
|
688 | + ); |
|
689 | + |
|
690 | + } |
|
691 | + |
|
692 | + /** |
|
693 | + * Registers the gateway. |
|
694 | + * |
|
695 | + * @return array |
|
696 | + */ |
|
697 | + public function register_gateway( $gateways ) { |
|
698 | + |
|
699 | + $gateways[ $this->id ] = array( |
|
700 | + |
|
701 | + 'admin_label' => $this->method_title, |
|
702 | 702 | 'checkout_label' => $this->title, |
703 | - 'ordering' => $this->order, |
|
703 | + 'ordering' => $this->order, |
|
704 | 704 | |
705 | - ); |
|
705 | + ); |
|
706 | 706 | |
707 | - return $gateways; |
|
707 | + return $gateways; |
|
708 | 708 | |
709 | - } |
|
709 | + } |
|
710 | 710 | |
711 | - /** |
|
712 | - * Checks whether or not this is a sandbox request. |
|
713 | - * |
|
714 | - * @param WPInv_Invoice|null $invoice Invoice object or null. |
|
715 | - * @return bool |
|
716 | - */ |
|
717 | - public function is_sandbox( $invoice = null ) { |
|
711 | + /** |
|
712 | + * Checks whether or not this is a sandbox request. |
|
713 | + * |
|
714 | + * @param WPInv_Invoice|null $invoice Invoice object or null. |
|
715 | + * @return bool |
|
716 | + */ |
|
717 | + public function is_sandbox( $invoice = null ) { |
|
718 | 718 | |
719 | - if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) { |
|
720 | - return $invoice->get_mode() == 'test'; |
|
721 | - } |
|
719 | + if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) { |
|
720 | + return $invoice->get_mode() == 'test'; |
|
721 | + } |
|
722 | 722 | |
723 | - return wpinv_is_test_mode( $this->id ); |
|
723 | + return wpinv_is_test_mode( $this->id ); |
|
724 | 724 | |
725 | - } |
|
725 | + } |
|
726 | 726 | |
727 | - /** |
|
728 | - * Renames the checkout button |
|
729 | - * |
|
730 | - * @return string |
|
731 | - */ |
|
732 | - public function rename_checkout_button() { |
|
733 | - return $this->checkout_button_text; |
|
734 | - } |
|
727 | + /** |
|
728 | + * Renames the checkout button |
|
729 | + * |
|
730 | + * @return string |
|
731 | + */ |
|
732 | + public function rename_checkout_button() { |
|
733 | + return $this->checkout_button_text; |
|
734 | + } |
|
735 | 735 | |
736 | - /** |
|
737 | - * Validate gateway currency |
|
738 | - * |
|
739 | - * @return bool |
|
740 | - */ |
|
741 | - public function validate_currency( $validation, $currency ) { |
|
736 | + /** |
|
737 | + * Validate gateway currency |
|
738 | + * |
|
739 | + * @return bool |
|
740 | + */ |
|
741 | + public function validate_currency( $validation, $currency ) { |
|
742 | 742 | |
743 | - // Required currencies. |
|
744 | - if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) { |
|
745 | - return false; |
|
746 | - } |
|
743 | + // Required currencies. |
|
744 | + if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) { |
|
745 | + return false; |
|
746 | + } |
|
747 | 747 | |
748 | - // Excluded currencies. |
|
749 | - if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) { |
|
750 | - return false; |
|
751 | - } |
|
748 | + // Excluded currencies. |
|
749 | + if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) { |
|
750 | + return false; |
|
751 | + } |
|
752 | 752 | |
753 | - return $validation; |
|
754 | - } |
|
753 | + return $validation; |
|
754 | + } |
|
755 | 755 | |
756 | - /** |
|
757 | - * Displays an error |
|
758 | - * |
|
759 | - */ |
|
760 | - public function show_error( $code, $message, $type ) { |
|
756 | + /** |
|
757 | + * Displays an error |
|
758 | + * |
|
759 | + */ |
|
760 | + public function show_error( $code, $message, $type ) { |
|
761 | 761 | |
762 | - if ( is_admin() ) { |
|
763 | - getpaid_admin()->{"show_$type"}( $message ); |
|
764 | - } |
|
762 | + if ( is_admin() ) { |
|
763 | + getpaid_admin()->{"show_$type"}( $message ); |
|
764 | + } |
|
765 | 765 | |
766 | - wpinv_set_error( $code, $message, $type ); |
|
766 | + wpinv_set_error( $code, $message, $type ); |
|
767 | 767 | |
768 | - } |
|
768 | + } |
|
769 | 769 | |
770 | 770 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Abstaract Payment Gateway class. |
@@ -139,51 +139,51 @@ discard block |
||
139 | 139 | public function __construct() { |
140 | 140 | |
141 | 141 | // Register gateway. |
142 | - add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) ); |
|
142 | + add_filter('wpinv_payment_gateways', array($this, 'register_gateway')); |
|
143 | 143 | |
144 | - $this->enabled = wpinv_is_gateway_active( $this->id ); |
|
144 | + $this->enabled = wpinv_is_gateway_active($this->id); |
|
145 | 145 | |
146 | 146 | // Add support for various features. |
147 | - foreach ( $this->supports as $feature ) { |
|
148 | - add_filter( "wpinv_{$this->id}_support_{$feature}", '__return_true' ); |
|
149 | - add_filter( "getpaid_{$this->id}_support_{$feature}", '__return_true' ); |
|
150 | - add_filter( "getpaid_{$this->id}_supports_{$feature}", '__return_true' ); |
|
147 | + foreach ($this->supports as $feature) { |
|
148 | + add_filter("wpinv_{$this->id}_support_{$feature}", '__return_true'); |
|
149 | + add_filter("getpaid_{$this->id}_support_{$feature}", '__return_true'); |
|
150 | + add_filter("getpaid_{$this->id}_supports_{$feature}", '__return_true'); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | // Invoice addons. |
154 | - if ( $this->supports( 'addons' ) ) { |
|
155 | - add_action( "getpaid_process_{$this->id}_invoice_addons", array( $this, 'process_addons' ), 10, 2 ); |
|
154 | + if ($this->supports('addons')) { |
|
155 | + add_action("getpaid_process_{$this->id}_invoice_addons", array($this, 'process_addons'), 10, 2); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | // Gateway settings. |
159 | - add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) ); |
|
159 | + add_filter("wpinv_gateway_settings_{$this->id}", array($this, 'admin_settings')); |
|
160 | 160 | |
161 | 161 | |
162 | 162 | // Gateway checkout fiellds. |
163 | - add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 ); |
|
163 | + add_action("wpinv_{$this->id}_cc_form", array($this, 'payment_fields'), 10, 2); |
|
164 | 164 | |
165 | 165 | // Process payment. |
166 | - add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 ); |
|
166 | + add_action("getpaid_gateway_{$this->id}", array($this, 'process_payment'), 10, 3); |
|
167 | 167 | |
168 | 168 | // Change the checkout button text. |
169 | - if ( ! empty( $this->checkout_button_text ) ) { |
|
170 | - add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) ); |
|
169 | + if (!empty($this->checkout_button_text)) { |
|
170 | + add_filter("getpaid_gateway_{$this->id}_checkout_button_label", array($this, 'rename_checkout_button')); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | // Check if a gateway is valid for a given currency. |
174 | - add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 ); |
|
174 | + add_filter("getpaid_gateway_{$this->id}_is_valid_for_currency", array($this, 'validate_currency'), 10, 2); |
|
175 | 175 | |
176 | 176 | // Generate the transaction url. |
177 | - add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 ); |
|
177 | + add_filter("getpaid_gateway_{$this->id}_transaction_url", array($this, 'filter_transaction_url'), 10, 2); |
|
178 | 178 | |
179 | 179 | // Generate the subscription url. |
180 | - add_filter( 'getpaid_remote_subscription_profile_url', array( $this, 'generate_subscription_url' ), 10, 2 ); |
|
180 | + add_filter('getpaid_remote_subscription_profile_url', array($this, 'generate_subscription_url'), 10, 2); |
|
181 | 181 | |
182 | 182 | // Confirm payments. |
183 | - add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 ); |
|
183 | + add_filter("wpinv_payment_confirm_{$this->id}", array($this, 'confirm_payment'), 10, 2); |
|
184 | 184 | |
185 | 185 | // Verify IPNs. |
186 | - add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) ); |
|
186 | + add_action("wpinv_verify_{$this->id}_ipn", array($this, 'verify_ipn')); |
|
187 | 187 | |
188 | 188 | } |
189 | 189 | |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | * @since 1.0.19 |
194 | 194 | * @return bool |
195 | 195 | */ |
196 | - public function is( $gateway ) { |
|
196 | + public function is($gateway) { |
|
197 | 197 | return $gateway == $this->id; |
198 | 198 | } |
199 | 199 | |
@@ -203,24 +203,24 @@ discard block |
||
203 | 203 | * @since 1.0.19 |
204 | 204 | * @return array |
205 | 205 | */ |
206 | - public function get_tokens( $sandbox = null ) { |
|
206 | + public function get_tokens($sandbox = null) { |
|
207 | 207 | |
208 | - if ( is_user_logged_in() && $this->supports( 'tokens' ) && 0 == count( $this->tokens ) ) { |
|
209 | - $tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true ); |
|
208 | + if (is_user_logged_in() && $this->supports('tokens') && 0 == count($this->tokens)) { |
|
209 | + $tokens = get_user_meta(get_current_user_id(), "getpaid_{$this->id}_tokens", true); |
|
210 | 210 | |
211 | - if ( is_array( $tokens ) ) { |
|
211 | + if (is_array($tokens)) { |
|
212 | 212 | $this->tokens = $tokens; |
213 | 213 | } |
214 | 214 | |
215 | 215 | } |
216 | 216 | |
217 | - if ( ! is_bool( $sandbox ) ) { |
|
217 | + if (!is_bool($sandbox)) { |
|
218 | 218 | return $this->tokens; |
219 | 219 | } |
220 | 220 | |
221 | 221 | // Filter tokens. |
222 | - $args = array( 'type' => $sandbox ? 'sandbox' : 'live' ); |
|
223 | - return wp_list_filter( $this->tokens, $args ); |
|
222 | + $args = array('type' => $sandbox ? 'sandbox' : 'live'); |
|
223 | + return wp_list_filter($this->tokens, $args); |
|
224 | 224 | |
225 | 225 | } |
226 | 226 | |
@@ -229,12 +229,12 @@ discard block |
||
229 | 229 | * |
230 | 230 | * @since 1.0.19 |
231 | 231 | */ |
232 | - public function save_token( $token ) { |
|
232 | + public function save_token($token) { |
|
233 | 233 | |
234 | 234 | $tokens = $this->get_tokens(); |
235 | 235 | $tokens[] = $token; |
236 | 236 | |
237 | - update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens ); |
|
237 | + update_user_meta(get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens); |
|
238 | 238 | |
239 | 239 | $this->tokens = $tokens; |
240 | 240 | |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | * @return string |
247 | 247 | */ |
248 | 248 | public function get_method_title() { |
249 | - return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this ); |
|
249 | + return apply_filters('getpaid_gateway_method_title', $this->method_title, $this); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | * @return string |
256 | 256 | */ |
257 | 257 | public function get_method_description() { |
258 | - return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this ); |
|
258 | + return apply_filters('getpaid_gateway_method_description', $this->method_description, $this); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | /** |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | * @param WPInv_Invoice $invoice Invoice object. |
265 | 265 | * @return string |
266 | 266 | */ |
267 | - public function get_return_url( $invoice ) { |
|
267 | + public function get_return_url($invoice) { |
|
268 | 268 | |
269 | 269 | // Payment success url |
270 | 270 | $return_url = add_query_arg( |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | wpinv_get_success_page_uri() |
277 | 277 | ); |
278 | 278 | |
279 | - return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this ); |
|
279 | + return apply_filters('getpaid_gateway_success_url', $return_url, $invoice, $this); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | /** |
@@ -285,24 +285,24 @@ discard block |
||
285 | 285 | * @param string $content Success page content. |
286 | 286 | * @return string |
287 | 287 | */ |
288 | - public function confirm_payment( $content ) { |
|
288 | + public function confirm_payment($content) { |
|
289 | 289 | |
290 | 290 | // Retrieve the invoice. |
291 | 291 | $invoice_id = getpaid_get_current_invoice_id(); |
292 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
292 | + $invoice = wpinv_get_invoice($invoice_id); |
|
293 | 293 | |
294 | 294 | // Ensure that it exists and that it is pending payment. |
295 | - if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) { |
|
295 | + if (empty($invoice_id) || !$invoice->needs_payment()) { |
|
296 | 296 | return $content; |
297 | 297 | } |
298 | 298 | |
299 | 299 | // Can the user view this invoice?? |
300 | - if ( ! wpinv_user_can_view_invoice( $invoice ) ) { |
|
300 | + if (!wpinv_user_can_view_invoice($invoice)) { |
|
301 | 301 | return $content; |
302 | 302 | } |
303 | 303 | |
304 | 304 | // Show payment processing indicator. |
305 | - return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) ); |
|
305 | + return wpinv_get_template_html('wpinv-payment-processing.php', compact('invoice')); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | * @param GetPaid_Form_Item[] $items |
320 | 320 | * @return WPInv_Invoice |
321 | 321 | */ |
322 | - public function process_addons( $invoice, $items ) { |
|
322 | + public function process_addons($invoice, $items) { |
|
323 | 323 | |
324 | 324 | } |
325 | 325 | |
@@ -330,14 +330,14 @@ discard block |
||
330 | 330 | * @param WPInv_Invoice $invoice Invoice object. |
331 | 331 | * @return string transaction URL, or empty string. |
332 | 332 | */ |
333 | - public function filter_transaction_url( $transaction_url, $invoice ) { |
|
333 | + public function filter_transaction_url($transaction_url, $invoice) { |
|
334 | 334 | |
335 | - $transaction_id = $invoice->get_transaction_id(); |
|
335 | + $transaction_id = $invoice->get_transaction_id(); |
|
336 | 336 | |
337 | - if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) { |
|
338 | - $transaction_url = sprintf( $this->view_transaction_url, $transaction_id ); |
|
339 | - $replace = $this->is_sandbox( $invoice ) ? 'sandbox' : ''; |
|
340 | - $transaction_url = str_replace( '{sandbox}', $replace, $transaction_url ); |
|
337 | + if (!empty($this->view_transaction_url) && !empty($transaction_id)) { |
|
338 | + $transaction_url = sprintf($this->view_transaction_url, $transaction_id); |
|
339 | + $replace = $this->is_sandbox($invoice) ? 'sandbox' : ''; |
|
340 | + $transaction_url = str_replace('{sandbox}', $replace, $transaction_url); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | return $transaction_url; |
@@ -350,15 +350,15 @@ discard block |
||
350 | 350 | * @param WPInv_Subscription $subscription Subscription objectt. |
351 | 351 | * @return string subscription URL, or empty string. |
352 | 352 | */ |
353 | - public function generate_subscription_url( $subscription_url, $subscription ) { |
|
353 | + public function generate_subscription_url($subscription_url, $subscription) { |
|
354 | 354 | |
355 | - $profile_id = $subscription->get_profile_id(); |
|
355 | + $profile_id = $subscription->get_profile_id(); |
|
356 | 356 | |
357 | - if ( $this->id == $subscription->get_gateway() && ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) { |
|
357 | + if ($this->id == $subscription->get_gateway() && !empty($this->view_subscription_url) && !empty($profile_id)) { |
|
358 | 358 | |
359 | - $subscription_url = sprintf( $this->view_subscription_url, $profile_id ); |
|
360 | - $replace = $this->is_sandbox( $subscription->get_parent_invoice() ) ? 'sandbox' : ''; |
|
361 | - $subscription_url = str_replace( '{sandbox}', $replace, $subscription_url ); |
|
359 | + $subscription_url = sprintf($this->view_subscription_url, $profile_id); |
|
360 | + $replace = $this->is_sandbox($subscription->get_parent_invoice()) ? 'sandbox' : ''; |
|
361 | + $subscription_url = str_replace('{sandbox}', $replace, $subscription_url); |
|
362 | 362 | |
363 | 363 | } |
364 | 364 | |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | * @return bool |
372 | 372 | */ |
373 | 373 | public function is_available() { |
374 | - return ! empty( $this->enabled ); |
|
374 | + return !empty($this->enabled); |
|
375 | 375 | } |
376 | 376 | |
377 | 377 | /** |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | * @return string |
381 | 381 | */ |
382 | 382 | public function get_title() { |
383 | - return apply_filters( 'getpaid_gateway_title', $this->title, $this ); |
|
383 | + return apply_filters('getpaid_gateway_title', $this->title, $this); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | /** |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | * @return string |
390 | 390 | */ |
391 | 391 | public function get_description() { |
392 | - return apply_filters( 'getpaid_gateway_description', $this->description, $this ); |
|
392 | + return apply_filters('getpaid_gateway_description', $this->description, $this); |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | /** |
@@ -401,9 +401,9 @@ discard block |
||
401 | 401 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
402 | 402 | * @return void |
403 | 403 | */ |
404 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
404 | + public function process_payment($invoice, $submission_data, $submission) { |
|
405 | 405 | // Process the payment then either redirect to the success page or the gateway. |
406 | - do_action( 'getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission ); |
|
406 | + do_action('getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | /** |
@@ -417,8 +417,8 @@ discard block |
||
417 | 417 | * @param string $reason Refund reason. |
418 | 418 | * @return WP_Error|bool True or false based on success, or a WP_Error object. |
419 | 419 | */ |
420 | - public function process_refund( $invoice, $amount = null, $reason = '' ) { |
|
421 | - return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason ); |
|
420 | + public function process_refund($invoice, $amount = null, $reason = '') { |
|
421 | + return apply_filters('getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason); |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | /** |
@@ -427,8 +427,8 @@ discard block |
||
427 | 427 | * @param int $invoice_id 0 or invoice id. |
428 | 428 | * @param GetPaid_Payment_Form $form Current payment form. |
429 | 429 | */ |
430 | - public function payment_fields( $invoice_id, $form ) { |
|
431 | - do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form ); |
|
430 | + public function payment_fields($invoice_id, $form) { |
|
431 | + do_action('getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | /** |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | * |
437 | 437 | * @param array $admin_settings |
438 | 438 | */ |
439 | - public function admin_settings( $admin_settings ) { |
|
439 | + public function admin_settings($admin_settings) { |
|
440 | 440 | return $admin_settings; |
441 | 441 | } |
442 | 442 | |
@@ -445,8 +445,8 @@ discard block |
||
445 | 445 | * |
446 | 446 | * @param string $option |
447 | 447 | */ |
448 | - public function get_option( $option, $default = false ) { |
|
449 | - return wpinv_get_option( $this->id . '_' . $option, $default ); |
|
448 | + public function get_option($option, $default = false) { |
|
449 | + return wpinv_get_option($this->id . '_' . $option, $default); |
|
450 | 450 | } |
451 | 451 | |
452 | 452 | /** |
@@ -459,8 +459,8 @@ discard block |
||
459 | 459 | * @return bool True if the gateway supports the feature, false otherwise. |
460 | 460 | * @since 1.0.19 |
461 | 461 | */ |
462 | - public function supports( $feature ) { |
|
463 | - return getpaid_payment_gateway_supports( $this->id, $feature ); |
|
462 | + public function supports($feature) { |
|
463 | + return getpaid_payment_gateway_supports($this->id, $feature); |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | /** |
@@ -468,36 +468,36 @@ discard block |
||
468 | 468 | * |
469 | 469 | * @param bool $save whether or not to display the save button. |
470 | 470 | */ |
471 | - public function get_cc_form( $save = false ) { |
|
471 | + public function get_cc_form($save = false) { |
|
472 | 472 | |
473 | 473 | ob_start(); |
474 | 474 | |
475 | - $id_prefix = esc_attr( uniqid( $this->id ) ); |
|
475 | + $id_prefix = esc_attr(uniqid($this->id)); |
|
476 | 476 | |
477 | 477 | $months = array( |
478 | - '01' => __( 'January', 'invoicing' ), |
|
479 | - '02' => __( 'February', 'invoicing' ), |
|
480 | - '03' => __( 'March', 'invoicing' ), |
|
481 | - '04' => __( 'April', 'invoicing' ), |
|
482 | - '05' => __( 'May', 'invoicing' ), |
|
483 | - '06' => __( 'June', 'invoicing' ), |
|
484 | - '07' => __( 'July', 'invoicing' ), |
|
485 | - '08' => __( 'August', 'invoicing' ), |
|
486 | - '09' => __( 'September', 'invoicing' ), |
|
487 | - '10' => __( 'October', 'invoicing' ), |
|
488 | - '11' => __( 'November', 'invoicing' ), |
|
489 | - '12' => __( 'December', 'invoicing' ), |
|
478 | + '01' => __('January', 'invoicing'), |
|
479 | + '02' => __('February', 'invoicing'), |
|
480 | + '03' => __('March', 'invoicing'), |
|
481 | + '04' => __('April', 'invoicing'), |
|
482 | + '05' => __('May', 'invoicing'), |
|
483 | + '06' => __('June', 'invoicing'), |
|
484 | + '07' => __('July', 'invoicing'), |
|
485 | + '08' => __('August', 'invoicing'), |
|
486 | + '09' => __('September', 'invoicing'), |
|
487 | + '10' => __('October', 'invoicing'), |
|
488 | + '11' => __('November', 'invoicing'), |
|
489 | + '12' => __('December', 'invoicing'), |
|
490 | 490 | ); |
491 | 491 | |
492 | - $year = (int) date( 'Y', current_time( 'timestamp' ) ); |
|
492 | + $year = (int) date('Y', current_time('timestamp')); |
|
493 | 493 | $years = array(); |
494 | 494 | |
495 | - for ( $i = 0; $i <= 10; $i++ ) { |
|
496 | - $years[ $year + $i ] = $year + $i; |
|
495 | + for ($i = 0; $i <= 10; $i++) { |
|
496 | + $years[$year + $i] = $year + $i; |
|
497 | 497 | } |
498 | 498 | |
499 | 499 | ?> |
500 | - <div class="<?php echo esc_attr( $this->id );?>-cc-form getpaid-cc-form mt-1"> |
|
500 | + <div class="<?php echo esc_attr($this->id); ?>-cc-form getpaid-cc-form mt-1"> |
|
501 | 501 | |
502 | 502 | |
503 | 503 | <div class="getpaid-cc-card-inner"> |
@@ -506,14 +506,14 @@ discard block |
||
506 | 506 | <div class="col-12"> |
507 | 507 | |
508 | 508 | <div class="form-group"> |
509 | - <label for="<?php echo esc_attr( "$id_prefix-cc-number" ) ?>"><?php _e( 'Card number', 'invoicing' ); ?></label> |
|
509 | + <label for="<?php echo esc_attr("$id_prefix-cc-number") ?>"><?php _e('Card number', 'invoicing'); ?></label> |
|
510 | 510 | <div class="input-group input-group-sm"> |
511 | 511 | <div class="input-group-prepend "> |
512 | 512 | <span class="input-group-text"> |
513 | 513 | <i class="fa fa-credit-card"></i> |
514 | 514 | </span> |
515 | 515 | </div> |
516 | - <input type="text" name="<?php echo esc_attr( $this->id . '[cc_number]' ) ?>authorizenet[cc_number]" id="<?php echo esc_attr( "$id_prefix-cc-number" ) ?>" class="form-control form-control-sm" autocomplete="cc-number"> |
|
516 | + <input type="text" name="<?php echo esc_attr($this->id . '[cc_number]') ?>authorizenet[cc_number]" id="<?php echo esc_attr("$id_prefix-cc-number") ?>" class="form-control form-control-sm" autocomplete="cc-number"> |
|
517 | 517 | </div> |
518 | 518 | </div> |
519 | 519 | |
@@ -521,17 +521,17 @@ discard block |
||
521 | 521 | |
522 | 522 | <div class="col-12"> |
523 | 523 | <div class="form-group"> |
524 | - <label><?php _e( 'Expiration', 'invoicing' ); ?></label> |
|
524 | + <label><?php _e('Expiration', 'invoicing'); ?></label> |
|
525 | 525 | <div class="form-row"> |
526 | 526 | |
527 | 527 | <div class="col"> |
528 | - <select class="form-control form-control-sm" autocomplete="cc-exp-month" name="<?php echo esc_attr( $this->id );?>[cc_expire_month]"> |
|
529 | - <option disabled selected="selected"><?php _e( 'MM', 'invoicing' ); ?></option> |
|
528 | + <select class="form-control form-control-sm" autocomplete="cc-exp-month" name="<?php echo esc_attr($this->id); ?>[cc_expire_month]"> |
|
529 | + <option disabled selected="selected"><?php _e('MM', 'invoicing'); ?></option> |
|
530 | 530 | |
531 | 531 | <?php |
532 | - foreach ( $months as $key => $month ) { |
|
533 | - $key = esc_attr( $key ); |
|
534 | - $month = wpinv_clean( $month ); |
|
532 | + foreach ($months as $key => $month) { |
|
533 | + $key = esc_attr($key); |
|
534 | + $month = wpinv_clean($month); |
|
535 | 535 | echo "<option value='$key'>$month</option>" . PHP_EOL; |
536 | 536 | } |
537 | 537 | ?> |
@@ -540,13 +540,13 @@ discard block |
||
540 | 540 | </div> |
541 | 541 | |
542 | 542 | <div class="col"> |
543 | - <select class="form-control form-control-sm" autocomplete="cc-exp-year" name="<?php echo esc_attr( $this->id );?>[cc_expire_year]"> |
|
544 | - <option disabled selected="selected"><?php _e( 'YY', 'invoicing' ); ?></option> |
|
543 | + <select class="form-control form-control-sm" autocomplete="cc-exp-year" name="<?php echo esc_attr($this->id); ?>[cc_expire_year]"> |
|
544 | + <option disabled selected="selected"><?php _e('YY', 'invoicing'); ?></option> |
|
545 | 545 | |
546 | 546 | <?php |
547 | - foreach ( $years as $key => $year ) { |
|
548 | - $key = esc_attr( $key ); |
|
549 | - $year = wpinv_clean( $year ); |
|
547 | + foreach ($years as $key => $year) { |
|
548 | + $key = esc_attr($key); |
|
549 | + $year = wpinv_clean($year); |
|
550 | 550 | echo "<option value='$key'>$year</option>" . PHP_EOL; |
551 | 551 | } |
552 | 552 | ?> |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | array( |
565 | 565 | 'name' => $this->id . '[cc_cvv2]', |
566 | 566 | 'id' => "$id_prefix-cc-cvv2", |
567 | - 'label' => __( 'CCV', 'invoicing' ), |
|
567 | + 'label' => __('CCV', 'invoicing'), |
|
568 | 568 | 'label_type' => 'vertical', |
569 | 569 | 'class' => 'form-control-sm', |
570 | 570 | 'extra_attributes' => array( |
@@ -579,7 +579,7 @@ discard block |
||
579 | 579 | |
580 | 580 | <?php |
581 | 581 | |
582 | - if ( $save ) { |
|
582 | + if ($save) { |
|
583 | 583 | echo $this->save_payment_method_checkbox(); |
584 | 584 | } |
585 | 585 | |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | * |
599 | 599 | * @since 1.0.19 |
600 | 600 | */ |
601 | - public function new_payment_method_entry( $form ) { |
|
601 | + public function new_payment_method_entry($form) { |
|
602 | 602 | echo "<div class='getpaid-new-payment-method-form' style='display:none;'>$form</div>"; |
603 | 603 | } |
604 | 604 | |
@@ -608,16 +608,16 @@ discard block |
||
608 | 608 | * @since 1.0.19 |
609 | 609 | */ |
610 | 610 | public function saved_payment_methods() { |
611 | - $html = '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr( count( $this->get_tokens( $this->is_sandbox() ) ) ) . '">'; |
|
611 | + $html = '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr(count($this->get_tokens($this->is_sandbox()))) . '">'; |
|
612 | 612 | |
613 | - foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) { |
|
614 | - $html .= $this->get_saved_payment_method_option_html( $token ); |
|
613 | + foreach ($this->get_tokens($this->is_sandbox()) as $token) { |
|
614 | + $html .= $this->get_saved_payment_method_option_html($token); |
|
615 | 615 | } |
616 | 616 | |
617 | 617 | $html .= $this->get_new_payment_method_option_html(); |
618 | 618 | $html .= '</ul>'; |
619 | 619 | |
620 | - echo apply_filters( 'getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this ); |
|
620 | + echo apply_filters('getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this); |
|
621 | 621 | } |
622 | 622 | |
623 | 623 | /** |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | * @param array $token Payment Token. |
628 | 628 | * @return string Generated payment method HTML |
629 | 629 | */ |
630 | - public function get_saved_payment_method_option_html( $token ) { |
|
630 | + public function get_saved_payment_method_option_html($token) { |
|
631 | 631 | |
632 | 632 | return sprintf( |
633 | 633 | '<li class="getpaid-payment-method form-group"> |
@@ -636,11 +636,11 @@ discard block |
||
636 | 636 | <span>%3$s</span> |
637 | 637 | </label> |
638 | 638 | </li>', |
639 | - esc_attr( $this->id ), |
|
640 | - esc_attr( $token['id'] ), |
|
641 | - esc_html( $token['name'] ), |
|
642 | - checked( empty( $token['default'] ), false, false ), |
|
643 | - empty( $token['currency'] ) ? 'none' : esc_attr( $token['currency'] ) |
|
639 | + esc_attr($this->id), |
|
640 | + esc_attr($token['id']), |
|
641 | + esc_html($token['name']), |
|
642 | + checked(empty($token['default']), false, false), |
|
643 | + empty($token['currency']) ? 'none' : esc_attr($token['currency']) |
|
644 | 644 | ); |
645 | 645 | |
646 | 646 | } |
@@ -652,7 +652,7 @@ discard block |
||
652 | 652 | */ |
653 | 653 | public function get_new_payment_method_option_html() { |
654 | 654 | |
655 | - $label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this ); |
|
655 | + $label = apply_filters('getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __('Use a new payment method', 'invoicing'), $this); |
|
656 | 656 | |
657 | 657 | return sprintf( |
658 | 658 | '<li class="getpaid-new-payment-method"> |
@@ -661,8 +661,8 @@ discard block |
||
661 | 661 | <span>%2$s</span> |
662 | 662 | </label> |
663 | 663 | </li>', |
664 | - esc_attr( $this->id ), |
|
665 | - esc_html( $label ) |
|
664 | + esc_attr($this->id), |
|
665 | + esc_html($label) |
|
666 | 666 | ); |
667 | 667 | |
668 | 668 | } |
@@ -677,10 +677,10 @@ discard block |
||
677 | 677 | return aui()->input( |
678 | 678 | array( |
679 | 679 | 'type' => 'checkbox', |
680 | - 'name' => esc_attr( "getpaid-$this->id-new-payment-method" ), |
|
681 | - 'id' => esc_attr( uniqid( $this->id ) ), |
|
680 | + 'name' => esc_attr("getpaid-$this->id-new-payment-method"), |
|
681 | + 'id' => esc_attr(uniqid($this->id)), |
|
682 | 682 | 'required' => false, |
683 | - 'label' => esc_html__( 'Save payment method', 'invoicing' ), |
|
683 | + 'label' => esc_html__('Save payment method', 'invoicing'), |
|
684 | 684 | 'value' => 'true', |
685 | 685 | 'checked' => true, |
686 | 686 | 'wrap_class' => 'getpaid-save-payment-method pt-1 pb-1', |
@@ -694,9 +694,9 @@ discard block |
||
694 | 694 | * |
695 | 695 | * @return array |
696 | 696 | */ |
697 | - public function register_gateway( $gateways ) { |
|
697 | + public function register_gateway($gateways) { |
|
698 | 698 | |
699 | - $gateways[ $this->id ] = array( |
|
699 | + $gateways[$this->id] = array( |
|
700 | 700 | |
701 | 701 | 'admin_label' => $this->method_title, |
702 | 702 | 'checkout_label' => $this->title, |
@@ -714,13 +714,13 @@ discard block |
||
714 | 714 | * @param WPInv_Invoice|null $invoice Invoice object or null. |
715 | 715 | * @return bool |
716 | 716 | */ |
717 | - public function is_sandbox( $invoice = null ) { |
|
717 | + public function is_sandbox($invoice = null) { |
|
718 | 718 | |
719 | - if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) { |
|
719 | + if (!empty($invoice) && !$invoice->needs_payment()) { |
|
720 | 720 | return $invoice->get_mode() == 'test'; |
721 | 721 | } |
722 | 722 | |
723 | - return wpinv_is_test_mode( $this->id ); |
|
723 | + return wpinv_is_test_mode($this->id); |
|
724 | 724 | |
725 | 725 | } |
726 | 726 | |
@@ -738,15 +738,15 @@ discard block |
||
738 | 738 | * |
739 | 739 | * @return bool |
740 | 740 | */ |
741 | - public function validate_currency( $validation, $currency ) { |
|
741 | + public function validate_currency($validation, $currency) { |
|
742 | 742 | |
743 | 743 | // Required currencies. |
744 | - if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) { |
|
744 | + if (!empty($this->currencies) && !in_array($currency, $this->currencies)) { |
|
745 | 745 | return false; |
746 | 746 | } |
747 | 747 | |
748 | 748 | // Excluded currencies. |
749 | - if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) { |
|
749 | + if (!empty($this->exclude_currencies) && in_array($currency, $this->exclude_currencies)) { |
|
750 | 750 | return false; |
751 | 751 | } |
752 | 752 | |
@@ -757,13 +757,13 @@ discard block |
||
757 | 757 | * Displays an error |
758 | 758 | * |
759 | 759 | */ |
760 | - public function show_error( $code, $message, $type ) { |
|
760 | + public function show_error($code, $message, $type) { |
|
761 | 761 | |
762 | - if ( is_admin() ) { |
|
763 | - getpaid_admin()->{"show_$type"}( $message ); |
|
762 | + if (is_admin()) { |
|
763 | + getpaid_admin()->{"show_$type"}($message); |
|
764 | 764 | } |
765 | 765 | |
766 | - wpinv_set_error( $code, $message, $type ); |
|
766 | + wpinv_set_error($code, $message, $type); |
|
767 | 767 | |
768 | 768 | } |
769 | 769 |
@@ -10,66 +10,66 @@ discard block |
||
10 | 10 | * @var array $columns |
11 | 11 | */ |
12 | 12 | |
13 | -defined( 'ABSPATH' ) || exit; |
|
13 | +defined('ABSPATH') || exit; |
|
14 | 14 | |
15 | 15 | ?> |
16 | 16 | |
17 | -<?php do_action( 'getpaid_before_email_line_item', $invoice, $item ); ?> |
|
17 | +<?php do_action('getpaid_before_email_line_item', $invoice, $item); ?> |
|
18 | 18 | |
19 | -<tr class="wpinv_cart_item item-type-<?php echo sanitize_html_class( $item->get_type() ); ?>"> |
|
19 | +<tr class="wpinv_cart_item item-type-<?php echo sanitize_html_class($item->get_type()); ?>"> |
|
20 | 20 | |
21 | - <?php foreach ( array_keys( $columns ) as $column ): ?> |
|
21 | + <?php foreach (array_keys($columns) as $column): ?> |
|
22 | 22 | |
23 | - <td class="<?php echo 'name' == $column ? 'text-left' : 'text-right' ?> wpinv_cart_item_<?php echo sanitize_html_class( $column ); ?>"> |
|
23 | + <td class="<?php echo 'name' == $column ? 'text-left' : 'text-right' ?> wpinv_cart_item_<?php echo sanitize_html_class($column); ?>"> |
|
24 | 24 | |
25 | 25 | <?php |
26 | 26 | |
27 | 27 | // Fires before printing a line item column. |
28 | - do_action( "getpaid_email_line_item_before_$column", $item, $invoice ); |
|
28 | + do_action("getpaid_email_line_item_before_$column", $item, $invoice); |
|
29 | 29 | |
30 | 30 | // Item name. |
31 | - if ( 'name' == $column ) { |
|
31 | + if ('name' == $column) { |
|
32 | 32 | |
33 | 33 | // Display the name. |
34 | - echo '<div class="wpinv_email_cart_item_title">' . sanitize_text_field( $item->get_name() ) . '</div>'; |
|
34 | + echo '<div class="wpinv_email_cart_item_title">' . sanitize_text_field($item->get_name()) . '</div>'; |
|
35 | 35 | |
36 | 36 | // And an optional description. |
37 | 37 | $description = $item->get_description(); |
38 | 38 | |
39 | - if ( ! empty( $description ) ) { |
|
40 | - $description = wp_kses_post( $description ); |
|
39 | + if (!empty($description)) { |
|
40 | + $description = wp_kses_post($description); |
|
41 | 41 | echo "<p class='small'>$description</p>"; |
42 | 42 | } |
43 | 43 | |
44 | 44 | } |
45 | 45 | |
46 | 46 | // Item price. |
47 | - if ( 'price' == $column ) { |
|
47 | + if ('price' == $column) { |
|
48 | 48 | |
49 | 49 | // Display the item price (or recurring price if this is a renewal invoice) |
50 | 50 | $price = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price(); |
51 | - echo wpinv_price( $price, $invoice->get_currency() ); |
|
51 | + echo wpinv_price($price, $invoice->get_currency()); |
|
52 | 52 | |
53 | 53 | } |
54 | 54 | |
55 | 55 | // Item quantity. |
56 | - if ( 'quantity' == $column ) { |
|
56 | + if ('quantity' == $column) { |
|
57 | 57 | echo (float) $item->get_quantity(); |
58 | 58 | } |
59 | 59 | |
60 | 60 | // Tax rate. |
61 | - if ( 'tax_rate' == $column ) { |
|
62 | - echo round( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) . '%'; |
|
61 | + if ('tax_rate' == $column) { |
|
62 | + echo round(getpaid_get_invoice_tax_rate($invoice, $item), 2) . '%'; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | // Item sub total. |
66 | - if ( 'subtotal' == $column ) { |
|
66 | + if ('subtotal' == $column) { |
|
67 | 67 | $subtotal = $invoice->is_renewal() ? $item->get_recurring_sub_total() : $item->get_sub_total(); |
68 | - echo wpinv_price( $subtotal, $invoice->get_currency() ); |
|
68 | + echo wpinv_price($subtotal, $invoice->get_currency()); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | // Fires when printing a line item column. |
72 | - do_action( "getpaid_email_line_item_$column", $item, $invoice ); |
|
72 | + do_action("getpaid_email_line_item_$column", $item, $invoice); |
|
73 | 73 | |
74 | 74 | ?> |
75 | 75 | |
@@ -79,4 +79,4 @@ discard block |
||
79 | 79 | |
80 | 80 | </tr> |
81 | 81 | |
82 | -<?php do_action( 'getpaid_after_email_line_item', $invoice, $item ); ?> |
|
82 | +<?php do_action('getpaid_after_email_line_item', $invoice, $item); ?> |
@@ -10,55 +10,55 @@ discard block |
||
10 | 10 | * @var array $columns |
11 | 11 | */ |
12 | 12 | |
13 | -defined( 'ABSPATH' ) || exit; |
|
13 | +defined('ABSPATH') || exit; |
|
14 | 14 | |
15 | -do_action( 'getpaid_before_invoice_line_item', $invoice, $item ); |
|
15 | +do_action('getpaid_before_invoice_line_item', $invoice, $item); |
|
16 | 16 | |
17 | 17 | ?> |
18 | 18 | |
19 | -<div class='getpaid-invoice-item item-<?php echo (int) $item->get_id(); ?> item-type-<?php echo sanitize_html_class( $item->get_type() ); ?> border-bottom'> |
|
19 | +<div class='getpaid-invoice-item item-<?php echo (int) $item->get_id(); ?> item-type-<?php echo sanitize_html_class($item->get_type()); ?> border-bottom'> |
|
20 | 20 | |
21 | 21 | <div class="form-row"> |
22 | 22 | |
23 | - <?php foreach ( array_keys( $columns ) as $column ): ?> |
|
23 | + <?php foreach (array_keys($columns) as $column): ?> |
|
24 | 24 | |
25 | - <div class="<?php echo 'name' == $column ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-invoice-item-<?php echo sanitize_html_class( $column ); ?>"> |
|
25 | + <div class="<?php echo 'name' == $column ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-invoice-item-<?php echo sanitize_html_class($column); ?>"> |
|
26 | 26 | |
27 | 27 | <?php |
28 | 28 | |
29 | 29 | // Fires before printing a line item column. |
30 | - do_action( "getpaid_invoice_line_item_before_$column", $item, $invoice ); |
|
30 | + do_action("getpaid_invoice_line_item_before_$column", $item, $invoice); |
|
31 | 31 | |
32 | 32 | // Item name. |
33 | - if ( 'name' == $column ) { |
|
33 | + if ('name' == $column) { |
|
34 | 34 | |
35 | 35 | // Display the name. |
36 | - echo '<div class="mb-1">' . sanitize_text_field( $item->get_name() ) . '</div>'; |
|
36 | + echo '<div class="mb-1">' . sanitize_text_field($item->get_name()) . '</div>'; |
|
37 | 37 | |
38 | 38 | // And an optional description. |
39 | 39 | $description = $item->get_description(); |
40 | 40 | |
41 | - if ( ! empty( $description ) ) { |
|
42 | - $description = wp_kses_post( $description ); |
|
41 | + if (!empty($description)) { |
|
42 | + $description = wp_kses_post($description); |
|
43 | 43 | echo "<small class='form-text text-muted pr-2 m-0'>$description</small>"; |
44 | 44 | } |
45 | 45 | |
46 | 46 | // Fires before printing the line item actions. |
47 | - do_action( "getpaid_before_invoice_line_item_actions", $item, $invoice ); |
|
47 | + do_action("getpaid_before_invoice_line_item_actions", $item, $invoice); |
|
48 | 48 | |
49 | - $actions = apply_filters( 'getpaid-invoice-page-line-item-actions', array(), $item, $invoice ); |
|
49 | + $actions = apply_filters('getpaid-invoice-page-line-item-actions', array(), $item, $invoice); |
|
50 | 50 | |
51 | - if ( ! empty( $actions ) ) { |
|
51 | + if (!empty($actions)) { |
|
52 | 52 | |
53 | - $sanitized = array(); |
|
54 | - foreach ( $actions as $key => $action ) { |
|
55 | - $key = sanitize_html_class( $key ); |
|
56 | - $action = wp_kses_post( $action ); |
|
53 | + $sanitized = array(); |
|
54 | + foreach ($actions as $key => $action) { |
|
55 | + $key = sanitize_html_class($key); |
|
56 | + $action = wp_kses_post($action); |
|
57 | 57 | $sanitized[] = "<span class='$key'>$action</span>"; |
58 | 58 | } |
59 | 59 | |
60 | 60 | echo "<small class='form-text getpaid-line-item-actions'>"; |
61 | - echo implode( ' | ', $sanitized ); |
|
61 | + echo implode(' | ', $sanitized); |
|
62 | 62 | echo '</small>'; |
63 | 63 | |
64 | 64 | } |
@@ -66,35 +66,35 @@ discard block |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | // Item price. |
69 | - if ( 'price' == $column ) { |
|
69 | + if ('price' == $column) { |
|
70 | 70 | |
71 | 71 | // Display the item price (or recurring price if this is a renewal invoice) |
72 | 72 | $price = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price(); |
73 | - echo wpinv_price( $price, $invoice->get_currency() ); |
|
73 | + echo wpinv_price($price, $invoice->get_currency()); |
|
74 | 74 | |
75 | 75 | } |
76 | 76 | |
77 | 77 | // Tax rate. |
78 | - if ( 'tax_rate' == $column ) { |
|
79 | - echo round( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) . '%'; |
|
78 | + if ('tax_rate' == $column) { |
|
79 | + echo round(getpaid_get_invoice_tax_rate($invoice, $item), 2) . '%'; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | // Item quantity. |
83 | - if ( 'quantity' == $column ) { |
|
83 | + if ('quantity' == $column) { |
|
84 | 84 | echo (float) $item->get_quantity(); |
85 | 85 | } |
86 | 86 | |
87 | 87 | // Item sub total. |
88 | - if ( 'subtotal' == $column ) { |
|
88 | + if ('subtotal' == $column) { |
|
89 | 89 | $subtotal = $invoice->is_renewal() ? $item->get_recurring_sub_total() : $item->get_sub_total(); |
90 | - echo wpinv_price( $subtotal, $invoice->get_currency() ); |
|
90 | + echo wpinv_price($subtotal, $invoice->get_currency()); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | // Fires when printing a line item column. |
94 | - do_action( "getpaid_invoice_line_item_$column", $item, $invoice ); |
|
94 | + do_action("getpaid_invoice_line_item_$column", $item, $invoice); |
|
95 | 95 | |
96 | 96 | // Fires after printing a line item column. |
97 | - do_action( "getpaid_invoice_line_item_after_$column", $item, $invoice ); |
|
97 | + do_action("getpaid_invoice_line_item_after_$column", $item, $invoice); |
|
98 | 98 | |
99 | 99 | ?> |
100 | 100 |
@@ -15,331 +15,331 @@ |
||
15 | 15 | class GetPaid_Post_Types { |
16 | 16 | |
17 | 17 | /** |
18 | - * Hook in methods. |
|
19 | - */ |
|
20 | - public function __construct() { |
|
21 | - add_action( 'init', array( __CLASS__, 'register_post_types' ), 1 ); |
|
22 | - add_action( 'init', array( __CLASS__, 'register_post_status' ), 4 ); |
|
23 | - add_action( 'getpaid_flush_rewrite_rules', array( __CLASS__, 'flush_rewrite_rules' ) ); |
|
24 | - add_action( 'getpaid_after_register_post_types', array( __CLASS__, 'maybe_flush_rewrite_rules' ) ); |
|
25 | - } |
|
18 | + * Hook in methods. |
|
19 | + */ |
|
20 | + public function __construct() { |
|
21 | + add_action( 'init', array( __CLASS__, 'register_post_types' ), 1 ); |
|
22 | + add_action( 'init', array( __CLASS__, 'register_post_status' ), 4 ); |
|
23 | + add_action( 'getpaid_flush_rewrite_rules', array( __CLASS__, 'flush_rewrite_rules' ) ); |
|
24 | + add_action( 'getpaid_after_register_post_types', array( __CLASS__, 'maybe_flush_rewrite_rules' ) ); |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * Register core post types. |
|
29 | - */ |
|
30 | - public static function register_post_types() { |
|
27 | + /** |
|
28 | + * Register core post types. |
|
29 | + */ |
|
30 | + public static function register_post_types() { |
|
31 | 31 | |
32 | - if ( ! is_blog_installed() || post_type_exists( 'wpi_item' ) ) { |
|
33 | - return; |
|
34 | - } |
|
32 | + if ( ! is_blog_installed() || post_type_exists( 'wpi_item' ) ) { |
|
33 | + return; |
|
34 | + } |
|
35 | 35 | |
36 | - $capabilities = wpinv_current_user_can_manage_invoicing(); |
|
36 | + $capabilities = wpinv_current_user_can_manage_invoicing(); |
|
37 | 37 | |
38 | - // Fires before registering post types. |
|
39 | - do_action( 'getpaid_register_post_types' ); |
|
38 | + // Fires before registering post types. |
|
39 | + do_action( 'getpaid_register_post_types' ); |
|
40 | 40 | |
41 | - // Register item post type. |
|
42 | - register_post_type( |
|
43 | - 'wpi_item', |
|
44 | - apply_filters( |
|
45 | - 'wpinv_register_post_type_invoice_item', |
|
46 | - array( |
|
47 | - 'labels' => array( |
|
48 | - 'name' => _x( 'Items', 'post type general name', 'invoicing' ), |
|
49 | - 'singular_name' => _x( 'Item', 'post type singular name', 'invoicing' ), |
|
50 | - 'menu_name' => _x( 'Items', 'admin menu', 'invoicing' ), |
|
51 | - 'name_admin_bar' => _x( 'Item', 'add new on admin bar', 'invoicing' ), |
|
52 | - 'add_new' => _x( 'Add New', 'Item', 'invoicing' ), |
|
53 | - 'add_new_item' => __( 'Add New Item', 'invoicing' ), |
|
54 | - 'new_item' => __( 'New Item', 'invoicing' ), |
|
55 | - 'edit_item' => __( 'Edit Item', 'invoicing' ), |
|
56 | - 'view_item' => __( 'View Item', 'invoicing' ), |
|
57 | - 'all_items' => __( 'Items', 'invoicing' ), |
|
58 | - 'search_items' => __( 'Search items', 'invoicing' ), |
|
59 | - 'parent_item_colon' => __( 'Parent item:', 'invoicing' ), |
|
60 | - 'not_found' => __( 'No items found.', 'invoicing' ), |
|
61 | - 'not_found_in_trash' => __( 'No items found in trash.', 'invoicing' ) |
|
62 | - ), |
|
63 | - 'description' => __( 'This is where you can add new invoice items.', 'invoicing' ), |
|
64 | - 'public' => false, |
|
65 | - 'has_archive' => false, |
|
66 | - '_builtin' => false, |
|
67 | - 'show_ui' => true, |
|
68 | - 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
69 | - 'show_in_nav_menus' => false, |
|
70 | - 'supports' => array( 'title', 'excerpt', 'thumbnail' ), |
|
71 | - 'rewrite' => false, |
|
72 | - 'query_var' => false, |
|
73 | - 'map_meta_cap' => true, |
|
74 | - 'show_in_admin_bar' => true, |
|
75 | - 'can_export' => true, |
|
76 | - ) |
|
77 | - ) |
|
78 | - ); |
|
41 | + // Register item post type. |
|
42 | + register_post_type( |
|
43 | + 'wpi_item', |
|
44 | + apply_filters( |
|
45 | + 'wpinv_register_post_type_invoice_item', |
|
46 | + array( |
|
47 | + 'labels' => array( |
|
48 | + 'name' => _x( 'Items', 'post type general name', 'invoicing' ), |
|
49 | + 'singular_name' => _x( 'Item', 'post type singular name', 'invoicing' ), |
|
50 | + 'menu_name' => _x( 'Items', 'admin menu', 'invoicing' ), |
|
51 | + 'name_admin_bar' => _x( 'Item', 'add new on admin bar', 'invoicing' ), |
|
52 | + 'add_new' => _x( 'Add New', 'Item', 'invoicing' ), |
|
53 | + 'add_new_item' => __( 'Add New Item', 'invoicing' ), |
|
54 | + 'new_item' => __( 'New Item', 'invoicing' ), |
|
55 | + 'edit_item' => __( 'Edit Item', 'invoicing' ), |
|
56 | + 'view_item' => __( 'View Item', 'invoicing' ), |
|
57 | + 'all_items' => __( 'Items', 'invoicing' ), |
|
58 | + 'search_items' => __( 'Search items', 'invoicing' ), |
|
59 | + 'parent_item_colon' => __( 'Parent item:', 'invoicing' ), |
|
60 | + 'not_found' => __( 'No items found.', 'invoicing' ), |
|
61 | + 'not_found_in_trash' => __( 'No items found in trash.', 'invoicing' ) |
|
62 | + ), |
|
63 | + 'description' => __( 'This is where you can add new invoice items.', 'invoicing' ), |
|
64 | + 'public' => false, |
|
65 | + 'has_archive' => false, |
|
66 | + '_builtin' => false, |
|
67 | + 'show_ui' => true, |
|
68 | + 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
69 | + 'show_in_nav_menus' => false, |
|
70 | + 'supports' => array( 'title', 'excerpt', 'thumbnail' ), |
|
71 | + 'rewrite' => false, |
|
72 | + 'query_var' => false, |
|
73 | + 'map_meta_cap' => true, |
|
74 | + 'show_in_admin_bar' => true, |
|
75 | + 'can_export' => true, |
|
76 | + ) |
|
77 | + ) |
|
78 | + ); |
|
79 | 79 | |
80 | - // Register payment form post type. |
|
81 | - register_post_type( |
|
82 | - 'wpi_payment_form', |
|
83 | - apply_filters( |
|
84 | - 'wpinv_register_post_type_payment_form', |
|
85 | - array( |
|
86 | - 'labels' => array( |
|
87 | - 'name' => _x( 'Payment Forms', 'post type general name', 'invoicing' ), |
|
88 | - 'singular_name' => _x( 'Payment Form', 'post type singular name', 'invoicing' ), |
|
89 | - 'menu_name' => _x( 'Payment Forms', 'admin menu', 'invoicing' ), |
|
90 | - 'name_admin_bar' => _x( 'Payment Form', 'add new on admin bar', 'invoicing' ), |
|
91 | - 'add_new' => _x( 'Add New', 'Payment Form', 'invoicing' ), |
|
92 | - 'add_new_item' => __( 'Add New Payment Form', 'invoicing' ), |
|
93 | - 'new_item' => __( 'New Payment Form', 'invoicing' ), |
|
94 | - 'edit_item' => __( 'Edit Payment Form', 'invoicing' ), |
|
95 | - 'view_item' => __( 'View Payment Form', 'invoicing' ), |
|
96 | - 'all_items' => __( 'Payment Forms', 'invoicing' ), |
|
97 | - 'search_items' => __( 'Search Payment Forms', 'invoicing' ), |
|
98 | - 'parent_item_colon' => __( 'Parent Payment Forms:', 'invoicing' ), |
|
99 | - 'not_found' => __( 'No payment forms found.', 'invoicing' ), |
|
100 | - 'not_found_in_trash' => __( 'No payment forms found in trash.', 'invoicing' ) |
|
101 | - ), |
|
102 | - 'description' => __( 'Add new payment forms.', 'invoicing' ), |
|
103 | - 'public' => false, |
|
104 | - 'show_ui' => true, |
|
105 | - 'show_in_menu' => $capabilities ? 'wpinv' : true, |
|
106 | - 'show_in_nav_menus' => false, |
|
107 | - 'query_var' => false, |
|
108 | - 'rewrite' => true, |
|
109 | - 'map_meta_cap' => true, |
|
110 | - 'has_archive' => false, |
|
111 | - 'hierarchical' => false, |
|
112 | - 'menu_position' => null, |
|
113 | - 'supports' => array( 'title' ), |
|
114 | - 'menu_icon' => 'dashicons-media-form', |
|
115 | - 'capabilities' => array( |
|
116 | - 'edit_post' => $capabilities, |
|
117 | - 'read_post' => $capabilities, |
|
118 | - 'delete_post' => $capabilities, |
|
119 | - 'edit_posts' => 'update_core', |
|
120 | - 'edit_others_posts' => 'update_core', |
|
121 | - 'delete_posts' => 'update_core', |
|
122 | - 'publish_posts' => 'update_core', |
|
123 | - 'read_private_posts' => 'update_core' |
|
124 | - ), |
|
125 | - ) |
|
126 | - ) |
|
127 | - ); |
|
80 | + // Register payment form post type. |
|
81 | + register_post_type( |
|
82 | + 'wpi_payment_form', |
|
83 | + apply_filters( |
|
84 | + 'wpinv_register_post_type_payment_form', |
|
85 | + array( |
|
86 | + 'labels' => array( |
|
87 | + 'name' => _x( 'Payment Forms', 'post type general name', 'invoicing' ), |
|
88 | + 'singular_name' => _x( 'Payment Form', 'post type singular name', 'invoicing' ), |
|
89 | + 'menu_name' => _x( 'Payment Forms', 'admin menu', 'invoicing' ), |
|
90 | + 'name_admin_bar' => _x( 'Payment Form', 'add new on admin bar', 'invoicing' ), |
|
91 | + 'add_new' => _x( 'Add New', 'Payment Form', 'invoicing' ), |
|
92 | + 'add_new_item' => __( 'Add New Payment Form', 'invoicing' ), |
|
93 | + 'new_item' => __( 'New Payment Form', 'invoicing' ), |
|
94 | + 'edit_item' => __( 'Edit Payment Form', 'invoicing' ), |
|
95 | + 'view_item' => __( 'View Payment Form', 'invoicing' ), |
|
96 | + 'all_items' => __( 'Payment Forms', 'invoicing' ), |
|
97 | + 'search_items' => __( 'Search Payment Forms', 'invoicing' ), |
|
98 | + 'parent_item_colon' => __( 'Parent Payment Forms:', 'invoicing' ), |
|
99 | + 'not_found' => __( 'No payment forms found.', 'invoicing' ), |
|
100 | + 'not_found_in_trash' => __( 'No payment forms found in trash.', 'invoicing' ) |
|
101 | + ), |
|
102 | + 'description' => __( 'Add new payment forms.', 'invoicing' ), |
|
103 | + 'public' => false, |
|
104 | + 'show_ui' => true, |
|
105 | + 'show_in_menu' => $capabilities ? 'wpinv' : true, |
|
106 | + 'show_in_nav_menus' => false, |
|
107 | + 'query_var' => false, |
|
108 | + 'rewrite' => true, |
|
109 | + 'map_meta_cap' => true, |
|
110 | + 'has_archive' => false, |
|
111 | + 'hierarchical' => false, |
|
112 | + 'menu_position' => null, |
|
113 | + 'supports' => array( 'title' ), |
|
114 | + 'menu_icon' => 'dashicons-media-form', |
|
115 | + 'capabilities' => array( |
|
116 | + 'edit_post' => $capabilities, |
|
117 | + 'read_post' => $capabilities, |
|
118 | + 'delete_post' => $capabilities, |
|
119 | + 'edit_posts' => 'update_core', |
|
120 | + 'edit_others_posts' => 'update_core', |
|
121 | + 'delete_posts' => 'update_core', |
|
122 | + 'publish_posts' => 'update_core', |
|
123 | + 'read_private_posts' => 'update_core' |
|
124 | + ), |
|
125 | + ) |
|
126 | + ) |
|
127 | + ); |
|
128 | 128 | |
129 | - // Register invoice post type. |
|
130 | - register_post_type( |
|
131 | - 'wpi_invoice', |
|
132 | - apply_filters( |
|
133 | - 'wpinv_register_post_type_invoice', |
|
134 | - array( |
|
135 | - 'labels' => array( |
|
136 | - 'name' => __( 'Invoices', 'invoicing' ), |
|
137 | - 'singular_name' => __( 'Invoice', 'invoicing' ), |
|
138 | - 'all_items' => __( 'Invoices', 'invoicing' ), |
|
139 | - 'menu_name' => _x( 'Invoices', 'Admin menu name', 'invoicing' ), |
|
140 | - 'add_new' => __( 'Add New', 'invoicing' ), |
|
141 | - 'add_new_item' => __( 'Add new invoice', 'invoicing' ), |
|
142 | - 'edit' => __( 'Edit', 'invoicing' ), |
|
143 | - 'edit_item' => __( 'Edit invoice', 'invoicing' ), |
|
144 | - 'new_item' => __( 'New invoice', 'invoicing' ), |
|
145 | - 'view_item' => __( 'View invoice', 'invoicing' ), |
|
146 | - 'view_items' => __( 'View Invoices', 'invoicing' ), |
|
147 | - 'search_items' => __( 'Search invoices', 'invoicing' ), |
|
148 | - 'not_found' => __( 'No invoices found', 'invoicing' ), |
|
149 | - 'not_found_in_trash' => __( 'No invoices found in trash', 'invoicing' ), |
|
150 | - 'parent' => __( 'Parent invoice', 'invoicing' ), |
|
151 | - 'featured_image' => __( 'Invoice image', 'invoicing' ), |
|
152 | - 'set_featured_image' => __( 'Set invoice image', 'invoicing' ), |
|
153 | - 'remove_featured_image' => __( 'Remove invoice image', 'invoicing' ), |
|
154 | - 'use_featured_image' => __( 'Use as invoice image', 'invoicing' ), |
|
155 | - 'insert_into_item' => __( 'Insert into invoice', 'invoicing' ), |
|
156 | - 'uploaded_to_this_item' => __( 'Uploaded to this invoice', 'invoicing' ), |
|
157 | - 'filter_items_list' => __( 'Filter invoices', 'invoicing' ), |
|
158 | - 'items_list_navigation' => __( 'Invoices navigation', 'invoicing' ), |
|
159 | - 'items_list' => __( 'Invoices list', 'invoicing' ), |
|
160 | - ), |
|
161 | - 'description' => __( 'This is where invoices are stored.', 'invoicing' ), |
|
162 | - 'public' => true, |
|
163 | - 'has_archive' => false, |
|
164 | - 'publicly_queryable' => true, |
|
165 | - 'exclude_from_search' => true, |
|
166 | - 'show_ui' => true, |
|
167 | - 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
168 | - 'show_in_nav_menus' => false, |
|
169 | - 'supports' => array( 'title', 'author', 'excerpt' ), |
|
170 | - 'rewrite' => array( |
|
171 | - 'slug' => 'invoice', |
|
172 | - 'with_front' => false, |
|
173 | - ), |
|
174 | - 'query_var' => false, |
|
175 | - 'map_meta_cap' => true, |
|
176 | - 'show_in_admin_bar' => true, |
|
177 | - 'can_export' => true, |
|
178 | - 'hierarchical' => false, |
|
179 | - 'menu_position' => null, |
|
180 | - 'menu_icon' => 'dashicons-media-spreadsheet', |
|
181 | - ) |
|
182 | - ) |
|
183 | - ); |
|
129 | + // Register invoice post type. |
|
130 | + register_post_type( |
|
131 | + 'wpi_invoice', |
|
132 | + apply_filters( |
|
133 | + 'wpinv_register_post_type_invoice', |
|
134 | + array( |
|
135 | + 'labels' => array( |
|
136 | + 'name' => __( 'Invoices', 'invoicing' ), |
|
137 | + 'singular_name' => __( 'Invoice', 'invoicing' ), |
|
138 | + 'all_items' => __( 'Invoices', 'invoicing' ), |
|
139 | + 'menu_name' => _x( 'Invoices', 'Admin menu name', 'invoicing' ), |
|
140 | + 'add_new' => __( 'Add New', 'invoicing' ), |
|
141 | + 'add_new_item' => __( 'Add new invoice', 'invoicing' ), |
|
142 | + 'edit' => __( 'Edit', 'invoicing' ), |
|
143 | + 'edit_item' => __( 'Edit invoice', 'invoicing' ), |
|
144 | + 'new_item' => __( 'New invoice', 'invoicing' ), |
|
145 | + 'view_item' => __( 'View invoice', 'invoicing' ), |
|
146 | + 'view_items' => __( 'View Invoices', 'invoicing' ), |
|
147 | + 'search_items' => __( 'Search invoices', 'invoicing' ), |
|
148 | + 'not_found' => __( 'No invoices found', 'invoicing' ), |
|
149 | + 'not_found_in_trash' => __( 'No invoices found in trash', 'invoicing' ), |
|
150 | + 'parent' => __( 'Parent invoice', 'invoicing' ), |
|
151 | + 'featured_image' => __( 'Invoice image', 'invoicing' ), |
|
152 | + 'set_featured_image' => __( 'Set invoice image', 'invoicing' ), |
|
153 | + 'remove_featured_image' => __( 'Remove invoice image', 'invoicing' ), |
|
154 | + 'use_featured_image' => __( 'Use as invoice image', 'invoicing' ), |
|
155 | + 'insert_into_item' => __( 'Insert into invoice', 'invoicing' ), |
|
156 | + 'uploaded_to_this_item' => __( 'Uploaded to this invoice', 'invoicing' ), |
|
157 | + 'filter_items_list' => __( 'Filter invoices', 'invoicing' ), |
|
158 | + 'items_list_navigation' => __( 'Invoices navigation', 'invoicing' ), |
|
159 | + 'items_list' => __( 'Invoices list', 'invoicing' ), |
|
160 | + ), |
|
161 | + 'description' => __( 'This is where invoices are stored.', 'invoicing' ), |
|
162 | + 'public' => true, |
|
163 | + 'has_archive' => false, |
|
164 | + 'publicly_queryable' => true, |
|
165 | + 'exclude_from_search' => true, |
|
166 | + 'show_ui' => true, |
|
167 | + 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
168 | + 'show_in_nav_menus' => false, |
|
169 | + 'supports' => array( 'title', 'author', 'excerpt' ), |
|
170 | + 'rewrite' => array( |
|
171 | + 'slug' => 'invoice', |
|
172 | + 'with_front' => false, |
|
173 | + ), |
|
174 | + 'query_var' => false, |
|
175 | + 'map_meta_cap' => true, |
|
176 | + 'show_in_admin_bar' => true, |
|
177 | + 'can_export' => true, |
|
178 | + 'hierarchical' => false, |
|
179 | + 'menu_position' => null, |
|
180 | + 'menu_icon' => 'dashicons-media-spreadsheet', |
|
181 | + ) |
|
182 | + ) |
|
183 | + ); |
|
184 | 184 | |
185 | - // Register discount post type. |
|
186 | - register_post_type( |
|
187 | - 'wpi_discount', |
|
188 | - apply_filters( |
|
189 | - 'wpinv_register_post_type_discount', |
|
190 | - array( |
|
191 | - 'labels' => array( |
|
192 | - 'name' => __( 'Discounts', 'invoicing' ), |
|
193 | - 'singular_name' => __( 'Discount', 'invoicing' ), |
|
194 | - 'all_items' => __( 'Discounts', 'invoicing' ), |
|
195 | - 'menu_name' => _x( 'Discounts', 'Admin menu name', 'invoicing' ), |
|
196 | - 'add_new' => __( 'Add New', 'invoicing' ), |
|
197 | - 'add_new_item' => __( 'Add new discount', 'invoicing' ), |
|
198 | - 'edit' => __( 'Edit', 'invoicing' ), |
|
199 | - 'edit_item' => __( 'Edit discount', 'invoicing' ), |
|
200 | - 'new_item' => __( 'New discount', 'invoicing' ), |
|
201 | - 'view_item' => __( 'View discount', 'invoicing' ), |
|
202 | - 'view_items' => __( 'View Discounts', 'invoicing' ), |
|
203 | - 'search_items' => __( 'Search discounts', 'invoicing' ), |
|
204 | - 'not_found' => __( 'No discounts found', 'invoicing' ), |
|
205 | - 'not_found_in_trash' => __( 'No discounts found in trash', 'invoicing' ), |
|
206 | - 'parent' => __( 'Parent discount', 'invoicing' ), |
|
207 | - 'featured_image' => __( 'Discount image', 'invoicing' ), |
|
208 | - 'set_featured_image' => __( 'Set discount image', 'invoicing' ), |
|
209 | - 'remove_featured_image' => __( 'Remove discount image', 'invoicing' ), |
|
210 | - 'use_featured_image' => __( 'Use as discount image', 'invoicing' ), |
|
211 | - 'insert_into_item' => __( 'Insert into discount', 'invoicing' ), |
|
212 | - 'uploaded_to_this_item' => __( 'Uploaded to this discount', 'invoicing' ), |
|
213 | - 'filter_items_list' => __( 'Filter discounts', 'invoicing' ), |
|
214 | - 'items_list_navigation' => __( 'Discount navigation', 'invoicing' ), |
|
215 | - 'items_list' => __( 'Discounts list', 'invoicing' ), |
|
216 | - ), |
|
217 | - 'description' => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ), |
|
218 | - 'public' => false, |
|
219 | - 'can_export' => true, |
|
220 | - '_builtin' => false, |
|
221 | - 'publicly_queryable' => false, |
|
222 | - 'exclude_from_search'=> true, |
|
223 | - 'show_ui' => true, |
|
224 | - 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
225 | - 'query_var' => false, |
|
226 | - 'rewrite' => false, |
|
227 | - 'map_meta_cap' => true, |
|
228 | - 'has_archive' => false, |
|
229 | - 'hierarchical' => false, |
|
230 | - 'supports' => array( 'title', 'excerpt' ), |
|
231 | - 'show_in_nav_menus' => false, |
|
232 | - 'show_in_admin_bar' => true, |
|
233 | - 'menu_position' => null, |
|
234 | - ) |
|
235 | - ) |
|
236 | - ); |
|
185 | + // Register discount post type. |
|
186 | + register_post_type( |
|
187 | + 'wpi_discount', |
|
188 | + apply_filters( |
|
189 | + 'wpinv_register_post_type_discount', |
|
190 | + array( |
|
191 | + 'labels' => array( |
|
192 | + 'name' => __( 'Discounts', 'invoicing' ), |
|
193 | + 'singular_name' => __( 'Discount', 'invoicing' ), |
|
194 | + 'all_items' => __( 'Discounts', 'invoicing' ), |
|
195 | + 'menu_name' => _x( 'Discounts', 'Admin menu name', 'invoicing' ), |
|
196 | + 'add_new' => __( 'Add New', 'invoicing' ), |
|
197 | + 'add_new_item' => __( 'Add new discount', 'invoicing' ), |
|
198 | + 'edit' => __( 'Edit', 'invoicing' ), |
|
199 | + 'edit_item' => __( 'Edit discount', 'invoicing' ), |
|
200 | + 'new_item' => __( 'New discount', 'invoicing' ), |
|
201 | + 'view_item' => __( 'View discount', 'invoicing' ), |
|
202 | + 'view_items' => __( 'View Discounts', 'invoicing' ), |
|
203 | + 'search_items' => __( 'Search discounts', 'invoicing' ), |
|
204 | + 'not_found' => __( 'No discounts found', 'invoicing' ), |
|
205 | + 'not_found_in_trash' => __( 'No discounts found in trash', 'invoicing' ), |
|
206 | + 'parent' => __( 'Parent discount', 'invoicing' ), |
|
207 | + 'featured_image' => __( 'Discount image', 'invoicing' ), |
|
208 | + 'set_featured_image' => __( 'Set discount image', 'invoicing' ), |
|
209 | + 'remove_featured_image' => __( 'Remove discount image', 'invoicing' ), |
|
210 | + 'use_featured_image' => __( 'Use as discount image', 'invoicing' ), |
|
211 | + 'insert_into_item' => __( 'Insert into discount', 'invoicing' ), |
|
212 | + 'uploaded_to_this_item' => __( 'Uploaded to this discount', 'invoicing' ), |
|
213 | + 'filter_items_list' => __( 'Filter discounts', 'invoicing' ), |
|
214 | + 'items_list_navigation' => __( 'Discount navigation', 'invoicing' ), |
|
215 | + 'items_list' => __( 'Discounts list', 'invoicing' ), |
|
216 | + ), |
|
217 | + 'description' => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ), |
|
218 | + 'public' => false, |
|
219 | + 'can_export' => true, |
|
220 | + '_builtin' => false, |
|
221 | + 'publicly_queryable' => false, |
|
222 | + 'exclude_from_search'=> true, |
|
223 | + 'show_ui' => true, |
|
224 | + 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
225 | + 'query_var' => false, |
|
226 | + 'rewrite' => false, |
|
227 | + 'map_meta_cap' => true, |
|
228 | + 'has_archive' => false, |
|
229 | + 'hierarchical' => false, |
|
230 | + 'supports' => array( 'title', 'excerpt' ), |
|
231 | + 'show_in_nav_menus' => false, |
|
232 | + 'show_in_admin_bar' => true, |
|
233 | + 'menu_position' => null, |
|
234 | + ) |
|
235 | + ) |
|
236 | + ); |
|
237 | 237 | |
238 | - do_action( 'getpaid_after_register_post_types' ); |
|
239 | - } |
|
238 | + do_action( 'getpaid_after_register_post_types' ); |
|
239 | + } |
|
240 | 240 | |
241 | - /** |
|
242 | - * Register our custom post statuses. |
|
243 | - */ |
|
244 | - public static function register_post_status() { |
|
241 | + /** |
|
242 | + * Register our custom post statuses. |
|
243 | + */ |
|
244 | + public static function register_post_status() { |
|
245 | 245 | |
246 | - $invoice_statuses = apply_filters( |
|
247 | - 'getpaid_register_invoice_post_statuses', |
|
248 | - array( |
|
246 | + $invoice_statuses = apply_filters( |
|
247 | + 'getpaid_register_invoice_post_statuses', |
|
248 | + array( |
|
249 | 249 | |
250 | - 'wpi-pending' => array( |
|
251 | - 'label' => _x( 'Pending Payment', 'Invoice status', 'invoicing' ), |
|
252 | - 'public' => true, |
|
253 | - 'exclude_from_search' => true, |
|
254 | - 'show_in_admin_all_list' => true, |
|
255 | - 'show_in_admin_status_list' => true, |
|
256 | - /* translators: %s: number of invoices */ |
|
257 | - 'label_count' => _n_noop( 'Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'invoicing' ) |
|
258 | - ), |
|
250 | + 'wpi-pending' => array( |
|
251 | + 'label' => _x( 'Pending Payment', 'Invoice status', 'invoicing' ), |
|
252 | + 'public' => true, |
|
253 | + 'exclude_from_search' => true, |
|
254 | + 'show_in_admin_all_list' => true, |
|
255 | + 'show_in_admin_status_list' => true, |
|
256 | + /* translators: %s: number of invoices */ |
|
257 | + 'label_count' => _n_noop( 'Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'invoicing' ) |
|
258 | + ), |
|
259 | 259 | |
260 | - 'wpi-processing' => array( |
|
261 | - 'label' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
|
262 | - 'public' => true, |
|
263 | - 'exclude_from_search' => true, |
|
264 | - 'show_in_admin_all_list' => true, |
|
265 | - 'show_in_admin_status_list' => true, |
|
266 | - /* translators: %s: number of invoices */ |
|
267 | - 'label_count' => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' ) |
|
268 | - ), |
|
260 | + 'wpi-processing' => array( |
|
261 | + 'label' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
|
262 | + 'public' => true, |
|
263 | + 'exclude_from_search' => true, |
|
264 | + 'show_in_admin_all_list' => true, |
|
265 | + 'show_in_admin_status_list' => true, |
|
266 | + /* translators: %s: number of invoices */ |
|
267 | + 'label_count' => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' ) |
|
268 | + ), |
|
269 | 269 | |
270 | - 'wpi-onhold' => array( |
|
271 | - 'label' => _x( 'On Hold', 'Invoice status', 'invoicing' ), |
|
272 | - 'public' => true, |
|
273 | - 'exclude_from_search' => true, |
|
274 | - 'show_in_admin_all_list' => true, |
|
275 | - 'show_in_admin_status_list' => true, |
|
276 | - /* translators: %s: number of invoices */ |
|
277 | - 'label_count' => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' ) |
|
278 | - ), |
|
270 | + 'wpi-onhold' => array( |
|
271 | + 'label' => _x( 'On Hold', 'Invoice status', 'invoicing' ), |
|
272 | + 'public' => true, |
|
273 | + 'exclude_from_search' => true, |
|
274 | + 'show_in_admin_all_list' => true, |
|
275 | + 'show_in_admin_status_list' => true, |
|
276 | + /* translators: %s: number of invoices */ |
|
277 | + 'label_count' => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' ) |
|
278 | + ), |
|
279 | 279 | |
280 | - 'wpi-cancelled' => array( |
|
281 | - 'label' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
282 | - 'public' => true, |
|
283 | - 'exclude_from_search' => true, |
|
284 | - 'show_in_admin_all_list' => true, |
|
285 | - 'show_in_admin_status_list' => true, |
|
286 | - /* translators: %s: number of invoices */ |
|
287 | - 'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' ) |
|
288 | - ), |
|
280 | + 'wpi-cancelled' => array( |
|
281 | + 'label' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
282 | + 'public' => true, |
|
283 | + 'exclude_from_search' => true, |
|
284 | + 'show_in_admin_all_list' => true, |
|
285 | + 'show_in_admin_status_list' => true, |
|
286 | + /* translators: %s: number of invoices */ |
|
287 | + 'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' ) |
|
288 | + ), |
|
289 | 289 | |
290 | - 'wpi-refunded' => array( |
|
291 | - 'label' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
292 | - 'public' => true, |
|
293 | - 'exclude_from_search' => true, |
|
294 | - 'show_in_admin_all_list' => true, |
|
295 | - 'show_in_admin_status_list' => true, |
|
296 | - /* translators: %s: number of invoices */ |
|
297 | - 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' ) |
|
298 | - ), |
|
290 | + 'wpi-refunded' => array( |
|
291 | + 'label' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
292 | + 'public' => true, |
|
293 | + 'exclude_from_search' => true, |
|
294 | + 'show_in_admin_all_list' => true, |
|
295 | + 'show_in_admin_status_list' => true, |
|
296 | + /* translators: %s: number of invoices */ |
|
297 | + 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' ) |
|
298 | + ), |
|
299 | 299 | |
300 | - 'wpi-failed' => array( |
|
301 | - 'label' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
|
302 | - 'public' => true, |
|
303 | - 'exclude_from_search' => true, |
|
304 | - 'show_in_admin_all_list' => true, |
|
305 | - 'show_in_admin_status_list' => true, |
|
306 | - /* translators: %s: number of invoices */ |
|
307 | - 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' ) |
|
308 | - ), |
|
300 | + 'wpi-failed' => array( |
|
301 | + 'label' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
|
302 | + 'public' => true, |
|
303 | + 'exclude_from_search' => true, |
|
304 | + 'show_in_admin_all_list' => true, |
|
305 | + 'show_in_admin_status_list' => true, |
|
306 | + /* translators: %s: number of invoices */ |
|
307 | + 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' ) |
|
308 | + ), |
|
309 | 309 | |
310 | - 'wpi-renewal' => array( |
|
311 | - 'label' => _x( 'Renewal', 'Invoice status', 'invoicing' ), |
|
312 | - 'public' => true, |
|
313 | - 'exclude_from_search' => true, |
|
314 | - 'show_in_admin_all_list' => true, |
|
315 | - 'show_in_admin_status_list' => true, |
|
316 | - /* translators: %s: number of invoices */ |
|
317 | - 'label_count' => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' ) |
|
318 | - ) |
|
319 | - ) |
|
320 | - ); |
|
310 | + 'wpi-renewal' => array( |
|
311 | + 'label' => _x( 'Renewal', 'Invoice status', 'invoicing' ), |
|
312 | + 'public' => true, |
|
313 | + 'exclude_from_search' => true, |
|
314 | + 'show_in_admin_all_list' => true, |
|
315 | + 'show_in_admin_status_list' => true, |
|
316 | + /* translators: %s: number of invoices */ |
|
317 | + 'label_count' => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' ) |
|
318 | + ) |
|
319 | + ) |
|
320 | + ); |
|
321 | 321 | |
322 | - foreach ( $invoice_statuses as $invoice_statuse => $args ) { |
|
323 | - register_post_status( $invoice_statuse, $args ); |
|
324 | - } |
|
325 | - } |
|
322 | + foreach ( $invoice_statuses as $invoice_statuse => $args ) { |
|
323 | + register_post_status( $invoice_statuse, $args ); |
|
324 | + } |
|
325 | + } |
|
326 | 326 | |
327 | - /** |
|
328 | - * Flush rewrite rules. |
|
329 | - */ |
|
330 | - public static function flush_rewrite_rules() { |
|
331 | - flush_rewrite_rules(); |
|
332 | - } |
|
327 | + /** |
|
328 | + * Flush rewrite rules. |
|
329 | + */ |
|
330 | + public static function flush_rewrite_rules() { |
|
331 | + flush_rewrite_rules(); |
|
332 | + } |
|
333 | 333 | |
334 | - /** |
|
335 | - * Flush rules to prevent 404. |
|
336 | - * |
|
337 | - */ |
|
338 | - public static function maybe_flush_rewrite_rules() { |
|
339 | - if ( ! get_option( 'getpaid_flushed_rewrite_rules' ) ) { |
|
340 | - update_option( 'getpaid_flushed_rewrite_rules', '1' ); |
|
341 | - self::flush_rewrite_rules(); |
|
342 | - } |
|
343 | - } |
|
334 | + /** |
|
335 | + * Flush rules to prevent 404. |
|
336 | + * |
|
337 | + */ |
|
338 | + public static function maybe_flush_rewrite_rules() { |
|
339 | + if ( ! get_option( 'getpaid_flushed_rewrite_rules' ) ) { |
|
340 | + update_option( 'getpaid_flushed_rewrite_rules', '1' ); |
|
341 | + self::flush_rewrite_rules(); |
|
342 | + } |
|
343 | + } |
|
344 | 344 | |
345 | 345 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Post types Class |
@@ -18,10 +18,10 @@ discard block |
||
18 | 18 | * Hook in methods. |
19 | 19 | */ |
20 | 20 | public function __construct() { |
21 | - add_action( 'init', array( __CLASS__, 'register_post_types' ), 1 ); |
|
22 | - add_action( 'init', array( __CLASS__, 'register_post_status' ), 4 ); |
|
23 | - add_action( 'getpaid_flush_rewrite_rules', array( __CLASS__, 'flush_rewrite_rules' ) ); |
|
24 | - add_action( 'getpaid_after_register_post_types', array( __CLASS__, 'maybe_flush_rewrite_rules' ) ); |
|
21 | + add_action('init', array(__CLASS__, 'register_post_types'), 1); |
|
22 | + add_action('init', array(__CLASS__, 'register_post_status'), 4); |
|
23 | + add_action('getpaid_flush_rewrite_rules', array(__CLASS__, 'flush_rewrite_rules')); |
|
24 | + add_action('getpaid_after_register_post_types', array(__CLASS__, 'maybe_flush_rewrite_rules')); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -29,14 +29,14 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public static function register_post_types() { |
31 | 31 | |
32 | - if ( ! is_blog_installed() || post_type_exists( 'wpi_item' ) ) { |
|
32 | + if (!is_blog_installed() || post_type_exists('wpi_item')) { |
|
33 | 33 | return; |
34 | 34 | } |
35 | 35 | |
36 | 36 | $capabilities = wpinv_current_user_can_manage_invoicing(); |
37 | 37 | |
38 | 38 | // Fires before registering post types. |
39 | - do_action( 'getpaid_register_post_types' ); |
|
39 | + do_action('getpaid_register_post_types'); |
|
40 | 40 | |
41 | 41 | // Register item post type. |
42 | 42 | register_post_type( |
@@ -45,29 +45,29 @@ discard block |
||
45 | 45 | 'wpinv_register_post_type_invoice_item', |
46 | 46 | array( |
47 | 47 | 'labels' => array( |
48 | - 'name' => _x( 'Items', 'post type general name', 'invoicing' ), |
|
49 | - 'singular_name' => _x( 'Item', 'post type singular name', 'invoicing' ), |
|
50 | - 'menu_name' => _x( 'Items', 'admin menu', 'invoicing' ), |
|
51 | - 'name_admin_bar' => _x( 'Item', 'add new on admin bar', 'invoicing' ), |
|
52 | - 'add_new' => _x( 'Add New', 'Item', 'invoicing' ), |
|
53 | - 'add_new_item' => __( 'Add New Item', 'invoicing' ), |
|
54 | - 'new_item' => __( 'New Item', 'invoicing' ), |
|
55 | - 'edit_item' => __( 'Edit Item', 'invoicing' ), |
|
56 | - 'view_item' => __( 'View Item', 'invoicing' ), |
|
57 | - 'all_items' => __( 'Items', 'invoicing' ), |
|
58 | - 'search_items' => __( 'Search items', 'invoicing' ), |
|
59 | - 'parent_item_colon' => __( 'Parent item:', 'invoicing' ), |
|
60 | - 'not_found' => __( 'No items found.', 'invoicing' ), |
|
61 | - 'not_found_in_trash' => __( 'No items found in trash.', 'invoicing' ) |
|
48 | + 'name' => _x('Items', 'post type general name', 'invoicing'), |
|
49 | + 'singular_name' => _x('Item', 'post type singular name', 'invoicing'), |
|
50 | + 'menu_name' => _x('Items', 'admin menu', 'invoicing'), |
|
51 | + 'name_admin_bar' => _x('Item', 'add new on admin bar', 'invoicing'), |
|
52 | + 'add_new' => _x('Add New', 'Item', 'invoicing'), |
|
53 | + 'add_new_item' => __('Add New Item', 'invoicing'), |
|
54 | + 'new_item' => __('New Item', 'invoicing'), |
|
55 | + 'edit_item' => __('Edit Item', 'invoicing'), |
|
56 | + 'view_item' => __('View Item', 'invoicing'), |
|
57 | + 'all_items' => __('Items', 'invoicing'), |
|
58 | + 'search_items' => __('Search items', 'invoicing'), |
|
59 | + 'parent_item_colon' => __('Parent item:', 'invoicing'), |
|
60 | + 'not_found' => __('No items found.', 'invoicing'), |
|
61 | + 'not_found_in_trash' => __('No items found in trash.', 'invoicing') |
|
62 | 62 | ), |
63 | - 'description' => __( 'This is where you can add new invoice items.', 'invoicing' ), |
|
63 | + 'description' => __('This is where you can add new invoice items.', 'invoicing'), |
|
64 | 64 | 'public' => false, |
65 | 65 | 'has_archive' => false, |
66 | 66 | '_builtin' => false, |
67 | 67 | 'show_ui' => true, |
68 | 68 | 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
69 | 69 | 'show_in_nav_menus' => false, |
70 | - 'supports' => array( 'title', 'excerpt', 'thumbnail' ), |
|
70 | + 'supports' => array('title', 'excerpt', 'thumbnail'), |
|
71 | 71 | 'rewrite' => false, |
72 | 72 | 'query_var' => false, |
73 | 73 | 'map_meta_cap' => true, |
@@ -84,22 +84,22 @@ discard block |
||
84 | 84 | 'wpinv_register_post_type_payment_form', |
85 | 85 | array( |
86 | 86 | 'labels' => array( |
87 | - 'name' => _x( 'Payment Forms', 'post type general name', 'invoicing' ), |
|
88 | - 'singular_name' => _x( 'Payment Form', 'post type singular name', 'invoicing' ), |
|
89 | - 'menu_name' => _x( 'Payment Forms', 'admin menu', 'invoicing' ), |
|
90 | - 'name_admin_bar' => _x( 'Payment Form', 'add new on admin bar', 'invoicing' ), |
|
91 | - 'add_new' => _x( 'Add New', 'Payment Form', 'invoicing' ), |
|
92 | - 'add_new_item' => __( 'Add New Payment Form', 'invoicing' ), |
|
93 | - 'new_item' => __( 'New Payment Form', 'invoicing' ), |
|
94 | - 'edit_item' => __( 'Edit Payment Form', 'invoicing' ), |
|
95 | - 'view_item' => __( 'View Payment Form', 'invoicing' ), |
|
96 | - 'all_items' => __( 'Payment Forms', 'invoicing' ), |
|
97 | - 'search_items' => __( 'Search Payment Forms', 'invoicing' ), |
|
98 | - 'parent_item_colon' => __( 'Parent Payment Forms:', 'invoicing' ), |
|
99 | - 'not_found' => __( 'No payment forms found.', 'invoicing' ), |
|
100 | - 'not_found_in_trash' => __( 'No payment forms found in trash.', 'invoicing' ) |
|
87 | + 'name' => _x('Payment Forms', 'post type general name', 'invoicing'), |
|
88 | + 'singular_name' => _x('Payment Form', 'post type singular name', 'invoicing'), |
|
89 | + 'menu_name' => _x('Payment Forms', 'admin menu', 'invoicing'), |
|
90 | + 'name_admin_bar' => _x('Payment Form', 'add new on admin bar', 'invoicing'), |
|
91 | + 'add_new' => _x('Add New', 'Payment Form', 'invoicing'), |
|
92 | + 'add_new_item' => __('Add New Payment Form', 'invoicing'), |
|
93 | + 'new_item' => __('New Payment Form', 'invoicing'), |
|
94 | + 'edit_item' => __('Edit Payment Form', 'invoicing'), |
|
95 | + 'view_item' => __('View Payment Form', 'invoicing'), |
|
96 | + 'all_items' => __('Payment Forms', 'invoicing'), |
|
97 | + 'search_items' => __('Search Payment Forms', 'invoicing'), |
|
98 | + 'parent_item_colon' => __('Parent Payment Forms:', 'invoicing'), |
|
99 | + 'not_found' => __('No payment forms found.', 'invoicing'), |
|
100 | + 'not_found_in_trash' => __('No payment forms found in trash.', 'invoicing') |
|
101 | 101 | ), |
102 | - 'description' => __( 'Add new payment forms.', 'invoicing' ), |
|
102 | + 'description' => __('Add new payment forms.', 'invoicing'), |
|
103 | 103 | 'public' => false, |
104 | 104 | 'show_ui' => true, |
105 | 105 | 'show_in_menu' => $capabilities ? 'wpinv' : true, |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | 'has_archive' => false, |
111 | 111 | 'hierarchical' => false, |
112 | 112 | 'menu_position' => null, |
113 | - 'supports' => array( 'title' ), |
|
113 | + 'supports' => array('title'), |
|
114 | 114 | 'menu_icon' => 'dashicons-media-form', |
115 | 115 | 'capabilities' => array( |
116 | 116 | 'edit_post' => $capabilities, |
@@ -133,32 +133,32 @@ discard block |
||
133 | 133 | 'wpinv_register_post_type_invoice', |
134 | 134 | array( |
135 | 135 | 'labels' => array( |
136 | - 'name' => __( 'Invoices', 'invoicing' ), |
|
137 | - 'singular_name' => __( 'Invoice', 'invoicing' ), |
|
138 | - 'all_items' => __( 'Invoices', 'invoicing' ), |
|
139 | - 'menu_name' => _x( 'Invoices', 'Admin menu name', 'invoicing' ), |
|
140 | - 'add_new' => __( 'Add New', 'invoicing' ), |
|
141 | - 'add_new_item' => __( 'Add new invoice', 'invoicing' ), |
|
142 | - 'edit' => __( 'Edit', 'invoicing' ), |
|
143 | - 'edit_item' => __( 'Edit invoice', 'invoicing' ), |
|
144 | - 'new_item' => __( 'New invoice', 'invoicing' ), |
|
145 | - 'view_item' => __( 'View invoice', 'invoicing' ), |
|
146 | - 'view_items' => __( 'View Invoices', 'invoicing' ), |
|
147 | - 'search_items' => __( 'Search invoices', 'invoicing' ), |
|
148 | - 'not_found' => __( 'No invoices found', 'invoicing' ), |
|
149 | - 'not_found_in_trash' => __( 'No invoices found in trash', 'invoicing' ), |
|
150 | - 'parent' => __( 'Parent invoice', 'invoicing' ), |
|
151 | - 'featured_image' => __( 'Invoice image', 'invoicing' ), |
|
152 | - 'set_featured_image' => __( 'Set invoice image', 'invoicing' ), |
|
153 | - 'remove_featured_image' => __( 'Remove invoice image', 'invoicing' ), |
|
154 | - 'use_featured_image' => __( 'Use as invoice image', 'invoicing' ), |
|
155 | - 'insert_into_item' => __( 'Insert into invoice', 'invoicing' ), |
|
156 | - 'uploaded_to_this_item' => __( 'Uploaded to this invoice', 'invoicing' ), |
|
157 | - 'filter_items_list' => __( 'Filter invoices', 'invoicing' ), |
|
158 | - 'items_list_navigation' => __( 'Invoices navigation', 'invoicing' ), |
|
159 | - 'items_list' => __( 'Invoices list', 'invoicing' ), |
|
136 | + 'name' => __('Invoices', 'invoicing'), |
|
137 | + 'singular_name' => __('Invoice', 'invoicing'), |
|
138 | + 'all_items' => __('Invoices', 'invoicing'), |
|
139 | + 'menu_name' => _x('Invoices', 'Admin menu name', 'invoicing'), |
|
140 | + 'add_new' => __('Add New', 'invoicing'), |
|
141 | + 'add_new_item' => __('Add new invoice', 'invoicing'), |
|
142 | + 'edit' => __('Edit', 'invoicing'), |
|
143 | + 'edit_item' => __('Edit invoice', 'invoicing'), |
|
144 | + 'new_item' => __('New invoice', 'invoicing'), |
|
145 | + 'view_item' => __('View invoice', 'invoicing'), |
|
146 | + 'view_items' => __('View Invoices', 'invoicing'), |
|
147 | + 'search_items' => __('Search invoices', 'invoicing'), |
|
148 | + 'not_found' => __('No invoices found', 'invoicing'), |
|
149 | + 'not_found_in_trash' => __('No invoices found in trash', 'invoicing'), |
|
150 | + 'parent' => __('Parent invoice', 'invoicing'), |
|
151 | + 'featured_image' => __('Invoice image', 'invoicing'), |
|
152 | + 'set_featured_image' => __('Set invoice image', 'invoicing'), |
|
153 | + 'remove_featured_image' => __('Remove invoice image', 'invoicing'), |
|
154 | + 'use_featured_image' => __('Use as invoice image', 'invoicing'), |
|
155 | + 'insert_into_item' => __('Insert into invoice', 'invoicing'), |
|
156 | + 'uploaded_to_this_item' => __('Uploaded to this invoice', 'invoicing'), |
|
157 | + 'filter_items_list' => __('Filter invoices', 'invoicing'), |
|
158 | + 'items_list_navigation' => __('Invoices navigation', 'invoicing'), |
|
159 | + 'items_list' => __('Invoices list', 'invoicing'), |
|
160 | 160 | ), |
161 | - 'description' => __( 'This is where invoices are stored.', 'invoicing' ), |
|
161 | + 'description' => __('This is where invoices are stored.', 'invoicing'), |
|
162 | 162 | 'public' => true, |
163 | 163 | 'has_archive' => false, |
164 | 164 | 'publicly_queryable' => true, |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | 'show_ui' => true, |
167 | 167 | 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
168 | 168 | 'show_in_nav_menus' => false, |
169 | - 'supports' => array( 'title', 'author', 'excerpt' ), |
|
169 | + 'supports' => array('title', 'author', 'excerpt'), |
|
170 | 170 | 'rewrite' => array( |
171 | 171 | 'slug' => 'invoice', |
172 | 172 | 'with_front' => false, |
@@ -189,32 +189,32 @@ discard block |
||
189 | 189 | 'wpinv_register_post_type_discount', |
190 | 190 | array( |
191 | 191 | 'labels' => array( |
192 | - 'name' => __( 'Discounts', 'invoicing' ), |
|
193 | - 'singular_name' => __( 'Discount', 'invoicing' ), |
|
194 | - 'all_items' => __( 'Discounts', 'invoicing' ), |
|
195 | - 'menu_name' => _x( 'Discounts', 'Admin menu name', 'invoicing' ), |
|
196 | - 'add_new' => __( 'Add New', 'invoicing' ), |
|
197 | - 'add_new_item' => __( 'Add new discount', 'invoicing' ), |
|
198 | - 'edit' => __( 'Edit', 'invoicing' ), |
|
199 | - 'edit_item' => __( 'Edit discount', 'invoicing' ), |
|
200 | - 'new_item' => __( 'New discount', 'invoicing' ), |
|
201 | - 'view_item' => __( 'View discount', 'invoicing' ), |
|
202 | - 'view_items' => __( 'View Discounts', 'invoicing' ), |
|
203 | - 'search_items' => __( 'Search discounts', 'invoicing' ), |
|
204 | - 'not_found' => __( 'No discounts found', 'invoicing' ), |
|
205 | - 'not_found_in_trash' => __( 'No discounts found in trash', 'invoicing' ), |
|
206 | - 'parent' => __( 'Parent discount', 'invoicing' ), |
|
207 | - 'featured_image' => __( 'Discount image', 'invoicing' ), |
|
208 | - 'set_featured_image' => __( 'Set discount image', 'invoicing' ), |
|
209 | - 'remove_featured_image' => __( 'Remove discount image', 'invoicing' ), |
|
210 | - 'use_featured_image' => __( 'Use as discount image', 'invoicing' ), |
|
211 | - 'insert_into_item' => __( 'Insert into discount', 'invoicing' ), |
|
212 | - 'uploaded_to_this_item' => __( 'Uploaded to this discount', 'invoicing' ), |
|
213 | - 'filter_items_list' => __( 'Filter discounts', 'invoicing' ), |
|
214 | - 'items_list_navigation' => __( 'Discount navigation', 'invoicing' ), |
|
215 | - 'items_list' => __( 'Discounts list', 'invoicing' ), |
|
192 | + 'name' => __('Discounts', 'invoicing'), |
|
193 | + 'singular_name' => __('Discount', 'invoicing'), |
|
194 | + 'all_items' => __('Discounts', 'invoicing'), |
|
195 | + 'menu_name' => _x('Discounts', 'Admin menu name', 'invoicing'), |
|
196 | + 'add_new' => __('Add New', 'invoicing'), |
|
197 | + 'add_new_item' => __('Add new discount', 'invoicing'), |
|
198 | + 'edit' => __('Edit', 'invoicing'), |
|
199 | + 'edit_item' => __('Edit discount', 'invoicing'), |
|
200 | + 'new_item' => __('New discount', 'invoicing'), |
|
201 | + 'view_item' => __('View discount', 'invoicing'), |
|
202 | + 'view_items' => __('View Discounts', 'invoicing'), |
|
203 | + 'search_items' => __('Search discounts', 'invoicing'), |
|
204 | + 'not_found' => __('No discounts found', 'invoicing'), |
|
205 | + 'not_found_in_trash' => __('No discounts found in trash', 'invoicing'), |
|
206 | + 'parent' => __('Parent discount', 'invoicing'), |
|
207 | + 'featured_image' => __('Discount image', 'invoicing'), |
|
208 | + 'set_featured_image' => __('Set discount image', 'invoicing'), |
|
209 | + 'remove_featured_image' => __('Remove discount image', 'invoicing'), |
|
210 | + 'use_featured_image' => __('Use as discount image', 'invoicing'), |
|
211 | + 'insert_into_item' => __('Insert into discount', 'invoicing'), |
|
212 | + 'uploaded_to_this_item' => __('Uploaded to this discount', 'invoicing'), |
|
213 | + 'filter_items_list' => __('Filter discounts', 'invoicing'), |
|
214 | + 'items_list_navigation' => __('Discount navigation', 'invoicing'), |
|
215 | + 'items_list' => __('Discounts list', 'invoicing'), |
|
216 | 216 | ), |
217 | - 'description' => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ), |
|
217 | + 'description' => __('This is where you can add new discounts that users can use in invoices.', 'invoicing'), |
|
218 | 218 | 'public' => false, |
219 | 219 | 'can_export' => true, |
220 | 220 | '_builtin' => false, |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | 'map_meta_cap' => true, |
228 | 228 | 'has_archive' => false, |
229 | 229 | 'hierarchical' => false, |
230 | - 'supports' => array( 'title', 'excerpt' ), |
|
230 | + 'supports' => array('title', 'excerpt'), |
|
231 | 231 | 'show_in_nav_menus' => false, |
232 | 232 | 'show_in_admin_bar' => true, |
233 | 233 | 'menu_position' => null, |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | ) |
236 | 236 | ); |
237 | 237 | |
238 | - do_action( 'getpaid_after_register_post_types' ); |
|
238 | + do_action('getpaid_after_register_post_types'); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | /** |
@@ -248,79 +248,79 @@ discard block |
||
248 | 248 | array( |
249 | 249 | |
250 | 250 | 'wpi-pending' => array( |
251 | - 'label' => _x( 'Pending Payment', 'Invoice status', 'invoicing' ), |
|
251 | + 'label' => _x('Pending Payment', 'Invoice status', 'invoicing'), |
|
252 | 252 | 'public' => true, |
253 | 253 | 'exclude_from_search' => true, |
254 | 254 | 'show_in_admin_all_list' => true, |
255 | 255 | 'show_in_admin_status_list' => true, |
256 | 256 | /* translators: %s: number of invoices */ |
257 | - 'label_count' => _n_noop( 'Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'invoicing' ) |
|
257 | + 'label_count' => _n_noop('Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'invoicing') |
|
258 | 258 | ), |
259 | 259 | |
260 | 260 | 'wpi-processing' => array( |
261 | - 'label' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
|
261 | + 'label' => _x('Processing', 'Invoice status', 'invoicing'), |
|
262 | 262 | 'public' => true, |
263 | 263 | 'exclude_from_search' => true, |
264 | 264 | 'show_in_admin_all_list' => true, |
265 | 265 | 'show_in_admin_status_list' => true, |
266 | 266 | /* translators: %s: number of invoices */ |
267 | - 'label_count' => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' ) |
|
267 | + 'label_count' => _n_noop('Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing') |
|
268 | 268 | ), |
269 | 269 | |
270 | 270 | 'wpi-onhold' => array( |
271 | - 'label' => _x( 'On Hold', 'Invoice status', 'invoicing' ), |
|
271 | + 'label' => _x('On Hold', 'Invoice status', 'invoicing'), |
|
272 | 272 | 'public' => true, |
273 | 273 | 'exclude_from_search' => true, |
274 | 274 | 'show_in_admin_all_list' => true, |
275 | 275 | 'show_in_admin_status_list' => true, |
276 | 276 | /* translators: %s: number of invoices */ |
277 | - 'label_count' => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' ) |
|
277 | + 'label_count' => _n_noop('On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing') |
|
278 | 278 | ), |
279 | 279 | |
280 | 280 | 'wpi-cancelled' => array( |
281 | - 'label' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
281 | + 'label' => _x('Cancelled', 'Invoice status', 'invoicing'), |
|
282 | 282 | 'public' => true, |
283 | 283 | 'exclude_from_search' => true, |
284 | 284 | 'show_in_admin_all_list' => true, |
285 | 285 | 'show_in_admin_status_list' => true, |
286 | 286 | /* translators: %s: number of invoices */ |
287 | - 'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' ) |
|
287 | + 'label_count' => _n_noop('Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing') |
|
288 | 288 | ), |
289 | 289 | |
290 | 290 | 'wpi-refunded' => array( |
291 | - 'label' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
291 | + 'label' => _x('Refunded', 'Invoice status', 'invoicing'), |
|
292 | 292 | 'public' => true, |
293 | 293 | 'exclude_from_search' => true, |
294 | 294 | 'show_in_admin_all_list' => true, |
295 | 295 | 'show_in_admin_status_list' => true, |
296 | 296 | /* translators: %s: number of invoices */ |
297 | - 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' ) |
|
297 | + 'label_count' => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing') |
|
298 | 298 | ), |
299 | 299 | |
300 | 300 | 'wpi-failed' => array( |
301 | - 'label' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
|
301 | + 'label' => _x('Failed', 'Invoice status', 'invoicing'), |
|
302 | 302 | 'public' => true, |
303 | 303 | 'exclude_from_search' => true, |
304 | 304 | 'show_in_admin_all_list' => true, |
305 | 305 | 'show_in_admin_status_list' => true, |
306 | 306 | /* translators: %s: number of invoices */ |
307 | - 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' ) |
|
307 | + 'label_count' => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing') |
|
308 | 308 | ), |
309 | 309 | |
310 | 310 | 'wpi-renewal' => array( |
311 | - 'label' => _x( 'Renewal', 'Invoice status', 'invoicing' ), |
|
311 | + 'label' => _x('Renewal', 'Invoice status', 'invoicing'), |
|
312 | 312 | 'public' => true, |
313 | 313 | 'exclude_from_search' => true, |
314 | 314 | 'show_in_admin_all_list' => true, |
315 | 315 | 'show_in_admin_status_list' => true, |
316 | 316 | /* translators: %s: number of invoices */ |
317 | - 'label_count' => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' ) |
|
317 | + 'label_count' => _n_noop('Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing') |
|
318 | 318 | ) |
319 | 319 | ) |
320 | 320 | ); |
321 | 321 | |
322 | - foreach ( $invoice_statuses as $invoice_statuse => $args ) { |
|
323 | - register_post_status( $invoice_statuse, $args ); |
|
322 | + foreach ($invoice_statuses as $invoice_statuse => $args) { |
|
323 | + register_post_status($invoice_statuse, $args); |
|
324 | 324 | } |
325 | 325 | } |
326 | 326 | |
@@ -336,8 +336,8 @@ discard block |
||
336 | 336 | * |
337 | 337 | */ |
338 | 338 | public static function maybe_flush_rewrite_rules() { |
339 | - if ( ! get_option( 'getpaid_flushed_rewrite_rules' ) ) { |
|
340 | - update_option( 'getpaid_flushed_rewrite_rules', '1' ); |
|
339 | + if (!get_option('getpaid_flushed_rewrite_rules')) { |
|
340 | + update_option('getpaid_flushed_rewrite_rules', '1'); |
|
341 | 341 | self::flush_rewrite_rules(); |
342 | 342 | } |
343 | 343 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! defined( 'ABSPATH' ) ) { |
3 | - exit; |
|
3 | + exit; |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -10,55 +10,55 @@ discard block |
||
10 | 10 | class GetPaid_Payment_Form extends GetPaid_Data { |
11 | 11 | |
12 | 12 | /** |
13 | - * Which data store to load. |
|
14 | - * |
|
15 | - * @var string |
|
16 | - */ |
|
13 | + * Which data store to load. |
|
14 | + * |
|
15 | + * @var string |
|
16 | + */ |
|
17 | 17 | protected $data_store_name = 'payment_form'; |
18 | 18 | |
19 | 19 | /** |
20 | - * This is the name of this object type. |
|
21 | - * |
|
22 | - * @var string |
|
23 | - */ |
|
24 | - protected $object_type = 'payment_form'; |
|
20 | + * This is the name of this object type. |
|
21 | + * |
|
22 | + * @var string |
|
23 | + */ |
|
24 | + protected $object_type = 'payment_form'; |
|
25 | 25 | |
26 | 26 | /** |
27 | - * Form Data array. This is the core form data exposed in APIs. |
|
28 | - * |
|
29 | - * @since 1.0.19 |
|
30 | - * @var array |
|
31 | - */ |
|
32 | - protected $data = array( |
|
33 | - 'status' => 'draft', |
|
34 | - 'version' => '', |
|
35 | - 'date_created' => null, |
|
27 | + * Form Data array. This is the core form data exposed in APIs. |
|
28 | + * |
|
29 | + * @since 1.0.19 |
|
30 | + * @var array |
|
31 | + */ |
|
32 | + protected $data = array( |
|
33 | + 'status' => 'draft', |
|
34 | + 'version' => '', |
|
35 | + 'date_created' => null, |
|
36 | 36 | 'date_modified' => null, |
37 | 37 | 'name' => '', |
38 | 38 | 'author' => 1, |
39 | 39 | 'elements' => null, |
40 | - 'items' => null, |
|
41 | - 'earned' => 0, |
|
42 | - 'refunded' => 0, |
|
43 | - 'cancelled' => 0, |
|
44 | - 'failed' => 0, |
|
45 | - ); |
|
46 | - |
|
47 | - /** |
|
48 | - * Stores meta in cache for future reads. |
|
49 | - * |
|
50 | - * A group must be set to to enable caching. |
|
51 | - * |
|
52 | - * @var string |
|
53 | - */ |
|
54 | - protected $cache_group = 'getpaid_forms'; |
|
55 | - |
|
56 | - /** |
|
57 | - * Stores a reference to the invoice if the form is for an invoice.. |
|
58 | - * |
|
59 | - * @var WPInv_Invoice |
|
60 | - */ |
|
61 | - public $invoice = 0; |
|
40 | + 'items' => null, |
|
41 | + 'earned' => 0, |
|
42 | + 'refunded' => 0, |
|
43 | + 'cancelled' => 0, |
|
44 | + 'failed' => 0, |
|
45 | + ); |
|
46 | + |
|
47 | + /** |
|
48 | + * Stores meta in cache for future reads. |
|
49 | + * |
|
50 | + * A group must be set to to enable caching. |
|
51 | + * |
|
52 | + * @var string |
|
53 | + */ |
|
54 | + protected $cache_group = 'getpaid_forms'; |
|
55 | + |
|
56 | + /** |
|
57 | + * Stores a reference to the invoice if the form is for an invoice.. |
|
58 | + * |
|
59 | + * @var WPInv_Invoice |
|
60 | + */ |
|
61 | + public $invoice = 0; |
|
62 | 62 | |
63 | 63 | /** |
64 | 64 | * Stores a reference to the original WP_Post object |
@@ -68,35 +68,35 @@ discard block |
||
68 | 68 | protected $post = null; |
69 | 69 | |
70 | 70 | /** |
71 | - * Get the form if ID is passed, otherwise the form is new and empty. |
|
72 | - * |
|
73 | - * @param int|object|GetPaid_Payment_Form|WP_Post $form Form to read. |
|
74 | - */ |
|
75 | - public function __construct( $form = 0 ) { |
|
76 | - parent::__construct( $form ); |
|
71 | + * Get the form if ID is passed, otherwise the form is new and empty. |
|
72 | + * |
|
73 | + * @param int|object|GetPaid_Payment_Form|WP_Post $form Form to read. |
|
74 | + */ |
|
75 | + public function __construct( $form = 0 ) { |
|
76 | + parent::__construct( $form ); |
|
77 | 77 | |
78 | - if ( is_numeric( $form ) && $form > 0 ) { |
|
79 | - $this->set_id( $form ); |
|
80 | - } elseif ( $form instanceof self ) { |
|
78 | + if ( is_numeric( $form ) && $form > 0 ) { |
|
79 | + $this->set_id( $form ); |
|
80 | + } elseif ( $form instanceof self ) { |
|
81 | 81 | |
82 | - $this->set_id( $form->get_id() ); |
|
83 | - $this->invoice = $form->invoice; |
|
82 | + $this->set_id( $form->get_id() ); |
|
83 | + $this->invoice = $form->invoice; |
|
84 | 84 | |
85 | - } elseif ( ! empty( $form->ID ) ) { |
|
86 | - $this->set_id( $form->ID ); |
|
87 | - } else { |
|
88 | - $this->set_object_read( true ); |
|
89 | - } |
|
85 | + } elseif ( ! empty( $form->ID ) ) { |
|
86 | + $this->set_id( $form->ID ); |
|
87 | + } else { |
|
88 | + $this->set_object_read( true ); |
|
89 | + } |
|
90 | 90 | |
91 | 91 | // Load the datastore. |
92 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
92 | + $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
93 | 93 | |
94 | - if ( $this->get_id() > 0 ) { |
|
94 | + if ( $this->get_id() > 0 ) { |
|
95 | 95 | $this->post = get_post( $this->get_id() ); |
96 | - $this->data_store->read( $this ); |
|
96 | + $this->data_store->read( $this ); |
|
97 | 97 | } |
98 | 98 | |
99 | - } |
|
99 | + } |
|
100 | 100 | |
101 | 101 | /* |
102 | 102 | |-------------------------------------------------------------------------- |
@@ -114,358 +114,358 @@ discard block |
||
114 | 114 | */ |
115 | 115 | |
116 | 116 | /** |
117 | - * Get plugin version when the form was created. |
|
118 | - * |
|
119 | - * @since 1.0.19 |
|
120 | - * @param string $context View or edit context. |
|
121 | - * @return string |
|
122 | - */ |
|
123 | - public function get_version( $context = 'view' ) { |
|
124 | - return $this->get_prop( 'version', $context ); |
|
117 | + * Get plugin version when the form was created. |
|
118 | + * |
|
119 | + * @since 1.0.19 |
|
120 | + * @param string $context View or edit context. |
|
121 | + * @return string |
|
122 | + */ |
|
123 | + public function get_version( $context = 'view' ) { |
|
124 | + return $this->get_prop( 'version', $context ); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
128 | - * Get date when the form was created. |
|
129 | - * |
|
130 | - * @since 1.0.19 |
|
131 | - * @param string $context View or edit context. |
|
132 | - * @return string |
|
133 | - */ |
|
134 | - public function get_date_created( $context = 'view' ) { |
|
135 | - return $this->get_prop( 'date_created', $context ); |
|
128 | + * Get date when the form was created. |
|
129 | + * |
|
130 | + * @since 1.0.19 |
|
131 | + * @param string $context View or edit context. |
|
132 | + * @return string |
|
133 | + */ |
|
134 | + public function get_date_created( $context = 'view' ) { |
|
135 | + return $this->get_prop( 'date_created', $context ); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
139 | - * Get GMT date when the form was created. |
|
140 | - * |
|
141 | - * @since 1.0.19 |
|
142 | - * @param string $context View or edit context. |
|
143 | - * @return string |
|
144 | - */ |
|
145 | - public function get_date_created_gmt( $context = 'view' ) { |
|
139 | + * Get GMT date when the form was created. |
|
140 | + * |
|
141 | + * @since 1.0.19 |
|
142 | + * @param string $context View or edit context. |
|
143 | + * @return string |
|
144 | + */ |
|
145 | + public function get_date_created_gmt( $context = 'view' ) { |
|
146 | 146 | $date = $this->get_date_created( $context ); |
147 | 147 | |
148 | 148 | if ( $date ) { |
149 | 149 | $date = get_gmt_from_date( $date ); |
150 | 150 | } |
151 | - return $date; |
|
151 | + return $date; |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
155 | - * Get date when the form was last modified. |
|
156 | - * |
|
157 | - * @since 1.0.19 |
|
158 | - * @param string $context View or edit context. |
|
159 | - * @return string |
|
160 | - */ |
|
161 | - public function get_date_modified( $context = 'view' ) { |
|
162 | - return $this->get_prop( 'date_modified', $context ); |
|
155 | + * Get date when the form was last modified. |
|
156 | + * |
|
157 | + * @since 1.0.19 |
|
158 | + * @param string $context View or edit context. |
|
159 | + * @return string |
|
160 | + */ |
|
161 | + public function get_date_modified( $context = 'view' ) { |
|
162 | + return $this->get_prop( 'date_modified', $context ); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
166 | - * Get GMT date when the form was last modified. |
|
167 | - * |
|
168 | - * @since 1.0.19 |
|
169 | - * @param string $context View or edit context. |
|
170 | - * @return string |
|
171 | - */ |
|
172 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
166 | + * Get GMT date when the form was last modified. |
|
167 | + * |
|
168 | + * @since 1.0.19 |
|
169 | + * @param string $context View or edit context. |
|
170 | + * @return string |
|
171 | + */ |
|
172 | + public function get_date_modified_gmt( $context = 'view' ) { |
|
173 | 173 | $date = $this->get_date_modified( $context ); |
174 | 174 | |
175 | 175 | if ( $date ) { |
176 | 176 | $date = get_gmt_from_date( $date ); |
177 | 177 | } |
178 | - return $date; |
|
178 | + return $date; |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
182 | - * Get the form name. |
|
183 | - * |
|
184 | - * @since 1.0.19 |
|
185 | - * @param string $context View or edit context. |
|
186 | - * @return string |
|
187 | - */ |
|
188 | - public function get_name( $context = 'view' ) { |
|
189 | - return $this->get_prop( 'name', $context ); |
|
182 | + * Get the form name. |
|
183 | + * |
|
184 | + * @since 1.0.19 |
|
185 | + * @param string $context View or edit context. |
|
186 | + * @return string |
|
187 | + */ |
|
188 | + public function get_name( $context = 'view' ) { |
|
189 | + return $this->get_prop( 'name', $context ); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
193 | - * Alias of self::get_name(). |
|
194 | - * |
|
195 | - * @since 1.0.19 |
|
196 | - * @param string $context View or edit context. |
|
197 | - * @return string |
|
198 | - */ |
|
199 | - public function get_title( $context = 'view' ) { |
|
200 | - return $this->get_name( $context ); |
|
201 | - } |
|
193 | + * Alias of self::get_name(). |
|
194 | + * |
|
195 | + * @since 1.0.19 |
|
196 | + * @param string $context View or edit context. |
|
197 | + * @return string |
|
198 | + */ |
|
199 | + public function get_title( $context = 'view' ) { |
|
200 | + return $this->get_name( $context ); |
|
201 | + } |
|
202 | 202 | |
203 | 203 | /** |
204 | - * Get the owner of the form. |
|
205 | - * |
|
206 | - * @since 1.0.19 |
|
207 | - * @param string $context View or edit context. |
|
208 | - * @return int |
|
209 | - */ |
|
210 | - public function get_author( $context = 'view' ) { |
|
211 | - return (int) $this->get_prop( 'author', $context ); |
|
204 | + * Get the owner of the form. |
|
205 | + * |
|
206 | + * @since 1.0.19 |
|
207 | + * @param string $context View or edit context. |
|
208 | + * @return int |
|
209 | + */ |
|
210 | + public function get_author( $context = 'view' ) { |
|
211 | + return (int) $this->get_prop( 'author', $context ); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | /** |
215 | - * Get the elements that make up the form. |
|
216 | - * |
|
217 | - * @since 1.0.19 |
|
218 | - * @param string $context View or edit context. |
|
219 | - * @return array |
|
220 | - */ |
|
221 | - public function get_elements( $context = 'view' ) { |
|
222 | - $elements = $this->get_prop( 'elements', $context ); |
|
215 | + * Get the elements that make up the form. |
|
216 | + * |
|
217 | + * @since 1.0.19 |
|
218 | + * @param string $context View or edit context. |
|
219 | + * @return array |
|
220 | + */ |
|
221 | + public function get_elements( $context = 'view' ) { |
|
222 | + $elements = $this->get_prop( 'elements', $context ); |
|
223 | 223 | |
224 | - if ( empty( $elements ) || ! is_array( $elements ) ) { |
|
224 | + if ( empty( $elements ) || ! is_array( $elements ) ) { |
|
225 | 225 | return wpinv_get_data( 'sample-payment-form' ); |
226 | - } |
|
226 | + } |
|
227 | 227 | |
228 | - // Ensure that all required elements exist. |
|
229 | - $_elements = array(); |
|
230 | - foreach ( $elements as $element ) { |
|
228 | + // Ensure that all required elements exist. |
|
229 | + $_elements = array(); |
|
230 | + foreach ( $elements as $element ) { |
|
231 | 231 | |
232 | - if ( $element['type'] == 'pay_button' && ! $this->has_element_type( 'gateway_select' ) ) { |
|
232 | + if ( $element['type'] == 'pay_button' && ! $this->has_element_type( 'gateway_select' ) ) { |
|
233 | 233 | |
234 | - $_elements[] = array( |
|
235 | - 'text' => __( 'Select Payment Method', 'invoicing' ), |
|
236 | - 'id' => 'gtscicd', |
|
237 | - 'name' => 'gtscicd', |
|
238 | - 'type' => 'gateway_select', |
|
239 | - 'premade' => true |
|
234 | + $_elements[] = array( |
|
235 | + 'text' => __( 'Select Payment Method', 'invoicing' ), |
|
236 | + 'id' => 'gtscicd', |
|
237 | + 'name' => 'gtscicd', |
|
238 | + 'type' => 'gateway_select', |
|
239 | + 'premade' => true |
|
240 | 240 | |
241 | - ); |
|
241 | + ); |
|
242 | 242 | |
243 | - } |
|
243 | + } |
|
244 | 244 | |
245 | - $_elements[] = $element; |
|
245 | + $_elements[] = $element; |
|
246 | 246 | |
247 | - } |
|
247 | + } |
|
248 | 248 | |
249 | 249 | return $_elements; |
250 | - } |
|
251 | - |
|
252 | - /** |
|
253 | - * Get the items sold via the form. |
|
254 | - * |
|
255 | - * @since 1.0.19 |
|
256 | - * @param string $context View or edit context. |
|
257 | - * @param string $return objects or arrays. |
|
258 | - * @return GetPaid_Form_Item[] |
|
259 | - */ |
|
260 | - public function get_items( $context = 'view', $return = 'objects' ) { |
|
261 | - $items = $this->get_prop( 'items', $context ); |
|
262 | - |
|
263 | - if ( empty( $items ) || ! is_array( $items ) ) { |
|
250 | + } |
|
251 | + |
|
252 | + /** |
|
253 | + * Get the items sold via the form. |
|
254 | + * |
|
255 | + * @since 1.0.19 |
|
256 | + * @param string $context View or edit context. |
|
257 | + * @param string $return objects or arrays. |
|
258 | + * @return GetPaid_Form_Item[] |
|
259 | + */ |
|
260 | + public function get_items( $context = 'view', $return = 'objects' ) { |
|
261 | + $items = $this->get_prop( 'items', $context ); |
|
262 | + |
|
263 | + if ( empty( $items ) || ! is_array( $items ) ) { |
|
264 | 264 | $items = wpinv_get_data( 'sample-payment-form-items' ); |
265 | - } |
|
265 | + } |
|
266 | + |
|
267 | + // Convert the items. |
|
268 | + $prepared = array(); |
|
269 | + |
|
270 | + foreach ( $items as $key => $value ) { |
|
271 | + |
|
272 | + // Form items. |
|
273 | + if ( $value instanceof GetPaid_Form_Item ) { |
|
274 | + |
|
275 | + if ( $value->can_purchase() ) { |
|
276 | + $prepared[] = $value; |
|
277 | + } |
|
278 | + |
|
279 | + continue; |
|
280 | + |
|
281 | + } |
|
266 | 282 | |
267 | - // Convert the items. |
|
268 | - $prepared = array(); |
|
283 | + // $item_id => $quantity (buy buttons) |
|
284 | + if ( is_numeric( $key ) && is_numeric( $value ) ) { |
|
285 | + $item = new GetPaid_Form_Item( $key ); |
|
269 | 286 | |
270 | - foreach ( $items as $key => $value ) { |
|
287 | + if ( $item->can_purchase() ) { |
|
271 | 288 | |
272 | - // Form items. |
|
273 | - if ( $value instanceof GetPaid_Form_Item ) { |
|
289 | + $value = (float) $value; |
|
290 | + $item->set_quantity( $value ); |
|
291 | + if ( 0 == $value ) { |
|
292 | + $item->set_quantity( 1 ); |
|
293 | + $item->set_allow_quantities( true ); |
|
294 | + } |
|
274 | 295 | |
275 | - if ( $value->can_purchase() ) { |
|
276 | - $prepared[] = $value; |
|
277 | - } |
|
296 | + $prepared[] = $item; |
|
297 | + } |
|
278 | 298 | |
279 | - continue; |
|
299 | + continue; |
|
300 | + } |
|
280 | 301 | |
281 | - } |
|
302 | + // Items saved via payment forms editor. |
|
303 | + if ( is_array( $value ) && isset( $value['id'] ) ) { |
|
282 | 304 | |
283 | - // $item_id => $quantity (buy buttons) |
|
284 | - if ( is_numeric( $key ) && is_numeric( $value ) ) { |
|
285 | - $item = new GetPaid_Form_Item( $key ); |
|
305 | + $item = new GetPaid_Form_Item( $value['id'] ); |
|
286 | 306 | |
287 | - if ( $item->can_purchase() ) { |
|
307 | + if ( ! $item->can_purchase() ) { |
|
308 | + continue; |
|
309 | + } |
|
288 | 310 | |
289 | - $value = (float) $value; |
|
290 | - $item->set_quantity( $value ); |
|
291 | - if ( 0 == $value ) { |
|
292 | - $item->set_quantity( 1 ); |
|
293 | - $item->set_allow_quantities( true ); |
|
294 | - } |
|
311 | + // Sub-total (Cart items). |
|
312 | + if ( isset( $value['subtotal'] ) ) { |
|
313 | + $item->set_price( $value['subtotal'] ); |
|
314 | + } |
|
295 | 315 | |
296 | - $prepared[] = $item; |
|
297 | - } |
|
316 | + if ( isset( $value['quantity'] ) ) { |
|
317 | + $item->set_quantity( $value['quantity'] ); |
|
318 | + } |
|
298 | 319 | |
299 | - continue; |
|
300 | - } |
|
320 | + if ( isset( $value['allow_quantities'] ) ) { |
|
321 | + $item->set_allow_quantities( $value['allow_quantities'] ); |
|
322 | + } |
|
301 | 323 | |
302 | - // Items saved via payment forms editor. |
|
303 | - if ( is_array( $value ) && isset( $value['id'] ) ) { |
|
324 | + if ( isset( $value['required'] ) ) { |
|
325 | + $item->set_is_required( $value['required'] ); |
|
326 | + } |
|
304 | 327 | |
305 | - $item = new GetPaid_Form_Item( $value['id'] ); |
|
328 | + if ( isset( $value['description'] ) ) { |
|
329 | + $item->set_custom_description( $value['description'] ); |
|
330 | + } |
|
306 | 331 | |
307 | - if ( ! $item->can_purchase() ) { |
|
308 | - continue; |
|
309 | - } |
|
332 | + $prepared[] = $item; |
|
333 | + continue; |
|
310 | 334 | |
311 | - // Sub-total (Cart items). |
|
312 | - if ( isset( $value['subtotal'] ) ) { |
|
313 | - $item->set_price( $value['subtotal'] ); |
|
314 | - } |
|
335 | + } |
|
315 | 336 | |
316 | - if ( isset( $value['quantity'] ) ) { |
|
317 | - $item->set_quantity( $value['quantity'] ); |
|
318 | - } |
|
337 | + // $item_id => array( 'price' => 10 ) (item variations) |
|
338 | + if ( is_numeric( $key ) && is_array( $value ) ) { |
|
339 | + $item = new GetPaid_Form_Item( $key ); |
|
319 | 340 | |
320 | - if ( isset( $value['allow_quantities'] ) ) { |
|
321 | - $item->set_allow_quantities( $value['allow_quantities'] ); |
|
322 | - } |
|
341 | + if ( isset( $value['price'] ) && $item->user_can_set_their_price() ) { |
|
342 | + $item->set_price( $value['price'] ); |
|
343 | + } |
|
323 | 344 | |
324 | - if ( isset( $value['required'] ) ) { |
|
325 | - $item->set_is_required( $value['required'] ); |
|
326 | - } |
|
345 | + if ( $item->can_purchase() ) { |
|
346 | + $prepared[] = $item; |
|
347 | + } |
|
327 | 348 | |
328 | - if ( isset( $value['description'] ) ) { |
|
329 | - $item->set_custom_description( $value['description'] ); |
|
330 | - } |
|
349 | + continue; |
|
350 | + } |
|
331 | 351 | |
332 | - $prepared[] = $item; |
|
333 | - continue; |
|
352 | + } |
|
353 | + |
|
354 | + if ( 'objects' == $return && 'view' == $context ) { |
|
355 | + return $prepared; |
|
356 | + } |
|
357 | + |
|
358 | + $items = array(); |
|
359 | + foreach ( $prepared as $item ) { |
|
360 | + $items[] = $item->prepare_data_for_use(); |
|
361 | + } |
|
362 | + |
|
363 | + return $items; |
|
364 | + } |
|
334 | 365 | |
335 | - } |
|
366 | + /** |
|
367 | + * Get a single item belonging to the form. |
|
368 | + * |
|
369 | + * @since 1.0.19 |
|
370 | + * @param int $item_id The item id to return. |
|
371 | + * @return GetPaid_Form_Item|bool |
|
372 | + */ |
|
373 | + public function get_item( $item_id ) { |
|
336 | 374 | |
337 | - // $item_id => array( 'price' => 10 ) (item variations) |
|
338 | - if ( is_numeric( $key ) && is_array( $value ) ) { |
|
339 | - $item = new GetPaid_Form_Item( $key ); |
|
375 | + if ( empty( $item_id ) || ! is_numeric( $item_id ) ) { |
|
376 | + return false; |
|
377 | + } |
|
340 | 378 | |
341 | - if ( isset( $value['price'] ) && $item->user_can_set_their_price() ) { |
|
342 | - $item->set_price( $value['price'] ); |
|
343 | - } |
|
344 | - |
|
345 | - if ( $item->can_purchase() ) { |
|
346 | - $prepared[] = $item; |
|
347 | - } |
|
348 | - |
|
349 | - continue; |
|
350 | - } |
|
351 | - |
|
352 | - } |
|
353 | - |
|
354 | - if ( 'objects' == $return && 'view' == $context ) { |
|
355 | - return $prepared; |
|
356 | - } |
|
357 | - |
|
358 | - $items = array(); |
|
359 | - foreach ( $prepared as $item ) { |
|
360 | - $items[] = $item->prepare_data_for_use(); |
|
361 | - } |
|
362 | - |
|
363 | - return $items; |
|
364 | - } |
|
365 | - |
|
366 | - /** |
|
367 | - * Get a single item belonging to the form. |
|
368 | - * |
|
369 | - * @since 1.0.19 |
|
370 | - * @param int $item_id The item id to return. |
|
371 | - * @return GetPaid_Form_Item|bool |
|
372 | - */ |
|
373 | - public function get_item( $item_id ) { |
|
374 | - |
|
375 | - if ( empty( $item_id ) || ! is_numeric( $item_id ) ) { |
|
376 | - return false; |
|
377 | - } |
|
378 | - |
|
379 | - foreach( $this->get_items() as $item ) { |
|
380 | - if ( $item->get_id() == (int) $item_id ) { |
|
381 | - return $item; |
|
382 | - } |
|
383 | - } |
|
384 | - |
|
385 | - return false; |
|
386 | - |
|
387 | - } |
|
388 | - |
|
389 | - /** |
|
390 | - * Gets a single element. |
|
391 | - * |
|
392 | - * @since 1.0.19 |
|
393 | - * @param string $element_type The element type to return. |
|
394 | - * @return array|bool |
|
395 | - */ |
|
396 | - public function get_element_type( $element_type ) { |
|
397 | - |
|
398 | - if ( empty( $element_type ) || ! is_scalar( $element_type ) ) { |
|
399 | - return false; |
|
400 | - } |
|
401 | - |
|
402 | - foreach ( $this->get_prop( 'elements' ) as $element ) { |
|
403 | - |
|
404 | - if ( $element['type'] == $element_type ) { |
|
405 | - return $element; |
|
406 | - } |
|
407 | - |
|
408 | - } |
|
409 | - |
|
410 | - return false; |
|
411 | - |
|
412 | - } |
|
413 | - |
|
414 | - /** |
|
415 | - * Get the total amount earned via this form. |
|
416 | - * |
|
417 | - * @since 1.0.19 |
|
418 | - * @param string $context View or edit context. |
|
419 | - * @return float |
|
420 | - */ |
|
421 | - public function get_earned( $context = 'view' ) { |
|
422 | - return $this->get_prop( 'earned', $context ); |
|
423 | - } |
|
424 | - |
|
425 | - /** |
|
426 | - * Get the total amount refunded via this form. |
|
427 | - * |
|
428 | - * @since 1.0.19 |
|
429 | - * @param string $context View or edit context. |
|
430 | - * @return float |
|
431 | - */ |
|
432 | - public function get_refunded( $context = 'view' ) { |
|
433 | - return $this->get_prop( 'refunded', $context ); |
|
434 | - } |
|
435 | - |
|
436 | - /** |
|
437 | - * Get the total amount cancelled via this form. |
|
438 | - * |
|
439 | - * @since 1.0.19 |
|
440 | - * @param string $context View or edit context. |
|
441 | - * @return float |
|
442 | - */ |
|
443 | - public function get_cancelled( $context = 'view' ) { |
|
444 | - return $this->get_prop( 'cancelled', $context ); |
|
445 | - } |
|
446 | - |
|
447 | - /** |
|
448 | - * Get the total amount failed via this form. |
|
449 | - * |
|
450 | - * @since 1.0.19 |
|
451 | - * @param string $context View or edit context. |
|
452 | - * @return float |
|
453 | - */ |
|
454 | - public function get_failed( $context = 'view' ) { |
|
455 | - return $this->get_prop( 'failed', $context ); |
|
456 | - } |
|
457 | - |
|
458 | - /** |
|
459 | - * Get the currency. |
|
460 | - * |
|
461 | - * @since 1.0.19 |
|
462 | - * @param string $context View or edit context. |
|
463 | - * @return string |
|
464 | - */ |
|
465 | - public function get_currency() { |
|
466 | - $currency = empty( $this->invoice ) ? wpinv_get_currency() : $this->invoice->get_currency(); |
|
467 | - return apply_filters( 'getpaid-payment-form-currency', $currency, $this ); |
|
468 | - } |
|
379 | + foreach( $this->get_items() as $item ) { |
|
380 | + if ( $item->get_id() == (int) $item_id ) { |
|
381 | + return $item; |
|
382 | + } |
|
383 | + } |
|
384 | + |
|
385 | + return false; |
|
386 | + |
|
387 | + } |
|
388 | + |
|
389 | + /** |
|
390 | + * Gets a single element. |
|
391 | + * |
|
392 | + * @since 1.0.19 |
|
393 | + * @param string $element_type The element type to return. |
|
394 | + * @return array|bool |
|
395 | + */ |
|
396 | + public function get_element_type( $element_type ) { |
|
397 | + |
|
398 | + if ( empty( $element_type ) || ! is_scalar( $element_type ) ) { |
|
399 | + return false; |
|
400 | + } |
|
401 | + |
|
402 | + foreach ( $this->get_prop( 'elements' ) as $element ) { |
|
403 | + |
|
404 | + if ( $element['type'] == $element_type ) { |
|
405 | + return $element; |
|
406 | + } |
|
407 | + |
|
408 | + } |
|
409 | + |
|
410 | + return false; |
|
411 | + |
|
412 | + } |
|
413 | + |
|
414 | + /** |
|
415 | + * Get the total amount earned via this form. |
|
416 | + * |
|
417 | + * @since 1.0.19 |
|
418 | + * @param string $context View or edit context. |
|
419 | + * @return float |
|
420 | + */ |
|
421 | + public function get_earned( $context = 'view' ) { |
|
422 | + return $this->get_prop( 'earned', $context ); |
|
423 | + } |
|
424 | + |
|
425 | + /** |
|
426 | + * Get the total amount refunded via this form. |
|
427 | + * |
|
428 | + * @since 1.0.19 |
|
429 | + * @param string $context View or edit context. |
|
430 | + * @return float |
|
431 | + */ |
|
432 | + public function get_refunded( $context = 'view' ) { |
|
433 | + return $this->get_prop( 'refunded', $context ); |
|
434 | + } |
|
435 | + |
|
436 | + /** |
|
437 | + * Get the total amount cancelled via this form. |
|
438 | + * |
|
439 | + * @since 1.0.19 |
|
440 | + * @param string $context View or edit context. |
|
441 | + * @return float |
|
442 | + */ |
|
443 | + public function get_cancelled( $context = 'view' ) { |
|
444 | + return $this->get_prop( 'cancelled', $context ); |
|
445 | + } |
|
446 | + |
|
447 | + /** |
|
448 | + * Get the total amount failed via this form. |
|
449 | + * |
|
450 | + * @since 1.0.19 |
|
451 | + * @param string $context View or edit context. |
|
452 | + * @return float |
|
453 | + */ |
|
454 | + public function get_failed( $context = 'view' ) { |
|
455 | + return $this->get_prop( 'failed', $context ); |
|
456 | + } |
|
457 | + |
|
458 | + /** |
|
459 | + * Get the currency. |
|
460 | + * |
|
461 | + * @since 1.0.19 |
|
462 | + * @param string $context View or edit context. |
|
463 | + * @return string |
|
464 | + */ |
|
465 | + public function get_currency() { |
|
466 | + $currency = empty( $this->invoice ) ? wpinv_get_currency() : $this->invoice->get_currency(); |
|
467 | + return apply_filters( 'getpaid-payment-form-currency', $currency, $this ); |
|
468 | + } |
|
469 | 469 | |
470 | 470 | /* |
471 | 471 | |-------------------------------------------------------------------------- |
@@ -478,22 +478,22 @@ discard block |
||
478 | 478 | */ |
479 | 479 | |
480 | 480 | /** |
481 | - * Set plugin version when the item was created. |
|
482 | - * |
|
483 | - * @since 1.0.19 |
|
484 | - */ |
|
485 | - public function set_version( $value ) { |
|
486 | - $this->set_prop( 'version', $value ); |
|
481 | + * Set plugin version when the item was created. |
|
482 | + * |
|
483 | + * @since 1.0.19 |
|
484 | + */ |
|
485 | + public function set_version( $value ) { |
|
486 | + $this->set_prop( 'version', $value ); |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | /** |
490 | - * Set date when the item was created. |
|
491 | - * |
|
492 | - * @since 1.0.19 |
|
493 | - * @param string $value Value to set. |
|
490 | + * Set date when the item was created. |
|
491 | + * |
|
492 | + * @since 1.0.19 |
|
493 | + * @param string $value Value to set. |
|
494 | 494 | * @return bool Whether or not the date was set. |
495 | - */ |
|
496 | - public function set_date_created( $value ) { |
|
495 | + */ |
|
496 | + public function set_date_created( $value ) { |
|
497 | 497 | $date = strtotime( $value ); |
498 | 498 | |
499 | 499 | if ( $date ) { |
@@ -506,13 +506,13 @@ discard block |
||
506 | 506 | } |
507 | 507 | |
508 | 508 | /** |
509 | - * Set date when the item was last modified. |
|
510 | - * |
|
511 | - * @since 1.0.19 |
|
512 | - * @param string $value Value to set. |
|
509 | + * Set date when the item was last modified. |
|
510 | + * |
|
511 | + * @since 1.0.19 |
|
512 | + * @param string $value Value to set. |
|
513 | 513 | * @return bool Whether or not the date was set. |
514 | - */ |
|
515 | - public function set_date_modified( $value ) { |
|
514 | + */ |
|
515 | + public function set_date_modified( $value ) { |
|
516 | 516 | $date = strtotime( $value ); |
517 | 517 | |
518 | 518 | if ( $date ) { |
@@ -525,169 +525,169 @@ discard block |
||
525 | 525 | } |
526 | 526 | |
527 | 527 | /** |
528 | - * Set the item name. |
|
529 | - * |
|
530 | - * @since 1.0.19 |
|
531 | - * @param string $value New name. |
|
532 | - */ |
|
533 | - public function set_name( $value ) { |
|
534 | - $this->set_prop( 'name', sanitize_text_field( $value ) ); |
|
535 | - } |
|
536 | - |
|
537 | - /** |
|
538 | - * Alias of self::set_name(). |
|
539 | - * |
|
540 | - * @since 1.0.19 |
|
541 | - * @param string $value New name. |
|
542 | - */ |
|
543 | - public function set_title( $value ) { |
|
544 | - $this->set_name( $value ); |
|
545 | - } |
|
546 | - |
|
547 | - /** |
|
548 | - * Set the owner of the item. |
|
549 | - * |
|
550 | - * @since 1.0.19 |
|
551 | - * @param int $value New author. |
|
552 | - */ |
|
553 | - public function set_author( $value ) { |
|
554 | - $this->set_prop( 'author', (int) $value ); |
|
555 | - } |
|
556 | - |
|
557 | - /** |
|
558 | - * Set the form elements. |
|
559 | - * |
|
560 | - * @since 1.0.19 |
|
561 | - * @sinve 2.3.4 Array values sanitized. |
|
562 | - * @param array $value Form elements. |
|
563 | - */ |
|
564 | - public function set_elements( $value ) { |
|
565 | - if ( is_array( $value ) ) { |
|
566 | - |
|
567 | - // sanitize |
|
568 | - $value = $this->sanitize_array_values( $value ); |
|
569 | - |
|
570 | - $this->set_prop( 'elements', $value ); |
|
571 | - } |
|
572 | - } |
|
573 | - |
|
574 | - /** |
|
575 | - * Sanitize array values. |
|
576 | - * |
|
577 | - * @param $value |
|
578 | - * |
|
579 | - * @return mixed |
|
580 | - */ |
|
581 | - public function sanitize_array_values($value){ |
|
582 | - |
|
583 | - // sanitize |
|
584 | - if(!empty($value )){ |
|
585 | - |
|
586 | - foreach($value as $key => $val_arr){ |
|
587 | - |
|
588 | - if(is_array($val_arr)){ |
|
589 | - // check if we have sub array items. |
|
590 | - $sub_arr = array(); |
|
591 | - foreach($val_arr as $key2 => $val2){ |
|
592 | - if(is_array($val2)){ |
|
593 | - $sub_arr[$key2] = $this->sanitize_array_values($val2); |
|
594 | - unset($val_arr[$key][$key2]); |
|
595 | - } |
|
596 | - } |
|
597 | - |
|
598 | - // we allow some html in description so we sanitize it separately. |
|
599 | - $help_text = !empty($val_arr['description']) ? wp_kses_post($val_arr['description']) : ''; |
|
600 | - |
|
601 | - // sanitize array elements |
|
602 | - $value[$key] = array_map( 'sanitize_text_field', $val_arr ); |
|
603 | - |
|
604 | - // add back the description if set |
|
605 | - if(isset($val_arr['description'])){ $value[$key]['description'] = $help_text;} |
|
606 | - |
|
607 | - // add back sub array items after its been sanitized. |
|
608 | - if ( ! empty( $sub_arr ) ) { |
|
609 | - $value[$key] = array_merge($value[$key],$sub_arr); |
|
610 | - } |
|
611 | - } |
|
612 | - |
|
613 | - } |
|
614 | - |
|
615 | - } |
|
616 | - |
|
617 | - return $value; |
|
618 | - } |
|
619 | - |
|
620 | - /** |
|
621 | - * Set the form items. |
|
622 | - * |
|
623 | - * @since 1.0.19 |
|
624 | - * @param array $value Form elements. |
|
625 | - */ |
|
626 | - public function set_items( $value ) { |
|
627 | - if ( is_array( $value ) ) { |
|
628 | - $this->set_prop( 'items', $value ); |
|
629 | - } |
|
630 | - } |
|
631 | - |
|
632 | - /** |
|
633 | - * Set the total amount earned via this form. |
|
634 | - * |
|
635 | - * @since 1.0.19 |
|
636 | - * @param float $value Amount earned. |
|
637 | - */ |
|
638 | - public function set_earned( $value ) { |
|
639 | - $value = max( (float) $value, 0 ); |
|
640 | - $this->set_prop( 'earned', $value ); |
|
641 | - } |
|
642 | - |
|
643 | - /** |
|
644 | - * Set the total amount refunded via this form. |
|
645 | - * |
|
646 | - * @since 1.0.19 |
|
647 | - * @param float $value Amount refunded. |
|
648 | - */ |
|
649 | - public function set_refunded( $value ) { |
|
650 | - $value = max( (float) $value, 0 ); |
|
651 | - $this->set_prop( 'refunded', $value ); |
|
652 | - } |
|
653 | - |
|
654 | - /** |
|
655 | - * Set the total amount cancelled via this form. |
|
656 | - * |
|
657 | - * @since 1.0.19 |
|
658 | - * @param float $value Amount cancelled. |
|
659 | - */ |
|
660 | - public function set_cancelled( $value ) { |
|
661 | - $value = max( (float) $value, 0 ); |
|
662 | - $this->set_prop( 'cancelled', $value ); |
|
663 | - } |
|
664 | - |
|
665 | - /** |
|
666 | - * Set the total amount failed via this form. |
|
667 | - * |
|
668 | - * @since 1.0.19 |
|
669 | - * @param float $value Amount cancelled. |
|
670 | - */ |
|
671 | - public function set_failed( $value ) { |
|
672 | - $value = max( (float) $value, 0 ); |
|
673 | - $this->set_prop( 'failed', $value ); |
|
674 | - } |
|
528 | + * Set the item name. |
|
529 | + * |
|
530 | + * @since 1.0.19 |
|
531 | + * @param string $value New name. |
|
532 | + */ |
|
533 | + public function set_name( $value ) { |
|
534 | + $this->set_prop( 'name', sanitize_text_field( $value ) ); |
|
535 | + } |
|
536 | + |
|
537 | + /** |
|
538 | + * Alias of self::set_name(). |
|
539 | + * |
|
540 | + * @since 1.0.19 |
|
541 | + * @param string $value New name. |
|
542 | + */ |
|
543 | + public function set_title( $value ) { |
|
544 | + $this->set_name( $value ); |
|
545 | + } |
|
546 | + |
|
547 | + /** |
|
548 | + * Set the owner of the item. |
|
549 | + * |
|
550 | + * @since 1.0.19 |
|
551 | + * @param int $value New author. |
|
552 | + */ |
|
553 | + public function set_author( $value ) { |
|
554 | + $this->set_prop( 'author', (int) $value ); |
|
555 | + } |
|
556 | + |
|
557 | + /** |
|
558 | + * Set the form elements. |
|
559 | + * |
|
560 | + * @since 1.0.19 |
|
561 | + * @sinve 2.3.4 Array values sanitized. |
|
562 | + * @param array $value Form elements. |
|
563 | + */ |
|
564 | + public function set_elements( $value ) { |
|
565 | + if ( is_array( $value ) ) { |
|
566 | + |
|
567 | + // sanitize |
|
568 | + $value = $this->sanitize_array_values( $value ); |
|
569 | + |
|
570 | + $this->set_prop( 'elements', $value ); |
|
571 | + } |
|
572 | + } |
|
573 | + |
|
574 | + /** |
|
575 | + * Sanitize array values. |
|
576 | + * |
|
577 | + * @param $value |
|
578 | + * |
|
579 | + * @return mixed |
|
580 | + */ |
|
581 | + public function sanitize_array_values($value){ |
|
582 | + |
|
583 | + // sanitize |
|
584 | + if(!empty($value )){ |
|
585 | + |
|
586 | + foreach($value as $key => $val_arr){ |
|
587 | + |
|
588 | + if(is_array($val_arr)){ |
|
589 | + // check if we have sub array items. |
|
590 | + $sub_arr = array(); |
|
591 | + foreach($val_arr as $key2 => $val2){ |
|
592 | + if(is_array($val2)){ |
|
593 | + $sub_arr[$key2] = $this->sanitize_array_values($val2); |
|
594 | + unset($val_arr[$key][$key2]); |
|
595 | + } |
|
596 | + } |
|
597 | + |
|
598 | + // we allow some html in description so we sanitize it separately. |
|
599 | + $help_text = !empty($val_arr['description']) ? wp_kses_post($val_arr['description']) : ''; |
|
600 | + |
|
601 | + // sanitize array elements |
|
602 | + $value[$key] = array_map( 'sanitize_text_field', $val_arr ); |
|
603 | + |
|
604 | + // add back the description if set |
|
605 | + if(isset($val_arr['description'])){ $value[$key]['description'] = $help_text;} |
|
606 | + |
|
607 | + // add back sub array items after its been sanitized. |
|
608 | + if ( ! empty( $sub_arr ) ) { |
|
609 | + $value[$key] = array_merge($value[$key],$sub_arr); |
|
610 | + } |
|
611 | + } |
|
612 | + |
|
613 | + } |
|
614 | + |
|
615 | + } |
|
616 | + |
|
617 | + return $value; |
|
618 | + } |
|
619 | + |
|
620 | + /** |
|
621 | + * Set the form items. |
|
622 | + * |
|
623 | + * @since 1.0.19 |
|
624 | + * @param array $value Form elements. |
|
625 | + */ |
|
626 | + public function set_items( $value ) { |
|
627 | + if ( is_array( $value ) ) { |
|
628 | + $this->set_prop( 'items', $value ); |
|
629 | + } |
|
630 | + } |
|
631 | + |
|
632 | + /** |
|
633 | + * Set the total amount earned via this form. |
|
634 | + * |
|
635 | + * @since 1.0.19 |
|
636 | + * @param float $value Amount earned. |
|
637 | + */ |
|
638 | + public function set_earned( $value ) { |
|
639 | + $value = max( (float) $value, 0 ); |
|
640 | + $this->set_prop( 'earned', $value ); |
|
641 | + } |
|
642 | + |
|
643 | + /** |
|
644 | + * Set the total amount refunded via this form. |
|
645 | + * |
|
646 | + * @since 1.0.19 |
|
647 | + * @param float $value Amount refunded. |
|
648 | + */ |
|
649 | + public function set_refunded( $value ) { |
|
650 | + $value = max( (float) $value, 0 ); |
|
651 | + $this->set_prop( 'refunded', $value ); |
|
652 | + } |
|
653 | + |
|
654 | + /** |
|
655 | + * Set the total amount cancelled via this form. |
|
656 | + * |
|
657 | + * @since 1.0.19 |
|
658 | + * @param float $value Amount cancelled. |
|
659 | + */ |
|
660 | + public function set_cancelled( $value ) { |
|
661 | + $value = max( (float) $value, 0 ); |
|
662 | + $this->set_prop( 'cancelled', $value ); |
|
663 | + } |
|
664 | + |
|
665 | + /** |
|
666 | + * Set the total amount failed via this form. |
|
667 | + * |
|
668 | + * @since 1.0.19 |
|
669 | + * @param float $value Amount cancelled. |
|
670 | + */ |
|
671 | + public function set_failed( $value ) { |
|
672 | + $value = max( (float) $value, 0 ); |
|
673 | + $this->set_prop( 'failed', $value ); |
|
674 | + } |
|
675 | 675 | |
676 | 676 | /** |
677 | 677 | * Create an item. For backwards compatibilty. |
678 | 678 | * |
679 | 679 | * @deprecated |
680 | - * @return int item id |
|
680 | + * @return int item id |
|
681 | 681 | */ |
682 | 682 | public function create( $data = array() ) { |
683 | 683 | |
684 | - // Set the properties. |
|
685 | - if ( is_array( $data ) ) { |
|
686 | - $this->set_props( $data ); |
|
687 | - } |
|
684 | + // Set the properties. |
|
685 | + if ( is_array( $data ) ) { |
|
686 | + $this->set_props( $data ); |
|
687 | + } |
|
688 | 688 | |
689 | - // Save the item. |
|
690 | - return $this->save(); |
|
689 | + // Save the item. |
|
690 | + return $this->save(); |
|
691 | 691 | |
692 | 692 | } |
693 | 693 | |
@@ -695,7 +695,7 @@ discard block |
||
695 | 695 | * Updates an item. For backwards compatibilty. |
696 | 696 | * |
697 | 697 | * @deprecated |
698 | - * @return int item id |
|
698 | + * @return int item id |
|
699 | 699 | */ |
700 | 700 | public function update( $data = array() ) { |
701 | 701 | return $this->create( $data ); |
@@ -711,22 +711,22 @@ discard block |
||
711 | 711 | */ |
712 | 712 | |
713 | 713 | /** |
714 | - * Checks whether this is the default payment form. |
|
715 | - * |
|
716 | - * @since 1.0.19 |
|
717 | - * @return bool |
|
718 | - */ |
|
714 | + * Checks whether this is the default payment form. |
|
715 | + * |
|
716 | + * @since 1.0.19 |
|
717 | + * @return bool |
|
718 | + */ |
|
719 | 719 | public function is_default() { |
720 | 720 | $is_default = $this->get_id() == wpinv_get_default_payment_form(); |
721 | 721 | return (bool) apply_filters( 'wpinv_is_default_payment_form', $is_default, $this->get_id(), $this ); |
722 | - } |
|
722 | + } |
|
723 | 723 | |
724 | 724 | /** |
725 | - * Checks whether the form is active. |
|
726 | - * |
|
727 | - * @since 1.0.19 |
|
728 | - * @return bool |
|
729 | - */ |
|
725 | + * Checks whether the form is active. |
|
726 | + * |
|
727 | + * @since 1.0.19 |
|
728 | + * @return bool |
|
729 | + */ |
|
730 | 730 | public function is_active() { |
731 | 731 | $is_active = 0 !== (int) $this->get_id(); |
732 | 732 | |
@@ -735,76 +735,76 @@ discard block |
||
735 | 735 | } |
736 | 736 | |
737 | 737 | return (bool) apply_filters( 'wpinv_is_payment_form_active', $is_active, $this ); |
738 | - } |
|
739 | - |
|
740 | - /** |
|
741 | - * Checks whether the form has a given item. |
|
742 | - * |
|
743 | - * @since 1.0.19 |
|
744 | - * @return bool |
|
745 | - */ |
|
738 | + } |
|
739 | + |
|
740 | + /** |
|
741 | + * Checks whether the form has a given item. |
|
742 | + * |
|
743 | + * @since 1.0.19 |
|
744 | + * @return bool |
|
745 | + */ |
|
746 | 746 | public function has_item( $item_id ) { |
747 | 747 | return false !== $this->get_item( $item_id ); |
748 | - } |
|
749 | - |
|
750 | - /** |
|
751 | - * Checks whether the form has a given element. |
|
752 | - * |
|
753 | - * @since 1.0.19 |
|
754 | - * @return bool |
|
755 | - */ |
|
748 | + } |
|
749 | + |
|
750 | + /** |
|
751 | + * Checks whether the form has a given element. |
|
752 | + * |
|
753 | + * @since 1.0.19 |
|
754 | + * @return bool |
|
755 | + */ |
|
756 | 756 | public function has_element_type( $element_type ) { |
757 | 757 | return false !== $this->get_element_type( $element_type ); |
758 | - } |
|
759 | - |
|
760 | - /** |
|
761 | - * Checks whether this form is recurring or not. |
|
762 | - * |
|
763 | - * @since 1.0.19 |
|
764 | - * @return bool |
|
765 | - */ |
|
758 | + } |
|
759 | + |
|
760 | + /** |
|
761 | + * Checks whether this form is recurring or not. |
|
762 | + * |
|
763 | + * @since 1.0.19 |
|
764 | + * @return bool |
|
765 | + */ |
|
766 | 766 | public function is_recurring() { |
767 | 767 | |
768 | - if ( ! empty( $this->invoice ) ) { |
|
769 | - return $this->invoice->is_recurring(); |
|
770 | - } |
|
768 | + if ( ! empty( $this->invoice ) ) { |
|
769 | + return $this->invoice->is_recurring(); |
|
770 | + } |
|
771 | 771 | |
772 | - foreach ( $this->get_items() as $item ) { |
|
772 | + foreach ( $this->get_items() as $item ) { |
|
773 | 773 | |
774 | - if ( $item->is_recurring() ) { |
|
775 | - return true; |
|
776 | - } |
|
774 | + if ( $item->is_recurring() ) { |
|
775 | + return true; |
|
776 | + } |
|
777 | 777 | |
778 | - } |
|
778 | + } |
|
779 | 779 | |
780 | 780 | return false; |
781 | - } |
|
781 | + } |
|
782 | 782 | |
783 | - /** |
|
784 | - * Retrieves the form's html. |
|
785 | - * |
|
786 | - * @since 1.0.19 |
|
787 | - */ |
|
783 | + /** |
|
784 | + * Retrieves the form's html. |
|
785 | + * |
|
786 | + * @since 1.0.19 |
|
787 | + */ |
|
788 | 788 | public function get_html( $extra_markup = '' ) { |
789 | 789 | |
790 | - // Return the HTML. |
|
791 | - return wpinv_get_template_html( |
|
792 | - 'payment-forms/form.php', |
|
793 | - array( |
|
794 | - 'form' => $this, |
|
795 | - 'extra_markup' => $extra_markup, |
|
796 | - ) |
|
797 | - ); |
|
798 | - |
|
799 | - } |
|
800 | - |
|
801 | - /** |
|
802 | - * Displays the payment form. |
|
803 | - * |
|
804 | - * @since 1.0.19 |
|
805 | - */ |
|
790 | + // Return the HTML. |
|
791 | + return wpinv_get_template_html( |
|
792 | + 'payment-forms/form.php', |
|
793 | + array( |
|
794 | + 'form' => $this, |
|
795 | + 'extra_markup' => $extra_markup, |
|
796 | + ) |
|
797 | + ); |
|
798 | + |
|
799 | + } |
|
800 | + |
|
801 | + /** |
|
802 | + * Displays the payment form. |
|
803 | + * |
|
804 | + * @since 1.0.19 |
|
805 | + */ |
|
806 | 806 | public function display( $extra_markup = '' ) { |
807 | - echo $this->get_html( $extra_markup ); |
|
807 | + echo $this->get_html( $extra_markup ); |
|
808 | 808 | } |
809 | 809 | |
810 | 810 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -72,28 +72,28 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @param int|object|GetPaid_Payment_Form|WP_Post $form Form to read. |
74 | 74 | */ |
75 | - public function __construct( $form = 0 ) { |
|
76 | - parent::__construct( $form ); |
|
75 | + public function __construct($form = 0) { |
|
76 | + parent::__construct($form); |
|
77 | 77 | |
78 | - if ( is_numeric( $form ) && $form > 0 ) { |
|
79 | - $this->set_id( $form ); |
|
80 | - } elseif ( $form instanceof self ) { |
|
78 | + if (is_numeric($form) && $form > 0) { |
|
79 | + $this->set_id($form); |
|
80 | + } elseif ($form instanceof self) { |
|
81 | 81 | |
82 | - $this->set_id( $form->get_id() ); |
|
82 | + $this->set_id($form->get_id()); |
|
83 | 83 | $this->invoice = $form->invoice; |
84 | 84 | |
85 | - } elseif ( ! empty( $form->ID ) ) { |
|
86 | - $this->set_id( $form->ID ); |
|
85 | + } elseif (!empty($form->ID)) { |
|
86 | + $this->set_id($form->ID); |
|
87 | 87 | } else { |
88 | - $this->set_object_read( true ); |
|
88 | + $this->set_object_read(true); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | // Load the datastore. |
92 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
92 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
93 | 93 | |
94 | - if ( $this->get_id() > 0 ) { |
|
95 | - $this->post = get_post( $this->get_id() ); |
|
96 | - $this->data_store->read( $this ); |
|
94 | + if ($this->get_id() > 0) { |
|
95 | + $this->post = get_post($this->get_id()); |
|
96 | + $this->data_store->read($this); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | } |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | * @param string $context View or edit context. |
121 | 121 | * @return string |
122 | 122 | */ |
123 | - public function get_version( $context = 'view' ) { |
|
124 | - return $this->get_prop( 'version', $context ); |
|
123 | + public function get_version($context = 'view') { |
|
124 | + return $this->get_prop('version', $context); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | * @param string $context View or edit context. |
132 | 132 | * @return string |
133 | 133 | */ |
134 | - public function get_date_created( $context = 'view' ) { |
|
135 | - return $this->get_prop( 'date_created', $context ); |
|
134 | + public function get_date_created($context = 'view') { |
|
135 | + return $this->get_prop('date_created', $context); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -142,11 +142,11 @@ discard block |
||
142 | 142 | * @param string $context View or edit context. |
143 | 143 | * @return string |
144 | 144 | */ |
145 | - public function get_date_created_gmt( $context = 'view' ) { |
|
146 | - $date = $this->get_date_created( $context ); |
|
145 | + public function get_date_created_gmt($context = 'view') { |
|
146 | + $date = $this->get_date_created($context); |
|
147 | 147 | |
148 | - if ( $date ) { |
|
149 | - $date = get_gmt_from_date( $date ); |
|
148 | + if ($date) { |
|
149 | + $date = get_gmt_from_date($date); |
|
150 | 150 | } |
151 | 151 | return $date; |
152 | 152 | } |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | * @param string $context View or edit context. |
159 | 159 | * @return string |
160 | 160 | */ |
161 | - public function get_date_modified( $context = 'view' ) { |
|
162 | - return $this->get_prop( 'date_modified', $context ); |
|
161 | + public function get_date_modified($context = 'view') { |
|
162 | + return $this->get_prop('date_modified', $context); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -169,11 +169,11 @@ discard block |
||
169 | 169 | * @param string $context View or edit context. |
170 | 170 | * @return string |
171 | 171 | */ |
172 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
173 | - $date = $this->get_date_modified( $context ); |
|
172 | + public function get_date_modified_gmt($context = 'view') { |
|
173 | + $date = $this->get_date_modified($context); |
|
174 | 174 | |
175 | - if ( $date ) { |
|
176 | - $date = get_gmt_from_date( $date ); |
|
175 | + if ($date) { |
|
176 | + $date = get_gmt_from_date($date); |
|
177 | 177 | } |
178 | 178 | return $date; |
179 | 179 | } |
@@ -185,8 +185,8 @@ discard block |
||
185 | 185 | * @param string $context View or edit context. |
186 | 186 | * @return string |
187 | 187 | */ |
188 | - public function get_name( $context = 'view' ) { |
|
189 | - return $this->get_prop( 'name', $context ); |
|
188 | + public function get_name($context = 'view') { |
|
189 | + return $this->get_prop('name', $context); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
@@ -196,8 +196,8 @@ discard block |
||
196 | 196 | * @param string $context View or edit context. |
197 | 197 | * @return string |
198 | 198 | */ |
199 | - public function get_title( $context = 'view' ) { |
|
200 | - return $this->get_name( $context ); |
|
199 | + public function get_title($context = 'view') { |
|
200 | + return $this->get_name($context); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
@@ -207,8 +207,8 @@ discard block |
||
207 | 207 | * @param string $context View or edit context. |
208 | 208 | * @return int |
209 | 209 | */ |
210 | - public function get_author( $context = 'view' ) { |
|
211 | - return (int) $this->get_prop( 'author', $context ); |
|
210 | + public function get_author($context = 'view') { |
|
211 | + return (int) $this->get_prop('author', $context); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | /** |
@@ -218,21 +218,21 @@ discard block |
||
218 | 218 | * @param string $context View or edit context. |
219 | 219 | * @return array |
220 | 220 | */ |
221 | - public function get_elements( $context = 'view' ) { |
|
222 | - $elements = $this->get_prop( 'elements', $context ); |
|
221 | + public function get_elements($context = 'view') { |
|
222 | + $elements = $this->get_prop('elements', $context); |
|
223 | 223 | |
224 | - if ( empty( $elements ) || ! is_array( $elements ) ) { |
|
225 | - return wpinv_get_data( 'sample-payment-form' ); |
|
224 | + if (empty($elements) || !is_array($elements)) { |
|
225 | + return wpinv_get_data('sample-payment-form'); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | // Ensure that all required elements exist. |
229 | 229 | $_elements = array(); |
230 | - foreach ( $elements as $element ) { |
|
230 | + foreach ($elements as $element) { |
|
231 | 231 | |
232 | - if ( $element['type'] == 'pay_button' && ! $this->has_element_type( 'gateway_select' ) ) { |
|
232 | + if ($element['type'] == 'pay_button' && !$this->has_element_type('gateway_select')) { |
|
233 | 233 | |
234 | 234 | $_elements[] = array( |
235 | - 'text' => __( 'Select Payment Method', 'invoicing' ), |
|
235 | + 'text' => __('Select Payment Method', 'invoicing'), |
|
236 | 236 | 'id' => 'gtscicd', |
237 | 237 | 'name' => 'gtscicd', |
238 | 238 | 'type' => 'gateway_select', |
@@ -257,22 +257,22 @@ discard block |
||
257 | 257 | * @param string $return objects or arrays. |
258 | 258 | * @return GetPaid_Form_Item[] |
259 | 259 | */ |
260 | - public function get_items( $context = 'view', $return = 'objects' ) { |
|
261 | - $items = $this->get_prop( 'items', $context ); |
|
260 | + public function get_items($context = 'view', $return = 'objects') { |
|
261 | + $items = $this->get_prop('items', $context); |
|
262 | 262 | |
263 | - if ( empty( $items ) || ! is_array( $items ) ) { |
|
264 | - $items = wpinv_get_data( 'sample-payment-form-items' ); |
|
263 | + if (empty($items) || !is_array($items)) { |
|
264 | + $items = wpinv_get_data('sample-payment-form-items'); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | // Convert the items. |
268 | 268 | $prepared = array(); |
269 | 269 | |
270 | - foreach ( $items as $key => $value ) { |
|
270 | + foreach ($items as $key => $value) { |
|
271 | 271 | |
272 | 272 | // Form items. |
273 | - if ( $value instanceof GetPaid_Form_Item ) { |
|
273 | + if ($value instanceof GetPaid_Form_Item) { |
|
274 | 274 | |
275 | - if ( $value->can_purchase() ) { |
|
275 | + if ($value->can_purchase()) { |
|
276 | 276 | $prepared[] = $value; |
277 | 277 | } |
278 | 278 | |
@@ -281,16 +281,16 @@ discard block |
||
281 | 281 | } |
282 | 282 | |
283 | 283 | // $item_id => $quantity (buy buttons) |
284 | - if ( is_numeric( $key ) && is_numeric( $value ) ) { |
|
285 | - $item = new GetPaid_Form_Item( $key ); |
|
284 | + if (is_numeric($key) && is_numeric($value)) { |
|
285 | + $item = new GetPaid_Form_Item($key); |
|
286 | 286 | |
287 | - if ( $item->can_purchase() ) { |
|
287 | + if ($item->can_purchase()) { |
|
288 | 288 | |
289 | 289 | $value = (float) $value; |
290 | - $item->set_quantity( $value ); |
|
291 | - if ( 0 == $value ) { |
|
292 | - $item->set_quantity( 1 ); |
|
293 | - $item->set_allow_quantities( true ); |
|
290 | + $item->set_quantity($value); |
|
291 | + if (0 == $value) { |
|
292 | + $item->set_quantity(1); |
|
293 | + $item->set_allow_quantities(true); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | $prepared[] = $item; |
@@ -300,33 +300,33 @@ discard block |
||
300 | 300 | } |
301 | 301 | |
302 | 302 | // Items saved via payment forms editor. |
303 | - if ( is_array( $value ) && isset( $value['id'] ) ) { |
|
303 | + if (is_array($value) && isset($value['id'])) { |
|
304 | 304 | |
305 | - $item = new GetPaid_Form_Item( $value['id'] ); |
|
305 | + $item = new GetPaid_Form_Item($value['id']); |
|
306 | 306 | |
307 | - if ( ! $item->can_purchase() ) { |
|
307 | + if (!$item->can_purchase()) { |
|
308 | 308 | continue; |
309 | 309 | } |
310 | 310 | |
311 | 311 | // Sub-total (Cart items). |
312 | - if ( isset( $value['subtotal'] ) ) { |
|
313 | - $item->set_price( $value['subtotal'] ); |
|
312 | + if (isset($value['subtotal'])) { |
|
313 | + $item->set_price($value['subtotal']); |
|
314 | 314 | } |
315 | 315 | |
316 | - if ( isset( $value['quantity'] ) ) { |
|
317 | - $item->set_quantity( $value['quantity'] ); |
|
316 | + if (isset($value['quantity'])) { |
|
317 | + $item->set_quantity($value['quantity']); |
|
318 | 318 | } |
319 | 319 | |
320 | - if ( isset( $value['allow_quantities'] ) ) { |
|
321 | - $item->set_allow_quantities( $value['allow_quantities'] ); |
|
320 | + if (isset($value['allow_quantities'])) { |
|
321 | + $item->set_allow_quantities($value['allow_quantities']); |
|
322 | 322 | } |
323 | 323 | |
324 | - if ( isset( $value['required'] ) ) { |
|
325 | - $item->set_is_required( $value['required'] ); |
|
324 | + if (isset($value['required'])) { |
|
325 | + $item->set_is_required($value['required']); |
|
326 | 326 | } |
327 | 327 | |
328 | - if ( isset( $value['description'] ) ) { |
|
329 | - $item->set_custom_description( $value['description'] ); |
|
328 | + if (isset($value['description'])) { |
|
329 | + $item->set_custom_description($value['description']); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | $prepared[] = $item; |
@@ -335,14 +335,14 @@ discard block |
||
335 | 335 | } |
336 | 336 | |
337 | 337 | // $item_id => array( 'price' => 10 ) (item variations) |
338 | - if ( is_numeric( $key ) && is_array( $value ) ) { |
|
339 | - $item = new GetPaid_Form_Item( $key ); |
|
338 | + if (is_numeric($key) && is_array($value)) { |
|
339 | + $item = new GetPaid_Form_Item($key); |
|
340 | 340 | |
341 | - if ( isset( $value['price'] ) && $item->user_can_set_their_price() ) { |
|
342 | - $item->set_price( $value['price'] ); |
|
341 | + if (isset($value['price']) && $item->user_can_set_their_price()) { |
|
342 | + $item->set_price($value['price']); |
|
343 | 343 | } |
344 | 344 | |
345 | - if ( $item->can_purchase() ) { |
|
345 | + if ($item->can_purchase()) { |
|
346 | 346 | $prepared[] = $item; |
347 | 347 | } |
348 | 348 | |
@@ -351,12 +351,12 @@ discard block |
||
351 | 351 | |
352 | 352 | } |
353 | 353 | |
354 | - if ( 'objects' == $return && 'view' == $context ) { |
|
354 | + if ('objects' == $return && 'view' == $context) { |
|
355 | 355 | return $prepared; |
356 | 356 | } |
357 | 357 | |
358 | 358 | $items = array(); |
359 | - foreach ( $prepared as $item ) { |
|
359 | + foreach ($prepared as $item) { |
|
360 | 360 | $items[] = $item->prepare_data_for_use(); |
361 | 361 | } |
362 | 362 | |
@@ -370,14 +370,14 @@ discard block |
||
370 | 370 | * @param int $item_id The item id to return. |
371 | 371 | * @return GetPaid_Form_Item|bool |
372 | 372 | */ |
373 | - public function get_item( $item_id ) { |
|
373 | + public function get_item($item_id) { |
|
374 | 374 | |
375 | - if ( empty( $item_id ) || ! is_numeric( $item_id ) ) { |
|
375 | + if (empty($item_id) || !is_numeric($item_id)) { |
|
376 | 376 | return false; |
377 | 377 | } |
378 | 378 | |
379 | - foreach( $this->get_items() as $item ) { |
|
380 | - if ( $item->get_id() == (int) $item_id ) { |
|
379 | + foreach ($this->get_items() as $item) { |
|
380 | + if ($item->get_id() == (int) $item_id) { |
|
381 | 381 | return $item; |
382 | 382 | } |
383 | 383 | } |
@@ -393,15 +393,15 @@ discard block |
||
393 | 393 | * @param string $element_type The element type to return. |
394 | 394 | * @return array|bool |
395 | 395 | */ |
396 | - public function get_element_type( $element_type ) { |
|
396 | + public function get_element_type($element_type) { |
|
397 | 397 | |
398 | - if ( empty( $element_type ) || ! is_scalar( $element_type ) ) { |
|
398 | + if (empty($element_type) || !is_scalar($element_type)) { |
|
399 | 399 | return false; |
400 | 400 | } |
401 | 401 | |
402 | - foreach ( $this->get_prop( 'elements' ) as $element ) { |
|
402 | + foreach ($this->get_prop('elements') as $element) { |
|
403 | 403 | |
404 | - if ( $element['type'] == $element_type ) { |
|
404 | + if ($element['type'] == $element_type) { |
|
405 | 405 | return $element; |
406 | 406 | } |
407 | 407 | |
@@ -418,8 +418,8 @@ discard block |
||
418 | 418 | * @param string $context View or edit context. |
419 | 419 | * @return float |
420 | 420 | */ |
421 | - public function get_earned( $context = 'view' ) { |
|
422 | - return $this->get_prop( 'earned', $context ); |
|
421 | + public function get_earned($context = 'view') { |
|
422 | + return $this->get_prop('earned', $context); |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | /** |
@@ -429,8 +429,8 @@ discard block |
||
429 | 429 | * @param string $context View or edit context. |
430 | 430 | * @return float |
431 | 431 | */ |
432 | - public function get_refunded( $context = 'view' ) { |
|
433 | - return $this->get_prop( 'refunded', $context ); |
|
432 | + public function get_refunded($context = 'view') { |
|
433 | + return $this->get_prop('refunded', $context); |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | /** |
@@ -440,8 +440,8 @@ discard block |
||
440 | 440 | * @param string $context View or edit context. |
441 | 441 | * @return float |
442 | 442 | */ |
443 | - public function get_cancelled( $context = 'view' ) { |
|
444 | - return $this->get_prop( 'cancelled', $context ); |
|
443 | + public function get_cancelled($context = 'view') { |
|
444 | + return $this->get_prop('cancelled', $context); |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | /** |
@@ -451,8 +451,8 @@ discard block |
||
451 | 451 | * @param string $context View or edit context. |
452 | 452 | * @return float |
453 | 453 | */ |
454 | - public function get_failed( $context = 'view' ) { |
|
455 | - return $this->get_prop( 'failed', $context ); |
|
454 | + public function get_failed($context = 'view') { |
|
455 | + return $this->get_prop('failed', $context); |
|
456 | 456 | } |
457 | 457 | |
458 | 458 | /** |
@@ -463,8 +463,8 @@ discard block |
||
463 | 463 | * @return string |
464 | 464 | */ |
465 | 465 | public function get_currency() { |
466 | - $currency = empty( $this->invoice ) ? wpinv_get_currency() : $this->invoice->get_currency(); |
|
467 | - return apply_filters( 'getpaid-payment-form-currency', $currency, $this ); |
|
466 | + $currency = empty($this->invoice) ? wpinv_get_currency() : $this->invoice->get_currency(); |
|
467 | + return apply_filters('getpaid-payment-form-currency', $currency, $this); |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | /* |
@@ -482,8 +482,8 @@ discard block |
||
482 | 482 | * |
483 | 483 | * @since 1.0.19 |
484 | 484 | */ |
485 | - public function set_version( $value ) { |
|
486 | - $this->set_prop( 'version', $value ); |
|
485 | + public function set_version($value) { |
|
486 | + $this->set_prop('version', $value); |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | /** |
@@ -493,11 +493,11 @@ discard block |
||
493 | 493 | * @param string $value Value to set. |
494 | 494 | * @return bool Whether or not the date was set. |
495 | 495 | */ |
496 | - public function set_date_created( $value ) { |
|
497 | - $date = strtotime( $value ); |
|
496 | + public function set_date_created($value) { |
|
497 | + $date = strtotime($value); |
|
498 | 498 | |
499 | - if ( $date ) { |
|
500 | - $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) ); |
|
499 | + if ($date) { |
|
500 | + $this->set_prop('date_created', date('Y-m-d H:i:s', $date)); |
|
501 | 501 | return true; |
502 | 502 | } |
503 | 503 | |
@@ -512,11 +512,11 @@ discard block |
||
512 | 512 | * @param string $value Value to set. |
513 | 513 | * @return bool Whether or not the date was set. |
514 | 514 | */ |
515 | - public function set_date_modified( $value ) { |
|
516 | - $date = strtotime( $value ); |
|
515 | + public function set_date_modified($value) { |
|
516 | + $date = strtotime($value); |
|
517 | 517 | |
518 | - if ( $date ) { |
|
519 | - $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) ); |
|
518 | + if ($date) { |
|
519 | + $this->set_prop('date_modified', date('Y-m-d H:i:s', $date)); |
|
520 | 520 | return true; |
521 | 521 | } |
522 | 522 | |
@@ -530,8 +530,8 @@ discard block |
||
530 | 530 | * @since 1.0.19 |
531 | 531 | * @param string $value New name. |
532 | 532 | */ |
533 | - public function set_name( $value ) { |
|
534 | - $this->set_prop( 'name', sanitize_text_field( $value ) ); |
|
533 | + public function set_name($value) { |
|
534 | + $this->set_prop('name', sanitize_text_field($value)); |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | /** |
@@ -540,8 +540,8 @@ discard block |
||
540 | 540 | * @since 1.0.19 |
541 | 541 | * @param string $value New name. |
542 | 542 | */ |
543 | - public function set_title( $value ) { |
|
544 | - $this->set_name( $value ); |
|
543 | + public function set_title($value) { |
|
544 | + $this->set_name($value); |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | /** |
@@ -550,8 +550,8 @@ discard block |
||
550 | 550 | * @since 1.0.19 |
551 | 551 | * @param int $value New author. |
552 | 552 | */ |
553 | - public function set_author( $value ) { |
|
554 | - $this->set_prop( 'author', (int) $value ); |
|
553 | + public function set_author($value) { |
|
554 | + $this->set_prop('author', (int) $value); |
|
555 | 555 | } |
556 | 556 | |
557 | 557 | /** |
@@ -561,13 +561,13 @@ discard block |
||
561 | 561 | * @sinve 2.3.4 Array values sanitized. |
562 | 562 | * @param array $value Form elements. |
563 | 563 | */ |
564 | - public function set_elements( $value ) { |
|
565 | - if ( is_array( $value ) ) { |
|
564 | + public function set_elements($value) { |
|
565 | + if (is_array($value)) { |
|
566 | 566 | |
567 | 567 | // sanitize |
568 | - $value = $this->sanitize_array_values( $value ); |
|
568 | + $value = $this->sanitize_array_values($value); |
|
569 | 569 | |
570 | - $this->set_prop( 'elements', $value ); |
|
570 | + $this->set_prop('elements', $value); |
|
571 | 571 | } |
572 | 572 | } |
573 | 573 | |
@@ -578,18 +578,18 @@ discard block |
||
578 | 578 | * |
579 | 579 | * @return mixed |
580 | 580 | */ |
581 | - public function sanitize_array_values($value){ |
|
581 | + public function sanitize_array_values($value) { |
|
582 | 582 | |
583 | 583 | // sanitize |
584 | - if(!empty($value )){ |
|
584 | + if (!empty($value)) { |
|
585 | 585 | |
586 | - foreach($value as $key => $val_arr){ |
|
586 | + foreach ($value as $key => $val_arr) { |
|
587 | 587 | |
588 | - if(is_array($val_arr)){ |
|
588 | + if (is_array($val_arr)) { |
|
589 | 589 | // check if we have sub array items. |
590 | 590 | $sub_arr = array(); |
591 | - foreach($val_arr as $key2 => $val2){ |
|
592 | - if(is_array($val2)){ |
|
591 | + foreach ($val_arr as $key2 => $val2) { |
|
592 | + if (is_array($val2)) { |
|
593 | 593 | $sub_arr[$key2] = $this->sanitize_array_values($val2); |
594 | 594 | unset($val_arr[$key][$key2]); |
595 | 595 | } |
@@ -599,14 +599,14 @@ discard block |
||
599 | 599 | $help_text = !empty($val_arr['description']) ? wp_kses_post($val_arr['description']) : ''; |
600 | 600 | |
601 | 601 | // sanitize array elements |
602 | - $value[$key] = array_map( 'sanitize_text_field', $val_arr ); |
|
602 | + $value[$key] = array_map('sanitize_text_field', $val_arr); |
|
603 | 603 | |
604 | 604 | // add back the description if set |
605 | - if(isset($val_arr['description'])){ $value[$key]['description'] = $help_text;} |
|
605 | + if (isset($val_arr['description'])) { $value[$key]['description'] = $help_text; } |
|
606 | 606 | |
607 | 607 | // add back sub array items after its been sanitized. |
608 | - if ( ! empty( $sub_arr ) ) { |
|
609 | - $value[$key] = array_merge($value[$key],$sub_arr); |
|
608 | + if (!empty($sub_arr)) { |
|
609 | + $value[$key] = array_merge($value[$key], $sub_arr); |
|
610 | 610 | } |
611 | 611 | } |
612 | 612 | |
@@ -623,9 +623,9 @@ discard block |
||
623 | 623 | * @since 1.0.19 |
624 | 624 | * @param array $value Form elements. |
625 | 625 | */ |
626 | - public function set_items( $value ) { |
|
627 | - if ( is_array( $value ) ) { |
|
628 | - $this->set_prop( 'items', $value ); |
|
626 | + public function set_items($value) { |
|
627 | + if (is_array($value)) { |
|
628 | + $this->set_prop('items', $value); |
|
629 | 629 | } |
630 | 630 | } |
631 | 631 | |
@@ -635,9 +635,9 @@ discard block |
||
635 | 635 | * @since 1.0.19 |
636 | 636 | * @param float $value Amount earned. |
637 | 637 | */ |
638 | - public function set_earned( $value ) { |
|
639 | - $value = max( (float) $value, 0 ); |
|
640 | - $this->set_prop( 'earned', $value ); |
|
638 | + public function set_earned($value) { |
|
639 | + $value = max((float) $value, 0); |
|
640 | + $this->set_prop('earned', $value); |
|
641 | 641 | } |
642 | 642 | |
643 | 643 | /** |
@@ -646,9 +646,9 @@ discard block |
||
646 | 646 | * @since 1.0.19 |
647 | 647 | * @param float $value Amount refunded. |
648 | 648 | */ |
649 | - public function set_refunded( $value ) { |
|
650 | - $value = max( (float) $value, 0 ); |
|
651 | - $this->set_prop( 'refunded', $value ); |
|
649 | + public function set_refunded($value) { |
|
650 | + $value = max((float) $value, 0); |
|
651 | + $this->set_prop('refunded', $value); |
|
652 | 652 | } |
653 | 653 | |
654 | 654 | /** |
@@ -657,9 +657,9 @@ discard block |
||
657 | 657 | * @since 1.0.19 |
658 | 658 | * @param float $value Amount cancelled. |
659 | 659 | */ |
660 | - public function set_cancelled( $value ) { |
|
661 | - $value = max( (float) $value, 0 ); |
|
662 | - $this->set_prop( 'cancelled', $value ); |
|
660 | + public function set_cancelled($value) { |
|
661 | + $value = max((float) $value, 0); |
|
662 | + $this->set_prop('cancelled', $value); |
|
663 | 663 | } |
664 | 664 | |
665 | 665 | /** |
@@ -668,9 +668,9 @@ discard block |
||
668 | 668 | * @since 1.0.19 |
669 | 669 | * @param float $value Amount cancelled. |
670 | 670 | */ |
671 | - public function set_failed( $value ) { |
|
672 | - $value = max( (float) $value, 0 ); |
|
673 | - $this->set_prop( 'failed', $value ); |
|
671 | + public function set_failed($value) { |
|
672 | + $value = max((float) $value, 0); |
|
673 | + $this->set_prop('failed', $value); |
|
674 | 674 | } |
675 | 675 | |
676 | 676 | /** |
@@ -679,11 +679,11 @@ discard block |
||
679 | 679 | * @deprecated |
680 | 680 | * @return int item id |
681 | 681 | */ |
682 | - public function create( $data = array() ) { |
|
682 | + public function create($data = array()) { |
|
683 | 683 | |
684 | 684 | // Set the properties. |
685 | - if ( is_array( $data ) ) { |
|
686 | - $this->set_props( $data ); |
|
685 | + if (is_array($data)) { |
|
686 | + $this->set_props($data); |
|
687 | 687 | } |
688 | 688 | |
689 | 689 | // Save the item. |
@@ -697,8 +697,8 @@ discard block |
||
697 | 697 | * @deprecated |
698 | 698 | * @return int item id |
699 | 699 | */ |
700 | - public function update( $data = array() ) { |
|
701 | - return $this->create( $data ); |
|
700 | + public function update($data = array()) { |
|
701 | + return $this->create($data); |
|
702 | 702 | } |
703 | 703 | |
704 | 704 | /* |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | */ |
719 | 719 | public function is_default() { |
720 | 720 | $is_default = $this->get_id() == wpinv_get_default_payment_form(); |
721 | - return (bool) apply_filters( 'wpinv_is_default_payment_form', $is_default, $this->get_id(), $this ); |
|
721 | + return (bool) apply_filters('wpinv_is_default_payment_form', $is_default, $this->get_id(), $this); |
|
722 | 722 | } |
723 | 723 | |
724 | 724 | /** |
@@ -730,11 +730,11 @@ discard block |
||
730 | 730 | public function is_active() { |
731 | 731 | $is_active = 0 !== (int) $this->get_id(); |
732 | 732 | |
733 | - if ( $is_active && ! current_user_can( 'edit_post', $this->get_id() ) && $this->get_status() != 'publish' ) { |
|
733 | + if ($is_active && !current_user_can('edit_post', $this->get_id()) && $this->get_status() != 'publish') { |
|
734 | 734 | $is_active = false; |
735 | 735 | } |
736 | 736 | |
737 | - return (bool) apply_filters( 'wpinv_is_payment_form_active', $is_active, $this ); |
|
737 | + return (bool) apply_filters('wpinv_is_payment_form_active', $is_active, $this); |
|
738 | 738 | } |
739 | 739 | |
740 | 740 | /** |
@@ -743,8 +743,8 @@ discard block |
||
743 | 743 | * @since 1.0.19 |
744 | 744 | * @return bool |
745 | 745 | */ |
746 | - public function has_item( $item_id ) { |
|
747 | - return false !== $this->get_item( $item_id ); |
|
746 | + public function has_item($item_id) { |
|
747 | + return false !== $this->get_item($item_id); |
|
748 | 748 | } |
749 | 749 | |
750 | 750 | /** |
@@ -753,8 +753,8 @@ discard block |
||
753 | 753 | * @since 1.0.19 |
754 | 754 | * @return bool |
755 | 755 | */ |
756 | - public function has_element_type( $element_type ) { |
|
757 | - return false !== $this->get_element_type( $element_type ); |
|
756 | + public function has_element_type($element_type) { |
|
757 | + return false !== $this->get_element_type($element_type); |
|
758 | 758 | } |
759 | 759 | |
760 | 760 | /** |
@@ -765,13 +765,13 @@ discard block |
||
765 | 765 | */ |
766 | 766 | public function is_recurring() { |
767 | 767 | |
768 | - if ( ! empty( $this->invoice ) ) { |
|
768 | + if (!empty($this->invoice)) { |
|
769 | 769 | return $this->invoice->is_recurring(); |
770 | 770 | } |
771 | 771 | |
772 | - foreach ( $this->get_items() as $item ) { |
|
772 | + foreach ($this->get_items() as $item) { |
|
773 | 773 | |
774 | - if ( $item->is_recurring() ) { |
|
774 | + if ($item->is_recurring()) { |
|
775 | 775 | return true; |
776 | 776 | } |
777 | 777 | |
@@ -785,7 +785,7 @@ discard block |
||
785 | 785 | * |
786 | 786 | * @since 1.0.19 |
787 | 787 | */ |
788 | - public function get_html( $extra_markup = '' ) { |
|
788 | + public function get_html($extra_markup = '') { |
|
789 | 789 | |
790 | 790 | // Return the HTML. |
791 | 791 | return wpinv_get_template_html( |
@@ -803,8 +803,8 @@ discard block |
||
803 | 803 | * |
804 | 804 | * @since 1.0.19 |
805 | 805 | */ |
806 | - public function display( $extra_markup = '' ) { |
|
807 | - echo $this->get_html( $extra_markup ); |
|
806 | + public function display($extra_markup = '') { |
|
807 | + echo $this->get_html($extra_markup); |
|
808 | 808 | } |
809 | 809 | |
810 | 810 | } |