@@ -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(); |
@@ -66,7 +66,7 @@ discard block |
||
| 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" /> |
| 69 | - <?php $subscribers_table->search_box( __( 'Search Subscriptions', 'invoicing' ), 'getpaid-search-subscriptions' ); ?> |
|
| 69 | + <?php $subscribers_table->search_box(__('Search Subscriptions', 'invoicing'), 'getpaid-search-subscriptions'); ?> |
|
| 70 | 70 | <?php $subscribers_table->display(); ?> |
| 71 | 71 | </form> |
| 72 | 72 | <?php |
@@ -82,13 +82,13 @@ discard block |
||
| 82 | 82 | function wpinv_recurring_subscription_details() { |
| 83 | 83 | |
| 84 | 84 | // Fetch the subscription. |
| 85 | - $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
| 86 | - if ( ! $sub->exists() ) { |
|
| 85 | + $sub = new WPInv_Subscription((int) $_GET['id']); |
|
| 86 | + if (!$sub->exists()) { |
|
| 87 | 87 | |
| 88 | 88 | echo aui()->alert( |
| 89 | 89 | array( |
| 90 | 90 | 'type' => 'danger', |
| 91 | - 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
| 91 | + 'content' => __('Subscription not found.', 'invoicing'), |
|
| 92 | 92 | ) |
| 93 | 93 | ); |
| 94 | 94 | |
@@ -96,45 +96,45 @@ discard block |
||
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 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' ); |
|
| 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 | 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' ) ); |
|
| 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' ); |
|
| 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 | 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' ); |
|
| 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 | 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 | - <form method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ); ?>"> |
|
| 120 | + <form method="post" action="<?php echo admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($sub->get_id())); ?>"> |
|
| 121 | 121 | |
| 122 | - <?php wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); ?> |
|
| 123 | - <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> |
|
| 124 | - <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> |
|
| 122 | + <?php wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); ?> |
|
| 123 | + <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?> |
|
| 124 | + <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?> |
|
| 125 | 125 | <input type="hidden" name="getpaid-admin-action" value="update_single_subscription" /> |
| 126 | - <input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id() ;?>" /> |
|
| 126 | + <input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id(); ?>" /> |
|
| 127 | 127 | |
| 128 | 128 | <div id="poststuff"> |
| 129 | 129 | <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>"> |
| 130 | 130 | |
| 131 | 131 | <div id="postbox-container-1" class="postbox-container"> |
| 132 | - <?php do_meta_boxes( get_current_screen(), 'side', $sub ); ?> |
|
| 132 | + <?php do_meta_boxes(get_current_screen(), 'side', $sub); ?> |
|
| 133 | 133 | </div> |
| 134 | 134 | |
| 135 | 135 | <div id="postbox-container-2" class="postbox-container"> |
| 136 | - <?php do_meta_boxes( get_current_screen(), 'normal', $sub ); ?> |
|
| 137 | - <?php do_meta_boxes( get_current_screen(), 'advanced', $sub ); ?> |
|
| 136 | + <?php do_meta_boxes(get_current_screen(), 'normal', $sub); ?> |
|
| 137 | + <?php do_meta_boxes(get_current_screen(), 'advanced', $sub); ?> |
|
| 138 | 138 | </div> |
| 139 | 139 | |
| 140 | 140 | </div> |
@@ -153,44 +153,44 @@ discard block |
||
| 153 | 153 | * |
| 154 | 154 | * @param WPInv_Subscription $sub |
| 155 | 155 | */ |
| 156 | -function getpaid_admin_subscription_details_metabox( $sub ) { |
|
| 156 | +function getpaid_admin_subscription_details_metabox($sub) { |
|
| 157 | 157 | |
| 158 | 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'] ); |
|
| 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 | 161 | |
| 162 | 162 | // Prepare subscription detail columns. |
| 163 | 163 | $fields = apply_filters( |
| 164 | 164 | 'getpaid_subscription_admin_page_fields', |
| 165 | 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' ), |
|
| 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 | 176 | ) |
| 177 | 177 | ); |
| 178 | 178 | |
| 179 | - if ( ! $sub->is_active() ) { |
|
| 179 | + if (!$sub->is_active()) { |
|
| 180 | 180 | |
| 181 | - if ( isset( $fields['renews_on'] ) ) { |
|
| 182 | - unset( $fields['renews_on'] ); |
|
| 181 | + if (isset($fields['renews_on'])) { |
|
| 182 | + unset($fields['renews_on']); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - if ( isset( $fields['gateway'] ) ) { |
|
| 186 | - unset( $fields['gateway'] ); |
|
| 185 | + if (isset($fields['gateway'])) { |
|
| 186 | + unset($fields['gateway']); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | $profile_id = $sub->get_profile_id(); |
| 192 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
| 193 | - unset( $fields['profile_id'] ); |
|
| 192 | + if (empty($profile_id) && isset($fields['profile_id'])) { |
|
| 193 | + unset($fields['profile_id']); |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | ?> |
@@ -198,16 +198,16 @@ discard block |
||
| 198 | 198 | <table class="table table-borderless" style="font-size: 14px;"> |
| 199 | 199 | <tbody> |
| 200 | 200 | |
| 201 | - <?php foreach ( $fields as $key => $label ) : ?> |
|
| 201 | + <?php foreach ($fields as $key => $label) : ?> |
|
| 202 | 202 | |
| 203 | - <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class( $key ); ?>"> |
|
| 203 | + <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class($key); ?>"> |
|
| 204 | 204 | |
| 205 | 205 | <th class="w-25" style="font-weight: 500;"> |
| 206 | - <?php echo esc_html( $label ); ?> |
|
| 206 | + <?php echo esc_html($label); ?> |
|
| 207 | 207 | </th> |
| 208 | 208 | |
| 209 | 209 | <td class="w-75 text-muted"> |
| 210 | - <?php do_action( 'getpaid_subscription_admin_display_' . sanitize_key( $key ), $sub, $subscription_group ); ?> |
|
| 210 | + <?php do_action('getpaid_subscription_admin_display_' . sanitize_key($key), $sub, $subscription_group); ?> |
|
| 211 | 211 | </td> |
| 212 | 212 | |
| 213 | 213 | </tr> |
@@ -225,135 +225,135 @@ discard block |
||
| 225 | 225 | * |
| 226 | 226 | * @param WPInv_Subscription $subscription |
| 227 | 227 | */ |
| 228 | -function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
|
| 228 | +function getpaid_admin_subscription_metabox_display_customer($subscription) { |
|
| 229 | 229 | |
| 230 | - $username = __( '(Missing User)', 'invoicing' ); |
|
| 230 | + $username = __('(Missing User)', 'invoicing'); |
|
| 231 | 231 | |
| 232 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
| 233 | - if ( $user ) { |
|
| 232 | + $user = get_userdata($subscription->get_customer_id()); |
|
| 233 | + if ($user) { |
|
| 234 | 234 | |
| 235 | 235 | $username = sprintf( |
| 236 | 236 | '<a href="user-edit.php?user_id=%s">%s</a>', |
| 237 | - absint( $user->ID ), |
|
| 238 | - ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email ) |
|
| 237 | + absint($user->ID), |
|
| 238 | + !empty($user->display_name) ? esc_html($user->display_name) : sanitize_email($user->user_email) |
|
| 239 | 239 | ); |
| 240 | 240 | |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | echo $username; |
| 244 | 244 | } |
| 245 | -add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
|
| 245 | +add_action('getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer'); |
|
| 246 | 246 | |
| 247 | 247 | /** |
| 248 | 248 | * Displays the subscription amount. |
| 249 | 249 | * |
| 250 | 250 | * @param WPInv_Subscription $subscription |
| 251 | 251 | */ |
| 252 | -function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
|
| 253 | - $amount = wp_kses_post( getpaid_get_formatted_subscription_amount( $subscription ) ); |
|
| 252 | +function getpaid_admin_subscription_metabox_display_amount($subscription) { |
|
| 253 | + $amount = wp_kses_post(getpaid_get_formatted_subscription_amount($subscription)); |
|
| 254 | 254 | echo "<span>$amount</span>"; |
| 255 | 255 | } |
| 256 | -add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
|
| 256 | +add_action('getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount'); |
|
| 257 | 257 | |
| 258 | 258 | /** |
| 259 | 259 | * Displays the subscription id. |
| 260 | 260 | * |
| 261 | 261 | * @param WPInv_Subscription $subscription |
| 262 | 262 | */ |
| 263 | -function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
|
| 263 | +function getpaid_admin_subscription_metabox_display_id($subscription) { |
|
| 264 | 264 | |
| 265 | 265 | printf( |
| 266 | 266 | '<a href="%s">#%s</a>', |
| 267 | - esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ), |
|
| 268 | - absint( $subscription->get_id() ) |
|
| 267 | + esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($subscription->get_id()))), |
|
| 268 | + absint($subscription->get_id()) |
|
| 269 | 269 | ); |
| 270 | 270 | |
| 271 | 271 | } |
| 272 | -add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
|
| 272 | +add_action('getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id'); |
|
| 273 | 273 | |
| 274 | 274 | /** |
| 275 | 275 | * Displays the subscription renewal date. |
| 276 | 276 | * |
| 277 | 277 | * @param WPInv_Subscription $subscription |
| 278 | 278 | */ |
| 279 | -function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
|
| 280 | - echo getpaid_format_date_value( $subscription->get_date_created() ); |
|
| 279 | +function getpaid_admin_subscription_metabox_display_start_date($subscription) { |
|
| 280 | + echo getpaid_format_date_value($subscription->get_date_created()); |
|
| 281 | 281 | } |
| 282 | -add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
|
| 282 | +add_action('getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date'); |
|
| 283 | 283 | |
| 284 | 284 | /** |
| 285 | 285 | * Displays the subscription renewal date. |
| 286 | 286 | * |
| 287 | 287 | * @param WPInv_Subscription $subscription |
| 288 | 288 | */ |
| 289 | -function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
|
| 290 | - echo getpaid_format_date_value( $subscription->get_expiration() ); |
|
| 289 | +function getpaid_admin_subscription_metabox_display_renews_on($subscription) { |
|
| 290 | + echo getpaid_format_date_value($subscription->get_expiration()); |
|
| 291 | 291 | } |
| 292 | -add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
|
| 292 | +add_action('getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on'); |
|
| 293 | 293 | |
| 294 | 294 | /** |
| 295 | 295 | * Displays the subscription renewal count. |
| 296 | 296 | * |
| 297 | 297 | * @param WPInv_Subscription $subscription |
| 298 | 298 | */ |
| 299 | -function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
|
| 299 | +function getpaid_admin_subscription_metabox_display_renewals($subscription) { |
|
| 300 | 300 | $max_bills = $subscription->get_bill_times(); |
| 301 | - echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
| 301 | + echo $subscription->get_times_billed() . ' / ' . (empty($max_bills) ? "∞" : $max_bills); |
|
| 302 | 302 | } |
| 303 | -add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
|
| 303 | +add_action('getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals'); |
|
| 304 | 304 | /** |
| 305 | 305 | * Displays the subscription item. |
| 306 | 306 | * |
| 307 | 307 | * @param WPInv_Subscription $subscription |
| 308 | 308 | * @param false|array $subscription_group |
| 309 | 309 | */ |
| 310 | -function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) { |
|
| 310 | +function getpaid_admin_subscription_metabox_display_item($subscription, $subscription_group = false) { |
|
| 311 | 311 | |
| 312 | - if ( empty( $subscription_group ) ) { |
|
| 313 | - echo WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ); |
|
| 312 | + if (empty($subscription_group)) { |
|
| 313 | + echo WPInv_Subscriptions_List_Table::generate_item_markup($subscription->get_product_id()); |
|
| 314 | 314 | return; |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
| 318 | - echo implode( ' | ', $markup ); |
|
| 317 | + $markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
| 318 | + echo implode(' | ', $markup); |
|
| 319 | 319 | |
| 320 | 320 | } |
| 321 | -add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 ); |
|
| 321 | +add_action('getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2); |
|
| 322 | 322 | |
| 323 | 323 | /** |
| 324 | 324 | * Displays the subscription gateway. |
| 325 | 325 | * |
| 326 | 326 | * @param WPInv_Subscription $subscription |
| 327 | 327 | */ |
| 328 | -function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
|
| 328 | +function getpaid_admin_subscription_metabox_display_gateway($subscription) { |
|
| 329 | 329 | |
| 330 | 330 | $gateway = $subscription->get_gateway(); |
| 331 | 331 | |
| 332 | - if ( ! empty( $gateway ) ) { |
|
| 333 | - echo esc_html( wpinv_get_gateway_admin_label( $gateway ) ); |
|
| 332 | + if (!empty($gateway)) { |
|
| 333 | + echo esc_html(wpinv_get_gateway_admin_label($gateway)); |
|
| 334 | 334 | } else { |
| 335 | 335 | echo "—"; |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | } |
| 339 | -add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
|
| 339 | +add_action('getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway'); |
|
| 340 | 340 | |
| 341 | 341 | /** |
| 342 | 342 | * Displays the subscription status. |
| 343 | 343 | * |
| 344 | 344 | * @param WPInv_Subscription $subscription |
| 345 | 345 | */ |
| 346 | -function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
|
| 346 | +function getpaid_admin_subscription_metabox_display_status($subscription) { |
|
| 347 | 347 | echo $subscription->get_status_label_html(); |
| 348 | 348 | } |
| 349 | -add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
|
| 349 | +add_action('getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status'); |
|
| 350 | 350 | |
| 351 | 351 | /** |
| 352 | 352 | * Displays the subscription profile id. |
| 353 | 353 | * |
| 354 | 354 | * @param WPInv_Subscription $subscription |
| 355 | 355 | */ |
| 356 | -function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
|
| 356 | +function getpaid_admin_subscription_metabox_display_profile_id($subscription) { |
|
| 357 | 357 | |
| 358 | 358 | $profile_id = $subscription->get_profile_id(); |
| 359 | 359 | |
@@ -362,32 +362,32 @@ discard block |
||
| 362 | 362 | 'type' => 'text', |
| 363 | 363 | 'id' => 'wpinv_subscription_profile_id', |
| 364 | 364 | 'name' => 'wpinv_subscription_profile_id', |
| 365 | - 'label' => __( 'Profile Id', 'invoicing' ), |
|
| 365 | + 'label' => __('Profile Id', 'invoicing'), |
|
| 366 | 366 | 'label_type' => 'hidden', |
| 367 | - 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
| 368 | - 'value' => esc_attr( $profile_id ), |
|
| 367 | + 'placeholder' => __('Profile Id', 'invoicing'), |
|
| 368 | + 'value' => esc_attr($profile_id), |
|
| 369 | 369 | 'input_group_right' => '', |
| 370 | 370 | 'no_wrap' => true, |
| 371 | 371 | ) |
| 372 | 372 | ); |
| 373 | 373 | |
| 374 | - echo str_ireplace( 'form-control', 'regular-text', $input ); |
|
| 374 | + echo str_ireplace('form-control', 'regular-text', $input); |
|
| 375 | 375 | |
| 376 | - $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
| 377 | - if ( ! empty( $url ) ) { |
|
| 378 | - $url = esc_url_raw( $url ); |
|
| 379 | - 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>'; |
|
| 376 | + $url = apply_filters('getpaid_remote_subscription_profile_url', '', $subscription); |
|
| 377 | + if (!empty($url)) { |
|
| 378 | + $url = esc_url_raw($url); |
|
| 379 | + 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>'; |
|
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | } |
| 383 | -add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
|
| 383 | +add_action('getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id'); |
|
| 384 | 384 | |
| 385 | 385 | /** |
| 386 | 386 | * Displays the subscriptions update metabox. |
| 387 | 387 | * |
| 388 | 388 | * @param WPInv_Subscription $subscription |
| 389 | 389 | */ |
| 390 | -function getpaid_admin_subscription_update_metabox( $subscription ) { |
|
| 390 | +function getpaid_admin_subscription_update_metabox($subscription) { |
|
| 391 | 391 | |
| 392 | 392 | ?> |
| 393 | 393 | <div class="mt-3"> |
@@ -400,10 +400,10 @@ discard block |
||
| 400 | 400 | 'id' => 'subscription_status_update_select', |
| 401 | 401 | 'required' => true, |
| 402 | 402 | 'no_wrap' => false, |
| 403 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
| 404 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
| 403 | + 'label' => __('Subscription Status', 'invoicing'), |
|
| 404 | + 'help_text' => __('Updating the status will trigger related actions and hooks', 'invoicing'), |
|
| 405 | 405 | 'select2' => true, |
| 406 | - 'value' => $subscription->get_status( 'edit' ), |
|
| 406 | + 'value' => $subscription->get_status('edit'), |
|
| 407 | 407 | ) |
| 408 | 408 | ); |
| 409 | 409 | ?> |
@@ -411,13 +411,13 @@ discard block |
||
| 411 | 411 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;"> |
| 412 | 412 | |
| 413 | 413 | <?php |
| 414 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
| 414 | + submit_button(__('Update', 'invoicing'), 'primary', 'submit', false); |
|
| 415 | 415 | |
| 416 | - $url = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) ); |
|
| 417 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
| 418 | - $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' ); |
|
| 416 | + $url = esc_url(wp_nonce_url(add_query_arg('getpaid-admin-action', 'subscription_manual_renew'), 'getpaid-nonce', 'getpaid-nonce')); |
|
| 417 | + $anchor = __('Renew Subscription', 'invoicing'); |
|
| 418 | + $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'); |
|
| 419 | 419 | |
| 420 | - if ( $subscription->is_active() ) { |
|
| 420 | + if ($subscription->is_active()) { |
|
| 421 | 421 | echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>"; |
| 422 | 422 | } |
| 423 | 423 | |
@@ -430,31 +430,31 @@ discard block |
||
| 430 | 430 | * @param WPInv_Subscription $subscription |
| 431 | 431 | * @param bool $strict Whether or not to skip invoices of sibling subscriptions |
| 432 | 432 | */ |
| 433 | -function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) { |
|
| 433 | +function getpaid_admin_subscription_invoice_details_metabox($subscription, $strict = true) { |
|
| 434 | 434 | |
| 435 | 435 | $columns = apply_filters( |
| 436 | 436 | 'getpaid_subscription_related_invoices_columns', |
| 437 | 437 | array( |
| 438 | - 'invoice' => __( 'Invoice', 'invoicing' ), |
|
| 439 | - 'relationship' => __( 'Relationship', 'invoicing' ), |
|
| 440 | - 'date' => __( 'Date', 'invoicing' ), |
|
| 441 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 442 | - 'total' => __( 'Total', 'invoicing' ), |
|
| 438 | + 'invoice' => __('Invoice', 'invoicing'), |
|
| 439 | + 'relationship' => __('Relationship', 'invoicing'), |
|
| 440 | + 'date' => __('Date', 'invoicing'), |
|
| 441 | + 'status' => __('Status', 'invoicing'), |
|
| 442 | + 'total' => __('Total', 'invoicing'), |
|
| 443 | 443 | ), |
| 444 | 444 | $subscription |
| 445 | 445 | ); |
| 446 | 446 | |
| 447 | 447 | // Prepare the invoices. |
| 448 | - $payments = $subscription->get_child_payments( ! is_admin() ); |
|
| 448 | + $payments = $subscription->get_child_payments(!is_admin()); |
|
| 449 | 449 | $parent = $subscription->get_parent_invoice(); |
| 450 | 450 | |
| 451 | - if ( $parent->exists() ) { |
|
| 452 | - $payments = array_merge( array( $parent ), $payments ); |
|
| 451 | + if ($parent->exists()) { |
|
| 452 | + $payments = array_merge(array($parent), $payments); |
|
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | $table_class = 'w-100 bg-white'; |
| 456 | 456 | |
| 457 | - if ( ! is_admin() ) { |
|
| 457 | + if (!is_admin()) { |
|
| 458 | 458 | $table_class = 'table table-bordered'; |
| 459 | 459 | } |
| 460 | 460 | |
@@ -466,9 +466,9 @@ discard block |
||
| 466 | 466 | <thead> |
| 467 | 467 | <tr> |
| 468 | 468 | <?php |
| 469 | - foreach ( $columns as $key => $label ) { |
|
| 470 | - $key = esc_attr( $key ); |
|
| 471 | - $label = esc_html( $label ); |
|
| 469 | + foreach ($columns as $key => $label) { |
|
| 470 | + $key = esc_attr($key); |
|
| 471 | + $label = esc_html($label); |
|
| 472 | 472 | $class = 'text-left'; |
| 473 | 473 | |
| 474 | 474 | echo "<th class='subscription-invoice-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
@@ -479,57 +479,57 @@ discard block |
||
| 479 | 479 | |
| 480 | 480 | <tbody> |
| 481 | 481 | |
| 482 | - <?php if ( empty( $payments ) ) : ?> |
|
| 482 | + <?php if (empty($payments)) : ?> |
|
| 483 | 483 | <tr> |
| 484 | 484 | <td colspan="<?php echo count($columns); ?>" class="p-2 text-left text-muted"> |
| 485 | - <?php _e( 'This subscription has no invoices.', 'invoicing' ); ?> |
|
| 485 | + <?php _e('This subscription has no invoices.', 'invoicing'); ?> |
|
| 486 | 486 | </td> |
| 487 | 487 | </tr> |
| 488 | 488 | <?php endif; ?> |
| 489 | 489 | |
| 490 | 490 | <?php |
| 491 | 491 | |
| 492 | - foreach( $payments as $payment ) : |
|
| 492 | + foreach ($payments as $payment) : |
|
| 493 | 493 | |
| 494 | 494 | // Ensure that we have an invoice. |
| 495 | - $payment = new WPInv_Invoice( $payment ); |
|
| 495 | + $payment = new WPInv_Invoice($payment); |
|
| 496 | 496 | |
| 497 | 497 | // Abort if the invoice is invalid... |
| 498 | - if ( ! $payment->exists() ) { |
|
| 498 | + if (!$payment->exists()) { |
|
| 499 | 499 | continue; |
| 500 | 500 | } |
| 501 | 501 | |
| 502 | 502 | // ... or belongs to a different subscription. |
| 503 | - if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
| 503 | + if ($strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id()) { |
|
| 504 | 504 | continue; |
| 505 | 505 | } |
| 506 | 506 | |
| 507 | 507 | echo '<tr>'; |
| 508 | 508 | |
| 509 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 509 | + foreach (array_keys($columns) as $key) { |
|
| 510 | 510 | |
| 511 | 511 | $class = 'text-left'; |
| 512 | 512 | |
| 513 | 513 | echo "<td class='p-2 $class'>"; |
| 514 | 514 | |
| 515 | - switch( $key ) { |
|
| 515 | + switch ($key) { |
|
| 516 | 516 | |
| 517 | 517 | case 'total': |
| 518 | - echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>'; |
|
| 518 | + echo '<strong>' . wpinv_price($payment->get_total(), $payment->get_currency()) . '</strong>'; |
|
| 519 | 519 | break; |
| 520 | 520 | |
| 521 | 521 | case 'relationship': |
| 522 | - echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' ); |
|
| 522 | + echo $payment->is_renewal() ? __('Renewal Invoice', 'invoicing') : __('Initial Invoice', 'invoicing'); |
|
| 523 | 523 | break; |
| 524 | 524 | |
| 525 | 525 | case 'date': |
| 526 | - echo getpaid_format_date_value( $payment->get_date_created() ); |
|
| 526 | + echo getpaid_format_date_value($payment->get_date_created()); |
|
| 527 | 527 | break; |
| 528 | 528 | |
| 529 | 529 | case 'status': |
| 530 | 530 | |
| 531 | 531 | $status = $payment->get_status_nicename(); |
| 532 | - if ( is_admin() ) { |
|
| 532 | + if (is_admin()) { |
|
| 533 | 533 | $status = $payment->get_status_label_html(); |
| 534 | 534 | } |
| 535 | 535 | |
@@ -537,13 +537,13 @@ discard block |
||
| 537 | 537 | break; |
| 538 | 538 | |
| 539 | 539 | case 'invoice': |
| 540 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
| 540 | + $link = esc_url(get_edit_post_link($payment->get_id())); |
|
| 541 | 541 | |
| 542 | - if ( ! is_admin() ) { |
|
| 543 | - $link = esc_url( $payment->get_view_url() ); |
|
| 542 | + if (!is_admin()) { |
|
| 543 | + $link = esc_url($payment->get_view_url()); |
|
| 544 | 544 | } |
| 545 | 545 | |
| 546 | - $invoice = esc_html( $payment->get_number() ); |
|
| 546 | + $invoice = esc_html($payment->get_number()); |
|
| 547 | 547 | echo "<a href='$link'>$invoice</a>"; |
| 548 | 548 | break; |
| 549 | 549 | } |
@@ -571,12 +571,12 @@ discard block |
||
| 571 | 571 | * |
| 572 | 572 | * @param WPInv_Subscription $subscription |
| 573 | 573 | */ |
| 574 | -function getpaid_admin_subscription_item_details_metabox( $subscription ) { |
|
| 574 | +function getpaid_admin_subscription_item_details_metabox($subscription) { |
|
| 575 | 575 | |
| 576 | 576 | // Fetch the subscription group. |
| 577 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
| 577 | + $subscription_group = getpaid_get_invoice_subscription_group($subscription->get_parent_payment_id(), $subscription->get_id()); |
|
| 578 | 578 | |
| 579 | - if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
| 579 | + if (empty($subscription_group) || empty($subscription_group['items'])) { |
|
| 580 | 580 | return; |
| 581 | 581 | } |
| 582 | 582 | |
@@ -584,12 +584,12 @@ discard block |
||
| 584 | 584 | $columns = apply_filters( |
| 585 | 585 | 'getpaid_subscription_item_details_columns', |
| 586 | 586 | array( |
| 587 | - 'item_name' => __( 'Item', 'invoicing' ), |
|
| 588 | - 'price' => __( 'Price', 'invoicing' ), |
|
| 589 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
| 590 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
| 587 | + 'item_name' => __('Item', 'invoicing'), |
|
| 588 | + 'price' => __('Price', 'invoicing'), |
|
| 589 | + 'tax' => __('Tax', 'invoicing'), |
|
| 590 | + 'discount' => __('Discount', 'invoicing'), |
|
| 591 | 591 | //'initial' => __( 'Initial Amount', 'invoicing' ), |
| 592 | - 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
| 592 | + 'recurring' => __('Subtotal', 'invoicing'), |
|
| 593 | 593 | ), |
| 594 | 594 | $subscription |
| 595 | 595 | ); |
@@ -598,13 +598,13 @@ discard block |
||
| 598 | 598 | |
| 599 | 599 | $invoice = $subscription->get_parent_invoice(); |
| 600 | 600 | |
| 601 | - if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
| 602 | - unset( $columns['tax'] ); |
|
| 601 | + if ((!wpinv_use_taxes() || !$invoice->is_taxable()) && isset($columns['tax'])) { |
|
| 602 | + unset($columns['tax']); |
|
| 603 | 603 | } |
| 604 | 604 | |
| 605 | 605 | $table_class = 'w-100 bg-white'; |
| 606 | 606 | |
| 607 | - if ( ! is_admin() ) { |
|
| 607 | + if (!is_admin()) { |
|
| 608 | 608 | $table_class = 'table table-bordered'; |
| 609 | 609 | } |
| 610 | 610 | |
@@ -617,9 +617,9 @@ discard block |
||
| 617 | 617 | <tr> |
| 618 | 618 | <?php |
| 619 | 619 | |
| 620 | - foreach ( $columns as $key => $label ) { |
|
| 621 | - $key = esc_attr( $key ); |
|
| 622 | - $label = esc_html( $label ); |
|
| 620 | + foreach ($columns as $key => $label) { |
|
| 621 | + $key = esc_attr($key); |
|
| 622 | + $label = esc_html($label); |
|
| 623 | 623 | $class = 'text-left'; |
| 624 | 624 | |
| 625 | 625 | echo "<th class='subscription-item-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
@@ -632,48 +632,48 @@ discard block |
||
| 632 | 632 | |
| 633 | 633 | <?php |
| 634 | 634 | |
| 635 | - foreach( $subscription_group['items'] as $subscription_group_item ) : |
|
| 635 | + foreach ($subscription_group['items'] as $subscription_group_item) : |
|
| 636 | 636 | |
| 637 | 637 | echo '<tr>'; |
| 638 | 638 | |
| 639 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 639 | + foreach (array_keys($columns) as $key) { |
|
| 640 | 640 | |
| 641 | 641 | $class = 'text-left'; |
| 642 | 642 | |
| 643 | 643 | echo "<td class='p-2 $class'>"; |
| 644 | 644 | |
| 645 | - switch( $key ) { |
|
| 645 | + switch ($key) { |
|
| 646 | 646 | |
| 647 | 647 | case 'item_name': |
| 648 | - $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
| 649 | - $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
| 648 | + $item_name = get_the_title($subscription_group_item['item_id']); |
|
| 649 | + $item_name = empty($item_name) ? $subscription_group_item['item_name'] : $item_name; |
|
| 650 | 650 | |
| 651 | - if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
| 652 | - echo esc_html( $item_name ); |
|
| 651 | + if ($invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity']) { |
|
| 652 | + echo esc_html($item_name); |
|
| 653 | 653 | } else { |
| 654 | - printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
| 654 | + printf('%1$s x %2$d', esc_html($item_name), (float) $subscription_group_item['quantity']); |
|
| 655 | 655 | } |
| 656 | 656 | |
| 657 | 657 | break; |
| 658 | 658 | |
| 659 | 659 | case 'price': |
| 660 | - echo wpinv_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
| 660 | + echo wpinv_price($subscription_group_item['item_price'], $invoice->get_currency()); |
|
| 661 | 661 | break; |
| 662 | 662 | |
| 663 | 663 | case 'tax': |
| 664 | - echo wpinv_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
| 664 | + echo wpinv_price($subscription_group_item['tax'], $invoice->get_currency()); |
|
| 665 | 665 | break; |
| 666 | 666 | |
| 667 | 667 | case 'discount': |
| 668 | - echo wpinv_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
| 668 | + echo wpinv_price($subscription_group_item['discount'], $invoice->get_currency()); |
|
| 669 | 669 | break; |
| 670 | 670 | |
| 671 | 671 | case 'initial': |
| 672 | - echo wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
| 672 | + echo wpinv_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()); |
|
| 673 | 673 | break; |
| 674 | 674 | |
| 675 | 675 | case 'recurring': |
| 676 | - echo '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>'; |
|
| 676 | + echo '<strong>' . wpinv_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()) . '</strong>'; |
|
| 677 | 677 | break; |
| 678 | 678 | |
| 679 | 679 | } |
@@ -686,24 +686,24 @@ discard block |
||
| 686 | 686 | |
| 687 | 687 | endforeach; |
| 688 | 688 | |
| 689 | - foreach( $subscription_group['fees'] as $subscription_group_fee ) : |
|
| 689 | + foreach ($subscription_group['fees'] as $subscription_group_fee) : |
|
| 690 | 690 | |
| 691 | 691 | echo '<tr>'; |
| 692 | 692 | |
| 693 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 693 | + foreach (array_keys($columns) as $key) { |
|
| 694 | 694 | |
| 695 | 695 | $class = 'text-left'; |
| 696 | 696 | |
| 697 | 697 | echo "<td class='p-2 $class'>"; |
| 698 | 698 | |
| 699 | - switch( $key ) { |
|
| 699 | + switch ($key) { |
|
| 700 | 700 | |
| 701 | 701 | case 'item_name': |
| 702 | - echo esc_html( $subscription_group_fee['name'] ); |
|
| 702 | + echo esc_html($subscription_group_fee['name']); |
|
| 703 | 703 | break; |
| 704 | 704 | |
| 705 | 705 | case 'price': |
| 706 | - echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
| 706 | + echo wpinv_price($subscription_group_fee['initial_fee'], $invoice->get_currency()); |
|
| 707 | 707 | break; |
| 708 | 708 | |
| 709 | 709 | case 'tax': |
@@ -715,11 +715,11 @@ discard block |
||
| 715 | 715 | break; |
| 716 | 716 | |
| 717 | 717 | case 'initial': |
| 718 | - echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
| 718 | + echo wpinv_price($subscription_group_fee['initial_fee'], $invoice->get_currency()); |
|
| 719 | 719 | break; |
| 720 | 720 | |
| 721 | 721 | case 'recurring': |
| 722 | - echo '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>'; |
|
| 722 | + echo '<strong>' . wpinv_price($subscription_group_fee['recurring_fee'], $invoice->get_currency()) . '</strong>'; |
|
| 723 | 723 | break; |
| 724 | 724 | |
| 725 | 725 | } |
@@ -748,12 +748,12 @@ discard block |
||
| 748 | 748 | * @param WPInv_Subscription $subscription |
| 749 | 749 | * @param bool $skip_current |
| 750 | 750 | */ |
| 751 | -function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) { |
|
| 751 | +function getpaid_admin_subscription_related_subscriptions_metabox($subscription, $skip_current = true) { |
|
| 752 | 752 | |
| 753 | 753 | // Fetch the subscription groups. |
| 754 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
| 754 | + $subscription_groups = getpaid_get_invoice_subscription_groups($subscription->get_parent_payment_id()); |
|
| 755 | 755 | |
| 756 | - if ( empty( $subscription_groups ) ) { |
|
| 756 | + if (empty($subscription_groups)) { |
|
| 757 | 757 | return; |
| 758 | 758 | } |
| 759 | 759 | |
@@ -761,23 +761,23 @@ discard block |
||
| 761 | 761 | $columns = apply_filters( |
| 762 | 762 | 'getpaid_subscription_related_subscriptions_columns', |
| 763 | 763 | array( |
| 764 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 765 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 766 | - 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
| 767 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
| 768 | - 'item' => __( 'Items', 'invoicing' ), |
|
| 769 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 764 | + 'subscription' => __('Subscription', 'invoicing'), |
|
| 765 | + 'start_date' => __('Start Date', 'invoicing'), |
|
| 766 | + 'renewal_date' => __('Next Payment', 'invoicing'), |
|
| 767 | + 'renewals' => __('Payments', 'invoicing'), |
|
| 768 | + 'item' => __('Items', 'invoicing'), |
|
| 769 | + 'status' => __('Status', 'invoicing'), |
|
| 770 | 770 | ), |
| 771 | 771 | $subscription |
| 772 | 772 | ); |
| 773 | 773 | |
| 774 | - if ( $subscription->get_status() == 'pending' ) { |
|
| 775 | - unset( $columns['start_date'], $columns['renewal_date'] ); |
|
| 774 | + if ($subscription->get_status() == 'pending') { |
|
| 775 | + unset($columns['start_date'], $columns['renewal_date']); |
|
| 776 | 776 | } |
| 777 | 777 | |
| 778 | 778 | $table_class = 'w-100 bg-white'; |
| 779 | 779 | |
| 780 | - if ( ! is_admin() ) { |
|
| 780 | + if (!is_admin()) { |
|
| 781 | 781 | $table_class = 'table table-bordered'; |
| 782 | 782 | } |
| 783 | 783 | |
@@ -790,9 +790,9 @@ discard block |
||
| 790 | 790 | <tr> |
| 791 | 791 | <?php |
| 792 | 792 | |
| 793 | - foreach ( $columns as $key => $label ) { |
|
| 794 | - $key = esc_attr( $key ); |
|
| 795 | - $label = esc_html( $label ); |
|
| 793 | + foreach ($columns as $key => $label) { |
|
| 794 | + $key = esc_attr($key); |
|
| 795 | + $label = esc_html($label); |
|
| 796 | 796 | $class = 'text-left'; |
| 797 | 797 | |
| 798 | 798 | echo "<th class='related-subscription-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
@@ -805,62 +805,62 @@ discard block |
||
| 805 | 805 | |
| 806 | 806 | <?php |
| 807 | 807 | |
| 808 | - foreach( $subscription_groups as $subscription_group ) : |
|
| 808 | + foreach ($subscription_groups as $subscription_group) : |
|
| 809 | 809 | |
| 810 | 810 | // Do not list current subscription. |
| 811 | - if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
| 811 | + if ($skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id()) { |
|
| 812 | 812 | continue; |
| 813 | 813 | } |
| 814 | 814 | |
| 815 | 815 | // Ensure the subscription exists. |
| 816 | - $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
| 816 | + $_suscription = new WPInv_Subscription($subscription_group['subscription_id']); |
|
| 817 | 817 | |
| 818 | - if ( ! $_suscription->exists() ) { |
|
| 818 | + if (!$_suscription->exists()) { |
|
| 819 | 819 | continue; |
| 820 | 820 | } |
| 821 | 821 | |
| 822 | 822 | echo '<tr>'; |
| 823 | 823 | |
| 824 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 824 | + foreach (array_keys($columns) as $key) { |
|
| 825 | 825 | |
| 826 | 826 | $class = 'text-left'; |
| 827 | 827 | |
| 828 | 828 | echo "<td class='p-2 $class'>"; |
| 829 | 829 | |
| 830 | - switch( $key ) { |
|
| 830 | + switch ($key) { |
|
| 831 | 831 | |
| 832 | 832 | case 'status': |
| 833 | 833 | echo $_suscription->get_status_label_html(); |
| 834 | 834 | break; |
| 835 | 835 | |
| 836 | 836 | case 'item': |
| 837 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
| 838 | - echo implode( ' | ', $markup ); |
|
| 837 | + $markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
| 838 | + echo implode(' | ', $markup); |
|
| 839 | 839 | break; |
| 840 | 840 | |
| 841 | 841 | case 'renewals': |
| 842 | 842 | $max_bills = $_suscription->get_bill_times(); |
| 843 | - echo $_suscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
| 843 | + echo $_suscription->get_times_billed() . ' / ' . (empty($max_bills) ? "∞" : $max_bills); |
|
| 844 | 844 | break; |
| 845 | 845 | |
| 846 | 846 | case 'renewal_date': |
| 847 | - echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : "—"; |
|
| 847 | + echo $_suscription->is_active() ? getpaid_format_date_value($_suscription->get_expiration()) : "—"; |
|
| 848 | 848 | break; |
| 849 | 849 | |
| 850 | 850 | case 'start_date': |
| 851 | - echo 'pending' == $_suscription->get_status() ? "—" : getpaid_format_date_value( $_suscription->get_date_created() ); |
|
| 851 | + echo 'pending' == $_suscription->get_status() ? "—" : getpaid_format_date_value($_suscription->get_date_created()); |
|
| 852 | 852 | break; |
| 853 | 853 | |
| 854 | 854 | case 'subscription': |
| 855 | - $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
| 855 | + $url = is_admin() ? admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($_suscription->get_id())) : $_suscription->get_view_url(); |
|
| 856 | 856 | printf( |
| 857 | 857 | '%1$s#%2$s%3$s', |
| 858 | - '<a href="' . esc_url( $url ) . '">', |
|
| 859 | - '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
|
| 858 | + '<a href="' . esc_url($url) . '">', |
|
| 859 | + '<strong>' . intval($_suscription->get_id()) . '</strong>', |
|
| 860 | 860 | '</a>' |
| 861 | 861 | ); |
| 862 | 862 | |
| 863 | - echo WPInv_Subscriptions_List_Table::column_amount( $_suscription ); |
|
| 863 | + echo WPInv_Subscriptions_List_Table::column_amount($_suscription); |
|
| 864 | 864 | break; |
| 865 | 865 | |
| 866 | 866 | } |