@@ -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->exists() ) { |
|
84 | + $sub = new WPInv_Subscription((int) $_GET['id']); |
|
85 | + if (!$sub->exists()) { |
|
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,41 +95,41 @@ 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' ); |
|
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 | 100 | |
101 | 101 | $subscription_id = $sub->get_id(); |
102 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
103 | - $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
102 | + $subscription_groups = getpaid_get_invoice_subscription_groups($sub->get_parent_invoice_id()); |
|
103 | + $subscription_group = wp_list_filter($subscription_groups, compact('subscription_id')); |
|
104 | 104 | |
105 | - if ( ! empty( $subscription_group ) ) { |
|
106 | - add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'advanced' ); |
|
105 | + if (!empty($subscription_group)) { |
|
106 | + add_meta_box('getpaid_admin_subscription_item_details_metabox', __('Subscription Items', 'invoicing'), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'advanced'); |
|
107 | 107 | } |
108 | 108 | |
109 | - add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced', 'low' ); |
|
109 | + add_meta_box('getpaid_admin_subscription_invoice_details_metabox', __('Related Invoices', 'invoicing'), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced', 'low'); |
|
110 | 110 | |
111 | - do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
111 | + do_action('getpaid_admin_single_subscription_register_metabox', $sub); |
|
112 | 112 | |
113 | 113 | ?> |
114 | 114 | |
115 | - <form method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ); ?>"> |
|
115 | + <form method="post" action="<?php echo admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($sub->get_id())); ?>"> |
|
116 | 116 | |
117 | - <?php wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); ?> |
|
118 | - <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> |
|
119 | - <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> |
|
117 | + <?php wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); ?> |
|
118 | + <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?> |
|
119 | + <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?> |
|
120 | 120 | <input type="hidden" name="getpaid-admin-action" value="update_single_subscription" /> |
121 | - <input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id() ;?>" /> |
|
121 | + <input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id(); ?>" /> |
|
122 | 122 | |
123 | 123 | <div id="poststuff"> |
124 | 124 | <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>"> |
125 | 125 | |
126 | 126 | <div id="postbox-container-1" class="postbox-container"> |
127 | - <?php do_meta_boxes( get_current_screen(), 'side', $sub ); ?> |
|
127 | + <?php do_meta_boxes(get_current_screen(), 'side', $sub); ?> |
|
128 | 128 | </div> |
129 | 129 | |
130 | 130 | <div id="postbox-container-2" class="postbox-container"> |
131 | - <?php do_meta_boxes( get_current_screen(), 'normal', $sub ); ?> |
|
132 | - <?php do_meta_boxes( get_current_screen(), 'advanced', $sub ); ?> |
|
131 | + <?php do_meta_boxes(get_current_screen(), 'normal', $sub); ?> |
|
132 | + <?php do_meta_boxes(get_current_screen(), 'advanced', $sub); ?> |
|
133 | 133 | </div> |
134 | 134 | |
135 | 135 | </div> |
@@ -148,44 +148,44 @@ discard block |
||
148 | 148 | * |
149 | 149 | * @param WPInv_Subscription $sub |
150 | 150 | */ |
151 | -function getpaid_admin_subscription_details_metabox( $sub ) { |
|
151 | +function getpaid_admin_subscription_details_metabox($sub) { |
|
152 | 152 | |
153 | 153 | // Subscription items. |
154 | - $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
155 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
154 | + $subscription_group = getpaid_get_invoice_subscription_group($sub->get_parent_invoice_id(), $sub->get_id()); |
|
155 | + $items_count = empty($subscription_group) ? 1 : count($subscription_group['items']); |
|
156 | 156 | |
157 | 157 | // Prepare subscription detail columns. |
158 | 158 | $fields = apply_filters( |
159 | 159 | 'getpaid_subscription_admin_page_fields', |
160 | 160 | array( |
161 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
162 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
163 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
164 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
165 | - 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
166 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
167 | - 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
168 | - 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
169 | - 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
170 | - 'status' => __( 'Status', 'invoicing' ), |
|
161 | + 'subscription' => __('Subscription', 'invoicing'), |
|
162 | + 'customer' => __('Customer', 'invoicing'), |
|
163 | + 'amount' => __('Amount', 'invoicing'), |
|
164 | + 'start_date' => __('Start Date', 'invoicing'), |
|
165 | + 'renews_on' => __('Next Payment', 'invoicing'), |
|
166 | + 'renewals' => __('Payments', 'invoicing'), |
|
167 | + 'item' => _n('Item', 'Items', $items_count, 'invoicing'), |
|
168 | + 'gateway' => __('Payment Method', 'invoicing'), |
|
169 | + 'profile_id' => __('Profile ID', 'invoicing'), |
|
170 | + 'status' => __('Status', 'invoicing'), |
|
171 | 171 | ) |
172 | 172 | ); |
173 | 173 | |
174 | - if ( ! $sub->is_active() ) { |
|
174 | + if (!$sub->is_active()) { |
|
175 | 175 | |
176 | - if ( isset( $fields['renews_on'] ) ) { |
|
177 | - unset( $fields['renews_on'] ); |
|
176 | + if (isset($fields['renews_on'])) { |
|
177 | + unset($fields['renews_on']); |
|
178 | 178 | } |
179 | 179 | |
180 | - if ( isset( $fields['gateway'] ) ) { |
|
181 | - unset( $fields['gateway'] ); |
|
180 | + if (isset($fields['gateway'])) { |
|
181 | + unset($fields['gateway']); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | } |
185 | 185 | |
186 | 186 | $profile_id = $sub->get_profile_id(); |
187 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
188 | - unset( $fields['profile_id'] ); |
|
187 | + if (empty($profile_id) && isset($fields['profile_id'])) { |
|
188 | + unset($fields['profile_id']); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | ?> |
@@ -193,16 +193,16 @@ discard block |
||
193 | 193 | <table class="table table-borderless" style="font-size: 14px;"> |
194 | 194 | <tbody> |
195 | 195 | |
196 | - <?php foreach ( $fields as $key => $label ) : ?> |
|
196 | + <?php foreach ($fields as $key => $label) : ?> |
|
197 | 197 | |
198 | - <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class( $key ); ?>"> |
|
198 | + <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class($key); ?>"> |
|
199 | 199 | |
200 | 200 | <th class="w-25" style="font-weight: 500;"> |
201 | - <?php echo sanitize_text_field( $label ); ?> |
|
201 | + <?php echo sanitize_text_field($label); ?> |
|
202 | 202 | </th> |
203 | 203 | |
204 | 204 | <td class="w-75 text-muted"> |
205 | - <?php do_action( 'getpaid_subscription_admin_display_' . sanitize_text_field( $key ), $sub, $subscription_group ); ?> |
|
205 | + <?php do_action('getpaid_subscription_admin_display_' . sanitize_text_field($key), $sub, $subscription_group); ?> |
|
206 | 206 | </td> |
207 | 207 | |
208 | 208 | </tr> |
@@ -220,129 +220,129 @@ discard block |
||
220 | 220 | * |
221 | 221 | * @param WPInv_Subscription $subscription |
222 | 222 | */ |
223 | -function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
|
223 | +function getpaid_admin_subscription_metabox_display_customer($subscription) { |
|
224 | 224 | |
225 | - $username = __( '(Missing User)', 'invoicing' ); |
|
225 | + $username = __('(Missing User)', 'invoicing'); |
|
226 | 226 | |
227 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
228 | - if ( $user ) { |
|
227 | + $user = get_userdata($subscription->get_customer_id()); |
|
228 | + if ($user) { |
|
229 | 229 | |
230 | 230 | $username = sprintf( |
231 | 231 | '<a href="user-edit.php?user_id=%s">%s</a>', |
232 | - absint( $user->ID ), |
|
233 | - ! empty( $user->display_name ) ? sanitize_text_field( $user->display_name ) : sanitize_email( $user->user_email ) |
|
232 | + absint($user->ID), |
|
233 | + !empty($user->display_name) ? sanitize_text_field($user->display_name) : sanitize_email($user->user_email) |
|
234 | 234 | ); |
235 | 235 | |
236 | 236 | } |
237 | 237 | |
238 | 238 | echo $username; |
239 | 239 | } |
240 | -add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
|
240 | +add_action('getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer'); |
|
241 | 241 | |
242 | 242 | /** |
243 | 243 | * Displays the subscription amount. |
244 | 244 | * |
245 | 245 | * @param WPInv_Subscription $subscription |
246 | 246 | */ |
247 | -function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
|
248 | - $amount = sanitize_text_field( getpaid_get_formatted_subscription_amount( $subscription ) ); |
|
247 | +function getpaid_admin_subscription_metabox_display_amount($subscription) { |
|
248 | + $amount = sanitize_text_field(getpaid_get_formatted_subscription_amount($subscription)); |
|
249 | 249 | echo "<span>$amount</span>"; |
250 | 250 | } |
251 | -add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
|
251 | +add_action('getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount'); |
|
252 | 252 | |
253 | 253 | /** |
254 | 254 | * Displays the subscription id. |
255 | 255 | * |
256 | 256 | * @param WPInv_Subscription $subscription |
257 | 257 | */ |
258 | -function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
|
259 | - echo '#' . absint( $subscription->get_id() ); |
|
258 | +function getpaid_admin_subscription_metabox_display_id($subscription) { |
|
259 | + echo '#' . absint($subscription->get_id()); |
|
260 | 260 | } |
261 | -add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
|
261 | +add_action('getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id'); |
|
262 | 262 | |
263 | 263 | /** |
264 | 264 | * Displays the subscription renewal date. |
265 | 265 | * |
266 | 266 | * @param WPInv_Subscription $subscription |
267 | 267 | */ |
268 | -function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
|
269 | - echo getpaid_format_date_value( $subscription->get_date_created() ); |
|
268 | +function getpaid_admin_subscription_metabox_display_start_date($subscription) { |
|
269 | + echo getpaid_format_date_value($subscription->get_date_created()); |
|
270 | 270 | } |
271 | -add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
|
271 | +add_action('getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date'); |
|
272 | 272 | |
273 | 273 | /** |
274 | 274 | * Displays the subscription renewal date. |
275 | 275 | * |
276 | 276 | * @param WPInv_Subscription $subscription |
277 | 277 | */ |
278 | -function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
|
279 | - echo getpaid_format_date_value( $subscription->get_expiration() ); |
|
278 | +function getpaid_admin_subscription_metabox_display_renews_on($subscription) { |
|
279 | + echo getpaid_format_date_value($subscription->get_expiration()); |
|
280 | 280 | } |
281 | -add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
|
281 | +add_action('getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on'); |
|
282 | 282 | |
283 | 283 | /** |
284 | 284 | * Displays the subscription renewal count. |
285 | 285 | * |
286 | 286 | * @param WPInv_Subscription $subscription |
287 | 287 | */ |
288 | -function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
|
288 | +function getpaid_admin_subscription_metabox_display_renewals($subscription) { |
|
289 | 289 | $max_bills = $subscription->get_bill_times(); |
290 | - echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
290 | + echo $subscription->get_times_billed() . ' / ' . (empty($max_bills) ? "∞" : $max_bills); |
|
291 | 291 | } |
292 | -add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
|
292 | +add_action('getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals'); |
|
293 | 293 | /** |
294 | 294 | * Displays the subscription item. |
295 | 295 | * |
296 | 296 | * @param WPInv_Subscription $subscription |
297 | 297 | * @param false|array $subscription_group |
298 | 298 | */ |
299 | -function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) { |
|
299 | +function getpaid_admin_subscription_metabox_display_item($subscription, $subscription_group = false) { |
|
300 | 300 | |
301 | - if ( empty( $subscription_group ) ) { |
|
302 | - echo WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ); |
|
301 | + if (empty($subscription_group)) { |
|
302 | + echo WPInv_Subscriptions_List_Table::generate_item_markup($subscription->get_product_id()); |
|
303 | 303 | return; |
304 | 304 | } |
305 | 305 | |
306 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
307 | - echo implode( ' | ', $markup ); |
|
306 | + $markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
307 | + echo implode(' | ', $markup); |
|
308 | 308 | |
309 | 309 | } |
310 | -add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 ); |
|
310 | +add_action('getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2); |
|
311 | 311 | |
312 | 312 | /** |
313 | 313 | * Displays the subscription gateway. |
314 | 314 | * |
315 | 315 | * @param WPInv_Subscription $subscription |
316 | 316 | */ |
317 | -function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
|
317 | +function getpaid_admin_subscription_metabox_display_gateway($subscription) { |
|
318 | 318 | |
319 | 319 | $gateway = $subscription->get_gateway(); |
320 | 320 | |
321 | - if ( ! empty( $gateway ) ) { |
|
322 | - echo sanitize_text_field( wpinv_get_gateway_admin_label( $gateway ) ); |
|
321 | + if (!empty($gateway)) { |
|
322 | + echo sanitize_text_field(wpinv_get_gateway_admin_label($gateway)); |
|
323 | 323 | } else { |
324 | 324 | echo "—"; |
325 | 325 | } |
326 | 326 | |
327 | 327 | } |
328 | -add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
|
328 | +add_action('getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway'); |
|
329 | 329 | |
330 | 330 | /** |
331 | 331 | * Displays the subscription status. |
332 | 332 | * |
333 | 333 | * @param WPInv_Subscription $subscription |
334 | 334 | */ |
335 | -function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
|
335 | +function getpaid_admin_subscription_metabox_display_status($subscription) { |
|
336 | 336 | echo $subscription->get_status_label_html(); |
337 | 337 | } |
338 | -add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
|
338 | +add_action('getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status'); |
|
339 | 339 | |
340 | 340 | /** |
341 | 341 | * Displays the subscription profile id. |
342 | 342 | * |
343 | 343 | * @param WPInv_Subscription $subscription |
344 | 344 | */ |
345 | -function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
|
345 | +function getpaid_admin_subscription_metabox_display_profile_id($subscription) { |
|
346 | 346 | |
347 | 347 | $profile_id = $subscription->get_profile_id(); |
348 | 348 | |
@@ -351,32 +351,32 @@ discard block |
||
351 | 351 | 'type' => 'text', |
352 | 352 | 'id' => 'wpinv_subscription_profile_id', |
353 | 353 | 'name' => 'wpinv_subscription_profile_id', |
354 | - 'label' => __( 'Profile Id', 'invoicing' ), |
|
354 | + 'label' => __('Profile Id', 'invoicing'), |
|
355 | 355 | 'label_type' => 'hidden', |
356 | - 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
357 | - 'value' => sanitize_text_field( $profile_id ), |
|
356 | + 'placeholder' => __('Profile Id', 'invoicing'), |
|
357 | + 'value' => sanitize_text_field($profile_id), |
|
358 | 358 | 'input_group_right' => '', |
359 | 359 | 'no_wrap' => true, |
360 | 360 | ) |
361 | 361 | ); |
362 | 362 | |
363 | - echo str_ireplace( 'form-control', 'regular-text', $input ); |
|
363 | + echo str_ireplace('form-control', 'regular-text', $input); |
|
364 | 364 | |
365 | - $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
366 | - if ( ! empty( $url ) ) { |
|
367 | - $url = esc_url_raw( $url ); |
|
368 | - echo ' <a href="' . $url . '" title="' . __( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
365 | + $url = apply_filters('getpaid_remote_subscription_profile_url', '', $subscription); |
|
366 | + if (!empty($url)) { |
|
367 | + $url = esc_url_raw($url); |
|
368 | + echo ' <a href="' . $url . '" title="' . __('View in Gateway', 'invoicing') . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | } |
372 | -add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
|
372 | +add_action('getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id'); |
|
373 | 373 | |
374 | 374 | /** |
375 | 375 | * Displays the subscriptions update metabox. |
376 | 376 | * |
377 | 377 | * @param WPInv_Subscription $subscription |
378 | 378 | */ |
379 | -function getpaid_admin_subscription_update_metabox( $subscription ) { |
|
379 | +function getpaid_admin_subscription_update_metabox($subscription) { |
|
380 | 380 | |
381 | 381 | ?> |
382 | 382 | <div class="mt-3"> |
@@ -389,10 +389,10 @@ discard block |
||
389 | 389 | 'id' => 'subscription_status_update_select', |
390 | 390 | 'required' => true, |
391 | 391 | 'no_wrap' => false, |
392 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
393 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
392 | + 'label' => __('Subscription Status', 'invoicing'), |
|
393 | + 'help_text' => __('Updating the status will trigger related actions and hooks', 'invoicing'), |
|
394 | 394 | 'select2' => true, |
395 | - 'value' => $subscription->get_status( 'edit' ), |
|
395 | + 'value' => $subscription->get_status('edit'), |
|
396 | 396 | ) |
397 | 397 | ); |
398 | 398 | ?> |
@@ -400,13 +400,13 @@ discard block |
||
400 | 400 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;"> |
401 | 401 | |
402 | 402 | <?php |
403 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
403 | + submit_button(__('Update', 'invoicing'), 'primary', 'submit', false); |
|
404 | 404 | |
405 | - $url = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) ); |
|
406 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
407 | - $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' ); |
|
405 | + $url = esc_url(wp_nonce_url(add_query_arg('getpaid-admin-action', 'subscription_manual_renew'), 'getpaid-nonce', 'getpaid-nonce')); |
|
406 | + $anchor = __('Renew Subscription', 'invoicing'); |
|
407 | + $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'); |
|
408 | 408 | |
409 | - if ( $subscription->is_active() ) { |
|
409 | + if ($subscription->is_active()) { |
|
410 | 410 | echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>"; |
411 | 411 | } |
412 | 412 | |
@@ -418,31 +418,31 @@ discard block |
||
418 | 418 | * |
419 | 419 | * @param WPInv_Subscription $subscription |
420 | 420 | */ |
421 | -function getpaid_admin_subscription_invoice_details_metabox( $subscription ) { |
|
421 | +function getpaid_admin_subscription_invoice_details_metabox($subscription) { |
|
422 | 422 | |
423 | 423 | $columns = apply_filters( |
424 | 424 | 'getpaid_subscription_related_invoices_columns', |
425 | 425 | array( |
426 | - 'invoice' => __( 'Invoice', 'invoicing' ), |
|
427 | - 'relationship' => __( 'Relationship', 'invoicing' ), |
|
428 | - 'date' => __( 'Date', 'invoicing' ), |
|
429 | - 'status' => __( 'Status', 'invoicing' ), |
|
430 | - 'total' => __( 'Total', 'invoicing' ), |
|
426 | + 'invoice' => __('Invoice', 'invoicing'), |
|
427 | + 'relationship' => __('Relationship', 'invoicing'), |
|
428 | + 'date' => __('Date', 'invoicing'), |
|
429 | + 'status' => __('Status', 'invoicing'), |
|
430 | + 'total' => __('Total', 'invoicing'), |
|
431 | 431 | ), |
432 | 432 | $subscription |
433 | 433 | ); |
434 | 434 | |
435 | 435 | // Prepare the invoices. |
436 | - $payments = $subscription->get_child_payments( ! is_admin() ); |
|
436 | + $payments = $subscription->get_child_payments(!is_admin()); |
|
437 | 437 | $parent = $subscription->get_parent_invoice(); |
438 | 438 | |
439 | - if ( $parent->get_id() ) { |
|
440 | - $payments = array_merge( array( $parent ), $payments ); |
|
439 | + if ($parent->get_id()) { |
|
440 | + $payments = array_merge(array($parent), $payments); |
|
441 | 441 | } |
442 | 442 | |
443 | 443 | $table_class = 'w-100 bg-white'; |
444 | 444 | |
445 | - if ( ! is_admin() ) { |
|
445 | + if (!is_admin()) { |
|
446 | 446 | $table_class = 'table table-bordered table-striped'; |
447 | 447 | } |
448 | 448 | |
@@ -455,13 +455,13 @@ discard block |
||
455 | 455 | <tr> |
456 | 456 | <?php |
457 | 457 | $processed_columns = 0; |
458 | - foreach ( $columns as $key => $label ) { |
|
459 | - $key = esc_attr( $key ); |
|
460 | - $label = sanitize_text_field( $label ); |
|
458 | + foreach ($columns as $key => $label) { |
|
459 | + $key = esc_attr($key); |
|
460 | + $label = sanitize_text_field($label); |
|
461 | 461 | $class = 'text-center'; |
462 | - $class = empty( $processed_columns ) ? 'text-left' : $class; |
|
463 | - $class = count( $columns ) - 1 == $processed_columns ? 'text-right' : $class; |
|
464 | - $processed_columns ++; |
|
462 | + $class = empty($processed_columns) ? 'text-left' : $class; |
|
463 | + $class = count($columns) - 1 == $processed_columns ? 'text-right' : $class; |
|
464 | + $processed_columns++; |
|
465 | 465 | |
466 | 466 | echo "<th class='subscription-invoice-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
467 | 467 | } |
@@ -471,56 +471,56 @@ discard block |
||
471 | 471 | |
472 | 472 | <tbody> |
473 | 473 | |
474 | - <?php if ( empty( $payments ) ) : ?> |
|
474 | + <?php if (empty($payments)) : ?> |
|
475 | 475 | <tr> |
476 | 476 | <td colspan="<?php echo count($columns); ?>" class="p-2 text-left text-muted"> |
477 | - <?php _e( 'This subscription has no invoices.', 'invoicing' ); ?> |
|
477 | + <?php _e('This subscription has no invoices.', 'invoicing'); ?> |
|
478 | 478 | </td> |
479 | 479 | </tr> |
480 | 480 | <?php endif; ?> |
481 | 481 | |
482 | 482 | <?php |
483 | 483 | |
484 | - foreach( $payments as $payment ) : |
|
484 | + foreach ($payments as $payment) : |
|
485 | 485 | |
486 | 486 | // Ensure that we have an invoice. |
487 | - $payment = new WPInv_Invoice( $payment ); |
|
487 | + $payment = new WPInv_Invoice($payment); |
|
488 | 488 | |
489 | 489 | // Abort if the invoice is invalid. |
490 | - if ( ! $payment->get_id() ) { |
|
490 | + if (!$payment->get_id()) { |
|
491 | 491 | continue; |
492 | 492 | } |
493 | 493 | |
494 | 494 | echo '<tr>'; |
495 | 495 | |
496 | 496 | $processed_columns = 0; |
497 | - foreach ( array_keys( $columns ) as $key ) { |
|
497 | + foreach (array_keys($columns) as $key) { |
|
498 | 498 | |
499 | 499 | $class = 'text-center'; |
500 | - $class = empty( $processed_columns ) ? 'text-left' : $class; |
|
501 | - $class = count( $columns ) - 1 == $processed_columns ? 'text-right' : $class; |
|
502 | - $processed_columns ++; |
|
500 | + $class = empty($processed_columns) ? 'text-left' : $class; |
|
501 | + $class = count($columns) - 1 == $processed_columns ? 'text-right' : $class; |
|
502 | + $processed_columns++; |
|
503 | 503 | |
504 | 504 | echo "<td class='p-2 $class'>"; |
505 | 505 | |
506 | - switch( $key ) { |
|
506 | + switch ($key) { |
|
507 | 507 | |
508 | 508 | case 'total': |
509 | - echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>'; |
|
509 | + echo '<strong>' . wpinv_price($payment->get_total(), $payment->get_currency()) . '</strong>'; |
|
510 | 510 | break; |
511 | 511 | |
512 | 512 | case 'relationship': |
513 | - echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' ); |
|
513 | + echo $payment->is_renewal() ? __('Renewal Invoice', 'invoicing') : __('Initial Invoice', 'invoicing'); |
|
514 | 514 | break; |
515 | 515 | |
516 | 516 | case 'date': |
517 | - echo getpaid_format_date_value( $payment->get_date_created() ); |
|
517 | + echo getpaid_format_date_value($payment->get_date_created()); |
|
518 | 518 | break; |
519 | 519 | |
520 | 520 | case 'status': |
521 | 521 | |
522 | 522 | $status = $payment->get_status_nicename(); |
523 | - if ( is_admin() ) { |
|
523 | + if (is_admin()) { |
|
524 | 524 | $status = $payment->get_status_label_html(); |
525 | 525 | } |
526 | 526 | |
@@ -528,13 +528,13 @@ discard block |
||
528 | 528 | break; |
529 | 529 | |
530 | 530 | case 'invoice': |
531 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
531 | + $link = esc_url(get_edit_post_link($payment->get_id())); |
|
532 | 532 | |
533 | - if ( ! is_admin() ) { |
|
534 | - $link = esc_url( $payment->get_view_url() ); |
|
533 | + if (!is_admin()) { |
|
534 | + $link = esc_url($payment->get_view_url()); |
|
535 | 535 | } |
536 | 536 | |
537 | - $invoice = sanitize_text_field( $payment->get_number() ); |
|
537 | + $invoice = sanitize_text_field($payment->get_number()); |
|
538 | 538 | echo "<a href='$link'>$invoice</a>"; |
539 | 539 | break; |
540 | 540 | } |
@@ -562,12 +562,12 @@ discard block |
||
562 | 562 | * |
563 | 563 | * @param WPInv_Subscription $subscription |
564 | 564 | */ |
565 | -function getpaid_admin_subscription_item_details_metabox( $subscription ) { |
|
565 | +function getpaid_admin_subscription_item_details_metabox($subscription) { |
|
566 | 566 | |
567 | 567 | // Fetch the subscription group. |
568 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
568 | + $subscription_group = getpaid_get_invoice_subscription_group($subscription->get_parent_payment_id(), $subscription->get_id()); |
|
569 | 569 | |
570 | - if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
570 | + if (empty($subscription_group) || empty($subscription_group['items'])) { |
|
571 | 571 | return; |
572 | 572 | } |
573 | 573 | |
@@ -575,12 +575,12 @@ discard block |
||
575 | 575 | $columns = apply_filters( |
576 | 576 | 'getpaid_subscription_item_details_columns', |
577 | 577 | array( |
578 | - 'item_name' => __( 'Item', 'invoicing' ), |
|
579 | - 'price' => __( 'Price', 'invoicing' ), |
|
580 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
581 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
582 | - 'initial' => __( 'Initial Amount', 'invoicing' ), |
|
583 | - 'recurring' => __( 'Recurring Amount', 'invoicing' ), |
|
578 | + 'item_name' => __('Item', 'invoicing'), |
|
579 | + 'price' => __('Price', 'invoicing'), |
|
580 | + 'tax' => __('Tax', 'invoicing'), |
|
581 | + 'discount' => __('Discount', 'invoicing'), |
|
582 | + 'initial' => __('Initial Amount', 'invoicing'), |
|
583 | + 'recurring' => __('Recurring Amount', 'invoicing'), |
|
584 | 584 | ), |
585 | 585 | $subscription |
586 | 586 | ); |
@@ -589,13 +589,13 @@ discard block |
||
589 | 589 | |
590 | 590 | $invoice = $subscription->get_parent_invoice(); |
591 | 591 | |
592 | - if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
593 | - unset( $columns['tax'] ); |
|
592 | + if ((!wpinv_use_taxes() || !$invoice->is_taxable()) && isset($columns['tax'])) { |
|
593 | + unset($columns['tax']); |
|
594 | 594 | } |
595 | 595 | |
596 | 596 | $table_class = 'w-100 bg-white'; |
597 | 597 | |
598 | - if ( ! is_admin() ) { |
|
598 | + if (!is_admin()) { |
|
599 | 599 | $table_class = 'table table-bordered table-striped'; |
600 | 600 | } |
601 | 601 | |
@@ -608,13 +608,13 @@ discard block |
||
608 | 608 | <tr> |
609 | 609 | <?php |
610 | 610 | $processed_columns = 0; |
611 | - foreach ( $columns as $key => $label ) { |
|
612 | - $key = esc_attr( $key ); |
|
613 | - $label = sanitize_text_field( $label ); |
|
611 | + foreach ($columns as $key => $label) { |
|
612 | + $key = esc_attr($key); |
|
613 | + $label = sanitize_text_field($label); |
|
614 | 614 | $class = 'text-center'; |
615 | - $class = empty( $processed_columns ) ? 'text-left' : $class; |
|
616 | - $class = count( $columns ) - 1 == $processed_columns ? 'text-right' : $class; |
|
617 | - $processed_columns ++; |
|
615 | + $class = empty($processed_columns) ? 'text-left' : $class; |
|
616 | + $class = count($columns) - 1 == $processed_columns ? 'text-right' : $class; |
|
617 | + $processed_columns++; |
|
618 | 618 | |
619 | 619 | echo "<th class='subscription-item-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
620 | 620 | } |
@@ -626,52 +626,52 @@ discard block |
||
626 | 626 | |
627 | 627 | <?php |
628 | 628 | |
629 | - foreach( $subscription_group['items'] as $subscription_group_item ) : |
|
629 | + foreach ($subscription_group['items'] as $subscription_group_item) : |
|
630 | 630 | |
631 | 631 | echo '<tr>'; |
632 | 632 | |
633 | 633 | $processed_columns = 0; |
634 | - foreach ( array_keys( $columns ) as $key ) { |
|
634 | + foreach (array_keys($columns) as $key) { |
|
635 | 635 | |
636 | 636 | $class = 'text-center'; |
637 | - $class = empty( $processed_columns ) ? 'text-left' : $class; |
|
638 | - $class = count( $columns ) - 1 == $processed_columns ? 'text-right' : $class; |
|
639 | - $processed_columns ++; |
|
637 | + $class = empty($processed_columns) ? 'text-left' : $class; |
|
638 | + $class = count($columns) - 1 == $processed_columns ? 'text-right' : $class; |
|
639 | + $processed_columns++; |
|
640 | 640 | |
641 | 641 | echo "<td class='p-2 $class'>"; |
642 | 642 | |
643 | - switch( $key ) { |
|
643 | + switch ($key) { |
|
644 | 644 | |
645 | 645 | case 'item_name': |
646 | - $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
647 | - $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
646 | + $item_name = get_the_title($subscription_group_item['item_id']); |
|
647 | + $item_name = empty($item_name) ? $subscription_group_item['item_name'] : $item_name; |
|
648 | 648 | |
649 | - if ( $invoice->get_template() == 'amount' || 1 === (int) $subscription_group_item['quantity'] ) { |
|
650 | - echo sanitize_text_field( $item_name ); |
|
649 | + if ($invoice->get_template() == 'amount' || 1 === (int) $subscription_group_item['quantity']) { |
|
650 | + echo sanitize_text_field($item_name); |
|
651 | 651 | } else { |
652 | - printf( '%1$s x %2$d', sanitize_text_field( $item_name ), (int) $subscription_group_item['quantity'] ); |
|
652 | + printf('%1$s x %2$d', sanitize_text_field($item_name), (int) $subscription_group_item['quantity']); |
|
653 | 653 | } |
654 | 654 | |
655 | 655 | break; |
656 | 656 | |
657 | 657 | case 'price': |
658 | - echo wpinv_price( $subscription_group_item['price'], $invoice->get_currency() ); |
|
658 | + echo wpinv_price($subscription_group_item['price'], $invoice->get_currency()); |
|
659 | 659 | break; |
660 | 660 | |
661 | 661 | case 'tax': |
662 | - echo wpinv_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
662 | + echo wpinv_price($subscription_group_item['tax'], $invoice->get_currency()); |
|
663 | 663 | break; |
664 | 664 | |
665 | 665 | case 'discount': |
666 | - echo wpinv_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
666 | + echo wpinv_price($subscription_group_item['discount'], $invoice->get_currency()); |
|
667 | 667 | break; |
668 | 668 | |
669 | 669 | case 'initial': |
670 | - echo wpinv_price( $subscription_group_item['subtotal'], $invoice->get_currency() ); |
|
670 | + echo wpinv_price($subscription_group_item['subtotal'], $invoice->get_currency()); |
|
671 | 671 | break; |
672 | 672 | |
673 | 673 | case 'recurring': |
674 | - echo '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>'; |
|
674 | + echo '<strong>' . wpinv_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()) . '</strong>'; |
|
675 | 675 | break; |
676 | 676 | |
677 | 677 | } |
@@ -3,9 +3,9 @@ discard block |
||
3 | 3 | * Displays a list of all subscriptions rules |
4 | 4 | */ |
5 | 5 | |
6 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
6 | +if (!defined('ABSPATH')) exit; |
|
7 | 7 | |
8 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
8 | +if (!class_exists('WP_List_Table')) { |
|
9 | 9 | include_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
10 | 10 | } |
11 | 11 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | $this->prepare_query(); |
80 | 80 | |
81 | - $this->base_url = remove_query_arg( 'status' ); |
|
81 | + $this->base_url = remove_query_arg('status'); |
|
82 | 82 | |
83 | 83 | } |
84 | 84 | |
@@ -91,21 +91,21 @@ discard block |
||
91 | 91 | $query = array( |
92 | 92 | 'number' => $this->per_page, |
93 | 93 | 'paged' => $this->get_paged(), |
94 | - 'status' => ( isset( $_GET['status'] ) && array_key_exists( $_GET['status'], getpaid_get_subscription_statuses() ) ) ? $_GET['status'] : 'all', |
|
95 | - 'orderby' => ( isset( $_GET['orderby'] ) ) ? $_GET['orderby'] : 'id', |
|
96 | - 'order' => ( isset( $_GET['order'] ) ) ? $_GET['order'] : 'DESC', |
|
94 | + 'status' => (isset($_GET['status']) && array_key_exists($_GET['status'], getpaid_get_subscription_statuses())) ? $_GET['status'] : 'all', |
|
95 | + 'orderby' => (isset($_GET['orderby'])) ? $_GET['orderby'] : 'id', |
|
96 | + 'order' => (isset($_GET['order'])) ? $_GET['order'] : 'DESC', |
|
97 | 97 | ); |
98 | 98 | |
99 | 99 | // Prepare class properties. |
100 | - $this->query = new GetPaid_Subscriptions_Query( $query ); |
|
100 | + $this->query = new GetPaid_Subscriptions_Query($query); |
|
101 | 101 | $this->total_count = $this->query->get_total(); |
102 | 102 | $this->current_total_count = $this->query->get_total(); |
103 | 103 | $this->items = $this->query->get_results(); |
104 | - $this->status_counts = getpaid_get_subscription_status_counts( $query ); |
|
104 | + $this->status_counts = getpaid_get_subscription_status_counts($query); |
|
105 | 105 | |
106 | - if ( 'all' != $query['status'] ) { |
|
107 | - unset( $query['status'] ); |
|
108 | - $this->total_count = getpaid_get_subscriptions( $query, 'count' ); |
|
106 | + if ('all' != $query['status']) { |
|
107 | + unset($query['status']); |
|
108 | + $this->total_count = getpaid_get_subscriptions($query, 'count'); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | } |
@@ -122,26 +122,26 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function get_views() { |
124 | 124 | |
125 | - $current = isset( $_GET['status'] ) ? $_GET['status'] : 'all'; |
|
125 | + $current = isset($_GET['status']) ? $_GET['status'] : 'all'; |
|
126 | 126 | $views = array( |
127 | 127 | |
128 | 128 | 'all' => sprintf( |
129 | 129 | '<a href="%s" %s>%s <span class="count">(%d)</span></a>', |
130 | - esc_url( add_query_arg( 'status', false, $this->base_url ) ), |
|
130 | + esc_url(add_query_arg('status', false, $this->base_url)), |
|
131 | 131 | $current === 'all' ? ' class="current"' : '', |
132 | - __('All','invoicing' ), |
|
132 | + __('All', 'invoicing'), |
|
133 | 133 | $this->total_count |
134 | 134 | ) |
135 | 135 | |
136 | 136 | ); |
137 | 137 | |
138 | - foreach ( array_filter( $this->status_counts ) as $status => $count ) { |
|
138 | + foreach (array_filter($this->status_counts) as $status => $count) { |
|
139 | 139 | |
140 | - $views[ $status ] = sprintf( |
|
140 | + $views[$status] = sprintf( |
|
141 | 141 | '<a href="%s" %s>%s <span class="count">(%d)</span></a>', |
142 | - esc_url( add_query_arg( 'status', urlencode( $status ), $this->base_url ) ), |
|
142 | + esc_url(add_query_arg('status', urlencode($status), $this->base_url)), |
|
143 | 143 | $current === $status ? ' class="current"' : '', |
144 | - sanitize_text_field( getpaid_get_subscription_status_label( $status ) ), |
|
144 | + sanitize_text_field(getpaid_get_subscription_status_label($status)), |
|
145 | 145 | $count |
146 | 146 | ); |
147 | 147 | |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | * @since 1.0.0 |
159 | 159 | * @return string |
160 | 160 | */ |
161 | - public function column_default( $item, $column_name ) { |
|
162 | - return apply_filters( "getpaid_subscriptions_table_column_$column_name", $item->$column_name ); |
|
161 | + public function column_default($item, $column_name) { |
|
162 | + return apply_filters("getpaid_subscriptions_table_column_$column_name", $item->$column_name); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | * @param WPInv_Subscription $item |
169 | 169 | * @return string |
170 | 170 | */ |
171 | - public function column_cb( $item ) { |
|
172 | - return sprintf( '<input type="checkbox" name="id[]" value="%s" />', esc_html( $item->get_id() ) ); |
|
171 | + public function column_cb($item) { |
|
172 | + return sprintf('<input type="checkbox" name="id[]" value="%s" />', esc_html($item->get_id())); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | * @since 1.0.0 |
180 | 180 | * @return string |
181 | 181 | */ |
182 | - public function column_status( $item ) { |
|
182 | + public function column_status($item) { |
|
183 | 183 | return $item->get_status_label_html(); |
184 | 184 | } |
185 | 185 | |
@@ -190,44 +190,44 @@ discard block |
||
190 | 190 | * @since 1.0.0 |
191 | 191 | * @return string |
192 | 192 | */ |
193 | - public function column_subscription( $item ) { |
|
193 | + public function column_subscription($item) { |
|
194 | 194 | |
195 | - $username = __( '(Missing User)', 'invoicing' ); |
|
195 | + $username = __('(Missing User)', 'invoicing'); |
|
196 | 196 | |
197 | - $user = get_userdata( $item->get_customer_id() ); |
|
198 | - if ( $user ) { |
|
197 | + $user = get_userdata($item->get_customer_id()); |
|
198 | + if ($user) { |
|
199 | 199 | |
200 | 200 | $username = sprintf( |
201 | 201 | '<a href="user-edit.php?user_id=%s">%s</a>', |
202 | - absint( $user->ID ), |
|
203 | - ! empty( $user->display_name ) ? sanitize_text_field( $user->display_name ) : sanitize_email( $user->user_email ) |
|
202 | + absint($user->ID), |
|
203 | + !empty($user->display_name) ? sanitize_text_field($user->display_name) : sanitize_email($user->user_email) |
|
204 | 204 | ); |
205 | 205 | |
206 | 206 | } |
207 | 207 | |
208 | 208 | // translators: $1: is opening link, $2: is subscription id number, $3: is closing link tag, $4: is user's name |
209 | 209 | $column_content = sprintf( |
210 | - _x( '%1$s#%2$s%3$s for %4$s', 'Subscription title on admin table. (e.g.: #211 for John Doe)', 'invoicing' ), |
|
211 | - '<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $item->get_id() ) ) ) . '">', |
|
212 | - '<strong>' . esc_attr( $item->get_id() ) . '</strong>', '</a>', |
|
210 | + _x('%1$s#%2$s%3$s for %4$s', 'Subscription title on admin table. (e.g.: #211 for John Doe)', 'invoicing'), |
|
211 | + '<a href="' . esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($item->get_id()))) . '">', |
|
212 | + '<strong>' . esc_attr($item->get_id()) . '</strong>', '</a>', |
|
213 | 213 | $username |
214 | 214 | ); |
215 | 215 | |
216 | 216 | $row_actions = array(); |
217 | 217 | |
218 | 218 | // View subscription. |
219 | - $view_url = esc_url( add_query_arg( 'id', $item->get_id(), admin_url( 'admin.php?page=wpinv-subscriptions' ) )); |
|
220 | - $row_actions['view'] = '<a href="' . $view_url . '">' . __( 'View Subscription', 'invoicing' ) . '</a>'; |
|
219 | + $view_url = esc_url(add_query_arg('id', $item->get_id(), admin_url('admin.php?page=wpinv-subscriptions'))); |
|
220 | + $row_actions['view'] = '<a href="' . $view_url . '">' . __('View Subscription', 'invoicing') . '</a>'; |
|
221 | 221 | |
222 | 222 | // View invoice. |
223 | - $invoice = get_post( $item->get_parent_invoice_id() ); |
|
223 | + $invoice = get_post($item->get_parent_invoice_id()); |
|
224 | 224 | |
225 | - if ( ! empty( $invoice ) ) { |
|
226 | - $invoice_url = get_edit_post_link( $invoice ); |
|
227 | - $row_actions['invoice'] = '<a href="' . $invoice_url . '">' . __( 'View Invoice', 'invoicing' ) . '</a>'; |
|
225 | + if (!empty($invoice)) { |
|
226 | + $invoice_url = get_edit_post_link($invoice); |
|
227 | + $row_actions['invoice'] = '<a href="' . $invoice_url . '">' . __('View Invoice', 'invoicing') . '</a>'; |
|
228 | 228 | } |
229 | 229 | |
230 | - $delete_url = esc_url( |
|
230 | + $delete_url = esc_url( |
|
231 | 231 | wp_nonce_url( |
232 | 232 | add_query_arg( |
233 | 233 | array( |
@@ -239,11 +239,11 @@ discard block |
||
239 | 239 | 'getpaid-nonce' |
240 | 240 | ) |
241 | 241 | ); |
242 | - $row_actions['delete'] = '<a class="text-danger" href="' . $delete_url . '">' . __( 'Delete Subscription', 'invoicing' ) . '</a>'; |
|
242 | + $row_actions['delete'] = '<a class="text-danger" href="' . $delete_url . '">' . __('Delete Subscription', 'invoicing') . '</a>'; |
|
243 | 243 | |
244 | - $row_actions = $this->row_actions( apply_filters( 'getpaid_subscription_table_row_actions', $row_actions, $item ) ); |
|
244 | + $row_actions = $this->row_actions(apply_filters('getpaid_subscription_table_row_actions', $row_actions, $item)); |
|
245 | 245 | |
246 | - return "<strong>$column_content</strong>" . $this->column_amount( $item ) . $row_actions; |
|
246 | + return "<strong>$column_content</strong>" . $this->column_amount($item) . $row_actions; |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
@@ -253,8 +253,8 @@ discard block |
||
253 | 253 | * @since 1.0.0 |
254 | 254 | * @return string |
255 | 255 | */ |
256 | - public function column_renewal_date( $item ) { |
|
257 | - return getpaid_format_date_value( $item->get_expiration() ); |
|
256 | + public function column_renewal_date($item) { |
|
257 | + return getpaid_format_date_value($item->get_expiration()); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | /** |
@@ -264,8 +264,8 @@ discard block |
||
264 | 264 | * @since 1.0.0 |
265 | 265 | * @return string |
266 | 266 | */ |
267 | - public function column_start_date( $item ) { |
|
268 | - return getpaid_format_date_value( $item->get_date_created() ); |
|
267 | + public function column_start_date($item) { |
|
268 | + return getpaid_format_date_value($item->get_date_created()); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | /** |
@@ -275,8 +275,8 @@ discard block |
||
275 | 275 | * @since 1.0.19 |
276 | 276 | * @return string |
277 | 277 | */ |
278 | - public function column_amount( $item ) { |
|
279 | - $amount = getpaid_get_formatted_subscription_amount( $item ); |
|
278 | + public function column_amount($item) { |
|
279 | + $amount = getpaid_get_formatted_subscription_amount($item); |
|
280 | 280 | return "<span class='text-muted form-text mt-2 mb-2'>$amount</span>"; |
281 | 281 | } |
282 | 282 | |
@@ -287,9 +287,9 @@ discard block |
||
287 | 287 | * @since 1.0.0 |
288 | 288 | * @return string |
289 | 289 | */ |
290 | - public function column_renewals( $item ) { |
|
290 | + public function column_renewals($item) { |
|
291 | 291 | $max_bills = $item->get_bill_times(); |
292 | - return $item->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
292 | + return $item->get_times_billed() . ' / ' . (empty($max_bills) ? "∞" : $max_bills); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | /** |
@@ -299,15 +299,15 @@ discard block |
||
299 | 299 | * @since 1.0.0 |
300 | 300 | * @return string |
301 | 301 | */ |
302 | - public function column_item( $item ) { |
|
303 | - $subscription_group = getpaid_get_invoice_subscription_group( $item->get_parent_invoice_id(), $item->get_id() ); |
|
302 | + public function column_item($item) { |
|
303 | + $subscription_group = getpaid_get_invoice_subscription_group($item->get_parent_invoice_id(), $item->get_id()); |
|
304 | 304 | |
305 | - if ( empty( $subscription_group ) ) { |
|
306 | - return $this->generate_item_markup( $item->get_product_id() ); |
|
305 | + if (empty($subscription_group)) { |
|
306 | + return $this->generate_item_markup($item->get_product_id()); |
|
307 | 307 | } |
308 | 308 | |
309 | - $markup = array_map( array( $this, 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
310 | - return implode( ' | ', $markup ); |
|
309 | + $markup = array_map(array($this, 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
310 | + return implode(' | ', $markup); |
|
311 | 311 | |
312 | 312 | } |
313 | 313 | |
@@ -318,16 +318,16 @@ discard block |
||
318 | 318 | * @since 1.0.0 |
319 | 319 | * @return string |
320 | 320 | */ |
321 | - public static function generate_item_markup( $item_id ) { |
|
322 | - $item = get_post( $item_id ); |
|
321 | + public static function generate_item_markup($item_id) { |
|
322 | + $item = get_post($item_id); |
|
323 | 323 | |
324 | - if ( ! empty( $item ) ) { |
|
325 | - $link = get_edit_post_link( $item ); |
|
326 | - $link = esc_url( $link ); |
|
327 | - $name = esc_html( get_the_title( $item ) ); |
|
324 | + if (!empty($item)) { |
|
325 | + $link = get_edit_post_link($item); |
|
326 | + $link = esc_url($link); |
|
327 | + $name = esc_html(get_the_title($item)); |
|
328 | 328 | return "<a href='$link'>$name</a>"; |
329 | 329 | } else { |
330 | - return sprintf( __( 'Item #%s', 'invoicing' ), $item_id ); |
|
330 | + return sprintf(__('Item #%s', 'invoicing'), $item_id); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | } |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | * @return int |
339 | 339 | */ |
340 | 340 | public function get_paged() { |
341 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
341 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | /** |
@@ -351,13 +351,13 @@ discard block |
||
351 | 351 | $hidden = array(); |
352 | 352 | $sortable = $this->get_sortable_columns(); |
353 | 353 | |
354 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
354 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
355 | 355 | |
356 | 356 | $this->set_pagination_args( |
357 | 357 | array( |
358 | 358 | 'total_items' => $this->current_total_count, |
359 | 359 | 'per_page' => $this->per_page, |
360 | - 'total_pages' => ceil( $this->current_total_count / $this->per_page ) |
|
360 | + 'total_pages' => ceil($this->current_total_count / $this->per_page) |
|
361 | 361 | ) |
362 | 362 | ); |
363 | 363 | } |
@@ -367,18 +367,18 @@ discard block |
||
367 | 367 | * |
368 | 368 | * @return array |
369 | 369 | */ |
370 | - public function get_columns(){ |
|
370 | + public function get_columns() { |
|
371 | 371 | $columns = array( |
372 | 372 | 'cb' => '<input type="checkbox" />', |
373 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
374 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
375 | - 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
376 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
377 | - 'item' => __( 'Items', 'invoicing' ), |
|
378 | - 'status' => __( 'Status', 'invoicing' ), |
|
373 | + 'subscription' => __('Subscription', 'invoicing'), |
|
374 | + 'start_date' => __('Start Date', 'invoicing'), |
|
375 | + 'renewal_date' => __('Next Payment', 'invoicing'), |
|
376 | + 'renewals' => __('Payments', 'invoicing'), |
|
377 | + 'item' => __('Items', 'invoicing'), |
|
378 | + 'status' => __('Status', 'invoicing'), |
|
379 | 379 | ); |
380 | 380 | |
381 | - return apply_filters( 'manage_getpaid_subscriptions_table_columns', $columns ); |
|
381 | + return apply_filters('manage_getpaid_subscriptions_table_columns', $columns); |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | /** |
@@ -388,15 +388,15 @@ discard block |
||
388 | 388 | */ |
389 | 389 | public function get_sortable_columns() { |
390 | 390 | $sortable = array( |
391 | - 'subscription' => array( 'id', true ), |
|
392 | - 'start_date' => array( 'created', true ), |
|
393 | - 'renewal_date' => array( 'expiration', true ), |
|
394 | - 'renewals' => array( 'bill_times', true ), |
|
395 | - 'item' => array( 'product_id', true ), |
|
396 | - 'status' => array( 'status', true ), |
|
391 | + 'subscription' => array('id', true), |
|
392 | + 'start_date' => array('created', true), |
|
393 | + 'renewal_date' => array('expiration', true), |
|
394 | + 'renewals' => array('bill_times', true), |
|
395 | + 'item' => array('product_id', true), |
|
396 | + 'status' => array('status', true), |
|
397 | 397 | ); |
398 | 398 | |
399 | - return apply_filters( 'manage_getpaid_subscriptions_sortable_table_columns', $sortable ); |
|
399 | + return apply_filters('manage_getpaid_subscriptions_sortable_table_columns', $sortable); |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | /** |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | * @return bool |
406 | 406 | */ |
407 | 407 | public function has_items() { |
408 | - return ! empty( $this->current_total_count ); |
|
408 | + return !empty($this->current_total_count); |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | /** |