@@ -8,21 +8,21 @@ discard block |
||
8 | 8 | * @var WPInv_Invoice $invoice |
9 | 9 | */ |
10 | 10 | |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | 13 | ?> |
14 | 14 | |
15 | -<?php do_action( 'getpaid_invoice_before_line_items', $invoice ); ?> |
|
15 | +<?php do_action('getpaid_invoice_before_line_items', $invoice); ?> |
|
16 | 16 | |
17 | - <h2 class="mt-5 mb-1 h4"><?php echo sprintf( esc_html__( '%s Items', 'invoicing' ), ucfirst( $invoice->get_invoice_quote_type() )); ?></h2> |
|
17 | + <h2 class="mt-5 mb-1 h4"><?php echo sprintf(esc_html__('%s Items', 'invoicing'), ucfirst($invoice->get_invoice_quote_type())); ?></h2> |
|
18 | 18 | <div class="getpaid-invoice-items mb-4 border"> |
19 | 19 | |
20 | 20 | |
21 | - <div class="getpaid-invoice-items-header <?php echo sanitize_html_class( $invoice->get_template() ); ?>"> |
|
21 | + <div class="getpaid-invoice-items-header <?php echo sanitize_html_class($invoice->get_template()); ?>"> |
|
22 | 22 | <div class="form-row"> |
23 | - <?php foreach ( $columns as $key => $label ) : ?> |
|
24 | - <div class="<?php echo 'name' == $key ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-invoice-line-item-col-<?php echo esc_attr( $key ); ?>"> |
|
25 | - <?php echo sanitize_text_field( $label ); ?> |
|
23 | + <?php foreach ($columns as $key => $label) : ?> |
|
24 | + <div class="<?php echo 'name' == $key ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-invoice-line-item-col-<?php echo esc_attr($key); ?>"> |
|
25 | + <?php echo sanitize_text_field($label); ?> |
|
26 | 26 | </div> |
27 | 27 | <?php endforeach; ?> |
28 | 28 | </div> |
@@ -32,20 +32,20 @@ discard block |
||
32 | 32 | <?php |
33 | 33 | |
34 | 34 | // Display the item totals. |
35 | - foreach ( $invoice->get_items() as $item ) { |
|
36 | - wpinv_get_template( 'invoice/line-item.php', compact( 'invoice', 'item', 'columns' ) ); |
|
35 | + foreach ($invoice->get_items() as $item) { |
|
36 | + wpinv_get_template('invoice/line-item.php', compact('invoice', 'item', 'columns')); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | // Display the fee totals. |
40 | - foreach ( $invoice->get_fees() as $fee ) { |
|
41 | - wpinv_get_template( 'invoice/fee-item.php', compact( 'invoice', 'fee', 'columns' ) ); |
|
40 | + foreach ($invoice->get_fees() as $fee) { |
|
41 | + wpinv_get_template('invoice/fee-item.php', compact('invoice', 'fee', 'columns')); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | // Display the cart totals. |
45 | - wpinv_get_template( 'invoice/line-totals.php', compact( 'invoice' ) ); |
|
45 | + wpinv_get_template('invoice/line-totals.php', compact('invoice')); |
|
46 | 46 | |
47 | 47 | ?> |
48 | 48 | |
49 | 49 | </div> |
50 | 50 | |
51 | -<?php do_action( 'getpaid_invoice_after_line_items', $invoice ); ?> |
|
51 | +<?php do_action('getpaid_invoice_after_line_items', $invoice); ?> |
@@ -7,17 +7,17 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | // Prepare the selectable items. |
13 | 13 | $selectable = array(); |
14 | -foreach ( $form->get_items() as $item ) { |
|
15 | - if ( ! $item->is_required ) { |
|
16 | - $selectable[$item->get_id()] = strip_tags( $item->get_name() . ' — ' . wpinv_price( $item->get_initial_price() ) ); |
|
14 | +foreach ($form->get_items() as $item) { |
|
15 | + if (!$item->is_required) { |
|
16 | + $selectable[$item->get_id()] = strip_tags($item->get_name() . ' — ' . wpinv_price($item->get_initial_price())); |
|
17 | 17 | } |
18 | 18 | } |
19 | 19 | |
20 | -if ( empty( $selectable ) ) { |
|
20 | +if (empty($selectable)) { |
|
21 | 21 | return; |
22 | 22 | } |
23 | 23 | |
@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | echo aui()->select( |
28 | 28 | array( |
29 | 29 | 'name' => 'getpaid-payment-form-selected-item', |
30 | - 'id' => 'getpaid-payment-form-selected-item' . uniqid( '_' ), |
|
30 | + 'id' => 'getpaid-payment-form-selected-item' . uniqid('_'), |
|
31 | 31 | 'required' => true, |
32 | - 'label' => __( 'Select Item', 'invoicing' ), |
|
32 | + 'label' => __('Select Item', 'invoicing'), |
|
33 | 33 | 'label_type' => 'vertical', |
34 | 34 | 'inline' => false, |
35 | 35 | 'options' => $selectable, |
@@ -7,17 +7,17 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | // Prepare the selectable items. |
13 | 13 | $selectable = array(); |
14 | -foreach ( $form->get_items() as $item ) { |
|
15 | - if ( ! $item->is_required ) { |
|
16 | - $selectable[$item->get_id()] = $item->get_name() . ' — ' . wpinv_price( $item->get_initial_price() ); |
|
14 | +foreach ($form->get_items() as $item) { |
|
15 | + if (!$item->is_required) { |
|
16 | + $selectable[$item->get_id()] = $item->get_name() . ' — ' . wpinv_price($item->get_initial_price()); |
|
17 | 17 | } |
18 | 18 | } |
19 | 19 | |
20 | -if ( empty( $selectable ) ) { |
|
20 | +if (empty($selectable)) { |
|
21 | 21 | return; |
22 | 22 | } |
23 | 23 | |
@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | echo aui()->radio( |
28 | 28 | array( |
29 | 29 | 'name' => 'getpaid-payment-form-selected-item', |
30 | - 'id' => 'getpaid-payment-form-selected-item' . uniqid( '_' ), |
|
30 | + 'id' => 'getpaid-payment-form-selected-item' . uniqid('_'), |
|
31 | 31 | 'required' => true, |
32 | - 'label' => __( 'Select Item', 'invoicing' ), |
|
32 | + 'label' => __('Select Item', 'invoicing'), |
|
33 | 33 | 'label_type' => 'vertical', |
34 | 34 | 'inline' => false, |
35 | 35 | 'options' => $selectable, |
@@ -7,29 +7,29 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | // Prepare the selectable items. |
13 | 13 | $selectable = array(); |
14 | -foreach ( $form->get_items() as $item ) { |
|
15 | - if ( ! $item->is_required ) { |
|
16 | - $selectable[$item->get_id()] = $item->get_name() . ' — ' . wpinv_price( $item->get_initial_price() ); |
|
14 | +foreach ($form->get_items() as $item) { |
|
15 | + if (!$item->is_required) { |
|
16 | + $selectable[$item->get_id()] = $item->get_name() . ' — ' . wpinv_price($item->get_initial_price()); |
|
17 | 17 | } |
18 | 18 | } |
19 | 19 | |
20 | -if ( empty( $selectable ) ) { |
|
20 | +if (empty($selectable)) { |
|
21 | 21 | return; |
22 | 22 | } |
23 | 23 | |
24 | 24 | echo '<div class="getpaid-payment-form-items-checkbox form-group">'; |
25 | 25 | |
26 | -foreach ( $selectable as $item_id => $item_name ) { |
|
26 | +foreach ($selectable as $item_id => $item_name) { |
|
27 | 27 | |
28 | 28 | echo aui()->input( |
29 | 29 | array( |
30 | 30 | 'type' => 'checkbox', |
31 | 31 | 'name' => 'getpaid-payment-form-selected-item', |
32 | - 'id' => 'getpaid-payment-form-selected-item' . uniqid( '_' ) . $item_id, |
|
32 | + 'id' => 'getpaid-payment-form-selected-item' . uniqid('_') . $item_id, |
|
33 | 33 | 'label' => $item_name, |
34 | 34 | 'value' => $item_id, |
35 | 35 | 'no_wrap' => true, |
@@ -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 sanitize_text_field( $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 sanitize_text_field($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); |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | */ |
15 | 15 | function wpinv_subscriptions_page() { |
16 | 16 | |
17 | - ?> |
|
17 | + ?> |
|
18 | 18 | |
19 | 19 | <div class="wrap"> |
20 | 20 | <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> |
@@ -22,27 +22,27 @@ discard block |
||
22 | 22 | |
23 | 23 | <?php |
24 | 24 | |
25 | - // Verify user permissions. |
|
26 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
25 | + // Verify user permissions. |
|
26 | + if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
27 | 27 | |
28 | - echo aui()->alert( |
|
29 | - array( |
|
30 | - 'type' => 'danger', |
|
31 | - 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
32 | - ) |
|
33 | - ); |
|
28 | + echo aui()->alert( |
|
29 | + array( |
|
30 | + 'type' => 'danger', |
|
31 | + 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
32 | + ) |
|
33 | + ); |
|
34 | 34 | |
35 | - } else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
35 | + } else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
36 | 36 | |
37 | - // Display a single subscription. |
|
38 | - wpinv_recurring_subscription_details(); |
|
39 | - } else { |
|
37 | + // Display a single subscription. |
|
38 | + wpinv_recurring_subscription_details(); |
|
39 | + } else { |
|
40 | 40 | |
41 | - // Display a list of available subscriptions. |
|
42 | - getpaid_print_subscriptions_list(); |
|
43 | - } |
|
41 | + // Display a list of available subscriptions. |
|
42 | + getpaid_print_subscriptions_list(); |
|
43 | + } |
|
44 | 44 | |
45 | - ?> |
|
45 | + ?> |
|
46 | 46 | |
47 | 47 | </div> |
48 | 48 | </div> |
@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | */ |
60 | 60 | function getpaid_print_subscriptions_list() { |
61 | 61 | |
62 | - $subscribers_table = new WPInv_Subscriptions_List_Table(); |
|
63 | - $subscribers_table->prepare_items(); |
|
62 | + $subscribers_table = new WPInv_Subscriptions_List_Table(); |
|
63 | + $subscribers_table->prepare_items(); |
|
64 | 64 | |
65 | - ?> |
|
65 | + ?> |
|
66 | 66 | <form id="subscribers-filter" class="bsui" method="get"> |
67 | 67 | <input type="hidden" name="page" value="wpinv-subscriptions" /> |
68 | 68 | <?php $subscribers_table->views(); ?> |
@@ -80,27 +80,27 @@ discard block |
||
80 | 80 | */ |
81 | 81 | function wpinv_recurring_subscription_details() { |
82 | 82 | |
83 | - // Fetch the subscription. |
|
84 | - $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
85 | - if ( ! $sub->get_id() ) { |
|
83 | + // Fetch the subscription. |
|
84 | + $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
85 | + if ( ! $sub->get_id() ) { |
|
86 | 86 | |
87 | - echo aui()->alert( |
|
88 | - array( |
|
89 | - 'type' => 'danger', |
|
90 | - 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
91 | - ) |
|
92 | - ); |
|
87 | + echo aui()->alert( |
|
88 | + array( |
|
89 | + 'type' => 'danger', |
|
90 | + 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
91 | + ) |
|
92 | + ); |
|
93 | 93 | |
94 | - return; |
|
95 | - } |
|
94 | + return; |
|
95 | + } |
|
96 | 96 | |
97 | - // Use metaboxes to display the subscription details. |
|
98 | - add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal' ); |
|
99 | - add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
100 | - add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
101 | - do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
97 | + // Use metaboxes to display the subscription details. |
|
98 | + add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal' ); |
|
99 | + add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
100 | + add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
101 | + do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
102 | 102 | |
103 | - ?> |
|
103 | + ?> |
|
104 | 104 | |
105 | 105 | <form method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ); ?>"> |
106 | 106 | |
@@ -140,41 +140,41 @@ discard block |
||
140 | 140 | */ |
141 | 141 | function getpaid_admin_subscription_details_metabox( $sub ) { |
142 | 142 | |
143 | - // Prepare subscription detail columns. |
|
144 | - $fields = apply_filters( |
|
145 | - 'getpaid_subscription_admin_page_fields', |
|
146 | - array( |
|
147 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
148 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
149 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
150 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
151 | - 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
152 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
153 | - 'item' => __( 'Item', 'invoicing' ), |
|
154 | - 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
155 | - 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
156 | - 'status' => __( 'Status', 'invoicing' ), |
|
157 | - ) |
|
158 | - ); |
|
159 | - |
|
160 | - if ( ! $sub->is_active() ) { |
|
161 | - |
|
162 | - if ( isset( $fields['renews_on'] ) ) { |
|
163 | - unset( $fields['renews_on'] ); |
|
164 | - } |
|
165 | - |
|
166 | - if ( isset( $fields['gateway'] ) ) { |
|
167 | - unset( $fields['gateway'] ); |
|
168 | - } |
|
143 | + // Prepare subscription detail columns. |
|
144 | + $fields = apply_filters( |
|
145 | + 'getpaid_subscription_admin_page_fields', |
|
146 | + array( |
|
147 | + 'subscription' => __( 'Subscription', 'invoicing' ), |
|
148 | + 'customer' => __( 'Customer', 'invoicing' ), |
|
149 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
150 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
151 | + 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
152 | + 'renewals' => __( 'Payments', 'invoicing' ), |
|
153 | + 'item' => __( 'Item', 'invoicing' ), |
|
154 | + 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
155 | + 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
156 | + 'status' => __( 'Status', 'invoicing' ), |
|
157 | + ) |
|
158 | + ); |
|
159 | + |
|
160 | + if ( ! $sub->is_active() ) { |
|
161 | + |
|
162 | + if ( isset( $fields['renews_on'] ) ) { |
|
163 | + unset( $fields['renews_on'] ); |
|
164 | + } |
|
165 | + |
|
166 | + if ( isset( $fields['gateway'] ) ) { |
|
167 | + unset( $fields['gateway'] ); |
|
168 | + } |
|
169 | 169 | |
170 | - } |
|
170 | + } |
|
171 | 171 | |
172 | - $profile_id = $sub->get_profile_id(); |
|
173 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
174 | - unset( $fields['profile_id'] ); |
|
175 | - } |
|
172 | + $profile_id = $sub->get_profile_id(); |
|
173 | + if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
174 | + unset( $fields['profile_id'] ); |
|
175 | + } |
|
176 | 176 | |
177 | - ?> |
|
177 | + ?> |
|
178 | 178 | |
179 | 179 | <table class="table table-borderless" style="font-size: 14px;"> |
180 | 180 | <tbody> |
@@ -208,20 +208,20 @@ discard block |
||
208 | 208 | */ |
209 | 209 | function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
210 | 210 | |
211 | - $username = __( '(Missing User)', 'invoicing' ); |
|
211 | + $username = __( '(Missing User)', 'invoicing' ); |
|
212 | 212 | |
213 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
214 | - if ( $user ) { |
|
213 | + $user = get_userdata( $subscription->get_customer_id() ); |
|
214 | + if ( $user ) { |
|
215 | 215 | |
216 | - $username = sprintf( |
|
217 | - '<a href="user-edit.php?user_id=%s">%s</a>', |
|
218 | - absint( $user->ID ), |
|
219 | - ! empty( $user->display_name ) ? sanitize_text_field( $user->display_name ) : sanitize_email( $user->user_email ) |
|
220 | - ); |
|
216 | + $username = sprintf( |
|
217 | + '<a href="user-edit.php?user_id=%s">%s</a>', |
|
218 | + absint( $user->ID ), |
|
219 | + ! empty( $user->display_name ) ? sanitize_text_field( $user->display_name ) : sanitize_email( $user->user_email ) |
|
220 | + ); |
|
221 | 221 | |
222 | - } |
|
222 | + } |
|
223 | 223 | |
224 | - echo $username; |
|
224 | + echo $username; |
|
225 | 225 | } |
226 | 226 | add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
227 | 227 | |
@@ -231,8 +231,8 @@ discard block |
||
231 | 231 | * @param WPInv_Subscription $subscription |
232 | 232 | */ |
233 | 233 | function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
234 | - $amount = sanitize_text_field( getpaid_get_formatted_subscription_amount( $subscription ) ); |
|
235 | - echo "<span>$amount</span>"; |
|
234 | + $amount = sanitize_text_field( getpaid_get_formatted_subscription_amount( $subscription ) ); |
|
235 | + echo "<span>$amount</span>"; |
|
236 | 236 | } |
237 | 237 | add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
238 | 238 | |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | * @param WPInv_Subscription $subscription |
243 | 243 | */ |
244 | 244 | function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
245 | - echo '#' . absint( $subscription->get_id() ); |
|
245 | + echo '#' . absint( $subscription->get_id() ); |
|
246 | 246 | } |
247 | 247 | add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
248 | 248 | |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | * @param WPInv_Subscription $subscription |
253 | 253 | */ |
254 | 254 | function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
255 | - echo getpaid_format_date_value( $subscription->get_date_created() ); |
|
255 | + echo getpaid_format_date_value( $subscription->get_date_created() ); |
|
256 | 256 | } |
257 | 257 | add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
258 | 258 | |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | * @param WPInv_Subscription $subscription |
263 | 263 | */ |
264 | 264 | function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
265 | - echo getpaid_format_date_value( $subscription->get_expiration() ); |
|
265 | + echo getpaid_format_date_value( $subscription->get_expiration() ); |
|
266 | 266 | } |
267 | 267 | add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
268 | 268 | |
@@ -272,8 +272,8 @@ discard block |
||
272 | 272 | * @param WPInv_Subscription $subscription |
273 | 273 | */ |
274 | 274 | function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
275 | - $max_bills = $subscription->get_bill_times(); |
|
276 | - echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
275 | + $max_bills = $subscription->get_bill_times(); |
|
276 | + echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
277 | 277 | } |
278 | 278 | add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
279 | 279 | /** |
@@ -283,16 +283,16 @@ discard block |
||
283 | 283 | */ |
284 | 284 | function getpaid_admin_subscription_metabox_display_item( $subscription ) { |
285 | 285 | |
286 | - $item = get_post( $subscription->get_product_id() ); |
|
286 | + $item = get_post( $subscription->get_product_id() ); |
|
287 | 287 | |
288 | - if ( ! empty( $item ) ) { |
|
289 | - $link = get_edit_post_link( $item ); |
|
290 | - $link = esc_url( $link ); |
|
291 | - $name = esc_html( get_the_title( $item ) ); |
|
292 | - echo "<a href='$link'>$name</a>"; |
|
293 | - } else { |
|
294 | - echo sprintf( __( 'Item #%s', 'invoicing' ), $subscription->get_product_id() ); |
|
295 | - } |
|
288 | + if ( ! empty( $item ) ) { |
|
289 | + $link = get_edit_post_link( $item ); |
|
290 | + $link = esc_url( $link ); |
|
291 | + $name = esc_html( get_the_title( $item ) ); |
|
292 | + echo "<a href='$link'>$name</a>"; |
|
293 | + } else { |
|
294 | + echo sprintf( __( 'Item #%s', 'invoicing' ), $subscription->get_product_id() ); |
|
295 | + } |
|
296 | 296 | |
297 | 297 | } |
298 | 298 | add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item' ); |
@@ -304,13 +304,13 @@ discard block |
||
304 | 304 | */ |
305 | 305 | function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
306 | 306 | |
307 | - $gateway = $subscription->get_gateway(); |
|
307 | + $gateway = $subscription->get_gateway(); |
|
308 | 308 | |
309 | - if ( ! empty( $gateway ) ) { |
|
310 | - echo sanitize_text_field( wpinv_get_gateway_admin_label( $gateway ) ); |
|
311 | - } else { |
|
312 | - echo "—"; |
|
313 | - } |
|
309 | + if ( ! empty( $gateway ) ) { |
|
310 | + echo sanitize_text_field( wpinv_get_gateway_admin_label( $gateway ) ); |
|
311 | + } else { |
|
312 | + echo "—"; |
|
313 | + } |
|
314 | 314 | |
315 | 315 | } |
316 | 316 | add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | * @param WPInv_Subscription $subscription |
322 | 322 | */ |
323 | 323 | function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
324 | - echo $subscription->get_status_label_html(); |
|
324 | + echo $subscription->get_status_label_html(); |
|
325 | 325 | } |
326 | 326 | add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
327 | 327 | |
@@ -332,14 +332,14 @@ discard block |
||
332 | 332 | */ |
333 | 333 | function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
334 | 334 | |
335 | - $profile_id = $subscription->get_profile_id(); |
|
335 | + $profile_id = $subscription->get_profile_id(); |
|
336 | 336 | |
337 | - if ( ! empty( $profile_id ) ) { |
|
338 | - $profile_id = sanitize_text_field( $profile_id ); |
|
339 | - echo apply_filters( 'getpaid_subscription_profile_id_display', $profile_id, $subscription ); |
|
340 | - } else { |
|
341 | - echo "—"; |
|
342 | - } |
|
337 | + if ( ! empty( $profile_id ) ) { |
|
338 | + $profile_id = sanitize_text_field( $profile_id ); |
|
339 | + echo apply_filters( 'getpaid_subscription_profile_id_display', $profile_id, $subscription ); |
|
340 | + } else { |
|
341 | + echo "—"; |
|
342 | + } |
|
343 | 343 | |
344 | 344 | } |
345 | 345 | add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
@@ -351,39 +351,39 @@ discard block |
||
351 | 351 | */ |
352 | 352 | function getpaid_admin_subscription_update_metabox( $subscription ) { |
353 | 353 | |
354 | - ?> |
|
354 | + ?> |
|
355 | 355 | <div class="mt-3"> |
356 | 356 | |
357 | 357 | <?php |
358 | - echo aui()->select( |
|
359 | - array( |
|
360 | - 'options' => getpaid_get_subscription_statuses(), |
|
361 | - 'name' => 'subscription_status', |
|
362 | - 'id' => 'subscription_status_update_select', |
|
363 | - 'required' => true, |
|
364 | - 'no_wrap' => false, |
|
365 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
366 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
367 | - 'select2' => true, |
|
368 | - 'value' => $subscription->get_status( 'edit' ), |
|
369 | - ) |
|
370 | - ); |
|
371 | - ?> |
|
358 | + echo aui()->select( |
|
359 | + array( |
|
360 | + 'options' => getpaid_get_subscription_statuses(), |
|
361 | + 'name' => 'subscription_status', |
|
362 | + 'id' => 'subscription_status_update_select', |
|
363 | + 'required' => true, |
|
364 | + 'no_wrap' => false, |
|
365 | + 'label' => __( 'Subscription Status', 'invoicing' ), |
|
366 | + 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
367 | + 'select2' => true, |
|
368 | + 'value' => $subscription->get_status( 'edit' ), |
|
369 | + ) |
|
370 | + ); |
|
371 | + ?> |
|
372 | 372 | |
373 | 373 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;"> |
374 | 374 | |
375 | 375 | <?php |
376 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
376 | + submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
377 | 377 | |
378 | - $url = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) ); |
|
379 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
380 | - $title = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' ); |
|
378 | + $url = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) ); |
|
379 | + $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
380 | + $title = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' ); |
|
381 | 381 | |
382 | - if ( $subscription->is_active() ) { |
|
383 | - echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>"; |
|
384 | - } |
|
382 | + if ( $subscription->is_active() ) { |
|
383 | + echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>"; |
|
384 | + } |
|
385 | 385 | |
386 | - echo '</div></div>'; |
|
386 | + echo '</div></div>'; |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | /** |
@@ -393,33 +393,33 @@ discard block |
||
393 | 393 | */ |
394 | 394 | function getpaid_admin_subscription_invoice_details_metabox( $subscription ) { |
395 | 395 | |
396 | - $columns = apply_filters( |
|
397 | - 'getpaid_subscription_related_invoices_columns', |
|
398 | - array( |
|
399 | - 'invoice' => __( 'Invoice', 'invoicing' ), |
|
400 | - 'relationship' => __( 'Relationship', 'invoicing' ), |
|
401 | - 'date' => __( 'Date', 'invoicing' ), |
|
402 | - 'status' => __( 'Status', 'invoicing' ), |
|
403 | - 'total' => __( 'Total', 'invoicing' ), |
|
404 | - ), |
|
405 | - $subscription |
|
406 | - ); |
|
407 | - |
|
408 | - // Prepare the invoices. |
|
409 | - $payments = $subscription->get_child_payments( ! is_admin() ); |
|
410 | - $parent = $subscription->get_parent_invoice(); |
|
411 | - |
|
412 | - if ( $parent->get_id() ) { |
|
413 | - $payments = array_merge( array( $parent ), $payments ); |
|
414 | - } |
|
396 | + $columns = apply_filters( |
|
397 | + 'getpaid_subscription_related_invoices_columns', |
|
398 | + array( |
|
399 | + 'invoice' => __( 'Invoice', 'invoicing' ), |
|
400 | + 'relationship' => __( 'Relationship', 'invoicing' ), |
|
401 | + 'date' => __( 'Date', 'invoicing' ), |
|
402 | + 'status' => __( 'Status', 'invoicing' ), |
|
403 | + 'total' => __( 'Total', 'invoicing' ), |
|
404 | + ), |
|
405 | + $subscription |
|
406 | + ); |
|
407 | + |
|
408 | + // Prepare the invoices. |
|
409 | + $payments = $subscription->get_child_payments( ! is_admin() ); |
|
410 | + $parent = $subscription->get_parent_invoice(); |
|
411 | + |
|
412 | + if ( $parent->get_id() ) { |
|
413 | + $payments = array_merge( array( $parent ), $payments ); |
|
414 | + } |
|
415 | 415 | |
416 | - $table_class = 'w-100 bg-white'; |
|
416 | + $table_class = 'w-100 bg-white'; |
|
417 | 417 | |
418 | - if ( ! is_admin() ) { |
|
419 | - $table_class = 'table table-bordered table-striped'; |
|
420 | - } |
|
418 | + if ( ! is_admin() ) { |
|
419 | + $table_class = 'table table-bordered table-striped'; |
|
420 | + } |
|
421 | 421 | |
422 | - ?> |
|
422 | + ?> |
|
423 | 423 | <div class="m-0" style="overflow: auto;"> |
424 | 424 | |
425 | 425 | <table class="<?php echo $table_class; ?>"> |
@@ -427,13 +427,13 @@ discard block |
||
427 | 427 | <thead> |
428 | 428 | <tr> |
429 | 429 | <?php |
430 | - foreach ( $columns as $key => $label ) { |
|
431 | - $key = esc_attr( $key ); |
|
432 | - $label = sanitize_text_field( $label ); |
|
430 | + foreach ( $columns as $key => $label ) { |
|
431 | + $key = esc_attr( $key ); |
|
432 | + $label = sanitize_text_field( $label ); |
|
433 | 433 | |
434 | - echo "<th class='subscription-invoice-field-$key bg-light p-2 text-left color-dark font-weight-bold'>$label</th>"; |
|
435 | - } |
|
436 | - ?> |
|
434 | + echo "<th class='subscription-invoice-field-$key bg-light p-2 text-left color-dark font-weight-bold'>$label</th>"; |
|
435 | + } |
|
436 | + ?> |
|
437 | 437 | </tr> |
438 | 438 | </thead> |
439 | 439 | |
@@ -449,66 +449,66 @@ discard block |
||
449 | 449 | |
450 | 450 | <?php |
451 | 451 | |
452 | - foreach( $payments as $payment ) : |
|
452 | + foreach( $payments as $payment ) : |
|
453 | 453 | |
454 | - // Ensure that we have an invoice. |
|
455 | - $payment = new WPInv_Invoice( $payment ); |
|
454 | + // Ensure that we have an invoice. |
|
455 | + $payment = new WPInv_Invoice( $payment ); |
|
456 | 456 | |
457 | - // Abort if the invoice is invalid. |
|
458 | - if ( ! $payment->get_id() ) { |
|
459 | - continue; |
|
460 | - } |
|
457 | + // Abort if the invoice is invalid. |
|
458 | + if ( ! $payment->get_id() ) { |
|
459 | + continue; |
|
460 | + } |
|
461 | 461 | |
462 | - echo '<tr>'; |
|
462 | + echo '<tr>'; |
|
463 | 463 | |
464 | - foreach ( array_keys( $columns ) as $key ) { |
|
464 | + foreach ( array_keys( $columns ) as $key ) { |
|
465 | 465 | |
466 | - echo '<td class="p-2 text-left">'; |
|
466 | + echo '<td class="p-2 text-left">'; |
|
467 | 467 | |
468 | - switch( $key ) { |
|
468 | + switch( $key ) { |
|
469 | 469 | |
470 | - case 'total': |
|
471 | - echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>'; |
|
472 | - break; |
|
470 | + case 'total': |
|
471 | + echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>'; |
|
472 | + break; |
|
473 | 473 | |
474 | - case 'relationship': |
|
475 | - echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' ); |
|
476 | - break; |
|
474 | + case 'relationship': |
|
475 | + echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' ); |
|
476 | + break; |
|
477 | 477 | |
478 | - case 'date': |
|
479 | - echo getpaid_format_date_value( $payment->get_date_created() ); |
|
480 | - break; |
|
478 | + case 'date': |
|
479 | + echo getpaid_format_date_value( $payment->get_date_created() ); |
|
480 | + break; |
|
481 | 481 | |
482 | - case 'status': |
|
482 | + case 'status': |
|
483 | 483 | |
484 | - $status = $payment->get_status_nicename(); |
|
485 | - if ( is_admin() ) { |
|
486 | - $status = $payment->get_status_label_html(); |
|
487 | - } |
|
484 | + $status = $payment->get_status_nicename(); |
|
485 | + if ( is_admin() ) { |
|
486 | + $status = $payment->get_status_label_html(); |
|
487 | + } |
|
488 | 488 | |
489 | - echo $status; |
|
490 | - break; |
|
489 | + echo $status; |
|
490 | + break; |
|
491 | 491 | |
492 | - case 'invoice': |
|
493 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
492 | + case 'invoice': |
|
493 | + $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
494 | 494 | |
495 | - if ( ! is_admin() ) { |
|
496 | - $link = esc_url( $payment->get_view_url() ); |
|
497 | - } |
|
495 | + if ( ! is_admin() ) { |
|
496 | + $link = esc_url( $payment->get_view_url() ); |
|
497 | + } |
|
498 | 498 | |
499 | - $invoice = sanitize_text_field( $payment->get_number() ); |
|
500 | - echo "<a href='$link'>$invoice</a>"; |
|
501 | - break; |
|
502 | - } |
|
499 | + $invoice = sanitize_text_field( $payment->get_number() ); |
|
500 | + echo "<a href='$link'>$invoice</a>"; |
|
501 | + break; |
|
502 | + } |
|
503 | 503 | |
504 | - echo '</td>'; |
|
504 | + echo '</td>'; |
|
505 | 505 | |
506 | - } |
|
506 | + } |
|
507 | 507 | |
508 | - echo '</tr>'; |
|
508 | + echo '</tr>'; |
|
509 | 509 | |
510 | - endforeach; |
|
511 | - ?> |
|
510 | + endforeach; |
|
511 | + ?> |
|
512 | 512 | |
513 | 513 | </tbody> |
514 | 514 |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Contains functions that display the subscriptions admin page. |
4 | 4 | */ |
5 | 5 | |
6 | -defined( 'ABSPATH' ) || exit; |
|
6 | +defined('ABSPATH') || exit; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * Render the Subscriptions page |
@@ -17,22 +17,22 @@ discard block |
||
17 | 17 | ?> |
18 | 18 | |
19 | 19 | <div class="wrap"> |
20 | - <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> |
|
20 | + <h1><?php echo esc_html(get_admin_page_title()); ?></h1> |
|
21 | 21 | <div class="bsui"> |
22 | 22 | |
23 | 23 | <?php |
24 | 24 | |
25 | 25 | // Verify user permissions. |
26 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
26 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
27 | 27 | |
28 | 28 | echo aui()->alert( |
29 | 29 | array( |
30 | 30 | 'type' => 'danger', |
31 | - 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
31 | + 'content' => __('You are not permitted to view this page.', 'invoicing'), |
|
32 | 32 | ) |
33 | 33 | ); |
34 | 34 | |
35 | - } else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
35 | + } else if (!empty($_GET['id']) && is_numeric($_GET['id'])) { |
|
36 | 36 | |
37 | 37 | // Display a single subscription. |
38 | 38 | wpinv_recurring_subscription_details(); |
@@ -81,13 +81,13 @@ discard block |
||
81 | 81 | function wpinv_recurring_subscription_details() { |
82 | 82 | |
83 | 83 | // Fetch the subscription. |
84 | - $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
85 | - if ( ! $sub->get_id() ) { |
|
84 | + $sub = new WPInv_Subscription((int) $_GET['id']); |
|
85 | + if (!$sub->get_id()) { |
|
86 | 86 | |
87 | 87 | echo aui()->alert( |
88 | 88 | array( |
89 | 89 | 'type' => 'danger', |
90 | - 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
90 | + 'content' => __('Subscription not found.', 'invoicing'), |
|
91 | 91 | ) |
92 | 92 | ); |
93 | 93 | |
@@ -95,31 +95,31 @@ discard block |
||
95 | 95 | } |
96 | 96 | |
97 | 97 | // Use metaboxes to display the subscription details. |
98 | - add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal' ); |
|
99 | - add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
100 | - add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
101 | - do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
98 | + add_meta_box('getpaid_admin_subscription_details_metabox', __('Subscription Details', 'invoicing'), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal'); |
|
99 | + add_meta_box('getpaid_admin_subscription_update_metabox', __('Change Status', 'invoicing'), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side'); |
|
100 | + add_meta_box('getpaid_admin_subscription_invoice_details_metabox', __('Invoices', 'invoicing'), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced'); |
|
101 | + do_action('getpaid_admin_single_subscription_register_metabox', $sub); |
|
102 | 102 | |
103 | 103 | ?> |
104 | 104 | |
105 | - <form method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ); ?>"> |
|
105 | + <form method="post" action="<?php echo admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($sub->get_id())); ?>"> |
|
106 | 106 | |
107 | - <?php wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); ?> |
|
108 | - <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> |
|
109 | - <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> |
|
107 | + <?php wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); ?> |
|
108 | + <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?> |
|
109 | + <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?> |
|
110 | 110 | <input type="hidden" name="getpaid-admin-action" value="update_single_subscription" /> |
111 | - <input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id() ;?>" /> |
|
111 | + <input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id(); ?>" /> |
|
112 | 112 | |
113 | 113 | <div id="poststuff"> |
114 | 114 | <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>"> |
115 | 115 | |
116 | 116 | <div id="postbox-container-1" class="postbox-container"> |
117 | - <?php do_meta_boxes( get_current_screen(), 'side', $sub ); ?> |
|
117 | + <?php do_meta_boxes(get_current_screen(), 'side', $sub); ?> |
|
118 | 118 | </div> |
119 | 119 | |
120 | 120 | <div id="postbox-container-2" class="postbox-container"> |
121 | - <?php do_meta_boxes( get_current_screen(), 'normal', $sub ); ?> |
|
122 | - <?php do_meta_boxes( get_current_screen(), 'advanced', $sub ); ?> |
|
121 | + <?php do_meta_boxes(get_current_screen(), 'normal', $sub); ?> |
|
122 | + <?php do_meta_boxes(get_current_screen(), 'advanced', $sub); ?> |
|
123 | 123 | </div> |
124 | 124 | |
125 | 125 | </div> |
@@ -138,40 +138,40 @@ discard block |
||
138 | 138 | * |
139 | 139 | * @param WPInv_Subscription $sub |
140 | 140 | */ |
141 | -function getpaid_admin_subscription_details_metabox( $sub ) { |
|
141 | +function getpaid_admin_subscription_details_metabox($sub) { |
|
142 | 142 | |
143 | 143 | // Prepare subscription detail columns. |
144 | 144 | $fields = apply_filters( |
145 | 145 | 'getpaid_subscription_admin_page_fields', |
146 | 146 | array( |
147 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
148 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
149 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
150 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
151 | - 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
152 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
153 | - 'item' => __( 'Item', 'invoicing' ), |
|
154 | - 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
155 | - 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
156 | - 'status' => __( 'Status', 'invoicing' ), |
|
147 | + 'subscription' => __('Subscription', 'invoicing'), |
|
148 | + 'customer' => __('Customer', 'invoicing'), |
|
149 | + 'amount' => __('Amount', 'invoicing'), |
|
150 | + 'start_date' => __('Start Date', 'invoicing'), |
|
151 | + 'renews_on' => __('Next Payment', 'invoicing'), |
|
152 | + 'renewals' => __('Payments', 'invoicing'), |
|
153 | + 'item' => __('Item', 'invoicing'), |
|
154 | + 'gateway' => __('Payment Method', 'invoicing'), |
|
155 | + 'profile_id' => __('Profile ID', 'invoicing'), |
|
156 | + 'status' => __('Status', 'invoicing'), |
|
157 | 157 | ) |
158 | 158 | ); |
159 | 159 | |
160 | - if ( ! $sub->is_active() ) { |
|
160 | + if (!$sub->is_active()) { |
|
161 | 161 | |
162 | - if ( isset( $fields['renews_on'] ) ) { |
|
163 | - unset( $fields['renews_on'] ); |
|
162 | + if (isset($fields['renews_on'])) { |
|
163 | + unset($fields['renews_on']); |
|
164 | 164 | } |
165 | 165 | |
166 | - if ( isset( $fields['gateway'] ) ) { |
|
167 | - unset( $fields['gateway'] ); |
|
166 | + if (isset($fields['gateway'])) { |
|
167 | + unset($fields['gateway']); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | } |
171 | 171 | |
172 | 172 | $profile_id = $sub->get_profile_id(); |
173 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
174 | - unset( $fields['profile_id'] ); |
|
173 | + if (empty($profile_id) && isset($fields['profile_id'])) { |
|
174 | + unset($fields['profile_id']); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | ?> |
@@ -179,16 +179,16 @@ discard block |
||
179 | 179 | <table class="table table-borderless" style="font-size: 14px;"> |
180 | 180 | <tbody> |
181 | 181 | |
182 | - <?php foreach ( $fields as $key => $label ) : ?> |
|
182 | + <?php foreach ($fields as $key => $label) : ?> |
|
183 | 183 | |
184 | - <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class( $key ); ?>"> |
|
184 | + <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class($key); ?>"> |
|
185 | 185 | |
186 | 186 | <th class="w-25" style="font-weight: 500;"> |
187 | - <?php echo sanitize_text_field( $label ); ?> |
|
187 | + <?php echo sanitize_text_field($label); ?> |
|
188 | 188 | </th> |
189 | 189 | |
190 | 190 | <td class="w-75 text-muted"> |
191 | - <?php do_action( 'getpaid_subscription_admin_display_' . sanitize_text_field( $key ), $sub ); ?> |
|
191 | + <?php do_action('getpaid_subscription_admin_display_' . sanitize_text_field($key), $sub); ?> |
|
192 | 192 | </td> |
193 | 193 | |
194 | 194 | </tr> |
@@ -206,150 +206,150 @@ discard block |
||
206 | 206 | * |
207 | 207 | * @param WPInv_Subscription $subscription |
208 | 208 | */ |
209 | -function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
|
209 | +function getpaid_admin_subscription_metabox_display_customer($subscription) { |
|
210 | 210 | |
211 | - $username = __( '(Missing User)', 'invoicing' ); |
|
211 | + $username = __('(Missing User)', 'invoicing'); |
|
212 | 212 | |
213 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
214 | - if ( $user ) { |
|
213 | + $user = get_userdata($subscription->get_customer_id()); |
|
214 | + if ($user) { |
|
215 | 215 | |
216 | 216 | $username = sprintf( |
217 | 217 | '<a href="user-edit.php?user_id=%s">%s</a>', |
218 | - absint( $user->ID ), |
|
219 | - ! empty( $user->display_name ) ? sanitize_text_field( $user->display_name ) : sanitize_email( $user->user_email ) |
|
218 | + absint($user->ID), |
|
219 | + !empty($user->display_name) ? sanitize_text_field($user->display_name) : sanitize_email($user->user_email) |
|
220 | 220 | ); |
221 | 221 | |
222 | 222 | } |
223 | 223 | |
224 | 224 | echo $username; |
225 | 225 | } |
226 | -add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
|
226 | +add_action('getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer'); |
|
227 | 227 | |
228 | 228 | /** |
229 | 229 | * Displays the subscription amount. |
230 | 230 | * |
231 | 231 | * @param WPInv_Subscription $subscription |
232 | 232 | */ |
233 | -function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
|
234 | - $amount = sanitize_text_field( getpaid_get_formatted_subscription_amount( $subscription ) ); |
|
233 | +function getpaid_admin_subscription_metabox_display_amount($subscription) { |
|
234 | + $amount = sanitize_text_field(getpaid_get_formatted_subscription_amount($subscription)); |
|
235 | 235 | echo "<span>$amount</span>"; |
236 | 236 | } |
237 | -add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
|
237 | +add_action('getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount'); |
|
238 | 238 | |
239 | 239 | /** |
240 | 240 | * Displays the subscription id. |
241 | 241 | * |
242 | 242 | * @param WPInv_Subscription $subscription |
243 | 243 | */ |
244 | -function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
|
245 | - echo '#' . absint( $subscription->get_id() ); |
|
244 | +function getpaid_admin_subscription_metabox_display_id($subscription) { |
|
245 | + echo '#' . absint($subscription->get_id()); |
|
246 | 246 | } |
247 | -add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
|
247 | +add_action('getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id'); |
|
248 | 248 | |
249 | 249 | /** |
250 | 250 | * Displays the subscription renewal date. |
251 | 251 | * |
252 | 252 | * @param WPInv_Subscription $subscription |
253 | 253 | */ |
254 | -function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
|
255 | - echo getpaid_format_date_value( $subscription->get_date_created() ); |
|
254 | +function getpaid_admin_subscription_metabox_display_start_date($subscription) { |
|
255 | + echo getpaid_format_date_value($subscription->get_date_created()); |
|
256 | 256 | } |
257 | -add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
|
257 | +add_action('getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date'); |
|
258 | 258 | |
259 | 259 | /** |
260 | 260 | * Displays the subscription renewal date. |
261 | 261 | * |
262 | 262 | * @param WPInv_Subscription $subscription |
263 | 263 | */ |
264 | -function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
|
265 | - echo getpaid_format_date_value( $subscription->get_expiration() ); |
|
264 | +function getpaid_admin_subscription_metabox_display_renews_on($subscription) { |
|
265 | + echo getpaid_format_date_value($subscription->get_expiration()); |
|
266 | 266 | } |
267 | -add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
|
267 | +add_action('getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on'); |
|
268 | 268 | |
269 | 269 | /** |
270 | 270 | * Displays the subscription renewal count. |
271 | 271 | * |
272 | 272 | * @param WPInv_Subscription $subscription |
273 | 273 | */ |
274 | -function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
|
274 | +function getpaid_admin_subscription_metabox_display_renewals($subscription) { |
|
275 | 275 | $max_bills = $subscription->get_bill_times(); |
276 | - echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
276 | + echo $subscription->get_times_billed() . ' / ' . (empty($max_bills) ? "∞" : $max_bills); |
|
277 | 277 | } |
278 | -add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
|
278 | +add_action('getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals'); |
|
279 | 279 | /** |
280 | 280 | * Displays the subscription item. |
281 | 281 | * |
282 | 282 | * @param WPInv_Subscription $subscription |
283 | 283 | */ |
284 | -function getpaid_admin_subscription_metabox_display_item( $subscription ) { |
|
284 | +function getpaid_admin_subscription_metabox_display_item($subscription) { |
|
285 | 285 | |
286 | - $item = get_post( $subscription->get_product_id() ); |
|
286 | + $item = get_post($subscription->get_product_id()); |
|
287 | 287 | |
288 | - if ( ! empty( $item ) ) { |
|
289 | - $link = get_edit_post_link( $item ); |
|
290 | - $link = esc_url( $link ); |
|
291 | - $name = esc_html( get_the_title( $item ) ); |
|
288 | + if (!empty($item)) { |
|
289 | + $link = get_edit_post_link($item); |
|
290 | + $link = esc_url($link); |
|
291 | + $name = esc_html(get_the_title($item)); |
|
292 | 292 | echo "<a href='$link'>$name</a>"; |
293 | 293 | } else { |
294 | - echo sprintf( __( 'Item #%s', 'invoicing' ), $subscription->get_product_id() ); |
|
294 | + echo sprintf(__('Item #%s', 'invoicing'), $subscription->get_product_id()); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | } |
298 | -add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item' ); |
|
298 | +add_action('getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item'); |
|
299 | 299 | |
300 | 300 | /** |
301 | 301 | * Displays the subscription gateway. |
302 | 302 | * |
303 | 303 | * @param WPInv_Subscription $subscription |
304 | 304 | */ |
305 | -function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
|
305 | +function getpaid_admin_subscription_metabox_display_gateway($subscription) { |
|
306 | 306 | |
307 | 307 | $gateway = $subscription->get_gateway(); |
308 | 308 | |
309 | - if ( ! empty( $gateway ) ) { |
|
310 | - echo sanitize_text_field( wpinv_get_gateway_admin_label( $gateway ) ); |
|
309 | + if (!empty($gateway)) { |
|
310 | + echo sanitize_text_field(wpinv_get_gateway_admin_label($gateway)); |
|
311 | 311 | } else { |
312 | 312 | echo "—"; |
313 | 313 | } |
314 | 314 | |
315 | 315 | } |
316 | -add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
|
316 | +add_action('getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway'); |
|
317 | 317 | |
318 | 318 | /** |
319 | 319 | * Displays the subscription status. |
320 | 320 | * |
321 | 321 | * @param WPInv_Subscription $subscription |
322 | 322 | */ |
323 | -function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
|
323 | +function getpaid_admin_subscription_metabox_display_status($subscription) { |
|
324 | 324 | echo $subscription->get_status_label_html(); |
325 | 325 | } |
326 | -add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
|
326 | +add_action('getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status'); |
|
327 | 327 | |
328 | 328 | /** |
329 | 329 | * Displays the subscription profile id. |
330 | 330 | * |
331 | 331 | * @param WPInv_Subscription $subscription |
332 | 332 | */ |
333 | -function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
|
333 | +function getpaid_admin_subscription_metabox_display_profile_id($subscription) { |
|
334 | 334 | |
335 | 335 | $profile_id = $subscription->get_profile_id(); |
336 | 336 | |
337 | - if ( ! empty( $profile_id ) ) { |
|
338 | - $profile_id = sanitize_text_field( $profile_id ); |
|
339 | - echo apply_filters( 'getpaid_subscription_profile_id_display', $profile_id, $subscription ); |
|
337 | + if (!empty($profile_id)) { |
|
338 | + $profile_id = sanitize_text_field($profile_id); |
|
339 | + echo apply_filters('getpaid_subscription_profile_id_display', $profile_id, $subscription); |
|
340 | 340 | } else { |
341 | 341 | echo "—"; |
342 | 342 | } |
343 | 343 | |
344 | 344 | } |
345 | -add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
|
345 | +add_action('getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id'); |
|
346 | 346 | |
347 | 347 | /** |
348 | 348 | * Displays the subscriptions update metabox. |
349 | 349 | * |
350 | 350 | * @param WPInv_Subscription $subscription |
351 | 351 | */ |
352 | -function getpaid_admin_subscription_update_metabox( $subscription ) { |
|
352 | +function getpaid_admin_subscription_update_metabox($subscription) { |
|
353 | 353 | |
354 | 354 | ?> |
355 | 355 | <div class="mt-3"> |
@@ -362,10 +362,10 @@ discard block |
||
362 | 362 | 'id' => 'subscription_status_update_select', |
363 | 363 | 'required' => true, |
364 | 364 | 'no_wrap' => false, |
365 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
366 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
365 | + 'label' => __('Subscription Status', 'invoicing'), |
|
366 | + 'help_text' => __('Updating the status will trigger related actions and hooks', 'invoicing'), |
|
367 | 367 | 'select2' => true, |
368 | - 'value' => $subscription->get_status( 'edit' ), |
|
368 | + 'value' => $subscription->get_status('edit'), |
|
369 | 369 | ) |
370 | 370 | ); |
371 | 371 | ?> |
@@ -373,13 +373,13 @@ discard block |
||
373 | 373 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;"> |
374 | 374 | |
375 | 375 | <?php |
376 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
376 | + submit_button(__('Update', 'invoicing'), 'primary', 'submit', false); |
|
377 | 377 | |
378 | - $url = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) ); |
|
379 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
380 | - $title = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' ); |
|
378 | + $url = esc_url(wp_nonce_url(add_query_arg('getpaid-admin-action', 'subscription_manual_renew'), 'getpaid-nonce', 'getpaid-nonce')); |
|
379 | + $anchor = __('Renew Subscription', 'invoicing'); |
|
380 | + $title = esc_attr__('Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing'); |
|
381 | 381 | |
382 | - if ( $subscription->is_active() ) { |
|
382 | + if ($subscription->is_active()) { |
|
383 | 383 | echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>"; |
384 | 384 | } |
385 | 385 | |
@@ -391,31 +391,31 @@ discard block |
||
391 | 391 | * |
392 | 392 | * @param WPInv_Subscription $subscription |
393 | 393 | */ |
394 | -function getpaid_admin_subscription_invoice_details_metabox( $subscription ) { |
|
394 | +function getpaid_admin_subscription_invoice_details_metabox($subscription) { |
|
395 | 395 | |
396 | 396 | $columns = apply_filters( |
397 | 397 | 'getpaid_subscription_related_invoices_columns', |
398 | 398 | array( |
399 | - 'invoice' => __( 'Invoice', 'invoicing' ), |
|
400 | - 'relationship' => __( 'Relationship', 'invoicing' ), |
|
401 | - 'date' => __( 'Date', 'invoicing' ), |
|
402 | - 'status' => __( 'Status', 'invoicing' ), |
|
403 | - 'total' => __( 'Total', 'invoicing' ), |
|
399 | + 'invoice' => __('Invoice', 'invoicing'), |
|
400 | + 'relationship' => __('Relationship', 'invoicing'), |
|
401 | + 'date' => __('Date', 'invoicing'), |
|
402 | + 'status' => __('Status', 'invoicing'), |
|
403 | + 'total' => __('Total', 'invoicing'), |
|
404 | 404 | ), |
405 | 405 | $subscription |
406 | 406 | ); |
407 | 407 | |
408 | 408 | // Prepare the invoices. |
409 | - $payments = $subscription->get_child_payments( ! is_admin() ); |
|
409 | + $payments = $subscription->get_child_payments(!is_admin()); |
|
410 | 410 | $parent = $subscription->get_parent_invoice(); |
411 | 411 | |
412 | - if ( $parent->get_id() ) { |
|
413 | - $payments = array_merge( array( $parent ), $payments ); |
|
412 | + if ($parent->get_id()) { |
|
413 | + $payments = array_merge(array($parent), $payments); |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | $table_class = 'w-100 bg-white'; |
417 | 417 | |
418 | - if ( ! is_admin() ) { |
|
418 | + if (!is_admin()) { |
|
419 | 419 | $table_class = 'table table-bordered table-striped'; |
420 | 420 | } |
421 | 421 | |
@@ -427,9 +427,9 @@ discard block |
||
427 | 427 | <thead> |
428 | 428 | <tr> |
429 | 429 | <?php |
430 | - foreach ( $columns as $key => $label ) { |
|
431 | - $key = esc_attr( $key ); |
|
432 | - $label = sanitize_text_field( $label ); |
|
430 | + foreach ($columns as $key => $label) { |
|
431 | + $key = esc_attr($key); |
|
432 | + $label = sanitize_text_field($label); |
|
433 | 433 | |
434 | 434 | echo "<th class='subscription-invoice-field-$key bg-light p-2 text-left color-dark font-weight-bold'>$label</th>"; |
435 | 435 | } |
@@ -439,50 +439,50 @@ discard block |
||
439 | 439 | |
440 | 440 | <tbody> |
441 | 441 | |
442 | - <?php if ( empty( $payments ) ) : ?> |
|
442 | + <?php if (empty($payments)) : ?> |
|
443 | 443 | <tr> |
444 | 444 | <td colspan="<?php echo count($columns); ?>" class="p-2 text-left text-muted"> |
445 | - <?php _e( 'This subscription has no invoices.', 'invoicing' ); ?> |
|
445 | + <?php _e('This subscription has no invoices.', 'invoicing'); ?> |
|
446 | 446 | </td> |
447 | 447 | </tr> |
448 | 448 | <?php endif; ?> |
449 | 449 | |
450 | 450 | <?php |
451 | 451 | |
452 | - foreach( $payments as $payment ) : |
|
452 | + foreach ($payments as $payment) : |
|
453 | 453 | |
454 | 454 | // Ensure that we have an invoice. |
455 | - $payment = new WPInv_Invoice( $payment ); |
|
455 | + $payment = new WPInv_Invoice($payment); |
|
456 | 456 | |
457 | 457 | // Abort if the invoice is invalid. |
458 | - if ( ! $payment->get_id() ) { |
|
458 | + if (!$payment->get_id()) { |
|
459 | 459 | continue; |
460 | 460 | } |
461 | 461 | |
462 | 462 | echo '<tr>'; |
463 | 463 | |
464 | - foreach ( array_keys( $columns ) as $key ) { |
|
464 | + foreach (array_keys($columns) as $key) { |
|
465 | 465 | |
466 | 466 | echo '<td class="p-2 text-left">'; |
467 | 467 | |
468 | - switch( $key ) { |
|
468 | + switch ($key) { |
|
469 | 469 | |
470 | 470 | case 'total': |
471 | - echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>'; |
|
471 | + echo '<strong>' . wpinv_price($payment->get_total(), $payment->get_currency()) . '</strong>'; |
|
472 | 472 | break; |
473 | 473 | |
474 | 474 | case 'relationship': |
475 | - echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' ); |
|
475 | + echo $payment->is_renewal() ? __('Renewal Invoice', 'invoicing') : __('Initial Invoice', 'invoicing'); |
|
476 | 476 | break; |
477 | 477 | |
478 | 478 | case 'date': |
479 | - echo getpaid_format_date_value( $payment->get_date_created() ); |
|
479 | + echo getpaid_format_date_value($payment->get_date_created()); |
|
480 | 480 | break; |
481 | 481 | |
482 | 482 | case 'status': |
483 | 483 | |
484 | 484 | $status = $payment->get_status_nicename(); |
485 | - if ( is_admin() ) { |
|
485 | + if (is_admin()) { |
|
486 | 486 | $status = $payment->get_status_label_html(); |
487 | 487 | } |
488 | 488 | |
@@ -490,13 +490,13 @@ discard block |
||
490 | 490 | break; |
491 | 491 | |
492 | 492 | case 'invoice': |
493 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
493 | + $link = esc_url(get_edit_post_link($payment->get_id())); |
|
494 | 494 | |
495 | - if ( ! is_admin() ) { |
|
496 | - $link = esc_url( $payment->get_view_url() ); |
|
495 | + if (!is_admin()) { |
|
496 | + $link = esc_url($payment->get_view_url()); |
|
497 | 497 | } |
498 | 498 | |
499 | - $invoice = sanitize_text_field( $payment->get_number() ); |
|
499 | + $invoice = sanitize_text_field($payment->get_number()); |
|
500 | 500 | echo "<a href='$link'>$invoice</a>"; |
501 | 501 | break; |
502 | 502 | } |
@@ -17,28 +17,28 @@ discard block |
||
17 | 17 | */ |
18 | 18 | function getpaid_get_subscriptions( $args = array(), $return = 'results' ) { |
19 | 19 | |
20 | - // Do not retrieve all fields if we just want the count. |
|
21 | - if ( 'count' == $return ) { |
|
22 | - $args['fields'] = 'id'; |
|
23 | - $args['number'] = 1; |
|
24 | - } |
|
20 | + // Do not retrieve all fields if we just want the count. |
|
21 | + if ( 'count' == $return ) { |
|
22 | + $args['fields'] = 'id'; |
|
23 | + $args['number'] = 1; |
|
24 | + } |
|
25 | 25 | |
26 | - // Do not count all matches if we just want the results. |
|
27 | - if ( 'results' == $return ) { |
|
28 | - $args['count_total'] = false; |
|
29 | - } |
|
26 | + // Do not count all matches if we just want the results. |
|
27 | + if ( 'results' == $return ) { |
|
28 | + $args['count_total'] = false; |
|
29 | + } |
|
30 | 30 | |
31 | - $query = new GetPaid_Subscriptions_Query( $args ); |
|
31 | + $query = new GetPaid_Subscriptions_Query( $args ); |
|
32 | 32 | |
33 | - if ( 'results' == $return ) { |
|
34 | - return $query->get_results(); |
|
35 | - } |
|
33 | + if ( 'results' == $return ) { |
|
34 | + return $query->get_results(); |
|
35 | + } |
|
36 | 36 | |
37 | - if ( 'count' == $return ) { |
|
38 | - return $query->get_total(); |
|
39 | - } |
|
37 | + if ( 'count' == $return ) { |
|
38 | + return $query->get_total(); |
|
39 | + } |
|
40 | 40 | |
41 | - return $query; |
|
41 | + return $query; |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -48,18 +48,18 @@ discard block |
||
48 | 48 | */ |
49 | 49 | function getpaid_get_subscription_statuses() { |
50 | 50 | |
51 | - return apply_filters( |
|
52 | - 'getpaid_get_subscription_statuses', |
|
53 | - array( |
|
54 | - 'pending' => __( 'Pending', 'invoicing' ), |
|
55 | - 'trialling' => __( 'Trialing', 'invoicing' ), |
|
56 | - 'active' => __( 'Active', 'invoicing' ), |
|
57 | - 'failing' => __( 'Failing', 'invoicing' ), |
|
58 | - 'expired' => __( 'Expired', 'invoicing' ), |
|
59 | - 'completed' => __( 'Complete', 'invoicing' ), |
|
60 | - 'cancelled' => __( 'Cancelled', 'invoicing' ), |
|
61 | - ) |
|
62 | - ); |
|
51 | + return apply_filters( |
|
52 | + 'getpaid_get_subscription_statuses', |
|
53 | + array( |
|
54 | + 'pending' => __( 'Pending', 'invoicing' ), |
|
55 | + 'trialling' => __( 'Trialing', 'invoicing' ), |
|
56 | + 'active' => __( 'Active', 'invoicing' ), |
|
57 | + 'failing' => __( 'Failing', 'invoicing' ), |
|
58 | + 'expired' => __( 'Expired', 'invoicing' ), |
|
59 | + 'completed' => __( 'Complete', 'invoicing' ), |
|
60 | + 'cancelled' => __( 'Cancelled', 'invoicing' ), |
|
61 | + ) |
|
62 | + ); |
|
63 | 63 | |
64 | 64 | } |
65 | 65 | |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | * @return string |
70 | 70 | */ |
71 | 71 | function getpaid_get_subscription_status_label( $status ) { |
72 | - $statuses = getpaid_get_subscription_statuses(); |
|
73 | - return isset( $statuses[ $status ] ) ? $statuses[ $status ] : ucfirst( sanitize_text_field( $status ) ); |
|
72 | + $statuses = getpaid_get_subscription_statuses(); |
|
73 | + return isset( $statuses[ $status ] ) ? $statuses[ $status ] : ucfirst( sanitize_text_field( $status ) ); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -80,18 +80,18 @@ discard block |
||
80 | 80 | */ |
81 | 81 | function getpaid_get_subscription_status_classes() { |
82 | 82 | |
83 | - return apply_filters( |
|
84 | - 'getpaid_get_subscription_status_classes', |
|
85 | - array( |
|
86 | - 'pending' => 'badge-dark', |
|
87 | - 'trialling' => 'badge-info', |
|
88 | - 'active' => 'badge-success', |
|
89 | - 'failing' => 'badge-warning', |
|
90 | - 'expired' => 'badge-danger', |
|
91 | - 'completed' => 'badge-primary', |
|
92 | - 'cancelled' => 'badge-secondary', |
|
93 | - ) |
|
94 | - ); |
|
83 | + return apply_filters( |
|
84 | + 'getpaid_get_subscription_status_classes', |
|
85 | + array( |
|
86 | + 'pending' => 'badge-dark', |
|
87 | + 'trialling' => 'badge-info', |
|
88 | + 'active' => 'badge-success', |
|
89 | + 'failing' => 'badge-warning', |
|
90 | + 'expired' => 'badge-danger', |
|
91 | + 'completed' => 'badge-primary', |
|
92 | + 'cancelled' => 'badge-secondary', |
|
93 | + ) |
|
94 | + ); |
|
95 | 95 | |
96 | 96 | } |
97 | 97 | |
@@ -102,15 +102,15 @@ discard block |
||
102 | 102 | */ |
103 | 103 | function getpaid_get_subscription_status_counts( $args = array() ) { |
104 | 104 | |
105 | - $statuses = array_keys( getpaid_get_subscription_statuses() ); |
|
106 | - $counts = array(); |
|
105 | + $statuses = array_keys( getpaid_get_subscription_statuses() ); |
|
106 | + $counts = array(); |
|
107 | 107 | |
108 | - foreach ( $statuses as $status ) { |
|
109 | - $_args = wp_parse_args( "status=$status", $args ); |
|
110 | - $counts[ $status ] = getpaid_get_subscriptions( $_args, 'count' ); |
|
111 | - } |
|
108 | + foreach ( $statuses as $status ) { |
|
109 | + $_args = wp_parse_args( "status=$status", $args ); |
|
110 | + $counts[ $status ] = getpaid_get_subscriptions( $_args, 'count' ); |
|
111 | + } |
|
112 | 112 | |
113 | - return $counts; |
|
113 | + return $counts; |
|
114 | 114 | |
115 | 115 | } |
116 | 116 | |
@@ -121,32 +121,32 @@ discard block |
||
121 | 121 | */ |
122 | 122 | function getpaid_get_subscription_periods() { |
123 | 123 | |
124 | - return apply_filters( |
|
125 | - 'getpaid_get_subscription_periods', |
|
126 | - array( |
|
124 | + return apply_filters( |
|
125 | + 'getpaid_get_subscription_periods', |
|
126 | + array( |
|
127 | 127 | |
128 | - 'day' => array( |
|
129 | - 'singular' => __( '%s day', 'invoicing' ), |
|
130 | - 'plural' => __( '%d days', 'invoicing' ), |
|
131 | - ), |
|
128 | + 'day' => array( |
|
129 | + 'singular' => __( '%s day', 'invoicing' ), |
|
130 | + 'plural' => __( '%d days', 'invoicing' ), |
|
131 | + ), |
|
132 | 132 | |
133 | - 'week' => array( |
|
134 | - 'singular' => __( '%s week', 'invoicing' ), |
|
135 | - 'plural' => __( '%d weeks', 'invoicing' ), |
|
136 | - ), |
|
133 | + 'week' => array( |
|
134 | + 'singular' => __( '%s week', 'invoicing' ), |
|
135 | + 'plural' => __( '%d weeks', 'invoicing' ), |
|
136 | + ), |
|
137 | 137 | |
138 | - 'month' => array( |
|
139 | - 'singular' => __( '%s month', 'invoicing' ), |
|
140 | - 'plural' => __( '%d months', 'invoicing' ), |
|
141 | - ), |
|
138 | + 'month' => array( |
|
139 | + 'singular' => __( '%s month', 'invoicing' ), |
|
140 | + 'plural' => __( '%d months', 'invoicing' ), |
|
141 | + ), |
|
142 | 142 | |
143 | - 'year' => array( |
|
144 | - 'singular' => __( '%s year', 'invoicing' ), |
|
145 | - 'plural' => __( '%d years', 'invoicing' ), |
|
146 | - ), |
|
143 | + 'year' => array( |
|
144 | + 'singular' => __( '%s year', 'invoicing' ), |
|
145 | + 'plural' => __( '%d years', 'invoicing' ), |
|
146 | + ), |
|
147 | 147 | |
148 | - ) |
|
149 | - ); |
|
148 | + ) |
|
149 | + ); |
|
150 | 150 | |
151 | 151 | } |
152 | 152 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @return int |
158 | 158 | */ |
159 | 159 | function getpaid_get_subscription_trial_period_interval( $trial_period ) { |
160 | - return (int) preg_replace( '/[^0-9]/', '', $trial_period ); |
|
160 | + return (int) preg_replace( '/[^0-9]/', '', $trial_period ); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | * @return string |
168 | 168 | */ |
169 | 169 | function getpaid_get_subscription_trial_period_period( $trial_period ) { |
170 | - return preg_replace( '/[^a-z]/', '', strtolower( $trial_period ) ); |
|
170 | + return preg_replace( '/[^a-z]/', '', strtolower( $trial_period ) ); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
@@ -178,8 +178,8 @@ discard block |
||
178 | 178 | * @return string |
179 | 179 | */ |
180 | 180 | function getpaid_get_subscription_period_label( $period, $interval = 1, $singular_prefix = '1' ) { |
181 | - $label = (int) $interval > 1 ? getpaid_get_plural_subscription_period_label( $period, $interval ) : getpaid_get_singular_subscription_period_label( $period, $singular_prefix ); |
|
182 | - return strtolower( sanitize_text_field( $label ) ); |
|
181 | + $label = (int) $interval > 1 ? getpaid_get_plural_subscription_period_label( $period, $interval ) : getpaid_get_singular_subscription_period_label( $period, $singular_prefix ); |
|
182 | + return strtolower( sanitize_text_field( $label ) ); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | /** |
@@ -190,22 +190,22 @@ discard block |
||
190 | 190 | */ |
191 | 191 | function getpaid_get_singular_subscription_period_label( $period, $singular_prefix = '1' ) { |
192 | 192 | |
193 | - $periods = getpaid_get_subscription_periods(); |
|
194 | - $period = strtolower( $period ); |
|
193 | + $periods = getpaid_get_subscription_periods(); |
|
194 | + $period = strtolower( $period ); |
|
195 | 195 | |
196 | - if ( isset( $periods[ $period ] ) ) { |
|
197 | - return sprintf( $periods[ $period ]['singular'], $singular_prefix ); |
|
198 | - } |
|
196 | + if ( isset( $periods[ $period ] ) ) { |
|
197 | + return sprintf( $periods[ $period ]['singular'], $singular_prefix ); |
|
198 | + } |
|
199 | 199 | |
200 | - // Backwards compatibility. |
|
201 | - foreach ( $periods as $key => $data ) { |
|
202 | - if ( strpos( $key, $period ) === 0 ) { |
|
203 | - return sprintf( $data['singular'], $singular_prefix ); |
|
204 | - } |
|
205 | - } |
|
200 | + // Backwards compatibility. |
|
201 | + foreach ( $periods as $key => $data ) { |
|
202 | + if ( strpos( $key, $period ) === 0 ) { |
|
203 | + return sprintf( $data['singular'], $singular_prefix ); |
|
204 | + } |
|
205 | + } |
|
206 | 206 | |
207 | - // Invalid string. |
|
208 | - return ''; |
|
207 | + // Invalid string. |
|
208 | + return ''; |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | /** |
@@ -217,22 +217,22 @@ discard block |
||
217 | 217 | */ |
218 | 218 | function getpaid_get_plural_subscription_period_label( $period, $interval ) { |
219 | 219 | |
220 | - $periods = getpaid_get_subscription_periods(); |
|
221 | - $period = strtolower( $period ); |
|
220 | + $periods = getpaid_get_subscription_periods(); |
|
221 | + $period = strtolower( $period ); |
|
222 | 222 | |
223 | - if ( isset( $periods[ $period ] ) ) { |
|
224 | - return sprintf( $periods[ $period ]['plural'], $interval ); |
|
225 | - } |
|
223 | + if ( isset( $periods[ $period ] ) ) { |
|
224 | + return sprintf( $periods[ $period ]['plural'], $interval ); |
|
225 | + } |
|
226 | 226 | |
227 | - // Backwards compatibility. |
|
228 | - foreach ( $periods as $key => $data ) { |
|
229 | - if ( strpos( $key, $period ) === 0 ) { |
|
230 | - return sprintf( $data['plural'], $interval ); |
|
231 | - } |
|
232 | - } |
|
227 | + // Backwards compatibility. |
|
228 | + foreach ( $periods as $key => $data ) { |
|
229 | + if ( strpos( $key, $period ) === 0 ) { |
|
230 | + return sprintf( $data['plural'], $interval ); |
|
231 | + } |
|
232 | + } |
|
233 | 233 | |
234 | - // Invalid string. |
|
235 | - return ''; |
|
234 | + // Invalid string. |
|
235 | + return ''; |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | /** |
@@ -243,50 +243,50 @@ discard block |
||
243 | 243 | */ |
244 | 244 | function getpaid_get_formatted_subscription_amount( $subscription ) { |
245 | 245 | |
246 | - $initial = wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
247 | - $recurring = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
248 | - $period = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ); |
|
246 | + $initial = wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
247 | + $recurring = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
248 | + $period = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ); |
|
249 | 249 | |
250 | - // Trial periods. |
|
251 | - if ( $subscription->has_trial_period() ) { |
|
250 | + // Trial periods. |
|
251 | + if ( $subscription->has_trial_period() ) { |
|
252 | 252 | |
253 | - $trial_period = getpaid_get_subscription_trial_period_period( $subscription->get_trial_period() ); |
|
254 | - $trial_interval = getpaid_get_subscription_trial_period_interval( $subscription->get_trial_period() ); |
|
255 | - return sprintf( |
|
253 | + $trial_period = getpaid_get_subscription_trial_period_period( $subscription->get_trial_period() ); |
|
254 | + $trial_interval = getpaid_get_subscription_trial_period_interval( $subscription->get_trial_period() ); |
|
255 | + return sprintf( |
|
256 | 256 | |
257 | - // translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period |
|
258 | - _x( '%1$s trial for %2$s then %3$s / %4$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing' ), |
|
259 | - $initial, |
|
260 | - getpaid_get_subscription_period_label( $trial_period, $trial_interval ), |
|
261 | - $recurring, |
|
262 | - $period |
|
257 | + // translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period |
|
258 | + _x( '%1$s trial for %2$s then %3$s / %4$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing' ), |
|
259 | + $initial, |
|
260 | + getpaid_get_subscription_period_label( $trial_period, $trial_interval ), |
|
261 | + $recurring, |
|
262 | + $period |
|
263 | 263 | |
264 | - ); |
|
264 | + ); |
|
265 | 265 | |
266 | - } |
|
266 | + } |
|
267 | 267 | |
268 | - if ( $initial != $recurring ) { |
|
268 | + if ( $initial != $recurring ) { |
|
269 | 269 | |
270 | - return sprintf( |
|
270 | + return sprintf( |
|
271 | 271 | |
272 | - // translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period |
|
273 | - _x( 'Initial payment of %1$s which renews at %2$s / %3$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year)', 'invoicing' ), |
|
274 | - $initial, |
|
275 | - $recurring, |
|
276 | - $period |
|
272 | + // translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period |
|
273 | + _x( 'Initial payment of %1$s which renews at %2$s / %3$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year)', 'invoicing' ), |
|
274 | + $initial, |
|
275 | + $recurring, |
|
276 | + $period |
|
277 | 277 | |
278 | - ); |
|
278 | + ); |
|
279 | 279 | |
280 | - } |
|
280 | + } |
|
281 | 281 | |
282 | - return sprintf( |
|
282 | + return sprintf( |
|
283 | 283 | |
284 | - // translators: $1: is the recurring amount, $2: is the recurring period |
|
285 | - _x( '%1$s / %2$s', 'Subscription amount. (e.g.: $120 / year)', 'invoicing' ), |
|
286 | - $initial, |
|
287 | - $period |
|
284 | + // translators: $1: is the recurring amount, $2: is the recurring period |
|
285 | + _x( '%1$s / %2$s', 'Subscription amount. (e.g.: $120 / year)', 'invoicing' ), |
|
286 | + $initial, |
|
287 | + $period |
|
288 | 288 | |
289 | - ); |
|
289 | + ); |
|
290 | 290 | |
291 | 291 | } |
292 | 292 | |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | * @return WPInv_Subscription|bool |
298 | 298 | */ |
299 | 299 | function getpaid_get_invoice_subscription( $invoice ) { |
300 | - return getpaid_subscriptions()->get_invoice_subscription( $invoice ); |
|
300 | + return getpaid_subscriptions()->get_invoice_subscription( $invoice ); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | /** |
@@ -306,10 +306,10 @@ discard block |
||
306 | 306 | * @param WPInv_Invoice $invoice |
307 | 307 | */ |
308 | 308 | function getpaid_activate_invoice_subscription( $invoice ) { |
309 | - $subscription = getpaid_get_invoice_subscription( $invoice ); |
|
310 | - if ( is_a( $subscription, 'WPInv_Subscription' ) ) { |
|
311 | - $subscription->activate(); |
|
312 | - } |
|
309 | + $subscription = getpaid_get_invoice_subscription( $invoice ); |
|
310 | + if ( is_a( $subscription, 'WPInv_Subscription' ) ) { |
|
311 | + $subscription->activate(); |
|
312 | + } |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | /** |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | * @return WPInv_Subscriptions |
319 | 319 | */ |
320 | 320 | function getpaid_subscriptions() { |
321 | - return getpaid()->get( 'subscriptions' ); |
|
321 | + return getpaid()->get( 'subscriptions' ); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | /** |
@@ -336,14 +336,14 @@ discard block |
||
336 | 336 | return false; |
337 | 337 | } |
338 | 338 | |
339 | - // Fetch the invoiec subscription. |
|
340 | - $subscription = getpaid_get_subscriptions( |
|
341 | - array( |
|
342 | - 'invoice_in' => $invoice->is_renewal() ? $invoice->get_parent_id() : $invoice->get_id(), |
|
343 | - 'number' => 1, |
|
344 | - ) |
|
345 | - ); |
|
339 | + // Fetch the invoiec subscription. |
|
340 | + $subscription = getpaid_get_subscriptions( |
|
341 | + array( |
|
342 | + 'invoice_in' => $invoice->is_renewal() ? $invoice->get_parent_id() : $invoice->get_id(), |
|
343 | + 'number' => 1, |
|
344 | + ) |
|
345 | + ); |
|
346 | 346 | |
347 | - return empty( $subscription ) ? false : $subscription[0]; |
|
347 | + return empty( $subscription ) ? false : $subscription[0]; |
|
348 | 348 | |
349 | 349 | } |
@@ -15,26 +15,26 @@ discard block |
||
15 | 15 | * |
16 | 16 | * @return int|array|WPInv_Subscription[]|GetPaid_Subscriptions_Query |
17 | 17 | */ |
18 | -function getpaid_get_subscriptions( $args = array(), $return = 'results' ) { |
|
18 | +function getpaid_get_subscriptions($args = array(), $return = 'results') { |
|
19 | 19 | |
20 | 20 | // Do not retrieve all fields if we just want the count. |
21 | - if ( 'count' == $return ) { |
|
21 | + if ('count' == $return) { |
|
22 | 22 | $args['fields'] = 'id'; |
23 | 23 | $args['number'] = 1; |
24 | 24 | } |
25 | 25 | |
26 | 26 | // Do not count all matches if we just want the results. |
27 | - if ( 'results' == $return ) { |
|
27 | + if ('results' == $return) { |
|
28 | 28 | $args['count_total'] = false; |
29 | 29 | } |
30 | 30 | |
31 | - $query = new GetPaid_Subscriptions_Query( $args ); |
|
31 | + $query = new GetPaid_Subscriptions_Query($args); |
|
32 | 32 | |
33 | - if ( 'results' == $return ) { |
|
33 | + if ('results' == $return) { |
|
34 | 34 | return $query->get_results(); |
35 | 35 | } |
36 | 36 | |
37 | - if ( 'count' == $return ) { |
|
37 | + if ('count' == $return) { |
|
38 | 38 | return $query->get_total(); |
39 | 39 | } |
40 | 40 | |
@@ -51,13 +51,13 @@ discard block |
||
51 | 51 | return apply_filters( |
52 | 52 | 'getpaid_get_subscription_statuses', |
53 | 53 | array( |
54 | - 'pending' => __( 'Pending', 'invoicing' ), |
|
55 | - 'trialling' => __( 'Trialing', 'invoicing' ), |
|
56 | - 'active' => __( 'Active', 'invoicing' ), |
|
57 | - 'failing' => __( 'Failing', 'invoicing' ), |
|
58 | - 'expired' => __( 'Expired', 'invoicing' ), |
|
59 | - 'completed' => __( 'Complete', 'invoicing' ), |
|
60 | - 'cancelled' => __( 'Cancelled', 'invoicing' ), |
|
54 | + 'pending' => __('Pending', 'invoicing'), |
|
55 | + 'trialling' => __('Trialing', 'invoicing'), |
|
56 | + 'active' => __('Active', 'invoicing'), |
|
57 | + 'failing' => __('Failing', 'invoicing'), |
|
58 | + 'expired' => __('Expired', 'invoicing'), |
|
59 | + 'completed' => __('Complete', 'invoicing'), |
|
60 | + 'cancelled' => __('Cancelled', 'invoicing'), |
|
61 | 61 | ) |
62 | 62 | ); |
63 | 63 | |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | * |
69 | 69 | * @return string |
70 | 70 | */ |
71 | -function getpaid_get_subscription_status_label( $status ) { |
|
71 | +function getpaid_get_subscription_status_label($status) { |
|
72 | 72 | $statuses = getpaid_get_subscription_statuses(); |
73 | - return isset( $statuses[ $status ] ) ? $statuses[ $status ] : ucfirst( sanitize_text_field( $status ) ); |
|
73 | + return isset($statuses[$status]) ? $statuses[$status] : ucfirst(sanitize_text_field($status)); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -100,14 +100,14 @@ discard block |
||
100 | 100 | * |
101 | 101 | * @return array |
102 | 102 | */ |
103 | -function getpaid_get_subscription_status_counts( $args = array() ) { |
|
103 | +function getpaid_get_subscription_status_counts($args = array()) { |
|
104 | 104 | |
105 | - $statuses = array_keys( getpaid_get_subscription_statuses() ); |
|
105 | + $statuses = array_keys(getpaid_get_subscription_statuses()); |
|
106 | 106 | $counts = array(); |
107 | 107 | |
108 | - foreach ( $statuses as $status ) { |
|
109 | - $_args = wp_parse_args( "status=$status", $args ); |
|
110 | - $counts[ $status ] = getpaid_get_subscriptions( $_args, 'count' ); |
|
108 | + foreach ($statuses as $status) { |
|
109 | + $_args = wp_parse_args("status=$status", $args); |
|
110 | + $counts[$status] = getpaid_get_subscriptions($_args, 'count'); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | return $counts; |
@@ -126,23 +126,23 @@ discard block |
||
126 | 126 | array( |
127 | 127 | |
128 | 128 | 'day' => array( |
129 | - 'singular' => __( '%s day', 'invoicing' ), |
|
130 | - 'plural' => __( '%d days', 'invoicing' ), |
|
129 | + 'singular' => __('%s day', 'invoicing'), |
|
130 | + 'plural' => __('%d days', 'invoicing'), |
|
131 | 131 | ), |
132 | 132 | |
133 | 133 | 'week' => array( |
134 | - 'singular' => __( '%s week', 'invoicing' ), |
|
135 | - 'plural' => __( '%d weeks', 'invoicing' ), |
|
134 | + 'singular' => __('%s week', 'invoicing'), |
|
135 | + 'plural' => __('%d weeks', 'invoicing'), |
|
136 | 136 | ), |
137 | 137 | |
138 | 138 | 'month' => array( |
139 | - 'singular' => __( '%s month', 'invoicing' ), |
|
140 | - 'plural' => __( '%d months', 'invoicing' ), |
|
139 | + 'singular' => __('%s month', 'invoicing'), |
|
140 | + 'plural' => __('%d months', 'invoicing'), |
|
141 | 141 | ), |
142 | 142 | |
143 | 143 | 'year' => array( |
144 | - 'singular' => __( '%s year', 'invoicing' ), |
|
145 | - 'plural' => __( '%d years', 'invoicing' ), |
|
144 | + 'singular' => __('%s year', 'invoicing'), |
|
145 | + 'plural' => __('%d years', 'invoicing'), |
|
146 | 146 | ), |
147 | 147 | |
148 | 148 | ) |
@@ -156,8 +156,8 @@ discard block |
||
156 | 156 | * @param string $trial_period |
157 | 157 | * @return int |
158 | 158 | */ |
159 | -function getpaid_get_subscription_trial_period_interval( $trial_period ) { |
|
160 | - return (int) preg_replace( '/[^0-9]/', '', $trial_period ); |
|
159 | +function getpaid_get_subscription_trial_period_interval($trial_period) { |
|
160 | + return (int) preg_replace('/[^0-9]/', '', $trial_period); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -166,8 +166,8 @@ discard block |
||
166 | 166 | * @param string $trial_period |
167 | 167 | * @return string |
168 | 168 | */ |
169 | -function getpaid_get_subscription_trial_period_period( $trial_period ) { |
|
170 | - return preg_replace( '/[^a-z]/', '', strtolower( $trial_period ) ); |
|
169 | +function getpaid_get_subscription_trial_period_period($trial_period) { |
|
170 | + return preg_replace('/[^a-z]/', '', strtolower($trial_period)); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
@@ -177,9 +177,9 @@ discard block |
||
177 | 177 | * @param int $interval |
178 | 178 | * @return string |
179 | 179 | */ |
180 | -function getpaid_get_subscription_period_label( $period, $interval = 1, $singular_prefix = '1' ) { |
|
181 | - $label = (int) $interval > 1 ? getpaid_get_plural_subscription_period_label( $period, $interval ) : getpaid_get_singular_subscription_period_label( $period, $singular_prefix ); |
|
182 | - return strtolower( sanitize_text_field( $label ) ); |
|
180 | +function getpaid_get_subscription_period_label($period, $interval = 1, $singular_prefix = '1') { |
|
181 | + $label = (int) $interval > 1 ? getpaid_get_plural_subscription_period_label($period, $interval) : getpaid_get_singular_subscription_period_label($period, $singular_prefix); |
|
182 | + return strtolower(sanitize_text_field($label)); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | /** |
@@ -188,19 +188,19 @@ discard block |
||
188 | 188 | * @param string $period |
189 | 189 | * @return string |
190 | 190 | */ |
191 | -function getpaid_get_singular_subscription_period_label( $period, $singular_prefix = '1' ) { |
|
191 | +function getpaid_get_singular_subscription_period_label($period, $singular_prefix = '1') { |
|
192 | 192 | |
193 | 193 | $periods = getpaid_get_subscription_periods(); |
194 | - $period = strtolower( $period ); |
|
194 | + $period = strtolower($period); |
|
195 | 195 | |
196 | - if ( isset( $periods[ $period ] ) ) { |
|
197 | - return sprintf( $periods[ $period ]['singular'], $singular_prefix ); |
|
196 | + if (isset($periods[$period])) { |
|
197 | + return sprintf($periods[$period]['singular'], $singular_prefix); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | // Backwards compatibility. |
201 | - foreach ( $periods as $key => $data ) { |
|
202 | - if ( strpos( $key, $period ) === 0 ) { |
|
203 | - return sprintf( $data['singular'], $singular_prefix ); |
|
201 | + foreach ($periods as $key => $data) { |
|
202 | + if (strpos($key, $period) === 0) { |
|
203 | + return sprintf($data['singular'], $singular_prefix); |
|
204 | 204 | } |
205 | 205 | } |
206 | 206 | |
@@ -215,19 +215,19 @@ discard block |
||
215 | 215 | * @param int $interval |
216 | 216 | * @return string |
217 | 217 | */ |
218 | -function getpaid_get_plural_subscription_period_label( $period, $interval ) { |
|
218 | +function getpaid_get_plural_subscription_period_label($period, $interval) { |
|
219 | 219 | |
220 | 220 | $periods = getpaid_get_subscription_periods(); |
221 | - $period = strtolower( $period ); |
|
221 | + $period = strtolower($period); |
|
222 | 222 | |
223 | - if ( isset( $periods[ $period ] ) ) { |
|
224 | - return sprintf( $periods[ $period ]['plural'], $interval ); |
|
223 | + if (isset($periods[$period])) { |
|
224 | + return sprintf($periods[$period]['plural'], $interval); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | // Backwards compatibility. |
228 | - foreach ( $periods as $key => $data ) { |
|
229 | - if ( strpos( $key, $period ) === 0 ) { |
|
230 | - return sprintf( $data['plural'], $interval ); |
|
228 | + foreach ($periods as $key => $data) { |
|
229 | + if (strpos($key, $period) === 0) { |
|
230 | + return sprintf($data['plural'], $interval); |
|
231 | 231 | } |
232 | 232 | } |
233 | 233 | |
@@ -241,23 +241,23 @@ discard block |
||
241 | 241 | * @param WPInv_Subscription $subscription |
242 | 242 | * @return string |
243 | 243 | */ |
244 | -function getpaid_get_formatted_subscription_amount( $subscription ) { |
|
244 | +function getpaid_get_formatted_subscription_amount($subscription) { |
|
245 | 245 | |
246 | - $initial = wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
247 | - $recurring = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
248 | - $period = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ); |
|
246 | + $initial = wpinv_price($subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency()); |
|
247 | + $recurring = wpinv_price($subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency()); |
|
248 | + $period = getpaid_get_subscription_period_label($subscription->get_period(), $subscription->get_frequency(), ''); |
|
249 | 249 | |
250 | 250 | // Trial periods. |
251 | - if ( $subscription->has_trial_period() ) { |
|
251 | + if ($subscription->has_trial_period()) { |
|
252 | 252 | |
253 | - $trial_period = getpaid_get_subscription_trial_period_period( $subscription->get_trial_period() ); |
|
254 | - $trial_interval = getpaid_get_subscription_trial_period_interval( $subscription->get_trial_period() ); |
|
253 | + $trial_period = getpaid_get_subscription_trial_period_period($subscription->get_trial_period()); |
|
254 | + $trial_interval = getpaid_get_subscription_trial_period_interval($subscription->get_trial_period()); |
|
255 | 255 | return sprintf( |
256 | 256 | |
257 | 257 | // translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period |
258 | - _x( '%1$s trial for %2$s then %3$s / %4$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing' ), |
|
258 | + _x('%1$s trial for %2$s then %3$s / %4$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing'), |
|
259 | 259 | $initial, |
260 | - getpaid_get_subscription_period_label( $trial_period, $trial_interval ), |
|
260 | + getpaid_get_subscription_period_label($trial_period, $trial_interval), |
|
261 | 261 | $recurring, |
262 | 262 | $period |
263 | 263 | |
@@ -265,12 +265,12 @@ discard block |
||
265 | 265 | |
266 | 266 | } |
267 | 267 | |
268 | - if ( $initial != $recurring ) { |
|
268 | + if ($initial != $recurring) { |
|
269 | 269 | |
270 | 270 | return sprintf( |
271 | 271 | |
272 | 272 | // translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period |
273 | - _x( 'Initial payment of %1$s which renews at %2$s / %3$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year)', 'invoicing' ), |
|
273 | + _x('Initial payment of %1$s which renews at %2$s / %3$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year)', 'invoicing'), |
|
274 | 274 | $initial, |
275 | 275 | $recurring, |
276 | 276 | $period |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | return sprintf( |
283 | 283 | |
284 | 284 | // translators: $1: is the recurring amount, $2: is the recurring period |
285 | - _x( '%1$s / %2$s', 'Subscription amount. (e.g.: $120 / year)', 'invoicing' ), |
|
285 | + _x('%1$s / %2$s', 'Subscription amount. (e.g.: $120 / year)', 'invoicing'), |
|
286 | 286 | $initial, |
287 | 287 | $period |
288 | 288 | |
@@ -296,8 +296,8 @@ discard block |
||
296 | 296 | * @param WPInv_Invoice $invoice |
297 | 297 | * @return WPInv_Subscription|bool |
298 | 298 | */ |
299 | -function getpaid_get_invoice_subscription( $invoice ) { |
|
300 | - return getpaid_subscriptions()->get_invoice_subscription( $invoice ); |
|
299 | +function getpaid_get_invoice_subscription($invoice) { |
|
300 | + return getpaid_subscriptions()->get_invoice_subscription($invoice); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | /** |
@@ -305,9 +305,9 @@ discard block |
||
305 | 305 | * |
306 | 306 | * @param WPInv_Invoice $invoice |
307 | 307 | */ |
308 | -function getpaid_activate_invoice_subscription( $invoice ) { |
|
309 | - $subscription = getpaid_get_invoice_subscription( $invoice ); |
|
310 | - if ( is_a( $subscription, 'WPInv_Subscription' ) ) { |
|
308 | +function getpaid_activate_invoice_subscription($invoice) { |
|
309 | + $subscription = getpaid_get_invoice_subscription($invoice); |
|
310 | + if (is_a($subscription, 'WPInv_Subscription')) { |
|
311 | 311 | $subscription->activate(); |
312 | 312 | } |
313 | 313 | } |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | * @return WPInv_Subscriptions |
319 | 319 | */ |
320 | 320 | function getpaid_subscriptions() { |
321 | - return getpaid()->get( 'subscriptions' ); |
|
321 | + return getpaid()->get('subscriptions'); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | /** |
@@ -326,13 +326,13 @@ discard block |
||
326 | 326 | * |
327 | 327 | * @return WPInv_Subscription|bool |
328 | 328 | */ |
329 | -function wpinv_get_subscription( $invoice ) { |
|
329 | +function wpinv_get_subscription($invoice) { |
|
330 | 330 | |
331 | 331 | // Retrieve the invoice. |
332 | - $invoice = new WPInv_Invoice( $invoice ); |
|
332 | + $invoice = new WPInv_Invoice($invoice); |
|
333 | 333 | |
334 | 334 | // Ensure it is a recurring invoice. |
335 | - if ( ! $invoice->is_recurring() ) { |
|
335 | + if (!$invoice->is_recurring()) { |
|
336 | 336 | return false; |
337 | 337 | } |
338 | 338 | |
@@ -344,6 +344,6 @@ discard block |
||
344 | 344 | ) |
345 | 345 | ); |
346 | 346 | |
347 | - return empty( $subscription ) ? false : $subscription[0]; |
|
347 | + return empty($subscription) ? false : $subscription[0]; |
|
348 | 348 | |
349 | 349 | } |
@@ -13,282 +13,282 @@ |
||
13 | 13 | class GetPaid_Subscription_Notification_Emails { |
14 | 14 | |
15 | 15 | /** |
16 | - * The array of subscription email actions. |
|
17 | - * |
|
18 | - * @param array |
|
19 | - */ |
|
20 | - public $subscription_actions; |
|
16 | + * The array of subscription email actions. |
|
17 | + * |
|
18 | + * @param array |
|
19 | + */ |
|
20 | + public $subscription_actions; |
|
21 | 21 | |
22 | 22 | /** |
23 | - * Class constructor |
|
23 | + * Class constructor |
|
24 | 24 | * |
25 | - */ |
|
26 | - public function __construct() { |
|
27 | - |
|
28 | - $this->subscription_actions = apply_filters( |
|
29 | - 'getpaid_notification_email_subscription_triggers', |
|
30 | - array( |
|
31 | - 'getpaid_subscription_trialling' => 'subscription_trial', |
|
32 | - 'getpaid_subscription_cancelled' => 'subscription_cancelled', |
|
33 | - 'getpaid_subscription_expired' => 'subscription_expired', |
|
34 | - 'getpaid_subscription_completed' => 'subscription_complete', |
|
35 | - 'getpaid_daily_maintenance' => 'renewal_reminder', |
|
36 | - ) |
|
37 | - ); |
|
38 | - |
|
39 | - $this->init_hooks(); |
|
25 | + */ |
|
26 | + public function __construct() { |
|
27 | + |
|
28 | + $this->subscription_actions = apply_filters( |
|
29 | + 'getpaid_notification_email_subscription_triggers', |
|
30 | + array( |
|
31 | + 'getpaid_subscription_trialling' => 'subscription_trial', |
|
32 | + 'getpaid_subscription_cancelled' => 'subscription_cancelled', |
|
33 | + 'getpaid_subscription_expired' => 'subscription_expired', |
|
34 | + 'getpaid_subscription_completed' => 'subscription_complete', |
|
35 | + 'getpaid_daily_maintenance' => 'renewal_reminder', |
|
36 | + ) |
|
37 | + ); |
|
38 | + |
|
39 | + $this->init_hooks(); |
|
40 | 40 | |
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
44 | - * Registers email hooks. |
|
45 | - */ |
|
46 | - public function init_hooks() { |
|
47 | - |
|
48 | - add_filter( 'getpaid_get_email_merge_tags', array( $this, 'subscription_merge_tags' ), 10, 2 ); |
|
49 | - foreach ( $this->subscription_actions as $hook => $email_type ) { |
|
50 | - |
|
51 | - $email = new GetPaid_Notification_Email( $email_type ); |
|
52 | - |
|
53 | - if ( ! $email->is_active() ) { |
|
54 | - continue; |
|
55 | - } |
|
56 | - |
|
57 | - if ( method_exists( $this, $email_type ) ) { |
|
58 | - add_action( $hook, array( $this, $email_type ), 100, 2 ); |
|
59 | - continue; |
|
60 | - } |
|
61 | - |
|
62 | - do_action( 'getpaid_subscription_notification_email_register_hook', $email_type, $hook ); |
|
63 | - |
|
64 | - } |
|
65 | - |
|
66 | - } |
|
67 | - |
|
68 | - /** |
|
69 | - * Filters subscription merge tags. |
|
70 | - * |
|
71 | - * @param array $merge_tags |
|
72 | - * @param mixed|WPInv_Invoice|WPInv_Subscription $object |
|
73 | - */ |
|
74 | - public function subscription_merge_tags( $merge_tags, $object ) { |
|
75 | - |
|
76 | - if ( is_a( $object, 'WPInv_Subscription' ) ) { |
|
77 | - $merge_tags = array_merge( |
|
78 | - $merge_tags, |
|
79 | - $this->get_subscription_merge_tags( $object ) |
|
80 | - ); |
|
81 | - } |
|
82 | - |
|
83 | - return $merge_tags; |
|
84 | - |
|
85 | - } |
|
86 | - |
|
87 | - /** |
|
88 | - * Generates subscription merge tags. |
|
89 | - * |
|
90 | - * @param WPInv_Subscription $subscription |
|
91 | - * @return array |
|
92 | - */ |
|
93 | - public function get_subscription_merge_tags( $subscription ) { |
|
94 | - |
|
95 | - // Abort if it does not exist. |
|
96 | - if ( ! $subscription->get_id() ) { |
|
97 | - return array(); |
|
98 | - } |
|
99 | - |
|
100 | - $invoice = $subscription->get_parent_invoice(); |
|
101 | - return array( |
|
102 | - '{subscription_renewal_date}' => getpaid_format_date_value( $subscription->get_next_renewal_date(), __( 'Never', 'invoicing' ) ), |
|
103 | - '{subscription_created}' => getpaid_format_date_value( $subscription->get_date_created() ), |
|
104 | - '{subscription_status}' => sanitize_text_field( $subscription->get_status_label() ), |
|
105 | - '{subscription_profile_id}' => sanitize_text_field( $subscription->get_profile_id() ), |
|
106 | - '{subscription_id}' => absint( $subscription->get_id() ), |
|
107 | - '{subscription_recurring_amount}' => sanitize_text_field( wpinv_price( $subscription->get_recurring_amount(), $invoice->get_currency() ) ), |
|
108 | - '{subscription_initial_amount}' => sanitize_text_field( wpinv_price( $subscription->get_initial_amount(), $invoice->get_currency() ) ), |
|
109 | - '{subscription_recurring_period}' => getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ), |
|
110 | - '{subscription_bill_times}' => $subscription->get_bill_times(), |
|
111 | - '{subscription_url}' => esc_url( $subscription->get_view_url() ), |
|
112 | - ); |
|
113 | - |
|
114 | - } |
|
115 | - |
|
116 | - /** |
|
117 | - * Checks if we should send a notification for a subscription. |
|
118 | - * |
|
119 | - * @param WPInv_Invoice $invoice |
|
120 | - * @return bool |
|
121 | - */ |
|
122 | - public function should_send_notification( $invoice ) { |
|
123 | - return 0 != $invoice->get_id(); |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * Returns notification recipients. |
|
128 | - * |
|
129 | - * @param WPInv_Invoice $invoice |
|
130 | - * @return array |
|
131 | - */ |
|
132 | - public function get_recipients( $invoice ) { |
|
133 | - $recipients = array( $invoice->get_email() ); |
|
134 | - |
|
135 | - $cc = $invoice->get_email_cc(); |
|
136 | - |
|
137 | - if ( ! empty( $cc ) ) { |
|
138 | - $cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) ); |
|
139 | - $recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) ); |
|
140 | - } |
|
141 | - |
|
142 | - return $recipients; |
|
143 | - } |
|
144 | - |
|
145 | - /** |
|
146 | - * Helper function to send an email. |
|
147 | - * |
|
148 | - * @param WPInv_Subscription $subscription |
|
149 | - * @param GetPaid_Notification_Email $email |
|
150 | - * @param string $type |
|
151 | - * @param array $extra_args Extra template args. |
|
152 | - */ |
|
153 | - public function send_email( $subscription, $email, $type, $extra_args = array() ) { |
|
154 | - |
|
155 | - // Abort in case the parent invoice does not exist. |
|
156 | - $invoice = $subscription->get_parent_invoice(); |
|
157 | - if ( ! $this->should_send_notification( $invoice ) ) { |
|
158 | - return; |
|
159 | - } |
|
160 | - |
|
161 | - do_action( 'getpaid_before_send_subscription_notification', $type, $subscription, $email ); |
|
162 | - |
|
163 | - $recipients = $this->get_recipients( $invoice ); |
|
164 | - $mailer = new GetPaid_Notification_Email_Sender(); |
|
165 | - $merge_tags = $email->get_merge_tags(); |
|
166 | - $content = $email->get_content( $merge_tags, $extra_args ); |
|
167 | - $subject = $email->add_merge_tags( $email->get_subject(), $merge_tags ); |
|
168 | - $attachments = $email->get_attachments(); |
|
169 | - |
|
170 | - $result = $mailer->send( |
|
171 | - apply_filters( 'getpaid_subscription_email_recipients', wpinv_parse_list( $recipients ), $email ), |
|
172 | - $subject, |
|
173 | - $content, |
|
174 | - $attachments |
|
175 | - ); |
|
176 | - |
|
177 | - // Maybe send a copy to the admin. |
|
178 | - if ( $email->include_admin_bcc() ) { |
|
179 | - $mailer->send( |
|
180 | - wpinv_get_admin_email(), |
|
181 | - $subject . __( ' - ADMIN BCC COPY', 'invoicing' ), |
|
182 | - $content, |
|
183 | - $attachments |
|
184 | - ); |
|
185 | - } |
|
186 | - |
|
187 | - if ( ! $result ) { |
|
188 | - $subscription->get_parent_invoice()->add_note( sprintf( __( 'Failed sending %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true ); |
|
189 | - } |
|
190 | - |
|
191 | - do_action( 'getpaid_after_send_subscription_notification', $type, $subscription, $email ); |
|
192 | - |
|
193 | - } |
|
44 | + * Registers email hooks. |
|
45 | + */ |
|
46 | + public function init_hooks() { |
|
47 | + |
|
48 | + add_filter( 'getpaid_get_email_merge_tags', array( $this, 'subscription_merge_tags' ), 10, 2 ); |
|
49 | + foreach ( $this->subscription_actions as $hook => $email_type ) { |
|
50 | + |
|
51 | + $email = new GetPaid_Notification_Email( $email_type ); |
|
52 | + |
|
53 | + if ( ! $email->is_active() ) { |
|
54 | + continue; |
|
55 | + } |
|
56 | + |
|
57 | + if ( method_exists( $this, $email_type ) ) { |
|
58 | + add_action( $hook, array( $this, $email_type ), 100, 2 ); |
|
59 | + continue; |
|
60 | + } |
|
61 | + |
|
62 | + do_action( 'getpaid_subscription_notification_email_register_hook', $email_type, $hook ); |
|
63 | + |
|
64 | + } |
|
65 | + |
|
66 | + } |
|
194 | 67 | |
195 | 68 | /** |
196 | - * Sends a new trial notification. |
|
197 | - * |
|
198 | - * @param WPInv_Subscription $subscription |
|
199 | - */ |
|
200 | - public function subscription_trial( $subscription ) { |
|
69 | + * Filters subscription merge tags. |
|
70 | + * |
|
71 | + * @param array $merge_tags |
|
72 | + * @param mixed|WPInv_Invoice|WPInv_Subscription $object |
|
73 | + */ |
|
74 | + public function subscription_merge_tags( $merge_tags, $object ) { |
|
201 | 75 | |
202 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $subscription ); |
|
203 | - $this->send_email( $subscription, $email, __FUNCTION__ ); |
|
76 | + if ( is_a( $object, 'WPInv_Subscription' ) ) { |
|
77 | + $merge_tags = array_merge( |
|
78 | + $merge_tags, |
|
79 | + $this->get_subscription_merge_tags( $object ) |
|
80 | + ); |
|
81 | + } |
|
204 | 82 | |
205 | - } |
|
83 | + return $merge_tags; |
|
206 | 84 | |
207 | - /** |
|
208 | - * Sends a cancelled subscription notification. |
|
209 | - * |
|
210 | - * @param WPInv_Subscription $subscription |
|
211 | - */ |
|
212 | - public function subscription_cancelled( $subscription ) { |
|
85 | + } |
|
213 | 86 | |
214 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $subscription ); |
|
215 | - $this->send_email( $subscription, $email, __FUNCTION__ ); |
|
87 | + /** |
|
88 | + * Generates subscription merge tags. |
|
89 | + * |
|
90 | + * @param WPInv_Subscription $subscription |
|
91 | + * @return array |
|
92 | + */ |
|
93 | + public function get_subscription_merge_tags( $subscription ) { |
|
94 | + |
|
95 | + // Abort if it does not exist. |
|
96 | + if ( ! $subscription->get_id() ) { |
|
97 | + return array(); |
|
98 | + } |
|
99 | + |
|
100 | + $invoice = $subscription->get_parent_invoice(); |
|
101 | + return array( |
|
102 | + '{subscription_renewal_date}' => getpaid_format_date_value( $subscription->get_next_renewal_date(), __( 'Never', 'invoicing' ) ), |
|
103 | + '{subscription_created}' => getpaid_format_date_value( $subscription->get_date_created() ), |
|
104 | + '{subscription_status}' => sanitize_text_field( $subscription->get_status_label() ), |
|
105 | + '{subscription_profile_id}' => sanitize_text_field( $subscription->get_profile_id() ), |
|
106 | + '{subscription_id}' => absint( $subscription->get_id() ), |
|
107 | + '{subscription_recurring_amount}' => sanitize_text_field( wpinv_price( $subscription->get_recurring_amount(), $invoice->get_currency() ) ), |
|
108 | + '{subscription_initial_amount}' => sanitize_text_field( wpinv_price( $subscription->get_initial_amount(), $invoice->get_currency() ) ), |
|
109 | + '{subscription_recurring_period}' => getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ), |
|
110 | + '{subscription_bill_times}' => $subscription->get_bill_times(), |
|
111 | + '{subscription_url}' => esc_url( $subscription->get_view_url() ), |
|
112 | + ); |
|
216 | 113 | |
217 | - } |
|
114 | + } |
|
218 | 115 | |
219 | - /** |
|
220 | - * Sends a subscription expired notification. |
|
221 | - * |
|
222 | - * @param WPInv_Subscription $subscription |
|
223 | - */ |
|
224 | - public function subscription_expired( $subscription ) { |
|
116 | + /** |
|
117 | + * Checks if we should send a notification for a subscription. |
|
118 | + * |
|
119 | + * @param WPInv_Invoice $invoice |
|
120 | + * @return bool |
|
121 | + */ |
|
122 | + public function should_send_notification( $invoice ) { |
|
123 | + return 0 != $invoice->get_id(); |
|
124 | + } |
|
225 | 125 | |
226 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $subscription ); |
|
227 | - $this->send_email( $subscription, $email, __FUNCTION__ ); |
|
126 | + /** |
|
127 | + * Returns notification recipients. |
|
128 | + * |
|
129 | + * @param WPInv_Invoice $invoice |
|
130 | + * @return array |
|
131 | + */ |
|
132 | + public function get_recipients( $invoice ) { |
|
133 | + $recipients = array( $invoice->get_email() ); |
|
228 | 134 | |
229 | - } |
|
135 | + $cc = $invoice->get_email_cc(); |
|
230 | 136 | |
231 | - /** |
|
232 | - * Sends a completed subscription notification. |
|
233 | - * |
|
234 | - * @param WPInv_Subscription $subscription |
|
235 | - */ |
|
236 | - public function subscription_complete( $subscription ) { |
|
137 | + if ( ! empty( $cc ) ) { |
|
138 | + $cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) ); |
|
139 | + $recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) ); |
|
140 | + } |
|
237 | 141 | |
238 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $subscription ); |
|
239 | - $this->send_email( $subscription, $email, __FUNCTION__ ); |
|
142 | + return $recipients; |
|
143 | + } |
|
240 | 144 | |
241 | - } |
|
145 | + /** |
|
146 | + * Helper function to send an email. |
|
147 | + * |
|
148 | + * @param WPInv_Subscription $subscription |
|
149 | + * @param GetPaid_Notification_Email $email |
|
150 | + * @param string $type |
|
151 | + * @param array $extra_args Extra template args. |
|
152 | + */ |
|
153 | + public function send_email( $subscription, $email, $type, $extra_args = array() ) { |
|
154 | + |
|
155 | + // Abort in case the parent invoice does not exist. |
|
156 | + $invoice = $subscription->get_parent_invoice(); |
|
157 | + if ( ! $this->should_send_notification( $invoice ) ) { |
|
158 | + return; |
|
159 | + } |
|
160 | + |
|
161 | + do_action( 'getpaid_before_send_subscription_notification', $type, $subscription, $email ); |
|
162 | + |
|
163 | + $recipients = $this->get_recipients( $invoice ); |
|
164 | + $mailer = new GetPaid_Notification_Email_Sender(); |
|
165 | + $merge_tags = $email->get_merge_tags(); |
|
166 | + $content = $email->get_content( $merge_tags, $extra_args ); |
|
167 | + $subject = $email->add_merge_tags( $email->get_subject(), $merge_tags ); |
|
168 | + $attachments = $email->get_attachments(); |
|
169 | + |
|
170 | + $result = $mailer->send( |
|
171 | + apply_filters( 'getpaid_subscription_email_recipients', wpinv_parse_list( $recipients ), $email ), |
|
172 | + $subject, |
|
173 | + $content, |
|
174 | + $attachments |
|
175 | + ); |
|
176 | + |
|
177 | + // Maybe send a copy to the admin. |
|
178 | + if ( $email->include_admin_bcc() ) { |
|
179 | + $mailer->send( |
|
180 | + wpinv_get_admin_email(), |
|
181 | + $subject . __( ' - ADMIN BCC COPY', 'invoicing' ), |
|
182 | + $content, |
|
183 | + $attachments |
|
184 | + ); |
|
185 | + } |
|
186 | + |
|
187 | + if ( ! $result ) { |
|
188 | + $subscription->get_parent_invoice()->add_note( sprintf( __( 'Failed sending %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true ); |
|
189 | + } |
|
190 | + |
|
191 | + do_action( 'getpaid_after_send_subscription_notification', $type, $subscription, $email ); |
|
242 | 192 | |
243 | - /** |
|
244 | - * Sends a subscription renewal reminder notification. |
|
245 | - * |
|
246 | - */ |
|
247 | - public function renewal_reminder() { |
|
193 | + } |
|
248 | 194 | |
249 | - $email = new GetPaid_Notification_Email( __FUNCTION__ ); |
|
195 | + /** |
|
196 | + * Sends a new trial notification. |
|
197 | + * |
|
198 | + * @param WPInv_Subscription $subscription |
|
199 | + */ |
|
200 | + public function subscription_trial( $subscription ) { |
|
250 | 201 | |
251 | - // Fetch reminder days. |
|
252 | - $reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) ); |
|
202 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $subscription ); |
|
203 | + $this->send_email( $subscription, $email, __FUNCTION__ ); |
|
253 | 204 | |
254 | - // Abort if non is set. |
|
255 | - if ( empty( $reminder_days ) ) { |
|
256 | - return; |
|
257 | - } |
|
205 | + } |
|
258 | 206 | |
259 | - // Fetch matching subscriptions. |
|
207 | + /** |
|
208 | + * Sends a cancelled subscription notification. |
|
209 | + * |
|
210 | + * @param WPInv_Subscription $subscription |
|
211 | + */ |
|
212 | + public function subscription_cancelled( $subscription ) { |
|
213 | + |
|
214 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $subscription ); |
|
215 | + $this->send_email( $subscription, $email, __FUNCTION__ ); |
|
216 | + |
|
217 | + } |
|
218 | + |
|
219 | + /** |
|
220 | + * Sends a subscription expired notification. |
|
221 | + * |
|
222 | + * @param WPInv_Subscription $subscription |
|
223 | + */ |
|
224 | + public function subscription_expired( $subscription ) { |
|
225 | + |
|
226 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $subscription ); |
|
227 | + $this->send_email( $subscription, $email, __FUNCTION__ ); |
|
228 | + |
|
229 | + } |
|
230 | + |
|
231 | + /** |
|
232 | + * Sends a completed subscription notification. |
|
233 | + * |
|
234 | + * @param WPInv_Subscription $subscription |
|
235 | + */ |
|
236 | + public function subscription_complete( $subscription ) { |
|
237 | + |
|
238 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $subscription ); |
|
239 | + $this->send_email( $subscription, $email, __FUNCTION__ ); |
|
240 | + |
|
241 | + } |
|
242 | + |
|
243 | + /** |
|
244 | + * Sends a subscription renewal reminder notification. |
|
245 | + * |
|
246 | + */ |
|
247 | + public function renewal_reminder() { |
|
248 | + |
|
249 | + $email = new GetPaid_Notification_Email( __FUNCTION__ ); |
|
250 | + |
|
251 | + // Fetch reminder days. |
|
252 | + $reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) ); |
|
253 | + |
|
254 | + // Abort if non is set. |
|
255 | + if ( empty( $reminder_days ) ) { |
|
256 | + return; |
|
257 | + } |
|
258 | + |
|
259 | + // Fetch matching subscriptions. |
|
260 | 260 | $args = array( |
261 | 261 | 'number' => -1, |
262 | - 'count_total' => false, |
|
263 | - 'status' => 'trialling active', |
|
262 | + 'count_total' => false, |
|
263 | + 'status' => 'trialling active', |
|
264 | 264 | 'date_expires_query' => array( |
265 | - 'relation' => 'OR' |
|
265 | + 'relation' => 'OR' |
|
266 | 266 | ), |
267 | - ); |
|
267 | + ); |
|
268 | 268 | |
269 | - foreach ( $reminder_days as $days ) { |
|
270 | - $date = date_parse( date( 'Y-m-d', strtotime( "+$days days", current_time( 'timestamp' ) ) ) ); |
|
269 | + foreach ( $reminder_days as $days ) { |
|
270 | + $date = date_parse( date( 'Y-m-d', strtotime( "+$days days", current_time( 'timestamp' ) ) ) ); |
|
271 | 271 | |
272 | - $args['date_expires_query'][] = array( |
|
273 | - 'year' => $date['year'], |
|
274 | - 'month' => $date['month'], |
|
275 | - 'day' => $date['day'], |
|
276 | - ); |
|
272 | + $args['date_expires_query'][] = array( |
|
273 | + 'year' => $date['year'], |
|
274 | + 'month' => $date['month'], |
|
275 | + 'day' => $date['day'], |
|
276 | + ); |
|
277 | 277 | |
278 | - } |
|
278 | + } |
|
279 | 279 | |
280 | - $subscriptions = new GetPaid_Subscriptions_Query( $args ); |
|
280 | + $subscriptions = new GetPaid_Subscriptions_Query( $args ); |
|
281 | 281 | |
282 | 282 | foreach ( $subscriptions as $subscription ) { |
283 | 283 | |
284 | - // Skip packages. |
|
285 | - if ( get_post_meta( $subscription->get_product_id(), '_wpinv_type', true ) != 'package' ) { |
|
286 | - $email->object = $subscription; |
|
287 | - $this->send_email( $subscription, $email, __FUNCTION__ ); |
|
288 | - } |
|
284 | + // Skip packages. |
|
285 | + if ( get_post_meta( $subscription->get_product_id(), '_wpinv_type', true ) != 'package' ) { |
|
286 | + $email->object = $subscription; |
|
287 | + $this->send_email( $subscription, $email, __FUNCTION__ ); |
|
288 | + } |
|
289 | 289 | |
290 | - } |
|
290 | + } |
|
291 | 291 | |
292 | - } |
|
292 | + } |
|
293 | 293 | |
294 | 294 | } |
@@ -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 | * This class handles subscription notificaiton emails. |
@@ -45,21 +45,21 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function init_hooks() { |
47 | 47 | |
48 | - add_filter( 'getpaid_get_email_merge_tags', array( $this, 'subscription_merge_tags' ), 10, 2 ); |
|
49 | - foreach ( $this->subscription_actions as $hook => $email_type ) { |
|
48 | + add_filter('getpaid_get_email_merge_tags', array($this, 'subscription_merge_tags'), 10, 2); |
|
49 | + foreach ($this->subscription_actions as $hook => $email_type) { |
|
50 | 50 | |
51 | - $email = new GetPaid_Notification_Email( $email_type ); |
|
51 | + $email = new GetPaid_Notification_Email($email_type); |
|
52 | 52 | |
53 | - if ( ! $email->is_active() ) { |
|
53 | + if (!$email->is_active()) { |
|
54 | 54 | continue; |
55 | 55 | } |
56 | 56 | |
57 | - if ( method_exists( $this, $email_type ) ) { |
|
58 | - add_action( $hook, array( $this, $email_type ), 100, 2 ); |
|
57 | + if (method_exists($this, $email_type)) { |
|
58 | + add_action($hook, array($this, $email_type), 100, 2); |
|
59 | 59 | continue; |
60 | 60 | } |
61 | 61 | |
62 | - do_action( 'getpaid_subscription_notification_email_register_hook', $email_type, $hook ); |
|
62 | + do_action('getpaid_subscription_notification_email_register_hook', $email_type, $hook); |
|
63 | 63 | |
64 | 64 | } |
65 | 65 | |
@@ -71,12 +71,12 @@ discard block |
||
71 | 71 | * @param array $merge_tags |
72 | 72 | * @param mixed|WPInv_Invoice|WPInv_Subscription $object |
73 | 73 | */ |
74 | - public function subscription_merge_tags( $merge_tags, $object ) { |
|
74 | + public function subscription_merge_tags($merge_tags, $object) { |
|
75 | 75 | |
76 | - if ( is_a( $object, 'WPInv_Subscription' ) ) { |
|
76 | + if (is_a($object, 'WPInv_Subscription')) { |
|
77 | 77 | $merge_tags = array_merge( |
78 | 78 | $merge_tags, |
79 | - $this->get_subscription_merge_tags( $object ) |
|
79 | + $this->get_subscription_merge_tags($object) |
|
80 | 80 | ); |
81 | 81 | } |
82 | 82 | |
@@ -90,25 +90,25 @@ discard block |
||
90 | 90 | * @param WPInv_Subscription $subscription |
91 | 91 | * @return array |
92 | 92 | */ |
93 | - public function get_subscription_merge_tags( $subscription ) { |
|
93 | + public function get_subscription_merge_tags($subscription) { |
|
94 | 94 | |
95 | 95 | // Abort if it does not exist. |
96 | - if ( ! $subscription->get_id() ) { |
|
96 | + if (!$subscription->get_id()) { |
|
97 | 97 | return array(); |
98 | 98 | } |
99 | 99 | |
100 | - $invoice = $subscription->get_parent_invoice(); |
|
100 | + $invoice = $subscription->get_parent_invoice(); |
|
101 | 101 | return array( |
102 | - '{subscription_renewal_date}' => getpaid_format_date_value( $subscription->get_next_renewal_date(), __( 'Never', 'invoicing' ) ), |
|
103 | - '{subscription_created}' => getpaid_format_date_value( $subscription->get_date_created() ), |
|
104 | - '{subscription_status}' => sanitize_text_field( $subscription->get_status_label() ), |
|
105 | - '{subscription_profile_id}' => sanitize_text_field( $subscription->get_profile_id() ), |
|
106 | - '{subscription_id}' => absint( $subscription->get_id() ), |
|
107 | - '{subscription_recurring_amount}' => sanitize_text_field( wpinv_price( $subscription->get_recurring_amount(), $invoice->get_currency() ) ), |
|
108 | - '{subscription_initial_amount}' => sanitize_text_field( wpinv_price( $subscription->get_initial_amount(), $invoice->get_currency() ) ), |
|
109 | - '{subscription_recurring_period}' => getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ), |
|
102 | + '{subscription_renewal_date}' => getpaid_format_date_value($subscription->get_next_renewal_date(), __('Never', 'invoicing')), |
|
103 | + '{subscription_created}' => getpaid_format_date_value($subscription->get_date_created()), |
|
104 | + '{subscription_status}' => sanitize_text_field($subscription->get_status_label()), |
|
105 | + '{subscription_profile_id}' => sanitize_text_field($subscription->get_profile_id()), |
|
106 | + '{subscription_id}' => absint($subscription->get_id()), |
|
107 | + '{subscription_recurring_amount}' => sanitize_text_field(wpinv_price($subscription->get_recurring_amount(), $invoice->get_currency())), |
|
108 | + '{subscription_initial_amount}' => sanitize_text_field(wpinv_price($subscription->get_initial_amount(), $invoice->get_currency())), |
|
109 | + '{subscription_recurring_period}' => getpaid_get_subscription_period_label($subscription->get_period(), $subscription->get_frequency(), ''), |
|
110 | 110 | '{subscription_bill_times}' => $subscription->get_bill_times(), |
111 | - '{subscription_url}' => esc_url( $subscription->get_view_url() ), |
|
111 | + '{subscription_url}' => esc_url($subscription->get_view_url()), |
|
112 | 112 | ); |
113 | 113 | |
114 | 114 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * @param WPInv_Invoice $invoice |
120 | 120 | * @return bool |
121 | 121 | */ |
122 | - public function should_send_notification( $invoice ) { |
|
122 | + public function should_send_notification($invoice) { |
|
123 | 123 | return 0 != $invoice->get_id(); |
124 | 124 | } |
125 | 125 | |
@@ -129,14 +129,14 @@ discard block |
||
129 | 129 | * @param WPInv_Invoice $invoice |
130 | 130 | * @return array |
131 | 131 | */ |
132 | - public function get_recipients( $invoice ) { |
|
133 | - $recipients = array( $invoice->get_email() ); |
|
132 | + public function get_recipients($invoice) { |
|
133 | + $recipients = array($invoice->get_email()); |
|
134 | 134 | |
135 | 135 | $cc = $invoice->get_email_cc(); |
136 | 136 | |
137 | - if ( ! empty( $cc ) ) { |
|
138 | - $cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) ); |
|
139 | - $recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) ); |
|
137 | + if (!empty($cc)) { |
|
138 | + $cc = array_map('sanitize_email', wpinv_parse_list($cc)); |
|
139 | + $recipients = array_filter(array_unique(array_merge($recipients, $cc))); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | return $recipients; |
@@ -150,45 +150,45 @@ discard block |
||
150 | 150 | * @param string $type |
151 | 151 | * @param array $extra_args Extra template args. |
152 | 152 | */ |
153 | - public function send_email( $subscription, $email, $type, $extra_args = array() ) { |
|
153 | + public function send_email($subscription, $email, $type, $extra_args = array()) { |
|
154 | 154 | |
155 | 155 | // Abort in case the parent invoice does not exist. |
156 | 156 | $invoice = $subscription->get_parent_invoice(); |
157 | - if ( ! $this->should_send_notification( $invoice ) ) { |
|
157 | + if (!$this->should_send_notification($invoice)) { |
|
158 | 158 | return; |
159 | 159 | } |
160 | 160 | |
161 | - do_action( 'getpaid_before_send_subscription_notification', $type, $subscription, $email ); |
|
161 | + do_action('getpaid_before_send_subscription_notification', $type, $subscription, $email); |
|
162 | 162 | |
163 | - $recipients = $this->get_recipients( $invoice ); |
|
163 | + $recipients = $this->get_recipients($invoice); |
|
164 | 164 | $mailer = new GetPaid_Notification_Email_Sender(); |
165 | 165 | $merge_tags = $email->get_merge_tags(); |
166 | - $content = $email->get_content( $merge_tags, $extra_args ); |
|
167 | - $subject = $email->add_merge_tags( $email->get_subject(), $merge_tags ); |
|
166 | + $content = $email->get_content($merge_tags, $extra_args); |
|
167 | + $subject = $email->add_merge_tags($email->get_subject(), $merge_tags); |
|
168 | 168 | $attachments = $email->get_attachments(); |
169 | 169 | |
170 | 170 | $result = $mailer->send( |
171 | - apply_filters( 'getpaid_subscription_email_recipients', wpinv_parse_list( $recipients ), $email ), |
|
171 | + apply_filters('getpaid_subscription_email_recipients', wpinv_parse_list($recipients), $email), |
|
172 | 172 | $subject, |
173 | 173 | $content, |
174 | 174 | $attachments |
175 | 175 | ); |
176 | 176 | |
177 | 177 | // Maybe send a copy to the admin. |
178 | - if ( $email->include_admin_bcc() ) { |
|
178 | + if ($email->include_admin_bcc()) { |
|
179 | 179 | $mailer->send( |
180 | 180 | wpinv_get_admin_email(), |
181 | - $subject . __( ' - ADMIN BCC COPY', 'invoicing' ), |
|
181 | + $subject . __(' - ADMIN BCC COPY', 'invoicing'), |
|
182 | 182 | $content, |
183 | 183 | $attachments |
184 | 184 | ); |
185 | 185 | } |
186 | 186 | |
187 | - if ( ! $result ) { |
|
188 | - $subscription->get_parent_invoice()->add_note( sprintf( __( 'Failed sending %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true ); |
|
187 | + if (!$result) { |
|
188 | + $subscription->get_parent_invoice()->add_note(sprintf(__('Failed sending %s notification email.', 'invoicing'), sanitize_key($type)), false, false, true); |
|
189 | 189 | } |
190 | 190 | |
191 | - do_action( 'getpaid_after_send_subscription_notification', $type, $subscription, $email ); |
|
191 | + do_action('getpaid_after_send_subscription_notification', $type, $subscription, $email); |
|
192 | 192 | |
193 | 193 | } |
194 | 194 | |
@@ -197,10 +197,10 @@ discard block |
||
197 | 197 | * |
198 | 198 | * @param WPInv_Subscription $subscription |
199 | 199 | */ |
200 | - public function subscription_trial( $subscription ) { |
|
200 | + public function subscription_trial($subscription) { |
|
201 | 201 | |
202 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $subscription ); |
|
203 | - $this->send_email( $subscription, $email, __FUNCTION__ ); |
|
202 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $subscription); |
|
203 | + $this->send_email($subscription, $email, __FUNCTION__); |
|
204 | 204 | |
205 | 205 | } |
206 | 206 | |
@@ -209,10 +209,10 @@ discard block |
||
209 | 209 | * |
210 | 210 | * @param WPInv_Subscription $subscription |
211 | 211 | */ |
212 | - public function subscription_cancelled( $subscription ) { |
|
212 | + public function subscription_cancelled($subscription) { |
|
213 | 213 | |
214 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $subscription ); |
|
215 | - $this->send_email( $subscription, $email, __FUNCTION__ ); |
|
214 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $subscription); |
|
215 | + $this->send_email($subscription, $email, __FUNCTION__); |
|
216 | 216 | |
217 | 217 | } |
218 | 218 | |
@@ -221,10 +221,10 @@ discard block |
||
221 | 221 | * |
222 | 222 | * @param WPInv_Subscription $subscription |
223 | 223 | */ |
224 | - public function subscription_expired( $subscription ) { |
|
224 | + public function subscription_expired($subscription) { |
|
225 | 225 | |
226 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $subscription ); |
|
227 | - $this->send_email( $subscription, $email, __FUNCTION__ ); |
|
226 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $subscription); |
|
227 | + $this->send_email($subscription, $email, __FUNCTION__); |
|
228 | 228 | |
229 | 229 | } |
230 | 230 | |
@@ -233,10 +233,10 @@ discard block |
||
233 | 233 | * |
234 | 234 | * @param WPInv_Subscription $subscription |
235 | 235 | */ |
236 | - public function subscription_complete( $subscription ) { |
|
236 | + public function subscription_complete($subscription) { |
|
237 | 237 | |
238 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $subscription ); |
|
239 | - $this->send_email( $subscription, $email, __FUNCTION__ ); |
|
238 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $subscription); |
|
239 | + $this->send_email($subscription, $email, __FUNCTION__); |
|
240 | 240 | |
241 | 241 | } |
242 | 242 | |
@@ -246,18 +246,18 @@ discard block |
||
246 | 246 | */ |
247 | 247 | public function renewal_reminder() { |
248 | 248 | |
249 | - $email = new GetPaid_Notification_Email( __FUNCTION__ ); |
|
249 | + $email = new GetPaid_Notification_Email(__FUNCTION__); |
|
250 | 250 | |
251 | 251 | // Fetch reminder days. |
252 | - $reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) ); |
|
252 | + $reminder_days = array_unique(wp_parse_id_list($email->get_option('days'))); |
|
253 | 253 | |
254 | 254 | // Abort if non is set. |
255 | - if ( empty( $reminder_days ) ) { |
|
255 | + if (empty($reminder_days)) { |
|
256 | 256 | return; |
257 | 257 | } |
258 | 258 | |
259 | 259 | // Fetch matching subscriptions. |
260 | - $args = array( |
|
260 | + $args = array( |
|
261 | 261 | 'number' => -1, |
262 | 262 | 'count_total' => false, |
263 | 263 | 'status' => 'trialling active', |
@@ -266,8 +266,8 @@ discard block |
||
266 | 266 | ), |
267 | 267 | ); |
268 | 268 | |
269 | - foreach ( $reminder_days as $days ) { |
|
270 | - $date = date_parse( date( 'Y-m-d', strtotime( "+$days days", current_time( 'timestamp' ) ) ) ); |
|
269 | + foreach ($reminder_days as $days) { |
|
270 | + $date = date_parse(date('Y-m-d', strtotime("+$days days", current_time('timestamp')))); |
|
271 | 271 | |
272 | 272 | $args['date_expires_query'][] = array( |
273 | 273 | 'year' => $date['year'], |
@@ -277,14 +277,14 @@ discard block |
||
277 | 277 | |
278 | 278 | } |
279 | 279 | |
280 | - $subscriptions = new GetPaid_Subscriptions_Query( $args ); |
|
280 | + $subscriptions = new GetPaid_Subscriptions_Query($args); |
|
281 | 281 | |
282 | - foreach ( $subscriptions as $subscription ) { |
|
282 | + foreach ($subscriptions as $subscription) { |
|
283 | 283 | |
284 | 284 | // Skip packages. |
285 | - if ( get_post_meta( $subscription->get_product_id(), '_wpinv_type', true ) != 'package' ) { |
|
285 | + if (get_post_meta($subscription->get_product_id(), '_wpinv_type', true) != 'package') { |
|
286 | 286 | $email->object = $subscription; |
287 | - $this->send_email( $subscription, $email, __FUNCTION__ ); |
|
287 | + $this->send_email($subscription, $email, __FUNCTION__); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | } |
@@ -8,18 +8,18 @@ discard block |
||
8 | 8 | * @var WPInv_Invoice $invoice |
9 | 9 | */ |
10 | 10 | |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | -$column_count = count( $columns ); |
|
13 | +$column_count = count($columns); |
|
14 | 14 | ?> |
15 | 15 | |
16 | -<?php do_action( 'wpinv_before_email_items', $invoice ); ?> |
|
16 | +<?php do_action('wpinv_before_email_items', $invoice); ?> |
|
17 | 17 | |
18 | 18 | |
19 | 19 | <div id="wpinv-email-items"> |
20 | 20 | |
21 | 21 | <h3 class="invoice-items-title"> |
22 | - <?php echo sprintf( esc_html__( '%s Items', 'invoicing' ), ucfirst( $invoice->get_invoice_quote_type() )); ?> |
|
22 | + <?php echo sprintf(esc_html__('%s Items', 'invoicing'), ucfirst($invoice->get_invoice_quote_type())); ?> |
|
23 | 23 | </h3> |
24 | 24 | |
25 | 25 | <table class="table table-bordered table-hover"> |
@@ -28,9 +28,9 @@ discard block |
||
28 | 28 | |
29 | 29 | <tr class="wpinv_cart_header_row"> |
30 | 30 | |
31 | - <?php foreach ( $columns as $key => $label ) : ?> |
|
32 | - <th class="<?php echo 'name' == $key ? 'text-left' : 'text-right' ?> wpinv_cart_item_<?php echo sanitize_html_class( $key ); ?>"> |
|
33 | - <?php echo sanitize_text_field( $label ); ?> |
|
31 | + <?php foreach ($columns as $key => $label) : ?> |
|
32 | + <th class="<?php echo 'name' == $key ? 'text-left' : 'text-right' ?> wpinv_cart_item_<?php echo sanitize_html_class($key); ?>"> |
|
33 | + <?php echo sanitize_text_field($label); ?> |
|
34 | 34 | </th> |
35 | 35 | <?php endforeach; ?> |
36 | 36 | |
@@ -43,13 +43,13 @@ discard block |
||
43 | 43 | <?php |
44 | 44 | |
45 | 45 | // Display the item totals. |
46 | - foreach ( $invoice->get_items() as $item ) { |
|
47 | - wpinv_get_template( 'emails/invoice-item.php', compact( 'invoice', 'item', 'columns' ) ); |
|
46 | + foreach ($invoice->get_items() as $item) { |
|
47 | + wpinv_get_template('emails/invoice-item.php', compact('invoice', 'item', 'columns')); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | // Display the fee totals. |
51 | - foreach ( $invoice->get_fees() as $fee ) { |
|
52 | - wpinv_get_template( 'emails/fee-item.php', compact( 'invoice', 'fee', 'columns' ) ); |
|
51 | + foreach ($invoice->get_fees() as $fee) { |
|
52 | + wpinv_get_template('emails/fee-item.php', compact('invoice', 'fee', 'columns')); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | ?> |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | </tbody> |
58 | 58 | |
59 | 59 | <tfoot> |
60 | - <?php wpinv_get_template( 'emails/invoice-totals.php', compact( 'invoice', 'column_count' ) ); ?> |
|
60 | + <?php wpinv_get_template('emails/invoice-totals.php', compact('invoice', 'column_count')); ?> |
|
61 | 61 | </tfoot> |
62 | 62 | |
63 | 63 | </table> |