@@ -4,26 +4,26 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | ?> |
10 | 10 | <div class="table-responsive"> |
11 | 11 | <table id="wpinv_gateways_select" class="table border bg-white form-table"> |
12 | - <caption><?php echo esc_html_e( 'This table displays installed payment methods.', 'invoicing' ); ?></caption> |
|
12 | + <caption><?php echo esc_html_e('This table displays installed payment methods.', 'invoicing'); ?></caption> |
|
13 | 13 | |
14 | 14 | <thead> |
15 | 15 | <tr class="table-light"> |
16 | 16 | |
17 | 17 | <th scope="col" class="border-bottom border-top text-left"> |
18 | - <?php _e( 'Payment Method', 'invoicing' ); ?> |
|
18 | + <?php _e('Payment Method', 'invoicing'); ?> |
|
19 | 19 | </th> |
20 | 20 | |
21 | 21 | <th scope="col" class="border-bottom border-top text-center"> |
22 | - <?php _e( 'Enabled', 'invoicing' ); ?> |
|
22 | + <?php _e('Enabled', 'invoicing'); ?> |
|
23 | 23 | </th> |
24 | 24 | |
25 | 25 | <th scope="col" class="border-bottom border-top text-center"> |
26 | - <?php _e( 'Supports Subscriptions', 'invoicing' ); ?> |
|
26 | + <?php _e('Supports Subscriptions', 'invoicing'); ?> |
|
27 | 27 | </th> |
28 | 28 | |
29 | 29 | <th scope="col" class="border-bottom border-top text-right" style="width:32px"> </th> |
@@ -32,15 +32,15 @@ discard block |
||
32 | 32 | </thead> |
33 | 33 | |
34 | 34 | <tbody> |
35 | - <?php foreach ( wpinv_get_payment_gateways() as $id => $gateway ) : ?> |
|
35 | + <?php foreach (wpinv_get_payment_gateways() as $id => $gateway) : ?> |
|
36 | 36 | <tr> |
37 | 37 | <td class="getpaid-payment-method text-left"> |
38 | - <a style="color: #0073aa;" href="<?php echo esc_url( add_query_arg( 'section', $id ) ); ?>" class="font-weight-bold"><?php echo sanitize_text_field( $gateway['admin_label'] ); ?></a> |
|
38 | + <a style="color: #0073aa;" href="<?php echo esc_url(add_query_arg('section', $id)); ?>" class="font-weight-bold"><?php echo sanitize_text_field($gateway['admin_label']); ?></a> |
|
39 | 39 | </td> |
40 | 40 | <td class="getpaid-payment-method-enabled text-center"> |
41 | 41 | <?php |
42 | 42 | |
43 | - $id = esc_attr( $id ); |
|
43 | + $id = esc_attr($id); |
|
44 | 44 | echo aui()->input( |
45 | 45 | array( |
46 | 46 | 'type' => 'checkbox', |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | 'value' => 1, |
50 | 50 | 'switch' => true, |
51 | 51 | 'label' => ' ', |
52 | - 'checked' => wpinv_is_gateway_active( $id ), |
|
52 | + 'checked' => wpinv_is_gateway_active($id), |
|
53 | 53 | 'no_wrap' => true, |
54 | 54 | ) |
55 | 55 | ); |
@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | <td class="getpaid-payment-method-subscription text-center"> |
60 | 60 | <?php |
61 | 61 | |
62 | - $supports = apply_filters( "wpinv_{$id}_support_subscription", false ); |
|
63 | - $supports = apply_filters( 'getapid_gateway_supports_subscription', $supports, $id ); |
|
62 | + $supports = apply_filters("wpinv_{$id}_support_subscription", false); |
|
63 | + $supports = apply_filters('getapid_gateway_supports_subscription', $supports, $id); |
|
64 | 64 | |
65 | - if ( $supports ) { |
|
65 | + if ($supports) { |
|
66 | 66 | echo "<i class='text-success fa fa-check'></i>"; |
67 | 67 | } else { |
68 | 68 | echo "<i class='text-dark fa fa-times'></i>"; |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | </td> |
73 | 73 | |
74 | 74 | <td class="getpaid-payment-method-action text-right"> |
75 | - <a class="button button-secondary" href="<?php echo esc_url( add_query_arg( 'section', $id ) ); ?>"><?php _e( 'Manage', 'invoicing' ); ?></a> |
|
75 | + <a class="button button-secondary" href="<?php echo esc_url(add_query_arg('section', $id)); ?>"><?php _e('Manage', 'invoicing'); ?></a> |
|
76 | 76 | </td> |
77 | 77 | |
78 | 78 | </tr> |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | <tr class="table-light"> |
84 | 84 | <td colspan="4" class="border-top"> |
85 | 85 | <a class="button button-secondary getpaid-install-gateways" href="https://wpgetpaid.com/downloads/category/gateways/"> |
86 | - <span><?php _e( 'Add Payment Methods', 'invoicing' ); ?></span> |
|
86 | + <span><?php _e('Add Payment Methods', 'invoicing'); ?></span> |
|
87 | 87 | </a> |
88 | 88 | </td> |
89 | 89 | </tr> |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Retrieves the current invoice. |
@@ -14,15 +14,15 @@ discard block |
||
14 | 14 | function getpaid_get_current_invoice_id() { |
15 | 15 | |
16 | 16 | // Ensure that we have an invoice key. |
17 | - if ( empty( $_GET['invoice_key'] ) ) { |
|
17 | + if (empty($_GET['invoice_key'])) { |
|
18 | 18 | return 0; |
19 | 19 | } |
20 | 20 | |
21 | 21 | // Retrieve an invoice using the key. |
22 | - $invoice = new WPInv_Invoice( $_GET['invoice_key'] ); |
|
22 | + $invoice = new WPInv_Invoice($_GET['invoice_key']); |
|
23 | 23 | |
24 | 24 | // Compare the invoice key and the parsed key. |
25 | - if ( $invoice->get_id() != 0 && $invoice->get_key() == $_GET['invoice_key'] ) { |
|
25 | + if ($invoice->get_id() != 0 && $invoice->get_key() == $_GET['invoice_key']) { |
|
26 | 26 | return $invoice->get_id(); |
27 | 27 | } |
28 | 28 | |
@@ -32,42 +32,42 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * Checks if the current user cna view an invoice. |
34 | 34 | */ |
35 | -function wpinv_user_can_view_invoice( $invoice ) { |
|
36 | - $invoice = new WPInv_Invoice( $invoice ); |
|
35 | +function wpinv_user_can_view_invoice($invoice) { |
|
36 | + $invoice = new WPInv_Invoice($invoice); |
|
37 | 37 | |
38 | 38 | // Abort if the invoice does not exist. |
39 | - if ( 0 == $invoice->get_id() ) { |
|
39 | + if (0 == $invoice->get_id()) { |
|
40 | 40 | return false; |
41 | 41 | } |
42 | 42 | |
43 | 43 | // Don't allow trash, draft status |
44 | - if ( $invoice->is_draft() ) { |
|
44 | + if ($invoice->is_draft()) { |
|
45 | 45 | return false; |
46 | 46 | } |
47 | 47 | |
48 | 48 | // If users are not required to login to check out, compare the invoice keys. |
49 | - if ( ! wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && trim( $_GET['invoice_key'] ) == $invoice->get_key() ) { |
|
49 | + if (!wpinv_require_login_to_checkout() && isset($_GET['invoice_key']) && trim($_GET['invoice_key']) == $invoice->get_key()) { |
|
50 | 50 | return true; |
51 | 51 | } |
52 | 52 | |
53 | 53 | // Always enable for admins.. |
54 | - if ( wpinv_current_user_can_manage_invoicing() || current_user_can( 'view_invoices', $invoice->get_id() ) ) { // Admin user |
|
54 | + if (wpinv_current_user_can_manage_invoicing() || current_user_can('view_invoices', $invoice->get_id())) { // Admin user |
|
55 | 55 | return true; |
56 | 56 | } |
57 | 57 | |
58 | 58 | // Else, ensure that this is their invoice. |
59 | - if ( is_user_logged_in() && $invoice->get_user_id() == get_current_user_id() ) { |
|
59 | + if (is_user_logged_in() && $invoice->get_user_id() == get_current_user_id()) { |
|
60 | 60 | return true; |
61 | 61 | } |
62 | 62 | |
63 | - return apply_filters( 'wpinv_current_user_can_view_invoice', false, $invoice ); |
|
63 | + return apply_filters('wpinv_current_user_can_view_invoice', false, $invoice); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
67 | 67 | * Checks if the current user cna view an invoice receipt. |
68 | 68 | */ |
69 | -function wpinv_can_view_receipt( $invoice ) { |
|
70 | - return (bool) apply_filters( 'wpinv_can_view_receipt', wpinv_user_can_view_invoice( $invoice ), $invoice ); |
|
69 | +function wpinv_can_view_receipt($invoice) { |
|
70 | + return (bool) apply_filters('wpinv_can_view_receipt', wpinv_user_can_view_invoice($invoice), $invoice); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -77,16 +77,16 @@ discard block |
||
77 | 77 | */ |
78 | 78 | function getpaid_get_invoice_post_types() { |
79 | 79 | $post_types = array( |
80 | - 'wpi_quote' => __( 'Quote', 'invoicing' ), |
|
81 | - 'wpi_invoice' => __( 'Invoice', 'invoicing' ), |
|
80 | + 'wpi_quote' => __('Quote', 'invoicing'), |
|
81 | + 'wpi_invoice' => __('Invoice', 'invoicing'), |
|
82 | 82 | ); |
83 | 83 | |
84 | 84 | // Ensure the quotes addon is installed. |
85 | - if ( ! defined( 'WPINV_QUOTES_VERSION' ) ) { |
|
86 | - unset( $post_types['wpi_quote'] ); |
|
85 | + if (!defined('WPINV_QUOTES_VERSION')) { |
|
86 | + unset($post_types['wpi_quote']); |
|
87 | 87 | } |
88 | 88 | |
89 | - return apply_filters( 'getpaid_invoice_post_types', $post_types ); |
|
89 | + return apply_filters('getpaid_invoice_post_types', $post_types); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @param string $post_type The post type to check for. |
97 | 97 | */ |
98 | -function getpaid_is_invoice_post_type( $post_type ) { |
|
99 | - return is_scalar( $post_type ) && ! empty( $post_type ) && array_key_exists( $post_type, getpaid_get_invoice_post_types() ); |
|
98 | +function getpaid_is_invoice_post_type($post_type) { |
|
99 | + return is_scalar($post_type) && !empty($post_type) && array_key_exists($post_type, getpaid_get_invoice_post_types()); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -106,9 +106,9 @@ discard block |
||
106 | 106 | * @param bool $wp_error Whether to return false or WP_Error on failure. |
107 | 107 | * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success. |
108 | 108 | */ |
109 | -function wpinv_create_invoice( $data = array(), $deprecated = null, $wp_error = false ) { |
|
110 | - $data[ 'invoice_id' ] = 0; |
|
111 | - return wpinv_insert_invoice( $data, $wp_error ); |
|
109 | +function wpinv_create_invoice($data = array(), $deprecated = null, $wp_error = false) { |
|
110 | + $data['invoice_id'] = 0; |
|
111 | + return wpinv_insert_invoice($data, $wp_error); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -118,36 +118,36 @@ discard block |
||
118 | 118 | * @param bool $wp_error Whether to return false or WP_Error on failure. |
119 | 119 | * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success. |
120 | 120 | */ |
121 | -function wpinv_update_invoice( $data = array(), $wp_error = false ) { |
|
121 | +function wpinv_update_invoice($data = array(), $wp_error = false) { |
|
122 | 122 | |
123 | 123 | // Backwards compatibility. |
124 | - if ( ! empty( $data['ID'] ) ) { |
|
124 | + if (!empty($data['ID'])) { |
|
125 | 125 | $data['invoice_id'] = $data['ID']; |
126 | 126 | } |
127 | 127 | |
128 | 128 | // Do we have an invoice id? |
129 | - if ( empty( $data['invoice_id'] ) ) { |
|
130 | - return $wp_error ? new WP_Error( 'invalid_invoice_id', __( 'Invalid invoice ID.', 'invoicing' ) ) : 0; |
|
129 | + if (empty($data['invoice_id'])) { |
|
130 | + return $wp_error ? new WP_Error('invalid_invoice_id', __('Invalid invoice ID.', 'invoicing')) : 0; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | // Retrieve the invoice. |
134 | - $invoice = wpinv_get_invoice( $data['invoice_id'] ); |
|
134 | + $invoice = wpinv_get_invoice($data['invoice_id']); |
|
135 | 135 | |
136 | 136 | // And abort if it does not exist. |
137 | - if ( empty( $invoice ) ) { |
|
138 | - return $wp_error ? new WP_Error( 'missing_invoice', __( 'Invoice not found.', 'invoicing' ) ) : 0; |
|
137 | + if (empty($invoice)) { |
|
138 | + return $wp_error ? new WP_Error('missing_invoice', __('Invoice not found.', 'invoicing')) : 0; |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | // Do not update totals for paid / refunded invoices. |
142 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
142 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
143 | 143 | |
144 | - if ( ! empty( $data['items'] ) || ! empty( $data['cart_details'] ) ) { |
|
145 | - return $wp_error ? new WP_Error( 'paid_invoice', __( 'You can not update cart items for invoices that have already been paid for.', 'invoicing' ) ) : 0; |
|
144 | + if (!empty($data['items']) || !empty($data['cart_details'])) { |
|
145 | + return $wp_error ? new WP_Error('paid_invoice', __('You can not update cart items for invoices that have already been paid for.', 'invoicing')) : 0; |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | } |
149 | 149 | |
150 | - return wpinv_insert_invoice( $data, $wp_error ); |
|
150 | + return wpinv_insert_invoice($data, $wp_error); |
|
151 | 151 | |
152 | 152 | } |
153 | 153 | |
@@ -158,34 +158,34 @@ discard block |
||
158 | 158 | * @param bool $wp_error Whether to return false or WP_Error on failure. |
159 | 159 | * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success. |
160 | 160 | */ |
161 | -function wpinv_insert_invoice( $data = array(), $wp_error = false ) { |
|
161 | +function wpinv_insert_invoice($data = array(), $wp_error = false) { |
|
162 | 162 | |
163 | 163 | // Ensure that we have invoice data. |
164 | - if ( empty( $data ) ) { |
|
164 | + if (empty($data)) { |
|
165 | 165 | return false; |
166 | 166 | } |
167 | 167 | |
168 | 168 | // The invoice id will be provided when updating an invoice. |
169 | - $data['invoice_id'] = ! empty( $data['invoice_id'] ) ? (int) $data['invoice_id'] : false; |
|
169 | + $data['invoice_id'] = !empty($data['invoice_id']) ? (int) $data['invoice_id'] : false; |
|
170 | 170 | |
171 | 171 | // Retrieve the invoice. |
172 | - $invoice = new WPInv_Invoice( $data['invoice_id'] ); |
|
172 | + $invoice = new WPInv_Invoice($data['invoice_id']); |
|
173 | 173 | |
174 | 174 | // Do we have an error? |
175 | - if ( ! empty( $invoice->last_error ) ) { |
|
176 | - return $wp_error ? new WP_Error( 'invalid_invoice_id', $invoice->last_error ) : 0; |
|
175 | + if (!empty($invoice->last_error)) { |
|
176 | + return $wp_error ? new WP_Error('invalid_invoice_id', $invoice->last_error) : 0; |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | // Backwards compatibility (billing address). |
180 | - if ( ! empty( $data['user_info'] ) ) { |
|
180 | + if (!empty($data['user_info'])) { |
|
181 | 181 | |
182 | - foreach ( $data['user_info'] as $key => $value ) { |
|
182 | + foreach ($data['user_info'] as $key => $value) { |
|
183 | 183 | |
184 | - if ( $key == 'discounts' ) { |
|
184 | + if ($key == 'discounts') { |
|
185 | 185 | $value = (array) $value; |
186 | - $data[ 'discount_code' ] = empty( $value ) ? null : $value[0]; |
|
186 | + $data['discount_code'] = empty($value) ? null : $value[0]; |
|
187 | 187 | } else { |
188 | - $data[ $key ] = $value; |
|
188 | + $data[$key] = $value; |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | } |
@@ -193,30 +193,30 @@ discard block |
||
193 | 193 | } |
194 | 194 | |
195 | 195 | // Backwards compatibility. |
196 | - if ( ! empty( $data['payment_details'] ) ) { |
|
196 | + if (!empty($data['payment_details'])) { |
|
197 | 197 | |
198 | - foreach ( $data['payment_details'] as $key => $value ) { |
|
199 | - $data[ $key ] = $value; |
|
198 | + foreach ($data['payment_details'] as $key => $value) { |
|
199 | + $data[$key] = $value; |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | } |
203 | 203 | |
204 | 204 | // Set up the owner of the invoice. |
205 | - $user_id = ! empty( $data['user_id'] ) ? wpinv_clean( $data['user_id'] ) : get_current_user_id(); |
|
205 | + $user_id = !empty($data['user_id']) ? wpinv_clean($data['user_id']) : get_current_user_id(); |
|
206 | 206 | |
207 | 207 | // Make sure the user exists. |
208 | - if ( ! get_userdata( $user_id ) ) { |
|
209 | - return $wp_error ? new WP_Error( 'wpinv_invalid_user', __( 'There is no user with that ID.', 'invoicing' ) ) : 0; |
|
208 | + if (!get_userdata($user_id)) { |
|
209 | + return $wp_error ? new WP_Error('wpinv_invalid_user', __('There is no user with that ID.', 'invoicing')) : 0; |
|
210 | 210 | } |
211 | 211 | |
212 | - $address = wpinv_get_user_address( $user_id ); |
|
212 | + $address = wpinv_get_user_address($user_id); |
|
213 | 213 | |
214 | - foreach ( $address as $key => $value ) { |
|
214 | + foreach ($address as $key => $value) { |
|
215 | 215 | |
216 | - if ( $value == '' ) { |
|
217 | - $address[ $key ] = null; |
|
216 | + if ($value == '') { |
|
217 | + $address[$key] = null; |
|
218 | 218 | } else { |
219 | - $address[ $key ] = wpinv_clean( $value ); |
|
219 | + $address[$key] = wpinv_clean($value); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | } |
@@ -227,103 +227,103 @@ discard block |
||
227 | 227 | array( |
228 | 228 | |
229 | 229 | // Basic info. |
230 | - 'template' => isset( $data['template'] ) ? wpinv_clean( $data['template'] ) : null, |
|
231 | - 'email_cc' => isset( $data['email_cc'] ) ? wpinv_clean( $data['email_cc'] ) : null, |
|
232 | - 'date_created' => isset( $data['created_date'] ) ? wpinv_clean( $data['created_date'] ) : null, |
|
233 | - 'due_date' => isset( $data['due_date'] ) ? wpinv_clean( $data['due_date'] ) : null, |
|
234 | - 'date_completed' => isset( $data['date_completed'] ) ? wpinv_clean( $data['date_completed'] ) : null, |
|
235 | - 'number' => isset( $data['number'] ) ? wpinv_clean( $data['number'] ) : null, |
|
236 | - 'key' => isset( $data['key'] ) ? wpinv_clean( $data['key'] ) : null, |
|
237 | - 'status' => isset( $data['status'] ) ? wpinv_clean( $data['status'] ) : null, |
|
238 | - 'post_type' => isset( $data['post_type'] ) ? wpinv_clean( $data['post_type'] ) : null, |
|
239 | - 'user_ip' => isset( $data['ip'] ) ? wpinv_clean( $data['ip'] ) : wpinv_get_ip(), |
|
240 | - 'parent_id' => isset( $data['parent'] ) ? intval( $data['parent'] ) : null, |
|
241 | - 'mode' => isset( $data['mode'] ) ? wpinv_clean( $data['mode'] ) : null, |
|
242 | - 'description' => isset( $data['description'] ) ? wp_kses_post( $data['description'] ) : null, |
|
230 | + 'template' => isset($data['template']) ? wpinv_clean($data['template']) : null, |
|
231 | + 'email_cc' => isset($data['email_cc']) ? wpinv_clean($data['email_cc']) : null, |
|
232 | + 'date_created' => isset($data['created_date']) ? wpinv_clean($data['created_date']) : null, |
|
233 | + 'due_date' => isset($data['due_date']) ? wpinv_clean($data['due_date']) : null, |
|
234 | + 'date_completed' => isset($data['date_completed']) ? wpinv_clean($data['date_completed']) : null, |
|
235 | + 'number' => isset($data['number']) ? wpinv_clean($data['number']) : null, |
|
236 | + 'key' => isset($data['key']) ? wpinv_clean($data['key']) : null, |
|
237 | + 'status' => isset($data['status']) ? wpinv_clean($data['status']) : null, |
|
238 | + 'post_type' => isset($data['post_type']) ? wpinv_clean($data['post_type']) : null, |
|
239 | + 'user_ip' => isset($data['ip']) ? wpinv_clean($data['ip']) : wpinv_get_ip(), |
|
240 | + 'parent_id' => isset($data['parent']) ? intval($data['parent']) : null, |
|
241 | + 'mode' => isset($data['mode']) ? wpinv_clean($data['mode']) : null, |
|
242 | + 'description' => isset($data['description']) ? wp_kses_post($data['description']) : null, |
|
243 | 243 | |
244 | 244 | // Payment info. |
245 | - 'disable_taxes' => ! empty( $data['disable_taxes'] ), |
|
246 | - 'currency' => isset( $data['currency'] ) ? wpinv_clean( $data['currency'] ) : wpinv_get_currency(), |
|
247 | - 'gateway' => isset( $data['gateway'] ) ? wpinv_clean( $data['gateway'] ) : null, |
|
248 | - 'transaction_id' => isset( $data['transaction_id'] ) ? wpinv_clean( $data['transaction_id'] ) : null, |
|
249 | - 'discount_code' => isset( $data['discount_code'] ) ? wpinv_clean( $data['discount_code'] ) : null, |
|
250 | - 'payment_form' => isset( $data['payment_form'] ) ? intval( $data['payment_form'] ) : null, |
|
251 | - 'submission_id' => isset( $data['submission_id'] ) ? wpinv_clean( $data['submission_id'] ) : null, |
|
252 | - 'subscription_id' => isset( $data['subscription_id'] ) ? wpinv_clean( $data['subscription_id'] ) : null, |
|
253 | - 'is_viewed' => isset( $data['is_viewed'] ) ? wpinv_clean( $data['is_viewed'] ) : null, |
|
254 | - 'fees' => isset( $data['fees'] ) ? wpinv_clean( $data['fees'] ) : null, |
|
255 | - 'discounts' => isset( $data['discounts'] ) ? wpinv_clean( $data['discounts'] ) : null, |
|
256 | - 'taxes' => isset( $data['taxes'] ) ? wpinv_clean( $data['taxes'] ) : null, |
|
245 | + 'disable_taxes' => !empty($data['disable_taxes']), |
|
246 | + 'currency' => isset($data['currency']) ? wpinv_clean($data['currency']) : wpinv_get_currency(), |
|
247 | + 'gateway' => isset($data['gateway']) ? wpinv_clean($data['gateway']) : null, |
|
248 | + 'transaction_id' => isset($data['transaction_id']) ? wpinv_clean($data['transaction_id']) : null, |
|
249 | + 'discount_code' => isset($data['discount_code']) ? wpinv_clean($data['discount_code']) : null, |
|
250 | + 'payment_form' => isset($data['payment_form']) ? intval($data['payment_form']) : null, |
|
251 | + 'submission_id' => isset($data['submission_id']) ? wpinv_clean($data['submission_id']) : null, |
|
252 | + 'subscription_id' => isset($data['subscription_id']) ? wpinv_clean($data['subscription_id']) : null, |
|
253 | + 'is_viewed' => isset($data['is_viewed']) ? wpinv_clean($data['is_viewed']) : null, |
|
254 | + 'fees' => isset($data['fees']) ? wpinv_clean($data['fees']) : null, |
|
255 | + 'discounts' => isset($data['discounts']) ? wpinv_clean($data['discounts']) : null, |
|
256 | + 'taxes' => isset($data['taxes']) ? wpinv_clean($data['taxes']) : null, |
|
257 | 257 | |
258 | 258 | |
259 | 259 | // Billing details. |
260 | 260 | 'user_id' => $data['user_id'], |
261 | - 'first_name' => isset( $data['first_name'] ) ? wpinv_clean( $data['first_name'] ) : $address['first_name'], |
|
262 | - 'last_name' => isset( $data['last_name'] ) ? wpinv_clean( $data['last_name'] ) : $address['last_name'], |
|
263 | - 'address' => isset( $data['address'] ) ? wpinv_clean( $data['address'] ) : $address['address'] , |
|
264 | - 'vat_number' => isset( $data['vat_number'] ) ? wpinv_clean( $data['vat_number'] ) : $address['vat_number'], |
|
265 | - 'company' => isset( $data['company'] ) ? wpinv_clean( $data['company'] ) : $address['company'], |
|
266 | - 'zip' => isset( $data['zip'] ) ? wpinv_clean( $data['zip'] ) : $address['zip'], |
|
267 | - 'state' => isset( $data['state'] ) ? wpinv_clean( $data['state'] ) : $address['state'], |
|
268 | - 'city' => isset( $data['city'] ) ? wpinv_clean( $data['city'] ) : $address['city'], |
|
269 | - 'country' => isset( $data['country'] ) ? wpinv_clean( $data['country'] ) : $address['country'], |
|
270 | - 'phone' => isset( $data['phone'] ) ? wpinv_clean( $data['phone'] ) : $address['phone'], |
|
271 | - 'address_confirmed' => ! empty( $data['address_confirmed'] ), |
|
261 | + 'first_name' => isset($data['first_name']) ? wpinv_clean($data['first_name']) : $address['first_name'], |
|
262 | + 'last_name' => isset($data['last_name']) ? wpinv_clean($data['last_name']) : $address['last_name'], |
|
263 | + 'address' => isset($data['address']) ? wpinv_clean($data['address']) : $address['address'], |
|
264 | + 'vat_number' => isset($data['vat_number']) ? wpinv_clean($data['vat_number']) : $address['vat_number'], |
|
265 | + 'company' => isset($data['company']) ? wpinv_clean($data['company']) : $address['company'], |
|
266 | + 'zip' => isset($data['zip']) ? wpinv_clean($data['zip']) : $address['zip'], |
|
267 | + 'state' => isset($data['state']) ? wpinv_clean($data['state']) : $address['state'], |
|
268 | + 'city' => isset($data['city']) ? wpinv_clean($data['city']) : $address['city'], |
|
269 | + 'country' => isset($data['country']) ? wpinv_clean($data['country']) : $address['country'], |
|
270 | + 'phone' => isset($data['phone']) ? wpinv_clean($data['phone']) : $address['phone'], |
|
271 | + 'address_confirmed' => !empty($data['address_confirmed']), |
|
272 | 272 | |
273 | 273 | ) |
274 | 274 | |
275 | 275 | ); |
276 | 276 | |
277 | 277 | // Backwards compatibililty. |
278 | - if ( ! empty( $data['cart_details'] ) && is_array( $data['cart_details'] ) ) { |
|
278 | + if (!empty($data['cart_details']) && is_array($data['cart_details'])) { |
|
279 | 279 | $data['items'] = array(); |
280 | 280 | |
281 | - foreach( $data['cart_details'] as $_item ) { |
|
281 | + foreach ($data['cart_details'] as $_item) { |
|
282 | 282 | |
283 | 283 | // Ensure that we have an item id. |
284 | - if ( empty( $_item['id'] ) ) { |
|
284 | + if (empty($_item['id'])) { |
|
285 | 285 | continue; |
286 | 286 | } |
287 | 287 | |
288 | 288 | // Retrieve the item. |
289 | - $item = new GetPaid_Form_Item( $_item['id'] ); |
|
289 | + $item = new GetPaid_Form_Item($_item['id']); |
|
290 | 290 | |
291 | 291 | // Ensure that it is purchasable. |
292 | - if ( ! $item->can_purchase() ) { |
|
292 | + if (!$item->can_purchase()) { |
|
293 | 293 | continue; |
294 | 294 | } |
295 | 295 | |
296 | 296 | // Set quantity. |
297 | - if ( ! empty( $_item['quantity'] ) && is_numeric( $_item['quantity'] ) ) { |
|
298 | - $item->set_quantity( $_item['quantity'] ); |
|
297 | + if (!empty($_item['quantity']) && is_numeric($_item['quantity'])) { |
|
298 | + $item->set_quantity($_item['quantity']); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | // Set price. |
302 | - if ( isset( $_item['item_price'] ) ) { |
|
303 | - $item->set_price( $_item['item_price'] ); |
|
302 | + if (isset($_item['item_price'])) { |
|
303 | + $item->set_price($_item['item_price']); |
|
304 | 304 | } |
305 | 305 | |
306 | - if ( isset( $_item['custom_price'] ) ) { |
|
307 | - $item->set_price( $_item['custom_price'] ); |
|
306 | + if (isset($_item['custom_price'])) { |
|
307 | + $item->set_price($_item['custom_price']); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | // Set name. |
311 | - if ( ! empty( $_item['name'] ) ) { |
|
312 | - $item->set_name( $_item['name'] ); |
|
311 | + if (!empty($_item['name'])) { |
|
312 | + $item->set_name($_item['name']); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | // Set description. |
316 | - if ( isset( $_item['description'] ) ) { |
|
317 | - $item->set_custom_description( $_item['description'] ); |
|
316 | + if (isset($_item['description'])) { |
|
317 | + $item->set_custom_description($_item['description']); |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | // Set meta. |
321 | - if ( isset( $_item['meta'] ) && is_array( $_item['meta'] ) ) { |
|
321 | + if (isset($_item['meta']) && is_array($_item['meta'])) { |
|
322 | 322 | |
323 | - $item->set_item_meta( $_item['meta'] ); |
|
323 | + $item->set_item_meta($_item['meta']); |
|
324 | 324 | |
325 | - if ( isset( $_item['meta']['description'] ) ) { |
|
326 | - $item->set_custom_description( $_item['meta']['description'] ); |
|
325 | + if (isset($_item['meta']['description'])) { |
|
326 | + $item->set_custom_description($_item['meta']['description']); |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | } |
@@ -334,14 +334,14 @@ discard block |
||
334 | 334 | } |
335 | 335 | |
336 | 336 | // Add invoice items. |
337 | - if ( ! empty( $data['items'] ) && is_array( $data['items'] ) ) { |
|
337 | + if (!empty($data['items']) && is_array($data['items'])) { |
|
338 | 338 | |
339 | - $invoice->set_items( array() ); |
|
339 | + $invoice->set_items(array()); |
|
340 | 340 | |
341 | - foreach ( $data['items'] as $item ) { |
|
341 | + foreach ($data['items'] as $item) { |
|
342 | 342 | |
343 | - if ( is_object( $item ) && is_a( $item, 'GetPaid_Form_Item' ) && $item->can_purchase() ) { |
|
344 | - $invoice->add_item( $item ); |
|
343 | + if (is_object($item) && is_a($item, 'GetPaid_Form_Item') && $item->can_purchase()) { |
|
344 | + $invoice->add_item($item); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | } |
@@ -352,30 +352,30 @@ discard block |
||
352 | 352 | $invoice->recalculate_total(); |
353 | 353 | $invoice->save(); |
354 | 354 | |
355 | - if ( ! $invoice->get_id() ) { |
|
356 | - return $wp_error ? new WP_Error( 'wpinv_insert_invoice_error', __( 'An error occured when saving your invoice.', 'invoicing' ) ) : 0; |
|
355 | + if (!$invoice->get_id()) { |
|
356 | + return $wp_error ? new WP_Error('wpinv_insert_invoice_error', __('An error occured when saving your invoice.', 'invoicing')) : 0; |
|
357 | 357 | } |
358 | 358 | |
359 | 359 | // Add private note. |
360 | - if ( ! empty( $data['private_note'] ) ) { |
|
361 | - $invoice->add_note( $data['private_note'] ); |
|
360 | + if (!empty($data['private_note'])) { |
|
361 | + $invoice->add_note($data['private_note']); |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | // User notes. |
365 | - if ( !empty( $data['user_note'] ) ) { |
|
366 | - $invoice->add_note( $data['user_note'], true ); |
|
365 | + if (!empty($data['user_note'])) { |
|
366 | + $invoice->add_note($data['user_note'], true); |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | // Created via. |
370 | - if ( isset( $data['created_via'] ) ) { |
|
371 | - update_post_meta( $invoice->get_id(), 'wpinv_created_via', $data['created_via'] ); |
|
370 | + if (isset($data['created_via'])) { |
|
371 | + update_post_meta($invoice->get_id(), 'wpinv_created_via', $data['created_via']); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | // Backwards compatiblity. |
375 | - if ( $invoice->is_quote() ) { |
|
375 | + if ($invoice->is_quote()) { |
|
376 | 376 | |
377 | - if ( isset( $data['valid_until'] ) ) { |
|
378 | - update_post_meta( $invoice->get_id(), 'wpinv_quote_valid_until', $data['valid_until'] ); |
|
377 | + if (isset($data['valid_until'])) { |
|
378 | + update_post_meta($invoice->get_id(), 'wpinv_quote_valid_until', $data['valid_until']); |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | } |
@@ -390,18 +390,18 @@ discard block |
||
390 | 390 | * @param $bool $deprecated |
391 | 391 | * @return WPInv_Invoice|null |
392 | 392 | */ |
393 | -function wpinv_get_invoice( $invoice = 0, $deprecated = false ) { |
|
393 | +function wpinv_get_invoice($invoice = 0, $deprecated = false) { |
|
394 | 394 | |
395 | 395 | // If we are retrieving the invoice from the cart... |
396 | - if ( $deprecated && empty( $invoice ) ) { |
|
396 | + if ($deprecated && empty($invoice)) { |
|
397 | 397 | $invoice = (int) getpaid_get_current_invoice_id(); |
398 | 398 | } |
399 | 399 | |
400 | 400 | // Retrieve the invoice. |
401 | - $invoice = new WPInv_Invoice( $invoice ); |
|
401 | + $invoice = new WPInv_Invoice($invoice); |
|
402 | 402 | |
403 | 403 | // Check if it exists. |
404 | - if ( $invoice->get_id() != 0 ) { |
|
404 | + if ($invoice->get_id() != 0) { |
|
405 | 405 | return $invoice; |
406 | 406 | } |
407 | 407 | |
@@ -414,15 +414,15 @@ discard block |
||
414 | 414 | * @param array $args Args to search for. |
415 | 415 | * @return WPInv_Invoice[]|int[]|object |
416 | 416 | */ |
417 | -function wpinv_get_invoices( $args ) { |
|
417 | +function wpinv_get_invoices($args) { |
|
418 | 418 | |
419 | 419 | // Prepare args. |
420 | 420 | $args = wp_parse_args( |
421 | 421 | $args, |
422 | 422 | array( |
423 | - 'status' => array_keys( wpinv_get_invoice_statuses() ), |
|
423 | + 'status' => array_keys(wpinv_get_invoice_statuses()), |
|
424 | 424 | 'type' => 'wpi_invoice', |
425 | - 'limit' => get_option( 'posts_per_page' ), |
|
425 | + 'limit' => get_option('posts_per_page'), |
|
426 | 426 | 'return' => 'objects', |
427 | 427 | ) |
428 | 428 | ); |
@@ -440,24 +440,24 @@ discard block |
||
440 | 440 | 'post__in' => 'include', |
441 | 441 | ); |
442 | 442 | |
443 | - foreach ( $map_legacy as $to => $from ) { |
|
444 | - if ( isset( $args[ $from ] ) ) { |
|
445 | - $args[ $to ] = $args[ $from ]; |
|
446 | - unset( $args[ $from ] ); |
|
443 | + foreach ($map_legacy as $to => $from) { |
|
444 | + if (isset($args[$from])) { |
|
445 | + $args[$to] = $args[$from]; |
|
446 | + unset($args[$from]); |
|
447 | 447 | } |
448 | 448 | } |
449 | 449 | |
450 | 450 | // Backwards compatibility. |
451 | - if ( ! empty( $args['email'] ) && empty( $args['user'] ) ) { |
|
451 | + if (!empty($args['email']) && empty($args['user'])) { |
|
452 | 452 | $args['user'] = $args['email']; |
453 | - unset( $args['email'] ); |
|
453 | + unset($args['email']); |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | // Handle cases where the user is set as an email. |
457 | - if ( ! empty( $args['author'] ) && is_email( $args['author'] ) ) { |
|
458 | - $user = get_user_by( 'email', $args['user'] ); |
|
457 | + if (!empty($args['author']) && is_email($args['author'])) { |
|
458 | + $user = get_user_by('email', $args['user']); |
|
459 | 459 | |
460 | - if ( $user ) { |
|
460 | + if ($user) { |
|
461 | 461 | $args['author'] = $user->user_email; |
462 | 462 | } |
463 | 463 | |
@@ -468,31 +468,31 @@ discard block |
||
468 | 468 | |
469 | 469 | // Show all posts. |
470 | 470 | $paginate = true; |
471 | - if ( isset( $args['paginate'] ) ) { |
|
471 | + if (isset($args['paginate'])) { |
|
472 | 472 | |
473 | 473 | $paginate = $args['paginate']; |
474 | - $args['no_found_rows'] = empty( $args['paginate'] ); |
|
475 | - unset( $args['paginate'] ); |
|
474 | + $args['no_found_rows'] = empty($args['paginate']); |
|
475 | + unset($args['paginate']); |
|
476 | 476 | |
477 | 477 | } |
478 | 478 | |
479 | 479 | // Whether to return objects or fields. |
480 | 480 | $return = $args['return']; |
481 | - unset( $args['return'] ); |
|
481 | + unset($args['return']); |
|
482 | 482 | |
483 | 483 | // Get invoices. |
484 | - $invoices = new WP_Query( apply_filters( 'wpinv_get_invoices_args', $args ) ); |
|
484 | + $invoices = new WP_Query(apply_filters('wpinv_get_invoices_args', $args)); |
|
485 | 485 | |
486 | 486 | // Prepare the results. |
487 | - if ( 'objects' === $return ) { |
|
488 | - $results = array_map( 'wpinv_get_invoice', $invoices->posts ); |
|
489 | - } elseif ( 'self' === $return ) { |
|
487 | + if ('objects' === $return) { |
|
488 | + $results = array_map('wpinv_get_invoice', $invoices->posts); |
|
489 | + } elseif ('self' === $return) { |
|
490 | 490 | return $invoices; |
491 | 491 | } else { |
492 | 492 | $results = $invoices->posts; |
493 | 493 | } |
494 | 494 | |
495 | - if ( $paginate ) { |
|
495 | + if ($paginate) { |
|
496 | 496 | return (object) array( |
497 | 497 | 'invoices' => $results, |
498 | 498 | 'total' => $invoices->found_posts, |
@@ -510,8 +510,8 @@ discard block |
||
510 | 510 | * @param string $transaction_id The transaction id to check. |
511 | 511 | * @return int Invoice id on success or 0 on failure |
512 | 512 | */ |
513 | -function wpinv_get_id_by_transaction_id( $transaction_id ) { |
|
514 | - return WPInv_Invoice::get_invoice_id_by_field( $transaction_id, 'transaction_id' ); |
|
513 | +function wpinv_get_id_by_transaction_id($transaction_id) { |
|
514 | + return WPInv_Invoice::get_invoice_id_by_field($transaction_id, 'transaction_id'); |
|
515 | 515 | } |
516 | 516 | |
517 | 517 | /** |
@@ -520,8 +520,8 @@ discard block |
||
520 | 520 | * @param string $invoice_number The invoice number to check. |
521 | 521 | * @return int Invoice id on success or 0 on failure |
522 | 522 | */ |
523 | -function wpinv_get_id_by_invoice_number( $invoice_number ) { |
|
524 | - return WPInv_Invoice::get_invoice_id_by_field( $invoice_number, 'number' ); |
|
523 | +function wpinv_get_id_by_invoice_number($invoice_number) { |
|
524 | + return WPInv_Invoice::get_invoice_id_by_field($invoice_number, 'number'); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | /** |
@@ -530,8 +530,8 @@ discard block |
||
530 | 530 | * @param string $invoice_key The invoice key to check. |
531 | 531 | * @return int Invoice id on success or 0 on failure |
532 | 532 | */ |
533 | -function wpinv_get_invoice_id_by_key( $invoice_key ) { |
|
534 | - return WPInv_Invoice::get_invoice_id_by_field( $invoice_key, 'key' ); |
|
533 | +function wpinv_get_invoice_id_by_key($invoice_key) { |
|
534 | + return WPInv_Invoice::get_invoice_id_by_field($invoice_key, 'key'); |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | /** |
@@ -541,19 +541,19 @@ discard block |
||
541 | 541 | * @param string $type Optionally filter by type i.e customer|system |
542 | 542 | * @return array|null |
543 | 543 | */ |
544 | -function wpinv_get_invoice_notes( $invoice = 0, $type = '' ) { |
|
544 | +function wpinv_get_invoice_notes($invoice = 0, $type = '') { |
|
545 | 545 | |
546 | 546 | // Prepare the invoice. |
547 | - $invoice = wpinv_get_invoice( $invoice ); |
|
548 | - if ( empty( $invoice ) ) { |
|
547 | + $invoice = wpinv_get_invoice($invoice); |
|
548 | + if (empty($invoice)) { |
|
549 | 549 | return NULL; |
550 | 550 | } |
551 | 551 | |
552 | 552 | // Fetch notes. |
553 | - $notes = getpaid_notes()->get_invoice_notes( $invoice->get_id(), $type ); |
|
553 | + $notes = getpaid_notes()->get_invoice_notes($invoice->get_id(), $type); |
|
554 | 554 | |
555 | 555 | // Filter the notes. |
556 | - return apply_filters( 'wpinv_invoice_notes', $notes, $invoice->get_id(), $type ); |
|
556 | + return apply_filters('wpinv_invoice_notes', $notes, $invoice->get_id(), $type); |
|
557 | 557 | } |
558 | 558 | |
559 | 559 | /** |
@@ -561,10 +561,10 @@ discard block |
||
561 | 561 | * |
562 | 562 | * @param string $post_type |
563 | 563 | */ |
564 | -function wpinv_get_user_invoices_columns( $post_type = 'wpi_invoice' ) { |
|
564 | +function wpinv_get_user_invoices_columns($post_type = 'wpi_invoice') { |
|
565 | 565 | |
566 | - $label = getpaid_get_post_type_label( $post_type, false ); |
|
567 | - $label = empty( $label ) ? __( 'Invoice', 'invoicing' ) : sanitize_text_field( $label ); |
|
566 | + $label = getpaid_get_post_type_label($post_type, false); |
|
567 | + $label = empty($label) ? __('Invoice', 'invoicing') : sanitize_text_field($label); |
|
568 | 568 | $columns = array( |
569 | 569 | |
570 | 570 | 'invoice-number' => array( |
@@ -573,22 +573,22 @@ discard block |
||
573 | 573 | ), |
574 | 574 | |
575 | 575 | 'created-date' => array( |
576 | - 'title' => __( 'Created Date', 'invoicing' ), |
|
576 | + 'title' => __('Created Date', 'invoicing'), |
|
577 | 577 | 'class' => 'text-left' |
578 | 578 | ), |
579 | 579 | |
580 | 580 | 'payment-date' => array( |
581 | - 'title' => __( 'Payment Date', 'invoicing' ), |
|
581 | + 'title' => __('Payment Date', 'invoicing'), |
|
582 | 582 | 'class' => 'text-left' |
583 | 583 | ), |
584 | 584 | |
585 | 585 | 'invoice-status' => array( |
586 | - 'title' => __( 'Status', 'invoicing' ), |
|
586 | + 'title' => __('Status', 'invoicing'), |
|
587 | 587 | 'class' => 'text-center' |
588 | 588 | ), |
589 | 589 | |
590 | 590 | 'invoice-total' => array( |
591 | - 'title' => __( 'Total', 'invoicing' ), |
|
591 | + 'title' => __('Total', 'invoicing'), |
|
592 | 592 | 'class' => 'text-right' |
593 | 593 | ), |
594 | 594 | |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | |
600 | 600 | ); |
601 | 601 | |
602 | - return apply_filters( 'wpinv_user_invoices_columns', $columns, $post_type ); |
|
602 | + return apply_filters('wpinv_user_invoices_columns', $columns, $post_type); |
|
603 | 603 | } |
604 | 604 | |
605 | 605 | /** |
@@ -609,59 +609,59 @@ discard block |
||
609 | 609 | |
610 | 610 | // Find the invoice. |
611 | 611 | $invoice_id = getpaid_get_current_invoice_id(); |
612 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
612 | + $invoice = new WPInv_Invoice($invoice_id); |
|
613 | 613 | |
614 | 614 | // Abort if non was found. |
615 | - if ( empty( $invoice_id ) || $invoice->is_draft() ) { |
|
615 | + if (empty($invoice_id) || $invoice->is_draft()) { |
|
616 | 616 | |
617 | 617 | return aui()->alert( |
618 | 618 | array( |
619 | 619 | 'type' => 'warning', |
620 | - 'content' => __( 'We could not find your invoice', 'invoicing' ), |
|
620 | + 'content' => __('We could not find your invoice', 'invoicing'), |
|
621 | 621 | ) |
622 | 622 | ); |
623 | 623 | |
624 | 624 | } |
625 | 625 | |
626 | 626 | // Can the user view this invoice? |
627 | - if ( ! wpinv_can_view_receipt( $invoice_id ) ) { |
|
627 | + if (!wpinv_can_view_receipt($invoice_id)) { |
|
628 | 628 | |
629 | 629 | return aui()->alert( |
630 | 630 | array( |
631 | 631 | 'type' => 'warning', |
632 | - 'content' => __( 'You are not allowed to view this receipt', 'invoicing' ), |
|
632 | + 'content' => __('You are not allowed to view this receipt', 'invoicing'), |
|
633 | 633 | ) |
634 | 634 | ); |
635 | 635 | |
636 | 636 | } |
637 | 637 | |
638 | 638 | // Load the template. |
639 | - return wpinv_get_template_html( 'invoice-receipt.php', compact( 'invoice' ) ); |
|
639 | + return wpinv_get_template_html('invoice-receipt.php', compact('invoice')); |
|
640 | 640 | |
641 | 641 | } |
642 | 642 | |
643 | 643 | /** |
644 | 644 | * Displays the invoice history. |
645 | 645 | */ |
646 | -function getpaid_invoice_history( $user_id = 0, $post_type = 'wpi_invoice' ) { |
|
646 | +function getpaid_invoice_history($user_id = 0, $post_type = 'wpi_invoice') { |
|
647 | 647 | |
648 | 648 | // Ensure that we have a user id. |
649 | - if ( empty( $user_id ) || ! is_numeric( $user_id ) ) { |
|
649 | + if (empty($user_id) || !is_numeric($user_id)) { |
|
650 | 650 | $user_id = get_current_user_id(); |
651 | 651 | } |
652 | 652 | |
653 | - $label = getpaid_get_post_type_label( $post_type ); |
|
654 | - $label = empty( $label ) ? __( 'Invoices', 'invoicing' ) : sanitize_text_field( $label ); |
|
653 | + $label = getpaid_get_post_type_label($post_type); |
|
654 | + $label = empty($label) ? __('Invoices', 'invoicing') : sanitize_text_field($label); |
|
655 | 655 | |
656 | 656 | // View user id. |
657 | - if ( empty( $user_id ) ) { |
|
657 | + if (empty($user_id)) { |
|
658 | 658 | |
659 | 659 | return aui()->alert( |
660 | 660 | array( |
661 | 661 | 'type' => 'warning', |
662 | 662 | 'content' => sprintf( |
663 | - __( 'You must be logged in to view your %s.', 'invoicing' ), |
|
664 | - strtolower( $label ) |
|
663 | + __('You must be logged in to view your %s.', 'invoicing'), |
|
664 | + strtolower($label) |
|
665 | 665 | ) |
666 | 666 | ) |
667 | 667 | ); |
@@ -672,23 +672,23 @@ discard block |
||
672 | 672 | $invoices = wpinv_get_invoices( |
673 | 673 | |
674 | 674 | array( |
675 | - 'page' => ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1, |
|
675 | + 'page' => (get_query_var('paged')) ? absint(get_query_var('paged')) : 1, |
|
676 | 676 | 'user' => $user_id, |
677 | 677 | 'paginate' => true, |
678 | 678 | 'type' => $post_type, |
679 | - 'status' => array_keys( wpinv_get_invoice_statuses( false, false, $post_type ) ), |
|
679 | + 'status' => array_keys(wpinv_get_invoice_statuses(false, false, $post_type)), |
|
680 | 680 | ) |
681 | 681 | |
682 | 682 | ); |
683 | 683 | |
684 | - if ( empty( $invoices->total ) ) { |
|
684 | + if (empty($invoices->total)) { |
|
685 | 685 | |
686 | 686 | return aui()->alert( |
687 | 687 | array( |
688 | 688 | 'type' => 'info', |
689 | 689 | 'content' => sprintf( |
690 | - __( 'No %s found.', 'invoicing' ), |
|
691 | - strtolower( $label ) |
|
690 | + __('No %s found.', 'invoicing'), |
|
691 | + strtolower($label) |
|
692 | 692 | ) |
693 | 693 | ) |
694 | 694 | ); |
@@ -696,38 +696,38 @@ discard block |
||
696 | 696 | } |
697 | 697 | |
698 | 698 | // Load the template. |
699 | - return wpinv_get_template_html( 'invoice-history.php', compact( 'invoices', 'post_type' ) ); |
|
699 | + return wpinv_get_template_html('invoice-history.php', compact('invoices', 'post_type')); |
|
700 | 700 | |
701 | 701 | } |
702 | 702 | |
703 | 703 | /** |
704 | 704 | * Formats an invoice number given an invoice type. |
705 | 705 | */ |
706 | -function wpinv_format_invoice_number( $number, $type = '' ) { |
|
706 | +function wpinv_format_invoice_number($number, $type = '') { |
|
707 | 707 | |
708 | 708 | // Allow other plugins to overide this. |
709 | - $check = apply_filters( 'wpinv_pre_format_invoice_number', null, $number, $type ); |
|
710 | - if ( null !== $check ) { |
|
709 | + $check = apply_filters('wpinv_pre_format_invoice_number', null, $number, $type); |
|
710 | + if (null !== $check) { |
|
711 | 711 | return $check; |
712 | 712 | } |
713 | 713 | |
714 | 714 | // Ensure that we have a numeric number. |
715 | - if ( ! is_numeric( $number ) ) { |
|
715 | + if (!is_numeric($number)) { |
|
716 | 716 | return $number; |
717 | 717 | } |
718 | 718 | |
719 | 719 | // Format the number. |
720 | - $padd = absint( (int) wpinv_get_option( 'invoice_number_padd', 5 ) ); |
|
721 | - $prefix = sanitize_text_field( (string) wpinv_get_option( 'invoice_number_prefix', 'INV-' ) ); |
|
722 | - $prefix = sanitize_text_field( apply_filters( 'getpaid_invoice_type_prefix', $prefix, $type ) ); |
|
723 | - $postfix = sanitize_text_field( (string) wpinv_get_option( 'invoice_number_postfix' ) ); |
|
724 | - $postfix = sanitize_text_field( apply_filters( 'getpaid_invoice_type_postfix', $postfix, $type ) ); |
|
725 | - $formatted_number = zeroise( absint( $number ), $padd ); |
|
720 | + $padd = absint((int) wpinv_get_option('invoice_number_padd', 5)); |
|
721 | + $prefix = sanitize_text_field((string) wpinv_get_option('invoice_number_prefix', 'INV-')); |
|
722 | + $prefix = sanitize_text_field(apply_filters('getpaid_invoice_type_prefix', $prefix, $type)); |
|
723 | + $postfix = sanitize_text_field((string) wpinv_get_option('invoice_number_postfix')); |
|
724 | + $postfix = sanitize_text_field(apply_filters('getpaid_invoice_type_postfix', $postfix, $type)); |
|
725 | + $formatted_number = zeroise(absint($number), $padd); |
|
726 | 726 | |
727 | 727 | // Add the prefix and post fix. |
728 | 728 | $formatted_number = $prefix . $formatted_number . $postfix; |
729 | 729 | |
730 | - return apply_filters( 'wpinv_format_invoice_number', $formatted_number, $number, $prefix, $postfix, $padd ); |
|
730 | + return apply_filters('wpinv_format_invoice_number', $formatted_number, $number, $prefix, $postfix, $padd); |
|
731 | 731 | } |
732 | 732 | |
733 | 733 | /** |
@@ -736,58 +736,58 @@ discard block |
||
736 | 736 | * @param string $type. |
737 | 737 | * @return int|null|bool |
738 | 738 | */ |
739 | -function wpinv_get_next_invoice_number( $type = '' ) { |
|
739 | +function wpinv_get_next_invoice_number($type = '') { |
|
740 | 740 | |
741 | 741 | // Allow plugins to overide this. |
742 | - $check = apply_filters( 'wpinv_get_pre_next_invoice_number', null, $type ); |
|
743 | - if ( null !== $check ) { |
|
742 | + $check = apply_filters('wpinv_get_pre_next_invoice_number', null, $type); |
|
743 | + if (null !== $check) { |
|
744 | 744 | return $check; |
745 | 745 | } |
746 | 746 | |
747 | 747 | // Ensure sequential invoice numbers is active. |
748 | - if ( ! wpinv_sequential_number_active() ) { |
|
748 | + if (!wpinv_sequential_number_active()) { |
|
749 | 749 | return false; |
750 | 750 | } |
751 | 751 | |
752 | 752 | // Retrieve the current number and the start number. |
753 | - $number = (int) get_option( 'wpinv_last_invoice_number', 0 ); |
|
754 | - $start = absint( (int) wpinv_get_option( 'invoice_sequence_start', 1 ) ); |
|
753 | + $number = (int) get_option('wpinv_last_invoice_number', 0); |
|
754 | + $start = absint((int) wpinv_get_option('invoice_sequence_start', 1)); |
|
755 | 755 | |
756 | 756 | // Ensure that we are starting at a positive integer. |
757 | - $start = max( $start, 1 ); |
|
757 | + $start = max($start, 1); |
|
758 | 758 | |
759 | 759 | // If this is the first invoice, use the start number. |
760 | - $number = max( $start, $number ); |
|
760 | + $number = max($start, $number); |
|
761 | 761 | |
762 | 762 | // Format the invoice number. |
763 | - $formatted_number = wpinv_format_invoice_number( $number, $type ); |
|
763 | + $formatted_number = wpinv_format_invoice_number($number, $type); |
|
764 | 764 | |
765 | 765 | // Ensure that this number is unique. |
766 | - $invoice_id = WPInv_Invoice::get_invoice_id_by_field( $formatted_number, 'number' ); |
|
766 | + $invoice_id = WPInv_Invoice::get_invoice_id_by_field($formatted_number, 'number'); |
|
767 | 767 | |
768 | 768 | // We found a match. Nice. |
769 | - if ( empty( $invoice_id ) ) { |
|
770 | - update_option( 'wpinv_last_invoice_number', $number ); |
|
771 | - return apply_filters( 'wpinv_get_next_invoice_number', $number ); |
|
769 | + if (empty($invoice_id)) { |
|
770 | + update_option('wpinv_last_invoice_number', $number); |
|
771 | + return apply_filters('wpinv_get_next_invoice_number', $number); |
|
772 | 772 | } |
773 | 773 | |
774 | - update_option( 'wpinv_last_invoice_number', $number + 1 ); |
|
775 | - return wpinv_get_next_invoice_number( $type ); |
|
774 | + update_option('wpinv_last_invoice_number', $number + 1); |
|
775 | + return wpinv_get_next_invoice_number($type); |
|
776 | 776 | |
777 | 777 | } |
778 | 778 | |
779 | 779 | /** |
780 | 780 | * The prefix used for invoice paths. |
781 | 781 | */ |
782 | -function wpinv_post_name_prefix( $post_type = 'wpi_invoice' ) { |
|
783 | - return apply_filters( 'wpinv_post_name_prefix', 'inv-', $post_type ); |
|
782 | +function wpinv_post_name_prefix($post_type = 'wpi_invoice') { |
|
783 | + return apply_filters('wpinv_post_name_prefix', 'inv-', $post_type); |
|
784 | 784 | } |
785 | 785 | |
786 | -function wpinv_generate_post_name( $post_ID ) { |
|
787 | - $prefix = wpinv_post_name_prefix( get_post_type( $post_ID ) ); |
|
788 | - $post_name = sanitize_title( $prefix . $post_ID ); |
|
786 | +function wpinv_generate_post_name($post_ID) { |
|
787 | + $prefix = wpinv_post_name_prefix(get_post_type($post_ID)); |
|
788 | + $post_name = sanitize_title($prefix . $post_ID); |
|
789 | 789 | |
790 | - return apply_filters( 'wpinv_generate_post_name', $post_name, $post_ID, $prefix ); |
|
790 | + return apply_filters('wpinv_generate_post_name', $post_name, $post_ID, $prefix); |
|
791 | 791 | } |
792 | 792 | |
793 | 793 | /** |
@@ -795,8 +795,8 @@ discard block |
||
795 | 795 | * |
796 | 796 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object. |
797 | 797 | */ |
798 | -function wpinv_is_invoice_viewed( $invoice ) { |
|
799 | - $invoice = new WPInv_Invoice( $invoice ); |
|
798 | +function wpinv_is_invoice_viewed($invoice) { |
|
799 | + $invoice = new WPInv_Invoice($invoice); |
|
800 | 800 | return (bool) $invoice->get_is_viewed(); |
801 | 801 | } |
802 | 802 | |
@@ -805,17 +805,17 @@ discard block |
||
805 | 805 | * |
806 | 806 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object. |
807 | 807 | */ |
808 | -function getpaid_maybe_mark_invoice_as_viewed( $invoice ) { |
|
809 | - $invoice = new WPInv_Invoice( $invoice ); |
|
808 | +function getpaid_maybe_mark_invoice_as_viewed($invoice) { |
|
809 | + $invoice = new WPInv_Invoice($invoice); |
|
810 | 810 | |
811 | - if ( get_current_user_id() == $invoice->get_user_id() && ! $invoice->get_is_viewed() ) { |
|
812 | - $invoice->set_is_viewed( true ); |
|
811 | + if (get_current_user_id() == $invoice->get_user_id() && !$invoice->get_is_viewed()) { |
|
812 | + $invoice->set_is_viewed(true); |
|
813 | 813 | $invoice->save(); |
814 | 814 | } |
815 | 815 | |
816 | 816 | } |
817 | -add_action( 'wpinv_invoice_print_before_display', 'getpaid_maybe_mark_invoice_as_viewed' ); |
|
818 | -add_action( 'wpinv_before_receipt', 'getpaid_maybe_mark_invoice_as_viewed' ); |
|
817 | +add_action('wpinv_invoice_print_before_display', 'getpaid_maybe_mark_invoice_as_viewed'); |
|
818 | +add_action('wpinv_before_receipt', 'getpaid_maybe_mark_invoice_as_viewed'); |
|
819 | 819 | |
820 | 820 | /** |
821 | 821 | * Processes an invoice refund. |
@@ -824,27 +824,27 @@ discard block |
||
824 | 824 | * @param array $status_transition |
825 | 825 | * @todo: descrease customer/store earnings |
826 | 826 | */ |
827 | -function getpaid_maybe_process_refund( $invoice, $status_transition ) { |
|
827 | +function getpaid_maybe_process_refund($invoice, $status_transition) { |
|
828 | 828 | |
829 | - if ( empty( $status_transition['from'] ) || ! in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ) ) ) { |
|
829 | + if (empty($status_transition['from']) || !in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'))) { |
|
830 | 830 | return; |
831 | 831 | } |
832 | 832 | |
833 | 833 | $discount_code = $invoice->get_discount_code(); |
834 | - if ( ! empty( $discount_code ) ) { |
|
835 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
834 | + if (!empty($discount_code)) { |
|
835 | + $discount = wpinv_get_discount_obj($discount_code); |
|
836 | 836 | |
837 | - if ( $discount->exists() ) { |
|
837 | + if ($discount->exists()) { |
|
838 | 838 | $discount->increase_usage( -1 ); |
839 | 839 | } |
840 | 840 | |
841 | 841 | } |
842 | 842 | |
843 | - do_action( 'wpinv_pre_refund_invoice', $invoice, $invoice->get_id() ); |
|
844 | - do_action( 'wpinv_refund_invoice', $invoice, $invoice->get_id() ); |
|
845 | - do_action( 'wpinv_post_refund_invoice', $invoice, $invoice->get_id() ); |
|
843 | + do_action('wpinv_pre_refund_invoice', $invoice, $invoice->get_id()); |
|
844 | + do_action('wpinv_refund_invoice', $invoice, $invoice->get_id()); |
|
845 | + do_action('wpinv_post_refund_invoice', $invoice, $invoice->get_id()); |
|
846 | 846 | } |
847 | -add_action( 'getpaid_invoice_status_wpi-refunded', 'getpaid_maybe_process_refund', 10, 2 ); |
|
847 | +add_action('getpaid_invoice_status_wpi-refunded', 'getpaid_maybe_process_refund', 10, 2); |
|
848 | 848 | |
849 | 849 | |
850 | 850 | /** |
@@ -852,49 +852,49 @@ discard block |
||
852 | 852 | * |
853 | 853 | * @param int $invoice_id |
854 | 854 | */ |
855 | -function getpaid_process_invoice_payment( $invoice_id ) { |
|
855 | +function getpaid_process_invoice_payment($invoice_id) { |
|
856 | 856 | |
857 | 857 | // Fetch the invoice. |
858 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
858 | + $invoice = new WPInv_Invoice($invoice_id); |
|
859 | 859 | |
860 | 860 | // We only want to do this once. |
861 | - if ( 1 == get_post_meta( $invoice->get_id(), 'wpinv_processed_payment', true ) ) { |
|
861 | + if (1 == get_post_meta($invoice->get_id(), 'wpinv_processed_payment', true)) { |
|
862 | 862 | return; |
863 | 863 | } |
864 | 864 | |
865 | - update_post_meta( $invoice->get_id(), 'wpinv_processed_payment', 1 ); |
|
865 | + update_post_meta($invoice->get_id(), 'wpinv_processed_payment', 1); |
|
866 | 866 | |
867 | 867 | // Fires when processing a payment. |
868 | - do_action( 'getpaid_process_payment', $invoice ); |
|
868 | + do_action('getpaid_process_payment', $invoice); |
|
869 | 869 | |
870 | 870 | // Fire an action for each invoice item. |
871 | - foreach( $invoice->get_items() as $item ) { |
|
872 | - do_action( 'getpaid_process_item_payment', $item, $invoice ); |
|
871 | + foreach ($invoice->get_items() as $item) { |
|
872 | + do_action('getpaid_process_item_payment', $item, $invoice); |
|
873 | 873 | } |
874 | 874 | |
875 | 875 | // Increase discount usage. |
876 | 876 | $discount_code = $invoice->get_discount_code(); |
877 | - if ( ! empty( $discount_code ) && ! $invoice->is_renewal() ) { |
|
878 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
877 | + if (!empty($discount_code) && !$invoice->is_renewal()) { |
|
878 | + $discount = wpinv_get_discount_obj($discount_code); |
|
879 | 879 | |
880 | - if ( $discount->exists() ) { |
|
880 | + if ($discount->exists()) { |
|
881 | 881 | $discount->increase_usage(); |
882 | 882 | } |
883 | 883 | |
884 | 884 | } |
885 | 885 | |
886 | 886 | // Record reverse vat. |
887 | - if ( 'invoice' == $invoice->get_type() && wpinv_use_taxes() && ! $invoice->get_disable_taxes() ) { |
|
887 | + if ('invoice' == $invoice->get_type() && wpinv_use_taxes() && !$invoice->get_disable_taxes()) { |
|
888 | 888 | |
889 | 889 | $taxes = $invoice->get_total_tax(); |
890 | - if ( empty( $taxes ) && GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $invoice->get_country() ) ) { |
|
891 | - $invoice->add_note( __( 'VAT was reverse charged', 'invoicing' ), false, false, true ); |
|
890 | + if (empty($taxes) && GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction($invoice->get_country())) { |
|
891 | + $invoice->add_note(__('VAT was reverse charged', 'invoicing'), false, false, true); |
|
892 | 892 | } |
893 | 893 | |
894 | 894 | } |
895 | 895 | |
896 | 896 | } |
897 | -add_action( 'getpaid_invoice_payment_status_changed', 'getpaid_process_invoice_payment' ); |
|
897 | +add_action('getpaid_invoice_payment_status_changed', 'getpaid_process_invoice_payment'); |
|
898 | 898 | |
899 | 899 | /** |
900 | 900 | * Returns an array of invoice item columns |
@@ -902,13 +902,13 @@ discard block |
||
902 | 902 | * @param int|WPInv_Invoice $invoice |
903 | 903 | * @return array |
904 | 904 | */ |
905 | -function getpaid_invoice_item_columns( $invoice ) { |
|
905 | +function getpaid_invoice_item_columns($invoice) { |
|
906 | 906 | |
907 | 907 | // Prepare the invoice. |
908 | - $invoice = new WPInv_Invoice( $invoice ); |
|
908 | + $invoice = new WPInv_Invoice($invoice); |
|
909 | 909 | |
910 | 910 | // Abort if there is no invoice. |
911 | - if ( 0 == $invoice->get_id() ) { |
|
911 | + if (0 == $invoice->get_id()) { |
|
912 | 912 | return array(); |
913 | 913 | } |
914 | 914 | |
@@ -916,47 +916,47 @@ discard block |
||
916 | 916 | $columns = apply_filters( |
917 | 917 | 'getpaid_invoice_item_columns', |
918 | 918 | array( |
919 | - 'name' => __( 'Item', 'invoicing' ), |
|
920 | - 'price' => __( 'Price', 'invoicing' ), |
|
921 | - 'quantity' => __( 'Quantity', 'invoicing' ), |
|
922 | - 'subtotal' => __( 'Item Subtotal', 'invoicing' ), |
|
919 | + 'name' => __('Item', 'invoicing'), |
|
920 | + 'price' => __('Price', 'invoicing'), |
|
921 | + 'quantity' => __('Quantity', 'invoicing'), |
|
922 | + 'subtotal' => __('Item Subtotal', 'invoicing'), |
|
923 | 923 | ), |
924 | 924 | $invoice |
925 | 925 | ); |
926 | 926 | |
927 | 927 | // Quantities. |
928 | - if ( isset( $columns[ 'quantity' ] ) ) { |
|
928 | + if (isset($columns['quantity'])) { |
|
929 | 929 | |
930 | - if ( 'hours' == $invoice->get_template() ) { |
|
931 | - $columns[ 'quantity' ] = __( 'Hours', 'invoicing' ); |
|
930 | + if ('hours' == $invoice->get_template()) { |
|
931 | + $columns['quantity'] = __('Hours', 'invoicing'); |
|
932 | 932 | } |
933 | 933 | |
934 | - if ( ! wpinv_item_quantities_enabled() || 'amount' == $invoice->get_template() ) { |
|
935 | - unset( $columns[ 'quantity' ] ); |
|
934 | + if (!wpinv_item_quantities_enabled() || 'amount' == $invoice->get_template()) { |
|
935 | + unset($columns['quantity']); |
|
936 | 936 | } |
937 | 937 | |
938 | 938 | } |
939 | 939 | |
940 | 940 | |
941 | 941 | // Price. |
942 | - if ( isset( $columns[ 'price' ] ) ) { |
|
942 | + if (isset($columns['price'])) { |
|
943 | 943 | |
944 | - if ( 'amount' == $invoice->get_template() ) { |
|
945 | - $columns[ 'price' ] = __( 'Amount', 'invoicing' ); |
|
944 | + if ('amount' == $invoice->get_template()) { |
|
945 | + $columns['price'] = __('Amount', 'invoicing'); |
|
946 | 946 | } |
947 | 947 | |
948 | - if ( 'hours' == $invoice->get_template() ) { |
|
949 | - $columns[ 'price' ] = __( 'Rate', 'invoicing' ); |
|
948 | + if ('hours' == $invoice->get_template()) { |
|
949 | + $columns['price'] = __('Rate', 'invoicing'); |
|
950 | 950 | } |
951 | 951 | |
952 | 952 | } |
953 | 953 | |
954 | 954 | |
955 | 955 | // Sub total. |
956 | - if ( isset( $columns[ 'subtotal' ] ) ) { |
|
956 | + if (isset($columns['subtotal'])) { |
|
957 | 957 | |
958 | - if ( 'amount' == $invoice->get_template() ) { |
|
959 | - unset( $columns[ 'subtotal' ] ); |
|
958 | + if ('amount' == $invoice->get_template()) { |
|
959 | + unset($columns['subtotal']); |
|
960 | 960 | } |
961 | 961 | |
962 | 962 | } |
@@ -970,38 +970,38 @@ discard block |
||
970 | 970 | * @param int|WPInv_Invoice $invoice |
971 | 971 | * @return array |
972 | 972 | */ |
973 | -function getpaid_invoice_totals_rows( $invoice ) { |
|
973 | +function getpaid_invoice_totals_rows($invoice) { |
|
974 | 974 | |
975 | 975 | // Prepare the invoice. |
976 | - $invoice = new WPInv_Invoice( $invoice ); |
|
976 | + $invoice = new WPInv_Invoice($invoice); |
|
977 | 977 | |
978 | 978 | // Abort if there is no invoice. |
979 | - if ( 0 == $invoice->get_id() ) { |
|
979 | + if (0 == $invoice->get_id()) { |
|
980 | 980 | return array(); |
981 | 981 | } |
982 | 982 | |
983 | 983 | $totals = apply_filters( |
984 | 984 | 'getpaid_invoice_totals_rows', |
985 | 985 | array( |
986 | - 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
987 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
988 | - 'fee' => __( 'Fee', 'invoicing' ), |
|
989 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
990 | - 'total' => __( 'Total', 'invoicing' ), |
|
986 | + 'subtotal' => __('Subtotal', 'invoicing'), |
|
987 | + 'tax' => __('Tax', 'invoicing'), |
|
988 | + 'fee' => __('Fee', 'invoicing'), |
|
989 | + 'discount' => __('Discount', 'invoicing'), |
|
990 | + 'total' => __('Total', 'invoicing'), |
|
991 | 991 | ), |
992 | 992 | $invoice |
993 | 993 | ); |
994 | 994 | |
995 | - if ( ( $invoice->get_disable_taxes() || ! wpinv_use_taxes() ) && isset( $totals['tax'] ) ) { |
|
996 | - unset( $totals['tax'] ); |
|
995 | + if (($invoice->get_disable_taxes() || !wpinv_use_taxes()) && isset($totals['tax'])) { |
|
996 | + unset($totals['tax']); |
|
997 | 997 | } |
998 | 998 | |
999 | - if ( 0 == $invoice->get_total_fees() && isset( $totals['fee'] ) ) { |
|
1000 | - unset( $totals['fee'] ); |
|
999 | + if (0 == $invoice->get_total_fees() && isset($totals['fee'])) { |
|
1000 | + unset($totals['fee']); |
|
1001 | 1001 | } |
1002 | 1002 | |
1003 | - if ( 0 == $invoice->get_total_discount() && isset( $totals['discount'] ) ) { |
|
1004 | - unset( $totals['discount'] ); |
|
1003 | + if (0 == $invoice->get_total_discount() && isset($totals['discount'])) { |
|
1004 | + unset($totals['discount']); |
|
1005 | 1005 | } |
1006 | 1006 | |
1007 | 1007 | return $totals; |
@@ -1012,47 +1012,47 @@ discard block |
||
1012 | 1012 | * |
1013 | 1013 | * @param WPInv_Invoice $invoice |
1014 | 1014 | */ |
1015 | -function getpaid_new_invoice( $invoice ) { |
|
1015 | +function getpaid_new_invoice($invoice) { |
|
1016 | 1016 | |
1017 | - if ( ! $invoice->get_status() ) { |
|
1017 | + if (!$invoice->get_status()) { |
|
1018 | 1018 | return; |
1019 | 1019 | } |
1020 | 1020 | |
1021 | 1021 | // Add an invoice created note. |
1022 | 1022 | $invoice->add_note( |
1023 | 1023 | sprintf( |
1024 | - __( '%s created with the status "%s".', 'invoicing' ), |
|
1025 | - ucfirst( $invoice->get_invoice_quote_type() ), |
|
1026 | - wpinv_status_nicename( $invoice->get_status(), $invoice ) |
|
1024 | + __('%s created with the status "%s".', 'invoicing'), |
|
1025 | + ucfirst($invoice->get_invoice_quote_type()), |
|
1026 | + wpinv_status_nicename($invoice->get_status(), $invoice) |
|
1027 | 1027 | ) |
1028 | 1028 | ); |
1029 | 1029 | |
1030 | 1030 | } |
1031 | -add_action( 'getpaid_new_invoice', 'getpaid_new_invoice' ); |
|
1031 | +add_action('getpaid_new_invoice', 'getpaid_new_invoice'); |
|
1032 | 1032 | |
1033 | 1033 | /** |
1034 | 1034 | * This function updates invoice caches. |
1035 | 1035 | * |
1036 | 1036 | * @param WPInv_Invoice $invoice |
1037 | 1037 | */ |
1038 | -function getpaid_update_invoice_caches( $invoice ) { |
|
1038 | +function getpaid_update_invoice_caches($invoice) { |
|
1039 | 1039 | |
1040 | 1040 | // Cache invoice number. |
1041 | - wp_cache_set( $invoice->get_number(), $invoice->get_id(), "getpaid_invoice_numbers_to_invoice_ids" ); |
|
1041 | + wp_cache_set($invoice->get_number(), $invoice->get_id(), "getpaid_invoice_numbers_to_invoice_ids"); |
|
1042 | 1042 | |
1043 | 1043 | // Cache invoice key. |
1044 | - wp_cache_set( $invoice->get_key(), $invoice->get_id(), "getpaid_invoice_keys_to_invoice_ids" ); |
|
1044 | + wp_cache_set($invoice->get_key(), $invoice->get_id(), "getpaid_invoice_keys_to_invoice_ids"); |
|
1045 | 1045 | |
1046 | 1046 | // (Maybe) cache transaction id. |
1047 | 1047 | $transaction_id = $invoice->get_transaction_id(); |
1048 | 1048 | |
1049 | - if ( ! empty( $transaction_id ) ) { |
|
1050 | - wp_cache_set( $transaction_id, $invoice->get_id(), "getpaid_invoice_transaction_ids_to_invoice_ids" ); |
|
1049 | + if (!empty($transaction_id)) { |
|
1050 | + wp_cache_set($transaction_id, $invoice->get_id(), "getpaid_invoice_transaction_ids_to_invoice_ids"); |
|
1051 | 1051 | } |
1052 | 1052 | |
1053 | 1053 | } |
1054 | -add_action( 'getpaid_new_invoice', 'getpaid_update_invoice_caches', 5 ); |
|
1055 | -add_action( 'getpaid_update_invoice', 'getpaid_update_invoice_caches', 5 ); |
|
1054 | +add_action('getpaid_new_invoice', 'getpaid_update_invoice_caches', 5); |
|
1055 | +add_action('getpaid_update_invoice', 'getpaid_update_invoice_caches', 5); |
|
1056 | 1056 | |
1057 | 1057 | /** |
1058 | 1058 | * Duplicates an invoice. |
@@ -1062,7 +1062,7 @@ discard block |
||
1062 | 1062 | * @param WPInv_Invoice $old_invoice The invoice to duplicate |
1063 | 1063 | * @return WPInv_Invoice The new invoice. |
1064 | 1064 | */ |
1065 | -function getpaid_duplicate_invoice( $old_invoice ) { |
|
1065 | +function getpaid_duplicate_invoice($old_invoice) { |
|
1066 | 1066 | |
1067 | 1067 | // Create the new invoice. |
1068 | 1068 | $invoice = new WPInv_Invoice(); |
@@ -1123,123 +1123,123 @@ discard block |
||
1123 | 1123 | * @param WPInv_Invoice $invoice |
1124 | 1124 | * @return array |
1125 | 1125 | */ |
1126 | -function getpaid_get_invoice_meta( $invoice ) { |
|
1126 | +function getpaid_get_invoice_meta($invoice) { |
|
1127 | 1127 | |
1128 | 1128 | // Load the invoice meta. |
1129 | 1129 | $meta = array( |
1130 | 1130 | |
1131 | 1131 | 'number' => array( |
1132 | 1132 | 'label' => sprintf( |
1133 | - __( '%s Number', 'invoicing' ), |
|
1134 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
1133 | + __('%s Number', 'invoicing'), |
|
1134 | + ucfirst($invoice->get_invoice_quote_type()) |
|
1135 | 1135 | ), |
1136 | - 'value' => sanitize_text_field( $invoice->get_number() ), |
|
1136 | + 'value' => sanitize_text_field($invoice->get_number()), |
|
1137 | 1137 | ), |
1138 | 1138 | |
1139 | 1139 | 'status' => array( |
1140 | 1140 | 'label' => sprintf( |
1141 | - __( '%s Status', 'invoicing' ), |
|
1142 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
1141 | + __('%s Status', 'invoicing'), |
|
1142 | + ucfirst($invoice->get_invoice_quote_type()) |
|
1143 | 1143 | ), |
1144 | 1144 | 'value' => $invoice->get_status_label_html(), |
1145 | 1145 | ), |
1146 | 1146 | |
1147 | 1147 | 'date' => array( |
1148 | 1148 | 'label' => sprintf( |
1149 | - __( '%s Date', 'invoicing' ), |
|
1150 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
1149 | + __('%s Date', 'invoicing'), |
|
1150 | + ucfirst($invoice->get_invoice_quote_type()) |
|
1151 | 1151 | ), |
1152 | - 'value' => getpaid_format_date( $invoice->get_created_date() ), |
|
1152 | + 'value' => getpaid_format_date($invoice->get_created_date()), |
|
1153 | 1153 | ), |
1154 | 1154 | |
1155 | 1155 | 'date_paid' => array( |
1156 | - 'label' => __( 'Paid On', 'invoicing' ), |
|
1157 | - 'value' => getpaid_format_date( $invoice->get_completed_date() ), |
|
1156 | + 'label' => __('Paid On', 'invoicing'), |
|
1157 | + 'value' => getpaid_format_date($invoice->get_completed_date()), |
|
1158 | 1158 | ), |
1159 | 1159 | |
1160 | 1160 | 'gateway' => array( |
1161 | - 'label' => __( 'Payment Method', 'invoicing' ), |
|
1162 | - 'value' => sanitize_text_field( $invoice->get_gateway_title() ), |
|
1161 | + 'label' => __('Payment Method', 'invoicing'), |
|
1162 | + 'value' => sanitize_text_field($invoice->get_gateway_title()), |
|
1163 | 1163 | ), |
1164 | 1164 | |
1165 | 1165 | 'transaction_id' => array( |
1166 | - 'label' => __( 'Transaction ID', 'invoicing' ), |
|
1167 | - 'value' => sanitize_text_field( $invoice->get_transaction_id() ), |
|
1166 | + 'label' => __('Transaction ID', 'invoicing'), |
|
1167 | + 'value' => sanitize_text_field($invoice->get_transaction_id()), |
|
1168 | 1168 | ), |
1169 | 1169 | |
1170 | 1170 | 'due_date' => array( |
1171 | - 'label' => __( 'Due Date', 'invoicing' ), |
|
1172 | - 'value' => getpaid_format_date( $invoice->get_due_date() ), |
|
1171 | + 'label' => __('Due Date', 'invoicing'), |
|
1172 | + 'value' => getpaid_format_date($invoice->get_due_date()), |
|
1173 | 1173 | ), |
1174 | 1174 | |
1175 | 1175 | 'vat_number' => array( |
1176 | - 'label' => __( 'VAT Number', 'invoicing' ), |
|
1177 | - 'value' => sanitize_text_field( $invoice->get_vat_number() ), |
|
1176 | + 'label' => __('VAT Number', 'invoicing'), |
|
1177 | + 'value' => sanitize_text_field($invoice->get_vat_number()), |
|
1178 | 1178 | ), |
1179 | 1179 | |
1180 | 1180 | ); |
1181 | 1181 | |
1182 | 1182 | // If it is not paid, remove the date of payment. |
1183 | - if ( ! $invoice->is_paid() ) { |
|
1184 | - unset( $meta[ 'date_paid' ] ); |
|
1185 | - unset( $meta[ 'transaction_id' ] ); |
|
1183 | + if (!$invoice->is_paid()) { |
|
1184 | + unset($meta['date_paid']); |
|
1185 | + unset($meta['transaction_id']); |
|
1186 | 1186 | } |
1187 | 1187 | |
1188 | - if ( ! $invoice->is_paid() || 'none' == $invoice->get_gateway() ) { |
|
1189 | - unset( $meta[ 'gateway' ] ); |
|
1188 | + if (!$invoice->is_paid() || 'none' == $invoice->get_gateway()) { |
|
1189 | + unset($meta['gateway']); |
|
1190 | 1190 | } |
1191 | 1191 | |
1192 | 1192 | // Only display the due date if due dates are enabled. |
1193 | - if ( ! $invoice->needs_payment() || ! wpinv_get_option( 'overdue_active' ) ) { |
|
1194 | - unset( $meta[ 'due_date' ] ); |
|
1193 | + if (!$invoice->needs_payment() || !wpinv_get_option('overdue_active')) { |
|
1194 | + unset($meta['due_date']); |
|
1195 | 1195 | } |
1196 | 1196 | |
1197 | 1197 | // Only display the vat number if taxes are enabled. |
1198 | - if ( ! wpinv_use_taxes() ) { |
|
1199 | - unset( $meta[ 'vat_number' ] ); |
|
1198 | + if (!wpinv_use_taxes()) { |
|
1199 | + unset($meta['vat_number']); |
|
1200 | 1200 | } |
1201 | 1201 | |
1202 | - if ( $invoice->is_recurring() ) { |
|
1202 | + if ($invoice->is_recurring()) { |
|
1203 | 1203 | |
1204 | 1204 | // Link to the parent invoice. |
1205 | - if ( $invoice->is_renewal() ) { |
|
1205 | + if ($invoice->is_renewal()) { |
|
1206 | 1206 | |
1207 | - $meta[ 'parent' ] = array( |
|
1207 | + $meta['parent'] = array( |
|
1208 | 1208 | |
1209 | 1209 | 'label' => sprintf( |
1210 | - __( 'Parent %s', 'invoicing' ), |
|
1211 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
1210 | + __('Parent %s', 'invoicing'), |
|
1211 | + ucfirst($invoice->get_invoice_quote_type()) |
|
1212 | 1212 | ), |
1213 | 1213 | |
1214 | - 'value' => wpinv_invoice_link( $invoice->get_parent_id() ), |
|
1214 | + 'value' => wpinv_invoice_link($invoice->get_parent_id()), |
|
1215 | 1215 | |
1216 | 1216 | ); |
1217 | 1217 | |
1218 | 1218 | } |
1219 | 1219 | |
1220 | - $subscription = wpinv_get_subscription( $invoice ); |
|
1220 | + $subscription = wpinv_get_subscription($invoice); |
|
1221 | 1221 | |
1222 | - if ( ! empty ( $subscription ) ) { |
|
1222 | + if (!empty ($subscription)) { |
|
1223 | 1223 | |
1224 | 1224 | // Display the renewal date. |
1225 | - if ( $subscription->is_active() && 'cancelled' != $subscription->get_status() ) { |
|
1225 | + if ($subscription->is_active() && 'cancelled' != $subscription->get_status()) { |
|
1226 | 1226 | |
1227 | - $meta[ 'renewal_date' ] = array( |
|
1227 | + $meta['renewal_date'] = array( |
|
1228 | 1228 | |
1229 | - 'label' => __( 'Renews On', 'invoicing' ), |
|
1230 | - 'value' => getpaid_format_date( $subscription->get_expiration() ), |
|
1229 | + 'label' => __('Renews On', 'invoicing'), |
|
1230 | + 'value' => getpaid_format_date($subscription->get_expiration()), |
|
1231 | 1231 | |
1232 | 1232 | ); |
1233 | 1233 | |
1234 | 1234 | } |
1235 | 1235 | |
1236 | - if ( $invoice->is_parent() ) { |
|
1236 | + if ($invoice->is_parent()) { |
|
1237 | 1237 | |
1238 | 1238 | // Display the recurring amount. |
1239 | - $meta[ 'recurring_total' ] = array( |
|
1239 | + $meta['recurring_total'] = array( |
|
1240 | 1240 | |
1241 | - 'label' => __( 'Recurring Amount', 'invoicing' ), |
|
1242 | - 'value' => wpinv_price( $subscription->get_recurring_amount(), $invoice->get_currency() ), |
|
1241 | + 'label' => __('Recurring Amount', 'invoicing'), |
|
1242 | + 'value' => wpinv_price($subscription->get_recurring_amount(), $invoice->get_currency()), |
|
1243 | 1243 | |
1244 | 1244 | ); |
1245 | 1245 | |
@@ -1249,15 +1249,15 @@ discard block |
||
1249 | 1249 | } |
1250 | 1250 | |
1251 | 1251 | // Add the invoice total to the meta. |
1252 | - $meta[ 'invoice_total' ] = array( |
|
1252 | + $meta['invoice_total'] = array( |
|
1253 | 1253 | |
1254 | - 'label' => __( 'Total Amount', 'invoicing' ), |
|
1255 | - 'value' => wpinv_price( $invoice->get_total(), $invoice->get_currency() ), |
|
1254 | + 'label' => __('Total Amount', 'invoicing'), |
|
1255 | + 'value' => wpinv_price($invoice->get_total(), $invoice->get_currency()), |
|
1256 | 1256 | |
1257 | 1257 | ); |
1258 | 1258 | |
1259 | 1259 | // Provide a way for third party plugins to filter the meta. |
1260 | - $meta = apply_filters( 'getpaid_invoice_meta_data', $meta, $invoice ); |
|
1260 | + $meta = apply_filters('getpaid_invoice_meta_data', $meta, $invoice); |
|
1261 | 1261 | |
1262 | 1262 | return $meta; |
1263 | 1263 |
@@ -1,16 +1,16 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( !defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | -add_action( 'manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column' ); |
|
8 | -function wpinv_discount_custom_column( $column ) { |
|
7 | +add_action('manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column'); |
|
8 | +function wpinv_discount_custom_column($column) { |
|
9 | 9 | global $post; |
10 | 10 | |
11 | - $discount = new WPInv_Discount( $post ); |
|
11 | + $discount = new WPInv_Discount($post); |
|
12 | 12 | |
13 | - switch ( $column ) { |
|
13 | + switch ($column) { |
|
14 | 14 | case 'code' : |
15 | 15 | echo $discount->get_code(); |
16 | 16 | break; |
@@ -21,33 +21,33 @@ discard block |
||
21 | 21 | echo $discount->get_usage(); |
22 | 22 | break; |
23 | 23 | case 'start_date' : |
24 | - echo getpaid_format_date_value( $discount->get_start_date() ); |
|
24 | + echo getpaid_format_date_value($discount->get_start_date()); |
|
25 | 25 | break; |
26 | 26 | case 'expiry_date' : |
27 | - echo getpaid_format_date_value( $discount->get_expiration_date(), __( 'Never', 'invoicing' ) ); |
|
27 | + echo getpaid_format_date_value($discount->get_expiration_date(), __('Never', 'invoicing')); |
|
28 | 28 | break; |
29 | 29 | } |
30 | 30 | } |
31 | 31 | |
32 | -add_filter( 'post_row_actions', 'wpinv_post_row_actions', 90, 2 ); |
|
33 | -function wpinv_post_row_actions( $actions, $post ) { |
|
34 | - $post_type = !empty( $post->post_type ) ? $post->post_type : ''; |
|
32 | +add_filter('post_row_actions', 'wpinv_post_row_actions', 90, 2); |
|
33 | +function wpinv_post_row_actions($actions, $post) { |
|
34 | + $post_type = !empty($post->post_type) ? $post->post_type : ''; |
|
35 | 35 | |
36 | - if ( $post_type == 'wpi_discount' ) { |
|
37 | - $actions = wpinv_discount_row_actions( $post, $actions ); |
|
36 | + if ($post_type == 'wpi_discount') { |
|
37 | + $actions = wpinv_discount_row_actions($post, $actions); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | return $actions; |
41 | 41 | } |
42 | 42 | |
43 | -function wpinv_discount_row_actions( $discount, $row_actions ) { |
|
44 | - $row_actions = array(); |
|
45 | - $edit_link = get_edit_post_link( $discount->ID ); |
|
46 | - $row_actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'invoicing' ) . '</a>'; |
|
43 | +function wpinv_discount_row_actions($discount, $row_actions) { |
|
44 | + $row_actions = array(); |
|
45 | + $edit_link = get_edit_post_link($discount->ID); |
|
46 | + $row_actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'invoicing') . '</a>'; |
|
47 | 47 | |
48 | - if ( in_array( strtolower( $discount->post_status ), array( 'publish' ) ) ) { |
|
48 | + if (in_array(strtolower($discount->post_status), array('publish'))) { |
|
49 | 49 | |
50 | - $url = esc_url( |
|
50 | + $url = esc_url( |
|
51 | 51 | wp_nonce_url( |
52 | 52 | add_query_arg( |
53 | 53 | array( |
@@ -59,13 +59,13 @@ discard block |
||
59 | 59 | 'getpaid-nonce' |
60 | 60 | ) |
61 | 61 | ); |
62 | - $anchor = __( 'Deactivate', 'invoicing' ); |
|
63 | - $title = esc_attr__( 'Are you sure you want to deactivate this discount?', 'invoicing' ); |
|
62 | + $anchor = __('Deactivate', 'invoicing'); |
|
63 | + $title = esc_attr__('Are you sure you want to deactivate this discount?', 'invoicing'); |
|
64 | 64 | $row_actions['deactivate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>"; |
65 | 65 | |
66 | - } else if( in_array( strtolower( $discount->post_status ), array( 'pending', 'draft' ) ) ) { |
|
66 | + } else if (in_array(strtolower($discount->post_status), array('pending', 'draft'))) { |
|
67 | 67 | |
68 | - $url = esc_url( |
|
68 | + $url = esc_url( |
|
69 | 69 | wp_nonce_url( |
70 | 70 | add_query_arg( |
71 | 71 | array( |
@@ -77,13 +77,13 @@ discard block |
||
77 | 77 | 'getpaid-nonce' |
78 | 78 | ) |
79 | 79 | ); |
80 | - $anchor = __( 'Activate', 'invoicing' ); |
|
81 | - $title = esc_attr__( 'Are you sure you want to activate this discount?', 'invoicing' ); |
|
80 | + $anchor = __('Activate', 'invoicing'); |
|
81 | + $title = esc_attr__('Are you sure you want to activate this discount?', 'invoicing'); |
|
82 | 82 | $row_actions['activate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>"; |
83 | 83 | |
84 | 84 | } |
85 | 85 | |
86 | - $url = esc_url( |
|
86 | + $url = esc_url( |
|
87 | 87 | wp_nonce_url( |
88 | 88 | add_query_arg( |
89 | 89 | array( |
@@ -95,11 +95,11 @@ discard block |
||
95 | 95 | 'getpaid-nonce' |
96 | 96 | ) |
97 | 97 | ); |
98 | - $anchor = __( 'Delete', 'invoicing' ); |
|
99 | - $title = esc_attr__( 'Are you sure you want to delete this discount?', 'invoicing' ); |
|
98 | + $anchor = __('Delete', 'invoicing'); |
|
99 | + $title = esc_attr__('Are you sure you want to delete this discount?', 'invoicing'); |
|
100 | 100 | $row_actions['delete'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>"; |
101 | 101 | |
102 | - $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount ); |
|
102 | + $row_actions = apply_filters('wpinv_discount_row_actions', $row_actions, $discount); |
|
103 | 103 | |
104 | 104 | return $row_actions; |
105 | 105 | } |
@@ -107,68 +107,68 @@ discard block |
||
107 | 107 | function wpinv_restrict_manage_posts() { |
108 | 108 | global $typenow; |
109 | 109 | |
110 | - if( 'wpi_discount' == $typenow ) { |
|
110 | + if ('wpi_discount' == $typenow) { |
|
111 | 111 | wpinv_discount_filters(); |
112 | 112 | } |
113 | 113 | } |
114 | -add_action( 'restrict_manage_posts', 'wpinv_restrict_manage_posts', 10 ); |
|
114 | +add_action('restrict_manage_posts', 'wpinv_restrict_manage_posts', 10); |
|
115 | 115 | |
116 | 116 | function wpinv_discount_filters() { |
117 | 117 | |
118 | 118 | ?> |
119 | 119 | <select name="discount_type" id="dropdown_wpinv_discount_type"> |
120 | - <option value=""><?php _e( 'Show all types', 'invoicing' ); ?></option> |
|
120 | + <option value=""><?php _e('Show all types', 'invoicing'); ?></option> |
|
121 | 121 | <?php |
122 | 122 | $types = wpinv_get_discount_types(); |
123 | 123 | |
124 | - foreach ( $types as $name => $type ) { |
|
125 | - echo '<option value="' . esc_attr( $name ) . '"'; |
|
124 | + foreach ($types as $name => $type) { |
|
125 | + echo '<option value="' . esc_attr($name) . '"'; |
|
126 | 126 | |
127 | - if ( isset( $_GET['discount_type'] ) ) |
|
128 | - selected( $name, $_GET['discount_type'] ); |
|
127 | + if (isset($_GET['discount_type'])) |
|
128 | + selected($name, $_GET['discount_type']); |
|
129 | 129 | |
130 | - echo '>' . esc_html__( $type, 'invoicing' ) . '</option>'; |
|
130 | + echo '>' . esc_html__($type, 'invoicing') . '</option>'; |
|
131 | 131 | } |
132 | 132 | ?> |
133 | 133 | </select> |
134 | 134 | <?php |
135 | 135 | } |
136 | 136 | |
137 | -function wpinv_request( $vars ) { |
|
137 | +function wpinv_request($vars) { |
|
138 | 138 | global $typenow, $wp_post_statuses; |
139 | 139 | |
140 | - if ( getpaid_is_invoice_post_type( $typenow ) ) { |
|
141 | - if ( ! isset( $vars['post_status'] ) ) { |
|
142 | - $post_statuses = wpinv_get_invoice_statuses( false, false, $typenow ); |
|
140 | + if (getpaid_is_invoice_post_type($typenow)) { |
|
141 | + if (!isset($vars['post_status'])) { |
|
142 | + $post_statuses = wpinv_get_invoice_statuses(false, false, $typenow); |
|
143 | 143 | |
144 | - foreach ( $post_statuses as $status => $value ) { |
|
145 | - if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) { |
|
146 | - unset( $post_statuses[ $status ] ); |
|
144 | + foreach ($post_statuses as $status => $value) { |
|
145 | + if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) { |
|
146 | + unset($post_statuses[$status]); |
|
147 | 147 | } |
148 | 148 | } |
149 | 149 | |
150 | - $vars['post_status'] = array_keys( $post_statuses ); |
|
150 | + $vars['post_status'] = array_keys($post_statuses); |
|
151 | 151 | } |
152 | 152 | |
153 | - } else if ( 'wpi_discount' == $typenow ) { |
|
154 | - $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array(); |
|
153 | + } else if ('wpi_discount' == $typenow) { |
|
154 | + $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array(); |
|
155 | 155 | // Filter vat rule type |
156 | - if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) { |
|
156 | + if (isset($_GET['discount_type']) && $_GET['discount_type'] !== '') { |
|
157 | 157 | $meta_query[] = array( |
158 | 158 | 'key' => '_wpi_discount_type', |
159 | - 'value' => sanitize_text_field( $_GET['discount_type'] ), |
|
159 | + 'value' => sanitize_text_field($_GET['discount_type']), |
|
160 | 160 | 'compare' => '=' |
161 | 161 | ); |
162 | 162 | } |
163 | 163 | |
164 | - if ( !empty( $meta_query ) ) { |
|
164 | + if (!empty($meta_query)) { |
|
165 | 165 | $vars['meta_query'] = $meta_query; |
166 | 166 | } |
167 | 167 | } |
168 | 168 | |
169 | 169 | return $vars; |
170 | 170 | } |
171 | -add_filter( 'request', 'wpinv_request' ); |
|
171 | +add_filter('request', 'wpinv_request'); |
|
172 | 172 | |
173 | 173 | /** |
174 | 174 | * Create a page and store the ID in an option. |
@@ -180,19 +180,19 @@ discard block |
||
180 | 180 | * @param int $post_parent (default: 0) Parent for the new page |
181 | 181 | * @return int page ID |
182 | 182 | */ |
183 | -function wpinv_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) { |
|
183 | +function wpinv_create_page($slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0) { |
|
184 | 184 | global $wpdb; |
185 | 185 | |
186 | - $option_value = wpinv_get_option( $option ); |
|
186 | + $option_value = wpinv_get_option($option); |
|
187 | 187 | |
188 | - if ( ! empty( $option_value ) && ( $page_object = get_post( $option_value ) ) ) { |
|
189 | - if ( 'page' === $page_object->post_type && ! in_array( $page_object->post_status, array( 'pending', 'trash', 'future', 'auto-draft' ) ) ) { |
|
188 | + if (!empty($option_value) && ($page_object = get_post($option_value))) { |
|
189 | + if ('page' === $page_object->post_type && !in_array($page_object->post_status, array('pending', 'trash', 'future', 'auto-draft'))) { |
|
190 | 190 | // Valid page is already in place |
191 | 191 | return $page_object->ID; |
192 | 192 | } |
193 | 193 | } |
194 | 194 | |
195 | - if(!empty($post_parent)){ |
|
195 | + if (!empty($post_parent)) { |
|
196 | 196 | $page = get_page_by_path($post_parent); |
197 | 197 | if ($page) { |
198 | 198 | $post_parent = $page->ID; |
@@ -201,40 +201,40 @@ discard block |
||
201 | 201 | } |
202 | 202 | } |
203 | 203 | |
204 | - if ( strlen( $page_content ) > 0 ) { |
|
204 | + if (strlen($page_content) > 0) { |
|
205 | 205 | // Search for an existing page with the specified page content (typically a shortcode) |
206 | - $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) ); |
|
206 | + $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%")); |
|
207 | 207 | } else { |
208 | 208 | // Search for an existing page with the specified page slug |
209 | - $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_name = %s LIMIT 1;", $slug ) ); |
|
209 | + $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_name = %s LIMIT 1;", $slug)); |
|
210 | 210 | } |
211 | 211 | |
212 | - $valid_page_found = apply_filters( 'wpinv_create_page_id', $valid_page_found, $slug, $page_content ); |
|
212 | + $valid_page_found = apply_filters('wpinv_create_page_id', $valid_page_found, $slug, $page_content); |
|
213 | 213 | |
214 | - if ( $valid_page_found ) { |
|
215 | - if ( $option ) { |
|
216 | - wpinv_update_option( $option, $valid_page_found ); |
|
214 | + if ($valid_page_found) { |
|
215 | + if ($option) { |
|
216 | + wpinv_update_option($option, $valid_page_found); |
|
217 | 217 | } |
218 | 218 | return $valid_page_found; |
219 | 219 | } |
220 | 220 | |
221 | 221 | // Search for a matching valid trashed page |
222 | - if ( strlen( $page_content ) > 0 ) { |
|
222 | + if (strlen($page_content) > 0) { |
|
223 | 223 | // Search for an existing page with the specified page content (typically a shortcode) |
224 | - $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) ); |
|
224 | + $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%")); |
|
225 | 225 | } else { |
226 | 226 | // Search for an existing page with the specified page slug |
227 | - $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug ) ); |
|
227 | + $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug)); |
|
228 | 228 | } |
229 | 229 | |
230 | - if ( $trashed_page_found ) { |
|
230 | + if ($trashed_page_found) { |
|
231 | 231 | $page_id = $trashed_page_found; |
232 | 232 | $page_data = array( |
233 | 233 | 'ID' => $page_id, |
234 | 234 | 'post_status' => 'publish', |
235 | 235 | 'post_parent' => $post_parent, |
236 | 236 | ); |
237 | - wp_update_post( $page_data ); |
|
237 | + wp_update_post($page_data); |
|
238 | 238 | } else { |
239 | 239 | $page_data = array( |
240 | 240 | 'post_status' => 'publish', |
@@ -246,11 +246,11 @@ discard block |
||
246 | 246 | 'post_parent' => $post_parent, |
247 | 247 | 'comment_status' => 'closed', |
248 | 248 | ); |
249 | - $page_id = wp_insert_post( $page_data ); |
|
249 | + $page_id = wp_insert_post($page_data); |
|
250 | 250 | } |
251 | 251 | |
252 | - if ( $option ) { |
|
253 | - wpinv_update_option( $option, (int) $page_id ); |
|
252 | + if ($option) { |
|
253 | + wpinv_update_option($option, (int) $page_id); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | return $page_id; |
@@ -263,11 +263,11 @@ discard block |
||
263 | 263 | * |
264 | 264 | * @return array |
265 | 265 | */ |
266 | -function wpinv_add_aui_screens($screen_ids){ |
|
266 | +function wpinv_add_aui_screens($screen_ids) { |
|
267 | 267 | |
268 | 268 | // load on these pages if set |
269 | - $screen_ids = array_merge( $screen_ids, wpinv_get_screen_ids() ); |
|
269 | + $screen_ids = array_merge($screen_ids, wpinv_get_screen_ids()); |
|
270 | 270 | |
271 | 271 | return $screen_ids; |
272 | 272 | } |
273 | -add_filter('aui_screen_ids','wpinv_add_aui_screens'); |
|
274 | 273 | \ No newline at end of file |
274 | +add_filter('aui_screen_ids', 'wpinv_add_aui_screens'); |
|
275 | 275 | \ No newline at end of file |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Are we supporting item quantities? |
@@ -20,35 +20,35 @@ discard block |
||
20 | 20 | */ |
21 | 21 | function wpinv_get_ip() { |
22 | 22 | |
23 | - if ( isset( $_SERVER['HTTP_X_REAL_IP'] ) ) { |
|
24 | - return sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_REAL_IP'] ) ); |
|
23 | + if (isset($_SERVER['HTTP_X_REAL_IP'])) { |
|
24 | + return sanitize_text_field(wp_unslash($_SERVER['HTTP_X_REAL_IP'])); |
|
25 | 25 | } |
26 | 26 | |
27 | - if ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { |
|
27 | + if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
28 | 28 | // Proxy servers can send through this header like this: X-Forwarded-For: client1, proxy1, proxy2 |
29 | 29 | // Make sure we always only send through the first IP in the list which should always be the client IP. |
30 | - return (string) rest_is_ip_address( trim( current( preg_split( '/,/', sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) ) ) ) ); |
|
30 | + return (string) rest_is_ip_address(trim(current(preg_split('/,/', sanitize_text_field(wp_unslash($_SERVER['HTTP_X_FORWARDED_FOR'])))))); |
|
31 | 31 | } |
32 | 32 | |
33 | - if ( isset( $_SERVER['HTTP_CLIENT_IP'] ) ) { |
|
34 | - return sanitize_text_field( wp_unslash( $_SERVER['HTTP_CLIENT_IP'] ) ); |
|
33 | + if (isset($_SERVER['HTTP_CLIENT_IP'])) { |
|
34 | + return sanitize_text_field(wp_unslash($_SERVER['HTTP_CLIENT_IP'])); |
|
35 | 35 | } |
36 | 36 | |
37 | - if ( isset( $_SERVER['REMOTE_ADDR'] ) ) { |
|
38 | - return sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ); |
|
37 | + if (isset($_SERVER['REMOTE_ADDR'])) { |
|
38 | + return sanitize_text_field(wp_unslash($_SERVER['REMOTE_ADDR'])); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | return ''; |
42 | 42 | } |
43 | 43 | |
44 | 44 | function wpinv_get_user_agent() { |
45 | - if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
46 | - $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] ); |
|
45 | + if (!empty($_SERVER['HTTP_USER_AGENT'])) { |
|
46 | + $user_agent = sanitize_text_field($_SERVER['HTTP_USER_AGENT']); |
|
47 | 47 | } else { |
48 | 48 | $user_agent = ''; |
49 | 49 | } |
50 | 50 | |
51 | - return apply_filters( 'wpinv_get_user_agent', $user_agent ); |
|
51 | + return apply_filters('wpinv_get_user_agent', $user_agent); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -56,23 +56,23 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @param string $amount The amount to sanitize. |
58 | 58 | */ |
59 | -function wpinv_sanitize_amount( $amount ) { |
|
59 | +function wpinv_sanitize_amount($amount) { |
|
60 | 60 | |
61 | - if ( is_numeric( $amount ) ) { |
|
62 | - return floatval( $amount ); |
|
61 | + if (is_numeric($amount)) { |
|
62 | + return floatval($amount); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | // Separate the decimals and thousands. |
66 | - $amount = explode( wpinv_decimal_separator(), $amount ); |
|
66 | + $amount = explode(wpinv_decimal_separator(), $amount); |
|
67 | 67 | |
68 | 68 | // Remove thousands. |
69 | - $amount[0] = str_replace( wpinv_thousands_separator(), '', $amount[0] ); |
|
69 | + $amount[0] = str_replace(wpinv_thousands_separator(), '', $amount[0]); |
|
70 | 70 | |
71 | 71 | // Convert back to string. |
72 | - $amount = count( $amount ) > 1 ? "{$amount[0]}.{$amount[1]}" : $amount[0]; |
|
72 | + $amount = count($amount) > 1 ? "{$amount[0]}.{$amount[1]}" : $amount[0]; |
|
73 | 73 | |
74 | 74 | // Cast the remaining to a float. |
75 | - return (float) preg_replace( '/[^0-9\.\-]/', '', $amount ); |
|
75 | + return (float) preg_replace('/[^0-9\.\-]/', '', $amount); |
|
76 | 76 | |
77 | 77 | } |
78 | 78 | |
@@ -82,19 +82,19 @@ discard block |
||
82 | 82 | * @param float $amount |
83 | 83 | * @param float|string|int|null $decimals |
84 | 84 | */ |
85 | -function wpinv_round_amount( $amount, $decimals = null, $use_sprintf = false ) { |
|
85 | +function wpinv_round_amount($amount, $decimals = null, $use_sprintf = false) { |
|
86 | 86 | |
87 | - if ( $decimals === null ) { |
|
87 | + if ($decimals === null) { |
|
88 | 88 | $decimals = wpinv_decimals(); |
89 | 89 | } |
90 | 90 | |
91 | - if ( $use_sprintf ) { |
|
92 | - $amount = sprintf( "%.{$decimals}f", (float) $amount ); |
|
91 | + if ($use_sprintf) { |
|
92 | + $amount = sprintf("%.{$decimals}f", (float) $amount); |
|
93 | 93 | } else { |
94 | - $amount = round( (float) $amount, absint( $decimals ) ); |
|
94 | + $amount = round((float) $amount, absint($decimals)); |
|
95 | 95 | } |
96 | 96 | |
97 | - return apply_filters( 'wpinv_round_amount', $amount, $decimals ); |
|
97 | + return apply_filters('wpinv_round_amount', $amount, $decimals); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -106,32 +106,32 @@ discard block |
||
106 | 106 | * @param string|WPInv_Invoice $invoice The invoice object|post type|type |
107 | 107 | * @return array |
108 | 108 | */ |
109 | -function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) { |
|
109 | +function wpinv_get_invoice_statuses($draft = false, $trashed = false, $invoice = false) { |
|
110 | 110 | |
111 | 111 | $invoice_statuses = array( |
112 | - 'wpi-pending' => _x( 'Pending payment', 'Invoice status', 'invoicing' ), |
|
113 | - 'publish' => _x( 'Paid', 'Invoice status', 'invoicing' ), |
|
114 | - 'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
|
115 | - 'wpi-onhold' => _x( 'On hold', 'Invoice status', 'invoicing' ), |
|
116 | - 'wpi-cancelled' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
117 | - 'wpi-refunded' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
118 | - 'wpi-failed' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
|
119 | - 'wpi-renewal' => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ), |
|
112 | + 'wpi-pending' => _x('Pending payment', 'Invoice status', 'invoicing'), |
|
113 | + 'publish' => _x('Paid', 'Invoice status', 'invoicing'), |
|
114 | + 'wpi-processing' => _x('Processing', 'Invoice status', 'invoicing'), |
|
115 | + 'wpi-onhold' => _x('On hold', 'Invoice status', 'invoicing'), |
|
116 | + 'wpi-cancelled' => _x('Cancelled', 'Invoice status', 'invoicing'), |
|
117 | + 'wpi-refunded' => _x('Refunded', 'Invoice status', 'invoicing'), |
|
118 | + 'wpi-failed' => _x('Failed', 'Invoice status', 'invoicing'), |
|
119 | + 'wpi-renewal' => _x('Renewal Payment', 'Invoice status', 'invoicing'), |
|
120 | 120 | ); |
121 | 121 | |
122 | - if ( $draft ) { |
|
123 | - $invoice_statuses['draft'] = __( 'Draft', 'invoicing' ); |
|
122 | + if ($draft) { |
|
123 | + $invoice_statuses['draft'] = __('Draft', 'invoicing'); |
|
124 | 124 | } |
125 | 125 | |
126 | - if ( $trashed ) { |
|
127 | - $invoice_statuses['trash'] = __( 'Trash', 'invoicing' ); |
|
126 | + if ($trashed) { |
|
127 | + $invoice_statuses['trash'] = __('Trash', 'invoicing'); |
|
128 | 128 | } |
129 | 129 | |
130 | - if ( $invoice instanceof WPInv_Invoice ) { |
|
130 | + if ($invoice instanceof WPInv_Invoice) { |
|
131 | 131 | $invoice = $invoice->get_post_type(); |
132 | 132 | } |
133 | 133 | |
134 | - return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice ); |
|
134 | + return apply_filters('wpinv_statuses', $invoice_statuses, $invoice); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -140,11 +140,11 @@ discard block |
||
140 | 140 | * @param string $status The raw status |
141 | 141 | * @param string|WPInv_Invoice $invoice The invoice object|post type|type |
142 | 142 | */ |
143 | -function wpinv_status_nicename( $status, $invoice = false ) { |
|
144 | - $statuses = wpinv_get_invoice_statuses( true, true, $invoice ); |
|
145 | - $status = isset( $statuses[$status] ) ? $statuses[$status] : $status; |
|
143 | +function wpinv_status_nicename($status, $invoice = false) { |
|
144 | + $statuses = wpinv_get_invoice_statuses(true, true, $invoice); |
|
145 | + $status = isset($statuses[$status]) ? $statuses[$status] : $status; |
|
146 | 146 | |
147 | - return sanitize_text_field( $status ); |
|
147 | + return sanitize_text_field($status); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -152,13 +152,13 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @param string $current |
154 | 154 | */ |
155 | -function wpinv_get_currency( $current = '' ) { |
|
155 | +function wpinv_get_currency($current = '') { |
|
156 | 156 | |
157 | - if ( empty( $current ) ) { |
|
158 | - $current = apply_filters( 'wpinv_currency', wpinv_get_option( 'currency', 'USD' ) ); |
|
157 | + if (empty($current)) { |
|
158 | + $current = apply_filters('wpinv_currency', wpinv_get_option('currency', 'USD')); |
|
159 | 159 | } |
160 | 160 | |
161 | - return trim( strtoupper( $current ) ); |
|
161 | + return trim(strtoupper($current)); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -166,25 +166,25 @@ discard block |
||
166 | 166 | * |
167 | 167 | * @param string|null $currency The currency code. Defaults to the default currency. |
168 | 168 | */ |
169 | -function wpinv_currency_symbol( $currency = null ) { |
|
169 | +function wpinv_currency_symbol($currency = null) { |
|
170 | 170 | |
171 | 171 | // Prepare the currency. |
172 | - $currency = empty( $currency ) ? wpinv_get_currency() : wpinv_clean( $currency ); |
|
172 | + $currency = empty($currency) ? wpinv_get_currency() : wpinv_clean($currency); |
|
173 | 173 | |
174 | 174 | // Fetch all symbols. |
175 | 175 | $symbols = wpinv_get_currency_symbols(); |
176 | 176 | |
177 | 177 | // Fetch this currencies symbol. |
178 | - $currency_symbol = isset( $symbols[$currency] ) ? $symbols[$currency] : $currency; |
|
178 | + $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : $currency; |
|
179 | 179 | |
180 | 180 | // Filter the symbol. |
181 | - return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency ); |
|
181 | + return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | function wpinv_currency_position() { |
185 | - $position = wpinv_get_option( 'currency_position', 'left' ); |
|
185 | + $position = wpinv_get_option('currency_position', 'left'); |
|
186 | 186 | |
187 | - return apply_filters( 'wpinv_currency_position', $position ); |
|
187 | + return apply_filters('wpinv_currency_position', $position); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
@@ -192,13 +192,13 @@ discard block |
||
192 | 192 | * |
193 | 193 | * @param $string|null $current |
194 | 194 | */ |
195 | -function wpinv_thousands_separator( $current = null ) { |
|
195 | +function wpinv_thousands_separator($current = null) { |
|
196 | 196 | |
197 | - if ( null == $current ) { |
|
198 | - $current = wpinv_get_option( 'thousands_separator', ',' ); |
|
197 | + if (null == $current) { |
|
198 | + $current = wpinv_get_option('thousands_separator', ','); |
|
199 | 199 | } |
200 | 200 | |
201 | - return trim( $current ); |
|
201 | + return trim($current); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -206,13 +206,13 @@ discard block |
||
206 | 206 | * |
207 | 207 | * @param $string|null $current |
208 | 208 | */ |
209 | -function wpinv_decimal_separator( $current = null ) { |
|
209 | +function wpinv_decimal_separator($current = null) { |
|
210 | 210 | |
211 | - if ( null == $current ) { |
|
212 | - $current = wpinv_get_option( 'decimal_separator', '.' ); |
|
211 | + if (null == $current) { |
|
212 | + $current = wpinv_get_option('decimal_separator', '.'); |
|
213 | 213 | } |
214 | 214 | |
215 | - return trim( $current ); |
|
215 | + return trim($current); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
@@ -220,27 +220,27 @@ discard block |
||
220 | 220 | * |
221 | 221 | * @param $string|null $current |
222 | 222 | */ |
223 | -function wpinv_decimals( $current = null ) { |
|
223 | +function wpinv_decimals($current = null) { |
|
224 | 224 | |
225 | - if ( null == $current ) { |
|
226 | - $current = wpinv_get_option( 'decimals', 2 ); |
|
225 | + if (null == $current) { |
|
226 | + $current = wpinv_get_option('decimals', 2); |
|
227 | 227 | } |
228 | 228 | |
229 | - return absint( $current ); |
|
229 | + return absint($current); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
233 | 233 | * Retrieves a list of all supported currencies. |
234 | 234 | */ |
235 | 235 | function wpinv_get_currencies() { |
236 | - return apply_filters( 'wpinv_currencies', wpinv_get_data( 'currencies' ) ); |
|
236 | + return apply_filters('wpinv_currencies', wpinv_get_data('currencies')); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | /** |
240 | 240 | * Retrieves a list of all currency symbols. |
241 | 241 | */ |
242 | 242 | function wpinv_get_currency_symbols() { |
243 | - return apply_filters( 'wpinv_currency_symbols', wpinv_get_data( 'currency-symbols' ) ); |
|
243 | + return apply_filters('wpinv_currency_symbols', wpinv_get_data('currency-symbols')); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | $currency_pos = wpinv_currency_position(); |
253 | 253 | $format = '%1$s%2$s'; |
254 | 254 | |
255 | - switch ( $currency_pos ) { |
|
255 | + switch ($currency_pos) { |
|
256 | 256 | case 'left': |
257 | 257 | $format = '%1$s%2$s'; |
258 | 258 | break; |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | break; |
268 | 268 | } |
269 | 269 | |
270 | - return apply_filters( 'getpaid_price_format', $format, $currency_pos ); |
|
270 | + return apply_filters('getpaid_price_format', $format, $currency_pos); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | /** |
@@ -277,25 +277,25 @@ discard block |
||
277 | 277 | * @param string $currency Currency. |
278 | 278 | * @return string |
279 | 279 | */ |
280 | -function wpinv_price( $amount = 0, $currency = '' ) { |
|
280 | +function wpinv_price($amount = 0, $currency = '') { |
|
281 | 281 | |
282 | 282 | // Backwards compatibility. |
283 | - $amount = wpinv_sanitize_amount( $amount ); |
|
283 | + $amount = wpinv_sanitize_amount($amount); |
|
284 | 284 | |
285 | 285 | // Prepare variables. |
286 | - $currency = wpinv_get_currency( $currency ); |
|
286 | + $currency = wpinv_get_currency($currency); |
|
287 | 287 | $amount = (float) $amount; |
288 | 288 | $unformatted_amount = $amount; |
289 | 289 | $negative = $amount < 0; |
290 | - $amount = apply_filters( 'getpaid_raw_amount', floatval( $negative ? $amount * -1 : $amount ) ); |
|
291 | - $amount = wpinv_format_amount( $amount ); |
|
290 | + $amount = apply_filters('getpaid_raw_amount', floatval($negative ? $amount * -1 : $amount)); |
|
291 | + $amount = wpinv_format_amount($amount); |
|
292 | 292 | |
293 | 293 | // Format the amount. |
294 | 294 | $format = getpaid_get_price_format(); |
295 | - $formatted_amount = ( $negative ? '-' : '' ) . sprintf( $format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol( $currency ) . '</span>', $amount ); |
|
295 | + $formatted_amount = ($negative ? '-' : '') . sprintf($format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol($currency) . '</span>', $amount); |
|
296 | 296 | |
297 | 297 | // Filter the formatting. |
298 | - return apply_filters( 'wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount ); |
|
298 | + return apply_filters('wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | /** |
@@ -306,25 +306,25 @@ discard block |
||
306 | 306 | * @param bool $calculate Whether or not to apply separators. |
307 | 307 | * @return string |
308 | 308 | */ |
309 | -function wpinv_format_amount( $amount, $decimals = null, $calculate = false ) { |
|
309 | +function wpinv_format_amount($amount, $decimals = null, $calculate = false) { |
|
310 | 310 | $thousands_sep = wpinv_thousands_separator(); |
311 | 311 | $decimal_sep = wpinv_decimal_separator(); |
312 | - $decimals = wpinv_decimals( $decimals ); |
|
313 | - $amount = wpinv_sanitize_amount( $amount ); |
|
312 | + $decimals = wpinv_decimals($decimals); |
|
313 | + $amount = wpinv_sanitize_amount($amount); |
|
314 | 314 | |
315 | - if ( $calculate ) { |
|
315 | + if ($calculate) { |
|
316 | 316 | return $amount; |
317 | 317 | } |
318 | 318 | |
319 | 319 | // Fomart the amount. |
320 | - return number_format( $amount, $decimals, $decimal_sep, $thousands_sep ); |
|
320 | + return number_format($amount, $decimals, $decimal_sep, $thousands_sep); |
|
321 | 321 | } |
322 | 322 | |
323 | -function wpinv_sanitize_key( $key ) { |
|
323 | +function wpinv_sanitize_key($key) { |
|
324 | 324 | $raw_key = $key; |
325 | - $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key ); |
|
325 | + $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key); |
|
326 | 326 | |
327 | - return apply_filters( 'wpinv_sanitize_key', $key, $raw_key ); |
|
327 | + return apply_filters('wpinv_sanitize_key', $key, $raw_key); |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | /** |
@@ -332,8 +332,8 @@ discard block |
||
332 | 332 | * |
333 | 333 | * @param $str the file whose extension should be retrieved. |
334 | 334 | */ |
335 | -function wpinv_get_file_extension( $str ) { |
|
336 | - $filetype = wp_check_filetype( $str ); |
|
335 | +function wpinv_get_file_extension($str) { |
|
336 | + $filetype = wp_check_filetype($str); |
|
337 | 337 | return $filetype['ext']; |
338 | 338 | } |
339 | 339 | |
@@ -342,16 +342,16 @@ discard block |
||
342 | 342 | * |
343 | 343 | * @param string $string |
344 | 344 | */ |
345 | -function wpinv_string_is_image_url( $string ) { |
|
346 | - $extension = strtolower( wpinv_get_file_extension( $string ) ); |
|
347 | - return in_array( $extension, array( 'jpeg', 'jpg', 'png', 'gif', 'ico' ), true ); |
|
345 | +function wpinv_string_is_image_url($string) { |
|
346 | + $extension = strtolower(wpinv_get_file_extension($string)); |
|
347 | + return in_array($extension, array('jpeg', 'jpg', 'png', 'gif', 'ico'), true); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | /** |
351 | 351 | * Returns the current URL. |
352 | 352 | */ |
353 | 353 | function wpinv_get_current_page_url() { |
354 | - return ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
|
354 | + return (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | /** |
@@ -361,46 +361,46 @@ discard block |
||
361 | 361 | * @param string $name Constant name. |
362 | 362 | * @param mixed $value Value. |
363 | 363 | */ |
364 | -function getpaid_maybe_define_constant( $name, $value ) { |
|
365 | - if ( ! defined( $name ) ) { |
|
366 | - define( $name, $value ); |
|
364 | +function getpaid_maybe_define_constant($name, $value) { |
|
365 | + if (!defined($name)) { |
|
366 | + define($name, $value); |
|
367 | 367 | } |
368 | 368 | } |
369 | 369 | |
370 | 370 | function wpinv_get_php_arg_separator_output() { |
371 | - return ini_get( 'arg_separator.output' ); |
|
371 | + return ini_get('arg_separator.output'); |
|
372 | 372 | } |
373 | 373 | |
374 | -function wpinv_rgb_from_hex( $color ) { |
|
375 | - $color = str_replace( '#', '', $color ); |
|
374 | +function wpinv_rgb_from_hex($color) { |
|
375 | + $color = str_replace('#', '', $color); |
|
376 | 376 | |
377 | 377 | // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF" |
378 | - $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color ); |
|
379 | - if ( empty( $color ) ) { |
|
378 | + $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color); |
|
379 | + if (empty($color)) { |
|
380 | 380 | return NULL; |
381 | 381 | } |
382 | 382 | |
383 | - $color = str_split( $color ); |
|
383 | + $color = str_split($color); |
|
384 | 384 | |
385 | 385 | $rgb = array(); |
386 | - $rgb['R'] = hexdec( $color[0] . $color[1] ); |
|
387 | - $rgb['G'] = hexdec( $color[2] . $color[3] ); |
|
388 | - $rgb['B'] = hexdec( $color[4] . $color[5] ); |
|
386 | + $rgb['R'] = hexdec($color[0] . $color[1]); |
|
387 | + $rgb['G'] = hexdec($color[2] . $color[3]); |
|
388 | + $rgb['B'] = hexdec($color[4] . $color[5]); |
|
389 | 389 | |
390 | 390 | return $rgb; |
391 | 391 | } |
392 | 392 | |
393 | -function wpinv_hex_darker( $color, $factor = 30 ) { |
|
394 | - $base = wpinv_rgb_from_hex( $color ); |
|
393 | +function wpinv_hex_darker($color, $factor = 30) { |
|
394 | + $base = wpinv_rgb_from_hex($color); |
|
395 | 395 | $color = '#'; |
396 | 396 | |
397 | - foreach ( $base as $k => $v ) { |
|
397 | + foreach ($base as $k => $v) { |
|
398 | 398 | $amount = $v / 100; |
399 | - $amount = round( $amount * $factor ); |
|
399 | + $amount = round($amount * $factor); |
|
400 | 400 | $new_decimal = $v - $amount; |
401 | 401 | |
402 | - $new_hex_component = dechex( $new_decimal ); |
|
403 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
402 | + $new_hex_component = dechex($new_decimal); |
|
403 | + if (strlen($new_hex_component) < 2) { |
|
404 | 404 | $new_hex_component = "0" . $new_hex_component; |
405 | 405 | } |
406 | 406 | $color .= $new_hex_component; |
@@ -409,18 +409,18 @@ discard block |
||
409 | 409 | return $color; |
410 | 410 | } |
411 | 411 | |
412 | -function wpinv_hex_lighter( $color, $factor = 30 ) { |
|
413 | - $base = wpinv_rgb_from_hex( $color ); |
|
412 | +function wpinv_hex_lighter($color, $factor = 30) { |
|
413 | + $base = wpinv_rgb_from_hex($color); |
|
414 | 414 | $color = '#'; |
415 | 415 | |
416 | - foreach ( $base as $k => $v ) { |
|
416 | + foreach ($base as $k => $v) { |
|
417 | 417 | $amount = 255 - $v; |
418 | 418 | $amount = $amount / 100; |
419 | - $amount = round( $amount * $factor ); |
|
419 | + $amount = round($amount * $factor); |
|
420 | 420 | $new_decimal = $v + $amount; |
421 | 421 | |
422 | - $new_hex_component = dechex( $new_decimal ); |
|
423 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
422 | + $new_hex_component = dechex($new_decimal); |
|
423 | + if (strlen($new_hex_component) < 2) { |
|
424 | 424 | $new_hex_component = "0" . $new_hex_component; |
425 | 425 | } |
426 | 426 | $color .= $new_hex_component; |
@@ -429,22 +429,22 @@ discard block |
||
429 | 429 | return $color; |
430 | 430 | } |
431 | 431 | |
432 | -function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) { |
|
433 | - $hex = str_replace( '#', '', $color ); |
|
432 | +function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') { |
|
433 | + $hex = str_replace('#', '', $color); |
|
434 | 434 | |
435 | - $c_r = hexdec( substr( $hex, 0, 2 ) ); |
|
436 | - $c_g = hexdec( substr( $hex, 2, 2 ) ); |
|
437 | - $c_b = hexdec( substr( $hex, 4, 2 ) ); |
|
435 | + $c_r = hexdec(substr($hex, 0, 2)); |
|
436 | + $c_g = hexdec(substr($hex, 2, 2)); |
|
437 | + $c_b = hexdec(substr($hex, 4, 2)); |
|
438 | 438 | |
439 | - $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000; |
|
439 | + $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000; |
|
440 | 440 | |
441 | 441 | return $brightness > 155 ? $dark : $light; |
442 | 442 | } |
443 | 443 | |
444 | -function wpinv_format_hex( $hex ) { |
|
445 | - $hex = trim( str_replace( '#', '', $hex ) ); |
|
444 | +function wpinv_format_hex($hex) { |
|
445 | + $hex = trim(str_replace('#', '', $hex)); |
|
446 | 446 | |
447 | - if ( strlen( $hex ) == 3 ) { |
|
447 | + if (strlen($hex) == 3) { |
|
448 | 448 | $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2]; |
449 | 449 | } |
450 | 450 | |
@@ -464,12 +464,12 @@ discard block |
||
464 | 464 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
465 | 465 | * @return string |
466 | 466 | */ |
467 | -function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) { |
|
468 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
469 | - return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding ); |
|
467 | +function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') { |
|
468 | + if (function_exists('mb_strimwidth')) { |
|
469 | + return mb_strimwidth($str, $start, $width, $trimmaker, $encoding); |
|
470 | 470 | } |
471 | 471 | |
472 | - return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker; |
|
472 | + return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker; |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | /** |
@@ -481,28 +481,28 @@ discard block |
||
481 | 481 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
482 | 482 | * @return int Returns the number of characters in string. |
483 | 483 | */ |
484 | -function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) { |
|
485 | - if ( function_exists( 'mb_strlen' ) ) { |
|
486 | - return mb_strlen( $str, $encoding ); |
|
484 | +function wpinv_utf8_strlen($str, $encoding = 'UTF-8') { |
|
485 | + if (function_exists('mb_strlen')) { |
|
486 | + return mb_strlen($str, $encoding); |
|
487 | 487 | } |
488 | 488 | |
489 | - return strlen( $str ); |
|
489 | + return strlen($str); |
|
490 | 490 | } |
491 | 491 | |
492 | -function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) { |
|
493 | - if ( function_exists( 'mb_strtolower' ) ) { |
|
494 | - return mb_strtolower( $str, $encoding ); |
|
492 | +function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') { |
|
493 | + if (function_exists('mb_strtolower')) { |
|
494 | + return mb_strtolower($str, $encoding); |
|
495 | 495 | } |
496 | 496 | |
497 | - return strtolower( $str ); |
|
497 | + return strtolower($str); |
|
498 | 498 | } |
499 | 499 | |
500 | -function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) { |
|
501 | - if ( function_exists( 'mb_strtoupper' ) ) { |
|
502 | - return mb_strtoupper( $str, $encoding ); |
|
500 | +function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') { |
|
501 | + if (function_exists('mb_strtoupper')) { |
|
502 | + return mb_strtoupper($str, $encoding); |
|
503 | 503 | } |
504 | 504 | |
505 | - return strtoupper( $str ); |
|
505 | + return strtoupper($str); |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | /** |
@@ -516,12 +516,12 @@ discard block |
||
516 | 516 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
517 | 517 | * @return int Returns the position of the first occurrence of search in the string. |
518 | 518 | */ |
519 | -function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
520 | - if ( function_exists( 'mb_strpos' ) ) { |
|
521 | - return mb_strpos( $str, $find, $offset, $encoding ); |
|
519 | +function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
520 | + if (function_exists('mb_strpos')) { |
|
521 | + return mb_strpos($str, $find, $offset, $encoding); |
|
522 | 522 | } |
523 | 523 | |
524 | - return strpos( $str, $find, $offset ); |
|
524 | + return strpos($str, $find, $offset); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | /** |
@@ -535,12 +535,12 @@ discard block |
||
535 | 535 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
536 | 536 | * @return int Returns the position of the last occurrence of search. |
537 | 537 | */ |
538 | -function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
539 | - if ( function_exists( 'mb_strrpos' ) ) { |
|
540 | - return mb_strrpos( $str, $find, $offset, $encoding ); |
|
538 | +function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
539 | + if (function_exists('mb_strrpos')) { |
|
540 | + return mb_strrpos($str, $find, $offset, $encoding); |
|
541 | 541 | } |
542 | 542 | |
543 | - return strrpos( $str, $find, $offset ); |
|
543 | + return strrpos($str, $find, $offset); |
|
544 | 544 | } |
545 | 545 | |
546 | 546 | /** |
@@ -555,16 +555,16 @@ discard block |
||
555 | 555 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
556 | 556 | * @return string |
557 | 557 | */ |
558 | -function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) { |
|
559 | - if ( function_exists( 'mb_substr' ) ) { |
|
560 | - if ( $length === null ) { |
|
561 | - return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
558 | +function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') { |
|
559 | + if (function_exists('mb_substr')) { |
|
560 | + if ($length === null) { |
|
561 | + return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
562 | 562 | } else { |
563 | - return mb_substr( $str, $start, $length, $encoding ); |
|
563 | + return mb_substr($str, $start, $length, $encoding); |
|
564 | 564 | } |
565 | 565 | } |
566 | 566 | |
567 | - return substr( $str, $start, $length ); |
|
567 | + return substr($str, $start, $length); |
|
568 | 568 | } |
569 | 569 | |
570 | 570 | /** |
@@ -576,48 +576,48 @@ discard block |
||
576 | 576 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
577 | 577 | * @return string The width of string. |
578 | 578 | */ |
579 | -function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) { |
|
580 | - if ( function_exists( 'mb_strwidth' ) ) { |
|
581 | - return mb_strwidth( $str, $encoding ); |
|
579 | +function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') { |
|
580 | + if (function_exists('mb_strwidth')) { |
|
581 | + return mb_strwidth($str, $encoding); |
|
582 | 582 | } |
583 | 583 | |
584 | - return wpinv_utf8_strlen( $str, $encoding ); |
|
584 | + return wpinv_utf8_strlen($str, $encoding); |
|
585 | 585 | } |
586 | 586 | |
587 | -function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) { |
|
588 | - if ( function_exists( 'mb_strlen' ) ) { |
|
589 | - $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding ); |
|
587 | +function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') { |
|
588 | + if (function_exists('mb_strlen')) { |
|
589 | + $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding); |
|
590 | 590 | $str_end = ""; |
591 | 591 | |
592 | - if ( $lower_str_end ) { |
|
593 | - $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding ); |
|
592 | + if ($lower_str_end) { |
|
593 | + $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding); |
|
594 | 594 | } else { |
595 | - $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
595 | + $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
596 | 596 | } |
597 | 597 | |
598 | 598 | return $first_letter . $str_end; |
599 | 599 | } |
600 | 600 | |
601 | - return ucfirst( $str ); |
|
601 | + return ucfirst($str); |
|
602 | 602 | } |
603 | 603 | |
604 | -function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) { |
|
605 | - if ( function_exists( 'mb_convert_case' ) ) { |
|
606 | - return mb_convert_case( $str, MB_CASE_TITLE, $encoding ); |
|
604 | +function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') { |
|
605 | + if (function_exists('mb_convert_case')) { |
|
606 | + return mb_convert_case($str, MB_CASE_TITLE, $encoding); |
|
607 | 607 | } |
608 | 608 | |
609 | - return ucwords( $str ); |
|
609 | + return ucwords($str); |
|
610 | 610 | } |
611 | 611 | |
612 | -function wpinv_period_in_days( $period, $unit ) { |
|
613 | - $period = absint( $period ); |
|
612 | +function wpinv_period_in_days($period, $unit) { |
|
613 | + $period = absint($period); |
|
614 | 614 | |
615 | - if ( $period > 0 ) { |
|
616 | - if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) { |
|
615 | + if ($period > 0) { |
|
616 | + if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) { |
|
617 | 617 | $period = $period * 7; |
618 | - } else if ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) { |
|
618 | + } else if (in_array(strtolower($unit), array('m', 'month', 'months'))) { |
|
619 | 619 | $period = $period * 30; |
620 | - } else if ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) { |
|
620 | + } else if (in_array(strtolower($unit), array('y', 'year', 'years'))) { |
|
621 | 621 | $period = $period * 365; |
622 | 622 | } |
623 | 623 | } |
@@ -625,14 +625,14 @@ discard block |
||
625 | 625 | return $period; |
626 | 626 | } |
627 | 627 | |
628 | -function wpinv_cal_days_in_month( $calendar, $month, $year ) { |
|
629 | - if ( function_exists( 'cal_days_in_month' ) ) { |
|
630 | - return cal_days_in_month( $calendar, $month, $year ); |
|
628 | +function wpinv_cal_days_in_month($calendar, $month, $year) { |
|
629 | + if (function_exists('cal_days_in_month')) { |
|
630 | + return cal_days_in_month($calendar, $month, $year); |
|
631 | 631 | } |
632 | 632 | |
633 | 633 | // Fallback in case the calendar extension is not loaded in PHP |
634 | 634 | // Only supports Gregorian calendar |
635 | - return date( 't', mktime( 0, 0, 0, $month, 1, $year ) ); |
|
635 | + return date('t', mktime(0, 0, 0, $month, 1, $year)); |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | /** |
@@ -643,12 +643,12 @@ discard block |
||
643 | 643 | * |
644 | 644 | * @return string |
645 | 645 | */ |
646 | -function wpi_help_tip( $tip, $allow_html = false ) { |
|
646 | +function wpi_help_tip($tip, $allow_html = false) { |
|
647 | 647 | |
648 | - if ( $allow_html ) { |
|
649 | - $tip = wpi_sanitize_tooltip( $tip ); |
|
648 | + if ($allow_html) { |
|
649 | + $tip = wpi_sanitize_tooltip($tip); |
|
650 | 650 | } else { |
651 | - $tip = esc_attr( $tip ); |
|
651 | + $tip = esc_attr($tip); |
|
652 | 652 | } |
653 | 653 | |
654 | 654 | return '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; |
@@ -662,8 +662,8 @@ discard block |
||
662 | 662 | * @param string $var |
663 | 663 | * @return string |
664 | 664 | */ |
665 | -function wpi_sanitize_tooltip( $var ) { |
|
666 | - return wp_kses( html_entity_decode( $var ), array( |
|
665 | +function wpi_sanitize_tooltip($var) { |
|
666 | + return wp_kses(html_entity_decode($var), array( |
|
667 | 667 | 'br' => array(), |
668 | 668 | 'em' => array(), |
669 | 669 | 'strong' => array(), |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | 'li' => array(), |
675 | 675 | 'ol' => array(), |
676 | 676 | 'p' => array(), |
677 | - ) ); |
|
677 | + )); |
|
678 | 678 | } |
679 | 679 | |
680 | 680 | /** |
@@ -684,7 +684,7 @@ discard block |
||
684 | 684 | */ |
685 | 685 | function wpinv_get_screen_ids() { |
686 | 686 | |
687 | - $screen_id = sanitize_title( __( 'Invoicing', 'invoicing' ) ); |
|
687 | + $screen_id = sanitize_title(__('Invoicing', 'invoicing')); |
|
688 | 688 | |
689 | 689 | $screen_ids = array( |
690 | 690 | 'toplevel_page_' . $screen_id, |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | 'getpaid_page_wpinv-customers', |
706 | 706 | ); |
707 | 707 | |
708 | - return apply_filters( 'wpinv_screen_ids', $screen_ids ); |
|
708 | + return apply_filters('wpinv_screen_ids', $screen_ids); |
|
709 | 709 | } |
710 | 710 | |
711 | 711 | /** |
@@ -716,14 +716,14 @@ discard block |
||
716 | 716 | * @param array|string $list List of values. |
717 | 717 | * @return array Sanitized array of values. |
718 | 718 | */ |
719 | -function wpinv_parse_list( $list ) { |
|
719 | +function wpinv_parse_list($list) { |
|
720 | 720 | |
721 | - if ( empty( $list ) ) { |
|
721 | + if (empty($list)) { |
|
722 | 722 | $list = array(); |
723 | 723 | } |
724 | 724 | |
725 | - if ( ! is_array( $list ) ) { |
|
726 | - return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
725 | + if (!is_array($list)) { |
|
726 | + return preg_split('/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY); |
|
727 | 727 | } |
728 | 728 | |
729 | 729 | return $list; |
@@ -737,16 +737,16 @@ discard block |
||
737 | 737 | * @param string $key Type of data to fetch. |
738 | 738 | * @return mixed Fetched data. |
739 | 739 | */ |
740 | -function wpinv_get_data( $key ) { |
|
740 | +function wpinv_get_data($key) { |
|
741 | 741 | |
742 | 742 | // Try fetching it from the cache. |
743 | - $data = wp_cache_get( "wpinv-data-$key", 'wpinv' ); |
|
744 | - if( $data ) { |
|
743 | + $data = wp_cache_get("wpinv-data-$key", 'wpinv'); |
|
744 | + if ($data) { |
|
745 | 745 | return $data; |
746 | 746 | } |
747 | 747 | |
748 | - $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" ); |
|
749 | - wp_cache_set( "wpinv-data-$key", $data, 'wpinv' ); |
|
748 | + $data = apply_filters("wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php"); |
|
749 | + wp_cache_set("wpinv-data-$key", $data, 'wpinv'); |
|
750 | 750 | |
751 | 751 | return $data; |
752 | 752 | } |
@@ -760,10 +760,10 @@ discard block |
||
760 | 760 | * @param bool $first_empty Whether or not the first item in the list should be empty |
761 | 761 | * @return mixed Fetched data. |
762 | 762 | */ |
763 | -function wpinv_maybe_add_empty_option( $options, $first_empty ) { |
|
763 | +function wpinv_maybe_add_empty_option($options, $first_empty) { |
|
764 | 764 | |
765 | - if ( ! empty( $options ) && $first_empty ) { |
|
766 | - return array_merge( array( '' => '' ), $options ); |
|
765 | + if (!empty($options) && $first_empty) { |
|
766 | + return array_merge(array('' => ''), $options); |
|
767 | 767 | } |
768 | 768 | return $options; |
769 | 769 | |
@@ -775,21 +775,21 @@ discard block |
||
775 | 775 | * @param mixed $var Data to sanitize. |
776 | 776 | * @return string|array |
777 | 777 | */ |
778 | -function wpinv_clean( $var ) { |
|
778 | +function wpinv_clean($var) { |
|
779 | 779 | |
780 | - if ( is_array( $var ) ) { |
|
781 | - return array_map( 'wpinv_clean', $var ); |
|
780 | + if (is_array($var)) { |
|
781 | + return array_map('wpinv_clean', $var); |
|
782 | 782 | } |
783 | 783 | |
784 | - if ( is_object( $var ) ) { |
|
785 | - $object_vars = get_object_vars( $var ); |
|
786 | - foreach ( $object_vars as $property_name => $property_value ) { |
|
787 | - $var->$property_name = wpinv_clean( $property_value ); |
|
784 | + if (is_object($var)) { |
|
785 | + $object_vars = get_object_vars($var); |
|
786 | + foreach ($object_vars as $property_name => $property_value) { |
|
787 | + $var->$property_name = wpinv_clean($property_value); |
|
788 | 788 | } |
789 | 789 | return $var; |
790 | 790 | } |
791 | 791 | |
792 | - return is_string( $var ) ? sanitize_text_field( $var ) : $var; |
|
792 | + return is_string($var) ? sanitize_text_field($var) : $var; |
|
793 | 793 | } |
794 | 794 | |
795 | 795 | /** |
@@ -798,43 +798,43 @@ discard block |
||
798 | 798 | * @param string $str Data to convert. |
799 | 799 | * @return string|array |
800 | 800 | */ |
801 | -function getpaid_convert_price_string_to_options( $str ) { |
|
801 | +function getpaid_convert_price_string_to_options($str) { |
|
802 | 802 | |
803 | - $raw_options = array_map( 'trim', explode( ',', $str ) ); |
|
804 | - $options = array(); |
|
803 | + $raw_options = array_map('trim', explode(',', $str)); |
|
804 | + $options = array(); |
|
805 | 805 | |
806 | - foreach ( $raw_options as $option ) { |
|
806 | + foreach ($raw_options as $option) { |
|
807 | 807 | |
808 | - if ( '' == $option ) { |
|
808 | + if ('' == $option) { |
|
809 | 809 | continue; |
810 | 810 | } |
811 | 811 | |
812 | - $option = array_map( 'trim', explode( '|', $option ) ); |
|
812 | + $option = array_map('trim', explode('|', $option)); |
|
813 | 813 | |
814 | 814 | $price = null; |
815 | 815 | $label = null; |
816 | 816 | |
817 | - if ( isset( $option[0] ) && '' != $option[0] ) { |
|
818 | - $label = $option[0]; |
|
817 | + if (isset($option[0]) && '' != $option[0]) { |
|
818 | + $label = $option[0]; |
|
819 | 819 | } |
820 | 820 | |
821 | - if ( isset( $option[1] ) && '' != $option[1] ) { |
|
821 | + if (isset($option[1]) && '' != $option[1]) { |
|
822 | 822 | $price = $option[1]; |
823 | 823 | } |
824 | 824 | |
825 | - if ( ! isset( $price ) ) { |
|
825 | + if (!isset($price)) { |
|
826 | 826 | $price = $label; |
827 | 827 | } |
828 | 828 | |
829 | - if ( ! isset( $price ) || ! is_numeric( $price ) ) { |
|
829 | + if (!isset($price) || !is_numeric($price)) { |
|
830 | 830 | continue; |
831 | 831 | } |
832 | 832 | |
833 | - if ( ! isset( $label ) ) { |
|
833 | + if (!isset($label)) { |
|
834 | 834 | $label = $price; |
835 | 835 | } |
836 | 836 | |
837 | - $options[ $price ] = $label; |
|
837 | + $options[$price] = $label; |
|
838 | 838 | } |
839 | 839 | |
840 | 840 | return $options; |
@@ -843,27 +843,27 @@ discard block |
||
843 | 843 | /** |
844 | 844 | * Returns the help tip. |
845 | 845 | */ |
846 | -function getpaid_get_help_tip( $tip, $additional_classes = '' ) { |
|
847 | - $additional_classes = sanitize_html_class( $additional_classes ); |
|
848 | - $tip = esc_attr__( $tip ); |
|
846 | +function getpaid_get_help_tip($tip, $additional_classes = '') { |
|
847 | + $additional_classes = sanitize_html_class($additional_classes); |
|
848 | + $tip = esc_attr__($tip); |
|
849 | 849 | return "<span class='wpi-help-tip dashicons dashicons-editor-help $additional_classes' title='$tip'></span>"; |
850 | 850 | } |
851 | 851 | |
852 | 852 | /** |
853 | 853 | * Formats a date |
854 | 854 | */ |
855 | -function getpaid_format_date( $date, $with_time = false ) { |
|
855 | +function getpaid_format_date($date, $with_time = false) { |
|
856 | 856 | |
857 | - if ( empty( $date ) || $date == '0000-00-00 00:00:00' ) { |
|
857 | + if (empty($date) || $date == '0000-00-00 00:00:00') { |
|
858 | 858 | return ''; |
859 | 859 | } |
860 | 860 | |
861 | 861 | $format = getpaid_date_format(); |
862 | 862 | |
863 | - if ( $with_time ) { |
|
863 | + if ($with_time) { |
|
864 | 864 | $format .= ' ' . getpaid_time_format(); |
865 | 865 | } |
866 | - return date_i18n( $format, strtotime( $date ) ); |
|
866 | + return date_i18n($format, strtotime($date)); |
|
867 | 867 | |
868 | 868 | } |
869 | 869 | |
@@ -872,9 +872,9 @@ discard block |
||
872 | 872 | * |
873 | 873 | * @return string |
874 | 874 | */ |
875 | -function getpaid_format_date_value( $date, $default = "—", $with_time = false ) { |
|
876 | - $date = getpaid_format_date( $date, $with_time ); |
|
877 | - return empty( $date ) ? $default : $date; |
|
875 | +function getpaid_format_date_value($date, $default = "—", $with_time = false) { |
|
876 | + $date = getpaid_format_date($date, $with_time); |
|
877 | + return empty($date) ? $default : $date; |
|
878 | 878 | } |
879 | 879 | |
880 | 880 | /** |
@@ -883,7 +883,7 @@ discard block |
||
883 | 883 | * @return string |
884 | 884 | */ |
885 | 885 | function getpaid_date_format() { |
886 | - return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) ); |
|
886 | + return apply_filters('getpaid_date_format', get_option('date_format')); |
|
887 | 887 | } |
888 | 888 | |
889 | 889 | /** |
@@ -892,7 +892,7 @@ discard block |
||
892 | 892 | * @return string |
893 | 893 | */ |
894 | 894 | function getpaid_time_format() { |
895 | - return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) ); |
|
895 | + return apply_filters('getpaid_time_format', get_option('time_format')); |
|
896 | 896 | } |
897 | 897 | |
898 | 898 | /** |
@@ -902,16 +902,16 @@ discard block |
||
902 | 902 | * @param integer $limit Limit size in characters. |
903 | 903 | * @return string |
904 | 904 | */ |
905 | -function getpaid_limit_length( $string, $limit ) { |
|
905 | +function getpaid_limit_length($string, $limit) { |
|
906 | 906 | $str_limit = $limit - 3; |
907 | 907 | |
908 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
909 | - if ( mb_strlen( $string ) > $limit ) { |
|
910 | - $string = mb_strimwidth( $string, 0, $str_limit ) . '...'; |
|
908 | + if (function_exists('mb_strimwidth')) { |
|
909 | + if (mb_strlen($string) > $limit) { |
|
910 | + $string = mb_strimwidth($string, 0, $str_limit) . '...'; |
|
911 | 911 | } |
912 | 912 | } else { |
913 | - if ( strlen( $string ) > $limit ) { |
|
914 | - $string = substr( $string, 0, $str_limit ) . '...'; |
|
913 | + if (strlen($string) > $limit) { |
|
914 | + $string = substr($string, 0, $str_limit) . '...'; |
|
915 | 915 | } |
916 | 916 | } |
917 | 917 | return $string; |
@@ -925,7 +925,7 @@ discard block |
||
925 | 925 | * @since 1.0.19 |
926 | 926 | */ |
927 | 927 | function getpaid_api() { |
928 | - return getpaid()->get( 'api' ); |
|
928 | + return getpaid()->get('api'); |
|
929 | 929 | } |
930 | 930 | |
931 | 931 | /** |
@@ -935,7 +935,7 @@ discard block |
||
935 | 935 | * @since 1.0.19 |
936 | 936 | */ |
937 | 937 | function getpaid_post_types() { |
938 | - return getpaid()->get( 'post_types' ); |
|
938 | + return getpaid()->get('post_types'); |
|
939 | 939 | } |
940 | 940 | |
941 | 941 | /** |
@@ -945,7 +945,7 @@ discard block |
||
945 | 945 | * @since 1.0.19 |
946 | 946 | */ |
947 | 947 | function getpaid_session() { |
948 | - return getpaid()->get( 'session' ); |
|
948 | + return getpaid()->get('session'); |
|
949 | 949 | } |
950 | 950 | |
951 | 951 | /** |
@@ -955,7 +955,7 @@ discard block |
||
955 | 955 | * @since 1.0.19 |
956 | 956 | */ |
957 | 957 | function getpaid_notes() { |
958 | - return getpaid()->get( 'notes' ); |
|
958 | + return getpaid()->get('notes'); |
|
959 | 959 | } |
960 | 960 | |
961 | 961 | /** |
@@ -964,7 +964,7 @@ discard block |
||
964 | 964 | * @return GetPaid_Admin |
965 | 965 | */ |
966 | 966 | function getpaid_admin() { |
967 | - return getpaid()->get( 'admin' ); |
|
967 | + return getpaid()->get('admin'); |
|
968 | 968 | } |
969 | 969 | |
970 | 970 | /** |
@@ -974,8 +974,8 @@ discard block |
||
974 | 974 | * @param string $base the base url |
975 | 975 | * @return string |
976 | 976 | */ |
977 | -function getpaid_get_authenticated_action_url( $action, $base = false ) { |
|
978 | - return wp_nonce_url( add_query_arg( 'getpaid-action', $action, $base ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
977 | +function getpaid_get_authenticated_action_url($action, $base = false) { |
|
978 | + return wp_nonce_url(add_query_arg('getpaid-action', $action, $base), 'getpaid-nonce', 'getpaid-nonce'); |
|
979 | 979 | } |
980 | 980 | |
981 | 981 | /** |
@@ -983,11 +983,11 @@ discard block |
||
983 | 983 | * |
984 | 984 | * @return string |
985 | 985 | */ |
986 | -function getpaid_get_post_type_label( $post_type, $plural = true ) { |
|
986 | +function getpaid_get_post_type_label($post_type, $plural = true) { |
|
987 | 987 | |
988 | - $post_type = get_post_type_object( $post_type ); |
|
988 | + $post_type = get_post_type_object($post_type); |
|
989 | 989 | |
990 | - if ( ! is_object( $post_type ) ) { |
|
990 | + if (!is_object($post_type)) { |
|
991 | 991 | return null; |
992 | 992 | } |
993 | 993 | |
@@ -1000,18 +1000,18 @@ discard block |
||
1000 | 1000 | * |
1001 | 1001 | * @return mixed|null |
1002 | 1002 | */ |
1003 | -function getpaid_get_array_field( $array, $key, $secondary_key = null ) { |
|
1003 | +function getpaid_get_array_field($array, $key, $secondary_key = null) { |
|
1004 | 1004 | |
1005 | - if ( ! is_array( $array ) ) { |
|
1005 | + if (!is_array($array)) { |
|
1006 | 1006 | return null; |
1007 | 1007 | } |
1008 | 1008 | |
1009 | - if ( ! empty( $secondary_key ) ) { |
|
1010 | - $array = isset( $array[ $secondary_key ] ) ? $array[ $secondary_key ] : array(); |
|
1011 | - return getpaid_get_array_field( $array, $key ); |
|
1009 | + if (!empty($secondary_key)) { |
|
1010 | + $array = isset($array[$secondary_key]) ? $array[$secondary_key] : array(); |
|
1011 | + return getpaid_get_array_field($array, $key); |
|
1012 | 1012 | } |
1013 | 1013 | |
1014 | - return isset( $array[ $key ] ) ? $array[ $key ] : null; |
|
1014 | + return isset($array[$key]) ? $array[$key] : null; |
|
1015 | 1015 | |
1016 | 1016 | } |
1017 | 1017 | |
@@ -1020,12 +1020,12 @@ discard block |
||
1020 | 1020 | * |
1021 | 1021 | * @return array |
1022 | 1022 | */ |
1023 | -function getpaid_array_merge_if_empty( $args, $defaults ) { |
|
1023 | +function getpaid_array_merge_if_empty($args, $defaults) { |
|
1024 | 1024 | |
1025 | - foreach ( $defaults as $key => $value ) { |
|
1025 | + foreach ($defaults as $key => $value) { |
|
1026 | 1026 | |
1027 | - if ( array_key_exists( $key, $args ) && empty( $args[ $key ] ) ) { |
|
1028 | - $args[ $key ] = $value; |
|
1027 | + if (array_key_exists($key, $args) && empty($args[$key])) { |
|
1028 | + $args[$key] = $value; |
|
1029 | 1029 | } |
1030 | 1030 | |
1031 | 1031 | } |
@@ -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,25 +13,25 @@ discard block |
||
13 | 13 | * Hook in tabs. |
14 | 14 | */ |
15 | 15 | public function __construct() { |
16 | - add_action( 'admin_menu', array( $this, 'admin_menu' ), 10 ); |
|
17 | - add_action( 'admin_menu', array( $this, 'add_customers_menu' ), 18 ); |
|
18 | - add_action( 'admin_menu', array( $this, 'add_subscriptions_menu' ), 40 ); |
|
19 | - add_action( 'admin_menu', array( $this, 'add_addons_menu' ), 100 ); |
|
20 | - add_action( 'admin_menu', array( $this, 'add_settings_menu' ), 60 ); |
|
21 | - add_action( 'admin_menu', array( $this, 'remove_admin_submenus' ), 10 ); |
|
22 | - add_action( 'admin_head-nav-menus.php', array( $this, 'add_nav_menu_meta_boxes' ) ); |
|
16 | + add_action('admin_menu', array($this, 'admin_menu'), 10); |
|
17 | + add_action('admin_menu', array($this, 'add_customers_menu'), 18); |
|
18 | + add_action('admin_menu', array($this, 'add_subscriptions_menu'), 40); |
|
19 | + add_action('admin_menu', array($this, 'add_addons_menu'), 100); |
|
20 | + add_action('admin_menu', array($this, 'add_settings_menu'), 60); |
|
21 | + add_action('admin_menu', array($this, 'remove_admin_submenus'), 10); |
|
22 | + add_action('admin_head-nav-menus.php', array($this, 'add_nav_menu_meta_boxes')); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | public function admin_menu() { |
26 | 26 | |
27 | - $capability = apply_filters( 'invoicing_capability', wpinv_get_capability() ); |
|
27 | + $capability = apply_filters('invoicing_capability', wpinv_get_capability()); |
|
28 | 28 | add_menu_page( |
29 | - __( 'GetPaid', 'invoicing' ), |
|
30 | - __( 'GetPaid', 'invoicing' ), |
|
29 | + __('GetPaid', 'invoicing'), |
|
30 | + __('GetPaid', 'invoicing'), |
|
31 | 31 | $capability, |
32 | 32 | 'wpinv', |
33 | 33 | null, |
34 | - 'data:image/svg+xml;base64,' . base64_encode( file_get_contents( WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg' ) ), |
|
34 | + 'data:image/svg+xml;base64,' . base64_encode(file_get_contents(WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg')), |
|
35 | 35 | '54.123460' |
36 | 36 | ); |
37 | 37 | |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | public function add_customers_menu() { |
44 | 44 | add_submenu_page( |
45 | 45 | 'wpinv', |
46 | - __( 'Customers', 'invoicing' ), |
|
47 | - __( 'Customers', 'invoicing' ), |
|
46 | + __('Customers', 'invoicing'), |
|
47 | + __('Customers', 'invoicing'), |
|
48 | 48 | wpinv_get_capability(), |
49 | 49 | 'wpinv-customers', |
50 | - array( $this, 'customers_page' ) |
|
50 | + array($this, 'customers_page') |
|
51 | 51 | ); |
52 | 52 | } |
53 | 53 | |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | public function add_subscriptions_menu() { |
58 | 58 | add_submenu_page( |
59 | 59 | 'wpinv', |
60 | - __( 'Subscriptions', 'invoicing' ), |
|
61 | - __( 'Subscriptions', 'invoicing' ), |
|
60 | + __('Subscriptions', 'invoicing'), |
|
61 | + __('Subscriptions', 'invoicing'), |
|
62 | 62 | wpinv_get_capability(), |
63 | 63 | 'wpinv-subscriptions', |
64 | 64 | 'wpinv_subscriptions_page' |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * Displays the customers page. |
70 | 70 | */ |
71 | 71 | public function customers_page() { |
72 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-customers-table.php' ); |
|
72 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-customers-table.php'); |
|
73 | 73 | ?> |
74 | 74 | <div class="wrap wpi-customers-wrap"> |
75 | 75 | <style> |
@@ -77,12 +77,12 @@ discard block |
||
77 | 77 | width: 30%; |
78 | 78 | } |
79 | 79 | </style> |
80 | - <h1><?php echo esc_html( __( 'Customers', 'invoicing' ) ); ?></h1> |
|
80 | + <h1><?php echo esc_html(__('Customers', 'invoicing')); ?></h1> |
|
81 | 81 | <form method="post"> |
82 | 82 | <?php |
83 | 83 | $table = new WPInv_Customers_Table(); |
84 | 84 | $table->prepare_items(); |
85 | - $table->search_box( __( 'Search Customers', 'invoicing' ), 'search-customers' ); |
|
85 | + $table->search_box(__('Search Customers', 'invoicing'), 'search-customers'); |
|
86 | 86 | $table->display(); |
87 | 87 | ?> |
88 | 88 | </form> |
@@ -96,16 +96,16 @@ discard block |
||
96 | 96 | public function add_settings_menu() { |
97 | 97 | add_submenu_page( |
98 | 98 | 'wpinv', |
99 | - __( 'Invoice Settings', 'invoicing' ), |
|
100 | - __( 'Settings', 'invoicing' ), |
|
101 | - apply_filters( 'invoicing_capability', wpinv_get_capability() ), |
|
99 | + __('Invoice Settings', 'invoicing'), |
|
100 | + __('Settings', 'invoicing'), |
|
101 | + apply_filters('invoicing_capability', wpinv_get_capability()), |
|
102 | 102 | 'wpinv-settings', |
103 | - array( $this, 'options_page' ) |
|
103 | + array($this, 'options_page') |
|
104 | 104 | ); |
105 | 105 | } |
106 | 106 | |
107 | - public function add_addons_menu(){ |
|
108 | - if ( !apply_filters( 'wpi_show_addons_page', true ) ) { |
|
107 | + public function add_addons_menu() { |
|
108 | + if (!apply_filters('wpi_show_addons_page', true)) { |
|
109 | 109 | return; |
110 | 110 | } |
111 | 111 | |
@@ -115,78 +115,78 @@ discard block |
||
115 | 115 | __('Extensions', 'invoicing'), |
116 | 116 | 'manage_options', |
117 | 117 | 'wpi-addons', |
118 | - array( $this, 'addons_page' ) |
|
118 | + array($this, 'addons_page') |
|
119 | 119 | ); |
120 | 120 | } |
121 | 121 | |
122 | - public function addons_page(){ |
|
122 | + public function addons_page() { |
|
123 | 123 | $addon_obj = new WPInv_Admin_Addons(); |
124 | 124 | $addon_obj->output(); |
125 | 125 | } |
126 | 126 | |
127 | 127 | function options_page() { |
128 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
128 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
129 | 129 | |
130 | - if ( $page !== 'wpinv-settings' ) { |
|
130 | + if ($page !== 'wpinv-settings') { |
|
131 | 131 | return; |
132 | 132 | } |
133 | 133 | |
134 | 134 | $settings_tabs = wpinv_get_settings_tabs(); |
135 | 135 | $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs; |
136 | - $active_tab = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general'; |
|
137 | - $sections = wpinv_get_settings_tab_sections( $active_tab ); |
|
136 | + $active_tab = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? sanitize_text_field($_GET['tab']) : 'general'; |
|
137 | + $sections = wpinv_get_settings_tab_sections($active_tab); |
|
138 | 138 | $key = 'main'; |
139 | 139 | |
140 | - if ( is_array( $sections ) ) { |
|
141 | - $key = key( $sections ); |
|
140 | + if (is_array($sections)) { |
|
141 | + $key = key($sections); |
|
142 | 142 | } |
143 | 143 | |
144 | - $registered_sections = wpinv_get_settings_tab_sections( $active_tab ); |
|
145 | - $section = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? $_GET['section'] : $key; |
|
144 | + $registered_sections = wpinv_get_settings_tab_sections($active_tab); |
|
145 | + $section = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? $_GET['section'] : $key; |
|
146 | 146 | ob_start(); |
147 | 147 | ?> |
148 | 148 | <div class="wrap"> |
149 | 149 | <h1 class="nav-tab-wrapper"> |
150 | 150 | <?php |
151 | - foreach( wpinv_get_settings_tabs() as $tab_id => $tab_name ) { |
|
152 | - $tab_url = add_query_arg( array( |
|
151 | + foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) { |
|
152 | + $tab_url = add_query_arg(array( |
|
153 | 153 | 'settings-updated' => false, |
154 | 154 | 'tab' => $tab_id, |
155 | - ) ); |
|
155 | + )); |
|
156 | 156 | |
157 | 157 | // Remove the section from the tabs so we always end up at the main section |
158 | - $tab_url = remove_query_arg( 'section', $tab_url ); |
|
159 | - $tab_url = remove_query_arg( 'wpi_sub', $tab_url ); |
|
158 | + $tab_url = remove_query_arg('section', $tab_url); |
|
159 | + $tab_url = remove_query_arg('wpi_sub', $tab_url); |
|
160 | 160 | |
161 | 161 | $active = $active_tab == $tab_id ? ' nav-tab-active' : ''; |
162 | 162 | |
163 | - echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">'; |
|
164 | - echo esc_html( $tab_name ); |
|
163 | + echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . $active . '">'; |
|
164 | + echo esc_html($tab_name); |
|
165 | 165 | echo '</a>'; |
166 | 166 | } |
167 | 167 | ?> |
168 | 168 | </h1> |
169 | 169 | <?php |
170 | - $number_of_sections = count( $sections ); |
|
170 | + $number_of_sections = count($sections); |
|
171 | 171 | $number = 0; |
172 | - if ( $number_of_sections > 1 ) { |
|
172 | + if ($number_of_sections > 1) { |
|
173 | 173 | echo '<div><ul class="subsubsub">'; |
174 | - foreach( $sections as $section_id => $section_name ) { |
|
174 | + foreach ($sections as $section_id => $section_name) { |
|
175 | 175 | echo '<li>'; |
176 | 176 | $number++; |
177 | - $tab_url = add_query_arg( array( |
|
177 | + $tab_url = add_query_arg(array( |
|
178 | 178 | 'settings-updated' => false, |
179 | 179 | 'tab' => $active_tab, |
180 | 180 | 'section' => $section_id |
181 | - ) ); |
|
182 | - $tab_url = remove_query_arg( 'wpi_sub', $tab_url ); |
|
181 | + )); |
|
182 | + $tab_url = remove_query_arg('wpi_sub', $tab_url); |
|
183 | 183 | $class = ''; |
184 | - if ( $section == $section_id ) { |
|
184 | + if ($section == $section_id) { |
|
185 | 185 | $class = 'current'; |
186 | 186 | } |
187 | - echo '<a class="' . $class . '" href="' . esc_url( $tab_url ) . '">' . $section_name . '</a>'; |
|
187 | + echo '<a class="' . $class . '" href="' . esc_url($tab_url) . '">' . $section_name . '</a>'; |
|
188 | 188 | |
189 | - if ( $number != $number_of_sections ) { |
|
189 | + if ($number != $number_of_sections) { |
|
190 | 190 | echo ' | '; |
191 | 191 | } |
192 | 192 | echo '</li>'; |
@@ -198,20 +198,20 @@ discard block |
||
198 | 198 | <form method="post" action="options.php"> |
199 | 199 | <table class="form-table"> |
200 | 200 | <?php |
201 | - settings_fields( 'wpinv_settings' ); |
|
201 | + settings_fields('wpinv_settings'); |
|
202 | 202 | |
203 | - if ( 'main' === $section ) { |
|
204 | - do_action( 'wpinv_settings_tab_top', $active_tab ); |
|
203 | + if ('main' === $section) { |
|
204 | + do_action('wpinv_settings_tab_top', $active_tab); |
|
205 | 205 | } |
206 | 206 | |
207 | - do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section ); |
|
208 | - do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section ); |
|
209 | - do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section ); |
|
210 | - do_action( 'getpaid_settings_tab_bottom', $active_tab, $section ); |
|
207 | + do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section); |
|
208 | + do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section); |
|
209 | + do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section); |
|
210 | + do_action('getpaid_settings_tab_bottom', $active_tab, $section); |
|
211 | 211 | |
212 | 212 | // For backwards compatibility |
213 | - if ( 'main' === $section ) { |
|
214 | - do_action( 'wpinv_settings_tab_bottom', $active_tab ); |
|
213 | + if ('main' === $section) { |
|
214 | + do_action('wpinv_settings_tab_bottom', $active_tab); |
|
215 | 215 | } |
216 | 216 | ?> |
217 | 217 | </table> |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | } |
226 | 226 | |
227 | 227 | public function remove_admin_submenus() { |
228 | - remove_submenu_page( 'edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice' ); |
|
228 | + remove_submenu_page('edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice'); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | /** |
@@ -235,8 +235,8 @@ discard block |
||
235 | 235 | |
236 | 236 | add_meta_box( |
237 | 237 | 'wpinv_endpoints_nav_link', |
238 | - __( 'GetPaid endpoints', 'invoicing' ), |
|
239 | - array( $this, 'nav_menu_links' ), |
|
238 | + __('GetPaid endpoints', 'invoicing'), |
|
239 | + array($this, 'nav_menu_links'), |
|
240 | 240 | 'nav-menus', |
241 | 241 | 'side', |
242 | 242 | 'low' |
@@ -251,12 +251,12 @@ discard block |
||
251 | 251 | $endpoints = $this->get_menu_items(); |
252 | 252 | ?> |
253 | 253 | <div id="invoicing-endpoints" class="posttypediv"> |
254 | - <?php if ( ! empty( $endpoints['pages'] ) ) : ?> |
|
254 | + <?php if (!empty($endpoints['pages'])) : ?> |
|
255 | 255 | <div id="tabs-panel-invoicing-endpoints" class="tabs-panel tabs-panel-active"> |
256 | 256 | <ul id="invoicing-endpoints-checklist" class="categorychecklist form-no-clear"> |
257 | 257 | <?php |
258 | - $walker = new Walker_Nav_Menu_Checklist( array() ); |
|
259 | - echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $endpoints['pages'] ), 0, (object) array( 'walker' => $walker ) ); |
|
258 | + $walker = new Walker_Nav_Menu_Checklist(array()); |
|
259 | + echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $endpoints['pages']), 0, (object) array('walker' => $walker)); |
|
260 | 260 | ?> |
261 | 261 | </ul> |
262 | 262 | </div> |
@@ -265,11 +265,11 @@ discard block |
||
265 | 265 | <p class="button-controls wp-clearfix" data-items-type="invoicing-endpoints"> |
266 | 266 | <span class="list-controls hide-if-no-js"> |
267 | 267 | <input type="checkbox" id="invoicing-endpoints-tab" class="select-all"> |
268 | - <label for="invoicing-endpoints-tab"><?php _e( 'Select all', 'invoicing' ); ?></label> |
|
268 | + <label for="invoicing-endpoints-tab"><?php _e('Select all', 'invoicing'); ?></label> |
|
269 | 269 | </span> |
270 | 270 | |
271 | 271 | <span class="add-to-menu"> |
272 | - <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"> |
|
272 | + <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"> |
|
273 | 273 | <span class="spinner"></span> |
274 | 274 | </span> |
275 | 275 | </p> |
@@ -282,35 +282,35 @@ discard block |
||
282 | 282 | * |
283 | 283 | * @return array. |
284 | 284 | */ |
285 | - public function get_menu_items(){ |
|
285 | + public function get_menu_items() { |
|
286 | 286 | $items = array(); |
287 | 287 | |
288 | 288 | $pages = array( |
289 | 289 | array( |
290 | - 'id' => wpinv_get_option( 'invoice_history_page' ), |
|
291 | - 'label' => __( 'My Invoices', 'invoicing' ), |
|
290 | + 'id' => wpinv_get_option('invoice_history_page'), |
|
291 | + 'label' => __('My Invoices', 'invoicing'), |
|
292 | 292 | ), |
293 | 293 | array( |
294 | - 'id' => wpinv_get_option( 'invoice_subscription_page' ), |
|
295 | - 'label' => __( 'My Subscriptions', 'invoicing' ), |
|
294 | + 'id' => wpinv_get_option('invoice_subscription_page'), |
|
295 | + 'label' => __('My Subscriptions', 'invoicing'), |
|
296 | 296 | ) |
297 | 297 | ); |
298 | 298 | |
299 | - foreach ( apply_filters( 'getpaid_menu_pages', $pages ) as $page ) { |
|
299 | + foreach (apply_filters('getpaid_menu_pages', $pages) as $page) { |
|
300 | 300 | |
301 | - if ( (int) $page['id'] > 0 ) { |
|
301 | + if ((int) $page['id'] > 0) { |
|
302 | 302 | |
303 | 303 | $item = new stdClass(); |
304 | 304 | $item->object_id = (int) $page['id']; |
305 | 305 | $item->db_id = 0; |
306 | - $item->object = 'page'; |
|
306 | + $item->object = 'page'; |
|
307 | 307 | $item->menu_item_parent = 0; |
308 | 308 | $item->type = 'post_type'; |
309 | - $item->title = sanitize_text_field( $page['label'] ); |
|
310 | - $item->url = get_permalink( (int) $page['id'] ); |
|
309 | + $item->title = sanitize_text_field($page['label']); |
|
310 | + $item->url = get_permalink((int) $page['id']); |
|
311 | 311 | $item->target = ''; |
312 | 312 | $item->attr_title = ''; |
313 | - $item->classes = array( 'wpinv-menu-item' ); |
|
313 | + $item->classes = array('wpinv-menu-item'); |
|
314 | 314 | $item->xfn = ''; |
315 | 315 | |
316 | 316 | $items['pages'][] = $item; |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | |
320 | 320 | } |
321 | 321 | |
322 | - return apply_filters( 'wpinv_menu_items', $items ); |
|
322 | + return apply_filters('wpinv_menu_items', $items); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | $this->state = wpinv_get_default_state(); |
135 | 135 | |
136 | 136 | // Do we have an actual submission? |
137 | - if ( isset( $_POST['getpaid_payment_form_submission'] ) ) { |
|
138 | - $this->load_data( $_POST ); |
|
137 | + if (isset($_POST['getpaid_payment_form_submission'])) { |
|
138 | + $this->load_data($_POST); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | } |
@@ -145,19 +145,19 @@ discard block |
||
145 | 145 | * |
146 | 146 | * @param array $data |
147 | 147 | */ |
148 | - public function load_data( $data ) { |
|
148 | + public function load_data($data) { |
|
149 | 149 | |
150 | 150 | // Remove slashes from the submitted data... |
151 | - $data = wp_unslash( $data ); |
|
151 | + $data = wp_unslash($data); |
|
152 | 152 | |
153 | 153 | // Allow plugins to filter the data. |
154 | - $data = apply_filters( 'getpaid_submission_data', $data, $this ); |
|
154 | + $data = apply_filters('getpaid_submission_data', $data, $this); |
|
155 | 155 | |
156 | 156 | // Cache it... |
157 | 157 | $this->data = $data; |
158 | 158 | |
159 | 159 | // Then generate a unique id from the data. |
160 | - $this->id = md5( wp_json_encode( $data ) ); |
|
160 | + $this->id = md5(wp_json_encode($data)); |
|
161 | 161 | |
162 | 162 | // Finally, process the submission. |
163 | 163 | try { |
@@ -167,26 +167,26 @@ discard block |
||
167 | 167 | $processors = apply_filters( |
168 | 168 | 'getpaid_payment_form_submission_processors', |
169 | 169 | array( |
170 | - array( $this, 'process_payment_form' ), |
|
171 | - array( $this, 'process_invoice' ), |
|
172 | - array( $this, 'process_fees' ), |
|
173 | - array( $this, 'process_items' ), |
|
174 | - array( $this, 'process_discount' ), |
|
175 | - array( $this, 'process_taxes' ), |
|
170 | + array($this, 'process_payment_form'), |
|
171 | + array($this, 'process_invoice'), |
|
172 | + array($this, 'process_fees'), |
|
173 | + array($this, 'process_items'), |
|
174 | + array($this, 'process_discount'), |
|
175 | + array($this, 'process_taxes'), |
|
176 | 176 | ), |
177 | 177 | $this |
178 | 178 | ); |
179 | 179 | |
180 | - foreach ( $processors as $processor ) { |
|
181 | - call_user_func_array( $processor, array( &$this ) ); |
|
180 | + foreach ($processors as $processor) { |
|
181 | + call_user_func_array($processor, array(&$this)); |
|
182 | 182 | } |
183 | 183 | |
184 | - } catch ( Exception $e ) { |
|
184 | + } catch (Exception $e) { |
|
185 | 185 | $this->last_error = $e->getMessage(); |
186 | 186 | } |
187 | 187 | |
188 | 188 | // Fired when we are done processing a submission. |
189 | - do_action_ref_array( 'getpaid_process_submission', array( &$this ) ); |
|
189 | + do_action_ref_array('getpaid_process_submission', array(&$this)); |
|
190 | 190 | |
191 | 191 | } |
192 | 192 | |
@@ -207,18 +207,18 @@ discard block |
||
207 | 207 | public function process_payment_form() { |
208 | 208 | |
209 | 209 | // Every submission needs an active payment form. |
210 | - if ( empty( $this->data['form_id'] ) ) { |
|
211 | - throw new Exception( __( 'Missing payment form', 'invoicing' ) ); |
|
210 | + if (empty($this->data['form_id'])) { |
|
211 | + throw new Exception(__('Missing payment form', 'invoicing')); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | // Fetch the payment form. |
215 | - $this->payment_form = new GetPaid_Payment_Form( $this->data['form_id'] ); |
|
215 | + $this->payment_form = new GetPaid_Payment_Form($this->data['form_id']); |
|
216 | 216 | |
217 | - if ( ! $this->payment_form->is_active() ) { |
|
218 | - throw new Exception( __( 'Payment form not active', 'invoicing' ) ); |
|
217 | + if (!$this->payment_form->is_active()) { |
|
218 | + throw new Exception(__('Payment form not active', 'invoicing')); |
|
219 | 219 | } |
220 | 220 | |
221 | - do_action_ref_array( 'getpaid_submissions_process_payment_form', array( &$this ) ); |
|
221 | + do_action_ref_array('getpaid_submissions_process_payment_form', array(&$this)); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | /** |
@@ -248,30 +248,30 @@ discard block |
||
248 | 248 | public function process_invoice() { |
249 | 249 | |
250 | 250 | // Abort if there is no invoice. |
251 | - if ( empty( $this->data['invoice_id'] ) ) { |
|
251 | + if (empty($this->data['invoice_id'])) { |
|
252 | 252 | return; |
253 | 253 | } |
254 | 254 | |
255 | 255 | // If the submission is for an existing invoice, ensure that it exists |
256 | 256 | // and that it is not paid for. |
257 | - $invoice = wpinv_get_invoice( $this->data['invoice_id'] ); |
|
257 | + $invoice = wpinv_get_invoice($this->data['invoice_id']); |
|
258 | 258 | |
259 | - if ( empty( $invoice ) ) { |
|
260 | - throw new Exception( __( 'Invalid invoice', 'invoicing' ) ); |
|
259 | + if (empty($invoice)) { |
|
260 | + throw new Exception(__('Invalid invoice', 'invoicing')); |
|
261 | 261 | } |
262 | 262 | |
263 | - if ( $invoice->is_paid() ) { |
|
264 | - throw new Exception( __( 'This invoice is already paid for.', 'invoicing' ) ); |
|
263 | + if ($invoice->is_paid()) { |
|
264 | + throw new Exception(__('This invoice is already paid for.', 'invoicing')); |
|
265 | 265 | } |
266 | 266 | |
267 | - $this->payment_form->set_items( $invoice->get_items() ); |
|
267 | + $this->payment_form->set_items($invoice->get_items()); |
|
268 | 268 | $this->payment_form->invoice = $invoice; |
269 | 269 | |
270 | 270 | $this->country = $invoice->get_country(); |
271 | 271 | $this->state = $invoice->get_state(); |
272 | 272 | $this->invoice = $invoice; |
273 | 273 | |
274 | - do_action_ref_array( 'getpaid_submissions_process_invoice', array( &$this ) ); |
|
274 | + do_action_ref_array('getpaid_submissions_process_invoice', array(&$this)); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | /** |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | * @return bool |
292 | 292 | */ |
293 | 293 | public function has_invoice() { |
294 | - return ! empty( $this->invoice ); |
|
294 | + return !empty($this->invoice); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | /* |
@@ -310,13 +310,13 @@ discard block |
||
310 | 310 | */ |
311 | 311 | public function process_items() { |
312 | 312 | |
313 | - $processor = new GetPaid_Payment_Form_Submission_Items( $this ); |
|
313 | + $processor = new GetPaid_Payment_Form_Submission_Items($this); |
|
314 | 314 | |
315 | - foreach ( $processor->items as $item ) { |
|
316 | - $this->add_item( $item ); |
|
315 | + foreach ($processor->items as $item) { |
|
316 | + $this->add_item($item); |
|
317 | 317 | } |
318 | 318 | |
319 | - do_action_ref_array( 'getpaid_submissions_process_items', array( &$this ) ); |
|
319 | + do_action_ref_array('getpaid_submissions_process_items', array(&$this)); |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | /** |
@@ -325,18 +325,18 @@ discard block |
||
325 | 325 | * @since 1.0.19 |
326 | 326 | * @param GetPaid_Form_Item $item |
327 | 327 | */ |
328 | - public function add_item( $item ) { |
|
328 | + public function add_item($item) { |
|
329 | 329 | |
330 | 330 | // Make sure that it is available for purchase. |
331 | - if ( ! $item->can_purchase() || isset( $this->items[ $item->get_id() ] ) ) { |
|
331 | + if (!$item->can_purchase() || isset($this->items[$item->get_id()])) { |
|
332 | 332 | return; |
333 | 333 | } |
334 | 334 | |
335 | 335 | // Each submission can only contain one recurring item. |
336 | - if ( $item->is_recurring() ) { |
|
336 | + if ($item->is_recurring()) { |
|
337 | 337 | |
338 | - if ( $this->has_recurring != 0 ) { |
|
339 | - throw new Exception( __( 'You can only buy one recurring item at a time.', 'invoicing' ) ); |
|
338 | + if ($this->has_recurring != 0) { |
|
339 | + throw new Exception(__('You can only buy one recurring item at a time.', 'invoicing')); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | $this->has_recurring = $item->get_id(); |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | } |
345 | 345 | |
346 | 346 | // Update the items and totals. |
347 | - $this->items[ $item->get_id() ] = $item; |
|
347 | + $this->items[$item->get_id()] = $item; |
|
348 | 348 | $this->totals['subtotal']['initial'] += $item->get_sub_total(); |
349 | 349 | $this->totals['subtotal']['recurring'] += $item->get_recurring_sub_total(); |
350 | 350 | |
@@ -358,17 +358,17 @@ discard block |
||
358 | 358 | * |
359 | 359 | * @since 1.0.19 |
360 | 360 | */ |
361 | - public function remove_item( $item_id ) { |
|
361 | + public function remove_item($item_id) { |
|
362 | 362 | |
363 | - if ( isset( $this->items[ $item_id ] ) ) { |
|
364 | - $this->totals['subtotal']['initial'] -= $this->items[ $item_id ]->get_sub_total(); |
|
365 | - $this->totals['subtotal']['recurring'] -= $this->items[ $item_id ]->get_recurring_sub_total(); |
|
363 | + if (isset($this->items[$item_id])) { |
|
364 | + $this->totals['subtotal']['initial'] -= $this->items[$item_id]->get_sub_total(); |
|
365 | + $this->totals['subtotal']['recurring'] -= $this->items[$item_id]->get_recurring_sub_total(); |
|
366 | 366 | |
367 | - if ( $this->items[ $item_id ]->is_recurring() ) { |
|
367 | + if ($this->items[$item_id]->is_recurring()) { |
|
368 | 368 | $this->has_recurring = 0; |
369 | 369 | } |
370 | 370 | |
371 | - unset( $this->items[ $item_id ] ); |
|
371 | + unset($this->items[$item_id]); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | } |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | */ |
381 | 381 | public function get_subtotal() { |
382 | 382 | |
383 | - if ( wpinv_prices_include_tax() ) { |
|
383 | + if (wpinv_prices_include_tax()) { |
|
384 | 384 | return $this->totals['subtotal']['initial'] - $this->totals['taxes']['initial']; |
385 | 385 | } |
386 | 386 | |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | */ |
395 | 395 | public function get_recurring_subtotal() { |
396 | 396 | |
397 | - if ( wpinv_prices_include_tax() ) { |
|
397 | + if (wpinv_prices_include_tax()) { |
|
398 | 398 | return $this->totals['subtotal']['recurring'] - $this->totals['taxes']['recurring']; |
399 | 399 | } |
400 | 400 | |
@@ -428,39 +428,39 @@ discard block |
||
428 | 428 | public function process_taxes() { |
429 | 429 | |
430 | 430 | // Abort if we're not using taxes. |
431 | - if ( ! $this->use_taxes() ) { |
|
431 | + if (!$this->use_taxes()) { |
|
432 | 432 | return; |
433 | 433 | } |
434 | 434 | |
435 | 435 | // If a custom country && state has been passed in, use it to calculate taxes. |
436 | - $country = $this->get_field( 'wpinv_country', 'billing' ); |
|
437 | - if ( ! empty( $country ) ) { |
|
436 | + $country = $this->get_field('wpinv_country', 'billing'); |
|
437 | + if (!empty($country)) { |
|
438 | 438 | $this->country = $country; |
439 | 439 | } |
440 | 440 | |
441 | - $state = $this->get_field( 'wpinv_state', 'billing' ); |
|
442 | - if ( ! empty( $state ) ) { |
|
441 | + $state = $this->get_field('wpinv_state', 'billing'); |
|
442 | + if (!empty($state)) { |
|
443 | 443 | $this->state = $state; |
444 | 444 | } |
445 | 445 | |
446 | 446 | // Confirm if the provided country and the ip country are similar. |
447 | - $address_confirmed = $this->get_field( 'confirm-address' ); |
|
448 | - if ( wpinv_should_validate_vat_number() && getpaid_get_ip_country() != $this->country && empty( $address_confirmed ) ) { |
|
449 | - throw new Exception( __( 'The country of your current location must be the same as the country of your billing location or you must confirm the billing address is your home country.', 'invoicing' ) ); |
|
447 | + $address_confirmed = $this->get_field('confirm-address'); |
|
448 | + if (wpinv_should_validate_vat_number() && getpaid_get_ip_country() != $this->country && empty($address_confirmed)) { |
|
449 | + throw new Exception(__('The country of your current location must be the same as the country of your billing location or you must confirm the billing address is your home country.', 'invoicing')); |
|
450 | 450 | } |
451 | 451 | |
452 | 452 | // Abort if the country is not taxable. |
453 | - if ( ! wpinv_is_country_taxable( $this->country ) ) { |
|
453 | + if (!wpinv_is_country_taxable($this->country)) { |
|
454 | 454 | return; |
455 | 455 | } |
456 | 456 | |
457 | - $processor = new GetPaid_Payment_Form_Submission_Taxes( $this ); |
|
457 | + $processor = new GetPaid_Payment_Form_Submission_Taxes($this); |
|
458 | 458 | |
459 | - foreach ( $processor->taxes as $tax ) { |
|
460 | - $this->add_tax( $tax ); |
|
459 | + foreach ($processor->taxes as $tax) { |
|
460 | + $this->add_tax($tax); |
|
461 | 461 | } |
462 | 462 | |
463 | - do_action_ref_array( 'getpaid_submissions_process_taxes', array( &$this ) ); |
|
463 | + do_action_ref_array('getpaid_submissions_process_taxes', array(&$this)); |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | /** |
@@ -469,16 +469,16 @@ discard block |
||
469 | 469 | * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required. |
470 | 470 | * @since 1.0.19 |
471 | 471 | */ |
472 | - public function add_tax( $tax ) { |
|
472 | + public function add_tax($tax) { |
|
473 | 473 | |
474 | - if ( wpinv_round_tax_per_tax_rate() ) { |
|
475 | - $tax['initial_tax'] = wpinv_round_amount( $tax['initial_tax'] ); |
|
476 | - $tax['recurring_tax'] = wpinv_round_amount( $tax['recurring_tax'] ); |
|
474 | + if (wpinv_round_tax_per_tax_rate()) { |
|
475 | + $tax['initial_tax'] = wpinv_round_amount($tax['initial_tax']); |
|
476 | + $tax['recurring_tax'] = wpinv_round_amount($tax['recurring_tax']); |
|
477 | 477 | } |
478 | 478 | |
479 | - $this->taxes[ $tax['name'] ] = $tax; |
|
480 | - $this->totals['taxes']['initial'] += wpinv_sanitize_amount( $tax['initial_tax'] ); |
|
481 | - $this->totals['taxes']['recurring'] += wpinv_sanitize_amount( $tax['recurring_tax'] ); |
|
479 | + $this->taxes[$tax['name']] = $tax; |
|
480 | + $this->totals['taxes']['initial'] += wpinv_sanitize_amount($tax['initial_tax']); |
|
481 | + $this->totals['taxes']['recurring'] += wpinv_sanitize_amount($tax['recurring_tax']); |
|
482 | 482 | |
483 | 483 | } |
484 | 484 | |
@@ -487,12 +487,12 @@ discard block |
||
487 | 487 | * |
488 | 488 | * @since 1.0.19 |
489 | 489 | */ |
490 | - public function remove_tax( $tax_name ) { |
|
490 | + public function remove_tax($tax_name) { |
|
491 | 491 | |
492 | - if ( isset( $this->taxes[ $tax_name ] ) ) { |
|
493 | - $this->totals['taxes']['initial'] -= $this->taxes[ $tax_name ]['initial_tax']; |
|
494 | - $this->totals['taxes']['recurring'] -= $this->taxes[ $tax_name ]['recurring_tax']; |
|
495 | - unset( $this->taxes[ $tax_name ] ); |
|
492 | + if (isset($this->taxes[$tax_name])) { |
|
493 | + $this->totals['taxes']['initial'] -= $this->taxes[$tax_name]['initial_tax']; |
|
494 | + $this->totals['taxes']['recurring'] -= $this->taxes[$tax_name]['recurring_tax']; |
|
495 | + unset($this->taxes[$tax_name]); |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | } |
@@ -506,11 +506,11 @@ discard block |
||
506 | 506 | |
507 | 507 | $use_taxes = wpinv_use_taxes(); |
508 | 508 | |
509 | - if ( $this->has_invoice() && ! $this->invoice->is_taxable() ) { |
|
509 | + if ($this->has_invoice() && !$this->invoice->is_taxable()) { |
|
510 | 510 | $use_taxes = false; |
511 | 511 | } |
512 | 512 | |
513 | - return apply_filters( 'getpaid_submission_use_taxes', $use_taxes, $this ); |
|
513 | + return apply_filters('getpaid_submission_use_taxes', $use_taxes, $this); |
|
514 | 514 | |
515 | 515 | } |
516 | 516 | |
@@ -559,13 +559,13 @@ discard block |
||
559 | 559 | |
560 | 560 | $initial_total = $this->get_subtotal() + $this->get_fee() + $this->get_tax(); |
561 | 561 | $recurring_total = $this->get_recurring_subtotal() + $this->get_recurring_fee() + $this->get_recurring_tax(); |
562 | - $processor = new GetPaid_Payment_Form_Submission_Discount( $this, $initial_total, $recurring_total ); |
|
562 | + $processor = new GetPaid_Payment_Form_Submission_Discount($this, $initial_total, $recurring_total); |
|
563 | 563 | |
564 | - foreach ( $processor->discounts as $discount ) { |
|
565 | - $this->add_discount( $discount ); |
|
564 | + foreach ($processor->discounts as $discount) { |
|
565 | + $this->add_discount($discount); |
|
566 | 566 | } |
567 | 567 | |
568 | - do_action_ref_array( 'getpaid_submissions_process_discounts', array( &$this ) ); |
|
568 | + do_action_ref_array('getpaid_submissions_process_discounts', array(&$this)); |
|
569 | 569 | } |
570 | 570 | |
571 | 571 | /** |
@@ -574,10 +574,10 @@ discard block |
||
574 | 574 | * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code. |
575 | 575 | * @since 1.0.19 |
576 | 576 | */ |
577 | - public function add_discount( $discount ) { |
|
578 | - $this->discounts[ $discount['name'] ] = $discount; |
|
579 | - $this->totals['discount']['initial'] += wpinv_sanitize_amount( $discount['initial_discount'] ); |
|
580 | - $this->totals['discount']['recurring'] += wpinv_sanitize_amount( $discount['recurring_discount'] ); |
|
577 | + public function add_discount($discount) { |
|
578 | + $this->discounts[$discount['name']] = $discount; |
|
579 | + $this->totals['discount']['initial'] += wpinv_sanitize_amount($discount['initial_discount']); |
|
580 | + $this->totals['discount']['recurring'] += wpinv_sanitize_amount($discount['recurring_discount']); |
|
581 | 581 | } |
582 | 582 | |
583 | 583 | /** |
@@ -585,12 +585,12 @@ discard block |
||
585 | 585 | * |
586 | 586 | * @since 1.0.19 |
587 | 587 | */ |
588 | - public function remove_discount( $name ) { |
|
588 | + public function remove_discount($name) { |
|
589 | 589 | |
590 | - if ( isset( $this->discounts[ $name ] ) ) { |
|
591 | - $this->totals['discount']['initial'] -= $this->discounts[ $name ]['initial_discount']; |
|
592 | - $this->totals['discount']['recurring'] -= $this->discounts[ $name ]['recurring_discount']; |
|
593 | - unset( $this->discounts[ $name ] ); |
|
590 | + if (isset($this->discounts[$name])) { |
|
591 | + $this->totals['discount']['initial'] -= $this->discounts[$name]['initial_discount']; |
|
592 | + $this->totals['discount']['recurring'] -= $this->discounts[$name]['recurring_discount']; |
|
593 | + unset($this->discounts[$name]); |
|
594 | 594 | } |
595 | 595 | |
596 | 596 | } |
@@ -602,7 +602,7 @@ discard block |
||
602 | 602 | * @return bool |
603 | 603 | */ |
604 | 604 | public function has_discount_code() { |
605 | - return ! empty( $this->discounts['discount_code'] ); |
|
605 | + return !empty($this->discounts['discount_code']); |
|
606 | 606 | } |
607 | 607 | |
608 | 608 | /** |
@@ -659,13 +659,13 @@ discard block |
||
659 | 659 | */ |
660 | 660 | public function process_fees() { |
661 | 661 | |
662 | - $fees_processor = new GetPaid_Payment_Form_Submission_Fees( $this ); |
|
662 | + $fees_processor = new GetPaid_Payment_Form_Submission_Fees($this); |
|
663 | 663 | |
664 | - foreach ( $fees_processor->fees as $fee ) { |
|
665 | - $this->add_fee( $fee ); |
|
664 | + foreach ($fees_processor->fees as $fee) { |
|
665 | + $this->add_fee($fee); |
|
666 | 666 | } |
667 | 667 | |
668 | - do_action_ref_array( 'getpaid_submissions_process_fees', array( &$this ) ); |
|
668 | + do_action_ref_array('getpaid_submissions_process_fees', array(&$this)); |
|
669 | 669 | } |
670 | 670 | |
671 | 671 | /** |
@@ -674,11 +674,11 @@ discard block |
||
674 | 674 | * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required. |
675 | 675 | * @since 1.0.19 |
676 | 676 | */ |
677 | - public function add_fee( $fee ) { |
|
677 | + public function add_fee($fee) { |
|
678 | 678 | |
679 | - $this->fees[ $fee['name'] ] = $fee; |
|
680 | - $this->totals['fees']['initial'] += wpinv_sanitize_amount( $fee['initial_fee'] ); |
|
681 | - $this->totals['fees']['recurring'] += wpinv_sanitize_amount( $fee['recurring_fee'] ); |
|
679 | + $this->fees[$fee['name']] = $fee; |
|
680 | + $this->totals['fees']['initial'] += wpinv_sanitize_amount($fee['initial_fee']); |
|
681 | + $this->totals['fees']['recurring'] += wpinv_sanitize_amount($fee['recurring_fee']); |
|
682 | 682 | |
683 | 683 | } |
684 | 684 | |
@@ -687,12 +687,12 @@ discard block |
||
687 | 687 | * |
688 | 688 | * @since 1.0.19 |
689 | 689 | */ |
690 | - public function remove_fee( $name ) { |
|
690 | + public function remove_fee($name) { |
|
691 | 691 | |
692 | - if ( isset( $this->fees[ $name ] ) ) { |
|
693 | - $this->totals['fees']['initial'] -= $this->fees[ $name ]['initial_fee']; |
|
694 | - $this->totals['fees']['recurring'] -= $this->fees[ $name ]['recurring_fee']; |
|
695 | - unset( $this->fees[ $name ] ); |
|
692 | + if (isset($this->fees[$name])) { |
|
693 | + $this->totals['fees']['initial'] -= $this->fees[$name]['initial_fee']; |
|
694 | + $this->totals['fees']['recurring'] -= $this->fees[$name]['recurring_fee']; |
|
695 | + unset($this->fees[$name]); |
|
696 | 696 | } |
697 | 697 | |
698 | 698 | } |
@@ -731,7 +731,7 @@ discard block |
||
731 | 731 | * @since 1.0.19 |
732 | 732 | */ |
733 | 733 | public function has_fees() { |
734 | - return count( $this->fees ) !== 0; |
|
734 | + return count($this->fees) !== 0; |
|
735 | 735 | } |
736 | 736 | |
737 | 737 | /* |
@@ -749,7 +749,7 @@ discard block |
||
749 | 749 | * @since 1.0.19 |
750 | 750 | */ |
751 | 751 | public function is_initial_fetch() { |
752 | - return empty( $this->data['initial_state'] ); |
|
752 | + return empty($this->data['initial_state']); |
|
753 | 753 | } |
754 | 754 | |
755 | 755 | /** |
@@ -759,7 +759,7 @@ discard block |
||
759 | 759 | */ |
760 | 760 | public function get_total() { |
761 | 761 | $total = $this->get_subtotal() + $this->get_fee() + $this->get_tax() - $this->get_discount(); |
762 | - return max( $total, 0 ); |
|
762 | + return max($total, 0); |
|
763 | 763 | } |
764 | 764 | |
765 | 765 | /** |
@@ -769,7 +769,7 @@ discard block |
||
769 | 769 | */ |
770 | 770 | public function get_recurring_total() { |
771 | 771 | $total = $this->get_recurring_subtotal() + $this->get_recurring_fee() + $this->get_recurring_tax() - $this->get_recurring_discount(); |
772 | - return max( $total, 0 ); |
|
772 | + return max($total, 0); |
|
773 | 773 | } |
774 | 774 | |
775 | 775 | /** |
@@ -781,12 +781,12 @@ discard block |
||
781 | 781 | $initial = $this->get_total(); |
782 | 782 | $recurring = $this->get_recurring_total(); |
783 | 783 | |
784 | - if ( $this->has_recurring == 0 ) { |
|
784 | + if ($this->has_recurring == 0) { |
|
785 | 785 | $recurring = 0; |
786 | 786 | } |
787 | 787 | |
788 | 788 | $collect = $initial > 0 || $recurring > 0; |
789 | - return apply_filters( 'getpaid_submission_should_collect_payment_details', $collect, $this ); |
|
789 | + return apply_filters('getpaid_submission_should_collect_payment_details', $collect, $this); |
|
790 | 790 | } |
791 | 791 | |
792 | 792 | /** |
@@ -795,7 +795,7 @@ discard block |
||
795 | 795 | * @since 1.0.19 |
796 | 796 | */ |
797 | 797 | public function get_billing_email() { |
798 | - return apply_filters( 'getpaid_get_submission_billing_email', $this->get_field( 'billing_email' ), $this ); |
|
798 | + return apply_filters('getpaid_get_submission_billing_email', $this->get_field('billing_email'), $this); |
|
799 | 799 | } |
800 | 800 | |
801 | 801 | /** |
@@ -805,7 +805,7 @@ discard block |
||
805 | 805 | */ |
806 | 806 | public function has_billing_email() { |
807 | 807 | $billing_email = $this->get_billing_email(); |
808 | - return ! empty( $billing_email ) && is_email( $billing_email ); |
|
808 | + return !empty($billing_email) && is_email($billing_email); |
|
809 | 809 | } |
810 | 810 | |
811 | 811 | /** |
@@ -835,8 +835,8 @@ discard block |
||
835 | 835 | * @since 1.0.19 |
836 | 836 | * @return mixed|null |
837 | 837 | */ |
838 | - public function get_field( $field, $sub_array_key = null ) { |
|
839 | - return getpaid_get_array_field( $this->data, $field, $sub_array_key ); |
|
838 | + public function get_field($field, $sub_array_key = null) { |
|
839 | + return getpaid_get_array_field($this->data, $field, $sub_array_key); |
|
840 | 840 | } |
841 | 841 | |
842 | 842 | /** |
@@ -844,8 +844,8 @@ discard block |
||
844 | 844 | * |
845 | 845 | * @since 1.0.19 |
846 | 846 | */ |
847 | - public function is_required_field_set( $field ) { |
|
848 | - return empty( $field['required'] ) || ! empty( $this->data[ $field['id'] ] ); |
|
847 | + public function is_required_field_set($field) { |
|
848 | + return empty($field['required']) || !empty($this->data[$field['id']]); |
|
849 | 849 | } |
850 | 850 | |
851 | 851 | /** |
@@ -853,8 +853,8 @@ discard block |
||
853 | 853 | * |
854 | 854 | * @since 1.0.19 |
855 | 855 | */ |
856 | - public function format_amount( $amount ) { |
|
857 | - return wpinv_price( $amount, $this->get_currency() ); |
|
856 | + public function format_amount($amount) { |
|
857 | + return wpinv_price($amount, $this->get_currency()); |
|
858 | 858 | } |
859 | 859 | |
860 | 860 | } |
@@ -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 | * Bank transfer Payment Gateway class. |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @var array |
26 | 26 | */ |
27 | - protected $supports = array( 'addons' ); |
|
27 | + protected $supports = array('addons'); |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * Payment method order. |
@@ -39,15 +39,15 @@ discard block |
||
39 | 39 | public function __construct() { |
40 | 40 | parent::__construct(); |
41 | 41 | |
42 | - $this->title = __( 'Direct bank transfer', 'invoicing' ); |
|
43 | - $this->method_title = __( 'Bank transfer', 'invoicing' ); |
|
44 | - $this->checkout_button_text = __( 'Proceed', 'invoicing' ); |
|
45 | - $this->instructions = apply_filters( 'wpinv_bank_instructions', $this->get_option( 'info' ) ); |
|
42 | + $this->title = __('Direct bank transfer', 'invoicing'); |
|
43 | + $this->method_title = __('Bank transfer', 'invoicing'); |
|
44 | + $this->checkout_button_text = __('Proceed', 'invoicing'); |
|
45 | + $this->instructions = apply_filters('wpinv_bank_instructions', $this->get_option('info')); |
|
46 | 46 | |
47 | - add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) ); |
|
48 | - add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 ); |
|
49 | - add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 ); |
|
50 | - add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 ); |
|
47 | + add_action('wpinv_receipt_end', array($this, 'thankyou_page')); |
|
48 | + add_action('getpaid_invoice_line_items', array($this, 'thankyou_page'), 40); |
|
49 | + add_action('wpinv_pdf_content_billing', array($this, 'thankyou_page'), 11); |
|
50 | + add_action('wpinv_email_invoice_details', array($this, 'email_instructions'), 10, 3); |
|
51 | 51 | |
52 | 52 | } |
53 | 53 | |
@@ -60,23 +60,23 @@ discard block |
||
60 | 60 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
61 | 61 | * @return array |
62 | 62 | */ |
63 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
63 | + public function process_payment($invoice, $submission_data, $submission) { |
|
64 | 64 | |
65 | 65 | // Add a transaction id. |
66 | - $invoice->set_transaction_id( $invoice->generate_key('trans_') ); |
|
66 | + $invoice->set_transaction_id($invoice->generate_key('trans_')); |
|
67 | 67 | |
68 | 68 | // Set it as pending payment. |
69 | - if ( ! $invoice->needs_payment() ) { |
|
69 | + if (!$invoice->needs_payment()) { |
|
70 | 70 | $invoice->mark_paid(); |
71 | - } else if ( ! $invoice->is_paid() ) { |
|
72 | - $invoice->set_status( 'wpi-onhold' ); |
|
71 | + } else if (!$invoice->is_paid()) { |
|
72 | + $invoice->set_status('wpi-onhold'); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | // Save it. |
76 | 76 | $invoice->save(); |
77 | 77 | |
78 | 78 | // Send to the success page. |
79 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
79 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
80 | 80 | |
81 | 81 | } |
82 | 82 | |
@@ -85,17 +85,17 @@ discard block |
||
85 | 85 | * |
86 | 86 | * @param WPInv_Invoice $invoice Invoice. |
87 | 87 | */ |
88 | - public function thankyou_page( $invoice ) { |
|
88 | + public function thankyou_page($invoice) { |
|
89 | 89 | |
90 | - if ( 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) { |
|
90 | + if ('bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment()) { |
|
91 | 91 | |
92 | 92 | echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL; |
93 | 93 | |
94 | - if ( ! empty( $this->instructions ) ) { |
|
95 | - echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) ); |
|
94 | + if (!empty($this->instructions)) { |
|
95 | + echo wp_kses_post(wpautop(wptexturize($this->instructions))); |
|
96 | 96 | } |
97 | 97 | |
98 | - $this->bank_details( $invoice ); |
|
98 | + $this->bank_details($invoice); |
|
99 | 99 | |
100 | 100 | echo '</div>'; |
101 | 101 | |
@@ -110,17 +110,17 @@ discard block |
||
110 | 110 | * @param string $email_type Email format: plain text or HTML. |
111 | 111 | * @param bool $sent_to_admin Sent to admin. |
112 | 112 | */ |
113 | - public function email_instructions( $invoice, $email_type, $sent_to_admin ) { |
|
113 | + public function email_instructions($invoice, $email_type, $sent_to_admin) { |
|
114 | 114 | |
115 | - if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) { |
|
115 | + if (!$sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment()) { |
|
116 | 116 | |
117 | 117 | echo '<div class="wpi-email-row getpaid-bank-transfer-details">'; |
118 | 118 | |
119 | - if ( $this->instructions ) { |
|
120 | - echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL ); |
|
119 | + if ($this->instructions) { |
|
120 | + echo wp_kses_post(wpautop(wptexturize($this->instructions)) . PHP_EOL); |
|
121 | 121 | } |
122 | 122 | |
123 | - $this->bank_details( $invoice ); |
|
123 | + $this->bank_details($invoice); |
|
124 | 124 | |
125 | 125 | echo '</div>'; |
126 | 126 | |
@@ -133,51 +133,51 @@ discard block |
||
133 | 133 | * |
134 | 134 | * @param WPInv_Invoice $invoice Invoice. |
135 | 135 | */ |
136 | - protected function bank_details( $invoice ) { |
|
136 | + protected function bank_details($invoice) { |
|
137 | 137 | |
138 | 138 | // Get the invoice country and country $locale. |
139 | 139 | $country = $invoice->get_country(); |
140 | 140 | $locale = $this->get_country_locale(); |
141 | 141 | |
142 | 142 | // Get sortcode label in the $locale array and use appropriate one. |
143 | - $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' ); |
|
143 | + $sortcode = isset($locale[$country]['sortcode']['label']) ? $locale[$country]['sortcode']['label'] : __('Sort code', 'invoicing'); |
|
144 | 144 | |
145 | 145 | $bank_fields = array( |
146 | - 'ac_name' => __( 'Account Name', 'invoicing' ), |
|
147 | - 'ac_no' => __( 'Account Number', 'invoicing' ), |
|
148 | - 'bank_name' => __( 'Bank Name', 'invoicing' ), |
|
149 | - 'ifsc' => __( 'IFSC code', 'invoicing' ), |
|
150 | - 'iban' => __( 'IBAN', 'invoicing' ), |
|
151 | - 'bic' => __( 'BIC/Swift code', 'invoicing' ), |
|
146 | + 'ac_name' => __('Account Name', 'invoicing'), |
|
147 | + 'ac_no' => __('Account Number', 'invoicing'), |
|
148 | + 'bank_name' => __('Bank Name', 'invoicing'), |
|
149 | + 'ifsc' => __('IFSC code', 'invoicing'), |
|
150 | + 'iban' => __('IBAN', 'invoicing'), |
|
151 | + 'bic' => __('BIC/Swift code', 'invoicing'), |
|
152 | 152 | 'sort_code' => $sortcode, |
153 | 153 | ); |
154 | 154 | |
155 | 155 | $bank_info = array(); |
156 | 156 | |
157 | - foreach ( $bank_fields as $field => $label ) { |
|
158 | - $value = $this->get_option( $field ); |
|
157 | + foreach ($bank_fields as $field => $label) { |
|
158 | + $value = $this->get_option($field); |
|
159 | 159 | |
160 | - if ( ! empty( $value ) ) { |
|
161 | - $bank_info[$field] = array( 'label' => $label, 'value' => $value ); |
|
160 | + if (!empty($value)) { |
|
161 | + $bank_info[$field] = array('label' => $label, 'value' => $value); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | } |
165 | 165 | |
166 | - $bank_info = apply_filters( 'wpinv_bank_info', $bank_info ); |
|
166 | + $bank_info = apply_filters('wpinv_bank_info', $bank_info); |
|
167 | 167 | |
168 | - if ( empty( $bank_info ) ) { |
|
168 | + if (empty($bank_info)) { |
|
169 | 169 | return; |
170 | 170 | } |
171 | 171 | |
172 | - echo '<h3 class="getpaid-bank-transfer-title"> ' . apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ) ) . '</h3>' . PHP_EOL; |
|
172 | + echo '<h3 class="getpaid-bank-transfer-title"> ' . apply_filters('wpinv_receipt_bank_details_title', __('Bank Details', 'invoicing')) . '</h3>' . PHP_EOL; |
|
173 | 173 | |
174 | 174 | echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL; |
175 | 175 | |
176 | - foreach ( $bank_info as $key => $data ) { |
|
176 | + foreach ($bank_info as $key => $data) { |
|
177 | 177 | |
178 | - $key = sanitize_html_class( $key ); |
|
179 | - $label = wp_kses_post( $data['label'] ); |
|
180 | - $value = wp_kses_post( wptexturize( $data['value'] ) ); |
|
178 | + $key = sanitize_html_class($key); |
|
179 | + $label = wp_kses_post($data['label']); |
|
180 | + $value = wp_kses_post(wptexturize($data['value'])); |
|
181 | 181 | |
182 | 182 | echo "<tr class='getpaid-bank-transfer-$key'><th class='font-weight-bold'>$label</th><td class='w-75'>$value</td></tr>" . PHP_EOL; |
183 | 183 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | */ |
194 | 194 | public function get_country_locale() { |
195 | 195 | |
196 | - if ( empty( $this->locale ) ) { |
|
196 | + if (empty($this->locale)) { |
|
197 | 197 | |
198 | 198 | // Locale information to be used - only those that are not 'Sort Code'. |
199 | 199 | $this->locale = apply_filters( |
@@ -201,42 +201,42 @@ discard block |
||
201 | 201 | array( |
202 | 202 | 'AU' => array( |
203 | 203 | 'sortcode' => array( |
204 | - 'label' => __( 'BSB', 'invoicing' ), |
|
204 | + 'label' => __('BSB', 'invoicing'), |
|
205 | 205 | ), |
206 | 206 | ), |
207 | 207 | 'CA' => array( |
208 | 208 | 'sortcode' => array( |
209 | - 'label' => __( 'Bank transit number', 'invoicing' ), |
|
209 | + 'label' => __('Bank transit number', 'invoicing'), |
|
210 | 210 | ), |
211 | 211 | ), |
212 | 212 | 'IN' => array( |
213 | 213 | 'sortcode' => array( |
214 | - 'label' => __( 'IFSC', 'invoicing' ), |
|
214 | + 'label' => __('IFSC', 'invoicing'), |
|
215 | 215 | ), |
216 | 216 | ), |
217 | 217 | 'IT' => array( |
218 | 218 | 'sortcode' => array( |
219 | - 'label' => __( 'Branch sort', 'invoicing' ), |
|
219 | + 'label' => __('Branch sort', 'invoicing'), |
|
220 | 220 | ), |
221 | 221 | ), |
222 | 222 | 'NZ' => array( |
223 | 223 | 'sortcode' => array( |
224 | - 'label' => __( 'Bank code', 'invoicing' ), |
|
224 | + 'label' => __('Bank code', 'invoicing'), |
|
225 | 225 | ), |
226 | 226 | ), |
227 | 227 | 'SE' => array( |
228 | 228 | 'sortcode' => array( |
229 | - 'label' => __( 'Bank code', 'invoicing' ), |
|
229 | + 'label' => __('Bank code', 'invoicing'), |
|
230 | 230 | ), |
231 | 231 | ), |
232 | 232 | 'US' => array( |
233 | 233 | 'sortcode' => array( |
234 | - 'label' => __( 'Routing number', 'invoicing' ), |
|
234 | + 'label' => __('Routing number', 'invoicing'), |
|
235 | 235 | ), |
236 | 236 | ), |
237 | 237 | 'ZA' => array( |
238 | 238 | 'sortcode' => array( |
239 | - 'label' => __( 'Branch code', 'invoicing' ), |
|
239 | + 'label' => __('Branch code', 'invoicing'), |
|
240 | 240 | ), |
241 | 241 | ), |
242 | 242 | ) |
@@ -253,51 +253,51 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @param array $admin_settings |
255 | 255 | */ |
256 | - public function admin_settings( $admin_settings ) { |
|
256 | + public function admin_settings($admin_settings) { |
|
257 | 257 | |
258 | - $admin_settings['bank_transfer_desc']['std'] = __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' ); |
|
259 | - $admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' ); |
|
258 | + $admin_settings['bank_transfer_desc']['std'] = __("Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing'); |
|
259 | + $admin_settings['bank_transfer_active']['desc'] = __('Enable bank transfer', 'invoicing'); |
|
260 | 260 | |
261 | - $locale = $this->get_country_locale(); |
|
261 | + $locale = $this->get_country_locale(); |
|
262 | 262 | |
263 | 263 | // Get sortcode label in the $locale array and use appropriate one. |
264 | 264 | $country = wpinv_default_billing_country(); |
265 | - $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' ); |
|
265 | + $sortcode = isset($locale[$country]['sortcode']['label']) ? $locale[$country]['sortcode']['label'] : __('Sort code', 'invoicing'); |
|
266 | 266 | |
267 | 267 | $admin_settings['bank_transfer_ac_name'] = array( |
268 | 268 | 'type' => 'text', |
269 | 269 | 'id' => 'bank_transfer_ac_name', |
270 | - 'name' => __( 'Account Name', 'invoicing' ), |
|
270 | + 'name' => __('Account Name', 'invoicing'), |
|
271 | 271 | ); |
272 | 272 | |
273 | 273 | $admin_settings['bank_transfer_ac_no'] = array( |
274 | 274 | 'type' => 'text', |
275 | 275 | 'id' => 'bank_transfer_ac_no', |
276 | - 'name' => __( 'Account Number', 'invoicing' ), |
|
276 | + 'name' => __('Account Number', 'invoicing'), |
|
277 | 277 | ); |
278 | 278 | |
279 | 279 | $admin_settings['bank_transfer_bank_name'] = array( |
280 | 280 | 'type' => 'text', |
281 | 281 | 'id' => 'bank_transfer_bank_name', |
282 | - 'name' => __( 'Bank Name', 'invoicing' ), |
|
282 | + 'name' => __('Bank Name', 'invoicing'), |
|
283 | 283 | ); |
284 | 284 | |
285 | 285 | $admin_settings['bank_transfer_ifsc'] = array( |
286 | 286 | 'type' => 'text', |
287 | 287 | 'id' => 'bank_transfer_ifsc', |
288 | - 'name' => __( 'IFSC Code', 'invoicing' ), |
|
288 | + 'name' => __('IFSC Code', 'invoicing'), |
|
289 | 289 | ); |
290 | 290 | |
291 | 291 | $admin_settings['bank_transfer_iban'] = array( |
292 | 292 | 'type' => 'text', |
293 | 293 | 'id' => 'bank_transfer_iban', |
294 | - 'name' => __( 'IBAN', 'invoicing' ), |
|
294 | + 'name' => __('IBAN', 'invoicing'), |
|
295 | 295 | ); |
296 | 296 | |
297 | 297 | $admin_settings['bank_transfer_bic'] = array( |
298 | 298 | 'type' => 'text', |
299 | 299 | 'id' => 'bank_transfer_bic', |
300 | - 'name' => __( 'BIC/Swift Code', 'invoicing' ), |
|
300 | + 'name' => __('BIC/Swift Code', 'invoicing'), |
|
301 | 301 | ); |
302 | 302 | |
303 | 303 | $admin_settings['bank_transfer_sort_code'] = array( |
@@ -308,10 +308,10 @@ discard block |
||
308 | 308 | |
309 | 309 | $admin_settings['bank_transfer_info'] = array( |
310 | 310 | 'id' => 'bank_transfer_info', |
311 | - 'name' => __( 'Instructions', 'invoicing' ), |
|
312 | - 'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ), |
|
311 | + 'name' => __('Instructions', 'invoicing'), |
|
312 | + 'desc' => __('Instructions that will be added to the thank you page and emails.', 'invoicing'), |
|
313 | 313 | 'type' => 'textarea', |
314 | - 'std' => __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' ), |
|
314 | + 'std' => __("Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing'), |
|
315 | 315 | 'cols' => 50, |
316 | 316 | 'rows' => 5 |
317 | 317 | ); |
@@ -326,10 +326,10 @@ discard block |
||
326 | 326 | * @param GetPaid_Form_Item[] $items |
327 | 327 | * @return WPInv_Invoice |
328 | 328 | */ |
329 | - public function process_addons( $invoice, $items ) { |
|
329 | + public function process_addons($invoice, $items) { |
|
330 | 330 | |
331 | - foreach ( $items as $item ) { |
|
332 | - $invoice->add_item( $item ); |
|
331 | + foreach ($items as $item) { |
|
332 | + $invoice->add_item($item); |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | $invoice->recalculate_total(); |
@@ -7,50 +7,50 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | -$class = ! is_singular( 'page' ) ? 'px-1' : ''; |
|
12 | +$class = !is_singular('page') ? 'px-1' : ''; |
|
13 | 13 | ?> |
14 | 14 | |
15 | - <?php do_action( 'getpaid_before_invoice_meta', $invoice ); ?> |
|
15 | + <?php do_action('getpaid_before_invoice_meta', $invoice); ?> |
|
16 | 16 | <div class="getpaid-invoice-meta-data"> |
17 | 17 | |
18 | - <?php do_action( 'getpaid_before_invoice_meta_table', $invoice ); ?> |
|
18 | + <?php do_action('getpaid_before_invoice_meta_table', $invoice); ?> |
|
19 | 19 | <table class="table table-bordered"> |
20 | 20 | <tbody> |
21 | 21 | |
22 | - <?php do_action( "getpaid_before_invoice_meta_rows", $invoice ); ?> |
|
23 | - <?php foreach ( $meta as $key => $data ) : ?> |
|
22 | + <?php do_action("getpaid_before_invoice_meta_rows", $invoice); ?> |
|
23 | + <?php foreach ($meta as $key => $data) : ?> |
|
24 | 24 | |
25 | - <?php if ( ! empty( $data['value'] ) ) : ?> |
|
25 | + <?php if (!empty($data['value'])) : ?> |
|
26 | 26 | |
27 | - <?php do_action( "getpaid_before_invoice_meta_$key", $invoice, $data ); ?> |
|
27 | + <?php do_action("getpaid_before_invoice_meta_$key", $invoice, $data); ?> |
|
28 | 28 | |
29 | - <tr class="getpaid-invoice-meta-<?php echo sanitize_html_class( $key ); ?>"> |
|
29 | + <tr class="getpaid-invoice-meta-<?php echo sanitize_html_class($key); ?>"> |
|
30 | 30 | |
31 | 31 | <th class="<?php echo $class; ?> font-weight-bold"> |
32 | - <?php echo sanitize_text_field( $data['label'] ); ?> |
|
32 | + <?php echo sanitize_text_field($data['label']); ?> |
|
33 | 33 | </th> |
34 | 34 | |
35 | 35 | <td class="<?php echo $class; ?> <?php echo $key == 'invoice_total' ? 'font-weight-bold' : 'font-weight-normal'; ?> text-break w-75"> |
36 | - <span class="getpaid-invoice-meta-<?php echo sanitize_html_class( $key ); ?>-value"><?php echo wp_kses_post( $data['value'] ); ?></span> |
|
36 | + <span class="getpaid-invoice-meta-<?php echo sanitize_html_class($key); ?>-value"><?php echo wp_kses_post($data['value']); ?></span> |
|
37 | 37 | </td> |
38 | 38 | |
39 | 39 | </tr> |
40 | 40 | |
41 | - <?php do_action( "getpaid_after_invoice_meta_$key", $invoice, $data ); ?> |
|
41 | + <?php do_action("getpaid_after_invoice_meta_$key", $invoice, $data); ?> |
|
42 | 42 | |
43 | 43 | <?php endif; ?> |
44 | 44 | |
45 | 45 | <?php endforeach; ?> |
46 | - <?php do_action( "getpaid_after_invoice_meta_rows", $invoice ); ?> |
|
46 | + <?php do_action("getpaid_after_invoice_meta_rows", $invoice); ?> |
|
47 | 47 | |
48 | 48 | </tbody> |
49 | 49 | </table> |
50 | - <?php do_action( 'getpaid_after_invoice_meta_table', $invoice ); ?> |
|
50 | + <?php do_action('getpaid_after_invoice_meta_table', $invoice); ?> |
|
51 | 51 | |
52 | 52 | |
53 | 53 | </div> |
54 | - <?php do_action( 'getpaid_after_invoice_meta', $invoice ); ?> |
|
54 | + <?php do_action('getpaid_after_invoice_meta', $invoice); ?> |
|
55 | 55 | |
56 | 56 | <?php |
@@ -7,7 +7,7 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 |