@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | */ |
15 | 15 | function wpinv_subscriptions_page() { |
16 | 16 | |
17 | - ?> |
|
17 | + ?> |
|
18 | 18 | |
19 | 19 | <div class="wrap"> |
20 | 20 | <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> |
@@ -22,28 +22,28 @@ discard block |
||
22 | 22 | |
23 | 23 | <?php |
24 | 24 | |
25 | - // Verify user permissions. |
|
26 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
25 | + // Verify user permissions. |
|
26 | + if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
27 | 27 | |
28 | - aui()->alert( |
|
28 | + aui()->alert( |
|
29 | 29 | array( |
30 | - 'type' => 'danger', |
|
31 | - 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
32 | - ), |
|
33 | - true |
|
30 | + 'type' => 'danger', |
|
31 | + 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
32 | + ), |
|
33 | + true |
|
34 | 34 | ); |
35 | 35 | |
36 | - } elseif ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
36 | + } elseif ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
37 | 37 | |
38 | - // Display a single subscription. |
|
39 | - wpinv_recurring_subscription_details(); |
|
40 | - } else { |
|
38 | + // Display a single subscription. |
|
39 | + wpinv_recurring_subscription_details(); |
|
40 | + } else { |
|
41 | 41 | |
42 | - // Display a list of available subscriptions. |
|
43 | - getpaid_print_subscriptions_list(); |
|
44 | - } |
|
42 | + // Display a list of available subscriptions. |
|
43 | + getpaid_print_subscriptions_list(); |
|
44 | + } |
|
45 | 45 | |
46 | - ?> |
|
46 | + ?> |
|
47 | 47 | |
48 | 48 | </div> |
49 | 49 | </div> |
@@ -60,10 +60,10 @@ discard block |
||
60 | 60 | */ |
61 | 61 | function getpaid_print_subscriptions_list() { |
62 | 62 | |
63 | - $subscribers_table = new WPInv_Subscriptions_List_Table(); |
|
64 | - $subscribers_table->prepare_items(); |
|
63 | + $subscribers_table = new WPInv_Subscriptions_List_Table(); |
|
64 | + $subscribers_table->prepare_items(); |
|
65 | 65 | |
66 | - ?> |
|
66 | + ?> |
|
67 | 67 | <?php $subscribers_table->views(); ?> |
68 | 68 | <form id="subscribers-filter" class="bsui" method="get"> |
69 | 69 | <input type="hidden" name="page" value="wpinv-subscriptions" /> |
@@ -82,42 +82,42 @@ discard block |
||
82 | 82 | */ |
83 | 83 | function wpinv_recurring_subscription_details() { |
84 | 84 | |
85 | - // Fetch the subscription. |
|
86 | - $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
87 | - if ( ! $sub->exists() ) { |
|
85 | + // Fetch the subscription. |
|
86 | + $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
87 | + if ( ! $sub->exists() ) { |
|
88 | 88 | |
89 | - aui()->alert( |
|
90 | - array( |
|
91 | - 'type' => 'danger', |
|
92 | - 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
93 | - ), |
|
94 | - true |
|
95 | - ); |
|
89 | + aui()->alert( |
|
90 | + array( |
|
91 | + 'type' => 'danger', |
|
92 | + 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
93 | + ), |
|
94 | + true |
|
95 | + ); |
|
96 | 96 | |
97 | - return; |
|
98 | - } |
|
97 | + return; |
|
98 | + } |
|
99 | 99 | |
100 | - // Use metaboxes to display the subscription details. |
|
101 | - add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
102 | - add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
100 | + // Use metaboxes to display the subscription details. |
|
101 | + add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
102 | + add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
103 | 103 | |
104 | - $subscription_id = $sub->get_id(); |
|
105 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
106 | - $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
104 | + $subscription_id = $sub->get_id(); |
|
105 | + $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
106 | + $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
107 | 107 | |
108 | - if ( 1 < count( $subscription_groups ) ) { |
|
109 | - add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
110 | - } |
|
108 | + if ( 1 < count( $subscription_groups ) ) { |
|
109 | + add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
110 | + } |
|
111 | 111 | |
112 | - if ( ! empty( $subscription_group ) ) { |
|
113 | - add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
114 | - } |
|
112 | + if ( ! empty( $subscription_group ) ) { |
|
113 | + add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
114 | + } |
|
115 | 115 | |
116 | - add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
116 | + add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
117 | 117 | |
118 | - do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
118 | + do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
119 | 119 | |
120 | - ?> |
|
120 | + ?> |
|
121 | 121 | |
122 | 122 | <form method="post" action="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ) ); ?>"> |
123 | 123 | |
@@ -157,49 +157,49 @@ discard block |
||
157 | 157 | */ |
158 | 158 | function getpaid_admin_subscription_details_metabox( $sub ) { |
159 | 159 | |
160 | - // Subscription items. |
|
161 | - $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
162 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
163 | - |
|
164 | - // Prepare subscription detail columns. |
|
165 | - $fields = apply_filters( |
|
166 | - 'getpaid_subscription_admin_page_fields', |
|
167 | - array( |
|
168 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
169 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
170 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
171 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
172 | - 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
173 | - 'renewals' => __( 'Collected Payments', 'invoicing' ), |
|
174 | - 'item' => $items_count > 1 ? __( 'Items', 'invoicing' ) : __( 'Item', 'invoicing' ), |
|
175 | - 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
176 | - 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
177 | - 'status' => __( 'Status', 'invoicing' ), |
|
178 | - ) |
|
179 | - ); |
|
180 | - |
|
181 | - if ( ! $sub->is_active() ) { |
|
182 | - |
|
183 | - if ( isset( $fields['renews_on'] ) ) { |
|
184 | - unset( $fields['renews_on'] ); |
|
185 | - } |
|
186 | - |
|
187 | - if ( isset( $fields['gateway'] ) ) { |
|
188 | - unset( $fields['gateway'] ); |
|
189 | - } |
|
190 | - } elseif ( $sub->is_last_renewal() ) { |
|
191 | - |
|
192 | - if ( isset( $fields['renews_on'] ) ) { |
|
193 | - $fields['renews_on'] = __( 'End Date', 'invoicing' ); |
|
194 | - } |
|
195 | - } |
|
196 | - |
|
197 | - $profile_id = $sub->get_profile_id(); |
|
198 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
199 | - unset( $fields['profile_id'] ); |
|
200 | - } |
|
201 | - |
|
202 | - ?> |
|
160 | + // Subscription items. |
|
161 | + $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
162 | + $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
163 | + |
|
164 | + // Prepare subscription detail columns. |
|
165 | + $fields = apply_filters( |
|
166 | + 'getpaid_subscription_admin_page_fields', |
|
167 | + array( |
|
168 | + 'subscription' => __( 'Subscription', 'invoicing' ), |
|
169 | + 'customer' => __( 'Customer', 'invoicing' ), |
|
170 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
171 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
172 | + 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
173 | + 'renewals' => __( 'Collected Payments', 'invoicing' ), |
|
174 | + 'item' => $items_count > 1 ? __( 'Items', 'invoicing' ) : __( 'Item', 'invoicing' ), |
|
175 | + 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
176 | + 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
177 | + 'status' => __( 'Status', 'invoicing' ), |
|
178 | + ) |
|
179 | + ); |
|
180 | + |
|
181 | + if ( ! $sub->is_active() ) { |
|
182 | + |
|
183 | + if ( isset( $fields['renews_on'] ) ) { |
|
184 | + unset( $fields['renews_on'] ); |
|
185 | + } |
|
186 | + |
|
187 | + if ( isset( $fields['gateway'] ) ) { |
|
188 | + unset( $fields['gateway'] ); |
|
189 | + } |
|
190 | + } elseif ( $sub->is_last_renewal() ) { |
|
191 | + |
|
192 | + if ( isset( $fields['renews_on'] ) ) { |
|
193 | + $fields['renews_on'] = __( 'End Date', 'invoicing' ); |
|
194 | + } |
|
195 | + } |
|
196 | + |
|
197 | + $profile_id = $sub->get_profile_id(); |
|
198 | + if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
199 | + unset( $fields['profile_id'] ); |
|
200 | + } |
|
201 | + |
|
202 | + ?> |
|
203 | 203 | |
204 | 204 | <table class="table table-borderless" style="font-size: 14px;"> |
205 | 205 | <tbody> |
@@ -233,20 +233,20 @@ discard block |
||
233 | 233 | */ |
234 | 234 | function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
235 | 235 | |
236 | - $username = __( '(Missing User)', 'invoicing' ); |
|
236 | + $username = __( '(Missing User)', 'invoicing' ); |
|
237 | 237 | |
238 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
239 | - if ( $user ) { |
|
238 | + $user = get_userdata( $subscription->get_customer_id() ); |
|
239 | + if ( $user ) { |
|
240 | 240 | |
241 | - $username = sprintf( |
|
242 | - '<a href="user-edit.php?user_id=%s">%s</a>', |
|
243 | - absint( $user->ID ), |
|
244 | - ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email ) |
|
245 | - ); |
|
241 | + $username = sprintf( |
|
242 | + '<a href="user-edit.php?user_id=%s">%s</a>', |
|
243 | + absint( $user->ID ), |
|
244 | + ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email ) |
|
245 | + ); |
|
246 | 246 | |
247 | - } |
|
247 | + } |
|
248 | 248 | |
249 | - echo wp_kses_post( $username ); |
|
249 | + echo wp_kses_post( $username ); |
|
250 | 250 | } |
251 | 251 | add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
252 | 252 | |
@@ -256,8 +256,8 @@ discard block |
||
256 | 256 | * @param WPInv_Subscription $subscription |
257 | 257 | */ |
258 | 258 | function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
259 | - $amount = getpaid_get_formatted_subscription_amount( $subscription ); |
|
260 | - echo wp_kses_post( "<span>$amount</span>" ); |
|
259 | + $amount = getpaid_get_formatted_subscription_amount( $subscription ); |
|
260 | + echo wp_kses_post( "<span>$amount</span>" ); |
|
261 | 261 | } |
262 | 262 | add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
263 | 263 | |
@@ -268,11 +268,11 @@ discard block |
||
268 | 268 | */ |
269 | 269 | function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
270 | 270 | |
271 | - printf( |
|
272 | - '<a href="%s">#%s</a>', |
|
273 | - esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ), |
|
274 | - absint( $subscription->get_id() ) |
|
275 | - ); |
|
271 | + printf( |
|
272 | + '<a href="%s">#%s</a>', |
|
273 | + esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ), |
|
274 | + absint( $subscription->get_id() ) |
|
275 | + ); |
|
276 | 276 | |
277 | 277 | } |
278 | 278 | add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
@@ -284,24 +284,24 @@ discard block |
||
284 | 284 | */ |
285 | 285 | function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
286 | 286 | |
287 | - if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) { |
|
288 | - aui()->input( |
|
289 | - array( |
|
290 | - 'type' => 'text', |
|
291 | - 'id' => 'wpinv_subscription_date_created', |
|
292 | - 'name' => 'wpinv_subscription_date_created', |
|
293 | - 'label' => __( 'Start Date', 'invoicing' ), |
|
294 | - 'label_type' => 'hidden', |
|
295 | - 'placeholder' => 'YYYY-MM-DD', |
|
296 | - 'value' => esc_attr( $subscription->get_date_created( 'edit' ) ), |
|
297 | - 'no_wrap' => true, |
|
298 | - 'size' => 'sm', |
|
299 | - ), |
|
300 | - true |
|
301 | - ); |
|
302 | - } else { |
|
303 | - echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) ); |
|
304 | - } |
|
287 | + if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) { |
|
288 | + aui()->input( |
|
289 | + array( |
|
290 | + 'type' => 'text', |
|
291 | + 'id' => 'wpinv_subscription_date_created', |
|
292 | + 'name' => 'wpinv_subscription_date_created', |
|
293 | + 'label' => __( 'Start Date', 'invoicing' ), |
|
294 | + 'label_type' => 'hidden', |
|
295 | + 'placeholder' => 'YYYY-MM-DD', |
|
296 | + 'value' => esc_attr( $subscription->get_date_created( 'edit' ) ), |
|
297 | + 'no_wrap' => true, |
|
298 | + 'size' => 'sm', |
|
299 | + ), |
|
300 | + true |
|
301 | + ); |
|
302 | + } else { |
|
303 | + echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) ); |
|
304 | + } |
|
305 | 305 | |
306 | 306 | } |
307 | 307 | add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
@@ -313,24 +313,24 @@ discard block |
||
313 | 313 | */ |
314 | 314 | function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
315 | 315 | |
316 | - if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) { |
|
317 | - aui()->input( |
|
318 | - array( |
|
319 | - 'type' => 'text', |
|
320 | - 'id' => 'wpinv_subscription_expiration', |
|
321 | - 'name' => 'wpinv_subscription_expiration', |
|
322 | - 'label' => __( 'Renews On', 'invoicing' ), |
|
323 | - 'label_type' => 'hidden', |
|
324 | - 'placeholder' => 'YYYY-MM-DD', |
|
325 | - 'value' => esc_attr( $subscription->get_expiration( 'edit' ) ), |
|
326 | - 'no_wrap' => true, |
|
327 | - 'size' => 'sm', |
|
328 | - ), |
|
329 | - true |
|
330 | - ); |
|
331 | - } else { |
|
332 | - echo esc_html( getpaid_format_date_value( $subscription->get_expiration() ) ); |
|
333 | - } |
|
316 | + if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) { |
|
317 | + aui()->input( |
|
318 | + array( |
|
319 | + 'type' => 'text', |
|
320 | + 'id' => 'wpinv_subscription_expiration', |
|
321 | + 'name' => 'wpinv_subscription_expiration', |
|
322 | + 'label' => __( 'Renews On', 'invoicing' ), |
|
323 | + 'label_type' => 'hidden', |
|
324 | + 'placeholder' => 'YYYY-MM-DD', |
|
325 | + 'value' => esc_attr( $subscription->get_expiration( 'edit' ) ), |
|
326 | + 'no_wrap' => true, |
|
327 | + 'size' => 'sm', |
|
328 | + ), |
|
329 | + true |
|
330 | + ); |
|
331 | + } else { |
|
332 | + echo esc_html( getpaid_format_date_value( $subscription->get_expiration() ) ); |
|
333 | + } |
|
334 | 334 | } |
335 | 335 | add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
336 | 336 | |
@@ -341,32 +341,32 @@ discard block |
||
341 | 341 | */ |
342 | 342 | function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
343 | 343 | |
344 | - $max_bills = $subscription->get_bill_times(); |
|
345 | - $times_billed = (int) $subscription->get_times_billed(); |
|
346 | - |
|
347 | - if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_bill_times_change' ) ) { |
|
348 | - aui()->input( |
|
349 | - array( |
|
350 | - 'type' => 'number', |
|
351 | - 'id' => 'wpinv_subscription_max_bill_times', |
|
352 | - 'name' => 'wpinv_subscription_max_bill_times', |
|
353 | - 'label' => __( 'Maximum bill times', 'invoicing' ), |
|
354 | - 'label_type' => 'hidden', |
|
355 | - 'placeholder' => __( 'Unlimited', 'invoicing' ), |
|
356 | - 'value' => empty( $max_bills ) ? '' : (int) $max_bills, |
|
357 | - 'no_wrap' => true, |
|
358 | - 'size' => 'sm', |
|
359 | - 'input_group_left' => sprintf( |
|
360 | - // translators: %d: Number of times billed |
|
361 | - __( '%d of', 'invoicing' ), |
|
362 | - $times_billed |
|
363 | - ), |
|
364 | - ), |
|
365 | - true |
|
366 | - ); |
|
367 | - } else { |
|
368 | - echo esc_html( $times_billed ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
369 | - } |
|
344 | + $max_bills = $subscription->get_bill_times(); |
|
345 | + $times_billed = (int) $subscription->get_times_billed(); |
|
346 | + |
|
347 | + if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_bill_times_change' ) ) { |
|
348 | + aui()->input( |
|
349 | + array( |
|
350 | + 'type' => 'number', |
|
351 | + 'id' => 'wpinv_subscription_max_bill_times', |
|
352 | + 'name' => 'wpinv_subscription_max_bill_times', |
|
353 | + 'label' => __( 'Maximum bill times', 'invoicing' ), |
|
354 | + 'label_type' => 'hidden', |
|
355 | + 'placeholder' => __( 'Unlimited', 'invoicing' ), |
|
356 | + 'value' => empty( $max_bills ) ? '' : (int) $max_bills, |
|
357 | + 'no_wrap' => true, |
|
358 | + 'size' => 'sm', |
|
359 | + 'input_group_left' => sprintf( |
|
360 | + // translators: %d: Number of times billed |
|
361 | + __( '%d of', 'invoicing' ), |
|
362 | + $times_billed |
|
363 | + ), |
|
364 | + ), |
|
365 | + true |
|
366 | + ); |
|
367 | + } else { |
|
368 | + echo esc_html( $times_billed ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
369 | + } |
|
370 | 370 | } |
371 | 371 | add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
372 | 372 | |
@@ -378,13 +378,13 @@ discard block |
||
378 | 378 | */ |
379 | 379 | function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) { |
380 | 380 | |
381 | - if ( empty( $subscription_group ) ) { |
|
382 | - echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) ); |
|
383 | - return; |
|
384 | - } |
|
381 | + if ( empty( $subscription_group ) ) { |
|
382 | + echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) ); |
|
383 | + return; |
|
384 | + } |
|
385 | 385 | |
386 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
387 | - echo wp_kses_post( implode( ' | ', $markup ) ); |
|
386 | + $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
387 | + echo wp_kses_post( implode( ' | ', $markup ) ); |
|
388 | 388 | |
389 | 389 | } |
390 | 390 | add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 ); |
@@ -396,13 +396,13 @@ discard block |
||
396 | 396 | */ |
397 | 397 | function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
398 | 398 | |
399 | - $gateway = $subscription->get_gateway(); |
|
399 | + $gateway = $subscription->get_gateway(); |
|
400 | 400 | |
401 | - if ( ! empty( $gateway ) ) { |
|
402 | - echo esc_html( wpinv_get_gateway_admin_label( $gateway ) ); |
|
403 | - } else { |
|
404 | - echo '—'; |
|
405 | - } |
|
401 | + if ( ! empty( $gateway ) ) { |
|
402 | + echo esc_html( wpinv_get_gateway_admin_label( $gateway ) ); |
|
403 | + } else { |
|
404 | + echo '—'; |
|
405 | + } |
|
406 | 406 | |
407 | 407 | } |
408 | 408 | add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | * @param WPInv_Subscription $subscription |
414 | 414 | */ |
415 | 415 | function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
416 | - echo wp_kses_post( $subscription->get_status_label_html() ); |
|
416 | + echo wp_kses_post( $subscription->get_status_label_html() ); |
|
417 | 417 | } |
418 | 418 | add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
419 | 419 | |
@@ -424,28 +424,28 @@ discard block |
||
424 | 424 | */ |
425 | 425 | function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
426 | 426 | |
427 | - $profile_id = $subscription->get_profile_id(); |
|
428 | - |
|
429 | - aui()->input( |
|
430 | - array( |
|
431 | - 'type' => 'text', |
|
432 | - 'id' => 'wpinv_subscription_profile_id', |
|
433 | - 'name' => 'wpinv_subscription_profile_id', |
|
434 | - 'label' => __( 'Profile Id', 'invoicing' ), |
|
435 | - 'label_type' => 'hidden', |
|
436 | - 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
437 | - 'value' => esc_attr( $profile_id ), |
|
438 | - 'input_group_right' => '', |
|
439 | - 'no_wrap' => true, |
|
440 | - 'size' => 'sm', |
|
441 | - ), |
|
442 | - true |
|
443 | - ); |
|
444 | - |
|
445 | - $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
446 | - if ( ! empty( $url ) ) { |
|
447 | - echo ' <a href="' . esc_url_raw( $url ) . '" title="' . esc_attr__( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
448 | - } |
|
427 | + $profile_id = $subscription->get_profile_id(); |
|
428 | + |
|
429 | + aui()->input( |
|
430 | + array( |
|
431 | + 'type' => 'text', |
|
432 | + 'id' => 'wpinv_subscription_profile_id', |
|
433 | + 'name' => 'wpinv_subscription_profile_id', |
|
434 | + 'label' => __( 'Profile Id', 'invoicing' ), |
|
435 | + 'label_type' => 'hidden', |
|
436 | + 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
437 | + 'value' => esc_attr( $profile_id ), |
|
438 | + 'input_group_right' => '', |
|
439 | + 'no_wrap' => true, |
|
440 | + 'size' => 'sm', |
|
441 | + ), |
|
442 | + true |
|
443 | + ); |
|
444 | + |
|
445 | + $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
446 | + if ( ! empty( $url ) ) { |
|
447 | + echo ' <a href="' . esc_url_raw( $url ) . '" title="' . esc_attr__( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
448 | + } |
|
449 | 449 | |
450 | 450 | } |
451 | 451 | add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
@@ -457,40 +457,40 @@ discard block |
||
457 | 457 | */ |
458 | 458 | function getpaid_admin_subscription_update_metabox( $subscription ) { |
459 | 459 | |
460 | - ?> |
|
460 | + ?> |
|
461 | 461 | <div class="mt-3"> |
462 | 462 | |
463 | 463 | <?php |
464 | - aui()->select( |
|
465 | - array( |
|
466 | - 'options' => getpaid_get_subscription_statuses(), |
|
467 | - 'name' => 'subscription_status', |
|
468 | - 'id' => 'subscription_status_update_select', |
|
469 | - 'required' => true, |
|
470 | - 'no_wrap' => false, |
|
471 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
472 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
473 | - 'select2' => true, |
|
474 | - 'value' => $subscription->get_status( 'edit' ), |
|
475 | - ), |
|
476 | - true |
|
477 | - ); |
|
478 | - ?> |
|
464 | + aui()->select( |
|
465 | + array( |
|
466 | + 'options' => getpaid_get_subscription_statuses(), |
|
467 | + 'name' => 'subscription_status', |
|
468 | + 'id' => 'subscription_status_update_select', |
|
469 | + 'required' => true, |
|
470 | + 'no_wrap' => false, |
|
471 | + 'label' => __( 'Subscription Status', 'invoicing' ), |
|
472 | + 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
473 | + 'select2' => true, |
|
474 | + 'value' => $subscription->get_status( 'edit' ), |
|
475 | + ), |
|
476 | + true |
|
477 | + ); |
|
478 | + ?> |
|
479 | 479 | |
480 | 480 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;"> |
481 | 481 | |
482 | 482 | <?php |
483 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
483 | + submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
484 | 484 | |
485 | - $url = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
486 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
487 | - $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' ); |
|
485 | + $url = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
486 | + $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
487 | + $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' ); |
|
488 | 488 | |
489 | - if ( $subscription->is_active() ) { |
|
490 | - echo "<a href='" . esc_url( $url ) . "' class='float-right text-muted' onclick='return confirm(\"" . esc_attr( $title ) . "\")'>" . esc_html( $anchor ) . "</a>"; |
|
491 | - } |
|
489 | + if ( $subscription->is_active() ) { |
|
490 | + echo "<a href='" . esc_url( $url ) . "' class='float-right text-muted' onclick='return confirm(\"" . esc_attr( $title ) . "\")'>" . esc_html( $anchor ) . "</a>"; |
|
491 | + } |
|
492 | 492 | |
493 | - echo '</div></div>'; |
|
493 | + echo '</div></div>'; |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | /** |
@@ -501,33 +501,33 @@ discard block |
||
501 | 501 | */ |
502 | 502 | function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) { |
503 | 503 | |
504 | - $columns = apply_filters( |
|
505 | - 'getpaid_subscription_related_invoices_columns', |
|
506 | - array( |
|
507 | - 'invoice' => __( 'Invoice', 'invoicing' ), |
|
508 | - 'relationship' => __( 'Relationship', 'invoicing' ), |
|
509 | - 'date' => __( 'Date', 'invoicing' ), |
|
510 | - 'status' => __( 'Status', 'invoicing' ), |
|
511 | - 'total' => __( 'Total', 'invoicing' ), |
|
512 | - ), |
|
513 | - $subscription |
|
514 | - ); |
|
515 | - |
|
516 | - // Prepare the invoices. |
|
517 | - $payments = $subscription->get_child_payments( ! is_admin() ); |
|
518 | - $parent = $subscription->get_parent_invoice(); |
|
519 | - |
|
520 | - if ( $parent->exists() ) { |
|
521 | - $payments = array_merge( array( $parent ), $payments ); |
|
522 | - } |
|
523 | - |
|
524 | - $table_class = 'w-100 bg-white'; |
|
525 | - |
|
526 | - if ( ! is_admin() ) { |
|
527 | - $table_class = 'table table-bordered'; |
|
528 | - } |
|
529 | - |
|
530 | - ?> |
|
504 | + $columns = apply_filters( |
|
505 | + 'getpaid_subscription_related_invoices_columns', |
|
506 | + array( |
|
507 | + 'invoice' => __( 'Invoice', 'invoicing' ), |
|
508 | + 'relationship' => __( 'Relationship', 'invoicing' ), |
|
509 | + 'date' => __( 'Date', 'invoicing' ), |
|
510 | + 'status' => __( 'Status', 'invoicing' ), |
|
511 | + 'total' => __( 'Total', 'invoicing' ), |
|
512 | + ), |
|
513 | + $subscription |
|
514 | + ); |
|
515 | + |
|
516 | + // Prepare the invoices. |
|
517 | + $payments = $subscription->get_child_payments( ! is_admin() ); |
|
518 | + $parent = $subscription->get_parent_invoice(); |
|
519 | + |
|
520 | + if ( $parent->exists() ) { |
|
521 | + $payments = array_merge( array( $parent ), $payments ); |
|
522 | + } |
|
523 | + |
|
524 | + $table_class = 'w-100 bg-white'; |
|
525 | + |
|
526 | + if ( ! is_admin() ) { |
|
527 | + $table_class = 'table table-bordered'; |
|
528 | + } |
|
529 | + |
|
530 | + ?> |
|
531 | 531 | <div class="m-0" style="overflow: auto;"> |
532 | 532 | |
533 | 533 | <table class="<?php echo esc_attr( $table_class ); ?>"> |
@@ -535,10 +535,10 @@ discard block |
||
535 | 535 | <thead> |
536 | 536 | <tr> |
537 | 537 | <?php |
538 | - foreach ( $columns as $key => $label ) { |
|
539 | - echo "<th class='subscription-invoice-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
540 | - } |
|
541 | - ?> |
|
538 | + foreach ( $columns as $key => $label ) { |
|
539 | + echo "<th class='subscription-invoice-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
540 | + } |
|
541 | + ?> |
|
542 | 542 | </tr> |
543 | 543 | </thead> |
544 | 544 | |
@@ -554,72 +554,72 @@ discard block |
||
554 | 554 | |
555 | 555 | <?php |
556 | 556 | |
557 | - foreach ( $payments as $payment ) : |
|
557 | + foreach ( $payments as $payment ) : |
|
558 | 558 | |
559 | - // Ensure that we have an invoice. |
|
560 | - $payment = new WPInv_Invoice( $payment ); |
|
559 | + // Ensure that we have an invoice. |
|
560 | + $payment = new WPInv_Invoice( $payment ); |
|
561 | 561 | |
562 | - // Abort if the invoice is invalid... |
|
563 | - if ( ! $payment->exists() ) { |
|
564 | - continue; |
|
565 | - } |
|
562 | + // Abort if the invoice is invalid... |
|
563 | + if ( ! $payment->exists() ) { |
|
564 | + continue; |
|
565 | + } |
|
566 | 566 | |
567 | - // ... or belongs to a different subscription. |
|
568 | - if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
569 | - continue; |
|
570 | - } |
|
567 | + // ... or belongs to a different subscription. |
|
568 | + if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
569 | + continue; |
|
570 | + } |
|
571 | 571 | |
572 | - echo '<tr>'; |
|
572 | + echo '<tr>'; |
|
573 | 573 | |
574 | - foreach ( array_keys( $columns ) as $key ) { |
|
574 | + foreach ( array_keys( $columns ) as $key ) { |
|
575 | 575 | |
576 | - echo "<td class='p-2 text-left'>"; |
|
576 | + echo "<td class='p-2 text-left'>"; |
|
577 | 577 | |
578 | - switch ( $key ) { |
|
578 | + switch ( $key ) { |
|
579 | 579 | |
580 | - case 'total': |
|
581 | - echo '<strong>'; |
|
582 | - wpinv_the_price( $payment->get_total(), $payment->get_currency() ); |
|
583 | - echo '</strong>'; |
|
584 | - break; |
|
580 | + case 'total': |
|
581 | + echo '<strong>'; |
|
582 | + wpinv_the_price( $payment->get_total(), $payment->get_currency() ); |
|
583 | + echo '</strong>'; |
|
584 | + break; |
|
585 | 585 | |
586 | - case 'relationship': |
|
587 | - echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' ); |
|
588 | - break; |
|
586 | + case 'relationship': |
|
587 | + echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' ); |
|
588 | + break; |
|
589 | 589 | |
590 | - case 'date': |
|
591 | - echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) ); |
|
592 | - break; |
|
590 | + case 'date': |
|
591 | + echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) ); |
|
592 | + break; |
|
593 | 593 | |
594 | - case 'status': |
|
595 | - $status = $payment->get_status_nicename(); |
|
596 | - if ( is_admin() ) { |
|
597 | - $status = $payment->get_status_label_html(); |
|
598 | - } |
|
594 | + case 'status': |
|
595 | + $status = $payment->get_status_nicename(); |
|
596 | + if ( is_admin() ) { |
|
597 | + $status = $payment->get_status_label_html(); |
|
598 | + } |
|
599 | 599 | |
600 | - echo wp_kses_post( $status ); |
|
601 | - break; |
|
600 | + echo wp_kses_post( $status ); |
|
601 | + break; |
|
602 | 602 | |
603 | - case 'invoice': |
|
604 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
603 | + case 'invoice': |
|
604 | + $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
605 | 605 | |
606 | - if ( ! is_admin() ) { |
|
607 | - $link = esc_url( $payment->get_view_url() ); |
|
608 | - } |
|
606 | + if ( ! is_admin() ) { |
|
607 | + $link = esc_url( $payment->get_view_url() ); |
|
608 | + } |
|
609 | 609 | |
610 | - $invoice = esc_html( $payment->get_number() ); |
|
611 | - echo wp_kses_post( "<a href='$link'>$invoice</a>" ); |
|
612 | - break; |
|
613 | - } |
|
610 | + $invoice = esc_html( $payment->get_number() ); |
|
611 | + echo wp_kses_post( "<a href='$link'>$invoice</a>" ); |
|
612 | + break; |
|
613 | + } |
|
614 | 614 | |
615 | - echo '</td>'; |
|
615 | + echo '</td>'; |
|
616 | 616 | |
617 | - } |
|
617 | + } |
|
618 | 618 | |
619 | - echo '</tr>'; |
|
619 | + echo '</tr>'; |
|
620 | 620 | |
621 | - endforeach; |
|
622 | - ?> |
|
621 | + endforeach; |
|
622 | + ?> |
|
623 | 623 | |
624 | 624 | </tbody> |
625 | 625 | |
@@ -637,42 +637,42 @@ discard block |
||
637 | 637 | */ |
638 | 638 | function getpaid_admin_subscription_item_details_metabox( $subscription ) { |
639 | 639 | |
640 | - // Fetch the subscription group. |
|
641 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
640 | + // Fetch the subscription group. |
|
641 | + $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
642 | 642 | |
643 | - if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
644 | - return; |
|
645 | - } |
|
643 | + if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
644 | + return; |
|
645 | + } |
|
646 | 646 | |
647 | - // Prepare table columns. |
|
648 | - $columns = apply_filters( |
|
649 | - 'getpaid_subscription_item_details_columns', |
|
650 | - array( |
|
651 | - 'item_name' => __( 'Item', 'invoicing' ), |
|
652 | - 'price' => __( 'Price', 'invoicing' ), |
|
653 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
654 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
655 | - //'initial' => __( 'Initial Amount', 'invoicing' ), |
|
656 | - 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
657 | - ), |
|
658 | - $subscription |
|
659 | - ); |
|
647 | + // Prepare table columns. |
|
648 | + $columns = apply_filters( |
|
649 | + 'getpaid_subscription_item_details_columns', |
|
650 | + array( |
|
651 | + 'item_name' => __( 'Item', 'invoicing' ), |
|
652 | + 'price' => __( 'Price', 'invoicing' ), |
|
653 | + 'tax' => __( 'Tax', 'invoicing' ), |
|
654 | + 'discount' => __( 'Discount', 'invoicing' ), |
|
655 | + //'initial' => __( 'Initial Amount', 'invoicing' ), |
|
656 | + 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
657 | + ), |
|
658 | + $subscription |
|
659 | + ); |
|
660 | 660 | |
661 | - // Prepare the invoices. |
|
661 | + // Prepare the invoices. |
|
662 | 662 | |
663 | - $invoice = $subscription->get_parent_invoice(); |
|
663 | + $invoice = $subscription->get_parent_invoice(); |
|
664 | 664 | |
665 | - if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
666 | - unset( $columns['tax'] ); |
|
667 | - } |
|
665 | + if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
666 | + unset( $columns['tax'] ); |
|
667 | + } |
|
668 | 668 | |
669 | - $table_class = 'w-100 bg-white'; |
|
669 | + $table_class = 'w-100 bg-white'; |
|
670 | 670 | |
671 | - if ( ! is_admin() ) { |
|
672 | - $table_class = 'table table-bordered'; |
|
673 | - } |
|
671 | + if ( ! is_admin() ) { |
|
672 | + $table_class = 'table table-bordered'; |
|
673 | + } |
|
674 | 674 | |
675 | - ?> |
|
675 | + ?> |
|
676 | 676 | <div class="m-0" style="overflow: auto;"> |
677 | 677 | |
678 | 678 | <table class="<?php echo esc_attr( $table_class ); ?>"> |
@@ -681,10 +681,10 @@ discard block |
||
681 | 681 | <tr> |
682 | 682 | <?php |
683 | 683 | |
684 | - foreach ( $columns as $key => $label ) { |
|
685 | - echo "<th class='subscription-item-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
686 | - } |
|
687 | - ?> |
|
684 | + foreach ( $columns as $key => $label ) { |
|
685 | + echo "<th class='subscription-item-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
686 | + } |
|
687 | + ?> |
|
688 | 688 | </tr> |
689 | 689 | </thead> |
690 | 690 | |
@@ -692,106 +692,106 @@ discard block |
||
692 | 692 | |
693 | 693 | <?php |
694 | 694 | |
695 | - foreach ( $subscription_group['items'] as $subscription_group_item ) : |
|
695 | + foreach ( $subscription_group['items'] as $subscription_group_item ) : |
|
696 | 696 | |
697 | - echo '<tr>'; |
|
697 | + echo '<tr>'; |
|
698 | 698 | |
699 | - foreach ( array_keys( $columns ) as $key ) { |
|
699 | + foreach ( array_keys( $columns ) as $key ) { |
|
700 | 700 | |
701 | - $class = 'text-left'; |
|
701 | + $class = 'text-left'; |
|
702 | 702 | |
703 | - echo "<td class='p-2 text-left'>"; |
|
703 | + echo "<td class='p-2 text-left'>"; |
|
704 | 704 | |
705 | - switch ( $key ) { |
|
705 | + switch ( $key ) { |
|
706 | 706 | |
707 | - case 'item_name': |
|
708 | - $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
709 | - $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
707 | + case 'item_name': |
|
708 | + $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
709 | + $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
710 | 710 | |
711 | - if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
712 | - echo esc_html( $item_name ); |
|
713 | - } else { |
|
714 | - printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
715 | - } |
|
711 | + if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
712 | + echo esc_html( $item_name ); |
|
713 | + } else { |
|
714 | + printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
715 | + } |
|
716 | 716 | |
717 | - break; |
|
717 | + break; |
|
718 | 718 | |
719 | - case 'price': |
|
720 | - wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
721 | - break; |
|
719 | + case 'price': |
|
720 | + wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
721 | + break; |
|
722 | 722 | |
723 | - case 'tax': |
|
724 | - wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
725 | - break; |
|
723 | + case 'tax': |
|
724 | + wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
725 | + break; |
|
726 | 726 | |
727 | - case 'discount': |
|
728 | - wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
729 | - break; |
|
727 | + case 'discount': |
|
728 | + wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
729 | + break; |
|
730 | 730 | |
731 | - case 'initial': |
|
732 | - wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
733 | - break; |
|
731 | + case 'initial': |
|
732 | + wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
733 | + break; |
|
734 | 734 | |
735 | - case 'recurring': |
|
736 | - echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' ); |
|
737 | - break; |
|
735 | + case 'recurring': |
|
736 | + echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' ); |
|
737 | + break; |
|
738 | 738 | |
739 | - } |
|
739 | + } |
|
740 | 740 | |
741 | - echo '</td>'; |
|
741 | + echo '</td>'; |
|
742 | 742 | |
743 | - } |
|
743 | + } |
|
744 | 744 | |
745 | - echo '</tr>'; |
|
745 | + echo '</tr>'; |
|
746 | 746 | |
747 | - endforeach; |
|
747 | + endforeach; |
|
748 | 748 | |
749 | - foreach ( $subscription_group['fees'] as $subscription_group_fee ) : |
|
749 | + foreach ( $subscription_group['fees'] as $subscription_group_fee ) : |
|
750 | 750 | |
751 | - echo '<tr>'; |
|
751 | + echo '<tr>'; |
|
752 | 752 | |
753 | - foreach ( array_keys( $columns ) as $key ) { |
|
753 | + foreach ( array_keys( $columns ) as $key ) { |
|
754 | 754 | |
755 | - $class = 'text-left'; |
|
755 | + $class = 'text-left'; |
|
756 | 756 | |
757 | - echo "<td class='p-2 text-left'>"; |
|
757 | + echo "<td class='p-2 text-left'>"; |
|
758 | 758 | |
759 | - switch ( $key ) { |
|
759 | + switch ( $key ) { |
|
760 | 760 | |
761 | - case 'item_name': |
|
762 | - echo esc_html( $subscription_group_fee['name'] ); |
|
763 | - break; |
|
761 | + case 'item_name': |
|
762 | + echo esc_html( $subscription_group_fee['name'] ); |
|
763 | + break; |
|
764 | 764 | |
765 | - case 'price': |
|
766 | - wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
767 | - break; |
|
765 | + case 'price': |
|
766 | + wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
767 | + break; |
|
768 | 768 | |
769 | - case 'tax': |
|
770 | - echo '—'; |
|
771 | - break; |
|
769 | + case 'tax': |
|
770 | + echo '—'; |
|
771 | + break; |
|
772 | 772 | |
773 | - case 'discount': |
|
774 | - echo '—'; |
|
775 | - break; |
|
773 | + case 'discount': |
|
774 | + echo '—'; |
|
775 | + break; |
|
776 | 776 | |
777 | - case 'initial': |
|
778 | - wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
779 | - break; |
|
777 | + case 'initial': |
|
778 | + wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
779 | + break; |
|
780 | 780 | |
781 | - case 'recurring': |
|
782 | - echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' ); |
|
783 | - break; |
|
781 | + case 'recurring': |
|
782 | + echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' ); |
|
783 | + break; |
|
784 | 784 | |
785 | - } |
|
785 | + } |
|
786 | 786 | |
787 | - echo '</td>'; |
|
787 | + echo '</td>'; |
|
788 | 788 | |
789 | - } |
|
789 | + } |
|
790 | 790 | |
791 | - echo '</tr>'; |
|
791 | + echo '</tr>'; |
|
792 | 792 | |
793 | - endforeach; |
|
794 | - ?> |
|
793 | + endforeach; |
|
794 | + ?> |
|
795 | 795 | |
796 | 796 | </tbody> |
797 | 797 | |
@@ -810,38 +810,38 @@ discard block |
||
810 | 810 | */ |
811 | 811 | function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) { |
812 | 812 | |
813 | - // Fetch the subscription groups. |
|
814 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
815 | - |
|
816 | - if ( empty( $subscription_groups ) ) { |
|
817 | - return; |
|
818 | - } |
|
819 | - |
|
820 | - // Prepare table columns. |
|
821 | - $columns = apply_filters( |
|
822 | - 'getpaid_subscription_related_subscriptions_columns', |
|
823 | - array( |
|
824 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
825 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
826 | - 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
827 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
828 | - 'item' => __( 'Items', 'invoicing' ), |
|
829 | - 'status' => __( 'Status', 'invoicing' ), |
|
830 | - ), |
|
831 | - $subscription |
|
832 | - ); |
|
833 | - |
|
834 | - if ( $subscription->get_status() == 'pending' ) { |
|
835 | - unset( $columns['start_date'], $columns['renewal_date'] ); |
|
836 | - } |
|
837 | - |
|
838 | - $table_class = 'w-100 bg-white'; |
|
839 | - |
|
840 | - if ( ! is_admin() ) { |
|
841 | - $table_class = 'table table-bordered'; |
|
842 | - } |
|
843 | - |
|
844 | - ?> |
|
813 | + // Fetch the subscription groups. |
|
814 | + $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
815 | + |
|
816 | + if ( empty( $subscription_groups ) ) { |
|
817 | + return; |
|
818 | + } |
|
819 | + |
|
820 | + // Prepare table columns. |
|
821 | + $columns = apply_filters( |
|
822 | + 'getpaid_subscription_related_subscriptions_columns', |
|
823 | + array( |
|
824 | + 'subscription' => __( 'Subscription', 'invoicing' ), |
|
825 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
826 | + 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
827 | + 'renewals' => __( 'Payments', 'invoicing' ), |
|
828 | + 'item' => __( 'Items', 'invoicing' ), |
|
829 | + 'status' => __( 'Status', 'invoicing' ), |
|
830 | + ), |
|
831 | + $subscription |
|
832 | + ); |
|
833 | + |
|
834 | + if ( $subscription->get_status() == 'pending' ) { |
|
835 | + unset( $columns['start_date'], $columns['renewal_date'] ); |
|
836 | + } |
|
837 | + |
|
838 | + $table_class = 'w-100 bg-white'; |
|
839 | + |
|
840 | + if ( ! is_admin() ) { |
|
841 | + $table_class = 'table table-bordered'; |
|
842 | + } |
|
843 | + |
|
844 | + ?> |
|
845 | 845 | <div class="m-0" style="overflow: auto;"> |
846 | 846 | |
847 | 847 | <table class="<?php echo esc_attr( $table_class ); ?>"> |
@@ -850,10 +850,10 @@ discard block |
||
850 | 850 | <tr> |
851 | 851 | <?php |
852 | 852 | |
853 | - foreach ( $columns as $key => $label ) { |
|
854 | - echo "<th class='related-subscription-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
855 | - } |
|
856 | - ?> |
|
853 | + foreach ( $columns as $key => $label ) { |
|
854 | + echo "<th class='related-subscription-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
855 | + } |
|
856 | + ?> |
|
857 | 857 | </tr> |
858 | 858 | </thead> |
859 | 859 | |
@@ -861,74 +861,74 @@ discard block |
||
861 | 861 | |
862 | 862 | <?php |
863 | 863 | |
864 | - foreach ( $subscription_groups as $subscription_group ) : |
|
864 | + foreach ( $subscription_groups as $subscription_group ) : |
|
865 | 865 | |
866 | - // Do not list current subscription. |
|
867 | - if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
868 | - continue; |
|
869 | - } |
|
866 | + // Do not list current subscription. |
|
867 | + if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
868 | + continue; |
|
869 | + } |
|
870 | 870 | |
871 | - // Ensure the subscription exists. |
|
872 | - $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
871 | + // Ensure the subscription exists. |
|
872 | + $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
873 | 873 | |
874 | - if ( ! $_suscription->exists() ) { |
|
875 | - continue; |
|
876 | - } |
|
874 | + if ( ! $_suscription->exists() ) { |
|
875 | + continue; |
|
876 | + } |
|
877 | 877 | |
878 | - echo '<tr>'; |
|
878 | + echo '<tr>'; |
|
879 | 879 | |
880 | - foreach ( array_keys( $columns ) as $key ) { |
|
880 | + foreach ( array_keys( $columns ) as $key ) { |
|
881 | 881 | |
882 | - $class = 'text-left'; |
|
882 | + $class = 'text-left'; |
|
883 | 883 | |
884 | - echo "<td class='p-2 text-left'>"; |
|
884 | + echo "<td class='p-2 text-left'>"; |
|
885 | 885 | |
886 | - switch ( $key ) { |
|
886 | + switch ( $key ) { |
|
887 | 887 | |
888 | - case 'status': |
|
889 | - echo wp_kses_post( $_suscription->get_status_label_html() ); |
|
890 | - break; |
|
888 | + case 'status': |
|
889 | + echo wp_kses_post( $_suscription->get_status_label_html() ); |
|
890 | + break; |
|
891 | 891 | |
892 | - case 'item': |
|
893 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
894 | - echo wp_kses_post( implode( ' | ', $markup ) ); |
|
895 | - break; |
|
892 | + case 'item': |
|
893 | + $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
894 | + echo wp_kses_post( implode( ' | ', $markup ) ); |
|
895 | + break; |
|
896 | 896 | |
897 | - case 'renewals': |
|
898 | - $max_bills = $_suscription->get_bill_times(); |
|
899 | - echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
900 | - break; |
|
897 | + case 'renewals': |
|
898 | + $max_bills = $_suscription->get_bill_times(); |
|
899 | + echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
900 | + break; |
|
901 | 901 | |
902 | - case 'renewal_date': |
|
903 | - echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '—'; |
|
904 | - break; |
|
902 | + case 'renewal_date': |
|
903 | + echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '—'; |
|
904 | + break; |
|
905 | 905 | |
906 | - case 'start_date': |
|
907 | - echo 'pending' == $_suscription->get_status() ? '—' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) ); |
|
908 | - break; |
|
906 | + case 'start_date': |
|
907 | + echo 'pending' == $_suscription->get_status() ? '—' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) ); |
|
908 | + break; |
|
909 | 909 | |
910 | - case 'subscription': |
|
911 | - $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
912 | - printf( |
|
910 | + case 'subscription': |
|
911 | + $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
912 | + printf( |
|
913 | 913 | '%1$s#%2$s%3$s', |
914 | 914 | '<a href="' . esc_url( $url ) . '">', |
915 | 915 | '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
916 | - '</a>' |
|
916 | + '</a>' |
|
917 | 917 | ); |
918 | 918 | |
919 | - echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) ); |
|
920 | - break; |
|
919 | + echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) ); |
|
920 | + break; |
|
921 | 921 | |
922 | - } |
|
922 | + } |
|
923 | 923 | |
924 | - echo '</td>'; |
|
924 | + echo '</td>'; |
|
925 | 925 | |
926 | - } |
|
926 | + } |
|
927 | 927 | |
928 | - echo '</tr>'; |
|
928 | + echo '</tr>'; |
|
929 | 929 | |
930 | - endforeach; |
|
931 | - ?> |
|
930 | + endforeach; |
|
931 | + ?> |
|
932 | 932 | |
933 | 933 | </tbody> |
934 | 934 |
@@ -19,16 +19,16 @@ discard block |
||
19 | 19 | |
20 | 20 | // Define constants. |
21 | 21 | if ( ! defined( 'WPINV_PLUGIN_FILE' ) ) { |
22 | - define( 'WPINV_PLUGIN_FILE', __FILE__ ); |
|
22 | + define( 'WPINV_PLUGIN_FILE', __FILE__ ); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | if ( ! defined( 'WPINV_VERSION' ) ) { |
26 | - define( 'WPINV_VERSION', '2.8.8' ); |
|
26 | + define( 'WPINV_VERSION', '2.8.8' ); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | // Include the main Invoicing class. |
30 | 30 | if ( ! class_exists( 'WPInv_Plugin', false ) ) { |
31 | - require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php'; |
|
31 | + require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php'; |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | $GLOBALS['invoicing'] = new WPInv_Plugin(); |
44 | 44 | } |
45 | 45 | |
46 | - return $GLOBALS['invoicing']; |
|
46 | + return $GLOBALS['invoicing']; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |