@@ -12,180 +12,180 @@ discard block |
||
12 | 12 | */ |
13 | 13 | class GetPaid_Checkout { |
14 | 14 | |
15 | - /** |
|
16 | - * @var GetPaid_Payment_Form_Submission |
|
17 | - */ |
|
18 | - protected $payment_form_submission; |
|
19 | - |
|
20 | - /** |
|
21 | - * Class constructor. |
|
22 | - * |
|
23 | - * @param GetPaid_Payment_Form_Submission $submission |
|
24 | - */ |
|
25 | - public function __construct( $submission ) { |
|
26 | - $this->payment_form_submission = $submission; |
|
27 | - } |
|
28 | - |
|
29 | - /** |
|
30 | - * Processes the checkout. |
|
31 | - * |
|
32 | - */ |
|
33 | - public function process_checkout() { |
|
34 | - |
|
35 | - // Validate the submission. |
|
36 | - $this->validate_submission(); |
|
37 | - |
|
38 | - // Prepare the invoice. |
|
39 | - $items = $this->get_submission_items(); |
|
40 | - $invoice = $this->get_submission_invoice(); |
|
41 | - $invoice = $this->process_submission_invoice( $invoice, $items ); |
|
42 | - $prepared = $this->prepare_submission_data_for_saving(); |
|
43 | - |
|
44 | - $this->prepare_billing_info( $invoice ); |
|
45 | - |
|
46 | - $shipping = $this->prepare_shipping_info( $invoice ); |
|
47 | - |
|
48 | - // Save the invoice. |
|
49 | - $invoice->set_is_viewed( true ); |
|
50 | - $invoice->recalculate_total(); |
|
15 | + /** |
|
16 | + * @var GetPaid_Payment_Form_Submission |
|
17 | + */ |
|
18 | + protected $payment_form_submission; |
|
19 | + |
|
20 | + /** |
|
21 | + * Class constructor. |
|
22 | + * |
|
23 | + * @param GetPaid_Payment_Form_Submission $submission |
|
24 | + */ |
|
25 | + public function __construct( $submission ) { |
|
26 | + $this->payment_form_submission = $submission; |
|
27 | + } |
|
28 | + |
|
29 | + /** |
|
30 | + * Processes the checkout. |
|
31 | + * |
|
32 | + */ |
|
33 | + public function process_checkout() { |
|
34 | + |
|
35 | + // Validate the submission. |
|
36 | + $this->validate_submission(); |
|
37 | + |
|
38 | + // Prepare the invoice. |
|
39 | + $items = $this->get_submission_items(); |
|
40 | + $invoice = $this->get_submission_invoice(); |
|
41 | + $invoice = $this->process_submission_invoice( $invoice, $items ); |
|
42 | + $prepared = $this->prepare_submission_data_for_saving(); |
|
43 | + |
|
44 | + $this->prepare_billing_info( $invoice ); |
|
45 | + |
|
46 | + $shipping = $this->prepare_shipping_info( $invoice ); |
|
47 | + |
|
48 | + // Save the invoice. |
|
49 | + $invoice->set_is_viewed( true ); |
|
50 | + $invoice->recalculate_total(); |
|
51 | 51 | $invoice->save(); |
52 | 52 | |
53 | - do_action( 'getpaid_checkout_invoice_updated', $invoice ); |
|
53 | + do_action( 'getpaid_checkout_invoice_updated', $invoice ); |
|
54 | 54 | |
55 | - // Send to the gateway. |
|
56 | - $this->post_process_submission( $invoice, $prepared, $shipping ); |
|
57 | - } |
|
55 | + // Send to the gateway. |
|
56 | + $this->post_process_submission( $invoice, $prepared, $shipping ); |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * Validates the submission. |
|
61 | - * |
|
62 | - */ |
|
63 | - protected function validate_submission() { |
|
59 | + /** |
|
60 | + * Validates the submission. |
|
61 | + * |
|
62 | + */ |
|
63 | + protected function validate_submission() { |
|
64 | 64 | |
65 | - $submission = $this->payment_form_submission; |
|
66 | - $data = $submission->get_data(); |
|
65 | + $submission = $this->payment_form_submission; |
|
66 | + $data = $submission->get_data(); |
|
67 | 67 | |
68 | - // Do we have an error? |
|
68 | + // Do we have an error? |
|
69 | 69 | if ( ! empty( $submission->last_error ) ) { |
70 | - wp_send_json_error( $submission->last_error ); |
|
70 | + wp_send_json_error( $submission->last_error ); |
|
71 | 71 | } |
72 | 72 | |
73 | - // We need a billing email. |
|
73 | + // We need a billing email. |
|
74 | 74 | if ( ! $submission->has_billing_email() ) { |
75 | 75 | wp_send_json_error( __( 'Provide a valid billing email.', 'invoicing' ) ); |
76 | - } |
|
76 | + } |
|
77 | 77 | |
78 | - // Non-recurring gateways should not be allowed to process recurring invoices. |
|
79 | - if ( $submission->should_collect_payment_details() && $submission->has_recurring && ! wpinv_gateway_support_subscription( $data['wpi-gateway'] ) ) { |
|
80 | - wp_send_json_error( __( 'The selected payment gateway does not support subscription payments.', 'invoicing' ) ); |
|
81 | - } |
|
78 | + // Non-recurring gateways should not be allowed to process recurring invoices. |
|
79 | + if ( $submission->should_collect_payment_details() && $submission->has_recurring && ! wpinv_gateway_support_subscription( $data['wpi-gateway'] ) ) { |
|
80 | + wp_send_json_error( __( 'The selected payment gateway does not support subscription payments.', 'invoicing' ) ); |
|
81 | + } |
|
82 | 82 | |
83 | - // Ensure the gateway is active. |
|
84 | - if ( $submission->should_collect_payment_details() && ! wpinv_is_gateway_active( $data['wpi-gateway'] ) ) { |
|
85 | - wpinv_set_error( 'invalid_gateway', __( 'The selected payment gateway is not active', 'invoicing' ) ); |
|
86 | - } |
|
83 | + // Ensure the gateway is active. |
|
84 | + if ( $submission->should_collect_payment_details() && ! wpinv_is_gateway_active( $data['wpi-gateway'] ) ) { |
|
85 | + wpinv_set_error( 'invalid_gateway', __( 'The selected payment gateway is not active', 'invoicing' ) ); |
|
86 | + } |
|
87 | 87 | |
88 | - // Clear any existing errors. |
|
89 | - wpinv_clear_errors(); |
|
88 | + // Clear any existing errors. |
|
89 | + wpinv_clear_errors(); |
|
90 | 90 | |
91 | - // Allow themes and plugins to hook to errors |
|
92 | - do_action( 'getpaid_checkout_error_checks', $submission ); |
|
91 | + // Allow themes and plugins to hook to errors |
|
92 | + do_action( 'getpaid_checkout_error_checks', $submission ); |
|
93 | 93 | |
94 | - // Do we have any errors? |
|
94 | + // Do we have any errors? |
|
95 | 95 | if ( wpinv_get_errors() ) { |
96 | 96 | wp_send_json_error( getpaid_get_errors_html() ); |
97 | - } |
|
97 | + } |
|
98 | 98 | |
99 | - } |
|
99 | + } |
|
100 | 100 | |
101 | - /** |
|
102 | - * Retrieves submission items. |
|
103 | - * |
|
104 | - * @return GetPaid_Form_Item[] |
|
105 | - */ |
|
106 | - protected function get_submission_items() { |
|
101 | + /** |
|
102 | + * Retrieves submission items. |
|
103 | + * |
|
104 | + * @return GetPaid_Form_Item[] |
|
105 | + */ |
|
106 | + protected function get_submission_items() { |
|
107 | 107 | |
108 | - $items = $this->payment_form_submission->get_items(); |
|
108 | + $items = $this->payment_form_submission->get_items(); |
|
109 | 109 | |
110 | 110 | // Ensure that we have items. |
111 | 111 | if ( empty( $items ) && ! $this->payment_form_submission->has_fees() ) { |
112 | 112 | wp_send_json_error( __( 'Please provide at least one item or amount.', 'invoicing' ) ); |
113 | - } |
|
114 | - |
|
115 | - return $items; |
|
116 | - } |
|
117 | - |
|
118 | - /** |
|
119 | - * Retrieves submission invoice. |
|
120 | - * |
|
121 | - * @return WPInv_Invoice |
|
122 | - */ |
|
123 | - protected function get_submission_invoice() { |
|
124 | - $submission = $this->payment_form_submission; |
|
125 | - |
|
126 | - if ( ! $submission->has_invoice() ) { |
|
127 | - $invoice = new WPInv_Invoice(); |
|
128 | - $invoice->set_created_via( 'payment_form' ); |
|
129 | - return $invoice; |
|
130 | 113 | } |
131 | 114 | |
132 | - $invoice = $submission->get_invoice(); |
|
115 | + return $items; |
|
116 | + } |
|
133 | 117 | |
134 | - // Make sure that it is neither paid or refunded. |
|
135 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
136 | - wp_send_json_error( __( 'This invoice has already been paid for.', 'invoicing' ) ); |
|
137 | - } |
|
118 | + /** |
|
119 | + * Retrieves submission invoice. |
|
120 | + * |
|
121 | + * @return WPInv_Invoice |
|
122 | + */ |
|
123 | + protected function get_submission_invoice() { |
|
124 | + $submission = $this->payment_form_submission; |
|
138 | 125 | |
139 | - return $invoice; |
|
140 | - } |
|
126 | + if ( ! $submission->has_invoice() ) { |
|
127 | + $invoice = new WPInv_Invoice(); |
|
128 | + $invoice->set_created_via( 'payment_form' ); |
|
129 | + return $invoice; |
|
130 | + } |
|
141 | 131 | |
142 | - /** |
|
143 | - * Processes the submission invoice. |
|
144 | - * |
|
145 | - * @param WPInv_Invoice $invoice |
|
146 | - * @param GetPaid_Form_Item[] $items |
|
147 | - * @return WPInv_Invoice |
|
148 | - */ |
|
149 | - protected function process_submission_invoice( $invoice, $items ) { |
|
132 | + $invoice = $submission->get_invoice(); |
|
150 | 133 | |
151 | - $submission = $this->payment_form_submission; |
|
152 | - $data = $submission->get_data(); |
|
134 | + // Make sure that it is neither paid or refunded. |
|
135 | + if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
136 | + wp_send_json_error( __( 'This invoice has already been paid for.', 'invoicing' ) ); |
|
137 | + } |
|
153 | 138 | |
154 | - // Set-up the invoice details. |
|
155 | - $invoice->set_email( sanitize_email( $submission->get_billing_email() ) ); |
|
156 | - $invoice->set_user_id( $this->get_submission_customer() ); |
|
157 | - $invoice->set_payment_form( absint( $submission->get_payment_form()->get_id() ) ); |
|
139 | + return $invoice; |
|
140 | + } |
|
141 | + |
|
142 | + /** |
|
143 | + * Processes the submission invoice. |
|
144 | + * |
|
145 | + * @param WPInv_Invoice $invoice |
|
146 | + * @param GetPaid_Form_Item[] $items |
|
147 | + * @return WPInv_Invoice |
|
148 | + */ |
|
149 | + protected function process_submission_invoice( $invoice, $items ) { |
|
150 | + |
|
151 | + $submission = $this->payment_form_submission; |
|
152 | + $data = $submission->get_data(); |
|
153 | + |
|
154 | + // Set-up the invoice details. |
|
155 | + $invoice->set_email( sanitize_email( $submission->get_billing_email() ) ); |
|
156 | + $invoice->set_user_id( $this->get_submission_customer() ); |
|
157 | + $invoice->set_payment_form( absint( $submission->get_payment_form()->get_id() ) ); |
|
158 | 158 | $invoice->set_items( $items ); |
159 | 159 | $invoice->set_fees( $submission->get_fees() ); |
160 | 160 | $invoice->set_taxes( $submission->get_taxes() ); |
161 | - $invoice->set_discounts( $submission->get_discounts() ); |
|
162 | - $invoice->set_gateway( $data['wpi-gateway'] ); |
|
161 | + $invoice->set_discounts( $submission->get_discounts() ); |
|
162 | + $invoice->set_gateway( $data['wpi-gateway'] ); |
|
163 | 163 | |
164 | - $address_confirmed = $submission->get_field( 'confirm-address' ); |
|
165 | - $invoice->set_address_confirmed( ! empty( $address_confirmed ) ); |
|
164 | + $address_confirmed = $submission->get_field( 'confirm-address' ); |
|
165 | + $invoice->set_address_confirmed( ! empty( $address_confirmed ) ); |
|
166 | 166 | |
167 | - if ( $submission->has_discount_code() ) { |
|
167 | + if ( $submission->has_discount_code() ) { |
|
168 | 168 | $invoice->set_discount_code( $submission->get_discount_code() ); |
169 | - } |
|
170 | - |
|
171 | - getpaid_maybe_add_default_address( $invoice ); |
|
172 | - return $invoice; |
|
173 | - } |
|
174 | - |
|
175 | - /** |
|
176 | - * Retrieves the submission's customer. |
|
177 | - * |
|
178 | - * @return int The customer id. |
|
179 | - */ |
|
180 | - protected function get_submission_customer() { |
|
181 | - $submission = $this->payment_form_submission; |
|
182 | - |
|
183 | - // If this is an existing invoice... |
|
184 | - if ( $submission->has_invoice() ) { |
|
185 | - return $submission->get_invoice()->get_user_id(); |
|
186 | - } |
|
187 | - |
|
188 | - // (Maybe) create the user. |
|
169 | + } |
|
170 | + |
|
171 | + getpaid_maybe_add_default_address( $invoice ); |
|
172 | + return $invoice; |
|
173 | + } |
|
174 | + |
|
175 | + /** |
|
176 | + * Retrieves the submission's customer. |
|
177 | + * |
|
178 | + * @return int The customer id. |
|
179 | + */ |
|
180 | + protected function get_submission_customer() { |
|
181 | + $submission = $this->payment_form_submission; |
|
182 | + |
|
183 | + // If this is an existing invoice... |
|
184 | + if ( $submission->has_invoice() ) { |
|
185 | + return $submission->get_invoice()->get_user_id(); |
|
186 | + } |
|
187 | + |
|
188 | + // (Maybe) create the user. |
|
189 | 189 | $user = get_current_user_id(); |
190 | 190 | |
191 | 191 | if ( empty( $user ) ) { |
@@ -195,11 +195,11 @@ discard block |
||
195 | 195 | if ( empty( $user ) ) { |
196 | 196 | $user = wpinv_create_user( $submission->get_billing_email() ); |
197 | 197 | |
198 | - // (Maybe) send new user notification. |
|
199 | - $should_send_notification = wpinv_get_option( 'disable_new_user_emails' ); |
|
200 | - if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ) ) ) { |
|
201 | - wp_send_new_user_notifications( $user, 'user' ); |
|
202 | - } |
|
198 | + // (Maybe) send new user notification. |
|
199 | + $should_send_notification = wpinv_get_option( 'disable_new_user_emails' ); |
|
200 | + if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ) ) ) { |
|
201 | + wp_send_new_user_notifications( $user, 'user' ); |
|
202 | + } |
|
203 | 203 | |
204 | 204 | } |
205 | 205 | |
@@ -209,31 +209,31 @@ discard block |
||
209 | 209 | |
210 | 210 | if ( is_numeric( $user ) ) { |
211 | 211 | return $user; |
212 | - } |
|
212 | + } |
|
213 | 213 | |
214 | - return $user->ID; |
|
214 | + return $user->ID; |
|
215 | 215 | |
216 | - } |
|
216 | + } |
|
217 | 217 | |
218 | - /** |
|
218 | + /** |
|
219 | 219 | * Prepares submission data for saving to the database. |
220 | 220 | * |
221 | - * @return array |
|
221 | + * @return array |
|
222 | 222 | */ |
223 | 223 | public function prepare_submission_data_for_saving() { |
224 | 224 | |
225 | - $submission = $this->payment_form_submission; |
|
225 | + $submission = $this->payment_form_submission; |
|
226 | 226 | |
227 | - // Prepared submission details. |
|
227 | + // Prepared submission details. |
|
228 | 228 | $prepared = array(); |
229 | 229 | |
230 | 230 | // Raw submission details. |
231 | - $data = $submission->get_data(); |
|
231 | + $data = $submission->get_data(); |
|
232 | 232 | |
233 | - // Loop through the submitted details. |
|
233 | + // Loop through the submitted details. |
|
234 | 234 | foreach ( $submission->get_payment_form()->get_elements() as $field ) { |
235 | 235 | |
236 | - // Skip premade fields. |
|
236 | + // Skip premade fields. |
|
237 | 237 | if ( ! empty( $field['premade'] ) || $field['type'] == 'address' ) { |
238 | 238 | continue; |
239 | 239 | } |
@@ -251,176 +251,176 @@ discard block |
||
251 | 251 | $label = $field['label']; |
252 | 252 | } |
253 | 253 | |
254 | - $prepared[ wpinv_clean( $label ) ] = wp_kses_post( $data[ $field['id'] ] ); |
|
254 | + $prepared[ wpinv_clean( $label ) ] = wp_kses_post( $data[ $field['id'] ] ); |
|
255 | 255 | |
256 | 256 | } |
257 | 257 | |
258 | - } |
|
258 | + } |
|
259 | 259 | |
260 | - return $prepared; |
|
260 | + return $prepared; |
|
261 | 261 | |
262 | - } |
|
262 | + } |
|
263 | 263 | |
264 | - /** |
|
264 | + /** |
|
265 | 265 | * Retrieves address details. |
266 | 266 | * |
267 | - * @return array |
|
268 | - * @param WPInv_Invoice $invoice |
|
269 | - * @param string $type |
|
267 | + * @return array |
|
268 | + * @param WPInv_Invoice $invoice |
|
269 | + * @param string $type |
|
270 | 270 | */ |
271 | 271 | public function prepare_address_details( $invoice, $type = 'billing' ) { |
272 | 272 | |
273 | - $data = $this->payment_form_submission->get_data(); |
|
274 | - $type = sanitize_key( $type ); |
|
275 | - $address = array(); |
|
276 | - $prepared = array(); |
|
273 | + $data = $this->payment_form_submission->get_data(); |
|
274 | + $type = sanitize_key( $type ); |
|
275 | + $address = array(); |
|
276 | + $prepared = array(); |
|
277 | 277 | |
278 | - if ( ! empty( $data[ $type ] ) ) { |
|
279 | - $address = $data[ $type ]; |
|
280 | - } |
|
278 | + if ( ! empty( $data[ $type ] ) ) { |
|
279 | + $address = $data[ $type ]; |
|
280 | + } |
|
281 | 281 | |
282 | - // Clean address details. |
|
283 | - foreach ( $address as $key => $value ) { |
|
284 | - $key = sanitize_key( $key ); |
|
285 | - $key = str_replace( 'wpinv_', '', $key ); |
|
286 | - $value = wpinv_clean( $value ); |
|
287 | - $prepared[ $key] = apply_filters( "getpaid_checkout_{$type}_address_$key", $value, $this->payment_form_submission, $invoice ); |
|
288 | - } |
|
282 | + // Clean address details. |
|
283 | + foreach ( $address as $key => $value ) { |
|
284 | + $key = sanitize_key( $key ); |
|
285 | + $key = str_replace( 'wpinv_', '', $key ); |
|
286 | + $value = wpinv_clean( $value ); |
|
287 | + $prepared[ $key] = apply_filters( "getpaid_checkout_{$type}_address_$key", $value, $this->payment_form_submission, $invoice ); |
|
288 | + } |
|
289 | 289 | |
290 | - // Filter address details. |
|
291 | - $prepared = apply_filters( "getpaid_checkout_{$type}_address", $prepared, $this->payment_form_submission, $invoice ); |
|
290 | + // Filter address details. |
|
291 | + $prepared = apply_filters( "getpaid_checkout_{$type}_address", $prepared, $this->payment_form_submission, $invoice ); |
|
292 | 292 | |
293 | - // Remove non-whitelisted values. |
|
294 | - return array_filter( $prepared, 'getpaid_is_address_field_whitelisted', ARRAY_FILTER_USE_KEY ); |
|
293 | + // Remove non-whitelisted values. |
|
294 | + return array_filter( $prepared, 'getpaid_is_address_field_whitelisted', ARRAY_FILTER_USE_KEY ); |
|
295 | 295 | |
296 | - } |
|
296 | + } |
|
297 | 297 | |
298 | - /** |
|
298 | + /** |
|
299 | 299 | * Prepares the billing details. |
300 | 300 | * |
301 | - * @return array |
|
302 | - * @param WPInv_Invoice $invoice |
|
301 | + * @return array |
|
302 | + * @param WPInv_Invoice $invoice |
|
303 | 303 | */ |
304 | 304 | protected function prepare_billing_info( &$invoice ) { |
305 | 305 | |
306 | - $billing_address = $this->prepare_address_details( $invoice, 'billing' ); |
|
306 | + $billing_address = $this->prepare_address_details( $invoice, 'billing' ); |
|
307 | 307 | |
308 | - // Update the invoice with the billing details. |
|
309 | - $invoice->set_props( $billing_address ); |
|
308 | + // Update the invoice with the billing details. |
|
309 | + $invoice->set_props( $billing_address ); |
|
310 | 310 | |
311 | - } |
|
311 | + } |
|
312 | 312 | |
313 | - /** |
|
313 | + /** |
|
314 | 314 | * Prepares the shipping details. |
315 | 315 | * |
316 | - * @return array |
|
317 | - * @param WPInv_Invoice $invoice |
|
316 | + * @return array |
|
317 | + * @param WPInv_Invoice $invoice |
|
318 | 318 | */ |
319 | 319 | protected function prepare_shipping_info( $invoice ) { |
320 | 320 | |
321 | - $data = $this->payment_form_submission->get_data(); |
|
321 | + $data = $this->payment_form_submission->get_data(); |
|
322 | 322 | |
323 | - if ( empty( $data['same-shipping-address'] ) ) { |
|
324 | - return $this->prepare_address_details( $invoice, 'shipping' ); |
|
325 | - } |
|
323 | + if ( empty( $data['same-shipping-address'] ) ) { |
|
324 | + return $this->prepare_address_details( $invoice, 'shipping' ); |
|
325 | + } |
|
326 | 326 | |
327 | - return $this->prepare_address_details( $invoice, 'billing' ); |
|
327 | + return $this->prepare_address_details( $invoice, 'billing' ); |
|
328 | 328 | |
329 | - } |
|
329 | + } |
|
330 | 330 | |
331 | - /** |
|
332 | - * Confirms the submission is valid and send users to the gateway. |
|
333 | - * |
|
334 | - * @param WPInv_Invoice $invoice |
|
335 | - * @param array $prepared_payment_form_data |
|
336 | - * @param array $shipping |
|
337 | - */ |
|
338 | - protected function post_process_submission( $invoice, $prepared_payment_form_data, $shipping ) { |
|
331 | + /** |
|
332 | + * Confirms the submission is valid and send users to the gateway. |
|
333 | + * |
|
334 | + * @param WPInv_Invoice $invoice |
|
335 | + * @param array $prepared_payment_form_data |
|
336 | + * @param array $shipping |
|
337 | + */ |
|
338 | + protected function post_process_submission( $invoice, $prepared_payment_form_data, $shipping ) { |
|
339 | 339 | |
340 | - // Ensure the invoice exists. |
|
340 | + // Ensure the invoice exists. |
|
341 | 341 | if ( ! $invoice->exists() ) { |
342 | 342 | wp_send_json_error( __( 'An error occured while saving your invoice. Please try again.', 'invoicing' ) ); |
343 | 343 | } |
344 | 344 | |
345 | - // Save payment form data. |
|
346 | - $prepared_payment_form_data = apply_filters( 'getpaid_prepared_payment_form_data', $prepared_payment_form_data, $invoice ); |
|
345 | + // Save payment form data. |
|
346 | + $prepared_payment_form_data = apply_filters( 'getpaid_prepared_payment_form_data', $prepared_payment_form_data, $invoice ); |
|
347 | 347 | if ( ! empty( $prepared_payment_form_data ) ) { |
348 | 348 | update_post_meta( $invoice->get_id(), 'payment_form_data', $prepared_payment_form_data ); |
349 | - } |
|
349 | + } |
|
350 | 350 | |
351 | - // Save payment form data. |
|
351 | + // Save payment form data. |
|
352 | 352 | if ( ! empty( $shipping ) ) { |
353 | 353 | update_post_meta( $invoice->get_id(), 'shipping_address', $shipping ); |
354 | - } |
|
354 | + } |
|
355 | 355 | |
356 | - // Backwards compatibility. |
|
356 | + // Backwards compatibility. |
|
357 | 357 | add_filter( 'wp_redirect', array( $this, 'send_redirect_response' ) ); |
358 | 358 | |
359 | - $this->process_payment( $invoice ); |
|
359 | + $this->process_payment( $invoice ); |
|
360 | 360 | |
361 | 361 | // If we are here, there was an error. |
362 | - wpinv_send_back_to_checkout( $invoice ); |
|
362 | + wpinv_send_back_to_checkout( $invoice ); |
|
363 | 363 | |
364 | - } |
|
364 | + } |
|
365 | 365 | |
366 | - /** |
|
367 | - * Processes the actual payment. |
|
368 | - * |
|
369 | - * @param WPInv_Invoice $invoice |
|
370 | - */ |
|
371 | - protected function process_payment( $invoice ) { |
|
366 | + /** |
|
367 | + * Processes the actual payment. |
|
368 | + * |
|
369 | + * @param WPInv_Invoice $invoice |
|
370 | + */ |
|
371 | + protected function process_payment( $invoice ) { |
|
372 | 372 | |
373 | - // Clear any checkout errors. |
|
374 | - wpinv_clear_errors(); |
|
373 | + // Clear any checkout errors. |
|
374 | + wpinv_clear_errors(); |
|
375 | 375 | |
376 | - // No need to send free invoices to the gateway. |
|
377 | - if ( $invoice->is_free() ) { |
|
378 | - $this->process_free_payment( $invoice ); |
|
379 | - } |
|
376 | + // No need to send free invoices to the gateway. |
|
377 | + if ( $invoice->is_free() ) { |
|
378 | + $this->process_free_payment( $invoice ); |
|
379 | + } |
|
380 | 380 | |
381 | - $submission = $this->payment_form_submission; |
|
381 | + $submission = $this->payment_form_submission; |
|
382 | 382 | |
383 | - // Fires before sending to the gateway. |
|
384 | - do_action( 'getpaid_checkout_before_gateway', $invoice, $submission ); |
|
383 | + // Fires before sending to the gateway. |
|
384 | + do_action( 'getpaid_checkout_before_gateway', $invoice, $submission ); |
|
385 | 385 | |
386 | - // Allow the sumission data to be modified before it is sent to the gateway. |
|
387 | - $submission_data = $submission->get_data(); |
|
388 | - $submission_gateway = apply_filters( 'getpaid_gateway_submission_gateway', $invoice->get_gateway(), $submission, $invoice ); |
|
389 | - $submission_data = apply_filters( 'getpaid_gateway_submission_data', $submission_data, $submission, $invoice ); |
|
386 | + // Allow the sumission data to be modified before it is sent to the gateway. |
|
387 | + $submission_data = $submission->get_data(); |
|
388 | + $submission_gateway = apply_filters( 'getpaid_gateway_submission_gateway', $invoice->get_gateway(), $submission, $invoice ); |
|
389 | + $submission_data = apply_filters( 'getpaid_gateway_submission_data', $submission_data, $submission, $invoice ); |
|
390 | 390 | |
391 | - // Validate the currency. |
|
392 | - if ( ! apply_filters( "getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency() ) ) { |
|
393 | - wpinv_set_error( 'invalid_currency', __( 'The chosen payment gateway does not support this currency', 'invoicing' ) ); |
|
394 | - } |
|
391 | + // Validate the currency. |
|
392 | + if ( ! apply_filters( "getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency() ) ) { |
|
393 | + wpinv_set_error( 'invalid_currency', __( 'The chosen payment gateway does not support this currency', 'invoicing' ) ); |
|
394 | + } |
|
395 | 395 | |
396 | - // Check to see if we have any errors. |
|
397 | - if ( wpinv_get_errors() ) { |
|
398 | - wpinv_send_back_to_checkout( $invoice ); |
|
399 | - } |
|
396 | + // Check to see if we have any errors. |
|
397 | + if ( wpinv_get_errors() ) { |
|
398 | + wpinv_send_back_to_checkout( $invoice ); |
|
399 | + } |
|
400 | 400 | |
401 | - // Send info to the gateway for payment processing |
|
402 | - do_action( "getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission ); |
|
401 | + // Send info to the gateway for payment processing |
|
402 | + do_action( "getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission ); |
|
403 | 403 | |
404 | - // Backwards compatibility. |
|
405 | - wpinv_send_to_gateway( $submission_gateway, $invoice ); |
|
404 | + // Backwards compatibility. |
|
405 | + wpinv_send_to_gateway( $submission_gateway, $invoice ); |
|
406 | 406 | |
407 | - } |
|
407 | + } |
|
408 | 408 | |
409 | - /** |
|
410 | - * Marks the invoice as paid in case the checkout is free. |
|
411 | - * |
|
412 | - * @param WPInv_Invoice $invoice |
|
413 | - */ |
|
414 | - protected function process_free_payment( $invoice ) { |
|
409 | + /** |
|
410 | + * Marks the invoice as paid in case the checkout is free. |
|
411 | + * |
|
412 | + * @param WPInv_Invoice $invoice |
|
413 | + */ |
|
414 | + protected function process_free_payment( $invoice ) { |
|
415 | 415 | |
416 | - $invoice->set_gateway( 'none' ); |
|
417 | - $invoice->add_note( __( "This is a free invoice and won't be sent to the payment gateway", 'invoicing' ), false, false, true ); |
|
418 | - $invoice->mark_paid(); |
|
419 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
416 | + $invoice->set_gateway( 'none' ); |
|
417 | + $invoice->add_note( __( "This is a free invoice and won't be sent to the payment gateway", 'invoicing' ), false, false, true ); |
|
418 | + $invoice->mark_paid(); |
|
419 | + wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
420 | 420 | |
421 | - } |
|
421 | + } |
|
422 | 422 | |
423 | - /** |
|
423 | + /** |
|
424 | 424 | * Sends a redrect response to payment details. |
425 | 425 | * |
426 | 426 | */ |
@@ -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 | * Main Checkout Class. |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @param GetPaid_Payment_Form_Submission $submission |
24 | 24 | */ |
25 | - public function __construct( $submission ) { |
|
25 | + public function __construct($submission) { |
|
26 | 26 | $this->payment_form_submission = $submission; |
27 | 27 | } |
28 | 28 | |
@@ -38,22 +38,22 @@ discard block |
||
38 | 38 | // Prepare the invoice. |
39 | 39 | $items = $this->get_submission_items(); |
40 | 40 | $invoice = $this->get_submission_invoice(); |
41 | - $invoice = $this->process_submission_invoice( $invoice, $items ); |
|
41 | + $invoice = $this->process_submission_invoice($invoice, $items); |
|
42 | 42 | $prepared = $this->prepare_submission_data_for_saving(); |
43 | 43 | |
44 | - $this->prepare_billing_info( $invoice ); |
|
44 | + $this->prepare_billing_info($invoice); |
|
45 | 45 | |
46 | - $shipping = $this->prepare_shipping_info( $invoice ); |
|
46 | + $shipping = $this->prepare_shipping_info($invoice); |
|
47 | 47 | |
48 | 48 | // Save the invoice. |
49 | - $invoice->set_is_viewed( true ); |
|
49 | + $invoice->set_is_viewed(true); |
|
50 | 50 | $invoice->recalculate_total(); |
51 | 51 | $invoice->save(); |
52 | 52 | |
53 | - do_action( 'getpaid_checkout_invoice_updated', $invoice ); |
|
53 | + do_action('getpaid_checkout_invoice_updated', $invoice); |
|
54 | 54 | |
55 | 55 | // Send to the gateway. |
56 | - $this->post_process_submission( $invoice, $prepared, $shipping ); |
|
56 | + $this->post_process_submission($invoice, $prepared, $shipping); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -66,34 +66,34 @@ discard block |
||
66 | 66 | $data = $submission->get_data(); |
67 | 67 | |
68 | 68 | // Do we have an error? |
69 | - if ( ! empty( $submission->last_error ) ) { |
|
70 | - wp_send_json_error( $submission->last_error ); |
|
69 | + if (!empty($submission->last_error)) { |
|
70 | + wp_send_json_error($submission->last_error); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | // We need a billing email. |
74 | - if ( ! $submission->has_billing_email() ) { |
|
75 | - wp_send_json_error( __( 'Provide a valid billing email.', 'invoicing' ) ); |
|
74 | + if (!$submission->has_billing_email()) { |
|
75 | + wp_send_json_error(__('Provide a valid billing email.', 'invoicing')); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | // Non-recurring gateways should not be allowed to process recurring invoices. |
79 | - if ( $submission->should_collect_payment_details() && $submission->has_recurring && ! wpinv_gateway_support_subscription( $data['wpi-gateway'] ) ) { |
|
80 | - wp_send_json_error( __( 'The selected payment gateway does not support subscription payments.', 'invoicing' ) ); |
|
79 | + if ($submission->should_collect_payment_details() && $submission->has_recurring && !wpinv_gateway_support_subscription($data['wpi-gateway'])) { |
|
80 | + wp_send_json_error(__('The selected payment gateway does not support subscription payments.', 'invoicing')); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | // Ensure the gateway is active. |
84 | - if ( $submission->should_collect_payment_details() && ! wpinv_is_gateway_active( $data['wpi-gateway'] ) ) { |
|
85 | - wpinv_set_error( 'invalid_gateway', __( 'The selected payment gateway is not active', 'invoicing' ) ); |
|
84 | + if ($submission->should_collect_payment_details() && !wpinv_is_gateway_active($data['wpi-gateway'])) { |
|
85 | + wpinv_set_error('invalid_gateway', __('The selected payment gateway is not active', 'invoicing')); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | // Clear any existing errors. |
89 | 89 | wpinv_clear_errors(); |
90 | 90 | |
91 | 91 | // Allow themes and plugins to hook to errors |
92 | - do_action( 'getpaid_checkout_error_checks', $submission ); |
|
92 | + do_action('getpaid_checkout_error_checks', $submission); |
|
93 | 93 | |
94 | 94 | // Do we have any errors? |
95 | - if ( wpinv_get_errors() ) { |
|
96 | - wp_send_json_error( getpaid_get_errors_html() ); |
|
95 | + if (wpinv_get_errors()) { |
|
96 | + wp_send_json_error(getpaid_get_errors_html()); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | } |
@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | $items = $this->payment_form_submission->get_items(); |
109 | 109 | |
110 | 110 | // Ensure that we have items. |
111 | - if ( empty( $items ) && ! $this->payment_form_submission->has_fees() ) { |
|
112 | - wp_send_json_error( __( 'Please provide at least one item or amount.', 'invoicing' ) ); |
|
111 | + if (empty($items) && !$this->payment_form_submission->has_fees()) { |
|
112 | + wp_send_json_error(__('Please provide at least one item or amount.', 'invoicing')); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | return $items; |
@@ -123,17 +123,17 @@ discard block |
||
123 | 123 | protected function get_submission_invoice() { |
124 | 124 | $submission = $this->payment_form_submission; |
125 | 125 | |
126 | - if ( ! $submission->has_invoice() ) { |
|
126 | + if (!$submission->has_invoice()) { |
|
127 | 127 | $invoice = new WPInv_Invoice(); |
128 | - $invoice->set_created_via( 'payment_form' ); |
|
128 | + $invoice->set_created_via('payment_form'); |
|
129 | 129 | return $invoice; |
130 | 130 | } |
131 | 131 | |
132 | 132 | $invoice = $submission->get_invoice(); |
133 | 133 | |
134 | 134 | // Make sure that it is neither paid or refunded. |
135 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
136 | - wp_send_json_error( __( 'This invoice has already been paid for.', 'invoicing' ) ); |
|
135 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
136 | + wp_send_json_error(__('This invoice has already been paid for.', 'invoicing')); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | return $invoice; |
@@ -146,29 +146,29 @@ discard block |
||
146 | 146 | * @param GetPaid_Form_Item[] $items |
147 | 147 | * @return WPInv_Invoice |
148 | 148 | */ |
149 | - protected function process_submission_invoice( $invoice, $items ) { |
|
149 | + protected function process_submission_invoice($invoice, $items) { |
|
150 | 150 | |
151 | 151 | $submission = $this->payment_form_submission; |
152 | 152 | $data = $submission->get_data(); |
153 | 153 | |
154 | 154 | // Set-up the invoice details. |
155 | - $invoice->set_email( sanitize_email( $submission->get_billing_email() ) ); |
|
156 | - $invoice->set_user_id( $this->get_submission_customer() ); |
|
157 | - $invoice->set_payment_form( absint( $submission->get_payment_form()->get_id() ) ); |
|
158 | - $invoice->set_items( $items ); |
|
159 | - $invoice->set_fees( $submission->get_fees() ); |
|
160 | - $invoice->set_taxes( $submission->get_taxes() ); |
|
161 | - $invoice->set_discounts( $submission->get_discounts() ); |
|
162 | - $invoice->set_gateway( $data['wpi-gateway'] ); |
|
163 | - |
|
164 | - $address_confirmed = $submission->get_field( 'confirm-address' ); |
|
165 | - $invoice->set_address_confirmed( ! empty( $address_confirmed ) ); |
|
166 | - |
|
167 | - if ( $submission->has_discount_code() ) { |
|
168 | - $invoice->set_discount_code( $submission->get_discount_code() ); |
|
155 | + $invoice->set_email(sanitize_email($submission->get_billing_email())); |
|
156 | + $invoice->set_user_id($this->get_submission_customer()); |
|
157 | + $invoice->set_payment_form(absint($submission->get_payment_form()->get_id())); |
|
158 | + $invoice->set_items($items); |
|
159 | + $invoice->set_fees($submission->get_fees()); |
|
160 | + $invoice->set_taxes($submission->get_taxes()); |
|
161 | + $invoice->set_discounts($submission->get_discounts()); |
|
162 | + $invoice->set_gateway($data['wpi-gateway']); |
|
163 | + |
|
164 | + $address_confirmed = $submission->get_field('confirm-address'); |
|
165 | + $invoice->set_address_confirmed(!empty($address_confirmed)); |
|
166 | + |
|
167 | + if ($submission->has_discount_code()) { |
|
168 | + $invoice->set_discount_code($submission->get_discount_code()); |
|
169 | 169 | } |
170 | 170 | |
171 | - getpaid_maybe_add_default_address( $invoice ); |
|
171 | + getpaid_maybe_add_default_address($invoice); |
|
172 | 172 | return $invoice; |
173 | 173 | } |
174 | 174 | |
@@ -181,33 +181,33 @@ discard block |
||
181 | 181 | $submission = $this->payment_form_submission; |
182 | 182 | |
183 | 183 | // If this is an existing invoice... |
184 | - if ( $submission->has_invoice() ) { |
|
184 | + if ($submission->has_invoice()) { |
|
185 | 185 | return $submission->get_invoice()->get_user_id(); |
186 | 186 | } |
187 | 187 | |
188 | 188 | // (Maybe) create the user. |
189 | 189 | $user = get_current_user_id(); |
190 | 190 | |
191 | - if ( empty( $user ) ) { |
|
192 | - $user = get_user_by( 'email', $submission->get_billing_email() ); |
|
191 | + if (empty($user)) { |
|
192 | + $user = get_user_by('email', $submission->get_billing_email()); |
|
193 | 193 | } |
194 | 194 | |
195 | - if ( empty( $user ) ) { |
|
196 | - $user = wpinv_create_user( $submission->get_billing_email() ); |
|
195 | + if (empty($user)) { |
|
196 | + $user = wpinv_create_user($submission->get_billing_email()); |
|
197 | 197 | |
198 | 198 | // (Maybe) send new user notification. |
199 | - $should_send_notification = wpinv_get_option( 'disable_new_user_emails' ); |
|
200 | - if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ) ) ) { |
|
201 | - wp_send_new_user_notifications( $user, 'user' ); |
|
199 | + $should_send_notification = wpinv_get_option('disable_new_user_emails'); |
|
200 | + if (!empty($user) && is_numeric($user) && apply_filters('getpaid_send_new_user_notification', empty($should_send_notification))) { |
|
201 | + wp_send_new_user_notifications($user, 'user'); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | } |
205 | 205 | |
206 | - if ( is_wp_error( $user ) ) { |
|
207 | - wp_send_json_error( $user->get_error_message() ); |
|
206 | + if (is_wp_error($user)) { |
|
207 | + wp_send_json_error($user->get_error_message()); |
|
208 | 208 | } |
209 | 209 | |
210 | - if ( is_numeric( $user ) ) { |
|
210 | + if (is_numeric($user)) { |
|
211 | 211 | return $user; |
212 | 212 | } |
213 | 213 | |
@@ -228,30 +228,30 @@ discard block |
||
228 | 228 | $prepared = array(); |
229 | 229 | |
230 | 230 | // Raw submission details. |
231 | - $data = $submission->get_data(); |
|
231 | + $data = $submission->get_data(); |
|
232 | 232 | |
233 | 233 | // Loop through the submitted details. |
234 | - foreach ( $submission->get_payment_form()->get_elements() as $field ) { |
|
234 | + foreach ($submission->get_payment_form()->get_elements() as $field) { |
|
235 | 235 | |
236 | 236 | // Skip premade fields. |
237 | - if ( ! empty( $field['premade'] ) || $field['type'] == 'address' ) { |
|
237 | + if (!empty($field['premade']) || $field['type'] == 'address') { |
|
238 | 238 | continue; |
239 | 239 | } |
240 | 240 | |
241 | 241 | // If it is required and not set, abort. |
242 | - if ( ! $submission->is_required_field_set( $field ) ) { |
|
243 | - wp_send_json_error( __( 'Please fill all required fields.', 'invoicing' ) ); |
|
242 | + if (!$submission->is_required_field_set($field)) { |
|
243 | + wp_send_json_error(__('Please fill all required fields.', 'invoicing')); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | // Handle misc fields. |
247 | - if ( isset( $data[ $field['id'] ] ) ) { |
|
247 | + if (isset($data[$field['id']])) { |
|
248 | 248 | $label = $field['id']; |
249 | 249 | |
250 | - if ( isset( $field['label'] ) ) { |
|
250 | + if (isset($field['label'])) { |
|
251 | 251 | $label = $field['label']; |
252 | 252 | } |
253 | 253 | |
254 | - $prepared[ wpinv_clean( $label ) ] = wp_kses_post( $data[ $field['id'] ] ); |
|
254 | + $prepared[wpinv_clean($label)] = wp_kses_post($data[$field['id']]); |
|
255 | 255 | |
256 | 256 | } |
257 | 257 | |
@@ -268,30 +268,30 @@ discard block |
||
268 | 268 | * @param WPInv_Invoice $invoice |
269 | 269 | * @param string $type |
270 | 270 | */ |
271 | - public function prepare_address_details( $invoice, $type = 'billing' ) { |
|
271 | + public function prepare_address_details($invoice, $type = 'billing') { |
|
272 | 272 | |
273 | 273 | $data = $this->payment_form_submission->get_data(); |
274 | - $type = sanitize_key( $type ); |
|
274 | + $type = sanitize_key($type); |
|
275 | 275 | $address = array(); |
276 | 276 | $prepared = array(); |
277 | 277 | |
278 | - if ( ! empty( $data[ $type ] ) ) { |
|
279 | - $address = $data[ $type ]; |
|
278 | + if (!empty($data[$type])) { |
|
279 | + $address = $data[$type]; |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | // Clean address details. |
283 | - foreach ( $address as $key => $value ) { |
|
284 | - $key = sanitize_key( $key ); |
|
285 | - $key = str_replace( 'wpinv_', '', $key ); |
|
286 | - $value = wpinv_clean( $value ); |
|
287 | - $prepared[ $key] = apply_filters( "getpaid_checkout_{$type}_address_$key", $value, $this->payment_form_submission, $invoice ); |
|
283 | + foreach ($address as $key => $value) { |
|
284 | + $key = sanitize_key($key); |
|
285 | + $key = str_replace('wpinv_', '', $key); |
|
286 | + $value = wpinv_clean($value); |
|
287 | + $prepared[$key] = apply_filters("getpaid_checkout_{$type}_address_$key", $value, $this->payment_form_submission, $invoice); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | // Filter address details. |
291 | - $prepared = apply_filters( "getpaid_checkout_{$type}_address", $prepared, $this->payment_form_submission, $invoice ); |
|
291 | + $prepared = apply_filters("getpaid_checkout_{$type}_address", $prepared, $this->payment_form_submission, $invoice); |
|
292 | 292 | |
293 | 293 | // Remove non-whitelisted values. |
294 | - return array_filter( $prepared, 'getpaid_is_address_field_whitelisted', ARRAY_FILTER_USE_KEY ); |
|
294 | + return array_filter($prepared, 'getpaid_is_address_field_whitelisted', ARRAY_FILTER_USE_KEY); |
|
295 | 295 | |
296 | 296 | } |
297 | 297 | |
@@ -301,12 +301,12 @@ discard block |
||
301 | 301 | * @return array |
302 | 302 | * @param WPInv_Invoice $invoice |
303 | 303 | */ |
304 | - protected function prepare_billing_info( &$invoice ) { |
|
304 | + protected function prepare_billing_info(&$invoice) { |
|
305 | 305 | |
306 | - $billing_address = $this->prepare_address_details( $invoice, 'billing' ); |
|
306 | + $billing_address = $this->prepare_address_details($invoice, 'billing'); |
|
307 | 307 | |
308 | 308 | // Update the invoice with the billing details. |
309 | - $invoice->set_props( $billing_address ); |
|
309 | + $invoice->set_props($billing_address); |
|
310 | 310 | |
311 | 311 | } |
312 | 312 | |
@@ -316,15 +316,15 @@ discard block |
||
316 | 316 | * @return array |
317 | 317 | * @param WPInv_Invoice $invoice |
318 | 318 | */ |
319 | - protected function prepare_shipping_info( $invoice ) { |
|
319 | + protected function prepare_shipping_info($invoice) { |
|
320 | 320 | |
321 | 321 | $data = $this->payment_form_submission->get_data(); |
322 | 322 | |
323 | - if ( empty( $data['same-shipping-address'] ) ) { |
|
324 | - return $this->prepare_address_details( $invoice, 'shipping' ); |
|
323 | + if (empty($data['same-shipping-address'])) { |
|
324 | + return $this->prepare_address_details($invoice, 'shipping'); |
|
325 | 325 | } |
326 | 326 | |
327 | - return $this->prepare_address_details( $invoice, 'billing' ); |
|
327 | + return $this->prepare_address_details($invoice, 'billing'); |
|
328 | 328 | |
329 | 329 | } |
330 | 330 | |
@@ -335,31 +335,31 @@ discard block |
||
335 | 335 | * @param array $prepared_payment_form_data |
336 | 336 | * @param array $shipping |
337 | 337 | */ |
338 | - protected function post_process_submission( $invoice, $prepared_payment_form_data, $shipping ) { |
|
338 | + protected function post_process_submission($invoice, $prepared_payment_form_data, $shipping) { |
|
339 | 339 | |
340 | 340 | // Ensure the invoice exists. |
341 | - if ( ! $invoice->exists() ) { |
|
342 | - wp_send_json_error( __( 'An error occured while saving your invoice. Please try again.', 'invoicing' ) ); |
|
341 | + if (!$invoice->exists()) { |
|
342 | + wp_send_json_error(__('An error occured while saving your invoice. Please try again.', 'invoicing')); |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | // Save payment form data. |
346 | - $prepared_payment_form_data = apply_filters( 'getpaid_prepared_payment_form_data', $prepared_payment_form_data, $invoice ); |
|
347 | - if ( ! empty( $prepared_payment_form_data ) ) { |
|
348 | - update_post_meta( $invoice->get_id(), 'payment_form_data', $prepared_payment_form_data ); |
|
346 | + $prepared_payment_form_data = apply_filters('getpaid_prepared_payment_form_data', $prepared_payment_form_data, $invoice); |
|
347 | + if (!empty($prepared_payment_form_data)) { |
|
348 | + update_post_meta($invoice->get_id(), 'payment_form_data', $prepared_payment_form_data); |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | // Save payment form data. |
352 | - if ( ! empty( $shipping ) ) { |
|
353 | - update_post_meta( $invoice->get_id(), 'shipping_address', $shipping ); |
|
352 | + if (!empty($shipping)) { |
|
353 | + update_post_meta($invoice->get_id(), 'shipping_address', $shipping); |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | // Backwards compatibility. |
357 | - add_filter( 'wp_redirect', array( $this, 'send_redirect_response' ) ); |
|
357 | + add_filter('wp_redirect', array($this, 'send_redirect_response')); |
|
358 | 358 | |
359 | - $this->process_payment( $invoice ); |
|
359 | + $this->process_payment($invoice); |
|
360 | 360 | |
361 | 361 | // If we are here, there was an error. |
362 | - wpinv_send_back_to_checkout( $invoice ); |
|
362 | + wpinv_send_back_to_checkout($invoice); |
|
363 | 363 | |
364 | 364 | } |
365 | 365 | |
@@ -368,41 +368,41 @@ discard block |
||
368 | 368 | * |
369 | 369 | * @param WPInv_Invoice $invoice |
370 | 370 | */ |
371 | - protected function process_payment( $invoice ) { |
|
371 | + protected function process_payment($invoice) { |
|
372 | 372 | |
373 | 373 | // Clear any checkout errors. |
374 | 374 | wpinv_clear_errors(); |
375 | 375 | |
376 | 376 | // No need to send free invoices to the gateway. |
377 | - if ( $invoice->is_free() ) { |
|
378 | - $this->process_free_payment( $invoice ); |
|
377 | + if ($invoice->is_free()) { |
|
378 | + $this->process_free_payment($invoice); |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | $submission = $this->payment_form_submission; |
382 | 382 | |
383 | 383 | // Fires before sending to the gateway. |
384 | - do_action( 'getpaid_checkout_before_gateway', $invoice, $submission ); |
|
384 | + do_action('getpaid_checkout_before_gateway', $invoice, $submission); |
|
385 | 385 | |
386 | 386 | // Allow the sumission data to be modified before it is sent to the gateway. |
387 | 387 | $submission_data = $submission->get_data(); |
388 | - $submission_gateway = apply_filters( 'getpaid_gateway_submission_gateway', $invoice->get_gateway(), $submission, $invoice ); |
|
389 | - $submission_data = apply_filters( 'getpaid_gateway_submission_data', $submission_data, $submission, $invoice ); |
|
388 | + $submission_gateway = apply_filters('getpaid_gateway_submission_gateway', $invoice->get_gateway(), $submission, $invoice); |
|
389 | + $submission_data = apply_filters('getpaid_gateway_submission_data', $submission_data, $submission, $invoice); |
|
390 | 390 | |
391 | 391 | // Validate the currency. |
392 | - if ( ! apply_filters( "getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency() ) ) { |
|
393 | - wpinv_set_error( 'invalid_currency', __( 'The chosen payment gateway does not support this currency', 'invoicing' ) ); |
|
392 | + if (!apply_filters("getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency())) { |
|
393 | + wpinv_set_error('invalid_currency', __('The chosen payment gateway does not support this currency', 'invoicing')); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | // Check to see if we have any errors. |
397 | - if ( wpinv_get_errors() ) { |
|
398 | - wpinv_send_back_to_checkout( $invoice ); |
|
397 | + if (wpinv_get_errors()) { |
|
398 | + wpinv_send_back_to_checkout($invoice); |
|
399 | 399 | } |
400 | 400 | |
401 | 401 | // Send info to the gateway for payment processing |
402 | - do_action( "getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission ); |
|
402 | + do_action("getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission); |
|
403 | 403 | |
404 | 404 | // Backwards compatibility. |
405 | - wpinv_send_to_gateway( $submission_gateway, $invoice ); |
|
405 | + wpinv_send_to_gateway($submission_gateway, $invoice); |
|
406 | 406 | |
407 | 407 | } |
408 | 408 | |
@@ -411,12 +411,12 @@ discard block |
||
411 | 411 | * |
412 | 412 | * @param WPInv_Invoice $invoice |
413 | 413 | */ |
414 | - protected function process_free_payment( $invoice ) { |
|
414 | + protected function process_free_payment($invoice) { |
|
415 | 415 | |
416 | - $invoice->set_gateway( 'none' ); |
|
417 | - $invoice->add_note( __( "This is a free invoice and won't be sent to the payment gateway", 'invoicing' ), false, false, true ); |
|
416 | + $invoice->set_gateway('none'); |
|
417 | + $invoice->add_note(__("This is a free invoice and won't be sent to the payment gateway", 'invoicing'), false, false, true); |
|
418 | 418 | $invoice->mark_paid(); |
419 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
419 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
420 | 420 | |
421 | 421 | } |
422 | 422 | |
@@ -424,9 +424,9 @@ discard block |
||
424 | 424 | * Sends a redrect response to payment details. |
425 | 425 | * |
426 | 426 | */ |
427 | - public function send_redirect_response( $url ) { |
|
428 | - $url = urlencode( $url ); |
|
429 | - wp_send_json_success( $url ); |
|
427 | + public function send_redirect_response($url) { |
|
428 | + $url = urlencode($url); |
|
429 | + wp_send_json_success($url); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | } |
@@ -24,14 +24,14 @@ |
||
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
27 | - * Highlights sub menus. |
|
28 | - */ |
|
29 | - public function set_admin_menu_class() { |
|
30 | - global $current_screen, $parent_file, $submenu_file; |
|
27 | + * Highlights sub menus. |
|
28 | + */ |
|
29 | + public function set_admin_menu_class() { |
|
30 | + global $current_screen, $parent_file, $submenu_file; |
|
31 | 31 | |
32 | 32 | if ( ! empty( $current_screen->id ) && in_array( $current_screen->id , array( 'wpi_discount', 'wpi_payment_form', 'wpi_invoice' ) ) ) { |
33 | - $parent_file = 'wpinv'; |
|
34 | - $submenu_file = 'edit.php?post_type=' . $current_screen->id; |
|
33 | + $parent_file = 'wpinv'; |
|
34 | + $submenu_file = 'edit.php?post_type=' . $current_screen->id; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Setup menus in WP admin. |
4 | 4 | */ |
5 | 5 | |
6 | -defined( 'ABSPATH' ) || exit; |
|
6 | +defined('ABSPATH') || exit; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * WC_Admin_Menus Class. |
@@ -13,14 +13,14 @@ discard block |
||
13 | 13 | * Hook in tabs. |
14 | 14 | */ |
15 | 15 | public function __construct() { |
16 | - add_action( 'admin_head', array( $this, 'set_admin_menu_class' ) ); |
|
17 | - add_action( 'admin_menu', array( $this, 'admin_menu' ), 10 ); |
|
18 | - add_action( 'admin_menu', array( $this, 'add_customers_menu' ), 18 ); |
|
19 | - add_action( 'admin_menu', array( $this, 'add_subscriptions_menu' ), 40 ); |
|
20 | - add_action( 'admin_menu', array( $this, 'add_addons_menu' ), 100 ); |
|
21 | - add_action( 'admin_menu', array( $this, 'add_settings_menu' ), 60 ); |
|
22 | - add_action( 'admin_menu', array( $this, 'remove_admin_submenus' ), 10 ); |
|
23 | - add_action( 'admin_head-nav-menus.php', array( $this, 'add_nav_menu_meta_boxes' ) ); |
|
16 | + add_action('admin_head', array($this, 'set_admin_menu_class')); |
|
17 | + add_action('admin_menu', array($this, 'admin_menu'), 10); |
|
18 | + add_action('admin_menu', array($this, 'add_customers_menu'), 18); |
|
19 | + add_action('admin_menu', array($this, 'add_subscriptions_menu'), 40); |
|
20 | + add_action('admin_menu', array($this, 'add_addons_menu'), 100); |
|
21 | + add_action('admin_menu', array($this, 'add_settings_menu'), 60); |
|
22 | + add_action('admin_menu', array($this, 'remove_admin_submenus'), 10); |
|
23 | + add_action('admin_head-nav-menus.php', array($this, 'add_nav_menu_meta_boxes')); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | public function set_admin_menu_class() { |
30 | 30 | global $current_screen, $parent_file, $submenu_file; |
31 | 31 | |
32 | - if ( ! empty( $current_screen->id ) && in_array( $current_screen->id , array( 'wpi_discount', 'wpi_payment_form', 'wpi_invoice' ) ) ) { |
|
32 | + if (!empty($current_screen->id) && in_array($current_screen->id, array('wpi_discount', 'wpi_payment_form', 'wpi_invoice'))) { |
|
33 | 33 | $parent_file = 'wpinv'; |
34 | 34 | $submenu_file = 'edit.php?post_type=' . $current_screen->id; |
35 | 35 | } |
@@ -38,14 +38,14 @@ discard block |
||
38 | 38 | |
39 | 39 | public function admin_menu() { |
40 | 40 | |
41 | - $capability = apply_filters( 'invoicing_capability', wpinv_get_capability() ); |
|
41 | + $capability = apply_filters('invoicing_capability', wpinv_get_capability()); |
|
42 | 42 | add_menu_page( |
43 | - __( 'GetPaid', 'invoicing' ), |
|
44 | - __( 'GetPaid', 'invoicing' ), |
|
43 | + __('GetPaid', 'invoicing'), |
|
44 | + __('GetPaid', 'invoicing'), |
|
45 | 45 | $capability, |
46 | 46 | 'wpinv', |
47 | 47 | null, |
48 | - 'data:image/svg+xml;base64,' . base64_encode( file_get_contents( WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg' ) ), |
|
48 | + 'data:image/svg+xml;base64,' . base64_encode(file_get_contents(WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg')), |
|
49 | 49 | '54.123460' |
50 | 50 | ); |
51 | 51 | |
@@ -57,11 +57,11 @@ discard block |
||
57 | 57 | public function add_customers_menu() { |
58 | 58 | add_submenu_page( |
59 | 59 | 'wpinv', |
60 | - __( 'Customers', 'invoicing' ), |
|
61 | - __( 'Customers', 'invoicing' ), |
|
60 | + __('Customers', 'invoicing'), |
|
61 | + __('Customers', 'invoicing'), |
|
62 | 62 | wpinv_get_capability(), |
63 | 63 | 'wpinv-customers', |
64 | - array( $this, 'customers_page' ) |
|
64 | + array($this, 'customers_page') |
|
65 | 65 | ); |
66 | 66 | } |
67 | 67 | |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | public function add_subscriptions_menu() { |
72 | 72 | add_submenu_page( |
73 | 73 | 'wpinv', |
74 | - __( 'Subscriptions', 'invoicing' ), |
|
75 | - __( 'Subscriptions', 'invoicing' ), |
|
74 | + __('Subscriptions', 'invoicing'), |
|
75 | + __('Subscriptions', 'invoicing'), |
|
76 | 76 | wpinv_get_capability(), |
77 | 77 | 'wpinv-subscriptions', |
78 | 78 | 'wpinv_subscriptions_page' |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * Displays the customers page. |
84 | 84 | */ |
85 | 85 | public function customers_page() { |
86 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-customers-table.php' ); |
|
86 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-customers-table.php'); |
|
87 | 87 | ?> |
88 | 88 | <div class="wrap wpi-customers-wrap"> |
89 | 89 | <style> |
@@ -91,12 +91,12 @@ discard block |
||
91 | 91 | width: 30%; |
92 | 92 | } |
93 | 93 | </style> |
94 | - <h1><?php echo esc_html( __( 'Customers', 'invoicing' ) ); ?></h1> |
|
94 | + <h1><?php echo esc_html(__('Customers', 'invoicing')); ?></h1> |
|
95 | 95 | <form method="post"> |
96 | 96 | <?php |
97 | 97 | $table = new WPInv_Customers_Table(); |
98 | 98 | $table->prepare_items(); |
99 | - $table->search_box( __( 'Search Customers', 'invoicing' ), 'search-customers' ); |
|
99 | + $table->search_box(__('Search Customers', 'invoicing'), 'search-customers'); |
|
100 | 100 | $table->display(); |
101 | 101 | ?> |
102 | 102 | </form> |
@@ -110,16 +110,16 @@ discard block |
||
110 | 110 | public function add_settings_menu() { |
111 | 111 | add_submenu_page( |
112 | 112 | 'wpinv', |
113 | - __( 'Invoice Settings', 'invoicing' ), |
|
114 | - __( 'Settings', 'invoicing' ), |
|
115 | - apply_filters( 'invoicing_capability', wpinv_get_capability() ), |
|
113 | + __('Invoice Settings', 'invoicing'), |
|
114 | + __('Settings', 'invoicing'), |
|
115 | + apply_filters('invoicing_capability', wpinv_get_capability()), |
|
116 | 116 | 'wpinv-settings', |
117 | - array( $this, 'options_page' ) |
|
117 | + array($this, 'options_page') |
|
118 | 118 | ); |
119 | 119 | } |
120 | 120 | |
121 | - public function add_addons_menu(){ |
|
122 | - if ( !apply_filters( 'wpi_show_addons_page', true ) ) { |
|
121 | + public function add_addons_menu() { |
|
122 | + if (!apply_filters('wpi_show_addons_page', true)) { |
|
123 | 123 | return; |
124 | 124 | } |
125 | 125 | |
@@ -129,80 +129,80 @@ discard block |
||
129 | 129 | __('Extensions', 'invoicing'), |
130 | 130 | 'manage_options', |
131 | 131 | 'wpi-addons', |
132 | - array( $this, 'addons_page' ) |
|
132 | + array($this, 'addons_page') |
|
133 | 133 | ); |
134 | 134 | } |
135 | 135 | |
136 | - public function addons_page(){ |
|
136 | + public function addons_page() { |
|
137 | 137 | $addon_obj = new WPInv_Admin_Addons(); |
138 | 138 | $addon_obj->output(); |
139 | 139 | } |
140 | 140 | |
141 | 141 | function options_page() { |
142 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
142 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
143 | 143 | |
144 | - if ( $page !== 'wpinv-settings' ) { |
|
144 | + if ($page !== 'wpinv-settings') { |
|
145 | 145 | return; |
146 | 146 | } |
147 | 147 | |
148 | 148 | $settings_tabs = wpinv_get_settings_tabs(); |
149 | 149 | $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs; |
150 | - $active_tab = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general'; |
|
151 | - $sections = wpinv_get_settings_tab_sections( $active_tab ); |
|
150 | + $active_tab = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? sanitize_text_field($_GET['tab']) : 'general'; |
|
151 | + $sections = wpinv_get_settings_tab_sections($active_tab); |
|
152 | 152 | $key = 'main'; |
153 | 153 | |
154 | - if ( is_array( $sections ) ) { |
|
155 | - $key = key( $sections ); |
|
154 | + if (is_array($sections)) { |
|
155 | + $key = key($sections); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | add_thickbox(); |
159 | 159 | |
160 | - $registered_sections = wpinv_get_settings_tab_sections( $active_tab ); |
|
161 | - $section = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? $_GET['section'] : $key; |
|
160 | + $registered_sections = wpinv_get_settings_tab_sections($active_tab); |
|
161 | + $section = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? $_GET['section'] : $key; |
|
162 | 162 | ob_start(); |
163 | 163 | ?> |
164 | 164 | <div class="wrap"> |
165 | 165 | <h1 class="nav-tab-wrapper"> |
166 | 166 | <?php |
167 | - foreach( wpinv_get_settings_tabs() as $tab_id => $tab_name ) { |
|
168 | - $tab_url = add_query_arg( array( |
|
167 | + foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) { |
|
168 | + $tab_url = add_query_arg(array( |
|
169 | 169 | 'settings-updated' => false, |
170 | 170 | 'tab' => $tab_id, |
171 | - ) ); |
|
171 | + )); |
|
172 | 172 | |
173 | 173 | // Remove the section from the tabs so we always end up at the main section |
174 | - $tab_url = remove_query_arg( 'section', $tab_url ); |
|
175 | - $tab_url = remove_query_arg( 'wpi_sub', $tab_url ); |
|
174 | + $tab_url = remove_query_arg('section', $tab_url); |
|
175 | + $tab_url = remove_query_arg('wpi_sub', $tab_url); |
|
176 | 176 | |
177 | 177 | $active = $active_tab == $tab_id ? ' nav-tab-active' : ''; |
178 | 178 | |
179 | - echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">'; |
|
180 | - echo esc_html( $tab_name ); |
|
179 | + echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . $active . '">'; |
|
180 | + echo esc_html($tab_name); |
|
181 | 181 | echo '</a>'; |
182 | 182 | } |
183 | 183 | ?> |
184 | 184 | </h1> |
185 | 185 | <?php |
186 | - $number_of_sections = count( $sections ); |
|
186 | + $number_of_sections = count($sections); |
|
187 | 187 | $number = 0; |
188 | - if ( $number_of_sections > 1 ) { |
|
188 | + if ($number_of_sections > 1) { |
|
189 | 189 | echo '<div><ul class="subsubsub">'; |
190 | - foreach( $sections as $section_id => $section_name ) { |
|
190 | + foreach ($sections as $section_id => $section_name) { |
|
191 | 191 | echo '<li>'; |
192 | 192 | $number++; |
193 | - $tab_url = add_query_arg( array( |
|
193 | + $tab_url = add_query_arg(array( |
|
194 | 194 | 'settings-updated' => false, |
195 | 195 | 'tab' => $active_tab, |
196 | 196 | 'section' => $section_id |
197 | - ) ); |
|
198 | - $tab_url = remove_query_arg( 'wpi_sub', $tab_url ); |
|
197 | + )); |
|
198 | + $tab_url = remove_query_arg('wpi_sub', $tab_url); |
|
199 | 199 | $class = ''; |
200 | - if ( $section == $section_id ) { |
|
200 | + if ($section == $section_id) { |
|
201 | 201 | $class = 'current'; |
202 | 202 | } |
203 | - echo '<a class="' . $class . '" href="' . esc_url( $tab_url ) . '">' . $section_name . '</a>'; |
|
203 | + echo '<a class="' . $class . '" href="' . esc_url($tab_url) . '">' . $section_name . '</a>'; |
|
204 | 204 | |
205 | - if ( $number != $number_of_sections ) { |
|
205 | + if ($number != $number_of_sections) { |
|
206 | 206 | echo ' | '; |
207 | 207 | } |
208 | 208 | echo '</li>'; |
@@ -214,20 +214,20 @@ discard block |
||
214 | 214 | <form method="post" action="options.php"> |
215 | 215 | <table class="form-table"> |
216 | 216 | <?php |
217 | - settings_fields( 'wpinv_settings' ); |
|
217 | + settings_fields('wpinv_settings'); |
|
218 | 218 | |
219 | - if ( 'main' === $section ) { |
|
220 | - do_action( 'wpinv_settings_tab_top', $active_tab ); |
|
219 | + if ('main' === $section) { |
|
220 | + do_action('wpinv_settings_tab_top', $active_tab); |
|
221 | 221 | } |
222 | 222 | |
223 | - do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section ); |
|
224 | - do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section ); |
|
225 | - do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section ); |
|
226 | - do_action( 'getpaid_settings_tab_bottom', $active_tab, $section ); |
|
223 | + do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section); |
|
224 | + do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section); |
|
225 | + do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section); |
|
226 | + do_action('getpaid_settings_tab_bottom', $active_tab, $section); |
|
227 | 227 | |
228 | 228 | // For backwards compatibility |
229 | - if ( 'main' === $section ) { |
|
230 | - do_action( 'wpinv_settings_tab_bottom', $active_tab ); |
|
229 | + if ('main' === $section) { |
|
230 | + do_action('wpinv_settings_tab_bottom', $active_tab); |
|
231 | 231 | } |
232 | 232 | ?> |
233 | 233 | </table> |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | } |
242 | 242 | |
243 | 243 | public function remove_admin_submenus() { |
244 | - remove_submenu_page( 'edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice' ); |
|
244 | + remove_submenu_page('edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice'); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -251,8 +251,8 @@ discard block |
||
251 | 251 | |
252 | 252 | add_meta_box( |
253 | 253 | 'wpinv_endpoints_nav_link', |
254 | - __( 'GetPaid endpoints', 'invoicing' ), |
|
255 | - array( $this, 'nav_menu_links' ), |
|
254 | + __('GetPaid endpoints', 'invoicing'), |
|
255 | + array($this, 'nav_menu_links'), |
|
256 | 256 | 'nav-menus', |
257 | 257 | 'side', |
258 | 258 | 'low' |
@@ -267,12 +267,12 @@ discard block |
||
267 | 267 | $endpoints = $this->get_menu_items(); |
268 | 268 | ?> |
269 | 269 | <div id="invoicing-endpoints" class="posttypediv"> |
270 | - <?php if ( ! empty( $endpoints['pages'] ) ) : ?> |
|
270 | + <?php if (!empty($endpoints['pages'])) : ?> |
|
271 | 271 | <div id="tabs-panel-invoicing-endpoints" class="tabs-panel tabs-panel-active"> |
272 | 272 | <ul id="invoicing-endpoints-checklist" class="categorychecklist form-no-clear"> |
273 | 273 | <?php |
274 | - $walker = new Walker_Nav_Menu_Checklist( array() ); |
|
275 | - echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $endpoints['pages'] ), 0, (object) array( 'walker' => $walker ) ); |
|
274 | + $walker = new Walker_Nav_Menu_Checklist(array()); |
|
275 | + echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $endpoints['pages']), 0, (object) array('walker' => $walker)); |
|
276 | 276 | ?> |
277 | 277 | </ul> |
278 | 278 | </div> |
@@ -281,11 +281,11 @@ discard block |
||
281 | 281 | <p class="button-controls wp-clearfix" data-items-type="invoicing-endpoints"> |
282 | 282 | <span class="list-controls hide-if-no-js"> |
283 | 283 | <input type="checkbox" id="invoicing-endpoints-tab" class="select-all"> |
284 | - <label for="invoicing-endpoints-tab"><?php _e( 'Select all', 'invoicing' ); ?></label> |
|
284 | + <label for="invoicing-endpoints-tab"><?php _e('Select all', 'invoicing'); ?></label> |
|
285 | 285 | </span> |
286 | 286 | |
287 | 287 | <span class="add-to-menu"> |
288 | - <input type="submit" class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to menu', 'invoicing' ); ?>" name="add-invoicing-endpoints-item" id="submit-invoicing-endpoints"> |
|
288 | + <input type="submit" class="button submit-add-to-menu right" value="<?php esc_attr_e('Add to menu', 'invoicing'); ?>" name="add-invoicing-endpoints-item" id="submit-invoicing-endpoints"> |
|
289 | 289 | <span class="spinner"></span> |
290 | 290 | </span> |
291 | 291 | </p> |
@@ -298,35 +298,35 @@ discard block |
||
298 | 298 | * |
299 | 299 | * @return array. |
300 | 300 | */ |
301 | - public function get_menu_items(){ |
|
301 | + public function get_menu_items() { |
|
302 | 302 | $items = array(); |
303 | 303 | |
304 | 304 | $pages = array( |
305 | 305 | array( |
306 | - 'id' => wpinv_get_option( 'invoice_history_page' ), |
|
307 | - 'label' => __( 'My Invoices', 'invoicing' ), |
|
306 | + 'id' => wpinv_get_option('invoice_history_page'), |
|
307 | + 'label' => __('My Invoices', 'invoicing'), |
|
308 | 308 | ), |
309 | 309 | array( |
310 | - 'id' => wpinv_get_option( 'invoice_subscription_page' ), |
|
311 | - 'label' => __( 'My Subscriptions', 'invoicing' ), |
|
310 | + 'id' => wpinv_get_option('invoice_subscription_page'), |
|
311 | + 'label' => __('My Subscriptions', 'invoicing'), |
|
312 | 312 | ) |
313 | 313 | ); |
314 | 314 | |
315 | - foreach ( apply_filters( 'getpaid_menu_pages', $pages ) as $page ) { |
|
315 | + foreach (apply_filters('getpaid_menu_pages', $pages) as $page) { |
|
316 | 316 | |
317 | - if ( (int) $page['id'] > 0 ) { |
|
317 | + if ((int) $page['id'] > 0) { |
|
318 | 318 | |
319 | 319 | $item = new stdClass(); |
320 | 320 | $item->object_id = (int) $page['id']; |
321 | 321 | $item->db_id = 0; |
322 | - $item->object = 'page'; |
|
322 | + $item->object = 'page'; |
|
323 | 323 | $item->menu_item_parent = 0; |
324 | 324 | $item->type = 'post_type'; |
325 | - $item->title = sanitize_text_field( $page['label'] ); |
|
326 | - $item->url = get_permalink( (int) $page['id'] ); |
|
325 | + $item->title = sanitize_text_field($page['label']); |
|
326 | + $item->url = get_permalink((int) $page['id']); |
|
327 | 327 | $item->target = ''; |
328 | 328 | $item->attr_title = ''; |
329 | - $item->classes = array( 'wpinv-menu-item' ); |
|
329 | + $item->classes = array('wpinv-menu-item'); |
|
330 | 330 | $item->xfn = ''; |
331 | 331 | |
332 | 332 | $items['pages'][] = $item; |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | |
336 | 336 | } |
337 | 337 | |
338 | - return apply_filters( 'wpinv_menu_items', $items ); |
|
338 | + return apply_filters('wpinv_menu_items', $items); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | } |
@@ -12,79 +12,79 @@ |
||
12 | 12 | */ |
13 | 13 | class GetPaid_Payment_Form_Submission_Items { |
14 | 14 | |
15 | - /** |
|
16 | - * Submission items. |
|
17 | - * @var GetPaid_Form_Item[] |
|
18 | - */ |
|
19 | - public $items = array(); |
|
20 | - |
|
21 | 15 | /** |
22 | - * Class constructor |
|
23 | - * |
|
24 | - * @param GetPaid_Payment_Form_Submission $submission |
|
25 | - */ |
|
26 | - public function __construct( $submission ) { |
|
27 | - |
|
28 | - $data = $submission->get_data(); |
|
29 | - $payment_form = $submission->get_payment_form(); |
|
30 | - |
|
31 | - // Prepare the selected items. |
|
32 | - $selected_items = array(); |
|
33 | - if ( ! empty( $data['getpaid-items'] ) ) { |
|
34 | - $selected_items = wpinv_clean( $data['getpaid-items'] ); |
|
35 | - } |
|
36 | - |
|
37 | - // For default forms, ensure that an item has been set. |
|
38 | - if ( $payment_form->is_default() && ( ! $submission->has_invoice() || 'payment_form' == $submission->get_invoice()->get_created_via() ) && isset( $data['getpaid-form-items'] ) ) { |
|
39 | - $form_items = wpinv_clean( $data['getpaid-form-items'] ); |
|
40 | - $payment_form->set_items( getpaid_convert_items_to_array( $form_items ) ); |
|
41 | - } |
|
16 | + * Submission items. |
|
17 | + * @var GetPaid_Form_Item[] |
|
18 | + */ |
|
19 | + public $items = array(); |
|
42 | 20 | |
43 | - // Process each individual item. |
|
44 | - foreach ( $payment_form->get_items() as $item ) { |
|
45 | - $this->process_item( $item, $selected_items ); |
|
46 | - } |
|
47 | - |
|
48 | - } |
|
21 | + /** |
|
22 | + * Class constructor |
|
23 | + * |
|
24 | + * @param GetPaid_Payment_Form_Submission $submission |
|
25 | + */ |
|
26 | + public function __construct( $submission ) { |
|
27 | + |
|
28 | + $data = $submission->get_data(); |
|
29 | + $payment_form = $submission->get_payment_form(); |
|
30 | + |
|
31 | + // Prepare the selected items. |
|
32 | + $selected_items = array(); |
|
33 | + if ( ! empty( $data['getpaid-items'] ) ) { |
|
34 | + $selected_items = wpinv_clean( $data['getpaid-items'] ); |
|
35 | + } |
|
36 | + |
|
37 | + // For default forms, ensure that an item has been set. |
|
38 | + if ( $payment_form->is_default() && ( ! $submission->has_invoice() || 'payment_form' == $submission->get_invoice()->get_created_via() ) && isset( $data['getpaid-form-items'] ) ) { |
|
39 | + $form_items = wpinv_clean( $data['getpaid-form-items'] ); |
|
40 | + $payment_form->set_items( getpaid_convert_items_to_array( $form_items ) ); |
|
41 | + } |
|
42 | + |
|
43 | + // Process each individual item. |
|
44 | + foreach ( $payment_form->get_items() as $item ) { |
|
45 | + $this->process_item( $item, $selected_items ); |
|
46 | + } |
|
47 | + |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * Process a single item. |
|
52 | - * |
|
53 | - * @param GetPaid_Form_Item $item |
|
54 | - * @param array $selected_items |
|
55 | - */ |
|
56 | - public function process_item( $item, $selected_items ) { |
|
50 | + /** |
|
51 | + * Process a single item. |
|
52 | + * |
|
53 | + * @param GetPaid_Form_Item $item |
|
54 | + * @param array $selected_items |
|
55 | + */ |
|
56 | + public function process_item( $item, $selected_items ) { |
|
57 | 57 | |
58 | - // Abort if this is an optional item and it has not been selected. |
|
59 | - if ( ! $item->is_required() && ! isset( $selected_items[ $item->get_id() ] ) ) { |
|
60 | - return; |
|
61 | - } |
|
58 | + // Abort if this is an optional item and it has not been selected. |
|
59 | + if ( ! $item->is_required() && ! isset( $selected_items[ $item->get_id() ] ) ) { |
|
60 | + return; |
|
61 | + } |
|
62 | 62 | |
63 | - // (maybe) let customers change the quantities and prices. |
|
64 | - if ( isset( $selected_items[ $item->get_id() ] ) ) { |
|
63 | + // (maybe) let customers change the quantities and prices. |
|
64 | + if ( isset( $selected_items[ $item->get_id() ] ) ) { |
|
65 | 65 | |
66 | - // Maybe change the quantities. |
|
67 | - if ( $item->allows_quantities() ) { |
|
68 | - $item->set_quantity( (float) $selected_items[ $item->get_id() ]['quantity'] ); |
|
69 | - } |
|
66 | + // Maybe change the quantities. |
|
67 | + if ( $item->allows_quantities() ) { |
|
68 | + $item->set_quantity( (float) $selected_items[ $item->get_id() ]['quantity'] ); |
|
69 | + } |
|
70 | 70 | |
71 | - // Maybe change the price. |
|
72 | - if ( $item->user_can_set_their_price() ) { |
|
73 | - $price = (float) wpinv_sanitize_amount( $selected_items[ $item->get_id() ]['price'] ); |
|
71 | + // Maybe change the price. |
|
72 | + if ( $item->user_can_set_their_price() ) { |
|
73 | + $price = (float) wpinv_sanitize_amount( $selected_items[ $item->get_id() ]['price'] ); |
|
74 | 74 | |
75 | - if ( $item->get_minimum_price() > $price ) { |
|
76 | - throw new Exception( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), wpinv_sanitize_amount( $item->get_minimum_price() ) ) ); |
|
77 | - } |
|
75 | + if ( $item->get_minimum_price() > $price ) { |
|
76 | + throw new Exception( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), wpinv_sanitize_amount( $item->get_minimum_price() ) ) ); |
|
77 | + } |
|
78 | 78 | |
79 | - $item->set_price( $price ); |
|
79 | + $item->set_price( $price ); |
|
80 | 80 | |
81 | - } |
|
81 | + } |
|
82 | 82 | |
83 | - } |
|
83 | + } |
|
84 | 84 | |
85 | - // Save the item. |
|
86 | - $this->items[] = $item; |
|
85 | + // Save the item. |
|
86 | + $this->items[] = $item; |
|
87 | 87 | |
88 | - } |
|
88 | + } |
|
89 | 89 | |
90 | 90 | } |
@@ -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 | * Payment form submission itemss class |
@@ -23,26 +23,26 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @param GetPaid_Payment_Form_Submission $submission |
25 | 25 | */ |
26 | - public function __construct( $submission ) { |
|
26 | + public function __construct($submission) { |
|
27 | 27 | |
28 | 28 | $data = $submission->get_data(); |
29 | 29 | $payment_form = $submission->get_payment_form(); |
30 | 30 | |
31 | 31 | // Prepare the selected items. |
32 | 32 | $selected_items = array(); |
33 | - if ( ! empty( $data['getpaid-items'] ) ) { |
|
34 | - $selected_items = wpinv_clean( $data['getpaid-items'] ); |
|
33 | + if (!empty($data['getpaid-items'])) { |
|
34 | + $selected_items = wpinv_clean($data['getpaid-items']); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | // For default forms, ensure that an item has been set. |
38 | - if ( $payment_form->is_default() && ( ! $submission->has_invoice() || 'payment_form' == $submission->get_invoice()->get_created_via() ) && isset( $data['getpaid-form-items'] ) ) { |
|
39 | - $form_items = wpinv_clean( $data['getpaid-form-items'] ); |
|
40 | - $payment_form->set_items( getpaid_convert_items_to_array( $form_items ) ); |
|
38 | + if ($payment_form->is_default() && (!$submission->has_invoice() || 'payment_form' == $submission->get_invoice()->get_created_via()) && isset($data['getpaid-form-items'])) { |
|
39 | + $form_items = wpinv_clean($data['getpaid-form-items']); |
|
40 | + $payment_form->set_items(getpaid_convert_items_to_array($form_items)); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | // Process each individual item. |
44 | - foreach ( $payment_form->get_items() as $item ) { |
|
45 | - $this->process_item( $item, $selected_items ); |
|
44 | + foreach ($payment_form->get_items() as $item) { |
|
45 | + $this->process_item($item, $selected_items); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | } |
@@ -53,30 +53,30 @@ discard block |
||
53 | 53 | * @param GetPaid_Form_Item $item |
54 | 54 | * @param array $selected_items |
55 | 55 | */ |
56 | - public function process_item( $item, $selected_items ) { |
|
56 | + public function process_item($item, $selected_items) { |
|
57 | 57 | |
58 | 58 | // Abort if this is an optional item and it has not been selected. |
59 | - if ( ! $item->is_required() && ! isset( $selected_items[ $item->get_id() ] ) ) { |
|
59 | + if (!$item->is_required() && !isset($selected_items[$item->get_id()])) { |
|
60 | 60 | return; |
61 | 61 | } |
62 | 62 | |
63 | 63 | // (maybe) let customers change the quantities and prices. |
64 | - if ( isset( $selected_items[ $item->get_id() ] ) ) { |
|
64 | + if (isset($selected_items[$item->get_id()])) { |
|
65 | 65 | |
66 | 66 | // Maybe change the quantities. |
67 | - if ( $item->allows_quantities() ) { |
|
68 | - $item->set_quantity( (float) $selected_items[ $item->get_id() ]['quantity'] ); |
|
67 | + if ($item->allows_quantities()) { |
|
68 | + $item->set_quantity((float) $selected_items[$item->get_id()]['quantity']); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | // Maybe change the price. |
72 | - if ( $item->user_can_set_their_price() ) { |
|
73 | - $price = (float) wpinv_sanitize_amount( $selected_items[ $item->get_id() ]['price'] ); |
|
72 | + if ($item->user_can_set_their_price()) { |
|
73 | + $price = (float) wpinv_sanitize_amount($selected_items[$item->get_id()]['price']); |
|
74 | 74 | |
75 | - if ( $item->get_minimum_price() > $price ) { |
|
76 | - throw new Exception( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), wpinv_sanitize_amount( $item->get_minimum_price() ) ) ); |
|
75 | + if ($item->get_minimum_price() > $price) { |
|
76 | + throw new Exception(sprintf(__('The minimum allowed amount is %s', 'invoicing'), wpinv_sanitize_amount($item->get_minimum_price()))); |
|
77 | 77 | } |
78 | 78 | |
79 | - $item->set_price( $price ); |
|
79 | + $item->set_price($price); |
|
80 | 80 | |
81 | 81 | } |
82 | 82 |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | if ( ! defined( 'ABSPATH' ) ) { |
11 | - exit; // Exit if accessed directly |
|
11 | + exit; // Exit if accessed directly |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | /** |
@@ -17,10 +17,10 @@ discard block |
||
17 | 17 | class GetPaid_Meta_Box_Item_Details { |
18 | 18 | |
19 | 19 | /** |
20 | - * Output the metabox. |
|
21 | - * |
|
22 | - * @param WP_Post $post |
|
23 | - */ |
|
20 | + * Output the metabox. |
|
21 | + * |
|
22 | + * @param WP_Post $post |
|
23 | + */ |
|
24 | 24 | public static function output( $post ) { |
25 | 25 | |
26 | 26 | // Prepare the item. |
@@ -270,35 +270,35 @@ discard block |
||
270 | 270 | } |
271 | 271 | |
272 | 272 | /** |
273 | - * Save meta box data. |
|
274 | - * |
|
275 | - * @param int $post_id |
|
276 | - */ |
|
277 | - public static function save( $post_id ) { |
|
273 | + * Save meta box data. |
|
274 | + * |
|
275 | + * @param int $post_id |
|
276 | + */ |
|
277 | + public static function save( $post_id ) { |
|
278 | 278 | |
279 | 279 | // Prepare the item. |
280 | 280 | $item = new WPInv_Item( $post_id ); |
281 | 281 | |
282 | 282 | // Load new data. |
283 | 283 | $item->set_props( |
284 | - array( |
|
285 | - 'price' => isset( $_POST['wpinv_item_price'] ) ? (float) $_POST['wpinv_item_price'] : null, |
|
286 | - 'vat_rule' => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null, |
|
287 | - 'vat_class' => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null, |
|
288 | - 'type' => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null, |
|
289 | - 'is_dynamic_pricing' => isset( $_POST['wpinv_name_your_price'] ), |
|
284 | + array( |
|
285 | + 'price' => isset( $_POST['wpinv_item_price'] ) ? (float) $_POST['wpinv_item_price'] : null, |
|
286 | + 'vat_rule' => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null, |
|
287 | + 'vat_class' => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null, |
|
288 | + 'type' => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null, |
|
289 | + 'is_dynamic_pricing' => isset( $_POST['wpinv_name_your_price'] ), |
|
290 | 290 | 'minimum_price' => isset( $_POST['wpinv_minimum_price'] ) ? (float) $_POST['wpinv_minimum_price'] : null, |
291 | - 'is_recurring' => isset( $_POST['wpinv_is_recurring'] ), |
|
292 | - 'recurring_period' => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null, |
|
293 | - 'recurring_interval' => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1, |
|
294 | - 'recurring_limit' => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null, |
|
295 | - 'is_free_trial' => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null, |
|
296 | - 'trial_period' => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null, |
|
297 | - 'trial_interval' => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null, |
|
298 | - ) |
|
291 | + 'is_recurring' => isset( $_POST['wpinv_is_recurring'] ), |
|
292 | + 'recurring_period' => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null, |
|
293 | + 'recurring_interval' => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1, |
|
294 | + 'recurring_limit' => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null, |
|
295 | + 'is_free_trial' => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null, |
|
296 | + 'trial_period' => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null, |
|
297 | + 'trial_interval' => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null, |
|
298 | + ) |
|
299 | 299 | ); |
300 | 300 | |
301 | - $item->save(); |
|
302 | - do_action( 'getpaid_item_metabox_save', $post_id, $item ); |
|
303 | - } |
|
301 | + $item->save(); |
|
302 | + do_action( 'getpaid_item_metabox_save', $post_id, $item ); |
|
303 | + } |
|
304 | 304 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -21,27 +21,27 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param WP_Post $post |
23 | 23 | */ |
24 | - public static function output( $post ) { |
|
24 | + public static function output($post) { |
|
25 | 25 | |
26 | 26 | // Prepare the item. |
27 | - $item = new WPInv_Item( $post ); |
|
27 | + $item = new WPInv_Item($post); |
|
28 | 28 | |
29 | 29 | // Nonce field. |
30 | - wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' ); |
|
30 | + wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce'); |
|
31 | 31 | |
32 | 32 | // Set the currency position. |
33 | 33 | $position = wpinv_currency_position(); |
34 | 34 | |
35 | - if ( $position == 'left_space' ) { |
|
35 | + if ($position == 'left_space') { |
|
36 | 36 | $position = 'left'; |
37 | 37 | } |
38 | 38 | |
39 | - if ( $position == 'right_space' ) { |
|
39 | + if ($position == 'right_space') { |
|
40 | 40 | $position = 'right'; |
41 | 41 | } |
42 | 42 | |
43 | 43 | ?> |
44 | - <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr( $item->get_type( 'edit' ) ); ?>" /> |
|
44 | + <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr($item->get_type('edit')); ?>" /> |
|
45 | 45 | <style> |
46 | 46 | #poststuff .input-group-text, |
47 | 47 | #poststuff .form-control { |
@@ -55,21 +55,21 @@ discard block |
||
55 | 55 | </style> |
56 | 56 | <div class='bsui' style='max-width: 600px;padding-top: 10px;'> |
57 | 57 | |
58 | - <?php do_action( 'wpinv_item_details_metabox_before_price', $item ); ?> |
|
58 | + <?php do_action('wpinv_item_details_metabox_before_price', $item); ?> |
|
59 | 59 | <div class="form-group row"> |
60 | - <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php _e( 'Item Price', 'invoicing' )?></span></label> |
|
60 | + <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php _e('Item Price', 'invoicing')?></span></label> |
|
61 | 61 | <div class="col-sm-8"> |
62 | 62 | <div class="row"> |
63 | 63 | <div class="col-sm-4 getpaid-price-input"> |
64 | 64 | <div class="input-group input-group-sm"> |
65 | - <?php if( 'left' == $position ) : ?> |
|
65 | + <?php if ('left' == $position) : ?> |
|
66 | 66 | <div class="input-group-prepend"> |
67 | 67 | <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wpinv_currency_symbol(); ?></span> |
68 | 68 | </div> |
69 | 69 | <?php endif; ?> |
70 | - <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr( $item->get_price( 'edit' ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control"> |
|
70 | + <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr($item->get_price('edit')); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control"> |
|
71 | 71 | |
72 | - <?php if( 'left' != $position ) : ?> |
|
72 | + <?php if ('left' != $position) : ?> |
|
73 | 73 | <div class="input-group-append"> |
74 | 74 | <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wpinv_currency_symbol(); ?></span> |
75 | 75 | </div> |
@@ -79,10 +79,10 @@ discard block |
||
79 | 79 | </div> |
80 | 80 | <div class="col-sm-4 wpinv_show_if_recurring"> |
81 | 81 | <?php |
82 | - _e( 'every' ); |
|
82 | + _e('every'); |
|
83 | 83 | echo " "; |
84 | 84 | ?> |
85 | - <input type="number" style="max-width: 60px;" value="<?php echo esc_attr( $item->get_recurring_interval( 'edit' ) ); ?>" placeholder="1" name="wpinv_recurring_interval" id="wpinv_recurring_interval" /> |
|
85 | + <input type="number" style="max-width: 60px;" value="<?php echo esc_attr($item->get_recurring_interval('edit')); ?>" placeholder="1" name="wpinv_recurring_interval" id="wpinv_recurring_interval" /> |
|
86 | 86 | </div> |
87 | 87 | <div class="col-sm-4 wpinv_show_if_recurring"> |
88 | 88 | <?php |
@@ -90,16 +90,16 @@ discard block |
||
90 | 90 | array( |
91 | 91 | 'id' => 'wpinv_recurring_period', |
92 | 92 | 'name' => 'wpinv_recurring_period', |
93 | - 'label' => __( 'Period', 'invoicing' ), |
|
94 | - 'placeholder' => __( 'Select Period', 'invoicing' ), |
|
95 | - 'value' => $item->get_recurring_period( 'edit' ), |
|
93 | + 'label' => __('Period', 'invoicing'), |
|
94 | + 'placeholder' => __('Select Period', 'invoicing'), |
|
95 | + 'value' => $item->get_recurring_period('edit'), |
|
96 | 96 | 'select2' => true, |
97 | 97 | 'data-allow-clear' => 'false', |
98 | 98 | 'options' => array( |
99 | - 'D' => __( 'day(s)', 'invoicing' ), |
|
100 | - 'W' => __( 'week(s)', 'invoicing' ), |
|
101 | - 'M' => __( 'month(s)', 'invoicing' ), |
|
102 | - 'Y' => __( 'year(s)', 'invoicing' ), |
|
99 | + 'D' => __('day(s)', 'invoicing'), |
|
100 | + 'W' => __('week(s)', 'invoicing'), |
|
101 | + 'M' => __('month(s)', 'invoicing'), |
|
102 | + 'Y' => __('year(s)', 'invoicing'), |
|
103 | 103 | ) |
104 | 104 | ) |
105 | 105 | ); |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | <?php |
112 | 112 | |
113 | 113 | // Dynamic pricing. |
114 | - if( $item->supports_dynamic_pricing() ) { |
|
114 | + if ($item->supports_dynamic_pricing()) { |
|
115 | 115 | |
116 | - do_action( 'wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item ); |
|
116 | + do_action('wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item); |
|
117 | 117 | |
118 | 118 | // NYP toggle. |
119 | 119 | echo aui()->input( |
@@ -121,31 +121,31 @@ discard block |
||
121 | 121 | 'id' => 'wpinv_name_your_price', |
122 | 122 | 'name' => 'wpinv_name_your_price', |
123 | 123 | 'type' => 'checkbox', |
124 | - 'label' => apply_filters( 'wpinv_name_your_price_toggle_text', __( 'Let customers name their price', 'invoicing' ) ), |
|
124 | + 'label' => apply_filters('wpinv_name_your_price_toggle_text', __('Let customers name their price', 'invoicing')), |
|
125 | 125 | 'value' => '1', |
126 | 126 | 'checked' => $item->user_can_set_their_price(), |
127 | 127 | 'no_wrap' => true, |
128 | 128 | ) |
129 | 129 | ); |
130 | 130 | |
131 | - do_action( 'wpinv_item_details_metabox_dynamic_pricing_checkbox', $item ); |
|
131 | + do_action('wpinv_item_details_metabox_dynamic_pricing_checkbox', $item); |
|
132 | 132 | |
133 | 133 | } |
134 | 134 | |
135 | 135 | // Subscriptions. |
136 | - do_action( 'wpinv_item_details_metabox_before_subscription_checkbox', $item ); |
|
136 | + do_action('wpinv_item_details_metabox_before_subscription_checkbox', $item); |
|
137 | 137 | echo aui()->input( |
138 | 138 | array( |
139 | 139 | 'id' => 'wpinv_is_recurring', |
140 | 140 | 'name' => 'wpinv_is_recurring', |
141 | 141 | 'type' => 'checkbox', |
142 | - 'label' => apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Charge customers a recurring amount for this item', 'invoicing' ) ), |
|
142 | + 'label' => apply_filters('wpinv_is_recurring_toggle_text', __('Charge customers a recurring amount for this item', 'invoicing')), |
|
143 | 143 | 'value' => '1', |
144 | 144 | 'checked' => $item->is_recurring(), |
145 | 145 | 'no_wrap' => true, |
146 | 146 | ) |
147 | 147 | ); |
148 | - do_action( 'wpinv_item_details_metabox_subscription_checkbox', $item ); |
|
148 | + do_action('wpinv_item_details_metabox_subscription_checkbox', $item); |
|
149 | 149 | |
150 | 150 | ?> |
151 | 151 | <div class="wpinv_show_if_recurring"> |
@@ -155,30 +155,30 @@ discard block |
||
155 | 155 | </div> |
156 | 156 | </div> |
157 | 157 | <div class="col-sm-1 pt-2 pl-0"> |
158 | - <span class="wpi-help-tip dashicons dashicons-editor-help wpinv_show_if_recurring" title="<?php esc_attr_e( 'Set the subscription price, billing interval and period.', 'invoicing' ); ?>"></span> |
|
158 | + <span class="wpi-help-tip dashicons dashicons-editor-help wpinv_show_if_recurring" title="<?php esc_attr_e('Set the subscription price, billing interval and period.', 'invoicing'); ?>"></span> |
|
159 | 159 | </div> |
160 | 160 | </div> |
161 | - <?php do_action( 'wpinv_item_details_metabox_after_price', $item ); ?> |
|
161 | + <?php do_action('wpinv_item_details_metabox_after_price', $item); ?> |
|
162 | 162 | |
163 | - <?php if( $item->supports_dynamic_pricing() ) : ?> |
|
164 | - <?php do_action( 'wpinv_item_details_metabox_before_minimum_price', $item ); ?> |
|
163 | + <?php if ($item->supports_dynamic_pricing()) : ?> |
|
164 | + <?php do_action('wpinv_item_details_metabox_before_minimum_price', $item); ?> |
|
165 | 165 | <div class="wpinv_show_if_dynamic wpinv_minimum_price"> |
166 | 166 | |
167 | 167 | <div class="form-group row"> |
168 | 168 | <label for="wpinv_minimum_price" class="col-sm-3 col-form-label"> |
169 | - <?php _e( 'Minimum Price', 'invoicing' );?> |
|
169 | + <?php _e('Minimum Price', 'invoicing'); ?> |
|
170 | 170 | </label> |
171 | 171 | <div class="col-sm-8"> |
172 | 172 | <div class="input-group input-group-sm"> |
173 | - <?php if( 'left' == $position ) : ?> |
|
173 | + <?php if ('left' == $position) : ?> |
|
174 | 174 | <div class="input-group-prepend"> |
175 | 175 | <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wpinv_currency_symbol(); ?></span> |
176 | 176 | </div> |
177 | 177 | <?php endif; ?> |
178 | 178 | |
179 | - <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr( $item->get_minimum_price( 'edit' ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control"> |
|
179 | + <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr($item->get_minimum_price('edit')); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control"> |
|
180 | 180 | |
181 | - <?php if( 'left' != $position ) : ?> |
|
181 | + <?php if ('left' != $position) : ?> |
|
182 | 182 | <div class="input-group-append"> |
183 | 183 | <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wpinv_currency_symbol(); ?></span> |
184 | 184 | </div> |
@@ -187,45 +187,45 @@ discard block |
||
187 | 187 | </div> |
188 | 188 | |
189 | 189 | <div class="col-sm-1 pt-2 pl-0"> |
190 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter the minimum amount that users are allowed to set', 'invoicing' ); ?>"></span> |
|
190 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter the minimum amount that users are allowed to set', 'invoicing'); ?>"></span> |
|
191 | 191 | </div> |
192 | 192 | </div> |
193 | 193 | |
194 | 194 | </div> |
195 | - <?php do_action( 'wpinv_item_details_metabox_minimum_price', $item ); ?> |
|
195 | + <?php do_action('wpinv_item_details_metabox_minimum_price', $item); ?> |
|
196 | 196 | <?php endif; ?> |
197 | 197 | |
198 | - <?php do_action( 'wpinv_item_details_metabox_before_maximum_renewals', $item ); ?> |
|
198 | + <?php do_action('wpinv_item_details_metabox_before_maximum_renewals', $item); ?> |
|
199 | 199 | <div class="wpinv_show_if_recurring wpinv_maximum_renewals"> |
200 | 200 | |
201 | 201 | <div class="form-group row"> |
202 | 202 | <label for="wpinv_recurring_limit" class="col-sm-3 col-form-label"> |
203 | - <?php _e( 'Maximum Renewals', 'invoicing' );?> |
|
203 | + <?php _e('Maximum Renewals', 'invoicing'); ?> |
|
204 | 204 | </label> |
205 | 205 | <div class="col-sm-8"> |
206 | - <input type="number" value="<?php echo esc_attr( $item->get_recurring_limit( 'edit' ) ); ?>" placeholder="0" name="wpinv_recurring_limit" id="wpinv_recurring_limit" style="width: 100%;" /> |
|
206 | + <input type="number" value="<?php echo esc_attr($item->get_recurring_limit('edit')); ?>" placeholder="0" name="wpinv_recurring_limit" id="wpinv_recurring_limit" style="width: 100%;" /> |
|
207 | 207 | </div> |
208 | 208 | <div class="col-sm-1 pt-2 pl-0"> |
209 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Leave empty if you want the subscription to renew until it is cancelled.', 'invoicing' ); ?>"></span> |
|
209 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Leave empty if you want the subscription to renew until it is cancelled.', 'invoicing'); ?>"></span> |
|
210 | 210 | </div> |
211 | 211 | </div> |
212 | 212 | |
213 | 213 | </div> |
214 | - <?php do_action( 'wpinv_item_details_metabox_maximum_renewals', $item ); ?> |
|
214 | + <?php do_action('wpinv_item_details_metabox_maximum_renewals', $item); ?> |
|
215 | 215 | |
216 | - <?php do_action( 'wpinv_item_details_metabox_before_free_trial', $item ); ?> |
|
216 | + <?php do_action('wpinv_item_details_metabox_before_free_trial', $item); ?> |
|
217 | 217 | <div class="wpinv_show_if_recurring wpinv_free_trial"> |
218 | 218 | |
219 | 219 | <div class="form-group row"> |
220 | - <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php _e( 'Free Trial', 'invoicing' )?></label> |
|
220 | + <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php _e('Free Trial', 'invoicing')?></label> |
|
221 | 221 | |
222 | 222 | <div class="col-sm-8"> |
223 | 223 | <div class="row"> |
224 | 224 | <div class="col-sm-6"> |
225 | - <?php $value = $item->has_free_trial() ? $item->get_trial_interval( 'edit' ) : 0;?> |
|
225 | + <?php $value = $item->has_free_trial() ? $item->get_trial_interval('edit') : 0; ?> |
|
226 | 226 | |
227 | 227 | <div> |
228 | - <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr( $value ); ?>" > |
|
228 | + <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr($value); ?>" > |
|
229 | 229 | </div> |
230 | 230 | </div> |
231 | 231 | <div class="col-sm-6"> |
@@ -234,17 +234,17 @@ discard block |
||
234 | 234 | array( |
235 | 235 | 'id' => 'wpinv_trial_period', |
236 | 236 | 'name' => 'wpinv_trial_period', |
237 | - 'label' => __( 'Trial Period', 'invoicing' ), |
|
238 | - 'placeholder' => __( 'Trial Period', 'invoicing' ), |
|
239 | - 'value' => $item->get_trial_period( 'edit' ), |
|
237 | + 'label' => __('Trial Period', 'invoicing'), |
|
238 | + 'placeholder' => __('Trial Period', 'invoicing'), |
|
239 | + 'value' => $item->get_trial_period('edit'), |
|
240 | 240 | 'select2' => true, |
241 | 241 | 'data-allow-clear' => 'false', |
242 | 242 | 'no_wrap' => true, |
243 | 243 | 'options' => array( |
244 | - 'D' => __( 'day(s)', 'invoicing' ), |
|
245 | - 'W' => __( 'week(s)', 'invoicing' ), |
|
246 | - 'M' => __( 'month(s)', 'invoicing' ), |
|
247 | - 'Y' => __( 'year(s)', 'invoicing' ), |
|
244 | + 'D' => __('day(s)', 'invoicing'), |
|
245 | + 'W' => __('week(s)', 'invoicing'), |
|
246 | + 'M' => __('month(s)', 'invoicing'), |
|
247 | + 'Y' => __('year(s)', 'invoicing'), |
|
248 | 248 | ) |
249 | 249 | ) |
250 | 250 | ); |
@@ -255,15 +255,15 @@ discard block |
||
255 | 255 | </div> |
256 | 256 | |
257 | 257 | <div class="col-sm-1 pt-2 pl-0"> |
258 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'An optional period of time to wait before charging the first recurring payment.', 'invoicing' ); ?>"></span> |
|
258 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('An optional period of time to wait before charging the first recurring payment.', 'invoicing'); ?>"></span> |
|
259 | 259 | </div> |
260 | 260 | |
261 | 261 | </div> |
262 | 262 | |
263 | 263 | </div> |
264 | - <?php do_action( 'wpinv_item_details_metabox__free_trial', $item ); ?> |
|
264 | + <?php do_action('wpinv_item_details_metabox__free_trial', $item); ?> |
|
265 | 265 | |
266 | - <?php do_action( 'wpinv_item_details_metabox_item_details', $item ); ?> |
|
266 | + <?php do_action('wpinv_item_details_metabox_item_details', $item); ?> |
|
267 | 267 | </div> |
268 | 268 | <?php |
269 | 269 | |
@@ -274,31 +274,31 @@ discard block |
||
274 | 274 | * |
275 | 275 | * @param int $post_id |
276 | 276 | */ |
277 | - public static function save( $post_id ) { |
|
277 | + public static function save($post_id) { |
|
278 | 278 | |
279 | 279 | // Prepare the item. |
280 | - $item = new WPInv_Item( $post_id ); |
|
280 | + $item = new WPInv_Item($post_id); |
|
281 | 281 | |
282 | 282 | // Load new data. |
283 | 283 | $item->set_props( |
284 | 284 | array( |
285 | - 'price' => isset( $_POST['wpinv_item_price'] ) ? (float) $_POST['wpinv_item_price'] : null, |
|
286 | - 'vat_rule' => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null, |
|
287 | - 'vat_class' => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null, |
|
288 | - 'type' => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null, |
|
289 | - 'is_dynamic_pricing' => isset( $_POST['wpinv_name_your_price'] ), |
|
290 | - 'minimum_price' => isset( $_POST['wpinv_minimum_price'] ) ? (float) $_POST['wpinv_minimum_price'] : null, |
|
291 | - 'is_recurring' => isset( $_POST['wpinv_is_recurring'] ), |
|
292 | - 'recurring_period' => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null, |
|
293 | - 'recurring_interval' => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1, |
|
294 | - 'recurring_limit' => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null, |
|
295 | - 'is_free_trial' => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null, |
|
296 | - 'trial_period' => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null, |
|
297 | - 'trial_interval' => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null, |
|
285 | + 'price' => isset($_POST['wpinv_item_price']) ? (float) $_POST['wpinv_item_price'] : null, |
|
286 | + 'vat_rule' => isset($_POST['wpinv_vat_rules']) ? wpinv_clean($_POST['wpinv_vat_rules']) : null, |
|
287 | + 'vat_class' => isset($_POST['wpinv_vat_class']) ? wpinv_clean($_POST['wpinv_vat_class']) : null, |
|
288 | + 'type' => isset($_POST['wpinv_item_type']) ? wpinv_clean($_POST['wpinv_item_type']) : null, |
|
289 | + 'is_dynamic_pricing' => isset($_POST['wpinv_name_your_price']), |
|
290 | + 'minimum_price' => isset($_POST['wpinv_minimum_price']) ? (float) $_POST['wpinv_minimum_price'] : null, |
|
291 | + 'is_recurring' => isset($_POST['wpinv_is_recurring']), |
|
292 | + 'recurring_period' => isset($_POST['wpinv_recurring_period']) ? wpinv_clean($_POST['wpinv_recurring_period']) : null, |
|
293 | + 'recurring_interval' => isset($_POST['wpinv_recurring_interval']) ? (int) $_POST['wpinv_recurring_interval'] : 1, |
|
294 | + 'recurring_limit' => isset($_POST['wpinv_recurring_limit']) ? (int) $_POST['wpinv_recurring_limit'] : null, |
|
295 | + 'is_free_trial' => isset($_POST['wpinv_trial_interval']) ? (0 != (int) $_POST['wpinv_trial_interval']) : null, |
|
296 | + 'trial_period' => isset($_POST['wpinv_trial_period']) ? wpinv_clean($_POST['wpinv_trial_period']) : null, |
|
297 | + 'trial_interval' => isset($_POST['wpinv_trial_interval']) ? (int) $_POST['wpinv_trial_interval'] : null, |
|
298 | 298 | ) |
299 | 299 | ); |
300 | 300 | |
301 | 301 | $item->save(); |
302 | - do_action( 'getpaid_item_metabox_save', $post_id, $item ); |
|
302 | + do_action('getpaid_item_metabox_save', $post_id, $item); |
|
303 | 303 | } |
304 | 304 | } |
@@ -13,648 +13,648 @@ discard block |
||
13 | 13 | class GetPaid_Post_Types_Admin { |
14 | 14 | |
15 | 15 | /** |
16 | - * Hook in methods. |
|
17 | - */ |
|
18 | - public static function init() { |
|
19 | - |
|
20 | - // Init metaboxes. |
|
21 | - GetPaid_Metaboxes::init(); |
|
22 | - |
|
23 | - // Filter the post updated messages. |
|
24 | - add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' ); |
|
25 | - |
|
26 | - // Filter post actions. |
|
27 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 ); |
|
28 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 ); |
|
29 | - |
|
30 | - // Invoice table columns. |
|
31 | - add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 ); |
|
32 | - add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 ); |
|
33 | - |
|
34 | - // Items table columns. |
|
35 | - add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
36 | - add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
37 | - add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
38 | - add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
39 | - add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
40 | - add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
41 | - |
|
42 | - // Payment forms columns. |
|
43 | - add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
44 | - add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
45 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
46 | - |
|
47 | - // Discount table columns. |
|
48 | - add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
49 | - add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 ); |
|
50 | - |
|
51 | - // Deleting posts. |
|
52 | - add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
53 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
54 | - |
|
55 | - add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 ); |
|
56 | - } |
|
57 | - |
|
58 | - /** |
|
59 | - * Post updated messages. |
|
60 | - */ |
|
61 | - public static function post_updated_messages( $messages ) { |
|
62 | - global $post; |
|
63 | - |
|
64 | - $messages['wpi_discount'] = array( |
|
65 | - 0 => '', |
|
66 | - 1 => __( 'Discount updated.', 'invoicing' ), |
|
67 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
68 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
69 | - 4 => __( 'Discount updated.', 'invoicing' ), |
|
70 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
71 | - 6 => __( 'Discount updated.', 'invoicing' ), |
|
72 | - 7 => __( 'Discount saved.', 'invoicing' ), |
|
73 | - 8 => __( 'Discount submitted.', 'invoicing' ), |
|
74 | - 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
75 | - 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
76 | - ); |
|
77 | - |
|
78 | - $messages['wpi_payment_form'] = array( |
|
79 | - 0 => '', |
|
80 | - 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
81 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
82 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
83 | - 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
84 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
85 | - 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
86 | - 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
87 | - 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
88 | - 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
89 | - 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
90 | - ); |
|
91 | - |
|
92 | - return $messages; |
|
93 | - |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * Post row actions. |
|
98 | - */ |
|
99 | - public static function post_row_actions( $actions, $post ) { |
|
100 | - |
|
101 | - $post = get_post( $post ); |
|
102 | - |
|
103 | - // We do not want to edit the default payment form. |
|
104 | - if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) { |
|
105 | - unset( $actions['trash'] ); |
|
106 | - unset( $actions['inline hide-if-no-js'] ); |
|
107 | - } |
|
108 | - |
|
109 | - return $actions; |
|
110 | - } |
|
111 | - |
|
112 | - /** |
|
16 | + * Hook in methods. |
|
17 | + */ |
|
18 | + public static function init() { |
|
19 | + |
|
20 | + // Init metaboxes. |
|
21 | + GetPaid_Metaboxes::init(); |
|
22 | + |
|
23 | + // Filter the post updated messages. |
|
24 | + add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' ); |
|
25 | + |
|
26 | + // Filter post actions. |
|
27 | + add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 ); |
|
28 | + add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 ); |
|
29 | + |
|
30 | + // Invoice table columns. |
|
31 | + add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 ); |
|
32 | + add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 ); |
|
33 | + |
|
34 | + // Items table columns. |
|
35 | + add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
36 | + add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
37 | + add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
38 | + add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
39 | + add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
40 | + add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
41 | + |
|
42 | + // Payment forms columns. |
|
43 | + add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
44 | + add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
45 | + add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
46 | + |
|
47 | + // Discount table columns. |
|
48 | + add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
49 | + add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 ); |
|
50 | + |
|
51 | + // Deleting posts. |
|
52 | + add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
53 | + add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
54 | + |
|
55 | + add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 ); |
|
56 | + } |
|
57 | + |
|
58 | + /** |
|
59 | + * Post updated messages. |
|
60 | + */ |
|
61 | + public static function post_updated_messages( $messages ) { |
|
62 | + global $post; |
|
63 | + |
|
64 | + $messages['wpi_discount'] = array( |
|
65 | + 0 => '', |
|
66 | + 1 => __( 'Discount updated.', 'invoicing' ), |
|
67 | + 2 => __( 'Custom field updated.', 'invoicing' ), |
|
68 | + 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
69 | + 4 => __( 'Discount updated.', 'invoicing' ), |
|
70 | + 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
71 | + 6 => __( 'Discount updated.', 'invoicing' ), |
|
72 | + 7 => __( 'Discount saved.', 'invoicing' ), |
|
73 | + 8 => __( 'Discount submitted.', 'invoicing' ), |
|
74 | + 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
75 | + 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
76 | + ); |
|
77 | + |
|
78 | + $messages['wpi_payment_form'] = array( |
|
79 | + 0 => '', |
|
80 | + 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
81 | + 2 => __( 'Custom field updated.', 'invoicing' ), |
|
82 | + 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
83 | + 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
84 | + 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
85 | + 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
86 | + 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
87 | + 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
88 | + 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
89 | + 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
90 | + ); |
|
91 | + |
|
92 | + return $messages; |
|
93 | + |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * Post row actions. |
|
98 | + */ |
|
99 | + public static function post_row_actions( $actions, $post ) { |
|
100 | + |
|
101 | + $post = get_post( $post ); |
|
102 | + |
|
103 | + // We do not want to edit the default payment form. |
|
104 | + if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) { |
|
105 | + unset( $actions['trash'] ); |
|
106 | + unset( $actions['inline hide-if-no-js'] ); |
|
107 | + } |
|
108 | + |
|
109 | + return $actions; |
|
110 | + } |
|
111 | + |
|
112 | + /** |
|
113 | 113 | * Remove bulk edit option from admin side quote listing |
114 | 114 | * |
115 | 115 | * @since 1.0.0 |
116 | 116 | * @param array $actions post actions |
117 | - * @param WP_Post $post |
|
117 | + * @param WP_Post $post |
|
118 | 118 | * @return array $actions actions without edit option |
119 | 119 | */ |
120 | 120 | public static function filter_invoice_row_actions( $actions, $post ) { |
121 | 121 | |
122 | 122 | if ( getpaid_is_invoice_post_type( $post->post_type ) ) { |
123 | 123 | |
124 | - $actions = array(); |
|
125 | - $invoice = new WPInv_Invoice( $post ); |
|
126 | - |
|
127 | - $actions['edit'] = sprintf( |
|
128 | - '<a href="%1$s">%2$s</a>', |
|
129 | - esc_url( get_edit_post_link( $invoice->get_id() ) ), |
|
130 | - esc_html( __( 'Edit', 'invoicing' ) ) |
|
131 | - ); |
|
132 | - |
|
133 | - if ( ! $invoice->is_draft() ) { |
|
134 | - |
|
135 | - $actions['view'] = sprintf( |
|
136 | - '<a href="%1$s">%2$s</a>', |
|
137 | - esc_url( $invoice->get_view_url() ), |
|
138 | - sprintf( |
|
139 | - esc_html( __( 'View %s', 'invoicing' ) ), |
|
140 | - getpaid_get_post_type_label( $invoice->get_post_type(), false ) |
|
141 | - ) |
|
142 | - ); |
|
143 | - |
|
144 | - $actions['send'] = sprintf( |
|
145 | - '<a href="%1$s">%2$s</a>', |
|
146 | - esc_url( |
|
147 | - wp_nonce_url( |
|
148 | - add_query_arg( |
|
149 | - array( |
|
150 | - 'getpaid-admin-action' => 'send_invoice', |
|
151 | - 'invoice_id' => $invoice->get_id() |
|
152 | - ) |
|
153 | - ), |
|
154 | - 'getpaid-nonce', |
|
155 | - 'getpaid-nonce' |
|
156 | - ) |
|
157 | - ), |
|
158 | - esc_html( __( 'Send to Customer', 'invoicing' ) ) |
|
159 | - ); |
|
160 | - |
|
161 | - } |
|
124 | + $actions = array(); |
|
125 | + $invoice = new WPInv_Invoice( $post ); |
|
126 | + |
|
127 | + $actions['edit'] = sprintf( |
|
128 | + '<a href="%1$s">%2$s</a>', |
|
129 | + esc_url( get_edit_post_link( $invoice->get_id() ) ), |
|
130 | + esc_html( __( 'Edit', 'invoicing' ) ) |
|
131 | + ); |
|
132 | + |
|
133 | + if ( ! $invoice->is_draft() ) { |
|
134 | + |
|
135 | + $actions['view'] = sprintf( |
|
136 | + '<a href="%1$s">%2$s</a>', |
|
137 | + esc_url( $invoice->get_view_url() ), |
|
138 | + sprintf( |
|
139 | + esc_html( __( 'View %s', 'invoicing' ) ), |
|
140 | + getpaid_get_post_type_label( $invoice->get_post_type(), false ) |
|
141 | + ) |
|
142 | + ); |
|
143 | + |
|
144 | + $actions['send'] = sprintf( |
|
145 | + '<a href="%1$s">%2$s</a>', |
|
146 | + esc_url( |
|
147 | + wp_nonce_url( |
|
148 | + add_query_arg( |
|
149 | + array( |
|
150 | + 'getpaid-admin-action' => 'send_invoice', |
|
151 | + 'invoice_id' => $invoice->get_id() |
|
152 | + ) |
|
153 | + ), |
|
154 | + 'getpaid-nonce', |
|
155 | + 'getpaid-nonce' |
|
156 | + ) |
|
157 | + ), |
|
158 | + esc_html( __( 'Send to Customer', 'invoicing' ) ) |
|
159 | + ); |
|
160 | + |
|
161 | + } |
|
162 | 162 | |
163 | 163 | } |
164 | 164 | |
165 | 165 | return $actions; |
166 | - } |
|
167 | - |
|
168 | - /** |
|
169 | - * Returns an array of invoice table columns. |
|
170 | - */ |
|
171 | - public static function invoice_columns( $columns ) { |
|
172 | - |
|
173 | - $columns = array( |
|
174 | - 'cb' => $columns['cb'], |
|
175 | - 'number' => __( 'Invoice', 'invoicing' ), |
|
176 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
177 | - 'invoice_date' => __( 'Created', 'invoicing' ), |
|
178 | - 'payment_date' => __( 'Completed', 'invoicing' ), |
|
179 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
180 | - 'recurring' => __( 'Recurring', 'invoicing' ), |
|
181 | - 'status' => __( 'Status', 'invoicing' ), |
|
182 | - ); |
|
183 | - |
|
184 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
185 | - } |
|
186 | - |
|
187 | - /** |
|
188 | - * Displays invoice table columns. |
|
189 | - */ |
|
190 | - public static function display_invoice_columns( $column_name, $post_id ) { |
|
191 | - |
|
192 | - $invoice = new WPInv_Invoice( $post_id ); |
|
193 | - |
|
194 | - switch ( $column_name ) { |
|
195 | - |
|
196 | - case 'invoice_date' : |
|
197 | - $date_time = esc_attr( $invoice->get_created_date() ); |
|
198 | - $date = getpaid_format_date_value( $date_time, "—", true ); |
|
199 | - echo "<span title='$date_time'>$date</span>"; |
|
200 | - break; |
|
201 | - |
|
202 | - case 'payment_date' : |
|
203 | - |
|
204 | - if ( $invoice->is_paid() ) { |
|
205 | - $date_time = esc_attr( $invoice->get_completed_date() ); |
|
206 | - $date = getpaid_format_date_value( $date_time, "—", true ); |
|
207 | - echo "<span title='$date_time'>$date</span>"; |
|
208 | - } else { |
|
209 | - echo "—"; |
|
210 | - } |
|
166 | + } |
|
167 | + |
|
168 | + /** |
|
169 | + * Returns an array of invoice table columns. |
|
170 | + */ |
|
171 | + public static function invoice_columns( $columns ) { |
|
172 | + |
|
173 | + $columns = array( |
|
174 | + 'cb' => $columns['cb'], |
|
175 | + 'number' => __( 'Invoice', 'invoicing' ), |
|
176 | + 'customer' => __( 'Customer', 'invoicing' ), |
|
177 | + 'invoice_date' => __( 'Created', 'invoicing' ), |
|
178 | + 'payment_date' => __( 'Completed', 'invoicing' ), |
|
179 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
180 | + 'recurring' => __( 'Recurring', 'invoicing' ), |
|
181 | + 'status' => __( 'Status', 'invoicing' ), |
|
182 | + ); |
|
183 | + |
|
184 | + return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
185 | + } |
|
186 | + |
|
187 | + /** |
|
188 | + * Displays invoice table columns. |
|
189 | + */ |
|
190 | + public static function display_invoice_columns( $column_name, $post_id ) { |
|
191 | + |
|
192 | + $invoice = new WPInv_Invoice( $post_id ); |
|
193 | + |
|
194 | + switch ( $column_name ) { |
|
195 | + |
|
196 | + case 'invoice_date' : |
|
197 | + $date_time = esc_attr( $invoice->get_created_date() ); |
|
198 | + $date = getpaid_format_date_value( $date_time, "—", true ); |
|
199 | + echo "<span title='$date_time'>$date</span>"; |
|
200 | + break; |
|
201 | + |
|
202 | + case 'payment_date' : |
|
203 | + |
|
204 | + if ( $invoice->is_paid() ) { |
|
205 | + $date_time = esc_attr( $invoice->get_completed_date() ); |
|
206 | + $date = getpaid_format_date_value( $date_time, "—", true ); |
|
207 | + echo "<span title='$date_time'>$date</span>"; |
|
208 | + } else { |
|
209 | + echo "—"; |
|
210 | + } |
|
211 | 211 | |
212 | - break; |
|
212 | + break; |
|
213 | 213 | |
214 | - case 'amount' : |
|
214 | + case 'amount' : |
|
215 | 215 | |
216 | - $amount = $invoice->get_total(); |
|
217 | - $formated_amount = wpinv_price( $amount, $invoice->get_currency() ); |
|
216 | + $amount = $invoice->get_total(); |
|
217 | + $formated_amount = wpinv_price( $amount, $invoice->get_currency() ); |
|
218 | 218 | |
219 | - if ( $invoice->is_refunded() ) { |
|
220 | - $refunded_amount = wpinv_price( 0, $invoice->get_currency() ); |
|
221 | - echo "<del>$formated_amount</del> <ins>$refunded_amount</ins>"; |
|
222 | - } else { |
|
219 | + if ( $invoice->is_refunded() ) { |
|
220 | + $refunded_amount = wpinv_price( 0, $invoice->get_currency() ); |
|
221 | + echo "<del>$formated_amount</del> <ins>$refunded_amount</ins>"; |
|
222 | + } else { |
|
223 | 223 | |
224 | - $discount = $invoice->get_total_discount(); |
|
224 | + $discount = $invoice->get_total_discount(); |
|
225 | 225 | |
226 | - if ( ! empty( $discount ) ) { |
|
227 | - $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() ); |
|
228 | - echo "<del>$new_amount</del> <ins>$formated_amount</ins>"; |
|
229 | - } else { |
|
230 | - echo $formated_amount; |
|
231 | - } |
|
226 | + if ( ! empty( $discount ) ) { |
|
227 | + $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() ); |
|
228 | + echo "<del>$new_amount</del> <ins>$formated_amount</ins>"; |
|
229 | + } else { |
|
230 | + echo $formated_amount; |
|
231 | + } |
|
232 | 232 | |
233 | - } |
|
233 | + } |
|
234 | 234 | |
235 | - break; |
|
235 | + break; |
|
236 | 236 | |
237 | - case 'status' : |
|
238 | - $status = sanitize_text_field( $invoice->get_status() ); |
|
239 | - $status_label = sanitize_text_field( $invoice->get_status_nicename() ); |
|
237 | + case 'status' : |
|
238 | + $status = sanitize_text_field( $invoice->get_status() ); |
|
239 | + $status_label = sanitize_text_field( $invoice->get_status_nicename() ); |
|
240 | 240 | |
241 | - // If it is paid, show the gateway title. |
|
242 | - if ( $invoice->is_paid() ) { |
|
243 | - $gateway = sanitize_text_field( $invoice->get_gateway_title() ); |
|
244 | - $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway ); |
|
241 | + // If it is paid, show the gateway title. |
|
242 | + if ( $invoice->is_paid() ) { |
|
243 | + $gateway = sanitize_text_field( $invoice->get_gateway_title() ); |
|
244 | + $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway ); |
|
245 | 245 | |
246 | - echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>"; |
|
247 | - } else { |
|
248 | - echo "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>"; |
|
249 | - } |
|
246 | + echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>"; |
|
247 | + } else { |
|
248 | + echo "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>"; |
|
249 | + } |
|
250 | 250 | |
251 | - // If it is not paid, display the overdue and view status. |
|
252 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
251 | + // If it is not paid, display the overdue and view status. |
|
252 | + if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
253 | 253 | |
254 | - // Invoice view status. |
|
255 | - if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
256 | - echo ' <i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
257 | - } else { |
|
258 | - echo ' <i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>'; |
|
259 | - } |
|
254 | + // Invoice view status. |
|
255 | + if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
256 | + echo ' <i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
257 | + } else { |
|
258 | + echo ' <i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>'; |
|
259 | + } |
|
260 | 260 | |
261 | - // Display the overview status. |
|
262 | - if ( wpinv_get_option( 'overdue_active' ) ) { |
|
263 | - $due_date = $invoice->get_due_date(); |
|
264 | - $fomatted = getpaid_format_date( $due_date ); |
|
261 | + // Display the overview status. |
|
262 | + if ( wpinv_get_option( 'overdue_active' ) ) { |
|
263 | + $due_date = $invoice->get_due_date(); |
|
264 | + $fomatted = getpaid_format_date( $due_date ); |
|
265 | 265 | |
266 | - if ( ! empty( $fomatted ) ) { |
|
267 | - $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted ); |
|
268 | - echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>"; |
|
269 | - } |
|
270 | - } |
|
266 | + if ( ! empty( $fomatted ) ) { |
|
267 | + $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted ); |
|
268 | + echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>"; |
|
269 | + } |
|
270 | + } |
|
271 | 271 | |
272 | - } |
|
272 | + } |
|
273 | 273 | |
274 | - break; |
|
274 | + break; |
|
275 | 275 | |
276 | - case 'recurring': |
|
276 | + case 'recurring': |
|
277 | 277 | |
278 | - if ( $invoice->is_recurring() ) { |
|
279 | - echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
|
280 | - } else { |
|
281 | - echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
|
282 | - } |
|
283 | - break; |
|
278 | + if ( $invoice->is_recurring() ) { |
|
279 | + echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
|
280 | + } else { |
|
281 | + echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
|
282 | + } |
|
283 | + break; |
|
284 | 284 | |
285 | - case 'number' : |
|
285 | + case 'number' : |
|
286 | 286 | |
287 | - $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
288 | - $invoice_number = sanitize_text_field( $invoice->get_number() ); |
|
289 | - $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
287 | + $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
288 | + $invoice_number = sanitize_text_field( $invoice->get_number() ); |
|
289 | + $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
290 | 290 | |
291 | - echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>"; |
|
291 | + echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>"; |
|
292 | 292 | |
293 | - break; |
|
293 | + break; |
|
294 | 294 | |
295 | - case 'customer' : |
|
295 | + case 'customer' : |
|
296 | 296 | |
297 | - $customer_name = $invoice->get_user_full_name(); |
|
297 | + $customer_name = $invoice->get_user_full_name(); |
|
298 | 298 | |
299 | - if ( empty( $customer_name ) ) { |
|
300 | - $customer_name = $invoice->get_email(); |
|
301 | - } |
|
299 | + if ( empty( $customer_name ) ) { |
|
300 | + $customer_name = $invoice->get_email(); |
|
301 | + } |
|
302 | 302 | |
303 | - if ( ! empty( $customer_name ) ) { |
|
304 | - $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
305 | - $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
306 | - echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>"; |
|
307 | - } else { |
|
308 | - echo '<div>—</div>'; |
|
309 | - } |
|
303 | + if ( ! empty( $customer_name ) ) { |
|
304 | + $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
305 | + $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
306 | + echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>"; |
|
307 | + } else { |
|
308 | + echo '<div>—</div>'; |
|
309 | + } |
|
310 | 310 | |
311 | - break; |
|
311 | + break; |
|
312 | 312 | |
313 | - } |
|
313 | + } |
|
314 | 314 | |
315 | - } |
|
315 | + } |
|
316 | 316 | |
317 | - /** |
|
318 | - * Returns an array of payment forms table columns. |
|
319 | - */ |
|
320 | - public static function payment_form_columns( $columns ) { |
|
317 | + /** |
|
318 | + * Returns an array of payment forms table columns. |
|
319 | + */ |
|
320 | + public static function payment_form_columns( $columns ) { |
|
321 | 321 | |
322 | - $columns = array( |
|
323 | - 'cb' => $columns['cb'], |
|
324 | - 'title' => __( 'Name', 'invoicing' ), |
|
325 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
326 | - 'earnings' => __( 'Revenue', 'invoicing' ), |
|
327 | - 'refunds' => __( 'Refunded', 'invoicing' ), |
|
328 | - 'items' => __( 'Items', 'invoicing' ), |
|
329 | - 'date' => __( 'Date', 'invoicing' ), |
|
330 | - ); |
|
322 | + $columns = array( |
|
323 | + 'cb' => $columns['cb'], |
|
324 | + 'title' => __( 'Name', 'invoicing' ), |
|
325 | + 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
326 | + 'earnings' => __( 'Revenue', 'invoicing' ), |
|
327 | + 'refunds' => __( 'Refunded', 'invoicing' ), |
|
328 | + 'items' => __( 'Items', 'invoicing' ), |
|
329 | + 'date' => __( 'Date', 'invoicing' ), |
|
330 | + ); |
|
331 | 331 | |
332 | - return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
332 | + return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
333 | 333 | |
334 | - } |
|
334 | + } |
|
335 | 335 | |
336 | - /** |
|
337 | - * Displays payment form table columns. |
|
338 | - */ |
|
339 | - public static function display_payment_form_columns( $column_name, $post_id ) { |
|
336 | + /** |
|
337 | + * Displays payment form table columns. |
|
338 | + */ |
|
339 | + public static function display_payment_form_columns( $column_name, $post_id ) { |
|
340 | 340 | |
341 | - // Retrieve the payment form. |
|
342 | - $form = new GetPaid_Payment_Form( $post_id ); |
|
341 | + // Retrieve the payment form. |
|
342 | + $form = new GetPaid_Payment_Form( $post_id ); |
|
343 | 343 | |
344 | - switch ( $column_name ) { |
|
344 | + switch ( $column_name ) { |
|
345 | 345 | |
346 | - case 'earnings' : |
|
347 | - echo wpinv_price( $form->get_earned() ); |
|
348 | - break; |
|
346 | + case 'earnings' : |
|
347 | + echo wpinv_price( $form->get_earned() ); |
|
348 | + break; |
|
349 | 349 | |
350 | - case 'refunds' : |
|
351 | - echo wpinv_price( $form->get_refunded() ); |
|
352 | - break; |
|
350 | + case 'refunds' : |
|
351 | + echo wpinv_price( $form->get_refunded() ); |
|
352 | + break; |
|
353 | 353 | |
354 | - case 'refunds' : |
|
355 | - echo wpinv_price( $form->get_refunded() ); |
|
356 | - break; |
|
354 | + case 'refunds' : |
|
355 | + echo wpinv_price( $form->get_refunded() ); |
|
356 | + break; |
|
357 | 357 | |
358 | - case 'shortcode' : |
|
358 | + case 'shortcode' : |
|
359 | 359 | |
360 | - if ( $form->is_default() ) { |
|
361 | - echo '—'; |
|
362 | - } else { |
|
363 | - echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
364 | - } |
|
360 | + if ( $form->is_default() ) { |
|
361 | + echo '—'; |
|
362 | + } else { |
|
363 | + echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
364 | + } |
|
365 | 365 | |
366 | - break; |
|
366 | + break; |
|
367 | 367 | |
368 | - case 'items' : |
|
368 | + case 'items' : |
|
369 | 369 | |
370 | - $items = $form->get_items(); |
|
370 | + $items = $form->get_items(); |
|
371 | 371 | |
372 | - if ( $form->is_default() || empty( $items ) ) { |
|
373 | - echo '—'; |
|
374 | - return; |
|
375 | - } |
|
372 | + if ( $form->is_default() || empty( $items ) ) { |
|
373 | + echo '—'; |
|
374 | + return; |
|
375 | + } |
|
376 | 376 | |
377 | - $_items = array(); |
|
377 | + $_items = array(); |
|
378 | 378 | |
379 | - foreach ( $items as $item ) { |
|
380 | - $url = $item->get_edit_url(); |
|
379 | + foreach ( $items as $item ) { |
|
380 | + $url = $item->get_edit_url(); |
|
381 | 381 | |
382 | - if ( empty( $url ) ) { |
|
383 | - $_items[] = sanitize_text_field( $item->get_name() ); |
|
384 | - } else { |
|
385 | - $_items[] = sprintf( |
|
386 | - '<a href="%s">%s</a>', |
|
387 | - esc_url( $url ), |
|
388 | - sanitize_text_field( $item->get_name() ) |
|
389 | - ); |
|
390 | - } |
|
382 | + if ( empty( $url ) ) { |
|
383 | + $_items[] = sanitize_text_field( $item->get_name() ); |
|
384 | + } else { |
|
385 | + $_items[] = sprintf( |
|
386 | + '<a href="%s">%s</a>', |
|
387 | + esc_url( $url ), |
|
388 | + sanitize_text_field( $item->get_name() ) |
|
389 | + ); |
|
390 | + } |
|
391 | 391 | |
392 | - } |
|
392 | + } |
|
393 | 393 | |
394 | - echo implode( '<br>', $_items ); |
|
394 | + echo implode( '<br>', $_items ); |
|
395 | 395 | |
396 | - break; |
|
396 | + break; |
|
397 | 397 | |
398 | - } |
|
398 | + } |
|
399 | 399 | |
400 | - } |
|
400 | + } |
|
401 | 401 | |
402 | - /** |
|
403 | - * Filters post states. |
|
404 | - */ |
|
405 | - public static function filter_payment_form_state( $post_states, $post ) { |
|
402 | + /** |
|
403 | + * Filters post states. |
|
404 | + */ |
|
405 | + public static function filter_payment_form_state( $post_states, $post ) { |
|
406 | 406 | |
407 | - if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) { |
|
408 | - $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' ); |
|
409 | - } |
|
407 | + if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) { |
|
408 | + $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' ); |
|
409 | + } |
|
410 | 410 | |
411 | - return $post_states; |
|
412 | - |
|
413 | - } |
|
414 | - |
|
415 | - /** |
|
416 | - * Returns an array of coupon table columns. |
|
417 | - */ |
|
418 | - public static function discount_columns( $columns ) { |
|
419 | - |
|
420 | - $columns = array( |
|
421 | - 'cb' => $columns['cb'], |
|
422 | - 'title' => __( 'Name', 'invoicing' ), |
|
423 | - 'code' => __( 'Code', 'invoicing' ), |
|
424 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
425 | - 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
426 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
427 | - 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
428 | - ); |
|
429 | - |
|
430 | - return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
431 | - } |
|
432 | - |
|
433 | - /** |
|
434 | - * Filters post states. |
|
435 | - */ |
|
436 | - public static function filter_discount_state( $post_states, $post ) { |
|
437 | - |
|
438 | - if ( 'wpi_discount' == $post->post_type ) { |
|
439 | - |
|
440 | - $discount = new WPInv_Discount( $post ); |
|
441 | - |
|
442 | - $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
|
443 | - |
|
444 | - if ( $status != 'publish' ) { |
|
445 | - return array( |
|
446 | - 'discount_status' => wpinv_discount_status( $status ), |
|
447 | - ); |
|
448 | - } |
|
449 | - |
|
450 | - return array(); |
|
451 | - |
|
452 | - } |
|
453 | - |
|
454 | - return $post_states; |
|
455 | - |
|
456 | - } |
|
457 | - |
|
458 | - /** |
|
459 | - * Returns an array of items table columns. |
|
460 | - */ |
|
461 | - public static function item_columns( $columns ) { |
|
462 | - |
|
463 | - $columns = array( |
|
464 | - 'cb' => $columns['cb'], |
|
465 | - 'title' => __( 'Name', 'invoicing' ), |
|
466 | - 'price' => __( 'Price', 'invoicing' ), |
|
467 | - 'vat_rule' => __( 'VAT rule', 'invoicing' ), |
|
468 | - 'vat_class' => __( 'VAT class', 'invoicing' ), |
|
469 | - 'type' => __( 'Type', 'invoicing' ), |
|
470 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
471 | - ); |
|
472 | - |
|
473 | - if ( ! wpinv_use_taxes() ) { |
|
474 | - unset( $columns['vat_rule'] ); |
|
475 | - unset( $columns['vat_class'] ); |
|
476 | - } |
|
477 | - |
|
478 | - return apply_filters( 'wpi_item_table_columns', $columns ); |
|
479 | - } |
|
480 | - |
|
481 | - /** |
|
482 | - * Returns an array of sortable items table columns. |
|
483 | - */ |
|
484 | - public static function sortable_item_columns( $columns ) { |
|
485 | - |
|
486 | - return array_merge( |
|
487 | - $columns, |
|
488 | - array( |
|
489 | - 'price' => 'price', |
|
490 | - 'vat_rule' => 'vat_rule', |
|
491 | - 'vat_class' => 'vat_class', |
|
492 | - 'type' => 'type', |
|
493 | - ) |
|
494 | - ); |
|
495 | - |
|
496 | - } |
|
497 | - |
|
498 | - /** |
|
499 | - * Displays items table columns. |
|
500 | - */ |
|
501 | - public static function display_item_columns( $column_name, $post_id ) { |
|
411 | + return $post_states; |
|
412 | + |
|
413 | + } |
|
414 | + |
|
415 | + /** |
|
416 | + * Returns an array of coupon table columns. |
|
417 | + */ |
|
418 | + public static function discount_columns( $columns ) { |
|
419 | + |
|
420 | + $columns = array( |
|
421 | + 'cb' => $columns['cb'], |
|
422 | + 'title' => __( 'Name', 'invoicing' ), |
|
423 | + 'code' => __( 'Code', 'invoicing' ), |
|
424 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
425 | + 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
426 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
427 | + 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
428 | + ); |
|
429 | + |
|
430 | + return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
431 | + } |
|
432 | + |
|
433 | + /** |
|
434 | + * Filters post states. |
|
435 | + */ |
|
436 | + public static function filter_discount_state( $post_states, $post ) { |
|
437 | + |
|
438 | + if ( 'wpi_discount' == $post->post_type ) { |
|
439 | + |
|
440 | + $discount = new WPInv_Discount( $post ); |
|
441 | + |
|
442 | + $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
|
443 | + |
|
444 | + if ( $status != 'publish' ) { |
|
445 | + return array( |
|
446 | + 'discount_status' => wpinv_discount_status( $status ), |
|
447 | + ); |
|
448 | + } |
|
449 | + |
|
450 | + return array(); |
|
451 | + |
|
452 | + } |
|
453 | + |
|
454 | + return $post_states; |
|
455 | + |
|
456 | + } |
|
457 | + |
|
458 | + /** |
|
459 | + * Returns an array of items table columns. |
|
460 | + */ |
|
461 | + public static function item_columns( $columns ) { |
|
462 | + |
|
463 | + $columns = array( |
|
464 | + 'cb' => $columns['cb'], |
|
465 | + 'title' => __( 'Name', 'invoicing' ), |
|
466 | + 'price' => __( 'Price', 'invoicing' ), |
|
467 | + 'vat_rule' => __( 'VAT rule', 'invoicing' ), |
|
468 | + 'vat_class' => __( 'VAT class', 'invoicing' ), |
|
469 | + 'type' => __( 'Type', 'invoicing' ), |
|
470 | + 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
471 | + ); |
|
472 | + |
|
473 | + if ( ! wpinv_use_taxes() ) { |
|
474 | + unset( $columns['vat_rule'] ); |
|
475 | + unset( $columns['vat_class'] ); |
|
476 | + } |
|
477 | + |
|
478 | + return apply_filters( 'wpi_item_table_columns', $columns ); |
|
479 | + } |
|
480 | + |
|
481 | + /** |
|
482 | + * Returns an array of sortable items table columns. |
|
483 | + */ |
|
484 | + public static function sortable_item_columns( $columns ) { |
|
485 | + |
|
486 | + return array_merge( |
|
487 | + $columns, |
|
488 | + array( |
|
489 | + 'price' => 'price', |
|
490 | + 'vat_rule' => 'vat_rule', |
|
491 | + 'vat_class' => 'vat_class', |
|
492 | + 'type' => 'type', |
|
493 | + ) |
|
494 | + ); |
|
495 | + |
|
496 | + } |
|
497 | + |
|
498 | + /** |
|
499 | + * Displays items table columns. |
|
500 | + */ |
|
501 | + public static function display_item_columns( $column_name, $post_id ) { |
|
502 | 502 | |
503 | - $item = new WPInv_Item( $post_id ); |
|
503 | + $item = new WPInv_Item( $post_id ); |
|
504 | 504 | |
505 | - switch ( $column_name ) { |
|
505 | + switch ( $column_name ) { |
|
506 | 506 | |
507 | - case 'price' : |
|
507 | + case 'price' : |
|
508 | 508 | |
509 | - if ( ! $item->is_recurring() ) { |
|
510 | - echo $item->get_the_price(); |
|
511 | - break; |
|
512 | - } |
|
509 | + if ( ! $item->is_recurring() ) { |
|
510 | + echo $item->get_the_price(); |
|
511 | + break; |
|
512 | + } |
|
513 | 513 | |
514 | - $price = wp_sprintf( |
|
515 | - __( '%s / %s', 'invoicing' ), |
|
516 | - $item->get_the_price(), |
|
517 | - getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ) |
|
518 | - ); |
|
514 | + $price = wp_sprintf( |
|
515 | + __( '%s / %s', 'invoicing' ), |
|
516 | + $item->get_the_price(), |
|
517 | + getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ) |
|
518 | + ); |
|
519 | 519 | |
520 | - if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
521 | - echo $price; |
|
522 | - break; |
|
523 | - } |
|
520 | + if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
521 | + echo $price; |
|
522 | + break; |
|
523 | + } |
|
524 | 524 | |
525 | - echo $item->get_the_initial_price(); |
|
525 | + echo $item->get_the_initial_price(); |
|
526 | 526 | |
527 | - echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price ) .'</span>'; |
|
528 | - break; |
|
527 | + echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price ) .'</span>'; |
|
528 | + break; |
|
529 | 529 | |
530 | - case 'vat_rule' : |
|
531 | - echo getpaid_get_tax_rule_label( $item->get_vat_rule() ); |
|
532 | - break; |
|
530 | + case 'vat_rule' : |
|
531 | + echo getpaid_get_tax_rule_label( $item->get_vat_rule() ); |
|
532 | + break; |
|
533 | 533 | |
534 | - case 'vat_class' : |
|
535 | - echo getpaid_get_tax_class_label( $item->get_vat_class() ); |
|
536 | - break; |
|
534 | + case 'vat_class' : |
|
535 | + echo getpaid_get_tax_class_label( $item->get_vat_class() ); |
|
536 | + break; |
|
537 | 537 | |
538 | - case 'shortcode' : |
|
539 | - echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
540 | - break; |
|
538 | + case 'shortcode' : |
|
539 | + echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
540 | + break; |
|
541 | 541 | |
542 | - case 'type' : |
|
543 | - echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
544 | - break; |
|
542 | + case 'type' : |
|
543 | + echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
544 | + break; |
|
545 | 545 | |
546 | - } |
|
546 | + } |
|
547 | 547 | |
548 | - } |
|
548 | + } |
|
549 | 549 | |
550 | - /** |
|
551 | - * Lets users filter items using taxes. |
|
552 | - */ |
|
553 | - public static function add_item_filters( $post_type ) { |
|
550 | + /** |
|
551 | + * Lets users filter items using taxes. |
|
552 | + */ |
|
553 | + public static function add_item_filters( $post_type ) { |
|
554 | 554 | |
555 | - // Abort if we're not dealing with items. |
|
556 | - if ( $post_type != 'wpi_item' ) { |
|
557 | - return; |
|
558 | - } |
|
555 | + // Abort if we're not dealing with items. |
|
556 | + if ( $post_type != 'wpi_item' ) { |
|
557 | + return; |
|
558 | + } |
|
559 | 559 | |
560 | - // Filter by vat rules. |
|
561 | - if ( wpinv_use_taxes() ) { |
|
560 | + // Filter by vat rules. |
|
561 | + if ( wpinv_use_taxes() ) { |
|
562 | 562 | |
563 | - // Sanitize selected vat rule. |
|
564 | - $vat_rule = ''; |
|
565 | - $vat_rules = getpaid_get_tax_rules(); |
|
566 | - if ( isset( $_GET['vat_rule'] ) ) { |
|
567 | - $vat_rule = $_GET['vat_rule']; |
|
568 | - } |
|
569 | - |
|
570 | - // Filter by VAT rule. |
|
571 | - echo wpinv_html_select( |
|
572 | - array( |
|
573 | - 'options' => array_merge( |
|
574 | - array( |
|
575 | - '' => __( 'All VAT rules', 'invoicing' ) |
|
576 | - ), |
|
577 | - $vat_rules |
|
578 | - ), |
|
579 | - 'name' => 'vat_rule', |
|
580 | - 'id' => 'vat_rule', |
|
581 | - 'selected' => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '', |
|
582 | - 'show_option_all' => false, |
|
583 | - 'show_option_none' => false, |
|
584 | - ) |
|
585 | - ); |
|
586 | - |
|
587 | - // Filter by VAT class. |
|
563 | + // Sanitize selected vat rule. |
|
564 | + $vat_rule = ''; |
|
565 | + $vat_rules = getpaid_get_tax_rules(); |
|
566 | + if ( isset( $_GET['vat_rule'] ) ) { |
|
567 | + $vat_rule = $_GET['vat_rule']; |
|
568 | + } |
|
569 | + |
|
570 | + // Filter by VAT rule. |
|
571 | + echo wpinv_html_select( |
|
572 | + array( |
|
573 | + 'options' => array_merge( |
|
574 | + array( |
|
575 | + '' => __( 'All VAT rules', 'invoicing' ) |
|
576 | + ), |
|
577 | + $vat_rules |
|
578 | + ), |
|
579 | + 'name' => 'vat_rule', |
|
580 | + 'id' => 'vat_rule', |
|
581 | + 'selected' => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '', |
|
582 | + 'show_option_all' => false, |
|
583 | + 'show_option_none' => false, |
|
584 | + ) |
|
585 | + ); |
|
586 | + |
|
587 | + // Filter by VAT class. |
|
588 | 588 | |
589 | - // Sanitize selected vat rule. |
|
590 | - $vat_class = ''; |
|
591 | - $vat_classes = getpaid_get_tax_classes(); |
|
592 | - if ( isset( $_GET['vat_class'] ) ) { |
|
593 | - $vat_class = $_GET['vat_class']; |
|
594 | - } |
|
595 | - |
|
596 | - echo wpinv_html_select( |
|
597 | - array( |
|
598 | - 'options' => array_merge( |
|
599 | - array( |
|
600 | - '' => __( 'All VAT classes', 'invoicing' ) |
|
601 | - ), |
|
602 | - $vat_classes |
|
603 | - ), |
|
604 | - 'name' => 'vat_class', |
|
605 | - 'id' => 'vat_class', |
|
606 | - 'selected' => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '', |
|
607 | - 'show_option_all' => false, |
|
608 | - 'show_option_none' => false, |
|
609 | - ) |
|
610 | - ); |
|
611 | - |
|
612 | - } |
|
613 | - |
|
614 | - // Filter by item type. |
|
615 | - $type = ''; |
|
616 | - if ( isset( $_GET['type'] ) ) { |
|
617 | - $type = $_GET['type']; |
|
618 | - } |
|
619 | - |
|
620 | - echo wpinv_html_select( |
|
621 | - array( |
|
622 | - 'options' => array_merge( |
|
623 | - array( |
|
624 | - '' => __( 'All item types', 'invoicing' ) |
|
625 | - ), |
|
626 | - wpinv_get_item_types() |
|
627 | - ), |
|
628 | - 'name' => 'type', |
|
629 | - 'id' => 'type', |
|
630 | - 'selected' => in_array( $type, wpinv_item_types() ) ? $type : '', |
|
631 | - 'show_option_all' => false, |
|
632 | - 'show_option_none' => false, |
|
633 | - ) |
|
634 | - ); |
|
635 | - |
|
636 | - } |
|
637 | - |
|
638 | - /** |
|
639 | - * Filters the item query. |
|
640 | - */ |
|
641 | - public static function filter_item_query( $query ) { |
|
642 | - |
|
643 | - // modify the query only if it admin and main query. |
|
644 | - if ( ! ( is_admin() && $query->is_main_query() ) ){ |
|
645 | - return $query; |
|
646 | - } |
|
647 | - |
|
648 | - // we want to modify the query for our items. |
|
649 | - if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ){ |
|
650 | - return $query; |
|
651 | - } |
|
652 | - |
|
653 | - if ( empty( $query->query_vars['meta_query'] ) ) { |
|
654 | - $query->query_vars['meta_query'] = array(); |
|
655 | - } |
|
656 | - |
|
657 | - // Filter vat rule type |
|
589 | + // Sanitize selected vat rule. |
|
590 | + $vat_class = ''; |
|
591 | + $vat_classes = getpaid_get_tax_classes(); |
|
592 | + if ( isset( $_GET['vat_class'] ) ) { |
|
593 | + $vat_class = $_GET['vat_class']; |
|
594 | + } |
|
595 | + |
|
596 | + echo wpinv_html_select( |
|
597 | + array( |
|
598 | + 'options' => array_merge( |
|
599 | + array( |
|
600 | + '' => __( 'All VAT classes', 'invoicing' ) |
|
601 | + ), |
|
602 | + $vat_classes |
|
603 | + ), |
|
604 | + 'name' => 'vat_class', |
|
605 | + 'id' => 'vat_class', |
|
606 | + 'selected' => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '', |
|
607 | + 'show_option_all' => false, |
|
608 | + 'show_option_none' => false, |
|
609 | + ) |
|
610 | + ); |
|
611 | + |
|
612 | + } |
|
613 | + |
|
614 | + // Filter by item type. |
|
615 | + $type = ''; |
|
616 | + if ( isset( $_GET['type'] ) ) { |
|
617 | + $type = $_GET['type']; |
|
618 | + } |
|
619 | + |
|
620 | + echo wpinv_html_select( |
|
621 | + array( |
|
622 | + 'options' => array_merge( |
|
623 | + array( |
|
624 | + '' => __( 'All item types', 'invoicing' ) |
|
625 | + ), |
|
626 | + wpinv_get_item_types() |
|
627 | + ), |
|
628 | + 'name' => 'type', |
|
629 | + 'id' => 'type', |
|
630 | + 'selected' => in_array( $type, wpinv_item_types() ) ? $type : '', |
|
631 | + 'show_option_all' => false, |
|
632 | + 'show_option_none' => false, |
|
633 | + ) |
|
634 | + ); |
|
635 | + |
|
636 | + } |
|
637 | + |
|
638 | + /** |
|
639 | + * Filters the item query. |
|
640 | + */ |
|
641 | + public static function filter_item_query( $query ) { |
|
642 | + |
|
643 | + // modify the query only if it admin and main query. |
|
644 | + if ( ! ( is_admin() && $query->is_main_query() ) ){ |
|
645 | + return $query; |
|
646 | + } |
|
647 | + |
|
648 | + // we want to modify the query for our items. |
|
649 | + if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ){ |
|
650 | + return $query; |
|
651 | + } |
|
652 | + |
|
653 | + if ( empty( $query->query_vars['meta_query'] ) ) { |
|
654 | + $query->query_vars['meta_query'] = array(); |
|
655 | + } |
|
656 | + |
|
657 | + // Filter vat rule type |
|
658 | 658 | if ( ! empty( $_GET['vat_rule'] ) ) { |
659 | 659 | $query->query_vars['meta_query'][] = array( |
660 | 660 | 'key' => '_wpinv_vat_rule', |
@@ -679,97 +679,97 @@ discard block |
||
679 | 679 | 'value' => sanitize_text_field( $_GET['type'] ), |
680 | 680 | 'compare' => '=' |
681 | 681 | ); |
682 | - } |
|
683 | - |
|
684 | - } |
|
685 | - |
|
686 | - /** |
|
687 | - * Reorders items. |
|
688 | - */ |
|
689 | - public static function reorder_items( $vars ) { |
|
690 | - global $typenow; |
|
691 | - |
|
692 | - if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
693 | - return $vars; |
|
694 | - } |
|
695 | - |
|
696 | - // By item type. |
|
697 | - if ( 'type' == $vars['orderby'] ) { |
|
698 | - return array_merge( |
|
699 | - $vars, |
|
700 | - array( |
|
701 | - 'meta_key' => '_wpinv_type', |
|
702 | - 'orderby' => 'meta_value' |
|
703 | - ) |
|
704 | - ); |
|
705 | - } |
|
706 | - |
|
707 | - // By vat class. |
|
708 | - if ( 'vat_class' == $vars['orderby'] ) { |
|
709 | - return array_merge( |
|
710 | - $vars, |
|
711 | - array( |
|
712 | - 'meta_key' => '_wpinv_vat_class', |
|
713 | - 'orderby' => 'meta_value' |
|
714 | - ) |
|
715 | - ); |
|
716 | - } |
|
717 | - |
|
718 | - // By vat rule. |
|
719 | - if ( 'vat_rule' == $vars['orderby'] ) { |
|
720 | - return array_merge( |
|
721 | - $vars, |
|
722 | - array( |
|
723 | - 'meta_key' => '_wpinv_vat_rule', |
|
724 | - 'orderby' => 'meta_value' |
|
725 | - ) |
|
726 | - ); |
|
727 | - } |
|
728 | - |
|
729 | - // By price. |
|
730 | - if ( 'price' == $vars['orderby'] ) { |
|
731 | - return array_merge( |
|
732 | - $vars, |
|
733 | - array( |
|
734 | - 'meta_key' => '_wpinv_price', |
|
735 | - 'orderby' => 'meta_value_num' |
|
736 | - ) |
|
737 | - ); |
|
738 | - } |
|
739 | - |
|
740 | - return $vars; |
|
741 | - |
|
742 | - } |
|
743 | - |
|
744 | - /** |
|
745 | - * Fired when deleting a post. |
|
746 | - */ |
|
747 | - public static function delete_post( $post_id ) { |
|
748 | - |
|
749 | - switch ( get_post_type( $post_id ) ) { |
|
750 | - |
|
751 | - case 'wpi_item' : |
|
752 | - do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) ); |
|
753 | - break; |
|
754 | - |
|
755 | - case 'wpi_payment_form' : |
|
756 | - do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) ); |
|
757 | - break; |
|
758 | - |
|
759 | - case 'wpi_discount' : |
|
760 | - do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) ); |
|
761 | - break; |
|
762 | - |
|
763 | - case 'wpi_invoice' : |
|
764 | - $invoice = new WPInv_Invoice( $post_id ); |
|
765 | - do_action( "getpaid_before_delete_invoice", $invoice ); |
|
766 | - $invoice->get_data_store()->delete_items( $invoice ); |
|
767 | - $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
768 | - break; |
|
769 | - } |
|
770 | - } |
|
771 | - |
|
772 | - /** |
|
682 | + } |
|
683 | + |
|
684 | + } |
|
685 | + |
|
686 | + /** |
|
687 | + * Reorders items. |
|
688 | + */ |
|
689 | + public static function reorder_items( $vars ) { |
|
690 | + global $typenow; |
|
691 | + |
|
692 | + if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
693 | + return $vars; |
|
694 | + } |
|
695 | + |
|
696 | + // By item type. |
|
697 | + if ( 'type' == $vars['orderby'] ) { |
|
698 | + return array_merge( |
|
699 | + $vars, |
|
700 | + array( |
|
701 | + 'meta_key' => '_wpinv_type', |
|
702 | + 'orderby' => 'meta_value' |
|
703 | + ) |
|
704 | + ); |
|
705 | + } |
|
706 | + |
|
707 | + // By vat class. |
|
708 | + if ( 'vat_class' == $vars['orderby'] ) { |
|
709 | + return array_merge( |
|
710 | + $vars, |
|
711 | + array( |
|
712 | + 'meta_key' => '_wpinv_vat_class', |
|
713 | + 'orderby' => 'meta_value' |
|
714 | + ) |
|
715 | + ); |
|
716 | + } |
|
717 | + |
|
718 | + // By vat rule. |
|
719 | + if ( 'vat_rule' == $vars['orderby'] ) { |
|
720 | + return array_merge( |
|
721 | + $vars, |
|
722 | + array( |
|
723 | + 'meta_key' => '_wpinv_vat_rule', |
|
724 | + 'orderby' => 'meta_value' |
|
725 | + ) |
|
726 | + ); |
|
727 | + } |
|
728 | + |
|
729 | + // By price. |
|
730 | + if ( 'price' == $vars['orderby'] ) { |
|
731 | + return array_merge( |
|
732 | + $vars, |
|
733 | + array( |
|
734 | + 'meta_key' => '_wpinv_price', |
|
735 | + 'orderby' => 'meta_value_num' |
|
736 | + ) |
|
737 | + ); |
|
738 | + } |
|
739 | + |
|
740 | + return $vars; |
|
741 | + |
|
742 | + } |
|
743 | + |
|
744 | + /** |
|
745 | + * Fired when deleting a post. |
|
746 | + */ |
|
747 | + public static function delete_post( $post_id ) { |
|
748 | + |
|
749 | + switch ( get_post_type( $post_id ) ) { |
|
750 | + |
|
751 | + case 'wpi_item' : |
|
752 | + do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) ); |
|
753 | + break; |
|
754 | + |
|
755 | + case 'wpi_payment_form' : |
|
756 | + do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) ); |
|
757 | + break; |
|
758 | + |
|
759 | + case 'wpi_discount' : |
|
760 | + do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) ); |
|
761 | + break; |
|
762 | + |
|
763 | + case 'wpi_invoice' : |
|
764 | + $invoice = new WPInv_Invoice( $post_id ); |
|
765 | + do_action( "getpaid_before_delete_invoice", $invoice ); |
|
766 | + $invoice->get_data_store()->delete_items( $invoice ); |
|
767 | + $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
768 | + break; |
|
769 | + } |
|
770 | + } |
|
771 | + |
|
772 | + /** |
|
773 | 773 | * Add a post display state for special GetPaid pages in the page list table. |
774 | 774 | * |
775 | 775 | * @param array $post_states An array of post display states. |
@@ -783,22 +783,22 @@ discard block |
||
783 | 783 | $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' ); |
784 | 784 | } |
785 | 785 | |
786 | - foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) { |
|
786 | + foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) { |
|
787 | 787 | |
788 | - if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) { |
|
789 | - $post_states["getpaid_{$post_type}_history_page"] = sprintf( |
|
790 | - __( 'GetPaid %s History Page', 'invoicing' ), |
|
791 | - $label |
|
792 | - ); |
|
793 | - } |
|
788 | + if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) { |
|
789 | + $post_states["getpaid_{$post_type}_history_page"] = sprintf( |
|
790 | + __( 'GetPaid %s History Page', 'invoicing' ), |
|
791 | + $label |
|
792 | + ); |
|
793 | + } |
|
794 | 794 | |
795 | - } |
|
795 | + } |
|
796 | 796 | |
797 | - if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) { |
|
797 | + if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) { |
|
798 | 798 | $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscription Page', 'invoicing' ); |
799 | 799 | } |
800 | 800 | |
801 | - if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) { |
|
801 | + if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) { |
|
802 | 802 | $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' ); |
803 | 803 | } |
804 | 804 |
@@ -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 | * Post types Admin Class |
@@ -21,72 +21,72 @@ discard block |
||
21 | 21 | GetPaid_Metaboxes::init(); |
22 | 22 | |
23 | 23 | // Filter the post updated messages. |
24 | - add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' ); |
|
24 | + add_filter('post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages'); |
|
25 | 25 | |
26 | 26 | // Filter post actions. |
27 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 ); |
|
28 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 ); |
|
27 | + add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2); |
|
28 | + add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2); |
|
29 | 29 | |
30 | 30 | // Invoice table columns. |
31 | - add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 ); |
|
32 | - add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 ); |
|
31 | + add_filter('manage_wpi_invoice_posts_columns', array(__CLASS__, 'invoice_columns'), 100); |
|
32 | + add_action('manage_wpi_invoice_posts_custom_column', array(__CLASS__, 'display_invoice_columns'), 10, 2); |
|
33 | 33 | |
34 | 34 | // Items table columns. |
35 | - add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
36 | - add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
37 | - add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
38 | - add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
39 | - add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
40 | - add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
35 | + add_filter('manage_wpi_item_posts_columns', array(__CLASS__, 'item_columns'), 100); |
|
36 | + add_filter('manage_edit-wpi_item_sortable_columns', array(__CLASS__, 'sortable_item_columns'), 20); |
|
37 | + add_action('manage_wpi_item_posts_custom_column', array(__CLASS__, 'display_item_columns'), 10, 2); |
|
38 | + add_action('restrict_manage_posts', array(__CLASS__, 'add_item_filters'), 100); |
|
39 | + add_action('parse_query', array(__CLASS__, 'filter_item_query'), 100); |
|
40 | + add_action('request', array(__CLASS__, 'reorder_items'), 100); |
|
41 | 41 | |
42 | 42 | // Payment forms columns. |
43 | - add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
44 | - add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
45 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
43 | + add_filter('manage_wpi_payment_form_posts_columns', array(__CLASS__, 'payment_form_columns'), 100); |
|
44 | + add_action('manage_wpi_payment_form_posts_custom_column', array(__CLASS__, 'display_payment_form_columns'), 10, 2); |
|
45 | + add_filter('display_post_states', array(__CLASS__, 'filter_payment_form_state'), 10, 2); |
|
46 | 46 | |
47 | 47 | // Discount table columns. |
48 | - add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
49 | - add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 ); |
|
48 | + add_filter('manage_wpi_discount_posts_columns', array(__CLASS__, 'discount_columns'), 100); |
|
49 | + add_filter('bulk_actions-edit-wpi_discount', '__return_empty_array', 100); |
|
50 | 50 | |
51 | 51 | // Deleting posts. |
52 | - add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
53 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
52 | + add_action('delete_post', array(__CLASS__, 'delete_post')); |
|
53 | + add_filter('display_post_states', array(__CLASS__, 'filter_discount_state'), 10, 2); |
|
54 | 54 | |
55 | - add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 ); |
|
55 | + add_filter('display_post_states', array(__CLASS__, 'add_display_post_states'), 10, 2); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
59 | 59 | * Post updated messages. |
60 | 60 | */ |
61 | - public static function post_updated_messages( $messages ) { |
|
61 | + public static function post_updated_messages($messages) { |
|
62 | 62 | global $post; |
63 | 63 | |
64 | 64 | $messages['wpi_discount'] = array( |
65 | 65 | 0 => '', |
66 | - 1 => __( 'Discount updated.', 'invoicing' ), |
|
67 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
68 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
69 | - 4 => __( 'Discount updated.', 'invoicing' ), |
|
70 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
71 | - 6 => __( 'Discount updated.', 'invoicing' ), |
|
72 | - 7 => __( 'Discount saved.', 'invoicing' ), |
|
73 | - 8 => __( 'Discount submitted.', 'invoicing' ), |
|
74 | - 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
75 | - 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
66 | + 1 => __('Discount updated.', 'invoicing'), |
|
67 | + 2 => __('Custom field updated.', 'invoicing'), |
|
68 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
69 | + 4 => __('Discount updated.', 'invoicing'), |
|
70 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
71 | + 6 => __('Discount updated.', 'invoicing'), |
|
72 | + 7 => __('Discount saved.', 'invoicing'), |
|
73 | + 8 => __('Discount submitted.', 'invoicing'), |
|
74 | + 9 => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
75 | + 10 => __('Discount draft updated.', 'invoicing'), |
|
76 | 76 | ); |
77 | 77 | |
78 | 78 | $messages['wpi_payment_form'] = array( |
79 | 79 | 0 => '', |
80 | - 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
81 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
82 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
83 | - 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
84 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
85 | - 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
86 | - 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
87 | - 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
88 | - 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
89 | - 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
80 | + 1 => __('Payment Form updated.', 'invoicing'), |
|
81 | + 2 => __('Custom field updated.', 'invoicing'), |
|
82 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
83 | + 4 => __('Payment Form updated.', 'invoicing'), |
|
84 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Payment Form restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
85 | + 6 => __('Payment Form updated.', 'invoicing'), |
|
86 | + 7 => __('Payment Form saved.', 'invoicing'), |
|
87 | + 8 => __('Payment Form submitted.', 'invoicing'), |
|
88 | + 9 => wp_sprintf(__('Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
89 | + 10 => __('Payment Form draft updated.', 'invoicing'), |
|
90 | 90 | ); |
91 | 91 | |
92 | 92 | return $messages; |
@@ -96,14 +96,14 @@ discard block |
||
96 | 96 | /** |
97 | 97 | * Post row actions. |
98 | 98 | */ |
99 | - public static function post_row_actions( $actions, $post ) { |
|
99 | + public static function post_row_actions($actions, $post) { |
|
100 | 100 | |
101 | - $post = get_post( $post ); |
|
101 | + $post = get_post($post); |
|
102 | 102 | |
103 | 103 | // We do not want to edit the default payment form. |
104 | - if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) { |
|
105 | - unset( $actions['trash'] ); |
|
106 | - unset( $actions['inline hide-if-no-js'] ); |
|
104 | + if ('wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form()) { |
|
105 | + unset($actions['trash']); |
|
106 | + unset($actions['inline hide-if-no-js']); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | return $actions; |
@@ -117,31 +117,31 @@ discard block |
||
117 | 117 | * @param WP_Post $post |
118 | 118 | * @return array $actions actions without edit option |
119 | 119 | */ |
120 | - public static function filter_invoice_row_actions( $actions, $post ) { |
|
120 | + public static function filter_invoice_row_actions($actions, $post) { |
|
121 | 121 | |
122 | - if ( getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
122 | + if (getpaid_is_invoice_post_type($post->post_type)) { |
|
123 | 123 | |
124 | 124 | $actions = array(); |
125 | - $invoice = new WPInv_Invoice( $post ); |
|
125 | + $invoice = new WPInv_Invoice($post); |
|
126 | 126 | |
127 | - $actions['edit'] = sprintf( |
|
127 | + $actions['edit'] = sprintf( |
|
128 | 128 | '<a href="%1$s">%2$s</a>', |
129 | - esc_url( get_edit_post_link( $invoice->get_id() ) ), |
|
130 | - esc_html( __( 'Edit', 'invoicing' ) ) |
|
129 | + esc_url(get_edit_post_link($invoice->get_id())), |
|
130 | + esc_html(__('Edit', 'invoicing')) |
|
131 | 131 | ); |
132 | 132 | |
133 | - if ( ! $invoice->is_draft() ) { |
|
133 | + if (!$invoice->is_draft()) { |
|
134 | 134 | |
135 | - $actions['view'] = sprintf( |
|
135 | + $actions['view'] = sprintf( |
|
136 | 136 | '<a href="%1$s">%2$s</a>', |
137 | - esc_url( $invoice->get_view_url() ), |
|
137 | + esc_url($invoice->get_view_url()), |
|
138 | 138 | sprintf( |
139 | - esc_html( __( 'View %s', 'invoicing' ) ), |
|
140 | - getpaid_get_post_type_label( $invoice->get_post_type(), false ) |
|
139 | + esc_html(__('View %s', 'invoicing')), |
|
140 | + getpaid_get_post_type_label($invoice->get_post_type(), false) |
|
141 | 141 | ) |
142 | 142 | ); |
143 | 143 | |
144 | - $actions['send'] = sprintf( |
|
144 | + $actions['send'] = sprintf( |
|
145 | 145 | '<a href="%1$s">%2$s</a>', |
146 | 146 | esc_url( |
147 | 147 | wp_nonce_url( |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | 'getpaid-nonce' |
156 | 156 | ) |
157 | 157 | ), |
158 | - esc_html( __( 'Send to Customer', 'invoicing' ) ) |
|
158 | + esc_html(__('Send to Customer', 'invoicing')) |
|
159 | 159 | ); |
160 | 160 | |
161 | 161 | } |
@@ -168,42 +168,42 @@ discard block |
||
168 | 168 | /** |
169 | 169 | * Returns an array of invoice table columns. |
170 | 170 | */ |
171 | - public static function invoice_columns( $columns ) { |
|
171 | + public static function invoice_columns($columns) { |
|
172 | 172 | |
173 | 173 | $columns = array( |
174 | 174 | 'cb' => $columns['cb'], |
175 | - 'number' => __( 'Invoice', 'invoicing' ), |
|
176 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
177 | - 'invoice_date' => __( 'Created', 'invoicing' ), |
|
178 | - 'payment_date' => __( 'Completed', 'invoicing' ), |
|
179 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
180 | - 'recurring' => __( 'Recurring', 'invoicing' ), |
|
181 | - 'status' => __( 'Status', 'invoicing' ), |
|
175 | + 'number' => __('Invoice', 'invoicing'), |
|
176 | + 'customer' => __('Customer', 'invoicing'), |
|
177 | + 'invoice_date' => __('Created', 'invoicing'), |
|
178 | + 'payment_date' => __('Completed', 'invoicing'), |
|
179 | + 'amount' => __('Amount', 'invoicing'), |
|
180 | + 'recurring' => __('Recurring', 'invoicing'), |
|
181 | + 'status' => __('Status', 'invoicing'), |
|
182 | 182 | ); |
183 | 183 | |
184 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
184 | + return apply_filters('wpi_invoice_table_columns', $columns); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | /** |
188 | 188 | * Displays invoice table columns. |
189 | 189 | */ |
190 | - public static function display_invoice_columns( $column_name, $post_id ) { |
|
190 | + public static function display_invoice_columns($column_name, $post_id) { |
|
191 | 191 | |
192 | - $invoice = new WPInv_Invoice( $post_id ); |
|
192 | + $invoice = new WPInv_Invoice($post_id); |
|
193 | 193 | |
194 | - switch ( $column_name ) { |
|
194 | + switch ($column_name) { |
|
195 | 195 | |
196 | 196 | case 'invoice_date' : |
197 | - $date_time = esc_attr( $invoice->get_created_date() ); |
|
198 | - $date = getpaid_format_date_value( $date_time, "—", true ); |
|
197 | + $date_time = esc_attr($invoice->get_created_date()); |
|
198 | + $date = getpaid_format_date_value($date_time, "—", true); |
|
199 | 199 | echo "<span title='$date_time'>$date</span>"; |
200 | 200 | break; |
201 | 201 | |
202 | 202 | case 'payment_date' : |
203 | 203 | |
204 | - if ( $invoice->is_paid() ) { |
|
205 | - $date_time = esc_attr( $invoice->get_completed_date() ); |
|
206 | - $date = getpaid_format_date_value( $date_time, "—", true ); |
|
204 | + if ($invoice->is_paid()) { |
|
205 | + $date_time = esc_attr($invoice->get_completed_date()); |
|
206 | + $date = getpaid_format_date_value($date_time, "—", true); |
|
207 | 207 | echo "<span title='$date_time'>$date</span>"; |
208 | 208 | } else { |
209 | 209 | echo "—"; |
@@ -214,17 +214,17 @@ discard block |
||
214 | 214 | case 'amount' : |
215 | 215 | |
216 | 216 | $amount = $invoice->get_total(); |
217 | - $formated_amount = wpinv_price( $amount, $invoice->get_currency() ); |
|
217 | + $formated_amount = wpinv_price($amount, $invoice->get_currency()); |
|
218 | 218 | |
219 | - if ( $invoice->is_refunded() ) { |
|
220 | - $refunded_amount = wpinv_price( 0, $invoice->get_currency() ); |
|
219 | + if ($invoice->is_refunded()) { |
|
220 | + $refunded_amount = wpinv_price(0, $invoice->get_currency()); |
|
221 | 221 | echo "<del>$formated_amount</del> <ins>$refunded_amount</ins>"; |
222 | 222 | } else { |
223 | 223 | |
224 | 224 | $discount = $invoice->get_total_discount(); |
225 | 225 | |
226 | - if ( ! empty( $discount ) ) { |
|
227 | - $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() ); |
|
226 | + if (!empty($discount)) { |
|
227 | + $new_amount = wpinv_price($amount + $discount, $invoice->get_currency()); |
|
228 | 228 | echo "<del>$new_amount</del> <ins>$formated_amount</ins>"; |
229 | 229 | } else { |
230 | 230 | echo $formated_amount; |
@@ -235,13 +235,13 @@ discard block |
||
235 | 235 | break; |
236 | 236 | |
237 | 237 | case 'status' : |
238 | - $status = sanitize_text_field( $invoice->get_status() ); |
|
239 | - $status_label = sanitize_text_field( $invoice->get_status_nicename() ); |
|
238 | + $status = sanitize_text_field($invoice->get_status()); |
|
239 | + $status_label = sanitize_text_field($invoice->get_status_nicename()); |
|
240 | 240 | |
241 | 241 | // If it is paid, show the gateway title. |
242 | - if ( $invoice->is_paid() ) { |
|
243 | - $gateway = sanitize_text_field( $invoice->get_gateway_title() ); |
|
244 | - $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway ); |
|
242 | + if ($invoice->is_paid()) { |
|
243 | + $gateway = sanitize_text_field($invoice->get_gateway_title()); |
|
244 | + $gateway = wp_sprintf(esc_attr__('Paid via %s', 'invoicing'), $gateway); |
|
245 | 245 | |
246 | 246 | echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>"; |
247 | 247 | } else { |
@@ -249,22 +249,22 @@ discard block |
||
249 | 249 | } |
250 | 250 | |
251 | 251 | // If it is not paid, display the overdue and view status. |
252 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
252 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
253 | 253 | |
254 | 254 | // Invoice view status. |
255 | - if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
256 | - echo ' <i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
255 | + if (wpinv_is_invoice_viewed($invoice->get_id())) { |
|
256 | + echo ' <i class="fa fa-eye wpi-help-tip" title="' . esc_attr__('Viewed by Customer', 'invoicing') . '"></i>'; |
|
257 | 257 | } else { |
258 | - echo ' <i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>'; |
|
258 | + echo ' <i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__('Not Viewed by Customer', 'invoicing') . '"></i>'; |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | // Display the overview status. |
262 | - if ( wpinv_get_option( 'overdue_active' ) ) { |
|
262 | + if (wpinv_get_option('overdue_active')) { |
|
263 | 263 | $due_date = $invoice->get_due_date(); |
264 | - $fomatted = getpaid_format_date( $due_date ); |
|
264 | + $fomatted = getpaid_format_date($due_date); |
|
265 | 265 | |
266 | - if ( ! empty( $fomatted ) ) { |
|
267 | - $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted ); |
|
266 | + if (!empty($fomatted)) { |
|
267 | + $date = wp_sprintf(__('Due %s', 'invoicing'), $fomatted); |
|
268 | 268 | echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>"; |
269 | 269 | } |
270 | 270 | } |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | |
276 | 276 | case 'recurring': |
277 | 277 | |
278 | - if ( $invoice->is_recurring() ) { |
|
278 | + if ($invoice->is_recurring()) { |
|
279 | 279 | echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
280 | 280 | } else { |
281 | 281 | echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
@@ -284,9 +284,9 @@ discard block |
||
284 | 284 | |
285 | 285 | case 'number' : |
286 | 286 | |
287 | - $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
288 | - $invoice_number = sanitize_text_field( $invoice->get_number() ); |
|
289 | - $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
287 | + $edit_link = esc_url(get_edit_post_link($invoice->get_id())); |
|
288 | + $invoice_number = sanitize_text_field($invoice->get_number()); |
|
289 | + $invoice_details = esc_attr__('View Invoice Details', 'invoicing'); |
|
290 | 290 | |
291 | 291 | echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>"; |
292 | 292 | |
@@ -296,13 +296,13 @@ discard block |
||
296 | 296 | |
297 | 297 | $customer_name = $invoice->get_user_full_name(); |
298 | 298 | |
299 | - if ( empty( $customer_name ) ) { |
|
299 | + if (empty($customer_name)) { |
|
300 | 300 | $customer_name = $invoice->get_email(); |
301 | 301 | } |
302 | 302 | |
303 | - if ( ! empty( $customer_name ) ) { |
|
304 | - $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
305 | - $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
303 | + if (!empty($customer_name)) { |
|
304 | + $customer_details = esc_attr__('View Customer Details', 'invoicing'); |
|
305 | + $view_link = esc_url(add_query_arg('user_id', $invoice->get_user_id(), admin_url('user-edit.php'))); |
|
306 | 306 | echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>"; |
307 | 307 | } else { |
308 | 308 | echo '<div>—</div>'; |
@@ -317,50 +317,50 @@ discard block |
||
317 | 317 | /** |
318 | 318 | * Returns an array of payment forms table columns. |
319 | 319 | */ |
320 | - public static function payment_form_columns( $columns ) { |
|
320 | + public static function payment_form_columns($columns) { |
|
321 | 321 | |
322 | 322 | $columns = array( |
323 | 323 | 'cb' => $columns['cb'], |
324 | - 'title' => __( 'Name', 'invoicing' ), |
|
325 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
326 | - 'earnings' => __( 'Revenue', 'invoicing' ), |
|
327 | - 'refunds' => __( 'Refunded', 'invoicing' ), |
|
328 | - 'items' => __( 'Items', 'invoicing' ), |
|
329 | - 'date' => __( 'Date', 'invoicing' ), |
|
324 | + 'title' => __('Name', 'invoicing'), |
|
325 | + 'shortcode' => __('Shortcode', 'invoicing'), |
|
326 | + 'earnings' => __('Revenue', 'invoicing'), |
|
327 | + 'refunds' => __('Refunded', 'invoicing'), |
|
328 | + 'items' => __('Items', 'invoicing'), |
|
329 | + 'date' => __('Date', 'invoicing'), |
|
330 | 330 | ); |
331 | 331 | |
332 | - return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
332 | + return apply_filters('wpi_payment_form_table_columns', $columns); |
|
333 | 333 | |
334 | 334 | } |
335 | 335 | |
336 | 336 | /** |
337 | 337 | * Displays payment form table columns. |
338 | 338 | */ |
339 | - public static function display_payment_form_columns( $column_name, $post_id ) { |
|
339 | + public static function display_payment_form_columns($column_name, $post_id) { |
|
340 | 340 | |
341 | 341 | // Retrieve the payment form. |
342 | - $form = new GetPaid_Payment_Form( $post_id ); |
|
342 | + $form = new GetPaid_Payment_Form($post_id); |
|
343 | 343 | |
344 | - switch ( $column_name ) { |
|
344 | + switch ($column_name) { |
|
345 | 345 | |
346 | 346 | case 'earnings' : |
347 | - echo wpinv_price( $form->get_earned() ); |
|
347 | + echo wpinv_price($form->get_earned()); |
|
348 | 348 | break; |
349 | 349 | |
350 | 350 | case 'refunds' : |
351 | - echo wpinv_price( $form->get_refunded() ); |
|
351 | + echo wpinv_price($form->get_refunded()); |
|
352 | 352 | break; |
353 | 353 | |
354 | 354 | case 'refunds' : |
355 | - echo wpinv_price( $form->get_refunded() ); |
|
355 | + echo wpinv_price($form->get_refunded()); |
|
356 | 356 | break; |
357 | 357 | |
358 | 358 | case 'shortcode' : |
359 | 359 | |
360 | - if ( $form->is_default() ) { |
|
360 | + if ($form->is_default()) { |
|
361 | 361 | echo '—'; |
362 | 362 | } else { |
363 | - echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
363 | + echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr($form->get_id()) . ']" style="width: 100%;" readonly/>'; |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | break; |
@@ -369,29 +369,29 @@ discard block |
||
369 | 369 | |
370 | 370 | $items = $form->get_items(); |
371 | 371 | |
372 | - if ( $form->is_default() || empty( $items ) ) { |
|
372 | + if ($form->is_default() || empty($items)) { |
|
373 | 373 | echo '—'; |
374 | 374 | return; |
375 | 375 | } |
376 | 376 | |
377 | 377 | $_items = array(); |
378 | 378 | |
379 | - foreach ( $items as $item ) { |
|
379 | + foreach ($items as $item) { |
|
380 | 380 | $url = $item->get_edit_url(); |
381 | 381 | |
382 | - if ( empty( $url ) ) { |
|
383 | - $_items[] = sanitize_text_field( $item->get_name() ); |
|
382 | + if (empty($url)) { |
|
383 | + $_items[] = sanitize_text_field($item->get_name()); |
|
384 | 384 | } else { |
385 | 385 | $_items[] = sprintf( |
386 | 386 | '<a href="%s">%s</a>', |
387 | - esc_url( $url ), |
|
388 | - sanitize_text_field( $item->get_name() ) |
|
387 | + esc_url($url), |
|
388 | + sanitize_text_field($item->get_name()) |
|
389 | 389 | ); |
390 | 390 | } |
391 | 391 | |
392 | 392 | } |
393 | 393 | |
394 | - echo implode( '<br>', $_items ); |
|
394 | + echo implode('<br>', $_items); |
|
395 | 395 | |
396 | 396 | break; |
397 | 397 | |
@@ -402,10 +402,10 @@ discard block |
||
402 | 402 | /** |
403 | 403 | * Filters post states. |
404 | 404 | */ |
405 | - public static function filter_payment_form_state( $post_states, $post ) { |
|
405 | + public static function filter_payment_form_state($post_states, $post) { |
|
406 | 406 | |
407 | - if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) { |
|
408 | - $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' ); |
|
407 | + if ('wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID) { |
|
408 | + $post_states['default_form'] = __('Default Payment Form', 'invoicing'); |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | return $post_states; |
@@ -415,35 +415,35 @@ discard block |
||
415 | 415 | /** |
416 | 416 | * Returns an array of coupon table columns. |
417 | 417 | */ |
418 | - public static function discount_columns( $columns ) { |
|
418 | + public static function discount_columns($columns) { |
|
419 | 419 | |
420 | 420 | $columns = array( |
421 | 421 | 'cb' => $columns['cb'], |
422 | - 'title' => __( 'Name', 'invoicing' ), |
|
423 | - 'code' => __( 'Code', 'invoicing' ), |
|
424 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
425 | - 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
426 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
427 | - 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
422 | + 'title' => __('Name', 'invoicing'), |
|
423 | + 'code' => __('Code', 'invoicing'), |
|
424 | + 'amount' => __('Amount', 'invoicing'), |
|
425 | + 'usage' => __('Usage / Limit', 'invoicing'), |
|
426 | + 'start_date' => __('Start Date', 'invoicing'), |
|
427 | + 'expiry_date' => __('Expiry Date', 'invoicing'), |
|
428 | 428 | ); |
429 | 429 | |
430 | - return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
430 | + return apply_filters('wpi_discount_table_columns', $columns); |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | /** |
434 | 434 | * Filters post states. |
435 | 435 | */ |
436 | - public static function filter_discount_state( $post_states, $post ) { |
|
436 | + public static function filter_discount_state($post_states, $post) { |
|
437 | 437 | |
438 | - if ( 'wpi_discount' == $post->post_type ) { |
|
438 | + if ('wpi_discount' == $post->post_type) { |
|
439 | 439 | |
440 | - $discount = new WPInv_Discount( $post ); |
|
440 | + $discount = new WPInv_Discount($post); |
|
441 | 441 | |
442 | 442 | $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
443 | 443 | |
444 | - if ( $status != 'publish' ) { |
|
444 | + if ($status != 'publish') { |
|
445 | 445 | return array( |
446 | - 'discount_status' => wpinv_discount_status( $status ), |
|
446 | + 'discount_status' => wpinv_discount_status($status), |
|
447 | 447 | ); |
448 | 448 | } |
449 | 449 | |
@@ -458,30 +458,30 @@ discard block |
||
458 | 458 | /** |
459 | 459 | * Returns an array of items table columns. |
460 | 460 | */ |
461 | - public static function item_columns( $columns ) { |
|
461 | + public static function item_columns($columns) { |
|
462 | 462 | |
463 | 463 | $columns = array( |
464 | 464 | 'cb' => $columns['cb'], |
465 | - 'title' => __( 'Name', 'invoicing' ), |
|
466 | - 'price' => __( 'Price', 'invoicing' ), |
|
467 | - 'vat_rule' => __( 'VAT rule', 'invoicing' ), |
|
468 | - 'vat_class' => __( 'VAT class', 'invoicing' ), |
|
469 | - 'type' => __( 'Type', 'invoicing' ), |
|
470 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
465 | + 'title' => __('Name', 'invoicing'), |
|
466 | + 'price' => __('Price', 'invoicing'), |
|
467 | + 'vat_rule' => __('VAT rule', 'invoicing'), |
|
468 | + 'vat_class' => __('VAT class', 'invoicing'), |
|
469 | + 'type' => __('Type', 'invoicing'), |
|
470 | + 'shortcode' => __('Shortcode', 'invoicing'), |
|
471 | 471 | ); |
472 | 472 | |
473 | - if ( ! wpinv_use_taxes() ) { |
|
474 | - unset( $columns['vat_rule'] ); |
|
475 | - unset( $columns['vat_class'] ); |
|
473 | + if (!wpinv_use_taxes()) { |
|
474 | + unset($columns['vat_rule']); |
|
475 | + unset($columns['vat_class']); |
|
476 | 476 | } |
477 | 477 | |
478 | - return apply_filters( 'wpi_item_table_columns', $columns ); |
|
478 | + return apply_filters('wpi_item_table_columns', $columns); |
|
479 | 479 | } |
480 | 480 | |
481 | 481 | /** |
482 | 482 | * Returns an array of sortable items table columns. |
483 | 483 | */ |
484 | - public static function sortable_item_columns( $columns ) { |
|
484 | + public static function sortable_item_columns($columns) { |
|
485 | 485 | |
486 | 486 | return array_merge( |
487 | 487 | $columns, |
@@ -498,49 +498,49 @@ discard block |
||
498 | 498 | /** |
499 | 499 | * Displays items table columns. |
500 | 500 | */ |
501 | - public static function display_item_columns( $column_name, $post_id ) { |
|
501 | + public static function display_item_columns($column_name, $post_id) { |
|
502 | 502 | |
503 | - $item = new WPInv_Item( $post_id ); |
|
503 | + $item = new WPInv_Item($post_id); |
|
504 | 504 | |
505 | - switch ( $column_name ) { |
|
505 | + switch ($column_name) { |
|
506 | 506 | |
507 | 507 | case 'price' : |
508 | 508 | |
509 | - if ( ! $item->is_recurring() ) { |
|
509 | + if (!$item->is_recurring()) { |
|
510 | 510 | echo $item->get_the_price(); |
511 | 511 | break; |
512 | 512 | } |
513 | 513 | |
514 | 514 | $price = wp_sprintf( |
515 | - __( '%s / %s', 'invoicing' ), |
|
515 | + __('%s / %s', 'invoicing'), |
|
516 | 516 | $item->get_the_price(), |
517 | - getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ) |
|
517 | + getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), '') |
|
518 | 518 | ); |
519 | 519 | |
520 | - if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
520 | + if ($item->get_the_price() == $item->get_the_initial_price()) { |
|
521 | 521 | echo $price; |
522 | 522 | break; |
523 | 523 | } |
524 | 524 | |
525 | 525 | echo $item->get_the_initial_price(); |
526 | 526 | |
527 | - echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price ) .'</span>'; |
|
527 | + echo '<span class="meta">' . wp_sprintf(__('then %s', 'invoicing'), $price) . '</span>'; |
|
528 | 528 | break; |
529 | 529 | |
530 | 530 | case 'vat_rule' : |
531 | - echo getpaid_get_tax_rule_label( $item->get_vat_rule() ); |
|
531 | + echo getpaid_get_tax_rule_label($item->get_vat_rule()); |
|
532 | 532 | break; |
533 | 533 | |
534 | 534 | case 'vat_class' : |
535 | - echo getpaid_get_tax_class_label( $item->get_vat_class() ); |
|
535 | + echo getpaid_get_tax_class_label($item->get_vat_class()); |
|
536 | 536 | break; |
537 | 537 | |
538 | 538 | case 'shortcode' : |
539 | - echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
539 | + echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr($item->get_id()) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
540 | 540 | break; |
541 | 541 | |
542 | 542 | case 'type' : |
543 | - echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
543 | + echo wpinv_item_type($item->get_id()) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
544 | 544 | break; |
545 | 545 | |
546 | 546 | } |
@@ -550,21 +550,21 @@ discard block |
||
550 | 550 | /** |
551 | 551 | * Lets users filter items using taxes. |
552 | 552 | */ |
553 | - public static function add_item_filters( $post_type ) { |
|
553 | + public static function add_item_filters($post_type) { |
|
554 | 554 | |
555 | 555 | // Abort if we're not dealing with items. |
556 | - if ( $post_type != 'wpi_item' ) { |
|
556 | + if ($post_type != 'wpi_item') { |
|
557 | 557 | return; |
558 | 558 | } |
559 | 559 | |
560 | 560 | // Filter by vat rules. |
561 | - if ( wpinv_use_taxes() ) { |
|
561 | + if (wpinv_use_taxes()) { |
|
562 | 562 | |
563 | 563 | // Sanitize selected vat rule. |
564 | 564 | $vat_rule = ''; |
565 | 565 | $vat_rules = getpaid_get_tax_rules(); |
566 | - if ( isset( $_GET['vat_rule'] ) ) { |
|
567 | - $vat_rule = $_GET['vat_rule']; |
|
566 | + if (isset($_GET['vat_rule'])) { |
|
567 | + $vat_rule = $_GET['vat_rule']; |
|
568 | 568 | } |
569 | 569 | |
570 | 570 | // Filter by VAT rule. |
@@ -572,13 +572,13 @@ discard block |
||
572 | 572 | array( |
573 | 573 | 'options' => array_merge( |
574 | 574 | array( |
575 | - '' => __( 'All VAT rules', 'invoicing' ) |
|
575 | + '' => __('All VAT rules', 'invoicing') |
|
576 | 576 | ), |
577 | 577 | $vat_rules |
578 | 578 | ), |
579 | 579 | 'name' => 'vat_rule', |
580 | 580 | 'id' => 'vat_rule', |
581 | - 'selected' => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '', |
|
581 | + 'selected' => in_array($vat_rule, array_keys($vat_rules)) ? $vat_rule : '', |
|
582 | 582 | 'show_option_all' => false, |
583 | 583 | 'show_option_none' => false, |
584 | 584 | ) |
@@ -589,21 +589,21 @@ discard block |
||
589 | 589 | // Sanitize selected vat rule. |
590 | 590 | $vat_class = ''; |
591 | 591 | $vat_classes = getpaid_get_tax_classes(); |
592 | - if ( isset( $_GET['vat_class'] ) ) { |
|
593 | - $vat_class = $_GET['vat_class']; |
|
592 | + if (isset($_GET['vat_class'])) { |
|
593 | + $vat_class = $_GET['vat_class']; |
|
594 | 594 | } |
595 | 595 | |
596 | 596 | echo wpinv_html_select( |
597 | 597 | array( |
598 | 598 | 'options' => array_merge( |
599 | 599 | array( |
600 | - '' => __( 'All VAT classes', 'invoicing' ) |
|
600 | + '' => __('All VAT classes', 'invoicing') |
|
601 | 601 | ), |
602 | 602 | $vat_classes |
603 | 603 | ), |
604 | 604 | 'name' => 'vat_class', |
605 | 605 | 'id' => 'vat_class', |
606 | - 'selected' => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '', |
|
606 | + 'selected' => in_array($vat_class, array_keys($vat_classes)) ? $vat_class : '', |
|
607 | 607 | 'show_option_all' => false, |
608 | 608 | 'show_option_none' => false, |
609 | 609 | ) |
@@ -612,22 +612,22 @@ discard block |
||
612 | 612 | } |
613 | 613 | |
614 | 614 | // Filter by item type. |
615 | - $type = ''; |
|
616 | - if ( isset( $_GET['type'] ) ) { |
|
617 | - $type = $_GET['type']; |
|
615 | + $type = ''; |
|
616 | + if (isset($_GET['type'])) { |
|
617 | + $type = $_GET['type']; |
|
618 | 618 | } |
619 | 619 | |
620 | 620 | echo wpinv_html_select( |
621 | 621 | array( |
622 | 622 | 'options' => array_merge( |
623 | 623 | array( |
624 | - '' => __( 'All item types', 'invoicing' ) |
|
624 | + '' => __('All item types', 'invoicing') |
|
625 | 625 | ), |
626 | 626 | wpinv_get_item_types() |
627 | 627 | ), |
628 | 628 | 'name' => 'type', |
629 | 629 | 'id' => 'type', |
630 | - 'selected' => in_array( $type, wpinv_item_types() ) ? $type : '', |
|
630 | + 'selected' => in_array($type, wpinv_item_types()) ? $type : '', |
|
631 | 631 | 'show_option_all' => false, |
632 | 632 | 'show_option_none' => false, |
633 | 633 | ) |
@@ -638,45 +638,45 @@ discard block |
||
638 | 638 | /** |
639 | 639 | * Filters the item query. |
640 | 640 | */ |
641 | - public static function filter_item_query( $query ) { |
|
641 | + public static function filter_item_query($query) { |
|
642 | 642 | |
643 | 643 | // modify the query only if it admin and main query. |
644 | - if ( ! ( is_admin() && $query->is_main_query() ) ){ |
|
644 | + if (!(is_admin() && $query->is_main_query())) { |
|
645 | 645 | return $query; |
646 | 646 | } |
647 | 647 | |
648 | 648 | // we want to modify the query for our items. |
649 | - if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ){ |
|
649 | + if (empty($query->query['post_type']) || 'wpi_item' != $query->query['post_type']) { |
|
650 | 650 | return $query; |
651 | 651 | } |
652 | 652 | |
653 | - if ( empty( $query->query_vars['meta_query'] ) ) { |
|
653 | + if (empty($query->query_vars['meta_query'])) { |
|
654 | 654 | $query->query_vars['meta_query'] = array(); |
655 | 655 | } |
656 | 656 | |
657 | 657 | // Filter vat rule type |
658 | - if ( ! empty( $_GET['vat_rule'] ) ) { |
|
658 | + if (!empty($_GET['vat_rule'])) { |
|
659 | 659 | $query->query_vars['meta_query'][] = array( |
660 | 660 | 'key' => '_wpinv_vat_rule', |
661 | - 'value' => sanitize_text_field( $_GET['vat_rule'] ), |
|
661 | + 'value' => sanitize_text_field($_GET['vat_rule']), |
|
662 | 662 | 'compare' => '=' |
663 | 663 | ); |
664 | 664 | } |
665 | 665 | |
666 | 666 | // Filter vat class |
667 | - if ( ! empty( $_GET['vat_class'] ) ) { |
|
667 | + if (!empty($_GET['vat_class'])) { |
|
668 | 668 | $query->query_vars['meta_query'][] = array( |
669 | 669 | 'key' => '_wpinv_vat_class', |
670 | - 'value' => sanitize_text_field( $_GET['vat_class'] ), |
|
670 | + 'value' => sanitize_text_field($_GET['vat_class']), |
|
671 | 671 | 'compare' => '=' |
672 | 672 | ); |
673 | 673 | } |
674 | 674 | |
675 | 675 | // Filter item type |
676 | - if ( ! empty( $_GET['type'] ) ) { |
|
676 | + if (!empty($_GET['type'])) { |
|
677 | 677 | $query->query_vars['meta_query'][] = array( |
678 | 678 | 'key' => '_wpinv_type', |
679 | - 'value' => sanitize_text_field( $_GET['type'] ), |
|
679 | + 'value' => sanitize_text_field($_GET['type']), |
|
680 | 680 | 'compare' => '=' |
681 | 681 | ); |
682 | 682 | } |
@@ -686,15 +686,15 @@ discard block |
||
686 | 686 | /** |
687 | 687 | * Reorders items. |
688 | 688 | */ |
689 | - public static function reorder_items( $vars ) { |
|
689 | + public static function reorder_items($vars) { |
|
690 | 690 | global $typenow; |
691 | 691 | |
692 | - if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
692 | + if ('wpi_item' !== $typenow || empty($vars['orderby'])) { |
|
693 | 693 | return $vars; |
694 | 694 | } |
695 | 695 | |
696 | 696 | // By item type. |
697 | - if ( 'type' == $vars['orderby'] ) { |
|
697 | + if ('type' == $vars['orderby']) { |
|
698 | 698 | return array_merge( |
699 | 699 | $vars, |
700 | 700 | array( |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | } |
706 | 706 | |
707 | 707 | // By vat class. |
708 | - if ( 'vat_class' == $vars['orderby'] ) { |
|
708 | + if ('vat_class' == $vars['orderby']) { |
|
709 | 709 | return array_merge( |
710 | 710 | $vars, |
711 | 711 | array( |
@@ -716,7 +716,7 @@ discard block |
||
716 | 716 | } |
717 | 717 | |
718 | 718 | // By vat rule. |
719 | - if ( 'vat_rule' == $vars['orderby'] ) { |
|
719 | + if ('vat_rule' == $vars['orderby']) { |
|
720 | 720 | return array_merge( |
721 | 721 | $vars, |
722 | 722 | array( |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | } |
728 | 728 | |
729 | 729 | // By price. |
730 | - if ( 'price' == $vars['orderby'] ) { |
|
730 | + if ('price' == $vars['orderby']) { |
|
731 | 731 | return array_merge( |
732 | 732 | $vars, |
733 | 733 | array( |
@@ -744,27 +744,27 @@ discard block |
||
744 | 744 | /** |
745 | 745 | * Fired when deleting a post. |
746 | 746 | */ |
747 | - public static function delete_post( $post_id ) { |
|
747 | + public static function delete_post($post_id) { |
|
748 | 748 | |
749 | - switch ( get_post_type( $post_id ) ) { |
|
749 | + switch (get_post_type($post_id)) { |
|
750 | 750 | |
751 | 751 | case 'wpi_item' : |
752 | - do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) ); |
|
752 | + do_action("getpaid_before_delete_item", new WPInv_Item($post_id)); |
|
753 | 753 | break; |
754 | 754 | |
755 | 755 | case 'wpi_payment_form' : |
756 | - do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) ); |
|
756 | + do_action("getpaid_before_delete_payment_form", new GetPaid_Payment_Form($post_id)); |
|
757 | 757 | break; |
758 | 758 | |
759 | 759 | case 'wpi_discount' : |
760 | - do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) ); |
|
760 | + do_action("getpaid_before_delete_discount", new WPInv_Discount($post_id)); |
|
761 | 761 | break; |
762 | 762 | |
763 | 763 | case 'wpi_invoice' : |
764 | - $invoice = new WPInv_Invoice( $post_id ); |
|
765 | - do_action( "getpaid_before_delete_invoice", $invoice ); |
|
766 | - $invoice->get_data_store()->delete_items( $invoice ); |
|
767 | - $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
764 | + $invoice = new WPInv_Invoice($post_id); |
|
765 | + do_action("getpaid_before_delete_invoice", $invoice); |
|
766 | + $invoice->get_data_store()->delete_items($invoice); |
|
767 | + $invoice->get_data_store()->delete_special_fields($invoice); |
|
768 | 768 | break; |
769 | 769 | } |
770 | 770 | } |
@@ -777,29 +777,29 @@ discard block |
||
777 | 777 | * |
778 | 778 | * @return mixed |
779 | 779 | */ |
780 | - public static function add_display_post_states( $post_states, $post ) { |
|
780 | + public static function add_display_post_states($post_states, $post) { |
|
781 | 781 | |
782 | - if ( wpinv_get_option( 'success_page', 0 ) == $post->ID ) { |
|
783 | - $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' ); |
|
782 | + if (wpinv_get_option('success_page', 0) == $post->ID) { |
|
783 | + $post_states['getpaid_success_page'] = __('GetPaid Receipt Page', 'invoicing'); |
|
784 | 784 | } |
785 | 785 | |
786 | - foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) { |
|
786 | + foreach (getpaid_get_invoice_post_types() as $post_type => $label) { |
|
787 | 787 | |
788 | - if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) { |
|
788 | + if (wpinv_get_option("{$post_type}_history_page", 0) == $post->ID) { |
|
789 | 789 | $post_states["getpaid_{$post_type}_history_page"] = sprintf( |
790 | - __( 'GetPaid %s History Page', 'invoicing' ), |
|
790 | + __('GetPaid %s History Page', 'invoicing'), |
|
791 | 791 | $label |
792 | 792 | ); |
793 | 793 | } |
794 | 794 | |
795 | 795 | } |
796 | 796 | |
797 | - if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) { |
|
798 | - $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscription Page', 'invoicing' ); |
|
797 | + if (wpinv_get_option('invoice_subscription_page', 0) == $post->ID) { |
|
798 | + $post_states['getpaid_invoice_subscription_page'] = __('GetPaid Subscription Page', 'invoicing'); |
|
799 | 799 | } |
800 | 800 | |
801 | - if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) { |
|
802 | - $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' ); |
|
801 | + if (wpinv_get_option('checkout_page', 0) == $post->ID) { |
|
802 | + $post_states['getpaid_checkout_page'] = __('GetPaid Checkout Page', 'invoicing'); |
|
803 | 803 | } |
804 | 804 | |
805 | 805 | return $post_states; |
@@ -12,288 +12,288 @@ |
||
12 | 12 | */ |
13 | 13 | class GetPaid_Payment_Form_Submission_Refresh_Prices { |
14 | 14 | |
15 | - /** |
|
16 | - * Contains the response for refreshing prices. |
|
17 | - * @var array |
|
18 | - */ |
|
19 | - public $response = array(); |
|
15 | + /** |
|
16 | + * Contains the response for refreshing prices. |
|
17 | + * @var array |
|
18 | + */ |
|
19 | + public $response = array(); |
|
20 | 20 | |
21 | 21 | /** |
22 | - * Class constructor |
|
23 | - * |
|
24 | - * @param GetPaid_Payment_Form_Submission $submission |
|
25 | - */ |
|
26 | - public function __construct( $submission ) { |
|
27 | - |
|
28 | - $this->response = array( |
|
29 | - 'submission_id' => $submission->id, |
|
22 | + * Class constructor |
|
23 | + * |
|
24 | + * @param GetPaid_Payment_Form_Submission $submission |
|
25 | + */ |
|
26 | + public function __construct( $submission ) { |
|
27 | + |
|
28 | + $this->response = array( |
|
29 | + 'submission_id' => $submission->id, |
|
30 | 30 | 'has_recurring' => $submission->has_recurring, |
31 | - 'has_subscription_group' => $submission->has_subscription_group(), |
|
32 | - 'has_multiple_subscription_groups' => $submission->has_multiple_subscription_groups(), |
|
31 | + 'has_subscription_group' => $submission->has_subscription_group(), |
|
32 | + 'has_multiple_subscription_groups' => $submission->has_multiple_subscription_groups(), |
|
33 | 33 | 'is_free' => ! $submission->should_collect_payment_details(), |
34 | - ); |
|
35 | - |
|
36 | - $this->add_totals( $submission ); |
|
37 | - $this->add_texts( $submission ); |
|
38 | - $this->add_items( $submission ); |
|
39 | - $this->add_fees( $submission ); |
|
40 | - $this->add_discounts( $submission ); |
|
41 | - $this->add_taxes( $submission ); |
|
42 | - $this->add_gateways( $submission ); |
|
43 | - $this->add_data( $submission ); |
|
44 | - |
|
45 | - } |
|
46 | - |
|
47 | - /** |
|
48 | - * Adds totals to a response for submission refresh prices. |
|
49 | - * |
|
50 | - * @param GetPaid_Payment_Form_Submission $submission |
|
51 | - */ |
|
52 | - public function add_totals( $submission ) { |
|
53 | - |
|
54 | - $this->response = array_merge( |
|
55 | - $this->response, |
|
56 | - array( |
|
57 | - |
|
58 | - 'totals' => array( |
|
59 | - 'subtotal' => $submission->format_amount( $submission->get_subtotal() ), |
|
60 | - 'discount' => $submission->format_amount( $submission->get_discount() ), |
|
61 | - 'fees' => $submission->format_amount( $submission->get_fee() ), |
|
62 | - 'tax' => $submission->format_amount( $submission->get_tax() ), |
|
63 | - 'total' => $submission->format_amount( $submission->get_total() ), |
|
64 | - 'raw_total' => html_entity_decode( sanitize_text_field( $submission->format_amount( $submission->get_total() ) ), ENT_QUOTES ), |
|
65 | - ), |
|
66 | - |
|
67 | - 'recurring' => array( |
|
68 | - 'subtotal' => $submission->format_amount( $submission->get_recurring_subtotal() ), |
|
69 | - 'discount' => $submission->format_amount( $submission->get_recurring_discount() ), |
|
70 | - 'fees' => $submission->format_amount( $submission->get_recurring_fee() ), |
|
71 | - 'tax' => $submission->format_amount( $submission->get_recurring_tax() ), |
|
72 | - 'total' => $submission->format_amount( $submission->get_recurring_total() ), |
|
73 | - ), |
|
74 | - |
|
75 | - 'initial_amt' => wpinv_round_amount( $submission->get_total(), null, true ), |
|
76 | - 'currency' => $submission->get_currency(), |
|
77 | - |
|
78 | - ) |
|
79 | - ); |
|
80 | - |
|
81 | - } |
|
82 | - |
|
83 | - /** |
|
84 | - * Adds texts to a response for submission refresh prices. |
|
85 | - * |
|
86 | - * @param GetPaid_Payment_Form_Submission $submission |
|
87 | - */ |
|
88 | - public function add_texts( $submission ) { |
|
89 | - |
|
90 | - $payable = $submission->format_amount( $submission->get_total() ); |
|
91 | - $groups = getpaid_get_subscription_groups( $submission ); |
|
92 | - |
|
93 | - if ( $submission->has_recurring && 2 > count( $groups ) ) { |
|
94 | - |
|
95 | - $recurring = new WPInv_Item( $submission->has_recurring ); |
|
96 | - $period = getpaid_get_subscription_period_label( $recurring->get_recurring_period( true ), $recurring->get_recurring_interval(), '' ); |
|
97 | - $main_item = reset( $groups ); |
|
98 | - |
|
99 | - if ( $submission->get_total() == $submission->get_recurring_total() ) { |
|
100 | - $payable = "$payable / $period"; |
|
101 | - } else if ( $main_item ) { |
|
102 | - |
|
103 | - $main_item = reset( $main_item ); |
|
104 | - |
|
105 | - // Calculate the next renewal date. |
|
106 | - $_period = $main_item->get_recurring_period( true ); |
|
107 | - $_interval = $main_item->get_recurring_interval(); |
|
108 | - |
|
109 | - // If the subscription item has a trial period... |
|
110 | - if ( $main_item->has_free_trial() ) { |
|
111 | - $_period = $main_item->get_trial_period( true ); |
|
112 | - $_interval = $main_item->get_trial_interval(); |
|
113 | - } |
|
114 | - |
|
115 | - $payable = sprintf( |
|
116 | - __( '%1$s (renews at %2$s / %3$s)', 'invoicing' ), |
|
117 | - $submission->format_amount( $submission->get_total() ), |
|
118 | - $submission->format_amount( $submission->get_recurring_total() ), |
|
119 | - $period |
|
120 | - ); |
|
121 | - |
|
122 | - $payable .= sprintf( |
|
123 | - '<small class="text-muted form-text">%s</small>', |
|
124 | - sprintf( |
|
125 | - __( 'First renewal on %s', 'invoicing' ), |
|
126 | - getpaid_format_date( date( 'Y-m-d H:i:s', strtotime( "+$_interval $_period", current_time( 'timestamp' ) ) ) ) |
|
127 | - ) |
|
128 | - ); |
|
129 | - |
|
130 | - } else { |
|
131 | - $payable = sprintf( |
|
132 | - __( '%1$s (renews at %2$s / %3$s)', 'invoicing' ), |
|
133 | - $submission->format_amount( $submission->get_total() ), |
|
134 | - $submission->format_amount( $submission->get_recurring_total() ), |
|
135 | - $period |
|
136 | - ); |
|
137 | - } |
|
138 | - |
|
139 | - } |
|
140 | - |
|
141 | - $texts = array( |
|
142 | - '.getpaid-checkout-total-payable' => $payable, |
|
143 | - ); |
|
144 | - |
|
145 | - foreach ( $submission->get_items() as $item ) { |
|
146 | - $item_id = $item->get_id(); |
|
147 | - $initial_price = $submission->format_amount( $item->get_sub_total() - $item->item_discount ); |
|
148 | - $recurring_price = $submission->format_amount( $item->get_recurring_sub_total() - $item->recurring_item_discount ); |
|
149 | - $texts[".item-$item_id .getpaid-form-item-price-desc"] = getpaid_item_recurring_price_help_text( $item, $submission->get_currency(), $initial_price, $recurring_price ); |
|
150 | - } |
|
151 | - |
|
152 | - $this->response = array_merge( $this->response, array( 'texts' => $texts ) ); |
|
153 | - |
|
154 | - } |
|
155 | - |
|
156 | - /** |
|
157 | - * Adds items to a response for submission refresh prices. |
|
158 | - * |
|
159 | - * @param GetPaid_Payment_Form_Submission $submission |
|
160 | - */ |
|
161 | - public function add_items( $submission ) { |
|
162 | - |
|
163 | - // Add items. |
|
164 | - $items = array(); |
|
34 | + ); |
|
35 | + |
|
36 | + $this->add_totals( $submission ); |
|
37 | + $this->add_texts( $submission ); |
|
38 | + $this->add_items( $submission ); |
|
39 | + $this->add_fees( $submission ); |
|
40 | + $this->add_discounts( $submission ); |
|
41 | + $this->add_taxes( $submission ); |
|
42 | + $this->add_gateways( $submission ); |
|
43 | + $this->add_data( $submission ); |
|
44 | + |
|
45 | + } |
|
46 | + |
|
47 | + /** |
|
48 | + * Adds totals to a response for submission refresh prices. |
|
49 | + * |
|
50 | + * @param GetPaid_Payment_Form_Submission $submission |
|
51 | + */ |
|
52 | + public function add_totals( $submission ) { |
|
53 | + |
|
54 | + $this->response = array_merge( |
|
55 | + $this->response, |
|
56 | + array( |
|
57 | + |
|
58 | + 'totals' => array( |
|
59 | + 'subtotal' => $submission->format_amount( $submission->get_subtotal() ), |
|
60 | + 'discount' => $submission->format_amount( $submission->get_discount() ), |
|
61 | + 'fees' => $submission->format_amount( $submission->get_fee() ), |
|
62 | + 'tax' => $submission->format_amount( $submission->get_tax() ), |
|
63 | + 'total' => $submission->format_amount( $submission->get_total() ), |
|
64 | + 'raw_total' => html_entity_decode( sanitize_text_field( $submission->format_amount( $submission->get_total() ) ), ENT_QUOTES ), |
|
65 | + ), |
|
66 | + |
|
67 | + 'recurring' => array( |
|
68 | + 'subtotal' => $submission->format_amount( $submission->get_recurring_subtotal() ), |
|
69 | + 'discount' => $submission->format_amount( $submission->get_recurring_discount() ), |
|
70 | + 'fees' => $submission->format_amount( $submission->get_recurring_fee() ), |
|
71 | + 'tax' => $submission->format_amount( $submission->get_recurring_tax() ), |
|
72 | + 'total' => $submission->format_amount( $submission->get_recurring_total() ), |
|
73 | + ), |
|
74 | + |
|
75 | + 'initial_amt' => wpinv_round_amount( $submission->get_total(), null, true ), |
|
76 | + 'currency' => $submission->get_currency(), |
|
77 | + |
|
78 | + ) |
|
79 | + ); |
|
80 | + |
|
81 | + } |
|
82 | + |
|
83 | + /** |
|
84 | + * Adds texts to a response for submission refresh prices. |
|
85 | + * |
|
86 | + * @param GetPaid_Payment_Form_Submission $submission |
|
87 | + */ |
|
88 | + public function add_texts( $submission ) { |
|
89 | + |
|
90 | + $payable = $submission->format_amount( $submission->get_total() ); |
|
91 | + $groups = getpaid_get_subscription_groups( $submission ); |
|
92 | + |
|
93 | + if ( $submission->has_recurring && 2 > count( $groups ) ) { |
|
94 | + |
|
95 | + $recurring = new WPInv_Item( $submission->has_recurring ); |
|
96 | + $period = getpaid_get_subscription_period_label( $recurring->get_recurring_period( true ), $recurring->get_recurring_interval(), '' ); |
|
97 | + $main_item = reset( $groups ); |
|
98 | + |
|
99 | + if ( $submission->get_total() == $submission->get_recurring_total() ) { |
|
100 | + $payable = "$payable / $period"; |
|
101 | + } else if ( $main_item ) { |
|
102 | + |
|
103 | + $main_item = reset( $main_item ); |
|
104 | + |
|
105 | + // Calculate the next renewal date. |
|
106 | + $_period = $main_item->get_recurring_period( true ); |
|
107 | + $_interval = $main_item->get_recurring_interval(); |
|
108 | + |
|
109 | + // If the subscription item has a trial period... |
|
110 | + if ( $main_item->has_free_trial() ) { |
|
111 | + $_period = $main_item->get_trial_period( true ); |
|
112 | + $_interval = $main_item->get_trial_interval(); |
|
113 | + } |
|
114 | + |
|
115 | + $payable = sprintf( |
|
116 | + __( '%1$s (renews at %2$s / %3$s)', 'invoicing' ), |
|
117 | + $submission->format_amount( $submission->get_total() ), |
|
118 | + $submission->format_amount( $submission->get_recurring_total() ), |
|
119 | + $period |
|
120 | + ); |
|
121 | + |
|
122 | + $payable .= sprintf( |
|
123 | + '<small class="text-muted form-text">%s</small>', |
|
124 | + sprintf( |
|
125 | + __( 'First renewal on %s', 'invoicing' ), |
|
126 | + getpaid_format_date( date( 'Y-m-d H:i:s', strtotime( "+$_interval $_period", current_time( 'timestamp' ) ) ) ) |
|
127 | + ) |
|
128 | + ); |
|
129 | + |
|
130 | + } else { |
|
131 | + $payable = sprintf( |
|
132 | + __( '%1$s (renews at %2$s / %3$s)', 'invoicing' ), |
|
133 | + $submission->format_amount( $submission->get_total() ), |
|
134 | + $submission->format_amount( $submission->get_recurring_total() ), |
|
135 | + $period |
|
136 | + ); |
|
137 | + } |
|
138 | + |
|
139 | + } |
|
140 | + |
|
141 | + $texts = array( |
|
142 | + '.getpaid-checkout-total-payable' => $payable, |
|
143 | + ); |
|
165 | 144 | |
166 | 145 | foreach ( $submission->get_items() as $item ) { |
167 | - $item_id = $item->get_id(); |
|
168 | - $items["$item_id"] = $submission->format_amount( $item->get_sub_total() ); |
|
169 | - } |
|
146 | + $item_id = $item->get_id(); |
|
147 | + $initial_price = $submission->format_amount( $item->get_sub_total() - $item->item_discount ); |
|
148 | + $recurring_price = $submission->format_amount( $item->get_recurring_sub_total() - $item->recurring_item_discount ); |
|
149 | + $texts[".item-$item_id .getpaid-form-item-price-desc"] = getpaid_item_recurring_price_help_text( $item, $submission->get_currency(), $initial_price, $recurring_price ); |
|
150 | + } |
|
170 | 151 | |
171 | - $this->response = array_merge( |
|
172 | - $this->response, |
|
173 | - array( 'items' => $items ) |
|
174 | - ); |
|
152 | + $this->response = array_merge( $this->response, array( 'texts' => $texts ) ); |
|
175 | 153 | |
176 | - } |
|
154 | + } |
|
177 | 155 | |
178 | - /** |
|
179 | - * Adds fees to a response for submission refresh prices. |
|
180 | - * |
|
181 | - * @param GetPaid_Payment_Form_Submission $submission |
|
182 | - */ |
|
183 | - public function add_fees( $submission ) { |
|
156 | + /** |
|
157 | + * Adds items to a response for submission refresh prices. |
|
158 | + * |
|
159 | + * @param GetPaid_Payment_Form_Submission $submission |
|
160 | + */ |
|
161 | + public function add_items( $submission ) { |
|
184 | 162 | |
185 | - $fees = array(); |
|
163 | + // Add items. |
|
164 | + $items = array(); |
|
165 | + |
|
166 | + foreach ( $submission->get_items() as $item ) { |
|
167 | + $item_id = $item->get_id(); |
|
168 | + $items["$item_id"] = $submission->format_amount( $item->get_sub_total() ); |
|
169 | + } |
|
170 | + |
|
171 | + $this->response = array_merge( |
|
172 | + $this->response, |
|
173 | + array( 'items' => $items ) |
|
174 | + ); |
|
175 | + |
|
176 | + } |
|
177 | + |
|
178 | + /** |
|
179 | + * Adds fees to a response for submission refresh prices. |
|
180 | + * |
|
181 | + * @param GetPaid_Payment_Form_Submission $submission |
|
182 | + */ |
|
183 | + public function add_fees( $submission ) { |
|
184 | + |
|
185 | + $fees = array(); |
|
186 | 186 | |
187 | 187 | foreach ( $submission->get_fees() as $name => $data ) { |
188 | - $fees[$name] = $submission->format_amount( $data['initial_fee'] ); |
|
189 | - } |
|
188 | + $fees[$name] = $submission->format_amount( $data['initial_fee'] ); |
|
189 | + } |
|
190 | 190 | |
191 | - $this->response = array_merge( |
|
192 | - $this->response, |
|
193 | - array( 'fees' => $fees ) |
|
194 | - ); |
|
191 | + $this->response = array_merge( |
|
192 | + $this->response, |
|
193 | + array( 'fees' => $fees ) |
|
194 | + ); |
|
195 | 195 | |
196 | - } |
|
196 | + } |
|
197 | 197 | |
198 | - /** |
|
199 | - * Adds discounts to a response for submission refresh prices. |
|
200 | - * |
|
201 | - * @param GetPaid_Payment_Form_Submission $submission |
|
202 | - */ |
|
203 | - public function add_discounts( $submission ) { |
|
198 | + /** |
|
199 | + * Adds discounts to a response for submission refresh prices. |
|
200 | + * |
|
201 | + * @param GetPaid_Payment_Form_Submission $submission |
|
202 | + */ |
|
203 | + public function add_discounts( $submission ) { |
|
204 | 204 | |
205 | - $discounts = array(); |
|
205 | + $discounts = array(); |
|
206 | 206 | |
207 | 207 | foreach ( $submission->get_discounts() as $name => $data ) { |
208 | - $discounts[$name] = $submission->format_amount( $data['initial_discount'] ); |
|
209 | - } |
|
210 | - |
|
211 | - $this->response = array_merge( |
|
212 | - $this->response, |
|
213 | - array( 'discounts' => $discounts ) |
|
214 | - ); |
|
208 | + $discounts[$name] = $submission->format_amount( $data['initial_discount'] ); |
|
209 | + } |
|
215 | 210 | |
216 | - } |
|
211 | + $this->response = array_merge( |
|
212 | + $this->response, |
|
213 | + array( 'discounts' => $discounts ) |
|
214 | + ); |
|
217 | 215 | |
218 | - /** |
|
219 | - * Adds taxes to a response for submission refresh prices. |
|
220 | - * |
|
221 | - * @param GetPaid_Payment_Form_Submission $submission |
|
222 | - */ |
|
223 | - public function add_taxes( $submission ) { |
|
216 | + } |
|
224 | 217 | |
225 | - $taxes = array(); |
|
226 | - $markup = ''; |
|
218 | + /** |
|
219 | + * Adds taxes to a response for submission refresh prices. |
|
220 | + * |
|
221 | + * @param GetPaid_Payment_Form_Submission $submission |
|
222 | + */ |
|
223 | + public function add_taxes( $submission ) { |
|
224 | + |
|
225 | + $taxes = array(); |
|
226 | + $markup = ''; |
|
227 | 227 | foreach ( $submission->get_taxes() as $name => $data ) { |
228 | - $name = sanitize_text_field( $name ); |
|
229 | - $amount = $submission->format_amount( $data['initial_tax'] ); |
|
230 | - $taxes[$name] = $amount; |
|
231 | - $markup .= "<small class='form-text'>$name : $amount</small>"; |
|
232 | - } |
|
233 | - |
|
234 | - if ( wpinv_display_individual_tax_rates() && ! empty( $taxes ) ) { |
|
235 | - $this->response['texts']['.getpaid-form-cart-totals-total-tax'] = $markup; |
|
236 | - } |
|
237 | - |
|
238 | - $this->response = array_merge( |
|
239 | - $this->response, |
|
240 | - array( 'taxes' => $taxes ) |
|
241 | - ); |
|
242 | - |
|
243 | - } |
|
244 | - |
|
245 | - /** |
|
246 | - * Adds gateways to a response for submission refresh prices. |
|
247 | - * |
|
248 | - * @param GetPaid_Payment_Form_Submission $submission |
|
249 | - */ |
|
250 | - public function add_gateways( $submission ) { |
|
251 | - |
|
252 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
253 | - |
|
254 | - if ( $this->response['has_recurring'] ) { |
|
255 | - |
|
256 | - foreach ( $gateways as $i => $gateway ) { |
|
257 | - |
|
258 | - if ( |
|
259 | - ! getpaid_payment_gateway_supports( $gateway, 'subscription' ) |
|
260 | - || ( $this->response['has_subscription_group'] && ! getpaid_payment_gateway_supports( $gateway, 'single_subscription_group' ) ) |
|
261 | - || ( $this->response['has_multiple_subscription_groups'] && ! getpaid_payment_gateway_supports( $gateway, 'multiple_subscription_groups' ) ) ) { |
|
262 | - unset( $gateways[ $i ] ); |
|
263 | - } |
|
264 | - |
|
265 | - } |
|
266 | - |
|
267 | - } |
|
268 | - |
|
269 | - $gateways = apply_filters( 'getpaid_submission_gateways', $gateways, $submission ); |
|
270 | - $this->response = array_merge( |
|
271 | - $this->response, |
|
272 | - array( 'gateways' => $gateways ) |
|
273 | - ); |
|
274 | - |
|
275 | - } |
|
276 | - |
|
277 | - /** |
|
278 | - * Adds data to a response for submission refresh prices. |
|
279 | - * |
|
280 | - * @param GetPaid_Payment_Form_Submission $submission |
|
281 | - */ |
|
282 | - public function add_data( $submission ) { |
|
283 | - |
|
284 | - $this->response = array_merge( |
|
285 | - $this->response, |
|
286 | - array( |
|
287 | - 'js_data' => apply_filters( |
|
288 | - 'getpaid_submission_js_data', |
|
289 | - array( |
|
290 | - 'is_recurring' => $this->response['has_recurring'], |
|
291 | - ), |
|
292 | - $submission |
|
293 | - ) |
|
294 | - ) |
|
295 | - ); |
|
296 | - |
|
297 | - } |
|
228 | + $name = sanitize_text_field( $name ); |
|
229 | + $amount = $submission->format_amount( $data['initial_tax'] ); |
|
230 | + $taxes[$name] = $amount; |
|
231 | + $markup .= "<small class='form-text'>$name : $amount</small>"; |
|
232 | + } |
|
233 | + |
|
234 | + if ( wpinv_display_individual_tax_rates() && ! empty( $taxes ) ) { |
|
235 | + $this->response['texts']['.getpaid-form-cart-totals-total-tax'] = $markup; |
|
236 | + } |
|
237 | + |
|
238 | + $this->response = array_merge( |
|
239 | + $this->response, |
|
240 | + array( 'taxes' => $taxes ) |
|
241 | + ); |
|
242 | + |
|
243 | + } |
|
244 | + |
|
245 | + /** |
|
246 | + * Adds gateways to a response for submission refresh prices. |
|
247 | + * |
|
248 | + * @param GetPaid_Payment_Form_Submission $submission |
|
249 | + */ |
|
250 | + public function add_gateways( $submission ) { |
|
251 | + |
|
252 | + $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
253 | + |
|
254 | + if ( $this->response['has_recurring'] ) { |
|
255 | + |
|
256 | + foreach ( $gateways as $i => $gateway ) { |
|
257 | + |
|
258 | + if ( |
|
259 | + ! getpaid_payment_gateway_supports( $gateway, 'subscription' ) |
|
260 | + || ( $this->response['has_subscription_group'] && ! getpaid_payment_gateway_supports( $gateway, 'single_subscription_group' ) ) |
|
261 | + || ( $this->response['has_multiple_subscription_groups'] && ! getpaid_payment_gateway_supports( $gateway, 'multiple_subscription_groups' ) ) ) { |
|
262 | + unset( $gateways[ $i ] ); |
|
263 | + } |
|
264 | + |
|
265 | + } |
|
266 | + |
|
267 | + } |
|
268 | + |
|
269 | + $gateways = apply_filters( 'getpaid_submission_gateways', $gateways, $submission ); |
|
270 | + $this->response = array_merge( |
|
271 | + $this->response, |
|
272 | + array( 'gateways' => $gateways ) |
|
273 | + ); |
|
274 | + |
|
275 | + } |
|
276 | + |
|
277 | + /** |
|
278 | + * Adds data to a response for submission refresh prices. |
|
279 | + * |
|
280 | + * @param GetPaid_Payment_Form_Submission $submission |
|
281 | + */ |
|
282 | + public function add_data( $submission ) { |
|
283 | + |
|
284 | + $this->response = array_merge( |
|
285 | + $this->response, |
|
286 | + array( |
|
287 | + 'js_data' => apply_filters( |
|
288 | + 'getpaid_submission_js_data', |
|
289 | + array( |
|
290 | + 'is_recurring' => $this->response['has_recurring'], |
|
291 | + ), |
|
292 | + $submission |
|
293 | + ) |
|
294 | + ) |
|
295 | + ); |
|
296 | + |
|
297 | + } |
|
298 | 298 | |
299 | 299 | } |
@@ -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 | * Payment form submission refresh prices class |
@@ -23,24 +23,24 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @param GetPaid_Payment_Form_Submission $submission |
25 | 25 | */ |
26 | - public function __construct( $submission ) { |
|
26 | + public function __construct($submission) { |
|
27 | 27 | |
28 | 28 | $this->response = array( |
29 | 29 | 'submission_id' => $submission->id, |
30 | 30 | 'has_recurring' => $submission->has_recurring, |
31 | 31 | 'has_subscription_group' => $submission->has_subscription_group(), |
32 | 32 | 'has_multiple_subscription_groups' => $submission->has_multiple_subscription_groups(), |
33 | - 'is_free' => ! $submission->should_collect_payment_details(), |
|
33 | + 'is_free' => !$submission->should_collect_payment_details(), |
|
34 | 34 | ); |
35 | 35 | |
36 | - $this->add_totals( $submission ); |
|
37 | - $this->add_texts( $submission ); |
|
38 | - $this->add_items( $submission ); |
|
39 | - $this->add_fees( $submission ); |
|
40 | - $this->add_discounts( $submission ); |
|
41 | - $this->add_taxes( $submission ); |
|
42 | - $this->add_gateways( $submission ); |
|
43 | - $this->add_data( $submission ); |
|
36 | + $this->add_totals($submission); |
|
37 | + $this->add_texts($submission); |
|
38 | + $this->add_items($submission); |
|
39 | + $this->add_fees($submission); |
|
40 | + $this->add_discounts($submission); |
|
41 | + $this->add_taxes($submission); |
|
42 | + $this->add_gateways($submission); |
|
43 | + $this->add_data($submission); |
|
44 | 44 | |
45 | 45 | } |
46 | 46 | |
@@ -49,30 +49,30 @@ discard block |
||
49 | 49 | * |
50 | 50 | * @param GetPaid_Payment_Form_Submission $submission |
51 | 51 | */ |
52 | - public function add_totals( $submission ) { |
|
52 | + public function add_totals($submission) { |
|
53 | 53 | |
54 | 54 | $this->response = array_merge( |
55 | 55 | $this->response, |
56 | 56 | array( |
57 | 57 | |
58 | 58 | 'totals' => array( |
59 | - 'subtotal' => $submission->format_amount( $submission->get_subtotal() ), |
|
60 | - 'discount' => $submission->format_amount( $submission->get_discount() ), |
|
61 | - 'fees' => $submission->format_amount( $submission->get_fee() ), |
|
62 | - 'tax' => $submission->format_amount( $submission->get_tax() ), |
|
63 | - 'total' => $submission->format_amount( $submission->get_total() ), |
|
64 | - 'raw_total' => html_entity_decode( sanitize_text_field( $submission->format_amount( $submission->get_total() ) ), ENT_QUOTES ), |
|
59 | + 'subtotal' => $submission->format_amount($submission->get_subtotal()), |
|
60 | + 'discount' => $submission->format_amount($submission->get_discount()), |
|
61 | + 'fees' => $submission->format_amount($submission->get_fee()), |
|
62 | + 'tax' => $submission->format_amount($submission->get_tax()), |
|
63 | + 'total' => $submission->format_amount($submission->get_total()), |
|
64 | + 'raw_total' => html_entity_decode(sanitize_text_field($submission->format_amount($submission->get_total())), ENT_QUOTES), |
|
65 | 65 | ), |
66 | 66 | |
67 | 67 | 'recurring' => array( |
68 | - 'subtotal' => $submission->format_amount( $submission->get_recurring_subtotal() ), |
|
69 | - 'discount' => $submission->format_amount( $submission->get_recurring_discount() ), |
|
70 | - 'fees' => $submission->format_amount( $submission->get_recurring_fee() ), |
|
71 | - 'tax' => $submission->format_amount( $submission->get_recurring_tax() ), |
|
72 | - 'total' => $submission->format_amount( $submission->get_recurring_total() ), |
|
68 | + 'subtotal' => $submission->format_amount($submission->get_recurring_subtotal()), |
|
69 | + 'discount' => $submission->format_amount($submission->get_recurring_discount()), |
|
70 | + 'fees' => $submission->format_amount($submission->get_recurring_fee()), |
|
71 | + 'tax' => $submission->format_amount($submission->get_recurring_tax()), |
|
72 | + 'total' => $submission->format_amount($submission->get_recurring_total()), |
|
73 | 73 | ), |
74 | 74 | |
75 | - 'initial_amt' => wpinv_round_amount( $submission->get_total(), null, true ), |
|
75 | + 'initial_amt' => wpinv_round_amount($submission->get_total(), null, true), |
|
76 | 76 | 'currency' => $submission->get_currency(), |
77 | 77 | |
78 | 78 | ) |
@@ -85,53 +85,53 @@ discard block |
||
85 | 85 | * |
86 | 86 | * @param GetPaid_Payment_Form_Submission $submission |
87 | 87 | */ |
88 | - public function add_texts( $submission ) { |
|
88 | + public function add_texts($submission) { |
|
89 | 89 | |
90 | - $payable = $submission->format_amount( $submission->get_total() ); |
|
91 | - $groups = getpaid_get_subscription_groups( $submission ); |
|
90 | + $payable = $submission->format_amount($submission->get_total()); |
|
91 | + $groups = getpaid_get_subscription_groups($submission); |
|
92 | 92 | |
93 | - if ( $submission->has_recurring && 2 > count( $groups ) ) { |
|
93 | + if ($submission->has_recurring && 2 > count($groups)) { |
|
94 | 94 | |
95 | - $recurring = new WPInv_Item( $submission->has_recurring ); |
|
96 | - $period = getpaid_get_subscription_period_label( $recurring->get_recurring_period( true ), $recurring->get_recurring_interval(), '' ); |
|
97 | - $main_item = reset( $groups ); |
|
95 | + $recurring = new WPInv_Item($submission->has_recurring); |
|
96 | + $period = getpaid_get_subscription_period_label($recurring->get_recurring_period(true), $recurring->get_recurring_interval(), ''); |
|
97 | + $main_item = reset($groups); |
|
98 | 98 | |
99 | - if ( $submission->get_total() == $submission->get_recurring_total() ) { |
|
99 | + if ($submission->get_total() == $submission->get_recurring_total()) { |
|
100 | 100 | $payable = "$payable / $period"; |
101 | - } else if ( $main_item ) { |
|
101 | + } else if ($main_item) { |
|
102 | 102 | |
103 | - $main_item = reset( $main_item ); |
|
103 | + $main_item = reset($main_item); |
|
104 | 104 | |
105 | 105 | // Calculate the next renewal date. |
106 | - $_period = $main_item->get_recurring_period( true ); |
|
106 | + $_period = $main_item->get_recurring_period(true); |
|
107 | 107 | $_interval = $main_item->get_recurring_interval(); |
108 | 108 | |
109 | 109 | // If the subscription item has a trial period... |
110 | - if ( $main_item->has_free_trial() ) { |
|
111 | - $_period = $main_item->get_trial_period( true ); |
|
110 | + if ($main_item->has_free_trial()) { |
|
111 | + $_period = $main_item->get_trial_period(true); |
|
112 | 112 | $_interval = $main_item->get_trial_interval(); |
113 | 113 | } |
114 | 114 | |
115 | 115 | $payable = sprintf( |
116 | - __( '%1$s (renews at %2$s / %3$s)', 'invoicing' ), |
|
117 | - $submission->format_amount( $submission->get_total() ), |
|
118 | - $submission->format_amount( $submission->get_recurring_total() ), |
|
116 | + __('%1$s (renews at %2$s / %3$s)', 'invoicing'), |
|
117 | + $submission->format_amount($submission->get_total()), |
|
118 | + $submission->format_amount($submission->get_recurring_total()), |
|
119 | 119 | $period |
120 | 120 | ); |
121 | 121 | |
122 | 122 | $payable .= sprintf( |
123 | 123 | '<small class="text-muted form-text">%s</small>', |
124 | 124 | sprintf( |
125 | - __( 'First renewal on %s', 'invoicing' ), |
|
126 | - getpaid_format_date( date( 'Y-m-d H:i:s', strtotime( "+$_interval $_period", current_time( 'timestamp' ) ) ) ) |
|
125 | + __('First renewal on %s', 'invoicing'), |
|
126 | + getpaid_format_date(date('Y-m-d H:i:s', strtotime("+$_interval $_period", current_time('timestamp')))) |
|
127 | 127 | ) |
128 | 128 | ); |
129 | 129 | |
130 | 130 | } else { |
131 | 131 | $payable = sprintf( |
132 | - __( '%1$s (renews at %2$s / %3$s)', 'invoicing' ), |
|
133 | - $submission->format_amount( $submission->get_total() ), |
|
134 | - $submission->format_amount( $submission->get_recurring_total() ), |
|
132 | + __('%1$s (renews at %2$s / %3$s)', 'invoicing'), |
|
133 | + $submission->format_amount($submission->get_total()), |
|
134 | + $submission->format_amount($submission->get_recurring_total()), |
|
135 | 135 | $period |
136 | 136 | ); |
137 | 137 | } |
@@ -142,14 +142,14 @@ discard block |
||
142 | 142 | '.getpaid-checkout-total-payable' => $payable, |
143 | 143 | ); |
144 | 144 | |
145 | - foreach ( $submission->get_items() as $item ) { |
|
145 | + foreach ($submission->get_items() as $item) { |
|
146 | 146 | $item_id = $item->get_id(); |
147 | - $initial_price = $submission->format_amount( $item->get_sub_total() - $item->item_discount ); |
|
148 | - $recurring_price = $submission->format_amount( $item->get_recurring_sub_total() - $item->recurring_item_discount ); |
|
149 | - $texts[".item-$item_id .getpaid-form-item-price-desc"] = getpaid_item_recurring_price_help_text( $item, $submission->get_currency(), $initial_price, $recurring_price ); |
|
147 | + $initial_price = $submission->format_amount($item->get_sub_total() - $item->item_discount); |
|
148 | + $recurring_price = $submission->format_amount($item->get_recurring_sub_total() - $item->recurring_item_discount); |
|
149 | + $texts[".item-$item_id .getpaid-form-item-price-desc"] = getpaid_item_recurring_price_help_text($item, $submission->get_currency(), $initial_price, $recurring_price); |
|
150 | 150 | } |
151 | 151 | |
152 | - $this->response = array_merge( $this->response, array( 'texts' => $texts ) ); |
|
152 | + $this->response = array_merge($this->response, array('texts' => $texts)); |
|
153 | 153 | |
154 | 154 | } |
155 | 155 | |
@@ -158,19 +158,19 @@ discard block |
||
158 | 158 | * |
159 | 159 | * @param GetPaid_Payment_Form_Submission $submission |
160 | 160 | */ |
161 | - public function add_items( $submission ) { |
|
161 | + public function add_items($submission) { |
|
162 | 162 | |
163 | 163 | // Add items. |
164 | 164 | $items = array(); |
165 | 165 | |
166 | - foreach ( $submission->get_items() as $item ) { |
|
166 | + foreach ($submission->get_items() as $item) { |
|
167 | 167 | $item_id = $item->get_id(); |
168 | - $items["$item_id"] = $submission->format_amount( $item->get_sub_total() ); |
|
168 | + $items["$item_id"] = $submission->format_amount($item->get_sub_total()); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | $this->response = array_merge( |
172 | 172 | $this->response, |
173 | - array( 'items' => $items ) |
|
173 | + array('items' => $items) |
|
174 | 174 | ); |
175 | 175 | |
176 | 176 | } |
@@ -180,17 +180,17 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @param GetPaid_Payment_Form_Submission $submission |
182 | 182 | */ |
183 | - public function add_fees( $submission ) { |
|
183 | + public function add_fees($submission) { |
|
184 | 184 | |
185 | 185 | $fees = array(); |
186 | 186 | |
187 | - foreach ( $submission->get_fees() as $name => $data ) { |
|
188 | - $fees[$name] = $submission->format_amount( $data['initial_fee'] ); |
|
187 | + foreach ($submission->get_fees() as $name => $data) { |
|
188 | + $fees[$name] = $submission->format_amount($data['initial_fee']); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | $this->response = array_merge( |
192 | 192 | $this->response, |
193 | - array( 'fees' => $fees ) |
|
193 | + array('fees' => $fees) |
|
194 | 194 | ); |
195 | 195 | |
196 | 196 | } |
@@ -200,17 +200,17 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @param GetPaid_Payment_Form_Submission $submission |
202 | 202 | */ |
203 | - public function add_discounts( $submission ) { |
|
203 | + public function add_discounts($submission) { |
|
204 | 204 | |
205 | 205 | $discounts = array(); |
206 | 206 | |
207 | - foreach ( $submission->get_discounts() as $name => $data ) { |
|
208 | - $discounts[$name] = $submission->format_amount( $data['initial_discount'] ); |
|
207 | + foreach ($submission->get_discounts() as $name => $data) { |
|
208 | + $discounts[$name] = $submission->format_amount($data['initial_discount']); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | $this->response = array_merge( |
212 | 212 | $this->response, |
213 | - array( 'discounts' => $discounts ) |
|
213 | + array('discounts' => $discounts) |
|
214 | 214 | ); |
215 | 215 | |
216 | 216 | } |
@@ -220,24 +220,24 @@ discard block |
||
220 | 220 | * |
221 | 221 | * @param GetPaid_Payment_Form_Submission $submission |
222 | 222 | */ |
223 | - public function add_taxes( $submission ) { |
|
223 | + public function add_taxes($submission) { |
|
224 | 224 | |
225 | 225 | $taxes = array(); |
226 | 226 | $markup = ''; |
227 | - foreach ( $submission->get_taxes() as $name => $data ) { |
|
228 | - $name = sanitize_text_field( $name ); |
|
229 | - $amount = $submission->format_amount( $data['initial_tax'] ); |
|
227 | + foreach ($submission->get_taxes() as $name => $data) { |
|
228 | + $name = sanitize_text_field($name); |
|
229 | + $amount = $submission->format_amount($data['initial_tax']); |
|
230 | 230 | $taxes[$name] = $amount; |
231 | 231 | $markup .= "<small class='form-text'>$name : $amount</small>"; |
232 | 232 | } |
233 | 233 | |
234 | - if ( wpinv_display_individual_tax_rates() && ! empty( $taxes ) ) { |
|
234 | + if (wpinv_display_individual_tax_rates() && !empty($taxes)) { |
|
235 | 235 | $this->response['texts']['.getpaid-form-cart-totals-total-tax'] = $markup; |
236 | 236 | } |
237 | 237 | |
238 | 238 | $this->response = array_merge( |
239 | 239 | $this->response, |
240 | - array( 'taxes' => $taxes ) |
|
240 | + array('taxes' => $taxes) |
|
241 | 241 | ); |
242 | 242 | |
243 | 243 | } |
@@ -247,29 +247,29 @@ discard block |
||
247 | 247 | * |
248 | 248 | * @param GetPaid_Payment_Form_Submission $submission |
249 | 249 | */ |
250 | - public function add_gateways( $submission ) { |
|
250 | + public function add_gateways($submission) { |
|
251 | 251 | |
252 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
252 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
253 | 253 | |
254 | - if ( $this->response['has_recurring'] ) { |
|
254 | + if ($this->response['has_recurring']) { |
|
255 | 255 | |
256 | - foreach ( $gateways as $i => $gateway ) { |
|
256 | + foreach ($gateways as $i => $gateway) { |
|
257 | 257 | |
258 | 258 | if ( |
259 | - ! getpaid_payment_gateway_supports( $gateway, 'subscription' ) |
|
260 | - || ( $this->response['has_subscription_group'] && ! getpaid_payment_gateway_supports( $gateway, 'single_subscription_group' ) ) |
|
261 | - || ( $this->response['has_multiple_subscription_groups'] && ! getpaid_payment_gateway_supports( $gateway, 'multiple_subscription_groups' ) ) ) { |
|
262 | - unset( $gateways[ $i ] ); |
|
259 | + !getpaid_payment_gateway_supports($gateway, 'subscription') |
|
260 | + || ($this->response['has_subscription_group'] && !getpaid_payment_gateway_supports($gateway, 'single_subscription_group')) |
|
261 | + || ($this->response['has_multiple_subscription_groups'] && !getpaid_payment_gateway_supports($gateway, 'multiple_subscription_groups')) ) { |
|
262 | + unset($gateways[$i]); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | } |
266 | 266 | |
267 | 267 | } |
268 | 268 | |
269 | - $gateways = apply_filters( 'getpaid_submission_gateways', $gateways, $submission ); |
|
269 | + $gateways = apply_filters('getpaid_submission_gateways', $gateways, $submission); |
|
270 | 270 | $this->response = array_merge( |
271 | 271 | $this->response, |
272 | - array( 'gateways' => $gateways ) |
|
272 | + array('gateways' => $gateways) |
|
273 | 273 | ); |
274 | 274 | |
275 | 275 | } |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | * |
280 | 280 | * @param GetPaid_Payment_Form_Submission $submission |
281 | 281 | */ |
282 | - public function add_data( $submission ) { |
|
282 | + public function add_data($submission) { |
|
283 | 283 | |
284 | 284 | $this->response = array_merge( |
285 | 285 | $this->response, |
@@ -7,45 +7,45 @@ |
||
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 | 15 | <label class="d-block"> |
16 | - <span><?php esc_html_e( 'Button Text', 'invoicing' ); ?></span> |
|
16 | + <span><?php esc_html_e('Button Text', 'invoicing'); ?></span> |
|
17 | 17 | <input v-model='active_form_element.label' class='form-control' type="text"/> |
18 | - <small class="form-text text-muted"><?php _e( '%price% will be replaced by the total payable amount', 'invoicing' ); ?></small> |
|
18 | + <small class="form-text text-muted"><?php _e('%price% will be replaced by the total payable amount', 'invoicing'); ?></small> |
|
19 | 19 | </label> |
20 | 20 | </div> |
21 | 21 | |
22 | 22 | <div class='form-group'> |
23 | 23 | <label class="d-block"> |
24 | - <span><?php esc_html_e( 'Free Checkout Text', 'invoicing' ); ?></span> |
|
24 | + <span><?php esc_html_e('Free Checkout Text', 'invoicing'); ?></span> |
|
25 | 25 | <input v-model='active_form_element.free' class='form-control' type="text"/> |
26 | - <small class="form-text text-muted"><?php _e( 'The text to display if the total payable amount is zero', 'invoicing' ); ?></small> |
|
26 | + <small class="form-text text-muted"><?php _e('The text to display if the total payable amount is zero', 'invoicing'); ?></small> |
|
27 | 27 | </label> |
28 | 28 | </div> |
29 | 29 | |
30 | 30 | <div class='form-group'> |
31 | 31 | <label class="d-block"> |
32 | - <span><?php esc_html_e( 'Help Text', 'invoicing' ); ?></span> |
|
33 | - <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> |
|
34 | - <small class="form-text text-muted"><?php _e( 'HTML is allowed', 'invoicing' ); ?></small> |
|
32 | + <span><?php esc_html_e('Help Text', 'invoicing'); ?></span> |
|
33 | + <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> |
|
34 | + <small class="form-text text-muted"><?php _e('HTML is allowed', 'invoicing'); ?></small> |
|
35 | 35 | </label> |
36 | 36 | </div> |
37 | 37 | |
38 | 38 | <div class='form-group'> |
39 | - <label :for="active_form_element.id + '_edit_type'"><?php esc_html_e( 'Button Type', 'invoicing' ) ?></label> |
|
39 | + <label :for="active_form_element.id + '_edit_type'"><?php esc_html_e('Button Type', 'invoicing') ?></label> |
|
40 | 40 | <select class='form-control custom-select' :id="active_form_element.id + '_edit_type'" v-model='active_form_element.class'> |
41 | - <option value='btn-primary'><?php esc_html_e( 'Primary', 'invoicing' ); ?></option> |
|
42 | - <option value='btn-secondary'><?php esc_html_e( 'Secondary', 'invoicing' ); ?></option> |
|
43 | - <option value='btn-success'><?php esc_html_e( 'Success', 'invoicing' ); ?></option> |
|
44 | - <option value='btn-danger'><?php esc_html_e( 'Danger', 'invoicing' ); ?></option> |
|
45 | - <option value='btn-warning'><?php esc_html_e( 'Warning', 'invoicing' ); ?></option> |
|
46 | - <option value='btn-info'><?php esc_html_e( 'Info', 'invoicing' ); ?></option> |
|
47 | - <option value='btn-light'><?php esc_html_e( 'Light', 'invoicing' ); ?></option> |
|
48 | - <option value='btn-dark'><?php esc_html_e( 'Dark', 'invoicing' ); ?></option> |
|
49 | - <option value='btn-link'><?php esc_html_e( 'Link', 'invoicing' ); ?></option> |
|
41 | + <option value='btn-primary'><?php esc_html_e('Primary', 'invoicing'); ?></option> |
|
42 | + <option value='btn-secondary'><?php esc_html_e('Secondary', 'invoicing'); ?></option> |
|
43 | + <option value='btn-success'><?php esc_html_e('Success', 'invoicing'); ?></option> |
|
44 | + <option value='btn-danger'><?php esc_html_e('Danger', 'invoicing'); ?></option> |
|
45 | + <option value='btn-warning'><?php esc_html_e('Warning', 'invoicing'); ?></option> |
|
46 | + <option value='btn-info'><?php esc_html_e('Info', 'invoicing'); ?></option> |
|
47 | + <option value='btn-light'><?php esc_html_e('Light', 'invoicing'); ?></option> |
|
48 | + <option value='btn-dark'><?php esc_html_e('Dark', 'invoicing'); ?></option> |
|
49 | + <option value='btn-link'><?php esc_html_e('Link', 'invoicing'); ?></option> |
|
50 | 50 | </select> |
51 | 51 | </div> |
@@ -7,37 +7,37 @@ |
||
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 | 15 | <label class="d-block"> |
16 | - <span><?php esc_html_e( 'Field Label', 'invoicing' ); ?></span> |
|
16 | + <span><?php esc_html_e('Field Label', 'invoicing'); ?></span> |
|
17 | 17 | <input v-model='active_form_element.label' class='form-control' type="text"/> |
18 | 18 | </label> |
19 | 19 | </div> |
20 | 20 | |
21 | 21 | <div class='form-group'> |
22 | 22 | <label class="d-block"> |
23 | - <span><?php esc_html_e( 'Help Text', 'invoicing' ); ?></span> |
|
24 | - <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> |
|
25 | - <small class="form-text text-muted"><?php _e( 'HTML is allowed', 'invoicing' ); ?></small> |
|
23 | + <span><?php esc_html_e('Help Text', 'invoicing'); ?></span> |
|
24 | + <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> |
|
25 | + <small class="form-text text-muted"><?php _e('HTML is allowed', 'invoicing'); ?></small> |
|
26 | 26 | </label> |
27 | 27 | </div> |
28 | 28 | |
29 | 29 | <div class='form-group form-check'> |
30 | 30 | <input :id="active_form_element.id + '_edit'" v-model='active_form_element.required' type='checkbox' class='form-check-input' /> |
31 | - <label class='form-check-label' :for="active_form_element.id + '_edit'"><?php esc_html_e( 'Is this field required?', 'invoicing' ); ?></label> |
|
31 | + <label class='form-check-label' :for="active_form_element.id + '_edit'"><?php esc_html_e('Is this field required?', 'invoicing'); ?></label> |
|
32 | 32 | </div> |
33 | 33 | |
34 | 34 | <hr class='featurette-divider mt-4'> |
35 | 35 | |
36 | 36 | <div class='form-group'> |
37 | 37 | <label class="d-block"> |
38 | - <span><?php esc_html_e( 'Email Merge Tag', 'invoicing' ); ?></span> |
|
38 | + <span><?php esc_html_e('Email Merge Tag', 'invoicing'); ?></span> |
|
39 | 39 | <input :value='active_form_element.label | formatMergeTag' class='form-control bg-white' type="text" readonly onclick="this.select()" /> |
40 | - <span class="form-text text-muted"><?php esc_html_e( 'You can use this merge tag in notification emails', 'invoicing' ); ?></span> |
|
40 | + <span class="form-text text-muted"><?php esc_html_e('You can use this merge tag in notification emails', 'invoicing'); ?></span> |
|
41 | 41 | </label> |
42 | 42 | </div> |
43 | 43 |
@@ -7,44 +7,44 @@ |
||
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 | 15 | <label class="d-block"> |
16 | - <span><?php esc_html_e( 'Field Label', 'invoicing' ); ?></span> |
|
16 | + <span><?php esc_html_e('Field Label', 'invoicing'); ?></span> |
|
17 | 17 | <input v-model='active_form_element.label' class='form-control' type="text"/> |
18 | 18 | </label> |
19 | 19 | </div> |
20 | 20 | |
21 | 21 | <div class='form-group'> |
22 | 22 | <label class="d-block"> |
23 | - <span><?php esc_html_e( 'Placeholder text', 'invoicing' ); ?></span> |
|
23 | + <span><?php esc_html_e('Placeholder text', 'invoicing'); ?></span> |
|
24 | 24 | <input v-model='active_form_element.placeholder' class='form-control' type="text"/> |
25 | 25 | </label> |
26 | 26 | </div> |
27 | 27 | |
28 | 28 | <div class='form-group'> |
29 | 29 | <label class="d-block"> |
30 | - <span><?php esc_html_e( 'Help Text', 'invoicing' ); ?></span> |
|
31 | - <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> |
|
32 | - <small class="form-text text-muted"><?php _e( 'HTML is allowed', 'invoicing' ); ?></small> |
|
30 | + <span><?php esc_html_e('Help Text', 'invoicing'); ?></span> |
|
31 | + <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> |
|
32 | + <small class="form-text text-muted"><?php _e('HTML is allowed', 'invoicing'); ?></small> |
|
33 | 33 | </label> |
34 | 34 | </div> |
35 | 35 | |
36 | 36 | <div class='form-group form-check'> |
37 | 37 | <input :id="active_form_element.id + '_edit'" v-model='active_form_element.required' type='checkbox' class='form-check-input' /> |
38 | - <label class='form-check-label' :for="active_form_element.id + '_edit'"><?php esc_html_e( 'Is this field required?', 'invoicing' ); ?></label> |
|
38 | + <label class='form-check-label' :for="active_form_element.id + '_edit'"><?php esc_html_e('Is this field required?', 'invoicing'); ?></label> |
|
39 | 39 | </div> |
40 | 40 | |
41 | 41 | <hr class='featurette-divider mt-4'> |
42 | 42 | |
43 | 43 | <div class='form-group'> |
44 | 44 | <label class="d-block"> |
45 | - <span><?php esc_html_e( 'Email Merge Tag', 'invoicing' ); ?></span> |
|
45 | + <span><?php esc_html_e('Email Merge Tag', 'invoicing'); ?></span> |
|
46 | 46 | <input :value='active_form_element.label | formatMergeTag' class='form-control bg-white' type="text" readonly onclick="this.select()" /> |
47 | - <span class="form-text text-muted"><?php esc_html_e( 'You can use this merge tag in notification emails', 'invoicing' ); ?></span> |
|
47 | + <span class="form-text text-muted"><?php esc_html_e('You can use this merge tag in notification emails', 'invoicing'); ?></span> |
|
48 | 48 | </label> |
49 | 49 | </div> |
50 | 50 |