@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | if ( ! defined( 'ABSPATH' ) ) { |
11 | - exit; // Exit if accessed directly |
|
11 | + exit; // Exit if accessed directly |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | /** |
@@ -17,10 +17,10 @@ discard block |
||
17 | 17 | class GetPaid_Meta_Box_Invoice_Payment_Meta { |
18 | 18 | |
19 | 19 | /** |
20 | - * Output the metabox. |
|
21 | - * |
|
22 | - * @param WP_Post $post |
|
23 | - */ |
|
20 | + * Output the metabox. |
|
21 | + * |
|
22 | + * @param WP_Post $post |
|
23 | + */ |
|
24 | 24 | public static function output( $post ) { |
25 | 25 | |
26 | 26 | // Prepare the invoice. |
@@ -42,155 +42,155 @@ discard block |
||
42 | 42 | |
43 | 43 | if ( $invoice->is_draft() ) { |
44 | 44 | |
45 | - // Set gateway. |
|
46 | - echo aui()->select( |
|
45 | + // Set gateway. |
|
46 | + echo aui()->select( |
|
47 | 47 | array( |
48 | - 'id' => 'wpinv_gateway', |
|
49 | - 'name' => 'wpinv_gateway', |
|
50 | - 'label' => __( 'Gateway:', 'invoicing' ), |
|
51 | - 'label_type' => 'vertical', |
|
52 | - 'placeholder' => __( 'Select Gateway', 'invoicing' ), |
|
53 | - 'value' => wpinv_get_default_gateway(), |
|
54 | - 'select2' => true, |
|
55 | - 'data-allow-clear' => 'false', |
|
56 | - 'options' => wp_list_pluck( wpinv_get_enabled_payment_gateways( true ), 'admin_label' ), |
|
48 | + 'id' => 'wpinv_gateway', |
|
49 | + 'name' => 'wpinv_gateway', |
|
50 | + 'label' => __( 'Gateway:', 'invoicing' ), |
|
51 | + 'label_type' => 'vertical', |
|
52 | + 'placeholder' => __( 'Select Gateway', 'invoicing' ), |
|
53 | + 'value' => wpinv_get_default_gateway(), |
|
54 | + 'select2' => true, |
|
55 | + 'data-allow-clear' => 'false', |
|
56 | + 'options' => wp_list_pluck( wpinv_get_enabled_payment_gateways( true ), 'admin_label' ), |
|
57 | 57 | ) |
58 | 58 | ); |
59 | 59 | |
60 | 60 | } else { |
61 | - // Invoice key. |
|
62 | - echo aui()->input( |
|
61 | + // Invoice key. |
|
62 | + echo aui()->input( |
|
63 | 63 | array( |
64 | - 'type' => 'text', |
|
65 | - 'id' => 'wpinv_key', |
|
66 | - 'name' => 'wpinv_key', |
|
67 | - 'label' => sprintf( |
|
64 | + 'type' => 'text', |
|
65 | + 'id' => 'wpinv_key', |
|
66 | + 'name' => 'wpinv_key', |
|
67 | + 'label' => sprintf( |
|
68 | 68 | __( '%s Key:', 'invoicing' ), |
69 | 69 | ucfirst( $invoice->get_invoice_quote_type() ) |
70 | - ), |
|
71 | - 'label_type' => 'vertical', |
|
72 | - 'class' => 'form-control-sm', |
|
73 | - 'value' => $invoice->get_key( 'edit' ), |
|
74 | - 'extra_attributes' => array( |
|
70 | + ), |
|
71 | + 'label_type' => 'vertical', |
|
72 | + 'class' => 'form-control-sm', |
|
73 | + 'value' => $invoice->get_key( 'edit' ), |
|
74 | + 'extra_attributes' => array( |
|
75 | 75 | 'onclick' => 'this.select();', |
76 | 76 | 'readonly' => 'true', |
77 | - ), |
|
77 | + ), |
|
78 | 78 | ) |
79 | - ); |
|
79 | + ); |
|
80 | 80 | |
81 | - // View URL. |
|
82 | - echo aui()->input( |
|
81 | + // View URL. |
|
82 | + echo aui()->input( |
|
83 | 83 | array( |
84 | - 'type' => 'text', |
|
85 | - 'id' => 'wpinv_view_url', |
|
86 | - 'name' => 'wpinv_view_url', |
|
87 | - 'label' => sprintf( |
|
84 | + 'type' => 'text', |
|
85 | + 'id' => 'wpinv_view_url', |
|
86 | + 'name' => 'wpinv_view_url', |
|
87 | + 'label' => sprintf( |
|
88 | 88 | __( '%s URL:', 'invoicing' ), |
89 | 89 | ucfirst( $invoice->get_invoice_quote_type() ) |
90 | - ) . ' <a href="' . esc_url_raw( $invoice->get_view_url() ) . '" title="' . __( 'View invoice', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>', |
|
91 | - 'label_type' => 'vertical', |
|
92 | - 'class' => 'form-control-sm', |
|
93 | - 'value' => $invoice->get_view_url(), |
|
94 | - 'extra_attributes' => array( |
|
90 | + ) . ' <a href="' . esc_url_raw( $invoice->get_view_url() ) . '" title="' . __( 'View invoice', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>', |
|
91 | + 'label_type' => 'vertical', |
|
92 | + 'class' => 'form-control-sm', |
|
93 | + 'value' => $invoice->get_view_url(), |
|
94 | + 'extra_attributes' => array( |
|
95 | 95 | 'onclick' => 'this.select();', |
96 | 96 | 'readonly' => 'true', |
97 | - ), |
|
97 | + ), |
|
98 | 98 | ) |
99 | - ); |
|
100 | - |
|
101 | - // If the invoice is paid... |
|
102 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
103 | - |
|
104 | - // Gateway. |
|
105 | - echo aui()->input( |
|
106 | - array( |
|
107 | - 'type' => 'text', |
|
108 | - 'id' => 'wpinv_gateway', |
|
109 | - 'name' => '', |
|
110 | - 'label' => __( 'Gateway:', 'invoicing' ), |
|
111 | - 'label_type' => 'vertical', |
|
112 | - 'class' => 'form-control-sm', |
|
113 | - 'value' => wpinv_get_gateway_admin_label( $invoice->get_gateway( 'edit' ) ), |
|
114 | - 'extra_attributes' => array( |
|
115 | - 'onclick' => 'this.select();', |
|
116 | - 'readonly' => 'true', |
|
117 | - ), |
|
118 | - ) |
|
119 | - ); |
|
120 | - |
|
121 | - // Transaction ID. |
|
122 | - $transaction_url = $invoice->get_transaction_url(); |
|
123 | - echo aui()->input( |
|
124 | - array( |
|
125 | - 'type' => 'text', |
|
126 | - 'id' => 'wpinv_transaction_id', |
|
127 | - 'name' => 'wpinv_transaction_id', |
|
128 | - 'label' => __( 'Transaction ID:', 'invoicing' ) . ( $transaction_url ? ' <a href="' . esc_url( $transaction_url ) . '" title="' . __( 'View details', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>' : '' ), |
|
129 | - 'label_type' => 'vertical', |
|
130 | - 'class' => 'form-control-sm', |
|
131 | - 'value' => $invoice->get_transaction_id( 'edit' ), |
|
132 | - 'help_text' => apply_filters( 'wpinv_invoice_transaction_link_' . $invoice->get_gateway( 'edit' ), '', $invoice->get_transaction_id(), $invoice ), |
|
133 | - 'extra_attributes' => array( |
|
134 | - 'onclick' => 'this.select();', |
|
135 | - 'readonly' => 'true', |
|
136 | - ), |
|
137 | - ) |
|
138 | - ); |
|
139 | - |
|
140 | - // Currency. |
|
141 | - echo aui()->input( |
|
142 | - array( |
|
143 | - 'type' => 'text', |
|
144 | - 'id' => 'wpinv_currency', |
|
145 | - 'name' => 'wpinv_currency', |
|
146 | - 'label' => __( 'Currency:', 'invoicing' ), |
|
147 | - 'label_type' => 'vertical', |
|
148 | - 'class' => 'form-control-sm', |
|
149 | - 'value' => $invoice->get_currency( 'edit' ), |
|
150 | - 'extra_attributes' => array( |
|
151 | - 'onclick' => 'this.select();', |
|
152 | - 'readonly' => 'true', |
|
153 | - ), |
|
154 | - ) |
|
155 | - ); |
|
156 | - |
|
157 | - } else { |
|
158 | - |
|
159 | - if ( 'wpi_invoice' == $invoice->get_post_type() ) { |
|
160 | - |
|
161 | - // Payment URL. |
|
162 | - echo aui()->input( |
|
163 | - array( |
|
164 | - 'type' => 'text', |
|
165 | - 'id' => 'wpinv_payment_url', |
|
166 | - 'name' => 'wpinv_payment_url', |
|
167 | - 'label' => __( 'Payment URL:', 'invoicing' ), |
|
168 | - 'label_type' => 'vertical', |
|
169 | - 'class' => 'form-control-sm', |
|
170 | - 'value' => $invoice->get_checkout_payment_url(), |
|
171 | - 'extra_attributes' => array( |
|
172 | - 'onclick' => 'this.select();', |
|
173 | - 'readonly' => 'true', |
|
174 | - ), |
|
175 | - ) |
|
176 | - ); |
|
177 | - |
|
178 | - // Set gateway. |
|
179 | - echo aui()->select( |
|
180 | - array( |
|
181 | - 'id' => 'wpinv_gateway', |
|
182 | - 'name' => 'wpinv_gateway', |
|
183 | - 'label' => __( 'Gateway:', 'invoicing' ), |
|
184 | - 'label_type' => 'vertical', |
|
185 | - 'placeholder' => __( 'Select Gateway', 'invoicing' ), |
|
186 | - 'value' => $invoice->get_gateway( 'edit' ), |
|
187 | - 'select2' => true, |
|
188 | - 'data-allow-clear' => 'false', |
|
189 | - 'options' => wp_list_pluck( wpinv_get_enabled_payment_gateways( true ), 'admin_label' ), |
|
190 | - ) |
|
191 | - ); |
|
192 | - |
|
193 | - } |
|
99 | + ); |
|
100 | + |
|
101 | + // If the invoice is paid... |
|
102 | + if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
103 | + |
|
104 | + // Gateway. |
|
105 | + echo aui()->input( |
|
106 | + array( |
|
107 | + 'type' => 'text', |
|
108 | + 'id' => 'wpinv_gateway', |
|
109 | + 'name' => '', |
|
110 | + 'label' => __( 'Gateway:', 'invoicing' ), |
|
111 | + 'label_type' => 'vertical', |
|
112 | + 'class' => 'form-control-sm', |
|
113 | + 'value' => wpinv_get_gateway_admin_label( $invoice->get_gateway( 'edit' ) ), |
|
114 | + 'extra_attributes' => array( |
|
115 | + 'onclick' => 'this.select();', |
|
116 | + 'readonly' => 'true', |
|
117 | + ), |
|
118 | + ) |
|
119 | + ); |
|
120 | + |
|
121 | + // Transaction ID. |
|
122 | + $transaction_url = $invoice->get_transaction_url(); |
|
123 | + echo aui()->input( |
|
124 | + array( |
|
125 | + 'type' => 'text', |
|
126 | + 'id' => 'wpinv_transaction_id', |
|
127 | + 'name' => 'wpinv_transaction_id', |
|
128 | + 'label' => __( 'Transaction ID:', 'invoicing' ) . ( $transaction_url ? ' <a href="' . esc_url( $transaction_url ) . '" title="' . __( 'View details', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>' : '' ), |
|
129 | + 'label_type' => 'vertical', |
|
130 | + 'class' => 'form-control-sm', |
|
131 | + 'value' => $invoice->get_transaction_id( 'edit' ), |
|
132 | + 'help_text' => apply_filters( 'wpinv_invoice_transaction_link_' . $invoice->get_gateway( 'edit' ), '', $invoice->get_transaction_id(), $invoice ), |
|
133 | + 'extra_attributes' => array( |
|
134 | + 'onclick' => 'this.select();', |
|
135 | + 'readonly' => 'true', |
|
136 | + ), |
|
137 | + ) |
|
138 | + ); |
|
139 | + |
|
140 | + // Currency. |
|
141 | + echo aui()->input( |
|
142 | + array( |
|
143 | + 'type' => 'text', |
|
144 | + 'id' => 'wpinv_currency', |
|
145 | + 'name' => 'wpinv_currency', |
|
146 | + 'label' => __( 'Currency:', 'invoicing' ), |
|
147 | + 'label_type' => 'vertical', |
|
148 | + 'class' => 'form-control-sm', |
|
149 | + 'value' => $invoice->get_currency( 'edit' ), |
|
150 | + 'extra_attributes' => array( |
|
151 | + 'onclick' => 'this.select();', |
|
152 | + 'readonly' => 'true', |
|
153 | + ), |
|
154 | + ) |
|
155 | + ); |
|
156 | + |
|
157 | + } else { |
|
158 | + |
|
159 | + if ( 'wpi_invoice' == $invoice->get_post_type() ) { |
|
160 | + |
|
161 | + // Payment URL. |
|
162 | + echo aui()->input( |
|
163 | + array( |
|
164 | + 'type' => 'text', |
|
165 | + 'id' => 'wpinv_payment_url', |
|
166 | + 'name' => 'wpinv_payment_url', |
|
167 | + 'label' => __( 'Payment URL:', 'invoicing' ), |
|
168 | + 'label_type' => 'vertical', |
|
169 | + 'class' => 'form-control-sm', |
|
170 | + 'value' => $invoice->get_checkout_payment_url(), |
|
171 | + 'extra_attributes' => array( |
|
172 | + 'onclick' => 'this.select();', |
|
173 | + 'readonly' => 'true', |
|
174 | + ), |
|
175 | + ) |
|
176 | + ); |
|
177 | + |
|
178 | + // Set gateway. |
|
179 | + echo aui()->select( |
|
180 | + array( |
|
181 | + 'id' => 'wpinv_gateway', |
|
182 | + 'name' => 'wpinv_gateway', |
|
183 | + 'label' => __( 'Gateway:', 'invoicing' ), |
|
184 | + 'label_type' => 'vertical', |
|
185 | + 'placeholder' => __( 'Select Gateway', 'invoicing' ), |
|
186 | + 'value' => $invoice->get_gateway( 'edit' ), |
|
187 | + 'select2' => true, |
|
188 | + 'data-allow-clear' => 'false', |
|
189 | + 'options' => wp_list_pluck( wpinv_get_enabled_payment_gateways( true ), 'admin_label' ), |
|
190 | + ) |
|
191 | + ); |
|
192 | + |
|
193 | + } |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | ?> |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | if ( ! defined( 'ABSPATH' ) ) { |
11 | - exit; // Exit if accessed directly |
|
11 | + exit; // Exit if accessed directly |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | /** |
@@ -17,10 +17,10 @@ discard block |
||
17 | 17 | class GetPaid_Meta_Box_Item_Details { |
18 | 18 | |
19 | 19 | /** |
20 | - * Output the metabox. |
|
21 | - * |
|
22 | - * @param WP_Post $post |
|
23 | - */ |
|
20 | + * Output the metabox. |
|
21 | + * |
|
22 | + * @param WP_Post $post |
|
23 | + */ |
|
24 | 24 | public static function output( $post ) { |
25 | 25 | |
26 | 26 | // Prepare the item. |
@@ -113,22 +113,22 @@ discard block |
||
113 | 113 | // Dynamic pricing. |
114 | 114 | if ( $item->supports_dynamic_pricing() ) { |
115 | 115 | |
116 | - do_action( 'wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item ); |
|
116 | + do_action( 'wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item ); |
|
117 | 117 | |
118 | - // NYP toggle. |
|
119 | - echo aui()->input( |
|
118 | + // NYP toggle. |
|
119 | + echo aui()->input( |
|
120 | 120 | array( |
121 | - 'id' => 'wpinv_name_your_price', |
|
122 | - 'name' => 'wpinv_name_your_price', |
|
123 | - 'type' => 'checkbox', |
|
124 | - 'label' => apply_filters( 'wpinv_name_your_price_toggle_text', __( 'Let customers name their price', 'invoicing' ) ), |
|
125 | - 'value' => '1', |
|
126 | - 'checked' => $item->user_can_set_their_price(), |
|
127 | - 'no_wrap' => true, |
|
121 | + 'id' => 'wpinv_name_your_price', |
|
122 | + 'name' => 'wpinv_name_your_price', |
|
123 | + 'type' => 'checkbox', |
|
124 | + 'label' => apply_filters( 'wpinv_name_your_price_toggle_text', __( 'Let customers name their price', 'invoicing' ) ), |
|
125 | + 'value' => '1', |
|
126 | + 'checked' => $item->user_can_set_their_price(), |
|
127 | + 'no_wrap' => true, |
|
128 | 128 | ) |
129 | 129 | ); |
130 | 130 | |
131 | - do_action( 'wpinv_item_details_metabox_dynamic_pricing_checkbox', $item ); |
|
131 | + do_action( 'wpinv_item_details_metabox_dynamic_pricing_checkbox', $item ); |
|
132 | 132 | |
133 | 133 | } |
134 | 134 | |
@@ -270,35 +270,35 @@ discard block |
||
270 | 270 | } |
271 | 271 | |
272 | 272 | /** |
273 | - * Save meta box data. |
|
274 | - * |
|
275 | - * @param int $post_id |
|
276 | - */ |
|
277 | - public static function save( $post_id ) { |
|
273 | + * Save meta box data. |
|
274 | + * |
|
275 | + * @param int $post_id |
|
276 | + */ |
|
277 | + public static function save( $post_id ) { |
|
278 | 278 | |
279 | 279 | // Prepare the item. |
280 | 280 | $item = new WPInv_Item( $post_id ); |
281 | 281 | |
282 | 282 | // Load new data. |
283 | 283 | $item->set_props( |
284 | - array( |
|
285 | - 'price' => isset( $_POST['wpinv_item_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_item_price'] ) : null, |
|
286 | - 'vat_rule' => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null, |
|
287 | - 'vat_class' => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null, |
|
288 | - 'type' => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null, |
|
289 | - 'is_dynamic_pricing' => ! empty( $_POST['wpinv_name_your_price'] ), |
|
284 | + array( |
|
285 | + 'price' => isset( $_POST['wpinv_item_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_item_price'] ) : null, |
|
286 | + 'vat_rule' => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null, |
|
287 | + 'vat_class' => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null, |
|
288 | + 'type' => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null, |
|
289 | + 'is_dynamic_pricing' => ! empty( $_POST['wpinv_name_your_price'] ), |
|
290 | 290 | 'minimum_price' => isset( $_POST['wpinv_minimum_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_minimum_price'] ) : null, |
291 | - 'is_recurring' => ! empty( $_POST['wpinv_is_recurring'] ), |
|
292 | - 'recurring_period' => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null, |
|
293 | - 'recurring_interval' => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1, |
|
294 | - 'recurring_limit' => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null, |
|
295 | - 'is_free_trial' => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null, |
|
296 | - 'trial_period' => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null, |
|
297 | - 'trial_interval' => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null, |
|
298 | - ) |
|
291 | + 'is_recurring' => ! empty( $_POST['wpinv_is_recurring'] ), |
|
292 | + 'recurring_period' => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null, |
|
293 | + 'recurring_interval' => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1, |
|
294 | + 'recurring_limit' => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null, |
|
295 | + 'is_free_trial' => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null, |
|
296 | + 'trial_period' => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null, |
|
297 | + 'trial_interval' => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null, |
|
298 | + ) |
|
299 | 299 | ); |
300 | 300 | |
301 | - $item->save(); |
|
302 | - do_action( 'getpaid_item_metabox_save', $post_id, $item ); |
|
303 | - } |
|
301 | + $item->save(); |
|
302 | + do_action( 'getpaid_item_metabox_save', $post_id, $item ); |
|
303 | + } |
|
304 | 304 | } |
@@ -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( |
|
28 | + echo aui()->alert( |
|
29 | 29 | array( |
30 | - 'type' => 'danger', |
|
31 | - 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
30 | + 'type' => 'danger', |
|
31 | + 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
32 | 32 | ) |
33 | 33 | ); |
34 | 34 | |
35 | - } elseif ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
35 | + } elseif ( ! 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 | <?php $subscribers_table->views(); ?> |
67 | 67 | <form id="subscribers-filter" class="bsui" method="get"> |
68 | 68 | <input type="hidden" name="page" value="wpinv-subscriptions" /> |
@@ -81,41 +81,41 @@ discard block |
||
81 | 81 | */ |
82 | 82 | function wpinv_recurring_subscription_details() { |
83 | 83 | |
84 | - // Fetch the subscription. |
|
85 | - $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
86 | - if ( ! $sub->exists() ) { |
|
84 | + // Fetch the subscription. |
|
85 | + $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
86 | + if ( ! $sub->exists() ) { |
|
87 | 87 | |
88 | - echo aui()->alert( |
|
89 | - array( |
|
90 | - 'type' => 'danger', |
|
91 | - 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
92 | - ) |
|
93 | - ); |
|
88 | + echo aui()->alert( |
|
89 | + array( |
|
90 | + 'type' => 'danger', |
|
91 | + 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
92 | + ) |
|
93 | + ); |
|
94 | 94 | |
95 | - return; |
|
96 | - } |
|
95 | + return; |
|
96 | + } |
|
97 | 97 | |
98 | - // Use metaboxes to display the subscription details. |
|
99 | - add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
100 | - add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
98 | + // Use metaboxes to display the subscription details. |
|
99 | + add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
100 | + add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
101 | 101 | |
102 | - $subscription_id = $sub->get_id(); |
|
103 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
104 | - $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
102 | + $subscription_id = $sub->get_id(); |
|
103 | + $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
104 | + $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
105 | 105 | |
106 | - if ( 1 < count( $subscription_groups ) ) { |
|
107 | - add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
108 | - } |
|
106 | + if ( 1 < count( $subscription_groups ) ) { |
|
107 | + add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
108 | + } |
|
109 | 109 | |
110 | - if ( ! empty( $subscription_group ) ) { |
|
111 | - add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
112 | - } |
|
110 | + if ( ! empty( $subscription_group ) ) { |
|
111 | + add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
112 | + } |
|
113 | 113 | |
114 | - add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
114 | + add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
115 | 115 | |
116 | - do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
116 | + do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
117 | 117 | |
118 | - ?> |
|
118 | + ?> |
|
119 | 119 | |
120 | 120 | <form method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ); ?>"> |
121 | 121 | |
@@ -155,44 +155,44 @@ discard block |
||
155 | 155 | */ |
156 | 156 | function getpaid_admin_subscription_details_metabox( $sub ) { |
157 | 157 | |
158 | - // Subscription items. |
|
159 | - $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
160 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
161 | - |
|
162 | - // Prepare subscription detail columns. |
|
163 | - $fields = apply_filters( |
|
164 | - 'getpaid_subscription_admin_page_fields', |
|
165 | - array( |
|
166 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
167 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
168 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
169 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
170 | - 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
171 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
172 | - 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
173 | - 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
174 | - 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
175 | - 'status' => __( 'Status', 'invoicing' ), |
|
176 | - ) |
|
177 | - ); |
|
178 | - |
|
179 | - if ( ! $sub->is_active() ) { |
|
180 | - |
|
181 | - if ( isset( $fields['renews_on'] ) ) { |
|
182 | - unset( $fields['renews_on'] ); |
|
183 | - } |
|
184 | - |
|
185 | - if ( isset( $fields['gateway'] ) ) { |
|
186 | - unset( $fields['gateway'] ); |
|
187 | - } |
|
158 | + // Subscription items. |
|
159 | + $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
160 | + $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
161 | + |
|
162 | + // Prepare subscription detail columns. |
|
163 | + $fields = apply_filters( |
|
164 | + 'getpaid_subscription_admin_page_fields', |
|
165 | + array( |
|
166 | + 'subscription' => __( 'Subscription', 'invoicing' ), |
|
167 | + 'customer' => __( 'Customer', 'invoicing' ), |
|
168 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
169 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
170 | + 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
171 | + 'renewals' => __( 'Payments', 'invoicing' ), |
|
172 | + 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
173 | + 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
174 | + 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
175 | + 'status' => __( 'Status', 'invoicing' ), |
|
176 | + ) |
|
177 | + ); |
|
178 | + |
|
179 | + if ( ! $sub->is_active() ) { |
|
180 | + |
|
181 | + if ( isset( $fields['renews_on'] ) ) { |
|
182 | + unset( $fields['renews_on'] ); |
|
183 | + } |
|
184 | + |
|
185 | + if ( isset( $fields['gateway'] ) ) { |
|
186 | + unset( $fields['gateway'] ); |
|
187 | + } |
|
188 | 188 | } |
189 | 189 | |
190 | - $profile_id = $sub->get_profile_id(); |
|
191 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
192 | - unset( $fields['profile_id'] ); |
|
193 | - } |
|
190 | + $profile_id = $sub->get_profile_id(); |
|
191 | + if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
192 | + unset( $fields['profile_id'] ); |
|
193 | + } |
|
194 | 194 | |
195 | - ?> |
|
195 | + ?> |
|
196 | 196 | |
197 | 197 | <table class="table table-borderless" style="font-size: 14px;"> |
198 | 198 | <tbody> |
@@ -226,20 +226,20 @@ discard block |
||
226 | 226 | */ |
227 | 227 | function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
228 | 228 | |
229 | - $username = __( '(Missing User)', 'invoicing' ); |
|
229 | + $username = __( '(Missing User)', 'invoicing' ); |
|
230 | 230 | |
231 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
232 | - if ( $user ) { |
|
231 | + $user = get_userdata( $subscription->get_customer_id() ); |
|
232 | + if ( $user ) { |
|
233 | 233 | |
234 | - $username = sprintf( |
|
235 | - '<a href="user-edit.php?user_id=%s">%s</a>', |
|
236 | - absint( $user->ID ), |
|
237 | - ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email ) |
|
238 | - ); |
|
234 | + $username = sprintf( |
|
235 | + '<a href="user-edit.php?user_id=%s">%s</a>', |
|
236 | + absint( $user->ID ), |
|
237 | + ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email ) |
|
238 | + ); |
|
239 | 239 | |
240 | - } |
|
240 | + } |
|
241 | 241 | |
242 | - echo wp_kses_post( $username ); |
|
242 | + echo wp_kses_post( $username ); |
|
243 | 243 | } |
244 | 244 | add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
245 | 245 | |
@@ -249,8 +249,8 @@ discard block |
||
249 | 249 | * @param WPInv_Subscription $subscription |
250 | 250 | */ |
251 | 251 | function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
252 | - $amount = wp_kses_post( getpaid_get_formatted_subscription_amount( $subscription ) ); |
|
253 | - echo "<span>$amount</span>"; |
|
252 | + $amount = wp_kses_post( getpaid_get_formatted_subscription_amount( $subscription ) ); |
|
253 | + echo "<span>$amount</span>"; |
|
254 | 254 | } |
255 | 255 | add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
256 | 256 | |
@@ -261,11 +261,11 @@ discard block |
||
261 | 261 | */ |
262 | 262 | function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
263 | 263 | |
264 | - printf( |
|
265 | - '<a href="%s">#%s</a>', |
|
266 | - esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ), |
|
267 | - absint( $subscription->get_id() ) |
|
268 | - ); |
|
264 | + printf( |
|
265 | + '<a href="%s">#%s</a>', |
|
266 | + esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ), |
|
267 | + absint( $subscription->get_id() ) |
|
268 | + ); |
|
269 | 269 | |
270 | 270 | } |
271 | 271 | add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | * @param WPInv_Subscription $subscription |
277 | 277 | */ |
278 | 278 | function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
279 | - echo getpaid_format_date_value( $subscription->get_date_created() ); |
|
279 | + echo getpaid_format_date_value( $subscription->get_date_created() ); |
|
280 | 280 | } |
281 | 281 | add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
282 | 282 | |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | * @param WPInv_Subscription $subscription |
287 | 287 | */ |
288 | 288 | function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
289 | - echo getpaid_format_date_value( $subscription->get_expiration() ); |
|
289 | + echo getpaid_format_date_value( $subscription->get_expiration() ); |
|
290 | 290 | } |
291 | 291 | add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
292 | 292 | |
@@ -296,8 +296,8 @@ discard block |
||
296 | 296 | * @param WPInv_Subscription $subscription |
297 | 297 | */ |
298 | 298 | function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
299 | - $max_bills = $subscription->get_bill_times(); |
|
300 | - echo ( (int) $subscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
299 | + $max_bills = $subscription->get_bill_times(); |
|
300 | + echo ( (int) $subscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
301 | 301 | } |
302 | 302 | add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
303 | 303 | /** |
@@ -308,13 +308,13 @@ discard block |
||
308 | 308 | */ |
309 | 309 | function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) { |
310 | 310 | |
311 | - if ( empty( $subscription_group ) ) { |
|
312 | - echo WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ); |
|
313 | - return; |
|
314 | - } |
|
311 | + if ( empty( $subscription_group ) ) { |
|
312 | + echo WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ); |
|
313 | + return; |
|
314 | + } |
|
315 | 315 | |
316 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
317 | - echo wp_kses_post( implode( ' | ', $markup ) ); |
|
316 | + $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
317 | + echo wp_kses_post( implode( ' | ', $markup ) ); |
|
318 | 318 | |
319 | 319 | } |
320 | 320 | add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 ); |
@@ -326,13 +326,13 @@ discard block |
||
326 | 326 | */ |
327 | 327 | function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
328 | 328 | |
329 | - $gateway = $subscription->get_gateway(); |
|
329 | + $gateway = $subscription->get_gateway(); |
|
330 | 330 | |
331 | - if ( ! empty( $gateway ) ) { |
|
332 | - echo esc_html( wpinv_get_gateway_admin_label( $gateway ) ); |
|
333 | - } else { |
|
334 | - echo '—'; |
|
335 | - } |
|
331 | + if ( ! empty( $gateway ) ) { |
|
332 | + echo esc_html( wpinv_get_gateway_admin_label( $gateway ) ); |
|
333 | + } else { |
|
334 | + echo '—'; |
|
335 | + } |
|
336 | 336 | |
337 | 337 | } |
338 | 338 | add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | * @param WPInv_Subscription $subscription |
344 | 344 | */ |
345 | 345 | function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
346 | - echo wp_kses_post( $subscription->get_status_label_html() ); |
|
346 | + echo wp_kses_post( $subscription->get_status_label_html() ); |
|
347 | 347 | } |
348 | 348 | add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
349 | 349 | |
@@ -354,28 +354,28 @@ discard block |
||
354 | 354 | */ |
355 | 355 | function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
356 | 356 | |
357 | - $profile_id = $subscription->get_profile_id(); |
|
358 | - |
|
359 | - $input = aui()->input( |
|
360 | - array( |
|
361 | - 'type' => 'text', |
|
362 | - 'id' => 'wpinv_subscription_profile_id', |
|
363 | - 'name' => 'wpinv_subscription_profile_id', |
|
364 | - 'label' => __( 'Profile Id', 'invoicing' ), |
|
365 | - 'label_type' => 'hidden', |
|
366 | - 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
367 | - 'value' => esc_attr( $profile_id ), |
|
368 | - 'input_group_right' => '', |
|
369 | - 'no_wrap' => true, |
|
370 | - ) |
|
371 | - ); |
|
372 | - |
|
373 | - echo str_ireplace( 'form-control', 'regular-text', $input ); |
|
374 | - |
|
375 | - $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
376 | - if ( ! empty( $url ) ) { |
|
377 | - echo ' <a href="' . esc_url_raw( $url ) . '" title="' . __( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
378 | - } |
|
357 | + $profile_id = $subscription->get_profile_id(); |
|
358 | + |
|
359 | + $input = aui()->input( |
|
360 | + array( |
|
361 | + 'type' => 'text', |
|
362 | + 'id' => 'wpinv_subscription_profile_id', |
|
363 | + 'name' => 'wpinv_subscription_profile_id', |
|
364 | + 'label' => __( 'Profile Id', 'invoicing' ), |
|
365 | + 'label_type' => 'hidden', |
|
366 | + 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
367 | + 'value' => esc_attr( $profile_id ), |
|
368 | + 'input_group_right' => '', |
|
369 | + 'no_wrap' => true, |
|
370 | + ) |
|
371 | + ); |
|
372 | + |
|
373 | + echo str_ireplace( 'form-control', 'regular-text', $input ); |
|
374 | + |
|
375 | + $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
376 | + if ( ! empty( $url ) ) { |
|
377 | + echo ' <a href="' . esc_url_raw( $url ) . '" title="' . __( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
378 | + } |
|
379 | 379 | |
380 | 380 | } |
381 | 381 | add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
@@ -387,39 +387,39 @@ discard block |
||
387 | 387 | */ |
388 | 388 | function getpaid_admin_subscription_update_metabox( $subscription ) { |
389 | 389 | |
390 | - ?> |
|
390 | + ?> |
|
391 | 391 | <div class="mt-3"> |
392 | 392 | |
393 | 393 | <?php |
394 | - echo aui()->select( |
|
395 | - array( |
|
396 | - 'options' => getpaid_get_subscription_statuses(), |
|
397 | - 'name' => 'subscription_status', |
|
398 | - 'id' => 'subscription_status_update_select', |
|
399 | - 'required' => true, |
|
400 | - 'no_wrap' => false, |
|
401 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
402 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
403 | - 'select2' => true, |
|
404 | - 'value' => $subscription->get_status( 'edit' ), |
|
405 | - ) |
|
406 | - ); |
|
407 | - ?> |
|
394 | + echo aui()->select( |
|
395 | + array( |
|
396 | + 'options' => getpaid_get_subscription_statuses(), |
|
397 | + 'name' => 'subscription_status', |
|
398 | + 'id' => 'subscription_status_update_select', |
|
399 | + 'required' => true, |
|
400 | + 'no_wrap' => false, |
|
401 | + 'label' => __( 'Subscription Status', 'invoicing' ), |
|
402 | + 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
403 | + 'select2' => true, |
|
404 | + 'value' => $subscription->get_status( 'edit' ), |
|
405 | + ) |
|
406 | + ); |
|
407 | + ?> |
|
408 | 408 | |
409 | 409 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;"> |
410 | 410 | |
411 | 411 | <?php |
412 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
412 | + submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
413 | 413 | |
414 | - $url = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
415 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
416 | - $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' ); |
|
414 | + $url = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
415 | + $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
416 | + $title = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' ); |
|
417 | 417 | |
418 | - if ( $subscription->is_active() ) { |
|
419 | - echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>"; |
|
420 | - } |
|
418 | + if ( $subscription->is_active() ) { |
|
419 | + echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>"; |
|
420 | + } |
|
421 | 421 | |
422 | - echo '</div></div>'; |
|
422 | + echo '</div></div>'; |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | /** |
@@ -430,33 +430,33 @@ discard block |
||
430 | 430 | */ |
431 | 431 | function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) { |
432 | 432 | |
433 | - $columns = apply_filters( |
|
434 | - 'getpaid_subscription_related_invoices_columns', |
|
435 | - array( |
|
436 | - 'invoice' => __( 'Invoice', 'invoicing' ), |
|
437 | - 'relationship' => __( 'Relationship', 'invoicing' ), |
|
438 | - 'date' => __( 'Date', 'invoicing' ), |
|
439 | - 'status' => __( 'Status', 'invoicing' ), |
|
440 | - 'total' => __( 'Total', 'invoicing' ), |
|
441 | - ), |
|
442 | - $subscription |
|
443 | - ); |
|
444 | - |
|
445 | - // Prepare the invoices. |
|
446 | - $payments = $subscription->get_child_payments( ! is_admin() ); |
|
447 | - $parent = $subscription->get_parent_invoice(); |
|
448 | - |
|
449 | - if ( $parent->exists() ) { |
|
450 | - $payments = array_merge( array( $parent ), $payments ); |
|
451 | - } |
|
452 | - |
|
453 | - $table_class = 'w-100 bg-white'; |
|
454 | - |
|
455 | - if ( ! is_admin() ) { |
|
456 | - $table_class = 'table table-bordered'; |
|
457 | - } |
|
458 | - |
|
459 | - ?> |
|
433 | + $columns = apply_filters( |
|
434 | + 'getpaid_subscription_related_invoices_columns', |
|
435 | + array( |
|
436 | + 'invoice' => __( 'Invoice', 'invoicing' ), |
|
437 | + 'relationship' => __( 'Relationship', 'invoicing' ), |
|
438 | + 'date' => __( 'Date', 'invoicing' ), |
|
439 | + 'status' => __( 'Status', 'invoicing' ), |
|
440 | + 'total' => __( 'Total', 'invoicing' ), |
|
441 | + ), |
|
442 | + $subscription |
|
443 | + ); |
|
444 | + |
|
445 | + // Prepare the invoices. |
|
446 | + $payments = $subscription->get_child_payments( ! is_admin() ); |
|
447 | + $parent = $subscription->get_parent_invoice(); |
|
448 | + |
|
449 | + if ( $parent->exists() ) { |
|
450 | + $payments = array_merge( array( $parent ), $payments ); |
|
451 | + } |
|
452 | + |
|
453 | + $table_class = 'w-100 bg-white'; |
|
454 | + |
|
455 | + if ( ! is_admin() ) { |
|
456 | + $table_class = 'table table-bordered'; |
|
457 | + } |
|
458 | + |
|
459 | + ?> |
|
460 | 460 | <div class="m-0" style="overflow: auto;"> |
461 | 461 | |
462 | 462 | <table class="<?php echo esc_attr( $table_class ); ?>"> |
@@ -464,14 +464,14 @@ discard block |
||
464 | 464 | <thead> |
465 | 465 | <tr> |
466 | 466 | <?php |
467 | - foreach ( $columns as $key => $label ) { |
|
468 | - $key = esc_attr( $key ); |
|
469 | - $label = esc_html( $label ); |
|
470 | - $class = 'text-left'; |
|
471 | - |
|
472 | - echo "<th class='subscription-invoice-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
|
473 | - } |
|
474 | - ?> |
|
467 | + foreach ( $columns as $key => $label ) { |
|
468 | + $key = esc_attr( $key ); |
|
469 | + $label = esc_html( $label ); |
|
470 | + $class = 'text-left'; |
|
471 | + |
|
472 | + echo "<th class='subscription-invoice-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
|
473 | + } |
|
474 | + ?> |
|
475 | 475 | </tr> |
476 | 476 | </thead> |
477 | 477 | |
@@ -487,72 +487,72 @@ discard block |
||
487 | 487 | |
488 | 488 | <?php |
489 | 489 | |
490 | - foreach ( $payments as $payment ) : |
|
490 | + foreach ( $payments as $payment ) : |
|
491 | 491 | |
492 | - // Ensure that we have an invoice. |
|
493 | - $payment = new WPInv_Invoice( $payment ); |
|
492 | + // Ensure that we have an invoice. |
|
493 | + $payment = new WPInv_Invoice( $payment ); |
|
494 | 494 | |
495 | - // Abort if the invoice is invalid... |
|
496 | - if ( ! $payment->exists() ) { |
|
497 | - continue; |
|
498 | - } |
|
495 | + // Abort if the invoice is invalid... |
|
496 | + if ( ! $payment->exists() ) { |
|
497 | + continue; |
|
498 | + } |
|
499 | 499 | |
500 | - // ... or belongs to a different subscription. |
|
501 | - if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
502 | - continue; |
|
503 | - } |
|
500 | + // ... or belongs to a different subscription. |
|
501 | + if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
502 | + continue; |
|
503 | + } |
|
504 | 504 | |
505 | - echo '<tr>'; |
|
505 | + echo '<tr>'; |
|
506 | 506 | |
507 | - foreach ( array_keys( $columns ) as $key ) { |
|
507 | + foreach ( array_keys( $columns ) as $key ) { |
|
508 | 508 | |
509 | - $class = 'text-left'; |
|
509 | + $class = 'text-left'; |
|
510 | 510 | |
511 | - echo "<td class='p-2 text-left'>"; |
|
511 | + echo "<td class='p-2 text-left'>"; |
|
512 | 512 | |
513 | - switch ( $key ) { |
|
513 | + switch ( $key ) { |
|
514 | 514 | |
515 | - case 'total': |
|
516 | - echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>'; |
|
517 | - break; |
|
515 | + case 'total': |
|
516 | + echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>'; |
|
517 | + break; |
|
518 | 518 | |
519 | - case 'relationship': |
|
520 | - echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' ); |
|
521 | - break; |
|
519 | + case 'relationship': |
|
520 | + echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' ); |
|
521 | + break; |
|
522 | 522 | |
523 | - case 'date': |
|
524 | - echo getpaid_format_date_value( $payment->get_date_created() ); |
|
525 | - break; |
|
523 | + case 'date': |
|
524 | + echo getpaid_format_date_value( $payment->get_date_created() ); |
|
525 | + break; |
|
526 | 526 | |
527 | - case 'status': |
|
528 | - $status = $payment->get_status_nicename(); |
|
529 | - if ( is_admin() ) { |
|
530 | - $status = $payment->get_status_label_html(); |
|
531 | - } |
|
527 | + case 'status': |
|
528 | + $status = $payment->get_status_nicename(); |
|
529 | + if ( is_admin() ) { |
|
530 | + $status = $payment->get_status_label_html(); |
|
531 | + } |
|
532 | 532 | |
533 | - echo wp_kses_post( $status ); |
|
534 | - break; |
|
533 | + echo wp_kses_post( $status ); |
|
534 | + break; |
|
535 | 535 | |
536 | - case 'invoice': |
|
537 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
536 | + case 'invoice': |
|
537 | + $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
538 | 538 | |
539 | - if ( ! is_admin() ) { |
|
540 | - $link = esc_url( $payment->get_view_url() ); |
|
541 | - } |
|
539 | + if ( ! is_admin() ) { |
|
540 | + $link = esc_url( $payment->get_view_url() ); |
|
541 | + } |
|
542 | 542 | |
543 | - $invoice = esc_html( $payment->get_number() ); |
|
544 | - echo "<a href='$link'>$invoice</a>"; |
|
545 | - break; |
|
546 | - } |
|
543 | + $invoice = esc_html( $payment->get_number() ); |
|
544 | + echo "<a href='$link'>$invoice</a>"; |
|
545 | + break; |
|
546 | + } |
|
547 | 547 | |
548 | - echo '</td>'; |
|
548 | + echo '</td>'; |
|
549 | 549 | |
550 | - } |
|
550 | + } |
|
551 | 551 | |
552 | - echo '</tr>'; |
|
552 | + echo '</tr>'; |
|
553 | 553 | |
554 | - endforeach; |
|
555 | - ?> |
|
554 | + endforeach; |
|
555 | + ?> |
|
556 | 556 | |
557 | 557 | </tbody> |
558 | 558 | |
@@ -570,42 +570,42 @@ discard block |
||
570 | 570 | */ |
571 | 571 | function getpaid_admin_subscription_item_details_metabox( $subscription ) { |
572 | 572 | |
573 | - // Fetch the subscription group. |
|
574 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
573 | + // Fetch the subscription group. |
|
574 | + $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
575 | 575 | |
576 | - if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
577 | - return; |
|
578 | - } |
|
576 | + if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
577 | + return; |
|
578 | + } |
|
579 | 579 | |
580 | - // Prepare table columns. |
|
581 | - $columns = apply_filters( |
|
582 | - 'getpaid_subscription_item_details_columns', |
|
583 | - array( |
|
584 | - 'item_name' => __( 'Item', 'invoicing' ), |
|
585 | - 'price' => __( 'Price', 'invoicing' ), |
|
586 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
587 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
588 | - //'initial' => __( 'Initial Amount', 'invoicing' ), |
|
589 | - 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
590 | - ), |
|
591 | - $subscription |
|
592 | - ); |
|
580 | + // Prepare table columns. |
|
581 | + $columns = apply_filters( |
|
582 | + 'getpaid_subscription_item_details_columns', |
|
583 | + array( |
|
584 | + 'item_name' => __( 'Item', 'invoicing' ), |
|
585 | + 'price' => __( 'Price', 'invoicing' ), |
|
586 | + 'tax' => __( 'Tax', 'invoicing' ), |
|
587 | + 'discount' => __( 'Discount', 'invoicing' ), |
|
588 | + //'initial' => __( 'Initial Amount', 'invoicing' ), |
|
589 | + 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
590 | + ), |
|
591 | + $subscription |
|
592 | + ); |
|
593 | 593 | |
594 | - // Prepare the invoices. |
|
594 | + // Prepare the invoices. |
|
595 | 595 | |
596 | - $invoice = $subscription->get_parent_invoice(); |
|
596 | + $invoice = $subscription->get_parent_invoice(); |
|
597 | 597 | |
598 | - if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
599 | - unset( $columns['tax'] ); |
|
600 | - } |
|
598 | + if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
599 | + unset( $columns['tax'] ); |
|
600 | + } |
|
601 | 601 | |
602 | - $table_class = 'w-100 bg-white'; |
|
602 | + $table_class = 'w-100 bg-white'; |
|
603 | 603 | |
604 | - if ( ! is_admin() ) { |
|
605 | - $table_class = 'table table-bordered'; |
|
606 | - } |
|
604 | + if ( ! is_admin() ) { |
|
605 | + $table_class = 'table table-bordered'; |
|
606 | + } |
|
607 | 607 | |
608 | - ?> |
|
608 | + ?> |
|
609 | 609 | <div class="m-0" style="overflow: auto;"> |
610 | 610 | |
611 | 611 | <table class="<?php echo esc_attr( $table_class ); ?>"> |
@@ -614,14 +614,14 @@ discard block |
||
614 | 614 | <tr> |
615 | 615 | <?php |
616 | 616 | |
617 | - foreach ( $columns as $key => $label ) { |
|
618 | - $key = esc_attr( $key ); |
|
619 | - $label = esc_html( $label ); |
|
620 | - $class = 'text-left'; |
|
617 | + foreach ( $columns as $key => $label ) { |
|
618 | + $key = esc_attr( $key ); |
|
619 | + $label = esc_html( $label ); |
|
620 | + $class = 'text-left'; |
|
621 | 621 | |
622 | - echo "<th class='subscription-item-field-$key bg-light p-2 text-left color-dark font-weight-bold'>$label</th>"; |
|
623 | - } |
|
624 | - ?> |
|
622 | + echo "<th class='subscription-item-field-$key bg-light p-2 text-left color-dark font-weight-bold'>$label</th>"; |
|
623 | + } |
|
624 | + ?> |
|
625 | 625 | </tr> |
626 | 626 | </thead> |
627 | 627 | |
@@ -629,106 +629,106 @@ discard block |
||
629 | 629 | |
630 | 630 | <?php |
631 | 631 | |
632 | - foreach ( $subscription_group['items'] as $subscription_group_item ) : |
|
632 | + foreach ( $subscription_group['items'] as $subscription_group_item ) : |
|
633 | 633 | |
634 | - echo '<tr>'; |
|
634 | + echo '<tr>'; |
|
635 | 635 | |
636 | - foreach ( array_keys( $columns ) as $key ) { |
|
636 | + foreach ( array_keys( $columns ) as $key ) { |
|
637 | 637 | |
638 | - $class = 'text-left'; |
|
638 | + $class = 'text-left'; |
|
639 | 639 | |
640 | - echo "<td class='p-2 text-left'>"; |
|
640 | + echo "<td class='p-2 text-left'>"; |
|
641 | 641 | |
642 | - switch ( $key ) { |
|
642 | + switch ( $key ) { |
|
643 | 643 | |
644 | - case 'item_name': |
|
645 | - $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
646 | - $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
644 | + case 'item_name': |
|
645 | + $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
646 | + $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
647 | 647 | |
648 | - if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
649 | - echo esc_html( $item_name ); |
|
650 | - } else { |
|
651 | - printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
652 | - } |
|
648 | + if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
649 | + echo esc_html( $item_name ); |
|
650 | + } else { |
|
651 | + printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
652 | + } |
|
653 | 653 | |
654 | - break; |
|
654 | + break; |
|
655 | 655 | |
656 | - case 'price': |
|
657 | - echo wpinv_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
658 | - break; |
|
656 | + case 'price': |
|
657 | + echo wpinv_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
658 | + break; |
|
659 | 659 | |
660 | - case 'tax': |
|
661 | - echo wpinv_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
662 | - break; |
|
660 | + case 'tax': |
|
661 | + echo wpinv_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
662 | + break; |
|
663 | 663 | |
664 | - case 'discount': |
|
665 | - echo wpinv_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
666 | - break; |
|
664 | + case 'discount': |
|
665 | + echo wpinv_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
666 | + break; |
|
667 | 667 | |
668 | - case 'initial': |
|
669 | - echo wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
670 | - break; |
|
668 | + case 'initial': |
|
669 | + echo wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
670 | + break; |
|
671 | 671 | |
672 | - case 'recurring': |
|
673 | - echo '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>'; |
|
674 | - break; |
|
672 | + case 'recurring': |
|
673 | + echo '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>'; |
|
674 | + break; |
|
675 | 675 | |
676 | - } |
|
676 | + } |
|
677 | 677 | |
678 | - echo '</td>'; |
|
678 | + echo '</td>'; |
|
679 | 679 | |
680 | - } |
|
680 | + } |
|
681 | 681 | |
682 | - echo '</tr>'; |
|
682 | + echo '</tr>'; |
|
683 | 683 | |
684 | - endforeach; |
|
684 | + endforeach; |
|
685 | 685 | |
686 | - foreach ( $subscription_group['fees'] as $subscription_group_fee ) : |
|
686 | + foreach ( $subscription_group['fees'] as $subscription_group_fee ) : |
|
687 | 687 | |
688 | - echo '<tr>'; |
|
688 | + echo '<tr>'; |
|
689 | 689 | |
690 | - foreach ( array_keys( $columns ) as $key ) { |
|
690 | + foreach ( array_keys( $columns ) as $key ) { |
|
691 | 691 | |
692 | - $class = 'text-left'; |
|
692 | + $class = 'text-left'; |
|
693 | 693 | |
694 | - echo "<td class='p-2 text-left'>"; |
|
694 | + echo "<td class='p-2 text-left'>"; |
|
695 | 695 | |
696 | - switch ( $key ) { |
|
696 | + switch ( $key ) { |
|
697 | 697 | |
698 | - case 'item_name': |
|
699 | - echo esc_html( $subscription_group_fee['name'] ); |
|
700 | - break; |
|
698 | + case 'item_name': |
|
699 | + echo esc_html( $subscription_group_fee['name'] ); |
|
700 | + break; |
|
701 | 701 | |
702 | - case 'price': |
|
703 | - echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
704 | - break; |
|
702 | + case 'price': |
|
703 | + echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
704 | + break; |
|
705 | 705 | |
706 | - case 'tax': |
|
707 | - echo '—'; |
|
708 | - break; |
|
706 | + case 'tax': |
|
707 | + echo '—'; |
|
708 | + break; |
|
709 | 709 | |
710 | - case 'discount': |
|
711 | - echo '—'; |
|
712 | - break; |
|
710 | + case 'discount': |
|
711 | + echo '—'; |
|
712 | + break; |
|
713 | 713 | |
714 | - case 'initial': |
|
715 | - echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
716 | - break; |
|
714 | + case 'initial': |
|
715 | + echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
716 | + break; |
|
717 | 717 | |
718 | - case 'recurring': |
|
719 | - echo '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>'; |
|
720 | - break; |
|
718 | + case 'recurring': |
|
719 | + echo '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>'; |
|
720 | + break; |
|
721 | 721 | |
722 | - } |
|
722 | + } |
|
723 | 723 | |
724 | - echo '</td>'; |
|
724 | + echo '</td>'; |
|
725 | 725 | |
726 | - } |
|
726 | + } |
|
727 | 727 | |
728 | - echo '</tr>'; |
|
728 | + echo '</tr>'; |
|
729 | 729 | |
730 | - endforeach; |
|
731 | - ?> |
|
730 | + endforeach; |
|
731 | + ?> |
|
732 | 732 | |
733 | 733 | </tbody> |
734 | 734 | |
@@ -747,38 +747,38 @@ discard block |
||
747 | 747 | */ |
748 | 748 | function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) { |
749 | 749 | |
750 | - // Fetch the subscription groups. |
|
751 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
752 | - |
|
753 | - if ( empty( $subscription_groups ) ) { |
|
754 | - return; |
|
755 | - } |
|
756 | - |
|
757 | - // Prepare table columns. |
|
758 | - $columns = apply_filters( |
|
759 | - 'getpaid_subscription_related_subscriptions_columns', |
|
760 | - array( |
|
761 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
762 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
763 | - 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
764 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
765 | - 'item' => __( 'Items', 'invoicing' ), |
|
766 | - 'status' => __( 'Status', 'invoicing' ), |
|
767 | - ), |
|
768 | - $subscription |
|
769 | - ); |
|
770 | - |
|
771 | - if ( $subscription->get_status() == 'pending' ) { |
|
772 | - unset( $columns['start_date'], $columns['renewal_date'] ); |
|
773 | - } |
|
774 | - |
|
775 | - $table_class = 'w-100 bg-white'; |
|
776 | - |
|
777 | - if ( ! is_admin() ) { |
|
778 | - $table_class = 'table table-bordered'; |
|
779 | - } |
|
780 | - |
|
781 | - ?> |
|
750 | + // Fetch the subscription groups. |
|
751 | + $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
752 | + |
|
753 | + if ( empty( $subscription_groups ) ) { |
|
754 | + return; |
|
755 | + } |
|
756 | + |
|
757 | + // Prepare table columns. |
|
758 | + $columns = apply_filters( |
|
759 | + 'getpaid_subscription_related_subscriptions_columns', |
|
760 | + array( |
|
761 | + 'subscription' => __( 'Subscription', 'invoicing' ), |
|
762 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
763 | + 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
764 | + 'renewals' => __( 'Payments', 'invoicing' ), |
|
765 | + 'item' => __( 'Items', 'invoicing' ), |
|
766 | + 'status' => __( 'Status', 'invoicing' ), |
|
767 | + ), |
|
768 | + $subscription |
|
769 | + ); |
|
770 | + |
|
771 | + if ( $subscription->get_status() == 'pending' ) { |
|
772 | + unset( $columns['start_date'], $columns['renewal_date'] ); |
|
773 | + } |
|
774 | + |
|
775 | + $table_class = 'w-100 bg-white'; |
|
776 | + |
|
777 | + if ( ! is_admin() ) { |
|
778 | + $table_class = 'table table-bordered'; |
|
779 | + } |
|
780 | + |
|
781 | + ?> |
|
782 | 782 | <div class="m-0" style="overflow: auto;"> |
783 | 783 | |
784 | 784 | <table class="<?php echo esc_attr( $table_class ); ?>"> |
@@ -787,14 +787,14 @@ discard block |
||
787 | 787 | <tr> |
788 | 788 | <?php |
789 | 789 | |
790 | - foreach ( $columns as $key => $label ) { |
|
791 | - $key = esc_attr( $key ); |
|
792 | - $label = esc_html( $label ); |
|
793 | - $class = 'text-left'; |
|
790 | + foreach ( $columns as $key => $label ) { |
|
791 | + $key = esc_attr( $key ); |
|
792 | + $label = esc_html( $label ); |
|
793 | + $class = 'text-left'; |
|
794 | 794 | |
795 | - echo "<th class='related-subscription-field-$key bg-light p-2 text-left color-dark font-weight-bold'>$label</th>"; |
|
796 | - } |
|
797 | - ?> |
|
795 | + echo "<th class='related-subscription-field-$key bg-light p-2 text-left color-dark font-weight-bold'>$label</th>"; |
|
796 | + } |
|
797 | + ?> |
|
798 | 798 | </tr> |
799 | 799 | </thead> |
800 | 800 | |
@@ -802,74 +802,74 @@ discard block |
||
802 | 802 | |
803 | 803 | <?php |
804 | 804 | |
805 | - foreach ( $subscription_groups as $subscription_group ) : |
|
805 | + foreach ( $subscription_groups as $subscription_group ) : |
|
806 | 806 | |
807 | - // Do not list current subscription. |
|
808 | - if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
809 | - continue; |
|
810 | - } |
|
807 | + // Do not list current subscription. |
|
808 | + if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
809 | + continue; |
|
810 | + } |
|
811 | 811 | |
812 | - // Ensure the subscription exists. |
|
813 | - $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
812 | + // Ensure the subscription exists. |
|
813 | + $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
814 | 814 | |
815 | - if ( ! $_suscription->exists() ) { |
|
816 | - continue; |
|
817 | - } |
|
815 | + if ( ! $_suscription->exists() ) { |
|
816 | + continue; |
|
817 | + } |
|
818 | 818 | |
819 | - echo '<tr>'; |
|
819 | + echo '<tr>'; |
|
820 | 820 | |
821 | - foreach ( array_keys( $columns ) as $key ) { |
|
821 | + foreach ( array_keys( $columns ) as $key ) { |
|
822 | 822 | |
823 | - $class = 'text-left'; |
|
823 | + $class = 'text-left'; |
|
824 | 824 | |
825 | - echo "<td class='p-2 text-left'>"; |
|
825 | + echo "<td class='p-2 text-left'>"; |
|
826 | 826 | |
827 | - switch ( $key ) { |
|
827 | + switch ( $key ) { |
|
828 | 828 | |
829 | - case 'status': |
|
830 | - echo wp_kses_post( $_suscription->get_status_label_html() ); |
|
831 | - break; |
|
829 | + case 'status': |
|
830 | + echo wp_kses_post( $_suscription->get_status_label_html() ); |
|
831 | + break; |
|
832 | 832 | |
833 | - case 'item': |
|
834 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
835 | - echo implode( ' | ', $markup ); |
|
836 | - break; |
|
833 | + case 'item': |
|
834 | + $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
835 | + echo implode( ' | ', $markup ); |
|
836 | + break; |
|
837 | 837 | |
838 | - case 'renewals': |
|
839 | - $max_bills = $_suscription->get_bill_times(); |
|
840 | - echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
841 | - break; |
|
838 | + case 'renewals': |
|
839 | + $max_bills = $_suscription->get_bill_times(); |
|
840 | + echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
841 | + break; |
|
842 | 842 | |
843 | - case 'renewal_date': |
|
844 | - echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : '—'; |
|
845 | - break; |
|
843 | + case 'renewal_date': |
|
844 | + echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : '—'; |
|
845 | + break; |
|
846 | 846 | |
847 | - case 'start_date': |
|
848 | - echo 'pending' == $_suscription->get_status() ? '—' : getpaid_format_date_value( $_suscription->get_date_created() ); |
|
849 | - break; |
|
847 | + case 'start_date': |
|
848 | + echo 'pending' == $_suscription->get_status() ? '—' : getpaid_format_date_value( $_suscription->get_date_created() ); |
|
849 | + break; |
|
850 | 850 | |
851 | - case 'subscription': |
|
852 | - $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
853 | - printf( |
|
851 | + case 'subscription': |
|
852 | + $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
853 | + printf( |
|
854 | 854 | '%1$s#%2$s%3$s', |
855 | 855 | '<a href="' . esc_url( $url ) . '">', |
856 | 856 | '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
857 | - '</a>' |
|
857 | + '</a>' |
|
858 | 858 | ); |
859 | 859 | |
860 | - echo WPInv_Subscriptions_List_Table::column_amount( $_suscription ); |
|
861 | - break; |
|
860 | + echo WPInv_Subscriptions_List_Table::column_amount( $_suscription ); |
|
861 | + break; |
|
862 | 862 | |
863 | - } |
|
863 | + } |
|
864 | 864 | |
865 | - echo '</td>'; |
|
865 | + echo '</td>'; |
|
866 | 866 | |
867 | - } |
|
867 | + } |
|
868 | 868 | |
869 | - echo '</tr>'; |
|
869 | + echo '</tr>'; |
|
870 | 870 | |
871 | - endforeach; |
|
872 | - ?> |
|
871 | + endforeach; |
|
872 | + ?> |
|
873 | 873 | |
874 | 874 | </tbody> |
875 | 875 |
@@ -21,101 +21,101 @@ |
||
21 | 21 | global $wp_settings_fields; |
22 | 22 | |
23 | 23 | if ( isset( $wp_settings_fields[ $page ][ $section ] ) ) { |
24 | - $settings = $wp_settings_fields[ $page ][ $section ]; |
|
25 | - |
|
26 | - foreach ( $settings as $field ) { |
|
27 | - |
|
28 | - $name = esc_attr( $field['id'] ); |
|
29 | - $id = sanitize_key( $name ); |
|
30 | - $class = ''; |
|
31 | - $value = isset( $field['args']['std'] ) ? $field['args']['std'] : ''; |
|
32 | - $value = wpinv_clean( wpinv_get_option( $field['args']['id'], $value ) ); |
|
33 | - $help_text = isset( $field['args']['desc'] ) ? wp_kses_post( $field['args']['desc'] ) : ''; |
|
34 | - $type = str_replace( 'wpinv_', '', str_replace( '_callback', '', $field['callback'] ) ); |
|
35 | - $label = isset( $field['args']['name'] ) ? wp_kses_post( $field['args']['name'] ) : ''; |
|
36 | - $options = isset( $field['args']['options'] ) ? $field['args']['options'] : array(); |
|
37 | - |
|
38 | - if ( false !== strpos( $name, 'logo' ) ) { |
|
39 | - $type = 'hidden'; |
|
24 | + $settings = $wp_settings_fields[ $page ][ $section ]; |
|
25 | + |
|
26 | + foreach ( $settings as $field ) { |
|
27 | + |
|
28 | + $name = esc_attr( $field['id'] ); |
|
29 | + $id = sanitize_key( $name ); |
|
30 | + $class = ''; |
|
31 | + $value = isset( $field['args']['std'] ) ? $field['args']['std'] : ''; |
|
32 | + $value = wpinv_clean( wpinv_get_option( $field['args']['id'], $value ) ); |
|
33 | + $help_text = isset( $field['args']['desc'] ) ? wp_kses_post( $field['args']['desc'] ) : ''; |
|
34 | + $type = str_replace( 'wpinv_', '', str_replace( '_callback', '', $field['callback'] ) ); |
|
35 | + $label = isset( $field['args']['name'] ) ? wp_kses_post( $field['args']['name'] ) : ''; |
|
36 | + $options = isset( $field['args']['options'] ) ? $field['args']['options'] : array(); |
|
37 | + |
|
38 | + if ( false !== strpos( $name, 'logo' ) ) { |
|
39 | + $type = 'hidden'; |
|
40 | 40 | } |
41 | 41 | |
42 | - if ( 'country_states' == $type ) { |
|
42 | + if ( 'country_states' == $type ) { |
|
43 | 43 | |
44 | - if ( 0 == count( wpinv_get_country_states( wpinv_get_default_country() ) ) ) { |
|
45 | - $type = 'text'; |
|
44 | + if ( 0 == count( wpinv_get_country_states( wpinv_get_default_country() ) ) ) { |
|
45 | + $type = 'text'; |
|
46 | 46 | } else { |
47 | - $type = 'select'; |
|
47 | + $type = 'select'; |
|
48 | 48 | } |
49 | 49 | |
50 | - $class = 'getpaid_js_field-state'; |
|
50 | + $class = 'getpaid_js_field-state'; |
|
51 | 51 | } |
52 | 52 | |
53 | - if ( 'wpinv_settings[default_country]' == $name ) { |
|
54 | - $class = 'getpaid_js_field-country'; |
|
53 | + if ( 'wpinv_settings[default_country]' == $name ) { |
|
54 | + $class = 'getpaid_js_field-country'; |
|
55 | 55 | } |
56 | 56 | |
57 | - switch ( $type ) { |
|
57 | + switch ( $type ) { |
|
58 | 58 | |
59 | - case 'hidden': |
|
60 | - echo "<input type='hidden' id='$id' name='$name' value='$value' />"; |
|
61 | - break; |
|
62 | - case 'text': |
|
59 | + case 'hidden': |
|
60 | + echo "<input type='hidden' id='$id' name='$name' value='$value' />"; |
|
61 | + break; |
|
62 | + case 'text': |
|
63 | 63 | case 'number': |
64 | - echo aui()->input( |
|
64 | + echo aui()->input( |
|
65 | 65 | array( |
66 | - 'type' => $type, |
|
67 | - 'id' => $id, |
|
68 | - 'name' => $name, |
|
69 | - 'value' => is_scalar( $value ) ? esc_attr( $value ) : '', |
|
70 | - 'required' => false, |
|
71 | - 'help_text' => $help_text, |
|
72 | - 'label' => $label, |
|
73 | - 'class' => $class, |
|
74 | - 'label_type' => 'floating', |
|
75 | - 'label_class' => 'settings-label', |
|
66 | + 'type' => $type, |
|
67 | + 'id' => $id, |
|
68 | + 'name' => $name, |
|
69 | + 'value' => is_scalar( $value ) ? esc_attr( $value ) : '', |
|
70 | + 'required' => false, |
|
71 | + 'help_text' => $help_text, |
|
72 | + 'label' => $label, |
|
73 | + 'class' => $class, |
|
74 | + 'label_type' => 'floating', |
|
75 | + 'label_class' => 'settings-label', |
|
76 | 76 | ) |
77 | 77 | ); |
78 | - break; |
|
79 | - case 'textarea': |
|
80 | - $textarea = aui()->textarea( |
|
81 | - array( |
|
82 | - 'id' => $id, |
|
83 | - 'name' => $name, |
|
84 | - 'value' => is_scalar( $value ) ? esc_textarea( $value ) : '', |
|
85 | - 'required' => false, |
|
86 | - 'help_text' => $help_text, |
|
87 | - 'label' => $label, |
|
88 | - 'rows' => '4', |
|
89 | - 'class' => $class, |
|
90 | - 'label_type' => 'floating', |
|
91 | - 'label_class' => 'settings-label', |
|
92 | - ) |
|
93 | - ); |
|
94 | - |
|
95 | - // Bug fixed in AUI 0.1.51 for name stripping [] |
|
96 | - echo str_replace( sanitize_html_class( $name ), esc_attr( $name ), $textarea ); |
|
97 | - |
|
98 | - break; |
|
99 | - case 'select': |
|
100 | - echo aui()->select( |
|
101 | - array( |
|
102 | - 'id' => $id, |
|
103 | - 'name' => $name, |
|
104 | - 'placeholder' => '', |
|
105 | - 'value' => is_scalar( $value ) ? esc_attr( $value ) : '', |
|
106 | - 'required' => false, |
|
107 | - 'help_text' => $help_text, |
|
108 | - 'label' => $label, |
|
109 | - 'options' => $options, |
|
110 | - 'label_type' => 'floating', |
|
111 | - 'label_class' => 'settings-label', |
|
112 | - 'class' => $class, |
|
113 | - ) |
|
114 | - ); |
|
115 | - break; |
|
116 | - default: |
|
117 | - // Do something. |
|
118 | - break; |
|
78 | + break; |
|
79 | + case 'textarea': |
|
80 | + $textarea = aui()->textarea( |
|
81 | + array( |
|
82 | + 'id' => $id, |
|
83 | + 'name' => $name, |
|
84 | + 'value' => is_scalar( $value ) ? esc_textarea( $value ) : '', |
|
85 | + 'required' => false, |
|
86 | + 'help_text' => $help_text, |
|
87 | + 'label' => $label, |
|
88 | + 'rows' => '4', |
|
89 | + 'class' => $class, |
|
90 | + 'label_type' => 'floating', |
|
91 | + 'label_class' => 'settings-label', |
|
92 | + ) |
|
93 | + ); |
|
94 | + |
|
95 | + // Bug fixed in AUI 0.1.51 for name stripping [] |
|
96 | + echo str_replace( sanitize_html_class( $name ), esc_attr( $name ), $textarea ); |
|
97 | + |
|
98 | + break; |
|
99 | + case 'select': |
|
100 | + echo aui()->select( |
|
101 | + array( |
|
102 | + 'id' => $id, |
|
103 | + 'name' => $name, |
|
104 | + 'placeholder' => '', |
|
105 | + 'value' => is_scalar( $value ) ? esc_attr( $value ) : '', |
|
106 | + 'required' => false, |
|
107 | + 'help_text' => $help_text, |
|
108 | + 'label' => $label, |
|
109 | + 'options' => $options, |
|
110 | + 'label_type' => 'floating', |
|
111 | + 'label_class' => 'settings-label', |
|
112 | + 'class' => $class, |
|
113 | + ) |
|
114 | + ); |
|
115 | + break; |
|
116 | + default: |
|
117 | + // Do something. |
|
118 | + break; |
|
119 | 119 | } |
120 | 120 | } |
121 | 121 | } |
@@ -12,49 +12,49 @@ discard block |
||
12 | 12 | */ |
13 | 13 | class GetPaid_Reports { |
14 | 14 | |
15 | - /** |
|
16 | - * Class constructor. |
|
17 | - * |
|
18 | - */ |
|
19 | - public function __construct() { |
|
20 | - add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 ); |
|
21 | - add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) ); |
|
22 | - add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) ); |
|
23 | - add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) ); |
|
24 | - add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) ); |
|
25 | - |
|
26 | - } |
|
27 | - |
|
28 | - /** |
|
29 | - * Registers the reports page. |
|
30 | - * |
|
31 | - */ |
|
32 | - public function register_reports_page() { |
|
33 | - |
|
34 | - add_submenu_page( |
|
15 | + /** |
|
16 | + * Class constructor. |
|
17 | + * |
|
18 | + */ |
|
19 | + public function __construct() { |
|
20 | + add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 ); |
|
21 | + add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) ); |
|
22 | + add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) ); |
|
23 | + add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) ); |
|
24 | + add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) ); |
|
25 | + |
|
26 | + } |
|
27 | + |
|
28 | + /** |
|
29 | + * Registers the reports page. |
|
30 | + * |
|
31 | + */ |
|
32 | + public function register_reports_page() { |
|
33 | + |
|
34 | + add_submenu_page( |
|
35 | 35 | 'wpinv', |
36 | 36 | __( 'Reports', 'invoicing' ), |
37 | 37 | __( 'Reports', 'invoicing' ), |
38 | 38 | wpinv_get_capability(), |
39 | 39 | 'wpinv-reports', |
40 | 40 | array( $this, 'display_reports_page' ) |
41 | - ); |
|
41 | + ); |
|
42 | 42 | |
43 | - } |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * Displays the reports page. |
|
47 | - * |
|
48 | - */ |
|
49 | - public function display_reports_page() { |
|
45 | + /** |
|
46 | + * Displays the reports page. |
|
47 | + * |
|
48 | + */ |
|
49 | + public function display_reports_page() { |
|
50 | 50 | |
51 | - // Prepare variables. |
|
52 | - $tabs = $this->get_tabs(); |
|
53 | - $current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports'; |
|
54 | - $current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports'; |
|
51 | + // Prepare variables. |
|
52 | + $tabs = $this->get_tabs(); |
|
53 | + $current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports'; |
|
54 | + $current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports'; |
|
55 | 55 | |
56 | - // Display the current tab. |
|
57 | - ?> |
|
56 | + // Display the current tab. |
|
57 | + ?> |
|
58 | 58 | |
59 | 59 | <div class="wrap"> |
60 | 60 | |
@@ -63,19 +63,19 @@ discard block |
||
63 | 63 | <nav class="nav-tab-wrapper"> |
64 | 64 | |
65 | 65 | <?php |
66 | - foreach ( $tabs as $key => $label ) { |
|
66 | + foreach ( $tabs as $key => $label ) { |
|
67 | 67 | |
68 | - $key = sanitize_key( $key ); |
|
69 | - $label = esc_html( $label ); |
|
70 | - $class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab'; |
|
71 | - $url = esc_url( |
|
68 | + $key = sanitize_key( $key ); |
|
69 | + $label = esc_html( $label ); |
|
70 | + $class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab'; |
|
71 | + $url = esc_url( |
|
72 | 72 | add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) ) |
73 | 73 | ); |
74 | 74 | |
75 | - echo "\n\t\t\t<a href='$url' class='$class'>$label</a>"; |
|
75 | + echo "\n\t\t\t<a href='$url' class='$class'>$label</a>"; |
|
76 | 76 | |
77 | - } |
|
78 | - ?> |
|
77 | + } |
|
78 | + ?> |
|
79 | 79 | |
80 | 80 | </nav> |
81 | 81 | |
@@ -86,82 +86,82 @@ discard block |
||
86 | 86 | </div> |
87 | 87 | <?php |
88 | 88 | |
89 | - // Wordfence loads an unsupported version of chart js on our page. |
|
90 | - wp_deregister_style( 'chart-js' ); |
|
91 | - wp_deregister_script( 'chart-js' ); |
|
92 | - wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array( 'jquery' ), '3.7.1', true ); |
|
89 | + // Wordfence loads an unsupported version of chart js on our page. |
|
90 | + wp_deregister_style( 'chart-js' ); |
|
91 | + wp_deregister_script( 'chart-js' ); |
|
92 | + wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array( 'jquery' ), '3.7.1', true ); |
|
93 | 93 | |
94 | - } |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * Retrieves reports page tabs. |
|
98 | - * |
|
99 | - * @return array |
|
100 | - */ |
|
101 | - public function get_tabs() { |
|
96 | + /** |
|
97 | + * Retrieves reports page tabs. |
|
98 | + * |
|
99 | + * @return array |
|
100 | + */ |
|
101 | + public function get_tabs() { |
|
102 | 102 | |
103 | - $tabs = array( |
|
104 | - 'reports' => __( 'Reports', 'invoicing' ), |
|
105 | - 'export' => __( 'Export', 'invoicing' ), |
|
106 | - ); |
|
103 | + $tabs = array( |
|
104 | + 'reports' => __( 'Reports', 'invoicing' ), |
|
105 | + 'export' => __( 'Export', 'invoicing' ), |
|
106 | + ); |
|
107 | 107 | |
108 | - return apply_filters( 'getpaid_report_tabs', $tabs ); |
|
109 | - } |
|
108 | + return apply_filters( 'getpaid_report_tabs', $tabs ); |
|
109 | + } |
|
110 | 110 | |
111 | - /** |
|
112 | - * Displays the reports tab. |
|
113 | - * |
|
114 | - */ |
|
115 | - public function display_reports_tab() { |
|
111 | + /** |
|
112 | + * Displays the reports tab. |
|
113 | + * |
|
114 | + */ |
|
115 | + public function display_reports_tab() { |
|
116 | 116 | |
117 | - $reports = new GetPaid_Reports_Report(); |
|
118 | - $reports->display(); |
|
117 | + $reports = new GetPaid_Reports_Report(); |
|
118 | + $reports->display(); |
|
119 | 119 | |
120 | - } |
|
120 | + } |
|
121 | 121 | |
122 | - /** |
|
123 | - * Displays the exports tab. |
|
124 | - * |
|
125 | - */ |
|
126 | - public function display_exports_tab() { |
|
122 | + /** |
|
123 | + * Displays the exports tab. |
|
124 | + * |
|
125 | + */ |
|
126 | + public function display_exports_tab() { |
|
127 | 127 | |
128 | - $exports = new GetPaid_Reports_Export(); |
|
129 | - $exports->display(); |
|
128 | + $exports = new GetPaid_Reports_Export(); |
|
129 | + $exports->display(); |
|
130 | 130 | |
131 | - } |
|
131 | + } |
|
132 | 132 | |
133 | - /** |
|
134 | - * Donwnloads a graph. |
|
135 | - * |
|
136 | - * @param array $args |
|
137 | - */ |
|
138 | - public function download_graph( $args ) { |
|
133 | + /** |
|
134 | + * Donwnloads a graph. |
|
135 | + * |
|
136 | + * @param array $args |
|
137 | + */ |
|
138 | + public function download_graph( $args ) { |
|
139 | 139 | |
140 | - if ( ! empty( $args['graph'] ) ) { |
|
141 | - $downloader = new GetPaid_Graph_Downloader(); |
|
142 | - $downloader->download( $args['graph'] ); |
|
143 | - } |
|
140 | + if ( ! empty( $args['graph'] ) ) { |
|
141 | + $downloader = new GetPaid_Graph_Downloader(); |
|
142 | + $downloader->download( $args['graph'] ); |
|
143 | + } |
|
144 | 144 | |
145 | - } |
|
145 | + } |
|
146 | 146 | |
147 | - /** |
|
148 | - * Exports invoices. |
|
149 | - * |
|
150 | - * @param array $args |
|
151 | - */ |
|
152 | - public function export_invoices( $args ) { |
|
147 | + /** |
|
148 | + * Exports invoices. |
|
149 | + * |
|
150 | + * @param array $args |
|
151 | + */ |
|
152 | + public function export_invoices( $args ) { |
|
153 | 153 | |
154 | - if ( ! empty( $args['post_type'] ) ) { |
|
154 | + if ( ! empty( $args['post_type'] ) ) { |
|
155 | 155 | |
156 | - if ( 'subscriptions' === $args['post_type'] ) { |
|
157 | - $downloader = new GetPaid_Subscription_Exporter(); |
|
158 | - } else { |
|
159 | - $downloader = new GetPaid_Invoice_Exporter(); |
|
160 | - } |
|
156 | + if ( 'subscriptions' === $args['post_type'] ) { |
|
157 | + $downloader = new GetPaid_Subscription_Exporter(); |
|
158 | + } else { |
|
159 | + $downloader = new GetPaid_Invoice_Exporter(); |
|
160 | + } |
|
161 | 161 | |
162 | - $downloader->export( $args['post_type'], $args ); |
|
163 | - } |
|
162 | + $downloader->export( $args['post_type'], $args ); |
|
163 | + } |
|
164 | 164 | |
165 | - } |
|
165 | + } |
|
166 | 166 | |
167 | 167 | } |