@@ -8,23 +8,23 @@ discard block |
||
8 | 8 | */ |
9 | 9 | function wpinv_subscriptions_page() { |
10 | 10 | |
11 | - if ( ! empty( $_GET['id'] ) ) { |
|
11 | + if ( ! empty( $_GET['id'] ) ) { |
|
12 | 12 | |
13 | 13 | wpinv_recurring_subscription_details(); |
14 | 14 | |
15 | - return; |
|
15 | + return; |
|
16 | 16 | |
17 | - } |
|
18 | - ?> |
|
17 | + } |
|
18 | + ?> |
|
19 | 19 | <div class="wrap"> |
20 | 20 | |
21 | 21 | <h1> |
22 | 22 | <?php _e( 'Subscriptions', 'invoicing' ); ?> |
23 | 23 | </h1> |
24 | 24 | <?php |
25 | - $subscribers_table = new WPInv_Subscription_Reports_Table(); |
|
26 | - $subscribers_table->prepare_items(); |
|
27 | - ?> |
|
25 | + $subscribers_table = new WPInv_Subscription_Reports_Table(); |
|
26 | + $subscribers_table->prepare_items(); |
|
27 | + ?> |
|
28 | 28 | |
29 | 29 | <form id="subscribers-filter" method="get"> |
30 | 30 | |
@@ -47,24 +47,24 @@ discard block |
||
47 | 47 | */ |
48 | 48 | function wpinv_recurring_subscription_details() { |
49 | 49 | |
50 | - $render = true; |
|
50 | + $render = true; |
|
51 | 51 | |
52 | - if ( ! current_user_can( 'manage_invoicing' ) ) { |
|
53 | - die( __( 'You are not permitted to view this data.', 'invoicing' ) ); |
|
54 | - } |
|
52 | + if ( ! current_user_can( 'manage_invoicing' ) ) { |
|
53 | + die( __( 'You are not permitted to view this data.', 'invoicing' ) ); |
|
54 | + } |
|
55 | 55 | |
56 | - if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
56 | + if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
57 | 57 | die( __( 'Invalid subscription ID Provided.', 'invoicing' ) ); |
58 | - } |
|
58 | + } |
|
59 | 59 | |
60 | - $sub_id = (int) $_GET['id']; |
|
61 | - $sub = new WPInv_Subscription( $sub_id ); |
|
60 | + $sub_id = (int) $_GET['id']; |
|
61 | + $sub = new WPInv_Subscription( $sub_id ); |
|
62 | 62 | |
63 | - if ( empty( $sub ) ) { |
|
64 | - die( __( 'Invalid subscription ID Provided.', 'invoicing' ) ); |
|
65 | - } |
|
63 | + if ( empty( $sub ) ) { |
|
64 | + die( __( 'Invalid subscription ID Provided.', 'invoicing' ) ); |
|
65 | + } |
|
66 | 66 | |
67 | - ?> |
|
67 | + ?> |
|
68 | 68 | <div class="wrap"> |
69 | 69 | <h2><?php _e( 'Subscription Details', 'invoicing' ); ?></h2> |
70 | 70 | |
@@ -88,11 +88,11 @@ discard block |
||
88 | 88 | </td> |
89 | 89 | <td> |
90 | 90 | <?php |
91 | - $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $sub->period, $sub->frequency ); |
|
92 | - $billing = wpinv_price( wpinv_format_amount( $sub->recurring_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ) . ' / ' . $frequency; |
|
93 | - $initial = wpinv_price( wpinv_format_amount( $sub->initial_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ); |
|
94 | - printf( _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), $initial, $billing ); |
|
95 | - ?> |
|
91 | + $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $sub->period, $sub->frequency ); |
|
92 | + $billing = wpinv_price( wpinv_format_amount( $sub->recurring_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ) . ' / ' . $frequency; |
|
93 | + $initial = wpinv_price( wpinv_format_amount( $sub->initial_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ); |
|
94 | + printf( _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), $initial, $billing ); |
|
95 | + ?> |
|
96 | 96 | </td> |
97 | 97 | </tr> |
98 | 98 | <tr> |
@@ -134,9 +134,9 @@ discard block |
||
134 | 134 | |
135 | 135 | ?> |
136 | 136 | <a href="<?php echo esc_url( add_query_arg( array( |
137 | - 'post' => $sub->product_id, |
|
138 | - 'action' => 'edit' |
|
139 | - ), admin_url( 'post.php' ) ) ); ?>" target="_blank"><?php _e( 'View Item', 'invoicing' ) ; ?></a> |
|
137 | + 'post' => $sub->product_id, |
|
138 | + 'action' => 'edit' |
|
139 | + ), admin_url( 'post.php' ) ) ); ?>" target="_blank"><?php _e( 'View Item', 'invoicing' ) ; ?></a> |
|
140 | 140 | </td> |
141 | 141 | </tr> |
142 | 142 | <tr> |
@@ -299,56 +299,56 @@ discard block |
||
299 | 299 | */ |
300 | 300 | function wpinv_recurring_process_subscription_update() { |
301 | 301 | |
302 | - if( empty( $_POST['sub_id'] ) ) { |
|
303 | - return; |
|
304 | - } |
|
302 | + if( empty( $_POST['sub_id'] ) ) { |
|
303 | + return; |
|
304 | + } |
|
305 | 305 | |
306 | - if( empty( $_POST['wpinv_update_subscription'] ) ) { |
|
307 | - return; |
|
308 | - } |
|
306 | + if( empty( $_POST['wpinv_update_subscription'] ) ) { |
|
307 | + return; |
|
308 | + } |
|
309 | 309 | |
310 | - if( ! current_user_can( 'manage_invoicing') ) { |
|
311 | - return; |
|
312 | - } |
|
310 | + if( ! current_user_can( 'manage_invoicing') ) { |
|
311 | + return; |
|
312 | + } |
|
313 | 313 | |
314 | - if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
315 | - wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
316 | - } |
|
314 | + if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
315 | + wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
316 | + } |
|
317 | 317 | |
318 | - $profile_id = sanitize_text_field( $_POST['profile_id'] ); |
|
319 | - $transaction_id = sanitize_text_field( $_POST['transaction_id'] ); |
|
320 | - $product_id = absint( $_POST['product_id'] ); |
|
321 | - $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
322 | - $subscription->update( array( |
|
323 | - 'status' => sanitize_text_field( $_POST['status'] ), |
|
324 | - 'profile_id' => $profile_id, |
|
325 | - 'product_id' => $product_id, |
|
326 | - 'transaction_id' => $transaction_id, |
|
327 | - ) ); |
|
318 | + $profile_id = sanitize_text_field( $_POST['profile_id'] ); |
|
319 | + $transaction_id = sanitize_text_field( $_POST['transaction_id'] ); |
|
320 | + $product_id = absint( $_POST['product_id'] ); |
|
321 | + $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
322 | + $subscription->update( array( |
|
323 | + 'status' => sanitize_text_field( $_POST['status'] ), |
|
324 | + 'profile_id' => $profile_id, |
|
325 | + 'product_id' => $product_id, |
|
326 | + 'transaction_id' => $transaction_id, |
|
327 | + ) ); |
|
328 | 328 | |
329 | - $status = sanitize_text_field( $_POST['status'] ); |
|
329 | + $status = sanitize_text_field( $_POST['status'] ); |
|
330 | 330 | |
331 | - switch( $status ) { |
|
331 | + switch( $status ) { |
|
332 | 332 | |
333 | - case 'cancelled' : |
|
333 | + case 'cancelled' : |
|
334 | 334 | |
335 | - $subscription->cancel(); |
|
336 | - break; |
|
335 | + $subscription->cancel(); |
|
336 | + break; |
|
337 | 337 | |
338 | - case 'expired' : |
|
338 | + case 'expired' : |
|
339 | 339 | |
340 | - $subscription->expire(); |
|
341 | - break; |
|
340 | + $subscription->expire(); |
|
341 | + break; |
|
342 | 342 | |
343 | - case 'completed' : |
|
343 | + case 'completed' : |
|
344 | 344 | |
345 | - $subscription->complete(); |
|
346 | - break; |
|
345 | + $subscription->complete(); |
|
346 | + break; |
|
347 | 347 | |
348 | - } |
|
348 | + } |
|
349 | 349 | |
350 | - wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=updated&id=' . $subscription->id ) ); |
|
351 | - exit; |
|
350 | + wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=updated&id=' . $subscription->id ) ); |
|
351 | + exit; |
|
352 | 352 | |
353 | 353 | } |
354 | 354 | add_action( 'admin_init', 'wpinv_recurring_process_subscription_update', 1 ); |
@@ -362,30 +362,30 @@ discard block |
||
362 | 362 | */ |
363 | 363 | function wpinv_recurring_process_subscription_deletion() { |
364 | 364 | |
365 | - if( empty( $_POST['sub_id'] ) ) { |
|
366 | - return; |
|
367 | - } |
|
365 | + if( empty( $_POST['sub_id'] ) ) { |
|
366 | + return; |
|
367 | + } |
|
368 | 368 | |
369 | - if( empty( $_POST['wpinv_delete_subscription'] ) ) { |
|
370 | - return; |
|
371 | - } |
|
369 | + if( empty( $_POST['wpinv_delete_subscription'] ) ) { |
|
370 | + return; |
|
371 | + } |
|
372 | 372 | |
373 | - if( ! current_user_can( 'manage_invoicing') ) { |
|
374 | - return; |
|
375 | - } |
|
373 | + if( ! current_user_can( 'manage_invoicing') ) { |
|
374 | + return; |
|
375 | + } |
|
376 | 376 | |
377 | - if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
378 | - wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
379 | - } |
|
377 | + if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
378 | + wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
379 | + } |
|
380 | 380 | |
381 | - $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
381 | + $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
382 | 382 | |
383 | - delete_post_meta( $subscription->parent_payment_id, '_wpinv_subscription_payment' ); |
|
383 | + delete_post_meta( $subscription->parent_payment_id, '_wpinv_subscription_payment' ); |
|
384 | 384 | |
385 | - $subscription->delete(); |
|
385 | + $subscription->delete(); |
|
386 | 386 | |
387 | - wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=deleted' ) ); |
|
388 | - exit; |
|
387 | + wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=deleted' ) ); |
|
388 | + exit; |
|
389 | 389 | |
390 | 390 | } |
391 | 391 | add_action( 'admin_init', 'wpinv_recurring_process_subscription_deletion', 2 ); |