@@ -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 sanitize_html_class( $key ); ?>_row"> |
|
36 | + <tr class="wpinv_cart_footer_row wpinv_cart_<?php echo sanitize_html_class($key); ?>_row"> |
|
37 | 37 | |
38 | - <td colspan="<?php echo ( $column_count - 1 ); ?>" class="wpinv_cart_<?php echo sanitize_html_class( $key ); ?>_label text-right"> |
|
39 | - <strong><?php echo esc_html( $label ); ?>:</strong> |
|
38 | + <td colspan="<?php echo ($column_count - 1); ?>" class="wpinv_cart_<?php echo sanitize_html_class($key); ?>_label text-right"> |
|
39 | + <strong><?php echo esc_html($label); ?>:</strong> |
|
40 | 40 | </td> |
41 | 41 | |
42 | - <td class="wpinv_cart_<?php echo sanitize_html_class( $key ); ?> text-right"> |
|
42 | + <td class="wpinv_cart_<?php echo sanitize_html_class($key); ?> text-right"> |
|
43 | 43 | |
44 | 44 | <?php |
45 | 45 | |
46 | 46 | // Total tax. |
47 | - if ( 'tax' == $key ) { |
|
48 | - echo wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() ); |
|
47 | + if ('tax' == $key) { |
|
48 | + echo wpinv_price($invoice->get_total_tax(), $invoice->get_currency()); |
|
49 | 49 | } |
50 | 50 | |
51 | - if ( 'fee' == $key ) { |
|
52 | - echo wpinv_price( $invoice->get_total_fees(), $invoice->get_currency() ); |
|
51 | + if ('fee' == $key) { |
|
52 | + echo wpinv_price($invoice->get_total_fees(), $invoice->get_currency()); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | // Total discount. |
56 | - if ( 'discount' == $key ) { |
|
57 | - echo wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() ); |
|
56 | + if ('discount' == $key) { |
|
57 | + echo wpinv_price($invoice->get_total_discount(), $invoice->get_currency()); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | // Sub total. |
61 | - if ( 'subtotal' == $key ) { |
|
62 | - echo wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() ); |
|
61 | + if ('subtotal' == $key) { |
|
62 | + echo wpinv_price($invoice->get_subtotal(), $invoice->get_currency()); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | // Total. |
66 | - if ( 'total' == $key ) { |
|
67 | - echo wpinv_price( $invoice->get_total(), $invoice->get_currency() ); |
|
66 | + if ('total' == $key) { |
|
67 | + echo wpinv_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); |
@@ -10,66 +10,66 @@ 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 | - $description = wp_kses_post( $description ); |
|
39 | + if (!empty($description)) { |
|
40 | + $description = wp_kses_post($description); |
|
41 | 41 | echo "<p class='small'>$description</p>"; |
42 | 42 | } |
43 | 43 | |
44 | 44 | } |
45 | 45 | |
46 | 46 | // Item price. |
47 | - if ( 'price' == $column ) { |
|
47 | + if ('price' == $column) { |
|
48 | 48 | |
49 | 49 | // Display the item price (or recurring price if this is a renewal invoice) |
50 | 50 | $price = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price(); |
51 | - echo wpinv_price( $price, $invoice->get_currency() ); |
|
51 | + echo wpinv_price($price, $invoice->get_currency()); |
|
52 | 52 | |
53 | 53 | } |
54 | 54 | |
55 | 55 | // Item quantity. |
56 | - if ( 'quantity' == $column ) { |
|
56 | + if ('quantity' == $column) { |
|
57 | 57 | echo (float) $item->get_quantity(); |
58 | 58 | } |
59 | 59 | |
60 | 60 | // Tax rate. |
61 | - if ( 'tax_rate' == $column ) { |
|
62 | - echo round( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) . '%'; |
|
61 | + if ('tax_rate' == $column) { |
|
62 | + echo round(getpaid_get_invoice_tax_rate($invoice, $item), 2) . '%'; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | // Item sub total. |
66 | - if ( 'subtotal' == $column ) { |
|
66 | + if ('subtotal' == $column) { |
|
67 | 67 | $subtotal = $invoice->is_renewal() ? $item->get_recurring_sub_total() : $item->get_sub_total(); |
68 | - echo wpinv_price( $subtotal, $invoice->get_currency() ); |
|
68 | + echo wpinv_price($subtotal, $invoice->get_currency()); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | // Fires when printing a line item column. |
72 | - do_action( "getpaid_email_line_item_$column", $item, $invoice ); |
|
72 | + do_action("getpaid_email_line_item_$column", $item, $invoice); |
|
73 | 73 | |
74 | 74 | ?> |
75 | 75 | |
@@ -79,4 +79,4 @@ discard block |
||
79 | 79 | |
80 | 80 | </tr> |
81 | 81 | |
82 | -<?php do_action( 'getpaid_after_email_line_item', $invoice, $item ); ?> |
|
82 | +<?php do_action('getpaid_after_email_line_item', $invoice, $item); ?> |
@@ -10,68 +10,68 @@ 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'] ); |
|
37 | + $description = empty($fee['description']) ? esc_html__('Fee', 'invoicing') : esc_html($fee['description']); |
|
38 | 38 | echo "<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 | - echo wpinv_price( $fee['recurring_fee'], $invoice->get_currency() ); |
|
46 | + if ($invoice->is_recurring() && $invoice->is_renewal()) { |
|
47 | + echo wpinv_price($fee['recurring_fee'], $invoice->get_currency()); |
|
48 | 48 | } else { |
49 | - echo wpinv_price( $fee['initial_fee'], $invoice->get_currency() ); |
|
49 | + echo wpinv_price($fee['initial_fee'], $invoice->get_currency()); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | } |
53 | 53 | |
54 | 54 | // Item quantity. |
55 | - if ( 'quantity' == $column ) { |
|
55 | + if ('quantity' == $column) { |
|
56 | 56 | echo "—"; |
57 | 57 | } |
58 | 58 | |
59 | 59 | // Item tax. |
60 | - if ( 'tax_rate' == $column ) { |
|
60 | + if ('tax_rate' == $column) { |
|
61 | 61 | echo "—"; |
62 | 62 | } |
63 | 63 | |
64 | 64 | // Item sub total. |
65 | - if ( 'subtotal' == $column ) { |
|
66 | - if ( $invoice->is_recurring() && $invoice->is_renewal() ) { |
|
67 | - echo wpinv_price( $fee['recurring_fee'], $invoice->get_currency() ); |
|
65 | + if ('subtotal' == $column) { |
|
66 | + if ($invoice->is_recurring() && $invoice->is_renewal()) { |
|
67 | + echo wpinv_price($fee['recurring_fee'], $invoice->get_currency()); |
|
68 | 68 | } else { |
69 | - echo wpinv_price( $fee['initial_fee'], $invoice->get_currency() ); |
|
69 | + echo wpinv_price($fee['initial_fee'], $invoice->get_currency()); |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
73 | 73 | // Fires when printing a line item column. |
74 | - do_action( "getpaid_email_fee_item_$column", $fee, $invoice ); |
|
74 | + do_action("getpaid_email_fee_item_$column", $fee, $invoice); |
|
75 | 75 | |
76 | 76 | ?> |
77 | 77 | |
@@ -81,4 +81,4 @@ discard block |
||
81 | 81 | |
82 | 82 | </tr> |
83 | 83 | |
84 | -<?php do_action( 'getpaid_after_email_fee_item', $invoice, $fee ); ?> |
|
84 | +<?php do_action('getpaid_after_email_fee_item', $invoice, $fee); ?> |
@@ -10,55 +10,55 @@ discard block |
||
10 | 10 | * @var array $columns |
11 | 11 | */ |
12 | 12 | |
13 | -defined( 'ABSPATH' ) || exit; |
|
13 | +defined('ABSPATH') || exit; |
|
14 | 14 | |
15 | -do_action( 'getpaid_before_invoice_line_item', $invoice, $item ); |
|
15 | +do_action('getpaid_before_invoice_line_item', $invoice, $item); |
|
16 | 16 | |
17 | 17 | ?> |
18 | 18 | |
19 | -<div class='getpaid-invoice-item item-<?php echo (int) $item->get_id(); ?> item-type-<?php echo sanitize_html_class( $item->get_type() ); ?> border-bottom'> |
|
19 | +<div class='getpaid-invoice-item item-<?php echo (int) $item->get_id(); ?> item-type-<?php echo sanitize_html_class($item->get_type()); ?> border-bottom'> |
|
20 | 20 | |
21 | 21 | <div class="form-row"> |
22 | 22 | |
23 | - <?php foreach ( array_keys( $columns ) as $column ): ?> |
|
23 | + <?php foreach (array_keys($columns) as $column): ?> |
|
24 | 24 | |
25 | - <div class="<?php echo 'name' == $column ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-invoice-item-<?php echo sanitize_html_class( $column ); ?>"> |
|
25 | + <div class="<?php echo 'name' == $column ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-invoice-item-<?php echo sanitize_html_class($column); ?>"> |
|
26 | 26 | |
27 | 27 | <?php |
28 | 28 | |
29 | 29 | // Fires before printing a line item column. |
30 | - do_action( "getpaid_invoice_line_item_before_$column", $item, $invoice ); |
|
30 | + do_action("getpaid_invoice_line_item_before_$column", $item, $invoice); |
|
31 | 31 | |
32 | 32 | // Item name. |
33 | - if ( 'name' == $column ) { |
|
33 | + if ('name' == $column) { |
|
34 | 34 | |
35 | 35 | // Display the name. |
36 | - echo '<div class="mb-1">' . esc_html( $item->get_name() ) . '</div>'; |
|
36 | + echo '<div class="mb-1">' . esc_html($item->get_name()) . '</div>'; |
|
37 | 37 | |
38 | 38 | // And an optional description. |
39 | 39 | $description = $item->get_description(); |
40 | 40 | |
41 | - if ( ! empty( $description ) ) { |
|
42 | - $description = wp_kses_post( $description ); |
|
41 | + if (!empty($description)) { |
|
42 | + $description = wp_kses_post($description); |
|
43 | 43 | echo "<small class='form-text text-muted pr-2 m-0'>$description</small>"; |
44 | 44 | } |
45 | 45 | |
46 | 46 | // Fires before printing the line item actions. |
47 | - do_action( "getpaid_before_invoice_line_item_actions", $item, $invoice ); |
|
47 | + do_action("getpaid_before_invoice_line_item_actions", $item, $invoice); |
|
48 | 48 | |
49 | - $actions = apply_filters( 'getpaid-invoice-page-line-item-actions', array(), $item, $invoice ); |
|
49 | + $actions = apply_filters('getpaid-invoice-page-line-item-actions', array(), $item, $invoice); |
|
50 | 50 | |
51 | - if ( ! empty( $actions ) ) { |
|
51 | + if (!empty($actions)) { |
|
52 | 52 | |
53 | - $sanitized = array(); |
|
54 | - foreach ( $actions as $key => $action ) { |
|
55 | - $key = sanitize_html_class( $key ); |
|
56 | - $action = wp_kses_post( $action ); |
|
53 | + $sanitized = array(); |
|
54 | + foreach ($actions as $key => $action) { |
|
55 | + $key = sanitize_html_class($key); |
|
56 | + $action = wp_kses_post($action); |
|
57 | 57 | $sanitized[] = "<span class='$key'>$action</span>"; |
58 | 58 | } |
59 | 59 | |
60 | 60 | echo "<small class='form-text getpaid-line-item-actions'>"; |
61 | - echo implode( ' | ', $sanitized ); |
|
61 | + echo implode(' | ', $sanitized); |
|
62 | 62 | echo '</small>'; |
63 | 63 | |
64 | 64 | } |
@@ -66,35 +66,35 @@ discard block |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | // Item price. |
69 | - if ( 'price' == $column ) { |
|
69 | + if ('price' == $column) { |
|
70 | 70 | |
71 | 71 | // Display the item price (or recurring price if this is a renewal invoice) |
72 | 72 | $price = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price(); |
73 | - echo wpinv_price( $price, $invoice->get_currency() ); |
|
73 | + echo wpinv_price($price, $invoice->get_currency()); |
|
74 | 74 | |
75 | 75 | } |
76 | 76 | |
77 | 77 | // Tax rate. |
78 | - if ( 'tax_rate' == $column ) { |
|
79 | - echo round( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) . '%'; |
|
78 | + if ('tax_rate' == $column) { |
|
79 | + echo round(getpaid_get_invoice_tax_rate($invoice, $item), 2) . '%'; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | // Item quantity. |
83 | - if ( 'quantity' == $column ) { |
|
83 | + if ('quantity' == $column) { |
|
84 | 84 | echo (float) $item->get_quantity(); |
85 | 85 | } |
86 | 86 | |
87 | 87 | // Item sub total. |
88 | - if ( 'subtotal' == $column ) { |
|
88 | + if ('subtotal' == $column) { |
|
89 | 89 | $subtotal = $invoice->is_renewal() ? $item->get_recurring_sub_total() : $item->get_sub_total(); |
90 | - echo wpinv_price( $subtotal, $invoice->get_currency() ); |
|
90 | + echo wpinv_price($subtotal, $invoice->get_currency()); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | // Fires when printing a line item column. |
94 | - do_action( "getpaid_invoice_line_item_$column", $item, $invoice ); |
|
94 | + do_action("getpaid_invoice_line_item_$column", $item, $invoice); |
|
95 | 95 | |
96 | 96 | // Fires after printing a line item column. |
97 | - do_action( "getpaid_invoice_line_item_after_$column", $item, $invoice ); |
|
97 | + do_action("getpaid_invoice_line_item_after_$column", $item, $invoice); |
|
98 | 98 | |
99 | 99 | ?> |
100 | 100 |
@@ -9,9 +9,9 @@ discard block |
||
9 | 9 | * @var array $fee |
10 | 10 | */ |
11 | 11 | |
12 | -defined( 'ABSPATH' ) || exit; |
|
12 | +defined('ABSPATH') || exit; |
|
13 | 13 | |
14 | -do_action( 'getpaid_before_invoice_fee_item', $invoice, $fee ); |
|
14 | +do_action('getpaid_before_invoice_fee_item', $invoice, $fee); |
|
15 | 15 | |
16 | 16 | ?> |
17 | 17 | |
@@ -19,66 +19,66 @@ discard block |
||
19 | 19 | |
20 | 20 | <div class="form-row"> |
21 | 21 | |
22 | - <?php foreach ( array_keys( $columns ) as $column ): ?> |
|
22 | + <?php foreach (array_keys($columns) as $column): ?> |
|
23 | 23 | |
24 | - <div class="<?php echo 'name' == $column ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-invoice-item-<?php echo sanitize_html_class( $column ); ?>"> |
|
24 | + <div class="<?php echo 'name' == $column ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-invoice-item-<?php echo sanitize_html_class($column); ?>"> |
|
25 | 25 | |
26 | 26 | <?php |
27 | 27 | |
28 | 28 | // Fires before printing a fee item column. |
29 | - do_action( "getpaid_invoice_fee_item_before_$column", $fee, $invoice ); |
|
29 | + do_action("getpaid_invoice_fee_item_before_$column", $fee, $invoice); |
|
30 | 30 | |
31 | 31 | // Item name. |
32 | - if ( 'name' == $column ) { |
|
32 | + if ('name' == $column) { |
|
33 | 33 | |
34 | 34 | // Display the name. |
35 | - echo '<div class="mb-1">' . esc_html( $fee['name'] ) . '</div>'; |
|
35 | + echo '<div class="mb-1">' . esc_html($fee['name']) . '</div>'; |
|
36 | 36 | |
37 | 37 | // And an optional description. |
38 | - $description = empty( $fee['description'] ) ? esc_html__( 'Fee', 'invoicing' ) : esc_html( $fee['description'] ); |
|
38 | + $description = empty($fee['description']) ? esc_html__('Fee', 'invoicing') : esc_html($fee['description']); |
|
39 | 39 | echo "<small class='form-text text-muted pr-2 m-0'>$description</small>"; |
40 | 40 | |
41 | 41 | } |
42 | 42 | |
43 | 43 | // Item price. |
44 | - if ( 'price' == $column ) { |
|
44 | + if ('price' == $column) { |
|
45 | 45 | |
46 | 46 | // Display the item price (or recurring price if this is a renewal invoice) |
47 | - if ( $invoice->is_recurring() && $invoice->is_renewal() ) { |
|
48 | - echo wpinv_price( $fee['recurring_fee'], $invoice->get_currency() ); |
|
47 | + if ($invoice->is_recurring() && $invoice->is_renewal()) { |
|
48 | + echo wpinv_price($fee['recurring_fee'], $invoice->get_currency()); |
|
49 | 49 | } else { |
50 | - echo wpinv_price( $fee['initial_fee'], $invoice->get_currency() ); |
|
50 | + echo wpinv_price($fee['initial_fee'], $invoice->get_currency()); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | } |
54 | 54 | |
55 | 55 | // Item quantity. |
56 | - if ( 'quantity' == $column ) { |
|
56 | + if ('quantity' == $column) { |
|
57 | 57 | echo "—"; |
58 | 58 | } |
59 | 59 | |
60 | 60 | // Item tax. |
61 | - if ( 'tax_rate' == $column ) { |
|
61 | + if ('tax_rate' == $column) { |
|
62 | 62 | echo "—"; |
63 | 63 | } |
64 | 64 | |
65 | 65 | // Item sub total. |
66 | - if ( 'subtotal' == $column ) { |
|
66 | + if ('subtotal' == $column) { |
|
67 | 67 | |
68 | 68 | // Display the item price (or recurring price if this is a renewal invoice) |
69 | - if ( $invoice->is_recurring() && $invoice->is_renewal() ) { |
|
70 | - echo wpinv_price( $fee['recurring_fee'], $invoice->get_currency() ); |
|
69 | + if ($invoice->is_recurring() && $invoice->is_renewal()) { |
|
70 | + echo wpinv_price($fee['recurring_fee'], $invoice->get_currency()); |
|
71 | 71 | } else { |
72 | - echo wpinv_price( $fee['initial_fee'], $invoice->get_currency() ); |
|
72 | + echo wpinv_price($fee['initial_fee'], $invoice->get_currency()); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | } |
76 | 76 | |
77 | 77 | // Fires when printing a fee item column. |
78 | - do_action( "getpaid_invoice_fee_item_$column", $fee, $invoice ); |
|
78 | + do_action("getpaid_invoice_fee_item_$column", $fee, $invoice); |
|
79 | 79 | |
80 | 80 | // Fires after printing a fee item column. |
81 | - do_action( "getpaid_invoice_fee_item_after_$column", $fee, $invoice ); |
|
81 | + do_action("getpaid_invoice_fee_item_after_$column", $fee, $invoice); |
|
82 | 82 | |
83 | 83 | ?> |
84 | 84 |
@@ -7,10 +7,10 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 | <span>{{form_element.text}}</span> |
14 | 14 | <a target='_blank' href="#"> |
15 | - <?php echo esc_html( wpinv_get_ip() ); ?> <i class='fa fa-external-link-square' aria-hidden='true'></i> |
|
15 | + <?php echo esc_html(wpinv_get_ip()); ?> <i class='fa fa-external-link-square' aria-hidden='true'></i> |
|
16 | 16 | </a> |
@@ -15,321 +15,321 @@ |
||
15 | 15 | class GetPaid_Post_Types { |
16 | 16 | |
17 | 17 | /** |
18 | - * Hook in methods. |
|
19 | - */ |
|
20 | - public function __construct() { |
|
21 | - add_action( 'init', array( __CLASS__, 'register_post_types' ), 1 ); |
|
22 | - add_action( 'init', array( __CLASS__, 'register_post_status' ), 4 ); |
|
23 | - add_action( 'getpaid_flush_rewrite_rules', array( __CLASS__, 'flush_rewrite_rules' ) ); |
|
24 | - add_action( 'getpaid_after_register_post_types', array( __CLASS__, 'maybe_flush_rewrite_rules' ) ); |
|
25 | - } |
|
18 | + * Hook in methods. |
|
19 | + */ |
|
20 | + public function __construct() { |
|
21 | + add_action( 'init', array( __CLASS__, 'register_post_types' ), 1 ); |
|
22 | + add_action( 'init', array( __CLASS__, 'register_post_status' ), 4 ); |
|
23 | + add_action( 'getpaid_flush_rewrite_rules', array( __CLASS__, 'flush_rewrite_rules' ) ); |
|
24 | + add_action( 'getpaid_after_register_post_types', array( __CLASS__, 'maybe_flush_rewrite_rules' ) ); |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * Register core post types. |
|
29 | - */ |
|
30 | - public static function register_post_types() { |
|
27 | + /** |
|
28 | + * Register core post types. |
|
29 | + */ |
|
30 | + public static function register_post_types() { |
|
31 | 31 | |
32 | - if ( ! is_blog_installed() || post_type_exists( 'wpi_item' ) ) { |
|
33 | - return; |
|
34 | - } |
|
32 | + if ( ! is_blog_installed() || post_type_exists( 'wpi_item' ) ) { |
|
33 | + return; |
|
34 | + } |
|
35 | 35 | |
36 | - $capabilities = wpinv_current_user_can_manage_invoicing(); |
|
36 | + $capabilities = wpinv_current_user_can_manage_invoicing(); |
|
37 | 37 | |
38 | - // Fires before registering post types. |
|
39 | - do_action( 'getpaid_register_post_types' ); |
|
38 | + // Fires before registering post types. |
|
39 | + do_action( 'getpaid_register_post_types' ); |
|
40 | 40 | |
41 | - // Register item post type. |
|
42 | - register_post_type( |
|
43 | - 'wpi_item', |
|
44 | - apply_filters( |
|
45 | - 'wpinv_register_post_type_invoice_item', |
|
46 | - array( |
|
47 | - 'labels' => array( |
|
48 | - 'name' => _x( 'Items', 'post type general name', 'invoicing' ), |
|
49 | - 'singular_name' => _x( 'Item', 'post type singular name', 'invoicing' ), |
|
50 | - 'menu_name' => _x( 'Items', 'admin menu', 'invoicing' ), |
|
51 | - 'name_admin_bar' => _x( 'Item', 'add new on admin bar', 'invoicing' ), |
|
52 | - 'add_new' => _x( 'Add New', 'Item', 'invoicing' ), |
|
53 | - 'add_new_item' => __( 'Add New Item', 'invoicing' ), |
|
54 | - 'new_item' => __( 'New Item', 'invoicing' ), |
|
55 | - 'edit_item' => __( 'Edit Item', 'invoicing' ), |
|
56 | - 'view_item' => __( 'View Item', 'invoicing' ), |
|
57 | - 'all_items' => __( 'Items', 'invoicing' ), |
|
58 | - 'search_items' => __( 'Search items', 'invoicing' ), |
|
59 | - 'parent_item_colon' => __( 'Parent item:', 'invoicing' ), |
|
60 | - 'not_found' => __( 'No items found.', 'invoicing' ), |
|
61 | - 'not_found_in_trash' => __( 'No items found in trash.', 'invoicing' ) |
|
62 | - ), |
|
63 | - 'description' => __( 'This is where you can add new invoice items.', 'invoicing' ), |
|
64 | - 'public' => false, |
|
65 | - 'has_archive' => false, |
|
66 | - '_builtin' => false, |
|
67 | - 'show_ui' => true, |
|
68 | - 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
69 | - 'show_in_nav_menus' => false, |
|
70 | - 'supports' => array( 'title', 'excerpt', 'thumbnail' ), |
|
71 | - 'rewrite' => false, |
|
72 | - 'query_var' => false, |
|
73 | - 'map_meta_cap' => true, |
|
74 | - 'show_in_admin_bar' => true, |
|
75 | - 'can_export' => true, |
|
76 | - ) |
|
77 | - ) |
|
78 | - ); |
|
41 | + // Register item post type. |
|
42 | + register_post_type( |
|
43 | + 'wpi_item', |
|
44 | + apply_filters( |
|
45 | + 'wpinv_register_post_type_invoice_item', |
|
46 | + array( |
|
47 | + 'labels' => array( |
|
48 | + 'name' => _x( 'Items', 'post type general name', 'invoicing' ), |
|
49 | + 'singular_name' => _x( 'Item', 'post type singular name', 'invoicing' ), |
|
50 | + 'menu_name' => _x( 'Items', 'admin menu', 'invoicing' ), |
|
51 | + 'name_admin_bar' => _x( 'Item', 'add new on admin bar', 'invoicing' ), |
|
52 | + 'add_new' => _x( 'Add New', 'Item', 'invoicing' ), |
|
53 | + 'add_new_item' => __( 'Add New Item', 'invoicing' ), |
|
54 | + 'new_item' => __( 'New Item', 'invoicing' ), |
|
55 | + 'edit_item' => __( 'Edit Item', 'invoicing' ), |
|
56 | + 'view_item' => __( 'View Item', 'invoicing' ), |
|
57 | + 'all_items' => __( 'Items', 'invoicing' ), |
|
58 | + 'search_items' => __( 'Search items', 'invoicing' ), |
|
59 | + 'parent_item_colon' => __( 'Parent item:', 'invoicing' ), |
|
60 | + 'not_found' => __( 'No items found.', 'invoicing' ), |
|
61 | + 'not_found_in_trash' => __( 'No items found in trash.', 'invoicing' ) |
|
62 | + ), |
|
63 | + 'description' => __( 'This is where you can add new invoice items.', 'invoicing' ), |
|
64 | + 'public' => false, |
|
65 | + 'has_archive' => false, |
|
66 | + '_builtin' => false, |
|
67 | + 'show_ui' => true, |
|
68 | + 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
69 | + 'show_in_nav_menus' => false, |
|
70 | + 'supports' => array( 'title', 'excerpt', 'thumbnail' ), |
|
71 | + 'rewrite' => false, |
|
72 | + 'query_var' => false, |
|
73 | + 'map_meta_cap' => true, |
|
74 | + 'show_in_admin_bar' => true, |
|
75 | + 'can_export' => true, |
|
76 | + ) |
|
77 | + ) |
|
78 | + ); |
|
79 | 79 | |
80 | - // Register payment form post type. |
|
81 | - register_post_type( |
|
82 | - 'wpi_payment_form', |
|
83 | - apply_filters( |
|
84 | - 'wpinv_register_post_type_payment_form', |
|
85 | - array( |
|
86 | - 'labels' => array( |
|
87 | - 'name' => _x( 'Payment Forms', 'post type general name', 'invoicing' ), |
|
88 | - 'singular_name' => _x( 'Payment Form', 'post type singular name', 'invoicing' ), |
|
89 | - 'menu_name' => _x( 'Payment Forms', 'admin menu', 'invoicing' ), |
|
90 | - 'name_admin_bar' => _x( 'Payment Form', 'add new on admin bar', 'invoicing' ), |
|
91 | - 'add_new' => _x( 'Add New', 'Payment Form', 'invoicing' ), |
|
92 | - 'add_new_item' => __( 'Add New Payment Form', 'invoicing' ), |
|
93 | - 'new_item' => __( 'New Payment Form', 'invoicing' ), |
|
94 | - 'edit_item' => __( 'Edit Payment Form', 'invoicing' ), |
|
95 | - 'view_item' => __( 'View Payment Form', 'invoicing' ), |
|
96 | - 'all_items' => __( 'Payment Forms', 'invoicing' ), |
|
97 | - 'search_items' => __( 'Search Payment Forms', 'invoicing' ), |
|
98 | - 'parent_item_colon' => __( 'Parent Payment Forms:', 'invoicing' ), |
|
99 | - 'not_found' => __( 'No payment forms found.', 'invoicing' ), |
|
100 | - 'not_found_in_trash' => __( 'No payment forms found in trash.', 'invoicing' ) |
|
101 | - ), |
|
102 | - 'description' => __( 'Add new payment forms.', 'invoicing' ), |
|
103 | - 'public' => false, |
|
104 | - 'show_ui' => true, |
|
105 | - 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
106 | - 'show_in_nav_menus' => false, |
|
107 | - 'query_var' => false, |
|
108 | - 'rewrite' => true, |
|
109 | - 'map_meta_cap' => true, |
|
110 | - 'has_archive' => false, |
|
111 | - 'hierarchical' => false, |
|
112 | - 'menu_position' => null, |
|
113 | - 'supports' => array( 'title' ), |
|
114 | - 'menu_icon' => 'dashicons-media-form', |
|
115 | - ) |
|
116 | - ) |
|
117 | - ); |
|
80 | + // Register payment form post type. |
|
81 | + register_post_type( |
|
82 | + 'wpi_payment_form', |
|
83 | + apply_filters( |
|
84 | + 'wpinv_register_post_type_payment_form', |
|
85 | + array( |
|
86 | + 'labels' => array( |
|
87 | + 'name' => _x( 'Payment Forms', 'post type general name', 'invoicing' ), |
|
88 | + 'singular_name' => _x( 'Payment Form', 'post type singular name', 'invoicing' ), |
|
89 | + 'menu_name' => _x( 'Payment Forms', 'admin menu', 'invoicing' ), |
|
90 | + 'name_admin_bar' => _x( 'Payment Form', 'add new on admin bar', 'invoicing' ), |
|
91 | + 'add_new' => _x( 'Add New', 'Payment Form', 'invoicing' ), |
|
92 | + 'add_new_item' => __( 'Add New Payment Form', 'invoicing' ), |
|
93 | + 'new_item' => __( 'New Payment Form', 'invoicing' ), |
|
94 | + 'edit_item' => __( 'Edit Payment Form', 'invoicing' ), |
|
95 | + 'view_item' => __( 'View Payment Form', 'invoicing' ), |
|
96 | + 'all_items' => __( 'Payment Forms', 'invoicing' ), |
|
97 | + 'search_items' => __( 'Search Payment Forms', 'invoicing' ), |
|
98 | + 'parent_item_colon' => __( 'Parent Payment Forms:', 'invoicing' ), |
|
99 | + 'not_found' => __( 'No payment forms found.', 'invoicing' ), |
|
100 | + 'not_found_in_trash' => __( 'No payment forms found in trash.', 'invoicing' ) |
|
101 | + ), |
|
102 | + 'description' => __( 'Add new payment forms.', 'invoicing' ), |
|
103 | + 'public' => false, |
|
104 | + 'show_ui' => true, |
|
105 | + 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
106 | + 'show_in_nav_menus' => false, |
|
107 | + 'query_var' => false, |
|
108 | + 'rewrite' => true, |
|
109 | + 'map_meta_cap' => true, |
|
110 | + 'has_archive' => false, |
|
111 | + 'hierarchical' => false, |
|
112 | + 'menu_position' => null, |
|
113 | + 'supports' => array( 'title' ), |
|
114 | + 'menu_icon' => 'dashicons-media-form', |
|
115 | + ) |
|
116 | + ) |
|
117 | + ); |
|
118 | 118 | |
119 | - // Register invoice post type. |
|
120 | - register_post_type( |
|
121 | - 'wpi_invoice', |
|
122 | - apply_filters( |
|
123 | - 'wpinv_register_post_type_invoice', |
|
124 | - array( |
|
125 | - 'labels' => array( |
|
126 | - 'name' => __( 'Invoices', 'invoicing' ), |
|
127 | - 'singular_name' => __( 'Invoice', 'invoicing' ), |
|
128 | - 'all_items' => __( 'Invoices', 'invoicing' ), |
|
129 | - 'menu_name' => _x( 'Invoices', 'Admin menu name', 'invoicing' ), |
|
130 | - 'add_new' => __( 'Add New', 'invoicing' ), |
|
131 | - 'add_new_item' => __( 'Add new invoice', 'invoicing' ), |
|
132 | - 'edit' => __( 'Edit', 'invoicing' ), |
|
133 | - 'edit_item' => __( 'Edit invoice', 'invoicing' ), |
|
134 | - 'new_item' => __( 'New invoice', 'invoicing' ), |
|
135 | - 'view_item' => __( 'View invoice', 'invoicing' ), |
|
136 | - 'view_items' => __( 'View Invoices', 'invoicing' ), |
|
137 | - 'search_items' => __( 'Search invoices', 'invoicing' ), |
|
138 | - 'not_found' => __( 'No invoices found', 'invoicing' ), |
|
139 | - 'not_found_in_trash' => __( 'No invoices found in trash', 'invoicing' ), |
|
140 | - 'parent' => __( 'Parent invoice', 'invoicing' ), |
|
141 | - 'featured_image' => __( 'Invoice image', 'invoicing' ), |
|
142 | - 'set_featured_image' => __( 'Set invoice image', 'invoicing' ), |
|
143 | - 'remove_featured_image' => __( 'Remove invoice image', 'invoicing' ), |
|
144 | - 'use_featured_image' => __( 'Use as invoice image', 'invoicing' ), |
|
145 | - 'insert_into_item' => __( 'Insert into invoice', 'invoicing' ), |
|
146 | - 'uploaded_to_this_item' => __( 'Uploaded to this invoice', 'invoicing' ), |
|
147 | - 'filter_items_list' => __( 'Filter invoices', 'invoicing' ), |
|
148 | - 'items_list_navigation' => __( 'Invoices navigation', 'invoicing' ), |
|
149 | - 'items_list' => __( 'Invoices list', 'invoicing' ), |
|
150 | - ), |
|
151 | - 'description' => __( 'This is where invoices are stored.', 'invoicing' ), |
|
152 | - 'public' => true, |
|
153 | - 'has_archive' => false, |
|
154 | - 'publicly_queryable' => true, |
|
155 | - 'exclude_from_search' => true, |
|
156 | - 'show_ui' => true, |
|
157 | - 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
158 | - 'show_in_nav_menus' => false, |
|
159 | - 'supports' => array( 'title', 'author', 'excerpt' ), |
|
160 | - 'rewrite' => array( |
|
161 | - 'slug' => 'invoice', |
|
162 | - 'with_front' => false, |
|
163 | - ), |
|
164 | - 'query_var' => false, |
|
165 | - 'map_meta_cap' => true, |
|
166 | - 'show_in_admin_bar' => true, |
|
167 | - 'can_export' => true, |
|
168 | - 'hierarchical' => false, |
|
169 | - 'menu_position' => null, |
|
170 | - 'menu_icon' => 'dashicons-media-spreadsheet', |
|
171 | - ) |
|
172 | - ) |
|
173 | - ); |
|
119 | + // Register invoice post type. |
|
120 | + register_post_type( |
|
121 | + 'wpi_invoice', |
|
122 | + apply_filters( |
|
123 | + 'wpinv_register_post_type_invoice', |
|
124 | + array( |
|
125 | + 'labels' => array( |
|
126 | + 'name' => __( 'Invoices', 'invoicing' ), |
|
127 | + 'singular_name' => __( 'Invoice', 'invoicing' ), |
|
128 | + 'all_items' => __( 'Invoices', 'invoicing' ), |
|
129 | + 'menu_name' => _x( 'Invoices', 'Admin menu name', 'invoicing' ), |
|
130 | + 'add_new' => __( 'Add New', 'invoicing' ), |
|
131 | + 'add_new_item' => __( 'Add new invoice', 'invoicing' ), |
|
132 | + 'edit' => __( 'Edit', 'invoicing' ), |
|
133 | + 'edit_item' => __( 'Edit invoice', 'invoicing' ), |
|
134 | + 'new_item' => __( 'New invoice', 'invoicing' ), |
|
135 | + 'view_item' => __( 'View invoice', 'invoicing' ), |
|
136 | + 'view_items' => __( 'View Invoices', 'invoicing' ), |
|
137 | + 'search_items' => __( 'Search invoices', 'invoicing' ), |
|
138 | + 'not_found' => __( 'No invoices found', 'invoicing' ), |
|
139 | + 'not_found_in_trash' => __( 'No invoices found in trash', 'invoicing' ), |
|
140 | + 'parent' => __( 'Parent invoice', 'invoicing' ), |
|
141 | + 'featured_image' => __( 'Invoice image', 'invoicing' ), |
|
142 | + 'set_featured_image' => __( 'Set invoice image', 'invoicing' ), |
|
143 | + 'remove_featured_image' => __( 'Remove invoice image', 'invoicing' ), |
|
144 | + 'use_featured_image' => __( 'Use as invoice image', 'invoicing' ), |
|
145 | + 'insert_into_item' => __( 'Insert into invoice', 'invoicing' ), |
|
146 | + 'uploaded_to_this_item' => __( 'Uploaded to this invoice', 'invoicing' ), |
|
147 | + 'filter_items_list' => __( 'Filter invoices', 'invoicing' ), |
|
148 | + 'items_list_navigation' => __( 'Invoices navigation', 'invoicing' ), |
|
149 | + 'items_list' => __( 'Invoices list', 'invoicing' ), |
|
150 | + ), |
|
151 | + 'description' => __( 'This is where invoices are stored.', 'invoicing' ), |
|
152 | + 'public' => true, |
|
153 | + 'has_archive' => false, |
|
154 | + 'publicly_queryable' => true, |
|
155 | + 'exclude_from_search' => true, |
|
156 | + 'show_ui' => true, |
|
157 | + 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
158 | + 'show_in_nav_menus' => false, |
|
159 | + 'supports' => array( 'title', 'author', 'excerpt' ), |
|
160 | + 'rewrite' => array( |
|
161 | + 'slug' => 'invoice', |
|
162 | + 'with_front' => false, |
|
163 | + ), |
|
164 | + 'query_var' => false, |
|
165 | + 'map_meta_cap' => true, |
|
166 | + 'show_in_admin_bar' => true, |
|
167 | + 'can_export' => true, |
|
168 | + 'hierarchical' => false, |
|
169 | + 'menu_position' => null, |
|
170 | + 'menu_icon' => 'dashicons-media-spreadsheet', |
|
171 | + ) |
|
172 | + ) |
|
173 | + ); |
|
174 | 174 | |
175 | - // Register discount post type. |
|
176 | - register_post_type( |
|
177 | - 'wpi_discount', |
|
178 | - apply_filters( |
|
179 | - 'wpinv_register_post_type_discount', |
|
180 | - array( |
|
181 | - 'labels' => array( |
|
182 | - 'name' => __( 'Discounts', 'invoicing' ), |
|
183 | - 'singular_name' => __( 'Discount', 'invoicing' ), |
|
184 | - 'all_items' => __( 'Discounts', 'invoicing' ), |
|
185 | - 'menu_name' => _x( 'Discounts', 'Admin menu name', 'invoicing' ), |
|
186 | - 'add_new' => __( 'Add New', 'invoicing' ), |
|
187 | - 'add_new_item' => __( 'Add new discount', 'invoicing' ), |
|
188 | - 'edit' => __( 'Edit', 'invoicing' ), |
|
189 | - 'edit_item' => __( 'Edit discount', 'invoicing' ), |
|
190 | - 'new_item' => __( 'New discount', 'invoicing' ), |
|
191 | - 'view_item' => __( 'View discount', 'invoicing' ), |
|
192 | - 'view_items' => __( 'View Discounts', 'invoicing' ), |
|
193 | - 'search_items' => __( 'Search discounts', 'invoicing' ), |
|
194 | - 'not_found' => __( 'No discounts found', 'invoicing' ), |
|
195 | - 'not_found_in_trash' => __( 'No discounts found in trash', 'invoicing' ), |
|
196 | - 'parent' => __( 'Parent discount', 'invoicing' ), |
|
197 | - 'featured_image' => __( 'Discount image', 'invoicing' ), |
|
198 | - 'set_featured_image' => __( 'Set discount image', 'invoicing' ), |
|
199 | - 'remove_featured_image' => __( 'Remove discount image', 'invoicing' ), |
|
200 | - 'use_featured_image' => __( 'Use as discount image', 'invoicing' ), |
|
201 | - 'insert_into_item' => __( 'Insert into discount', 'invoicing' ), |
|
202 | - 'uploaded_to_this_item' => __( 'Uploaded to this discount', 'invoicing' ), |
|
203 | - 'filter_items_list' => __( 'Filter discounts', 'invoicing' ), |
|
204 | - 'items_list_navigation' => __( 'Discount navigation', 'invoicing' ), |
|
205 | - 'items_list' => __( 'Discounts list', 'invoicing' ), |
|
206 | - ), |
|
207 | - 'description' => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ), |
|
208 | - 'public' => false, |
|
209 | - 'can_export' => true, |
|
210 | - '_builtin' => false, |
|
211 | - 'publicly_queryable' => false, |
|
212 | - 'exclude_from_search'=> true, |
|
213 | - 'show_ui' => true, |
|
214 | - 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
215 | - 'query_var' => false, |
|
216 | - 'rewrite' => false, |
|
217 | - 'map_meta_cap' => true, |
|
218 | - 'has_archive' => false, |
|
219 | - 'hierarchical' => false, |
|
220 | - 'supports' => array( 'title', 'excerpt' ), |
|
221 | - 'show_in_nav_menus' => false, |
|
222 | - 'show_in_admin_bar' => true, |
|
223 | - 'menu_position' => null, |
|
224 | - ) |
|
225 | - ) |
|
226 | - ); |
|
175 | + // Register discount post type. |
|
176 | + register_post_type( |
|
177 | + 'wpi_discount', |
|
178 | + apply_filters( |
|
179 | + 'wpinv_register_post_type_discount', |
|
180 | + array( |
|
181 | + 'labels' => array( |
|
182 | + 'name' => __( 'Discounts', 'invoicing' ), |
|
183 | + 'singular_name' => __( 'Discount', 'invoicing' ), |
|
184 | + 'all_items' => __( 'Discounts', 'invoicing' ), |
|
185 | + 'menu_name' => _x( 'Discounts', 'Admin menu name', 'invoicing' ), |
|
186 | + 'add_new' => __( 'Add New', 'invoicing' ), |
|
187 | + 'add_new_item' => __( 'Add new discount', 'invoicing' ), |
|
188 | + 'edit' => __( 'Edit', 'invoicing' ), |
|
189 | + 'edit_item' => __( 'Edit discount', 'invoicing' ), |
|
190 | + 'new_item' => __( 'New discount', 'invoicing' ), |
|
191 | + 'view_item' => __( 'View discount', 'invoicing' ), |
|
192 | + 'view_items' => __( 'View Discounts', 'invoicing' ), |
|
193 | + 'search_items' => __( 'Search discounts', 'invoicing' ), |
|
194 | + 'not_found' => __( 'No discounts found', 'invoicing' ), |
|
195 | + 'not_found_in_trash' => __( 'No discounts found in trash', 'invoicing' ), |
|
196 | + 'parent' => __( 'Parent discount', 'invoicing' ), |
|
197 | + 'featured_image' => __( 'Discount image', 'invoicing' ), |
|
198 | + 'set_featured_image' => __( 'Set discount image', 'invoicing' ), |
|
199 | + 'remove_featured_image' => __( 'Remove discount image', 'invoicing' ), |
|
200 | + 'use_featured_image' => __( 'Use as discount image', 'invoicing' ), |
|
201 | + 'insert_into_item' => __( 'Insert into discount', 'invoicing' ), |
|
202 | + 'uploaded_to_this_item' => __( 'Uploaded to this discount', 'invoicing' ), |
|
203 | + 'filter_items_list' => __( 'Filter discounts', 'invoicing' ), |
|
204 | + 'items_list_navigation' => __( 'Discount navigation', 'invoicing' ), |
|
205 | + 'items_list' => __( 'Discounts list', 'invoicing' ), |
|
206 | + ), |
|
207 | + 'description' => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ), |
|
208 | + 'public' => false, |
|
209 | + 'can_export' => true, |
|
210 | + '_builtin' => false, |
|
211 | + 'publicly_queryable' => false, |
|
212 | + 'exclude_from_search'=> true, |
|
213 | + 'show_ui' => true, |
|
214 | + 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
215 | + 'query_var' => false, |
|
216 | + 'rewrite' => false, |
|
217 | + 'map_meta_cap' => true, |
|
218 | + 'has_archive' => false, |
|
219 | + 'hierarchical' => false, |
|
220 | + 'supports' => array( 'title', 'excerpt' ), |
|
221 | + 'show_in_nav_menus' => false, |
|
222 | + 'show_in_admin_bar' => true, |
|
223 | + 'menu_position' => null, |
|
224 | + ) |
|
225 | + ) |
|
226 | + ); |
|
227 | 227 | |
228 | - do_action( 'getpaid_after_register_post_types' ); |
|
229 | - } |
|
228 | + do_action( 'getpaid_after_register_post_types' ); |
|
229 | + } |
|
230 | 230 | |
231 | - /** |
|
232 | - * Register our custom post statuses. |
|
233 | - */ |
|
234 | - public static function register_post_status() { |
|
231 | + /** |
|
232 | + * Register our custom post statuses. |
|
233 | + */ |
|
234 | + public static function register_post_status() { |
|
235 | 235 | |
236 | - $invoice_statuses = apply_filters( |
|
237 | - 'getpaid_register_invoice_post_statuses', |
|
238 | - array( |
|
236 | + $invoice_statuses = apply_filters( |
|
237 | + 'getpaid_register_invoice_post_statuses', |
|
238 | + array( |
|
239 | 239 | |
240 | - 'wpi-pending' => array( |
|
241 | - 'label' => _x( 'Pending Payment', 'Invoice status', 'invoicing' ), |
|
242 | - 'public' => true, |
|
243 | - 'exclude_from_search' => true, |
|
244 | - 'show_in_admin_all_list' => true, |
|
245 | - 'show_in_admin_status_list' => true, |
|
246 | - /* translators: %s: number of invoices */ |
|
247 | - 'label_count' => _n_noop( 'Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'invoicing' ) |
|
248 | - ), |
|
240 | + 'wpi-pending' => array( |
|
241 | + 'label' => _x( 'Pending Payment', 'Invoice status', 'invoicing' ), |
|
242 | + 'public' => true, |
|
243 | + 'exclude_from_search' => true, |
|
244 | + 'show_in_admin_all_list' => true, |
|
245 | + 'show_in_admin_status_list' => true, |
|
246 | + /* translators: %s: number of invoices */ |
|
247 | + 'label_count' => _n_noop( 'Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'invoicing' ) |
|
248 | + ), |
|
249 | 249 | |
250 | - 'wpi-processing' => array( |
|
251 | - 'label' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
|
252 | - 'public' => true, |
|
253 | - 'exclude_from_search' => true, |
|
254 | - 'show_in_admin_all_list' => true, |
|
255 | - 'show_in_admin_status_list' => true, |
|
256 | - /* translators: %s: number of invoices */ |
|
257 | - 'label_count' => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' ) |
|
258 | - ), |
|
250 | + 'wpi-processing' => array( |
|
251 | + 'label' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
|
252 | + 'public' => true, |
|
253 | + 'exclude_from_search' => true, |
|
254 | + 'show_in_admin_all_list' => true, |
|
255 | + 'show_in_admin_status_list' => true, |
|
256 | + /* translators: %s: number of invoices */ |
|
257 | + 'label_count' => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' ) |
|
258 | + ), |
|
259 | 259 | |
260 | - 'wpi-onhold' => array( |
|
261 | - 'label' => _x( 'On Hold', 'Invoice status', 'invoicing' ), |
|
262 | - 'public' => true, |
|
263 | - 'exclude_from_search' => true, |
|
264 | - 'show_in_admin_all_list' => true, |
|
265 | - 'show_in_admin_status_list' => true, |
|
266 | - /* translators: %s: number of invoices */ |
|
267 | - 'label_count' => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' ) |
|
268 | - ), |
|
260 | + 'wpi-onhold' => array( |
|
261 | + 'label' => _x( 'On Hold', 'Invoice status', 'invoicing' ), |
|
262 | + 'public' => true, |
|
263 | + 'exclude_from_search' => true, |
|
264 | + 'show_in_admin_all_list' => true, |
|
265 | + 'show_in_admin_status_list' => true, |
|
266 | + /* translators: %s: number of invoices */ |
|
267 | + 'label_count' => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' ) |
|
268 | + ), |
|
269 | 269 | |
270 | - 'wpi-cancelled' => array( |
|
271 | - 'label' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
272 | - 'public' => true, |
|
273 | - 'exclude_from_search' => true, |
|
274 | - 'show_in_admin_all_list' => true, |
|
275 | - 'show_in_admin_status_list' => true, |
|
276 | - /* translators: %s: number of invoices */ |
|
277 | - 'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' ) |
|
278 | - ), |
|
270 | + 'wpi-cancelled' => array( |
|
271 | + 'label' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
272 | + 'public' => true, |
|
273 | + 'exclude_from_search' => true, |
|
274 | + 'show_in_admin_all_list' => true, |
|
275 | + 'show_in_admin_status_list' => true, |
|
276 | + /* translators: %s: number of invoices */ |
|
277 | + 'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' ) |
|
278 | + ), |
|
279 | 279 | |
280 | - 'wpi-refunded' => array( |
|
281 | - 'label' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
282 | - 'public' => true, |
|
283 | - 'exclude_from_search' => true, |
|
284 | - 'show_in_admin_all_list' => true, |
|
285 | - 'show_in_admin_status_list' => true, |
|
286 | - /* translators: %s: number of invoices */ |
|
287 | - 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' ) |
|
288 | - ), |
|
280 | + 'wpi-refunded' => array( |
|
281 | + 'label' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
282 | + 'public' => true, |
|
283 | + 'exclude_from_search' => true, |
|
284 | + 'show_in_admin_all_list' => true, |
|
285 | + 'show_in_admin_status_list' => true, |
|
286 | + /* translators: %s: number of invoices */ |
|
287 | + 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' ) |
|
288 | + ), |
|
289 | 289 | |
290 | - 'wpi-failed' => array( |
|
291 | - 'label' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
|
292 | - 'public' => true, |
|
293 | - 'exclude_from_search' => true, |
|
294 | - 'show_in_admin_all_list' => true, |
|
295 | - 'show_in_admin_status_list' => true, |
|
296 | - /* translators: %s: number of invoices */ |
|
297 | - 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' ) |
|
298 | - ), |
|
290 | + 'wpi-failed' => array( |
|
291 | + 'label' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
|
292 | + 'public' => true, |
|
293 | + 'exclude_from_search' => true, |
|
294 | + 'show_in_admin_all_list' => true, |
|
295 | + 'show_in_admin_status_list' => true, |
|
296 | + /* translators: %s: number of invoices */ |
|
297 | + 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' ) |
|
298 | + ), |
|
299 | 299 | |
300 | - 'wpi-renewal' => array( |
|
301 | - 'label' => _x( 'Renewal', 'Invoice status', 'invoicing' ), |
|
302 | - 'public' => true, |
|
303 | - 'exclude_from_search' => true, |
|
304 | - 'show_in_admin_all_list' => true, |
|
305 | - 'show_in_admin_status_list' => true, |
|
306 | - /* translators: %s: number of invoices */ |
|
307 | - 'label_count' => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' ) |
|
308 | - ) |
|
309 | - ) |
|
310 | - ); |
|
300 | + 'wpi-renewal' => array( |
|
301 | + 'label' => _x( 'Renewal', 'Invoice status', 'invoicing' ), |
|
302 | + 'public' => true, |
|
303 | + 'exclude_from_search' => true, |
|
304 | + 'show_in_admin_all_list' => true, |
|
305 | + 'show_in_admin_status_list' => true, |
|
306 | + /* translators: %s: number of invoices */ |
|
307 | + 'label_count' => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' ) |
|
308 | + ) |
|
309 | + ) |
|
310 | + ); |
|
311 | 311 | |
312 | - foreach ( $invoice_statuses as $invoice_statuse => $args ) { |
|
313 | - register_post_status( $invoice_statuse, $args ); |
|
314 | - } |
|
315 | - } |
|
312 | + foreach ( $invoice_statuses as $invoice_statuse => $args ) { |
|
313 | + register_post_status( $invoice_statuse, $args ); |
|
314 | + } |
|
315 | + } |
|
316 | 316 | |
317 | - /** |
|
318 | - * Flush rewrite rules. |
|
319 | - */ |
|
320 | - public static function flush_rewrite_rules() { |
|
321 | - flush_rewrite_rules(); |
|
322 | - } |
|
317 | + /** |
|
318 | + * Flush rewrite rules. |
|
319 | + */ |
|
320 | + public static function flush_rewrite_rules() { |
|
321 | + flush_rewrite_rules(); |
|
322 | + } |
|
323 | 323 | |
324 | - /** |
|
325 | - * Flush rules to prevent 404. |
|
326 | - * |
|
327 | - */ |
|
328 | - public static function maybe_flush_rewrite_rules() { |
|
329 | - if ( ! get_option( 'getpaid_flushed_rewrite_rules' ) ) { |
|
330 | - update_option( 'getpaid_flushed_rewrite_rules', '1' ); |
|
331 | - self::flush_rewrite_rules(); |
|
332 | - } |
|
333 | - } |
|
324 | + /** |
|
325 | + * Flush rules to prevent 404. |
|
326 | + * |
|
327 | + */ |
|
328 | + public static function maybe_flush_rewrite_rules() { |
|
329 | + if ( ! get_option( 'getpaid_flushed_rewrite_rules' ) ) { |
|
330 | + update_option( 'getpaid_flushed_rewrite_rules', '1' ); |
|
331 | + self::flush_rewrite_rules(); |
|
332 | + } |
|
333 | + } |
|
334 | 334 | |
335 | 335 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Post types Class |
@@ -18,10 +18,10 @@ discard block |
||
18 | 18 | * Hook in methods. |
19 | 19 | */ |
20 | 20 | public function __construct() { |
21 | - add_action( 'init', array( __CLASS__, 'register_post_types' ), 1 ); |
|
22 | - add_action( 'init', array( __CLASS__, 'register_post_status' ), 4 ); |
|
23 | - add_action( 'getpaid_flush_rewrite_rules', array( __CLASS__, 'flush_rewrite_rules' ) ); |
|
24 | - add_action( 'getpaid_after_register_post_types', array( __CLASS__, 'maybe_flush_rewrite_rules' ) ); |
|
21 | + add_action('init', array(__CLASS__, 'register_post_types'), 1); |
|
22 | + add_action('init', array(__CLASS__, 'register_post_status'), 4); |
|
23 | + add_action('getpaid_flush_rewrite_rules', array(__CLASS__, 'flush_rewrite_rules')); |
|
24 | + add_action('getpaid_after_register_post_types', array(__CLASS__, 'maybe_flush_rewrite_rules')); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -29,14 +29,14 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public static function register_post_types() { |
31 | 31 | |
32 | - if ( ! is_blog_installed() || post_type_exists( 'wpi_item' ) ) { |
|
32 | + if (!is_blog_installed() || post_type_exists('wpi_item')) { |
|
33 | 33 | return; |
34 | 34 | } |
35 | 35 | |
36 | 36 | $capabilities = wpinv_current_user_can_manage_invoicing(); |
37 | 37 | |
38 | 38 | // Fires before registering post types. |
39 | - do_action( 'getpaid_register_post_types' ); |
|
39 | + do_action('getpaid_register_post_types'); |
|
40 | 40 | |
41 | 41 | // Register item post type. |
42 | 42 | register_post_type( |
@@ -45,29 +45,29 @@ discard block |
||
45 | 45 | 'wpinv_register_post_type_invoice_item', |
46 | 46 | array( |
47 | 47 | 'labels' => array( |
48 | - 'name' => _x( 'Items', 'post type general name', 'invoicing' ), |
|
49 | - 'singular_name' => _x( 'Item', 'post type singular name', 'invoicing' ), |
|
50 | - 'menu_name' => _x( 'Items', 'admin menu', 'invoicing' ), |
|
51 | - 'name_admin_bar' => _x( 'Item', 'add new on admin bar', 'invoicing' ), |
|
52 | - 'add_new' => _x( 'Add New', 'Item', 'invoicing' ), |
|
53 | - 'add_new_item' => __( 'Add New Item', 'invoicing' ), |
|
54 | - 'new_item' => __( 'New Item', 'invoicing' ), |
|
55 | - 'edit_item' => __( 'Edit Item', 'invoicing' ), |
|
56 | - 'view_item' => __( 'View Item', 'invoicing' ), |
|
57 | - 'all_items' => __( 'Items', 'invoicing' ), |
|
58 | - 'search_items' => __( 'Search items', 'invoicing' ), |
|
59 | - 'parent_item_colon' => __( 'Parent item:', 'invoicing' ), |
|
60 | - 'not_found' => __( 'No items found.', 'invoicing' ), |
|
61 | - 'not_found_in_trash' => __( 'No items found in trash.', 'invoicing' ) |
|
48 | + 'name' => _x('Items', 'post type general name', 'invoicing'), |
|
49 | + 'singular_name' => _x('Item', 'post type singular name', 'invoicing'), |
|
50 | + 'menu_name' => _x('Items', 'admin menu', 'invoicing'), |
|
51 | + 'name_admin_bar' => _x('Item', 'add new on admin bar', 'invoicing'), |
|
52 | + 'add_new' => _x('Add New', 'Item', 'invoicing'), |
|
53 | + 'add_new_item' => __('Add New Item', 'invoicing'), |
|
54 | + 'new_item' => __('New Item', 'invoicing'), |
|
55 | + 'edit_item' => __('Edit Item', 'invoicing'), |
|
56 | + 'view_item' => __('View Item', 'invoicing'), |
|
57 | + 'all_items' => __('Items', 'invoicing'), |
|
58 | + 'search_items' => __('Search items', 'invoicing'), |
|
59 | + 'parent_item_colon' => __('Parent item:', 'invoicing'), |
|
60 | + 'not_found' => __('No items found.', 'invoicing'), |
|
61 | + 'not_found_in_trash' => __('No items found in trash.', 'invoicing') |
|
62 | 62 | ), |
63 | - 'description' => __( 'This is where you can add new invoice items.', 'invoicing' ), |
|
63 | + 'description' => __('This is where you can add new invoice items.', 'invoicing'), |
|
64 | 64 | 'public' => false, |
65 | 65 | 'has_archive' => false, |
66 | 66 | '_builtin' => false, |
67 | 67 | 'show_ui' => true, |
68 | 68 | 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
69 | 69 | 'show_in_nav_menus' => false, |
70 | - 'supports' => array( 'title', 'excerpt', 'thumbnail' ), |
|
70 | + 'supports' => array('title', 'excerpt', 'thumbnail'), |
|
71 | 71 | 'rewrite' => false, |
72 | 72 | 'query_var' => false, |
73 | 73 | 'map_meta_cap' => true, |
@@ -84,22 +84,22 @@ discard block |
||
84 | 84 | 'wpinv_register_post_type_payment_form', |
85 | 85 | array( |
86 | 86 | 'labels' => array( |
87 | - 'name' => _x( 'Payment Forms', 'post type general name', 'invoicing' ), |
|
88 | - 'singular_name' => _x( 'Payment Form', 'post type singular name', 'invoicing' ), |
|
89 | - 'menu_name' => _x( 'Payment Forms', 'admin menu', 'invoicing' ), |
|
90 | - 'name_admin_bar' => _x( 'Payment Form', 'add new on admin bar', 'invoicing' ), |
|
91 | - 'add_new' => _x( 'Add New', 'Payment Form', 'invoicing' ), |
|
92 | - 'add_new_item' => __( 'Add New Payment Form', 'invoicing' ), |
|
93 | - 'new_item' => __( 'New Payment Form', 'invoicing' ), |
|
94 | - 'edit_item' => __( 'Edit Payment Form', 'invoicing' ), |
|
95 | - 'view_item' => __( 'View Payment Form', 'invoicing' ), |
|
96 | - 'all_items' => __( 'Payment Forms', 'invoicing' ), |
|
97 | - 'search_items' => __( 'Search Payment Forms', 'invoicing' ), |
|
98 | - 'parent_item_colon' => __( 'Parent Payment Forms:', 'invoicing' ), |
|
99 | - 'not_found' => __( 'No payment forms found.', 'invoicing' ), |
|
100 | - 'not_found_in_trash' => __( 'No payment forms found in trash.', 'invoicing' ) |
|
87 | + 'name' => _x('Payment Forms', 'post type general name', 'invoicing'), |
|
88 | + 'singular_name' => _x('Payment Form', 'post type singular name', 'invoicing'), |
|
89 | + 'menu_name' => _x('Payment Forms', 'admin menu', 'invoicing'), |
|
90 | + 'name_admin_bar' => _x('Payment Form', 'add new on admin bar', 'invoicing'), |
|
91 | + 'add_new' => _x('Add New', 'Payment Form', 'invoicing'), |
|
92 | + 'add_new_item' => __('Add New Payment Form', 'invoicing'), |
|
93 | + 'new_item' => __('New Payment Form', 'invoicing'), |
|
94 | + 'edit_item' => __('Edit Payment Form', 'invoicing'), |
|
95 | + 'view_item' => __('View Payment Form', 'invoicing'), |
|
96 | + 'all_items' => __('Payment Forms', 'invoicing'), |
|
97 | + 'search_items' => __('Search Payment Forms', 'invoicing'), |
|
98 | + 'parent_item_colon' => __('Parent Payment Forms:', 'invoicing'), |
|
99 | + 'not_found' => __('No payment forms found.', 'invoicing'), |
|
100 | + 'not_found_in_trash' => __('No payment forms found in trash.', 'invoicing') |
|
101 | 101 | ), |
102 | - 'description' => __( 'Add new payment forms.', 'invoicing' ), |
|
102 | + 'description' => __('Add new payment forms.', 'invoicing'), |
|
103 | 103 | 'public' => false, |
104 | 104 | 'show_ui' => true, |
105 | 105 | 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | 'has_archive' => false, |
111 | 111 | 'hierarchical' => false, |
112 | 112 | 'menu_position' => null, |
113 | - 'supports' => array( 'title' ), |
|
113 | + 'supports' => array('title'), |
|
114 | 114 | 'menu_icon' => 'dashicons-media-form', |
115 | 115 | ) |
116 | 116 | ) |
@@ -123,32 +123,32 @@ discard block |
||
123 | 123 | 'wpinv_register_post_type_invoice', |
124 | 124 | array( |
125 | 125 | 'labels' => array( |
126 | - 'name' => __( 'Invoices', 'invoicing' ), |
|
127 | - 'singular_name' => __( 'Invoice', 'invoicing' ), |
|
128 | - 'all_items' => __( 'Invoices', 'invoicing' ), |
|
129 | - 'menu_name' => _x( 'Invoices', 'Admin menu name', 'invoicing' ), |
|
130 | - 'add_new' => __( 'Add New', 'invoicing' ), |
|
131 | - 'add_new_item' => __( 'Add new invoice', 'invoicing' ), |
|
132 | - 'edit' => __( 'Edit', 'invoicing' ), |
|
133 | - 'edit_item' => __( 'Edit invoice', 'invoicing' ), |
|
134 | - 'new_item' => __( 'New invoice', 'invoicing' ), |
|
135 | - 'view_item' => __( 'View invoice', 'invoicing' ), |
|
136 | - 'view_items' => __( 'View Invoices', 'invoicing' ), |
|
137 | - 'search_items' => __( 'Search invoices', 'invoicing' ), |
|
138 | - 'not_found' => __( 'No invoices found', 'invoicing' ), |
|
139 | - 'not_found_in_trash' => __( 'No invoices found in trash', 'invoicing' ), |
|
140 | - 'parent' => __( 'Parent invoice', 'invoicing' ), |
|
141 | - 'featured_image' => __( 'Invoice image', 'invoicing' ), |
|
142 | - 'set_featured_image' => __( 'Set invoice image', 'invoicing' ), |
|
143 | - 'remove_featured_image' => __( 'Remove invoice image', 'invoicing' ), |
|
144 | - 'use_featured_image' => __( 'Use as invoice image', 'invoicing' ), |
|
145 | - 'insert_into_item' => __( 'Insert into invoice', 'invoicing' ), |
|
146 | - 'uploaded_to_this_item' => __( 'Uploaded to this invoice', 'invoicing' ), |
|
147 | - 'filter_items_list' => __( 'Filter invoices', 'invoicing' ), |
|
148 | - 'items_list_navigation' => __( 'Invoices navigation', 'invoicing' ), |
|
149 | - 'items_list' => __( 'Invoices list', 'invoicing' ), |
|
126 | + 'name' => __('Invoices', 'invoicing'), |
|
127 | + 'singular_name' => __('Invoice', 'invoicing'), |
|
128 | + 'all_items' => __('Invoices', 'invoicing'), |
|
129 | + 'menu_name' => _x('Invoices', 'Admin menu name', 'invoicing'), |
|
130 | + 'add_new' => __('Add New', 'invoicing'), |
|
131 | + 'add_new_item' => __('Add new invoice', 'invoicing'), |
|
132 | + 'edit' => __('Edit', 'invoicing'), |
|
133 | + 'edit_item' => __('Edit invoice', 'invoicing'), |
|
134 | + 'new_item' => __('New invoice', 'invoicing'), |
|
135 | + 'view_item' => __('View invoice', 'invoicing'), |
|
136 | + 'view_items' => __('View Invoices', 'invoicing'), |
|
137 | + 'search_items' => __('Search invoices', 'invoicing'), |
|
138 | + 'not_found' => __('No invoices found', 'invoicing'), |
|
139 | + 'not_found_in_trash' => __('No invoices found in trash', 'invoicing'), |
|
140 | + 'parent' => __('Parent invoice', 'invoicing'), |
|
141 | + 'featured_image' => __('Invoice image', 'invoicing'), |
|
142 | + 'set_featured_image' => __('Set invoice image', 'invoicing'), |
|
143 | + 'remove_featured_image' => __('Remove invoice image', 'invoicing'), |
|
144 | + 'use_featured_image' => __('Use as invoice image', 'invoicing'), |
|
145 | + 'insert_into_item' => __('Insert into invoice', 'invoicing'), |
|
146 | + 'uploaded_to_this_item' => __('Uploaded to this invoice', 'invoicing'), |
|
147 | + 'filter_items_list' => __('Filter invoices', 'invoicing'), |
|
148 | + 'items_list_navigation' => __('Invoices navigation', 'invoicing'), |
|
149 | + 'items_list' => __('Invoices list', 'invoicing'), |
|
150 | 150 | ), |
151 | - 'description' => __( 'This is where invoices are stored.', 'invoicing' ), |
|
151 | + 'description' => __('This is where invoices are stored.', 'invoicing'), |
|
152 | 152 | 'public' => true, |
153 | 153 | 'has_archive' => false, |
154 | 154 | 'publicly_queryable' => true, |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | 'show_ui' => true, |
157 | 157 | 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
158 | 158 | 'show_in_nav_menus' => false, |
159 | - 'supports' => array( 'title', 'author', 'excerpt' ), |
|
159 | + 'supports' => array('title', 'author', 'excerpt'), |
|
160 | 160 | 'rewrite' => array( |
161 | 161 | 'slug' => 'invoice', |
162 | 162 | 'with_front' => false, |
@@ -179,32 +179,32 @@ discard block |
||
179 | 179 | 'wpinv_register_post_type_discount', |
180 | 180 | array( |
181 | 181 | 'labels' => array( |
182 | - 'name' => __( 'Discounts', 'invoicing' ), |
|
183 | - 'singular_name' => __( 'Discount', 'invoicing' ), |
|
184 | - 'all_items' => __( 'Discounts', 'invoicing' ), |
|
185 | - 'menu_name' => _x( 'Discounts', 'Admin menu name', 'invoicing' ), |
|
186 | - 'add_new' => __( 'Add New', 'invoicing' ), |
|
187 | - 'add_new_item' => __( 'Add new discount', 'invoicing' ), |
|
188 | - 'edit' => __( 'Edit', 'invoicing' ), |
|
189 | - 'edit_item' => __( 'Edit discount', 'invoicing' ), |
|
190 | - 'new_item' => __( 'New discount', 'invoicing' ), |
|
191 | - 'view_item' => __( 'View discount', 'invoicing' ), |
|
192 | - 'view_items' => __( 'View Discounts', 'invoicing' ), |
|
193 | - 'search_items' => __( 'Search discounts', 'invoicing' ), |
|
194 | - 'not_found' => __( 'No discounts found', 'invoicing' ), |
|
195 | - 'not_found_in_trash' => __( 'No discounts found in trash', 'invoicing' ), |
|
196 | - 'parent' => __( 'Parent discount', 'invoicing' ), |
|
197 | - 'featured_image' => __( 'Discount image', 'invoicing' ), |
|
198 | - 'set_featured_image' => __( 'Set discount image', 'invoicing' ), |
|
199 | - 'remove_featured_image' => __( 'Remove discount image', 'invoicing' ), |
|
200 | - 'use_featured_image' => __( 'Use as discount image', 'invoicing' ), |
|
201 | - 'insert_into_item' => __( 'Insert into discount', 'invoicing' ), |
|
202 | - 'uploaded_to_this_item' => __( 'Uploaded to this discount', 'invoicing' ), |
|
203 | - 'filter_items_list' => __( 'Filter discounts', 'invoicing' ), |
|
204 | - 'items_list_navigation' => __( 'Discount navigation', 'invoicing' ), |
|
205 | - 'items_list' => __( 'Discounts list', 'invoicing' ), |
|
182 | + 'name' => __('Discounts', 'invoicing'), |
|
183 | + 'singular_name' => __('Discount', 'invoicing'), |
|
184 | + 'all_items' => __('Discounts', 'invoicing'), |
|
185 | + 'menu_name' => _x('Discounts', 'Admin menu name', 'invoicing'), |
|
186 | + 'add_new' => __('Add New', 'invoicing'), |
|
187 | + 'add_new_item' => __('Add new discount', 'invoicing'), |
|
188 | + 'edit' => __('Edit', 'invoicing'), |
|
189 | + 'edit_item' => __('Edit discount', 'invoicing'), |
|
190 | + 'new_item' => __('New discount', 'invoicing'), |
|
191 | + 'view_item' => __('View discount', 'invoicing'), |
|
192 | + 'view_items' => __('View Discounts', 'invoicing'), |
|
193 | + 'search_items' => __('Search discounts', 'invoicing'), |
|
194 | + 'not_found' => __('No discounts found', 'invoicing'), |
|
195 | + 'not_found_in_trash' => __('No discounts found in trash', 'invoicing'), |
|
196 | + 'parent' => __('Parent discount', 'invoicing'), |
|
197 | + 'featured_image' => __('Discount image', 'invoicing'), |
|
198 | + 'set_featured_image' => __('Set discount image', 'invoicing'), |
|
199 | + 'remove_featured_image' => __('Remove discount image', 'invoicing'), |
|
200 | + 'use_featured_image' => __('Use as discount image', 'invoicing'), |
|
201 | + 'insert_into_item' => __('Insert into discount', 'invoicing'), |
|
202 | + 'uploaded_to_this_item' => __('Uploaded to this discount', 'invoicing'), |
|
203 | + 'filter_items_list' => __('Filter discounts', 'invoicing'), |
|
204 | + 'items_list_navigation' => __('Discount navigation', 'invoicing'), |
|
205 | + 'items_list' => __('Discounts list', 'invoicing'), |
|
206 | 206 | ), |
207 | - 'description' => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ), |
|
207 | + 'description' => __('This is where you can add new discounts that users can use in invoices.', 'invoicing'), |
|
208 | 208 | 'public' => false, |
209 | 209 | 'can_export' => true, |
210 | 210 | '_builtin' => false, |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | 'map_meta_cap' => true, |
218 | 218 | 'has_archive' => false, |
219 | 219 | 'hierarchical' => false, |
220 | - 'supports' => array( 'title', 'excerpt' ), |
|
220 | + 'supports' => array('title', 'excerpt'), |
|
221 | 221 | 'show_in_nav_menus' => false, |
222 | 222 | 'show_in_admin_bar' => true, |
223 | 223 | 'menu_position' => null, |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | ) |
226 | 226 | ); |
227 | 227 | |
228 | - do_action( 'getpaid_after_register_post_types' ); |
|
228 | + do_action('getpaid_after_register_post_types'); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | /** |
@@ -238,79 +238,79 @@ discard block |
||
238 | 238 | array( |
239 | 239 | |
240 | 240 | 'wpi-pending' => array( |
241 | - 'label' => _x( 'Pending Payment', 'Invoice status', 'invoicing' ), |
|
241 | + 'label' => _x('Pending Payment', 'Invoice status', 'invoicing'), |
|
242 | 242 | 'public' => true, |
243 | 243 | 'exclude_from_search' => true, |
244 | 244 | 'show_in_admin_all_list' => true, |
245 | 245 | 'show_in_admin_status_list' => true, |
246 | 246 | /* translators: %s: number of invoices */ |
247 | - 'label_count' => _n_noop( 'Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'invoicing' ) |
|
247 | + 'label_count' => _n_noop('Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'invoicing') |
|
248 | 248 | ), |
249 | 249 | |
250 | 250 | 'wpi-processing' => array( |
251 | - 'label' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
|
251 | + 'label' => _x('Processing', 'Invoice status', 'invoicing'), |
|
252 | 252 | 'public' => true, |
253 | 253 | 'exclude_from_search' => true, |
254 | 254 | 'show_in_admin_all_list' => true, |
255 | 255 | 'show_in_admin_status_list' => true, |
256 | 256 | /* translators: %s: number of invoices */ |
257 | - 'label_count' => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' ) |
|
257 | + 'label_count' => _n_noop('Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing') |
|
258 | 258 | ), |
259 | 259 | |
260 | 260 | 'wpi-onhold' => array( |
261 | - 'label' => _x( 'On Hold', 'Invoice status', 'invoicing' ), |
|
261 | + 'label' => _x('On Hold', 'Invoice status', 'invoicing'), |
|
262 | 262 | 'public' => true, |
263 | 263 | 'exclude_from_search' => true, |
264 | 264 | 'show_in_admin_all_list' => true, |
265 | 265 | 'show_in_admin_status_list' => true, |
266 | 266 | /* translators: %s: number of invoices */ |
267 | - 'label_count' => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' ) |
|
267 | + 'label_count' => _n_noop('On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing') |
|
268 | 268 | ), |
269 | 269 | |
270 | 270 | 'wpi-cancelled' => array( |
271 | - 'label' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
271 | + 'label' => _x('Cancelled', 'Invoice status', 'invoicing'), |
|
272 | 272 | 'public' => true, |
273 | 273 | 'exclude_from_search' => true, |
274 | 274 | 'show_in_admin_all_list' => true, |
275 | 275 | 'show_in_admin_status_list' => true, |
276 | 276 | /* translators: %s: number of invoices */ |
277 | - 'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' ) |
|
277 | + 'label_count' => _n_noop('Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing') |
|
278 | 278 | ), |
279 | 279 | |
280 | 280 | 'wpi-refunded' => array( |
281 | - 'label' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
281 | + 'label' => _x('Refunded', 'Invoice status', 'invoicing'), |
|
282 | 282 | 'public' => true, |
283 | 283 | 'exclude_from_search' => true, |
284 | 284 | 'show_in_admin_all_list' => true, |
285 | 285 | 'show_in_admin_status_list' => true, |
286 | 286 | /* translators: %s: number of invoices */ |
287 | - 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' ) |
|
287 | + 'label_count' => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing') |
|
288 | 288 | ), |
289 | 289 | |
290 | 290 | 'wpi-failed' => array( |
291 | - 'label' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
|
291 | + 'label' => _x('Failed', 'Invoice status', 'invoicing'), |
|
292 | 292 | 'public' => true, |
293 | 293 | 'exclude_from_search' => true, |
294 | 294 | 'show_in_admin_all_list' => true, |
295 | 295 | 'show_in_admin_status_list' => true, |
296 | 296 | /* translators: %s: number of invoices */ |
297 | - 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' ) |
|
297 | + 'label_count' => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing') |
|
298 | 298 | ), |
299 | 299 | |
300 | 300 | 'wpi-renewal' => array( |
301 | - 'label' => _x( 'Renewal', 'Invoice status', 'invoicing' ), |
|
301 | + 'label' => _x('Renewal', 'Invoice status', 'invoicing'), |
|
302 | 302 | 'public' => true, |
303 | 303 | 'exclude_from_search' => true, |
304 | 304 | 'show_in_admin_all_list' => true, |
305 | 305 | 'show_in_admin_status_list' => true, |
306 | 306 | /* translators: %s: number of invoices */ |
307 | - 'label_count' => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' ) |
|
307 | + 'label_count' => _n_noop('Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing') |
|
308 | 308 | ) |
309 | 309 | ) |
310 | 310 | ); |
311 | 311 | |
312 | - foreach ( $invoice_statuses as $invoice_statuse => $args ) { |
|
313 | - register_post_status( $invoice_statuse, $args ); |
|
312 | + foreach ($invoice_statuses as $invoice_statuse => $args) { |
|
313 | + register_post_status($invoice_statuse, $args); |
|
314 | 314 | } |
315 | 315 | } |
316 | 316 | |
@@ -326,8 +326,8 @@ discard block |
||
326 | 326 | * |
327 | 327 | */ |
328 | 328 | public static function maybe_flush_rewrite_rules() { |
329 | - if ( ! get_option( 'getpaid_flushed_rewrite_rules' ) ) { |
|
330 | - update_option( 'getpaid_flushed_rewrite_rules', '1' ); |
|
329 | + if (!get_option('getpaid_flushed_rewrite_rules')) { |
|
330 | + update_option('getpaid_flushed_rewrite_rules', '1'); |
|
331 | 331 | self::flush_rewrite_rules(); |
332 | 332 | } |
333 | 333 | } |
@@ -13,30 +13,30 @@ discard block |
||
13 | 13 | class GetPaid_Bank_Transfer_Gateway extends GetPaid_Payment_Gateway { |
14 | 14 | |
15 | 15 | /** |
16 | - * Payment method id. |
|
17 | - * |
|
18 | - * @var string |
|
19 | - */ |
|
16 | + * Payment method id. |
|
17 | + * |
|
18 | + * @var string |
|
19 | + */ |
|
20 | 20 | public $id = 'bank_transfer'; |
21 | 21 | |
22 | - /** |
|
23 | - * An array of features that this gateway supports. |
|
24 | - * |
|
25 | - * @var array |
|
26 | - */ |
|
27 | - protected $supports = array( 'subscription', 'addons', 'single_subscription_group', 'multiple_subscription_groups' ); |
|
22 | + /** |
|
23 | + * An array of features that this gateway supports. |
|
24 | + * |
|
25 | + * @var array |
|
26 | + */ |
|
27 | + protected $supports = array( 'subscription', 'addons', 'single_subscription_group', 'multiple_subscription_groups' ); |
|
28 | 28 | |
29 | 29 | /** |
30 | - * Payment method order. |
|
31 | - * |
|
32 | - * @var int |
|
33 | - */ |
|
34 | - public $order = 8; |
|
30 | + * Payment method order. |
|
31 | + * |
|
32 | + * @var int |
|
33 | + */ |
|
34 | + public $order = 8; |
|
35 | 35 | |
36 | 36 | /** |
37 | - * Class constructor. |
|
38 | - */ |
|
39 | - public function __construct() { |
|
37 | + * Class constructor. |
|
38 | + */ |
|
39 | + public function __construct() { |
|
40 | 40 | parent::__construct(); |
41 | 41 | |
42 | 42 | $this->title = __( 'Direct bank transfer', 'invoicing' ); |
@@ -44,24 +44,24 @@ discard block |
||
44 | 44 | $this->checkout_button_text = __( 'Proceed', 'invoicing' ); |
45 | 45 | $this->instructions = apply_filters( 'wpinv_bank_instructions', $this->get_option( 'info' ) ); |
46 | 46 | |
47 | - add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) ); |
|
48 | - add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 ); |
|
49 | - add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 ); |
|
50 | - add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 ); |
|
51 | - add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ) ); |
|
52 | - add_action( 'getpaid_invoice_status_publish', array( $this, 'invoice_paid' ), 20 ); |
|
47 | + add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) ); |
|
48 | + add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 ); |
|
49 | + add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 ); |
|
50 | + add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 ); |
|
51 | + add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ) ); |
|
52 | + add_action( 'getpaid_invoice_status_publish', array( $this, 'invoice_paid' ), 20 ); |
|
53 | 53 | |
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
57 | - * Process Payment. |
|
58 | - * |
|
59 | - * @param WPInv_Invoice $invoice Invoice. |
|
60 | - * @param array $submission_data Posted checkout fields. |
|
61 | - * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
62 | - * @return array |
|
63 | - */ |
|
64 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
57 | + * Process Payment. |
|
58 | + * |
|
59 | + * @param WPInv_Invoice $invoice Invoice. |
|
60 | + * @param array $submission_data Posted checkout fields. |
|
61 | + * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
62 | + * @return array |
|
63 | + */ |
|
64 | + public function process_payment( $invoice, $submission_data, $submission ) { |
|
65 | 65 | |
66 | 66 | // Add a transaction id. |
67 | 67 | $invoice->set_transaction_id( $invoice->generate_key('bt_') ); |
@@ -82,66 +82,66 @@ discard block |
||
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
85 | - * Output for the order received page. |
|
86 | - * |
|
87 | - * @param WPInv_Invoice $invoice Invoice. |
|
88 | - */ |
|
89 | - public function thankyou_page( $invoice ) { |
|
85 | + * Output for the order received page. |
|
86 | + * |
|
87 | + * @param WPInv_Invoice $invoice Invoice. |
|
88 | + */ |
|
89 | + public function thankyou_page( $invoice ) { |
|
90 | 90 | |
91 | 91 | if ( 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) { |
92 | 92 | |
93 | - echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL; |
|
93 | + echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL; |
|
94 | 94 | |
95 | 95 | if ( ! empty( $this->instructions ) ) { |
96 | 96 | echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) ); |
97 | - } |
|
97 | + } |
|
98 | 98 | |
99 | - $this->bank_details( $invoice ); |
|
99 | + $this->bank_details( $invoice ); |
|
100 | 100 | |
101 | - echo '</div>'; |
|
101 | + echo '</div>'; |
|
102 | 102 | |
103 | 103 | } |
104 | 104 | |
105 | - } |
|
105 | + } |
|
106 | 106 | |
107 | 107 | /** |
108 | - * Add content to the WPI emails. |
|
109 | - * |
|
110 | - * @param WPInv_Invoice $invoice Invoice. |
|
111 | - * @param string $email_type Email format: plain text or HTML. |
|
112 | - * @param bool $sent_to_admin Sent to admin. |
|
113 | - */ |
|
114 | - public function email_instructions( $invoice, $email_type, $sent_to_admin ) { |
|
108 | + * Add content to the WPI emails. |
|
109 | + * |
|
110 | + * @param WPInv_Invoice $invoice Invoice. |
|
111 | + * @param string $email_type Email format: plain text or HTML. |
|
112 | + * @param bool $sent_to_admin Sent to admin. |
|
113 | + */ |
|
114 | + public function email_instructions( $invoice, $email_type, $sent_to_admin ) { |
|
115 | 115 | |
116 | - if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) { |
|
116 | + if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) { |
|
117 | 117 | |
118 | - echo '<div class="wpi-email-row getpaid-bank-transfer-details">'; |
|
118 | + echo '<div class="wpi-email-row getpaid-bank-transfer-details">'; |
|
119 | 119 | |
120 | - if ( $this->instructions ) { |
|
121 | - echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL ); |
|
120 | + if ( $this->instructions ) { |
|
121 | + echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL ); |
|
122 | 122 | } |
123 | 123 | |
124 | - $this->bank_details( $invoice ); |
|
124 | + $this->bank_details( $invoice ); |
|
125 | 125 | |
126 | - echo '</div>'; |
|
126 | + echo '</div>'; |
|
127 | 127 | |
128 | - } |
|
128 | + } |
|
129 | 129 | |
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
133 | - * Get bank details and place into a list format. |
|
134 | - * |
|
135 | - * @param WPInv_Invoice $invoice Invoice. |
|
136 | - */ |
|
137 | - protected function bank_details( $invoice ) { |
|
133 | + * Get bank details and place into a list format. |
|
134 | + * |
|
135 | + * @param WPInv_Invoice $invoice Invoice. |
|
136 | + */ |
|
137 | + protected function bank_details( $invoice ) { |
|
138 | 138 | |
139 | - // Get the invoice country and country $locale. |
|
140 | - $country = $invoice->get_country(); |
|
141 | - $locale = $this->get_country_locale(); |
|
139 | + // Get the invoice country and country $locale. |
|
140 | + $country = $invoice->get_country(); |
|
141 | + $locale = $this->get_country_locale(); |
|
142 | 142 | |
143 | - // Get sortcode label in the $locale array and use appropriate one. |
|
144 | - $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' ); |
|
143 | + // Get sortcode label in the $locale array and use appropriate one. |
|
144 | + $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' ); |
|
145 | 145 | |
146 | 146 | $bank_fields = array( |
147 | 147 | 'ac_name' => __( 'Account Name', 'invoicing' ), |
@@ -170,144 +170,144 @@ discard block |
||
170 | 170 | return; |
171 | 171 | } |
172 | 172 | |
173 | - echo '<h3 class="getpaid-bank-transfer-title"> ' . apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ) ) . '</h3>' . PHP_EOL; |
|
173 | + echo '<h3 class="getpaid-bank-transfer-title"> ' . apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ) ) . '</h3>' . PHP_EOL; |
|
174 | + |
|
175 | + echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL; |
|
176 | + |
|
177 | + foreach ( $bank_info as $key => $data ) { |
|
178 | + |
|
179 | + $key = sanitize_html_class( $key ); |
|
180 | + $label = wp_kses_post( $data['label'] ); |
|
181 | + $value = wp_kses_post( wptexturize( $data['value'] ) ); |
|
182 | + |
|
183 | + echo "<tr class='getpaid-bank-transfer-$key'><th class='font-weight-bold'>$label</th><td class='w-75'>$value</td></tr>" . PHP_EOL; |
|
184 | + } |
|
174 | 185 | |
175 | - echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL; |
|
186 | + echo '</table>'; |
|
176 | 187 | |
177 | - foreach ( $bank_info as $key => $data ) { |
|
188 | + } |
|
178 | 189 | |
179 | - $key = sanitize_html_class( $key ); |
|
180 | - $label = wp_kses_post( $data['label'] ); |
|
181 | - $value = wp_kses_post( wptexturize( $data['value'] ) ); |
|
190 | + /** |
|
191 | + * Get country locale if localized. |
|
192 | + * |
|
193 | + * @return array |
|
194 | + */ |
|
195 | + public function get_country_locale() { |
|
196 | + |
|
197 | + if ( empty( $this->locale ) ) { |
|
198 | + |
|
199 | + // Locale information to be used - only those that are not 'Sort Code'. |
|
200 | + $this->locale = apply_filters( |
|
201 | + 'getpaid_get_bank_transfer_locale', |
|
202 | + array( |
|
203 | + 'AU' => array( |
|
204 | + 'sortcode' => array( |
|
205 | + 'label' => __( 'BSB', 'invoicing' ), |
|
206 | + ), |
|
207 | + ), |
|
208 | + 'CA' => array( |
|
209 | + 'sortcode' => array( |
|
210 | + 'label' => __( 'Bank transit number', 'invoicing' ), |
|
211 | + ), |
|
212 | + ), |
|
213 | + 'IN' => array( |
|
214 | + 'sortcode' => array( |
|
215 | + 'label' => __( 'IFSC', 'invoicing' ), |
|
216 | + ), |
|
217 | + ), |
|
218 | + 'IT' => array( |
|
219 | + 'sortcode' => array( |
|
220 | + 'label' => __( 'Branch sort', 'invoicing' ), |
|
221 | + ), |
|
222 | + ), |
|
223 | + 'NZ' => array( |
|
224 | + 'sortcode' => array( |
|
225 | + 'label' => __( 'Bank code', 'invoicing' ), |
|
226 | + ), |
|
227 | + ), |
|
228 | + 'SE' => array( |
|
229 | + 'sortcode' => array( |
|
230 | + 'label' => __( 'Bank code', 'invoicing' ), |
|
231 | + ), |
|
232 | + ), |
|
233 | + 'US' => array( |
|
234 | + 'sortcode' => array( |
|
235 | + 'label' => __( 'Routing number', 'invoicing' ), |
|
236 | + ), |
|
237 | + ), |
|
238 | + 'ZA' => array( |
|
239 | + 'sortcode' => array( |
|
240 | + 'label' => __( 'Branch code', 'invoicing' ), |
|
241 | + ), |
|
242 | + ), |
|
243 | + ) |
|
244 | + ); |
|
182 | 245 | |
183 | - echo "<tr class='getpaid-bank-transfer-$key'><th class='font-weight-bold'>$label</th><td class='w-75'>$value</td></tr>" . PHP_EOL; |
|
184 | - } |
|
246 | + } |
|
185 | 247 | |
186 | - echo '</table>'; |
|
248 | + return $this->locale; |
|
187 | 249 | |
188 | 250 | } |
189 | 251 | |
190 | 252 | /** |
191 | - * Get country locale if localized. |
|
192 | - * |
|
193 | - * @return array |
|
194 | - */ |
|
195 | - public function get_country_locale() { |
|
196 | - |
|
197 | - if ( empty( $this->locale ) ) { |
|
198 | - |
|
199 | - // Locale information to be used - only those that are not 'Sort Code'. |
|
200 | - $this->locale = apply_filters( |
|
201 | - 'getpaid_get_bank_transfer_locale', |
|
202 | - array( |
|
203 | - 'AU' => array( |
|
204 | - 'sortcode' => array( |
|
205 | - 'label' => __( 'BSB', 'invoicing' ), |
|
206 | - ), |
|
207 | - ), |
|
208 | - 'CA' => array( |
|
209 | - 'sortcode' => array( |
|
210 | - 'label' => __( 'Bank transit number', 'invoicing' ), |
|
211 | - ), |
|
212 | - ), |
|
213 | - 'IN' => array( |
|
214 | - 'sortcode' => array( |
|
215 | - 'label' => __( 'IFSC', 'invoicing' ), |
|
216 | - ), |
|
217 | - ), |
|
218 | - 'IT' => array( |
|
219 | - 'sortcode' => array( |
|
220 | - 'label' => __( 'Branch sort', 'invoicing' ), |
|
221 | - ), |
|
222 | - ), |
|
223 | - 'NZ' => array( |
|
224 | - 'sortcode' => array( |
|
225 | - 'label' => __( 'Bank code', 'invoicing' ), |
|
226 | - ), |
|
227 | - ), |
|
228 | - 'SE' => array( |
|
229 | - 'sortcode' => array( |
|
230 | - 'label' => __( 'Bank code', 'invoicing' ), |
|
231 | - ), |
|
232 | - ), |
|
233 | - 'US' => array( |
|
234 | - 'sortcode' => array( |
|
235 | - 'label' => __( 'Routing number', 'invoicing' ), |
|
236 | - ), |
|
237 | - ), |
|
238 | - 'ZA' => array( |
|
239 | - 'sortcode' => array( |
|
240 | - 'label' => __( 'Branch code', 'invoicing' ), |
|
241 | - ), |
|
242 | - ), |
|
243 | - ) |
|
244 | - ); |
|
245 | - |
|
246 | - } |
|
247 | - |
|
248 | - return $this->locale; |
|
249 | - |
|
250 | - } |
|
251 | - |
|
252 | - /** |
|
253 | - * Filters the gateway settings. |
|
254 | - * |
|
255 | - * @param array $admin_settings |
|
256 | - */ |
|
257 | - public function admin_settings( $admin_settings ) { |
|
253 | + * Filters the gateway settings. |
|
254 | + * |
|
255 | + * @param array $admin_settings |
|
256 | + */ |
|
257 | + public function admin_settings( $admin_settings ) { |
|
258 | 258 | |
259 | 259 | $admin_settings['bank_transfer_desc']['std'] = __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' ); |
260 | - $admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' ); |
|
260 | + $admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' ); |
|
261 | 261 | |
262 | - $locale = $this->get_country_locale(); |
|
262 | + $locale = $this->get_country_locale(); |
|
263 | 263 | |
264 | - // Get sortcode label in the $locale array and use appropriate one. |
|
265 | - $country = wpinv_default_billing_country(); |
|
266 | - $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' ); |
|
264 | + // Get sortcode label in the $locale array and use appropriate one. |
|
265 | + $country = wpinv_default_billing_country(); |
|
266 | + $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' ); |
|
267 | 267 | |
268 | - $admin_settings['bank_transfer_ac_name'] = array( |
|
268 | + $admin_settings['bank_transfer_ac_name'] = array( |
|
269 | 269 | 'type' => 'text', |
270 | 270 | 'id' => 'bank_transfer_ac_name', |
271 | 271 | 'name' => __( 'Account Name', 'invoicing' ), |
272 | - ); |
|
272 | + ); |
|
273 | 273 | |
274 | - $admin_settings['bank_transfer_ac_no'] = array( |
|
274 | + $admin_settings['bank_transfer_ac_no'] = array( |
|
275 | 275 | 'type' => 'text', |
276 | 276 | 'id' => 'bank_transfer_ac_no', |
277 | 277 | 'name' => __( 'Account Number', 'invoicing' ), |
278 | - ); |
|
278 | + ); |
|
279 | 279 | |
280 | - $admin_settings['bank_transfer_bank_name'] = array( |
|
280 | + $admin_settings['bank_transfer_bank_name'] = array( |
|
281 | 281 | 'type' => 'text', |
282 | 282 | 'id' => 'bank_transfer_bank_name', |
283 | 283 | 'name' => __( 'Bank Name', 'invoicing' ), |
284 | - ); |
|
284 | + ); |
|
285 | 285 | |
286 | - $admin_settings['bank_transfer_ifsc'] = array( |
|
286 | + $admin_settings['bank_transfer_ifsc'] = array( |
|
287 | 287 | 'type' => 'text', |
288 | 288 | 'id' => 'bank_transfer_ifsc', |
289 | 289 | 'name' => __( 'IFSC Code', 'invoicing' ), |
290 | - ); |
|
290 | + ); |
|
291 | 291 | |
292 | - $admin_settings['bank_transfer_iban'] = array( |
|
292 | + $admin_settings['bank_transfer_iban'] = array( |
|
293 | 293 | 'type' => 'text', |
294 | 294 | 'id' => 'bank_transfer_iban', |
295 | 295 | 'name' => __( 'IBAN', 'invoicing' ), |
296 | - ); |
|
296 | + ); |
|
297 | 297 | |
298 | - $admin_settings['bank_transfer_bic'] = array( |
|
298 | + $admin_settings['bank_transfer_bic'] = array( |
|
299 | 299 | 'type' => 'text', |
300 | 300 | 'id' => 'bank_transfer_bic', |
301 | 301 | 'name' => __( 'BIC/Swift Code', 'invoicing' ), |
302 | - ); |
|
302 | + ); |
|
303 | 303 | |
304 | - $admin_settings['bank_transfer_sort_code'] = array( |
|
305 | - 'type' => 'text', |
|
306 | - 'id' => 'bank_transfer_sort_code', |
|
307 | - 'name' => $sortcode, |
|
308 | - ); |
|
304 | + $admin_settings['bank_transfer_sort_code'] = array( |
|
305 | + 'type' => 'text', |
|
306 | + 'id' => 'bank_transfer_sort_code', |
|
307 | + 'name' => $sortcode, |
|
308 | + ); |
|
309 | 309 | |
310 | - $admin_settings['bank_transfer_info'] = array( |
|
310 | + $admin_settings['bank_transfer_info'] = array( |
|
311 | 311 | 'id' => 'bank_transfer_info', |
312 | 312 | 'name' => __( 'Instructions', 'invoicing' ), |
313 | 313 | 'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ), |
@@ -317,17 +317,17 @@ discard block |
||
317 | 317 | 'rows' => 5 |
318 | 318 | ); |
319 | 319 | |
320 | - return $admin_settings; |
|
321 | - } |
|
320 | + return $admin_settings; |
|
321 | + } |
|
322 | 322 | |
323 | - /** |
|
324 | - * Processes invoice addons. |
|
325 | - * |
|
326 | - * @param WPInv_Invoice $invoice |
|
327 | - * @param GetPaid_Form_Item[] $items |
|
328 | - * @return WPInv_Invoice |
|
329 | - */ |
|
330 | - public function process_addons( $invoice, $items ) { |
|
323 | + /** |
|
324 | + * Processes invoice addons. |
|
325 | + * |
|
326 | + * @param WPInv_Invoice $invoice |
|
327 | + * @param GetPaid_Form_Item[] $items |
|
328 | + * @return WPInv_Invoice |
|
329 | + */ |
|
330 | + public function process_addons( $invoice, $items ) { |
|
331 | 331 | |
332 | 332 | foreach ( $items as $item ) { |
333 | 333 | $invoice->add_item( $item ); |
@@ -335,70 +335,70 @@ discard block |
||
335 | 335 | |
336 | 336 | $invoice->recalculate_total(); |
337 | 337 | $invoice->save(); |
338 | - } |
|
338 | + } |
|
339 | 339 | |
340 | - /** |
|
341 | - * (Maybe) renews a bank transfer subscription profile. |
|
342 | - * |
|
343 | - * |
|
340 | + /** |
|
341 | + * (Maybe) renews a bank transfer subscription profile. |
|
342 | + * |
|
343 | + * |
|
344 | 344 | * @param WPInv_Subscription $subscription |
345 | - */ |
|
346 | - public function maybe_renew_subscription( $subscription ) { |
|
345 | + */ |
|
346 | + public function maybe_renew_subscription( $subscription ) { |
|
347 | 347 | |
348 | 348 | // Ensure its our subscription && it's active. |
349 | 349 | if ( $this->id == $subscription->get_gateway() && $subscription->has_status( 'active trialling' ) ) { |
350 | - $subscription->create_payment(); |
|
350 | + $subscription->create_payment(); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | } |
354 | 354 | |
355 | - /** |
|
356 | - * Process a bank transfer payment. |
|
357 | - * |
|
358 | - * |
|
355 | + /** |
|
356 | + * Process a bank transfer payment. |
|
357 | + * |
|
358 | + * |
|
359 | 359 | * @param WPInv_Invoice $invoice |
360 | - */ |
|
361 | - public function invoice_paid( $invoice ) { |
|
360 | + */ |
|
361 | + public function invoice_paid( $invoice ) { |
|
362 | 362 | |
363 | - // Abort if not paid by bank transfer. |
|
364 | - if ( $this->id !== $invoice->get_gateway() || ! $invoice->is_recurring() ) { |
|
365 | - return; |
|
366 | - } |
|
363 | + // Abort if not paid by bank transfer. |
|
364 | + if ( $this->id !== $invoice->get_gateway() || ! $invoice->is_recurring() ) { |
|
365 | + return; |
|
366 | + } |
|
367 | 367 | |
368 | - // Is it a parent payment? |
|
369 | - if ( 0 == $invoice->get_parent_id() ) { |
|
368 | + // Is it a parent payment? |
|
369 | + if ( 0 == $invoice->get_parent_id() ) { |
|
370 | 370 | |
371 | - // (Maybe) activate subscriptions. |
|
372 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
371 | + // (Maybe) activate subscriptions. |
|
372 | + $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
373 | 373 | |
374 | - if ( ! empty( $subscriptions ) ) { |
|
375 | - $subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions ); |
|
374 | + if ( ! empty( $subscriptions ) ) { |
|
375 | + $subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions ); |
|
376 | 376 | |
377 | - foreach ( $subscriptions as $subscription ) { |
|
378 | - if ( $subscription->exists() ) { |
|
379 | - $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() ); |
|
380 | - $expiry = date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ); |
|
377 | + foreach ( $subscriptions as $subscription ) { |
|
378 | + if ( $subscription->exists() ) { |
|
379 | + $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() ); |
|
380 | + $expiry = date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ); |
|
381 | 381 | |
382 | - $subscription->set_next_renewal_date( $expiry ); |
|
383 | - $subscription->set_date_created( current_time( 'mysql' ) ); |
|
384 | - $subscription->set_profile_id( 'bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id() ); |
|
385 | - $subscription->activate(); |
|
386 | - } |
|
387 | - } |
|
382 | + $subscription->set_next_renewal_date( $expiry ); |
|
383 | + $subscription->set_date_created( current_time( 'mysql' ) ); |
|
384 | + $subscription->set_profile_id( 'bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id() ); |
|
385 | + $subscription->activate(); |
|
386 | + } |
|
387 | + } |
|
388 | 388 | |
389 | - } |
|
389 | + } |
|
390 | 390 | |
391 | - } else { |
|
391 | + } else { |
|
392 | 392 | |
393 | - $subscription = getpaid_get_subscription( $invoice->get_subscription_id() ); |
|
393 | + $subscription = getpaid_get_subscription( $invoice->get_subscription_id() ); |
|
394 | 394 | |
395 | - // Renew the subscription. |
|
396 | - if ( $subscription && $subscription->exists() ) { |
|
397 | - $subscription->add_payment( array(), $invoice ); |
|
398 | - $subscription->renew(); |
|
399 | - } |
|
395 | + // Renew the subscription. |
|
396 | + if ( $subscription && $subscription->exists() ) { |
|
397 | + $subscription->add_payment( array(), $invoice ); |
|
398 | + $subscription->renew(); |
|
399 | + } |
|
400 | 400 | |
401 | - } |
|
401 | + } |
|
402 | 402 | |
403 | 403 | } |
404 | 404 |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Bank transfer Payment Gateway class. |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @var array |
26 | 26 | */ |
27 | - protected $supports = array( 'subscription', 'addons', 'single_subscription_group', 'multiple_subscription_groups' ); |
|
27 | + protected $supports = array('subscription', 'addons', 'single_subscription_group', 'multiple_subscription_groups'); |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * Payment method order. |
@@ -39,17 +39,17 @@ discard block |
||
39 | 39 | public function __construct() { |
40 | 40 | parent::__construct(); |
41 | 41 | |
42 | - $this->title = __( 'Direct bank transfer', 'invoicing' ); |
|
43 | - $this->method_title = __( 'Bank transfer', 'invoicing' ); |
|
44 | - $this->checkout_button_text = __( 'Proceed', 'invoicing' ); |
|
45 | - $this->instructions = apply_filters( 'wpinv_bank_instructions', $this->get_option( 'info' ) ); |
|
42 | + $this->title = __('Direct bank transfer', 'invoicing'); |
|
43 | + $this->method_title = __('Bank transfer', 'invoicing'); |
|
44 | + $this->checkout_button_text = __('Proceed', 'invoicing'); |
|
45 | + $this->instructions = apply_filters('wpinv_bank_instructions', $this->get_option('info')); |
|
46 | 46 | |
47 | - add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) ); |
|
48 | - add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 ); |
|
49 | - add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 ); |
|
50 | - add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 ); |
|
51 | - add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ) ); |
|
52 | - add_action( 'getpaid_invoice_status_publish', array( $this, 'invoice_paid' ), 20 ); |
|
47 | + add_action('wpinv_receipt_end', array($this, 'thankyou_page')); |
|
48 | + add_action('getpaid_invoice_line_items', array($this, 'thankyou_page'), 40); |
|
49 | + add_action('wpinv_pdf_content_billing', array($this, 'thankyou_page'), 11); |
|
50 | + add_action('wpinv_email_invoice_details', array($this, 'email_instructions'), 10, 3); |
|
51 | + add_action('getpaid_should_renew_subscription', array($this, 'maybe_renew_subscription')); |
|
52 | + add_action('getpaid_invoice_status_publish', array($this, 'invoice_paid'), 20); |
|
53 | 53 | |
54 | 54 | } |
55 | 55 | |
@@ -61,23 +61,23 @@ discard block |
||
61 | 61 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
62 | 62 | * @return array |
63 | 63 | */ |
64 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
64 | + public function process_payment($invoice, $submission_data, $submission) { |
|
65 | 65 | |
66 | 66 | // Add a transaction id. |
67 | - $invoice->set_transaction_id( $invoice->generate_key('bt_') ); |
|
67 | + $invoice->set_transaction_id($invoice->generate_key('bt_')); |
|
68 | 68 | |
69 | 69 | // Set it as pending payment. |
70 | - if ( ! $invoice->needs_payment() ) { |
|
70 | + if (!$invoice->needs_payment()) { |
|
71 | 71 | $invoice->mark_paid(); |
72 | - } else if ( ! $invoice->is_paid() ) { |
|
73 | - $invoice->set_status( 'wpi-onhold' ); |
|
72 | + } else if (!$invoice->is_paid()) { |
|
73 | + $invoice->set_status('wpi-onhold'); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | // Save it. |
77 | 77 | $invoice->save(); |
78 | 78 | |
79 | 79 | // Send to the success page. |
80 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
80 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
81 | 81 | |
82 | 82 | } |
83 | 83 | |
@@ -86,17 +86,17 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @param WPInv_Invoice $invoice Invoice. |
88 | 88 | */ |
89 | - public function thankyou_page( $invoice ) { |
|
89 | + public function thankyou_page($invoice) { |
|
90 | 90 | |
91 | - if ( 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) { |
|
91 | + if ('bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment()) { |
|
92 | 92 | |
93 | 93 | echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL; |
94 | 94 | |
95 | - if ( ! empty( $this->instructions ) ) { |
|
96 | - echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) ); |
|
95 | + if (!empty($this->instructions)) { |
|
96 | + echo wp_kses_post(wpautop(wptexturize($this->instructions))); |
|
97 | 97 | } |
98 | 98 | |
99 | - $this->bank_details( $invoice ); |
|
99 | + $this->bank_details($invoice); |
|
100 | 100 | |
101 | 101 | echo '</div>'; |
102 | 102 | |
@@ -111,17 +111,17 @@ discard block |
||
111 | 111 | * @param string $email_type Email format: plain text or HTML. |
112 | 112 | * @param bool $sent_to_admin Sent to admin. |
113 | 113 | */ |
114 | - public function email_instructions( $invoice, $email_type, $sent_to_admin ) { |
|
114 | + public function email_instructions($invoice, $email_type, $sent_to_admin) { |
|
115 | 115 | |
116 | - if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) { |
|
116 | + if (!$sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment()) { |
|
117 | 117 | |
118 | 118 | echo '<div class="wpi-email-row getpaid-bank-transfer-details">'; |
119 | 119 | |
120 | - if ( $this->instructions ) { |
|
121 | - echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL ); |
|
120 | + if ($this->instructions) { |
|
121 | + echo wp_kses_post(wpautop(wptexturize($this->instructions)) . PHP_EOL); |
|
122 | 122 | } |
123 | 123 | |
124 | - $this->bank_details( $invoice ); |
|
124 | + $this->bank_details($invoice); |
|
125 | 125 | |
126 | 126 | echo '</div>'; |
127 | 127 | |
@@ -134,51 +134,51 @@ discard block |
||
134 | 134 | * |
135 | 135 | * @param WPInv_Invoice $invoice Invoice. |
136 | 136 | */ |
137 | - protected function bank_details( $invoice ) { |
|
137 | + protected function bank_details($invoice) { |
|
138 | 138 | |
139 | 139 | // Get the invoice country and country $locale. |
140 | 140 | $country = $invoice->get_country(); |
141 | 141 | $locale = $this->get_country_locale(); |
142 | 142 | |
143 | 143 | // Get sortcode label in the $locale array and use appropriate one. |
144 | - $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' ); |
|
144 | + $sortcode = isset($locale[$country]['sortcode']['label']) ? $locale[$country]['sortcode']['label'] : __('Sort code', 'invoicing'); |
|
145 | 145 | |
146 | 146 | $bank_fields = array( |
147 | - 'ac_name' => __( 'Account Name', 'invoicing' ), |
|
148 | - 'ac_no' => __( 'Account Number', 'invoicing' ), |
|
149 | - 'bank_name' => __( 'Bank Name', 'invoicing' ), |
|
150 | - 'ifsc' => __( 'IFSC code', 'invoicing' ), |
|
151 | - 'iban' => __( 'IBAN', 'invoicing' ), |
|
152 | - 'bic' => __( 'BIC/Swift code', 'invoicing' ), |
|
147 | + 'ac_name' => __('Account Name', 'invoicing'), |
|
148 | + 'ac_no' => __('Account Number', 'invoicing'), |
|
149 | + 'bank_name' => __('Bank Name', 'invoicing'), |
|
150 | + 'ifsc' => __('IFSC code', 'invoicing'), |
|
151 | + 'iban' => __('IBAN', 'invoicing'), |
|
152 | + 'bic' => __('BIC/Swift code', 'invoicing'), |
|
153 | 153 | 'sort_code' => $sortcode, |
154 | 154 | ); |
155 | 155 | |
156 | 156 | $bank_info = array(); |
157 | 157 | |
158 | - foreach ( $bank_fields as $field => $label ) { |
|
159 | - $value = $this->get_option( $field ); |
|
158 | + foreach ($bank_fields as $field => $label) { |
|
159 | + $value = $this->get_option($field); |
|
160 | 160 | |
161 | - if ( ! empty( $value ) ) { |
|
162 | - $bank_info[$field] = array( 'label' => $label, 'value' => $value ); |
|
161 | + if (!empty($value)) { |
|
162 | + $bank_info[$field] = array('label' => $label, 'value' => $value); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | } |
166 | 166 | |
167 | - $bank_info = apply_filters( 'wpinv_bank_info', $bank_info ); |
|
167 | + $bank_info = apply_filters('wpinv_bank_info', $bank_info); |
|
168 | 168 | |
169 | - if ( empty( $bank_info ) ) { |
|
169 | + if (empty($bank_info)) { |
|
170 | 170 | return; |
171 | 171 | } |
172 | 172 | |
173 | - echo '<h3 class="getpaid-bank-transfer-title"> ' . apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ) ) . '</h3>' . PHP_EOL; |
|
173 | + echo '<h3 class="getpaid-bank-transfer-title"> ' . apply_filters('wpinv_receipt_bank_details_title', __('Bank Details', 'invoicing')) . '</h3>' . PHP_EOL; |
|
174 | 174 | |
175 | 175 | echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL; |
176 | 176 | |
177 | - foreach ( $bank_info as $key => $data ) { |
|
177 | + foreach ($bank_info as $key => $data) { |
|
178 | 178 | |
179 | - $key = sanitize_html_class( $key ); |
|
180 | - $label = wp_kses_post( $data['label'] ); |
|
181 | - $value = wp_kses_post( wptexturize( $data['value'] ) ); |
|
179 | + $key = sanitize_html_class($key); |
|
180 | + $label = wp_kses_post($data['label']); |
|
181 | + $value = wp_kses_post(wptexturize($data['value'])); |
|
182 | 182 | |
183 | 183 | echo "<tr class='getpaid-bank-transfer-$key'><th class='font-weight-bold'>$label</th><td class='w-75'>$value</td></tr>" . PHP_EOL; |
184 | 184 | } |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | */ |
195 | 195 | public function get_country_locale() { |
196 | 196 | |
197 | - if ( empty( $this->locale ) ) { |
|
197 | + if (empty($this->locale)) { |
|
198 | 198 | |
199 | 199 | // Locale information to be used - only those that are not 'Sort Code'. |
200 | 200 | $this->locale = apply_filters( |
@@ -202,42 +202,42 @@ discard block |
||
202 | 202 | array( |
203 | 203 | 'AU' => array( |
204 | 204 | 'sortcode' => array( |
205 | - 'label' => __( 'BSB', 'invoicing' ), |
|
205 | + 'label' => __('BSB', 'invoicing'), |
|
206 | 206 | ), |
207 | 207 | ), |
208 | 208 | 'CA' => array( |
209 | 209 | 'sortcode' => array( |
210 | - 'label' => __( 'Bank transit number', 'invoicing' ), |
|
210 | + 'label' => __('Bank transit number', 'invoicing'), |
|
211 | 211 | ), |
212 | 212 | ), |
213 | 213 | 'IN' => array( |
214 | 214 | 'sortcode' => array( |
215 | - 'label' => __( 'IFSC', 'invoicing' ), |
|
215 | + 'label' => __('IFSC', 'invoicing'), |
|
216 | 216 | ), |
217 | 217 | ), |
218 | 218 | 'IT' => array( |
219 | 219 | 'sortcode' => array( |
220 | - 'label' => __( 'Branch sort', 'invoicing' ), |
|
220 | + 'label' => __('Branch sort', 'invoicing'), |
|
221 | 221 | ), |
222 | 222 | ), |
223 | 223 | 'NZ' => array( |
224 | 224 | 'sortcode' => array( |
225 | - 'label' => __( 'Bank code', 'invoicing' ), |
|
225 | + 'label' => __('Bank code', 'invoicing'), |
|
226 | 226 | ), |
227 | 227 | ), |
228 | 228 | 'SE' => array( |
229 | 229 | 'sortcode' => array( |
230 | - 'label' => __( 'Bank code', 'invoicing' ), |
|
230 | + 'label' => __('Bank code', 'invoicing'), |
|
231 | 231 | ), |
232 | 232 | ), |
233 | 233 | 'US' => array( |
234 | 234 | 'sortcode' => array( |
235 | - 'label' => __( 'Routing number', 'invoicing' ), |
|
235 | + 'label' => __('Routing number', 'invoicing'), |
|
236 | 236 | ), |
237 | 237 | ), |
238 | 238 | 'ZA' => array( |
239 | 239 | 'sortcode' => array( |
240 | - 'label' => __( 'Branch code', 'invoicing' ), |
|
240 | + 'label' => __('Branch code', 'invoicing'), |
|
241 | 241 | ), |
242 | 242 | ), |
243 | 243 | ) |
@@ -254,51 +254,51 @@ discard block |
||
254 | 254 | * |
255 | 255 | * @param array $admin_settings |
256 | 256 | */ |
257 | - public function admin_settings( $admin_settings ) { |
|
257 | + public function admin_settings($admin_settings) { |
|
258 | 258 | |
259 | - $admin_settings['bank_transfer_desc']['std'] = __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' ); |
|
260 | - $admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' ); |
|
259 | + $admin_settings['bank_transfer_desc']['std'] = __("Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing'); |
|
260 | + $admin_settings['bank_transfer_active']['desc'] = __('Enable bank transfer', 'invoicing'); |
|
261 | 261 | |
262 | - $locale = $this->get_country_locale(); |
|
262 | + $locale = $this->get_country_locale(); |
|
263 | 263 | |
264 | 264 | // Get sortcode label in the $locale array and use appropriate one. |
265 | 265 | $country = wpinv_default_billing_country(); |
266 | - $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' ); |
|
266 | + $sortcode = isset($locale[$country]['sortcode']['label']) ? $locale[$country]['sortcode']['label'] : __('Sort code', 'invoicing'); |
|
267 | 267 | |
268 | 268 | $admin_settings['bank_transfer_ac_name'] = array( |
269 | 269 | 'type' => 'text', |
270 | 270 | 'id' => 'bank_transfer_ac_name', |
271 | - 'name' => __( 'Account Name', 'invoicing' ), |
|
271 | + 'name' => __('Account Name', 'invoicing'), |
|
272 | 272 | ); |
273 | 273 | |
274 | 274 | $admin_settings['bank_transfer_ac_no'] = array( |
275 | 275 | 'type' => 'text', |
276 | 276 | 'id' => 'bank_transfer_ac_no', |
277 | - 'name' => __( 'Account Number', 'invoicing' ), |
|
277 | + 'name' => __('Account Number', 'invoicing'), |
|
278 | 278 | ); |
279 | 279 | |
280 | 280 | $admin_settings['bank_transfer_bank_name'] = array( |
281 | 281 | 'type' => 'text', |
282 | 282 | 'id' => 'bank_transfer_bank_name', |
283 | - 'name' => __( 'Bank Name', 'invoicing' ), |
|
283 | + 'name' => __('Bank Name', 'invoicing'), |
|
284 | 284 | ); |
285 | 285 | |
286 | 286 | $admin_settings['bank_transfer_ifsc'] = array( |
287 | 287 | 'type' => 'text', |
288 | 288 | 'id' => 'bank_transfer_ifsc', |
289 | - 'name' => __( 'IFSC Code', 'invoicing' ), |
|
289 | + 'name' => __('IFSC Code', 'invoicing'), |
|
290 | 290 | ); |
291 | 291 | |
292 | 292 | $admin_settings['bank_transfer_iban'] = array( |
293 | 293 | 'type' => 'text', |
294 | 294 | 'id' => 'bank_transfer_iban', |
295 | - 'name' => __( 'IBAN', 'invoicing' ), |
|
295 | + 'name' => __('IBAN', 'invoicing'), |
|
296 | 296 | ); |
297 | 297 | |
298 | 298 | $admin_settings['bank_transfer_bic'] = array( |
299 | 299 | 'type' => 'text', |
300 | 300 | 'id' => 'bank_transfer_bic', |
301 | - 'name' => __( 'BIC/Swift Code', 'invoicing' ), |
|
301 | + 'name' => __('BIC/Swift Code', 'invoicing'), |
|
302 | 302 | ); |
303 | 303 | |
304 | 304 | $admin_settings['bank_transfer_sort_code'] = array( |
@@ -309,10 +309,10 @@ discard block |
||
309 | 309 | |
310 | 310 | $admin_settings['bank_transfer_info'] = array( |
311 | 311 | 'id' => 'bank_transfer_info', |
312 | - 'name' => __( 'Instructions', 'invoicing' ), |
|
313 | - 'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ), |
|
312 | + 'name' => __('Instructions', 'invoicing'), |
|
313 | + 'desc' => __('Instructions that will be added to the thank you page and emails.', 'invoicing'), |
|
314 | 314 | 'type' => 'textarea', |
315 | - 'std' => __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' ), |
|
315 | + 'std' => __("Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing'), |
|
316 | 316 | 'cols' => 50, |
317 | 317 | 'rows' => 5 |
318 | 318 | ); |
@@ -327,10 +327,10 @@ discard block |
||
327 | 327 | * @param GetPaid_Form_Item[] $items |
328 | 328 | * @return WPInv_Invoice |
329 | 329 | */ |
330 | - public function process_addons( $invoice, $items ) { |
|
330 | + public function process_addons($invoice, $items) { |
|
331 | 331 | |
332 | - foreach ( $items as $item ) { |
|
333 | - $invoice->add_item( $item ); |
|
332 | + foreach ($items as $item) { |
|
333 | + $invoice->add_item($item); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | $invoice->recalculate_total(); |
@@ -343,10 +343,10 @@ discard block |
||
343 | 343 | * |
344 | 344 | * @param WPInv_Subscription $subscription |
345 | 345 | */ |
346 | - public function maybe_renew_subscription( $subscription ) { |
|
346 | + public function maybe_renew_subscription($subscription) { |
|
347 | 347 | |
348 | 348 | // Ensure its our subscription && it's active. |
349 | - if ( $this->id == $subscription->get_gateway() && $subscription->has_status( 'active trialling' ) ) { |
|
349 | + if ($this->id == $subscription->get_gateway() && $subscription->has_status('active trialling')) { |
|
350 | 350 | $subscription->create_payment(); |
351 | 351 | } |
352 | 352 | |
@@ -358,30 +358,30 @@ discard block |
||
358 | 358 | * |
359 | 359 | * @param WPInv_Invoice $invoice |
360 | 360 | */ |
361 | - public function invoice_paid( $invoice ) { |
|
361 | + public function invoice_paid($invoice) { |
|
362 | 362 | |
363 | 363 | // Abort if not paid by bank transfer. |
364 | - if ( $this->id !== $invoice->get_gateway() || ! $invoice->is_recurring() ) { |
|
364 | + if ($this->id !== $invoice->get_gateway() || !$invoice->is_recurring()) { |
|
365 | 365 | return; |
366 | 366 | } |
367 | 367 | |
368 | 368 | // Is it a parent payment? |
369 | - if ( 0 == $invoice->get_parent_id() ) { |
|
369 | + if (0 == $invoice->get_parent_id()) { |
|
370 | 370 | |
371 | 371 | // (Maybe) activate subscriptions. |
372 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
372 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
373 | 373 | |
374 | - if ( ! empty( $subscriptions ) ) { |
|
375 | - $subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions ); |
|
374 | + if (!empty($subscriptions)) { |
|
375 | + $subscriptions = is_array($subscriptions) ? $subscriptions : array($subscriptions); |
|
376 | 376 | |
377 | - foreach ( $subscriptions as $subscription ) { |
|
378 | - if ( $subscription->exists() ) { |
|
379 | - $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() ); |
|
380 | - $expiry = date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ); |
|
377 | + foreach ($subscriptions as $subscription) { |
|
378 | + if ($subscription->exists()) { |
|
379 | + $duration = strtotime($subscription->get_expiration()) - strtotime($subscription->get_date_created()); |
|
380 | + $expiry = date('Y-m-d H:i:s', (current_time('timestamp') + $duration)); |
|
381 | 381 | |
382 | - $subscription->set_next_renewal_date( $expiry ); |
|
383 | - $subscription->set_date_created( current_time( 'mysql' ) ); |
|
384 | - $subscription->set_profile_id( 'bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id() ); |
|
382 | + $subscription->set_next_renewal_date($expiry); |
|
383 | + $subscription->set_date_created(current_time('mysql')); |
|
384 | + $subscription->set_profile_id('bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id()); |
|
385 | 385 | $subscription->activate(); |
386 | 386 | } |
387 | 387 | } |
@@ -390,11 +390,11 @@ discard block |
||
390 | 390 | |
391 | 391 | } else { |
392 | 392 | |
393 | - $subscription = getpaid_get_subscription( $invoice->get_subscription_id() ); |
|
393 | + $subscription = getpaid_get_subscription($invoice->get_subscription_id()); |
|
394 | 394 | |
395 | 395 | // Renew the subscription. |
396 | - if ( $subscription && $subscription->exists() ) { |
|
397 | - $subscription->add_payment( array(), $invoice ); |
|
396 | + if ($subscription && $subscription->exists()) { |
|
397 | + $subscription->add_payment(array(), $invoice); |
|
398 | 398 | $subscription->renew(); |
399 | 399 | } |
400 | 400 |
@@ -436,7 +436,7 @@ |
||
436 | 436 | |
437 | 437 | if ( is_admin() && $pagenow && in_array($pagenow, $block_widget_init_screens)) { |
438 | 438 | // don't initiate in these conditions. |
439 | - }else{ |
|
439 | + } else{ |
|
440 | 440 | |
441 | 441 | // Only load allowed widgets. |
442 | 442 | $exclude = function_exists( 'sd_widget_exclude' ) ? sd_widget_exclude() : array(); |
@@ -14,621 +14,621 @@ |
||
14 | 14 | */ |
15 | 15 | class WPInv_Plugin { |
16 | 16 | |
17 | - /** |
|
18 | - * GetPaid version. |
|
19 | - * |
|
20 | - * @var string |
|
21 | - */ |
|
22 | - public $version; |
|
23 | - |
|
24 | - /** |
|
25 | - * Data container. |
|
26 | - * |
|
27 | - * @var array |
|
28 | - */ |
|
29 | - protected $data = array(); |
|
30 | - |
|
31 | - /** |
|
32 | - * Form elements instance. |
|
33 | - * |
|
34 | - * @var WPInv_Payment_Form_Elements |
|
35 | - */ |
|
36 | - public $form_elements; |
|
37 | - |
|
38 | - /** |
|
39 | - * @var array An array of payment gateways. |
|
40 | - */ |
|
41 | - public $gateways; |
|
42 | - |
|
43 | - /** |
|
44 | - * Class constructor. |
|
45 | - */ |
|
46 | - public function __construct() { |
|
47 | - $this->define_constants(); |
|
48 | - $this->includes(); |
|
49 | - $this->init_hooks(); |
|
50 | - $this->set_properties(); |
|
51 | - } |
|
52 | - |
|
53 | - /** |
|
54 | - * Sets a custom data property. |
|
55 | - * |
|
56 | - * @param string $prop The prop to set. |
|
57 | - * @param mixed $value The value to retrieve. |
|
58 | - */ |
|
59 | - public function set( $prop, $value ) { |
|
60 | - $this->data[ $prop ] = $value; |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * Gets a custom data property. |
|
65 | - * |
|
66 | - * @param string $prop The prop to set. |
|
67 | - * @return mixed The value. |
|
68 | - */ |
|
69 | - public function get( $prop ) { |
|
70 | - |
|
71 | - if ( isset( $this->data[ $prop ] ) ) { |
|
72 | - return $this->data[ $prop ]; |
|
73 | - } |
|
74 | - |
|
75 | - return null; |
|
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * Define class properties. |
|
80 | - */ |
|
81 | - public function set_properties() { |
|
82 | - |
|
83 | - // Sessions. |
|
84 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
85 | - $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility. |
|
86 | - $GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility. |
|
87 | - |
|
88 | - // Init other objects. |
|
89 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
90 | - $this->set( 'notes', new WPInv_Notes() ); |
|
91 | - $this->set( 'api', new WPInv_API() ); |
|
92 | - $this->set( 'post_types', new GetPaid_Post_Types() ); |
|
93 | - $this->set( 'template', new GetPaid_Template() ); |
|
94 | - $this->set( 'admin', new GetPaid_Admin() ); |
|
95 | - $this->set( 'subscriptions', new WPInv_Subscriptions() ); |
|
96 | - $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() ); |
|
97 | - $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() ); |
|
98 | - $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() ); |
|
99 | - $this->set( 'payment_forms', new GetPaid_Payment_Forms() ); |
|
100 | - $this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() ); |
|
101 | - |
|
102 | - } |
|
103 | - |
|
104 | - /** |
|
105 | - * Define plugin constants. |
|
106 | - */ |
|
107 | - public function define_constants() { |
|
108 | - define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
109 | - define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
110 | - $this->version = WPINV_VERSION; |
|
111 | - } |
|
112 | - |
|
113 | - /** |
|
114 | - * Hook into actions and filters. |
|
115 | - * |
|
116 | - * @since 1.0.19 |
|
117 | - */ |
|
118 | - protected function init_hooks() { |
|
119 | - /* Internationalize the text strings used. */ |
|
120 | - add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
121 | - |
|
122 | - // Init the plugin after WordPress inits. |
|
123 | - add_action( 'init', array( $this, 'init' ), 1 ); |
|
124 | - add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 ); |
|
125 | - add_action( 'init', array( $this, 'wpinv_actions' ) ); |
|
126 | - add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 ); |
|
127 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 ); |
|
128 | - add_action( 'wp_footer', array( $this, 'wp_footer' ) ); |
|
129 | - add_action( 'wp_head', array( $this, 'wp_head' ) ); |
|
130 | - add_action( 'widgets_init', array( $this, 'register_widgets' ) ); |
|
131 | - add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) ); |
|
132 | - add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
133 | - |
|
134 | - add_filter( 'query_vars', array( $this, 'custom_query_vars' ) ); |
|
17 | + /** |
|
18 | + * GetPaid version. |
|
19 | + * |
|
20 | + * @var string |
|
21 | + */ |
|
22 | + public $version; |
|
23 | + |
|
24 | + /** |
|
25 | + * Data container. |
|
26 | + * |
|
27 | + * @var array |
|
28 | + */ |
|
29 | + protected $data = array(); |
|
30 | + |
|
31 | + /** |
|
32 | + * Form elements instance. |
|
33 | + * |
|
34 | + * @var WPInv_Payment_Form_Elements |
|
35 | + */ |
|
36 | + public $form_elements; |
|
37 | + |
|
38 | + /** |
|
39 | + * @var array An array of payment gateways. |
|
40 | + */ |
|
41 | + public $gateways; |
|
42 | + |
|
43 | + /** |
|
44 | + * Class constructor. |
|
45 | + */ |
|
46 | + public function __construct() { |
|
47 | + $this->define_constants(); |
|
48 | + $this->includes(); |
|
49 | + $this->init_hooks(); |
|
50 | + $this->set_properties(); |
|
51 | + } |
|
52 | + |
|
53 | + /** |
|
54 | + * Sets a custom data property. |
|
55 | + * |
|
56 | + * @param string $prop The prop to set. |
|
57 | + * @param mixed $value The value to retrieve. |
|
58 | + */ |
|
59 | + public function set( $prop, $value ) { |
|
60 | + $this->data[ $prop ] = $value; |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * Gets a custom data property. |
|
65 | + * |
|
66 | + * @param string $prop The prop to set. |
|
67 | + * @return mixed The value. |
|
68 | + */ |
|
69 | + public function get( $prop ) { |
|
70 | + |
|
71 | + if ( isset( $this->data[ $prop ] ) ) { |
|
72 | + return $this->data[ $prop ]; |
|
73 | + } |
|
74 | + |
|
75 | + return null; |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * Define class properties. |
|
80 | + */ |
|
81 | + public function set_properties() { |
|
82 | + |
|
83 | + // Sessions. |
|
84 | + $this->set( 'session', new WPInv_Session_Handler() ); |
|
85 | + $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility. |
|
86 | + $GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility. |
|
87 | + |
|
88 | + // Init other objects. |
|
89 | + $this->set( 'session', new WPInv_Session_Handler() ); |
|
90 | + $this->set( 'notes', new WPInv_Notes() ); |
|
91 | + $this->set( 'api', new WPInv_API() ); |
|
92 | + $this->set( 'post_types', new GetPaid_Post_Types() ); |
|
93 | + $this->set( 'template', new GetPaid_Template() ); |
|
94 | + $this->set( 'admin', new GetPaid_Admin() ); |
|
95 | + $this->set( 'subscriptions', new WPInv_Subscriptions() ); |
|
96 | + $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() ); |
|
97 | + $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() ); |
|
98 | + $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() ); |
|
99 | + $this->set( 'payment_forms', new GetPaid_Payment_Forms() ); |
|
100 | + $this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() ); |
|
101 | + |
|
102 | + } |
|
103 | + |
|
104 | + /** |
|
105 | + * Define plugin constants. |
|
106 | + */ |
|
107 | + public function define_constants() { |
|
108 | + define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
109 | + define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
110 | + $this->version = WPINV_VERSION; |
|
111 | + } |
|
112 | + |
|
113 | + /** |
|
114 | + * Hook into actions and filters. |
|
115 | + * |
|
116 | + * @since 1.0.19 |
|
117 | + */ |
|
118 | + protected function init_hooks() { |
|
119 | + /* Internationalize the text strings used. */ |
|
120 | + add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
121 | + |
|
122 | + // Init the plugin after WordPress inits. |
|
123 | + add_action( 'init', array( $this, 'init' ), 1 ); |
|
124 | + add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 ); |
|
125 | + add_action( 'init', array( $this, 'wpinv_actions' ) ); |
|
126 | + add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 ); |
|
127 | + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 ); |
|
128 | + add_action( 'wp_footer', array( $this, 'wp_footer' ) ); |
|
129 | + add_action( 'wp_head', array( $this, 'wp_head' ) ); |
|
130 | + add_action( 'widgets_init', array( $this, 'register_widgets' ) ); |
|
131 | + add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) ); |
|
132 | + add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
133 | + |
|
134 | + add_filter( 'query_vars', array( $this, 'custom_query_vars' ) ); |
|
135 | 135 | add_action( 'init', array( $this, 'add_rewrite_rule' ), 10, 0 ); |
136 | - add_action( 'pre_get_posts', array( $this, 'maybe_process_new_ipn' ), 1 ); |
|
137 | - |
|
138 | - // Fires after registering actions. |
|
139 | - do_action( 'wpinv_actions', $this ); |
|
140 | - do_action( 'getpaid_actions', $this ); |
|
141 | - |
|
142 | - } |
|
143 | - |
|
144 | - public function plugins_loaded() { |
|
145 | - /* Internationalize the text strings used. */ |
|
146 | - $this->load_textdomain(); |
|
147 | - |
|
148 | - do_action( 'wpinv_loaded' ); |
|
149 | - |
|
150 | - // Fix oxygen page builder conflict |
|
151 | - if ( function_exists( 'ct_css_output' ) ) { |
|
152 | - wpinv_oxygen_fix_conflict(); |
|
153 | - } |
|
154 | - } |
|
155 | - |
|
156 | - /** |
|
157 | - * Load Localisation files. |
|
158 | - * |
|
159 | - * Note: the first-loaded translation file overrides any following ones if the same translation is present. |
|
160 | - * |
|
161 | - * Locales found in: |
|
162 | - * - WP_LANG_DIR/plugins/invoicing-LOCALE.mo |
|
163 | - * - WP_PLUGIN_DIR/invoicing/languages/invoicing-LOCALE.mo |
|
164 | - * |
|
165 | - * @since 1.0.0 |
|
166 | - */ |
|
167 | - public function load_textdomain() { |
|
168 | - |
|
169 | - load_plugin_textdomain( |
|
170 | - 'invoicing', |
|
171 | - false, |
|
172 | - plugin_basename( dirname( WPINV_PLUGIN_FILE ) ) . '/languages/' |
|
173 | - ); |
|
174 | - |
|
175 | - } |
|
176 | - |
|
177 | - /** |
|
178 | - * Include required core files used in admin and on the frontend. |
|
179 | - */ |
|
180 | - public function includes() { |
|
181 | - |
|
182 | - // Start with the settings. |
|
183 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
184 | - |
|
185 | - // Packages/libraries. |
|
186 | - require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' ); |
|
187 | - require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' ); |
|
188 | - |
|
189 | - // Load functions. |
|
190 | - require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' ); |
|
191 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
192 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
193 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
194 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
195 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
196 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
197 | - require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' ); |
|
198 | - require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' ); |
|
199 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
200 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
201 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
202 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
203 | - require_once( WPINV_PLUGIN_DIR . 'includes/user-functions.php' ); |
|
204 | - require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' ); |
|
205 | - |
|
206 | - // Register autoloader. |
|
207 | - try { |
|
208 | - spl_autoload_register( array( $this, 'autoload' ), true ); |
|
209 | - } catch ( Exception $e ) { |
|
210 | - wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true ); |
|
211 | - } |
|
212 | - |
|
213 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' ); |
|
214 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' ); |
|
215 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
216 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
217 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
218 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
219 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
220 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
221 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
222 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' ); |
|
223 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
224 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
|
225 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
|
226 | - require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
227 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
228 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
229 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
230 | - require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
231 | - require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
232 | - require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' ); |
|
233 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice.php' ); |
|
234 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
235 | - |
|
236 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
237 | - GetPaid_Post_Types_Admin::init(); |
|
238 | - |
|
239 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
240 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' ); |
|
241 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
242 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
|
243 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
244 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' ); |
|
245 | - // load the user class only on the users.php page |
|
246 | - global $pagenow; |
|
247 | - if($pagenow=='users.php'){ |
|
248 | - new WPInv_Admin_Users(); |
|
249 | - } |
|
250 | - } |
|
251 | - |
|
252 | - // Register cli commands |
|
253 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
254 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
|
255 | - WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
256 | - } |
|
257 | - |
|
258 | - } |
|
259 | - |
|
260 | - /** |
|
261 | - * Class autoloader |
|
262 | - * |
|
263 | - * @param string $class_name The name of the class to load. |
|
264 | - * @access public |
|
265 | - * @since 1.0.19 |
|
266 | - * @return void |
|
267 | - */ |
|
268 | - public function autoload( $class_name ) { |
|
269 | - |
|
270 | - // Normalize the class name... |
|
271 | - $class_name = strtolower( $class_name ); |
|
272 | - |
|
273 | - // ... and make sure it is our class. |
|
274 | - if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
|
275 | - return; |
|
276 | - } |
|
277 | - |
|
278 | - // Next, prepare the file name from the class. |
|
279 | - $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
|
280 | - |
|
281 | - // Base path of the classes. |
|
282 | - $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR ); |
|
283 | - |
|
284 | - // And an array of possible locations in order of importance. |
|
285 | - $locations = array( |
|
286 | - "$plugin_path/includes", |
|
287 | - "$plugin_path/includes/data-stores", |
|
288 | - "$plugin_path/includes/gateways", |
|
289 | - "$plugin_path/includes/payments", |
|
290 | - "$plugin_path/includes/geolocation", |
|
291 | - "$plugin_path/includes/reports", |
|
292 | - "$plugin_path/includes/api", |
|
293 | - "$plugin_path/includes/admin", |
|
294 | - "$plugin_path/includes/admin/meta-boxes", |
|
295 | - ); |
|
296 | - |
|
297 | - foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) { |
|
298 | - |
|
299 | - if ( file_exists( trailingslashit( $location ) . $file_name ) ) { |
|
300 | - include trailingslashit( $location ) . $file_name; |
|
301 | - break; |
|
302 | - } |
|
303 | - |
|
304 | - } |
|
305 | - |
|
306 | - } |
|
307 | - |
|
308 | - /** |
|
309 | - * Inits hooks etc. |
|
310 | - */ |
|
311 | - public function init() { |
|
312 | - |
|
313 | - // Fires before getpaid inits. |
|
314 | - do_action( 'before_getpaid_init', $this ); |
|
315 | - |
|
316 | - // Maybe upgrade. |
|
317 | - $this->maybe_upgrade_database(); |
|
318 | - |
|
319 | - // Load default gateways. |
|
320 | - $gateways = apply_filters( |
|
321 | - 'getpaid_default_gateways', |
|
322 | - array( |
|
323 | - 'manual' => 'GetPaid_Manual_Gateway', |
|
324 | - 'paypal' => 'GetPaid_Paypal_Gateway', |
|
325 | - 'worldpay' => 'GetPaid_Worldpay_Gateway', |
|
326 | - 'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway', |
|
327 | - 'authorizenet' => 'GetPaid_Authorize_Net_Gateway', |
|
328 | - ) |
|
329 | - ); |
|
330 | - |
|
331 | - foreach ( $gateways as $id => $class ) { |
|
332 | - $this->gateways[ $id ] = new $class(); |
|
333 | - } |
|
334 | - |
|
335 | - if ( 'yes' != get_option( 'wpinv_renamed_gateways' ) ) { |
|
336 | - GetPaid_Installer::rename_gateways_label(); |
|
337 | - update_option( 'wpinv_renamed_gateways', 'yes' ); |
|
338 | - } |
|
339 | - |
|
340 | - // Fires after getpaid inits. |
|
341 | - do_action( 'getpaid_init', $this ); |
|
342 | - |
|
343 | - } |
|
344 | - |
|
345 | - /** |
|
346 | - * Checks if this is an IPN request and processes it. |
|
347 | - */ |
|
348 | - public function maybe_process_ipn() { |
|
349 | - |
|
350 | - // Ensure that this is an IPN request. |
|
351 | - if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) { |
|
352 | - return; |
|
353 | - } |
|
354 | - |
|
355 | - $gateway = sanitize_text_field( $_GET['wpi-gateway'] ); |
|
356 | - |
|
357 | - do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
358 | - do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
359 | - exit; |
|
360 | - |
|
361 | - } |
|
362 | - |
|
363 | - public function enqueue_scripts() { |
|
364 | - |
|
365 | - // Fires before adding scripts. |
|
366 | - do_action( 'getpaid_enqueue_scripts' ); |
|
367 | - |
|
368 | - $localize = array(); |
|
369 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
370 | - $localize['thousands'] = wpinv_thousands_separator(); |
|
371 | - $localize['decimals'] = wpinv_decimal_separator(); |
|
372 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
373 | - $localize['txtComplete'] = __( 'Continue', 'invoicing' ); |
|
374 | - $localize['UseTaxes'] = wpinv_use_taxes(); |
|
375 | - $localize['formNonce'] = wp_create_nonce( 'getpaid_form_nonce' ); |
|
376 | - $localize['loading'] = __( 'Loading...', 'invoicing' ); |
|
377 | - $localize['connectionError'] = __( 'Could not establish a connection to the server.', 'invoicing' ); |
|
378 | - |
|
379 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
380 | - |
|
381 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' ); |
|
382 | - wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'jquery' ), $version, true ); |
|
383 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
384 | - } |
|
385 | - |
|
386 | - public function wpinv_actions() { |
|
387 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
388 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
389 | - } |
|
390 | - |
|
391 | - if ( defined( 'WP_ALL_IMPORT_ROOT_DIR' ) ) { |
|
392 | - include plugin_dir_path( __FILE__ ) . 'libraries/wp-all-import/class-getpaid-wp-all-import.php'; |
|
393 | - } |
|
394 | - } |
|
136 | + add_action( 'pre_get_posts', array( $this, 'maybe_process_new_ipn' ), 1 ); |
|
137 | + |
|
138 | + // Fires after registering actions. |
|
139 | + do_action( 'wpinv_actions', $this ); |
|
140 | + do_action( 'getpaid_actions', $this ); |
|
141 | + |
|
142 | + } |
|
143 | + |
|
144 | + public function plugins_loaded() { |
|
145 | + /* Internationalize the text strings used. */ |
|
146 | + $this->load_textdomain(); |
|
147 | + |
|
148 | + do_action( 'wpinv_loaded' ); |
|
149 | + |
|
150 | + // Fix oxygen page builder conflict |
|
151 | + if ( function_exists( 'ct_css_output' ) ) { |
|
152 | + wpinv_oxygen_fix_conflict(); |
|
153 | + } |
|
154 | + } |
|
155 | + |
|
156 | + /** |
|
157 | + * Load Localisation files. |
|
158 | + * |
|
159 | + * Note: the first-loaded translation file overrides any following ones if the same translation is present. |
|
160 | + * |
|
161 | + * Locales found in: |
|
162 | + * - WP_LANG_DIR/plugins/invoicing-LOCALE.mo |
|
163 | + * - WP_PLUGIN_DIR/invoicing/languages/invoicing-LOCALE.mo |
|
164 | + * |
|
165 | + * @since 1.0.0 |
|
166 | + */ |
|
167 | + public function load_textdomain() { |
|
168 | + |
|
169 | + load_plugin_textdomain( |
|
170 | + 'invoicing', |
|
171 | + false, |
|
172 | + plugin_basename( dirname( WPINV_PLUGIN_FILE ) ) . '/languages/' |
|
173 | + ); |
|
174 | + |
|
175 | + } |
|
176 | + |
|
177 | + /** |
|
178 | + * Include required core files used in admin and on the frontend. |
|
179 | + */ |
|
180 | + public function includes() { |
|
181 | + |
|
182 | + // Start with the settings. |
|
183 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
184 | + |
|
185 | + // Packages/libraries. |
|
186 | + require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' ); |
|
187 | + require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' ); |
|
188 | + |
|
189 | + // Load functions. |
|
190 | + require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' ); |
|
191 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
192 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
193 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
194 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
195 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
196 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
197 | + require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' ); |
|
198 | + require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' ); |
|
199 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
200 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
201 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
202 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
203 | + require_once( WPINV_PLUGIN_DIR . 'includes/user-functions.php' ); |
|
204 | + require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' ); |
|
205 | + |
|
206 | + // Register autoloader. |
|
207 | + try { |
|
208 | + spl_autoload_register( array( $this, 'autoload' ), true ); |
|
209 | + } catch ( Exception $e ) { |
|
210 | + wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true ); |
|
211 | + } |
|
212 | + |
|
213 | + require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' ); |
|
214 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' ); |
|
215 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
216 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
217 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
218 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
219 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
220 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
221 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
222 | + require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' ); |
|
223 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
224 | + require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
|
225 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
|
226 | + require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
227 | + require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
228 | + require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
229 | + require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
230 | + require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
231 | + require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
232 | + require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' ); |
|
233 | + require_once( WPINV_PLUGIN_DIR . 'widgets/invoice.php' ); |
|
234 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
235 | + |
|
236 | + if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
237 | + GetPaid_Post_Types_Admin::init(); |
|
238 | + |
|
239 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
240 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' ); |
|
241 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
242 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
|
243 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
244 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' ); |
|
245 | + // load the user class only on the users.php page |
|
246 | + global $pagenow; |
|
247 | + if($pagenow=='users.php'){ |
|
248 | + new WPInv_Admin_Users(); |
|
249 | + } |
|
250 | + } |
|
251 | + |
|
252 | + // Register cli commands |
|
253 | + if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
254 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
|
255 | + WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
256 | + } |
|
257 | + |
|
258 | + } |
|
259 | + |
|
260 | + /** |
|
261 | + * Class autoloader |
|
262 | + * |
|
263 | + * @param string $class_name The name of the class to load. |
|
264 | + * @access public |
|
265 | + * @since 1.0.19 |
|
266 | + * @return void |
|
267 | + */ |
|
268 | + public function autoload( $class_name ) { |
|
269 | + |
|
270 | + // Normalize the class name... |
|
271 | + $class_name = strtolower( $class_name ); |
|
272 | + |
|
273 | + // ... and make sure it is our class. |
|
274 | + if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
|
275 | + return; |
|
276 | + } |
|
277 | + |
|
278 | + // Next, prepare the file name from the class. |
|
279 | + $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
|
280 | + |
|
281 | + // Base path of the classes. |
|
282 | + $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR ); |
|
283 | + |
|
284 | + // And an array of possible locations in order of importance. |
|
285 | + $locations = array( |
|
286 | + "$plugin_path/includes", |
|
287 | + "$plugin_path/includes/data-stores", |
|
288 | + "$plugin_path/includes/gateways", |
|
289 | + "$plugin_path/includes/payments", |
|
290 | + "$plugin_path/includes/geolocation", |
|
291 | + "$plugin_path/includes/reports", |
|
292 | + "$plugin_path/includes/api", |
|
293 | + "$plugin_path/includes/admin", |
|
294 | + "$plugin_path/includes/admin/meta-boxes", |
|
295 | + ); |
|
296 | + |
|
297 | + foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) { |
|
298 | + |
|
299 | + if ( file_exists( trailingslashit( $location ) . $file_name ) ) { |
|
300 | + include trailingslashit( $location ) . $file_name; |
|
301 | + break; |
|
302 | + } |
|
303 | + |
|
304 | + } |
|
305 | + |
|
306 | + } |
|
307 | + |
|
308 | + /** |
|
309 | + * Inits hooks etc. |
|
310 | + */ |
|
311 | + public function init() { |
|
312 | + |
|
313 | + // Fires before getpaid inits. |
|
314 | + do_action( 'before_getpaid_init', $this ); |
|
315 | + |
|
316 | + // Maybe upgrade. |
|
317 | + $this->maybe_upgrade_database(); |
|
318 | + |
|
319 | + // Load default gateways. |
|
320 | + $gateways = apply_filters( |
|
321 | + 'getpaid_default_gateways', |
|
322 | + array( |
|
323 | + 'manual' => 'GetPaid_Manual_Gateway', |
|
324 | + 'paypal' => 'GetPaid_Paypal_Gateway', |
|
325 | + 'worldpay' => 'GetPaid_Worldpay_Gateway', |
|
326 | + 'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway', |
|
327 | + 'authorizenet' => 'GetPaid_Authorize_Net_Gateway', |
|
328 | + ) |
|
329 | + ); |
|
330 | + |
|
331 | + foreach ( $gateways as $id => $class ) { |
|
332 | + $this->gateways[ $id ] = new $class(); |
|
333 | + } |
|
334 | + |
|
335 | + if ( 'yes' != get_option( 'wpinv_renamed_gateways' ) ) { |
|
336 | + GetPaid_Installer::rename_gateways_label(); |
|
337 | + update_option( 'wpinv_renamed_gateways', 'yes' ); |
|
338 | + } |
|
339 | + |
|
340 | + // Fires after getpaid inits. |
|
341 | + do_action( 'getpaid_init', $this ); |
|
342 | + |
|
343 | + } |
|
395 | 344 | |
396 | - /** |
|
345 | + /** |
|
346 | + * Checks if this is an IPN request and processes it. |
|
347 | + */ |
|
348 | + public function maybe_process_ipn() { |
|
349 | + |
|
350 | + // Ensure that this is an IPN request. |
|
351 | + if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) { |
|
352 | + return; |
|
353 | + } |
|
354 | + |
|
355 | + $gateway = sanitize_text_field( $_GET['wpi-gateway'] ); |
|
356 | + |
|
357 | + do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
358 | + do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
359 | + exit; |
|
360 | + |
|
361 | + } |
|
362 | + |
|
363 | + public function enqueue_scripts() { |
|
364 | + |
|
365 | + // Fires before adding scripts. |
|
366 | + do_action( 'getpaid_enqueue_scripts' ); |
|
367 | + |
|
368 | + $localize = array(); |
|
369 | + $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
370 | + $localize['thousands'] = wpinv_thousands_separator(); |
|
371 | + $localize['decimals'] = wpinv_decimal_separator(); |
|
372 | + $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
373 | + $localize['txtComplete'] = __( 'Continue', 'invoicing' ); |
|
374 | + $localize['UseTaxes'] = wpinv_use_taxes(); |
|
375 | + $localize['formNonce'] = wp_create_nonce( 'getpaid_form_nonce' ); |
|
376 | + $localize['loading'] = __( 'Loading...', 'invoicing' ); |
|
377 | + $localize['connectionError'] = __( 'Could not establish a connection to the server.', 'invoicing' ); |
|
378 | + |
|
379 | + $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
380 | + |
|
381 | + $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' ); |
|
382 | + wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'jquery' ), $version, true ); |
|
383 | + wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
384 | + } |
|
385 | + |
|
386 | + public function wpinv_actions() { |
|
387 | + if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
388 | + do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
389 | + } |
|
390 | + |
|
391 | + if ( defined( 'WP_ALL_IMPORT_ROOT_DIR' ) ) { |
|
392 | + include plugin_dir_path( __FILE__ ) . 'libraries/wp-all-import/class-getpaid-wp-all-import.php'; |
|
393 | + } |
|
394 | + } |
|
395 | + |
|
396 | + /** |
|
397 | 397 | * Fires an action after verifying that a user can fire them. |
398 | - * |
|
399 | - * Note: If the action is on an invoice, subscription etc, esure that the |
|
400 | - * current user owns the invoice/subscription. |
|
398 | + * |
|
399 | + * Note: If the action is on an invoice, subscription etc, esure that the |
|
400 | + * current user owns the invoice/subscription. |
|
401 | 401 | */ |
402 | 402 | public function maybe_do_authenticated_action() { |
403 | 403 | |
404 | - if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
404 | + if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
405 | + |
|
406 | + $key = sanitize_key( $_REQUEST['getpaid-action'] ); |
|
407 | + $data = wp_unslash( $_REQUEST ); |
|
408 | + if ( is_user_logged_in() ) { |
|
409 | + do_action( "getpaid_authenticated_action_$key", $data ); |
|
410 | + } |
|
411 | + |
|
412 | + do_action( "getpaid_unauthenticated_action_$key", $data ); |
|
413 | + |
|
414 | + } |
|
415 | + |
|
416 | + } |
|
417 | + |
|
418 | + public function pre_get_posts( $wp_query ) { |
|
419 | + |
|
420 | + if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) { |
|
421 | + $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) ); |
|
422 | + } |
|
423 | + |
|
424 | + return $wp_query; |
|
425 | + } |
|
426 | + |
|
427 | + /** |
|
428 | + * Register widgets |
|
429 | + * |
|
430 | + */ |
|
431 | + public function register_widgets() { |
|
432 | + global $pagenow; |
|
433 | + |
|
434 | + // Currently, UX Builder does not work particulaly well with SuperDuper. |
|
435 | + // So we disable our widgets when editing a page with UX Builder. |
|
436 | + if ( function_exists( 'ux_builder_is_active' ) && ux_builder_is_active() ) { |
|
437 | + return; |
|
438 | + } |
|
439 | + |
|
440 | + $block_widget_init_screens = function_exists('sd_pagenow_exclude') ? sd_pagenow_exclude() : array(); |
|
441 | + |
|
442 | + if ( is_admin() && $pagenow && in_array($pagenow, $block_widget_init_screens)) { |
|
443 | + // don't initiate in these conditions. |
|
444 | + }else{ |
|
445 | + |
|
446 | + // Only load allowed widgets. |
|
447 | + $exclude = function_exists( 'sd_widget_exclude' ) ? sd_widget_exclude() : array(); |
|
448 | + $widgets = apply_filters( |
|
449 | + 'getpaid_widget_classes', |
|
450 | + array( |
|
451 | + 'WPInv_Checkout_Widget', |
|
452 | + 'WPInv_History_Widget', |
|
453 | + 'WPInv_Receipt_Widget', |
|
454 | + 'WPInv_Subscriptions_Widget', |
|
455 | + 'WPInv_Buy_Item_Widget', |
|
456 | + 'WPInv_Messages_Widget', |
|
457 | + 'WPInv_GetPaid_Widget', |
|
458 | + 'WPInv_Invoice_Widget' |
|
459 | + ) |
|
460 | + ); |
|
461 | + |
|
462 | + // For each widget... |
|
463 | + foreach ( $widgets as $widget ) { |
|
464 | + |
|
465 | + // Abort early if it is excluded for this page. |
|
466 | + if ( in_array( $widget, $exclude ) ) { |
|
467 | + continue; |
|
468 | + } |
|
469 | + |
|
470 | + // SD V1 used to extend the widget class. V2 does not, so we cannot call register widget on it. |
|
471 | + if ( is_subclass_of( $widget, 'WP_Widget' ) ) { |
|
472 | + register_widget( $widget ); |
|
473 | + } else { |
|
474 | + new $widget(); |
|
475 | + } |
|
476 | + |
|
477 | + } |
|
478 | + |
|
479 | + } |
|
480 | + |
|
481 | + } |
|
482 | + |
|
483 | + /** |
|
484 | + * Upgrades the database. |
|
485 | + * |
|
486 | + * @since 2.0.2 |
|
487 | + */ |
|
488 | + public function maybe_upgrade_database() { |
|
489 | + |
|
490 | + $wpi_version = get_option( 'wpinv_version', 0 ); |
|
491 | + |
|
492 | + if ( $wpi_version == WPINV_VERSION ) { |
|
493 | + return; |
|
494 | + } |
|
495 | + |
|
496 | + $installer = new GetPaid_Installer(); |
|
497 | + |
|
498 | + if ( empty( $wpi_version ) ) { |
|
499 | + return $installer->upgrade_db( 0 ); |
|
500 | + } |
|
501 | + |
|
502 | + $upgrades = array( |
|
503 | + '0.0.5' => '004', |
|
504 | + '1.0.3' => '102', |
|
505 | + '2.0.0' => '118', |
|
506 | + '2.0.8' => '207', |
|
507 | + ); |
|
508 | + |
|
509 | + foreach ( $upgrades as $key => $method ) { |
|
510 | + |
|
511 | + if ( version_compare( $wpi_version, $key, '<' ) ) { |
|
512 | + return $installer->upgrade_db( $method ); |
|
513 | + } |
|
514 | + |
|
515 | + } |
|
405 | 516 | |
406 | - $key = sanitize_key( $_REQUEST['getpaid-action'] ); |
|
407 | - $data = wp_unslash( $_REQUEST ); |
|
408 | - if ( is_user_logged_in() ) { |
|
409 | - do_action( "getpaid_authenticated_action_$key", $data ); |
|
410 | - } |
|
517 | + } |
|
411 | 518 | |
412 | - do_action( "getpaid_unauthenticated_action_$key", $data ); |
|
519 | + /** |
|
520 | + * Flushes the permalinks if needed. |
|
521 | + * |
|
522 | + * @since 2.0.8 |
|
523 | + */ |
|
524 | + public function maybe_flush_permalinks() { |
|
413 | 525 | |
414 | - } |
|
526 | + $flush = get_option( 'wpinv_flush_permalinks', 0 ); |
|
527 | + |
|
528 | + if ( ! empty( $flush ) ) { |
|
529 | + flush_rewrite_rules(); |
|
530 | + delete_option( 'wpinv_flush_permalinks' ); |
|
531 | + } |
|
415 | 532 | |
416 | 533 | } |
417 | 534 | |
418 | - public function pre_get_posts( $wp_query ) { |
|
535 | + /** |
|
536 | + * Remove our pages from yoast sitemaps. |
|
537 | + * |
|
538 | + * @since 1.0.19 |
|
539 | + * @param int[] $excluded_posts_ids |
|
540 | + */ |
|
541 | + public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){ |
|
419 | 542 | |
420 | - if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) { |
|
421 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) ); |
|
422 | - } |
|
423 | - |
|
424 | - return $wp_query; |
|
425 | - } |
|
426 | - |
|
427 | - /** |
|
428 | - * Register widgets |
|
429 | - * |
|
430 | - */ |
|
431 | - public function register_widgets() { |
|
432 | - global $pagenow; |
|
433 | - |
|
434 | - // Currently, UX Builder does not work particulaly well with SuperDuper. |
|
435 | - // So we disable our widgets when editing a page with UX Builder. |
|
436 | - if ( function_exists( 'ux_builder_is_active' ) && ux_builder_is_active() ) { |
|
437 | - return; |
|
438 | - } |
|
439 | - |
|
440 | - $block_widget_init_screens = function_exists('sd_pagenow_exclude') ? sd_pagenow_exclude() : array(); |
|
441 | - |
|
442 | - if ( is_admin() && $pagenow && in_array($pagenow, $block_widget_init_screens)) { |
|
443 | - // don't initiate in these conditions. |
|
444 | - }else{ |
|
445 | - |
|
446 | - // Only load allowed widgets. |
|
447 | - $exclude = function_exists( 'sd_widget_exclude' ) ? sd_widget_exclude() : array(); |
|
448 | - $widgets = apply_filters( |
|
449 | - 'getpaid_widget_classes', |
|
450 | - array( |
|
451 | - 'WPInv_Checkout_Widget', |
|
452 | - 'WPInv_History_Widget', |
|
453 | - 'WPInv_Receipt_Widget', |
|
454 | - 'WPInv_Subscriptions_Widget', |
|
455 | - 'WPInv_Buy_Item_Widget', |
|
456 | - 'WPInv_Messages_Widget', |
|
457 | - 'WPInv_GetPaid_Widget', |
|
458 | - 'WPInv_Invoice_Widget' |
|
459 | - ) |
|
460 | - ); |
|
461 | - |
|
462 | - // For each widget... |
|
463 | - foreach ( $widgets as $widget ) { |
|
464 | - |
|
465 | - // Abort early if it is excluded for this page. |
|
466 | - if ( in_array( $widget, $exclude ) ) { |
|
467 | - continue; |
|
468 | - } |
|
543 | + // Ensure that we have an array. |
|
544 | + if ( ! is_array( $excluded_posts_ids ) ) { |
|
545 | + $excluded_posts_ids = array(); |
|
546 | + } |
|
469 | 547 | |
470 | - // SD V1 used to extend the widget class. V2 does not, so we cannot call register widget on it. |
|
471 | - if ( is_subclass_of( $widget, 'WP_Widget' ) ) { |
|
472 | - register_widget( $widget ); |
|
473 | - } else { |
|
474 | - new $widget(); |
|
475 | - } |
|
548 | + // Prepare our pages. |
|
549 | + $our_pages = array(); |
|
476 | 550 | |
477 | - } |
|
551 | + // Checkout page. |
|
552 | + $our_pages[] = wpinv_get_option( 'checkout_page', false ); |
|
478 | 553 | |
479 | - } |
|
480 | - |
|
481 | - } |
|
554 | + // Success page. |
|
555 | + $our_pages[] = wpinv_get_option( 'success_page', false ); |
|
482 | 556 | |
483 | - /** |
|
484 | - * Upgrades the database. |
|
485 | - * |
|
486 | - * @since 2.0.2 |
|
487 | - */ |
|
488 | - public function maybe_upgrade_database() { |
|
489 | - |
|
490 | - $wpi_version = get_option( 'wpinv_version', 0 ); |
|
491 | - |
|
492 | - if ( $wpi_version == WPINV_VERSION ) { |
|
493 | - return; |
|
494 | - } |
|
495 | - |
|
496 | - $installer = new GetPaid_Installer(); |
|
497 | - |
|
498 | - if ( empty( $wpi_version ) ) { |
|
499 | - return $installer->upgrade_db( 0 ); |
|
500 | - } |
|
501 | - |
|
502 | - $upgrades = array( |
|
503 | - '0.0.5' => '004', |
|
504 | - '1.0.3' => '102', |
|
505 | - '2.0.0' => '118', |
|
506 | - '2.0.8' => '207', |
|
507 | - ); |
|
508 | - |
|
509 | - foreach ( $upgrades as $key => $method ) { |
|
510 | - |
|
511 | - if ( version_compare( $wpi_version, $key, '<' ) ) { |
|
512 | - return $installer->upgrade_db( $method ); |
|
513 | - } |
|
514 | - |
|
515 | - } |
|
516 | - |
|
517 | - } |
|
518 | - |
|
519 | - /** |
|
520 | - * Flushes the permalinks if needed. |
|
521 | - * |
|
522 | - * @since 2.0.8 |
|
523 | - */ |
|
524 | - public function maybe_flush_permalinks() { |
|
525 | - |
|
526 | - $flush = get_option( 'wpinv_flush_permalinks', 0 ); |
|
527 | - |
|
528 | - if ( ! empty( $flush ) ) { |
|
529 | - flush_rewrite_rules(); |
|
530 | - delete_option( 'wpinv_flush_permalinks' ); |
|
531 | - } |
|
532 | - |
|
533 | - } |
|
534 | - |
|
535 | - /** |
|
536 | - * Remove our pages from yoast sitemaps. |
|
537 | - * |
|
538 | - * @since 1.0.19 |
|
539 | - * @param int[] $excluded_posts_ids |
|
540 | - */ |
|
541 | - public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){ |
|
542 | - |
|
543 | - // Ensure that we have an array. |
|
544 | - if ( ! is_array( $excluded_posts_ids ) ) { |
|
545 | - $excluded_posts_ids = array(); |
|
546 | - } |
|
547 | - |
|
548 | - // Prepare our pages. |
|
549 | - $our_pages = array(); |
|
550 | - |
|
551 | - // Checkout page. |
|
552 | - $our_pages[] = wpinv_get_option( 'checkout_page', false ); |
|
553 | - |
|
554 | - // Success page. |
|
555 | - $our_pages[] = wpinv_get_option( 'success_page', false ); |
|
556 | - |
|
557 | - // Failure page. |
|
558 | - $our_pages[] = wpinv_get_option( 'failure_page', false ); |
|
557 | + // Failure page. |
|
558 | + $our_pages[] = wpinv_get_option( 'failure_page', false ); |
|
559 | 559 | |
560 | - // History page. |
|
561 | - $our_pages[] = wpinv_get_option( 'invoice_history_page', false ); |
|
560 | + // History page. |
|
561 | + $our_pages[] = wpinv_get_option( 'invoice_history_page', false ); |
|
562 | 562 | |
563 | - // Subscriptions page. |
|
564 | - $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false ); |
|
563 | + // Subscriptions page. |
|
564 | + $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false ); |
|
565 | 565 | |
566 | - $our_pages = array_map( 'intval', array_filter( $our_pages ) ); |
|
566 | + $our_pages = array_map( 'intval', array_filter( $our_pages ) ); |
|
567 | 567 | |
568 | - $excluded_posts_ids = $excluded_posts_ids + $our_pages; |
|
569 | - return array_unique( $excluded_posts_ids ); |
|
568 | + $excluded_posts_ids = $excluded_posts_ids + $our_pages; |
|
569 | + return array_unique( $excluded_posts_ids ); |
|
570 | 570 | |
571 | - } |
|
571 | + } |
|
572 | 572 | |
573 | - /** |
|
574 | - * Displays additional footer code. |
|
575 | - * |
|
576 | - * @since 2.0.0 |
|
577 | - */ |
|
578 | - public function wp_footer() { |
|
579 | - wpinv_get_template( 'frontend-footer.php' ); |
|
580 | - } |
|
573 | + /** |
|
574 | + * Displays additional footer code. |
|
575 | + * |
|
576 | + * @since 2.0.0 |
|
577 | + */ |
|
578 | + public function wp_footer() { |
|
579 | + wpinv_get_template( 'frontend-footer.php' ); |
|
580 | + } |
|
581 | 581 | |
582 | - /** |
|
583 | - * Displays additional header code. |
|
584 | - * |
|
585 | - * @since 2.0.0 |
|
586 | - */ |
|
587 | - public function wp_head() { |
|
588 | - wpinv_get_template( 'frontend-head.php' ); |
|
589 | - } |
|
582 | + /** |
|
583 | + * Displays additional header code. |
|
584 | + * |
|
585 | + * @since 2.0.0 |
|
586 | + */ |
|
587 | + public function wp_head() { |
|
588 | + wpinv_get_template( 'frontend-head.php' ); |
|
589 | + } |
|
590 | 590 | |
591 | - /** |
|
592 | - * Custom query vars. |
|
593 | - * |
|
594 | - */ |
|
595 | - public function custom_query_vars( $vars ) { |
|
591 | + /** |
|
592 | + * Custom query vars. |
|
593 | + * |
|
594 | + */ |
|
595 | + public function custom_query_vars( $vars ) { |
|
596 | 596 | $vars[] = 'getpaid-ipn'; |
597 | 597 | return $vars; |
598 | - } |
|
598 | + } |
|
599 | 599 | |
600 | - /** |
|
601 | - * Add rewrite tags and rules. |
|
602 | - * |
|
603 | - */ |
|
604 | - public function add_rewrite_rule() { |
|
600 | + /** |
|
601 | + * Add rewrite tags and rules. |
|
602 | + * |
|
603 | + */ |
|
604 | + public function add_rewrite_rule() { |
|
605 | 605 | $tag = 'getpaid-ipn'; |
606 | 606 | add_rewrite_tag( "%$tag%", '([^&]+)' ); |
607 | 607 | add_rewrite_rule( "^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]",'top' ); |
608 | - } |
|
608 | + } |
|
609 | 609 | |
610 | - /** |
|
611 | - * Processes non-query string ipns. |
|
612 | - * |
|
613 | - */ |
|
614 | - public function maybe_process_new_ipn( $query ) { |
|
610 | + /** |
|
611 | + * Processes non-query string ipns. |
|
612 | + * |
|
613 | + */ |
|
614 | + public function maybe_process_new_ipn( $query ) { |
|
615 | 615 | |
616 | 616 | if ( is_admin() || ! $query->is_main_query() ) { |
617 | 617 | return; |
618 | 618 | } |
619 | 619 | |
620 | - $gateway = get_query_var( 'getpaid-ipn' ); |
|
620 | + $gateway = get_query_var( 'getpaid-ipn' ); |
|
621 | 621 | |
622 | 622 | if ( ! empty( $gateway ) ){ |
623 | 623 | |
624 | - $gateway = sanitize_text_field( $gateway ); |
|
625 | - nocache_headers(); |
|
626 | - do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
627 | - do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
628 | - exit; |
|
624 | + $gateway = sanitize_text_field( $gateway ); |
|
625 | + nocache_headers(); |
|
626 | + do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
627 | + do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
628 | + exit; |
|
629 | 629 | |
630 | 630 | } |
631 | 631 | |
632 | - } |
|
632 | + } |
|
633 | 633 | |
634 | 634 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @since 1.0.0 |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Main Invoicing class. |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | * @param string $prop The prop to set. |
57 | 57 | * @param mixed $value The value to retrieve. |
58 | 58 | */ |
59 | - public function set( $prop, $value ) { |
|
60 | - $this->data[ $prop ] = $value; |
|
59 | + public function set($prop, $value) { |
|
60 | + $this->data[$prop] = $value; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -66,10 +66,10 @@ discard block |
||
66 | 66 | * @param string $prop The prop to set. |
67 | 67 | * @return mixed The value. |
68 | 68 | */ |
69 | - public function get( $prop ) { |
|
69 | + public function get($prop) { |
|
70 | 70 | |
71 | - if ( isset( $this->data[ $prop ] ) ) { |
|
72 | - return $this->data[ $prop ]; |
|
71 | + if (isset($this->data[$prop])) { |
|
72 | + return $this->data[$prop]; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | return null; |
@@ -81,23 +81,23 @@ discard block |
||
81 | 81 | public function set_properties() { |
82 | 82 | |
83 | 83 | // Sessions. |
84 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
85 | - $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility. |
|
84 | + $this->set('session', new WPInv_Session_Handler()); |
|
85 | + $GLOBALS['wpi_session'] = $this->get('session'); // Backwards compatibility. |
|
86 | 86 | $GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility. |
87 | 87 | |
88 | 88 | // Init other objects. |
89 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
90 | - $this->set( 'notes', new WPInv_Notes() ); |
|
91 | - $this->set( 'api', new WPInv_API() ); |
|
92 | - $this->set( 'post_types', new GetPaid_Post_Types() ); |
|
93 | - $this->set( 'template', new GetPaid_Template() ); |
|
94 | - $this->set( 'admin', new GetPaid_Admin() ); |
|
95 | - $this->set( 'subscriptions', new WPInv_Subscriptions() ); |
|
96 | - $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() ); |
|
97 | - $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() ); |
|
98 | - $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() ); |
|
99 | - $this->set( 'payment_forms', new GetPaid_Payment_Forms() ); |
|
100 | - $this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() ); |
|
89 | + $this->set('session', new WPInv_Session_Handler()); |
|
90 | + $this->set('notes', new WPInv_Notes()); |
|
91 | + $this->set('api', new WPInv_API()); |
|
92 | + $this->set('post_types', new GetPaid_Post_Types()); |
|
93 | + $this->set('template', new GetPaid_Template()); |
|
94 | + $this->set('admin', new GetPaid_Admin()); |
|
95 | + $this->set('subscriptions', new WPInv_Subscriptions()); |
|
96 | + $this->set('invoice_emails', new GetPaid_Invoice_Notification_Emails()); |
|
97 | + $this->set('subscription_emails', new GetPaid_Subscription_Notification_Emails()); |
|
98 | + $this->set('daily_maintenace', new GetPaid_Daily_Maintenance()); |
|
99 | + $this->set('payment_forms', new GetPaid_Payment_Forms()); |
|
100 | + $this->set('maxmind', new GetPaid_MaxMind_Geolocation()); |
|
101 | 101 | |
102 | 102 | } |
103 | 103 | |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | * Define plugin constants. |
106 | 106 | */ |
107 | 107 | public function define_constants() { |
108 | - define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
109 | - define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
108 | + define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE)); |
|
109 | + define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE)); |
|
110 | 110 | $this->version = WPINV_VERSION; |
111 | 111 | } |
112 | 112 | |
@@ -117,27 +117,27 @@ discard block |
||
117 | 117 | */ |
118 | 118 | protected function init_hooks() { |
119 | 119 | /* Internationalize the text strings used. */ |
120 | - add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
120 | + add_action('plugins_loaded', array(&$this, 'plugins_loaded')); |
|
121 | 121 | |
122 | 122 | // Init the plugin after WordPress inits. |
123 | - add_action( 'init', array( $this, 'init' ), 1 ); |
|
124 | - add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 ); |
|
125 | - add_action( 'init', array( $this, 'wpinv_actions' ) ); |
|
126 | - add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 ); |
|
127 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 ); |
|
128 | - add_action( 'wp_footer', array( $this, 'wp_footer' ) ); |
|
129 | - add_action( 'wp_head', array( $this, 'wp_head' ) ); |
|
130 | - add_action( 'widgets_init', array( $this, 'register_widgets' ) ); |
|
131 | - add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) ); |
|
132 | - add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
133 | - |
|
134 | - add_filter( 'query_vars', array( $this, 'custom_query_vars' ) ); |
|
135 | - add_action( 'init', array( $this, 'add_rewrite_rule' ), 10, 0 ); |
|
136 | - add_action( 'pre_get_posts', array( $this, 'maybe_process_new_ipn' ), 1 ); |
|
123 | + add_action('init', array($this, 'init'), 1); |
|
124 | + add_action('init', array($this, 'maybe_process_ipn'), 10); |
|
125 | + add_action('init', array($this, 'wpinv_actions')); |
|
126 | + add_action('init', array($this, 'maybe_do_authenticated_action'), 100); |
|
127 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 11); |
|
128 | + add_action('wp_footer', array($this, 'wp_footer')); |
|
129 | + add_action('wp_head', array($this, 'wp_head')); |
|
130 | + add_action('widgets_init', array($this, 'register_widgets')); |
|
131 | + add_filter('wpseo_exclude_from_sitemap_by_post_ids', array($this, 'wpseo_exclude_from_sitemap_by_post_ids')); |
|
132 | + add_filter('pre_get_posts', array(&$this, 'pre_get_posts')); |
|
133 | + |
|
134 | + add_filter('query_vars', array($this, 'custom_query_vars')); |
|
135 | + add_action('init', array($this, 'add_rewrite_rule'), 10, 0); |
|
136 | + add_action('pre_get_posts', array($this, 'maybe_process_new_ipn'), 1); |
|
137 | 137 | |
138 | 138 | // Fires after registering actions. |
139 | - do_action( 'wpinv_actions', $this ); |
|
140 | - do_action( 'getpaid_actions', $this ); |
|
139 | + do_action('wpinv_actions', $this); |
|
140 | + do_action('getpaid_actions', $this); |
|
141 | 141 | |
142 | 142 | } |
143 | 143 | |
@@ -145,10 +145,10 @@ discard block |
||
145 | 145 | /* Internationalize the text strings used. */ |
146 | 146 | $this->load_textdomain(); |
147 | 147 | |
148 | - do_action( 'wpinv_loaded' ); |
|
148 | + do_action('wpinv_loaded'); |
|
149 | 149 | |
150 | 150 | // Fix oxygen page builder conflict |
151 | - if ( function_exists( 'ct_css_output' ) ) { |
|
151 | + if (function_exists('ct_css_output')) { |
|
152 | 152 | wpinv_oxygen_fix_conflict(); |
153 | 153 | } |
154 | 154 | } |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | load_plugin_textdomain( |
170 | 170 | 'invoicing', |
171 | 171 | false, |
172 | - plugin_basename( dirname( WPINV_PLUGIN_FILE ) ) . '/languages/' |
|
172 | + plugin_basename(dirname(WPINV_PLUGIN_FILE)) . '/languages/' |
|
173 | 173 | ); |
174 | 174 | |
175 | 175 | } |
@@ -180,79 +180,79 @@ discard block |
||
180 | 180 | public function includes() { |
181 | 181 | |
182 | 182 | // Start with the settings. |
183 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
183 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php'); |
|
184 | 184 | |
185 | 185 | // Packages/libraries. |
186 | - require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' ); |
|
187 | - require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' ); |
|
186 | + require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php'); |
|
187 | + require_once(WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php'); |
|
188 | 188 | |
189 | 189 | // Load functions. |
190 | - require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' ); |
|
191 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
192 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
193 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
194 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
195 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
196 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
197 | - require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' ); |
|
198 | - require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' ); |
|
199 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
200 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
201 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
202 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
203 | - require_once( WPINV_PLUGIN_DIR . 'includes/user-functions.php' ); |
|
204 | - require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' ); |
|
190 | + require_once(WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php'); |
|
191 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php'); |
|
192 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php'); |
|
193 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php'); |
|
194 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php'); |
|
195 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php'); |
|
196 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php'); |
|
197 | + require_once(WPINV_PLUGIN_DIR . 'includes/invoice-functions.php'); |
|
198 | + require_once(WPINV_PLUGIN_DIR . 'includes/subscription-functions.php'); |
|
199 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php'); |
|
200 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php'); |
|
201 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php'); |
|
202 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php'); |
|
203 | + require_once(WPINV_PLUGIN_DIR . 'includes/user-functions.php'); |
|
204 | + require_once(WPINV_PLUGIN_DIR . 'includes/error-functions.php'); |
|
205 | 205 | |
206 | 206 | // Register autoloader. |
207 | 207 | try { |
208 | - spl_autoload_register( array( $this, 'autoload' ), true ); |
|
209 | - } catch ( Exception $e ) { |
|
210 | - wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true ); |
|
208 | + spl_autoload_register(array($this, 'autoload'), true); |
|
209 | + } catch (Exception $e) { |
|
210 | + wpinv_error_log($e->getMessage(), '', __FILE__, 149, true); |
|
211 | 211 | } |
212 | 212 | |
213 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' ); |
|
214 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' ); |
|
215 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
216 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
217 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
218 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
219 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
220 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
221 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
222 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' ); |
|
223 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
224 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
|
225 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
|
226 | - require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
227 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
228 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
229 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
230 | - require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
231 | - require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
232 | - require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' ); |
|
233 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice.php' ); |
|
234 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
235 | - |
|
236 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
213 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php'); |
|
214 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php'); |
|
215 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php'); |
|
216 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php'); |
|
217 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php'); |
|
218 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php'); |
|
219 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php'); |
|
220 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php'); |
|
221 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php'); |
|
222 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php'); |
|
223 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php'); |
|
224 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php'); |
|
225 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php'); |
|
226 | + require_once(WPINV_PLUGIN_DIR . 'widgets/checkout.php'); |
|
227 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-history.php'); |
|
228 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php'); |
|
229 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php'); |
|
230 | + require_once(WPINV_PLUGIN_DIR . 'widgets/subscriptions.php'); |
|
231 | + require_once(WPINV_PLUGIN_DIR . 'widgets/buy-item.php'); |
|
232 | + require_once(WPINV_PLUGIN_DIR . 'widgets/getpaid.php'); |
|
233 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice.php'); |
|
234 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php'); |
|
235 | + |
|
236 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
237 | 237 | GetPaid_Post_Types_Admin::init(); |
238 | 238 | |
239 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
240 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' ); |
|
241 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
242 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
|
243 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
244 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' ); |
|
239 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php'); |
|
240 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php'); |
|
241 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php'); |
|
242 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php'); |
|
243 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php'); |
|
244 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php'); |
|
245 | 245 | // load the user class only on the users.php page |
246 | 246 | global $pagenow; |
247 | - if($pagenow=='users.php'){ |
|
247 | + if ($pagenow == 'users.php') { |
|
248 | 248 | new WPInv_Admin_Users(); |
249 | 249 | } |
250 | 250 | } |
251 | 251 | |
252 | 252 | // Register cli commands |
253 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
254 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
|
255 | - WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
253 | + if (defined('WP_CLI') && WP_CLI) { |
|
254 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php'); |
|
255 | + WP_CLI::add_command('invoicing', 'WPInv_CLI'); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | } |
@@ -265,21 +265,21 @@ discard block |
||
265 | 265 | * @since 1.0.19 |
266 | 266 | * @return void |
267 | 267 | */ |
268 | - public function autoload( $class_name ) { |
|
268 | + public function autoload($class_name) { |
|
269 | 269 | |
270 | 270 | // Normalize the class name... |
271 | - $class_name = strtolower( $class_name ); |
|
271 | + $class_name = strtolower($class_name); |
|
272 | 272 | |
273 | 273 | // ... and make sure it is our class. |
274 | - if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
|
274 | + if (false === strpos($class_name, 'getpaid_') && false === strpos($class_name, 'wpinv_')) { |
|
275 | 275 | return; |
276 | 276 | } |
277 | 277 | |
278 | 278 | // Next, prepare the file name from the class. |
279 | - $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
|
279 | + $file_name = 'class-' . str_replace('_', '-', $class_name) . '.php'; |
|
280 | 280 | |
281 | 281 | // Base path of the classes. |
282 | - $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR ); |
|
282 | + $plugin_path = untrailingslashit(WPINV_PLUGIN_DIR); |
|
283 | 283 | |
284 | 284 | // And an array of possible locations in order of importance. |
285 | 285 | $locations = array( |
@@ -294,10 +294,10 @@ discard block |
||
294 | 294 | "$plugin_path/includes/admin/meta-boxes", |
295 | 295 | ); |
296 | 296 | |
297 | - foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) { |
|
297 | + foreach (apply_filters('getpaid_autoload_locations', $locations) as $location) { |
|
298 | 298 | |
299 | - if ( file_exists( trailingslashit( $location ) . $file_name ) ) { |
|
300 | - include trailingslashit( $location ) . $file_name; |
|
299 | + if (file_exists(trailingslashit($location) . $file_name)) { |
|
300 | + include trailingslashit($location) . $file_name; |
|
301 | 301 | break; |
302 | 302 | } |
303 | 303 | |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | public function init() { |
312 | 312 | |
313 | 313 | // Fires before getpaid inits. |
314 | - do_action( 'before_getpaid_init', $this ); |
|
314 | + do_action('before_getpaid_init', $this); |
|
315 | 315 | |
316 | 316 | // Maybe upgrade. |
317 | 317 | $this->maybe_upgrade_database(); |
@@ -328,17 +328,17 @@ discard block |
||
328 | 328 | ) |
329 | 329 | ); |
330 | 330 | |
331 | - foreach ( $gateways as $id => $class ) { |
|
332 | - $this->gateways[ $id ] = new $class(); |
|
331 | + foreach ($gateways as $id => $class) { |
|
332 | + $this->gateways[$id] = new $class(); |
|
333 | 333 | } |
334 | 334 | |
335 | - if ( 'yes' != get_option( 'wpinv_renamed_gateways' ) ) { |
|
335 | + if ('yes' != get_option('wpinv_renamed_gateways')) { |
|
336 | 336 | GetPaid_Installer::rename_gateways_label(); |
337 | - update_option( 'wpinv_renamed_gateways', 'yes' ); |
|
337 | + update_option('wpinv_renamed_gateways', 'yes'); |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | // Fires after getpaid inits. |
341 | - do_action( 'getpaid_init', $this ); |
|
341 | + do_action('getpaid_init', $this); |
|
342 | 342 | |
343 | 343 | } |
344 | 344 | |
@@ -348,14 +348,14 @@ discard block |
||
348 | 348 | public function maybe_process_ipn() { |
349 | 349 | |
350 | 350 | // Ensure that this is an IPN request. |
351 | - if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) { |
|
351 | + if (empty($_GET['wpi-listener']) || 'IPN' !== $_GET['wpi-listener'] || empty($_GET['wpi-gateway'])) { |
|
352 | 352 | return; |
353 | 353 | } |
354 | 354 | |
355 | - $gateway = sanitize_text_field( $_GET['wpi-gateway'] ); |
|
355 | + $gateway = sanitize_text_field($_GET['wpi-gateway']); |
|
356 | 356 | |
357 | - do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
358 | - do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
357 | + do_action('wpinv_verify_payment_ipn', $gateway); |
|
358 | + do_action("wpinv_verify_{$gateway}_ipn"); |
|
359 | 359 | exit; |
360 | 360 | |
361 | 361 | } |
@@ -363,33 +363,33 @@ discard block |
||
363 | 363 | public function enqueue_scripts() { |
364 | 364 | |
365 | 365 | // Fires before adding scripts. |
366 | - do_action( 'getpaid_enqueue_scripts' ); |
|
366 | + do_action('getpaid_enqueue_scripts'); |
|
367 | 367 | |
368 | 368 | $localize = array(); |
369 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
369 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
370 | 370 | $localize['thousands'] = wpinv_thousands_separator(); |
371 | 371 | $localize['decimals'] = wpinv_decimal_separator(); |
372 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
373 | - $localize['txtComplete'] = __( 'Continue', 'invoicing' ); |
|
372 | + $localize['nonce'] = wp_create_nonce('wpinv-nonce'); |
|
373 | + $localize['txtComplete'] = __('Continue', 'invoicing'); |
|
374 | 374 | $localize['UseTaxes'] = wpinv_use_taxes(); |
375 | - $localize['formNonce'] = wp_create_nonce( 'getpaid_form_nonce' ); |
|
376 | - $localize['loading'] = __( 'Loading...', 'invoicing' ); |
|
377 | - $localize['connectionError'] = __( 'Could not establish a connection to the server.', 'invoicing' ); |
|
375 | + $localize['formNonce'] = wp_create_nonce('getpaid_form_nonce'); |
|
376 | + $localize['loading'] = __('Loading...', 'invoicing'); |
|
377 | + $localize['connectionError'] = __('Could not establish a connection to the server.', 'invoicing'); |
|
378 | 378 | |
379 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
379 | + $localize = apply_filters('wpinv_front_js_localize', $localize); |
|
380 | 380 | |
381 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' ); |
|
382 | - wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'jquery' ), $version, true ); |
|
383 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
381 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js'); |
|
382 | + wp_enqueue_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array('jquery'), $version, true); |
|
383 | + wp_localize_script('wpinv-front-script', 'WPInv', $localize); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | public function wpinv_actions() { |
387 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
388 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
387 | + if (isset($_REQUEST['wpi_action'])) { |
|
388 | + do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST); |
|
389 | 389 | } |
390 | 390 | |
391 | - if ( defined( 'WP_ALL_IMPORT_ROOT_DIR' ) ) { |
|
392 | - include plugin_dir_path( __FILE__ ) . 'libraries/wp-all-import/class-getpaid-wp-all-import.php'; |
|
391 | + if (defined('WP_ALL_IMPORT_ROOT_DIR')) { |
|
392 | + include plugin_dir_path(__FILE__) . 'libraries/wp-all-import/class-getpaid-wp-all-import.php'; |
|
393 | 393 | } |
394 | 394 | } |
395 | 395 | |
@@ -401,24 +401,24 @@ discard block |
||
401 | 401 | */ |
402 | 402 | public function maybe_do_authenticated_action() { |
403 | 403 | |
404 | - if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
404 | + if (isset($_REQUEST['getpaid-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) { |
|
405 | 405 | |
406 | - $key = sanitize_key( $_REQUEST['getpaid-action'] ); |
|
407 | - $data = wp_unslash( $_REQUEST ); |
|
408 | - if ( is_user_logged_in() ) { |
|
409 | - do_action( "getpaid_authenticated_action_$key", $data ); |
|
406 | + $key = sanitize_key($_REQUEST['getpaid-action']); |
|
407 | + $data = wp_unslash($_REQUEST); |
|
408 | + if (is_user_logged_in()) { |
|
409 | + do_action("getpaid_authenticated_action_$key", $data); |
|
410 | 410 | } |
411 | 411 | |
412 | - do_action( "getpaid_unauthenticated_action_$key", $data ); |
|
412 | + do_action("getpaid_unauthenticated_action_$key", $data); |
|
413 | 413 | |
414 | 414 | } |
415 | 415 | |
416 | 416 | } |
417 | 417 | |
418 | - public function pre_get_posts( $wp_query ) { |
|
418 | + public function pre_get_posts($wp_query) { |
|
419 | 419 | |
420 | - if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) { |
|
421 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) ); |
|
420 | + if (!is_admin() && !empty($wp_query->query_vars['post_type']) && getpaid_is_invoice_post_type($wp_query->query_vars['post_type']) && is_user_logged_in() && is_single() && $wp_query->is_main_query()) { |
|
421 | + $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses(false, false, $wp_query->query_vars['post_type'])); |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | return $wp_query; |
@@ -433,18 +433,18 @@ discard block |
||
433 | 433 | |
434 | 434 | // Currently, UX Builder does not work particulaly well with SuperDuper. |
435 | 435 | // So we disable our widgets when editing a page with UX Builder. |
436 | - if ( function_exists( 'ux_builder_is_active' ) && ux_builder_is_active() ) { |
|
436 | + if (function_exists('ux_builder_is_active') && ux_builder_is_active()) { |
|
437 | 437 | return; |
438 | 438 | } |
439 | 439 | |
440 | 440 | $block_widget_init_screens = function_exists('sd_pagenow_exclude') ? sd_pagenow_exclude() : array(); |
441 | 441 | |
442 | - if ( is_admin() && $pagenow && in_array($pagenow, $block_widget_init_screens)) { |
|
442 | + if (is_admin() && $pagenow && in_array($pagenow, $block_widget_init_screens)) { |
|
443 | 443 | // don't initiate in these conditions. |
444 | - }else{ |
|
444 | + } else { |
|
445 | 445 | |
446 | 446 | // Only load allowed widgets. |
447 | - $exclude = function_exists( 'sd_widget_exclude' ) ? sd_widget_exclude() : array(); |
|
447 | + $exclude = function_exists('sd_widget_exclude') ? sd_widget_exclude() : array(); |
|
448 | 448 | $widgets = apply_filters( |
449 | 449 | 'getpaid_widget_classes', |
450 | 450 | array( |
@@ -460,16 +460,16 @@ discard block |
||
460 | 460 | ); |
461 | 461 | |
462 | 462 | // For each widget... |
463 | - foreach ( $widgets as $widget ) { |
|
463 | + foreach ($widgets as $widget) { |
|
464 | 464 | |
465 | 465 | // Abort early if it is excluded for this page. |
466 | - if ( in_array( $widget, $exclude ) ) { |
|
466 | + if (in_array($widget, $exclude)) { |
|
467 | 467 | continue; |
468 | 468 | } |
469 | 469 | |
470 | 470 | // SD V1 used to extend the widget class. V2 does not, so we cannot call register widget on it. |
471 | - if ( is_subclass_of( $widget, 'WP_Widget' ) ) { |
|
472 | - register_widget( $widget ); |
|
471 | + if (is_subclass_of($widget, 'WP_Widget')) { |
|
472 | + register_widget($widget); |
|
473 | 473 | } else { |
474 | 474 | new $widget(); |
475 | 475 | } |
@@ -487,29 +487,29 @@ discard block |
||
487 | 487 | */ |
488 | 488 | public function maybe_upgrade_database() { |
489 | 489 | |
490 | - $wpi_version = get_option( 'wpinv_version', 0 ); |
|
490 | + $wpi_version = get_option('wpinv_version', 0); |
|
491 | 491 | |
492 | - if ( $wpi_version == WPINV_VERSION ) { |
|
492 | + if ($wpi_version == WPINV_VERSION) { |
|
493 | 493 | return; |
494 | 494 | } |
495 | 495 | |
496 | 496 | $installer = new GetPaid_Installer(); |
497 | 497 | |
498 | - if ( empty( $wpi_version ) ) { |
|
499 | - return $installer->upgrade_db( 0 ); |
|
498 | + if (empty($wpi_version)) { |
|
499 | + return $installer->upgrade_db(0); |
|
500 | 500 | } |
501 | 501 | |
502 | - $upgrades = array( |
|
502 | + $upgrades = array( |
|
503 | 503 | '0.0.5' => '004', |
504 | 504 | '1.0.3' => '102', |
505 | 505 | '2.0.0' => '118', |
506 | 506 | '2.0.8' => '207', |
507 | 507 | ); |
508 | 508 | |
509 | - foreach ( $upgrades as $key => $method ) { |
|
509 | + foreach ($upgrades as $key => $method) { |
|
510 | 510 | |
511 | - if ( version_compare( $wpi_version, $key, '<' ) ) { |
|
512 | - return $installer->upgrade_db( $method ); |
|
511 | + if (version_compare($wpi_version, $key, '<')) { |
|
512 | + return $installer->upgrade_db($method); |
|
513 | 513 | } |
514 | 514 | |
515 | 515 | } |
@@ -523,11 +523,11 @@ discard block |
||
523 | 523 | */ |
524 | 524 | public function maybe_flush_permalinks() { |
525 | 525 | |
526 | - $flush = get_option( 'wpinv_flush_permalinks', 0 ); |
|
526 | + $flush = get_option('wpinv_flush_permalinks', 0); |
|
527 | 527 | |
528 | - if ( ! empty( $flush ) ) { |
|
528 | + if (!empty($flush)) { |
|
529 | 529 | flush_rewrite_rules(); |
530 | - delete_option( 'wpinv_flush_permalinks' ); |
|
530 | + delete_option('wpinv_flush_permalinks'); |
|
531 | 531 | } |
532 | 532 | |
533 | 533 | } |
@@ -538,10 +538,10 @@ discard block |
||
538 | 538 | * @since 1.0.19 |
539 | 539 | * @param int[] $excluded_posts_ids |
540 | 540 | */ |
541 | - public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){ |
|
541 | + public function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) { |
|
542 | 542 | |
543 | 543 | // Ensure that we have an array. |
544 | - if ( ! is_array( $excluded_posts_ids ) ) { |
|
544 | + if (!is_array($excluded_posts_ids)) { |
|
545 | 545 | $excluded_posts_ids = array(); |
546 | 546 | } |
547 | 547 | |
@@ -549,24 +549,24 @@ discard block |
||
549 | 549 | $our_pages = array(); |
550 | 550 | |
551 | 551 | // Checkout page. |
552 | - $our_pages[] = wpinv_get_option( 'checkout_page', false ); |
|
552 | + $our_pages[] = wpinv_get_option('checkout_page', false); |
|
553 | 553 | |
554 | 554 | // Success page. |
555 | - $our_pages[] = wpinv_get_option( 'success_page', false ); |
|
555 | + $our_pages[] = wpinv_get_option('success_page', false); |
|
556 | 556 | |
557 | 557 | // Failure page. |
558 | - $our_pages[] = wpinv_get_option( 'failure_page', false ); |
|
558 | + $our_pages[] = wpinv_get_option('failure_page', false); |
|
559 | 559 | |
560 | 560 | // History page. |
561 | - $our_pages[] = wpinv_get_option( 'invoice_history_page', false ); |
|
561 | + $our_pages[] = wpinv_get_option('invoice_history_page', false); |
|
562 | 562 | |
563 | 563 | // Subscriptions page. |
564 | - $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false ); |
|
564 | + $our_pages[] = wpinv_get_option('invoice_subscription_page', false); |
|
565 | 565 | |
566 | - $our_pages = array_map( 'intval', array_filter( $our_pages ) ); |
|
566 | + $our_pages = array_map('intval', array_filter($our_pages)); |
|
567 | 567 | |
568 | 568 | $excluded_posts_ids = $excluded_posts_ids + $our_pages; |
569 | - return array_unique( $excluded_posts_ids ); |
|
569 | + return array_unique($excluded_posts_ids); |
|
570 | 570 | |
571 | 571 | } |
572 | 572 | |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | * @since 2.0.0 |
577 | 577 | */ |
578 | 578 | public function wp_footer() { |
579 | - wpinv_get_template( 'frontend-footer.php' ); |
|
579 | + wpinv_get_template('frontend-footer.php'); |
|
580 | 580 | } |
581 | 581 | |
582 | 582 | /** |
@@ -585,14 +585,14 @@ discard block |
||
585 | 585 | * @since 2.0.0 |
586 | 586 | */ |
587 | 587 | public function wp_head() { |
588 | - wpinv_get_template( 'frontend-head.php' ); |
|
588 | + wpinv_get_template('frontend-head.php'); |
|
589 | 589 | } |
590 | 590 | |
591 | 591 | /** |
592 | 592 | * Custom query vars. |
593 | 593 | * |
594 | 594 | */ |
595 | - public function custom_query_vars( $vars ) { |
|
595 | + public function custom_query_vars($vars) { |
|
596 | 596 | $vars[] = 'getpaid-ipn'; |
597 | 597 | return $vars; |
598 | 598 | } |
@@ -603,28 +603,28 @@ discard block |
||
603 | 603 | */ |
604 | 604 | public function add_rewrite_rule() { |
605 | 605 | $tag = 'getpaid-ipn'; |
606 | - add_rewrite_tag( "%$tag%", '([^&]+)' ); |
|
607 | - add_rewrite_rule( "^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]",'top' ); |
|
606 | + add_rewrite_tag("%$tag%", '([^&]+)'); |
|
607 | + add_rewrite_rule("^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]", 'top'); |
|
608 | 608 | } |
609 | 609 | |
610 | 610 | /** |
611 | 611 | * Processes non-query string ipns. |
612 | 612 | * |
613 | 613 | */ |
614 | - public function maybe_process_new_ipn( $query ) { |
|
614 | + public function maybe_process_new_ipn($query) { |
|
615 | 615 | |
616 | - if ( is_admin() || ! $query->is_main_query() ) { |
|
616 | + if (is_admin() || !$query->is_main_query()) { |
|
617 | 617 | return; |
618 | 618 | } |
619 | 619 | |
620 | - $gateway = get_query_var( 'getpaid-ipn' ); |
|
620 | + $gateway = get_query_var('getpaid-ipn'); |
|
621 | 621 | |
622 | - if ( ! empty( $gateway ) ){ |
|
622 | + if (!empty($gateway)) { |
|
623 | 623 | |
624 | - $gateway = sanitize_text_field( $gateway ); |
|
624 | + $gateway = sanitize_text_field($gateway); |
|
625 | 625 | nocache_headers(); |
626 | - do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
627 | - do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
626 | + do_action('wpinv_verify_payment_ipn', $gateway); |
|
627 | + do_action("wpinv_verify_{$gateway}_ipn"); |
|
628 | 628 | exit; |
629 | 629 | |
630 | 630 | } |