@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Contains functions that display the subscriptions admin page. |
4 | 4 | */ |
5 | 5 | |
6 | -defined( 'ABSPATH' ) || exit; |
|
6 | +defined('ABSPATH') || exit; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * Render the Subscriptions page |
@@ -17,22 +17,22 @@ discard block |
||
17 | 17 | ?> |
18 | 18 | |
19 | 19 | <div class="wrap"> |
20 | - <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> |
|
20 | + <h1><?php echo esc_html(get_admin_page_title()); ?></h1> |
|
21 | 21 | <div class="bsui"> |
22 | 22 | |
23 | 23 | <?php |
24 | 24 | |
25 | 25 | // Verify user permissions. |
26 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
26 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
27 | 27 | |
28 | 28 | echo aui()->alert( |
29 | 29 | array( |
30 | 30 | 'type' => 'danger', |
31 | - 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
31 | + 'content' => __('You are not permitted to view this page.', 'invoicing'), |
|
32 | 32 | ) |
33 | 33 | ); |
34 | 34 | |
35 | - } else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
35 | + } else if (!empty($_GET['id']) && is_numeric($_GET['id'])) { |
|
36 | 36 | |
37 | 37 | // Display a single subscription. |
38 | 38 | wpinv_recurring_subscription_details(); |
@@ -81,13 +81,13 @@ discard block |
||
81 | 81 | function wpinv_recurring_subscription_details() { |
82 | 82 | |
83 | 83 | // Fetch the subscription. |
84 | - $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
85 | - if ( ! $sub->exists() ) { |
|
84 | + $sub = new WPInv_Subscription((int) $_GET['id']); |
|
85 | + if (!$sub->exists()) { |
|
86 | 86 | |
87 | 87 | echo aui()->alert( |
88 | 88 | array( |
89 | 89 | 'type' => 'danger', |
90 | - 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
90 | + 'content' => __('Subscription not found.', 'invoicing'), |
|
91 | 91 | ) |
92 | 92 | ); |
93 | 93 | |
@@ -95,45 +95,45 @@ discard block |
||
95 | 95 | } |
96 | 96 | |
97 | 97 | // Use metaboxes to display the subscription details. |
98 | - add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
99 | - add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
98 | + add_meta_box('getpaid_admin_subscription_details_metabox', __('Subscription Details', 'invoicing'), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high'); |
|
99 | + add_meta_box('getpaid_admin_subscription_update_metabox', __('Change Status', 'invoicing'), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side'); |
|
100 | 100 | |
101 | 101 | $subscription_id = $sub->get_id(); |
102 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
103 | - $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
102 | + $subscription_groups = getpaid_get_invoice_subscription_groups($sub->get_parent_invoice_id()); |
|
103 | + $subscription_group = wp_list_filter($subscription_groups, compact('subscription_id')); |
|
104 | 104 | |
105 | - if ( 1 < count( $subscription_groups ) ) { |
|
106 | - add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
105 | + if (1 < count($subscription_groups)) { |
|
106 | + add_meta_box('getpaid_admin_subscription_related_subscriptions_metabox', __('Related Subscriptions', 'invoicing'), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced'); |
|
107 | 107 | } |
108 | 108 | |
109 | - if ( ! empty( $subscription_group ) ) { |
|
110 | - add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
109 | + if (!empty($subscription_group)) { |
|
110 | + add_meta_box('getpaid_admin_subscription_item_details_metabox', __('Subscription Items', 'invoicing'), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low'); |
|
111 | 111 | } |
112 | 112 | |
113 | - add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
113 | + add_meta_box('getpaid_admin_subscription_invoice_details_metabox', __('Related Invoices', 'invoicing'), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced'); |
|
114 | 114 | |
115 | - do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
115 | + do_action('getpaid_admin_single_subscription_register_metabox', $sub); |
|
116 | 116 | |
117 | 117 | ?> |
118 | 118 | |
119 | - <form method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ); ?>"> |
|
119 | + <form method="post" action="<?php echo admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($sub->get_id())); ?>"> |
|
120 | 120 | |
121 | - <?php wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); ?> |
|
122 | - <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> |
|
123 | - <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> |
|
121 | + <?php wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); ?> |
|
122 | + <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?> |
|
123 | + <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?> |
|
124 | 124 | <input type="hidden" name="getpaid-admin-action" value="update_single_subscription" /> |
125 | - <input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id() ;?>" /> |
|
125 | + <input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id(); ?>" /> |
|
126 | 126 | |
127 | 127 | <div id="poststuff"> |
128 | 128 | <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>"> |
129 | 129 | |
130 | 130 | <div id="postbox-container-1" class="postbox-container"> |
131 | - <?php do_meta_boxes( get_current_screen(), 'side', $sub ); ?> |
|
131 | + <?php do_meta_boxes(get_current_screen(), 'side', $sub); ?> |
|
132 | 132 | </div> |
133 | 133 | |
134 | 134 | <div id="postbox-container-2" class="postbox-container"> |
135 | - <?php do_meta_boxes( get_current_screen(), 'normal', $sub ); ?> |
|
136 | - <?php do_meta_boxes( get_current_screen(), 'advanced', $sub ); ?> |
|
135 | + <?php do_meta_boxes(get_current_screen(), 'normal', $sub); ?> |
|
136 | + <?php do_meta_boxes(get_current_screen(), 'advanced', $sub); ?> |
|
137 | 137 | </div> |
138 | 138 | |
139 | 139 | </div> |
@@ -152,44 +152,44 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @param WPInv_Subscription $sub |
154 | 154 | */ |
155 | -function getpaid_admin_subscription_details_metabox( $sub ) { |
|
155 | +function getpaid_admin_subscription_details_metabox($sub) { |
|
156 | 156 | |
157 | 157 | // Subscription items. |
158 | - $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
159 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
158 | + $subscription_group = getpaid_get_invoice_subscription_group($sub->get_parent_invoice_id(), $sub->get_id()); |
|
159 | + $items_count = empty($subscription_group) ? 1 : count($subscription_group['items']); |
|
160 | 160 | |
161 | 161 | // Prepare subscription detail columns. |
162 | 162 | $fields = apply_filters( |
163 | 163 | 'getpaid_subscription_admin_page_fields', |
164 | 164 | array( |
165 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
166 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
167 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
168 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
169 | - 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
170 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
171 | - 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
172 | - 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
173 | - 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
174 | - 'status' => __( 'Status', 'invoicing' ), |
|
165 | + 'subscription' => __('Subscription', 'invoicing'), |
|
166 | + 'customer' => __('Customer', 'invoicing'), |
|
167 | + 'amount' => __('Amount', 'invoicing'), |
|
168 | + 'start_date' => __('Start Date', 'invoicing'), |
|
169 | + 'renews_on' => __('Next Payment', 'invoicing'), |
|
170 | + 'renewals' => __('Payments', 'invoicing'), |
|
171 | + 'item' => _n('Item', 'Items', $items_count, 'invoicing'), |
|
172 | + 'gateway' => __('Payment Method', 'invoicing'), |
|
173 | + 'profile_id' => __('Profile ID', 'invoicing'), |
|
174 | + 'status' => __('Status', 'invoicing'), |
|
175 | 175 | ) |
176 | 176 | ); |
177 | 177 | |
178 | - if ( ! $sub->is_active() ) { |
|
178 | + if (!$sub->is_active()) { |
|
179 | 179 | |
180 | - if ( isset( $fields['renews_on'] ) ) { |
|
181 | - unset( $fields['renews_on'] ); |
|
180 | + if (isset($fields['renews_on'])) { |
|
181 | + unset($fields['renews_on']); |
|
182 | 182 | } |
183 | 183 | |
184 | - if ( isset( $fields['gateway'] ) ) { |
|
185 | - unset( $fields['gateway'] ); |
|
184 | + if (isset($fields['gateway'])) { |
|
185 | + unset($fields['gateway']); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | } |
189 | 189 | |
190 | 190 | $profile_id = $sub->get_profile_id(); |
191 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
192 | - unset( $fields['profile_id'] ); |
|
191 | + if (empty($profile_id) && isset($fields['profile_id'])) { |
|
192 | + unset($fields['profile_id']); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | ?> |
@@ -197,16 +197,16 @@ discard block |
||
197 | 197 | <table class="table table-borderless" style="font-size: 14px;"> |
198 | 198 | <tbody> |
199 | 199 | |
200 | - <?php foreach ( $fields as $key => $label ) : ?> |
|
200 | + <?php foreach ($fields as $key => $label) : ?> |
|
201 | 201 | |
202 | - <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class( $key ); ?>"> |
|
202 | + <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class($key); ?>"> |
|
203 | 203 | |
204 | 204 | <th class="w-25" style="font-weight: 500;"> |
205 | - <?php echo sanitize_text_field( $label ); ?> |
|
205 | + <?php echo sanitize_text_field($label); ?> |
|
206 | 206 | </th> |
207 | 207 | |
208 | 208 | <td class="w-75 text-muted"> |
209 | - <?php do_action( 'getpaid_subscription_admin_display_' . sanitize_text_field( $key ), $sub, $subscription_group ); ?> |
|
209 | + <?php do_action('getpaid_subscription_admin_display_' . sanitize_text_field($key), $sub, $subscription_group); ?> |
|
210 | 210 | </td> |
211 | 211 | |
212 | 212 | </tr> |
@@ -224,129 +224,129 @@ discard block |
||
224 | 224 | * |
225 | 225 | * @param WPInv_Subscription $subscription |
226 | 226 | */ |
227 | -function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
|
227 | +function getpaid_admin_subscription_metabox_display_customer($subscription) { |
|
228 | 228 | |
229 | - $username = __( '(Missing User)', 'invoicing' ); |
|
229 | + $username = __('(Missing User)', 'invoicing'); |
|
230 | 230 | |
231 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
232 | - if ( $user ) { |
|
231 | + $user = get_userdata($subscription->get_customer_id()); |
|
232 | + if ($user) { |
|
233 | 233 | |
234 | 234 | $username = sprintf( |
235 | 235 | '<a href="user-edit.php?user_id=%s">%s</a>', |
236 | - absint( $user->ID ), |
|
237 | - ! empty( $user->display_name ) ? sanitize_text_field( $user->display_name ) : sanitize_email( $user->user_email ) |
|
236 | + absint($user->ID), |
|
237 | + !empty($user->display_name) ? sanitize_text_field($user->display_name) : sanitize_email($user->user_email) |
|
238 | 238 | ); |
239 | 239 | |
240 | 240 | } |
241 | 241 | |
242 | 242 | echo $username; |
243 | 243 | } |
244 | -add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
|
244 | +add_action('getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer'); |
|
245 | 245 | |
246 | 246 | /** |
247 | 247 | * Displays the subscription amount. |
248 | 248 | * |
249 | 249 | * @param WPInv_Subscription $subscription |
250 | 250 | */ |
251 | -function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
|
252 | - $amount = sanitize_text_field( getpaid_get_formatted_subscription_amount( $subscription ) ); |
|
251 | +function getpaid_admin_subscription_metabox_display_amount($subscription) { |
|
252 | + $amount = sanitize_text_field(getpaid_get_formatted_subscription_amount($subscription)); |
|
253 | 253 | echo "<span>$amount</span>"; |
254 | 254 | } |
255 | -add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
|
255 | +add_action('getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount'); |
|
256 | 256 | |
257 | 257 | /** |
258 | 258 | * Displays the subscription id. |
259 | 259 | * |
260 | 260 | * @param WPInv_Subscription $subscription |
261 | 261 | */ |
262 | -function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
|
263 | - echo '#' . absint( $subscription->get_id() ); |
|
262 | +function getpaid_admin_subscription_metabox_display_id($subscription) { |
|
263 | + echo '#' . absint($subscription->get_id()); |
|
264 | 264 | } |
265 | -add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
|
265 | +add_action('getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id'); |
|
266 | 266 | |
267 | 267 | /** |
268 | 268 | * Displays the subscription renewal date. |
269 | 269 | * |
270 | 270 | * @param WPInv_Subscription $subscription |
271 | 271 | */ |
272 | -function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
|
273 | - echo getpaid_format_date_value( $subscription->get_date_created() ); |
|
272 | +function getpaid_admin_subscription_metabox_display_start_date($subscription) { |
|
273 | + echo getpaid_format_date_value($subscription->get_date_created()); |
|
274 | 274 | } |
275 | -add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
|
275 | +add_action('getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date'); |
|
276 | 276 | |
277 | 277 | /** |
278 | 278 | * Displays the subscription renewal date. |
279 | 279 | * |
280 | 280 | * @param WPInv_Subscription $subscription |
281 | 281 | */ |
282 | -function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
|
283 | - echo getpaid_format_date_value( $subscription->get_expiration() ); |
|
282 | +function getpaid_admin_subscription_metabox_display_renews_on($subscription) { |
|
283 | + echo getpaid_format_date_value($subscription->get_expiration()); |
|
284 | 284 | } |
285 | -add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
|
285 | +add_action('getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on'); |
|
286 | 286 | |
287 | 287 | /** |
288 | 288 | * Displays the subscription renewal count. |
289 | 289 | * |
290 | 290 | * @param WPInv_Subscription $subscription |
291 | 291 | */ |
292 | -function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
|
292 | +function getpaid_admin_subscription_metabox_display_renewals($subscription) { |
|
293 | 293 | $max_bills = $subscription->get_bill_times(); |
294 | - echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
294 | + echo $subscription->get_times_billed() . ' / ' . (empty($max_bills) ? "∞" : $max_bills); |
|
295 | 295 | } |
296 | -add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
|
296 | +add_action('getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals'); |
|
297 | 297 | /** |
298 | 298 | * Displays the subscription item. |
299 | 299 | * |
300 | 300 | * @param WPInv_Subscription $subscription |
301 | 301 | * @param false|array $subscription_group |
302 | 302 | */ |
303 | -function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) { |
|
303 | +function getpaid_admin_subscription_metabox_display_item($subscription, $subscription_group = false) { |
|
304 | 304 | |
305 | - if ( empty( $subscription_group ) ) { |
|
306 | - echo WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ); |
|
305 | + if (empty($subscription_group)) { |
|
306 | + echo WPInv_Subscriptions_List_Table::generate_item_markup($subscription->get_product_id()); |
|
307 | 307 | return; |
308 | 308 | } |
309 | 309 | |
310 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
311 | - echo implode( ' | ', $markup ); |
|
310 | + $markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
311 | + echo implode(' | ', $markup); |
|
312 | 312 | |
313 | 313 | } |
314 | -add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 ); |
|
314 | +add_action('getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2); |
|
315 | 315 | |
316 | 316 | /** |
317 | 317 | * Displays the subscription gateway. |
318 | 318 | * |
319 | 319 | * @param WPInv_Subscription $subscription |
320 | 320 | */ |
321 | -function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
|
321 | +function getpaid_admin_subscription_metabox_display_gateway($subscription) { |
|
322 | 322 | |
323 | 323 | $gateway = $subscription->get_gateway(); |
324 | 324 | |
325 | - if ( ! empty( $gateway ) ) { |
|
326 | - echo sanitize_text_field( wpinv_get_gateway_admin_label( $gateway ) ); |
|
325 | + if (!empty($gateway)) { |
|
326 | + echo sanitize_text_field(wpinv_get_gateway_admin_label($gateway)); |
|
327 | 327 | } else { |
328 | 328 | echo "—"; |
329 | 329 | } |
330 | 330 | |
331 | 331 | } |
332 | -add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
|
332 | +add_action('getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway'); |
|
333 | 333 | |
334 | 334 | /** |
335 | 335 | * Displays the subscription status. |
336 | 336 | * |
337 | 337 | * @param WPInv_Subscription $subscription |
338 | 338 | */ |
339 | -function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
|
339 | +function getpaid_admin_subscription_metabox_display_status($subscription) { |
|
340 | 340 | echo $subscription->get_status_label_html(); |
341 | 341 | } |
342 | -add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
|
342 | +add_action('getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status'); |
|
343 | 343 | |
344 | 344 | /** |
345 | 345 | * Displays the subscription profile id. |
346 | 346 | * |
347 | 347 | * @param WPInv_Subscription $subscription |
348 | 348 | */ |
349 | -function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
|
349 | +function getpaid_admin_subscription_metabox_display_profile_id($subscription) { |
|
350 | 350 | |
351 | 351 | $profile_id = $subscription->get_profile_id(); |
352 | 352 | |
@@ -355,32 +355,32 @@ discard block |
||
355 | 355 | 'type' => 'text', |
356 | 356 | 'id' => 'wpinv_subscription_profile_id', |
357 | 357 | 'name' => 'wpinv_subscription_profile_id', |
358 | - 'label' => __( 'Profile Id', 'invoicing' ), |
|
358 | + 'label' => __('Profile Id', 'invoicing'), |
|
359 | 359 | 'label_type' => 'hidden', |
360 | - 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
361 | - 'value' => sanitize_text_field( $profile_id ), |
|
360 | + 'placeholder' => __('Profile Id', 'invoicing'), |
|
361 | + 'value' => sanitize_text_field($profile_id), |
|
362 | 362 | 'input_group_right' => '', |
363 | 363 | 'no_wrap' => true, |
364 | 364 | ) |
365 | 365 | ); |
366 | 366 | |
367 | - echo str_ireplace( 'form-control', 'regular-text', $input ); |
|
367 | + echo str_ireplace('form-control', 'regular-text', $input); |
|
368 | 368 | |
369 | - $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
370 | - if ( ! empty( $url ) ) { |
|
371 | - $url = esc_url_raw( $url ); |
|
372 | - echo ' <a href="' . $url . '" title="' . __( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
369 | + $url = apply_filters('getpaid_remote_subscription_profile_url', '', $subscription); |
|
370 | + if (!empty($url)) { |
|
371 | + $url = esc_url_raw($url); |
|
372 | + echo ' <a href="' . $url . '" title="' . __('View in Gateway', 'invoicing') . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | } |
376 | -add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
|
376 | +add_action('getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id'); |
|
377 | 377 | |
378 | 378 | /** |
379 | 379 | * Displays the subscriptions update metabox. |
380 | 380 | * |
381 | 381 | * @param WPInv_Subscription $subscription |
382 | 382 | */ |
383 | -function getpaid_admin_subscription_update_metabox( $subscription ) { |
|
383 | +function getpaid_admin_subscription_update_metabox($subscription) { |
|
384 | 384 | |
385 | 385 | ?> |
386 | 386 | <div class="mt-3"> |
@@ -393,10 +393,10 @@ discard block |
||
393 | 393 | 'id' => 'subscription_status_update_select', |
394 | 394 | 'required' => true, |
395 | 395 | 'no_wrap' => false, |
396 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
397 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
396 | + 'label' => __('Subscription Status', 'invoicing'), |
|
397 | + 'help_text' => __('Updating the status will trigger related actions and hooks', 'invoicing'), |
|
398 | 398 | 'select2' => true, |
399 | - 'value' => $subscription->get_status( 'edit' ), |
|
399 | + 'value' => $subscription->get_status('edit'), |
|
400 | 400 | ) |
401 | 401 | ); |
402 | 402 | ?> |
@@ -404,13 +404,13 @@ discard block |
||
404 | 404 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;"> |
405 | 405 | |
406 | 406 | <?php |
407 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
407 | + submit_button(__('Update', 'invoicing'), 'primary', 'submit', false); |
|
408 | 408 | |
409 | - $url = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) ); |
|
410 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
411 | - $title = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' ); |
|
409 | + $url = esc_url(wp_nonce_url(add_query_arg('getpaid-admin-action', 'subscription_manual_renew'), 'getpaid-nonce', 'getpaid-nonce')); |
|
410 | + $anchor = __('Renew Subscription', 'invoicing'); |
|
411 | + $title = esc_attr__('Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing'); |
|
412 | 412 | |
413 | - if ( $subscription->is_active() ) { |
|
413 | + if ($subscription->is_active()) { |
|
414 | 414 | echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>"; |
415 | 415 | } |
416 | 416 | |
@@ -423,31 +423,31 @@ discard block |
||
423 | 423 | * @param WPInv_Subscription $subscription |
424 | 424 | * @param bool $strict Whether or not to skip invoices of sibling subscriptions |
425 | 425 | */ |
426 | -function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) { |
|
426 | +function getpaid_admin_subscription_invoice_details_metabox($subscription, $strict = true) { |
|
427 | 427 | |
428 | 428 | $columns = apply_filters( |
429 | 429 | 'getpaid_subscription_related_invoices_columns', |
430 | 430 | array( |
431 | - 'invoice' => __( 'Invoice', 'invoicing' ), |
|
432 | - 'relationship' => __( 'Relationship', 'invoicing' ), |
|
433 | - 'date' => __( 'Date', 'invoicing' ), |
|
434 | - 'status' => __( 'Status', 'invoicing' ), |
|
435 | - 'total' => __( 'Total', 'invoicing' ), |
|
431 | + 'invoice' => __('Invoice', 'invoicing'), |
|
432 | + 'relationship' => __('Relationship', 'invoicing'), |
|
433 | + 'date' => __('Date', 'invoicing'), |
|
434 | + 'status' => __('Status', 'invoicing'), |
|
435 | + 'total' => __('Total', 'invoicing'), |
|
436 | 436 | ), |
437 | 437 | $subscription |
438 | 438 | ); |
439 | 439 | |
440 | 440 | // Prepare the invoices. |
441 | - $payments = $subscription->get_child_payments( ! is_admin() ); |
|
441 | + $payments = $subscription->get_child_payments(!is_admin()); |
|
442 | 442 | $parent = $subscription->get_parent_invoice(); |
443 | 443 | |
444 | - if ( $parent->exists() ) { |
|
445 | - $payments = array_merge( array( $parent ), $payments ); |
|
444 | + if ($parent->exists()) { |
|
445 | + $payments = array_merge(array($parent), $payments); |
|
446 | 446 | } |
447 | 447 | |
448 | 448 | $table_class = 'w-100 bg-white'; |
449 | 449 | |
450 | - if ( ! is_admin() ) { |
|
450 | + if (!is_admin()) { |
|
451 | 451 | $table_class = 'table table-bordered'; |
452 | 452 | } |
453 | 453 | |
@@ -459,9 +459,9 @@ discard block |
||
459 | 459 | <thead> |
460 | 460 | <tr> |
461 | 461 | <?php |
462 | - foreach ( $columns as $key => $label ) { |
|
463 | - $key = esc_attr( $key ); |
|
464 | - $label = sanitize_text_field( $label ); |
|
462 | + foreach ($columns as $key => $label) { |
|
463 | + $key = esc_attr($key); |
|
464 | + $label = sanitize_text_field($label); |
|
465 | 465 | $class = 'text-left'; |
466 | 466 | |
467 | 467 | echo "<th class='subscription-invoice-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
@@ -472,57 +472,57 @@ discard block |
||
472 | 472 | |
473 | 473 | <tbody> |
474 | 474 | |
475 | - <?php if ( empty( $payments ) ) : ?> |
|
475 | + <?php if (empty($payments)) : ?> |
|
476 | 476 | <tr> |
477 | 477 | <td colspan="<?php echo count($columns); ?>" class="p-2 text-left text-muted"> |
478 | - <?php _e( 'This subscription has no invoices.', 'invoicing' ); ?> |
|
478 | + <?php _e('This subscription has no invoices.', 'invoicing'); ?> |
|
479 | 479 | </td> |
480 | 480 | </tr> |
481 | 481 | <?php endif; ?> |
482 | 482 | |
483 | 483 | <?php |
484 | 484 | |
485 | - foreach( $payments as $payment ) : |
|
485 | + foreach ($payments as $payment) : |
|
486 | 486 | |
487 | 487 | // Ensure that we have an invoice. |
488 | - $payment = new WPInv_Invoice( $payment ); |
|
488 | + $payment = new WPInv_Invoice($payment); |
|
489 | 489 | |
490 | 490 | // Abort if the invoice is invalid... |
491 | - if ( ! $payment->exists() ) { |
|
491 | + if (!$payment->exists()) { |
|
492 | 492 | continue; |
493 | 493 | } |
494 | 494 | |
495 | 495 | // ... or belongs to a different subscription. |
496 | - if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
496 | + if ($strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id()) { |
|
497 | 497 | continue; |
498 | 498 | } |
499 | 499 | |
500 | 500 | echo '<tr>'; |
501 | 501 | |
502 | - foreach ( array_keys( $columns ) as $key ) { |
|
502 | + foreach (array_keys($columns) as $key) { |
|
503 | 503 | |
504 | 504 | $class = 'text-left'; |
505 | 505 | |
506 | 506 | echo "<td class='p-2 $class'>"; |
507 | 507 | |
508 | - switch( $key ) { |
|
508 | + switch ($key) { |
|
509 | 509 | |
510 | 510 | case 'total': |
511 | - echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>'; |
|
511 | + echo '<strong>' . wpinv_price($payment->get_total(), $payment->get_currency()) . '</strong>'; |
|
512 | 512 | break; |
513 | 513 | |
514 | 514 | case 'relationship': |
515 | - echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' ); |
|
515 | + echo $payment->is_renewal() ? __('Renewal Invoice', 'invoicing') : __('Initial Invoice', 'invoicing'); |
|
516 | 516 | break; |
517 | 517 | |
518 | 518 | case 'date': |
519 | - echo getpaid_format_date_value( $payment->get_date_created() ); |
|
519 | + echo getpaid_format_date_value($payment->get_date_created()); |
|
520 | 520 | break; |
521 | 521 | |
522 | 522 | case 'status': |
523 | 523 | |
524 | 524 | $status = $payment->get_status_nicename(); |
525 | - if ( is_admin() ) { |
|
525 | + if (is_admin()) { |
|
526 | 526 | $status = $payment->get_status_label_html(); |
527 | 527 | } |
528 | 528 | |
@@ -530,13 +530,13 @@ discard block |
||
530 | 530 | break; |
531 | 531 | |
532 | 532 | case 'invoice': |
533 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
533 | + $link = esc_url(get_edit_post_link($payment->get_id())); |
|
534 | 534 | |
535 | - if ( ! is_admin() ) { |
|
536 | - $link = esc_url( $payment->get_view_url() ); |
|
535 | + if (!is_admin()) { |
|
536 | + $link = esc_url($payment->get_view_url()); |
|
537 | 537 | } |
538 | 538 | |
539 | - $invoice = sanitize_text_field( $payment->get_number() ); |
|
539 | + $invoice = sanitize_text_field($payment->get_number()); |
|
540 | 540 | echo "<a href='$link'>$invoice</a>"; |
541 | 541 | break; |
542 | 542 | } |
@@ -564,12 +564,12 @@ discard block |
||
564 | 564 | * |
565 | 565 | * @param WPInv_Subscription $subscription |
566 | 566 | */ |
567 | -function getpaid_admin_subscription_item_details_metabox( $subscription ) { |
|
567 | +function getpaid_admin_subscription_item_details_metabox($subscription) { |
|
568 | 568 | |
569 | 569 | // Fetch the subscription group. |
570 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
570 | + $subscription_group = getpaid_get_invoice_subscription_group($subscription->get_parent_payment_id(), $subscription->get_id()); |
|
571 | 571 | |
572 | - if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
572 | + if (empty($subscription_group) || empty($subscription_group['items'])) { |
|
573 | 573 | return; |
574 | 574 | } |
575 | 575 | |
@@ -577,12 +577,12 @@ discard block |
||
577 | 577 | $columns = apply_filters( |
578 | 578 | 'getpaid_subscription_item_details_columns', |
579 | 579 | array( |
580 | - 'item_name' => __( 'Item', 'invoicing' ), |
|
581 | - 'price' => __( 'Price', 'invoicing' ), |
|
582 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
583 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
580 | + 'item_name' => __('Item', 'invoicing'), |
|
581 | + 'price' => __('Price', 'invoicing'), |
|
582 | + 'tax' => __('Tax', 'invoicing'), |
|
583 | + 'discount' => __('Discount', 'invoicing'), |
|
584 | 584 | //'initial' => __( 'Initial Amount', 'invoicing' ), |
585 | - 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
585 | + 'recurring' => __('Subtotal', 'invoicing'), |
|
586 | 586 | ), |
587 | 587 | $subscription |
588 | 588 | ); |
@@ -591,13 +591,13 @@ discard block |
||
591 | 591 | |
592 | 592 | $invoice = $subscription->get_parent_invoice(); |
593 | 593 | |
594 | - if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
595 | - unset( $columns['tax'] ); |
|
594 | + if ((!wpinv_use_taxes() || !$invoice->is_taxable()) && isset($columns['tax'])) { |
|
595 | + unset($columns['tax']); |
|
596 | 596 | } |
597 | 597 | |
598 | 598 | $table_class = 'w-100 bg-white'; |
599 | 599 | |
600 | - if ( ! is_admin() ) { |
|
600 | + if (!is_admin()) { |
|
601 | 601 | $table_class = 'table table-bordered'; |
602 | 602 | } |
603 | 603 | |
@@ -610,9 +610,9 @@ discard block |
||
610 | 610 | <tr> |
611 | 611 | <?php |
612 | 612 | |
613 | - foreach ( $columns as $key => $label ) { |
|
614 | - $key = esc_attr( $key ); |
|
615 | - $label = sanitize_text_field( $label ); |
|
613 | + foreach ($columns as $key => $label) { |
|
614 | + $key = esc_attr($key); |
|
615 | + $label = sanitize_text_field($label); |
|
616 | 616 | $class = 'text-left'; |
617 | 617 | |
618 | 618 | echo "<th class='subscription-item-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
@@ -625,48 +625,48 @@ discard block |
||
625 | 625 | |
626 | 626 | <?php |
627 | 627 | |
628 | - foreach( $subscription_group['items'] as $subscription_group_item ) : |
|
628 | + foreach ($subscription_group['items'] as $subscription_group_item) : |
|
629 | 629 | |
630 | 630 | echo '<tr>'; |
631 | 631 | |
632 | - foreach ( array_keys( $columns ) as $key ) { |
|
632 | + foreach (array_keys($columns) as $key) { |
|
633 | 633 | |
634 | 634 | $class = 'text-left'; |
635 | 635 | |
636 | 636 | echo "<td class='p-2 $class'>"; |
637 | 637 | |
638 | - switch( $key ) { |
|
638 | + switch ($key) { |
|
639 | 639 | |
640 | 640 | case 'item_name': |
641 | - $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
642 | - $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
641 | + $item_name = get_the_title($subscription_group_item['item_id']); |
|
642 | + $item_name = empty($item_name) ? $subscription_group_item['item_name'] : $item_name; |
|
643 | 643 | |
644 | - if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
645 | - echo sanitize_text_field( $item_name ); |
|
644 | + if ($invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity']) { |
|
645 | + echo sanitize_text_field($item_name); |
|
646 | 646 | } else { |
647 | - printf( '%1$s x %2$d', sanitize_text_field( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
647 | + printf('%1$s x %2$d', sanitize_text_field($item_name), (float) $subscription_group_item['quantity']); |
|
648 | 648 | } |
649 | 649 | |
650 | 650 | break; |
651 | 651 | |
652 | 652 | case 'price': |
653 | - echo wpinv_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
653 | + echo wpinv_price($subscription_group_item['item_price'], $invoice->get_currency()); |
|
654 | 654 | break; |
655 | 655 | |
656 | 656 | case 'tax': |
657 | - echo wpinv_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
657 | + echo wpinv_price($subscription_group_item['tax'], $invoice->get_currency()); |
|
658 | 658 | break; |
659 | 659 | |
660 | 660 | case 'discount': |
661 | - echo wpinv_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
661 | + echo wpinv_price($subscription_group_item['discount'], $invoice->get_currency()); |
|
662 | 662 | break; |
663 | 663 | |
664 | 664 | case 'initial': |
665 | - echo wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
665 | + echo wpinv_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()); |
|
666 | 666 | break; |
667 | 667 | |
668 | 668 | case 'recurring': |
669 | - echo '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>'; |
|
669 | + echo '<strong>' . wpinv_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()) . '</strong>'; |
|
670 | 670 | break; |
671 | 671 | |
672 | 672 | } |
@@ -679,24 +679,24 @@ discard block |
||
679 | 679 | |
680 | 680 | endforeach; |
681 | 681 | |
682 | - foreach( $subscription_group['fees'] as $subscription_group_fee ) : |
|
682 | + foreach ($subscription_group['fees'] as $subscription_group_fee) : |
|
683 | 683 | |
684 | 684 | echo '<tr>'; |
685 | 685 | |
686 | - foreach ( array_keys( $columns ) as $key ) { |
|
686 | + foreach (array_keys($columns) as $key) { |
|
687 | 687 | |
688 | 688 | $class = 'text-left'; |
689 | 689 | |
690 | 690 | echo "<td class='p-2 $class'>"; |
691 | 691 | |
692 | - switch( $key ) { |
|
692 | + switch ($key) { |
|
693 | 693 | |
694 | 694 | case 'item_name': |
695 | - echo sanitize_text_field( $subscription_group_fee['name'] ); |
|
695 | + echo sanitize_text_field($subscription_group_fee['name']); |
|
696 | 696 | break; |
697 | 697 | |
698 | 698 | case 'price': |
699 | - echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
699 | + echo wpinv_price($subscription_group_fee['initial_fee'], $invoice->get_currency()); |
|
700 | 700 | break; |
701 | 701 | |
702 | 702 | case 'tax': |
@@ -708,11 +708,11 @@ discard block |
||
708 | 708 | break; |
709 | 709 | |
710 | 710 | case 'initial': |
711 | - echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
711 | + echo wpinv_price($subscription_group_fee['initial_fee'], $invoice->get_currency()); |
|
712 | 712 | break; |
713 | 713 | |
714 | 714 | case 'recurring': |
715 | - echo '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>'; |
|
715 | + echo '<strong>' . wpinv_price($subscription_group_fee['recurring_fee'], $invoice->get_currency()) . '</strong>'; |
|
716 | 716 | break; |
717 | 717 | |
718 | 718 | } |
@@ -741,12 +741,12 @@ discard block |
||
741 | 741 | * @param WPInv_Subscription $subscription |
742 | 742 | * @param bool $skip_current |
743 | 743 | */ |
744 | -function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) { |
|
744 | +function getpaid_admin_subscription_related_subscriptions_metabox($subscription, $skip_current = true) { |
|
745 | 745 | |
746 | 746 | // Fetch the subscription groups. |
747 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
747 | + $subscription_groups = getpaid_get_invoice_subscription_groups($subscription->get_parent_payment_id()); |
|
748 | 748 | |
749 | - if ( empty( $subscription_groups ) ) { |
|
749 | + if (empty($subscription_groups)) { |
|
750 | 750 | return; |
751 | 751 | } |
752 | 752 | |
@@ -754,23 +754,23 @@ discard block |
||
754 | 754 | $columns = apply_filters( |
755 | 755 | 'getpaid_subscription_related_subscriptions_columns', |
756 | 756 | array( |
757 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
758 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
759 | - 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
760 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
761 | - 'item' => __( 'Items', 'invoicing' ), |
|
762 | - 'status' => __( 'Status', 'invoicing' ), |
|
757 | + 'subscription' => __('Subscription', 'invoicing'), |
|
758 | + 'start_date' => __('Start Date', 'invoicing'), |
|
759 | + 'renewal_date' => __('Next Payment', 'invoicing'), |
|
760 | + 'renewals' => __('Payments', 'invoicing'), |
|
761 | + 'item' => __('Items', 'invoicing'), |
|
762 | + 'status' => __('Status', 'invoicing'), |
|
763 | 763 | ), |
764 | 764 | $subscription |
765 | 765 | ); |
766 | 766 | |
767 | - if ( $subscription->get_status() == 'pending' ) { |
|
768 | - unset( $columns['start_date'], $columns['renewal_date'] ); |
|
767 | + if ($subscription->get_status() == 'pending') { |
|
768 | + unset($columns['start_date'], $columns['renewal_date']); |
|
769 | 769 | } |
770 | 770 | |
771 | 771 | $table_class = 'w-100 bg-white'; |
772 | 772 | |
773 | - if ( ! is_admin() ) { |
|
773 | + if (!is_admin()) { |
|
774 | 774 | $table_class = 'table table-bordered'; |
775 | 775 | } |
776 | 776 | |
@@ -783,9 +783,9 @@ discard block |
||
783 | 783 | <tr> |
784 | 784 | <?php |
785 | 785 | |
786 | - foreach ( $columns as $key => $label ) { |
|
787 | - $key = esc_attr( $key ); |
|
788 | - $label = sanitize_text_field( $label ); |
|
786 | + foreach ($columns as $key => $label) { |
|
787 | + $key = esc_attr($key); |
|
788 | + $label = sanitize_text_field($label); |
|
789 | 789 | $class = 'text-left'; |
790 | 790 | |
791 | 791 | echo "<th class='related-subscription-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
@@ -798,62 +798,62 @@ discard block |
||
798 | 798 | |
799 | 799 | <?php |
800 | 800 | |
801 | - foreach( $subscription_groups as $subscription_group ) : |
|
801 | + foreach ($subscription_groups as $subscription_group) : |
|
802 | 802 | |
803 | 803 | // Do not list current subscription. |
804 | - if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
804 | + if ($skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id()) { |
|
805 | 805 | continue; |
806 | 806 | } |
807 | 807 | |
808 | 808 | // Ensure the subscription exists. |
809 | - $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
809 | + $_suscription = new WPInv_Subscription($subscription_group['subscription_id']); |
|
810 | 810 | |
811 | - if ( ! $_suscription->exists() ) { |
|
811 | + if (!$_suscription->exists()) { |
|
812 | 812 | continue; |
813 | 813 | } |
814 | 814 | |
815 | 815 | echo '<tr>'; |
816 | 816 | |
817 | - foreach ( array_keys( $columns ) as $key ) { |
|
817 | + foreach (array_keys($columns) as $key) { |
|
818 | 818 | |
819 | 819 | $class = 'text-left'; |
820 | 820 | |
821 | 821 | echo "<td class='p-2 $class'>"; |
822 | 822 | |
823 | - switch( $key ) { |
|
823 | + switch ($key) { |
|
824 | 824 | |
825 | 825 | case 'status': |
826 | 826 | echo $_suscription->get_status_label_html(); |
827 | 827 | break; |
828 | 828 | |
829 | 829 | case 'item': |
830 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
831 | - echo implode( ' | ', $markup ); |
|
830 | + $markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
831 | + echo implode(' | ', $markup); |
|
832 | 832 | break; |
833 | 833 | |
834 | 834 | case 'renewals': |
835 | 835 | $max_bills = $_suscription->get_bill_times(); |
836 | - echo $_suscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
836 | + echo $_suscription->get_times_billed() . ' / ' . (empty($max_bills) ? "∞" : $max_bills); |
|
837 | 837 | break; |
838 | 838 | |
839 | 839 | case 'renewal_date': |
840 | - echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : "—"; |
|
840 | + echo $_suscription->is_active() ? getpaid_format_date_value($_suscription->get_expiration()) : "—"; |
|
841 | 841 | break; |
842 | 842 | |
843 | 843 | case 'start_date': |
844 | - echo 'pending' == $_suscription->get_status() ? "—" : getpaid_format_date_value( $_suscription->get_date_created() ); |
|
844 | + echo 'pending' == $_suscription->get_status() ? "—" : getpaid_format_date_value($_suscription->get_date_created()); |
|
845 | 845 | break; |
846 | 846 | |
847 | 847 | case 'subscription': |
848 | - $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
848 | + $url = is_admin() ? admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($_suscription->get_id())) : $_suscription->get_view_url(); |
|
849 | 849 | printf( |
850 | 850 | '%1$s#%2$s%3$s', |
851 | - '<a href="' . esc_url( $url ) . '">', |
|
852 | - '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
|
851 | + '<a href="' . esc_url($url) . '">', |
|
852 | + '<strong>' . intval($_suscription->get_id()) . '</strong>', |
|
853 | 853 | '</a>' |
854 | 854 | ); |
855 | 855 | |
856 | - echo WPInv_Subscriptions_List_Table::column_amount( $_suscription ); |
|
856 | + echo WPInv_Subscriptions_List_Table::column_amount($_suscription); |
|
857 | 857 | break; |
858 | 858 | |
859 | 859 | } |
@@ -13,18 +13,18 @@ discard block |
||
13 | 13 | * @return WPInv_Subscription[]|WPInv_Subscription|false |
14 | 14 | * @since 2.3.0 |
15 | 15 | */ |
16 | -function getpaid_get_invoice_subscriptions( $invoice ) { |
|
16 | +function getpaid_get_invoice_subscriptions($invoice) { |
|
17 | 17 | |
18 | 18 | // Retrieve subscription groups. |
19 | - $subscription_ids = wp_list_pluck( getpaid_get_invoice_subscription_groups( $invoice->get_id() ), 'subscription_id' ); |
|
19 | + $subscription_ids = wp_list_pluck(getpaid_get_invoice_subscription_groups($invoice->get_id()), 'subscription_id'); |
|
20 | 20 | |
21 | 21 | // No subscription groups, normal subscription. |
22 | - if ( empty( $subscription_ids ) ) { |
|
23 | - return getpaid_subscriptions()->get_invoice_subscription( $invoice ); |
|
22 | + if (empty($subscription_ids)) { |
|
23 | + return getpaid_subscriptions()->get_invoice_subscription($invoice); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | // Subscription groups. |
27 | - return array_filter( array_map( 'getpaid_get_subscription', $subscription_ids ) ); |
|
27 | + return array_filter(array_map('getpaid_get_subscription', $subscription_ids)); |
|
28 | 28 | |
29 | 29 | } |
30 | 30 | |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | * @return array |
36 | 36 | * @since 2.3.0 |
37 | 37 | */ |
38 | -function getpaid_get_invoice_subscription_groups( $invoice_id ) { |
|
39 | - $subscription_groups = get_post_meta( $invoice_id, 'getpaid_subscription_groups', true ); |
|
40 | - return empty( $subscription_groups ) ? array() : $subscription_groups; |
|
38 | +function getpaid_get_invoice_subscription_groups($invoice_id) { |
|
39 | + $subscription_groups = get_post_meta($invoice_id, 'getpaid_subscription_groups', true); |
|
40 | + return empty($subscription_groups) ? array() : $subscription_groups; |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | * @return array|false |
49 | 49 | * @since 2.3.0 |
50 | 50 | */ |
51 | -function getpaid_get_invoice_subscription_group( $invoice_id, $subscription_id ) { |
|
52 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $invoice_id ); |
|
53 | - $matching_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
54 | - return reset( $matching_group ); |
|
51 | +function getpaid_get_invoice_subscription_group($invoice_id, $subscription_id) { |
|
52 | + $subscription_groups = getpaid_get_invoice_subscription_groups($invoice_id); |
|
53 | + $matching_group = wp_list_filter($subscription_groups, compact('subscription_id')); |
|
54 | + return reset($matching_group); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -61,10 +61,10 @@ discard block |
||
61 | 61 | * @since 2.3.0 |
62 | 62 | * @return WPInv_Subscription|false |
63 | 63 | */ |
64 | -function getpaid_get_subscription( $subscription ) { |
|
64 | +function getpaid_get_subscription($subscription) { |
|
65 | 65 | |
66 | - if ( ! is_a( $subscription, 'WPInv_Subscription' ) ) { |
|
67 | - $subscription = new WPInv_Subscription( $subscription ); |
|
66 | + if (!is_a($subscription, 'WPInv_Subscription')) { |
|
67 | + $subscription = new WPInv_Subscription($subscription); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | return $subscription->exists() ? $subscription : false; |
@@ -79,26 +79,26 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @return int|array|WPInv_Subscription[]|GetPaid_Subscriptions_Query |
81 | 81 | */ |
82 | -function getpaid_get_subscriptions( $args = array(), $return = 'results' ) { |
|
82 | +function getpaid_get_subscriptions($args = array(), $return = 'results') { |
|
83 | 83 | |
84 | 84 | // Do not retrieve all fields if we just want the count. |
85 | - if ( 'count' == $return ) { |
|
85 | + if ('count' == $return) { |
|
86 | 86 | $args['fields'] = 'id'; |
87 | 87 | $args['number'] = 1; |
88 | 88 | } |
89 | 89 | |
90 | 90 | // Do not count all matches if we just want the results. |
91 | - if ( 'results' == $return ) { |
|
91 | + if ('results' == $return) { |
|
92 | 92 | $args['count_total'] = false; |
93 | 93 | } |
94 | 94 | |
95 | - $query = new GetPaid_Subscriptions_Query( $args ); |
|
95 | + $query = new GetPaid_Subscriptions_Query($args); |
|
96 | 96 | |
97 | - if ( 'results' == $return ) { |
|
97 | + if ('results' == $return) { |
|
98 | 98 | return $query->get_results(); |
99 | 99 | } |
100 | 100 | |
101 | - if ( 'count' == $return ) { |
|
101 | + if ('count' == $return) { |
|
102 | 102 | return $query->get_total(); |
103 | 103 | } |
104 | 104 | |
@@ -115,13 +115,13 @@ discard block |
||
115 | 115 | return apply_filters( |
116 | 116 | 'getpaid_get_subscription_statuses', |
117 | 117 | array( |
118 | - 'pending' => __( 'Pending', 'invoicing' ), |
|
119 | - 'trialling' => __( 'Trialing', 'invoicing' ), |
|
120 | - 'active' => __( 'Active', 'invoicing' ), |
|
121 | - 'failing' => __( 'Failing', 'invoicing' ), |
|
122 | - 'expired' => __( 'Expired', 'invoicing' ), |
|
123 | - 'completed' => __( 'Complete', 'invoicing' ), |
|
124 | - 'cancelled' => __( 'Cancelled', 'invoicing' ), |
|
118 | + 'pending' => __('Pending', 'invoicing'), |
|
119 | + 'trialling' => __('Trialing', 'invoicing'), |
|
120 | + 'active' => __('Active', 'invoicing'), |
|
121 | + 'failing' => __('Failing', 'invoicing'), |
|
122 | + 'expired' => __('Expired', 'invoicing'), |
|
123 | + 'completed' => __('Complete', 'invoicing'), |
|
124 | + 'cancelled' => __('Cancelled', 'invoicing'), |
|
125 | 125 | ) |
126 | 126 | ); |
127 | 127 | |
@@ -132,9 +132,9 @@ discard block |
||
132 | 132 | * |
133 | 133 | * @return string |
134 | 134 | */ |
135 | -function getpaid_get_subscription_status_label( $status ) { |
|
135 | +function getpaid_get_subscription_status_label($status) { |
|
136 | 136 | $statuses = getpaid_get_subscription_statuses(); |
137 | - return isset( $statuses[ $status ] ) ? $statuses[ $status ] : ucfirst( sanitize_text_field( $status ) ); |
|
137 | + return isset($statuses[$status]) ? $statuses[$status] : ucfirst(sanitize_text_field($status)); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -164,14 +164,14 @@ discard block |
||
164 | 164 | * |
165 | 165 | * @return array |
166 | 166 | */ |
167 | -function getpaid_get_subscription_status_counts( $args = array() ) { |
|
167 | +function getpaid_get_subscription_status_counts($args = array()) { |
|
168 | 168 | |
169 | - $statuses = array_keys( getpaid_get_subscription_statuses() ); |
|
169 | + $statuses = array_keys(getpaid_get_subscription_statuses()); |
|
170 | 170 | $counts = array(); |
171 | 171 | |
172 | - foreach ( $statuses as $status ) { |
|
173 | - $_args = wp_parse_args( "status=$status", $args ); |
|
174 | - $counts[ $status ] = getpaid_get_subscriptions( $_args, 'count' ); |
|
172 | + foreach ($statuses as $status) { |
|
173 | + $_args = wp_parse_args("status=$status", $args); |
|
174 | + $counts[$status] = getpaid_get_subscriptions($_args, 'count'); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | return $counts; |
@@ -190,23 +190,23 @@ discard block |
||
190 | 190 | array( |
191 | 191 | |
192 | 192 | 'day' => array( |
193 | - 'singular' => __( '%s day', 'invoicing' ), |
|
194 | - 'plural' => __( '%d days', 'invoicing' ), |
|
193 | + 'singular' => __('%s day', 'invoicing'), |
|
194 | + 'plural' => __('%d days', 'invoicing'), |
|
195 | 195 | ), |
196 | 196 | |
197 | 197 | 'week' => array( |
198 | - 'singular' => __( '%s week', 'invoicing' ), |
|
199 | - 'plural' => __( '%d weeks', 'invoicing' ), |
|
198 | + 'singular' => __('%s week', 'invoicing'), |
|
199 | + 'plural' => __('%d weeks', 'invoicing'), |
|
200 | 200 | ), |
201 | 201 | |
202 | 202 | 'month' => array( |
203 | - 'singular' => __( '%s month', 'invoicing' ), |
|
204 | - 'plural' => __( '%d months', 'invoicing' ), |
|
203 | + 'singular' => __('%s month', 'invoicing'), |
|
204 | + 'plural' => __('%d months', 'invoicing'), |
|
205 | 205 | ), |
206 | 206 | |
207 | 207 | 'year' => array( |
208 | - 'singular' => __( '%s year', 'invoicing' ), |
|
209 | - 'plural' => __( '%d years', 'invoicing' ), |
|
208 | + 'singular' => __('%s year', 'invoicing'), |
|
209 | + 'plural' => __('%d years', 'invoicing'), |
|
210 | 210 | ), |
211 | 211 | |
212 | 212 | ) |
@@ -220,8 +220,8 @@ discard block |
||
220 | 220 | * @param string $trial_period |
221 | 221 | * @return int |
222 | 222 | */ |
223 | -function getpaid_get_subscription_trial_period_interval( $trial_period ) { |
|
224 | - return (int) preg_replace( '/[^0-9]/', '', $trial_period ); |
|
223 | +function getpaid_get_subscription_trial_period_interval($trial_period) { |
|
224 | + return (int) preg_replace('/[^0-9]/', '', $trial_period); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | /** |
@@ -230,8 +230,8 @@ discard block |
||
230 | 230 | * @param string $trial_period |
231 | 231 | * @return string |
232 | 232 | */ |
233 | -function getpaid_get_subscription_trial_period_period( $trial_period ) { |
|
234 | - return preg_replace( '/[^a-z]/', '', strtolower( $trial_period ) ); |
|
233 | +function getpaid_get_subscription_trial_period_period($trial_period) { |
|
234 | + return preg_replace('/[^a-z]/', '', strtolower($trial_period)); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | /** |
@@ -241,9 +241,9 @@ discard block |
||
241 | 241 | * @param int $interval |
242 | 242 | * @return string |
243 | 243 | */ |
244 | -function getpaid_get_subscription_period_label( $period, $interval = 1, $singular_prefix = '1' ) { |
|
245 | - $label = (int) $interval > 1 ? getpaid_get_plural_subscription_period_label( $period, $interval ) : getpaid_get_singular_subscription_period_label( $period, $singular_prefix ); |
|
246 | - return strtolower( sanitize_text_field( $label ) ); |
|
244 | +function getpaid_get_subscription_period_label($period, $interval = 1, $singular_prefix = '1') { |
|
245 | + $label = (int) $interval > 1 ? getpaid_get_plural_subscription_period_label($period, $interval) : getpaid_get_singular_subscription_period_label($period, $singular_prefix); |
|
246 | + return strtolower(sanitize_text_field($label)); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
@@ -252,19 +252,19 @@ discard block |
||
252 | 252 | * @param string $period |
253 | 253 | * @return string |
254 | 254 | */ |
255 | -function getpaid_get_singular_subscription_period_label( $period, $singular_prefix = '1' ) { |
|
255 | +function getpaid_get_singular_subscription_period_label($period, $singular_prefix = '1') { |
|
256 | 256 | |
257 | 257 | $periods = getpaid_get_subscription_periods(); |
258 | - $period = strtolower( $period ); |
|
258 | + $period = strtolower($period); |
|
259 | 259 | |
260 | - if ( isset( $periods[ $period ] ) ) { |
|
261 | - return sprintf( $periods[ $period ]['singular'], $singular_prefix ); |
|
260 | + if (isset($periods[$period])) { |
|
261 | + return sprintf($periods[$period]['singular'], $singular_prefix); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | // Backwards compatibility. |
265 | - foreach ( $periods as $key => $data ) { |
|
266 | - if ( strpos( $key, $period ) === 0 ) { |
|
267 | - return sprintf( $data['singular'], $singular_prefix ); |
|
265 | + foreach ($periods as $key => $data) { |
|
266 | + if (strpos($key, $period) === 0) { |
|
267 | + return sprintf($data['singular'], $singular_prefix); |
|
268 | 268 | } |
269 | 269 | } |
270 | 270 | |
@@ -279,19 +279,19 @@ discard block |
||
279 | 279 | * @param int $interval |
280 | 280 | * @return string |
281 | 281 | */ |
282 | -function getpaid_get_plural_subscription_period_label( $period, $interval ) { |
|
282 | +function getpaid_get_plural_subscription_period_label($period, $interval) { |
|
283 | 283 | |
284 | 284 | $periods = getpaid_get_subscription_periods(); |
285 | - $period = strtolower( $period ); |
|
285 | + $period = strtolower($period); |
|
286 | 286 | |
287 | - if ( isset( $periods[ $period ] ) ) { |
|
288 | - return sprintf( $periods[ $period ]['plural'], $interval ); |
|
287 | + if (isset($periods[$period])) { |
|
288 | + return sprintf($periods[$period]['plural'], $interval); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | // Backwards compatibility. |
292 | - foreach ( $periods as $key => $data ) { |
|
293 | - if ( strpos( $key, $period ) === 0 ) { |
|
294 | - return sprintf( $data['plural'], $interval ); |
|
292 | + foreach ($periods as $key => $data) { |
|
293 | + if (strpos($key, $period) === 0) { |
|
294 | + return sprintf($data['plural'], $interval); |
|
295 | 295 | } |
296 | 296 | } |
297 | 297 | |
@@ -305,32 +305,32 @@ discard block |
||
305 | 305 | * @param WPInv_Subscription $subscription |
306 | 306 | * @return string |
307 | 307 | */ |
308 | -function getpaid_get_formatted_subscription_amount( $subscription ) { |
|
308 | +function getpaid_get_formatted_subscription_amount($subscription) { |
|
309 | 309 | |
310 | - $initial = wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
311 | - $recurring = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
312 | - $period = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ); |
|
310 | + $initial = wpinv_price($subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency()); |
|
311 | + $recurring = wpinv_price($subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency()); |
|
312 | + $period = getpaid_get_subscription_period_label($subscription->get_period(), $subscription->get_frequency(), ''); |
|
313 | 313 | $bill_times = $subscription->get_bill_times(); |
314 | 314 | |
315 | - if ( ! empty( $bill_times ) ) { |
|
315 | + if (!empty($bill_times)) { |
|
316 | 316 | $bill_times = $subscription->get_frequency() * $bill_times; |
317 | - $bill_times = getpaid_get_subscription_period_label( $subscription->get_period(), $bill_times ); |
|
317 | + $bill_times = getpaid_get_subscription_period_label($subscription->get_period(), $bill_times); |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | // Trial periods. |
321 | - if ( $subscription->has_trial_period() ) { |
|
321 | + if ($subscription->has_trial_period()) { |
|
322 | 322 | |
323 | - $trial_period = getpaid_get_subscription_trial_period_period( $subscription->get_trial_period() ); |
|
324 | - $trial_interval = getpaid_get_subscription_trial_period_interval( $subscription->get_trial_period() ); |
|
323 | + $trial_period = getpaid_get_subscription_trial_period_period($subscription->get_trial_period()); |
|
324 | + $trial_interval = getpaid_get_subscription_trial_period_interval($subscription->get_trial_period()); |
|
325 | 325 | |
326 | - if ( empty( $bill_times ) ) { |
|
326 | + if (empty($bill_times)) { |
|
327 | 327 | |
328 | 328 | return sprintf( |
329 | 329 | |
330 | 330 | // translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period |
331 | - _x( '%1$s trial for %2$s then %3$s / %4$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing' ), |
|
331 | + _x('%1$s trial for %2$s then %3$s / %4$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing'), |
|
332 | 332 | $initial, |
333 | - getpaid_get_subscription_period_label( $trial_period, $trial_interval ), |
|
333 | + getpaid_get_subscription_period_label($trial_period, $trial_interval), |
|
334 | 334 | $recurring, |
335 | 335 | $period |
336 | 336 | |
@@ -341,9 +341,9 @@ discard block |
||
341 | 341 | return sprintf( |
342 | 342 | |
343 | 343 | // translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period, $5: is the bill times |
344 | - _x( '%1$s trial for %2$s then %3$s / %4$s for %5$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year for 4 years)', 'invoicing' ), |
|
344 | + _x('%1$s trial for %2$s then %3$s / %4$s for %5$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year for 4 years)', 'invoicing'), |
|
345 | 345 | $initial, |
346 | - getpaid_get_subscription_period_label( $trial_period, $trial_interval ), |
|
346 | + getpaid_get_subscription_period_label($trial_period, $trial_interval), |
|
347 | 347 | $recurring, |
348 | 348 | $period, |
349 | 349 | $bill_times |
@@ -351,14 +351,14 @@ discard block |
||
351 | 351 | |
352 | 352 | } |
353 | 353 | |
354 | - if ( $initial != $recurring ) { |
|
354 | + if ($initial != $recurring) { |
|
355 | 355 | |
356 | - if ( empty( $bill_times ) ) { |
|
356 | + if (empty($bill_times)) { |
|
357 | 357 | |
358 | 358 | return sprintf( |
359 | 359 | |
360 | 360 | // translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period |
361 | - _x( 'Initial payment of %1$s which renews at %2$s / %3$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year)', 'invoicing' ), |
|
361 | + _x('Initial payment of %1$s which renews at %2$s / %3$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year)', 'invoicing'), |
|
362 | 362 | $initial, |
363 | 363 | $recurring, |
364 | 364 | $period |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | return sprintf( |
371 | 371 | |
372 | 372 | // translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period, $4: is the bill times |
373 | - _x( 'Initial payment of %1$s which renews at %2$s / %3$s for %4$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year for 5 years)', 'invoicing' ), |
|
373 | + _x('Initial payment of %1$s which renews at %2$s / %3$s for %4$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year for 5 years)', 'invoicing'), |
|
374 | 374 | $initial, |
375 | 375 | $recurring, |
376 | 376 | $period, |
@@ -380,12 +380,12 @@ discard block |
||
380 | 380 | |
381 | 381 | } |
382 | 382 | |
383 | - if ( empty( $bill_times ) ) { |
|
383 | + if (empty($bill_times)) { |
|
384 | 384 | |
385 | 385 | return sprintf( |
386 | 386 | |
387 | 387 | // translators: $1: is the recurring amount, $2: is the recurring period |
388 | - _x( '%1$s / %2$s', 'Subscription amount. (e.g.: $120 / year)', 'invoicing' ), |
|
388 | + _x('%1$s / %2$s', 'Subscription amount. (e.g.: $120 / year)', 'invoicing'), |
|
389 | 389 | $initial, |
390 | 390 | $period |
391 | 391 | |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | return sprintf( |
397 | 397 | |
398 | 398 | // translators: $1: is the bill times, $2: is the recurring amount, $3: is the recurring period |
399 | - _x( '%2$s / %3$s for %1$s', 'Subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing' ), |
|
399 | + _x('%2$s / %3$s for %1$s', 'Subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing'), |
|
400 | 400 | $bill_times, |
401 | 401 | $initial, |
402 | 402 | $period |
@@ -411,8 +411,8 @@ discard block |
||
411 | 411 | * @param WPInv_Invoice $invoice |
412 | 412 | * @return WPInv_Subscription|false |
413 | 413 | */ |
414 | -function getpaid_get_invoice_subscription( $invoice ) { |
|
415 | - return getpaid_subscriptions()->get_invoice_subscription( $invoice ); |
|
414 | +function getpaid_get_invoice_subscription($invoice) { |
|
415 | + return getpaid_subscriptions()->get_invoice_subscription($invoice); |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | /** |
@@ -420,9 +420,9 @@ discard block |
||
420 | 420 | * |
421 | 421 | * @param WPInv_Invoice $invoice |
422 | 422 | */ |
423 | -function getpaid_activate_invoice_subscription( $invoice ) { |
|
424 | - $subscription = getpaid_get_invoice_subscription( $invoice ); |
|
425 | - if ( is_a( $subscription, 'WPInv_Subscription' ) ) { |
|
423 | +function getpaid_activate_invoice_subscription($invoice) { |
|
424 | + $subscription = getpaid_get_invoice_subscription($invoice); |
|
425 | + if (is_a($subscription, 'WPInv_Subscription')) { |
|
426 | 426 | $subscription->activate(); |
427 | 427 | } |
428 | 428 | } |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | * @return WPInv_Subscriptions |
434 | 434 | */ |
435 | 435 | function getpaid_subscriptions() { |
436 | - return getpaid()->get( 'subscriptions' ); |
|
436 | + return getpaid()->get('subscriptions'); |
|
437 | 437 | } |
438 | 438 | |
439 | 439 | /** |
@@ -442,13 +442,13 @@ discard block |
||
442 | 442 | * @since 2.3.0 |
443 | 443 | * @return WPInv_Subscription|bool |
444 | 444 | */ |
445 | -function wpinv_get_invoice_subscription( $invoice ) { |
|
445 | +function wpinv_get_invoice_subscription($invoice) { |
|
446 | 446 | |
447 | 447 | // Retrieve the invoice. |
448 | - $invoice = new WPInv_Invoice( $invoice ); |
|
448 | + $invoice = new WPInv_Invoice($invoice); |
|
449 | 449 | |
450 | 450 | // Ensure it is a recurring invoice. |
451 | - if ( ! $invoice->is_recurring() ) { |
|
451 | + if (!$invoice->is_recurring()) { |
|
452 | 452 | return false; |
453 | 453 | } |
454 | 454 | |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | ) |
461 | 461 | ); |
462 | 462 | |
463 | - return empty( $subscription ) ? false : $subscription[0]; |
|
463 | + return empty($subscription) ? false : $subscription[0]; |
|
464 | 464 | |
465 | 465 | } |
466 | 466 | |
@@ -475,50 +475,50 @@ discard block |
||
475 | 475 | * @param GetPaid_Form_Item|WPInv_Item $cart_item |
476 | 476 | * @return string |
477 | 477 | */ |
478 | -function getpaid_get_recurring_item_key( $cart_item ) { |
|
478 | +function getpaid_get_recurring_item_key($cart_item) { |
|
479 | 479 | |
480 | 480 | $cart_key = 'renews_'; |
481 | 481 | $interval = $cart_item->get_recurring_interval(); |
482 | - $period = $cart_item->get_recurring_period( true ); |
|
482 | + $period = $cart_item->get_recurring_period(true); |
|
483 | 483 | $length = $cart_item->get_recurring_limit() * $interval; |
484 | - $trial_period = $cart_item->get_trial_period( true ); |
|
484 | + $trial_period = $cart_item->get_trial_period(true); |
|
485 | 485 | $trial_length = $cart_item->get_trial_interval(); |
486 | 486 | |
487 | 487 | // First start with the billing interval and period |
488 | - switch ( $interval ) { |
|
488 | + switch ($interval) { |
|
489 | 489 | case 1 : |
490 | - if ( 'day' == $period ) { |
|
490 | + if ('day' == $period) { |
|
491 | 491 | $cart_key .= 'daily'; |
492 | 492 | } else { |
493 | - $cart_key .= sprintf( '%sly', $period ); |
|
493 | + $cart_key .= sprintf('%sly', $period); |
|
494 | 494 | } |
495 | 495 | break; |
496 | 496 | case 2 : |
497 | - $cart_key .= sprintf( 'every_2nd_%s', $period ); |
|
497 | + $cart_key .= sprintf('every_2nd_%s', $period); |
|
498 | 498 | break; |
499 | 499 | case 3 : |
500 | - $cart_key .= sprintf( 'every_3rd_%s', $period ); |
|
500 | + $cart_key .= sprintf('every_3rd_%s', $period); |
|
501 | 501 | break; |
502 | 502 | default: |
503 | - $cart_key .= sprintf( 'every_%dth_%s', $interval, $period ); |
|
503 | + $cart_key .= sprintf('every_%dth_%s', $interval, $period); |
|
504 | 504 | break; |
505 | 505 | } |
506 | 506 | |
507 | 507 | // Maybe add the optional maximum billing periods... |
508 | - if ( $length > 0 ) { |
|
508 | + if ($length > 0) { |
|
509 | 509 | $cart_key .= '_for_'; |
510 | - $cart_key .= sprintf( '%d_%s', $length, $period ); |
|
511 | - if ( $length > 1 ) { |
|
510 | + $cart_key .= sprintf('%d_%s', $length, $period); |
|
511 | + if ($length > 1) { |
|
512 | 512 | $cart_key .= 's'; |
513 | 513 | } |
514 | 514 | } |
515 | 515 | |
516 | 516 | // And an optional free trial. |
517 | - if ( $cart_item->has_free_trial() ) { |
|
518 | - $cart_key .= sprintf( '_after_a_%d_%s_trial', $trial_length, $trial_period ); |
|
517 | + if ($cart_item->has_free_trial()) { |
|
518 | + $cart_key .= sprintf('_after_a_%d_%s_trial', $trial_length, $trial_period); |
|
519 | 519 | } |
520 | 520 | |
521 | - return apply_filters( 'getpaid_get_recurring_item_key', $cart_key, $cart_item ); |
|
521 | + return apply_filters('getpaid_get_recurring_item_key', $cart_key, $cart_item); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | /** |
@@ -527,14 +527,14 @@ discard block |
||
527 | 527 | * @param WPInv_Invoice|GetPaid_Payment_Form_Submission|GetPaid_Payment_Form $invoice |
528 | 528 | * @return array |
529 | 529 | */ |
530 | -function getpaid_get_subscription_groups( $invoice ) { |
|
530 | +function getpaid_get_subscription_groups($invoice) { |
|
531 | 531 | |
532 | 532 | // Generate subscription groups. |
533 | 533 | $subscription_groups = array(); |
534 | - foreach ( $invoice->get_items() as $item ) { |
|
534 | + foreach ($invoice->get_items() as $item) { |
|
535 | 535 | |
536 | - if ( $item->is_recurring() ) { |
|
537 | - $subscription_groups[ getpaid_get_recurring_item_key( $item ) ][] = $item; |
|
536 | + if ($item->is_recurring()) { |
|
537 | + $subscription_groups[getpaid_get_recurring_item_key($item)][] = $item; |
|
538 | 538 | } |
539 | 539 | |
540 | 540 | } |
@@ -551,19 +551,19 @@ discard block |
||
551 | 551 | * @param WPInv_Invoice|GetPaid_Payment_Form_Submission|GetPaid_Payment_Form $invoice |
552 | 552 | * @return array |
553 | 553 | */ |
554 | -function getpaid_calculate_subscription_totals( $invoice ) { |
|
554 | +function getpaid_calculate_subscription_totals($invoice) { |
|
555 | 555 | |
556 | 556 | // Generate subscription groups. |
557 | - $subscription_groups = getpaid_get_subscription_groups( $invoice ); |
|
557 | + $subscription_groups = getpaid_get_subscription_groups($invoice); |
|
558 | 558 | |
559 | 559 | // Now let's calculate the totals for each group of subscriptions |
560 | 560 | $subscription_totals = array(); |
561 | 561 | |
562 | - foreach ( $subscription_groups as $subscription_key => $items ) { |
|
562 | + foreach ($subscription_groups as $subscription_key => $items) { |
|
563 | 563 | |
564 | - if ( empty( $subscription_totals[ $subscription_key ] ) ) { |
|
564 | + if (empty($subscription_totals[$subscription_key])) { |
|
565 | 565 | |
566 | - $subscription_totals[ $subscription_key ] = array( |
|
566 | + $subscription_totals[$subscription_key] = array( |
|
567 | 567 | 'initial_total' => 0, |
568 | 568 | 'recurring_total' => 0, |
569 | 569 | 'items' => array(), |
@@ -576,34 +576,34 @@ discard block |
||
576 | 576 | * Get the totals of the group. |
577 | 577 | * @var GetPaid_Form_Item $item |
578 | 578 | */ |
579 | - foreach ( $items as $item ) { |
|
579 | + foreach ($items as $item) { |
|
580 | 580 | |
581 | - $subscription_totals[ $subscription_key ]['items'][$item->get_id()] = $item->prepare_data_for_saving(); |
|
582 | - $subscription_totals[ $subscription_key ]['item_id'] = $item->get_id(); |
|
583 | - $subscription_totals[ $subscription_key ]['period'] = $item->get_recurring_period( true ); |
|
584 | - $subscription_totals[ $subscription_key ]['interval'] = $item->get_recurring_interval(); |
|
585 | - $subscription_totals[ $subscription_key ]['initial_total'] += $item->get_sub_total() + $item->item_tax - $item->item_discount; |
|
586 | - $subscription_totals[ $subscription_key ]['recurring_total'] += $item->get_recurring_sub_total() + $item->item_tax - $item->recurring_item_discount; |
|
587 | - $subscription_totals[ $subscription_key ]['recurring_limit'] = $item->get_recurring_limit(); |
|
581 | + $subscription_totals[$subscription_key]['items'][$item->get_id()] = $item->prepare_data_for_saving(); |
|
582 | + $subscription_totals[$subscription_key]['item_id'] = $item->get_id(); |
|
583 | + $subscription_totals[$subscription_key]['period'] = $item->get_recurring_period(true); |
|
584 | + $subscription_totals[$subscription_key]['interval'] = $item->get_recurring_interval(); |
|
585 | + $subscription_totals[$subscription_key]['initial_total'] += $item->get_sub_total() + $item->item_tax - $item->item_discount; |
|
586 | + $subscription_totals[$subscription_key]['recurring_total'] += $item->get_recurring_sub_total() + $item->item_tax - $item->recurring_item_discount; |
|
587 | + $subscription_totals[$subscription_key]['recurring_limit'] = $item->get_recurring_limit(); |
|
588 | 588 | |
589 | 589 | // Calculate the next renewal date. |
590 | - $period = $item->get_recurring_period( true ); |
|
590 | + $period = $item->get_recurring_period(true); |
|
591 | 591 | $interval = $item->get_recurring_interval(); |
592 | 592 | |
593 | 593 | // If the subscription item has a trial period... |
594 | - if ( $item->has_free_trial() ) { |
|
595 | - $period = $item->get_trial_period( true ); |
|
594 | + if ($item->has_free_trial()) { |
|
595 | + $period = $item->get_trial_period(true); |
|
596 | 596 | $interval = $item->get_trial_interval(); |
597 | - $subscription_totals[ $subscription_key ]['trialling'] = $interval . ' ' . $period; |
|
597 | + $subscription_totals[$subscription_key]['trialling'] = $interval . ' ' . $period; |
|
598 | 598 | } |
599 | 599 | |
600 | - $subscription_totals[ $subscription_key ]['renews_on'] = date( 'Y-m-d H:i:s', strtotime( "+$interval $period", current_time( 'timestamp' ) ) ); |
|
600 | + $subscription_totals[$subscription_key]['renews_on'] = date('Y-m-d H:i:s', strtotime("+$interval $period", current_time('timestamp'))); |
|
601 | 601 | |
602 | 602 | } |
603 | 603 | |
604 | 604 | } |
605 | 605 | |
606 | - return apply_filters( 'getpaid_calculate_subscription_totals', $subscription_totals, $invoice ); |
|
606 | + return apply_filters('getpaid_calculate_subscription_totals', $subscription_totals, $invoice); |
|
607 | 607 | } |
608 | 608 | |
609 | 609 | /** |
@@ -612,19 +612,19 @@ discard block |
||
612 | 612 | * @param WPInv_Invoice|GetPaid_Payment_Form_Submission|GetPaid_Payment_Form $invoice |
613 | 613 | * @return array |
614 | 614 | */ |
615 | -function getpaid_should_group_subscriptions( $invoice ) { |
|
615 | +function getpaid_should_group_subscriptions($invoice) { |
|
616 | 616 | |
617 | 617 | $recurring_items = 0; |
618 | 618 | |
619 | - foreach ( $invoice->get_items() as $item ) { |
|
619 | + foreach ($invoice->get_items() as $item) { |
|
620 | 620 | |
621 | - if ( $item->is_recurring() ) { |
|
622 | - $recurring_items ++; |
|
621 | + if ($item->is_recurring()) { |
|
622 | + $recurring_items++; |
|
623 | 623 | } |
624 | 624 | |
625 | 625 | } |
626 | 626 | |
627 | - return apply_filters( 'getpaid_should_group_subscriptions', $recurring_items > 1, $invoice ); |
|
627 | + return apply_filters('getpaid_should_group_subscriptions', $recurring_items > 1, $invoice); |
|
628 | 628 | } |
629 | 629 | |
630 | 630 | /** |
@@ -634,12 +634,12 @@ discard block |
||
634 | 634 | * @param int|false $subscription_id |
635 | 635 | * @return int |
636 | 636 | */ |
637 | -function getpaid_count_subscription_invoices( $parent_invoice_id, $subscription_id = false ) { |
|
637 | +function getpaid_count_subscription_invoices($parent_invoice_id, $subscription_id = false) { |
|
638 | 638 | global $wpdb; |
639 | 639 | |
640 | 640 | $parent_invoice_id = (int) $parent_invoice_id; |
641 | 641 | |
642 | - if ( false === $subscription_id || ! (bool) get_post_meta( $parent_invoice_id, '_wpinv_subscription_id', true ) ) { |
|
642 | + if (false === $subscription_id || !(bool) get_post_meta($parent_invoice_id, '_wpinv_subscription_id', true)) { |
|
643 | 643 | |
644 | 644 | return (int) $wpdb->get_var( |
645 | 645 | $wpdb->prepare( |
@@ -661,10 +661,10 @@ discard block |
||
661 | 661 | |
662 | 662 | $count = 0; |
663 | 663 | |
664 | - foreach ( wp_parse_id_list( $invoice_ids ) as $invoice_id ) { |
|
664 | + foreach (wp_parse_id_list($invoice_ids) as $invoice_id) { |
|
665 | 665 | |
666 | - if ( $invoice_id == $parent_invoice_id || $subscription_id == (int) get_post_meta( $invoice_id, '_wpinv_subscription_id', true ) ) { |
|
667 | - $count ++; |
|
666 | + if ($invoice_id == $parent_invoice_id || $subscription_id == (int) get_post_meta($invoice_id, '_wpinv_subscription_id', true)) { |
|
667 | + $count++; |
|
668 | 668 | continue; |
669 | 669 | } |
670 | 670 |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Payment form submission taxes class |
@@ -29,22 +29,22 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @param GetPaid_Payment_Form_Submission $submission |
31 | 31 | */ |
32 | - public function __construct( $submission ) { |
|
32 | + public function __construct($submission) { |
|
33 | 33 | |
34 | 34 | // Validate VAT number. |
35 | - $this->validate_vat( $submission ); |
|
35 | + $this->validate_vat($submission); |
|
36 | 36 | |
37 | - if ( $this->skip_taxes ) { |
|
37 | + if ($this->skip_taxes) { |
|
38 | 38 | return; |
39 | 39 | } |
40 | 40 | |
41 | - foreach ( $submission->get_items() as $item ) { |
|
42 | - $this->process_item_tax( $item, $submission ); |
|
41 | + foreach ($submission->get_items() as $item) { |
|
42 | + $this->process_item_tax($item, $submission); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | // Process any existing invoice taxes. |
46 | - if ( $submission->has_invoice() ) { |
|
47 | - $this->taxes = array_replace( $submission->get_invoice()->get_taxes(), $this->taxes ); |
|
46 | + if ($submission->has_invoice()) { |
|
47 | + $this->taxes = array_replace($submission->get_invoice()->get_taxes(), $this->taxes); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | } |
@@ -56,26 +56,26 @@ discard block |
||
56 | 56 | * @param GetPaid_Form_Item $item |
57 | 57 | * @param GetPaid_Payment_Form_Submission $submission |
58 | 58 | */ |
59 | - public function process_item_tax( $item, $submission ) { |
|
59 | + public function process_item_tax($item, $submission) { |
|
60 | 60 | |
61 | - $rates = getpaid_get_item_tax_rates( $item, $submission->country, $submission->state ); |
|
62 | - $rates = getpaid_filter_item_tax_rates( $item, $rates ); |
|
63 | - $taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates ); |
|
64 | - $r_taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates ); |
|
61 | + $rates = getpaid_get_item_tax_rates($item, $submission->country, $submission->state); |
|
62 | + $rates = getpaid_filter_item_tax_rates($item, $rates); |
|
63 | + $taxes = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, false), $rates); |
|
64 | + $r_taxes = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, true), $rates); |
|
65 | 65 | |
66 | - foreach ( $taxes as $name => $amount ) { |
|
67 | - $recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0; |
|
68 | - $tax = getpaid_prepare_item_tax( $item, $name, $amount, $recurring ); |
|
66 | + foreach ($taxes as $name => $amount) { |
|
67 | + $recurring = isset($r_taxes[$name]) ? $r_taxes[$name] : 0; |
|
68 | + $tax = getpaid_prepare_item_tax($item, $name, $amount, $recurring); |
|
69 | 69 | |
70 | - $item->item_tax += wpinv_sanitize_amount( $tax['initial_tax'] ); |
|
70 | + $item->item_tax += wpinv_sanitize_amount($tax['initial_tax']); |
|
71 | 71 | |
72 | - if ( ! isset( $this->taxes[ $name ] ) ) { |
|
73 | - $this->taxes[ $name ] = $tax; |
|
72 | + if (!isset($this->taxes[$name])) { |
|
73 | + $this->taxes[$name] = $tax; |
|
74 | 74 | continue; |
75 | 75 | } |
76 | 76 | |
77 | - $this->taxes[ $name ]['initial_tax'] += $tax['initial_tax']; |
|
78 | - $this->taxes[ $name ]['recurring_tax'] += $tax['recurring_tax']; |
|
77 | + $this->taxes[$name]['initial_tax'] += $tax['initial_tax']; |
|
78 | + $this->taxes[$name]['recurring_tax'] += $tax['recurring_tax']; |
|
79 | 79 | |
80 | 80 | } |
81 | 81 | |
@@ -88,11 +88,11 @@ discard block |
||
88 | 88 | * @since 1.0.19 |
89 | 89 | * @return bool |
90 | 90 | */ |
91 | - public function has_digital_item( $submission ) { |
|
91 | + public function has_digital_item($submission) { |
|
92 | 92 | |
93 | - foreach ( $submission->get_items() as $item ) { |
|
93 | + foreach ($submission->get_items() as $item) { |
|
94 | 94 | |
95 | - if ( 'digital' == $item->get_vat_rule() ) { |
|
95 | + if ('digital' == $item->get_vat_rule()) { |
|
96 | 96 | return true; |
97 | 97 | } |
98 | 98 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * @return bool |
109 | 109 | */ |
110 | 110 | public static function is_eu_store() { |
111 | - return self::is_eu_country( wpinv_get_default_country() ); |
|
111 | + return self::is_eu_country(wpinv_get_default_country()); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -118,8 +118,8 @@ discard block |
||
118 | 118 | * @since 1.0.19 |
119 | 119 | * @return bool |
120 | 120 | */ |
121 | - public static function is_eu_country( $country ) { |
|
122 | - return getpaid_is_eu_state( $country ); |
|
121 | + public static function is_eu_country($country) { |
|
122 | + return getpaid_is_eu_state($country); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | * @since 1.0.19 |
130 | 130 | * @return bool |
131 | 131 | */ |
132 | - public static function is_eu_transaction( $customer_country ) { |
|
133 | - return self::is_eu_country( $customer_country ) && self::is_eu_store(); |
|
132 | + public static function is_eu_transaction($customer_country) { |
|
133 | + return self::is_eu_country($customer_country) && self::is_eu_store(); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -140,12 +140,12 @@ discard block |
||
140 | 140 | * @since 1.0.19 |
141 | 141 | * @return string |
142 | 142 | */ |
143 | - public function get_vat_number( $submission ) { |
|
143 | + public function get_vat_number($submission) { |
|
144 | 144 | |
145 | 145 | // Retrieve from the posted number. |
146 | - $vat_number = $submission->get_field( 'wpinv_vat_number', 'billing' ); |
|
147 | - if ( ! is_null( $vat_number ) ) { |
|
148 | - return wpinv_clean( $vat_number ); |
|
146 | + $vat_number = $submission->get_field('wpinv_vat_number', 'billing'); |
|
147 | + if (!is_null($vat_number)) { |
|
148 | + return wpinv_clean($vat_number); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | return $submission->has_invoice() ? $submission->get_invoice()->get_vat_number() : ''; |
@@ -158,12 +158,12 @@ discard block |
||
158 | 158 | * @since 1.0.19 |
159 | 159 | * @return string |
160 | 160 | */ |
161 | - public function get_company( $submission ) { |
|
161 | + public function get_company($submission) { |
|
162 | 162 | |
163 | 163 | // Retrieve from the posted data. |
164 | - $company = $submission->get_field( 'wpinv_company', 'billing' ); |
|
165 | - if ( ! empty( $company ) ) { |
|
166 | - return wpinv_clean( $company ); |
|
164 | + $company = $submission->get_field('wpinv_company', 'billing'); |
|
165 | + if (!empty($company)) { |
|
166 | + return wpinv_clean($company); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | // Retrieve from the invoice. |
@@ -178,10 +178,10 @@ discard block |
||
178 | 178 | * @since 1.0.19 |
179 | 179 | * @return string |
180 | 180 | */ |
181 | - public function requires_vat( $ip_in_eu, $country_in_eu ) { |
|
181 | + public function requires_vat($ip_in_eu, $country_in_eu) { |
|
182 | 182 | |
183 | - $prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' ); |
|
184 | - $prevent_b2c = ! empty( $prevent_b2c ); |
|
183 | + $prevent_b2c = wpinv_get_option('vat_prevent_b2c_purchase'); |
|
184 | + $prevent_b2c = !empty($prevent_b2c); |
|
185 | 185 | $is_eu = $ip_in_eu || $country_in_eu; |
186 | 186 | |
187 | 187 | return $prevent_b2c && $is_eu; |
@@ -193,45 +193,45 @@ discard block |
||
193 | 193 | * @param GetPaid_Payment_Form_Submission $submission |
194 | 194 | * @since 1.0.19 |
195 | 195 | */ |
196 | - public function validate_vat( $submission ) { |
|
196 | + public function validate_vat($submission) { |
|
197 | 197 | |
198 | - $in_eu = $this->is_eu_transaction( $submission->country ); |
|
198 | + $in_eu = $this->is_eu_transaction($submission->country); |
|
199 | 199 | |
200 | 200 | // Abort if we are not validating vat numbers. |
201 | - if ( ! $in_eu ) { |
|
201 | + if (!$in_eu) { |
|
202 | 202 | return; |
203 | 203 | } |
204 | 204 | |
205 | 205 | // Prepare variables. |
206 | - $vat_number = $this->get_vat_number( $submission ); |
|
206 | + $vat_number = $this->get_vat_number($submission); |
|
207 | 207 | $ip_country = getpaid_get_ip_country(); |
208 | - $is_eu = $this->is_eu_country( $submission->country ); |
|
209 | - $is_ip_eu = $this->is_eu_country( $ip_country ); |
|
208 | + $is_eu = $this->is_eu_country($submission->country); |
|
209 | + $is_ip_eu = $this->is_eu_country($ip_country); |
|
210 | 210 | |
211 | 211 | // Maybe abort early for initial fetches. |
212 | - if ( $submission->is_initial_fetch() && empty( $vat_number ) ) { |
|
212 | + if ($submission->is_initial_fetch() && empty($vat_number)) { |
|
213 | 213 | return; |
214 | 214 | } |
215 | 215 | |
216 | 216 | // If we're preventing business to consumer purchases, |
217 | - if ( $this->requires_vat( $is_ip_eu, $is_eu ) && empty( $vat_number ) ) { |
|
217 | + if ($this->requires_vat($is_ip_eu, $is_eu) && empty($vat_number)) { |
|
218 | 218 | |
219 | 219 | // Ensure that a vat number has been specified. |
220 | 220 | throw new Exception( |
221 | - __( 'Please enter your VAT number to verify your purchase is by an EU business.', 'invoicing' ) |
|
221 | + __('Please enter your VAT number to verify your purchase is by an EU business.', 'invoicing') |
|
222 | 222 | ); |
223 | 223 | |
224 | 224 | } |
225 | 225 | |
226 | - if ( empty( $vat_number ) ) { |
|
226 | + if (empty($vat_number)) { |
|
227 | 227 | return; |
228 | 228 | } |
229 | 229 | |
230 | - if ( wpinv_should_validate_vat_number() && ! wpinv_validate_vat_number( $vat_number, $submission->country ) ) { |
|
231 | - throw new Exception( __( 'Your VAT number is invalid', 'invoicing' ) ); |
|
230 | + if (wpinv_should_validate_vat_number() && !wpinv_validate_vat_number($vat_number, $submission->country)) { |
|
231 | + throw new Exception(__('Your VAT number is invalid', 'invoicing')); |
|
232 | 232 | } |
233 | 233 | |
234 | - if ( wpinv_default_billing_country() == $submission->country && 'vat_too' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) { |
|
234 | + if (wpinv_default_billing_country() == $submission->country && 'vat_too' == wpinv_get_option('vat_same_country_rule', 'vat_too')) { |
|
235 | 235 | return; |
236 | 236 | } |
237 | 237 |
@@ -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,20 +390,20 @@ 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 | - if ( ! is_a( $invoice, 'WPInv_Invoice' ) ) { |
|
402 | - $invoice = new WPInv_Invoice( $invoice ); |
|
401 | + if (!is_a($invoice, 'WPInv_Invoice')) { |
|
402 | + $invoice = new WPInv_Invoice($invoice); |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | // Check if it exists. |
406 | - if ( $invoice->exists() ) { |
|
406 | + if ($invoice->exists()) { |
|
407 | 407 | return $invoice; |
408 | 408 | } |
409 | 409 | |
@@ -416,15 +416,15 @@ discard block |
||
416 | 416 | * @param array $args Args to search for. |
417 | 417 | * @return WPInv_Invoice[]|int[]|object |
418 | 418 | */ |
419 | -function wpinv_get_invoices( $args ) { |
|
419 | +function wpinv_get_invoices($args) { |
|
420 | 420 | |
421 | 421 | // Prepare args. |
422 | 422 | $args = wp_parse_args( |
423 | 423 | $args, |
424 | 424 | array( |
425 | - 'status' => array_keys( wpinv_get_invoice_statuses() ), |
|
425 | + 'status' => array_keys(wpinv_get_invoice_statuses()), |
|
426 | 426 | 'type' => 'wpi_invoice', |
427 | - 'limit' => get_option( 'posts_per_page' ), |
|
427 | + 'limit' => get_option('posts_per_page'), |
|
428 | 428 | 'return' => 'objects', |
429 | 429 | ) |
430 | 430 | ); |
@@ -442,24 +442,24 @@ discard block |
||
442 | 442 | 'post__in' => 'include', |
443 | 443 | ); |
444 | 444 | |
445 | - foreach ( $map_legacy as $to => $from ) { |
|
446 | - if ( isset( $args[ $from ] ) ) { |
|
447 | - $args[ $to ] = $args[ $from ]; |
|
448 | - unset( $args[ $from ] ); |
|
445 | + foreach ($map_legacy as $to => $from) { |
|
446 | + if (isset($args[$from])) { |
|
447 | + $args[$to] = $args[$from]; |
|
448 | + unset($args[$from]); |
|
449 | 449 | } |
450 | 450 | } |
451 | 451 | |
452 | 452 | // Backwards compatibility. |
453 | - if ( ! empty( $args['email'] ) && empty( $args['user'] ) ) { |
|
453 | + if (!empty($args['email']) && empty($args['user'])) { |
|
454 | 454 | $args['user'] = $args['email']; |
455 | - unset( $args['email'] ); |
|
455 | + unset($args['email']); |
|
456 | 456 | } |
457 | 457 | |
458 | 458 | // Handle cases where the user is set as an email. |
459 | - if ( ! empty( $args['author'] ) && is_email( $args['author'] ) ) { |
|
460 | - $user = get_user_by( 'email', $args['user'] ); |
|
459 | + if (!empty($args['author']) && is_email($args['author'])) { |
|
460 | + $user = get_user_by('email', $args['user']); |
|
461 | 461 | |
462 | - if ( $user ) { |
|
462 | + if ($user) { |
|
463 | 463 | $args['author'] = $user->user_email; |
464 | 464 | } |
465 | 465 | |
@@ -470,31 +470,31 @@ discard block |
||
470 | 470 | |
471 | 471 | // Show all posts. |
472 | 472 | $paginate = true; |
473 | - if ( isset( $args['paginate'] ) ) { |
|
473 | + if (isset($args['paginate'])) { |
|
474 | 474 | |
475 | 475 | $paginate = $args['paginate']; |
476 | - $args['no_found_rows'] = empty( $args['paginate'] ); |
|
477 | - unset( $args['paginate'] ); |
|
476 | + $args['no_found_rows'] = empty($args['paginate']); |
|
477 | + unset($args['paginate']); |
|
478 | 478 | |
479 | 479 | } |
480 | 480 | |
481 | 481 | // Whether to return objects or fields. |
482 | 482 | $return = $args['return']; |
483 | - unset( $args['return'] ); |
|
483 | + unset($args['return']); |
|
484 | 484 | |
485 | 485 | // Get invoices. |
486 | - $invoices = new WP_Query( apply_filters( 'wpinv_get_invoices_args', $args ) ); |
|
486 | + $invoices = new WP_Query(apply_filters('wpinv_get_invoices_args', $args)); |
|
487 | 487 | |
488 | 488 | // Prepare the results. |
489 | - if ( 'objects' === $return ) { |
|
490 | - $results = array_map( 'wpinv_get_invoice', $invoices->posts ); |
|
491 | - } elseif ( 'self' === $return ) { |
|
489 | + if ('objects' === $return) { |
|
490 | + $results = array_map('wpinv_get_invoice', $invoices->posts); |
|
491 | + } elseif ('self' === $return) { |
|
492 | 492 | return $invoices; |
493 | 493 | } else { |
494 | 494 | $results = $invoices->posts; |
495 | 495 | } |
496 | 496 | |
497 | - if ( $paginate ) { |
|
497 | + if ($paginate) { |
|
498 | 498 | return (object) array( |
499 | 499 | 'invoices' => $results, |
500 | 500 | 'total' => $invoices->found_posts, |
@@ -512,8 +512,8 @@ discard block |
||
512 | 512 | * @param string $transaction_id The transaction id to check. |
513 | 513 | * @return int Invoice id on success or 0 on failure |
514 | 514 | */ |
515 | -function wpinv_get_id_by_transaction_id( $transaction_id ) { |
|
516 | - return WPInv_Invoice::get_invoice_id_by_field( $transaction_id, 'transaction_id' ); |
|
515 | +function wpinv_get_id_by_transaction_id($transaction_id) { |
|
516 | + return WPInv_Invoice::get_invoice_id_by_field($transaction_id, 'transaction_id'); |
|
517 | 517 | } |
518 | 518 | |
519 | 519 | /** |
@@ -522,8 +522,8 @@ discard block |
||
522 | 522 | * @param string $invoice_number The invoice number to check. |
523 | 523 | * @return int Invoice id on success or 0 on failure |
524 | 524 | */ |
525 | -function wpinv_get_id_by_invoice_number( $invoice_number ) { |
|
526 | - return WPInv_Invoice::get_invoice_id_by_field( $invoice_number, 'number' ); |
|
525 | +function wpinv_get_id_by_invoice_number($invoice_number) { |
|
526 | + return WPInv_Invoice::get_invoice_id_by_field($invoice_number, 'number'); |
|
527 | 527 | } |
528 | 528 | |
529 | 529 | /** |
@@ -532,8 +532,8 @@ discard block |
||
532 | 532 | * @param string $invoice_key The invoice key to check. |
533 | 533 | * @return int Invoice id on success or 0 on failure |
534 | 534 | */ |
535 | -function wpinv_get_invoice_id_by_key( $invoice_key ) { |
|
536 | - return WPInv_Invoice::get_invoice_id_by_field( $invoice_key, 'key' ); |
|
535 | +function wpinv_get_invoice_id_by_key($invoice_key) { |
|
536 | + return WPInv_Invoice::get_invoice_id_by_field($invoice_key, 'key'); |
|
537 | 537 | } |
538 | 538 | |
539 | 539 | /** |
@@ -543,19 +543,19 @@ discard block |
||
543 | 543 | * @param string $type Optionally filter by type i.e customer|system |
544 | 544 | * @return array|null |
545 | 545 | */ |
546 | -function wpinv_get_invoice_notes( $invoice = 0, $type = '' ) { |
|
546 | +function wpinv_get_invoice_notes($invoice = 0, $type = '') { |
|
547 | 547 | |
548 | 548 | // Prepare the invoice. |
549 | - $invoice = wpinv_get_invoice( $invoice ); |
|
550 | - if ( empty( $invoice ) ) { |
|
549 | + $invoice = wpinv_get_invoice($invoice); |
|
550 | + if (empty($invoice)) { |
|
551 | 551 | return NULL; |
552 | 552 | } |
553 | 553 | |
554 | 554 | // Fetch notes. |
555 | - $notes = getpaid_notes()->get_invoice_notes( $invoice->get_id(), $type ); |
|
555 | + $notes = getpaid_notes()->get_invoice_notes($invoice->get_id(), $type); |
|
556 | 556 | |
557 | 557 | // Filter the notes. |
558 | - return apply_filters( 'wpinv_invoice_notes', $notes, $invoice->get_id(), $type ); |
|
558 | + return apply_filters('wpinv_invoice_notes', $notes, $invoice->get_id(), $type); |
|
559 | 559 | } |
560 | 560 | |
561 | 561 | /** |
@@ -563,10 +563,10 @@ discard block |
||
563 | 563 | * |
564 | 564 | * @param string $post_type |
565 | 565 | */ |
566 | -function wpinv_get_user_invoices_columns( $post_type = 'wpi_invoice' ) { |
|
566 | +function wpinv_get_user_invoices_columns($post_type = 'wpi_invoice') { |
|
567 | 567 | |
568 | - $label = getpaid_get_post_type_label( $post_type, false ); |
|
569 | - $label = empty( $label ) ? __( 'Invoice', 'invoicing' ) : sanitize_text_field( $label ); |
|
568 | + $label = getpaid_get_post_type_label($post_type, false); |
|
569 | + $label = empty($label) ? __('Invoice', 'invoicing') : sanitize_text_field($label); |
|
570 | 570 | $columns = array( |
571 | 571 | |
572 | 572 | 'invoice-number' => array( |
@@ -575,22 +575,22 @@ discard block |
||
575 | 575 | ), |
576 | 576 | |
577 | 577 | 'created-date' => array( |
578 | - 'title' => __( 'Created Date', 'invoicing' ), |
|
578 | + 'title' => __('Created Date', 'invoicing'), |
|
579 | 579 | 'class' => 'text-left' |
580 | 580 | ), |
581 | 581 | |
582 | 582 | 'payment-date' => array( |
583 | - 'title' => __( 'Payment Date', 'invoicing' ), |
|
583 | + 'title' => __('Payment Date', 'invoicing'), |
|
584 | 584 | 'class' => 'text-left' |
585 | 585 | ), |
586 | 586 | |
587 | 587 | 'invoice-status' => array( |
588 | - 'title' => __( 'Status', 'invoicing' ), |
|
588 | + 'title' => __('Status', 'invoicing'), |
|
589 | 589 | 'class' => 'text-center' |
590 | 590 | ), |
591 | 591 | |
592 | 592 | 'invoice-total' => array( |
593 | - 'title' => __( 'Total', 'invoicing' ), |
|
593 | + 'title' => __('Total', 'invoicing'), |
|
594 | 594 | 'class' => 'text-right' |
595 | 595 | ), |
596 | 596 | |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | |
602 | 602 | ); |
603 | 603 | |
604 | - return apply_filters( 'wpinv_user_invoices_columns', $columns, $post_type ); |
|
604 | + return apply_filters('wpinv_user_invoices_columns', $columns, $post_type); |
|
605 | 605 | } |
606 | 606 | |
607 | 607 | /** |
@@ -611,59 +611,59 @@ discard block |
||
611 | 611 | |
612 | 612 | // Find the invoice. |
613 | 613 | $invoice_id = getpaid_get_current_invoice_id(); |
614 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
614 | + $invoice = new WPInv_Invoice($invoice_id); |
|
615 | 615 | |
616 | 616 | // Abort if non was found. |
617 | - if ( empty( $invoice_id ) || $invoice->is_draft() ) { |
|
617 | + if (empty($invoice_id) || $invoice->is_draft()) { |
|
618 | 618 | |
619 | 619 | return aui()->alert( |
620 | 620 | array( |
621 | 621 | 'type' => 'warning', |
622 | - 'content' => __( 'We could not find your invoice', 'invoicing' ), |
|
622 | + 'content' => __('We could not find your invoice', 'invoicing'), |
|
623 | 623 | ) |
624 | 624 | ); |
625 | 625 | |
626 | 626 | } |
627 | 627 | |
628 | 628 | // Can the user view this invoice? |
629 | - if ( ! wpinv_can_view_receipt( $invoice_id ) ) { |
|
629 | + if (!wpinv_can_view_receipt($invoice_id)) { |
|
630 | 630 | |
631 | 631 | return aui()->alert( |
632 | 632 | array( |
633 | 633 | 'type' => 'warning', |
634 | - 'content' => __( 'You are not allowed to view this receipt', 'invoicing' ), |
|
634 | + 'content' => __('You are not allowed to view this receipt', 'invoicing'), |
|
635 | 635 | ) |
636 | 636 | ); |
637 | 637 | |
638 | 638 | } |
639 | 639 | |
640 | 640 | // Load the template. |
641 | - return wpinv_get_template_html( 'invoice-receipt.php', compact( 'invoice' ) ); |
|
641 | + return wpinv_get_template_html('invoice-receipt.php', compact('invoice')); |
|
642 | 642 | |
643 | 643 | } |
644 | 644 | |
645 | 645 | /** |
646 | 646 | * Displays the invoice history. |
647 | 647 | */ |
648 | -function getpaid_invoice_history( $user_id = 0, $post_type = 'wpi_invoice' ) { |
|
648 | +function getpaid_invoice_history($user_id = 0, $post_type = 'wpi_invoice') { |
|
649 | 649 | |
650 | 650 | // Ensure that we have a user id. |
651 | - if ( empty( $user_id ) || ! is_numeric( $user_id ) ) { |
|
651 | + if (empty($user_id) || !is_numeric($user_id)) { |
|
652 | 652 | $user_id = get_current_user_id(); |
653 | 653 | } |
654 | 654 | |
655 | - $label = getpaid_get_post_type_label( $post_type ); |
|
656 | - $label = empty( $label ) ? __( 'Invoices', 'invoicing' ) : sanitize_text_field( $label ); |
|
655 | + $label = getpaid_get_post_type_label($post_type); |
|
656 | + $label = empty($label) ? __('Invoices', 'invoicing') : sanitize_text_field($label); |
|
657 | 657 | |
658 | 658 | // View user id. |
659 | - if ( empty( $user_id ) ) { |
|
659 | + if (empty($user_id)) { |
|
660 | 660 | |
661 | 661 | return aui()->alert( |
662 | 662 | array( |
663 | 663 | 'type' => 'warning', |
664 | 664 | 'content' => sprintf( |
665 | - __( 'You must be logged in to view your %s.', 'invoicing' ), |
|
666 | - strtolower( $label ) |
|
665 | + __('You must be logged in to view your %s.', 'invoicing'), |
|
666 | + strtolower($label) |
|
667 | 667 | ) |
668 | 668 | ) |
669 | 669 | ); |
@@ -674,23 +674,23 @@ discard block |
||
674 | 674 | $invoices = wpinv_get_invoices( |
675 | 675 | |
676 | 676 | array( |
677 | - 'page' => ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1, |
|
677 | + 'page' => (get_query_var('paged')) ? absint(get_query_var('paged')) : 1, |
|
678 | 678 | 'user' => $user_id, |
679 | 679 | 'paginate' => true, |
680 | 680 | 'type' => $post_type, |
681 | - 'status' => array_keys( wpinv_get_invoice_statuses( false, false, $post_type ) ), |
|
681 | + 'status' => array_keys(wpinv_get_invoice_statuses(false, false, $post_type)), |
|
682 | 682 | ) |
683 | 683 | |
684 | 684 | ); |
685 | 685 | |
686 | - if ( empty( $invoices->total ) ) { |
|
686 | + if (empty($invoices->total)) { |
|
687 | 687 | |
688 | 688 | return aui()->alert( |
689 | 689 | array( |
690 | 690 | 'type' => 'info', |
691 | 691 | 'content' => sprintf( |
692 | - __( 'No %s found.', 'invoicing' ), |
|
693 | - strtolower( $label ) |
|
692 | + __('No %s found.', 'invoicing'), |
|
693 | + strtolower($label) |
|
694 | 694 | ) |
695 | 695 | ) |
696 | 696 | ); |
@@ -698,38 +698,38 @@ discard block |
||
698 | 698 | } |
699 | 699 | |
700 | 700 | // Load the template. |
701 | - return wpinv_get_template_html( 'invoice-history.php', compact( 'invoices', 'post_type' ) ); |
|
701 | + return wpinv_get_template_html('invoice-history.php', compact('invoices', 'post_type')); |
|
702 | 702 | |
703 | 703 | } |
704 | 704 | |
705 | 705 | /** |
706 | 706 | * Formats an invoice number given an invoice type. |
707 | 707 | */ |
708 | -function wpinv_format_invoice_number( $number, $type = '' ) { |
|
708 | +function wpinv_format_invoice_number($number, $type = '') { |
|
709 | 709 | |
710 | 710 | // Allow other plugins to overide this. |
711 | - $check = apply_filters( 'wpinv_pre_format_invoice_number', null, $number, $type ); |
|
712 | - if ( null !== $check ) { |
|
711 | + $check = apply_filters('wpinv_pre_format_invoice_number', null, $number, $type); |
|
712 | + if (null !== $check) { |
|
713 | 713 | return $check; |
714 | 714 | } |
715 | 715 | |
716 | 716 | // Ensure that we have a numeric number. |
717 | - if ( ! is_numeric( $number ) ) { |
|
717 | + if (!is_numeric($number)) { |
|
718 | 718 | return $number; |
719 | 719 | } |
720 | 720 | |
721 | 721 | // Format the number. |
722 | - $padd = absint( (int) wpinv_get_option( 'invoice_number_padd', 5 ) ); |
|
723 | - $prefix = sanitize_text_field( (string) wpinv_get_option( 'invoice_number_prefix', 'INV-' ) ); |
|
724 | - $prefix = sanitize_text_field( apply_filters( 'getpaid_invoice_type_prefix', $prefix, $type ) ); |
|
725 | - $postfix = sanitize_text_field( (string) wpinv_get_option( 'invoice_number_postfix' ) ); |
|
726 | - $postfix = sanitize_text_field( apply_filters( 'getpaid_invoice_type_postfix', $postfix, $type ) ); |
|
727 | - $formatted_number = zeroise( absint( $number ), $padd ); |
|
722 | + $padd = absint((int) wpinv_get_option('invoice_number_padd', 5)); |
|
723 | + $prefix = sanitize_text_field((string) wpinv_get_option('invoice_number_prefix', 'INV-')); |
|
724 | + $prefix = sanitize_text_field(apply_filters('getpaid_invoice_type_prefix', $prefix, $type)); |
|
725 | + $postfix = sanitize_text_field((string) wpinv_get_option('invoice_number_postfix')); |
|
726 | + $postfix = sanitize_text_field(apply_filters('getpaid_invoice_type_postfix', $postfix, $type)); |
|
727 | + $formatted_number = zeroise(absint($number), $padd); |
|
728 | 728 | |
729 | 729 | // Add the prefix and post fix. |
730 | 730 | $formatted_number = $prefix . $formatted_number . $postfix; |
731 | 731 | |
732 | - return apply_filters( 'wpinv_format_invoice_number', $formatted_number, $number, $prefix, $postfix, $padd ); |
|
732 | + return apply_filters('wpinv_format_invoice_number', $formatted_number, $number, $prefix, $postfix, $padd); |
|
733 | 733 | } |
734 | 734 | |
735 | 735 | /** |
@@ -738,58 +738,58 @@ discard block |
||
738 | 738 | * @param string $type. |
739 | 739 | * @return int|null|bool |
740 | 740 | */ |
741 | -function wpinv_get_next_invoice_number( $type = '' ) { |
|
741 | +function wpinv_get_next_invoice_number($type = '') { |
|
742 | 742 | |
743 | 743 | // Allow plugins to overide this. |
744 | - $check = apply_filters( 'wpinv_get_pre_next_invoice_number', null, $type ); |
|
745 | - if ( null !== $check ) { |
|
744 | + $check = apply_filters('wpinv_get_pre_next_invoice_number', null, $type); |
|
745 | + if (null !== $check) { |
|
746 | 746 | return $check; |
747 | 747 | } |
748 | 748 | |
749 | 749 | // Ensure sequential invoice numbers is active. |
750 | - if ( ! wpinv_sequential_number_active() ) { |
|
750 | + if (!wpinv_sequential_number_active()) { |
|
751 | 751 | return false; |
752 | 752 | } |
753 | 753 | |
754 | 754 | // Retrieve the current number and the start number. |
755 | - $number = (int) get_option( 'wpinv_last_invoice_number', 0 ); |
|
756 | - $start = absint( (int) wpinv_get_option( 'invoice_sequence_start', 1 ) ); |
|
755 | + $number = (int) get_option('wpinv_last_invoice_number', 0); |
|
756 | + $start = absint((int) wpinv_get_option('invoice_sequence_start', 1)); |
|
757 | 757 | |
758 | 758 | // Ensure that we are starting at a positive integer. |
759 | - $start = max( $start, 1 ); |
|
759 | + $start = max($start, 1); |
|
760 | 760 | |
761 | 761 | // If this is the first invoice, use the start number. |
762 | - $number = max( $start, $number ); |
|
762 | + $number = max($start, $number); |
|
763 | 763 | |
764 | 764 | // Format the invoice number. |
765 | - $formatted_number = wpinv_format_invoice_number( $number, $type ); |
|
765 | + $formatted_number = wpinv_format_invoice_number($number, $type); |
|
766 | 766 | |
767 | 767 | // Ensure that this number is unique. |
768 | - $invoice_id = WPInv_Invoice::get_invoice_id_by_field( $formatted_number, 'number' ); |
|
768 | + $invoice_id = WPInv_Invoice::get_invoice_id_by_field($formatted_number, 'number'); |
|
769 | 769 | |
770 | 770 | // We found a match. Nice. |
771 | - if ( empty( $invoice_id ) ) { |
|
772 | - update_option( 'wpinv_last_invoice_number', $number ); |
|
773 | - return apply_filters( 'wpinv_get_next_invoice_number', $number ); |
|
771 | + if (empty($invoice_id)) { |
|
772 | + update_option('wpinv_last_invoice_number', $number); |
|
773 | + return apply_filters('wpinv_get_next_invoice_number', $number); |
|
774 | 774 | } |
775 | 775 | |
776 | - update_option( 'wpinv_last_invoice_number', $number + 1 ); |
|
777 | - return wpinv_get_next_invoice_number( $type ); |
|
776 | + update_option('wpinv_last_invoice_number', $number + 1); |
|
777 | + return wpinv_get_next_invoice_number($type); |
|
778 | 778 | |
779 | 779 | } |
780 | 780 | |
781 | 781 | /** |
782 | 782 | * The prefix used for invoice paths. |
783 | 783 | */ |
784 | -function wpinv_post_name_prefix( $post_type = 'wpi_invoice' ) { |
|
785 | - return apply_filters( 'wpinv_post_name_prefix', 'inv-', $post_type ); |
|
784 | +function wpinv_post_name_prefix($post_type = 'wpi_invoice') { |
|
785 | + return apply_filters('wpinv_post_name_prefix', 'inv-', $post_type); |
|
786 | 786 | } |
787 | 787 | |
788 | -function wpinv_generate_post_name( $post_ID ) { |
|
789 | - $prefix = wpinv_post_name_prefix( get_post_type( $post_ID ) ); |
|
790 | - $post_name = sanitize_title( $prefix . $post_ID ); |
|
788 | +function wpinv_generate_post_name($post_ID) { |
|
789 | + $prefix = wpinv_post_name_prefix(get_post_type($post_ID)); |
|
790 | + $post_name = sanitize_title($prefix . $post_ID); |
|
791 | 791 | |
792 | - return apply_filters( 'wpinv_generate_post_name', $post_name, $post_ID, $prefix ); |
|
792 | + return apply_filters('wpinv_generate_post_name', $post_name, $post_ID, $prefix); |
|
793 | 793 | } |
794 | 794 | |
795 | 795 | /** |
@@ -797,8 +797,8 @@ discard block |
||
797 | 797 | * |
798 | 798 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object. |
799 | 799 | */ |
800 | -function wpinv_is_invoice_viewed( $invoice ) { |
|
801 | - $invoice = new WPInv_Invoice( $invoice ); |
|
800 | +function wpinv_is_invoice_viewed($invoice) { |
|
801 | + $invoice = new WPInv_Invoice($invoice); |
|
802 | 802 | return (bool) $invoice->get_is_viewed(); |
803 | 803 | } |
804 | 804 | |
@@ -807,17 +807,17 @@ discard block |
||
807 | 807 | * |
808 | 808 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object. |
809 | 809 | */ |
810 | -function getpaid_maybe_mark_invoice_as_viewed( $invoice ) { |
|
811 | - $invoice = new WPInv_Invoice( $invoice ); |
|
810 | +function getpaid_maybe_mark_invoice_as_viewed($invoice) { |
|
811 | + $invoice = new WPInv_Invoice($invoice); |
|
812 | 812 | |
813 | - if ( get_current_user_id() == $invoice->get_user_id() && ! $invoice->get_is_viewed() ) { |
|
814 | - $invoice->set_is_viewed( true ); |
|
813 | + if (get_current_user_id() == $invoice->get_user_id() && !$invoice->get_is_viewed()) { |
|
814 | + $invoice->set_is_viewed(true); |
|
815 | 815 | $invoice->save(); |
816 | 816 | } |
817 | 817 | |
818 | 818 | } |
819 | -add_action( 'wpinv_invoice_print_before_display', 'getpaid_maybe_mark_invoice_as_viewed' ); |
|
820 | -add_action( 'wpinv_before_receipt', 'getpaid_maybe_mark_invoice_as_viewed' ); |
|
819 | +add_action('wpinv_invoice_print_before_display', 'getpaid_maybe_mark_invoice_as_viewed'); |
|
820 | +add_action('wpinv_before_receipt', 'getpaid_maybe_mark_invoice_as_viewed'); |
|
821 | 821 | |
822 | 822 | /** |
823 | 823 | * Processes an invoice refund. |
@@ -826,27 +826,27 @@ discard block |
||
826 | 826 | * @param array $status_transition |
827 | 827 | * @todo: descrease customer/store earnings |
828 | 828 | */ |
829 | -function getpaid_maybe_process_refund( $invoice, $status_transition ) { |
|
829 | +function getpaid_maybe_process_refund($invoice, $status_transition) { |
|
830 | 830 | |
831 | - if ( empty( $status_transition['from'] ) || ! in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ) ) ) { |
|
831 | + if (empty($status_transition['from']) || !in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'))) { |
|
832 | 832 | return; |
833 | 833 | } |
834 | 834 | |
835 | 835 | $discount_code = $invoice->get_discount_code(); |
836 | - if ( ! empty( $discount_code ) ) { |
|
837 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
836 | + if (!empty($discount_code)) { |
|
837 | + $discount = wpinv_get_discount_obj($discount_code); |
|
838 | 838 | |
839 | - if ( $discount->exists() ) { |
|
839 | + if ($discount->exists()) { |
|
840 | 840 | $discount->increase_usage( -1 ); |
841 | 841 | } |
842 | 842 | |
843 | 843 | } |
844 | 844 | |
845 | - do_action( 'wpinv_pre_refund_invoice', $invoice, $invoice->get_id() ); |
|
846 | - do_action( 'wpinv_refund_invoice', $invoice, $invoice->get_id() ); |
|
847 | - do_action( 'wpinv_post_refund_invoice', $invoice, $invoice->get_id() ); |
|
845 | + do_action('wpinv_pre_refund_invoice', $invoice, $invoice->get_id()); |
|
846 | + do_action('wpinv_refund_invoice', $invoice, $invoice->get_id()); |
|
847 | + do_action('wpinv_post_refund_invoice', $invoice, $invoice->get_id()); |
|
848 | 848 | } |
849 | -add_action( 'getpaid_invoice_status_wpi-refunded', 'getpaid_maybe_process_refund', 10, 2 ); |
|
849 | +add_action('getpaid_invoice_status_wpi-refunded', 'getpaid_maybe_process_refund', 10, 2); |
|
850 | 850 | |
851 | 851 | |
852 | 852 | /** |
@@ -854,49 +854,49 @@ discard block |
||
854 | 854 | * |
855 | 855 | * @param int $invoice_id |
856 | 856 | */ |
857 | -function getpaid_process_invoice_payment( $invoice_id ) { |
|
857 | +function getpaid_process_invoice_payment($invoice_id) { |
|
858 | 858 | |
859 | 859 | // Fetch the invoice. |
860 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
860 | + $invoice = new WPInv_Invoice($invoice_id); |
|
861 | 861 | |
862 | 862 | // We only want to do this once. |
863 | - if ( 1 == get_post_meta( $invoice->get_id(), 'wpinv_processed_payment', true ) ) { |
|
863 | + if (1 == get_post_meta($invoice->get_id(), 'wpinv_processed_payment', true)) { |
|
864 | 864 | return; |
865 | 865 | } |
866 | 866 | |
867 | - update_post_meta( $invoice->get_id(), 'wpinv_processed_payment', 1 ); |
|
867 | + update_post_meta($invoice->get_id(), 'wpinv_processed_payment', 1); |
|
868 | 868 | |
869 | 869 | // Fires when processing a payment. |
870 | - do_action( 'getpaid_process_payment', $invoice ); |
|
870 | + do_action('getpaid_process_payment', $invoice); |
|
871 | 871 | |
872 | 872 | // Fire an action for each invoice item. |
873 | - foreach( $invoice->get_items() as $item ) { |
|
874 | - do_action( 'getpaid_process_item_payment', $item, $invoice ); |
|
873 | + foreach ($invoice->get_items() as $item) { |
|
874 | + do_action('getpaid_process_item_payment', $item, $invoice); |
|
875 | 875 | } |
876 | 876 | |
877 | 877 | // Increase discount usage. |
878 | 878 | $discount_code = $invoice->get_discount_code(); |
879 | - if ( ! empty( $discount_code ) && ! $invoice->is_renewal() ) { |
|
880 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
879 | + if (!empty($discount_code) && !$invoice->is_renewal()) { |
|
880 | + $discount = wpinv_get_discount_obj($discount_code); |
|
881 | 881 | |
882 | - if ( $discount->exists() ) { |
|
882 | + if ($discount->exists()) { |
|
883 | 883 | $discount->increase_usage(); |
884 | 884 | } |
885 | 885 | |
886 | 886 | } |
887 | 887 | |
888 | 888 | // Record reverse vat. |
889 | - if ( 'invoice' == $invoice->get_type() && wpinv_use_taxes() && ! $invoice->get_disable_taxes() ) { |
|
889 | + if ('invoice' == $invoice->get_type() && wpinv_use_taxes() && !$invoice->get_disable_taxes()) { |
|
890 | 890 | |
891 | 891 | $taxes = $invoice->get_total_tax(); |
892 | - if ( empty( $taxes ) && GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $invoice->get_country() ) ) { |
|
893 | - $invoice->add_note( __( 'VAT was reverse charged', 'invoicing' ), false, false, true ); |
|
892 | + if (empty($taxes) && GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction($invoice->get_country())) { |
|
893 | + $invoice->add_note(__('VAT was reverse charged', 'invoicing'), false, false, true); |
|
894 | 894 | } |
895 | 895 | |
896 | 896 | } |
897 | 897 | |
898 | 898 | } |
899 | -add_action( 'getpaid_invoice_payment_status_changed', 'getpaid_process_invoice_payment' ); |
|
899 | +add_action('getpaid_invoice_payment_status_changed', 'getpaid_process_invoice_payment'); |
|
900 | 900 | |
901 | 901 | /** |
902 | 902 | * Returns an array of invoice item columns |
@@ -904,13 +904,13 @@ discard block |
||
904 | 904 | * @param int|WPInv_Invoice $invoice |
905 | 905 | * @return array |
906 | 906 | */ |
907 | -function getpaid_invoice_item_columns( $invoice ) { |
|
907 | +function getpaid_invoice_item_columns($invoice) { |
|
908 | 908 | |
909 | 909 | // Prepare the invoice. |
910 | - $invoice = new WPInv_Invoice( $invoice ); |
|
910 | + $invoice = new WPInv_Invoice($invoice); |
|
911 | 911 | |
912 | 912 | // Abort if there is no invoice. |
913 | - if ( 0 == $invoice->get_id() ) { |
|
913 | + if (0 == $invoice->get_id()) { |
|
914 | 914 | return array(); |
915 | 915 | } |
916 | 916 | |
@@ -918,57 +918,57 @@ discard block |
||
918 | 918 | $columns = apply_filters( |
919 | 919 | 'getpaid_invoice_item_columns', |
920 | 920 | array( |
921 | - 'name' => __( 'Item', 'invoicing' ), |
|
922 | - 'price' => __( 'Price', 'invoicing' ), |
|
923 | - 'tax_rate' => __( 'Tax Rate', 'invoicing' ), |
|
924 | - 'quantity' => __( 'Quantity', 'invoicing' ), |
|
925 | - 'subtotal' => __( 'Item Subtotal', 'invoicing' ), |
|
921 | + 'name' => __('Item', 'invoicing'), |
|
922 | + 'price' => __('Price', 'invoicing'), |
|
923 | + 'tax_rate' => __('Tax Rate', 'invoicing'), |
|
924 | + 'quantity' => __('Quantity', 'invoicing'), |
|
925 | + 'subtotal' => __('Item Subtotal', 'invoicing'), |
|
926 | 926 | ), |
927 | 927 | $invoice |
928 | 928 | ); |
929 | 929 | |
930 | 930 | // Quantities. |
931 | - if ( isset( $columns[ 'quantity' ] ) ) { |
|
931 | + if (isset($columns['quantity'])) { |
|
932 | 932 | |
933 | - if ( 'hours' == $invoice->get_template() ) { |
|
934 | - $columns[ 'quantity' ] = __( 'Hours', 'invoicing' ); |
|
933 | + if ('hours' == $invoice->get_template()) { |
|
934 | + $columns['quantity'] = __('Hours', 'invoicing'); |
|
935 | 935 | } |
936 | 936 | |
937 | - if ( ! wpinv_item_quantities_enabled() || 'amount' == $invoice->get_template() ) { |
|
938 | - unset( $columns[ 'quantity' ] ); |
|
937 | + if (!wpinv_item_quantities_enabled() || 'amount' == $invoice->get_template()) { |
|
938 | + unset($columns['quantity']); |
|
939 | 939 | } |
940 | 940 | |
941 | 941 | } |
942 | 942 | |
943 | 943 | |
944 | 944 | // Price. |
945 | - if ( isset( $columns[ 'price' ] ) ) { |
|
945 | + if (isset($columns['price'])) { |
|
946 | 946 | |
947 | - if ( 'amount' == $invoice->get_template() ) { |
|
948 | - $columns[ 'price' ] = __( 'Amount', 'invoicing' ); |
|
947 | + if ('amount' == $invoice->get_template()) { |
|
948 | + $columns['price'] = __('Amount', 'invoicing'); |
|
949 | 949 | } |
950 | 950 | |
951 | - if ( 'hours' == $invoice->get_template() ) { |
|
952 | - $columns[ 'price' ] = __( 'Rate', 'invoicing' ); |
|
951 | + if ('hours' == $invoice->get_template()) { |
|
952 | + $columns['price'] = __('Rate', 'invoicing'); |
|
953 | 953 | } |
954 | 954 | |
955 | 955 | } |
956 | 956 | |
957 | 957 | |
958 | 958 | // Sub total. |
959 | - if ( isset( $columns[ 'subtotal' ] ) ) { |
|
959 | + if (isset($columns['subtotal'])) { |
|
960 | 960 | |
961 | - if ( 'amount' == $invoice->get_template() ) { |
|
962 | - unset( $columns[ 'subtotal' ] ); |
|
961 | + if ('amount' == $invoice->get_template()) { |
|
962 | + unset($columns['subtotal']); |
|
963 | 963 | } |
964 | 964 | |
965 | 965 | } |
966 | 966 | |
967 | 967 | // Tax rates. |
968 | - if ( isset( $columns[ 'tax_rate' ] ) ) { |
|
968 | + if (isset($columns['tax_rate'])) { |
|
969 | 969 | |
970 | - if ( 0 == $invoice->get_tax() ) { |
|
971 | - unset( $columns[ 'tax_rate' ] ); |
|
970 | + if (0 == $invoice->get_tax()) { |
|
971 | + unset($columns['tax_rate']); |
|
972 | 972 | } |
973 | 973 | |
974 | 974 | } |
@@ -982,38 +982,38 @@ discard block |
||
982 | 982 | * @param int|WPInv_Invoice $invoice |
983 | 983 | * @return array |
984 | 984 | */ |
985 | -function getpaid_invoice_totals_rows( $invoice ) { |
|
985 | +function getpaid_invoice_totals_rows($invoice) { |
|
986 | 986 | |
987 | 987 | // Prepare the invoice. |
988 | - $invoice = new WPInv_Invoice( $invoice ); |
|
988 | + $invoice = new WPInv_Invoice($invoice); |
|
989 | 989 | |
990 | 990 | // Abort if there is no invoice. |
991 | - if ( 0 == $invoice->get_id() ) { |
|
991 | + if (0 == $invoice->get_id()) { |
|
992 | 992 | return array(); |
993 | 993 | } |
994 | 994 | |
995 | 995 | $totals = apply_filters( |
996 | 996 | 'getpaid_invoice_totals_rows', |
997 | 997 | array( |
998 | - 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
999 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
1000 | - 'fee' => __( 'Fee', 'invoicing' ), |
|
1001 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
1002 | - 'total' => __( 'Total', 'invoicing' ), |
|
998 | + 'subtotal' => __('Subtotal', 'invoicing'), |
|
999 | + 'tax' => __('Tax', 'invoicing'), |
|
1000 | + 'fee' => __('Fee', 'invoicing'), |
|
1001 | + 'discount' => __('Discount', 'invoicing'), |
|
1002 | + 'total' => __('Total', 'invoicing'), |
|
1003 | 1003 | ), |
1004 | 1004 | $invoice |
1005 | 1005 | ); |
1006 | 1006 | |
1007 | - if ( ( $invoice->get_disable_taxes() || ! wpinv_use_taxes() ) && isset( $totals['tax'] ) ) { |
|
1008 | - unset( $totals['tax'] ); |
|
1007 | + if (($invoice->get_disable_taxes() || !wpinv_use_taxes()) && isset($totals['tax'])) { |
|
1008 | + unset($totals['tax']); |
|
1009 | 1009 | } |
1010 | 1010 | |
1011 | - if ( 0 == $invoice->get_total_fees() && isset( $totals['fee'] ) ) { |
|
1012 | - unset( $totals['fee'] ); |
|
1011 | + if (0 == $invoice->get_total_fees() && isset($totals['fee'])) { |
|
1012 | + unset($totals['fee']); |
|
1013 | 1013 | } |
1014 | 1014 | |
1015 | - if ( 0 == $invoice->get_total_discount() && isset( $totals['discount'] ) ) { |
|
1016 | - unset( $totals['discount'] ); |
|
1015 | + if (0 == $invoice->get_total_discount() && isset($totals['discount'])) { |
|
1016 | + unset($totals['discount']); |
|
1017 | 1017 | } |
1018 | 1018 | |
1019 | 1019 | return $totals; |
@@ -1024,47 +1024,47 @@ discard block |
||
1024 | 1024 | * |
1025 | 1025 | * @param WPInv_Invoice $invoice |
1026 | 1026 | */ |
1027 | -function getpaid_new_invoice( $invoice ) { |
|
1027 | +function getpaid_new_invoice($invoice) { |
|
1028 | 1028 | |
1029 | - if ( ! $invoice->get_status() ) { |
|
1029 | + if (!$invoice->get_status()) { |
|
1030 | 1030 | return; |
1031 | 1031 | } |
1032 | 1032 | |
1033 | 1033 | // Add an invoice created note. |
1034 | 1034 | $invoice->add_note( |
1035 | 1035 | sprintf( |
1036 | - __( '%s created with the status "%s".', 'invoicing' ), |
|
1037 | - ucfirst( $invoice->get_invoice_quote_type() ), |
|
1038 | - wpinv_status_nicename( $invoice->get_status(), $invoice ) |
|
1036 | + __('%s created with the status "%s".', 'invoicing'), |
|
1037 | + ucfirst($invoice->get_invoice_quote_type()), |
|
1038 | + wpinv_status_nicename($invoice->get_status(), $invoice) |
|
1039 | 1039 | ) |
1040 | 1040 | ); |
1041 | 1041 | |
1042 | 1042 | } |
1043 | -add_action( 'getpaid_new_invoice', 'getpaid_new_invoice' ); |
|
1043 | +add_action('getpaid_new_invoice', 'getpaid_new_invoice'); |
|
1044 | 1044 | |
1045 | 1045 | /** |
1046 | 1046 | * This function updates invoice caches. |
1047 | 1047 | * |
1048 | 1048 | * @param WPInv_Invoice $invoice |
1049 | 1049 | */ |
1050 | -function getpaid_update_invoice_caches( $invoice ) { |
|
1050 | +function getpaid_update_invoice_caches($invoice) { |
|
1051 | 1051 | |
1052 | 1052 | // Cache invoice number. |
1053 | - wp_cache_set( $invoice->get_number(), $invoice->get_id(), "getpaid_invoice_numbers_to_invoice_ids" ); |
|
1053 | + wp_cache_set($invoice->get_number(), $invoice->get_id(), "getpaid_invoice_numbers_to_invoice_ids"); |
|
1054 | 1054 | |
1055 | 1055 | // Cache invoice key. |
1056 | - wp_cache_set( $invoice->get_key(), $invoice->get_id(), "getpaid_invoice_keys_to_invoice_ids" ); |
|
1056 | + wp_cache_set($invoice->get_key(), $invoice->get_id(), "getpaid_invoice_keys_to_invoice_ids"); |
|
1057 | 1057 | |
1058 | 1058 | // (Maybe) cache transaction id. |
1059 | 1059 | $transaction_id = $invoice->get_transaction_id(); |
1060 | 1060 | |
1061 | - if ( ! empty( $transaction_id ) ) { |
|
1062 | - wp_cache_set( $transaction_id, $invoice->get_id(), "getpaid_invoice_transaction_ids_to_invoice_ids" ); |
|
1061 | + if (!empty($transaction_id)) { |
|
1062 | + wp_cache_set($transaction_id, $invoice->get_id(), "getpaid_invoice_transaction_ids_to_invoice_ids"); |
|
1063 | 1063 | } |
1064 | 1064 | |
1065 | 1065 | } |
1066 | -add_action( 'getpaid_new_invoice', 'getpaid_update_invoice_caches', 5 ); |
|
1067 | -add_action( 'getpaid_update_invoice', 'getpaid_update_invoice_caches', 5 ); |
|
1066 | +add_action('getpaid_new_invoice', 'getpaid_update_invoice_caches', 5); |
|
1067 | +add_action('getpaid_update_invoice', 'getpaid_update_invoice_caches', 5); |
|
1068 | 1068 | |
1069 | 1069 | /** |
1070 | 1070 | * Duplicates an invoice. |
@@ -1074,7 +1074,7 @@ discard block |
||
1074 | 1074 | * @param WPInv_Invoice $old_invoice The invoice to duplicate |
1075 | 1075 | * @return WPInv_Invoice The new invoice. |
1076 | 1076 | */ |
1077 | -function getpaid_duplicate_invoice( $old_invoice ) { |
|
1077 | +function getpaid_duplicate_invoice($old_invoice) { |
|
1078 | 1078 | |
1079 | 1079 | // Create the new invoice. |
1080 | 1080 | $invoice = new WPInv_Invoice(); |
@@ -1135,121 +1135,121 @@ discard block |
||
1135 | 1135 | * @param WPInv_Invoice $invoice |
1136 | 1136 | * @return array |
1137 | 1137 | */ |
1138 | -function getpaid_get_invoice_meta( $invoice ) { |
|
1138 | +function getpaid_get_invoice_meta($invoice) { |
|
1139 | 1139 | |
1140 | 1140 | // Load the invoice meta. |
1141 | 1141 | $meta = array( |
1142 | 1142 | |
1143 | 1143 | 'number' => array( |
1144 | 1144 | 'label' => sprintf( |
1145 | - __( '%s Number', 'invoicing' ), |
|
1146 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
1145 | + __('%s Number', 'invoicing'), |
|
1146 | + ucfirst($invoice->get_invoice_quote_type()) |
|
1147 | 1147 | ), |
1148 | - 'value' => sanitize_text_field( $invoice->get_number() ), |
|
1148 | + 'value' => sanitize_text_field($invoice->get_number()), |
|
1149 | 1149 | ), |
1150 | 1150 | |
1151 | 1151 | 'status' => array( |
1152 | 1152 | 'label' => sprintf( |
1153 | - __( '%s Status', 'invoicing' ), |
|
1154 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
1153 | + __('%s Status', 'invoicing'), |
|
1154 | + ucfirst($invoice->get_invoice_quote_type()) |
|
1155 | 1155 | ), |
1156 | 1156 | 'value' => $invoice->get_status_label_html(), |
1157 | 1157 | ), |
1158 | 1158 | |
1159 | 1159 | 'date' => array( |
1160 | 1160 | 'label' => sprintf( |
1161 | - __( '%s Date', 'invoicing' ), |
|
1162 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
1161 | + __('%s Date', 'invoicing'), |
|
1162 | + ucfirst($invoice->get_invoice_quote_type()) |
|
1163 | 1163 | ), |
1164 | - 'value' => getpaid_format_date( $invoice->get_created_date() ), |
|
1164 | + 'value' => getpaid_format_date($invoice->get_created_date()), |
|
1165 | 1165 | ), |
1166 | 1166 | |
1167 | 1167 | 'date_paid' => array( |
1168 | - 'label' => __( 'Paid On', 'invoicing' ), |
|
1169 | - 'value' => getpaid_format_date( $invoice->get_completed_date() ), |
|
1168 | + 'label' => __('Paid On', 'invoicing'), |
|
1169 | + 'value' => getpaid_format_date($invoice->get_completed_date()), |
|
1170 | 1170 | ), |
1171 | 1171 | |
1172 | 1172 | 'gateway' => array( |
1173 | - 'label' => __( 'Payment Method', 'invoicing' ), |
|
1174 | - 'value' => sanitize_text_field( $invoice->get_gateway_title() ), |
|
1173 | + 'label' => __('Payment Method', 'invoicing'), |
|
1174 | + 'value' => sanitize_text_field($invoice->get_gateway_title()), |
|
1175 | 1175 | ), |
1176 | 1176 | |
1177 | 1177 | 'transaction_id' => array( |
1178 | - 'label' => __( 'Transaction ID', 'invoicing' ), |
|
1179 | - 'value' => sanitize_text_field( $invoice->get_transaction_id() ), |
|
1178 | + 'label' => __('Transaction ID', 'invoicing'), |
|
1179 | + 'value' => sanitize_text_field($invoice->get_transaction_id()), |
|
1180 | 1180 | ), |
1181 | 1181 | |
1182 | 1182 | 'due_date' => array( |
1183 | - 'label' => __( 'Due Date', 'invoicing' ), |
|
1184 | - 'value' => getpaid_format_date( $invoice->get_due_date() ), |
|
1183 | + 'label' => __('Due Date', 'invoicing'), |
|
1184 | + 'value' => getpaid_format_date($invoice->get_due_date()), |
|
1185 | 1185 | ), |
1186 | 1186 | |
1187 | 1187 | 'vat_number' => array( |
1188 | - 'label' => __( 'VAT Number', 'invoicing' ), |
|
1189 | - 'value' => sanitize_text_field( $invoice->get_vat_number() ), |
|
1188 | + 'label' => __('VAT Number', 'invoicing'), |
|
1189 | + 'value' => sanitize_text_field($invoice->get_vat_number()), |
|
1190 | 1190 | ), |
1191 | 1191 | |
1192 | 1192 | ); |
1193 | 1193 | |
1194 | 1194 | // If it is not paid, remove the date of payment. |
1195 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
1196 | - unset( $meta[ 'date_paid' ] ); |
|
1197 | - unset( $meta[ 'transaction_id' ] ); |
|
1195 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
1196 | + unset($meta['date_paid']); |
|
1197 | + unset($meta['transaction_id']); |
|
1198 | 1198 | } |
1199 | 1199 | |
1200 | - if ( ! $invoice->is_paid() || 'none' == $invoice->get_gateway() ) { |
|
1201 | - unset( $meta[ 'gateway' ] ); |
|
1200 | + if (!$invoice->is_paid() || 'none' == $invoice->get_gateway()) { |
|
1201 | + unset($meta['gateway']); |
|
1202 | 1202 | } |
1203 | 1203 | |
1204 | 1204 | // Only display the due date if due dates are enabled. |
1205 | - if ( ! $invoice->needs_payment() || ! wpinv_get_option( 'overdue_active' ) ) { |
|
1206 | - unset( $meta[ 'due_date' ] ); |
|
1205 | + if (!$invoice->needs_payment() || !wpinv_get_option('overdue_active')) { |
|
1206 | + unset($meta['due_date']); |
|
1207 | 1207 | } |
1208 | 1208 | |
1209 | 1209 | // Only display the vat number if taxes are enabled. |
1210 | - if ( ! wpinv_use_taxes() ) { |
|
1211 | - unset( $meta[ 'vat_number' ] ); |
|
1210 | + if (!wpinv_use_taxes()) { |
|
1211 | + unset($meta['vat_number']); |
|
1212 | 1212 | } |
1213 | 1213 | |
1214 | 1214 | // Link to the parent invoice. |
1215 | - if ( $invoice->get_parent_id() > 0 ) { |
|
1215 | + if ($invoice->get_parent_id() > 0) { |
|
1216 | 1216 | |
1217 | - $meta[ 'parent' ] = array( |
|
1217 | + $meta['parent'] = array( |
|
1218 | 1218 | |
1219 | 1219 | 'label' => sprintf( |
1220 | - __( 'Parent %s', 'invoicing' ), |
|
1221 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
1220 | + __('Parent %s', 'invoicing'), |
|
1221 | + ucfirst($invoice->get_invoice_quote_type()) |
|
1222 | 1222 | ), |
1223 | 1223 | |
1224 | - 'value' => wpinv_invoice_link( $invoice->get_parent_id() ), |
|
1224 | + 'value' => wpinv_invoice_link($invoice->get_parent_id()), |
|
1225 | 1225 | |
1226 | 1226 | ); |
1227 | 1227 | |
1228 | 1228 | } |
1229 | 1229 | |
1230 | 1230 | |
1231 | - if ( $invoice->is_recurring() ) { |
|
1231 | + if ($invoice->is_recurring()) { |
|
1232 | 1232 | |
1233 | - $subscription = getpaid_get_invoice_subscriptions( $invoice ); |
|
1234 | - if ( ! empty ( $subscription ) && ! is_array( $subscription ) && $subscription->exists() ) { |
|
1233 | + $subscription = getpaid_get_invoice_subscriptions($invoice); |
|
1234 | + if (!empty ($subscription) && !is_array($subscription) && $subscription->exists()) { |
|
1235 | 1235 | |
1236 | 1236 | // Display the renewal date. |
1237 | - if ( $subscription->is_active() && 'cancelled' != $subscription->get_status() ) { |
|
1237 | + if ($subscription->is_active() && 'cancelled' != $subscription->get_status()) { |
|
1238 | 1238 | |
1239 | - $meta[ 'renewal_date' ] = array( |
|
1240 | - 'label' => __( 'Renews On', 'invoicing' ), |
|
1241 | - 'value' => getpaid_format_date( $subscription->get_expiration() ), |
|
1239 | + $meta['renewal_date'] = array( |
|
1240 | + 'label' => __('Renews On', 'invoicing'), |
|
1241 | + 'value' => getpaid_format_date($subscription->get_expiration()), |
|
1242 | 1242 | ); |
1243 | 1243 | |
1244 | 1244 | } |
1245 | 1245 | |
1246 | - if ( $invoice->is_parent() ) { |
|
1246 | + if ($invoice->is_parent()) { |
|
1247 | 1247 | |
1248 | 1248 | // Display the recurring amount. |
1249 | - $meta[ 'recurring_total' ] = array( |
|
1249 | + $meta['recurring_total'] = array( |
|
1250 | 1250 | |
1251 | - 'label' => __( 'Recurring Amount', 'invoicing' ), |
|
1252 | - 'value' => wpinv_price( $subscription->get_recurring_amount(), $invoice->get_currency() ), |
|
1251 | + 'label' => __('Recurring Amount', 'invoicing'), |
|
1252 | + 'value' => wpinv_price($subscription->get_recurring_amount(), $invoice->get_currency()), |
|
1253 | 1253 | |
1254 | 1254 | ); |
1255 | 1255 | |
@@ -1259,15 +1259,15 @@ discard block |
||
1259 | 1259 | } |
1260 | 1260 | |
1261 | 1261 | // Add the invoice total to the meta. |
1262 | - $meta[ 'invoice_total' ] = array( |
|
1262 | + $meta['invoice_total'] = array( |
|
1263 | 1263 | |
1264 | - 'label' => __( 'Total Amount', 'invoicing' ), |
|
1265 | - 'value' => wpinv_price( $invoice->get_total(), $invoice->get_currency() ), |
|
1264 | + 'label' => __('Total Amount', 'invoicing'), |
|
1265 | + 'value' => wpinv_price($invoice->get_total(), $invoice->get_currency()), |
|
1266 | 1266 | |
1267 | 1267 | ); |
1268 | 1268 | |
1269 | 1269 | // Provide a way for third party plugins to filter the meta. |
1270 | - $meta = apply_filters( 'getpaid_invoice_meta_data', $meta, $invoice ); |
|
1270 | + $meta = apply_filters('getpaid_invoice_meta_data', $meta, $invoice); |
|
1271 | 1271 | |
1272 | 1272 | return $meta; |
1273 | 1273 | |
@@ -1306,12 +1306,12 @@ discard block |
||
1306 | 1306 | * @param GetPaid_Form_Item $item |
1307 | 1307 | * @return float |
1308 | 1308 | */ |
1309 | -function getpaid_get_invoice_tax_rate( $invoice, $item ) { |
|
1309 | +function getpaid_get_invoice_tax_rate($invoice, $item) { |
|
1310 | 1310 | |
1311 | - $rates = getpaid_get_item_tax_rates( $item, $invoice->get_country(), $invoice->get_state() ); |
|
1312 | - $rates = getpaid_filter_item_tax_rates( $item, $rates ); |
|
1313 | - $rates = wp_list_pluck( $rates, 'rate' ); |
|
1311 | + $rates = getpaid_get_item_tax_rates($item, $invoice->get_country(), $invoice->get_state()); |
|
1312 | + $rates = getpaid_filter_item_tax_rates($item, $rates); |
|
1313 | + $rates = wp_list_pluck($rates, 'rate'); |
|
1314 | 1314 | |
1315 | - return array_sum( $rates ); |
|
1315 | + return array_sum($rates); |
|
1316 | 1316 | |
1317 | 1317 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package GetPaid |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Generates a users select dropdown. |
@@ -16,13 +16,13 @@ discard block |
||
16 | 16 | * @param array $args |
17 | 17 | * @see wp_dropdown_users |
18 | 18 | */ |
19 | -function wpinv_dropdown_users( $args = '' ) { |
|
19 | +function wpinv_dropdown_users($args = '') { |
|
20 | 20 | |
21 | - if ( is_array( $args ) && ! empty( $args['show'] ) && 'display_name_with_email' == $args['show'] ) { |
|
21 | + if (is_array($args) && !empty($args['show']) && 'display_name_with_email' == $args['show']) { |
|
22 | 22 | $args['show'] = 'display_name_with_login'; |
23 | 23 | } |
24 | 24 | |
25 | - return wp_dropdown_users( $args ); |
|
25 | + return wp_dropdown_users($args); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | * @return string capability to check against |
33 | 33 | * @param string $capalibilty Optional. The alternative capability to check against. |
34 | 34 | */ |
35 | -function wpinv_get_capability( $capalibilty = 'manage_invoicing' ) { |
|
35 | +function wpinv_get_capability($capalibilty = 'manage_invoicing') { |
|
36 | 36 | |
37 | - if ( current_user_can( 'manage_options' ) ) { |
|
37 | + if (current_user_can('manage_options')) { |
|
38 | 38 | return 'manage_options'; |
39 | 39 | }; |
40 | 40 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @return bool |
49 | 49 | */ |
50 | 50 | function wpinv_current_user_can_manage_invoicing() { |
51 | - return current_user_can( wpinv_get_capability() ); |
|
51 | + return current_user_can(wpinv_get_capability()); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -57,19 +57,19 @@ discard block |
||
57 | 57 | * @since 1.0.19 |
58 | 58 | * @return int|WP_Error |
59 | 59 | */ |
60 | -function wpinv_create_user( $email, $prefix = '' ) { |
|
60 | +function wpinv_create_user($email, $prefix = '') { |
|
61 | 61 | |
62 | 62 | // Prepare user values. |
63 | - $prefix = preg_replace( '/\s+/', '', $prefix ); |
|
64 | - $prefix = empty( $prefix ) ? $email : $prefix; |
|
65 | - $args = array( |
|
66 | - 'user_login' => wpinv_generate_user_name( $prefix ), |
|
63 | + $prefix = preg_replace('/\s+/', '', $prefix); |
|
64 | + $prefix = empty($prefix) ? $email : $prefix; |
|
65 | + $args = array( |
|
66 | + 'user_login' => wpinv_generate_user_name($prefix), |
|
67 | 67 | 'user_pass' => wp_generate_password(), |
68 | 68 | 'user_email' => $email, |
69 | 69 | 'role' => 'subscriber', |
70 | 70 | ); |
71 | 71 | |
72 | - return wp_insert_user( $args ); |
|
72 | + return wp_insert_user($args); |
|
73 | 73 | |
74 | 74 | } |
75 | 75 | |
@@ -79,26 +79,26 @@ discard block |
||
79 | 79 | * @since 1.0.19 |
80 | 80 | * @return bool|WP_User |
81 | 81 | */ |
82 | -function wpinv_generate_user_name( $prefix = '' ) { |
|
82 | +function wpinv_generate_user_name($prefix = '') { |
|
83 | 83 | |
84 | 84 | // If prefix is an email, retrieve the part before the email. |
85 | - $prefix = strtok( $prefix, '@' ); |
|
86 | - $prefix = trim( $prefix, '.' ); |
|
85 | + $prefix = strtok($prefix, '@'); |
|
86 | + $prefix = trim($prefix, '.'); |
|
87 | 87 | |
88 | 88 | // Sanitize the username. |
89 | - $prefix = sanitize_user( $prefix, true ); |
|
89 | + $prefix = sanitize_user($prefix, true); |
|
90 | 90 | |
91 | - $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() ); |
|
92 | - if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) { |
|
93 | - $prefix = 'gtp_' . zeroise( wp_rand( 0, 9999 ), 4 ); |
|
91 | + $illegal_logins = (array) apply_filters('illegal_user_logins', array()); |
|
92 | + if (empty($prefix) || in_array(strtolower($prefix), array_map('strtolower', $illegal_logins), true)) { |
|
93 | + $prefix = 'gtp_' . zeroise(wp_rand(0, 9999), 4); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | $username = $prefix; |
97 | 97 | $postfix = 2; |
98 | 98 | |
99 | - while ( username_exists( $username ) ) { |
|
99 | + while (username_exists($username)) { |
|
100 | 100 | $username = $prefix + $postfix; |
101 | - $postfix ++; |
|
101 | + $postfix++; |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | return $username; |
@@ -115,31 +115,31 @@ discard block |
||
115 | 115 | $tabs = array( |
116 | 116 | |
117 | 117 | 'gp-invoices' => array( |
118 | - 'label' => __( 'Invoices', 'invoicing' ), // Name of the tab. |
|
118 | + 'label' => __('Invoices', 'invoicing'), // Name of the tab. |
|
119 | 119 | 'content' => '[wpinv_history]', // Content of the tab. Or specify "callback" to provide a callback instead. |
120 | 120 | 'icon' => 'fas fa-file-invoice', // Shown on some profile plugins. |
121 | 121 | ), |
122 | 122 | |
123 | 123 | 'gp-subscriptions' => array( |
124 | - 'label' => __( 'Subscriptions', 'invoicing' ), |
|
124 | + 'label' => __('Subscriptions', 'invoicing'), |
|
125 | 125 | 'content' => '[wpinv_subscriptions]', |
126 | 126 | 'icon' => 'fas fa-redo', |
127 | 127 | ), |
128 | 128 | |
129 | 129 | 'gp-edit-address' => array( |
130 | - 'label' => __( 'Billing Address', 'invoicing' ), |
|
130 | + 'label' => __('Billing Address', 'invoicing'), |
|
131 | 131 | 'callback' => 'getpaid_display_address_edit_tab', |
132 | 132 | 'icon' => 'fas fa-credit-card', |
133 | 133 | ), |
134 | 134 | |
135 | 135 | ); |
136 | 136 | |
137 | - $tabs = apply_filters( 'getpaid_user_content_tabs', $tabs ); |
|
137 | + $tabs = apply_filters('getpaid_user_content_tabs', $tabs); |
|
138 | 138 | |
139 | 139 | // Make sure address editing is last on the list. |
140 | - if ( isset( $tabs['gp-edit-address'] ) ) { |
|
140 | + if (isset($tabs['gp-edit-address'])) { |
|
141 | 141 | $address = $tabs['gp-edit-address']; |
142 | - unset( $tabs['gp-edit-address'] ); |
|
142 | + unset($tabs['gp-edit-address']); |
|
143 | 143 | $tabs['gp-edit-address'] = $address; |
144 | 144 | } |
145 | 145 | |
@@ -153,19 +153,19 @@ discard block |
||
153 | 153 | * @param array $tab |
154 | 154 | * @return array |
155 | 155 | */ |
156 | -function getpaid_prepare_user_content_tab( $tab ) { |
|
156 | +function getpaid_prepare_user_content_tab($tab) { |
|
157 | 157 | |
158 | - if ( ! empty( $tab['callback'] ) ) { |
|
159 | - return call_user_func( $tab['callback'] ); |
|
158 | + if (!empty($tab['callback'])) { |
|
159 | + return call_user_func($tab['callback']); |
|
160 | 160 | } |
161 | 161 | |
162 | - if ( ! empty( $tab['content'] ) ) { |
|
163 | - return convert_smilies( capital_P_dangit( wp_filter_content_tags( do_shortcode( shortcode_unautop( wpautop( wptexturize( do_blocks( $tab['content'] ) ) ) ) ) ) ) ); |
|
162 | + if (!empty($tab['content'])) { |
|
163 | + return convert_smilies(capital_P_dangit(wp_filter_content_tags(do_shortcode(shortcode_unautop(wpautop(wptexturize(do_blocks($tab['content'])))))))); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | $notice = aui()->alert( |
167 | 167 | array( |
168 | - 'content' => __( 'This tab has no content or content callback.', 'invoicing' ), |
|
168 | + 'content' => __('This tab has no content or content callback.', 'invoicing'), |
|
169 | 169 | 'type' => 'error', |
170 | 170 | ) |
171 | 171 | ); |
@@ -181,14 +181,14 @@ discard block |
||
181 | 181 | * @param string $default |
182 | 182 | * @return array |
183 | 183 | */ |
184 | -function getpaid_get_tab_url( $tab, $default ) { |
|
184 | +function getpaid_get_tab_url($tab, $default) { |
|
185 | 185 | global $getpaid_tab_url; |
186 | 186 | |
187 | - if ( empty( $getpaid_tab_url ) ) { |
|
187 | + if (empty($getpaid_tab_url)) { |
|
188 | 188 | return $default; |
189 | 189 | } |
190 | 190 | |
191 | - return sprintf( $getpaid_tab_url, $tab ); |
|
191 | + return sprintf($getpaid_tab_url, $tab); |
|
192 | 192 | |
193 | 193 | } |
194 | 194 | |
@@ -208,19 +208,19 @@ discard block |
||
208 | 208 | |
209 | 209 | <?php |
210 | 210 | |
211 | - foreach ( getpaid_user_address_fields() as $key => $label ) { |
|
211 | + foreach (getpaid_user_address_fields() as $key => $label) { |
|
212 | 212 | |
213 | 213 | // Display the country. |
214 | - if ( 'country' == $key ) { |
|
214 | + if ('country' == $key) { |
|
215 | 215 | |
216 | 216 | echo aui()->select( |
217 | 217 | array( |
218 | 218 | 'options' => wpinv_get_country_list(), |
219 | - 'name' => 'getpaid_address[' . esc_attr( $key ) . ']', |
|
220 | - 'id' => 'wpinv-' . sanitize_html_class( $key ), |
|
221 | - 'value' => sanitize_text_field( getpaid_get_user_address_field( get_current_user_id(), $key ) ), |
|
219 | + 'name' => 'getpaid_address[' . esc_attr($key) . ']', |
|
220 | + 'id' => 'wpinv-' . sanitize_html_class($key), |
|
221 | + 'value' => sanitize_text_field(getpaid_get_user_address_field(get_current_user_id(), $key)), |
|
222 | 222 | 'placeholder' => $label, |
223 | - 'label' => wp_kses_post( $label ), |
|
223 | + 'label' => wp_kses_post($label), |
|
224 | 224 | 'label_type' => 'vertical', |
225 | 225 | 'class' => 'getpaid-address-field', |
226 | 226 | ) |
@@ -229,30 +229,30 @@ discard block |
||
229 | 229 | } |
230 | 230 | |
231 | 231 | // Display the state. |
232 | - else if ( 'state' == $key ) { |
|
232 | + else if ('state' == $key) { |
|
233 | 233 | |
234 | - echo getpaid_get_states_select_markup ( |
|
235 | - getpaid_get_user_address_field( get_current_user_id(), 'country' ), |
|
236 | - getpaid_get_user_address_field( get_current_user_id(), 'state' ), |
|
234 | + echo getpaid_get_states_select_markup( |
|
235 | + getpaid_get_user_address_field(get_current_user_id(), 'country'), |
|
236 | + getpaid_get_user_address_field(get_current_user_id(), 'state'), |
|
237 | 237 | $label, |
238 | 238 | $label, |
239 | 239 | '', |
240 | 240 | false, |
241 | 241 | '', |
242 | - 'getpaid_address[' . esc_attr( $key ) . ']' |
|
242 | + 'getpaid_address[' . esc_attr($key) . ']' |
|
243 | 243 | ); |
244 | 244 | |
245 | 245 | } else { |
246 | 246 | |
247 | 247 | echo aui()->input( |
248 | 248 | array( |
249 | - 'name' => 'getpaid_address[' . esc_attr( $key ) . ']', |
|
250 | - 'id' => 'wpinv-' . sanitize_html_class( $key ), |
|
249 | + 'name' => 'getpaid_address[' . esc_attr($key) . ']', |
|
250 | + 'id' => 'wpinv-' . sanitize_html_class($key), |
|
251 | 251 | 'placeholder' => $label, |
252 | - 'label' => wp_kses_post( $label ), |
|
252 | + 'label' => wp_kses_post($label), |
|
253 | 253 | 'label_type' => 'vertical', |
254 | 254 | 'type' => 'text', |
255 | - 'value' => sanitize_text_field( getpaid_get_user_address_field( get_current_user_id(), $key ) ), |
|
255 | + 'value' => sanitize_text_field(getpaid_get_user_address_field(get_current_user_id(), $key)), |
|
256 | 256 | 'class' => 'getpaid-address-field', |
257 | 257 | ) |
258 | 258 | ); |
@@ -261,21 +261,21 @@ discard block |
||
261 | 261 | |
262 | 262 | } |
263 | 263 | |
264 | - do_action( 'getpaid_display_address_edit_tab' ); |
|
264 | + do_action('getpaid_display_address_edit_tab'); |
|
265 | 265 | |
266 | 266 | echo aui()->input( |
267 | 267 | array( |
268 | 268 | 'name' => 'getpaid_profile_edit_submit_button', |
269 | 269 | 'id' => 'getpaid_profile_edit_submit_button', |
270 | - 'value' => __( 'Save Address', 'invoicing' ), |
|
271 | - 'help_text' => __( 'New invoices will use this address as the billing address.', 'invoicing' ), |
|
270 | + 'value' => __('Save Address', 'invoicing'), |
|
271 | + 'help_text' => __('New invoices will use this address as the billing address.', 'invoicing'), |
|
272 | 272 | 'type' => 'submit', |
273 | 273 | 'class' => 'btn btn-primary btn-block submit-button', |
274 | 274 | ) |
275 | 275 | ); |
276 | 276 | |
277 | - wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); |
|
278 | - getpaid_hidden_field( 'getpaid-action', 'edit_billing_details' ); |
|
277 | + wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); |
|
278 | + getpaid_hidden_field('getpaid-action', 'edit_billing_details'); |
|
279 | 279 | ?> |
280 | 280 | |
281 | 281 | </form> |
@@ -292,27 +292,27 @@ discard block |
||
292 | 292 | * @since 2.1.4 |
293 | 293 | * @param array $data |
294 | 294 | */ |
295 | -function getpaid_save_address_edit_tab( $data ) { |
|
295 | +function getpaid_save_address_edit_tab($data) { |
|
296 | 296 | |
297 | - if ( empty( $data['getpaid_address'] ) || ! is_array( $data['getpaid_address'] ) ) { |
|
297 | + if (empty($data['getpaid_address']) || !is_array($data['getpaid_address'])) { |
|
298 | 298 | return; |
299 | 299 | } |
300 | 300 | |
301 | 301 | $data = $data['getpaid_address']; |
302 | 302 | $user_id = get_current_user_id(); |
303 | 303 | |
304 | - foreach ( array_keys( getpaid_user_address_fields() ) as $field ) { |
|
304 | + foreach (array_keys(getpaid_user_address_fields()) as $field) { |
|
305 | 305 | |
306 | - if ( isset( $data[ $field ] ) ) { |
|
307 | - $value = sanitize_text_field( $data[ $field ] ); |
|
308 | - update_user_meta( $user_id, '_wpinv_' . $field, $value ); |
|
306 | + if (isset($data[$field])) { |
|
307 | + $value = sanitize_text_field($data[$field]); |
|
308 | + update_user_meta($user_id, '_wpinv_' . $field, $value); |
|
309 | 309 | } |
310 | 310 | |
311 | - wpinv_set_error( 'address_updated', __( 'Your billing address has been updated', 'invoicing' ), 'success'); |
|
311 | + wpinv_set_error('address_updated', __('Your billing address has been updated', 'invoicing'), 'success'); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | } |
315 | -add_action( 'getpaid_authenticated_action_edit_billing_details', 'getpaid_save_address_edit_tab' ); |
|
315 | +add_action('getpaid_authenticated_action_edit_billing_details', 'getpaid_save_address_edit_tab'); |
|
316 | 316 | |
317 | 317 | |
318 | 318 | /* |
@@ -330,27 +330,27 @@ discard block |
||
330 | 330 | * @param array $tabs |
331 | 331 | * @return array |
332 | 332 | */ |
333 | -function getpaid_filter_userswp_account_tabs( $tabs ) { |
|
333 | +function getpaid_filter_userswp_account_tabs($tabs) { |
|
334 | 334 | |
335 | 335 | // Abort if the integration is inactive. |
336 | - if ( ! getpaid_is_userswp_integration_active() ) { |
|
336 | + if (!getpaid_is_userswp_integration_active()) { |
|
337 | 337 | return $tabs; |
338 | 338 | } |
339 | 339 | |
340 | - $new_tabs = array(); |
|
340 | + $new_tabs = array(); |
|
341 | 341 | |
342 | - foreach ( getpaid_get_user_content_tabs() as $slug => $tab ) { |
|
342 | + foreach (getpaid_get_user_content_tabs() as $slug => $tab) { |
|
343 | 343 | |
344 | - $new_tabs[ $slug ] = array( |
|
345 | - 'title' => $tab[ 'label'], |
|
346 | - 'icon' => $tab[ 'icon'], |
|
344 | + $new_tabs[$slug] = array( |
|
345 | + 'title' => $tab['label'], |
|
346 | + 'icon' => $tab['icon'], |
|
347 | 347 | ); |
348 | 348 | |
349 | 349 | } |
350 | 350 | |
351 | - return array_merge( $tabs, $new_tabs ); |
|
351 | + return array_merge($tabs, $new_tabs); |
|
352 | 352 | } |
353 | -add_filter( 'uwp_account_available_tabs', 'getpaid_filter_userswp_account_tabs' ); |
|
353 | +add_filter('uwp_account_available_tabs', 'getpaid_filter_userswp_account_tabs'); |
|
354 | 354 | |
355 | 355 | /** |
356 | 356 | * Display our UsersWP account tabs. |
@@ -359,18 +359,18 @@ discard block |
||
359 | 359 | * @param array $tabs |
360 | 360 | * @return array |
361 | 361 | */ |
362 | -function getpaid_display_userswp_account_tabs( $tab ) { |
|
362 | +function getpaid_display_userswp_account_tabs($tab) { |
|
363 | 363 | global $getpaid_tab_url; |
364 | 364 | |
365 | 365 | $our_tabs = getpaid_get_user_content_tabs(); |
366 | 366 | |
367 | - if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) { |
|
368 | - $getpaid_tab_url = add_query_arg( 'type', '%s', uwp_get_account_page_url() ); |
|
369 | - echo getpaid_prepare_user_content_tab( $our_tabs[ $tab ] ); |
|
367 | + if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) { |
|
368 | + $getpaid_tab_url = add_query_arg('type', '%s', uwp_get_account_page_url()); |
|
369 | + echo getpaid_prepare_user_content_tab($our_tabs[$tab]); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | } |
373 | -add_action( 'uwp_account_form_display', 'getpaid_display_userswp_account_tabs' ); |
|
373 | +add_action('uwp_account_form_display', 'getpaid_display_userswp_account_tabs'); |
|
374 | 374 | |
375 | 375 | |
376 | 376 | /** |
@@ -381,17 +381,17 @@ discard block |
||
381 | 381 | * @param string $tab Current tab. |
382 | 382 | * @return string Title. |
383 | 383 | */ |
384 | -function getpaid_filter_userswp_account_title( $title, $tab ) { |
|
384 | +function getpaid_filter_userswp_account_title($title, $tab) { |
|
385 | 385 | |
386 | - $our_tabs = getpaid_get_user_content_tabs(); |
|
386 | + $our_tabs = getpaid_get_user_content_tabs(); |
|
387 | 387 | |
388 | - if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) { |
|
389 | - return $our_tabs[ $tab ]['label']; |
|
388 | + if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) { |
|
389 | + return $our_tabs[$tab]['label']; |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | return $title; |
393 | 393 | } |
394 | -add_filter( 'uwp_account_page_title', 'getpaid_filter_userswp_account_title', 10, 2 ); |
|
394 | +add_filter('uwp_account_page_title', 'getpaid_filter_userswp_account_title', 10, 2); |
|
395 | 395 | |
396 | 396 | /** |
397 | 397 | * Registers the UsersWP integration settings. |
@@ -400,26 +400,26 @@ discard block |
||
400 | 400 | * @param array $settings An array of integration settings. |
401 | 401 | * @return array |
402 | 402 | */ |
403 | -function getpaid_register_userswp_settings( $settings ) { |
|
403 | +function getpaid_register_userswp_settings($settings) { |
|
404 | 404 | |
405 | - if ( defined( 'USERSWP_PLUGIN_FILE' ) ) { |
|
405 | + if (defined('USERSWP_PLUGIN_FILE')) { |
|
406 | 406 | |
407 | 407 | $settings[] = array( |
408 | 408 | |
409 | 409 | 'id' => 'userswp', |
410 | - 'label' => __( 'UsersWP', 'invoicing' ), |
|
410 | + 'label' => __('UsersWP', 'invoicing'), |
|
411 | 411 | 'settings' => array( |
412 | 412 | |
413 | 413 | 'userswp_settings' => array( |
414 | 414 | 'id' => 'userswp_settings', |
415 | - 'name' => '<h3>' . __( 'UsersWP', 'invoicing' ) . '</h3>', |
|
415 | + 'name' => '<h3>' . __('UsersWP', 'invoicing') . '</h3>', |
|
416 | 416 | 'type' => 'header', |
417 | 417 | ), |
418 | 418 | |
419 | 419 | 'enable_userswp' => array( |
420 | 420 | 'id' => 'enable_userswp', |
421 | - 'name' => __( 'Enable Integration', 'invoicing' ), |
|
422 | - 'desc' => __( 'Display GetPaid items on UsersWP account page.', 'invoicing' ), |
|
421 | + 'name' => __('Enable Integration', 'invoicing'), |
|
422 | + 'desc' => __('Display GetPaid items on UsersWP account page.', 'invoicing'), |
|
423 | 423 | 'type' => 'checkbox', |
424 | 424 | 'std' => 1, |
425 | 425 | ) |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | |
433 | 433 | return $settings; |
434 | 434 | } |
435 | -add_filter( 'getpaid_integration_settings', 'getpaid_register_userswp_settings' ); |
|
435 | +add_filter('getpaid_integration_settings', 'getpaid_register_userswp_settings'); |
|
436 | 436 | |
437 | 437 | /** |
438 | 438 | * Ovewrites the invoices history page to UsersWP. |
@@ -440,18 +440,18 @@ discard block |
||
440 | 440 | * @since 2.3.1 |
441 | 441 | * @return bool |
442 | 442 | */ |
443 | -function getpaid_userswp_overwrite_invoice_history_page( $url, $post_type ) { |
|
443 | +function getpaid_userswp_overwrite_invoice_history_page($url, $post_type) { |
|
444 | 444 | |
445 | 445 | $our_tabs = getpaid_get_user_content_tabs(); |
446 | 446 | $tab = "gp-{$post_type}s"; |
447 | - if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) { |
|
448 | - return add_query_arg( 'type', $tab, uwp_get_account_page_url() ); |
|
447 | + if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) { |
|
448 | + return add_query_arg('type', $tab, uwp_get_account_page_url()); |
|
449 | 449 | } |
450 | 450 | |
451 | 451 | return $url; |
452 | 452 | |
453 | 453 | } |
454 | -add_filter( 'wpinv_get_history_page_uri', 'getpaid_userswp_overwrite_invoice_history_page', 10, 2 ); |
|
454 | +add_filter('wpinv_get_history_page_uri', 'getpaid_userswp_overwrite_invoice_history_page', 10, 2); |
|
455 | 455 | |
456 | 456 | /** |
457 | 457 | * Checks if the integration is enabled. |
@@ -460,8 +460,8 @@ discard block |
||
460 | 460 | * @return bool |
461 | 461 | */ |
462 | 462 | function getpaid_is_userswp_integration_active() { |
463 | - $enabled = wpinv_get_option( 'enable_userswp', 1 ); |
|
464 | - return defined( 'USERSWP_PLUGIN_FILE' ) && ! empty( $enabled ); |
|
463 | + $enabled = wpinv_get_option('enable_userswp', 1); |
|
464 | + return defined('USERSWP_PLUGIN_FILE') && !empty($enabled); |
|
465 | 465 | } |
466 | 466 | |
467 | 467 | /* |
@@ -479,26 +479,26 @@ discard block |
||
479 | 479 | * @param array $settings An array of integration settings. |
480 | 480 | * @return array |
481 | 481 | */ |
482 | -function getpaid_register_buddypress_settings( $settings ) { |
|
482 | +function getpaid_register_buddypress_settings($settings) { |
|
483 | 483 | |
484 | - if ( class_exists( 'BuddyPress' ) ) { |
|
484 | + if (class_exists('BuddyPress')) { |
|
485 | 485 | |
486 | 486 | $settings[] = array( |
487 | 487 | |
488 | 488 | 'id' => 'buddypress', |
489 | - 'label' => __( 'BuddyPress', 'invoicing' ), |
|
489 | + 'label' => __('BuddyPress', 'invoicing'), |
|
490 | 490 | 'settings' => array( |
491 | 491 | |
492 | 492 | 'buddypress_settings' => array( |
493 | 493 | 'id' => 'buddypress_settings', |
494 | - 'name' => '<h3>' . __( 'BuddyPress', 'invoicing' ) . '</h3>', |
|
494 | + 'name' => '<h3>' . __('BuddyPress', 'invoicing') . '</h3>', |
|
495 | 495 | 'type' => 'header', |
496 | 496 | ), |
497 | 497 | |
498 | 498 | 'enable_buddypress' => array( |
499 | 499 | 'id' => 'enable_buddypress', |
500 | - 'name' => __( 'Enable Integration', 'invoicing' ), |
|
501 | - 'desc' => __( 'Display GetPaid items on BuddyPress account pages.', 'invoicing' ), |
|
500 | + 'name' => __('Enable Integration', 'invoicing'), |
|
501 | + 'desc' => __('Display GetPaid items on BuddyPress account pages.', 'invoicing'), |
|
502 | 502 | 'type' => 'checkbox', |
503 | 503 | 'std' => 1, |
504 | 504 | ) |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | |
512 | 512 | return $settings; |
513 | 513 | } |
514 | -add_filter( 'getpaid_integration_settings', 'getpaid_register_buddypress_settings' ); |
|
514 | +add_filter('getpaid_integration_settings', 'getpaid_register_buddypress_settings'); |
|
515 | 515 | |
516 | 516 | /** |
517 | 517 | * Checks if the integration is enabled. |
@@ -520,8 +520,8 @@ discard block |
||
520 | 520 | * @return bool |
521 | 521 | */ |
522 | 522 | function getpaid_is_buddypress_integration_active() { |
523 | - $enabled = wpinv_get_option( 'enable_buddypress', 1 ); |
|
524 | - return class_exists( 'BuddyPress' ) && ! empty( $enabled ); |
|
523 | + $enabled = wpinv_get_option('enable_buddypress', 1); |
|
524 | + return class_exists('BuddyPress') && !empty($enabled); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | /** |
@@ -532,10 +532,10 @@ discard block |
||
532 | 532 | */ |
533 | 533 | function getpaid_setup_buddypress_integration() { |
534 | 534 | |
535 | - if ( getpaid_is_buddypress_integration_active() ) { |
|
536 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-bp-getpaid-component.php' ); |
|
535 | + if (getpaid_is_buddypress_integration_active()) { |
|
536 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-bp-getpaid-component.php'); |
|
537 | 537 | buddypress()->getpaid = new BP_GetPaid_Component(); |
538 | 538 | } |
539 | 539 | |
540 | 540 | } |
541 | -add_action( 'bp_setup_components', 'getpaid_setup_buddypress_integration' ); |
|
541 | +add_action('bp_setup_components', 'getpaid_setup_buddypress_integration'); |
@@ -4,99 +4,99 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Displays an invoice. |
11 | 11 | * |
12 | 12 | * @param WPInv_Invoice $invoice. |
13 | 13 | */ |
14 | -function getpaid_invoice( $invoice ) { |
|
15 | - if ( ! empty( $invoice ) ) { |
|
16 | - wpinv_get_template( 'invoice/invoice.php', compact( 'invoice' ) ); |
|
14 | +function getpaid_invoice($invoice) { |
|
15 | + if (!empty($invoice)) { |
|
16 | + wpinv_get_template('invoice/invoice.php', compact('invoice')); |
|
17 | 17 | } |
18 | 18 | } |
19 | -add_action( 'getpaid_invoice', 'getpaid_invoice', 10 ); |
|
19 | +add_action('getpaid_invoice', 'getpaid_invoice', 10); |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Displays the invoice footer. |
23 | 23 | */ |
24 | -function getpaid_invoice_footer( $invoice ) { |
|
25 | - if ( ! empty( $invoice ) ) { |
|
26 | - wpinv_get_template( 'invoice/footer.php', compact( 'invoice' ) ); |
|
24 | +function getpaid_invoice_footer($invoice) { |
|
25 | + if (!empty($invoice)) { |
|
26 | + wpinv_get_template('invoice/footer.php', compact('invoice')); |
|
27 | 27 | } |
28 | 28 | } |
29 | -add_action( 'getpaid_invoice_footer', 'getpaid_invoice_footer', 10 ); |
|
29 | +add_action('getpaid_invoice_footer', 'getpaid_invoice_footer', 10); |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Displays the invoice top bar. |
33 | 33 | */ |
34 | -function getpaid_invoice_header( $invoice ) { |
|
35 | - if ( ! empty( $invoice ) ) { |
|
36 | - wpinv_get_template( 'invoice/header.php', compact( 'invoice' ) ); |
|
34 | +function getpaid_invoice_header($invoice) { |
|
35 | + if (!empty($invoice)) { |
|
36 | + wpinv_get_template('invoice/header.php', compact('invoice')); |
|
37 | 37 | } |
38 | 38 | } |
39 | -add_action( 'getpaid_invoice_header', 'getpaid_invoice_header', 10 ); |
|
39 | +add_action('getpaid_invoice_header', 'getpaid_invoice_header', 10); |
|
40 | 40 | |
41 | 41 | /** |
42 | 42 | * Displays actions on the left side of the header. |
43 | 43 | */ |
44 | -function getpaid_invoice_header_left_actions( $invoice ) { |
|
45 | - if ( ! empty( $invoice ) ) { |
|
46 | - wpinv_get_template( 'invoice/header-left-actions.php', compact( 'invoice' ) ); |
|
44 | +function getpaid_invoice_header_left_actions($invoice) { |
|
45 | + if (!empty($invoice)) { |
|
46 | + wpinv_get_template('invoice/header-left-actions.php', compact('invoice')); |
|
47 | 47 | } |
48 | 48 | } |
49 | -add_action( 'getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10 ); |
|
49 | +add_action('getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10); |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * Displays actions on the right side of the invoice top bar. |
53 | 53 | */ |
54 | -function getpaid_invoice_header_right_actions( $invoice ) { |
|
55 | - if ( ! empty( $invoice ) ) { |
|
56 | - wpinv_get_template( 'invoice/header-right-actions.php', compact( 'invoice' ) ); |
|
54 | +function getpaid_invoice_header_right_actions($invoice) { |
|
55 | + if (!empty($invoice)) { |
|
56 | + wpinv_get_template('invoice/header-right-actions.php', compact('invoice')); |
|
57 | 57 | } |
58 | 58 | } |
59 | -add_action( 'getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10 ); |
|
59 | +add_action('getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10); |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * Displays the invoice title, logo etc. |
63 | 63 | */ |
64 | -function getpaid_invoice_details_top( $invoice ) { |
|
65 | - if ( ! empty( $invoice ) ) { |
|
66 | - wpinv_get_template( 'invoice/details-top.php', compact( 'invoice' ) ); |
|
64 | +function getpaid_invoice_details_top($invoice) { |
|
65 | + if (!empty($invoice)) { |
|
66 | + wpinv_get_template('invoice/details-top.php', compact('invoice')); |
|
67 | 67 | } |
68 | 68 | } |
69 | -add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_top', 10 ); |
|
69 | +add_action('getpaid_invoice_details', 'getpaid_invoice_details_top', 10); |
|
70 | 70 | |
71 | 71 | /** |
72 | 72 | * Displays the company logo. |
73 | 73 | */ |
74 | -function getpaid_invoice_logo( $invoice ) { |
|
75 | - if ( ! empty( $invoice ) ) { |
|
76 | - wpinv_get_template( 'invoice/invoice-logo.php', compact( 'invoice' ) ); |
|
74 | +function getpaid_invoice_logo($invoice) { |
|
75 | + if (!empty($invoice)) { |
|
76 | + wpinv_get_template('invoice/invoice-logo.php', compact('invoice')); |
|
77 | 77 | } |
78 | 78 | } |
79 | -add_action( 'getpaid_invoice_details_top_left', 'getpaid_invoice_logo' ); |
|
79 | +add_action('getpaid_invoice_details_top_left', 'getpaid_invoice_logo'); |
|
80 | 80 | |
81 | 81 | /** |
82 | 82 | * Displays the type of invoice. |
83 | 83 | */ |
84 | -function getpaid_invoice_type( $invoice ) { |
|
85 | - if ( ! empty( $invoice ) ) { |
|
86 | - wpinv_get_template( 'invoice/invoice-type.php', compact( 'invoice' ) ); |
|
84 | +function getpaid_invoice_type($invoice) { |
|
85 | + if (!empty($invoice)) { |
|
86 | + wpinv_get_template('invoice/invoice-type.php', compact('invoice')); |
|
87 | 87 | } |
88 | 88 | } |
89 | -add_action( 'getpaid_invoice_details_top_right', 'getpaid_invoice_type' ); |
|
89 | +add_action('getpaid_invoice_details_top_right', 'getpaid_invoice_type'); |
|
90 | 90 | |
91 | 91 | /** |
92 | 92 | * Displays the invoice details. |
93 | 93 | */ |
94 | -function getpaid_invoice_details_main( $invoice ) { |
|
95 | - if ( ! empty( $invoice ) ) { |
|
96 | - wpinv_get_template( 'invoice/details.php', compact( 'invoice' ) ); |
|
94 | +function getpaid_invoice_details_main($invoice) { |
|
95 | + if (!empty($invoice)) { |
|
96 | + wpinv_get_template('invoice/details.php', compact('invoice')); |
|
97 | 97 | } |
98 | 98 | } |
99 | -add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_main', 50 ); |
|
99 | +add_action('getpaid_invoice_details', 'getpaid_invoice_details_main', 50); |
|
100 | 100 | |
101 | 101 | /** |
102 | 102 | * Returns a path to the templates directory. |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
126 | 126 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
127 | 127 | */ |
128 | -function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
129 | - getpaid_template()->display_template( $template_name, $args, $template_path, $default_path ); |
|
128 | +function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
129 | + getpaid_template()->display_template($template_name, $args, $template_path, $default_path); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
140 | 140 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
141 | 141 | */ |
142 | -function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
143 | - return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path ); |
|
142 | +function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
143 | + return getpaid_template()->get_template($template_name, $args, $template_path, $default_path); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * @return string |
150 | 150 | */ |
151 | 151 | function wpinv_template_path() { |
152 | - return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() ); |
|
152 | + return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name()); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * @return string |
159 | 159 | */ |
160 | 160 | function wpinv_get_theme_template_dir_name() { |
161 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
161 | + return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing')); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -170,56 +170,56 @@ discard block |
||
170 | 170 | * @param string $template_path The template path relative to the theme's root dir. Defaults to 'invoicing'. |
171 | 171 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
172 | 172 | */ |
173 | -function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
174 | - return getpaid_template()->locate_template( $template_name, $template_path, $default_path ); |
|
173 | +function wpinv_locate_template($template_name, $template_path = '', $default_path = '') { |
|
174 | + return getpaid_template()->locate_template($template_name, $template_path, $default_path); |
|
175 | 175 | } |
176 | 176 | |
177 | -function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
|
178 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
177 | +function wpinv_get_template_part($slug, $name = null, $load = true) { |
|
178 | + do_action('get_template_part_' . $slug, $slug, $name); |
|
179 | 179 | |
180 | 180 | // Setup possible parts |
181 | 181 | $templates = array(); |
182 | - if ( isset( $name ) ) |
|
182 | + if (isset($name)) |
|
183 | 183 | $templates[] = $slug . '-' . $name . '.php'; |
184 | 184 | $templates[] = $slug . '.php'; |
185 | 185 | |
186 | 186 | // Allow template parts to be filtered |
187 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
187 | + $templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name); |
|
188 | 188 | |
189 | 189 | // Return the part that is found |
190 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
190 | + return wpinv_locate_tmpl($templates, $load, false); |
|
191 | 191 | } |
192 | 192 | |
193 | -function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
|
193 | +function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) { |
|
194 | 194 | // No file found yet |
195 | 195 | $located = false; |
196 | 196 | |
197 | 197 | // Try to find a template file |
198 | - foreach ( (array)$template_names as $template_name ) { |
|
198 | + foreach ((array) $template_names as $template_name) { |
|
199 | 199 | |
200 | 200 | // Continue if template is empty |
201 | - if ( empty( $template_name ) ) |
|
201 | + if (empty($template_name)) |
|
202 | 202 | continue; |
203 | 203 | |
204 | 204 | // Trim off any slashes from the template name |
205 | - $template_name = ltrim( $template_name, '/' ); |
|
205 | + $template_name = ltrim($template_name, '/'); |
|
206 | 206 | |
207 | 207 | // try locating this template file by looping through the template paths |
208 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
208 | + foreach (wpinv_get_theme_template_paths() as $template_path) { |
|
209 | 209 | |
210 | - if( file_exists( $template_path . $template_name ) ) { |
|
210 | + if (file_exists($template_path . $template_name)) { |
|
211 | 211 | $located = $template_path . $template_name; |
212 | 212 | break; |
213 | 213 | } |
214 | 214 | } |
215 | 215 | |
216 | - if( !empty( $located ) ) { |
|
216 | + if (!empty($located)) { |
|
217 | 217 | break; |
218 | 218 | } |
219 | 219 | } |
220 | 220 | |
221 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
222 | - load_template( $located, $require_once ); |
|
221 | + if ((true == $load) && !empty($located)) |
|
222 | + load_template($located, $require_once); |
|
223 | 223 | |
224 | 224 | return $located; |
225 | 225 | } |
@@ -228,127 +228,127 @@ discard block |
||
228 | 228 | $template_dir = wpinv_get_theme_template_dir_name(); |
229 | 229 | |
230 | 230 | $file_paths = array( |
231 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
232 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
231 | + 1 => trailingslashit(get_stylesheet_directory()) . $template_dir, |
|
232 | + 10 => trailingslashit(get_template_directory()) . $template_dir, |
|
233 | 233 | 100 => wpinv_get_templates_dir() |
234 | 234 | ); |
235 | 235 | |
236 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
236 | + $file_paths = apply_filters('wpinv_template_paths', $file_paths); |
|
237 | 237 | |
238 | 238 | // sort the file paths based on priority |
239 | - ksort( $file_paths, SORT_NUMERIC ); |
|
239 | + ksort($file_paths, SORT_NUMERIC); |
|
240 | 240 | |
241 | - return array_map( 'trailingslashit', $file_paths ); |
|
241 | + return array_map('trailingslashit', $file_paths); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | function wpinv_checkout_meta_tags() { |
245 | 245 | |
246 | 246 | $pages = array(); |
247 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
248 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
249 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
250 | - $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
247 | + $pages[] = wpinv_get_option('success_page'); |
|
248 | + $pages[] = wpinv_get_option('failure_page'); |
|
249 | + $pages[] = wpinv_get_option('invoice_history_page'); |
|
250 | + $pages[] = wpinv_get_option('invoice_subscription_page'); |
|
251 | 251 | |
252 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
252 | + if (!wpinv_is_checkout() && !is_page($pages)) { |
|
253 | 253 | return; |
254 | 254 | } |
255 | 255 | |
256 | 256 | echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
257 | 257 | } |
258 | -add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
|
258 | +add_action('wp_head', 'wpinv_checkout_meta_tags'); |
|
259 | 259 | |
260 | -function wpinv_add_body_classes( $class ) { |
|
261 | - $classes = (array)$class; |
|
260 | +function wpinv_add_body_classes($class) { |
|
261 | + $classes = (array) $class; |
|
262 | 262 | |
263 | - if( wpinv_is_checkout() ) { |
|
263 | + if (wpinv_is_checkout()) { |
|
264 | 264 | $classes[] = 'wpinv-checkout'; |
265 | 265 | $classes[] = 'wpinv-page'; |
266 | 266 | } |
267 | 267 | |
268 | - if( wpinv_is_success_page() ) { |
|
268 | + if (wpinv_is_success_page()) { |
|
269 | 269 | $classes[] = 'wpinv-success'; |
270 | 270 | $classes[] = 'wpinv-page'; |
271 | 271 | } |
272 | 272 | |
273 | - if( wpinv_is_failed_transaction_page() ) { |
|
273 | + if (wpinv_is_failed_transaction_page()) { |
|
274 | 274 | $classes[] = 'wpinv-failed-transaction'; |
275 | 275 | $classes[] = 'wpinv-page'; |
276 | 276 | } |
277 | 277 | |
278 | - if( wpinv_is_invoice_history_page() ) { |
|
278 | + if (wpinv_is_invoice_history_page()) { |
|
279 | 279 | $classes[] = 'wpinv-history'; |
280 | 280 | $classes[] = 'wpinv-page'; |
281 | 281 | } |
282 | 282 | |
283 | - if( wpinv_is_subscriptions_history_page() ) { |
|
283 | + if (wpinv_is_subscriptions_history_page()) { |
|
284 | 284 | $classes[] = 'wpinv-subscription'; |
285 | 285 | $classes[] = 'wpinv-page'; |
286 | 286 | } |
287 | 287 | |
288 | - if( wpinv_is_test_mode() ) { |
|
288 | + if (wpinv_is_test_mode()) { |
|
289 | 289 | $classes[] = 'wpinv-test-mode'; |
290 | 290 | $classes[] = 'wpinv-page'; |
291 | 291 | } |
292 | 292 | |
293 | - return array_unique( $classes ); |
|
293 | + return array_unique($classes); |
|
294 | 294 | } |
295 | -add_filter( 'body_class', 'wpinv_add_body_classes' ); |
|
295 | +add_filter('body_class', 'wpinv_add_body_classes'); |
|
296 | 296 | |
297 | -function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) { |
|
298 | - $current = date( 'Y' ); |
|
299 | - $start_year = $current - absint( $years_before ); |
|
300 | - $end_year = $current + absint( $years_after ); |
|
301 | - $selected = empty( $selected ) ? date( 'Y' ) : $selected; |
|
297 | +function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) { |
|
298 | + $current = date('Y'); |
|
299 | + $start_year = $current - absint($years_before); |
|
300 | + $end_year = $current + absint($years_after); |
|
301 | + $selected = empty($selected) ? date('Y') : $selected; |
|
302 | 302 | $options = array(); |
303 | 303 | |
304 | - while ( $start_year <= $end_year ) { |
|
305 | - $options[ absint( $start_year ) ] = $start_year; |
|
304 | + while ($start_year <= $end_year) { |
|
305 | + $options[absint($start_year)] = $start_year; |
|
306 | 306 | $start_year++; |
307 | 307 | } |
308 | 308 | |
309 | - $output = wpinv_html_select( array( |
|
309 | + $output = wpinv_html_select(array( |
|
310 | 310 | 'name' => $name, |
311 | 311 | 'selected' => $selected, |
312 | 312 | 'options' => $options, |
313 | 313 | 'show_option_all' => false, |
314 | 314 | 'show_option_none' => false |
315 | - ) ); |
|
315 | + )); |
|
316 | 316 | |
317 | 317 | return $output; |
318 | 318 | } |
319 | 319 | |
320 | -function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) { |
|
320 | +function wpinv_html_month_dropdown($name = 'month', $selected = 0) { |
|
321 | 321 | |
322 | 322 | $options = array( |
323 | - '1' => __( 'January', 'invoicing' ), |
|
324 | - '2' => __( 'February', 'invoicing' ), |
|
325 | - '3' => __( 'March', 'invoicing' ), |
|
326 | - '4' => __( 'April', 'invoicing' ), |
|
327 | - '5' => __( 'May', 'invoicing' ), |
|
328 | - '6' => __( 'June', 'invoicing' ), |
|
329 | - '7' => __( 'July', 'invoicing' ), |
|
330 | - '8' => __( 'August', 'invoicing' ), |
|
331 | - '9' => __( 'September', 'invoicing' ), |
|
332 | - '10' => __( 'October', 'invoicing' ), |
|
333 | - '11' => __( 'November', 'invoicing' ), |
|
334 | - '12' => __( 'December', 'invoicing' ), |
|
323 | + '1' => __('January', 'invoicing'), |
|
324 | + '2' => __('February', 'invoicing'), |
|
325 | + '3' => __('March', 'invoicing'), |
|
326 | + '4' => __('April', 'invoicing'), |
|
327 | + '5' => __('May', 'invoicing'), |
|
328 | + '6' => __('June', 'invoicing'), |
|
329 | + '7' => __('July', 'invoicing'), |
|
330 | + '8' => __('August', 'invoicing'), |
|
331 | + '9' => __('September', 'invoicing'), |
|
332 | + '10' => __('October', 'invoicing'), |
|
333 | + '11' => __('November', 'invoicing'), |
|
334 | + '12' => __('December', 'invoicing'), |
|
335 | 335 | ); |
336 | 336 | |
337 | 337 | // If no month is selected, default to the current month |
338 | - $selected = empty( $selected ) ? date( 'n' ) : $selected; |
|
338 | + $selected = empty($selected) ? date('n') : $selected; |
|
339 | 339 | |
340 | - $output = wpinv_html_select( array( |
|
340 | + $output = wpinv_html_select(array( |
|
341 | 341 | 'name' => $name, |
342 | 342 | 'selected' => $selected, |
343 | 343 | 'options' => $options, |
344 | 344 | 'show_option_all' => false, |
345 | 345 | 'show_option_none' => false |
346 | - ) ); |
|
346 | + )); |
|
347 | 347 | |
348 | 348 | return $output; |
349 | 349 | } |
350 | 350 | |
351 | -function wpinv_html_select( $args = array() ) { |
|
351 | +function wpinv_html_select($args = array()) { |
|
352 | 352 | $defaults = array( |
353 | 353 | 'options' => array(), |
354 | 354 | 'name' => null, |
@@ -357,8 +357,8 @@ discard block |
||
357 | 357 | 'selected' => 0, |
358 | 358 | 'placeholder' => null, |
359 | 359 | 'multiple' => false, |
360 | - 'show_option_all' => _x( 'All', 'all dropdown items', 'invoicing' ), |
|
361 | - 'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ), |
|
360 | + 'show_option_all' => _x('All', 'all dropdown items', 'invoicing'), |
|
361 | + 'show_option_none' => _x('None', 'no dropdown items', 'invoicing'), |
|
362 | 362 | 'data' => array(), |
363 | 363 | 'onchange' => null, |
364 | 364 | 'required' => false, |
@@ -366,74 +366,74 @@ discard block |
||
366 | 366 | 'readonly' => false, |
367 | 367 | ); |
368 | 368 | |
369 | - $args = wp_parse_args( $args, $defaults ); |
|
369 | + $args = wp_parse_args($args, $defaults); |
|
370 | 370 | |
371 | 371 | $data_elements = ''; |
372 | - foreach ( $args['data'] as $key => $value ) { |
|
373 | - $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
|
372 | + foreach ($args['data'] as $key => $value) { |
|
373 | + $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"'; |
|
374 | 374 | } |
375 | 375 | |
376 | - if( $args['multiple'] ) { |
|
376 | + if ($args['multiple']) { |
|
377 | 377 | $multiple = ' MULTIPLE'; |
378 | 378 | } else { |
379 | 379 | $multiple = ''; |
380 | 380 | } |
381 | 381 | |
382 | - if( $args['placeholder'] ) { |
|
382 | + if ($args['placeholder']) { |
|
383 | 383 | $placeholder = $args['placeholder']; |
384 | 384 | } else { |
385 | 385 | $placeholder = ''; |
386 | 386 | } |
387 | 387 | |
388 | 388 | $options = ''; |
389 | - if( !empty( $args['onchange'] ) ) { |
|
390 | - $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
389 | + if (!empty($args['onchange'])) { |
|
390 | + $options .= ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
391 | 391 | } |
392 | 392 | |
393 | - if( !empty( $args['required'] ) ) { |
|
393 | + if (!empty($args['required'])) { |
|
394 | 394 | $options .= ' required="required"'; |
395 | 395 | } |
396 | 396 | |
397 | - if( !empty( $args['disabled'] ) ) { |
|
397 | + if (!empty($args['disabled'])) { |
|
398 | 398 | $options .= ' disabled'; |
399 | 399 | } |
400 | 400 | |
401 | - if( !empty( $args['readonly'] ) ) { |
|
401 | + if (!empty($args['readonly'])) { |
|
402 | 402 | $options .= ' readonly'; |
403 | 403 | } |
404 | 404 | |
405 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
406 | - $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>'; |
|
405 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
406 | + $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>'; |
|
407 | 407 | |
408 | - if ( $args['show_option_all'] ) { |
|
409 | - if( $args['multiple'] ) { |
|
410 | - $selected = selected( true, in_array( 0, $args['selected'] ), false ); |
|
408 | + if ($args['show_option_all']) { |
|
409 | + if ($args['multiple']) { |
|
410 | + $selected = selected(true, in_array(0, $args['selected']), false); |
|
411 | 411 | } else { |
412 | - $selected = selected( $args['selected'], 0, false ); |
|
412 | + $selected = selected($args['selected'], 0, false); |
|
413 | 413 | } |
414 | - $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
414 | + $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>'; |
|
415 | 415 | } |
416 | 416 | |
417 | - if ( !empty( $args['options'] ) ) { |
|
417 | + if (!empty($args['options'])) { |
|
418 | 418 | |
419 | - if ( $args['show_option_none'] ) { |
|
420 | - if( $args['multiple'] ) { |
|
421 | - $selected = selected( true, in_array( "", $args['selected'] ), false ); |
|
419 | + if ($args['show_option_none']) { |
|
420 | + if ($args['multiple']) { |
|
421 | + $selected = selected(true, in_array("", $args['selected']), false); |
|
422 | 422 | } else { |
423 | - $selected = selected( $args['selected'] === "", true, false ); |
|
423 | + $selected = selected($args['selected'] === "", true, false); |
|
424 | 424 | } |
425 | - $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
425 | + $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>'; |
|
426 | 426 | } |
427 | 427 | |
428 | - foreach( $args['options'] as $key => $option ) { |
|
428 | + foreach ($args['options'] as $key => $option) { |
|
429 | 429 | |
430 | - if( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
431 | - $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false ); |
|
430 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
431 | + $selected = selected(true, (bool) in_array($key, $args['selected']), false); |
|
432 | 432 | } else { |
433 | - $selected = selected( $args['selected'], $key, false ); |
|
433 | + $selected = selected($args['selected'], $key, false); |
|
434 | 434 | } |
435 | 435 | |
436 | - $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
|
436 | + $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>'; |
|
437 | 437 | } |
438 | 438 | } |
439 | 439 | |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | return $output; |
443 | 443 | } |
444 | 444 | |
445 | -function wpinv_item_dropdown( $args = array() ) { |
|
445 | +function wpinv_item_dropdown($args = array()) { |
|
446 | 446 | $defaults = array( |
447 | 447 | 'name' => 'wpi_item', |
448 | 448 | 'id' => 'wpi_item', |
@@ -450,14 +450,14 @@ discard block |
||
450 | 450 | 'multiple' => false, |
451 | 451 | 'selected' => 0, |
452 | 452 | 'number' => 100, |
453 | - 'placeholder' => __( 'Choose a item', 'invoicing' ), |
|
454 | - 'data' => array( 'search-type' => 'item' ), |
|
453 | + 'placeholder' => __('Choose a item', 'invoicing'), |
|
454 | + 'data' => array('search-type' => 'item'), |
|
455 | 455 | 'show_option_all' => false, |
456 | 456 | 'show_option_none' => false, |
457 | 457 | 'show_recurring' => false, |
458 | 458 | ); |
459 | 459 | |
460 | - $args = wp_parse_args( $args, $defaults ); |
|
460 | + $args = wp_parse_args($args, $defaults); |
|
461 | 461 | |
462 | 462 | $item_args = array( |
463 | 463 | 'post_type' => 'wpi_item', |
@@ -466,44 +466,44 @@ discard block |
||
466 | 466 | 'posts_per_page' => $args['number'] |
467 | 467 | ); |
468 | 468 | |
469 | - $item_args = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults ); |
|
469 | + $item_args = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults); |
|
470 | 470 | |
471 | - $items = get_posts( $item_args ); |
|
471 | + $items = get_posts($item_args); |
|
472 | 472 | $options = array(); |
473 | - if ( $items ) { |
|
474 | - foreach ( $items as $item ) { |
|
475 | - $title = esc_html( $item->post_title ); |
|
473 | + if ($items) { |
|
474 | + foreach ($items as $item) { |
|
475 | + $title = esc_html($item->post_title); |
|
476 | 476 | |
477 | - if ( !empty( $args['show_recurring'] ) ) { |
|
478 | - $title .= wpinv_get_item_suffix( $item->ID, false ); |
|
477 | + if (!empty($args['show_recurring'])) { |
|
478 | + $title .= wpinv_get_item_suffix($item->ID, false); |
|
479 | 479 | } |
480 | 480 | |
481 | - $options[ absint( $item->ID ) ] = $title; |
|
481 | + $options[absint($item->ID)] = $title; |
|
482 | 482 | } |
483 | 483 | } |
484 | 484 | |
485 | 485 | // This ensures that any selected items are included in the drop down |
486 | - if( is_array( $args['selected'] ) ) { |
|
487 | - foreach( $args['selected'] as $item ) { |
|
488 | - if( ! in_array( $item, $options ) ) { |
|
489 | - $title = get_the_title( $item ); |
|
490 | - if ( !empty( $args['show_recurring'] ) ) { |
|
491 | - $title .= wpinv_get_item_suffix( $item, false ); |
|
486 | + if (is_array($args['selected'])) { |
|
487 | + foreach ($args['selected'] as $item) { |
|
488 | + if (!in_array($item, $options)) { |
|
489 | + $title = get_the_title($item); |
|
490 | + if (!empty($args['show_recurring'])) { |
|
491 | + $title .= wpinv_get_item_suffix($item, false); |
|
492 | 492 | } |
493 | 493 | $options[$item] = $title; |
494 | 494 | } |
495 | 495 | } |
496 | - } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) { |
|
497 | - if ( ! in_array( $args['selected'], $options ) ) { |
|
498 | - $title = get_the_title( $args['selected'] ); |
|
499 | - if ( !empty( $args['show_recurring'] ) ) { |
|
500 | - $title .= wpinv_get_item_suffix( $args['selected'], false ); |
|
496 | + } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) { |
|
497 | + if (!in_array($args['selected'], $options)) { |
|
498 | + $title = get_the_title($args['selected']); |
|
499 | + if (!empty($args['show_recurring'])) { |
|
500 | + $title .= wpinv_get_item_suffix($args['selected'], false); |
|
501 | 501 | } |
502 | - $options[$args['selected']] = get_the_title( $args['selected'] ); |
|
502 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
503 | 503 | } |
504 | 504 | } |
505 | 505 | |
506 | - $output = wpinv_html_select( array( |
|
506 | + $output = wpinv_html_select(array( |
|
507 | 507 | 'name' => $args['name'], |
508 | 508 | 'selected' => $args['selected'], |
509 | 509 | 'id' => $args['id'], |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | 'show_option_all' => $args['show_option_all'], |
515 | 515 | 'show_option_none' => $args['show_option_none'], |
516 | 516 | 'data' => $args['data'], |
517 | - ) ); |
|
517 | + )); |
|
518 | 518 | |
519 | 519 | return $output; |
520 | 520 | } |
@@ -534,16 +534,16 @@ discard block |
||
534 | 534 | ); |
535 | 535 | |
536 | 536 | $options = array(); |
537 | - if ( $items ) { |
|
538 | - foreach ( $items as $item ) { |
|
539 | - $options[ $item->ID ] = esc_html( $item->post_title ) . wpinv_get_item_suffix( $item->ID, false ); |
|
537 | + if ($items) { |
|
538 | + foreach ($items as $item) { |
|
539 | + $options[$item->ID] = esc_html($item->post_title) . wpinv_get_item_suffix($item->ID, false); |
|
540 | 540 | } |
541 | 541 | } |
542 | 542 | |
543 | 543 | return $options; |
544 | 544 | } |
545 | 545 | |
546 | -function wpinv_html_checkbox( $args = array() ) { |
|
546 | +function wpinv_html_checkbox($args = array()) { |
|
547 | 547 | $defaults = array( |
548 | 548 | 'name' => null, |
549 | 549 | 'current' => null, |
@@ -554,17 +554,17 @@ discard block |
||
554 | 554 | ) |
555 | 555 | ); |
556 | 556 | |
557 | - $args = wp_parse_args( $args, $defaults ); |
|
557 | + $args = wp_parse_args($args, $defaults); |
|
558 | 558 | |
559 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
559 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
560 | 560 | $options = ''; |
561 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
561 | + if (!empty($args['options']['disabled'])) { |
|
562 | 562 | $options .= ' disabled="disabled"'; |
563 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
563 | + } elseif (!empty($args['options']['readonly'])) { |
|
564 | 564 | $options .= ' readonly'; |
565 | 565 | } |
566 | 566 | |
567 | - $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $class . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
567 | + $output = '<input type="checkbox"' . $options . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . $class . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />'; |
|
568 | 568 | |
569 | 569 | return $output; |
570 | 570 | } |
@@ -572,9 +572,9 @@ discard block |
||
572 | 572 | /** |
573 | 573 | * Displays a hidden field. |
574 | 574 | */ |
575 | -function getpaid_hidden_field( $name, $value ) { |
|
576 | - $name = sanitize_text_field( $name ); |
|
577 | - $value = esc_attr( $value ); |
|
575 | +function getpaid_hidden_field($name, $value) { |
|
576 | + $name = sanitize_text_field($name); |
|
577 | + $value = esc_attr($value); |
|
578 | 578 | |
579 | 579 | echo "<input type='hidden' name='$name' value='$value' />"; |
580 | 580 | } |
@@ -582,31 +582,31 @@ discard block |
||
582 | 582 | /** |
583 | 583 | * Displays a submit field. |
584 | 584 | */ |
585 | -function getpaid_submit_field( $value, $name = 'submit', $class = 'btn-primary' ) { |
|
586 | - $name = sanitize_text_field( $name ); |
|
587 | - $value = esc_attr( $value ); |
|
588 | - $class = esc_attr( $class ); |
|
585 | +function getpaid_submit_field($value, $name = 'submit', $class = 'btn-primary') { |
|
586 | + $name = sanitize_text_field($name); |
|
587 | + $value = esc_attr($value); |
|
588 | + $class = esc_attr($class); |
|
589 | 589 | |
590 | 590 | echo "<input type='submit' name='$name' value='$value' class='btn $class' />"; |
591 | 591 | } |
592 | 592 | |
593 | -function wpinv_html_text( $args = array() ) { |
|
593 | +function wpinv_html_text($args = array()) { |
|
594 | 594 | // Backwards compatibility |
595 | - if ( func_num_args() > 1 ) { |
|
595 | + if (func_num_args() > 1) { |
|
596 | 596 | $args = func_get_args(); |
597 | 597 | |
598 | 598 | $name = $args[0]; |
599 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
600 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
601 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
599 | + $value = isset($args[1]) ? $args[1] : ''; |
|
600 | + $label = isset($args[2]) ? $args[2] : ''; |
|
601 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
602 | 602 | } |
603 | 603 | |
604 | 604 | $defaults = array( |
605 | 605 | 'id' => '', |
606 | - 'name' => isset( $name ) ? $name : 'text', |
|
607 | - 'value' => isset( $value ) ? $value : null, |
|
608 | - 'label' => isset( $label ) ? $label : null, |
|
609 | - 'desc' => isset( $desc ) ? $desc : null, |
|
606 | + 'name' => isset($name) ? $name : 'text', |
|
607 | + 'value' => isset($value) ? $value : null, |
|
608 | + 'label' => isset($label) ? $label : null, |
|
609 | + 'desc' => isset($desc) ? $desc : null, |
|
610 | 610 | 'placeholder' => '', |
611 | 611 | 'class' => 'regular-text', |
612 | 612 | 'disabled' => false, |
@@ -616,41 +616,41 @@ discard block |
||
616 | 616 | 'data' => false |
617 | 617 | ); |
618 | 618 | |
619 | - $args = wp_parse_args( $args, $defaults ); |
|
619 | + $args = wp_parse_args($args, $defaults); |
|
620 | 620 | |
621 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
621 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
622 | 622 | $options = ''; |
623 | - if( $args['required'] ) { |
|
623 | + if ($args['required']) { |
|
624 | 624 | $options .= ' required="required"'; |
625 | 625 | } |
626 | - if( $args['readonly'] ) { |
|
626 | + if ($args['readonly']) { |
|
627 | 627 | $options .= ' readonly'; |
628 | 628 | } |
629 | - if( $args['readonly'] ) { |
|
629 | + if ($args['readonly']) { |
|
630 | 630 | $options .= ' readonly'; |
631 | 631 | } |
632 | 632 | |
633 | 633 | $data = ''; |
634 | - if ( !empty( $args['data'] ) ) { |
|
635 | - foreach ( $args['data'] as $key => $value ) { |
|
636 | - $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" '; |
|
634 | + if (!empty($args['data'])) { |
|
635 | + foreach ($args['data'] as $key => $value) { |
|
636 | + $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" '; |
|
637 | 637 | } |
638 | 638 | } |
639 | 639 | |
640 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
641 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
642 | - if ( ! empty( $args['desc'] ) ) { |
|
643 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
640 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
641 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>'; |
|
642 | + if (!empty($args['desc'])) { |
|
643 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
644 | 644 | } |
645 | 645 | |
646 | - $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>'; |
|
646 | + $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>'; |
|
647 | 647 | |
648 | 648 | $output .= '</span>'; |
649 | 649 | |
650 | 650 | return $output; |
651 | 651 | } |
652 | 652 | |
653 | -function wpinv_html_textarea( $args = array() ) { |
|
653 | +function wpinv_html_textarea($args = array()) { |
|
654 | 654 | $defaults = array( |
655 | 655 | 'name' => 'textarea', |
656 | 656 | 'value' => null, |
@@ -661,31 +661,31 @@ discard block |
||
661 | 661 | 'placeholder' => '', |
662 | 662 | ); |
663 | 663 | |
664 | - $args = wp_parse_args( $args, $defaults ); |
|
664 | + $args = wp_parse_args($args, $defaults); |
|
665 | 665 | |
666 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
666 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
667 | 667 | $disabled = ''; |
668 | - if( $args['disabled'] ) { |
|
668 | + if ($args['disabled']) { |
|
669 | 669 | $disabled = ' disabled="disabled"'; |
670 | 670 | } |
671 | 671 | |
672 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
673 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
674 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
672 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
673 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>'; |
|
674 | + $output .= '<textarea name="' . esc_attr($args['name']) . '" placeholder="' . esc_attr($args['placeholder']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>'; |
|
675 | 675 | |
676 | - if ( ! empty( $args['desc'] ) ) { |
|
677 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
676 | + if (!empty($args['desc'])) { |
|
677 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
678 | 678 | } |
679 | 679 | $output .= '</span>'; |
680 | 680 | |
681 | 681 | return $output; |
682 | 682 | } |
683 | 683 | |
684 | -function wpinv_html_ajax_user_search( $args = array() ) { |
|
684 | +function wpinv_html_ajax_user_search($args = array()) { |
|
685 | 685 | $defaults = array( |
686 | 686 | 'name' => 'user_id', |
687 | 687 | 'value' => null, |
688 | - 'placeholder' => __( 'Enter username', 'invoicing' ), |
|
688 | + 'placeholder' => __('Enter username', 'invoicing'), |
|
689 | 689 | 'label' => null, |
690 | 690 | 'desc' => null, |
691 | 691 | 'class' => '', |
@@ -694,13 +694,13 @@ discard block |
||
694 | 694 | 'data' => false |
695 | 695 | ); |
696 | 696 | |
697 | - $args = wp_parse_args( $args, $defaults ); |
|
697 | + $args = wp_parse_args($args, $defaults); |
|
698 | 698 | |
699 | 699 | $args['class'] = 'wpinv-ajax-user-search ' . $args['class']; |
700 | 700 | |
701 | 701 | $output = '<span class="wpinv_user_search_wrap">'; |
702 | - $output .= wpinv_html_text( $args ); |
|
703 | - $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>'; |
|
702 | + $output .= wpinv_html_text($args); |
|
703 | + $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>'; |
|
704 | 704 | $output .= '</span>'; |
705 | 705 | |
706 | 706 | return $output; |
@@ -711,20 +711,20 @@ discard block |
||
711 | 711 | * |
712 | 712 | * @param string $template the template that is currently being used. |
713 | 713 | */ |
714 | -function wpinv_template( $template ) { |
|
714 | +function wpinv_template($template) { |
|
715 | 715 | global $post; |
716 | 716 | |
717 | - if ( ! is_admin() && ( is_single() || is_404() ) && ! empty( $post->ID ) && getpaid_is_invoice_post_type( get_post_type( $post->ID ) ) ) { |
|
717 | + if (!is_admin() && (is_single() || is_404()) && !empty($post->ID) && getpaid_is_invoice_post_type(get_post_type($post->ID))) { |
|
718 | 718 | |
719 | 719 | // If the user can view this invoice, display it. |
720 | - if ( wpinv_user_can_view_invoice( $post->ID ) ) { |
|
720 | + if (wpinv_user_can_view_invoice($post->ID)) { |
|
721 | 721 | |
722 | - return wpinv_get_template_part( 'wpinv-invoice-print', false, false ); |
|
722 | + return wpinv_get_template_part('wpinv-invoice-print', false, false); |
|
723 | 723 | |
724 | 724 | // Else display an error message. |
725 | 725 | } else { |
726 | 726 | |
727 | - return wpinv_get_template_part( 'wpinv-invalid-access', false, false ); |
|
727 | + return wpinv_get_template_part('wpinv-invalid-access', false, false); |
|
728 | 728 | |
729 | 729 | } |
730 | 730 | |
@@ -732,24 +732,24 @@ discard block |
||
732 | 732 | |
733 | 733 | return $template; |
734 | 734 | } |
735 | -add_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
735 | +add_filter('template_include', 'wpinv_template', 10, 1); |
|
736 | 736 | |
737 | 737 | function wpinv_get_business_address() { |
738 | 738 | $business_address = wpinv_store_address(); |
739 | - $business_address = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : ''; |
|
739 | + $business_address = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : ''; |
|
740 | 740 | |
741 | 741 | $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : ''; |
742 | 742 | |
743 | - return apply_filters( 'wpinv_get_business_address', $business_address ); |
|
743 | + return apply_filters('wpinv_get_business_address', $business_address); |
|
744 | 744 | } |
745 | 745 | |
746 | 746 | /** |
747 | 747 | * Displays the company address. |
748 | 748 | */ |
749 | 749 | function wpinv_display_from_address() { |
750 | - wpinv_get_template( 'invoice/company-address.php' ); |
|
750 | + wpinv_get_template('invoice/company-address.php'); |
|
751 | 751 | } |
752 | -add_action( 'getpaid_invoice_details_left', 'wpinv_display_from_address', 10 ); |
|
752 | +add_action('getpaid_invoice_details_left', 'wpinv_display_from_address', 10); |
|
753 | 753 | |
754 | 754 | /** |
755 | 755 | * Generates a watermark text for an invoice. |
@@ -757,9 +757,9 @@ discard block |
||
757 | 757 | * @param WPInv_Invoice $invoice |
758 | 758 | * @return string |
759 | 759 | */ |
760 | -function wpinv_watermark( $invoice ) { |
|
761 | - $watermark = wpinv_get_watermark( $invoice ); |
|
762 | - return apply_filters( 'wpinv_get_watermark', $watermark, $invoice ); |
|
760 | +function wpinv_watermark($invoice) { |
|
761 | + $watermark = wpinv_get_watermark($invoice); |
|
762 | + return apply_filters('wpinv_get_watermark', $watermark, $invoice); |
|
763 | 763 | } |
764 | 764 | |
765 | 765 | /** |
@@ -768,37 +768,37 @@ discard block |
||
768 | 768 | * @param WPInv_Invoice $invoice |
769 | 769 | * @return string |
770 | 770 | */ |
771 | -function wpinv_get_watermark( $invoice ) { |
|
771 | +function wpinv_get_watermark($invoice) { |
|
772 | 772 | return $invoice->get_status_nicename(); |
773 | 773 | } |
774 | 774 | |
775 | 775 | /** |
776 | 776 | * @deprecated |
777 | 777 | */ |
778 | -function wpinv_display_invoice_details( $invoice ) { |
|
779 | - return getpaid_invoice_meta( $invoice ); |
|
778 | +function wpinv_display_invoice_details($invoice) { |
|
779 | + return getpaid_invoice_meta($invoice); |
|
780 | 780 | } |
781 | 781 | |
782 | 782 | /** |
783 | 783 | * Displays invoice meta. |
784 | 784 | */ |
785 | -function getpaid_invoice_meta( $invoice ) { |
|
785 | +function getpaid_invoice_meta($invoice) { |
|
786 | 786 | |
787 | - $invoice = new WPInv_Invoice( $invoice ); |
|
787 | + $invoice = new WPInv_Invoice($invoice); |
|
788 | 788 | |
789 | 789 | // Ensure that we have an invoice. |
790 | - if ( 0 == $invoice->get_id() ) { |
|
790 | + if (0 == $invoice->get_id()) { |
|
791 | 791 | return; |
792 | 792 | } |
793 | 793 | |
794 | 794 | // Get the invoice meta. |
795 | - $meta = getpaid_get_invoice_meta( $invoice ); |
|
795 | + $meta = getpaid_get_invoice_meta($invoice); |
|
796 | 796 | |
797 | 797 | // Display the meta. |
798 | - wpinv_get_template( 'invoice/invoice-meta.php', compact( 'invoice', 'meta' ) ); |
|
798 | + wpinv_get_template('invoice/invoice-meta.php', compact('invoice', 'meta')); |
|
799 | 799 | |
800 | 800 | } |
801 | -add_action( 'getpaid_invoice_details_right', 'getpaid_invoice_meta', 10 ); |
|
801 | +add_action('getpaid_invoice_details_right', 'getpaid_invoice_meta', 10); |
|
802 | 802 | |
803 | 803 | /** |
804 | 804 | * Retrieves the address markup to use on Invoices. |
@@ -810,29 +810,29 @@ discard block |
||
810 | 810 | * @param string $separator How to separate address lines. |
811 | 811 | * @return string |
812 | 812 | */ |
813 | -function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) { |
|
813 | +function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') { |
|
814 | 814 | |
815 | 815 | // Retrieve the address markup... |
816 | - $country= empty( $billing_details['country'] ) ? '' : $billing_details['country']; |
|
817 | - $format = wpinv_get_full_address_format( $country ); |
|
816 | + $country = empty($billing_details['country']) ? '' : $billing_details['country']; |
|
817 | + $format = wpinv_get_full_address_format($country); |
|
818 | 818 | |
819 | 819 | // ... and the replacements. |
820 | - $replacements = wpinv_get_invoice_address_replacements( $billing_details ); |
|
820 | + $replacements = wpinv_get_invoice_address_replacements($billing_details); |
|
821 | 821 | |
822 | - $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format ); |
|
822 | + $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format); |
|
823 | 823 | |
824 | 824 | // Remove unavailable tags. |
825 | - $formatted_address = preg_replace( "/\{\{\w+\}\}/", '', $formatted_address ); |
|
825 | + $formatted_address = preg_replace("/\{\{\w+\}\}/", '', $formatted_address); |
|
826 | 826 | |
827 | 827 | // Clean up white space. |
828 | - $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
829 | - $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address ); |
|
828 | + $formatted_address = preg_replace('/ +/', ' ', trim($formatted_address)); |
|
829 | + $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address); |
|
830 | 830 | |
831 | 831 | // Break newlines apart and remove empty lines/trim commas and white space. |
832 | - $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
832 | + $formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address))); |
|
833 | 833 | |
834 | 834 | // Add html breaks. |
835 | - $formatted_address = implode( $separator, $formatted_address ); |
|
835 | + $formatted_address = implode($separator, $formatted_address); |
|
836 | 836 | |
837 | 837 | // We're done! |
838 | 838 | return $formatted_address; |
@@ -844,118 +844,118 @@ discard block |
||
844 | 844 | * |
845 | 845 | * @param WPInv_Invoice $invoice |
846 | 846 | */ |
847 | -function wpinv_display_to_address( $invoice = 0 ) { |
|
848 | - if ( ! empty( $invoice ) ) { |
|
849 | - wpinv_get_template( 'invoice/billing-address.php', compact( 'invoice' ) ); |
|
847 | +function wpinv_display_to_address($invoice = 0) { |
|
848 | + if (!empty($invoice)) { |
|
849 | + wpinv_get_template('invoice/billing-address.php', compact('invoice')); |
|
850 | 850 | } |
851 | 851 | } |
852 | -add_action( 'getpaid_invoice_details_left', 'wpinv_display_to_address', 40 ); |
|
852 | +add_action('getpaid_invoice_details_left', 'wpinv_display_to_address', 40); |
|
853 | 853 | |
854 | 854 | |
855 | 855 | /** |
856 | 856 | * Displays invoice line items. |
857 | 857 | */ |
858 | -function wpinv_display_line_items( $invoice_id = 0 ) { |
|
858 | +function wpinv_display_line_items($invoice_id = 0) { |
|
859 | 859 | |
860 | 860 | // Prepare the invoice. |
861 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
861 | + $invoice = new WPInv_Invoice($invoice_id); |
|
862 | 862 | |
863 | 863 | // Abort if there is no invoice. |
864 | - if ( 0 == $invoice->get_id() ) { |
|
864 | + if (0 == $invoice->get_id()) { |
|
865 | 865 | return; |
866 | 866 | } |
867 | 867 | |
868 | 868 | // Line item columns. |
869 | - $columns = getpaid_invoice_item_columns( $invoice ); |
|
870 | - $columns = apply_filters( 'getpaid_invoice_line_items_table_columns', $columns, $invoice ); |
|
869 | + $columns = getpaid_invoice_item_columns($invoice); |
|
870 | + $columns = apply_filters('getpaid_invoice_line_items_table_columns', $columns, $invoice); |
|
871 | 871 | |
872 | - wpinv_get_template( 'invoice/line-items.php', compact( 'invoice', 'columns' ) ); |
|
872 | + wpinv_get_template('invoice/line-items.php', compact('invoice', 'columns')); |
|
873 | 873 | } |
874 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_line_items', 10 ); |
|
874 | +add_action('getpaid_invoice_line_items', 'wpinv_display_line_items', 10); |
|
875 | 875 | |
876 | 876 | /** |
877 | 877 | * Displays invoice subscriptions. |
878 | 878 | * |
879 | 879 | * @param WPInv_Invoice $invoice |
880 | 880 | */ |
881 | -function getpaid_display_invoice_subscriptions( $invoice ) { |
|
881 | +function getpaid_display_invoice_subscriptions($invoice) { |
|
882 | 882 | |
883 | 883 | // Subscriptions. |
884 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
884 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
885 | 885 | |
886 | - if ( empty( $subscriptions ) || ! $invoice->is_recurring() ) { |
|
886 | + if (empty($subscriptions) || !$invoice->is_recurring()) { |
|
887 | 887 | return; |
888 | 888 | } |
889 | 889 | |
890 | - $main_subscription = getpaid_get_invoice_subscription( $invoice ); |
|
890 | + $main_subscription = getpaid_get_invoice_subscription($invoice); |
|
891 | 891 | |
892 | 892 | // Display related subscriptions. |
893 | - if ( is_array( $subscriptions ) ) { |
|
894 | - printf( '<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__( 'Related Subscriptions', 'invoicing' ) ); |
|
895 | - getpaid_admin_subscription_related_subscriptions_metabox( $main_subscription, false ); |
|
893 | + if (is_array($subscriptions)) { |
|
894 | + printf('<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__('Related Subscriptions', 'invoicing')); |
|
895 | + getpaid_admin_subscription_related_subscriptions_metabox($main_subscription, false); |
|
896 | 896 | } |
897 | 897 | |
898 | - if ( $main_subscription->get_total_payments() > 1 ) { |
|
899 | - printf( '<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__( 'Related Invoices', 'invoicing' ) ); |
|
900 | - getpaid_admin_subscription_invoice_details_metabox( $main_subscription, false ); |
|
898 | + if ($main_subscription->get_total_payments() > 1) { |
|
899 | + printf('<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__('Related Invoices', 'invoicing')); |
|
900 | + getpaid_admin_subscription_invoice_details_metabox($main_subscription, false); |
|
901 | 901 | } |
902 | 902 | |
903 | 903 | } |
904 | -add_action( 'getpaid_invoice_line_items', 'getpaid_display_invoice_subscriptions', 15 ); |
|
904 | +add_action('getpaid_invoice_line_items', 'getpaid_display_invoice_subscriptions', 15); |
|
905 | 905 | |
906 | 906 | /** |
907 | 907 | * Displays invoice notices on invoices. |
908 | 908 | */ |
909 | 909 | function wpinv_display_invoice_notice() { |
910 | 910 | |
911 | - $label = wpinv_get_option( 'vat_invoice_notice_label' ); |
|
912 | - $notice = wpinv_get_option( 'vat_invoice_notice' ); |
|
911 | + $label = wpinv_get_option('vat_invoice_notice_label'); |
|
912 | + $notice = wpinv_get_option('vat_invoice_notice'); |
|
913 | 913 | |
914 | - if ( empty( $label ) && empty( $notice ) ) { |
|
914 | + if (empty($label) && empty($notice)) { |
|
915 | 915 | return; |
916 | 916 | } |
917 | 917 | |
918 | 918 | echo '<div class="mt-4 mb-4 wpinv-vat-notice">'; |
919 | 919 | |
920 | - if ( ! empty( $label ) ) { |
|
921 | - $label = sanitize_text_field( $label ); |
|
920 | + if (!empty($label)) { |
|
921 | + $label = sanitize_text_field($label); |
|
922 | 922 | echo "<h5>$label</h5>"; |
923 | 923 | } |
924 | 924 | |
925 | - if ( ! empty( $notice ) ) { |
|
926 | - echo '<small class="form-text text-muted">' . wpautop( wptexturize( $notice ) ) . '</small>'; |
|
925 | + if (!empty($notice)) { |
|
926 | + echo '<small class="form-text text-muted">' . wpautop(wptexturize($notice)) . '</small>'; |
|
927 | 927 | } |
928 | 928 | |
929 | 929 | echo '</div>'; |
930 | 930 | } |
931 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100 ); |
|
931 | +add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100); |
|
932 | 932 | |
933 | 933 | /** |
934 | 934 | * @param WPInv_Invoice $invoice |
935 | 935 | */ |
936 | -function wpinv_display_invoice_notes( $invoice ) { |
|
936 | +function wpinv_display_invoice_notes($invoice) { |
|
937 | 937 | |
938 | 938 | // Retrieve the notes. |
939 | - $notes = wpinv_get_invoice_notes( $invoice->get_id(), 'customer' ); |
|
939 | + $notes = wpinv_get_invoice_notes($invoice->get_id(), 'customer'); |
|
940 | 940 | |
941 | 941 | // Abort if we have non. |
942 | - if ( empty( $notes ) ) { |
|
942 | + if (empty($notes)) { |
|
943 | 943 | return; |
944 | 944 | } |
945 | 945 | |
946 | 946 | // Echo the note. |
947 | 947 | echo '<div class="getpaid-invoice-notes-wrapper position-relative my-4">'; |
948 | - echo '<h2 class="getpaid-invoice-notes-title mb-1 p-0 h4">' . __( 'Notes', 'invoicing' ) .'</h2>'; |
|
948 | + echo '<h2 class="getpaid-invoice-notes-title mb-1 p-0 h4">' . __('Notes', 'invoicing') . '</h2>'; |
|
949 | 949 | echo '<ul class="getpaid-invoice-notes text-break overflow-auto list-unstyled p-0 m-0">'; |
950 | 950 | |
951 | - foreach( $notes as $note ) { |
|
952 | - wpinv_get_invoice_note_line_item( $note ); |
|
951 | + foreach ($notes as $note) { |
|
952 | + wpinv_get_invoice_note_line_item($note); |
|
953 | 953 | } |
954 | 954 | |
955 | 955 | echo '</ul>'; |
956 | 956 | echo '</div>'; |
957 | 957 | } |
958 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60 ); |
|
958 | +add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60); |
|
959 | 959 | |
960 | 960 | /** |
961 | 961 | * Loads scripts on our invoice templates. |
@@ -963,31 +963,31 @@ discard block |
||
963 | 963 | function wpinv_display_style() { |
964 | 964 | |
965 | 965 | // Make sure that all scripts have been loaded. |
966 | - if ( ! did_action( 'wp_enqueue_scripts' ) ) { |
|
967 | - do_action( 'wp_enqueue_scripts' ); |
|
966 | + if (!did_action('wp_enqueue_scripts')) { |
|
967 | + do_action('wp_enqueue_scripts'); |
|
968 | 968 | } |
969 | 969 | |
970 | 970 | // Register the invoices style. |
971 | - wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice.css' ) ); |
|
971 | + wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice.css')); |
|
972 | 972 | |
973 | 973 | // Load required styles |
974 | - wp_print_styles( 'wpinv-single-style' ); |
|
975 | - wp_print_styles( 'ayecode-ui' ); |
|
974 | + wp_print_styles('wpinv-single-style'); |
|
975 | + wp_print_styles('ayecode-ui'); |
|
976 | 976 | |
977 | 977 | // Maybe load custom css. |
978 | - $custom_css = wpinv_get_option( 'template_custom_css' ); |
|
978 | + $custom_css = wpinv_get_option('template_custom_css'); |
|
979 | 979 | |
980 | - if ( isset( $custom_css ) && ! empty( $custom_css ) ) { |
|
981 | - $custom_css = wp_kses( $custom_css, array( '\'', '\"' ) ); |
|
982 | - $custom_css = str_replace( '>', '>', $custom_css ); |
|
980 | + if (isset($custom_css) && !empty($custom_css)) { |
|
981 | + $custom_css = wp_kses($custom_css, array('\'', '\"')); |
|
982 | + $custom_css = str_replace('>', '>', $custom_css); |
|
983 | 983 | echo '<style type="text/css">'; |
984 | 984 | echo $custom_css; |
985 | 985 | echo '</style>'; |
986 | 986 | } |
987 | 987 | |
988 | 988 | } |
989 | -add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' ); |
|
990 | -add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' ); |
|
989 | +add_action('wpinv_invoice_print_head', 'wpinv_display_style'); |
|
990 | +add_action('wpinv_invalid_invoice_head', 'wpinv_display_style'); |
|
991 | 991 | |
992 | 992 | |
993 | 993 | /** |
@@ -999,41 +999,41 @@ discard block |
||
999 | 999 | // Retrieve the current invoice. |
1000 | 1000 | $invoice_id = getpaid_get_current_invoice_id(); |
1001 | 1001 | |
1002 | - if ( empty( $invoice_id ) ) { |
|
1002 | + if (empty($invoice_id)) { |
|
1003 | 1003 | |
1004 | 1004 | return aui()->alert( |
1005 | 1005 | array( |
1006 | 1006 | 'type' => 'warning', |
1007 | - 'content' => __( 'Invalid invoice', 'invoicing' ), |
|
1007 | + 'content' => __('Invalid invoice', 'invoicing'), |
|
1008 | 1008 | ) |
1009 | 1009 | ); |
1010 | 1010 | |
1011 | 1011 | } |
1012 | 1012 | |
1013 | 1013 | // Can the user view this invoice? |
1014 | - if ( ! wpinv_user_can_view_invoice( $invoice_id ) ) { |
|
1014 | + if (!wpinv_user_can_view_invoice($invoice_id)) { |
|
1015 | 1015 | |
1016 | 1016 | return aui()->alert( |
1017 | 1017 | array( |
1018 | 1018 | 'type' => 'warning', |
1019 | - 'content' => __( 'You are not allowed to view this invoice', 'invoicing' ), |
|
1019 | + 'content' => __('You are not allowed to view this invoice', 'invoicing'), |
|
1020 | 1020 | ) |
1021 | 1021 | ); |
1022 | 1022 | |
1023 | 1023 | } |
1024 | 1024 | |
1025 | 1025 | // Ensure that it is not yet paid for. |
1026 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
1026 | + $invoice = new WPInv_Invoice($invoice_id); |
|
1027 | 1027 | |
1028 | 1028 | // Maybe mark it as viewed. |
1029 | - getpaid_maybe_mark_invoice_as_viewed( $invoice ); |
|
1029 | + getpaid_maybe_mark_invoice_as_viewed($invoice); |
|
1030 | 1030 | |
1031 | - if ( $invoice->is_paid() ) { |
|
1031 | + if ($invoice->is_paid()) { |
|
1032 | 1032 | |
1033 | 1033 | return aui()->alert( |
1034 | 1034 | array( |
1035 | 1035 | 'type' => 'success', |
1036 | - 'content' => __( 'This invoice has already been paid.', 'invoicing' ), |
|
1036 | + 'content' => __('This invoice has already been paid.', 'invoicing'), |
|
1037 | 1037 | ) |
1038 | 1038 | ); |
1039 | 1039 | |
@@ -1043,15 +1043,15 @@ discard block |
||
1043 | 1043 | $wpi_checkout_id = $invoice_id; |
1044 | 1044 | |
1045 | 1045 | // Retrieve appropriate payment form. |
1046 | - $payment_form = new GetPaid_Payment_Form( $invoice->get_meta( 'force_payment_form' ) ); |
|
1047 | - $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
1046 | + $payment_form = new GetPaid_Payment_Form($invoice->get_meta('force_payment_form')); |
|
1047 | + $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
1048 | 1048 | |
1049 | - if ( ! $payment_form->exists() ) { |
|
1049 | + if (!$payment_form->exists()) { |
|
1050 | 1050 | |
1051 | 1051 | return aui()->alert( |
1052 | 1052 | array( |
1053 | 1053 | 'type' => 'warning', |
1054 | - 'content' => __( 'Error loading the payment form', 'invoicing' ), |
|
1054 | + 'content' => __('Error loading the payment form', 'invoicing'), |
|
1055 | 1055 | ) |
1056 | 1056 | ); |
1057 | 1057 | |
@@ -1060,29 +1060,29 @@ discard block |
||
1060 | 1060 | // Set the invoice. |
1061 | 1061 | $payment_form->invoice = $invoice; |
1062 | 1062 | |
1063 | - if ( ! $payment_form->is_default() ) { |
|
1063 | + if (!$payment_form->is_default()) { |
|
1064 | 1064 | |
1065 | 1065 | $items = array(); |
1066 | 1066 | $item_ids = array(); |
1067 | 1067 | |
1068 | - foreach ( $invoice->get_items() as $item ) { |
|
1069 | - if ( ! in_array( $item->get_id(), $item_ids ) ) { |
|
1068 | + foreach ($invoice->get_items() as $item) { |
|
1069 | + if (!in_array($item->get_id(), $item_ids)) { |
|
1070 | 1070 | $item_ids[] = $item->get_id(); |
1071 | 1071 | $items[] = $item; |
1072 | 1072 | } |
1073 | 1073 | } |
1074 | 1074 | |
1075 | - foreach ( $payment_form->get_items() as $item ) { |
|
1076 | - if ( ! in_array( $item->get_id(), $item_ids ) ) { |
|
1075 | + foreach ($payment_form->get_items() as $item) { |
|
1076 | + if (!in_array($item->get_id(), $item_ids)) { |
|
1077 | 1077 | $item_ids[] = $item->get_id(); |
1078 | 1078 | $items[] = $item; |
1079 | 1079 | } |
1080 | 1080 | } |
1081 | 1081 | |
1082 | - $payment_form->set_items( $items ); |
|
1082 | + $payment_form->set_items($items); |
|
1083 | 1083 | |
1084 | 1084 | } else { |
1085 | - $payment_form->set_items( $invoice->get_items() ); |
|
1085 | + $payment_form->set_items($invoice->get_items()); |
|
1086 | 1086 | } |
1087 | 1087 | |
1088 | 1088 | // Generate the html. |
@@ -1091,7 +1091,7 @@ discard block |
||
1091 | 1091 | } |
1092 | 1092 | |
1093 | 1093 | function wpinv_empty_cart_message() { |
1094 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1094 | + return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>'); |
|
1095 | 1095 | } |
1096 | 1096 | |
1097 | 1097 | /** |
@@ -1108,76 +1108,76 @@ discard block |
||
1108 | 1108 | ) |
1109 | 1109 | ); |
1110 | 1110 | } |
1111 | -add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
|
1111 | +add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart'); |
|
1112 | 1112 | |
1113 | 1113 | /** |
1114 | 1114 | * Filters the receipt page. |
1115 | 1115 | */ |
1116 | -function wpinv_filter_success_page_content( $content ) { |
|
1116 | +function wpinv_filter_success_page_content($content) { |
|
1117 | 1117 | |
1118 | 1118 | // Maybe abort early. |
1119 | - if ( is_admin() || ! is_singular() || ! in_the_loop() || ! is_main_query() || is_preview() ) { |
|
1119 | + if (is_admin() || !is_singular() || !in_the_loop() || !is_main_query() || is_preview()) { |
|
1120 | 1120 | return $content; |
1121 | 1121 | } |
1122 | 1122 | |
1123 | 1123 | // Ensure this is our page. |
1124 | - if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) { |
|
1124 | + if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) { |
|
1125 | 1125 | |
1126 | - $gateway = sanitize_text_field( $_GET['payment-confirm'] ); |
|
1127 | - return apply_filters( "wpinv_payment_confirm_$gateway", $content ); |
|
1126 | + $gateway = sanitize_text_field($_GET['payment-confirm']); |
|
1127 | + return apply_filters("wpinv_payment_confirm_$gateway", $content); |
|
1128 | 1128 | |
1129 | 1129 | } |
1130 | 1130 | |
1131 | 1131 | return $content; |
1132 | 1132 | } |
1133 | -add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 ); |
|
1133 | +add_filter('the_content', 'wpinv_filter_success_page_content', 99999); |
|
1134 | 1134 | |
1135 | -function wpinv_invoice_link( $invoice_id ) { |
|
1136 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1135 | +function wpinv_invoice_link($invoice_id) { |
|
1136 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1137 | 1137 | |
1138 | - if ( empty( $invoice ) ) { |
|
1138 | + if (empty($invoice)) { |
|
1139 | 1139 | return NULL; |
1140 | 1140 | } |
1141 | 1141 | |
1142 | - $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>'; |
|
1142 | + $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>'; |
|
1143 | 1143 | |
1144 | - return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice ); |
|
1144 | + return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice); |
|
1145 | 1145 | } |
1146 | 1146 | |
1147 | -function wpinv_get_invoice_note_line_item( $note, $echo = true ) { |
|
1148 | - if ( empty( $note ) ) { |
|
1147 | +function wpinv_get_invoice_note_line_item($note, $echo = true) { |
|
1148 | + if (empty($note)) { |
|
1149 | 1149 | return NULL; |
1150 | 1150 | } |
1151 | 1151 | |
1152 | - if ( is_int( $note ) ) { |
|
1153 | - $note = get_comment( $note ); |
|
1152 | + if (is_int($note)) { |
|
1153 | + $note = get_comment($note); |
|
1154 | 1154 | } |
1155 | 1155 | |
1156 | - if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) { |
|
1156 | + if (!(is_object($note) && is_a($note, 'WP_Comment'))) { |
|
1157 | 1157 | return NULL; |
1158 | 1158 | } |
1159 | 1159 | |
1160 | - $note_classes = array( 'note' ); |
|
1161 | - $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : ''; |
|
1160 | + $note_classes = array('note'); |
|
1161 | + $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : ''; |
|
1162 | 1162 | $note_classes[] = $note->comment_author === 'System' ? 'system-note' : ''; |
1163 | - $note_classes = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note ); |
|
1164 | - $note_classes = !empty( $note_classes ) ? implode( ' ', $note_classes ) : ''; |
|
1163 | + $note_classes = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note); |
|
1164 | + $note_classes = !empty($note_classes) ? implode(' ', $note_classes) : ''; |
|
1165 | 1165 | |
1166 | 1166 | ob_start(); |
1167 | 1167 | ?> |
1168 | - <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?> mb-2"> |
|
1168 | + <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?> mb-2"> |
|
1169 | 1169 | <div class="note_content"> |
1170 | 1170 | |
1171 | - <?php echo wptexturize( wp_kses_post( $note->comment_content ) ); ?> |
|
1171 | + <?php echo wptexturize(wp_kses_post($note->comment_content)); ?> |
|
1172 | 1172 | |
1173 | - <?php if ( ! is_admin() ) : ?> |
|
1173 | + <?php if (!is_admin()) : ?> |
|
1174 | 1174 | <em class="small form-text text-muted mt-0"> |
1175 | 1175 | <?php |
1176 | 1176 | printf( |
1177 | - __( '%1$s - %2$s at %3$s', 'invoicing' ), |
|
1177 | + __('%1$s - %2$s at %3$s', 'invoicing'), |
|
1178 | 1178 | $note->comment_author, |
1179 | - getpaid_format_date_value( $note->comment_date ), |
|
1180 | - date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) |
|
1179 | + getpaid_format_date_value($note->comment_date), |
|
1180 | + date_i18n(get_option('time_format'), strtotime($note->comment_date)) |
|
1181 | 1181 | ); |
1182 | 1182 | ?> |
1183 | 1183 | </em> |
@@ -1185,21 +1185,21 @@ discard block |
||
1185 | 1185 | |
1186 | 1186 | </div> |
1187 | 1187 | |
1188 | - <?php if ( is_admin() ) : ?> |
|
1188 | + <?php if (is_admin()) : ?> |
|
1189 | 1189 | |
1190 | 1190 | <p class="meta px-4 py-2"> |
1191 | - <abbr class="exact-date" title="<?php echo esc_attr( $note->comment_date ); ?>"> |
|
1191 | + <abbr class="exact-date" title="<?php echo esc_attr($note->comment_date); ?>"> |
|
1192 | 1192 | <?php |
1193 | 1193 | printf( |
1194 | - __( '%1$s - %2$s at %3$s', 'invoicing' ), |
|
1194 | + __('%1$s - %2$s at %3$s', 'invoicing'), |
|
1195 | 1195 | $note->comment_author, |
1196 | - getpaid_format_date_value( $note->comment_date ), |
|
1197 | - date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) |
|
1196 | + getpaid_format_date_value($note->comment_date), |
|
1197 | + date_i18n(get_option('time_format'), strtotime($note->comment_date)) |
|
1198 | 1198 | ); |
1199 | 1199 | ?> |
1200 | 1200 | </abbr> |
1201 | - <?php if ( $note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing() ) { ?> |
|
1202 | - <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a> |
|
1201 | + <?php if ($note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing()) { ?> |
|
1202 | + <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a> |
|
1203 | 1203 | <?php } ?> |
1204 | 1204 | </p> |
1205 | 1205 | |
@@ -1208,9 +1208,9 @@ discard block |
||
1208 | 1208 | </li> |
1209 | 1209 | <?php |
1210 | 1210 | $note_content = ob_get_clean(); |
1211 | - $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo ); |
|
1211 | + $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo); |
|
1212 | 1212 | |
1213 | - if ( $echo ) { |
|
1213 | + if ($echo) { |
|
1214 | 1214 | echo $note_content; |
1215 | 1215 | } else { |
1216 | 1216 | return $note_content; |
@@ -1224,21 +1224,21 @@ discard block |
||
1224 | 1224 | * @return string |
1225 | 1225 | */ |
1226 | 1226 | function wpinv_get_policy_text() { |
1227 | - $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 ); |
|
1227 | + $privacy_page_id = get_option('wp_page_for_privacy_policy', 0); |
|
1228 | 1228 | |
1229 | - $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' )); |
|
1229 | + $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]')); |
|
1230 | 1230 | |
1231 | - if(!$privacy_page_id){ |
|
1232 | - $privacy_page_id = wpinv_get_option( 'privacy_page', 0 ); |
|
1231 | + if (!$privacy_page_id) { |
|
1232 | + $privacy_page_id = wpinv_get_option('privacy_page', 0); |
|
1233 | 1233 | } |
1234 | 1234 | |
1235 | - $privacy_link = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="wpinv-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'invoicing' ) . '</a>' : __( 'privacy policy', 'invoicing' ); |
|
1235 | + $privacy_link = $privacy_page_id ? '<a href="' . esc_url(get_permalink($privacy_page_id)) . '" class="wpinv-privacy-policy-link" target="_blank">' . __('privacy policy', 'invoicing') . '</a>' : __('privacy policy', 'invoicing'); |
|
1236 | 1236 | |
1237 | 1237 | $find_replace = array( |
1238 | 1238 | '[wpinv_privacy_policy]' => $privacy_link, |
1239 | 1239 | ); |
1240 | 1240 | |
1241 | - $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text ); |
|
1241 | + $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text); |
|
1242 | 1242 | |
1243 | 1243 | return wp_kses_post(wpautop($privacy_text)); |
1244 | 1244 | } |
@@ -1246,21 +1246,21 @@ discard block |
||
1246 | 1246 | function wpinv_oxygen_fix_conflict() { |
1247 | 1247 | global $ct_ignore_post_types; |
1248 | 1248 | |
1249 | - if ( ! is_array( $ct_ignore_post_types ) ) { |
|
1249 | + if (!is_array($ct_ignore_post_types)) { |
|
1250 | 1250 | $ct_ignore_post_types = array(); |
1251 | 1251 | } |
1252 | 1252 | |
1253 | - $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item', 'wpi_payment_form' ); |
|
1253 | + $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item', 'wpi_payment_form'); |
|
1254 | 1254 | |
1255 | - foreach ( $post_types as $post_type ) { |
|
1255 | + foreach ($post_types as $post_type) { |
|
1256 | 1256 | $ct_ignore_post_types[] = $post_type; |
1257 | 1257 | |
1258 | 1258 | // Ignore post type |
1259 | - add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 ); |
|
1259 | + add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999); |
|
1260 | 1260 | } |
1261 | 1261 | |
1262 | - remove_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
1263 | - add_filter( 'template_include', 'wpinv_template', 999, 1 ); |
|
1262 | + remove_filter('template_include', 'wpinv_template', 10, 1); |
|
1263 | + add_filter('template_include', 'wpinv_template', 999, 1); |
|
1264 | 1264 | } |
1265 | 1265 | |
1266 | 1266 | /** |
@@ -1268,10 +1268,10 @@ discard block |
||
1268 | 1268 | * |
1269 | 1269 | * @param GetPaid_Payment_Form $form |
1270 | 1270 | */ |
1271 | -function getpaid_display_payment_form( $form ) { |
|
1271 | +function getpaid_display_payment_form($form) { |
|
1272 | 1272 | |
1273 | - if ( is_numeric( $form ) ) { |
|
1274 | - $form = new GetPaid_Payment_Form( $form ); |
|
1273 | + if (is_numeric($form)) { |
|
1274 | + $form = new GetPaid_Payment_Form($form); |
|
1275 | 1275 | } |
1276 | 1276 | |
1277 | 1277 | $form->display(); |
@@ -1281,55 +1281,55 @@ discard block |
||
1281 | 1281 | /** |
1282 | 1282 | * Helper function to display a item payment form on the frontend. |
1283 | 1283 | */ |
1284 | -function getpaid_display_item_payment_form( $items ) { |
|
1284 | +function getpaid_display_item_payment_form($items) { |
|
1285 | 1285 | |
1286 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
1287 | - $form->set_items( $items ); |
|
1286 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
1287 | + $form->set_items($items); |
|
1288 | 1288 | |
1289 | - if ( 0 == count( $form->get_items() ) ) { |
|
1289 | + if (0 == count($form->get_items())) { |
|
1290 | 1290 | echo aui()->alert( |
1291 | 1291 | array( |
1292 | 1292 | 'type' => 'warning', |
1293 | - 'content' => __( 'No published items found', 'invoicing' ), |
|
1293 | + 'content' => __('No published items found', 'invoicing'), |
|
1294 | 1294 | ) |
1295 | 1295 | ); |
1296 | 1296 | return; |
1297 | 1297 | } |
1298 | 1298 | |
1299 | - $form_items = esc_attr( getpaid_convert_items_to_string( $items ) ); |
|
1299 | + $form_items = esc_attr(getpaid_convert_items_to_string($items)); |
|
1300 | 1300 | $form_items = "<input type='hidden' name='getpaid-form-items' value='$form_items' />"; |
1301 | - $form->display( $form_items ); |
|
1301 | + $form->display($form_items); |
|
1302 | 1302 | } |
1303 | 1303 | |
1304 | 1304 | /** |
1305 | 1305 | * Helper function to display an invoice payment form on the frontend. |
1306 | 1306 | */ |
1307 | -function getpaid_display_invoice_payment_form( $invoice_id ) { |
|
1307 | +function getpaid_display_invoice_payment_form($invoice_id) { |
|
1308 | 1308 | |
1309 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1309 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1310 | 1310 | |
1311 | - if ( empty( $invoice ) ) { |
|
1311 | + if (empty($invoice)) { |
|
1312 | 1312 | echo aui()->alert( |
1313 | 1313 | array( |
1314 | 1314 | 'type' => 'warning', |
1315 | - 'content' => __( 'Invoice not found', 'invoicing' ), |
|
1315 | + 'content' => __('Invoice not found', 'invoicing'), |
|
1316 | 1316 | ) |
1317 | 1317 | ); |
1318 | 1318 | return; |
1319 | 1319 | } |
1320 | 1320 | |
1321 | - if ( $invoice->is_paid() ) { |
|
1321 | + if ($invoice->is_paid()) { |
|
1322 | 1322 | echo aui()->alert( |
1323 | 1323 | array( |
1324 | 1324 | 'type' => 'warning', |
1325 | - 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
1325 | + 'content' => __('Invoice has already been paid', 'invoicing'), |
|
1326 | 1326 | ) |
1327 | 1327 | ); |
1328 | 1328 | return; |
1329 | 1329 | } |
1330 | 1330 | |
1331 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
1332 | - $form->set_items( $invoice->get_items() ); |
|
1331 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
1332 | + $form->set_items($invoice->get_items()); |
|
1333 | 1333 | |
1334 | 1334 | $form->display(); |
1335 | 1335 | } |
@@ -1337,23 +1337,23 @@ discard block |
||
1337 | 1337 | /** |
1338 | 1338 | * Helper function to convert item string to array. |
1339 | 1339 | */ |
1340 | -function getpaid_convert_items_to_array( $items ) { |
|
1341 | - $items = array_filter( array_map( 'trim', explode( ',', $items ) ) ); |
|
1340 | +function getpaid_convert_items_to_array($items) { |
|
1341 | + $items = array_filter(array_map('trim', explode(',', $items))); |
|
1342 | 1342 | $prepared = array(); |
1343 | 1343 | |
1344 | - foreach ( $items as $item ) { |
|
1345 | - $data = array_map( 'trim', explode( '|', $item ) ); |
|
1344 | + foreach ($items as $item) { |
|
1345 | + $data = array_map('trim', explode('|', $item)); |
|
1346 | 1346 | |
1347 | - if ( empty( $data[0] ) || ! is_numeric( $data[0] ) ) { |
|
1347 | + if (empty($data[0]) || !is_numeric($data[0])) { |
|
1348 | 1348 | continue; |
1349 | 1349 | } |
1350 | 1350 | |
1351 | 1351 | $quantity = 1; |
1352 | - if ( isset( $data[1] ) && is_numeric( $data[1] ) ) { |
|
1352 | + if (isset($data[1]) && is_numeric($data[1])) { |
|
1353 | 1353 | $quantity = (float) $data[1]; |
1354 | 1354 | } |
1355 | 1355 | |
1356 | - $prepared[ $data[0] ] = $quantity; |
|
1356 | + $prepared[$data[0]] = $quantity; |
|
1357 | 1357 | |
1358 | 1358 | } |
1359 | 1359 | |
@@ -1363,13 +1363,13 @@ discard block |
||
1363 | 1363 | /** |
1364 | 1364 | * Helper function to convert item array to string. |
1365 | 1365 | */ |
1366 | -function getpaid_convert_items_to_string( $items ) { |
|
1366 | +function getpaid_convert_items_to_string($items) { |
|
1367 | 1367 | $prepared = array(); |
1368 | 1368 | |
1369 | - foreach ( $items as $item => $quantity ) { |
|
1369 | + foreach ($items as $item => $quantity) { |
|
1370 | 1370 | $prepared[] = "$item|$quantity"; |
1371 | 1371 | } |
1372 | - return implode( ',', $prepared ); |
|
1372 | + return implode(',', $prepared); |
|
1373 | 1373 | } |
1374 | 1374 | |
1375 | 1375 | /** |
@@ -1377,21 +1377,21 @@ discard block |
||
1377 | 1377 | * |
1378 | 1378 | * Provide a label and one of $form, $items or $invoice. |
1379 | 1379 | */ |
1380 | -function getpaid_get_payment_button( $label, $form = null, $items = null, $invoice = null ) { |
|
1381 | - $label = sanitize_text_field( $label ); |
|
1380 | +function getpaid_get_payment_button($label, $form = null, $items = null, $invoice = null) { |
|
1381 | + $label = sanitize_text_field($label); |
|
1382 | 1382 | |
1383 | - if ( ! empty( $form ) ) { |
|
1384 | - $form = esc_attr( $form ); |
|
1383 | + if (!empty($form)) { |
|
1384 | + $form = esc_attr($form); |
|
1385 | 1385 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-form='$form'>$label</button>"; |
1386 | 1386 | } |
1387 | 1387 | |
1388 | - if ( ! empty( $items ) ) { |
|
1389 | - $items = esc_attr( $items ); |
|
1388 | + if (!empty($items)) { |
|
1389 | + $items = esc_attr($items); |
|
1390 | 1390 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-item='$items'>$label</button>"; |
1391 | 1391 | } |
1392 | 1392 | |
1393 | - if ( ! empty( $invoice ) ) { |
|
1394 | - $invoice = esc_attr( $invoice ); |
|
1393 | + if (!empty($invoice)) { |
|
1394 | + $invoice = esc_attr($invoice); |
|
1395 | 1395 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-invoice='$invoice'>$label</button>"; |
1396 | 1396 | } |
1397 | 1397 | |
@@ -1402,18 +1402,18 @@ discard block |
||
1402 | 1402 | * |
1403 | 1403 | * @param WPInv_Invoice $invoice |
1404 | 1404 | */ |
1405 | -function getpaid_the_invoice_description( $invoice ) { |
|
1405 | +function getpaid_the_invoice_description($invoice) { |
|
1406 | 1406 | $description = $invoice->get_description(); |
1407 | 1407 | |
1408 | - if ( empty( $description ) ) { |
|
1408 | + if (empty($description)) { |
|
1409 | 1409 | return; |
1410 | 1410 | } |
1411 | 1411 | |
1412 | - $description = wp_kses_post( $description ); |
|
1412 | + $description = wp_kses_post($description); |
|
1413 | 1413 | echo "<small class='getpaid-invoice-description text-dark p-2 form-text' style='margin-bottom: 20px; border-left: 2px solid #2196F3;'><em>$description</em></small>"; |
1414 | 1414 | } |
1415 | -add_action( 'getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100 ); |
|
1416 | -add_action( 'wpinv_email_billing_details', 'getpaid_the_invoice_description', 100 ); |
|
1415 | +add_action('getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100); |
|
1416 | +add_action('wpinv_email_billing_details', 'getpaid_the_invoice_description', 100); |
|
1417 | 1417 | |
1418 | 1418 | /** |
1419 | 1419 | * Render element on a form. |
@@ -1421,60 +1421,60 @@ discard block |
||
1421 | 1421 | * @param array $element |
1422 | 1422 | * @param GetPaid_Payment_Form $form |
1423 | 1423 | */ |
1424 | -function getpaid_payment_form_element( $element, $form ) { |
|
1424 | +function getpaid_payment_form_element($element, $form) { |
|
1425 | 1425 | |
1426 | 1426 | // Set up the args. |
1427 | - $element_type = trim( $element['type'] ); |
|
1427 | + $element_type = trim($element['type']); |
|
1428 | 1428 | $element['form'] = $form; |
1429 | - extract( $element ); |
|
1429 | + extract($element); |
|
1430 | 1430 | |
1431 | 1431 | // Try to locate the appropriate template. |
1432 | - $located = wpinv_locate_template( "payment-forms/elements/$element_type.php" ); |
|
1432 | + $located = wpinv_locate_template("payment-forms/elements/$element_type.php"); |
|
1433 | 1433 | |
1434 | 1434 | // Abort if this is not our element. |
1435 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
1435 | + if (empty($located) || !file_exists($located)) { |
|
1436 | 1436 | return; |
1437 | 1437 | } |
1438 | 1438 | |
1439 | 1439 | // Generate the class and id of the element. |
1440 | - $wrapper_class = 'getpaid-payment-form-element-' . trim( esc_attr( $element_type ) ); |
|
1441 | - $id = isset( $id ) ? $id : uniqid( 'gp' ); |
|
1440 | + $wrapper_class = 'getpaid-payment-form-element-' . trim(esc_attr($element_type)); |
|
1441 | + $id = isset($id) ? $id : uniqid('gp'); |
|
1442 | 1442 | |
1443 | 1443 | // Echo the opening wrapper. |
1444 | 1444 | echo "<div class='getpaid-payment-form-element $wrapper_class'>"; |
1445 | 1445 | |
1446 | 1446 | // Fires before displaying a given element type's content. |
1447 | - do_action( "getpaid_before_payment_form_{$element_type}_element", $element, $form ); |
|
1447 | + do_action("getpaid_before_payment_form_{$element_type}_element", $element, $form); |
|
1448 | 1448 | |
1449 | 1449 | // Include the template for the element. |
1450 | 1450 | include $located; |
1451 | 1451 | |
1452 | 1452 | // Fires after displaying a given element type's content. |
1453 | - do_action( "getpaid_payment_form_{$element_type}_element", $element, $form ); |
|
1453 | + do_action("getpaid_payment_form_{$element_type}_element", $element, $form); |
|
1454 | 1454 | |
1455 | 1455 | // Echo the closing wrapper. |
1456 | 1456 | echo '</div>'; |
1457 | 1457 | } |
1458 | -add_action( 'getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2 ); |
|
1458 | +add_action('getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2); |
|
1459 | 1459 | |
1460 | 1460 | /** |
1461 | 1461 | * Render an element's edit page. |
1462 | 1462 | * |
1463 | 1463 | * @param WP_Post $post |
1464 | 1464 | */ |
1465 | -function getpaid_payment_form_edit_element_template( $post ) { |
|
1465 | +function getpaid_payment_form_edit_element_template($post) { |
|
1466 | 1466 | |
1467 | 1467 | // Retrieve all elements. |
1468 | - $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' ); |
|
1468 | + $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type'); |
|
1469 | 1469 | |
1470 | - foreach ( $all_elements as $element ) { |
|
1470 | + foreach ($all_elements as $element) { |
|
1471 | 1471 | |
1472 | 1472 | // Try to locate the appropriate template. |
1473 | - $element = sanitize_key( $element ); |
|
1474 | - $located = wpinv_locate_template( "payment-forms-admin/edit/$element.php" ); |
|
1473 | + $element = sanitize_key($element); |
|
1474 | + $located = wpinv_locate_template("payment-forms-admin/edit/$element.php"); |
|
1475 | 1475 | |
1476 | 1476 | // Continue if this is not our element. |
1477 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
1477 | + if (empty($located) || !file_exists($located)) { |
|
1478 | 1478 | continue; |
1479 | 1479 | } |
1480 | 1480 | |
@@ -1485,7 +1485,7 @@ discard block |
||
1485 | 1485 | } |
1486 | 1486 | |
1487 | 1487 | } |
1488 | -add_action( 'getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template' ); |
|
1488 | +add_action('getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template'); |
|
1489 | 1489 | |
1490 | 1490 | /** |
1491 | 1491 | * Render an element's preview. |
@@ -1494,16 +1494,16 @@ discard block |
||
1494 | 1494 | function getpaid_payment_form_render_element_preview_template() { |
1495 | 1495 | |
1496 | 1496 | // Retrieve all elements. |
1497 | - $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' ); |
|
1497 | + $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type'); |
|
1498 | 1498 | |
1499 | - foreach ( $all_elements as $element ) { |
|
1499 | + foreach ($all_elements as $element) { |
|
1500 | 1500 | |
1501 | 1501 | // Try to locate the appropriate template. |
1502 | - $element = sanitize_key( $element ); |
|
1503 | - $located = wpinv_locate_template( "payment-forms-admin/previews/$element.php" ); |
|
1502 | + $element = sanitize_key($element); |
|
1503 | + $located = wpinv_locate_template("payment-forms-admin/previews/$element.php"); |
|
1504 | 1504 | |
1505 | 1505 | // Continue if this is not our element. |
1506 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
1506 | + if (empty($located) || !file_exists($located)) { |
|
1507 | 1507 | continue; |
1508 | 1508 | } |
1509 | 1509 | |
@@ -1514,7 +1514,7 @@ discard block |
||
1514 | 1514 | } |
1515 | 1515 | |
1516 | 1516 | } |
1517 | -add_action( 'wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template' ); |
|
1517 | +add_action('wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template'); |
|
1518 | 1518 | |
1519 | 1519 | /** |
1520 | 1520 | * Shows a list of gateways that support recurring payments. |
@@ -1522,17 +1522,17 @@ discard block |
||
1522 | 1522 | function wpinv_get_recurring_gateways_text() { |
1523 | 1523 | $gateways = array(); |
1524 | 1524 | |
1525 | - foreach ( wpinv_get_payment_gateways() as $key => $gateway ) { |
|
1526 | - if ( wpinv_gateway_support_subscription( $key ) ) { |
|
1527 | - $gateways[] = sanitize_text_field( $gateway['admin_label'] ); |
|
1525 | + foreach (wpinv_get_payment_gateways() as $key => $gateway) { |
|
1526 | + if (wpinv_gateway_support_subscription($key)) { |
|
1527 | + $gateways[] = sanitize_text_field($gateway['admin_label']); |
|
1528 | 1528 | } |
1529 | 1529 | } |
1530 | 1530 | |
1531 | - if ( empty( $gateways ) ) { |
|
1532 | - return "<span class='form-text text-danger'>" . __( 'No active gateways support subscription payments.', 'invoicing' ) ."</span>"; |
|
1531 | + if (empty($gateways)) { |
|
1532 | + return "<span class='form-text text-danger'>" . __('No active gateways support subscription payments.', 'invoicing') . "</span>"; |
|
1533 | 1533 | } |
1534 | 1534 | |
1535 | - return "<span class='form-text text-muted'>" . wp_sprintf( __( 'Subscription payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ) ."</span>"; |
|
1535 | + return "<span class='form-text text-muted'>" . wp_sprintf(__('Subscription payments only supported by: %s', 'invoicing'), implode(', ', $gateways)) . "</span>"; |
|
1536 | 1536 | |
1537 | 1537 | } |
1538 | 1538 | |
@@ -1542,7 +1542,7 @@ discard block |
||
1542 | 1542 | * @return GetPaid_Template |
1543 | 1543 | */ |
1544 | 1544 | function getpaid_template() { |
1545 | - return getpaid()->get( 'template' ); |
|
1545 | + return getpaid()->get('template'); |
|
1546 | 1546 | } |
1547 | 1547 | |
1548 | 1548 | /** |
@@ -1551,8 +1551,8 @@ discard block |
||
1551 | 1551 | * @param array args |
1552 | 1552 | * @return string |
1553 | 1553 | */ |
1554 | -function getpaid_paginate_links( $args ) { |
|
1555 | - return str_replace( 'page-link dots', 'page-link text-dark', aui()->pagination( $args ) ); |
|
1554 | +function getpaid_paginate_links($args) { |
|
1555 | + return str_replace('page-link dots', 'page-link text-dark', aui()->pagination($args)); |
|
1556 | 1556 | } |
1557 | 1557 | |
1558 | 1558 | /** |
@@ -1562,21 +1562,21 @@ discard block |
||
1562 | 1562 | * @param string state |
1563 | 1563 | * @return string |
1564 | 1564 | */ |
1565 | -function getpaid_get_states_select_markup( $country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12', $field_name = 'wpinv_state' ) { |
|
1565 | +function getpaid_get_states_select_markup($country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12', $field_name = 'wpinv_state') { |
|
1566 | 1566 | |
1567 | - $states = wpinv_get_country_states( $country ); |
|
1568 | - $uniqid = uniqid( '_' ); |
|
1567 | + $states = wpinv_get_country_states($country); |
|
1568 | + $uniqid = uniqid('_'); |
|
1569 | 1569 | |
1570 | - if ( ! empty( $states ) ) { |
|
1570 | + if (!empty($states)) { |
|
1571 | 1571 | |
1572 | - return aui()->select( array( |
|
1572 | + return aui()->select(array( |
|
1573 | 1573 | 'options' => $states, |
1574 | - 'name' => esc_attr( $field_name ), |
|
1575 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
1576 | - 'value' => sanitize_text_field( $state ), |
|
1574 | + 'name' => esc_attr($field_name), |
|
1575 | + 'id' => sanitize_html_class($field_name) . $uniqid, |
|
1576 | + 'value' => sanitize_text_field($state), |
|
1577 | 1577 | 'placeholder' => $placeholder, |
1578 | 1578 | 'required' => $required, |
1579 | - 'label' => wp_kses_post( $label ), |
|
1579 | + 'label' => wp_kses_post($label), |
|
1580 | 1580 | 'label_type' => 'vertical', |
1581 | 1581 | 'help_text' => $help_text, |
1582 | 1582 | 'class' => 'getpaid-address-field wpinv_state', |
@@ -1591,14 +1591,14 @@ discard block |
||
1591 | 1591 | |
1592 | 1592 | return aui()->input( |
1593 | 1593 | array( |
1594 | - 'name' => esc_attr( $field_name ), |
|
1595 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
1594 | + 'name' => esc_attr($field_name), |
|
1595 | + 'id' => sanitize_html_class($field_name) . $uniqid, |
|
1596 | 1596 | 'placeholder' => $placeholder, |
1597 | 1597 | 'required' => $required, |
1598 | - 'label' => wp_kses_post( $label ), |
|
1598 | + 'label' => wp_kses_post($label), |
|
1599 | 1599 | 'label_type' => 'vertical', |
1600 | 1600 | 'help_text' => $help_text, |
1601 | - 'value' => sanitize_text_field( $state ), |
|
1601 | + 'value' => sanitize_text_field($state), |
|
1602 | 1602 | 'class' => 'getpaid-address-field wpinv_state', |
1603 | 1603 | 'wrap_class' => "$wrapper_class getpaid-address-field-wrapper__state", |
1604 | 1604 | 'label_class' => 'getpaid-address-field-label getpaid-address-field-label__state', |
@@ -1616,16 +1616,16 @@ discard block |
||
1616 | 1616 | * @param array $element |
1617 | 1617 | * @return string |
1618 | 1618 | */ |
1619 | -function getpaid_get_form_element_grid_class( $element ) { |
|
1619 | +function getpaid_get_form_element_grid_class($element) { |
|
1620 | 1620 | |
1621 | 1621 | $class = "col-12"; |
1622 | - $width = empty( $element['grid_width'] ) ? 'full' : $element['grid_width']; |
|
1622 | + $width = empty($element['grid_width']) ? 'full' : $element['grid_width']; |
|
1623 | 1623 | |
1624 | - if ( $width == 'half' ) { |
|
1624 | + if ($width == 'half') { |
|
1625 | 1625 | $class = "col-12 col-md-6"; |
1626 | 1626 | } |
1627 | 1627 | |
1628 | - if ( $width == 'third' ) { |
|
1628 | + if ($width == 'third') { |
|
1629 | 1629 | $class = "col-12 col-md-4"; |
1630 | 1630 | } |
1631 | 1631 |
@@ -1,155 +1,155 @@ discard block |
||
1 | 1 | <?php |
2 | -function wpinv_is_subscription_payment( $invoice = '' ) { |
|
3 | - if ( empty( $invoice ) ) { |
|
2 | +function wpinv_is_subscription_payment($invoice = '') { |
|
3 | + if (empty($invoice)) { |
|
4 | 4 | return false; |
5 | 5 | } |
6 | 6 | |
7 | - if ( !is_object( $invoice ) && is_scalar( $invoice ) ) { |
|
8 | - $invoice = wpinv_get_invoice( $invoice ); |
|
7 | + if (!is_object($invoice) && is_scalar($invoice)) { |
|
8 | + $invoice = wpinv_get_invoice($invoice); |
|
9 | 9 | } |
10 | 10 | |
11 | - if ( empty( $invoice ) ) { |
|
11 | + if (empty($invoice)) { |
|
12 | 12 | return false; |
13 | 13 | } |
14 | 14 | |
15 | - if ( $invoice->is_renewal() ) { |
|
15 | + if ($invoice->is_renewal()) { |
|
16 | 16 | return true; |
17 | 17 | } |
18 | 18 | |
19 | 19 | return false; |
20 | 20 | } |
21 | 21 | |
22 | -function wpinv_payment_link_transaction_id( $invoice = '' ) { |
|
23 | - if ( empty( $invoice ) ) { |
|
22 | +function wpinv_payment_link_transaction_id($invoice = '') { |
|
23 | + if (empty($invoice)) { |
|
24 | 24 | return false; |
25 | 25 | } |
26 | 26 | |
27 | - if ( !is_object( $invoice ) && is_scalar( $invoice ) ) { |
|
28 | - $invoice = wpinv_get_invoice( $invoice ); |
|
27 | + if (!is_object($invoice) && is_scalar($invoice)) { |
|
28 | + $invoice = wpinv_get_invoice($invoice); |
|
29 | 29 | } |
30 | 30 | |
31 | - if ( empty( $invoice ) ) { |
|
31 | + if (empty($invoice)) { |
|
32 | 32 | return false; |
33 | 33 | } |
34 | 34 | |
35 | - return apply_filters( 'wpinv_payment_details_transaction_id-' . $invoice->gateway, $invoice->get_transaction_id(), $invoice->ID, $invoice ); |
|
35 | + return apply_filters('wpinv_payment_details_transaction_id-' . $invoice->gateway, $invoice->get_transaction_id(), $invoice->ID, $invoice); |
|
36 | 36 | } |
37 | 37 | |
38 | -function wpinv_subscription_initial_payment_desc( $amount, $period, $interval, $trial_period = '', $trial_interval = 0 ) { |
|
39 | - $interval = (int)$interval > 0 ? (int)$interval : 1; |
|
38 | +function wpinv_subscription_initial_payment_desc($amount, $period, $interval, $trial_period = '', $trial_interval = 0) { |
|
39 | + $interval = (int) $interval > 0 ? (int) $interval : 1; |
|
40 | 40 | |
41 | - if ( $trial_interval > 0 && !empty( $trial_period ) ) { |
|
42 | - $amount = __( 'Free', 'invoicing' ); |
|
41 | + if ($trial_interval > 0 && !empty($trial_period)) { |
|
42 | + $amount = __('Free', 'invoicing'); |
|
43 | 43 | $interval = $trial_interval; |
44 | 44 | $period = $trial_period; |
45 | 45 | } |
46 | 46 | |
47 | 47 | $description = ''; |
48 | - switch ( $period ) { |
|
48 | + switch ($period) { |
|
49 | 49 | case 'D' : |
50 | 50 | case 'day' : |
51 | - $description = wp_sprintf( _n( '%s for the first day.', '%s for the first %d days.', $interval, 'invoicing' ), $amount, $interval ); |
|
51 | + $description = wp_sprintf(_n('%s for the first day.', '%s for the first %d days.', $interval, 'invoicing'), $amount, $interval); |
|
52 | 52 | break; |
53 | 53 | case 'W' : |
54 | 54 | case 'week' : |
55 | - $description = wp_sprintf( _n( '%s for the first week.', '%s for the first %d weeks.', $interval, 'invoicing' ), $amount, $interval ); |
|
55 | + $description = wp_sprintf(_n('%s for the first week.', '%s for the first %d weeks.', $interval, 'invoicing'), $amount, $interval); |
|
56 | 56 | break; |
57 | 57 | case 'M' : |
58 | 58 | case 'month' : |
59 | - $description = wp_sprintf( _n( '%s for the first month.', '%s for the first %d months.', $interval, 'invoicing' ), $amount, $interval ); |
|
59 | + $description = wp_sprintf(_n('%s for the first month.', '%s for the first %d months.', $interval, 'invoicing'), $amount, $interval); |
|
60 | 60 | break; |
61 | 61 | case 'Y' : |
62 | 62 | case 'year' : |
63 | - $description = wp_sprintf( _n( '%s for the first year.', '%s for the first %d years.', $interval, 'invoicing' ), $amount, $interval ); |
|
63 | + $description = wp_sprintf(_n('%s for the first year.', '%s for the first %d years.', $interval, 'invoicing'), $amount, $interval); |
|
64 | 64 | break; |
65 | 65 | } |
66 | 66 | |
67 | - return apply_filters( 'wpinv_subscription_initial_payment_desc', $description, $amount, $period, $interval, $trial_period, $trial_interval ); |
|
67 | + return apply_filters('wpinv_subscription_initial_payment_desc', $description, $amount, $period, $interval, $trial_period, $trial_interval); |
|
68 | 68 | } |
69 | 69 | |
70 | -function wpinv_subscription_recurring_payment_desc( $amount, $period, $interval, $bill_times = 0, $trial_period = '', $trial_interval = 0 ) { |
|
71 | - $interval = (int)$interval > 0 ? (int)$interval : 1; |
|
72 | - $bill_times = (int)$bill_times > 0 ? (int)$bill_times : 0; |
|
70 | +function wpinv_subscription_recurring_payment_desc($amount, $period, $interval, $bill_times = 0, $trial_period = '', $trial_interval = 0) { |
|
71 | + $interval = (int) $interval > 0 ? (int) $interval : 1; |
|
72 | + $bill_times = (int) $bill_times > 0 ? (int) $bill_times : 0; |
|
73 | 73 | |
74 | 74 | $description = ''; |
75 | - switch ( $period ) { |
|
75 | + switch ($period) { |
|
76 | 76 | case 'D' : |
77 | 77 | case 'day' : |
78 | - if ( (int)$bill_times > 0 ) { |
|
79 | - if ( $interval > 1 ) { |
|
80 | - if ( $bill_times > 1 ) { |
|
81 | - $description = wp_sprintf( __( '%s for each %d days, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times ); |
|
78 | + if ((int) $bill_times > 0) { |
|
79 | + if ($interval > 1) { |
|
80 | + if ($bill_times > 1) { |
|
81 | + $description = wp_sprintf(__('%s for each %d days, for %d installments.', 'invoicing'), $amount, $interval, $bill_times); |
|
82 | 82 | } else { |
83 | - $description = wp_sprintf( __( '%s for %d days.', 'invoicing' ), $amount, $interval ); |
|
83 | + $description = wp_sprintf(__('%s for %d days.', 'invoicing'), $amount, $interval); |
|
84 | 84 | } |
85 | 85 | } else { |
86 | - $description = wp_sprintf( _n( '%s for one day.', '%s for each day, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times ); |
|
86 | + $description = wp_sprintf(_n('%s for one day.', '%s for each day, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times); |
|
87 | 87 | } |
88 | 88 | } else { |
89 | - $description = wp_sprintf( _n( '%s for each day.', '%s for each %d days.', $interval, 'invoicing'), $amount, $interval ); |
|
89 | + $description = wp_sprintf(_n('%s for each day.', '%s for each %d days.', $interval, 'invoicing'), $amount, $interval); |
|
90 | 90 | } |
91 | 91 | break; |
92 | 92 | case 'W' : |
93 | 93 | case 'week' : |
94 | - if ( (int)$bill_times > 0 ) { |
|
95 | - if ( $interval > 1 ) { |
|
96 | - if ( $bill_times > 1 ) { |
|
97 | - $description = wp_sprintf( __( '%s for each %d weeks, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times ); |
|
94 | + if ((int) $bill_times > 0) { |
|
95 | + if ($interval > 1) { |
|
96 | + if ($bill_times > 1) { |
|
97 | + $description = wp_sprintf(__('%s for each %d weeks, for %d installments.', 'invoicing'), $amount, $interval, $bill_times); |
|
98 | 98 | } else { |
99 | - $description = wp_sprintf( __( '%s for %d weeks.', 'invoicing' ), $amount, $interval ); |
|
99 | + $description = wp_sprintf(__('%s for %d weeks.', 'invoicing'), $amount, $interval); |
|
100 | 100 | } |
101 | 101 | } else { |
102 | - $description = wp_sprintf( _n( '%s for one week.', '%s for each week, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times ); |
|
102 | + $description = wp_sprintf(_n('%s for one week.', '%s for each week, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times); |
|
103 | 103 | } |
104 | 104 | } else { |
105 | - $description = wp_sprintf( _n( '%s for each week.', '%s for each %d weeks.', $interval, 'invoicing' ), $amount, $interval ); |
|
105 | + $description = wp_sprintf(_n('%s for each week.', '%s for each %d weeks.', $interval, 'invoicing'), $amount, $interval); |
|
106 | 106 | } |
107 | 107 | break; |
108 | 108 | case 'M' : |
109 | 109 | case 'month' : |
110 | - if ( (int)$bill_times > 0 ) { |
|
111 | - if ( $interval > 1 ) { |
|
112 | - if ( $bill_times > 1 ) { |
|
113 | - $description = wp_sprintf( __( '%s for each %d months, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times ); |
|
110 | + if ((int) $bill_times > 0) { |
|
111 | + if ($interval > 1) { |
|
112 | + if ($bill_times > 1) { |
|
113 | + $description = wp_sprintf(__('%s for each %d months, for %d installments.', 'invoicing'), $amount, $interval, $bill_times); |
|
114 | 114 | } else { |
115 | - $description = wp_sprintf( __( '%s for %d months.', 'invoicing' ), $amount, $interval ); |
|
115 | + $description = wp_sprintf(__('%s for %d months.', 'invoicing'), $amount, $interval); |
|
116 | 116 | } |
117 | 117 | } else { |
118 | - $description = wp_sprintf( _n( '%s for one month.', '%s for each month, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times ); |
|
118 | + $description = wp_sprintf(_n('%s for one month.', '%s for each month, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times); |
|
119 | 119 | } |
120 | 120 | } else { |
121 | - $description = wp_sprintf( _n( '%s for each month.', '%s for each %d months.', $interval, 'invoicing' ), $amount, $interval ); |
|
121 | + $description = wp_sprintf(_n('%s for each month.', '%s for each %d months.', $interval, 'invoicing'), $amount, $interval); |
|
122 | 122 | } |
123 | 123 | break; |
124 | 124 | case 'Y' : |
125 | 125 | case 'year' : |
126 | - if ( (int)$bill_times > 0 ) { |
|
127 | - if ( $interval > 1 ) { |
|
128 | - if ( $bill_times > 1 ) { |
|
129 | - $description = wp_sprintf( __( '%s for each %d years, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times ); |
|
126 | + if ((int) $bill_times > 0) { |
|
127 | + if ($interval > 1) { |
|
128 | + if ($bill_times > 1) { |
|
129 | + $description = wp_sprintf(__('%s for each %d years, for %d installments.', 'invoicing'), $amount, $interval, $bill_times); |
|
130 | 130 | } else { |
131 | - $description = wp_sprintf( __( '%s for %d years.', 'invoicing'), $amount, $interval ); |
|
131 | + $description = wp_sprintf(__('%s for %d years.', 'invoicing'), $amount, $interval); |
|
132 | 132 | } |
133 | 133 | } else { |
134 | - $description = wp_sprintf( _n( '%s for one year.', '%s for each year, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times ); |
|
134 | + $description = wp_sprintf(_n('%s for one year.', '%s for each year, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times); |
|
135 | 135 | } |
136 | 136 | } else { |
137 | - $description = wp_sprintf( _n( '%s for each year.', '%s for each %d years.', $interval, 'invoicing' ), $amount, $interval ); |
|
137 | + $description = wp_sprintf(_n('%s for each year.', '%s for each %d years.', $interval, 'invoicing'), $amount, $interval); |
|
138 | 138 | } |
139 | 139 | break; |
140 | 140 | } |
141 | 141 | |
142 | - return apply_filters( 'wpinv_subscription_recurring_payment_desc', $description, $amount, $period, $interval, $bill_times, $trial_period, $trial_interval ); |
|
142 | + return apply_filters('wpinv_subscription_recurring_payment_desc', $description, $amount, $period, $interval, $bill_times, $trial_period, $trial_interval); |
|
143 | 143 | } |
144 | 144 | |
145 | -function wpinv_subscription_payment_desc( $invoice ) { |
|
146 | - if ( empty( $invoice ) ) { |
|
145 | +function wpinv_subscription_payment_desc($invoice) { |
|
146 | + if (empty($invoice)) { |
|
147 | 147 | return NULL; |
148 | 148 | } |
149 | 149 | |
150 | 150 | $description = ''; |
151 | - if ( $invoice->is_parent() && $item = $invoice->get_recurring( true ) ) { |
|
152 | - if ( $item->has_free_trial() ) { |
|
151 | + if ($invoice->is_parent() && $item = $invoice->get_recurring(true)) { |
|
152 | + if ($item->has_free_trial()) { |
|
153 | 153 | $trial_period = $item->get_trial_period(); |
154 | 154 | $trial_interval = $item->get_trial_interval(); |
155 | 155 | } else { |
@@ -157,40 +157,40 @@ discard block |
||
157 | 157 | $trial_interval = 0; |
158 | 158 | } |
159 | 159 | |
160 | - $description = wpinv_get_billing_cycle( $invoice->get_total(), $invoice->get_recurring_details( 'total' ), $item->get_recurring_period(), $item->get_recurring_interval(), $item->get_recurring_limit(), $trial_period, $trial_interval, $invoice->get_currency() ); |
|
160 | + $description = wpinv_get_billing_cycle($invoice->get_total(), $invoice->get_recurring_details('total'), $item->get_recurring_period(), $item->get_recurring_interval(), $item->get_recurring_limit(), $trial_period, $trial_interval, $invoice->get_currency()); |
|
161 | 161 | } |
162 | 162 | |
163 | - return apply_filters( 'wpinv_subscription_payment_desc', $description, $invoice ); |
|
163 | + return apply_filters('wpinv_subscription_payment_desc', $description, $invoice); |
|
164 | 164 | } |
165 | 165 | |
166 | -function wpinv_get_billing_cycle( $initial, $recurring, $period, $interval, $bill_times, $trial_period = '', $trial_interval = 0, $currency = '' ) { |
|
167 | - $initial_total = wpinv_round_amount( $initial ); |
|
168 | - $recurring_total = wpinv_round_amount( $recurring ); |
|
166 | +function wpinv_get_billing_cycle($initial, $recurring, $period, $interval, $bill_times, $trial_period = '', $trial_interval = 0, $currency = '') { |
|
167 | + $initial_total = wpinv_round_amount($initial); |
|
168 | + $recurring_total = wpinv_round_amount($recurring); |
|
169 | 169 | |
170 | - if ( $trial_interval > 0 && !empty( $trial_period ) ) { |
|
170 | + if ($trial_interval > 0 && !empty($trial_period)) { |
|
171 | 171 | // Free trial |
172 | 172 | } else { |
173 | - if ( $bill_times == 1 ) { |
|
173 | + if ($bill_times == 1) { |
|
174 | 174 | $recurring_total = $initial_total; |
175 | - } else if ( $bill_times > 1 && $initial_total != $recurring_total ) { |
|
175 | + } else if ($bill_times > 1 && $initial_total != $recurring_total) { |
|
176 | 176 | $bill_times--; |
177 | 177 | } |
178 | 178 | } |
179 | 179 | |
180 | - $initial_amount = wpinv_price( $initial_total, $currency ); |
|
181 | - $recurring_amount = wpinv_price( $recurring_total, $currency ); |
|
180 | + $initial_amount = wpinv_price($initial_total, $currency); |
|
181 | + $recurring_amount = wpinv_price($recurring_total, $currency); |
|
182 | 182 | |
183 | - $recurring = wpinv_subscription_recurring_payment_desc( $recurring_amount, $period, $interval, $bill_times, $trial_period, $trial_interval ); |
|
183 | + $recurring = wpinv_subscription_recurring_payment_desc($recurring_amount, $period, $interval, $bill_times, $trial_period, $trial_interval); |
|
184 | 184 | |
185 | - if ( $initial_total != $recurring_total ) { |
|
186 | - $initial = wpinv_subscription_initial_payment_desc( $initial_amount, $period, $interval, $trial_period, $trial_interval ); |
|
185 | + if ($initial_total != $recurring_total) { |
|
186 | + $initial = wpinv_subscription_initial_payment_desc($initial_amount, $period, $interval, $trial_period, $trial_interval); |
|
187 | 187 | |
188 | - $description = wp_sprintf( __( '%s Then %s', 'invoicing' ), $initial, $recurring ); |
|
188 | + $description = wp_sprintf(__('%s Then %s', 'invoicing'), $initial, $recurring); |
|
189 | 189 | } else { |
190 | 190 | $description = $recurring; |
191 | 191 | } |
192 | 192 | |
193 | - return apply_filters( 'wpinv_get_billing_cycle', $description, $initial, $recurring, $period, $interval, $bill_times, $trial_period, $trial_interval, $currency ); |
|
193 | + return apply_filters('wpinv_get_billing_cycle', $description, $initial, $recurring, $period, $interval, $bill_times, $trial_period, $trial_interval, $currency); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | /** |
@@ -200,27 +200,27 @@ discard block |
||
200 | 200 | * @param string $card_number Card number. |
201 | 201 | * @return string |
202 | 202 | */ |
203 | -function getpaid_get_card_name( $card_number ) { |
|
203 | +function getpaid_get_card_name($card_number) { |
|
204 | 204 | |
205 | 205 | // Known regexes. |
206 | 206 | $regexes = array( |
207 | - '/^4/' => __( 'Visa', 'invoicing' ), |
|
208 | - '/^5[1-5]/' => __( 'Mastercard', 'invoicing' ), |
|
209 | - '/^3[47]/' => __( 'Amex', 'invoicing' ), |
|
210 | - '/^3(?:0[0-5]|[68])/' => __( 'Diners Club', 'invoicing' ), |
|
211 | - '/^6(?:011|5)/' => __( 'Discover', 'invoicing' ), |
|
212 | - '/^(?:2131|1800|35\d{3})/' => __( 'JCB', 'invoicing' ), |
|
207 | + '/^4/' => __('Visa', 'invoicing'), |
|
208 | + '/^5[1-5]/' => __('Mastercard', 'invoicing'), |
|
209 | + '/^3[47]/' => __('Amex', 'invoicing'), |
|
210 | + '/^3(?:0[0-5]|[68])/' => __('Diners Club', 'invoicing'), |
|
211 | + '/^6(?:011|5)/' => __('Discover', 'invoicing'), |
|
212 | + '/^(?:2131|1800|35\d{3})/' => __('JCB', 'invoicing'), |
|
213 | 213 | ); |
214 | 214 | |
215 | 215 | // Confirm if one matches. |
216 | - foreach ( $regexes as $regex => $card ) { |
|
217 | - if ( preg_match ( $regex, $card_number ) >= 1 ) { |
|
216 | + foreach ($regexes as $regex => $card) { |
|
217 | + if (preg_match($regex, $card_number) >= 1) { |
|
218 | 218 | return $card; |
219 | 219 | } |
220 | 220 | } |
221 | 221 | |
222 | 222 | // None matched. |
223 | - return __( 'Card', 'invoicing' ); |
|
223 | + return __('Card', 'invoicing'); |
|
224 | 224 | |
225 | 225 | } |
226 | 226 | |
@@ -229,23 +229,23 @@ discard block |
||
229 | 229 | * |
230 | 230 | * @param WPInv_Invoice|int|null $invoice |
231 | 231 | */ |
232 | -function wpinv_send_back_to_checkout( $invoice = null ) { |
|
233 | - $response = array( 'success' => false ); |
|
234 | - $invoice = wpinv_get_invoice( $invoice ); |
|
232 | +function wpinv_send_back_to_checkout($invoice = null) { |
|
233 | + $response = array('success' => false); |
|
234 | + $invoice = wpinv_get_invoice($invoice); |
|
235 | 235 | |
236 | 236 | // Was an invoice created? |
237 | - if ( ! empty( $invoice ) ) { |
|
238 | - $invoice = is_scalar( $invoice ) ? new WPInv_Invoice( $invoice ) : $invoice; |
|
237 | + if (!empty($invoice)) { |
|
238 | + $invoice = is_scalar($invoice) ? new WPInv_Invoice($invoice) : $invoice; |
|
239 | 239 | $response['invoice'] = $invoice->get_id(); |
240 | - do_action( 'getpaid_checkout_invoice_exception', $invoice ); |
|
240 | + do_action('getpaid_checkout_invoice_exception', $invoice); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | // Do we have any errors? |
244 | - if ( wpinv_get_errors() ) { |
|
245 | - $response['data'] = getpaid_get_errors_html( true, false ); |
|
244 | + if (wpinv_get_errors()) { |
|
245 | + $response['data'] = getpaid_get_errors_html(true, false); |
|
246 | 246 | } else { |
247 | - $response['data'] = __( 'An error occured while processing your payment. Please try again.', 'invoicing' ); |
|
247 | + $response['data'] = __('An error occured while processing your payment. Please try again.', 'invoicing'); |
|
248 | 248 | } |
249 | 249 | |
250 | - wp_send_json( $response ); |
|
250 | + wp_send_json($response); |
|
251 | 251 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -21,27 +21,27 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param WP_Post $post |
23 | 23 | */ |
24 | - public static function output( $post ) { |
|
24 | + public static function output($post) { |
|
25 | 25 | |
26 | 26 | // Prepare the item. |
27 | - $item = new WPInv_Item( $post ); |
|
27 | + $item = new WPInv_Item($post); |
|
28 | 28 | |
29 | 29 | // Nonce field. |
30 | - wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' ); |
|
30 | + wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce'); |
|
31 | 31 | |
32 | 32 | // Set the currency position. |
33 | 33 | $position = wpinv_currency_position(); |
34 | 34 | |
35 | - if ( $position == 'left_space' ) { |
|
35 | + if ($position == 'left_space') { |
|
36 | 36 | $position = 'left'; |
37 | 37 | } |
38 | 38 | |
39 | - if ( $position == 'right_space' ) { |
|
39 | + if ($position == 'right_space') { |
|
40 | 40 | $position = 'right'; |
41 | 41 | } |
42 | 42 | |
43 | 43 | ?> |
44 | - <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr( $item->get_type( 'edit' ) ); ?>" /> |
|
44 | + <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr($item->get_type('edit')); ?>" /> |
|
45 | 45 | <style> |
46 | 46 | #poststuff .input-group-text, |
47 | 47 | #poststuff .form-control { |
@@ -55,21 +55,21 @@ discard block |
||
55 | 55 | </style> |
56 | 56 | <div class='bsui' style='max-width: 600px;padding-top: 10px;'> |
57 | 57 | |
58 | - <?php do_action( 'wpinv_item_details_metabox_before_price', $item ); ?> |
|
58 | + <?php do_action('wpinv_item_details_metabox_before_price', $item); ?> |
|
59 | 59 | <div class="form-group row"> |
60 | - <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php _e( 'Item Price', 'invoicing' )?></span></label> |
|
60 | + <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php _e('Item Price', 'invoicing')?></span></label> |
|
61 | 61 | <div class="col-sm-8"> |
62 | 62 | <div class="row"> |
63 | 63 | <div class="col-sm-4 getpaid-price-input"> |
64 | 64 | <div class="input-group input-group-sm"> |
65 | - <?php if( 'left' == $position ) : ?> |
|
65 | + <?php if ('left' == $position) : ?> |
|
66 | 66 | <div class="input-group-prepend"> |
67 | 67 | <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wpinv_currency_symbol(); ?></span> |
68 | 68 | </div> |
69 | 69 | <?php endif; ?> |
70 | - <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr( $item->get_price( 'edit' ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control"> |
|
70 | + <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr($item->get_price('edit')); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control"> |
|
71 | 71 | |
72 | - <?php if( 'left' != $position ) : ?> |
|
72 | + <?php if ('left' != $position) : ?> |
|
73 | 73 | <div class="input-group-append"> |
74 | 74 | <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wpinv_currency_symbol(); ?></span> |
75 | 75 | </div> |
@@ -79,10 +79,10 @@ discard block |
||
79 | 79 | </div> |
80 | 80 | <div class="col-sm-4 wpinv_show_if_recurring"> |
81 | 81 | <?php |
82 | - _e( 'every' ); |
|
82 | + _e('every'); |
|
83 | 83 | echo " "; |
84 | 84 | ?> |
85 | - <input type="number" style="max-width: 60px;" value="<?php echo esc_attr( $item->get_recurring_interval( 'edit' ) ); ?>" placeholder="1" name="wpinv_recurring_interval" id="wpinv_recurring_interval" /> |
|
85 | + <input type="number" style="max-width: 60px;" value="<?php echo esc_attr($item->get_recurring_interval('edit')); ?>" placeholder="1" name="wpinv_recurring_interval" id="wpinv_recurring_interval" /> |
|
86 | 86 | </div> |
87 | 87 | <div class="col-sm-4 wpinv_show_if_recurring"> |
88 | 88 | <?php |
@@ -90,16 +90,16 @@ discard block |
||
90 | 90 | array( |
91 | 91 | 'id' => 'wpinv_recurring_period', |
92 | 92 | 'name' => 'wpinv_recurring_period', |
93 | - 'label' => __( 'Period', 'invoicing' ), |
|
94 | - 'placeholder' => __( 'Select Period', 'invoicing' ), |
|
95 | - 'value' => $item->get_recurring_period( 'edit' ), |
|
93 | + 'label' => __('Period', 'invoicing'), |
|
94 | + 'placeholder' => __('Select Period', 'invoicing'), |
|
95 | + 'value' => $item->get_recurring_period('edit'), |
|
96 | 96 | 'select2' => true, |
97 | 97 | 'data-allow-clear' => 'false', |
98 | 98 | 'options' => array( |
99 | - 'D' => __( 'day(s)', 'invoicing' ), |
|
100 | - 'W' => __( 'week(s)', 'invoicing' ), |
|
101 | - 'M' => __( 'month(s)', 'invoicing' ), |
|
102 | - 'Y' => __( 'year(s)', 'invoicing' ), |
|
99 | + 'D' => __('day(s)', 'invoicing'), |
|
100 | + 'W' => __('week(s)', 'invoicing'), |
|
101 | + 'M' => __('month(s)', 'invoicing'), |
|
102 | + 'Y' => __('year(s)', 'invoicing'), |
|
103 | 103 | ) |
104 | 104 | ) |
105 | 105 | ); |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | <?php |
112 | 112 | |
113 | 113 | // Dynamic pricing. |
114 | - if( $item->supports_dynamic_pricing() ) { |
|
114 | + if ($item->supports_dynamic_pricing()) { |
|
115 | 115 | |
116 | - do_action( 'wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item ); |
|
116 | + do_action('wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item); |
|
117 | 117 | |
118 | 118 | // NYP toggle. |
119 | 119 | echo aui()->input( |
@@ -121,31 +121,31 @@ discard block |
||
121 | 121 | 'id' => 'wpinv_name_your_price', |
122 | 122 | 'name' => 'wpinv_name_your_price', |
123 | 123 | 'type' => 'checkbox', |
124 | - 'label' => apply_filters( 'wpinv_name_your_price_toggle_text', __( 'Let customers name their price', 'invoicing' ) ), |
|
124 | + 'label' => apply_filters('wpinv_name_your_price_toggle_text', __('Let customers name their price', 'invoicing')), |
|
125 | 125 | 'value' => '1', |
126 | 126 | 'checked' => $item->user_can_set_their_price(), |
127 | 127 | 'no_wrap' => true, |
128 | 128 | ) |
129 | 129 | ); |
130 | 130 | |
131 | - do_action( 'wpinv_item_details_metabox_dynamic_pricing_checkbox', $item ); |
|
131 | + do_action('wpinv_item_details_metabox_dynamic_pricing_checkbox', $item); |
|
132 | 132 | |
133 | 133 | } |
134 | 134 | |
135 | 135 | // Subscriptions. |
136 | - do_action( 'wpinv_item_details_metabox_before_subscription_checkbox', $item ); |
|
136 | + do_action('wpinv_item_details_metabox_before_subscription_checkbox', $item); |
|
137 | 137 | echo aui()->input( |
138 | 138 | array( |
139 | 139 | 'id' => 'wpinv_is_recurring', |
140 | 140 | 'name' => 'wpinv_is_recurring', |
141 | 141 | 'type' => 'checkbox', |
142 | - 'label' => apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Charge customers a recurring amount for this item', 'invoicing' ) ), |
|
142 | + 'label' => apply_filters('wpinv_is_recurring_toggle_text', __('Charge customers a recurring amount for this item', 'invoicing')), |
|
143 | 143 | 'value' => '1', |
144 | 144 | 'checked' => $item->is_recurring(), |
145 | 145 | 'no_wrap' => true, |
146 | 146 | ) |
147 | 147 | ); |
148 | - do_action( 'wpinv_item_details_metabox_subscription_checkbox', $item ); |
|
148 | + do_action('wpinv_item_details_metabox_subscription_checkbox', $item); |
|
149 | 149 | |
150 | 150 | ?> |
151 | 151 | <div class="wpinv_show_if_recurring"> |
@@ -155,30 +155,30 @@ discard block |
||
155 | 155 | </div> |
156 | 156 | </div> |
157 | 157 | <div class="col-sm-1 pt-2 pl-0"> |
158 | - <span class="wpi-help-tip dashicons dashicons-editor-help wpinv_show_if_recurring" title="<?php esc_attr_e( 'Set the subscription price, billing interval and period.', 'invoicing' ); ?>"></span> |
|
158 | + <span class="wpi-help-tip dashicons dashicons-editor-help wpinv_show_if_recurring" title="<?php esc_attr_e('Set the subscription price, billing interval and period.', 'invoicing'); ?>"></span> |
|
159 | 159 | </div> |
160 | 160 | </div> |
161 | - <?php do_action( 'wpinv_item_details_metabox_after_price', $item ); ?> |
|
161 | + <?php do_action('wpinv_item_details_metabox_after_price', $item); ?> |
|
162 | 162 | |
163 | - <?php if( $item->supports_dynamic_pricing() ) : ?> |
|
164 | - <?php do_action( 'wpinv_item_details_metabox_before_minimum_price', $item ); ?> |
|
163 | + <?php if ($item->supports_dynamic_pricing()) : ?> |
|
164 | + <?php do_action('wpinv_item_details_metabox_before_minimum_price', $item); ?> |
|
165 | 165 | <div class="wpinv_show_if_dynamic wpinv_minimum_price"> |
166 | 166 | |
167 | 167 | <div class="form-group row"> |
168 | 168 | <label for="wpinv_minimum_price" class="col-sm-3 col-form-label"> |
169 | - <?php _e( 'Minimum Price', 'invoicing' );?> |
|
169 | + <?php _e('Minimum Price', 'invoicing'); ?> |
|
170 | 170 | </label> |
171 | 171 | <div class="col-sm-8"> |
172 | 172 | <div class="input-group input-group-sm"> |
173 | - <?php if( 'left' == $position ) : ?> |
|
173 | + <?php if ('left' == $position) : ?> |
|
174 | 174 | <div class="input-group-prepend"> |
175 | 175 | <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wpinv_currency_symbol(); ?></span> |
176 | 176 | </div> |
177 | 177 | <?php endif; ?> |
178 | 178 | |
179 | - <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr( $item->get_minimum_price( 'edit' ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control"> |
|
179 | + <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr($item->get_minimum_price('edit')); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control"> |
|
180 | 180 | |
181 | - <?php if( 'left' != $position ) : ?> |
|
181 | + <?php if ('left' != $position) : ?> |
|
182 | 182 | <div class="input-group-append"> |
183 | 183 | <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wpinv_currency_symbol(); ?></span> |
184 | 184 | </div> |
@@ -187,45 +187,45 @@ discard block |
||
187 | 187 | </div> |
188 | 188 | |
189 | 189 | <div class="col-sm-1 pt-2 pl-0"> |
190 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter the minimum amount that users are allowed to set', 'invoicing' ); ?>"></span> |
|
190 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter the minimum amount that users are allowed to set', 'invoicing'); ?>"></span> |
|
191 | 191 | </div> |
192 | 192 | </div> |
193 | 193 | |
194 | 194 | </div> |
195 | - <?php do_action( 'wpinv_item_details_metabox_minimum_price', $item ); ?> |
|
195 | + <?php do_action('wpinv_item_details_metabox_minimum_price', $item); ?> |
|
196 | 196 | <?php endif; ?> |
197 | 197 | |
198 | - <?php do_action( 'wpinv_item_details_metabox_before_maximum_renewals', $item ); ?> |
|
198 | + <?php do_action('wpinv_item_details_metabox_before_maximum_renewals', $item); ?> |
|
199 | 199 | <div class="wpinv_show_if_recurring wpinv_maximum_renewals"> |
200 | 200 | |
201 | 201 | <div class="form-group row"> |
202 | 202 | <label for="wpinv_recurring_limit" class="col-sm-3 col-form-label"> |
203 | - <?php _e( 'Maximum Renewals', 'invoicing' );?> |
|
203 | + <?php _e('Maximum Renewals', 'invoicing'); ?> |
|
204 | 204 | </label> |
205 | 205 | <div class="col-sm-8"> |
206 | - <input type="number" value="<?php echo esc_attr( $item->get_recurring_limit( 'edit' ) ); ?>" placeholder="0" name="wpinv_recurring_limit" id="wpinv_recurring_limit" style="width: 100%;" /> |
|
206 | + <input type="number" value="<?php echo esc_attr($item->get_recurring_limit('edit')); ?>" placeholder="0" name="wpinv_recurring_limit" id="wpinv_recurring_limit" style="width: 100%;" /> |
|
207 | 207 | </div> |
208 | 208 | <div class="col-sm-1 pt-2 pl-0"> |
209 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Leave empty if you want the subscription to renew until it is cancelled.', 'invoicing' ); ?>"></span> |
|
209 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Leave empty if you want the subscription to renew until it is cancelled.', 'invoicing'); ?>"></span> |
|
210 | 210 | </div> |
211 | 211 | </div> |
212 | 212 | |
213 | 213 | </div> |
214 | - <?php do_action( 'wpinv_item_details_metabox_maximum_renewals', $item ); ?> |
|
214 | + <?php do_action('wpinv_item_details_metabox_maximum_renewals', $item); ?> |
|
215 | 215 | |
216 | - <?php do_action( 'wpinv_item_details_metabox_before_free_trial', $item ); ?> |
|
216 | + <?php do_action('wpinv_item_details_metabox_before_free_trial', $item); ?> |
|
217 | 217 | <div class="wpinv_show_if_recurring wpinv_free_trial"> |
218 | 218 | |
219 | 219 | <div class="form-group row"> |
220 | - <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php _e( 'Free Trial', 'invoicing' )?></label> |
|
220 | + <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php _e('Free Trial', 'invoicing')?></label> |
|
221 | 221 | |
222 | 222 | <div class="col-sm-8"> |
223 | 223 | <div class="row"> |
224 | 224 | <div class="col-sm-6"> |
225 | - <?php $value = $item->has_free_trial() ? $item->get_trial_interval( 'edit' ) : 0;?> |
|
225 | + <?php $value = $item->has_free_trial() ? $item->get_trial_interval('edit') : 0; ?> |
|
226 | 226 | |
227 | 227 | <div> |
228 | - <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr( $value ); ?>" > |
|
228 | + <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr($value); ?>" > |
|
229 | 229 | </div> |
230 | 230 | </div> |
231 | 231 | <div class="col-sm-6"> |
@@ -234,17 +234,17 @@ discard block |
||
234 | 234 | array( |
235 | 235 | 'id' => 'wpinv_trial_period', |
236 | 236 | 'name' => 'wpinv_trial_period', |
237 | - 'label' => __( 'Trial Period', 'invoicing' ), |
|
238 | - 'placeholder' => __( 'Trial Period', 'invoicing' ), |
|
239 | - 'value' => $item->get_trial_period( 'edit' ), |
|
237 | + 'label' => __('Trial Period', 'invoicing'), |
|
238 | + 'placeholder' => __('Trial Period', 'invoicing'), |
|
239 | + 'value' => $item->get_trial_period('edit'), |
|
240 | 240 | 'select2' => true, |
241 | 241 | 'data-allow-clear' => 'false', |
242 | 242 | 'no_wrap' => true, |
243 | 243 | 'options' => array( |
244 | - 'D' => __( 'day(s)', 'invoicing' ), |
|
245 | - 'W' => __( 'week(s)', 'invoicing' ), |
|
246 | - 'M' => __( 'month(s)', 'invoicing' ), |
|
247 | - 'Y' => __( 'year(s)', 'invoicing' ), |
|
244 | + 'D' => __('day(s)', 'invoicing'), |
|
245 | + 'W' => __('week(s)', 'invoicing'), |
|
246 | + 'M' => __('month(s)', 'invoicing'), |
|
247 | + 'Y' => __('year(s)', 'invoicing'), |
|
248 | 248 | ) |
249 | 249 | ) |
250 | 250 | ); |
@@ -255,15 +255,15 @@ discard block |
||
255 | 255 | </div> |
256 | 256 | |
257 | 257 | <div class="col-sm-1 pt-2 pl-0"> |
258 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'An optional period of time to wait before charging the first recurring payment.', 'invoicing' ); ?>"></span> |
|
258 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('An optional period of time to wait before charging the first recurring payment.', 'invoicing'); ?>"></span> |
|
259 | 259 | </div> |
260 | 260 | |
261 | 261 | </div> |
262 | 262 | |
263 | 263 | </div> |
264 | - <?php do_action( 'wpinv_item_details_metabox__free_trial', $item ); ?> |
|
264 | + <?php do_action('wpinv_item_details_metabox__free_trial', $item); ?> |
|
265 | 265 | |
266 | - <?php do_action( 'wpinv_item_details_metabox_item_details', $item ); ?> |
|
266 | + <?php do_action('wpinv_item_details_metabox_item_details', $item); ?> |
|
267 | 267 | </div> |
268 | 268 | <?php |
269 | 269 | |
@@ -274,31 +274,31 @@ discard block |
||
274 | 274 | * |
275 | 275 | * @param int $post_id |
276 | 276 | */ |
277 | - public static function save( $post_id ) { |
|
277 | + public static function save($post_id) { |
|
278 | 278 | |
279 | 279 | // Prepare the item. |
280 | - $item = new WPInv_Item( $post_id ); |
|
280 | + $item = new WPInv_Item($post_id); |
|
281 | 281 | |
282 | 282 | // Load new data. |
283 | 283 | $item->set_props( |
284 | 284 | array( |
285 | - 'price' => isset( $_POST['wpinv_item_price'] ) ? (float) $_POST['wpinv_item_price'] : null, |
|
286 | - 'vat_rule' => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null, |
|
287 | - 'vat_class' => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null, |
|
288 | - 'type' => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null, |
|
289 | - 'is_dynamic_pricing' => isset( $_POST['wpinv_name_your_price'] ), |
|
290 | - 'minimum_price' => isset( $_POST['wpinv_minimum_price'] ) ? (float) $_POST['wpinv_minimum_price'] : null, |
|
291 | - 'is_recurring' => isset( $_POST['wpinv_is_recurring'] ), |
|
292 | - 'recurring_period' => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null, |
|
293 | - 'recurring_interval' => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1, |
|
294 | - 'recurring_limit' => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null, |
|
295 | - 'is_free_trial' => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null, |
|
296 | - 'trial_period' => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null, |
|
297 | - 'trial_interval' => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null, |
|
285 | + 'price' => isset($_POST['wpinv_item_price']) ? (float) $_POST['wpinv_item_price'] : null, |
|
286 | + 'vat_rule' => isset($_POST['wpinv_vat_rules']) ? wpinv_clean($_POST['wpinv_vat_rules']) : null, |
|
287 | + 'vat_class' => isset($_POST['wpinv_vat_class']) ? wpinv_clean($_POST['wpinv_vat_class']) : null, |
|
288 | + 'type' => isset($_POST['wpinv_item_type']) ? wpinv_clean($_POST['wpinv_item_type']) : null, |
|
289 | + 'is_dynamic_pricing' => isset($_POST['wpinv_name_your_price']), |
|
290 | + 'minimum_price' => isset($_POST['wpinv_minimum_price']) ? (float) $_POST['wpinv_minimum_price'] : null, |
|
291 | + 'is_recurring' => isset($_POST['wpinv_is_recurring']), |
|
292 | + 'recurring_period' => isset($_POST['wpinv_recurring_period']) ? wpinv_clean($_POST['wpinv_recurring_period']) : null, |
|
293 | + 'recurring_interval' => isset($_POST['wpinv_recurring_interval']) ? (int) $_POST['wpinv_recurring_interval'] : 1, |
|
294 | + 'recurring_limit' => isset($_POST['wpinv_recurring_limit']) ? (int) $_POST['wpinv_recurring_limit'] : null, |
|
295 | + 'is_free_trial' => isset($_POST['wpinv_trial_interval']) ? (0 != (int) $_POST['wpinv_trial_interval']) : null, |
|
296 | + 'trial_period' => isset($_POST['wpinv_trial_period']) ? wpinv_clean($_POST['wpinv_trial_period']) : null, |
|
297 | + 'trial_interval' => isset($_POST['wpinv_trial_interval']) ? (int) $_POST['wpinv_trial_interval'] : null, |
|
298 | 298 | ) |
299 | 299 | ); |
300 | 300 | |
301 | 301 | $item->save(); |
302 | - do_action( 'getpaid_item_metabox_save', $post_id, $item ); |
|
302 | + do_action('getpaid_item_metabox_save', $post_id, $item); |
|
303 | 303 | } |
304 | 304 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Post types Admin Class |
@@ -21,72 +21,72 @@ discard block |
||
21 | 21 | GetPaid_Metaboxes::init(); |
22 | 22 | |
23 | 23 | // Filter the post updated messages. |
24 | - add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' ); |
|
24 | + add_filter('post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages'); |
|
25 | 25 | |
26 | 26 | // Filter post actions. |
27 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 ); |
|
28 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 ); |
|
27 | + add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2); |
|
28 | + add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2); |
|
29 | 29 | |
30 | 30 | // Invoice table columns. |
31 | - add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 ); |
|
32 | - add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 ); |
|
31 | + add_filter('manage_wpi_invoice_posts_columns', array(__CLASS__, 'invoice_columns'), 100); |
|
32 | + add_action('manage_wpi_invoice_posts_custom_column', array(__CLASS__, 'display_invoice_columns'), 10, 2); |
|
33 | 33 | |
34 | 34 | // Items table columns. |
35 | - add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
36 | - add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
37 | - add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
38 | - add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
39 | - add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
40 | - add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
35 | + add_filter('manage_wpi_item_posts_columns', array(__CLASS__, 'item_columns'), 100); |
|
36 | + add_filter('manage_edit-wpi_item_sortable_columns', array(__CLASS__, 'sortable_item_columns'), 20); |
|
37 | + add_action('manage_wpi_item_posts_custom_column', array(__CLASS__, 'display_item_columns'), 10, 2); |
|
38 | + add_action('restrict_manage_posts', array(__CLASS__, 'add_item_filters'), 100); |
|
39 | + add_action('parse_query', array(__CLASS__, 'filter_item_query'), 100); |
|
40 | + add_action('request', array(__CLASS__, 'reorder_items'), 100); |
|
41 | 41 | |
42 | 42 | // Payment forms columns. |
43 | - add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
44 | - add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
45 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
43 | + add_filter('manage_wpi_payment_form_posts_columns', array(__CLASS__, 'payment_form_columns'), 100); |
|
44 | + add_action('manage_wpi_payment_form_posts_custom_column', array(__CLASS__, 'display_payment_form_columns'), 10, 2); |
|
45 | + add_filter('display_post_states', array(__CLASS__, 'filter_payment_form_state'), 10, 2); |
|
46 | 46 | |
47 | 47 | // Discount table columns. |
48 | - add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
49 | - add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 ); |
|
48 | + add_filter('manage_wpi_discount_posts_columns', array(__CLASS__, 'discount_columns'), 100); |
|
49 | + add_filter('bulk_actions-edit-wpi_discount', '__return_empty_array', 100); |
|
50 | 50 | |
51 | 51 | // Deleting posts. |
52 | - add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
53 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
52 | + add_action('delete_post', array(__CLASS__, 'delete_post')); |
|
53 | + add_filter('display_post_states', array(__CLASS__, 'filter_discount_state'), 10, 2); |
|
54 | 54 | |
55 | - add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 ); |
|
55 | + add_filter('display_post_states', array(__CLASS__, 'add_display_post_states'), 10, 2); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
59 | 59 | * Post updated messages. |
60 | 60 | */ |
61 | - public static function post_updated_messages( $messages ) { |
|
61 | + public static function post_updated_messages($messages) { |
|
62 | 62 | global $post; |
63 | 63 | |
64 | 64 | $messages['wpi_discount'] = array( |
65 | 65 | 0 => '', |
66 | - 1 => __( 'Discount updated.', 'invoicing' ), |
|
67 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
68 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
69 | - 4 => __( 'Discount updated.', 'invoicing' ), |
|
70 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
71 | - 6 => __( 'Discount updated.', 'invoicing' ), |
|
72 | - 7 => __( 'Discount saved.', 'invoicing' ), |
|
73 | - 8 => __( 'Discount submitted.', 'invoicing' ), |
|
74 | - 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
75 | - 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
66 | + 1 => __('Discount updated.', 'invoicing'), |
|
67 | + 2 => __('Custom field updated.', 'invoicing'), |
|
68 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
69 | + 4 => __('Discount updated.', 'invoicing'), |
|
70 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
71 | + 6 => __('Discount updated.', 'invoicing'), |
|
72 | + 7 => __('Discount saved.', 'invoicing'), |
|
73 | + 8 => __('Discount submitted.', 'invoicing'), |
|
74 | + 9 => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
75 | + 10 => __('Discount draft updated.', 'invoicing'), |
|
76 | 76 | ); |
77 | 77 | |
78 | 78 | $messages['wpi_payment_form'] = array( |
79 | 79 | 0 => '', |
80 | - 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
81 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
82 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
83 | - 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
84 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
85 | - 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
86 | - 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
87 | - 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
88 | - 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
89 | - 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
80 | + 1 => __('Payment Form updated.', 'invoicing'), |
|
81 | + 2 => __('Custom field updated.', 'invoicing'), |
|
82 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
83 | + 4 => __('Payment Form updated.', 'invoicing'), |
|
84 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Payment Form restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
85 | + 6 => __('Payment Form updated.', 'invoicing'), |
|
86 | + 7 => __('Payment Form saved.', 'invoicing'), |
|
87 | + 8 => __('Payment Form submitted.', 'invoicing'), |
|
88 | + 9 => wp_sprintf(__('Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
89 | + 10 => __('Payment Form draft updated.', 'invoicing'), |
|
90 | 90 | ); |
91 | 91 | |
92 | 92 | return $messages; |
@@ -96,14 +96,14 @@ discard block |
||
96 | 96 | /** |
97 | 97 | * Post row actions. |
98 | 98 | */ |
99 | - public static function post_row_actions( $actions, $post ) { |
|
99 | + public static function post_row_actions($actions, $post) { |
|
100 | 100 | |
101 | - $post = get_post( $post ); |
|
101 | + $post = get_post($post); |
|
102 | 102 | |
103 | 103 | // We do not want to edit the default payment form. |
104 | - if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) { |
|
105 | - unset( $actions['trash'] ); |
|
106 | - unset( $actions['inline hide-if-no-js'] ); |
|
104 | + if ('wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form()) { |
|
105 | + unset($actions['trash']); |
|
106 | + unset($actions['inline hide-if-no-js']); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | return $actions; |
@@ -117,31 +117,31 @@ discard block |
||
117 | 117 | * @param WP_Post $post |
118 | 118 | * @return array $actions actions without edit option |
119 | 119 | */ |
120 | - public static function filter_invoice_row_actions( $actions, $post ) { |
|
120 | + public static function filter_invoice_row_actions($actions, $post) { |
|
121 | 121 | |
122 | - if ( getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
122 | + if (getpaid_is_invoice_post_type($post->post_type)) { |
|
123 | 123 | |
124 | 124 | $actions = array(); |
125 | - $invoice = new WPInv_Invoice( $post ); |
|
125 | + $invoice = new WPInv_Invoice($post); |
|
126 | 126 | |
127 | - $actions['edit'] = sprintf( |
|
127 | + $actions['edit'] = sprintf( |
|
128 | 128 | '<a href="%1$s">%2$s</a>', |
129 | - esc_url( get_edit_post_link( $invoice->get_id() ) ), |
|
130 | - esc_html( __( 'Edit', 'invoicing' ) ) |
|
129 | + esc_url(get_edit_post_link($invoice->get_id())), |
|
130 | + esc_html(__('Edit', 'invoicing')) |
|
131 | 131 | ); |
132 | 132 | |
133 | - if ( ! $invoice->is_draft() ) { |
|
133 | + if (!$invoice->is_draft()) { |
|
134 | 134 | |
135 | - $actions['view'] = sprintf( |
|
135 | + $actions['view'] = sprintf( |
|
136 | 136 | '<a href="%1$s">%2$s</a>', |
137 | - esc_url( $invoice->get_view_url() ), |
|
137 | + esc_url($invoice->get_view_url()), |
|
138 | 138 | sprintf( |
139 | - esc_html( __( 'View %s', 'invoicing' ) ), |
|
140 | - getpaid_get_post_type_label( $invoice->get_post_type(), false ) |
|
139 | + esc_html(__('View %s', 'invoicing')), |
|
140 | + getpaid_get_post_type_label($invoice->get_post_type(), false) |
|
141 | 141 | ) |
142 | 142 | ); |
143 | 143 | |
144 | - $actions['send'] = sprintf( |
|
144 | + $actions['send'] = sprintf( |
|
145 | 145 | '<a href="%1$s">%2$s</a>', |
146 | 146 | esc_url( |
147 | 147 | wp_nonce_url( |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | 'getpaid-nonce' |
156 | 156 | ) |
157 | 157 | ), |
158 | - esc_html( __( 'Send to Customer', 'invoicing' ) ) |
|
158 | + esc_html(__('Send to Customer', 'invoicing')) |
|
159 | 159 | ); |
160 | 160 | |
161 | 161 | } |
@@ -168,42 +168,42 @@ discard block |
||
168 | 168 | /** |
169 | 169 | * Returns an array of invoice table columns. |
170 | 170 | */ |
171 | - public static function invoice_columns( $columns ) { |
|
171 | + public static function invoice_columns($columns) { |
|
172 | 172 | |
173 | 173 | $columns = array( |
174 | 174 | 'cb' => $columns['cb'], |
175 | - 'number' => __( 'Invoice', 'invoicing' ), |
|
176 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
177 | - 'invoice_date' => __( 'Created', 'invoicing' ), |
|
178 | - 'payment_date' => __( 'Completed', 'invoicing' ), |
|
179 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
180 | - 'recurring' => __( 'Recurring', 'invoicing' ), |
|
181 | - 'status' => __( 'Status', 'invoicing' ), |
|
175 | + 'number' => __('Invoice', 'invoicing'), |
|
176 | + 'customer' => __('Customer', 'invoicing'), |
|
177 | + 'invoice_date' => __('Created', 'invoicing'), |
|
178 | + 'payment_date' => __('Completed', 'invoicing'), |
|
179 | + 'amount' => __('Amount', 'invoicing'), |
|
180 | + 'recurring' => __('Recurring', 'invoicing'), |
|
181 | + 'status' => __('Status', 'invoicing'), |
|
182 | 182 | ); |
183 | 183 | |
184 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
184 | + return apply_filters('wpi_invoice_table_columns', $columns); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | /** |
188 | 188 | * Displays invoice table columns. |
189 | 189 | */ |
190 | - public static function display_invoice_columns( $column_name, $post_id ) { |
|
190 | + public static function display_invoice_columns($column_name, $post_id) { |
|
191 | 191 | |
192 | - $invoice = new WPInv_Invoice( $post_id ); |
|
192 | + $invoice = new WPInv_Invoice($post_id); |
|
193 | 193 | |
194 | - switch ( $column_name ) { |
|
194 | + switch ($column_name) { |
|
195 | 195 | |
196 | 196 | case 'invoice_date' : |
197 | - $date_time = esc_attr( $invoice->get_created_date() ); |
|
198 | - $date = getpaid_format_date_value( $date_time, "—", true ); |
|
197 | + $date_time = esc_attr($invoice->get_created_date()); |
|
198 | + $date = getpaid_format_date_value($date_time, "—", true); |
|
199 | 199 | echo "<span title='$date_time'>$date</span>"; |
200 | 200 | break; |
201 | 201 | |
202 | 202 | case 'payment_date' : |
203 | 203 | |
204 | - if ( $invoice->is_paid() ) { |
|
205 | - $date_time = esc_attr( $invoice->get_completed_date() ); |
|
206 | - $date = getpaid_format_date_value( $date_time, "—", true ); |
|
204 | + if ($invoice->is_paid()) { |
|
205 | + $date_time = esc_attr($invoice->get_completed_date()); |
|
206 | + $date = getpaid_format_date_value($date_time, "—", true); |
|
207 | 207 | echo "<span title='$date_time'>$date</span>"; |
208 | 208 | } else { |
209 | 209 | echo "—"; |
@@ -214,17 +214,17 @@ discard block |
||
214 | 214 | case 'amount' : |
215 | 215 | |
216 | 216 | $amount = $invoice->get_total(); |
217 | - $formated_amount = wpinv_price( $amount, $invoice->get_currency() ); |
|
217 | + $formated_amount = wpinv_price($amount, $invoice->get_currency()); |
|
218 | 218 | |
219 | - if ( $invoice->is_refunded() ) { |
|
220 | - $refunded_amount = wpinv_price( 0, $invoice->get_currency() ); |
|
219 | + if ($invoice->is_refunded()) { |
|
220 | + $refunded_amount = wpinv_price(0, $invoice->get_currency()); |
|
221 | 221 | echo "<del>$formated_amount</del> <ins>$refunded_amount</ins>"; |
222 | 222 | } else { |
223 | 223 | |
224 | 224 | $discount = $invoice->get_total_discount(); |
225 | 225 | |
226 | - if ( ! empty( $discount ) ) { |
|
227 | - $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() ); |
|
226 | + if (!empty($discount)) { |
|
227 | + $new_amount = wpinv_price($amount + $discount, $invoice->get_currency()); |
|
228 | 228 | echo "<del>$new_amount</del> <ins>$formated_amount</ins>"; |
229 | 229 | } else { |
230 | 230 | echo $formated_amount; |
@@ -235,13 +235,13 @@ discard block |
||
235 | 235 | break; |
236 | 236 | |
237 | 237 | case 'status' : |
238 | - $status = sanitize_text_field( $invoice->get_status() ); |
|
239 | - $status_label = sanitize_text_field( $invoice->get_status_nicename() ); |
|
238 | + $status = sanitize_text_field($invoice->get_status()); |
|
239 | + $status_label = sanitize_text_field($invoice->get_status_nicename()); |
|
240 | 240 | |
241 | 241 | // If it is paid, show the gateway title. |
242 | - if ( $invoice->is_paid() ) { |
|
243 | - $gateway = sanitize_text_field( $invoice->get_gateway_title() ); |
|
244 | - $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway ); |
|
242 | + if ($invoice->is_paid()) { |
|
243 | + $gateway = sanitize_text_field($invoice->get_gateway_title()); |
|
244 | + $gateway = wp_sprintf(esc_attr__('Paid via %s', 'invoicing'), $gateway); |
|
245 | 245 | |
246 | 246 | echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>"; |
247 | 247 | } else { |
@@ -249,22 +249,22 @@ discard block |
||
249 | 249 | } |
250 | 250 | |
251 | 251 | // If it is not paid, display the overdue and view status. |
252 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
252 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
253 | 253 | |
254 | 254 | // Invoice view status. |
255 | - if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
256 | - echo ' <i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
255 | + if (wpinv_is_invoice_viewed($invoice->get_id())) { |
|
256 | + echo ' <i class="fa fa-eye wpi-help-tip" title="' . esc_attr__('Viewed by Customer', 'invoicing') . '"></i>'; |
|
257 | 257 | } else { |
258 | - echo ' <i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>'; |
|
258 | + echo ' <i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__('Not Viewed by Customer', 'invoicing') . '"></i>'; |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | // Display the overview status. |
262 | - if ( wpinv_get_option( 'overdue_active' ) ) { |
|
262 | + if (wpinv_get_option('overdue_active')) { |
|
263 | 263 | $due_date = $invoice->get_due_date(); |
264 | - $fomatted = getpaid_format_date( $due_date ); |
|
264 | + $fomatted = getpaid_format_date($due_date); |
|
265 | 265 | |
266 | - if ( ! empty( $fomatted ) ) { |
|
267 | - $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted ); |
|
266 | + if (!empty($fomatted)) { |
|
267 | + $date = wp_sprintf(__('Due %s', 'invoicing'), $fomatted); |
|
268 | 268 | echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>"; |
269 | 269 | } |
270 | 270 | } |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | |
276 | 276 | case 'recurring': |
277 | 277 | |
278 | - if ( $invoice->is_recurring() ) { |
|
278 | + if ($invoice->is_recurring()) { |
|
279 | 279 | echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
280 | 280 | } else { |
281 | 281 | echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
@@ -284,9 +284,9 @@ discard block |
||
284 | 284 | |
285 | 285 | case 'number' : |
286 | 286 | |
287 | - $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
288 | - $invoice_number = sanitize_text_field( $invoice->get_number() ); |
|
289 | - $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
287 | + $edit_link = esc_url(get_edit_post_link($invoice->get_id())); |
|
288 | + $invoice_number = sanitize_text_field($invoice->get_number()); |
|
289 | + $invoice_details = esc_attr__('View Invoice Details', 'invoicing'); |
|
290 | 290 | |
291 | 291 | echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>"; |
292 | 292 | |
@@ -296,13 +296,13 @@ discard block |
||
296 | 296 | |
297 | 297 | $customer_name = $invoice->get_user_full_name(); |
298 | 298 | |
299 | - if ( empty( $customer_name ) ) { |
|
299 | + if (empty($customer_name)) { |
|
300 | 300 | $customer_name = $invoice->get_email(); |
301 | 301 | } |
302 | 302 | |
303 | - if ( ! empty( $customer_name ) ) { |
|
304 | - $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
305 | - $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
303 | + if (!empty($customer_name)) { |
|
304 | + $customer_details = esc_attr__('View Customer Details', 'invoicing'); |
|
305 | + $view_link = esc_url(add_query_arg('user_id', $invoice->get_user_id(), admin_url('user-edit.php'))); |
|
306 | 306 | echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>"; |
307 | 307 | } else { |
308 | 308 | echo '<div>—</div>'; |
@@ -317,50 +317,50 @@ discard block |
||
317 | 317 | /** |
318 | 318 | * Returns an array of payment forms table columns. |
319 | 319 | */ |
320 | - public static function payment_form_columns( $columns ) { |
|
320 | + public static function payment_form_columns($columns) { |
|
321 | 321 | |
322 | 322 | $columns = array( |
323 | 323 | 'cb' => $columns['cb'], |
324 | - 'title' => __( 'Name', 'invoicing' ), |
|
325 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
326 | - 'earnings' => __( 'Revenue', 'invoicing' ), |
|
327 | - 'refunds' => __( 'Refunded', 'invoicing' ), |
|
328 | - 'items' => __( 'Items', 'invoicing' ), |
|
329 | - 'date' => __( 'Date', 'invoicing' ), |
|
324 | + 'title' => __('Name', 'invoicing'), |
|
325 | + 'shortcode' => __('Shortcode', 'invoicing'), |
|
326 | + 'earnings' => __('Revenue', 'invoicing'), |
|
327 | + 'refunds' => __('Refunded', 'invoicing'), |
|
328 | + 'items' => __('Items', 'invoicing'), |
|
329 | + 'date' => __('Date', 'invoicing'), |
|
330 | 330 | ); |
331 | 331 | |
332 | - return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
332 | + return apply_filters('wpi_payment_form_table_columns', $columns); |
|
333 | 333 | |
334 | 334 | } |
335 | 335 | |
336 | 336 | /** |
337 | 337 | * Displays payment form table columns. |
338 | 338 | */ |
339 | - public static function display_payment_form_columns( $column_name, $post_id ) { |
|
339 | + public static function display_payment_form_columns($column_name, $post_id) { |
|
340 | 340 | |
341 | 341 | // Retrieve the payment form. |
342 | - $form = new GetPaid_Payment_Form( $post_id ); |
|
342 | + $form = new GetPaid_Payment_Form($post_id); |
|
343 | 343 | |
344 | - switch ( $column_name ) { |
|
344 | + switch ($column_name) { |
|
345 | 345 | |
346 | 346 | case 'earnings' : |
347 | - echo wpinv_price( $form->get_earned() ); |
|
347 | + echo wpinv_price($form->get_earned()); |
|
348 | 348 | break; |
349 | 349 | |
350 | 350 | case 'refunds' : |
351 | - echo wpinv_price( $form->get_refunded() ); |
|
351 | + echo wpinv_price($form->get_refunded()); |
|
352 | 352 | break; |
353 | 353 | |
354 | 354 | case 'refunds' : |
355 | - echo wpinv_price( $form->get_refunded() ); |
|
355 | + echo wpinv_price($form->get_refunded()); |
|
356 | 356 | break; |
357 | 357 | |
358 | 358 | case 'shortcode' : |
359 | 359 | |
360 | - if ( $form->is_default() ) { |
|
360 | + if ($form->is_default()) { |
|
361 | 361 | echo '—'; |
362 | 362 | } else { |
363 | - echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
363 | + echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr($form->get_id()) . ']" style="width: 100%;" readonly/>'; |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | break; |
@@ -369,29 +369,29 @@ discard block |
||
369 | 369 | |
370 | 370 | $items = $form->get_items(); |
371 | 371 | |
372 | - if ( $form->is_default() || empty( $items ) ) { |
|
372 | + if ($form->is_default() || empty($items)) { |
|
373 | 373 | echo '—'; |
374 | 374 | return; |
375 | 375 | } |
376 | 376 | |
377 | 377 | $_items = array(); |
378 | 378 | |
379 | - foreach ( $items as $item ) { |
|
379 | + foreach ($items as $item) { |
|
380 | 380 | $url = $item->get_edit_url(); |
381 | 381 | |
382 | - if ( empty( $url ) ) { |
|
383 | - $_items[] = sanitize_text_field( $item->get_name() ); |
|
382 | + if (empty($url)) { |
|
383 | + $_items[] = sanitize_text_field($item->get_name()); |
|
384 | 384 | } else { |
385 | 385 | $_items[] = sprintf( |
386 | 386 | '<a href="%s">%s</a>', |
387 | - esc_url( $url ), |
|
388 | - sanitize_text_field( $item->get_name() ) |
|
387 | + esc_url($url), |
|
388 | + sanitize_text_field($item->get_name()) |
|
389 | 389 | ); |
390 | 390 | } |
391 | 391 | |
392 | 392 | } |
393 | 393 | |
394 | - echo implode( '<br>', $_items ); |
|
394 | + echo implode('<br>', $_items); |
|
395 | 395 | |
396 | 396 | break; |
397 | 397 | |
@@ -402,10 +402,10 @@ discard block |
||
402 | 402 | /** |
403 | 403 | * Filters post states. |
404 | 404 | */ |
405 | - public static function filter_payment_form_state( $post_states, $post ) { |
|
405 | + public static function filter_payment_form_state($post_states, $post) { |
|
406 | 406 | |
407 | - if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) { |
|
408 | - $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' ); |
|
407 | + if ('wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID) { |
|
408 | + $post_states['default_form'] = __('Default Payment Form', 'invoicing'); |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | return $post_states; |
@@ -415,35 +415,35 @@ discard block |
||
415 | 415 | /** |
416 | 416 | * Returns an array of coupon table columns. |
417 | 417 | */ |
418 | - public static function discount_columns( $columns ) { |
|
418 | + public static function discount_columns($columns) { |
|
419 | 419 | |
420 | 420 | $columns = array( |
421 | 421 | 'cb' => $columns['cb'], |
422 | - 'title' => __( 'Name', 'invoicing' ), |
|
423 | - 'code' => __( 'Code', 'invoicing' ), |
|
424 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
425 | - 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
426 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
427 | - 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
422 | + 'title' => __('Name', 'invoicing'), |
|
423 | + 'code' => __('Code', 'invoicing'), |
|
424 | + 'amount' => __('Amount', 'invoicing'), |
|
425 | + 'usage' => __('Usage / Limit', 'invoicing'), |
|
426 | + 'start_date' => __('Start Date', 'invoicing'), |
|
427 | + 'expiry_date' => __('Expiry Date', 'invoicing'), |
|
428 | 428 | ); |
429 | 429 | |
430 | - return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
430 | + return apply_filters('wpi_discount_table_columns', $columns); |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | /** |
434 | 434 | * Filters post states. |
435 | 435 | */ |
436 | - public static function filter_discount_state( $post_states, $post ) { |
|
436 | + public static function filter_discount_state($post_states, $post) { |
|
437 | 437 | |
438 | - if ( 'wpi_discount' == $post->post_type ) { |
|
438 | + if ('wpi_discount' == $post->post_type) { |
|
439 | 439 | |
440 | - $discount = new WPInv_Discount( $post ); |
|
440 | + $discount = new WPInv_Discount($post); |
|
441 | 441 | |
442 | 442 | $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
443 | 443 | |
444 | - if ( $status != 'publish' ) { |
|
444 | + if ($status != 'publish') { |
|
445 | 445 | return array( |
446 | - 'discount_status' => wpinv_discount_status( $status ), |
|
446 | + 'discount_status' => wpinv_discount_status($status), |
|
447 | 447 | ); |
448 | 448 | } |
449 | 449 | |
@@ -458,30 +458,30 @@ discard block |
||
458 | 458 | /** |
459 | 459 | * Returns an array of items table columns. |
460 | 460 | */ |
461 | - public static function item_columns( $columns ) { |
|
461 | + public static function item_columns($columns) { |
|
462 | 462 | |
463 | 463 | $columns = array( |
464 | 464 | 'cb' => $columns['cb'], |
465 | - 'title' => __( 'Name', 'invoicing' ), |
|
466 | - 'price' => __( 'Price', 'invoicing' ), |
|
467 | - 'vat_rule' => __( 'VAT rule', 'invoicing' ), |
|
468 | - 'vat_class' => __( 'VAT class', 'invoicing' ), |
|
469 | - 'type' => __( 'Type', 'invoicing' ), |
|
470 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
465 | + 'title' => __('Name', 'invoicing'), |
|
466 | + 'price' => __('Price', 'invoicing'), |
|
467 | + 'vat_rule' => __('VAT rule', 'invoicing'), |
|
468 | + 'vat_class' => __('VAT class', 'invoicing'), |
|
469 | + 'type' => __('Type', 'invoicing'), |
|
470 | + 'shortcode' => __('Shortcode', 'invoicing'), |
|
471 | 471 | ); |
472 | 472 | |
473 | - if ( ! wpinv_use_taxes() ) { |
|
474 | - unset( $columns['vat_rule'] ); |
|
475 | - unset( $columns['vat_class'] ); |
|
473 | + if (!wpinv_use_taxes()) { |
|
474 | + unset($columns['vat_rule']); |
|
475 | + unset($columns['vat_class']); |
|
476 | 476 | } |
477 | 477 | |
478 | - return apply_filters( 'wpi_item_table_columns', $columns ); |
|
478 | + return apply_filters('wpi_item_table_columns', $columns); |
|
479 | 479 | } |
480 | 480 | |
481 | 481 | /** |
482 | 482 | * Returns an array of sortable items table columns. |
483 | 483 | */ |
484 | - public static function sortable_item_columns( $columns ) { |
|
484 | + public static function sortable_item_columns($columns) { |
|
485 | 485 | |
486 | 486 | return array_merge( |
487 | 487 | $columns, |
@@ -498,49 +498,49 @@ discard block |
||
498 | 498 | /** |
499 | 499 | * Displays items table columns. |
500 | 500 | */ |
501 | - public static function display_item_columns( $column_name, $post_id ) { |
|
501 | + public static function display_item_columns($column_name, $post_id) { |
|
502 | 502 | |
503 | - $item = new WPInv_Item( $post_id ); |
|
503 | + $item = new WPInv_Item($post_id); |
|
504 | 504 | |
505 | - switch ( $column_name ) { |
|
505 | + switch ($column_name) { |
|
506 | 506 | |
507 | 507 | case 'price' : |
508 | 508 | |
509 | - if ( ! $item->is_recurring() ) { |
|
509 | + if (!$item->is_recurring()) { |
|
510 | 510 | echo $item->get_the_price(); |
511 | 511 | break; |
512 | 512 | } |
513 | 513 | |
514 | 514 | $price = wp_sprintf( |
515 | - __( '%s / %s', 'invoicing' ), |
|
515 | + __('%s / %s', 'invoicing'), |
|
516 | 516 | $item->get_the_price(), |
517 | - getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ) |
|
517 | + getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), '') |
|
518 | 518 | ); |
519 | 519 | |
520 | - if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
520 | + if ($item->get_the_price() == $item->get_the_initial_price()) { |
|
521 | 521 | echo $price; |
522 | 522 | break; |
523 | 523 | } |
524 | 524 | |
525 | 525 | echo $item->get_the_initial_price(); |
526 | 526 | |
527 | - echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price ) .'</span>'; |
|
527 | + echo '<span class="meta">' . wp_sprintf(__('then %s', 'invoicing'), $price) . '</span>'; |
|
528 | 528 | break; |
529 | 529 | |
530 | 530 | case 'vat_rule' : |
531 | - echo getpaid_get_tax_rule_label( $item->get_vat_rule() ); |
|
531 | + echo getpaid_get_tax_rule_label($item->get_vat_rule()); |
|
532 | 532 | break; |
533 | 533 | |
534 | 534 | case 'vat_class' : |
535 | - echo getpaid_get_tax_class_label( $item->get_vat_class() ); |
|
535 | + echo getpaid_get_tax_class_label($item->get_vat_class()); |
|
536 | 536 | break; |
537 | 537 | |
538 | 538 | case 'shortcode' : |
539 | - echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
539 | + echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr($item->get_id()) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
540 | 540 | break; |
541 | 541 | |
542 | 542 | case 'type' : |
543 | - echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
543 | + echo wpinv_item_type($item->get_id()) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
544 | 544 | break; |
545 | 545 | |
546 | 546 | } |
@@ -550,21 +550,21 @@ discard block |
||
550 | 550 | /** |
551 | 551 | * Lets users filter items using taxes. |
552 | 552 | */ |
553 | - public static function add_item_filters( $post_type ) { |
|
553 | + public static function add_item_filters($post_type) { |
|
554 | 554 | |
555 | 555 | // Abort if we're not dealing with items. |
556 | - if ( $post_type != 'wpi_item' ) { |
|
556 | + if ($post_type != 'wpi_item') { |
|
557 | 557 | return; |
558 | 558 | } |
559 | 559 | |
560 | 560 | // Filter by vat rules. |
561 | - if ( wpinv_use_taxes() ) { |
|
561 | + if (wpinv_use_taxes()) { |
|
562 | 562 | |
563 | 563 | // Sanitize selected vat rule. |
564 | 564 | $vat_rule = ''; |
565 | 565 | $vat_rules = getpaid_get_tax_rules(); |
566 | - if ( isset( $_GET['vat_rule'] ) ) { |
|
567 | - $vat_rule = $_GET['vat_rule']; |
|
566 | + if (isset($_GET['vat_rule'])) { |
|
567 | + $vat_rule = $_GET['vat_rule']; |
|
568 | 568 | } |
569 | 569 | |
570 | 570 | // Filter by VAT rule. |
@@ -572,13 +572,13 @@ discard block |
||
572 | 572 | array( |
573 | 573 | 'options' => array_merge( |
574 | 574 | array( |
575 | - '' => __( 'All VAT rules', 'invoicing' ) |
|
575 | + '' => __('All VAT rules', 'invoicing') |
|
576 | 576 | ), |
577 | 577 | $vat_rules |
578 | 578 | ), |
579 | 579 | 'name' => 'vat_rule', |
580 | 580 | 'id' => 'vat_rule', |
581 | - 'selected' => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '', |
|
581 | + 'selected' => in_array($vat_rule, array_keys($vat_rules)) ? $vat_rule : '', |
|
582 | 582 | 'show_option_all' => false, |
583 | 583 | 'show_option_none' => false, |
584 | 584 | ) |
@@ -589,21 +589,21 @@ discard block |
||
589 | 589 | // Sanitize selected vat rule. |
590 | 590 | $vat_class = ''; |
591 | 591 | $vat_classes = getpaid_get_tax_classes(); |
592 | - if ( isset( $_GET['vat_class'] ) ) { |
|
593 | - $vat_class = $_GET['vat_class']; |
|
592 | + if (isset($_GET['vat_class'])) { |
|
593 | + $vat_class = $_GET['vat_class']; |
|
594 | 594 | } |
595 | 595 | |
596 | 596 | echo wpinv_html_select( |
597 | 597 | array( |
598 | 598 | 'options' => array_merge( |
599 | 599 | array( |
600 | - '' => __( 'All VAT classes', 'invoicing' ) |
|
600 | + '' => __('All VAT classes', 'invoicing') |
|
601 | 601 | ), |
602 | 602 | $vat_classes |
603 | 603 | ), |
604 | 604 | 'name' => 'vat_class', |
605 | 605 | 'id' => 'vat_class', |
606 | - 'selected' => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '', |
|
606 | + 'selected' => in_array($vat_class, array_keys($vat_classes)) ? $vat_class : '', |
|
607 | 607 | 'show_option_all' => false, |
608 | 608 | 'show_option_none' => false, |
609 | 609 | ) |
@@ -612,22 +612,22 @@ discard block |
||
612 | 612 | } |
613 | 613 | |
614 | 614 | // Filter by item type. |
615 | - $type = ''; |
|
616 | - if ( isset( $_GET['type'] ) ) { |
|
617 | - $type = $_GET['type']; |
|
615 | + $type = ''; |
|
616 | + if (isset($_GET['type'])) { |
|
617 | + $type = $_GET['type']; |
|
618 | 618 | } |
619 | 619 | |
620 | 620 | echo wpinv_html_select( |
621 | 621 | array( |
622 | 622 | 'options' => array_merge( |
623 | 623 | array( |
624 | - '' => __( 'All item types', 'invoicing' ) |
|
624 | + '' => __('All item types', 'invoicing') |
|
625 | 625 | ), |
626 | 626 | wpinv_get_item_types() |
627 | 627 | ), |
628 | 628 | 'name' => 'type', |
629 | 629 | 'id' => 'type', |
630 | - 'selected' => in_array( $type, wpinv_item_types() ) ? $type : '', |
|
630 | + 'selected' => in_array($type, wpinv_item_types()) ? $type : '', |
|
631 | 631 | 'show_option_all' => false, |
632 | 632 | 'show_option_none' => false, |
633 | 633 | ) |
@@ -638,45 +638,45 @@ discard block |
||
638 | 638 | /** |
639 | 639 | * Filters the item query. |
640 | 640 | */ |
641 | - public static function filter_item_query( $query ) { |
|
641 | + public static function filter_item_query($query) { |
|
642 | 642 | |
643 | 643 | // modify the query only if it admin and main query. |
644 | - if ( ! ( is_admin() && $query->is_main_query() ) ){ |
|
644 | + if (!(is_admin() && $query->is_main_query())) { |
|
645 | 645 | return $query; |
646 | 646 | } |
647 | 647 | |
648 | 648 | // we want to modify the query for our items. |
649 | - if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ){ |
|
649 | + if (empty($query->query['post_type']) || 'wpi_item' != $query->query['post_type']) { |
|
650 | 650 | return $query; |
651 | 651 | } |
652 | 652 | |
653 | - if ( empty( $query->query_vars['meta_query'] ) ) { |
|
653 | + if (empty($query->query_vars['meta_query'])) { |
|
654 | 654 | $query->query_vars['meta_query'] = array(); |
655 | 655 | } |
656 | 656 | |
657 | 657 | // Filter vat rule type |
658 | - if ( ! empty( $_GET['vat_rule'] ) ) { |
|
658 | + if (!empty($_GET['vat_rule'])) { |
|
659 | 659 | $query->query_vars['meta_query'][] = array( |
660 | 660 | 'key' => '_wpinv_vat_rule', |
661 | - 'value' => sanitize_text_field( $_GET['vat_rule'] ), |
|
661 | + 'value' => sanitize_text_field($_GET['vat_rule']), |
|
662 | 662 | 'compare' => '=' |
663 | 663 | ); |
664 | 664 | } |
665 | 665 | |
666 | 666 | // Filter vat class |
667 | - if ( ! empty( $_GET['vat_class'] ) ) { |
|
667 | + if (!empty($_GET['vat_class'])) { |
|
668 | 668 | $query->query_vars['meta_query'][] = array( |
669 | 669 | 'key' => '_wpinv_vat_class', |
670 | - 'value' => sanitize_text_field( $_GET['vat_class'] ), |
|
670 | + 'value' => sanitize_text_field($_GET['vat_class']), |
|
671 | 671 | 'compare' => '=' |
672 | 672 | ); |
673 | 673 | } |
674 | 674 | |
675 | 675 | // Filter item type |
676 | - if ( ! empty( $_GET['type'] ) ) { |
|
676 | + if (!empty($_GET['type'])) { |
|
677 | 677 | $query->query_vars['meta_query'][] = array( |
678 | 678 | 'key' => '_wpinv_type', |
679 | - 'value' => sanitize_text_field( $_GET['type'] ), |
|
679 | + 'value' => sanitize_text_field($_GET['type']), |
|
680 | 680 | 'compare' => '=' |
681 | 681 | ); |
682 | 682 | } |
@@ -686,15 +686,15 @@ discard block |
||
686 | 686 | /** |
687 | 687 | * Reorders items. |
688 | 688 | */ |
689 | - public static function reorder_items( $vars ) { |
|
689 | + public static function reorder_items($vars) { |
|
690 | 690 | global $typenow; |
691 | 691 | |
692 | - if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
692 | + if ('wpi_item' !== $typenow || empty($vars['orderby'])) { |
|
693 | 693 | return $vars; |
694 | 694 | } |
695 | 695 | |
696 | 696 | // By item type. |
697 | - if ( 'type' == $vars['orderby'] ) { |
|
697 | + if ('type' == $vars['orderby']) { |
|
698 | 698 | return array_merge( |
699 | 699 | $vars, |
700 | 700 | array( |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | } |
706 | 706 | |
707 | 707 | // By vat class. |
708 | - if ( 'vat_class' == $vars['orderby'] ) { |
|
708 | + if ('vat_class' == $vars['orderby']) { |
|
709 | 709 | return array_merge( |
710 | 710 | $vars, |
711 | 711 | array( |
@@ -716,7 +716,7 @@ discard block |
||
716 | 716 | } |
717 | 717 | |
718 | 718 | // By vat rule. |
719 | - if ( 'vat_rule' == $vars['orderby'] ) { |
|
719 | + if ('vat_rule' == $vars['orderby']) { |
|
720 | 720 | return array_merge( |
721 | 721 | $vars, |
722 | 722 | array( |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | } |
728 | 728 | |
729 | 729 | // By price. |
730 | - if ( 'price' == $vars['orderby'] ) { |
|
730 | + if ('price' == $vars['orderby']) { |
|
731 | 731 | return array_merge( |
732 | 732 | $vars, |
733 | 733 | array( |
@@ -744,27 +744,27 @@ discard block |
||
744 | 744 | /** |
745 | 745 | * Fired when deleting a post. |
746 | 746 | */ |
747 | - public static function delete_post( $post_id ) { |
|
747 | + public static function delete_post($post_id) { |
|
748 | 748 | |
749 | - switch ( get_post_type( $post_id ) ) { |
|
749 | + switch (get_post_type($post_id)) { |
|
750 | 750 | |
751 | 751 | case 'wpi_item' : |
752 | - do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) ); |
|
752 | + do_action("getpaid_before_delete_item", new WPInv_Item($post_id)); |
|
753 | 753 | break; |
754 | 754 | |
755 | 755 | case 'wpi_payment_form' : |
756 | - do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) ); |
|
756 | + do_action("getpaid_before_delete_payment_form", new GetPaid_Payment_Form($post_id)); |
|
757 | 757 | break; |
758 | 758 | |
759 | 759 | case 'wpi_discount' : |
760 | - do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) ); |
|
760 | + do_action("getpaid_before_delete_discount", new WPInv_Discount($post_id)); |
|
761 | 761 | break; |
762 | 762 | |
763 | 763 | case 'wpi_invoice' : |
764 | - $invoice = new WPInv_Invoice( $post_id ); |
|
765 | - do_action( "getpaid_before_delete_invoice", $invoice ); |
|
766 | - $invoice->get_data_store()->delete_items( $invoice ); |
|
767 | - $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
764 | + $invoice = new WPInv_Invoice($post_id); |
|
765 | + do_action("getpaid_before_delete_invoice", $invoice); |
|
766 | + $invoice->get_data_store()->delete_items($invoice); |
|
767 | + $invoice->get_data_store()->delete_special_fields($invoice); |
|
768 | 768 | break; |
769 | 769 | } |
770 | 770 | } |
@@ -777,29 +777,29 @@ discard block |
||
777 | 777 | * |
778 | 778 | * @return mixed |
779 | 779 | */ |
780 | - public static function add_display_post_states( $post_states, $post ) { |
|
780 | + public static function add_display_post_states($post_states, $post) { |
|
781 | 781 | |
782 | - if ( wpinv_get_option( 'success_page', 0 ) == $post->ID ) { |
|
783 | - $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' ); |
|
782 | + if (wpinv_get_option('success_page', 0) == $post->ID) { |
|
783 | + $post_states['getpaid_success_page'] = __('GetPaid Receipt Page', 'invoicing'); |
|
784 | 784 | } |
785 | 785 | |
786 | - foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) { |
|
786 | + foreach (getpaid_get_invoice_post_types() as $post_type => $label) { |
|
787 | 787 | |
788 | - if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) { |
|
788 | + if (wpinv_get_option("{$post_type}_history_page", 0) == $post->ID) { |
|
789 | 789 | $post_states["getpaid_{$post_type}_history_page"] = sprintf( |
790 | - __( 'GetPaid %s History Page', 'invoicing' ), |
|
790 | + __('GetPaid %s History Page', 'invoicing'), |
|
791 | 791 | $label |
792 | 792 | ); |
793 | 793 | } |
794 | 794 | |
795 | 795 | } |
796 | 796 | |
797 | - if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) { |
|
798 | - $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscription Page', 'invoicing' ); |
|
797 | + if (wpinv_get_option('invoice_subscription_page', 0) == $post->ID) { |
|
798 | + $post_states['getpaid_invoice_subscription_page'] = __('GetPaid Subscription Page', 'invoicing'); |
|
799 | 799 | } |
800 | 800 | |
801 | - if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) { |
|
802 | - $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' ); |
|
801 | + if (wpinv_get_option('checkout_page', 0) == $post->ID) { |
|
802 | + $post_states['getpaid_checkout_page'] = __('GetPaid Checkout Page', 'invoicing'); |
|
803 | 803 | } |
804 | 804 | |
805 | 805 | return $post_states; |