@@ -8,22 +8,22 @@ discard block |
||
8 | 8 | * @var WPInv_Invoice $invoice |
9 | 9 | */ |
10 | 10 | |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | 13 | // Totals rows. |
14 | -$totals = getpaid_invoice_totals_rows( $invoice ); |
|
14 | +$totals = getpaid_invoice_totals_rows($invoice); |
|
15 | 15 | |
16 | -do_action( 'getpaid_before_email_line_totals', $invoice, $totals ); |
|
16 | +do_action('getpaid_before_email_line_totals', $invoice, $totals); |
|
17 | 17 | |
18 | 18 | ?> |
19 | 19 | |
20 | 20 | |
21 | -<?php if ( has_action( 'wpinv_email_footer_buttons' ) ) : ?> |
|
21 | +<?php if (has_action('wpinv_email_footer_buttons')) : ?> |
|
22 | 22 | |
23 | 23 | <tr class="wpinv_cart_footer_row"> |
24 | 24 | |
25 | - <td colspan="<?php echo ( (int) $column_count ); ?>"> |
|
26 | - <?php do_action( 'wpinv_email_footer_buttons' ); ?> |
|
25 | + <td colspan="<?php echo ((int) $column_count); ?>"> |
|
26 | + <?php do_action('wpinv_email_footer_buttons'); ?> |
|
27 | 27 | </td> |
28 | 28 | |
29 | 29 | </tr> |
@@ -31,44 +31,44 @@ discard block |
||
31 | 31 | <?php endif; ?> |
32 | 32 | |
33 | 33 | |
34 | -<?php foreach ( $totals as $key => $label ) : ?> |
|
34 | +<?php foreach ($totals as $key => $label) : ?> |
|
35 | 35 | |
36 | - <tr class="wpinv_cart_footer_row wpinv_cart_<?php echo esc_html( $key ); ?>_row"> |
|
36 | + <tr class="wpinv_cart_footer_row wpinv_cart_<?php echo esc_html($key); ?>_row"> |
|
37 | 37 | |
38 | - <td colspan="<?php echo absint( ( $column_count - 1 ) ); ?>" class="wpinv_cart_<?php echo esc_html( $key ); ?>_label text-right"> |
|
39 | - <strong><?php echo esc_html( $label ); ?>:</strong> |
|
38 | + <td colspan="<?php echo absint(($column_count - 1)); ?>" class="wpinv_cart_<?php echo esc_html($key); ?>_label text-right"> |
|
39 | + <strong><?php echo esc_html($label); ?>:</strong> |
|
40 | 40 | </td> |
41 | 41 | |
42 | - <td class="wpinv_cart_<?php echo esc_html( $key ); ?> text-right"> |
|
42 | + <td class="wpinv_cart_<?php echo esc_html($key); ?> text-right"> |
|
43 | 43 | |
44 | 44 | <?php |
45 | 45 | |
46 | 46 | // Total tax. |
47 | - if ( 'tax' == $key ) { |
|
48 | - wpinv_the_price( $invoice->get_total_tax(), $invoice->get_currency() ); |
|
47 | + if ('tax' == $key) { |
|
48 | + wpinv_the_price($invoice->get_total_tax(), $invoice->get_currency()); |
|
49 | 49 | } |
50 | 50 | |
51 | - if ( 'fee' == $key ) { |
|
52 | - wpinv_the_price( $invoice->get_total_fees(), $invoice->get_currency() ); |
|
51 | + if ('fee' == $key) { |
|
52 | + wpinv_the_price($invoice->get_total_fees(), $invoice->get_currency()); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | // Total discount. |
56 | - if ( 'discount' == $key ) { |
|
57 | - wpinv_the_price( $invoice->get_total_discount(), $invoice->get_currency() ); |
|
56 | + if ('discount' == $key) { |
|
57 | + wpinv_the_price($invoice->get_total_discount(), $invoice->get_currency()); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | // Sub total. |
61 | - if ( 'subtotal' == $key ) { |
|
62 | - wpinv_the_price( $invoice->get_subtotal(), $invoice->get_currency() ); |
|
61 | + if ('subtotal' == $key) { |
|
62 | + wpinv_the_price($invoice->get_subtotal(), $invoice->get_currency()); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | // Total. |
66 | - if ( 'total' == $key ) { |
|
67 | - wpinv_the_price( $invoice->get_total(), $invoice->get_currency() ); |
|
66 | + if ('total' == $key) { |
|
67 | + wpinv_the_price($invoice->get_total(), $invoice->get_currency()); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | // Fires when printing a cart total in an email. |
71 | - do_action( "getpaid_email_cart_totals_$key", $invoice ); |
|
71 | + do_action("getpaid_email_cart_totals_$key", $invoice); |
|
72 | 72 | |
73 | 73 | ?> |
74 | 74 | |
@@ -80,4 +80,4 @@ discard block |
||
80 | 80 | |
81 | 81 | <?php |
82 | 82 | |
83 | - do_action( 'getpaid_after_email_line_totals', $invoice, $totals ); |
|
83 | + do_action('getpaid_after_email_line_totals', $invoice, $totals); |
@@ -30,40 +30,40 @@ |
||
30 | 30 | // Item name. |
31 | 31 | if ( 'name' == $column ) { |
32 | 32 | |
33 | - // Display the name. |
|
34 | - echo '<div class="wpinv_email_cart_item_title">' . esc_html( $item->get_name() ) . '</div>'; |
|
33 | + // Display the name. |
|
34 | + echo '<div class="wpinv_email_cart_item_title">' . esc_html( $item->get_name() ) . '</div>'; |
|
35 | 35 | |
36 | - // And an optional description. |
|
37 | - $description = $item->get_description(); |
|
36 | + // And an optional description. |
|
37 | + $description = $item->get_description(); |
|
38 | 38 | |
39 | - if ( ! empty( $description ) ) { |
|
40 | - echo "<p class='small'>" . wp_kses_post( $description ) . "</p>"; |
|
39 | + if ( ! empty( $description ) ) { |
|
40 | + echo "<p class='small'>" . wp_kses_post( $description ) . "</p>"; |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | |
44 | 44 | // Item price. |
45 | 45 | if ( 'price' == $column ) { |
46 | 46 | |
47 | - // Display the item price (or recurring price if this is a renewal invoice) |
|
48 | - $price = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price(); |
|
49 | - wpinv_the_price( $price, $invoice->get_currency() ); |
|
47 | + // Display the item price (or recurring price if this is a renewal invoice) |
|
48 | + $price = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price(); |
|
49 | + wpinv_the_price( $price, $invoice->get_currency() ); |
|
50 | 50 | |
51 | 51 | } |
52 | 52 | |
53 | 53 | // Item quantity. |
54 | 54 | if ( 'quantity' == $column ) { |
55 | - echo (float) $item->get_quantity(); |
|
55 | + echo (float) $item->get_quantity(); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | // Tax rate. |
59 | 59 | if ( 'tax_rate' == $column ) { |
60 | - echo floatval( round( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) ) . '%'; |
|
60 | + echo floatval( round( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) ) . '%'; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | // Item sub total. |
64 | 64 | if ( 'subtotal' == $column ) { |
65 | - $subtotal = $invoice->is_renewal() ? $item->get_recurring_sub_total() : $item->get_sub_total(); |
|
66 | - wpinv_the_price( $subtotal, $invoice->get_currency() ); |
|
65 | + $subtotal = $invoice->is_renewal() ? $item->get_recurring_sub_total() : $item->get_sub_total(); |
|
66 | + wpinv_the_price( $subtotal, $invoice->get_currency() ); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | // Fires when printing a line item column. |
@@ -10,64 +10,64 @@ discard block |
||
10 | 10 | * @var array $columns |
11 | 11 | */ |
12 | 12 | |
13 | -defined( 'ABSPATH' ) || exit; |
|
13 | +defined('ABSPATH') || exit; |
|
14 | 14 | |
15 | 15 | ?> |
16 | 16 | |
17 | -<?php do_action( 'getpaid_before_email_line_item', $invoice, $item ); ?> |
|
17 | +<?php do_action('getpaid_before_email_line_item', $invoice, $item); ?> |
|
18 | 18 | |
19 | -<tr class="wpinv_cart_item item-type-<?php echo sanitize_html_class( $item->get_type() ); ?>"> |
|
19 | +<tr class="wpinv_cart_item item-type-<?php echo sanitize_html_class($item->get_type()); ?>"> |
|
20 | 20 | |
21 | - <?php foreach ( array_keys( $columns ) as $column ) : ?> |
|
21 | + <?php foreach (array_keys($columns) as $column) : ?> |
|
22 | 22 | |
23 | - <td class="<?php echo 'name' == $column ? 'text-left' : 'text-right'; ?> wpinv_cart_item_<?php echo sanitize_html_class( $column ); ?>"> |
|
23 | + <td class="<?php echo 'name' == $column ? 'text-left' : 'text-right'; ?> wpinv_cart_item_<?php echo sanitize_html_class($column); ?>"> |
|
24 | 24 | |
25 | 25 | <?php |
26 | 26 | |
27 | 27 | // Fires before printing a line item column. |
28 | - do_action( "getpaid_email_line_item_before_$column", $item, $invoice ); |
|
28 | + do_action("getpaid_email_line_item_before_$column", $item, $invoice); |
|
29 | 29 | |
30 | 30 | // Item name. |
31 | - if ( 'name' == $column ) { |
|
31 | + if ('name' == $column) { |
|
32 | 32 | |
33 | 33 | // Display the name. |
34 | - echo '<div class="wpinv_email_cart_item_title">' . esc_html( $item->get_name() ) . '</div>'; |
|
34 | + echo '<div class="wpinv_email_cart_item_title">' . esc_html($item->get_name()) . '</div>'; |
|
35 | 35 | |
36 | 36 | // And an optional description. |
37 | 37 | $description = $item->get_description(); |
38 | 38 | |
39 | - if ( ! empty( $description ) ) { |
|
40 | - echo "<p class='small'>" . wp_kses_post( $description ) . "</p>"; |
|
39 | + if (!empty($description)) { |
|
40 | + echo "<p class='small'>" . wp_kses_post($description) . "</p>"; |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | |
44 | 44 | // Item price. |
45 | - if ( 'price' == $column ) { |
|
45 | + if ('price' == $column) { |
|
46 | 46 | |
47 | 47 | // Display the item price (or recurring price if this is a renewal invoice) |
48 | 48 | $price = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price(); |
49 | - wpinv_the_price( $price, $invoice->get_currency() ); |
|
49 | + wpinv_the_price($price, $invoice->get_currency()); |
|
50 | 50 | |
51 | 51 | } |
52 | 52 | |
53 | 53 | // Item quantity. |
54 | - if ( 'quantity' == $column ) { |
|
54 | + if ('quantity' == $column) { |
|
55 | 55 | echo (float) $item->get_quantity(); |
56 | 56 | } |
57 | 57 | |
58 | 58 | // Tax rate. |
59 | - if ( 'tax_rate' == $column ) { |
|
60 | - echo floatval( round( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) ) . '%'; |
|
59 | + if ('tax_rate' == $column) { |
|
60 | + echo floatval(round(getpaid_get_invoice_tax_rate($invoice, $item), 2)) . '%'; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | // Item sub total. |
64 | - if ( 'subtotal' == $column ) { |
|
64 | + if ('subtotal' == $column) { |
|
65 | 65 | $subtotal = $invoice->is_renewal() ? $item->get_recurring_sub_total() : $item->get_sub_total(); |
66 | - wpinv_the_price( $subtotal, $invoice->get_currency() ); |
|
66 | + wpinv_the_price($subtotal, $invoice->get_currency()); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | // Fires when printing a line item column. |
70 | - do_action( "getpaid_email_line_item_$column", $item, $invoice ); |
|
70 | + do_action("getpaid_email_line_item_$column", $item, $invoice); |
|
71 | 71 | |
72 | 72 | ?> |
73 | 73 | |
@@ -77,4 +77,4 @@ discard block |
||
77 | 77 | |
78 | 78 | </tr> |
79 | 79 | |
80 | -<?php do_action( 'getpaid_after_email_line_item', $invoice, $item ); ?> |
|
80 | +<?php do_action('getpaid_after_email_line_item', $invoice, $item); ?> |
@@ -7,21 +7,21 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | -do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
|
12 | +do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin); |
|
13 | 13 | |
14 | -do_action( 'wpinv_email_before_note_details', $invoice, $email_type, $sent_to_admin, $customer_note ); |
|
14 | +do_action('wpinv_email_before_note_details', $invoice, $email_type, $sent_to_admin, $customer_note); |
|
15 | 15 | |
16 | 16 | // Generate the custom message body. |
17 | -echo wp_kses_post( wptexturize( str_replace( '{customer_note}', $customer_note, $message_body ) ) ); |
|
17 | +echo wp_kses_post(wptexturize(str_replace('{customer_note}', $customer_note, $message_body))); |
|
18 | 18 | |
19 | -do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin ); |
|
19 | +do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin); |
|
20 | 20 | |
21 | -do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin ); |
|
21 | +do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin); |
|
22 | 22 | |
23 | -do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin ); |
|
23 | +do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin); |
|
24 | 24 | |
25 | -do_action( 'wpinv_email_after_note_details', $invoice, $email_type, $sent_to_admin, $customer_note ); |
|
25 | +do_action('wpinv_email_after_note_details', $invoice, $email_type, $sent_to_admin, $customer_note); |
|
26 | 26 | |
27 | -do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin ); |
|
27 | +do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin); |
@@ -30,21 +30,21 @@ discard block |
||
30 | 30 | // Item name. |
31 | 31 | if ( 'name' == $column ) { |
32 | 32 | |
33 | - // Display the name. |
|
34 | - echo '<div class="wpinv_email_cart_item_title">' . esc_html( $fee['name'] ) . '</div>'; |
|
33 | + // Display the name. |
|
34 | + echo '<div class="wpinv_email_cart_item_title">' . esc_html( $fee['name'] ) . '</div>'; |
|
35 | 35 | |
36 | - // And an optional description. |
|
37 | - $description = empty( $fee['description'] ) ? esc_html__( 'Fee', 'invoicing' ) : esc_html( $fee['description'] ); |
|
38 | - echo wp_kses_post( "<p class='small'>$description</p>" ); |
|
36 | + // And an optional description. |
|
37 | + $description = empty( $fee['description'] ) ? esc_html__( 'Fee', 'invoicing' ) : esc_html( $fee['description'] ); |
|
38 | + echo wp_kses_post( "<p class='small'>$description</p>" ); |
|
39 | 39 | |
40 | 40 | } |
41 | 41 | |
42 | 42 | // Item price. |
43 | 43 | if ( 'price' == $column ) { |
44 | 44 | |
45 | - // Display the item price (or recurring price if this is a renewal invoice) |
|
46 | - if ( $invoice->is_recurring() && $invoice->is_renewal() ) { |
|
47 | - wpinv_the_price( $fee['recurring_fee'], $invoice->get_currency() ); |
|
45 | + // Display the item price (or recurring price if this is a renewal invoice) |
|
46 | + if ( $invoice->is_recurring() && $invoice->is_renewal() ) { |
|
47 | + wpinv_the_price( $fee['recurring_fee'], $invoice->get_currency() ); |
|
48 | 48 | } else { |
49 | 49 | wpinv_the_price( $fee['initial_fee'], $invoice->get_currency() ); |
50 | 50 | } |
@@ -52,18 +52,18 @@ discard block |
||
52 | 52 | |
53 | 53 | // Item quantity. |
54 | 54 | if ( 'quantity' == $column ) { |
55 | - echo '—'; |
|
55 | + echo '—'; |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | // Item tax. |
59 | 59 | if ( 'tax_rate' == $column ) { |
60 | - echo '—'; |
|
60 | + echo '—'; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | // Item sub total. |
64 | 64 | if ( 'subtotal' == $column ) { |
65 | - if ( $invoice->is_recurring() && $invoice->is_renewal() ) { |
|
66 | - wpinv_the_price( $fee['recurring_fee'], $invoice->get_currency() ); |
|
65 | + if ( $invoice->is_recurring() && $invoice->is_renewal() ) { |
|
66 | + wpinv_the_price( $fee['recurring_fee'], $invoice->get_currency() ); |
|
67 | 67 | } else { |
68 | 68 | wpinv_the_price( $fee['initial_fee'], $invoice->get_currency() ); |
69 | 69 | } |
@@ -10,67 +10,67 @@ discard block |
||
10 | 10 | * @var array $columns |
11 | 11 | */ |
12 | 12 | |
13 | -defined( 'ABSPATH' ) || exit; |
|
13 | +defined('ABSPATH') || exit; |
|
14 | 14 | |
15 | 15 | ?> |
16 | 16 | |
17 | -<?php do_action( 'getpaid_before_email_fee_item', $invoice, $fee ); ?> |
|
17 | +<?php do_action('getpaid_before_email_fee_item', $invoice, $fee); ?> |
|
18 | 18 | |
19 | 19 | <tr class="wpinv_cart_item item-fee"> |
20 | 20 | |
21 | - <?php foreach ( array_keys( $columns ) as $column ) : ?> |
|
21 | + <?php foreach (array_keys($columns) as $column) : ?> |
|
22 | 22 | |
23 | - <td class="<?php echo 'name' == $column ? 'text-left' : 'text-right'; ?> wpinv_cart_item_<?php echo sanitize_html_class( $column ); ?>"> |
|
23 | + <td class="<?php echo 'name' == $column ? 'text-left' : 'text-right'; ?> wpinv_cart_item_<?php echo sanitize_html_class($column); ?>"> |
|
24 | 24 | |
25 | 25 | <?php |
26 | 26 | |
27 | 27 | // Fires before printing a fee item column. |
28 | - do_action( "getpaid_email_fee_item_before_$column", $fee, $invoice ); |
|
28 | + do_action("getpaid_email_fee_item_before_$column", $fee, $invoice); |
|
29 | 29 | |
30 | 30 | // Item name. |
31 | - if ( 'name' == $column ) { |
|
31 | + if ('name' == $column) { |
|
32 | 32 | |
33 | 33 | // Display the name. |
34 | - echo '<div class="wpinv_email_cart_item_title">' . esc_html( $fee['name'] ) . '</div>'; |
|
34 | + echo '<div class="wpinv_email_cart_item_title">' . esc_html($fee['name']) . '</div>'; |
|
35 | 35 | |
36 | 36 | // And an optional description. |
37 | - $description = empty( $fee['description'] ) ? esc_html__( 'Fee', 'invoicing' ) : esc_html( $fee['description'] ); |
|
38 | - echo wp_kses_post( "<p class='small'>$description</p>" ); |
|
37 | + $description = empty($fee['description']) ? esc_html__('Fee', 'invoicing') : esc_html($fee['description']); |
|
38 | + echo wp_kses_post("<p class='small'>$description</p>"); |
|
39 | 39 | |
40 | 40 | } |
41 | 41 | |
42 | 42 | // Item price. |
43 | - if ( 'price' == $column ) { |
|
43 | + if ('price' == $column) { |
|
44 | 44 | |
45 | 45 | // Display the item price (or recurring price if this is a renewal invoice) |
46 | - if ( $invoice->is_recurring() && $invoice->is_renewal() ) { |
|
47 | - wpinv_the_price( $fee['recurring_fee'], $invoice->get_currency() ); |
|
46 | + if ($invoice->is_recurring() && $invoice->is_renewal()) { |
|
47 | + wpinv_the_price($fee['recurring_fee'], $invoice->get_currency()); |
|
48 | 48 | } else { |
49 | - wpinv_the_price( $fee['initial_fee'], $invoice->get_currency() ); |
|
49 | + wpinv_the_price($fee['initial_fee'], $invoice->get_currency()); |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
53 | 53 | // Item quantity. |
54 | - if ( 'quantity' == $column ) { |
|
54 | + if ('quantity' == $column) { |
|
55 | 55 | echo '—'; |
56 | 56 | } |
57 | 57 | |
58 | 58 | // Item tax. |
59 | - if ( 'tax_rate' == $column ) { |
|
59 | + if ('tax_rate' == $column) { |
|
60 | 60 | echo '—'; |
61 | 61 | } |
62 | 62 | |
63 | 63 | // Item sub total. |
64 | - if ( 'subtotal' == $column ) { |
|
65 | - if ( $invoice->is_recurring() && $invoice->is_renewal() ) { |
|
66 | - wpinv_the_price( $fee['recurring_fee'], $invoice->get_currency() ); |
|
64 | + if ('subtotal' == $column) { |
|
65 | + if ($invoice->is_recurring() && $invoice->is_renewal()) { |
|
66 | + wpinv_the_price($fee['recurring_fee'], $invoice->get_currency()); |
|
67 | 67 | } else { |
68 | - wpinv_the_price( $fee['initial_fee'], $invoice->get_currency() ); |
|
68 | + wpinv_the_price($fee['initial_fee'], $invoice->get_currency()); |
|
69 | 69 | } |
70 | 70 | } |
71 | 71 | |
72 | 72 | // Fires when printing a line item column. |
73 | - do_action( "getpaid_email_fee_item_$column", $fee, $invoice ); |
|
73 | + do_action("getpaid_email_fee_item_$column", $fee, $invoice); |
|
74 | 74 | |
75 | 75 | ?> |
76 | 76 | |
@@ -80,4 +80,4 @@ discard block |
||
80 | 80 | |
81 | 81 | </tr> |
82 | 82 | |
83 | -<?php do_action( 'getpaid_after_email_fee_item', $invoice, $fee ); ?> |
|
83 | +<?php do_action('getpaid_after_email_fee_item', $invoice, $fee); ?> |
@@ -126,25 +126,25 @@ |
||
126 | 126 | |
127 | 127 | if ( ! empty( $invoice_actions ) ) { |
128 | 128 | |
129 | - echo '<div class="wpinv-receipt-actions text-right mt-1 mb-4">'; |
|
129 | + echo '<div class="wpinv-receipt-actions text-right mt-1 mb-4">'; |
|
130 | 130 | |
131 | - foreach ( $invoice_actions as $key => $invoice_action ) { |
|
131 | + foreach ( $invoice_actions as $key => $invoice_action ) { |
|
132 | 132 | |
133 | - $key = sanitize_html_class( $key ); |
|
134 | - $class = empty( $invoice_action['class'] ) ? 'btn-dark' : sanitize_html_class( $invoice_action['class'] ); |
|
135 | - $url = empty( $invoice_action['url'] ) ? '#' : esc_url( $invoice_action['url'] ); |
|
136 | - $attrs = empty( $invoice_action['attrs'] ) ? '' : $invoice_action['attrs']; |
|
137 | - $anchor = esc_html( $invoice_action['name'] ); |
|
133 | + $key = sanitize_html_class( $key ); |
|
134 | + $class = empty( $invoice_action['class'] ) ? 'btn-dark' : sanitize_html_class( $invoice_action['class'] ); |
|
135 | + $url = empty( $invoice_action['url'] ) ? '#' : esc_url( $invoice_action['url'] ); |
|
136 | + $attrs = empty( $invoice_action['attrs'] ) ? '' : $invoice_action['attrs']; |
|
137 | + $anchor = esc_html( $invoice_action['name'] ); |
|
138 | 138 | |
139 | - echo wp_kses_post( "<a href='$url' class='btn btn-sm ml-1 $class $key' $attrs>$anchor</a>" ); |
|
139 | + echo wp_kses_post( "<a href='$url' class='btn btn-sm ml-1 $class $key' $attrs>$anchor</a>" ); |
|
140 | 140 | } |
141 | 141 | |
142 | - echo '</div>'; |
|
142 | + echo '</div>'; |
|
143 | 143 | |
144 | 144 | } |
145 | 145 | |
146 | 146 | if ( ! empty( $alert ) ) { |
147 | - echo wp_kses_post( $alert ); |
|
147 | + echo wp_kses_post( $alert ); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | ?> |
@@ -7,64 +7,64 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | // Fetch the invoice. |
13 | -$invoice = new WPInv_Invoice( $invoice ); |
|
13 | +$invoice = new WPInv_Invoice($invoice); |
|
14 | 14 | |
15 | 15 | // @deprecated |
16 | -do_action( 'wpinv_success_content_before', $invoice ); |
|
17 | -do_action( 'wpinv_before_receipt', $invoice ); |
|
16 | +do_action('wpinv_success_content_before', $invoice); |
|
17 | +do_action('wpinv_before_receipt', $invoice); |
|
18 | 18 | |
19 | 19 | wpinv_print_errors(); |
20 | 20 | |
21 | 21 | // Prepare header text. |
22 | -if ( $invoice->is_paid() ) { |
|
22 | +if ($invoice->is_paid()) { |
|
23 | 23 | |
24 | 24 | $alert = aui()->alert( |
25 | 25 | array( |
26 | 26 | 'type' => 'success', |
27 | - 'content' => __( 'Thank you for your payment!', 'invoicing' ), |
|
27 | + 'content' => __('Thank you for your payment!', 'invoicing'), |
|
28 | 28 | ) |
29 | 29 | ); |
30 | 30 | |
31 | -} elseif ( $invoice->is_refunded() ) { |
|
31 | +} elseif ($invoice->is_refunded()) { |
|
32 | 32 | |
33 | 33 | $alert = aui()->alert( |
34 | 34 | array( |
35 | 35 | 'type' => 'info', |
36 | - 'content' => __( 'This invoice was refunded.', 'invoicing' ), |
|
36 | + 'content' => __('This invoice was refunded.', 'invoicing'), |
|
37 | 37 | ) |
38 | 38 | ); |
39 | 39 | |
40 | -} elseif ( $invoice->is_held() ) { |
|
40 | +} elseif ($invoice->is_held()) { |
|
41 | 41 | |
42 | 42 | $alert = aui()->alert( |
43 | 43 | array( |
44 | 44 | 'type' => 'info', |
45 | - 'content' => __( 'This invoice will be processed as soon we verify your payment.', 'invoicing' ), |
|
45 | + 'content' => __('This invoice will be processed as soon we verify your payment.', 'invoicing'), |
|
46 | 46 | ) |
47 | 47 | ); |
48 | 48 | |
49 | -} elseif ( $invoice->needs_payment() ) { |
|
49 | +} elseif ($invoice->needs_payment()) { |
|
50 | 50 | |
51 | - if ( ! empty( $_GET['token'] ) ) { |
|
51 | + if (!empty($_GET['token'])) { |
|
52 | 52 | |
53 | 53 | $alert = aui()->alert( |
54 | 54 | array( |
55 | 55 | 'type' => 'info', |
56 | - 'content' => __( "Sometimes it takes a few minutes for us to verify your payment. We'll notify you as soon as we've verified the payment.", 'invoicing' ), |
|
56 | + 'content' => __("Sometimes it takes a few minutes for us to verify your payment. We'll notify you as soon as we've verified the payment.", 'invoicing'), |
|
57 | 57 | ) |
58 | 58 | ); |
59 | 59 | |
60 | - } elseif ( $invoice->is_due() ) { |
|
60 | + } elseif ($invoice->is_due()) { |
|
61 | 61 | |
62 | 62 | $alert = aui()->alert( |
63 | 63 | array( |
64 | 64 | 'type' => 'danger', |
65 | 65 | 'content' => sprintf( |
66 | - __( 'This invoice was due on %.', 'invoicing' ), |
|
67 | - getpaid_format_date_value( $invoice->get_due_date() ) |
|
66 | + __('This invoice was due on %.', 'invoicing'), |
|
67 | + getpaid_format_date_value($invoice->get_due_date()) |
|
68 | 68 | ), |
69 | 69 | ) |
70 | 70 | ); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | $alert = aui()->alert( |
75 | 75 | array( |
76 | 76 | 'type' => 'warning', |
77 | - 'content' => __( 'This invoice needs payment.', 'invoicing' ), |
|
77 | + 'content' => __('This invoice needs payment.', 'invoicing'), |
|
78 | 78 | ) |
79 | 79 | ); |
80 | 80 | |
@@ -88,19 +88,19 @@ discard block |
||
88 | 88 | |
89 | 89 | 'pay' => array( |
90 | 90 | 'url' => $invoice->get_checkout_payment_url(), |
91 | - 'name' => __( 'Pay For Invoice', 'invoicing' ), |
|
91 | + 'name' => __('Pay For Invoice', 'invoicing'), |
|
92 | 92 | 'class' => 'btn-success', |
93 | 93 | ), |
94 | 94 | |
95 | 95 | 'view' => array( |
96 | 96 | 'url' => $invoice->get_view_url(), |
97 | - 'name' => __( 'View Invoice', 'invoicing' ), |
|
97 | + 'name' => __('View Invoice', 'invoicing'), |
|
98 | 98 | 'class' => 'btn-primary', |
99 | 99 | ), |
100 | 100 | |
101 | 101 | 'history' => array( |
102 | 102 | 'url' => wpinv_get_history_page_uri(), |
103 | - 'name' => __( 'Invoice History', 'invoicing' ), |
|
103 | + 'name' => __('Invoice History', 'invoicing'), |
|
104 | 104 | 'class' => 'btn-warning', |
105 | 105 | ), |
106 | 106 | |
@@ -108,12 +108,12 @@ discard block |
||
108 | 108 | $invoice |
109 | 109 | ); |
110 | 110 | |
111 | -if ( ( ! $invoice->needs_payment() || $invoice->is_held() ) && isset( $invoice_actions['pay'] ) ) { |
|
112 | - unset( $invoice_actions['pay'] ); |
|
111 | +if ((!$invoice->needs_payment() || $invoice->is_held()) && isset($invoice_actions['pay'])) { |
|
112 | + unset($invoice_actions['pay']); |
|
113 | 113 | } |
114 | 114 | |
115 | -if ( ! is_user_logged_in() && isset( $invoice_actions['history'] ) ) { |
|
116 | - unset( $invoice_actions['history'] ); |
|
115 | +if (!is_user_logged_in() && isset($invoice_actions['history'])) { |
|
116 | + unset($invoice_actions['history']); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | ?> |
@@ -122,29 +122,29 @@ discard block |
||
122 | 122 | |
123 | 123 | <?php |
124 | 124 | |
125 | - do_action( 'wpinv_receipt_start', $invoice ); |
|
125 | + do_action('wpinv_receipt_start', $invoice); |
|
126 | 126 | |
127 | - if ( ! empty( $invoice_actions ) ) { |
|
127 | + if (!empty($invoice_actions)) { |
|
128 | 128 | |
129 | 129 | echo '<div class="wpinv-receipt-actions text-right mt-1 mb-4">'; |
130 | 130 | |
131 | - foreach ( $invoice_actions as $key => $invoice_action ) { |
|
131 | + foreach ($invoice_actions as $key => $invoice_action) { |
|
132 | 132 | |
133 | - $key = sanitize_html_class( $key ); |
|
134 | - $class = empty( $invoice_action['class'] ) ? 'btn-dark' : sanitize_html_class( $invoice_action['class'] ); |
|
135 | - $url = empty( $invoice_action['url'] ) ? '#' : esc_url( $invoice_action['url'] ); |
|
136 | - $attrs = empty( $invoice_action['attrs'] ) ? '' : $invoice_action['attrs']; |
|
137 | - $anchor = esc_html( $invoice_action['name'] ); |
|
133 | + $key = sanitize_html_class($key); |
|
134 | + $class = empty($invoice_action['class']) ? 'btn-dark' : sanitize_html_class($invoice_action['class']); |
|
135 | + $url = empty($invoice_action['url']) ? '#' : esc_url($invoice_action['url']); |
|
136 | + $attrs = empty($invoice_action['attrs']) ? '' : $invoice_action['attrs']; |
|
137 | + $anchor = esc_html($invoice_action['name']); |
|
138 | 138 | |
139 | - echo wp_kses_post( "<a href='$url' class='btn btn-sm ml-1 $class $key' $attrs>$anchor</a>" ); |
|
139 | + echo wp_kses_post("<a href='$url' class='btn btn-sm ml-1 $class $key' $attrs>$anchor</a>"); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | echo '</div>'; |
143 | 143 | |
144 | 144 | } |
145 | 145 | |
146 | - if ( ! empty( $alert ) ) { |
|
147 | - echo wp_kses_post( $alert ); |
|
146 | + if (!empty($alert)) { |
|
147 | + echo wp_kses_post($alert); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | ?> |
@@ -152,19 +152,19 @@ discard block |
||
152 | 152 | <div class="wpinv-receipt-details"> |
153 | 153 | |
154 | 154 | <h4 class="wpinv-details-t mb-3 mt-3"> |
155 | - <?php echo esc_html( apply_filters( 'wpinv_receipt_details_title', __( 'Invoice Details', 'invoicing' ), $invoice ) ); ?> |
|
155 | + <?php echo esc_html(apply_filters('wpinv_receipt_details_title', __('Invoice Details', 'invoicing'), $invoice)); ?> |
|
156 | 156 | </h4> |
157 | 157 | |
158 | - <?php getpaid_invoice_meta( $invoice ); ?> |
|
158 | + <?php getpaid_invoice_meta($invoice); ?> |
|
159 | 159 | |
160 | 160 | </div> |
161 | 161 | |
162 | - <?php do_action( 'wpinv_receipt_end', $invoice ); ?> |
|
162 | + <?php do_action('wpinv_receipt_end', $invoice); ?> |
|
163 | 163 | |
164 | 164 | </div> |
165 | 165 | |
166 | 166 | <?php |
167 | 167 | |
168 | 168 | // @deprecated |
169 | -do_action( 'wpinv_success_content_after', $invoice ); |
|
170 | -do_action( 'wpinv_after_receipt', $invoice ); |
|
169 | +do_action('wpinv_success_content_after', $invoice); |
|
170 | +do_action('wpinv_after_receipt', $invoice); |
@@ -34,11 +34,11 @@ discard block |
||
34 | 34 | */ |
35 | 35 | function wpinv_get_capability( $capalibilty = 'manage_invoicing' ) { |
36 | 36 | |
37 | - if ( current_user_can( 'manage_options' ) ) { |
|
38 | - return 'manage_options'; |
|
39 | - }; |
|
37 | + if ( current_user_can( 'manage_options' ) ) { |
|
38 | + return 'manage_options'; |
|
39 | + }; |
|
40 | 40 | |
41 | - return $capalibilty; |
|
41 | + return $capalibilty; |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -62,10 +62,10 @@ discard block |
||
62 | 62 | // Prepare user values. |
63 | 63 | $prefix = preg_replace( '/\s+/', '', $prefix ); |
64 | 64 | $prefix = empty( $prefix ) ? $email : $prefix; |
65 | - $args = array( |
|
66 | - 'user_login' => wpinv_generate_user_name( $prefix ), |
|
67 | - 'user_pass' => wp_generate_password(), |
|
68 | - 'user_email' => $email, |
|
65 | + $args = array( |
|
66 | + 'user_login' => wpinv_generate_user_name( $prefix ), |
|
67 | + 'user_pass' => wp_generate_password(), |
|
68 | + 'user_email' => $email, |
|
69 | 69 | 'role' => 'subscriber', |
70 | 70 | ); |
71 | 71 | |
@@ -82,16 +82,16 @@ discard block |
||
82 | 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, '@' ); |
|
85 | + $prefix = strtok( $prefix, '@' ); |
|
86 | 86 | $prefix = trim( $prefix, '.' ); |
87 | 87 | |
88 | - // Sanitize the username. |
|
89 | - $prefix = sanitize_user( $prefix, true ); |
|
88 | + // Sanitize the username. |
|
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 ); |
|
94 | - } |
|
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 | + } |
|
95 | 95 | |
96 | 96 | $username = $prefix; |
97 | 97 | $postfix = 2; |
@@ -220,43 +220,43 @@ discard block |
||
220 | 220 | |
221 | 221 | foreach ( getpaid_user_address_fields() as $key => $label ) { |
222 | 222 | |
223 | - // Display the country. |
|
224 | - if ( 'country' == $key ) { |
|
225 | - |
|
226 | - aui()->select( |
|
227 | - array( |
|
228 | - 'options' => wpinv_get_country_list(), |
|
229 | - 'name' => 'getpaid_address[' . esc_attr( $key ) . ']', |
|
230 | - 'id' => 'wpinv-' . sanitize_html_class( $key ), |
|
231 | - 'value' => sanitize_text_field( getpaid_get_user_address_field( get_current_user_id(), $key ) ), |
|
232 | - 'placeholder' => $label, |
|
233 | - 'label' => wp_kses_post( $label ), |
|
234 | - 'label_type' => 'vertical', |
|
235 | - 'class' => 'getpaid-address-field', |
|
223 | + // Display the country. |
|
224 | + if ( 'country' == $key ) { |
|
225 | + |
|
226 | + aui()->select( |
|
227 | + array( |
|
228 | + 'options' => wpinv_get_country_list(), |
|
229 | + 'name' => 'getpaid_address[' . esc_attr( $key ) . ']', |
|
230 | + 'id' => 'wpinv-' . sanitize_html_class( $key ), |
|
231 | + 'value' => sanitize_text_field( getpaid_get_user_address_field( get_current_user_id(), $key ) ), |
|
232 | + 'placeholder' => $label, |
|
233 | + 'label' => wp_kses_post( $label ), |
|
234 | + 'label_type' => 'vertical', |
|
235 | + 'class' => 'getpaid-address-field', |
|
236 | 236 | ), |
237 | 237 | true |
238 | - ); |
|
239 | - |
|
240 | - } |
|
241 | - |
|
242 | - // Display the state. |
|
243 | - elseif ( 'state' == $key ) { |
|
244 | - |
|
245 | - getpaid_get_states_select_markup( |
|
246 | - getpaid_get_user_address_field( get_current_user_id(), 'country' ), |
|
247 | - getpaid_get_user_address_field( get_current_user_id(), 'state' ), |
|
248 | - $label, |
|
249 | - $label, |
|
250 | - '', |
|
251 | - false, |
|
252 | - '', |
|
253 | - 'getpaid_address[' . esc_attr( $key ) . ']', |
|
238 | + ); |
|
239 | + |
|
240 | + } |
|
241 | + |
|
242 | + // Display the state. |
|
243 | + elseif ( 'state' == $key ) { |
|
244 | + |
|
245 | + getpaid_get_states_select_markup( |
|
246 | + getpaid_get_user_address_field( get_current_user_id(), 'country' ), |
|
247 | + getpaid_get_user_address_field( get_current_user_id(), 'state' ), |
|
248 | + $label, |
|
249 | + $label, |
|
250 | + '', |
|
251 | + false, |
|
252 | + '', |
|
253 | + 'getpaid_address[' . esc_attr( $key ) . ']', |
|
254 | 254 | true |
255 | - ); |
|
255 | + ); |
|
256 | 256 | |
257 | 257 | } else { |
258 | 258 | |
259 | - aui()->input( |
|
259 | + aui()->input( |
|
260 | 260 | array( |
261 | 261 | 'name' => 'getpaid_address[' . esc_attr( $key ) . ']', |
262 | 262 | 'id' => 'wpinv-' . sanitize_html_class( $key ), |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | 'class' => 'getpaid-address-field', |
269 | 269 | ), |
270 | 270 | true |
271 | - ); |
|
271 | + ); |
|
272 | 272 | |
273 | 273 | } |
274 | 274 | } |
@@ -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 | |
@@ -200,11 +200,11 @@ discard block |
||
200 | 200 | */ |
201 | 201 | function getpaid_display_address_edit_tab() { |
202 | 202 | |
203 | - if ( 0 === get_current_user_id() ) { |
|
203 | + if (0 === get_current_user_id()) { |
|
204 | 204 | return '<div class="bsui">' . aui()->alert( |
205 | 205 | array( |
206 | 206 | 'type' => 'error', |
207 | - 'content' => __( 'Your must be logged in to view this section', 'invoicing' ), |
|
207 | + 'content' => __('Your must be logged in to view this section', 'invoicing'), |
|
208 | 208 | 'dismissible' => false, |
209 | 209 | ) |
210 | 210 | ) . '</div>'; |
@@ -218,19 +218,19 @@ discard block |
||
218 | 218 | |
219 | 219 | <?php |
220 | 220 | |
221 | - foreach ( getpaid_user_address_fields() as $key => $label ) { |
|
221 | + foreach (getpaid_user_address_fields() as $key => $label) { |
|
222 | 222 | |
223 | 223 | // Display the country. |
224 | - if ( 'country' == $key ) { |
|
224 | + if ('country' == $key) { |
|
225 | 225 | |
226 | 226 | aui()->select( |
227 | 227 | array( |
228 | 228 | 'options' => wpinv_get_country_list(), |
229 | - 'name' => 'getpaid_address[' . esc_attr( $key ) . ']', |
|
230 | - 'id' => 'wpinv-' . sanitize_html_class( $key ), |
|
231 | - 'value' => sanitize_text_field( getpaid_get_user_address_field( get_current_user_id(), $key ) ), |
|
229 | + 'name' => 'getpaid_address[' . esc_attr($key) . ']', |
|
230 | + 'id' => 'wpinv-' . sanitize_html_class($key), |
|
231 | + 'value' => sanitize_text_field(getpaid_get_user_address_field(get_current_user_id(), $key)), |
|
232 | 232 | 'placeholder' => $label, |
233 | - 'label' => wp_kses_post( $label ), |
|
233 | + 'label' => wp_kses_post($label), |
|
234 | 234 | 'label_type' => 'vertical', |
235 | 235 | 'class' => 'getpaid-address-field', |
236 | 236 | ), |
@@ -240,17 +240,17 @@ discard block |
||
240 | 240 | } |
241 | 241 | |
242 | 242 | // Display the state. |
243 | - elseif ( 'state' == $key ) { |
|
243 | + elseif ('state' == $key) { |
|
244 | 244 | |
245 | 245 | getpaid_get_states_select_markup( |
246 | - getpaid_get_user_address_field( get_current_user_id(), 'country' ), |
|
247 | - getpaid_get_user_address_field( get_current_user_id(), 'state' ), |
|
246 | + getpaid_get_user_address_field(get_current_user_id(), 'country'), |
|
247 | + getpaid_get_user_address_field(get_current_user_id(), 'state'), |
|
248 | 248 | $label, |
249 | 249 | $label, |
250 | 250 | '', |
251 | 251 | false, |
252 | 252 | '', |
253 | - 'getpaid_address[' . esc_attr( $key ) . ']', |
|
253 | + 'getpaid_address[' . esc_attr($key) . ']', |
|
254 | 254 | true |
255 | 255 | ); |
256 | 256 | |
@@ -258,13 +258,13 @@ discard block |
||
258 | 258 | |
259 | 259 | aui()->input( |
260 | 260 | array( |
261 | - 'name' => 'getpaid_address[' . esc_attr( $key ) . ']', |
|
262 | - 'id' => 'wpinv-' . sanitize_html_class( $key ), |
|
261 | + 'name' => 'getpaid_address[' . esc_attr($key) . ']', |
|
262 | + 'id' => 'wpinv-' . sanitize_html_class($key), |
|
263 | 263 | 'placeholder' => $label, |
264 | - 'label' => wp_kses_post( $label ), |
|
264 | + 'label' => wp_kses_post($label), |
|
265 | 265 | 'label_type' => 'vertical', |
266 | 266 | 'type' => 'text', |
267 | - 'value' => sanitize_text_field( getpaid_get_user_address_field( get_current_user_id(), $key ) ), |
|
267 | + 'value' => sanitize_text_field(getpaid_get_user_address_field(get_current_user_id(), $key)), |
|
268 | 268 | 'class' => 'getpaid-address-field', |
269 | 269 | ), |
270 | 270 | true |
@@ -278,32 +278,32 @@ discard block |
||
278 | 278 | 'name' => 'getpaid_address[email_cc]', |
279 | 279 | 'id' => 'wpinv-email_cc', |
280 | 280 | 'placeholder' => '[email protected], [email protected]', |
281 | - 'label' => __( 'Other email addresses', 'invoicing' ), |
|
281 | + 'label' => __('Other email addresses', 'invoicing'), |
|
282 | 282 | 'label_type' => 'vertical', |
283 | 283 | 'type' => 'text', |
284 | - 'value' => sanitize_text_field( get_user_meta( get_current_user_id(), '_wpinv_email_cc', true ) ), |
|
284 | + 'value' => sanitize_text_field(get_user_meta(get_current_user_id(), '_wpinv_email_cc', true)), |
|
285 | 285 | 'class' => 'getpaid-address-field', |
286 | - 'help_text' => __( 'Optionally provide other email addresses where we should send payment notifications', 'invoicing' ), |
|
286 | + 'help_text' => __('Optionally provide other email addresses where we should send payment notifications', 'invoicing'), |
|
287 | 287 | ), |
288 | 288 | true |
289 | 289 | ); |
290 | 290 | |
291 | - do_action( 'getpaid_display_address_edit_tab' ); |
|
291 | + do_action('getpaid_display_address_edit_tab'); |
|
292 | 292 | |
293 | 293 | aui()->input( |
294 | 294 | array( |
295 | 295 | 'name' => 'getpaid_profile_edit_submit_button', |
296 | 296 | 'id' => 'getpaid_profile_edit_submit_button', |
297 | - 'value' => __( 'Save Address', 'invoicing' ), |
|
298 | - 'help_text' => __( 'New invoices will use this address as the billing address.', 'invoicing' ), |
|
297 | + 'value' => __('Save Address', 'invoicing'), |
|
298 | + 'help_text' => __('New invoices will use this address as the billing address.', 'invoicing'), |
|
299 | 299 | 'type' => 'submit', |
300 | 300 | 'class' => 'btn btn-primary btn-block submit-button', |
301 | 301 | ), |
302 | 302 | true |
303 | 303 | ); |
304 | 304 | |
305 | - wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); |
|
306 | - getpaid_hidden_field( 'getpaid-action', 'edit_billing_details' ); |
|
305 | + wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); |
|
306 | + getpaid_hidden_field('getpaid-action', 'edit_billing_details'); |
|
307 | 307 | ?> |
308 | 308 | |
309 | 309 | </form> |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | |
314 | 314 | return ob_get_clean(); |
315 | 315 | } |
316 | -add_shortcode( 'getpaid_edit_address', 'getpaid_display_address_edit_tab' ); |
|
316 | +add_shortcode('getpaid_edit_address', 'getpaid_display_address_edit_tab'); |
|
317 | 317 | |
318 | 318 | /** |
319 | 319 | * Saves the billing address edit tab. |
@@ -321,30 +321,30 @@ discard block |
||
321 | 321 | * @since 2.1.4 |
322 | 322 | * @param array $data |
323 | 323 | */ |
324 | -function getpaid_save_address_edit_tab( $data ) { |
|
324 | +function getpaid_save_address_edit_tab($data) { |
|
325 | 325 | |
326 | - if ( empty( $data['getpaid_address'] ) || ! is_array( $data['getpaid_address'] ) ) { |
|
326 | + if (empty($data['getpaid_address']) || !is_array($data['getpaid_address'])) { |
|
327 | 327 | return; |
328 | 328 | } |
329 | 329 | |
330 | 330 | $data = $data['getpaid_address']; |
331 | 331 | $user_id = get_current_user_id(); |
332 | 332 | |
333 | - foreach ( array_keys( getpaid_user_address_fields() ) as $field ) { |
|
333 | + foreach (array_keys(getpaid_user_address_fields()) as $field) { |
|
334 | 334 | |
335 | - if ( isset( $data[ $field ] ) ) { |
|
336 | - $value = sanitize_text_field( $data[ $field ] ); |
|
337 | - update_user_meta( $user_id, '_wpinv_' . $field, $value ); |
|
335 | + if (isset($data[$field])) { |
|
336 | + $value = sanitize_text_field($data[$field]); |
|
337 | + update_user_meta($user_id, '_wpinv_' . $field, $value); |
|
338 | 338 | } |
339 | 339 | } |
340 | 340 | |
341 | - if ( isset( $data['email_cc'] ) ) { |
|
342 | - update_user_meta( $user_id, '_wpinv_email_cc', sanitize_text_field( $data['email_cc'] ) ); |
|
341 | + if (isset($data['email_cc'])) { |
|
342 | + update_user_meta($user_id, '_wpinv_email_cc', sanitize_text_field($data['email_cc'])); |
|
343 | 343 | } |
344 | 344 | |
345 | - wpinv_set_error( 'address_updated', __( 'Your billing address has been updated', 'invoicing' ), 'success' ); |
|
345 | + wpinv_set_error('address_updated', __('Your billing address has been updated', 'invoicing'), 'success'); |
|
346 | 346 | } |
347 | -add_action( 'getpaid_authenticated_action_edit_billing_details', 'getpaid_save_address_edit_tab' ); |
|
347 | +add_action('getpaid_authenticated_action_edit_billing_details', 'getpaid_save_address_edit_tab'); |
|
348 | 348 | |
349 | 349 | |
350 | 350 | /* |
@@ -362,27 +362,27 @@ discard block |
||
362 | 362 | * @param array $tabs |
363 | 363 | * @return array |
364 | 364 | */ |
365 | -function getpaid_filter_userswp_account_tabs( $tabs ) { |
|
365 | +function getpaid_filter_userswp_account_tabs($tabs) { |
|
366 | 366 | |
367 | 367 | // Abort if the integration is inactive. |
368 | - if ( ! getpaid_is_userswp_integration_active() ) { |
|
368 | + if (!getpaid_is_userswp_integration_active()) { |
|
369 | 369 | return $tabs; |
370 | 370 | } |
371 | 371 | |
372 | - $new_tabs = array(); |
|
372 | + $new_tabs = array(); |
|
373 | 373 | |
374 | - foreach ( getpaid_get_user_content_tabs() as $slug => $tab ) { |
|
374 | + foreach (getpaid_get_user_content_tabs() as $slug => $tab) { |
|
375 | 375 | |
376 | - $new_tabs[ $slug ] = array( |
|
376 | + $new_tabs[$slug] = array( |
|
377 | 377 | 'title' => $tab['label'], |
378 | 378 | 'icon' => $tab['icon'], |
379 | 379 | ); |
380 | 380 | |
381 | 381 | } |
382 | 382 | |
383 | - return array_merge( $tabs, $new_tabs ); |
|
383 | + return array_merge($tabs, $new_tabs); |
|
384 | 384 | } |
385 | -add_filter( 'uwp_account_available_tabs', 'getpaid_filter_userswp_account_tabs' ); |
|
385 | +add_filter('uwp_account_available_tabs', 'getpaid_filter_userswp_account_tabs'); |
|
386 | 386 | |
387 | 387 | /** |
388 | 388 | * Display our UsersWP account tabs. |
@@ -391,18 +391,18 @@ discard block |
||
391 | 391 | * @param array $tabs |
392 | 392 | * @return array |
393 | 393 | */ |
394 | -function getpaid_display_userswp_account_tabs( $tab ) { |
|
394 | +function getpaid_display_userswp_account_tabs($tab) { |
|
395 | 395 | global $getpaid_tab_url; |
396 | 396 | |
397 | 397 | $our_tabs = getpaid_get_user_content_tabs(); |
398 | 398 | |
399 | - if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) { |
|
400 | - $getpaid_tab_url = add_query_arg( 'type', '%s', uwp_get_account_page_url() ); |
|
401 | - echo getpaid_prepare_user_content_tab( $our_tabs[ $tab ] ); |
|
399 | + if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) { |
|
400 | + $getpaid_tab_url = add_query_arg('type', '%s', uwp_get_account_page_url()); |
|
401 | + echo getpaid_prepare_user_content_tab($our_tabs[$tab]); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | } |
405 | -add_action( 'uwp_account_form_display', 'getpaid_display_userswp_account_tabs' ); |
|
405 | +add_action('uwp_account_form_display', 'getpaid_display_userswp_account_tabs'); |
|
406 | 406 | |
407 | 407 | |
408 | 408 | /** |
@@ -413,17 +413,17 @@ discard block |
||
413 | 413 | * @param string $tab Current tab. |
414 | 414 | * @return string Title. |
415 | 415 | */ |
416 | -function getpaid_filter_userswp_account_title( $title, $tab ) { |
|
416 | +function getpaid_filter_userswp_account_title($title, $tab) { |
|
417 | 417 | |
418 | - $our_tabs = getpaid_get_user_content_tabs(); |
|
418 | + $our_tabs = getpaid_get_user_content_tabs(); |
|
419 | 419 | |
420 | - if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) { |
|
421 | - return $our_tabs[ $tab ]['label']; |
|
420 | + if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) { |
|
421 | + return $our_tabs[$tab]['label']; |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | return $title; |
425 | 425 | } |
426 | -add_filter( 'uwp_account_page_title', 'getpaid_filter_userswp_account_title', 10, 2 ); |
|
426 | +add_filter('uwp_account_page_title', 'getpaid_filter_userswp_account_title', 10, 2); |
|
427 | 427 | |
428 | 428 | /** |
429 | 429 | * Registers the UsersWP integration settings. |
@@ -432,26 +432,26 @@ discard block |
||
432 | 432 | * @param array $settings An array of integration settings. |
433 | 433 | * @return array |
434 | 434 | */ |
435 | -function getpaid_register_userswp_settings( $settings ) { |
|
435 | +function getpaid_register_userswp_settings($settings) { |
|
436 | 436 | |
437 | - if ( defined( 'USERSWP_PLUGIN_FILE' ) ) { |
|
437 | + if (defined('USERSWP_PLUGIN_FILE')) { |
|
438 | 438 | |
439 | 439 | $settings[] = array( |
440 | 440 | |
441 | 441 | 'id' => 'userswp', |
442 | - 'label' => __( 'UsersWP', 'invoicing' ), |
|
442 | + 'label' => __('UsersWP', 'invoicing'), |
|
443 | 443 | 'settings' => array( |
444 | 444 | |
445 | 445 | 'userswp_settings' => array( |
446 | 446 | 'id' => 'userswp_settings', |
447 | - 'name' => '<h3>' . __( 'UsersWP', 'invoicing' ) . '</h3>', |
|
447 | + 'name' => '<h3>' . __('UsersWP', 'invoicing') . '</h3>', |
|
448 | 448 | 'type' => 'header', |
449 | 449 | ), |
450 | 450 | |
451 | 451 | 'enable_userswp' => array( |
452 | 452 | 'id' => 'enable_userswp', |
453 | - 'name' => __( 'Enable Integration', 'invoicing' ), |
|
454 | - 'desc' => __( 'Display GetPaid items on UsersWP account page.', 'invoicing' ), |
|
453 | + 'name' => __('Enable Integration', 'invoicing'), |
|
454 | + 'desc' => __('Display GetPaid items on UsersWP account page.', 'invoicing'), |
|
455 | 455 | 'type' => 'checkbox', |
456 | 456 | 'std' => 1, |
457 | 457 | ), |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | |
465 | 465 | return $settings; |
466 | 466 | } |
467 | -add_filter( 'getpaid_integration_settings', 'getpaid_register_userswp_settings' ); |
|
467 | +add_filter('getpaid_integration_settings', 'getpaid_register_userswp_settings'); |
|
468 | 468 | |
469 | 469 | /** |
470 | 470 | * Ovewrites the invoices history page to UsersWP. |
@@ -472,18 +472,18 @@ discard block |
||
472 | 472 | * @since 2.3.1 |
473 | 473 | * @return bool |
474 | 474 | */ |
475 | -function getpaid_userswp_overwrite_invoice_history_page( $url, $post_type ) { |
|
475 | +function getpaid_userswp_overwrite_invoice_history_page($url, $post_type) { |
|
476 | 476 | |
477 | 477 | $our_tabs = getpaid_get_user_content_tabs(); |
478 | 478 | $tab = "gp-{$post_type}s"; |
479 | - if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) { |
|
480 | - return add_query_arg( 'type', $tab, uwp_get_account_page_url() ); |
|
479 | + if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) { |
|
480 | + return add_query_arg('type', $tab, uwp_get_account_page_url()); |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | return $url; |
484 | 484 | |
485 | 485 | } |
486 | -add_filter( 'wpinv_get_history_page_uri', 'getpaid_userswp_overwrite_invoice_history_page', 10, 2 ); |
|
486 | +add_filter('wpinv_get_history_page_uri', 'getpaid_userswp_overwrite_invoice_history_page', 10, 2); |
|
487 | 487 | |
488 | 488 | /** |
489 | 489 | * Checks if the integration is enabled. |
@@ -492,8 +492,8 @@ discard block |
||
492 | 492 | * @return bool |
493 | 493 | */ |
494 | 494 | function getpaid_is_userswp_integration_active() { |
495 | - $enabled = wpinv_get_option( 'enable_userswp', 1 ); |
|
496 | - return defined( 'USERSWP_PLUGIN_FILE' ) && ! empty( $enabled ); |
|
495 | + $enabled = wpinv_get_option('enable_userswp', 1); |
|
496 | + return defined('USERSWP_PLUGIN_FILE') && !empty($enabled); |
|
497 | 497 | } |
498 | 498 | |
499 | 499 | /* |
@@ -511,26 +511,26 @@ discard block |
||
511 | 511 | * @param array $settings An array of integration settings. |
512 | 512 | * @return array |
513 | 513 | */ |
514 | -function getpaid_register_buddypress_settings( $settings ) { |
|
514 | +function getpaid_register_buddypress_settings($settings) { |
|
515 | 515 | |
516 | - if ( class_exists( 'BuddyPress' ) ) { |
|
516 | + if (class_exists('BuddyPress')) { |
|
517 | 517 | |
518 | 518 | $settings[] = array( |
519 | 519 | |
520 | 520 | 'id' => 'buddypress', |
521 | - 'label' => __( 'BuddyPress', 'invoicing' ), |
|
521 | + 'label' => __('BuddyPress', 'invoicing'), |
|
522 | 522 | 'settings' => array( |
523 | 523 | |
524 | 524 | 'buddypress_settings' => array( |
525 | 525 | 'id' => 'buddypress_settings', |
526 | - 'name' => '<h3>' . __( 'BuddyPress', 'invoicing' ) . '</h3>', |
|
526 | + 'name' => '<h3>' . __('BuddyPress', 'invoicing') . '</h3>', |
|
527 | 527 | 'type' => 'header', |
528 | 528 | ), |
529 | 529 | |
530 | 530 | 'enable_buddypress' => array( |
531 | 531 | 'id' => 'enable_buddypress', |
532 | - 'name' => __( 'Enable Integration', 'invoicing' ), |
|
533 | - 'desc' => __( 'Display GetPaid items on BuddyPress account pages.', 'invoicing' ), |
|
532 | + 'name' => __('Enable Integration', 'invoicing'), |
|
533 | + 'desc' => __('Display GetPaid items on BuddyPress account pages.', 'invoicing'), |
|
534 | 534 | 'type' => 'checkbox', |
535 | 535 | 'std' => 1, |
536 | 536 | ), |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | |
544 | 544 | return $settings; |
545 | 545 | } |
546 | -add_filter( 'getpaid_integration_settings', 'getpaid_register_buddypress_settings' ); |
|
546 | +add_filter('getpaid_integration_settings', 'getpaid_register_buddypress_settings'); |
|
547 | 547 | |
548 | 548 | /** |
549 | 549 | * Checks if the integration is enabled. |
@@ -552,8 +552,8 @@ discard block |
||
552 | 552 | * @return bool |
553 | 553 | */ |
554 | 554 | function getpaid_is_buddypress_integration_active() { |
555 | - $enabled = wpinv_get_option( 'enable_buddypress', 1 ); |
|
556 | - return class_exists( 'BuddyPress' ) && ! empty( $enabled ); |
|
555 | + $enabled = wpinv_get_option('enable_buddypress', 1); |
|
556 | + return class_exists('BuddyPress') && !empty($enabled); |
|
557 | 557 | } |
558 | 558 | |
559 | 559 | /** |
@@ -564,10 +564,10 @@ discard block |
||
564 | 564 | */ |
565 | 565 | function getpaid_setup_buddypress_integration() { |
566 | 566 | |
567 | - if ( getpaid_is_buddypress_integration_active() ) { |
|
567 | + if (getpaid_is_buddypress_integration_active()) { |
|
568 | 568 | require_once WPINV_PLUGIN_DIR . 'includes/class-bp-getpaid-component.php'; |
569 | 569 | buddypress()->getpaid = new BP_GetPaid_Component(); |
570 | 570 | } |
571 | 571 | |
572 | 572 | } |
573 | -add_action( 'bp_setup_components', 'getpaid_setup_buddypress_integration' ); |
|
573 | +add_action('bp_setup_components', 'getpaid_setup_buddypress_integration'); |
@@ -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,44 +157,44 @@ 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' => __( 'Payments', 'invoicing' ), |
|
174 | - 'item' => _n( 'Item', 'Items', $items_count, '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 | - } |
|
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' => __( 'Payments', 'invoicing' ), |
|
174 | + 'item' => _n( 'Item', 'Items', $items_count, '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 | 190 | } |
191 | 191 | |
192 | - $profile_id = $sub->get_profile_id(); |
|
193 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
194 | - unset( $fields['profile_id'] ); |
|
195 | - } |
|
192 | + $profile_id = $sub->get_profile_id(); |
|
193 | + if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
194 | + unset( $fields['profile_id'] ); |
|
195 | + } |
|
196 | 196 | |
197 | - ?> |
|
197 | + ?> |
|
198 | 198 | |
199 | 199 | <table class="table table-borderless" style="font-size: 14px;"> |
200 | 200 | <tbody> |
@@ -228,20 +228,20 @@ discard block |
||
228 | 228 | */ |
229 | 229 | function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
230 | 230 | |
231 | - $username = __( '(Missing User)', 'invoicing' ); |
|
231 | + $username = __( '(Missing User)', 'invoicing' ); |
|
232 | 232 | |
233 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
234 | - if ( $user ) { |
|
233 | + $user = get_userdata( $subscription->get_customer_id() ); |
|
234 | + if ( $user ) { |
|
235 | 235 | |
236 | - $username = sprintf( |
|
237 | - '<a href="user-edit.php?user_id=%s">%s</a>', |
|
238 | - absint( $user->ID ), |
|
239 | - ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email ) |
|
240 | - ); |
|
236 | + $username = sprintf( |
|
237 | + '<a href="user-edit.php?user_id=%s">%s</a>', |
|
238 | + absint( $user->ID ), |
|
239 | + ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email ) |
|
240 | + ); |
|
241 | 241 | |
242 | - } |
|
242 | + } |
|
243 | 243 | |
244 | - echo wp_kses_post( $username ); |
|
244 | + echo wp_kses_post( $username ); |
|
245 | 245 | } |
246 | 246 | add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
247 | 247 | |
@@ -251,8 +251,8 @@ discard block |
||
251 | 251 | * @param WPInv_Subscription $subscription |
252 | 252 | */ |
253 | 253 | function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
254 | - $amount = getpaid_get_formatted_subscription_amount( $subscription ); |
|
255 | - echo wp_kses_post( "<span>$amount</span>" ); |
|
254 | + $amount = getpaid_get_formatted_subscription_amount( $subscription ); |
|
255 | + echo wp_kses_post( "<span>$amount</span>" ); |
|
256 | 256 | } |
257 | 257 | add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
258 | 258 | |
@@ -263,11 +263,11 @@ discard block |
||
263 | 263 | */ |
264 | 264 | function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
265 | 265 | |
266 | - printf( |
|
267 | - '<a href="%s">#%s</a>', |
|
268 | - esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ), |
|
269 | - absint( $subscription->get_id() ) |
|
270 | - ); |
|
266 | + printf( |
|
267 | + '<a href="%s">#%s</a>', |
|
268 | + esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ), |
|
269 | + absint( $subscription->get_id() ) |
|
270 | + ); |
|
271 | 271 | |
272 | 272 | } |
273 | 273 | add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * @param WPInv_Subscription $subscription |
279 | 279 | */ |
280 | 280 | function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
281 | - echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) ); |
|
281 | + echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) ); |
|
282 | 282 | } |
283 | 283 | add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
284 | 284 | |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | * @param WPInv_Subscription $subscription |
289 | 289 | */ |
290 | 290 | function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
291 | - echo esc_html( getpaid_format_date_value( $subscription->get_expiration() ) ); |
|
291 | + echo esc_html( getpaid_format_date_value( $subscription->get_expiration() ) ); |
|
292 | 292 | } |
293 | 293 | add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
294 | 294 | |
@@ -298,8 +298,8 @@ discard block |
||
298 | 298 | * @param WPInv_Subscription $subscription |
299 | 299 | */ |
300 | 300 | function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
301 | - $max_bills = $subscription->get_bill_times(); |
|
302 | - echo ( (int) $subscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
301 | + $max_bills = $subscription->get_bill_times(); |
|
302 | + echo ( (int) $subscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
303 | 303 | } |
304 | 304 | add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
305 | 305 | /** |
@@ -310,13 +310,13 @@ discard block |
||
310 | 310 | */ |
311 | 311 | function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) { |
312 | 312 | |
313 | - if ( empty( $subscription_group ) ) { |
|
314 | - echo WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ); |
|
315 | - return; |
|
316 | - } |
|
313 | + if ( empty( $subscription_group ) ) { |
|
314 | + echo WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ); |
|
315 | + return; |
|
316 | + } |
|
317 | 317 | |
318 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
319 | - echo wp_kses_post( implode( ' | ', $markup ) ); |
|
318 | + $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
319 | + echo wp_kses_post( implode( ' | ', $markup ) ); |
|
320 | 320 | |
321 | 321 | } |
322 | 322 | add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 ); |
@@ -328,13 +328,13 @@ discard block |
||
328 | 328 | */ |
329 | 329 | function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
330 | 330 | |
331 | - $gateway = $subscription->get_gateway(); |
|
331 | + $gateway = $subscription->get_gateway(); |
|
332 | 332 | |
333 | - if ( ! empty( $gateway ) ) { |
|
334 | - echo esc_html( wpinv_get_gateway_admin_label( $gateway ) ); |
|
335 | - } else { |
|
336 | - echo '—'; |
|
337 | - } |
|
333 | + if ( ! empty( $gateway ) ) { |
|
334 | + echo esc_html( wpinv_get_gateway_admin_label( $gateway ) ); |
|
335 | + } else { |
|
336 | + echo '—'; |
|
337 | + } |
|
338 | 338 | |
339 | 339 | } |
340 | 340 | add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | * @param WPInv_Subscription $subscription |
346 | 346 | */ |
347 | 347 | function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
348 | - echo wp_kses_post( $subscription->get_status_label_html() ); |
|
348 | + echo wp_kses_post( $subscription->get_status_label_html() ); |
|
349 | 349 | } |
350 | 350 | add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
351 | 351 | |
@@ -356,28 +356,28 @@ discard block |
||
356 | 356 | */ |
357 | 357 | function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
358 | 358 | |
359 | - $profile_id = $subscription->get_profile_id(); |
|
360 | - |
|
361 | - $input = aui()->input( |
|
362 | - array( |
|
363 | - 'type' => 'text', |
|
364 | - 'id' => 'wpinv_subscription_profile_id', |
|
365 | - 'name' => 'wpinv_subscription_profile_id', |
|
366 | - 'label' => __( 'Profile Id', 'invoicing' ), |
|
367 | - 'label_type' => 'hidden', |
|
368 | - 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
369 | - 'value' => esc_attr( $profile_id ), |
|
370 | - 'input_group_right' => '', |
|
371 | - 'no_wrap' => true, |
|
372 | - ) |
|
373 | - ); |
|
374 | - |
|
375 | - echo str_ireplace( 'form-control', 'regular-text', $input ); |
|
376 | - |
|
377 | - $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
378 | - if ( ! empty( $url ) ) { |
|
379 | - echo ' <a href="' . esc_url_raw( $url ) . '" title="' . __( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
380 | - } |
|
359 | + $profile_id = $subscription->get_profile_id(); |
|
360 | + |
|
361 | + $input = aui()->input( |
|
362 | + array( |
|
363 | + 'type' => 'text', |
|
364 | + 'id' => 'wpinv_subscription_profile_id', |
|
365 | + 'name' => 'wpinv_subscription_profile_id', |
|
366 | + 'label' => __( 'Profile Id', 'invoicing' ), |
|
367 | + 'label_type' => 'hidden', |
|
368 | + 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
369 | + 'value' => esc_attr( $profile_id ), |
|
370 | + 'input_group_right' => '', |
|
371 | + 'no_wrap' => true, |
|
372 | + ) |
|
373 | + ); |
|
374 | + |
|
375 | + echo str_ireplace( 'form-control', 'regular-text', $input ); |
|
376 | + |
|
377 | + $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
378 | + if ( ! empty( $url ) ) { |
|
379 | + echo ' <a href="' . esc_url_raw( $url ) . '" title="' . __( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
380 | + } |
|
381 | 381 | |
382 | 382 | } |
383 | 383 | add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
@@ -389,40 +389,40 @@ discard block |
||
389 | 389 | */ |
390 | 390 | function getpaid_admin_subscription_update_metabox( $subscription ) { |
391 | 391 | |
392 | - ?> |
|
392 | + ?> |
|
393 | 393 | <div class="mt-3"> |
394 | 394 | |
395 | 395 | <?php |
396 | - aui()->select( |
|
397 | - array( |
|
398 | - 'options' => getpaid_get_subscription_statuses(), |
|
399 | - 'name' => 'subscription_status', |
|
400 | - 'id' => 'subscription_status_update_select', |
|
401 | - 'required' => true, |
|
402 | - 'no_wrap' => false, |
|
403 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
404 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
405 | - 'select2' => true, |
|
406 | - 'value' => $subscription->get_status( 'edit' ), |
|
407 | - ), |
|
408 | - true |
|
409 | - ); |
|
410 | - ?> |
|
396 | + aui()->select( |
|
397 | + array( |
|
398 | + 'options' => getpaid_get_subscription_statuses(), |
|
399 | + 'name' => 'subscription_status', |
|
400 | + 'id' => 'subscription_status_update_select', |
|
401 | + 'required' => true, |
|
402 | + 'no_wrap' => false, |
|
403 | + 'label' => __( 'Subscription Status', 'invoicing' ), |
|
404 | + 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
405 | + 'select2' => true, |
|
406 | + 'value' => $subscription->get_status( 'edit' ), |
|
407 | + ), |
|
408 | + true |
|
409 | + ); |
|
410 | + ?> |
|
411 | 411 | |
412 | 412 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;"> |
413 | 413 | |
414 | 414 | <?php |
415 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
415 | + submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
416 | 416 | |
417 | - $url = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
418 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
419 | - $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' ); |
|
417 | + $url = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
418 | + $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
419 | + $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' ); |
|
420 | 420 | |
421 | - if ( $subscription->is_active() ) { |
|
422 | - echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>"; |
|
423 | - } |
|
421 | + if ( $subscription->is_active() ) { |
|
422 | + echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>"; |
|
423 | + } |
|
424 | 424 | |
425 | - echo '</div></div>'; |
|
425 | + echo '</div></div>'; |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | /** |
@@ -433,33 +433,33 @@ discard block |
||
433 | 433 | */ |
434 | 434 | function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) { |
435 | 435 | |
436 | - $columns = apply_filters( |
|
437 | - 'getpaid_subscription_related_invoices_columns', |
|
438 | - array( |
|
439 | - 'invoice' => __( 'Invoice', 'invoicing' ), |
|
440 | - 'relationship' => __( 'Relationship', 'invoicing' ), |
|
441 | - 'date' => __( 'Date', 'invoicing' ), |
|
442 | - 'status' => __( 'Status', 'invoicing' ), |
|
443 | - 'total' => __( 'Total', 'invoicing' ), |
|
444 | - ), |
|
445 | - $subscription |
|
446 | - ); |
|
447 | - |
|
448 | - // Prepare the invoices. |
|
449 | - $payments = $subscription->get_child_payments( ! is_admin() ); |
|
450 | - $parent = $subscription->get_parent_invoice(); |
|
451 | - |
|
452 | - if ( $parent->exists() ) { |
|
453 | - $payments = array_merge( array( $parent ), $payments ); |
|
454 | - } |
|
455 | - |
|
456 | - $table_class = 'w-100 bg-white'; |
|
457 | - |
|
458 | - if ( ! is_admin() ) { |
|
459 | - $table_class = 'table table-bordered'; |
|
460 | - } |
|
461 | - |
|
462 | - ?> |
|
436 | + $columns = apply_filters( |
|
437 | + 'getpaid_subscription_related_invoices_columns', |
|
438 | + array( |
|
439 | + 'invoice' => __( 'Invoice', 'invoicing' ), |
|
440 | + 'relationship' => __( 'Relationship', 'invoicing' ), |
|
441 | + 'date' => __( 'Date', 'invoicing' ), |
|
442 | + 'status' => __( 'Status', 'invoicing' ), |
|
443 | + 'total' => __( 'Total', 'invoicing' ), |
|
444 | + ), |
|
445 | + $subscription |
|
446 | + ); |
|
447 | + |
|
448 | + // Prepare the invoices. |
|
449 | + $payments = $subscription->get_child_payments( ! is_admin() ); |
|
450 | + $parent = $subscription->get_parent_invoice(); |
|
451 | + |
|
452 | + if ( $parent->exists() ) { |
|
453 | + $payments = array_merge( array( $parent ), $payments ); |
|
454 | + } |
|
455 | + |
|
456 | + $table_class = 'w-100 bg-white'; |
|
457 | + |
|
458 | + if ( ! is_admin() ) { |
|
459 | + $table_class = 'table table-bordered'; |
|
460 | + } |
|
461 | + |
|
462 | + ?> |
|
463 | 463 | <div class="m-0" style="overflow: auto;"> |
464 | 464 | |
465 | 465 | <table class="<?php echo esc_attr( $table_class ); ?>"> |
@@ -467,14 +467,14 @@ discard block |
||
467 | 467 | <thead> |
468 | 468 | <tr> |
469 | 469 | <?php |
470 | - foreach ( $columns as $key => $label ) { |
|
471 | - $key = esc_attr( $key ); |
|
472 | - $label = esc_html( $label ); |
|
473 | - $class = 'text-left'; |
|
474 | - |
|
475 | - echo "<th class='subscription-invoice-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
|
476 | - } |
|
477 | - ?> |
|
470 | + foreach ( $columns as $key => $label ) { |
|
471 | + $key = esc_attr( $key ); |
|
472 | + $label = esc_html( $label ); |
|
473 | + $class = 'text-left'; |
|
474 | + |
|
475 | + echo "<th class='subscription-invoice-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
|
476 | + } |
|
477 | + ?> |
|
478 | 478 | </tr> |
479 | 479 | </thead> |
480 | 480 | |
@@ -490,72 +490,72 @@ discard block |
||
490 | 490 | |
491 | 491 | <?php |
492 | 492 | |
493 | - foreach ( $payments as $payment ) : |
|
493 | + foreach ( $payments as $payment ) : |
|
494 | 494 | |
495 | - // Ensure that we have an invoice. |
|
496 | - $payment = new WPInv_Invoice( $payment ); |
|
495 | + // Ensure that we have an invoice. |
|
496 | + $payment = new WPInv_Invoice( $payment ); |
|
497 | 497 | |
498 | - // Abort if the invoice is invalid... |
|
499 | - if ( ! $payment->exists() ) { |
|
500 | - continue; |
|
501 | - } |
|
498 | + // Abort if the invoice is invalid... |
|
499 | + if ( ! $payment->exists() ) { |
|
500 | + continue; |
|
501 | + } |
|
502 | 502 | |
503 | - // ... or belongs to a different subscription. |
|
504 | - if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
505 | - continue; |
|
506 | - } |
|
503 | + // ... or belongs to a different subscription. |
|
504 | + if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
505 | + continue; |
|
506 | + } |
|
507 | 507 | |
508 | - echo '<tr>'; |
|
508 | + echo '<tr>'; |
|
509 | 509 | |
510 | - foreach ( array_keys( $columns ) as $key ) { |
|
510 | + foreach ( array_keys( $columns ) as $key ) { |
|
511 | 511 | |
512 | - $class = 'text-left'; |
|
512 | + $class = 'text-left'; |
|
513 | 513 | |
514 | - echo "<td class='p-2 text-left'>"; |
|
514 | + echo "<td class='p-2 text-left'>"; |
|
515 | 515 | |
516 | - switch ( $key ) { |
|
516 | + switch ( $key ) { |
|
517 | 517 | |
518 | - case 'total': |
|
519 | - echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>'; |
|
520 | - break; |
|
518 | + case 'total': |
|
519 | + echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>'; |
|
520 | + break; |
|
521 | 521 | |
522 | - case 'relationship': |
|
523 | - echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' ); |
|
524 | - break; |
|
522 | + case 'relationship': |
|
523 | + echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' ); |
|
524 | + break; |
|
525 | 525 | |
526 | - case 'date': |
|
527 | - echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) ); |
|
528 | - break; |
|
526 | + case 'date': |
|
527 | + echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) ); |
|
528 | + break; |
|
529 | 529 | |
530 | - case 'status': |
|
531 | - $status = $payment->get_status_nicename(); |
|
532 | - if ( is_admin() ) { |
|
533 | - $status = $payment->get_status_label_html(); |
|
534 | - } |
|
530 | + case 'status': |
|
531 | + $status = $payment->get_status_nicename(); |
|
532 | + if ( is_admin() ) { |
|
533 | + $status = $payment->get_status_label_html(); |
|
534 | + } |
|
535 | 535 | |
536 | - echo wp_kses_post( $status ); |
|
537 | - break; |
|
536 | + echo wp_kses_post( $status ); |
|
537 | + break; |
|
538 | 538 | |
539 | - case 'invoice': |
|
540 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
539 | + case 'invoice': |
|
540 | + $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
541 | 541 | |
542 | - if ( ! is_admin() ) { |
|
543 | - $link = esc_url( $payment->get_view_url() ); |
|
544 | - } |
|
542 | + if ( ! is_admin() ) { |
|
543 | + $link = esc_url( $payment->get_view_url() ); |
|
544 | + } |
|
545 | 545 | |
546 | - $invoice = esc_html( $payment->get_number() ); |
|
547 | - echo "<a href='$link'>$invoice</a>"; |
|
548 | - break; |
|
549 | - } |
|
546 | + $invoice = esc_html( $payment->get_number() ); |
|
547 | + echo "<a href='$link'>$invoice</a>"; |
|
548 | + break; |
|
549 | + } |
|
550 | 550 | |
551 | - echo '</td>'; |
|
551 | + echo '</td>'; |
|
552 | 552 | |
553 | - } |
|
553 | + } |
|
554 | 554 | |
555 | - echo '</tr>'; |
|
555 | + echo '</tr>'; |
|
556 | 556 | |
557 | - endforeach; |
|
558 | - ?> |
|
557 | + endforeach; |
|
558 | + ?> |
|
559 | 559 | |
560 | 560 | </tbody> |
561 | 561 | |
@@ -573,42 +573,42 @@ discard block |
||
573 | 573 | */ |
574 | 574 | function getpaid_admin_subscription_item_details_metabox( $subscription ) { |
575 | 575 | |
576 | - // Fetch the subscription group. |
|
577 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
576 | + // Fetch the subscription group. |
|
577 | + $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
578 | 578 | |
579 | - if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
580 | - return; |
|
581 | - } |
|
579 | + if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
580 | + return; |
|
581 | + } |
|
582 | 582 | |
583 | - // Prepare table columns. |
|
584 | - $columns = apply_filters( |
|
585 | - 'getpaid_subscription_item_details_columns', |
|
586 | - array( |
|
587 | - 'item_name' => __( 'Item', 'invoicing' ), |
|
588 | - 'price' => __( 'Price', 'invoicing' ), |
|
589 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
590 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
591 | - //'initial' => __( 'Initial Amount', 'invoicing' ), |
|
592 | - 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
593 | - ), |
|
594 | - $subscription |
|
595 | - ); |
|
583 | + // Prepare table columns. |
|
584 | + $columns = apply_filters( |
|
585 | + 'getpaid_subscription_item_details_columns', |
|
586 | + array( |
|
587 | + 'item_name' => __( 'Item', 'invoicing' ), |
|
588 | + 'price' => __( 'Price', 'invoicing' ), |
|
589 | + 'tax' => __( 'Tax', 'invoicing' ), |
|
590 | + 'discount' => __( 'Discount', 'invoicing' ), |
|
591 | + //'initial' => __( 'Initial Amount', 'invoicing' ), |
|
592 | + 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
593 | + ), |
|
594 | + $subscription |
|
595 | + ); |
|
596 | 596 | |
597 | - // Prepare the invoices. |
|
597 | + // Prepare the invoices. |
|
598 | 598 | |
599 | - $invoice = $subscription->get_parent_invoice(); |
|
599 | + $invoice = $subscription->get_parent_invoice(); |
|
600 | 600 | |
601 | - if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
602 | - unset( $columns['tax'] ); |
|
603 | - } |
|
601 | + if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
602 | + unset( $columns['tax'] ); |
|
603 | + } |
|
604 | 604 | |
605 | - $table_class = 'w-100 bg-white'; |
|
605 | + $table_class = 'w-100 bg-white'; |
|
606 | 606 | |
607 | - if ( ! is_admin() ) { |
|
608 | - $table_class = 'table table-bordered'; |
|
609 | - } |
|
607 | + if ( ! is_admin() ) { |
|
608 | + $table_class = 'table table-bordered'; |
|
609 | + } |
|
610 | 610 | |
611 | - ?> |
|
611 | + ?> |
|
612 | 612 | <div class="m-0" style="overflow: auto;"> |
613 | 613 | |
614 | 614 | <table class="<?php echo esc_attr( $table_class ); ?>"> |
@@ -617,14 +617,14 @@ discard block |
||
617 | 617 | <tr> |
618 | 618 | <?php |
619 | 619 | |
620 | - foreach ( $columns as $key => $label ) { |
|
621 | - $key = esc_attr( $key ); |
|
622 | - $label = esc_html( $label ); |
|
623 | - $class = 'text-left'; |
|
620 | + foreach ( $columns as $key => $label ) { |
|
621 | + $key = esc_attr( $key ); |
|
622 | + $label = esc_html( $label ); |
|
623 | + $class = 'text-left'; |
|
624 | 624 | |
625 | - echo "<th class='subscription-item-field-$key bg-light p-2 text-left color-dark font-weight-bold'>$label</th>"; |
|
626 | - } |
|
627 | - ?> |
|
625 | + echo "<th class='subscription-item-field-$key bg-light p-2 text-left color-dark font-weight-bold'>$label</th>"; |
|
626 | + } |
|
627 | + ?> |
|
628 | 628 | </tr> |
629 | 629 | </thead> |
630 | 630 | |
@@ -632,106 +632,106 @@ discard block |
||
632 | 632 | |
633 | 633 | <?php |
634 | 634 | |
635 | - foreach ( $subscription_group['items'] as $subscription_group_item ) : |
|
635 | + foreach ( $subscription_group['items'] as $subscription_group_item ) : |
|
636 | 636 | |
637 | - echo '<tr>'; |
|
637 | + echo '<tr>'; |
|
638 | 638 | |
639 | - foreach ( array_keys( $columns ) as $key ) { |
|
639 | + foreach ( array_keys( $columns ) as $key ) { |
|
640 | 640 | |
641 | - $class = 'text-left'; |
|
641 | + $class = 'text-left'; |
|
642 | 642 | |
643 | - echo "<td class='p-2 text-left'>"; |
|
643 | + echo "<td class='p-2 text-left'>"; |
|
644 | 644 | |
645 | - switch ( $key ) { |
|
645 | + switch ( $key ) { |
|
646 | 646 | |
647 | - case 'item_name': |
|
648 | - $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
649 | - $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
647 | + case 'item_name': |
|
648 | + $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
649 | + $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
650 | 650 | |
651 | - if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
652 | - echo esc_html( $item_name ); |
|
653 | - } else { |
|
654 | - printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
655 | - } |
|
651 | + if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
652 | + echo esc_html( $item_name ); |
|
653 | + } else { |
|
654 | + printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
655 | + } |
|
656 | 656 | |
657 | - break; |
|
657 | + break; |
|
658 | 658 | |
659 | - case 'price': |
|
660 | - wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
661 | - break; |
|
659 | + case 'price': |
|
660 | + wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
661 | + break; |
|
662 | 662 | |
663 | - case 'tax': |
|
664 | - wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
665 | - break; |
|
663 | + case 'tax': |
|
664 | + wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
665 | + break; |
|
666 | 666 | |
667 | - case 'discount': |
|
668 | - wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
669 | - break; |
|
667 | + case 'discount': |
|
668 | + wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
669 | + break; |
|
670 | 670 | |
671 | - case 'initial': |
|
672 | - wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
673 | - break; |
|
671 | + case 'initial': |
|
672 | + wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
673 | + break; |
|
674 | 674 | |
675 | - case 'recurring': |
|
676 | - echo '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>'; |
|
677 | - break; |
|
675 | + case 'recurring': |
|
676 | + echo '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>'; |
|
677 | + break; |
|
678 | 678 | |
679 | - } |
|
679 | + } |
|
680 | 680 | |
681 | - echo '</td>'; |
|
681 | + echo '</td>'; |
|
682 | 682 | |
683 | - } |
|
683 | + } |
|
684 | 684 | |
685 | - echo '</tr>'; |
|
685 | + echo '</tr>'; |
|
686 | 686 | |
687 | - endforeach; |
|
687 | + endforeach; |
|
688 | 688 | |
689 | - foreach ( $subscription_group['fees'] as $subscription_group_fee ) : |
|
689 | + foreach ( $subscription_group['fees'] as $subscription_group_fee ) : |
|
690 | 690 | |
691 | - echo '<tr>'; |
|
691 | + echo '<tr>'; |
|
692 | 692 | |
693 | - foreach ( array_keys( $columns ) as $key ) { |
|
693 | + foreach ( array_keys( $columns ) as $key ) { |
|
694 | 694 | |
695 | - $class = 'text-left'; |
|
695 | + $class = 'text-left'; |
|
696 | 696 | |
697 | - echo "<td class='p-2 text-left'>"; |
|
697 | + echo "<td class='p-2 text-left'>"; |
|
698 | 698 | |
699 | - switch ( $key ) { |
|
699 | + switch ( $key ) { |
|
700 | 700 | |
701 | - case 'item_name': |
|
702 | - echo esc_html( $subscription_group_fee['name'] ); |
|
703 | - break; |
|
701 | + case 'item_name': |
|
702 | + echo esc_html( $subscription_group_fee['name'] ); |
|
703 | + break; |
|
704 | 704 | |
705 | - case 'price': |
|
706 | - wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
707 | - break; |
|
705 | + case 'price': |
|
706 | + wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
707 | + break; |
|
708 | 708 | |
709 | - case 'tax': |
|
710 | - echo '—'; |
|
711 | - break; |
|
709 | + case 'tax': |
|
710 | + echo '—'; |
|
711 | + break; |
|
712 | 712 | |
713 | - case 'discount': |
|
714 | - echo '—'; |
|
715 | - break; |
|
713 | + case 'discount': |
|
714 | + echo '—'; |
|
715 | + break; |
|
716 | 716 | |
717 | - case 'initial': |
|
718 | - wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
719 | - break; |
|
717 | + case 'initial': |
|
718 | + wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
719 | + break; |
|
720 | 720 | |
721 | - case 'recurring': |
|
722 | - echo '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>'; |
|
723 | - break; |
|
721 | + case 'recurring': |
|
722 | + echo '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>'; |
|
723 | + break; |
|
724 | 724 | |
725 | - } |
|
725 | + } |
|
726 | 726 | |
727 | - echo '</td>'; |
|
727 | + echo '</td>'; |
|
728 | 728 | |
729 | - } |
|
729 | + } |
|
730 | 730 | |
731 | - echo '</tr>'; |
|
731 | + echo '</tr>'; |
|
732 | 732 | |
733 | - endforeach; |
|
734 | - ?> |
|
733 | + endforeach; |
|
734 | + ?> |
|
735 | 735 | |
736 | 736 | </tbody> |
737 | 737 | |
@@ -750,38 +750,38 @@ discard block |
||
750 | 750 | */ |
751 | 751 | function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) { |
752 | 752 | |
753 | - // Fetch the subscription groups. |
|
754 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
755 | - |
|
756 | - if ( empty( $subscription_groups ) ) { |
|
757 | - return; |
|
758 | - } |
|
759 | - |
|
760 | - // Prepare table columns. |
|
761 | - $columns = apply_filters( |
|
762 | - 'getpaid_subscription_related_subscriptions_columns', |
|
763 | - array( |
|
764 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
765 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
766 | - 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
767 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
768 | - 'item' => __( 'Items', 'invoicing' ), |
|
769 | - 'status' => __( 'Status', 'invoicing' ), |
|
770 | - ), |
|
771 | - $subscription |
|
772 | - ); |
|
773 | - |
|
774 | - if ( $subscription->get_status() == 'pending' ) { |
|
775 | - unset( $columns['start_date'], $columns['renewal_date'] ); |
|
776 | - } |
|
777 | - |
|
778 | - $table_class = 'w-100 bg-white'; |
|
779 | - |
|
780 | - if ( ! is_admin() ) { |
|
781 | - $table_class = 'table table-bordered'; |
|
782 | - } |
|
783 | - |
|
784 | - ?> |
|
753 | + // Fetch the subscription groups. |
|
754 | + $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
755 | + |
|
756 | + if ( empty( $subscription_groups ) ) { |
|
757 | + return; |
|
758 | + } |
|
759 | + |
|
760 | + // Prepare table columns. |
|
761 | + $columns = apply_filters( |
|
762 | + 'getpaid_subscription_related_subscriptions_columns', |
|
763 | + array( |
|
764 | + 'subscription' => __( 'Subscription', 'invoicing' ), |
|
765 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
766 | + 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
767 | + 'renewals' => __( 'Payments', 'invoicing' ), |
|
768 | + 'item' => __( 'Items', 'invoicing' ), |
|
769 | + 'status' => __( 'Status', 'invoicing' ), |
|
770 | + ), |
|
771 | + $subscription |
|
772 | + ); |
|
773 | + |
|
774 | + if ( $subscription->get_status() == 'pending' ) { |
|
775 | + unset( $columns['start_date'], $columns['renewal_date'] ); |
|
776 | + } |
|
777 | + |
|
778 | + $table_class = 'w-100 bg-white'; |
|
779 | + |
|
780 | + if ( ! is_admin() ) { |
|
781 | + $table_class = 'table table-bordered'; |
|
782 | + } |
|
783 | + |
|
784 | + ?> |
|
785 | 785 | <div class="m-0" style="overflow: auto;"> |
786 | 786 | |
787 | 787 | <table class="<?php echo esc_attr( $table_class ); ?>"> |
@@ -790,14 +790,14 @@ discard block |
||
790 | 790 | <tr> |
791 | 791 | <?php |
792 | 792 | |
793 | - foreach ( $columns as $key => $label ) { |
|
794 | - $key = esc_attr( $key ); |
|
795 | - $label = esc_html( $label ); |
|
796 | - $class = 'text-left'; |
|
793 | + foreach ( $columns as $key => $label ) { |
|
794 | + $key = esc_attr( $key ); |
|
795 | + $label = esc_html( $label ); |
|
796 | + $class = 'text-left'; |
|
797 | 797 | |
798 | - echo "<th class='related-subscription-field-$key bg-light p-2 text-left color-dark font-weight-bold'>$label</th>"; |
|
799 | - } |
|
800 | - ?> |
|
798 | + echo "<th class='related-subscription-field-$key bg-light p-2 text-left color-dark font-weight-bold'>$label</th>"; |
|
799 | + } |
|
800 | + ?> |
|
801 | 801 | </tr> |
802 | 802 | </thead> |
803 | 803 | |
@@ -805,74 +805,74 @@ discard block |
||
805 | 805 | |
806 | 806 | <?php |
807 | 807 | |
808 | - foreach ( $subscription_groups as $subscription_group ) : |
|
808 | + foreach ( $subscription_groups as $subscription_group ) : |
|
809 | 809 | |
810 | - // Do not list current subscription. |
|
811 | - if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
812 | - continue; |
|
813 | - } |
|
810 | + // Do not list current subscription. |
|
811 | + if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
812 | + continue; |
|
813 | + } |
|
814 | 814 | |
815 | - // Ensure the subscription exists. |
|
816 | - $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
815 | + // Ensure the subscription exists. |
|
816 | + $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
817 | 817 | |
818 | - if ( ! $_suscription->exists() ) { |
|
819 | - continue; |
|
820 | - } |
|
818 | + if ( ! $_suscription->exists() ) { |
|
819 | + continue; |
|
820 | + } |
|
821 | 821 | |
822 | - echo '<tr>'; |
|
822 | + echo '<tr>'; |
|
823 | 823 | |
824 | - foreach ( array_keys( $columns ) as $key ) { |
|
824 | + foreach ( array_keys( $columns ) as $key ) { |
|
825 | 825 | |
826 | - $class = 'text-left'; |
|
826 | + $class = 'text-left'; |
|
827 | 827 | |
828 | - echo "<td class='p-2 text-left'>"; |
|
828 | + echo "<td class='p-2 text-left'>"; |
|
829 | 829 | |
830 | - switch ( $key ) { |
|
830 | + switch ( $key ) { |
|
831 | 831 | |
832 | - case 'status': |
|
833 | - echo wp_kses_post( $_suscription->get_status_label_html() ); |
|
834 | - break; |
|
832 | + case 'status': |
|
833 | + echo wp_kses_post( $_suscription->get_status_label_html() ); |
|
834 | + break; |
|
835 | 835 | |
836 | - case 'item': |
|
837 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
838 | - echo implode( ' | ', $markup ); |
|
839 | - break; |
|
836 | + case 'item': |
|
837 | + $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
838 | + echo implode( ' | ', $markup ); |
|
839 | + break; |
|
840 | 840 | |
841 | - case 'renewals': |
|
842 | - $max_bills = $_suscription->get_bill_times(); |
|
843 | - echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
844 | - break; |
|
841 | + case 'renewals': |
|
842 | + $max_bills = $_suscription->get_bill_times(); |
|
843 | + echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
844 | + break; |
|
845 | 845 | |
846 | - case 'renewal_date': |
|
847 | - echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : '—'; |
|
848 | - break; |
|
846 | + case 'renewal_date': |
|
847 | + echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : '—'; |
|
848 | + break; |
|
849 | 849 | |
850 | - case 'start_date': |
|
851 | - echo 'pending' == $_suscription->get_status() ? '—' : getpaid_format_date_value( $_suscription->get_date_created() ); |
|
852 | - break; |
|
850 | + case 'start_date': |
|
851 | + echo 'pending' == $_suscription->get_status() ? '—' : getpaid_format_date_value( $_suscription->get_date_created() ); |
|
852 | + break; |
|
853 | 853 | |
854 | - case 'subscription': |
|
855 | - $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
856 | - printf( |
|
854 | + case 'subscription': |
|
855 | + $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
856 | + printf( |
|
857 | 857 | '%1$s#%2$s%3$s', |
858 | 858 | '<a href="' . esc_url( $url ) . '">', |
859 | 859 | '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
860 | - '</a>' |
|
860 | + '</a>' |
|
861 | 861 | ); |
862 | 862 | |
863 | - echo WPInv_Subscriptions_List_Table::column_amount( $_suscription ); |
|
864 | - break; |
|
863 | + echo WPInv_Subscriptions_List_Table::column_amount( $_suscription ); |
|
864 | + break; |
|
865 | 865 | |
866 | - } |
|
866 | + } |
|
867 | 867 | |
868 | - echo '</td>'; |
|
868 | + echo '</td>'; |
|
869 | 869 | |
870 | - } |
|
870 | + } |
|
871 | 871 | |
872 | - echo '</tr>'; |
|
872 | + echo '</tr>'; |
|
873 | 873 | |
874 | - endforeach; |
|
875 | - ?> |
|
874 | + endforeach; |
|
875 | + ?> |
|
876 | 876 | |
877 | 877 | </tbody> |
878 | 878 |
@@ -515,37 +515,37 @@ discard block |
||
515 | 515 | |
516 | 516 | switch ( $key ) { |
517 | 517 | |
518 | - case 'total': |
|
519 | - echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>'; |
|
520 | - break; |
|
521 | - |
|
522 | - case 'relationship': |
|
523 | - echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' ); |
|
524 | - break; |
|
525 | - |
|
526 | - case 'date': |
|
527 | - echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) ); |
|
528 | - break; |
|
529 | - |
|
530 | - case 'status': |
|
531 | - $status = $payment->get_status_nicename(); |
|
532 | - if ( is_admin() ) { |
|
533 | - $status = $payment->get_status_label_html(); |
|
534 | - } |
|
518 | + case 'total': |
|
519 | + echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>'; |
|
520 | + break; |
|
535 | 521 | |
536 | - echo wp_kses_post( $status ); |
|
537 | - break; |
|
522 | + case 'relationship': |
|
523 | + echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' ); |
|
524 | + break; |
|
538 | 525 | |
539 | - case 'invoice': |
|
540 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
526 | + case 'date': |
|
527 | + echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) ); |
|
528 | + break; |
|
541 | 529 | |
542 | - if ( ! is_admin() ) { |
|
543 | - $link = esc_url( $payment->get_view_url() ); |
|
544 | - } |
|
530 | + case 'status': |
|
531 | + $status = $payment->get_status_nicename(); |
|
532 | + if ( is_admin() ) { |
|
533 | + $status = $payment->get_status_label_html(); |
|
534 | + } |
|
535 | + |
|
536 | + echo wp_kses_post( $status ); |
|
537 | + break; |
|
538 | + |
|
539 | + case 'invoice': |
|
540 | + $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
541 | + |
|
542 | + if ( ! is_admin() ) { |
|
543 | + $link = esc_url( $payment->get_view_url() ); |
|
544 | + } |
|
545 | 545 | |
546 | - $invoice = esc_html( $payment->get_number() ); |
|
547 | - echo "<a href='$link'>$invoice</a>"; |
|
548 | - break; |
|
546 | + $invoice = esc_html( $payment->get_number() ); |
|
547 | + echo "<a href='$link'>$invoice</a>"; |
|
548 | + break; |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | echo '</td>'; |
@@ -644,37 +644,37 @@ discard block |
||
644 | 644 | |
645 | 645 | switch ( $key ) { |
646 | 646 | |
647 | - case 'item_name': |
|
648 | - $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
649 | - $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
647 | + case 'item_name': |
|
648 | + $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
649 | + $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
650 | 650 | |
651 | - if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
652 | - echo esc_html( $item_name ); |
|
653 | - } else { |
|
654 | - printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
655 | - } |
|
651 | + if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
652 | + echo esc_html( $item_name ); |
|
653 | + } else { |
|
654 | + printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
655 | + } |
|
656 | 656 | |
657 | - break; |
|
657 | + break; |
|
658 | 658 | |
659 | - case 'price': |
|
660 | - wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
661 | - break; |
|
659 | + case 'price': |
|
660 | + wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
661 | + break; |
|
662 | 662 | |
663 | - case 'tax': |
|
664 | - wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
665 | - break; |
|
663 | + case 'tax': |
|
664 | + wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
665 | + break; |
|
666 | 666 | |
667 | - case 'discount': |
|
668 | - wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
669 | - break; |
|
667 | + case 'discount': |
|
668 | + wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
669 | + break; |
|
670 | 670 | |
671 | - case 'initial': |
|
672 | - wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
673 | - break; |
|
671 | + case 'initial': |
|
672 | + wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
673 | + break; |
|
674 | 674 | |
675 | - case 'recurring': |
|
676 | - echo '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>'; |
|
677 | - break; |
|
675 | + case 'recurring': |
|
676 | + echo '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>'; |
|
677 | + break; |
|
678 | 678 | |
679 | 679 | } |
680 | 680 | |
@@ -698,29 +698,29 @@ discard block |
||
698 | 698 | |
699 | 699 | switch ( $key ) { |
700 | 700 | |
701 | - case 'item_name': |
|
702 | - echo esc_html( $subscription_group_fee['name'] ); |
|
703 | - break; |
|
701 | + case 'item_name': |
|
702 | + echo esc_html( $subscription_group_fee['name'] ); |
|
703 | + break; |
|
704 | 704 | |
705 | - case 'price': |
|
706 | - wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
707 | - break; |
|
705 | + case 'price': |
|
706 | + wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
707 | + break; |
|
708 | 708 | |
709 | - case 'tax': |
|
710 | - echo '—'; |
|
711 | - break; |
|
709 | + case 'tax': |
|
710 | + echo '—'; |
|
711 | + break; |
|
712 | 712 | |
713 | - case 'discount': |
|
714 | - echo '—'; |
|
715 | - break; |
|
713 | + case 'discount': |
|
714 | + echo '—'; |
|
715 | + break; |
|
716 | 716 | |
717 | - case 'initial': |
|
718 | - wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
719 | - break; |
|
717 | + case 'initial': |
|
718 | + wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
719 | + break; |
|
720 | 720 | |
721 | - case 'recurring': |
|
722 | - echo '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>'; |
|
723 | - break; |
|
721 | + case 'recurring': |
|
722 | + echo '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>'; |
|
723 | + break; |
|
724 | 724 | |
725 | 725 | } |
726 | 726 | |
@@ -829,39 +829,39 @@ discard block |
||
829 | 829 | |
830 | 830 | switch ( $key ) { |
831 | 831 | |
832 | - case 'status': |
|
833 | - echo wp_kses_post( $_suscription->get_status_label_html() ); |
|
834 | - break; |
|
835 | - |
|
836 | - case 'item': |
|
837 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
838 | - echo implode( ' | ', $markup ); |
|
839 | - break; |
|
840 | - |
|
841 | - case 'renewals': |
|
842 | - $max_bills = $_suscription->get_bill_times(); |
|
843 | - echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
844 | - break; |
|
845 | - |
|
846 | - case 'renewal_date': |
|
847 | - echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : '—'; |
|
848 | - break; |
|
849 | - |
|
850 | - case 'start_date': |
|
851 | - echo 'pending' == $_suscription->get_status() ? '—' : getpaid_format_date_value( $_suscription->get_date_created() ); |
|
852 | - break; |
|
853 | - |
|
854 | - case 'subscription': |
|
855 | - $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
856 | - printf( |
|
857 | - '%1$s#%2$s%3$s', |
|
858 | - '<a href="' . esc_url( $url ) . '">', |
|
859 | - '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
|
860 | - '</a>' |
|
861 | - ); |
|
862 | - |
|
863 | - echo WPInv_Subscriptions_List_Table::column_amount( $_suscription ); |
|
864 | - break; |
|
832 | + case 'status': |
|
833 | + echo wp_kses_post( $_suscription->get_status_label_html() ); |
|
834 | + break; |
|
835 | + |
|
836 | + case 'item': |
|
837 | + $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
838 | + echo implode( ' | ', $markup ); |
|
839 | + break; |
|
840 | + |
|
841 | + case 'renewals': |
|
842 | + $max_bills = $_suscription->get_bill_times(); |
|
843 | + echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
844 | + break; |
|
845 | + |
|
846 | + case 'renewal_date': |
|
847 | + echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : '—'; |
|
848 | + break; |
|
849 | + |
|
850 | + case 'start_date': |
|
851 | + echo 'pending' == $_suscription->get_status() ? '—' : getpaid_format_date_value( $_suscription->get_date_created() ); |
|
852 | + break; |
|
853 | + |
|
854 | + case 'subscription': |
|
855 | + $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
856 | + printf( |
|
857 | + '%1$s#%2$s%3$s', |
|
858 | + '<a href="' . esc_url( $url ) . '">', |
|
859 | + '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
|
860 | + '</a>' |
|
861 | + ); |
|
862 | + |
|
863 | + echo WPInv_Subscriptions_List_Table::column_amount( $_suscription ); |
|
864 | + break; |
|
865 | 865 | |
866 | 866 | } |
867 | 867 |
@@ -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,23 +17,23 @@ 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 | 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 | 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 | 38 | // Display a single subscription. |
39 | 39 | wpinv_recurring_subscription_details(); |
@@ -67,7 +67,7 @@ discard block |
||
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" /> |
70 | - <?php $subscribers_table->search_box( __( 'Search Subscriptions', 'invoicing' ), 'getpaid-search-subscriptions' ); ?> |
|
70 | + <?php $subscribers_table->search_box(__('Search Subscriptions', 'invoicing'), 'getpaid-search-subscriptions'); ?> |
|
71 | 71 | <?php $subscribers_table->display(); ?> |
72 | 72 | </form> |
73 | 73 | <?php |
@@ -83,13 +83,13 @@ discard block |
||
83 | 83 | function wpinv_recurring_subscription_details() { |
84 | 84 | |
85 | 85 | // Fetch the subscription. |
86 | - $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
87 | - if ( ! $sub->exists() ) { |
|
86 | + $sub = new WPInv_Subscription((int) $_GET['id']); |
|
87 | + if (!$sub->exists()) { |
|
88 | 88 | |
89 | 89 | aui()->alert( |
90 | 90 | array( |
91 | 91 | 'type' => 'danger', |
92 | - 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
92 | + 'content' => __('Subscription not found.', 'invoicing'), |
|
93 | 93 | ), |
94 | 94 | true |
95 | 95 | ); |
@@ -98,32 +98,32 @@ discard block |
||
98 | 98 | } |
99 | 99 | |
100 | 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' ); |
|
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 | 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' ) ); |
|
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' ); |
|
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 | 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' ); |
|
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 | 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 | - <form method="post" action="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ) ); ?>"> |
|
122 | + <form method="post" action="<?php echo esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($sub->get_id()))); ?>"> |
|
123 | 123 | |
124 | - <?php wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); ?> |
|
125 | - <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> |
|
126 | - <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> |
|
124 | + <?php wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); ?> |
|
125 | + <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?> |
|
126 | + <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?> |
|
127 | 127 | <input type="hidden" name="getpaid-admin-action" value="update_single_subscription" /> |
128 | 128 | <input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id(); ?>" /> |
129 | 129 | |
@@ -131,12 +131,12 @@ discard block |
||
131 | 131 | <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>"> |
132 | 132 | |
133 | 133 | <div id="postbox-container-1" class="postbox-container"> |
134 | - <?php do_meta_boxes( get_current_screen(), 'side', $sub ); ?> |
|
134 | + <?php do_meta_boxes(get_current_screen(), 'side', $sub); ?> |
|
135 | 135 | </div> |
136 | 136 | |
137 | 137 | <div id="postbox-container-2" class="postbox-container"> |
138 | - <?php do_meta_boxes( get_current_screen(), 'normal', $sub ); ?> |
|
139 | - <?php do_meta_boxes( get_current_screen(), 'advanced', $sub ); ?> |
|
138 | + <?php do_meta_boxes(get_current_screen(), 'normal', $sub); ?> |
|
139 | + <?php do_meta_boxes(get_current_screen(), 'advanced', $sub); ?> |
|
140 | 140 | </div> |
141 | 141 | |
142 | 142 | </div> |
@@ -155,43 +155,43 @@ discard block |
||
155 | 155 | * |
156 | 156 | * @param WPInv_Subscription $sub |
157 | 157 | */ |
158 | -function getpaid_admin_subscription_details_metabox( $sub ) { |
|
158 | +function getpaid_admin_subscription_details_metabox($sub) { |
|
159 | 159 | |
160 | 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'] ); |
|
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 | 163 | |
164 | 164 | // Prepare subscription detail columns. |
165 | 165 | $fields = apply_filters( |
166 | 166 | 'getpaid_subscription_admin_page_fields', |
167 | 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' => __( 'Payments', 'invoicing' ), |
|
174 | - 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
175 | - 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
176 | - 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
177 | - 'status' => __( 'Status', 'invoicing' ), |
|
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' => __('Payments', 'invoicing'), |
|
174 | + 'item' => _n('Item', 'Items', $items_count, 'invoicing'), |
|
175 | + 'gateway' => __('Payment Method', 'invoicing'), |
|
176 | + 'profile_id' => __('Profile ID', 'invoicing'), |
|
177 | + 'status' => __('Status', 'invoicing'), |
|
178 | 178 | ) |
179 | 179 | ); |
180 | 180 | |
181 | - if ( ! $sub->is_active() ) { |
|
181 | + if (!$sub->is_active()) { |
|
182 | 182 | |
183 | - if ( isset( $fields['renews_on'] ) ) { |
|
184 | - unset( $fields['renews_on'] ); |
|
183 | + if (isset($fields['renews_on'])) { |
|
184 | + unset($fields['renews_on']); |
|
185 | 185 | } |
186 | 186 | |
187 | - if ( isset( $fields['gateway'] ) ) { |
|
188 | - unset( $fields['gateway'] ); |
|
187 | + if (isset($fields['gateway'])) { |
|
188 | + unset($fields['gateway']); |
|
189 | 189 | } |
190 | 190 | } |
191 | 191 | |
192 | 192 | $profile_id = $sub->get_profile_id(); |
193 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
194 | - unset( $fields['profile_id'] ); |
|
193 | + if (empty($profile_id) && isset($fields['profile_id'])) { |
|
194 | + unset($fields['profile_id']); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | ?> |
@@ -199,16 +199,16 @@ discard block |
||
199 | 199 | <table class="table table-borderless" style="font-size: 14px;"> |
200 | 200 | <tbody> |
201 | 201 | |
202 | - <?php foreach ( $fields as $key => $label ) : ?> |
|
202 | + <?php foreach ($fields as $key => $label) : ?> |
|
203 | 203 | |
204 | - <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class( $key ); ?>"> |
|
204 | + <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class($key); ?>"> |
|
205 | 205 | |
206 | 206 | <th class="w-25" style="font-weight: 500;"> |
207 | - <?php echo esc_html( $label ); ?> |
|
207 | + <?php echo esc_html($label); ?> |
|
208 | 208 | </th> |
209 | 209 | |
210 | 210 | <td class="w-75 text-muted"> |
211 | - <?php do_action( 'getpaid_subscription_admin_display_' . sanitize_key( $key ), $sub, $subscription_group ); ?> |
|
211 | + <?php do_action('getpaid_subscription_admin_display_' . sanitize_key($key), $sub, $subscription_group); ?> |
|
212 | 212 | </td> |
213 | 213 | |
214 | 214 | </tr> |
@@ -226,135 +226,135 @@ discard block |
||
226 | 226 | * |
227 | 227 | * @param WPInv_Subscription $subscription |
228 | 228 | */ |
229 | -function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
|
229 | +function getpaid_admin_subscription_metabox_display_customer($subscription) { |
|
230 | 230 | |
231 | - $username = __( '(Missing User)', 'invoicing' ); |
|
231 | + $username = __('(Missing User)', 'invoicing'); |
|
232 | 232 | |
233 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
234 | - if ( $user ) { |
|
233 | + $user = get_userdata($subscription->get_customer_id()); |
|
234 | + if ($user) { |
|
235 | 235 | |
236 | 236 | $username = sprintf( |
237 | 237 | '<a href="user-edit.php?user_id=%s">%s</a>', |
238 | - absint( $user->ID ), |
|
239 | - ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email ) |
|
238 | + absint($user->ID), |
|
239 | + !empty($user->display_name) ? esc_html($user->display_name) : sanitize_email($user->user_email) |
|
240 | 240 | ); |
241 | 241 | |
242 | 242 | } |
243 | 243 | |
244 | - echo wp_kses_post( $username ); |
|
244 | + echo wp_kses_post($username); |
|
245 | 245 | } |
246 | -add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
|
246 | +add_action('getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer'); |
|
247 | 247 | |
248 | 248 | /** |
249 | 249 | * Displays the subscription amount. |
250 | 250 | * |
251 | 251 | * @param WPInv_Subscription $subscription |
252 | 252 | */ |
253 | -function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
|
254 | - $amount = getpaid_get_formatted_subscription_amount( $subscription ); |
|
255 | - echo wp_kses_post( "<span>$amount</span>" ); |
|
253 | +function getpaid_admin_subscription_metabox_display_amount($subscription) { |
|
254 | + $amount = getpaid_get_formatted_subscription_amount($subscription); |
|
255 | + echo wp_kses_post("<span>$amount</span>"); |
|
256 | 256 | } |
257 | -add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
|
257 | +add_action('getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount'); |
|
258 | 258 | |
259 | 259 | /** |
260 | 260 | * Displays the subscription id. |
261 | 261 | * |
262 | 262 | * @param WPInv_Subscription $subscription |
263 | 263 | */ |
264 | -function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
|
264 | +function getpaid_admin_subscription_metabox_display_id($subscription) { |
|
265 | 265 | |
266 | 266 | printf( |
267 | 267 | '<a href="%s">#%s</a>', |
268 | - esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ), |
|
269 | - absint( $subscription->get_id() ) |
|
268 | + esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($subscription->get_id()))), |
|
269 | + absint($subscription->get_id()) |
|
270 | 270 | ); |
271 | 271 | |
272 | 272 | } |
273 | -add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
|
273 | +add_action('getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id'); |
|
274 | 274 | |
275 | 275 | /** |
276 | 276 | * Displays the subscription renewal date. |
277 | 277 | * |
278 | 278 | * @param WPInv_Subscription $subscription |
279 | 279 | */ |
280 | -function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
|
281 | - echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) ); |
|
280 | +function getpaid_admin_subscription_metabox_display_start_date($subscription) { |
|
281 | + echo esc_html(getpaid_format_date_value($subscription->get_date_created())); |
|
282 | 282 | } |
283 | -add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
|
283 | +add_action('getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date'); |
|
284 | 284 | |
285 | 285 | /** |
286 | 286 | * Displays the subscription renewal date. |
287 | 287 | * |
288 | 288 | * @param WPInv_Subscription $subscription |
289 | 289 | */ |
290 | -function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
|
291 | - echo esc_html( getpaid_format_date_value( $subscription->get_expiration() ) ); |
|
290 | +function getpaid_admin_subscription_metabox_display_renews_on($subscription) { |
|
291 | + echo esc_html(getpaid_format_date_value($subscription->get_expiration())); |
|
292 | 292 | } |
293 | -add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
|
293 | +add_action('getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on'); |
|
294 | 294 | |
295 | 295 | /** |
296 | 296 | * Displays the subscription renewal count. |
297 | 297 | * |
298 | 298 | * @param WPInv_Subscription $subscription |
299 | 299 | */ |
300 | -function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
|
300 | +function getpaid_admin_subscription_metabox_display_renewals($subscription) { |
|
301 | 301 | $max_bills = $subscription->get_bill_times(); |
302 | - echo ( (int) $subscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
302 | + echo ((int) $subscription->get_times_billed()) . ' / ' . (empty($max_bills) ? '∞' : (int) $max_bills); |
|
303 | 303 | } |
304 | -add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
|
304 | +add_action('getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals'); |
|
305 | 305 | /** |
306 | 306 | * Displays the subscription item. |
307 | 307 | * |
308 | 308 | * @param WPInv_Subscription $subscription |
309 | 309 | * @param false|array $subscription_group |
310 | 310 | */ |
311 | -function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) { |
|
311 | +function getpaid_admin_subscription_metabox_display_item($subscription, $subscription_group = false) { |
|
312 | 312 | |
313 | - if ( empty( $subscription_group ) ) { |
|
314 | - echo WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ); |
|
313 | + if (empty($subscription_group)) { |
|
314 | + echo WPInv_Subscriptions_List_Table::generate_item_markup($subscription->get_product_id()); |
|
315 | 315 | return; |
316 | 316 | } |
317 | 317 | |
318 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
319 | - echo wp_kses_post( implode( ' | ', $markup ) ); |
|
318 | + $markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
319 | + echo wp_kses_post(implode(' | ', $markup)); |
|
320 | 320 | |
321 | 321 | } |
322 | -add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 ); |
|
322 | +add_action('getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2); |
|
323 | 323 | |
324 | 324 | /** |
325 | 325 | * Displays the subscription gateway. |
326 | 326 | * |
327 | 327 | * @param WPInv_Subscription $subscription |
328 | 328 | */ |
329 | -function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
|
329 | +function getpaid_admin_subscription_metabox_display_gateway($subscription) { |
|
330 | 330 | |
331 | 331 | $gateway = $subscription->get_gateway(); |
332 | 332 | |
333 | - if ( ! empty( $gateway ) ) { |
|
334 | - echo esc_html( wpinv_get_gateway_admin_label( $gateway ) ); |
|
333 | + if (!empty($gateway)) { |
|
334 | + echo esc_html(wpinv_get_gateway_admin_label($gateway)); |
|
335 | 335 | } else { |
336 | 336 | echo '—'; |
337 | 337 | } |
338 | 338 | |
339 | 339 | } |
340 | -add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
|
340 | +add_action('getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway'); |
|
341 | 341 | |
342 | 342 | /** |
343 | 343 | * Displays the subscription status. |
344 | 344 | * |
345 | 345 | * @param WPInv_Subscription $subscription |
346 | 346 | */ |
347 | -function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
|
348 | - echo wp_kses_post( $subscription->get_status_label_html() ); |
|
347 | +function getpaid_admin_subscription_metabox_display_status($subscription) { |
|
348 | + echo wp_kses_post($subscription->get_status_label_html()); |
|
349 | 349 | } |
350 | -add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
|
350 | +add_action('getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status'); |
|
351 | 351 | |
352 | 352 | /** |
353 | 353 | * Displays the subscription profile id. |
354 | 354 | * |
355 | 355 | * @param WPInv_Subscription $subscription |
356 | 356 | */ |
357 | -function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
|
357 | +function getpaid_admin_subscription_metabox_display_profile_id($subscription) { |
|
358 | 358 | |
359 | 359 | $profile_id = $subscription->get_profile_id(); |
360 | 360 | |
@@ -363,31 +363,31 @@ discard block |
||
363 | 363 | 'type' => 'text', |
364 | 364 | 'id' => 'wpinv_subscription_profile_id', |
365 | 365 | 'name' => 'wpinv_subscription_profile_id', |
366 | - 'label' => __( 'Profile Id', 'invoicing' ), |
|
366 | + 'label' => __('Profile Id', 'invoicing'), |
|
367 | 367 | 'label_type' => 'hidden', |
368 | - 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
369 | - 'value' => esc_attr( $profile_id ), |
|
368 | + 'placeholder' => __('Profile Id', 'invoicing'), |
|
369 | + 'value' => esc_attr($profile_id), |
|
370 | 370 | 'input_group_right' => '', |
371 | 371 | 'no_wrap' => true, |
372 | 372 | ) |
373 | 373 | ); |
374 | 374 | |
375 | - echo str_ireplace( 'form-control', 'regular-text', $input ); |
|
375 | + echo str_ireplace('form-control', 'regular-text', $input); |
|
376 | 376 | |
377 | - $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
378 | - if ( ! empty( $url ) ) { |
|
379 | - echo ' <a href="' . esc_url_raw( $url ) . '" title="' . __( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
377 | + $url = apply_filters('getpaid_remote_subscription_profile_url', '', $subscription); |
|
378 | + if (!empty($url)) { |
|
379 | + echo ' <a href="' . esc_url_raw($url) . '" title="' . __('View in Gateway', 'invoicing') . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | } |
383 | -add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
|
383 | +add_action('getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id'); |
|
384 | 384 | |
385 | 385 | /** |
386 | 386 | * Displays the subscriptions update metabox. |
387 | 387 | * |
388 | 388 | * @param WPInv_Subscription $subscription |
389 | 389 | */ |
390 | -function getpaid_admin_subscription_update_metabox( $subscription ) { |
|
390 | +function getpaid_admin_subscription_update_metabox($subscription) { |
|
391 | 391 | |
392 | 392 | ?> |
393 | 393 | <div class="mt-3"> |
@@ -400,10 +400,10 @@ discard block |
||
400 | 400 | 'id' => 'subscription_status_update_select', |
401 | 401 | 'required' => true, |
402 | 402 | 'no_wrap' => false, |
403 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
404 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
403 | + 'label' => __('Subscription Status', 'invoicing'), |
|
404 | + 'help_text' => __('Updating the status will trigger related actions and hooks', 'invoicing'), |
|
405 | 405 | 'select2' => true, |
406 | - 'value' => $subscription->get_status( 'edit' ), |
|
406 | + 'value' => $subscription->get_status('edit'), |
|
407 | 407 | ), |
408 | 408 | true |
409 | 409 | ); |
@@ -412,13 +412,13 @@ discard block |
||
412 | 412 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;"> |
413 | 413 | |
414 | 414 | <?php |
415 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
415 | + submit_button(__('Update', 'invoicing'), 'primary', 'submit', false); |
|
416 | 416 | |
417 | - $url = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
418 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
419 | - $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' ); |
|
417 | + $url = wp_nonce_url(add_query_arg('getpaid-admin-action', 'subscription_manual_renew'), 'getpaid-nonce', 'getpaid-nonce'); |
|
418 | + $anchor = __('Renew Subscription', 'invoicing'); |
|
419 | + $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'); |
|
420 | 420 | |
421 | - if ( $subscription->is_active() ) { |
|
421 | + if ($subscription->is_active()) { |
|
422 | 422 | echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>"; |
423 | 423 | } |
424 | 424 | |
@@ -431,45 +431,45 @@ discard block |
||
431 | 431 | * @param WPInv_Subscription $subscription |
432 | 432 | * @param bool $strict Whether or not to skip invoices of sibling subscriptions |
433 | 433 | */ |
434 | -function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) { |
|
434 | +function getpaid_admin_subscription_invoice_details_metabox($subscription, $strict = true) { |
|
435 | 435 | |
436 | 436 | $columns = apply_filters( |
437 | 437 | 'getpaid_subscription_related_invoices_columns', |
438 | 438 | array( |
439 | - 'invoice' => __( 'Invoice', 'invoicing' ), |
|
440 | - 'relationship' => __( 'Relationship', 'invoicing' ), |
|
441 | - 'date' => __( 'Date', 'invoicing' ), |
|
442 | - 'status' => __( 'Status', 'invoicing' ), |
|
443 | - 'total' => __( 'Total', 'invoicing' ), |
|
439 | + 'invoice' => __('Invoice', 'invoicing'), |
|
440 | + 'relationship' => __('Relationship', 'invoicing'), |
|
441 | + 'date' => __('Date', 'invoicing'), |
|
442 | + 'status' => __('Status', 'invoicing'), |
|
443 | + 'total' => __('Total', 'invoicing'), |
|
444 | 444 | ), |
445 | 445 | $subscription |
446 | 446 | ); |
447 | 447 | |
448 | 448 | // Prepare the invoices. |
449 | - $payments = $subscription->get_child_payments( ! is_admin() ); |
|
449 | + $payments = $subscription->get_child_payments(!is_admin()); |
|
450 | 450 | $parent = $subscription->get_parent_invoice(); |
451 | 451 | |
452 | - if ( $parent->exists() ) { |
|
453 | - $payments = array_merge( array( $parent ), $payments ); |
|
452 | + if ($parent->exists()) { |
|
453 | + $payments = array_merge(array($parent), $payments); |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | $table_class = 'w-100 bg-white'; |
457 | 457 | |
458 | - if ( ! is_admin() ) { |
|
458 | + if (!is_admin()) { |
|
459 | 459 | $table_class = 'table table-bordered'; |
460 | 460 | } |
461 | 461 | |
462 | 462 | ?> |
463 | 463 | <div class="m-0" style="overflow: auto;"> |
464 | 464 | |
465 | - <table class="<?php echo esc_attr( $table_class ); ?>"> |
|
465 | + <table class="<?php echo esc_attr($table_class); ?>"> |
|
466 | 466 | |
467 | 467 | <thead> |
468 | 468 | <tr> |
469 | 469 | <?php |
470 | - foreach ( $columns as $key => $label ) { |
|
471 | - $key = esc_attr( $key ); |
|
472 | - $label = esc_html( $label ); |
|
470 | + foreach ($columns as $key => $label) { |
|
471 | + $key = esc_attr($key); |
|
472 | + $label = esc_html($label); |
|
473 | 473 | $class = 'text-left'; |
474 | 474 | |
475 | 475 | echo "<th class='subscription-invoice-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
@@ -480,70 +480,70 @@ discard block |
||
480 | 480 | |
481 | 481 | <tbody> |
482 | 482 | |
483 | - <?php if ( empty( $payments ) ) : ?> |
|
483 | + <?php if (empty($payments)) : ?> |
|
484 | 484 | <tr> |
485 | - <td colspan="<?php echo count( $columns ); ?>" class="p-2 text-left text-muted"> |
|
486 | - <?php esc_html_e( 'This subscription has no invoices.', 'invoicing' ); ?> |
|
485 | + <td colspan="<?php echo count($columns); ?>" class="p-2 text-left text-muted"> |
|
486 | + <?php esc_html_e('This subscription has no invoices.', 'invoicing'); ?> |
|
487 | 487 | </td> |
488 | 488 | </tr> |
489 | 489 | <?php endif; ?> |
490 | 490 | |
491 | 491 | <?php |
492 | 492 | |
493 | - foreach ( $payments as $payment ) : |
|
493 | + foreach ($payments as $payment) : |
|
494 | 494 | |
495 | 495 | // Ensure that we have an invoice. |
496 | - $payment = new WPInv_Invoice( $payment ); |
|
496 | + $payment = new WPInv_Invoice($payment); |
|
497 | 497 | |
498 | 498 | // Abort if the invoice is invalid... |
499 | - if ( ! $payment->exists() ) { |
|
499 | + if (!$payment->exists()) { |
|
500 | 500 | continue; |
501 | 501 | } |
502 | 502 | |
503 | 503 | // ... or belongs to a different subscription. |
504 | - if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
504 | + if ($strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id()) { |
|
505 | 505 | continue; |
506 | 506 | } |
507 | 507 | |
508 | 508 | echo '<tr>'; |
509 | 509 | |
510 | - foreach ( array_keys( $columns ) as $key ) { |
|
510 | + foreach (array_keys($columns) as $key) { |
|
511 | 511 | |
512 | 512 | $class = 'text-left'; |
513 | 513 | |
514 | 514 | echo "<td class='p-2 text-left'>"; |
515 | 515 | |
516 | - switch ( $key ) { |
|
516 | + switch ($key) { |
|
517 | 517 | |
518 | 518 | case 'total': |
519 | - echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>'; |
|
519 | + echo '<strong>' . wpinv_price($payment->get_total(), $payment->get_currency()) . '</strong>'; |
|
520 | 520 | break; |
521 | 521 | |
522 | 522 | case 'relationship': |
523 | - echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' ); |
|
523 | + echo $payment->is_renewal() ? esc_html__('Renewal Invoice', 'invoicing') : esc_html__('Initial Invoice', 'invoicing'); |
|
524 | 524 | break; |
525 | 525 | |
526 | 526 | case 'date': |
527 | - echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) ); |
|
527 | + echo esc_html(getpaid_format_date_value($payment->get_date_created())); |
|
528 | 528 | break; |
529 | 529 | |
530 | 530 | case 'status': |
531 | 531 | $status = $payment->get_status_nicename(); |
532 | - if ( is_admin() ) { |
|
532 | + if (is_admin()) { |
|
533 | 533 | $status = $payment->get_status_label_html(); |
534 | 534 | } |
535 | 535 | |
536 | - echo wp_kses_post( $status ); |
|
536 | + echo wp_kses_post($status); |
|
537 | 537 | break; |
538 | 538 | |
539 | 539 | case 'invoice': |
540 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
540 | + $link = esc_url(get_edit_post_link($payment->get_id())); |
|
541 | 541 | |
542 | - if ( ! is_admin() ) { |
|
543 | - $link = esc_url( $payment->get_view_url() ); |
|
542 | + if (!is_admin()) { |
|
543 | + $link = esc_url($payment->get_view_url()); |
|
544 | 544 | } |
545 | 545 | |
546 | - $invoice = esc_html( $payment->get_number() ); |
|
546 | + $invoice = esc_html($payment->get_number()); |
|
547 | 547 | echo "<a href='$link'>$invoice</a>"; |
548 | 548 | break; |
549 | 549 | } |
@@ -571,12 +571,12 @@ discard block |
||
571 | 571 | * |
572 | 572 | * @param WPInv_Subscription $subscription |
573 | 573 | */ |
574 | -function getpaid_admin_subscription_item_details_metabox( $subscription ) { |
|
574 | +function getpaid_admin_subscription_item_details_metabox($subscription) { |
|
575 | 575 | |
576 | 576 | // Fetch the subscription group. |
577 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
577 | + $subscription_group = getpaid_get_invoice_subscription_group($subscription->get_parent_payment_id(), $subscription->get_id()); |
|
578 | 578 | |
579 | - if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
579 | + if (empty($subscription_group) || empty($subscription_group['items'])) { |
|
580 | 580 | return; |
581 | 581 | } |
582 | 582 | |
@@ -584,12 +584,12 @@ discard block |
||
584 | 584 | $columns = apply_filters( |
585 | 585 | 'getpaid_subscription_item_details_columns', |
586 | 586 | array( |
587 | - 'item_name' => __( 'Item', 'invoicing' ), |
|
588 | - 'price' => __( 'Price', 'invoicing' ), |
|
589 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
590 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
587 | + 'item_name' => __('Item', 'invoicing'), |
|
588 | + 'price' => __('Price', 'invoicing'), |
|
589 | + 'tax' => __('Tax', 'invoicing'), |
|
590 | + 'discount' => __('Discount', 'invoicing'), |
|
591 | 591 | //'initial' => __( 'Initial Amount', 'invoicing' ), |
592 | - 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
592 | + 'recurring' => __('Subtotal', 'invoicing'), |
|
593 | 593 | ), |
594 | 594 | $subscription |
595 | 595 | ); |
@@ -598,28 +598,28 @@ discard block |
||
598 | 598 | |
599 | 599 | $invoice = $subscription->get_parent_invoice(); |
600 | 600 | |
601 | - if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
602 | - unset( $columns['tax'] ); |
|
601 | + if ((!wpinv_use_taxes() || !$invoice->is_taxable()) && isset($columns['tax'])) { |
|
602 | + unset($columns['tax']); |
|
603 | 603 | } |
604 | 604 | |
605 | 605 | $table_class = 'w-100 bg-white'; |
606 | 606 | |
607 | - if ( ! is_admin() ) { |
|
607 | + if (!is_admin()) { |
|
608 | 608 | $table_class = 'table table-bordered'; |
609 | 609 | } |
610 | 610 | |
611 | 611 | ?> |
612 | 612 | <div class="m-0" style="overflow: auto;"> |
613 | 613 | |
614 | - <table class="<?php echo esc_attr( $table_class ); ?>"> |
|
614 | + <table class="<?php echo esc_attr($table_class); ?>"> |
|
615 | 615 | |
616 | 616 | <thead> |
617 | 617 | <tr> |
618 | 618 | <?php |
619 | 619 | |
620 | - foreach ( $columns as $key => $label ) { |
|
621 | - $key = esc_attr( $key ); |
|
622 | - $label = esc_html( $label ); |
|
620 | + foreach ($columns as $key => $label) { |
|
621 | + $key = esc_attr($key); |
|
622 | + $label = esc_html($label); |
|
623 | 623 | $class = 'text-left'; |
624 | 624 | |
625 | 625 | echo "<th class='subscription-item-field-$key bg-light p-2 text-left color-dark font-weight-bold'>$label</th>"; |
@@ -632,48 +632,48 @@ discard block |
||
632 | 632 | |
633 | 633 | <?php |
634 | 634 | |
635 | - foreach ( $subscription_group['items'] as $subscription_group_item ) : |
|
635 | + foreach ($subscription_group['items'] as $subscription_group_item) : |
|
636 | 636 | |
637 | 637 | echo '<tr>'; |
638 | 638 | |
639 | - foreach ( array_keys( $columns ) as $key ) { |
|
639 | + foreach (array_keys($columns) as $key) { |
|
640 | 640 | |
641 | 641 | $class = 'text-left'; |
642 | 642 | |
643 | 643 | echo "<td class='p-2 text-left'>"; |
644 | 644 | |
645 | - switch ( $key ) { |
|
645 | + switch ($key) { |
|
646 | 646 | |
647 | 647 | case 'item_name': |
648 | - $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
649 | - $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
648 | + $item_name = get_the_title($subscription_group_item['item_id']); |
|
649 | + $item_name = empty($item_name) ? $subscription_group_item['item_name'] : $item_name; |
|
650 | 650 | |
651 | - if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
652 | - echo esc_html( $item_name ); |
|
651 | + if ($invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity']) { |
|
652 | + echo esc_html($item_name); |
|
653 | 653 | } else { |
654 | - printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
654 | + printf('%1$s x %2$d', esc_html($item_name), (float) $subscription_group_item['quantity']); |
|
655 | 655 | } |
656 | 656 | |
657 | 657 | break; |
658 | 658 | |
659 | 659 | case 'price': |
660 | - wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
660 | + wpinv_the_price($subscription_group_item['item_price'], $invoice->get_currency()); |
|
661 | 661 | break; |
662 | 662 | |
663 | 663 | case 'tax': |
664 | - wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
664 | + wpinv_the_price($subscription_group_item['tax'], $invoice->get_currency()); |
|
665 | 665 | break; |
666 | 666 | |
667 | 667 | case 'discount': |
668 | - wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
668 | + wpinv_the_price($subscription_group_item['discount'], $invoice->get_currency()); |
|
669 | 669 | break; |
670 | 670 | |
671 | 671 | case 'initial': |
672 | - wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
672 | + wpinv_the_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()); |
|
673 | 673 | break; |
674 | 674 | |
675 | 675 | case 'recurring': |
676 | - echo '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>'; |
|
676 | + echo '<strong>' . wpinv_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()) . '</strong>'; |
|
677 | 677 | break; |
678 | 678 | |
679 | 679 | } |
@@ -686,24 +686,24 @@ discard block |
||
686 | 686 | |
687 | 687 | endforeach; |
688 | 688 | |
689 | - foreach ( $subscription_group['fees'] as $subscription_group_fee ) : |
|
689 | + foreach ($subscription_group['fees'] as $subscription_group_fee) : |
|
690 | 690 | |
691 | 691 | echo '<tr>'; |
692 | 692 | |
693 | - foreach ( array_keys( $columns ) as $key ) { |
|
693 | + foreach (array_keys($columns) as $key) { |
|
694 | 694 | |
695 | 695 | $class = 'text-left'; |
696 | 696 | |
697 | 697 | echo "<td class='p-2 text-left'>"; |
698 | 698 | |
699 | - switch ( $key ) { |
|
699 | + switch ($key) { |
|
700 | 700 | |
701 | 701 | case 'item_name': |
702 | - echo esc_html( $subscription_group_fee['name'] ); |
|
702 | + echo esc_html($subscription_group_fee['name']); |
|
703 | 703 | break; |
704 | 704 | |
705 | 705 | case 'price': |
706 | - wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
706 | + wpinv_the_price($subscription_group_fee['initial_fee'], $invoice->get_currency()); |
|
707 | 707 | break; |
708 | 708 | |
709 | 709 | case 'tax': |
@@ -715,11 +715,11 @@ discard block |
||
715 | 715 | break; |
716 | 716 | |
717 | 717 | case 'initial': |
718 | - wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
718 | + wpinv_the_price($subscription_group_fee['initial_fee'], $invoice->get_currency()); |
|
719 | 719 | break; |
720 | 720 | |
721 | 721 | case 'recurring': |
722 | - echo '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>'; |
|
722 | + echo '<strong>' . wpinv_price($subscription_group_fee['recurring_fee'], $invoice->get_currency()) . '</strong>'; |
|
723 | 723 | break; |
724 | 724 | |
725 | 725 | } |
@@ -748,12 +748,12 @@ discard block |
||
748 | 748 | * @param WPInv_Subscription $subscription |
749 | 749 | * @param bool $skip_current |
750 | 750 | */ |
751 | -function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) { |
|
751 | +function getpaid_admin_subscription_related_subscriptions_metabox($subscription, $skip_current = true) { |
|
752 | 752 | |
753 | 753 | // Fetch the subscription groups. |
754 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
754 | + $subscription_groups = getpaid_get_invoice_subscription_groups($subscription->get_parent_payment_id()); |
|
755 | 755 | |
756 | - if ( empty( $subscription_groups ) ) { |
|
756 | + if (empty($subscription_groups)) { |
|
757 | 757 | return; |
758 | 758 | } |
759 | 759 | |
@@ -761,38 +761,38 @@ discard block |
||
761 | 761 | $columns = apply_filters( |
762 | 762 | 'getpaid_subscription_related_subscriptions_columns', |
763 | 763 | array( |
764 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
765 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
766 | - 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
767 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
768 | - 'item' => __( 'Items', 'invoicing' ), |
|
769 | - 'status' => __( 'Status', 'invoicing' ), |
|
764 | + 'subscription' => __('Subscription', 'invoicing'), |
|
765 | + 'start_date' => __('Start Date', 'invoicing'), |
|
766 | + 'renewal_date' => __('Next Payment', 'invoicing'), |
|
767 | + 'renewals' => __('Payments', 'invoicing'), |
|
768 | + 'item' => __('Items', 'invoicing'), |
|
769 | + 'status' => __('Status', 'invoicing'), |
|
770 | 770 | ), |
771 | 771 | $subscription |
772 | 772 | ); |
773 | 773 | |
774 | - if ( $subscription->get_status() == 'pending' ) { |
|
775 | - unset( $columns['start_date'], $columns['renewal_date'] ); |
|
774 | + if ($subscription->get_status() == 'pending') { |
|
775 | + unset($columns['start_date'], $columns['renewal_date']); |
|
776 | 776 | } |
777 | 777 | |
778 | 778 | $table_class = 'w-100 bg-white'; |
779 | 779 | |
780 | - if ( ! is_admin() ) { |
|
780 | + if (!is_admin()) { |
|
781 | 781 | $table_class = 'table table-bordered'; |
782 | 782 | } |
783 | 783 | |
784 | 784 | ?> |
785 | 785 | <div class="m-0" style="overflow: auto;"> |
786 | 786 | |
787 | - <table class="<?php echo esc_attr( $table_class ); ?>"> |
|
787 | + <table class="<?php echo esc_attr($table_class); ?>"> |
|
788 | 788 | |
789 | 789 | <thead> |
790 | 790 | <tr> |
791 | 791 | <?php |
792 | 792 | |
793 | - foreach ( $columns as $key => $label ) { |
|
794 | - $key = esc_attr( $key ); |
|
795 | - $label = esc_html( $label ); |
|
793 | + foreach ($columns as $key => $label) { |
|
794 | + $key = esc_attr($key); |
|
795 | + $label = esc_html($label); |
|
796 | 796 | $class = 'text-left'; |
797 | 797 | |
798 | 798 | echo "<th class='related-subscription-field-$key bg-light p-2 text-left color-dark font-weight-bold'>$label</th>"; |
@@ -805,62 +805,62 @@ discard block |
||
805 | 805 | |
806 | 806 | <?php |
807 | 807 | |
808 | - foreach ( $subscription_groups as $subscription_group ) : |
|
808 | + foreach ($subscription_groups as $subscription_group) : |
|
809 | 809 | |
810 | 810 | // Do not list current subscription. |
811 | - if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
811 | + if ($skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id()) { |
|
812 | 812 | continue; |
813 | 813 | } |
814 | 814 | |
815 | 815 | // Ensure the subscription exists. |
816 | - $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
816 | + $_suscription = new WPInv_Subscription($subscription_group['subscription_id']); |
|
817 | 817 | |
818 | - if ( ! $_suscription->exists() ) { |
|
818 | + if (!$_suscription->exists()) { |
|
819 | 819 | continue; |
820 | 820 | } |
821 | 821 | |
822 | 822 | echo '<tr>'; |
823 | 823 | |
824 | - foreach ( array_keys( $columns ) as $key ) { |
|
824 | + foreach (array_keys($columns) as $key) { |
|
825 | 825 | |
826 | 826 | $class = 'text-left'; |
827 | 827 | |
828 | 828 | echo "<td class='p-2 text-left'>"; |
829 | 829 | |
830 | - switch ( $key ) { |
|
830 | + switch ($key) { |
|
831 | 831 | |
832 | 832 | case 'status': |
833 | - echo wp_kses_post( $_suscription->get_status_label_html() ); |
|
833 | + echo wp_kses_post($_suscription->get_status_label_html()); |
|
834 | 834 | break; |
835 | 835 | |
836 | 836 | case 'item': |
837 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
838 | - echo implode( ' | ', $markup ); |
|
837 | + $markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
838 | + echo implode(' | ', $markup); |
|
839 | 839 | break; |
840 | 840 | |
841 | 841 | case 'renewals': |
842 | 842 | $max_bills = $_suscription->get_bill_times(); |
843 | - echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
843 | + echo ((int) $_suscription->get_times_billed()) . ' / ' . (empty($max_bills) ? '∞' : (int) $max_bills); |
|
844 | 844 | break; |
845 | 845 | |
846 | 846 | case 'renewal_date': |
847 | - echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : '—'; |
|
847 | + echo $_suscription->is_active() ? getpaid_format_date_value($_suscription->get_expiration()) : '—'; |
|
848 | 848 | break; |
849 | 849 | |
850 | 850 | case 'start_date': |
851 | - echo 'pending' == $_suscription->get_status() ? '—' : getpaid_format_date_value( $_suscription->get_date_created() ); |
|
851 | + echo 'pending' == $_suscription->get_status() ? '—' : getpaid_format_date_value($_suscription->get_date_created()); |
|
852 | 852 | break; |
853 | 853 | |
854 | 854 | case 'subscription': |
855 | - $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
855 | + $url = is_admin() ? admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($_suscription->get_id())) : $_suscription->get_view_url(); |
|
856 | 856 | printf( |
857 | 857 | '%1$s#%2$s%3$s', |
858 | - '<a href="' . esc_url( $url ) . '">', |
|
859 | - '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
|
858 | + '<a href="' . esc_url($url) . '">', |
|
859 | + '<strong>' . intval($_suscription->get_id()) . '</strong>', |
|
860 | 860 | '</a>' |
861 | 861 | ); |
862 | 862 | |
863 | - echo WPInv_Subscriptions_List_Table::column_amount( $_suscription ); |
|
863 | + echo WPInv_Subscriptions_List_Table::column_amount($_suscription); |
|
864 | 864 | break; |
865 | 865 | |
866 | 866 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( ! defined( 'WPINC' ) ) { |
|
10 | +if (!defined('WPINC')) { |
|
11 | 11 | exit; |
12 | 12 | } |
13 | 13 | |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | private static $instance; |
16 | 16 | |
17 | 17 | public static function run() { |
18 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WPInv_Admin_Users ) ) { |
|
18 | + if (!isset(self::$instance) && !(self::$instance instanceof WPInv_Admin_Users)) { |
|
19 | 19 | self::$instance = new WPInv_Admin_Users(); |
20 | 20 | } |
21 | 21 | |
@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | } |
24 | 24 | |
25 | 25 | public function __construct() { |
26 | - add_filter( 'manage_users_columns', array( $this, 'wpinv_add_user_column' ) ); |
|
27 | - add_filter( 'manage_users_custom_column', array( $this, 'wpinv_user_column_content' ), 10, 3 ); |
|
26 | + add_filter('manage_users_columns', array($this, 'wpinv_add_user_column')); |
|
27 | + add_filter('manage_users_custom_column', array($this, 'wpinv_user_column_content'), 10, 3); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | * |
35 | 35 | * @return mixed |
36 | 36 | */ |
37 | - public function wpinv_add_user_column( $column ) { |
|
38 | - $column['wpinvoicing'] = __( 'Invoicing', 'invoicing' ); |
|
37 | + public function wpinv_add_user_column($column) { |
|
38 | + $column['wpinvoicing'] = __('Invoicing', 'invoicing'); |
|
39 | 39 | return $column; |
40 | 40 | } |
41 | 41 | |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @return string |
50 | 50 | */ |
51 | - public function wpinv_user_column_content( $val, $column_name, $user_id ) { |
|
52 | - switch ( $column_name ) { |
|
51 | + public function wpinv_user_column_content($val, $column_name, $user_id) { |
|
52 | + switch ($column_name) { |
|
53 | 53 | case 'wpinvoicing': |
54 | - return $this->get_user_invoices( $user_id ); |
|
54 | + return $this->get_user_invoices($user_id); |
|
55 | 55 | break; |
56 | 56 | default: |
57 | 57 | } |
@@ -65,30 +65,30 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @return string |
67 | 67 | */ |
68 | - public function get_user_invoices( $user_id ) { |
|
68 | + public function get_user_invoices($user_id) { |
|
69 | 69 | $output = ''; |
70 | 70 | $wp_query_args = array( |
71 | 71 | 'post_type' => 'wpi_invoice', |
72 | - 'post_status' => array( 'wpi-pending', 'publish', 'wpi-processing', 'wpi-onhold', 'wpi-refunded', 'wpi-cancelled', 'wpi-failed', 'wpi-renewal' ), |
|
72 | + 'post_status' => array('wpi-pending', 'publish', 'wpi-processing', 'wpi-onhold', 'wpi-refunded', 'wpi-cancelled', 'wpi-failed', 'wpi-renewal'), |
|
73 | 73 | 'posts_per_page' => -1, |
74 | 74 | 'fields' => 'ids', |
75 | 75 | 'author' => $user_id, |
76 | 76 | ); |
77 | 77 | |
78 | - $wp_query_args = apply_filters( 'wpinv_get_user_invoices_args', $wp_query_args, $user_id ); |
|
78 | + $wp_query_args = apply_filters('wpinv_get_user_invoices_args', $wp_query_args, $user_id); |
|
79 | 79 | |
80 | - $invoices = new WP_Query( $wp_query_args ); |
|
81 | - $count = absint( $invoices->found_posts ); |
|
80 | + $invoices = new WP_Query($wp_query_args); |
|
81 | + $count = absint($invoices->found_posts); |
|
82 | 82 | |
83 | - if ( empty( $count ) ) { |
|
84 | - $output .= __( 'No Invoice(s)', 'invoicing' ); |
|
83 | + if (empty($count)) { |
|
84 | + $output .= __('No Invoice(s)', 'invoicing'); |
|
85 | 85 | } else { |
86 | - $link_url = admin_url( 'edit.php?post_type=wpi_invoice&author=' . absint( $user_id ) ); |
|
87 | - $link_text = sprintf( __( 'Invoices ( %d )', 'invoicing' ), $count ); |
|
86 | + $link_url = admin_url('edit.php?post_type=wpi_invoice&author=' . absint($user_id)); |
|
87 | + $link_text = sprintf(__('Invoices ( %d )', 'invoicing'), $count); |
|
88 | 88 | $output .= "<a href='$link_url' >$link_text</a>"; |
89 | 89 | } |
90 | 90 | |
91 | - return apply_filters( 'wpinv_user_invoice_content', $output, $user_id ); |
|
91 | + return apply_filters('wpinv_user_invoice_content', $output, $user_id); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | } |
@@ -7,81 +7,81 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( ! defined( 'WPINC' ) ) { |
|
10 | +if (!defined('WPINC')) { |
|
11 | 11 | exit; |
12 | 12 | } |
13 | 13 | |
14 | -function wpinv_bulk_actions( $actions ) { |
|
15 | - if ( isset( $actions['edit'] ) ) { |
|
16 | - unset( $actions['edit'] ); |
|
14 | +function wpinv_bulk_actions($actions) { |
|
15 | + if (isset($actions['edit'])) { |
|
16 | + unset($actions['edit']); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | return $actions; |
20 | 20 | } |
21 | -add_filter( 'bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions' ); |
|
22 | -add_filter( 'bulk_actions-edit-wpi_item', 'wpinv_bulk_actions' ); |
|
21 | +add_filter('bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions'); |
|
22 | +add_filter('bulk_actions-edit-wpi_item', 'wpinv_bulk_actions'); |
|
23 | 23 | |
24 | -function wpinv_admin_post_id( $id = 0 ) { |
|
24 | +function wpinv_admin_post_id($id = 0) { |
|
25 | 25 | global $post; |
26 | 26 | |
27 | - if ( isset( $id ) && ! empty( $id ) ) { |
|
28 | - return (int)$id; |
|
29 | - } elseif ( get_the_ID() ) { |
|
27 | + if (isset($id) && !empty($id)) { |
|
28 | + return (int) $id; |
|
29 | + } elseif (get_the_ID()) { |
|
30 | 30 | return (int) get_the_ID(); |
31 | - } elseif ( isset( $post->ID ) && ! empty( $post->ID ) ) { |
|
31 | + } elseif (isset($post->ID) && !empty($post->ID)) { |
|
32 | 32 | return (int) $post->ID; |
33 | - } elseif ( isset( $_GET['post'] ) && ! empty( $_GET['post'] ) ) { |
|
33 | + } elseif (isset($_GET['post']) && !empty($_GET['post'])) { |
|
34 | 34 | return (int) $_GET['post']; |
35 | - } elseif ( isset( $_GET['id'] ) && ! empty( $_GET['id'] ) ) { |
|
35 | + } elseif (isset($_GET['id']) && !empty($_GET['id'])) { |
|
36 | 36 | return (int) $_GET['id']; |
37 | - } elseif ( isset( $_POST['id'] ) && ! empty( $_POST['id'] ) ) { |
|
37 | + } elseif (isset($_POST['id']) && !empty($_POST['id'])) { |
|
38 | 38 | return (int) $_POST['id']; |
39 | 39 | } |
40 | 40 | |
41 | 41 | return null; |
42 | 42 | } |
43 | 43 | |
44 | -function wpinv_admin_post_type( $id = 0 ) { |
|
45 | - if ( ! $id ) { |
|
44 | +function wpinv_admin_post_type($id = 0) { |
|
45 | + if (!$id) { |
|
46 | 46 | $id = wpinv_admin_post_id(); |
47 | 47 | } |
48 | 48 | |
49 | - $type = get_post_type( $id ); |
|
49 | + $type = get_post_type($id); |
|
50 | 50 | |
51 | - if ( ! $type ) { |
|
52 | - $type = isset( $_GET['post_type'] ) && ! empty( $_GET['post_type'] ) ? sanitize_text_field( $_GET['post_type'] ) : null; |
|
51 | + if (!$type) { |
|
52 | + $type = isset($_GET['post_type']) && !empty($_GET['post_type']) ? sanitize_text_field($_GET['post_type']) : null; |
|
53 | 53 | } |
54 | 54 | |
55 | - return apply_filters( 'wpinv_admin_post_type', $type, $id ); |
|
55 | + return apply_filters('wpinv_admin_post_type', $type, $id); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | function wpinv_admin_messages() { |
59 | - settings_errors( 'wpinv-notices' ); |
|
59 | + settings_errors('wpinv-notices'); |
|
60 | 60 | } |
61 | -add_action( 'admin_notices', 'wpinv_admin_messages' ); |
|
61 | +add_action('admin_notices', 'wpinv_admin_messages'); |
|
62 | 62 | |
63 | -add_action( 'admin_init', 'wpinv_show_test_payment_gateway_notice' ); |
|
63 | +add_action('admin_init', 'wpinv_show_test_payment_gateway_notice'); |
|
64 | 64 | function wpinv_show_test_payment_gateway_notice() { |
65 | - add_action( 'admin_notices', 'wpinv_test_payment_gateway_messages' ); |
|
65 | + add_action('admin_notices', 'wpinv_test_payment_gateway_messages'); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | function wpinv_test_payment_gateway_messages() { |
69 | 69 | $gateways = wpinv_get_enabled_payment_gateways(); |
70 | 70 | $name = array(); $test_gateways = ''; |
71 | - if ( $gateways ) { |
|
72 | - foreach ( $gateways as $id => $gateway ) { |
|
73 | - if ( wpinv_is_test_mode( $id ) ) { |
|
71 | + if ($gateways) { |
|
72 | + foreach ($gateways as $id => $gateway) { |
|
73 | + if (wpinv_is_test_mode($id)) { |
|
74 | 74 | $name[] = $gateway['checkout_label']; |
75 | 75 | } |
76 | 76 | } |
77 | - $test_gateways = implode( ', ', $name ); |
|
77 | + $test_gateways = implode(', ', $name); |
|
78 | 78 | } |
79 | - if ( isset( $test_gateways ) && ! empty( $test_gateways ) && wpinv_current_user_can_manage_invoicing() ) { |
|
80 | - $link = admin_url( 'admin.php?page=wpinv-settings&tab=gateways' ); |
|
81 | - $notice = wp_sprintf( __( '<strong>Important:</strong> Payment Gateway(s) %1$s are in testing mode and will not receive real payments. Go to <a href="%2$s"> Gateway Settings</a>.', 'invoicing' ), $test_gateways, $link ); |
|
79 | + if (isset($test_gateways) && !empty($test_gateways) && wpinv_current_user_can_manage_invoicing()) { |
|
80 | + $link = admin_url('admin.php?page=wpinv-settings&tab=gateways'); |
|
81 | + $notice = wp_sprintf(__('<strong>Important:</strong> Payment Gateway(s) %1$s are in testing mode and will not receive real payments. Go to <a href="%2$s"> Gateway Settings</a>.', 'invoicing'), $test_gateways, $link); |
|
82 | 82 | ?> |
83 | 83 | <div class="notice notice-warning is-dismissible"> |
84 | - <p><?php echo wp_kses_post( $notice ); ?></p> |
|
84 | + <p><?php echo wp_kses_post($notice); ?></p> |
|
85 | 85 | </div> |
86 | 86 | <?php |
87 | 87 | } |
@@ -95,37 +95,37 @@ discard block |
||
95 | 95 | global $wpdb; |
96 | 96 | |
97 | 97 | // Only do this on our settings page. |
98 | - if ( empty( $_GET['page'] ) || 'wpinv-settings' !== $_GET['page'] ) { |
|
98 | + if (empty($_GET['page']) || 'wpinv-settings' !== $_GET['page']) { |
|
99 | 99 | return; |
100 | 100 | } |
101 | 101 | |
102 | 102 | // Check tables. |
103 | - $tables = array( |
|
103 | + $tables = array( |
|
104 | 104 | "{$wpdb->prefix}wpinv_subscriptions", |
105 | 105 | "{$wpdb->prefix}getpaid_invoices", |
106 | 106 | "{$wpdb->prefix}getpaid_invoice_items", |
107 | 107 | ); |
108 | 108 | |
109 | - foreach ( $tables as $table ) { |
|
110 | - if ( $table != $wpdb->get_var( "SHOW TABLES LIKE '$table'" ) ) { |
|
109 | + foreach ($tables as $table) { |
|
110 | + if ($table != $wpdb->get_var("SHOW TABLES LIKE '$table'")) { |
|
111 | 111 | |
112 | - $url = wp_nonce_url( |
|
113 | - add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ), |
|
112 | + $url = wp_nonce_url( |
|
113 | + add_query_arg('getpaid-admin-action', 'create_missing_tables'), |
|
114 | 114 | 'getpaid-nonce', |
115 | 115 | 'getpaid-nonce' |
116 | 116 | ); |
117 | - $message = __( 'Some GetPaid database tables are missing. To use GetPaid without any issues, click on the button below to create the missing tables.', 'invoicing' ); |
|
118 | - $message2 = __( 'Create Tables', 'invoicing' ); |
|
119 | - echo wp_kses_post( "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>" ); |
|
117 | + $message = __('Some GetPaid database tables are missing. To use GetPaid without any issues, click on the button below to create the missing tables.', 'invoicing'); |
|
118 | + $message2 = __('Create Tables', 'invoicing'); |
|
119 | + echo wp_kses_post("<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>"); |
|
120 | 120 | break; |
121 | 121 | |
122 | 122 | } |
123 | 123 | } |
124 | 124 | |
125 | 125 | } |
126 | -add_action( 'admin_notices', 'wpinv_check_for_missing_tables' ); |
|
126 | +add_action('admin_notices', 'wpinv_check_for_missing_tables'); |
|
127 | 127 | |
128 | -add_action( 'admin_init', 'wpinv_admin_search_by_invoice' ); |
|
128 | +add_action('admin_init', 'wpinv_admin_search_by_invoice'); |
|
129 | 129 | |
130 | 130 | /** |
131 | 131 | * hook the posts search if we're on the admin page for our type |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | function wpinv_admin_search_by_invoice() { |
134 | 134 | global $typenow; |
135 | 135 | |
136 | - if ( $typenow === 'wpi_invoice' || $typenow === 'wpi_quote' ) { |
|
137 | - add_filter( 'posts_search', 'wpinv_posts_search_example_type', 10, 2 ); |
|
136 | + if ($typenow === 'wpi_invoice' || $typenow === 'wpi_quote') { |
|
137 | + add_filter('posts_search', 'wpinv_posts_search_example_type', 10, 2); |
|
138 | 138 | } |
139 | 139 | } |
140 | 140 | |
@@ -144,13 +144,13 @@ discard block |
||
144 | 144 | * @param WP_Query $query |
145 | 145 | * @return string |
146 | 146 | */ |
147 | -function wpinv_posts_search_example_type( $search, $query ) { |
|
147 | +function wpinv_posts_search_example_type($search, $query) { |
|
148 | 148 | global $wpdb; |
149 | 149 | |
150 | - if ( $query->is_main_query() && ! empty( $query->query['s'] ) ) { |
|
151 | - $conditions_str = "{$wpdb->posts}.post_author IN ( SELECT ID FROM {$wpdb->users} WHERE user_email LIKE '%" . esc_sql( $query->query['s'] ) . "%' )"; |
|
152 | - if ( ! empty( $search ) ) { |
|
153 | - $search = preg_replace( '/^ AND /', '', $search ); |
|
150 | + if ($query->is_main_query() && !empty($query->query['s'])) { |
|
151 | + $conditions_str = "{$wpdb->posts}.post_author IN ( SELECT ID FROM {$wpdb->users} WHERE user_email LIKE '%" . esc_sql($query->query['s']) . "%' )"; |
|
152 | + if (!empty($search)) { |
|
153 | + $search = preg_replace('/^ AND /', '', $search); |
|
154 | 154 | $search = " AND ( {$search} OR ( {$conditions_str} ) )"; |
155 | 155 | } else { |
156 | 156 | $search = " AND ( {$conditions_str} )"; |
@@ -164,16 +164,16 @@ discard block |
||
164 | 164 | * Resets invoice counts. |
165 | 165 | */ |
166 | 166 | function wpinv_reset_invoice_count() { |
167 | - if ( ! empty( $_GET['reset_invoice_count'] ) && isset( $_GET['_nonce'] ) && wp_verify_nonce( sanitize_text_field( $_GET['_nonce'] ), 'reset_invoice_count' ) ) { |
|
168 | - wpinv_update_option( 'invoice_sequence_start', 1 ); |
|
169 | - delete_option( 'wpinv_last_invoice_number' ); |
|
170 | - getpaid_admin()->show_success( __( 'Invoice number sequence reset successfully.', 'invoicing' ) ); |
|
171 | - $url = remove_query_arg( array( 'reset_invoice_count', '_nonce' ) ); |
|
172 | - wp_redirect( $url ); |
|
167 | + if (!empty($_GET['reset_invoice_count']) && isset($_GET['_nonce']) && wp_verify_nonce(sanitize_text_field($_GET['_nonce']), 'reset_invoice_count')) { |
|
168 | + wpinv_update_option('invoice_sequence_start', 1); |
|
169 | + delete_option('wpinv_last_invoice_number'); |
|
170 | + getpaid_admin()->show_success(__('Invoice number sequence reset successfully.', 'invoicing')); |
|
171 | + $url = remove_query_arg(array('reset_invoice_count', '_nonce')); |
|
172 | + wp_redirect($url); |
|
173 | 173 | exit(); |
174 | 174 | } |
175 | 175 | } |
176 | -add_action( 'admin_init', 'wpinv_reset_invoice_count' ); |
|
176 | +add_action('admin_init', 'wpinv_reset_invoice_count'); |
|
177 | 177 | |
178 | 178 | /** |
179 | 179 | * Displays line items on the invoice edit page. |
@@ -182,29 +182,29 @@ discard block |
||
182 | 182 | * @param array $columns |
183 | 183 | * @return string |
184 | 184 | */ |
185 | -function wpinv_admin_get_line_items( $invoice, $columns ) { |
|
185 | +function wpinv_admin_get_line_items($invoice, $columns) { |
|
186 | 186 | |
187 | 187 | ob_start(); |
188 | 188 | |
189 | - do_action( 'getpaid_admin_before_line_items', $invoice ); |
|
189 | + do_action('getpaid_admin_before_line_items', $invoice); |
|
190 | 190 | |
191 | 191 | $count = 0; |
192 | - foreach ( $invoice->get_items() as $item ) { |
|
192 | + foreach ($invoice->get_items() as $item) { |
|
193 | 193 | |
194 | - $item_price = wpinv_price( $item->get_price(), $invoice->get_currency() ); |
|
194 | + $item_price = wpinv_price($item->get_price(), $invoice->get_currency()); |
|
195 | 195 | $quantity = (int) $item->get_quantity(); |
196 | - $item_subtotal = wpinv_price( $item->get_sub_total(), $invoice->get_currency() ); |
|
197 | - $summary = apply_filters( 'getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice ); |
|
196 | + $item_subtotal = wpinv_price($item->get_sub_total(), $invoice->get_currency()); |
|
197 | + $summary = apply_filters('getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice); |
|
198 | 198 | $item_tax = $item->item_tax; |
199 | - $tax_rate = wpinv_round_amount( getpaid_get_invoice_tax_rate( $invoice, $item ), 2, true ) . '%'; |
|
200 | - $tax_rate = empty( $tax_rate ) ? ' <span class="tax-rate">(' . $tax_rate . '%)</span>' : ''; |
|
199 | + $tax_rate = wpinv_round_amount(getpaid_get_invoice_tax_rate($invoice, $item), 2, true) . '%'; |
|
200 | + $tax_rate = empty($tax_rate) ? ' <span class="tax-rate">(' . $tax_rate . '%)</span>' : ''; |
|
201 | 201 | $line_item_tax = $item_tax . $tax_rate; |
202 | - $line_item = '<tr class="item item-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . '" data-item-id="' . esc_attr( $item->get_id() ) . '">'; |
|
202 | + $line_item = '<tr class="item item-' . (($count % 2 == 0) ? 'even' : 'odd') . '" data-item-id="' . esc_attr($item->get_id()) . '">'; |
|
203 | 203 | $line_item .= '<td class="id">' . (int) $item->get_id() . '</td>'; |
204 | - $line_item .= '<td class="title"><a href="' . get_edit_post_link( $item->get_id() ) . '" target="_blank">' . $item->get_name() . '</a>'; |
|
204 | + $line_item .= '<td class="title"><a href="' . get_edit_post_link($item->get_id()) . '" target="_blank">' . $item->get_name() . '</a>'; |
|
205 | 205 | |
206 | - if ( $summary !== '' ) { |
|
207 | - $line_item .= '<span class="meta">' . wp_kses_post( wpautop( $summary ) ) . '</span>'; |
|
206 | + if ($summary !== '') { |
|
207 | + $line_item .= '<span class="meta">' . wp_kses_post(wpautop($summary)) . '</span>'; |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | $line_item .= '</td>'; |
@@ -212,23 +212,23 @@ discard block |
||
212 | 212 | $line_item .= '<td class="qty" data-quantity="' . $quantity . '"> × ' . $quantity . '</td>'; |
213 | 213 | $line_item .= '<td class="total">' . $item_subtotal . '</td>'; |
214 | 214 | |
215 | - if ( wpinv_use_taxes() && $invoice->is_taxable() ) { |
|
215 | + if (wpinv_use_taxes() && $invoice->is_taxable()) { |
|
216 | 216 | $line_item .= '<td class="tax">' . $line_item_tax . '</td>'; |
217 | 217 | } |
218 | 218 | |
219 | 219 | $line_item .= '<td class="action">'; |
220 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
220 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
221 | 221 | $line_item .= '<i class="fa fa-remove wpinv-item-remove"></i>'; |
222 | 222 | } |
223 | 223 | $line_item .= '</td>'; |
224 | 224 | $line_item .= '</tr>'; |
225 | 225 | |
226 | - echo wp_kses_post( apply_filters( 'getpaid_admin_line_item', $line_item, $item, $invoice ) ); |
|
226 | + echo wp_kses_post(apply_filters('getpaid_admin_line_item', $line_item, $item, $invoice)); |
|
227 | 227 | |
228 | 228 | $count++; |
229 | 229 | } |
230 | 230 | |
231 | - do_action( 'getpaid_admin_after_line_items', $invoice ); |
|
231 | + do_action('getpaid_admin_after_line_items', $invoice); |
|
232 | 232 | |
233 | 233 | return ob_get_clean(); |
234 | 234 | } |