@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | function wpinv_subscriptions_page() { |
| 16 | 16 | |
| 17 | - ?> |
|
| 17 | + ?> |
|
| 18 | 18 | |
| 19 | 19 | <div class="wrap"> |
| 20 | 20 | <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> |
@@ -22,28 +22,28 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | <?php |
| 24 | 24 | |
| 25 | - // Verify user permissions. |
|
| 26 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 25 | + // Verify user permissions. |
|
| 26 | + if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 27 | 27 | |
| 28 | - aui()->alert( |
|
| 28 | + aui()->alert( |
|
| 29 | 29 | array( |
| 30 | - 'type' => 'danger', |
|
| 31 | - 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
| 32 | - ), |
|
| 33 | - true |
|
| 30 | + 'type' => 'danger', |
|
| 31 | + 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
| 32 | + ), |
|
| 33 | + true |
|
| 34 | 34 | ); |
| 35 | 35 | |
| 36 | - } elseif ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
| 36 | + } elseif ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
| 37 | 37 | |
| 38 | - // Display a single subscription. |
|
| 39 | - wpinv_recurring_subscription_details(); |
|
| 40 | - } else { |
|
| 38 | + // Display a single subscription. |
|
| 39 | + wpinv_recurring_subscription_details(); |
|
| 40 | + } else { |
|
| 41 | 41 | |
| 42 | - // Display a list of available subscriptions. |
|
| 43 | - getpaid_print_subscriptions_list(); |
|
| 44 | - } |
|
| 42 | + // Display a list of available subscriptions. |
|
| 43 | + getpaid_print_subscriptions_list(); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - ?> |
|
| 46 | + ?> |
|
| 47 | 47 | |
| 48 | 48 | </div> |
| 49 | 49 | </div> |
@@ -60,10 +60,10 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | function getpaid_print_subscriptions_list() { |
| 62 | 62 | |
| 63 | - $subscribers_table = new WPInv_Subscriptions_List_Table(); |
|
| 64 | - $subscribers_table->prepare_items(); |
|
| 63 | + $subscribers_table = new WPInv_Subscriptions_List_Table(); |
|
| 64 | + $subscribers_table->prepare_items(); |
|
| 65 | 65 | |
| 66 | - ?> |
|
| 66 | + ?> |
|
| 67 | 67 | <?php $subscribers_table->views(); ?> |
| 68 | 68 | <form id="subscribers-filter" class="bsui" method="get"> |
| 69 | 69 | <input type="hidden" name="page" value="wpinv-subscriptions" /> |
@@ -82,42 +82,42 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | function wpinv_recurring_subscription_details() { |
| 84 | 84 | |
| 85 | - // Fetch the subscription. |
|
| 86 | - $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
| 87 | - if ( ! $sub->exists() ) { |
|
| 85 | + // Fetch the subscription. |
|
| 86 | + $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
| 87 | + if ( ! $sub->exists() ) { |
|
| 88 | 88 | |
| 89 | - aui()->alert( |
|
| 90 | - array( |
|
| 91 | - 'type' => 'danger', |
|
| 92 | - 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
| 93 | - ), |
|
| 94 | - true |
|
| 95 | - ); |
|
| 89 | + aui()->alert( |
|
| 90 | + array( |
|
| 91 | + 'type' => 'danger', |
|
| 92 | + 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
| 93 | + ), |
|
| 94 | + true |
|
| 95 | + ); |
|
| 96 | 96 | |
| 97 | - return; |
|
| 98 | - } |
|
| 97 | + return; |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - // Use metaboxes to display the subscription details. |
|
| 101 | - add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
| 102 | - add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
| 100 | + // Use metaboxes to display the subscription details. |
|
| 101 | + add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
| 102 | + add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
| 103 | 103 | |
| 104 | - $subscription_id = $sub->get_id(); |
|
| 105 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
| 106 | - $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
| 104 | + $subscription_id = $sub->get_id(); |
|
| 105 | + $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
| 106 | + $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
| 107 | 107 | |
| 108 | - if ( 1 < count( $subscription_groups ) ) { |
|
| 109 | - add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
| 110 | - } |
|
| 108 | + if ( 1 < count( $subscription_groups ) ) { |
|
| 109 | + add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | - if ( ! empty( $subscription_group ) ) { |
|
| 113 | - add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
| 114 | - } |
|
| 112 | + if ( ! empty( $subscription_group ) ) { |
|
| 113 | + add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | - add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
| 116 | + add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
| 117 | 117 | |
| 118 | - do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
| 118 | + do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
| 119 | 119 | |
| 120 | - ?> |
|
| 120 | + ?> |
|
| 121 | 121 | |
| 122 | 122 | <form method="post" action="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ) ); ?>"> |
| 123 | 123 | |
@@ -157,49 +157,49 @@ discard block |
||
| 157 | 157 | */ |
| 158 | 158 | function getpaid_admin_subscription_details_metabox( $sub ) { |
| 159 | 159 | |
| 160 | - // Subscription items. |
|
| 161 | - $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
| 162 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
| 163 | - |
|
| 164 | - // Prepare subscription detail columns. |
|
| 165 | - $fields = apply_filters( |
|
| 166 | - 'getpaid_subscription_admin_page_fields', |
|
| 167 | - array( |
|
| 168 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 169 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
| 170 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
| 171 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 172 | - 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
| 173 | - 'renewals' => __( 'Collected Payments', 'invoicing' ), |
|
| 174 | - 'item' => $items_count > 1 ? __( 'Items', 'invoicing' ) : __( 'Item', 'invoicing' ), |
|
| 175 | - 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
| 176 | - 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
| 177 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 178 | - ) |
|
| 179 | - ); |
|
| 180 | - |
|
| 181 | - if ( ! $sub->is_active() ) { |
|
| 182 | - |
|
| 183 | - if ( isset( $fields['renews_on'] ) ) { |
|
| 184 | - unset( $fields['renews_on'] ); |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - if ( isset( $fields['gateway'] ) ) { |
|
| 188 | - unset( $fields['gateway'] ); |
|
| 189 | - } |
|
| 190 | - } elseif ( $sub->is_last_renewal() ) { |
|
| 191 | - |
|
| 192 | - if ( isset( $fields['renews_on'] ) ) { |
|
| 193 | - $fields['renews_on'] = __( 'End Date', 'invoicing' ); |
|
| 194 | - } |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - $profile_id = $sub->get_profile_id(); |
|
| 198 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
| 199 | - unset( $fields['profile_id'] ); |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - ?> |
|
| 160 | + // Subscription items. |
|
| 161 | + $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
| 162 | + $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
| 163 | + |
|
| 164 | + // Prepare subscription detail columns. |
|
| 165 | + $fields = apply_filters( |
|
| 166 | + 'getpaid_subscription_admin_page_fields', |
|
| 167 | + array( |
|
| 168 | + 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 169 | + 'customer' => __( 'Customer', 'invoicing' ), |
|
| 170 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
| 171 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 172 | + 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
| 173 | + 'renewals' => __( 'Collected Payments', 'invoicing' ), |
|
| 174 | + 'item' => $items_count > 1 ? __( 'Items', 'invoicing' ) : __( 'Item', 'invoicing' ), |
|
| 175 | + 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
| 176 | + 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
| 177 | + 'status' => __( 'Status', 'invoicing' ), |
|
| 178 | + ) |
|
| 179 | + ); |
|
| 180 | + |
|
| 181 | + if ( ! $sub->is_active() ) { |
|
| 182 | + |
|
| 183 | + if ( isset( $fields['renews_on'] ) ) { |
|
| 184 | + unset( $fields['renews_on'] ); |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + if ( isset( $fields['gateway'] ) ) { |
|
| 188 | + unset( $fields['gateway'] ); |
|
| 189 | + } |
|
| 190 | + } elseif ( $sub->is_last_renewal() ) { |
|
| 191 | + |
|
| 192 | + if ( isset( $fields['renews_on'] ) ) { |
|
| 193 | + $fields['renews_on'] = __( 'End Date', 'invoicing' ); |
|
| 194 | + } |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + $profile_id = $sub->get_profile_id(); |
|
| 198 | + if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
| 199 | + unset( $fields['profile_id'] ); |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + ?> |
|
| 203 | 203 | |
| 204 | 204 | <table class="table table-borderless" style="font-size: 14px;"> |
| 205 | 205 | <tbody> |
@@ -233,20 +233,20 @@ discard block |
||
| 233 | 233 | */ |
| 234 | 234 | function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
| 235 | 235 | |
| 236 | - $username = __( '(Missing User)', 'invoicing' ); |
|
| 236 | + $username = __( '(Missing User)', 'invoicing' ); |
|
| 237 | 237 | |
| 238 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
| 239 | - if ( $user ) { |
|
| 238 | + $user = get_userdata( $subscription->get_customer_id() ); |
|
| 239 | + if ( $user ) { |
|
| 240 | 240 | |
| 241 | - $username = sprintf( |
|
| 242 | - '<a href="user-edit.php?user_id=%s">%s</a>', |
|
| 243 | - absint( $user->ID ), |
|
| 244 | - ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email ) |
|
| 245 | - ); |
|
| 241 | + $username = sprintf( |
|
| 242 | + '<a href="user-edit.php?user_id=%s">%s</a>', |
|
| 243 | + absint( $user->ID ), |
|
| 244 | + ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email ) |
|
| 245 | + ); |
|
| 246 | 246 | |
| 247 | - } |
|
| 247 | + } |
|
| 248 | 248 | |
| 249 | - echo wp_kses_post( $username ); |
|
| 249 | + echo wp_kses_post( $username ); |
|
| 250 | 250 | } |
| 251 | 251 | add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
| 252 | 252 | |
@@ -256,8 +256,8 @@ discard block |
||
| 256 | 256 | * @param WPInv_Subscription $subscription |
| 257 | 257 | */ |
| 258 | 258 | function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
| 259 | - $amount = getpaid_get_formatted_subscription_amount( $subscription ); |
|
| 260 | - echo wp_kses_post( "<span>$amount</span>" ); |
|
| 259 | + $amount = getpaid_get_formatted_subscription_amount( $subscription ); |
|
| 260 | + echo wp_kses_post( "<span>$amount</span>" ); |
|
| 261 | 261 | } |
| 262 | 262 | add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
| 263 | 263 | |
@@ -268,11 +268,11 @@ discard block |
||
| 268 | 268 | */ |
| 269 | 269 | function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
| 270 | 270 | |
| 271 | - printf( |
|
| 272 | - '<a href="%s">#%s</a>', |
|
| 273 | - esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ), |
|
| 274 | - absint( $subscription->get_id() ) |
|
| 275 | - ); |
|
| 271 | + printf( |
|
| 272 | + '<a href="%s">#%s</a>', |
|
| 273 | + esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ), |
|
| 274 | + absint( $subscription->get_id() ) |
|
| 275 | + ); |
|
| 276 | 276 | |
| 277 | 277 | } |
| 278 | 278 | add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
@@ -284,24 +284,24 @@ discard block |
||
| 284 | 284 | */ |
| 285 | 285 | function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
| 286 | 286 | |
| 287 | - if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) { |
|
| 288 | - aui()->input( |
|
| 289 | - array( |
|
| 290 | - 'type' => 'text', |
|
| 291 | - 'id' => 'wpinv_subscription_date_created', |
|
| 292 | - 'name' => 'wpinv_subscription_date_created', |
|
| 293 | - 'label' => __( 'Start Date', 'invoicing' ), |
|
| 294 | - 'label_type' => 'hidden', |
|
| 295 | - 'placeholder' => 'YYYY-MM-DD', |
|
| 296 | - 'value' => esc_attr( $subscription->get_date_created( 'edit' ) ), |
|
| 297 | - 'no_wrap' => true, |
|
| 298 | - 'size' => 'sm', |
|
| 299 | - ), |
|
| 300 | - true |
|
| 301 | - ); |
|
| 302 | - } else { |
|
| 303 | - echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) ); |
|
| 304 | - } |
|
| 287 | + if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) { |
|
| 288 | + aui()->input( |
|
| 289 | + array( |
|
| 290 | + 'type' => 'text', |
|
| 291 | + 'id' => 'wpinv_subscription_date_created', |
|
| 292 | + 'name' => 'wpinv_subscription_date_created', |
|
| 293 | + 'label' => __( 'Start Date', 'invoicing' ), |
|
| 294 | + 'label_type' => 'hidden', |
|
| 295 | + 'placeholder' => 'YYYY-MM-DD', |
|
| 296 | + 'value' => esc_attr( $subscription->get_date_created( 'edit' ) ), |
|
| 297 | + 'no_wrap' => true, |
|
| 298 | + 'size' => 'sm', |
|
| 299 | + ), |
|
| 300 | + true |
|
| 301 | + ); |
|
| 302 | + } else { |
|
| 303 | + echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) ); |
|
| 304 | + } |
|
| 305 | 305 | |
| 306 | 306 | } |
| 307 | 307 | add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
@@ -313,24 +313,24 @@ discard block |
||
| 313 | 313 | */ |
| 314 | 314 | function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
| 315 | 315 | |
| 316 | - if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) { |
|
| 317 | - aui()->input( |
|
| 318 | - array( |
|
| 319 | - 'type' => 'text', |
|
| 320 | - 'id' => 'wpinv_subscription_expiration', |
|
| 321 | - 'name' => 'wpinv_subscription_expiration', |
|
| 322 | - 'label' => __( 'Renews On', 'invoicing' ), |
|
| 323 | - 'label_type' => 'hidden', |
|
| 324 | - 'placeholder' => 'YYYY-MM-DD', |
|
| 325 | - 'value' => esc_attr( $subscription->get_expiration( 'edit' ) ), |
|
| 326 | - 'no_wrap' => true, |
|
| 327 | - 'size' => 'sm', |
|
| 328 | - ), |
|
| 329 | - true |
|
| 330 | - ); |
|
| 331 | - } else { |
|
| 332 | - echo esc_html( getpaid_format_date_value( $subscription->get_expiration() ) ); |
|
| 333 | - } |
|
| 316 | + if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) { |
|
| 317 | + aui()->input( |
|
| 318 | + array( |
|
| 319 | + 'type' => 'text', |
|
| 320 | + 'id' => 'wpinv_subscription_expiration', |
|
| 321 | + 'name' => 'wpinv_subscription_expiration', |
|
| 322 | + 'label' => __( 'Renews On', 'invoicing' ), |
|
| 323 | + 'label_type' => 'hidden', |
|
| 324 | + 'placeholder' => 'YYYY-MM-DD', |
|
| 325 | + 'value' => esc_attr( $subscription->get_expiration( 'edit' ) ), |
|
| 326 | + 'no_wrap' => true, |
|
| 327 | + 'size' => 'sm', |
|
| 328 | + ), |
|
| 329 | + true |
|
| 330 | + ); |
|
| 331 | + } else { |
|
| 332 | + echo esc_html( getpaid_format_date_value( $subscription->get_expiration() ) ); |
|
| 333 | + } |
|
| 334 | 334 | } |
| 335 | 335 | add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
| 336 | 336 | |
@@ -341,32 +341,32 @@ discard block |
||
| 341 | 341 | */ |
| 342 | 342 | function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
| 343 | 343 | |
| 344 | - $max_bills = $subscription->get_bill_times(); |
|
| 345 | - $times_billed = (int) $subscription->get_times_billed(); |
|
| 346 | - |
|
| 347 | - if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_bill_times_change' ) ) { |
|
| 348 | - aui()->input( |
|
| 349 | - array( |
|
| 350 | - 'type' => 'number', |
|
| 351 | - 'id' => 'wpinv_subscription_max_bill_times', |
|
| 352 | - 'name' => 'wpinv_subscription_max_bill_times', |
|
| 353 | - 'label' => __( 'Maximum bill times', 'invoicing' ), |
|
| 354 | - 'label_type' => 'hidden', |
|
| 355 | - 'placeholder' => __( 'Unlimited', 'invoicing' ), |
|
| 356 | - 'value' => empty( $max_bills ) ? '' : (int) $max_bills, |
|
| 357 | - 'no_wrap' => true, |
|
| 358 | - 'size' => 'sm', |
|
| 359 | - 'input_group_left' => sprintf( |
|
| 360 | - // translators: %d: Number of times billed |
|
| 361 | - __( '%d of', 'invoicing' ), |
|
| 362 | - $times_billed |
|
| 363 | - ), |
|
| 364 | - ), |
|
| 365 | - true |
|
| 366 | - ); |
|
| 367 | - } else { |
|
| 368 | - echo esc_html( $times_billed ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
| 369 | - } |
|
| 344 | + $max_bills = $subscription->get_bill_times(); |
|
| 345 | + $times_billed = (int) $subscription->get_times_billed(); |
|
| 346 | + |
|
| 347 | + if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_bill_times_change' ) ) { |
|
| 348 | + aui()->input( |
|
| 349 | + array( |
|
| 350 | + 'type' => 'number', |
|
| 351 | + 'id' => 'wpinv_subscription_max_bill_times', |
|
| 352 | + 'name' => 'wpinv_subscription_max_bill_times', |
|
| 353 | + 'label' => __( 'Maximum bill times', 'invoicing' ), |
|
| 354 | + 'label_type' => 'hidden', |
|
| 355 | + 'placeholder' => __( 'Unlimited', 'invoicing' ), |
|
| 356 | + 'value' => empty( $max_bills ) ? '' : (int) $max_bills, |
|
| 357 | + 'no_wrap' => true, |
|
| 358 | + 'size' => 'sm', |
|
| 359 | + 'input_group_left' => sprintf( |
|
| 360 | + // translators: %d: Number of times billed |
|
| 361 | + __( '%d of', 'invoicing' ), |
|
| 362 | + $times_billed |
|
| 363 | + ), |
|
| 364 | + ), |
|
| 365 | + true |
|
| 366 | + ); |
|
| 367 | + } else { |
|
| 368 | + echo esc_html( $times_billed ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
| 369 | + } |
|
| 370 | 370 | } |
| 371 | 371 | add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
| 372 | 372 | |
@@ -378,13 +378,13 @@ discard block |
||
| 378 | 378 | */ |
| 379 | 379 | function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) { |
| 380 | 380 | |
| 381 | - if ( empty( $subscription_group ) ) { |
|
| 382 | - echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) ); |
|
| 383 | - return; |
|
| 384 | - } |
|
| 381 | + if ( empty( $subscription_group ) ) { |
|
| 382 | + echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) ); |
|
| 383 | + return; |
|
| 384 | + } |
|
| 385 | 385 | |
| 386 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
| 387 | - echo wp_kses_post( implode( ' | ', $markup ) ); |
|
| 386 | + $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
| 387 | + echo wp_kses_post( implode( ' | ', $markup ) ); |
|
| 388 | 388 | |
| 389 | 389 | } |
| 390 | 390 | add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 ); |
@@ -396,13 +396,13 @@ discard block |
||
| 396 | 396 | */ |
| 397 | 397 | function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
| 398 | 398 | |
| 399 | - $gateway = $subscription->get_gateway(); |
|
| 399 | + $gateway = $subscription->get_gateway(); |
|
| 400 | 400 | |
| 401 | - if ( ! empty( $gateway ) ) { |
|
| 402 | - echo esc_html( wpinv_get_gateway_admin_label( $gateway ) ); |
|
| 403 | - } else { |
|
| 404 | - echo '—'; |
|
| 405 | - } |
|
| 401 | + if ( ! empty( $gateway ) ) { |
|
| 402 | + echo esc_html( wpinv_get_gateway_admin_label( $gateway ) ); |
|
| 403 | + } else { |
|
| 404 | + echo '—'; |
|
| 405 | + } |
|
| 406 | 406 | |
| 407 | 407 | } |
| 408 | 408 | add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | * @param WPInv_Subscription $subscription |
| 414 | 414 | */ |
| 415 | 415 | function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
| 416 | - echo wp_kses_post( $subscription->get_status_label_html() ); |
|
| 416 | + echo wp_kses_post( $subscription->get_status_label_html() ); |
|
| 417 | 417 | } |
| 418 | 418 | add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
| 419 | 419 | |
@@ -424,28 +424,28 @@ discard block |
||
| 424 | 424 | */ |
| 425 | 425 | function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
| 426 | 426 | |
| 427 | - $profile_id = $subscription->get_profile_id(); |
|
| 428 | - |
|
| 429 | - aui()->input( |
|
| 430 | - array( |
|
| 431 | - 'type' => 'text', |
|
| 432 | - 'id' => 'wpinv_subscription_profile_id', |
|
| 433 | - 'name' => 'wpinv_subscription_profile_id', |
|
| 434 | - 'label' => __( 'Profile Id', 'invoicing' ), |
|
| 435 | - 'label_type' => 'hidden', |
|
| 436 | - 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
| 437 | - 'value' => esc_attr( $profile_id ), |
|
| 438 | - 'input_group_right' => '', |
|
| 439 | - 'no_wrap' => true, |
|
| 440 | - 'size' => 'sm', |
|
| 441 | - ), |
|
| 442 | - true |
|
| 443 | - ); |
|
| 444 | - |
|
| 445 | - $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
| 446 | - if ( ! empty( $url ) ) { |
|
| 447 | - echo ' <a href="' . esc_url_raw( $url ) . '" title="' . esc_attr__( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
| 448 | - } |
|
| 427 | + $profile_id = $subscription->get_profile_id(); |
|
| 428 | + |
|
| 429 | + aui()->input( |
|
| 430 | + array( |
|
| 431 | + 'type' => 'text', |
|
| 432 | + 'id' => 'wpinv_subscription_profile_id', |
|
| 433 | + 'name' => 'wpinv_subscription_profile_id', |
|
| 434 | + 'label' => __( 'Profile Id', 'invoicing' ), |
|
| 435 | + 'label_type' => 'hidden', |
|
| 436 | + 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
| 437 | + 'value' => esc_attr( $profile_id ), |
|
| 438 | + 'input_group_right' => '', |
|
| 439 | + 'no_wrap' => true, |
|
| 440 | + 'size' => 'sm', |
|
| 441 | + ), |
|
| 442 | + true |
|
| 443 | + ); |
|
| 444 | + |
|
| 445 | + $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
| 446 | + if ( ! empty( $url ) ) { |
|
| 447 | + echo ' <a href="' . esc_url_raw( $url ) . '" title="' . esc_attr__( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
| 448 | + } |
|
| 449 | 449 | |
| 450 | 450 | } |
| 451 | 451 | add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
@@ -457,40 +457,40 @@ discard block |
||
| 457 | 457 | */ |
| 458 | 458 | function getpaid_admin_subscription_update_metabox( $subscription ) { |
| 459 | 459 | |
| 460 | - ?> |
|
| 460 | + ?> |
|
| 461 | 461 | <div class="mt-3"> |
| 462 | 462 | |
| 463 | 463 | <?php |
| 464 | - aui()->select( |
|
| 465 | - array( |
|
| 466 | - 'options' => getpaid_get_subscription_statuses(), |
|
| 467 | - 'name' => 'subscription_status', |
|
| 468 | - 'id' => 'subscription_status_update_select', |
|
| 469 | - 'required' => true, |
|
| 470 | - 'no_wrap' => false, |
|
| 471 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
| 472 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
| 473 | - 'select2' => true, |
|
| 474 | - 'value' => $subscription->get_status( 'edit' ), |
|
| 475 | - ), |
|
| 476 | - true |
|
| 477 | - ); |
|
| 478 | - ?> |
|
| 464 | + aui()->select( |
|
| 465 | + array( |
|
| 466 | + 'options' => getpaid_get_subscription_statuses(), |
|
| 467 | + 'name' => 'subscription_status', |
|
| 468 | + 'id' => 'subscription_status_update_select', |
|
| 469 | + 'required' => true, |
|
| 470 | + 'no_wrap' => false, |
|
| 471 | + 'label' => __( 'Subscription Status', 'invoicing' ), |
|
| 472 | + 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
| 473 | + 'select2' => true, |
|
| 474 | + 'value' => $subscription->get_status( 'edit' ), |
|
| 475 | + ), |
|
| 476 | + true |
|
| 477 | + ); |
|
| 478 | + ?> |
|
| 479 | 479 | |
| 480 | 480 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;"> |
| 481 | 481 | |
| 482 | 482 | <?php |
| 483 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
| 483 | + submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
| 484 | 484 | |
| 485 | - $url = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
| 486 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
| 487 | - $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' ); |
|
| 485 | + $url = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
| 486 | + $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
| 487 | + $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' ); |
|
| 488 | 488 | |
| 489 | - if ( $subscription->is_active() ) { |
|
| 490 | - echo "<a href='" . esc_url( $url ) . "' class='float-right text-muted' onclick='return confirm(\"" . esc_attr( $title ) . "\")'>" . esc_html( $anchor ) . "</a>"; |
|
| 491 | - } |
|
| 489 | + if ( $subscription->is_active() ) { |
|
| 490 | + echo "<a href='" . esc_url( $url ) . "' class='float-right text-muted' onclick='return confirm(\"" . esc_attr( $title ) . "\")'>" . esc_html( $anchor ) . "</a>"; |
|
| 491 | + } |
|
| 492 | 492 | |
| 493 | - echo '</div></div>'; |
|
| 493 | + echo '</div></div>'; |
|
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | /** |
@@ -501,33 +501,33 @@ discard block |
||
| 501 | 501 | */ |
| 502 | 502 | function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) { |
| 503 | 503 | |
| 504 | - $columns = apply_filters( |
|
| 505 | - 'getpaid_subscription_related_invoices_columns', |
|
| 506 | - array( |
|
| 507 | - 'invoice' => __( 'Invoice', 'invoicing' ), |
|
| 508 | - 'relationship' => __( 'Relationship', 'invoicing' ), |
|
| 509 | - 'date' => __( 'Date', 'invoicing' ), |
|
| 510 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 511 | - 'total' => __( 'Total', 'invoicing' ), |
|
| 512 | - ), |
|
| 513 | - $subscription |
|
| 514 | - ); |
|
| 515 | - |
|
| 516 | - // Prepare the invoices. |
|
| 517 | - $payments = $subscription->get_child_payments( ! is_admin() ); |
|
| 518 | - $parent = $subscription->get_parent_invoice(); |
|
| 519 | - |
|
| 520 | - if ( $parent->exists() ) { |
|
| 521 | - $payments = array_merge( array( $parent ), $payments ); |
|
| 522 | - } |
|
| 523 | - |
|
| 524 | - $table_class = 'w-100 bg-white'; |
|
| 525 | - |
|
| 526 | - if ( ! is_admin() ) { |
|
| 527 | - $table_class = 'table table-bordered'; |
|
| 528 | - } |
|
| 529 | - |
|
| 530 | - ?> |
|
| 504 | + $columns = apply_filters( |
|
| 505 | + 'getpaid_subscription_related_invoices_columns', |
|
| 506 | + array( |
|
| 507 | + 'invoice' => __( 'Invoice', 'invoicing' ), |
|
| 508 | + 'relationship' => __( 'Relationship', 'invoicing' ), |
|
| 509 | + 'date' => __( 'Date', 'invoicing' ), |
|
| 510 | + 'status' => __( 'Status', 'invoicing' ), |
|
| 511 | + 'total' => __( 'Total', 'invoicing' ), |
|
| 512 | + ), |
|
| 513 | + $subscription |
|
| 514 | + ); |
|
| 515 | + |
|
| 516 | + // Prepare the invoices. |
|
| 517 | + $payments = $subscription->get_child_payments( ! is_admin() ); |
|
| 518 | + $parent = $subscription->get_parent_invoice(); |
|
| 519 | + |
|
| 520 | + if ( $parent->exists() ) { |
|
| 521 | + $payments = array_merge( array( $parent ), $payments ); |
|
| 522 | + } |
|
| 523 | + |
|
| 524 | + $table_class = 'w-100 bg-white'; |
|
| 525 | + |
|
| 526 | + if ( ! is_admin() ) { |
|
| 527 | + $table_class = 'table table-bordered'; |
|
| 528 | + } |
|
| 529 | + |
|
| 530 | + ?> |
|
| 531 | 531 | <div class="m-0" style="overflow: auto;"> |
| 532 | 532 | |
| 533 | 533 | <table class="<?php echo esc_attr( $table_class ); ?>"> |
@@ -535,10 +535,10 @@ discard block |
||
| 535 | 535 | <thead> |
| 536 | 536 | <tr> |
| 537 | 537 | <?php |
| 538 | - foreach ( $columns as $key => $label ) { |
|
| 539 | - echo "<th class='subscription-invoice-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
| 540 | - } |
|
| 541 | - ?> |
|
| 538 | + foreach ( $columns as $key => $label ) { |
|
| 539 | + echo "<th class='subscription-invoice-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
| 540 | + } |
|
| 541 | + ?> |
|
| 542 | 542 | </tr> |
| 543 | 543 | </thead> |
| 544 | 544 | |
@@ -554,72 +554,72 @@ discard block |
||
| 554 | 554 | |
| 555 | 555 | <?php |
| 556 | 556 | |
| 557 | - foreach ( $payments as $payment ) : |
|
| 557 | + foreach ( $payments as $payment ) : |
|
| 558 | 558 | |
| 559 | - // Ensure that we have an invoice. |
|
| 560 | - $payment = new WPInv_Invoice( $payment ); |
|
| 559 | + // Ensure that we have an invoice. |
|
| 560 | + $payment = new WPInv_Invoice( $payment ); |
|
| 561 | 561 | |
| 562 | - // Abort if the invoice is invalid... |
|
| 563 | - if ( ! $payment->exists() ) { |
|
| 564 | - continue; |
|
| 565 | - } |
|
| 562 | + // Abort if the invoice is invalid... |
|
| 563 | + if ( ! $payment->exists() ) { |
|
| 564 | + continue; |
|
| 565 | + } |
|
| 566 | 566 | |
| 567 | - // ... or belongs to a different subscription. |
|
| 568 | - if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
| 569 | - continue; |
|
| 570 | - } |
|
| 567 | + // ... or belongs to a different subscription. |
|
| 568 | + if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
| 569 | + continue; |
|
| 570 | + } |
|
| 571 | 571 | |
| 572 | - echo '<tr>'; |
|
| 572 | + echo '<tr>'; |
|
| 573 | 573 | |
| 574 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 574 | + foreach ( array_keys( $columns ) as $key ) { |
|
| 575 | 575 | |
| 576 | - echo "<td class='p-2 text-left'>"; |
|
| 576 | + echo "<td class='p-2 text-left'>"; |
|
| 577 | 577 | |
| 578 | - switch ( $key ) { |
|
| 578 | + switch ( $key ) { |
|
| 579 | 579 | |
| 580 | - case 'total': |
|
| 581 | - echo '<strong>'; |
|
| 582 | - wpinv_the_price( $payment->get_total(), $payment->get_currency() ); |
|
| 583 | - echo '</strong>'; |
|
| 584 | - break; |
|
| 580 | + case 'total': |
|
| 581 | + echo '<strong>'; |
|
| 582 | + wpinv_the_price( $payment->get_total(), $payment->get_currency() ); |
|
| 583 | + echo '</strong>'; |
|
| 584 | + break; |
|
| 585 | 585 | |
| 586 | - case 'relationship': |
|
| 587 | - echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' ); |
|
| 588 | - break; |
|
| 586 | + case 'relationship': |
|
| 587 | + echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' ); |
|
| 588 | + break; |
|
| 589 | 589 | |
| 590 | - case 'date': |
|
| 591 | - echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) ); |
|
| 592 | - break; |
|
| 590 | + case 'date': |
|
| 591 | + echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) ); |
|
| 592 | + break; |
|
| 593 | 593 | |
| 594 | - case 'status': |
|
| 595 | - $status = $payment->get_status_nicename(); |
|
| 596 | - if ( is_admin() ) { |
|
| 597 | - $status = $payment->get_status_label_html(); |
|
| 598 | - } |
|
| 594 | + case 'status': |
|
| 595 | + $status = $payment->get_status_nicename(); |
|
| 596 | + if ( is_admin() ) { |
|
| 597 | + $status = $payment->get_status_label_html(); |
|
| 598 | + } |
|
| 599 | 599 | |
| 600 | - echo wp_kses_post( $status ); |
|
| 601 | - break; |
|
| 600 | + echo wp_kses_post( $status ); |
|
| 601 | + break; |
|
| 602 | 602 | |
| 603 | - case 'invoice': |
|
| 604 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
| 603 | + case 'invoice': |
|
| 604 | + $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
| 605 | 605 | |
| 606 | - if ( ! is_admin() ) { |
|
| 607 | - $link = esc_url( $payment->get_view_url() ); |
|
| 608 | - } |
|
| 606 | + if ( ! is_admin() ) { |
|
| 607 | + $link = esc_url( $payment->get_view_url() ); |
|
| 608 | + } |
|
| 609 | 609 | |
| 610 | - $invoice = esc_html( $payment->get_number() ); |
|
| 611 | - echo wp_kses_post( "<a href='$link'>$invoice</a>" ); |
|
| 612 | - break; |
|
| 613 | - } |
|
| 610 | + $invoice = esc_html( $payment->get_number() ); |
|
| 611 | + echo wp_kses_post( "<a href='$link'>$invoice</a>" ); |
|
| 612 | + break; |
|
| 613 | + } |
|
| 614 | 614 | |
| 615 | - echo '</td>'; |
|
| 615 | + echo '</td>'; |
|
| 616 | 616 | |
| 617 | - } |
|
| 617 | + } |
|
| 618 | 618 | |
| 619 | - echo '</tr>'; |
|
| 619 | + echo '</tr>'; |
|
| 620 | 620 | |
| 621 | - endforeach; |
|
| 622 | - ?> |
|
| 621 | + endforeach; |
|
| 622 | + ?> |
|
| 623 | 623 | |
| 624 | 624 | </tbody> |
| 625 | 625 | |
@@ -637,42 +637,42 @@ discard block |
||
| 637 | 637 | */ |
| 638 | 638 | function getpaid_admin_subscription_item_details_metabox( $subscription ) { |
| 639 | 639 | |
| 640 | - // Fetch the subscription group. |
|
| 641 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
| 640 | + // Fetch the subscription group. |
|
| 641 | + $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
| 642 | 642 | |
| 643 | - if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
| 644 | - return; |
|
| 645 | - } |
|
| 643 | + if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
| 644 | + return; |
|
| 645 | + } |
|
| 646 | 646 | |
| 647 | - // Prepare table columns. |
|
| 648 | - $columns = apply_filters( |
|
| 649 | - 'getpaid_subscription_item_details_columns', |
|
| 650 | - array( |
|
| 651 | - 'item_name' => __( 'Item', 'invoicing' ), |
|
| 652 | - 'price' => __( 'Price', 'invoicing' ), |
|
| 653 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
| 654 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
| 655 | - //'initial' => __( 'Initial Amount', 'invoicing' ), |
|
| 656 | - 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
| 657 | - ), |
|
| 658 | - $subscription |
|
| 659 | - ); |
|
| 647 | + // Prepare table columns. |
|
| 648 | + $columns = apply_filters( |
|
| 649 | + 'getpaid_subscription_item_details_columns', |
|
| 650 | + array( |
|
| 651 | + 'item_name' => __( 'Item', 'invoicing' ), |
|
| 652 | + 'price' => __( 'Price', 'invoicing' ), |
|
| 653 | + 'tax' => __( 'Tax', 'invoicing' ), |
|
| 654 | + 'discount' => __( 'Discount', 'invoicing' ), |
|
| 655 | + //'initial' => __( 'Initial Amount', 'invoicing' ), |
|
| 656 | + 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
| 657 | + ), |
|
| 658 | + $subscription |
|
| 659 | + ); |
|
| 660 | 660 | |
| 661 | - // Prepare the invoices. |
|
| 661 | + // Prepare the invoices. |
|
| 662 | 662 | |
| 663 | - $invoice = $subscription->get_parent_invoice(); |
|
| 663 | + $invoice = $subscription->get_parent_invoice(); |
|
| 664 | 664 | |
| 665 | - if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
| 666 | - unset( $columns['tax'] ); |
|
| 667 | - } |
|
| 665 | + if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
| 666 | + unset( $columns['tax'] ); |
|
| 667 | + } |
|
| 668 | 668 | |
| 669 | - $table_class = 'w-100 bg-white'; |
|
| 669 | + $table_class = 'w-100 bg-white'; |
|
| 670 | 670 | |
| 671 | - if ( ! is_admin() ) { |
|
| 672 | - $table_class = 'table table-bordered'; |
|
| 673 | - } |
|
| 671 | + if ( ! is_admin() ) { |
|
| 672 | + $table_class = 'table table-bordered'; |
|
| 673 | + } |
|
| 674 | 674 | |
| 675 | - ?> |
|
| 675 | + ?> |
|
| 676 | 676 | <div class="m-0" style="overflow: auto;"> |
| 677 | 677 | |
| 678 | 678 | <table class="<?php echo esc_attr( $table_class ); ?>"> |
@@ -681,10 +681,10 @@ discard block |
||
| 681 | 681 | <tr> |
| 682 | 682 | <?php |
| 683 | 683 | |
| 684 | - foreach ( $columns as $key => $label ) { |
|
| 685 | - echo "<th class='subscription-item-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
| 686 | - } |
|
| 687 | - ?> |
|
| 684 | + foreach ( $columns as $key => $label ) { |
|
| 685 | + echo "<th class='subscription-item-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
| 686 | + } |
|
| 687 | + ?> |
|
| 688 | 688 | </tr> |
| 689 | 689 | </thead> |
| 690 | 690 | |
@@ -692,106 +692,106 @@ discard block |
||
| 692 | 692 | |
| 693 | 693 | <?php |
| 694 | 694 | |
| 695 | - foreach ( $subscription_group['items'] as $subscription_group_item ) : |
|
| 695 | + foreach ( $subscription_group['items'] as $subscription_group_item ) : |
|
| 696 | 696 | |
| 697 | - echo '<tr>'; |
|
| 697 | + echo '<tr>'; |
|
| 698 | 698 | |
| 699 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 699 | + foreach ( array_keys( $columns ) as $key ) { |
|
| 700 | 700 | |
| 701 | - $class = 'text-left'; |
|
| 701 | + $class = 'text-left'; |
|
| 702 | 702 | |
| 703 | - echo "<td class='p-2 text-left'>"; |
|
| 703 | + echo "<td class='p-2 text-left'>"; |
|
| 704 | 704 | |
| 705 | - switch ( $key ) { |
|
| 705 | + switch ( $key ) { |
|
| 706 | 706 | |
| 707 | - case 'item_name': |
|
| 708 | - $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
| 709 | - $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
| 707 | + case 'item_name': |
|
| 708 | + $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
| 709 | + $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
| 710 | 710 | |
| 711 | - if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
| 712 | - echo esc_html( $item_name ); |
|
| 713 | - } else { |
|
| 714 | - printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
| 715 | - } |
|
| 711 | + if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
| 712 | + echo esc_html( $item_name ); |
|
| 713 | + } else { |
|
| 714 | + printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
| 715 | + } |
|
| 716 | 716 | |
| 717 | - break; |
|
| 717 | + break; |
|
| 718 | 718 | |
| 719 | - case 'price': |
|
| 720 | - wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
| 721 | - break; |
|
| 719 | + case 'price': |
|
| 720 | + wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
| 721 | + break; |
|
| 722 | 722 | |
| 723 | - case 'tax': |
|
| 724 | - wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
| 725 | - break; |
|
| 723 | + case 'tax': |
|
| 724 | + wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
| 725 | + break; |
|
| 726 | 726 | |
| 727 | - case 'discount': |
|
| 728 | - wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
| 729 | - break; |
|
| 727 | + case 'discount': |
|
| 728 | + wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
| 729 | + break; |
|
| 730 | 730 | |
| 731 | - case 'initial': |
|
| 732 | - wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
| 733 | - break; |
|
| 731 | + case 'initial': |
|
| 732 | + wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
| 733 | + break; |
|
| 734 | 734 | |
| 735 | - case 'recurring': |
|
| 736 | - echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' ); |
|
| 737 | - break; |
|
| 735 | + case 'recurring': |
|
| 736 | + echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' ); |
|
| 737 | + break; |
|
| 738 | 738 | |
| 739 | - } |
|
| 739 | + } |
|
| 740 | 740 | |
| 741 | - echo '</td>'; |
|
| 741 | + echo '</td>'; |
|
| 742 | 742 | |
| 743 | - } |
|
| 743 | + } |
|
| 744 | 744 | |
| 745 | - echo '</tr>'; |
|
| 745 | + echo '</tr>'; |
|
| 746 | 746 | |
| 747 | - endforeach; |
|
| 747 | + endforeach; |
|
| 748 | 748 | |
| 749 | - foreach ( $subscription_group['fees'] as $subscription_group_fee ) : |
|
| 749 | + foreach ( $subscription_group['fees'] as $subscription_group_fee ) : |
|
| 750 | 750 | |
| 751 | - echo '<tr>'; |
|
| 751 | + echo '<tr>'; |
|
| 752 | 752 | |
| 753 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 753 | + foreach ( array_keys( $columns ) as $key ) { |
|
| 754 | 754 | |
| 755 | - $class = 'text-left'; |
|
| 755 | + $class = 'text-left'; |
|
| 756 | 756 | |
| 757 | - echo "<td class='p-2 text-left'>"; |
|
| 757 | + echo "<td class='p-2 text-left'>"; |
|
| 758 | 758 | |
| 759 | - switch ( $key ) { |
|
| 759 | + switch ( $key ) { |
|
| 760 | 760 | |
| 761 | - case 'item_name': |
|
| 762 | - echo esc_html( $subscription_group_fee['name'] ); |
|
| 763 | - break; |
|
| 761 | + case 'item_name': |
|
| 762 | + echo esc_html( $subscription_group_fee['name'] ); |
|
| 763 | + break; |
|
| 764 | 764 | |
| 765 | - case 'price': |
|
| 766 | - wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
| 767 | - break; |
|
| 765 | + case 'price': |
|
| 766 | + wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
| 767 | + break; |
|
| 768 | 768 | |
| 769 | - case 'tax': |
|
| 770 | - echo '—'; |
|
| 771 | - break; |
|
| 769 | + case 'tax': |
|
| 770 | + echo '—'; |
|
| 771 | + break; |
|
| 772 | 772 | |
| 773 | - case 'discount': |
|
| 774 | - echo '—'; |
|
| 775 | - break; |
|
| 773 | + case 'discount': |
|
| 774 | + echo '—'; |
|
| 775 | + break; |
|
| 776 | 776 | |
| 777 | - case 'initial': |
|
| 778 | - wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
| 779 | - break; |
|
| 777 | + case 'initial': |
|
| 778 | + wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
| 779 | + break; |
|
| 780 | 780 | |
| 781 | - case 'recurring': |
|
| 782 | - echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' ); |
|
| 783 | - break; |
|
| 781 | + case 'recurring': |
|
| 782 | + echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' ); |
|
| 783 | + break; |
|
| 784 | 784 | |
| 785 | - } |
|
| 785 | + } |
|
| 786 | 786 | |
| 787 | - echo '</td>'; |
|
| 787 | + echo '</td>'; |
|
| 788 | 788 | |
| 789 | - } |
|
| 789 | + } |
|
| 790 | 790 | |
| 791 | - echo '</tr>'; |
|
| 791 | + echo '</tr>'; |
|
| 792 | 792 | |
| 793 | - endforeach; |
|
| 794 | - ?> |
|
| 793 | + endforeach; |
|
| 794 | + ?> |
|
| 795 | 795 | |
| 796 | 796 | </tbody> |
| 797 | 797 | |
@@ -810,38 +810,38 @@ discard block |
||
| 810 | 810 | */ |
| 811 | 811 | function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) { |
| 812 | 812 | |
| 813 | - // Fetch the subscription groups. |
|
| 814 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
| 815 | - |
|
| 816 | - if ( empty( $subscription_groups ) ) { |
|
| 817 | - return; |
|
| 818 | - } |
|
| 819 | - |
|
| 820 | - // Prepare table columns. |
|
| 821 | - $columns = apply_filters( |
|
| 822 | - 'getpaid_subscription_related_subscriptions_columns', |
|
| 823 | - array( |
|
| 824 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 825 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 826 | - 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
| 827 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
| 828 | - 'item' => __( 'Items', 'invoicing' ), |
|
| 829 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 830 | - ), |
|
| 831 | - $subscription |
|
| 832 | - ); |
|
| 833 | - |
|
| 834 | - if ( $subscription->get_status() == 'pending' ) { |
|
| 835 | - unset( $columns['start_date'], $columns['renewal_date'] ); |
|
| 836 | - } |
|
| 837 | - |
|
| 838 | - $table_class = 'w-100 bg-white'; |
|
| 839 | - |
|
| 840 | - if ( ! is_admin() ) { |
|
| 841 | - $table_class = 'table table-bordered'; |
|
| 842 | - } |
|
| 843 | - |
|
| 844 | - ?> |
|
| 813 | + // Fetch the subscription groups. |
|
| 814 | + $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
| 815 | + |
|
| 816 | + if ( empty( $subscription_groups ) ) { |
|
| 817 | + return; |
|
| 818 | + } |
|
| 819 | + |
|
| 820 | + // Prepare table columns. |
|
| 821 | + $columns = apply_filters( |
|
| 822 | + 'getpaid_subscription_related_subscriptions_columns', |
|
| 823 | + array( |
|
| 824 | + 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 825 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 826 | + 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
| 827 | + 'renewals' => __( 'Payments', 'invoicing' ), |
|
| 828 | + 'item' => __( 'Items', 'invoicing' ), |
|
| 829 | + 'status' => __( 'Status', 'invoicing' ), |
|
| 830 | + ), |
|
| 831 | + $subscription |
|
| 832 | + ); |
|
| 833 | + |
|
| 834 | + if ( $subscription->get_status() == 'pending' ) { |
|
| 835 | + unset( $columns['start_date'], $columns['renewal_date'] ); |
|
| 836 | + } |
|
| 837 | + |
|
| 838 | + $table_class = 'w-100 bg-white'; |
|
| 839 | + |
|
| 840 | + if ( ! is_admin() ) { |
|
| 841 | + $table_class = 'table table-bordered'; |
|
| 842 | + } |
|
| 843 | + |
|
| 844 | + ?> |
|
| 845 | 845 | <div class="m-0" style="overflow: auto;"> |
| 846 | 846 | |
| 847 | 847 | <table class="<?php echo esc_attr( $table_class ); ?>"> |
@@ -850,10 +850,10 @@ discard block |
||
| 850 | 850 | <tr> |
| 851 | 851 | <?php |
| 852 | 852 | |
| 853 | - foreach ( $columns as $key => $label ) { |
|
| 854 | - echo "<th class='related-subscription-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
| 855 | - } |
|
| 856 | - ?> |
|
| 853 | + foreach ( $columns as $key => $label ) { |
|
| 854 | + echo "<th class='related-subscription-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
| 855 | + } |
|
| 856 | + ?> |
|
| 857 | 857 | </tr> |
| 858 | 858 | </thead> |
| 859 | 859 | |
@@ -861,74 +861,74 @@ discard block |
||
| 861 | 861 | |
| 862 | 862 | <?php |
| 863 | 863 | |
| 864 | - foreach ( $subscription_groups as $subscription_group ) : |
|
| 864 | + foreach ( $subscription_groups as $subscription_group ) : |
|
| 865 | 865 | |
| 866 | - // Do not list current subscription. |
|
| 867 | - if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
| 868 | - continue; |
|
| 869 | - } |
|
| 866 | + // Do not list current subscription. |
|
| 867 | + if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
| 868 | + continue; |
|
| 869 | + } |
|
| 870 | 870 | |
| 871 | - // Ensure the subscription exists. |
|
| 872 | - $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
| 871 | + // Ensure the subscription exists. |
|
| 872 | + $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
| 873 | 873 | |
| 874 | - if ( ! $_suscription->exists() ) { |
|
| 875 | - continue; |
|
| 876 | - } |
|
| 874 | + if ( ! $_suscription->exists() ) { |
|
| 875 | + continue; |
|
| 876 | + } |
|
| 877 | 877 | |
| 878 | - echo '<tr>'; |
|
| 878 | + echo '<tr>'; |
|
| 879 | 879 | |
| 880 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 880 | + foreach ( array_keys( $columns ) as $key ) { |
|
| 881 | 881 | |
| 882 | - $class = 'text-left'; |
|
| 882 | + $class = 'text-left'; |
|
| 883 | 883 | |
| 884 | - echo "<td class='p-2 text-left'>"; |
|
| 884 | + echo "<td class='p-2 text-left'>"; |
|
| 885 | 885 | |
| 886 | - switch ( $key ) { |
|
| 886 | + switch ( $key ) { |
|
| 887 | 887 | |
| 888 | - case 'status': |
|
| 889 | - echo wp_kses_post( $_suscription->get_status_label_html() ); |
|
| 890 | - break; |
|
| 888 | + case 'status': |
|
| 889 | + echo wp_kses_post( $_suscription->get_status_label_html() ); |
|
| 890 | + break; |
|
| 891 | 891 | |
| 892 | - case 'item': |
|
| 893 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
| 894 | - echo wp_kses_post( implode( ' | ', $markup ) ); |
|
| 895 | - break; |
|
| 892 | + case 'item': |
|
| 893 | + $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
| 894 | + echo wp_kses_post( implode( ' | ', $markup ) ); |
|
| 895 | + break; |
|
| 896 | 896 | |
| 897 | - case 'renewals': |
|
| 898 | - $max_bills = $_suscription->get_bill_times(); |
|
| 899 | - echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
| 900 | - break; |
|
| 897 | + case 'renewals': |
|
| 898 | + $max_bills = $_suscription->get_bill_times(); |
|
| 899 | + echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
| 900 | + break; |
|
| 901 | 901 | |
| 902 | - case 'renewal_date': |
|
| 903 | - echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '—'; |
|
| 904 | - break; |
|
| 902 | + case 'renewal_date': |
|
| 903 | + echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '—'; |
|
| 904 | + break; |
|
| 905 | 905 | |
| 906 | - case 'start_date': |
|
| 907 | - echo 'pending' == $_suscription->get_status() ? '—' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) ); |
|
| 908 | - break; |
|
| 906 | + case 'start_date': |
|
| 907 | + echo 'pending' == $_suscription->get_status() ? '—' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) ); |
|
| 908 | + break; |
|
| 909 | 909 | |
| 910 | - case 'subscription': |
|
| 911 | - $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
| 912 | - printf( |
|
| 910 | + case 'subscription': |
|
| 911 | + $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
| 912 | + printf( |
|
| 913 | 913 | '%1$s#%2$s%3$s', |
| 914 | 914 | '<a href="' . esc_url( $url ) . '">', |
| 915 | 915 | '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
| 916 | - '</a>' |
|
| 916 | + '</a>' |
|
| 917 | 917 | ); |
| 918 | 918 | |
| 919 | - echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) ); |
|
| 920 | - break; |
|
| 919 | + echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) ); |
|
| 920 | + break; |
|
| 921 | 921 | |
| 922 | - } |
|
| 922 | + } |
|
| 923 | 923 | |
| 924 | - echo '</td>'; |
|
| 924 | + echo '</td>'; |
|
| 925 | 925 | |
| 926 | - } |
|
| 926 | + } |
|
| 927 | 927 | |
| 928 | - echo '</tr>'; |
|
| 928 | + echo '</tr>'; |
|
| 929 | 929 | |
| 930 | - endforeach; |
|
| 931 | - ?> |
|
| 930 | + endforeach; |
|
| 931 | + ?> |
|
| 932 | 932 | |
| 933 | 933 | </tbody> |
| 934 | 934 | |
@@ -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,23 +17,23 @@ 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 | 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 | true |
| 34 | 34 | ); |
| 35 | 35 | |
| 36 | - } elseif ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
| 36 | + } elseif (!empty($_GET['id']) && is_numeric($_GET['id'])) { |
|
| 37 | 37 | |
| 38 | 38 | // Display a single subscription. |
| 39 | 39 | wpinv_recurring_subscription_details(); |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | <?php $subscribers_table->views(); ?> |
| 68 | 68 | <form id="subscribers-filter" class="bsui" method="get"> |
| 69 | 69 | <input type="hidden" name="page" value="wpinv-subscriptions" /> |
| 70 | - <?php $subscribers_table->search_box( __( 'Search Subscriptions', 'invoicing' ), 'getpaid-search-subscriptions' ); ?> |
|
| 70 | + <?php $subscribers_table->search_box(__('Search Subscriptions', 'invoicing'), 'getpaid-search-subscriptions'); ?> |
|
| 71 | 71 | <?php $subscribers_table->display(); ?> |
| 72 | 72 | </form> |
| 73 | 73 | <?php |
@@ -83,13 +83,13 @@ discard block |
||
| 83 | 83 | function wpinv_recurring_subscription_details() { |
| 84 | 84 | |
| 85 | 85 | // Fetch the subscription. |
| 86 | - $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
| 87 | - if ( ! $sub->exists() ) { |
|
| 86 | + $sub = new WPInv_Subscription((int) $_GET['id']); |
|
| 87 | + if (!$sub->exists()) { |
|
| 88 | 88 | |
| 89 | 89 | aui()->alert( |
| 90 | 90 | array( |
| 91 | 91 | 'type' => 'danger', |
| 92 | - 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
| 92 | + 'content' => __('Subscription not found.', 'invoicing'), |
|
| 93 | 93 | ), |
| 94 | 94 | true |
| 95 | 95 | ); |
@@ -98,32 +98,32 @@ discard block |
||
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | // Use metaboxes to display the subscription details. |
| 101 | - add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
| 102 | - add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
| 101 | + add_meta_box('getpaid_admin_subscription_details_metabox', __('Subscription Details', 'invoicing'), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high'); |
|
| 102 | + add_meta_box('getpaid_admin_subscription_update_metabox', __('Change Status', 'invoicing'), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side'); |
|
| 103 | 103 | |
| 104 | 104 | $subscription_id = $sub->get_id(); |
| 105 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
| 106 | - $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
| 105 | + $subscription_groups = getpaid_get_invoice_subscription_groups($sub->get_parent_invoice_id()); |
|
| 106 | + $subscription_group = wp_list_filter($subscription_groups, compact('subscription_id')); |
|
| 107 | 107 | |
| 108 | - if ( 1 < count( $subscription_groups ) ) { |
|
| 109 | - add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
| 108 | + if (1 < count($subscription_groups)) { |
|
| 109 | + add_meta_box('getpaid_admin_subscription_related_subscriptions_metabox', __('Related Subscriptions', 'invoicing'), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced'); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - if ( ! empty( $subscription_group ) ) { |
|
| 113 | - add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
| 112 | + if (!empty($subscription_group)) { |
|
| 113 | + add_meta_box('getpaid_admin_subscription_item_details_metabox', __('Subscription Items', 'invoicing'), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low'); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
| 116 | + add_meta_box('getpaid_admin_subscription_invoice_details_metabox', __('Related Invoices', 'invoicing'), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced'); |
|
| 117 | 117 | |
| 118 | - do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
| 118 | + do_action('getpaid_admin_single_subscription_register_metabox', $sub); |
|
| 119 | 119 | |
| 120 | 120 | ?> |
| 121 | 121 | |
| 122 | - <form method="post" action="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ) ); ?>"> |
|
| 122 | + <form method="post" action="<?php echo esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($sub->get_id()))); ?>"> |
|
| 123 | 123 | |
| 124 | - <?php wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); ?> |
|
| 125 | - <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> |
|
| 126 | - <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> |
|
| 124 | + <?php wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); ?> |
|
| 125 | + <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?> |
|
| 126 | + <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?> |
|
| 127 | 127 | <input type="hidden" name="getpaid-admin-action" value="update_single_subscription" /> |
| 128 | 128 | <input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id(); ?>" /> |
| 129 | 129 | |
@@ -131,12 +131,12 @@ discard block |
||
| 131 | 131 | <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>"> |
| 132 | 132 | |
| 133 | 133 | <div id="postbox-container-1" class="postbox-container"> |
| 134 | - <?php do_meta_boxes( get_current_screen(), 'side', $sub ); ?> |
|
| 134 | + <?php do_meta_boxes(get_current_screen(), 'side', $sub); ?> |
|
| 135 | 135 | </div> |
| 136 | 136 | |
| 137 | 137 | <div id="postbox-container-2" class="postbox-container"> |
| 138 | - <?php do_meta_boxes( get_current_screen(), 'normal', $sub ); ?> |
|
| 139 | - <?php do_meta_boxes( get_current_screen(), 'advanced', $sub ); ?> |
|
| 138 | + <?php do_meta_boxes(get_current_screen(), 'normal', $sub); ?> |
|
| 139 | + <?php do_meta_boxes(get_current_screen(), 'advanced', $sub); ?> |
|
| 140 | 140 | </div> |
| 141 | 141 | |
| 142 | 142 | </div> |
@@ -155,48 +155,48 @@ discard block |
||
| 155 | 155 | * |
| 156 | 156 | * @param WPInv_Subscription $sub |
| 157 | 157 | */ |
| 158 | -function getpaid_admin_subscription_details_metabox( $sub ) { |
|
| 158 | +function getpaid_admin_subscription_details_metabox($sub) { |
|
| 159 | 159 | |
| 160 | 160 | // Subscription items. |
| 161 | - $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
| 162 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
| 161 | + $subscription_group = getpaid_get_invoice_subscription_group($sub->get_parent_invoice_id(), $sub->get_id()); |
|
| 162 | + $items_count = empty($subscription_group) ? 1 : count($subscription_group['items']); |
|
| 163 | 163 | |
| 164 | 164 | // Prepare subscription detail columns. |
| 165 | 165 | $fields = apply_filters( |
| 166 | 166 | 'getpaid_subscription_admin_page_fields', |
| 167 | 167 | array( |
| 168 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 169 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
| 170 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
| 171 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 172 | - 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
| 173 | - 'renewals' => __( 'Collected Payments', 'invoicing' ), |
|
| 174 | - 'item' => $items_count > 1 ? __( 'Items', 'invoicing' ) : __( 'Item', 'invoicing' ), |
|
| 175 | - 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
| 176 | - 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
| 177 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 168 | + 'subscription' => __('Subscription', 'invoicing'), |
|
| 169 | + 'customer' => __('Customer', 'invoicing'), |
|
| 170 | + 'amount' => __('Amount', 'invoicing'), |
|
| 171 | + 'start_date' => __('Start Date', 'invoicing'), |
|
| 172 | + 'renews_on' => __('Next Payment', 'invoicing'), |
|
| 173 | + 'renewals' => __('Collected Payments', 'invoicing'), |
|
| 174 | + 'item' => $items_count > 1 ? __('Items', 'invoicing') : __('Item', 'invoicing'), |
|
| 175 | + 'gateway' => __('Payment Method', 'invoicing'), |
|
| 176 | + 'profile_id' => __('Profile ID', 'invoicing'), |
|
| 177 | + 'status' => __('Status', 'invoicing'), |
|
| 178 | 178 | ) |
| 179 | 179 | ); |
| 180 | 180 | |
| 181 | - if ( ! $sub->is_active() ) { |
|
| 181 | + if (!$sub->is_active()) { |
|
| 182 | 182 | |
| 183 | - if ( isset( $fields['renews_on'] ) ) { |
|
| 184 | - unset( $fields['renews_on'] ); |
|
| 183 | + if (isset($fields['renews_on'])) { |
|
| 184 | + unset($fields['renews_on']); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - if ( isset( $fields['gateway'] ) ) { |
|
| 188 | - unset( $fields['gateway'] ); |
|
| 187 | + if (isset($fields['gateway'])) { |
|
| 188 | + unset($fields['gateway']); |
|
| 189 | 189 | } |
| 190 | - } elseif ( $sub->is_last_renewal() ) { |
|
| 190 | + } elseif ($sub->is_last_renewal()) { |
|
| 191 | 191 | |
| 192 | - if ( isset( $fields['renews_on'] ) ) { |
|
| 193 | - $fields['renews_on'] = __( 'End Date', 'invoicing' ); |
|
| 192 | + if (isset($fields['renews_on'])) { |
|
| 193 | + $fields['renews_on'] = __('End Date', 'invoicing'); |
|
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | $profile_id = $sub->get_profile_id(); |
| 198 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
| 199 | - unset( $fields['profile_id'] ); |
|
| 198 | + if (empty($profile_id) && isset($fields['profile_id'])) { |
|
| 199 | + unset($fields['profile_id']); |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | ?> |
@@ -204,16 +204,16 @@ discard block |
||
| 204 | 204 | <table class="table table-borderless" style="font-size: 14px;"> |
| 205 | 205 | <tbody> |
| 206 | 206 | |
| 207 | - <?php foreach ( $fields as $key => $label ) : ?> |
|
| 207 | + <?php foreach ($fields as $key => $label) : ?> |
|
| 208 | 208 | |
| 209 | - <tr class="getpaid-subscription-meta-<?php echo esc_attr( $key ); ?>"> |
|
| 209 | + <tr class="getpaid-subscription-meta-<?php echo esc_attr($key); ?>"> |
|
| 210 | 210 | |
| 211 | 211 | <th class="w-25" style="font-weight: 500;"> |
| 212 | - <?php echo esc_html( $label ); ?> |
|
| 212 | + <?php echo esc_html($label); ?> |
|
| 213 | 213 | </th> |
| 214 | 214 | |
| 215 | 215 | <td class="w-75 text-muted"> |
| 216 | - <?php do_action( 'getpaid_subscription_admin_display_' . sanitize_key( $key ), $sub, $subscription_group ); ?> |
|
| 216 | + <?php do_action('getpaid_subscription_admin_display_' . sanitize_key($key), $sub, $subscription_group); ?> |
|
| 217 | 217 | </td> |
| 218 | 218 | |
| 219 | 219 | </tr> |
@@ -231,144 +231,144 @@ discard block |
||
| 231 | 231 | * |
| 232 | 232 | * @param WPInv_Subscription $subscription |
| 233 | 233 | */ |
| 234 | -function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
|
| 234 | +function getpaid_admin_subscription_metabox_display_customer($subscription) { |
|
| 235 | 235 | |
| 236 | - $username = __( '(Missing User)', 'invoicing' ); |
|
| 236 | + $username = __('(Missing User)', 'invoicing'); |
|
| 237 | 237 | |
| 238 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
| 239 | - if ( $user ) { |
|
| 238 | + $user = get_userdata($subscription->get_customer_id()); |
|
| 239 | + if ($user) { |
|
| 240 | 240 | |
| 241 | 241 | $username = sprintf( |
| 242 | 242 | '<a href="user-edit.php?user_id=%s">%s</a>', |
| 243 | - absint( $user->ID ), |
|
| 244 | - ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email ) |
|
| 243 | + absint($user->ID), |
|
| 244 | + !empty($user->display_name) ? esc_html($user->display_name) : sanitize_email($user->user_email) |
|
| 245 | 245 | ); |
| 246 | 246 | |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | - echo wp_kses_post( $username ); |
|
| 249 | + echo wp_kses_post($username); |
|
| 250 | 250 | } |
| 251 | -add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
|
| 251 | +add_action('getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer'); |
|
| 252 | 252 | |
| 253 | 253 | /** |
| 254 | 254 | * Displays the subscription amount. |
| 255 | 255 | * |
| 256 | 256 | * @param WPInv_Subscription $subscription |
| 257 | 257 | */ |
| 258 | -function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
|
| 259 | - $amount = getpaid_get_formatted_subscription_amount( $subscription ); |
|
| 260 | - echo wp_kses_post( "<span>$amount</span>" ); |
|
| 258 | +function getpaid_admin_subscription_metabox_display_amount($subscription) { |
|
| 259 | + $amount = getpaid_get_formatted_subscription_amount($subscription); |
|
| 260 | + echo wp_kses_post("<span>$amount</span>"); |
|
| 261 | 261 | } |
| 262 | -add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
|
| 262 | +add_action('getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount'); |
|
| 263 | 263 | |
| 264 | 264 | /** |
| 265 | 265 | * Displays the subscription id. |
| 266 | 266 | * |
| 267 | 267 | * @param WPInv_Subscription $subscription |
| 268 | 268 | */ |
| 269 | -function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
|
| 269 | +function getpaid_admin_subscription_metabox_display_id($subscription) { |
|
| 270 | 270 | |
| 271 | 271 | printf( |
| 272 | 272 | '<a href="%s">#%s</a>', |
| 273 | - esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ), |
|
| 274 | - absint( $subscription->get_id() ) |
|
| 273 | + esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($subscription->get_id()))), |
|
| 274 | + absint($subscription->get_id()) |
|
| 275 | 275 | ); |
| 276 | 276 | |
| 277 | 277 | } |
| 278 | -add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
|
| 278 | +add_action('getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id'); |
|
| 279 | 279 | |
| 280 | 280 | /** |
| 281 | 281 | * Displays the subscription renewal date. |
| 282 | 282 | * |
| 283 | 283 | * @param WPInv_Subscription $subscription |
| 284 | 284 | */ |
| 285 | -function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
|
| 285 | +function getpaid_admin_subscription_metabox_display_start_date($subscription) { |
|
| 286 | 286 | |
| 287 | - if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) { |
|
| 287 | + if ($subscription->has_status('active trialling') && getpaid_payment_gateway_supports($subscription->get_gateway(), 'subscription_date_change')) { |
|
| 288 | 288 | aui()->input( |
| 289 | 289 | array( |
| 290 | 290 | 'type' => 'text', |
| 291 | 291 | 'id' => 'wpinv_subscription_date_created', |
| 292 | 292 | 'name' => 'wpinv_subscription_date_created', |
| 293 | - 'label' => __( 'Start Date', 'invoicing' ), |
|
| 293 | + 'label' => __('Start Date', 'invoicing'), |
|
| 294 | 294 | 'label_type' => 'hidden', |
| 295 | 295 | 'placeholder' => 'YYYY-MM-DD', |
| 296 | - 'value' => esc_attr( $subscription->get_date_created( 'edit' ) ), |
|
| 296 | + 'value' => esc_attr($subscription->get_date_created('edit')), |
|
| 297 | 297 | 'no_wrap' => true, |
| 298 | 298 | 'size' => 'sm', |
| 299 | 299 | ), |
| 300 | 300 | true |
| 301 | 301 | ); |
| 302 | 302 | } else { |
| 303 | - echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) ); |
|
| 303 | + echo esc_html(getpaid_format_date_value($subscription->get_date_created())); |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | } |
| 307 | -add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
|
| 307 | +add_action('getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date'); |
|
| 308 | 308 | |
| 309 | 309 | /** |
| 310 | 310 | * Displays the subscription renewal date. |
| 311 | 311 | * |
| 312 | 312 | * @param WPInv_Subscription $subscription |
| 313 | 313 | */ |
| 314 | -function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
|
| 314 | +function getpaid_admin_subscription_metabox_display_renews_on($subscription) { |
|
| 315 | 315 | |
| 316 | - if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) { |
|
| 316 | + if ($subscription->has_status('active trialling') && getpaid_payment_gateway_supports($subscription->get_gateway(), 'subscription_date_change')) { |
|
| 317 | 317 | aui()->input( |
| 318 | 318 | array( |
| 319 | 319 | 'type' => 'text', |
| 320 | 320 | 'id' => 'wpinv_subscription_expiration', |
| 321 | 321 | 'name' => 'wpinv_subscription_expiration', |
| 322 | - 'label' => __( 'Renews On', 'invoicing' ), |
|
| 322 | + 'label' => __('Renews On', 'invoicing'), |
|
| 323 | 323 | 'label_type' => 'hidden', |
| 324 | 324 | 'placeholder' => 'YYYY-MM-DD', |
| 325 | - 'value' => esc_attr( $subscription->get_expiration( 'edit' ) ), |
|
| 325 | + 'value' => esc_attr($subscription->get_expiration('edit')), |
|
| 326 | 326 | 'no_wrap' => true, |
| 327 | 327 | 'size' => 'sm', |
| 328 | 328 | ), |
| 329 | 329 | true |
| 330 | 330 | ); |
| 331 | 331 | } else { |
| 332 | - echo esc_html( getpaid_format_date_value( $subscription->get_expiration() ) ); |
|
| 332 | + echo esc_html(getpaid_format_date_value($subscription->get_expiration())); |
|
| 333 | 333 | } |
| 334 | 334 | } |
| 335 | -add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
|
| 335 | +add_action('getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on'); |
|
| 336 | 336 | |
| 337 | 337 | /** |
| 338 | 338 | * Displays the subscription renewal count. |
| 339 | 339 | * |
| 340 | 340 | * @param WPInv_Subscription $subscription |
| 341 | 341 | */ |
| 342 | -function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
|
| 342 | +function getpaid_admin_subscription_metabox_display_renewals($subscription) { |
|
| 343 | 343 | |
| 344 | 344 | $max_bills = $subscription->get_bill_times(); |
| 345 | 345 | $times_billed = (int) $subscription->get_times_billed(); |
| 346 | 346 | |
| 347 | - if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_bill_times_change' ) ) { |
|
| 347 | + if ($subscription->has_status('active trialling') && getpaid_payment_gateway_supports($subscription->get_gateway(), 'subscription_bill_times_change')) { |
|
| 348 | 348 | aui()->input( |
| 349 | 349 | array( |
| 350 | 350 | 'type' => 'number', |
| 351 | 351 | 'id' => 'wpinv_subscription_max_bill_times', |
| 352 | 352 | 'name' => 'wpinv_subscription_max_bill_times', |
| 353 | - 'label' => __( 'Maximum bill times', 'invoicing' ), |
|
| 353 | + 'label' => __('Maximum bill times', 'invoicing'), |
|
| 354 | 354 | 'label_type' => 'hidden', |
| 355 | - 'placeholder' => __( 'Unlimited', 'invoicing' ), |
|
| 356 | - 'value' => empty( $max_bills ) ? '' : (int) $max_bills, |
|
| 355 | + 'placeholder' => __('Unlimited', 'invoicing'), |
|
| 356 | + 'value' => empty($max_bills) ? '' : (int) $max_bills, |
|
| 357 | 357 | 'no_wrap' => true, |
| 358 | 358 | 'size' => 'sm', |
| 359 | 359 | 'input_group_left' => sprintf( |
| 360 | 360 | // translators: %d: Number of times billed |
| 361 | - __( '%d of', 'invoicing' ), |
|
| 361 | + __('%d of', 'invoicing'), |
|
| 362 | 362 | $times_billed |
| 363 | 363 | ), |
| 364 | 364 | ), |
| 365 | 365 | true |
| 366 | 366 | ); |
| 367 | 367 | } else { |
| 368 | - echo esc_html( $times_billed ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
| 368 | + echo esc_html($times_billed) . ' / ' . (empty($max_bills) ? '∞' : (int) $max_bills); |
|
| 369 | 369 | } |
| 370 | 370 | } |
| 371 | -add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
|
| 371 | +add_action('getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals'); |
|
| 372 | 372 | |
| 373 | 373 | /** |
| 374 | 374 | * Displays the subscription item. |
@@ -376,53 +376,53 @@ discard block |
||
| 376 | 376 | * @param WPInv_Subscription $subscription |
| 377 | 377 | * @param false|array $subscription_group |
| 378 | 378 | */ |
| 379 | -function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) { |
|
| 379 | +function getpaid_admin_subscription_metabox_display_item($subscription, $subscription_group = false) { |
|
| 380 | 380 | |
| 381 | - if ( empty( $subscription_group ) ) { |
|
| 382 | - echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) ); |
|
| 381 | + if (empty($subscription_group)) { |
|
| 382 | + echo wp_kses_post(WPInv_Subscriptions_List_Table::generate_item_markup($subscription->get_product_id())); |
|
| 383 | 383 | return; |
| 384 | 384 | } |
| 385 | 385 | |
| 386 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
| 387 | - echo wp_kses_post( implode( ' | ', $markup ) ); |
|
| 386 | + $markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
| 387 | + echo wp_kses_post(implode(' | ', $markup)); |
|
| 388 | 388 | |
| 389 | 389 | } |
| 390 | -add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 ); |
|
| 390 | +add_action('getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2); |
|
| 391 | 391 | |
| 392 | 392 | /** |
| 393 | 393 | * Displays the subscription gateway. |
| 394 | 394 | * |
| 395 | 395 | * @param WPInv_Subscription $subscription |
| 396 | 396 | */ |
| 397 | -function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
|
| 397 | +function getpaid_admin_subscription_metabox_display_gateway($subscription) { |
|
| 398 | 398 | |
| 399 | 399 | $gateway = $subscription->get_gateway(); |
| 400 | 400 | |
| 401 | - if ( ! empty( $gateway ) ) { |
|
| 402 | - echo esc_html( wpinv_get_gateway_admin_label( $gateway ) ); |
|
| 401 | + if (!empty($gateway)) { |
|
| 402 | + echo esc_html(wpinv_get_gateway_admin_label($gateway)); |
|
| 403 | 403 | } else { |
| 404 | 404 | echo '—'; |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | } |
| 408 | -add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
|
| 408 | +add_action('getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway'); |
|
| 409 | 409 | |
| 410 | 410 | /** |
| 411 | 411 | * Displays the subscription status. |
| 412 | 412 | * |
| 413 | 413 | * @param WPInv_Subscription $subscription |
| 414 | 414 | */ |
| 415 | -function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
|
| 416 | - echo wp_kses_post( $subscription->get_status_label_html() ); |
|
| 415 | +function getpaid_admin_subscription_metabox_display_status($subscription) { |
|
| 416 | + echo wp_kses_post($subscription->get_status_label_html()); |
|
| 417 | 417 | } |
| 418 | -add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
|
| 418 | +add_action('getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status'); |
|
| 419 | 419 | |
| 420 | 420 | /** |
| 421 | 421 | * Displays the subscription profile id. |
| 422 | 422 | * |
| 423 | 423 | * @param WPInv_Subscription $subscription |
| 424 | 424 | */ |
| 425 | -function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
|
| 425 | +function getpaid_admin_subscription_metabox_display_profile_id($subscription) { |
|
| 426 | 426 | |
| 427 | 427 | $profile_id = $subscription->get_profile_id(); |
| 428 | 428 | |
@@ -431,10 +431,10 @@ discard block |
||
| 431 | 431 | 'type' => 'text', |
| 432 | 432 | 'id' => 'wpinv_subscription_profile_id', |
| 433 | 433 | 'name' => 'wpinv_subscription_profile_id', |
| 434 | - 'label' => __( 'Profile Id', 'invoicing' ), |
|
| 434 | + 'label' => __('Profile Id', 'invoicing'), |
|
| 435 | 435 | 'label_type' => 'hidden', |
| 436 | - 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
| 437 | - 'value' => esc_attr( $profile_id ), |
|
| 436 | + 'placeholder' => __('Profile Id', 'invoicing'), |
|
| 437 | + 'value' => esc_attr($profile_id), |
|
| 438 | 438 | 'input_group_right' => '', |
| 439 | 439 | 'no_wrap' => true, |
| 440 | 440 | 'size' => 'sm', |
@@ -442,20 +442,20 @@ discard block |
||
| 442 | 442 | true |
| 443 | 443 | ); |
| 444 | 444 | |
| 445 | - $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
| 446 | - if ( ! empty( $url ) ) { |
|
| 447 | - echo ' <a href="' . esc_url_raw( $url ) . '" title="' . esc_attr__( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
| 445 | + $url = apply_filters('getpaid_remote_subscription_profile_url', '', $subscription); |
|
| 446 | + if (!empty($url)) { |
|
| 447 | + echo ' <a href="' . esc_url_raw($url) . '" title="' . esc_attr__('View in Gateway', 'invoicing') . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | } |
| 451 | -add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
|
| 451 | +add_action('getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id'); |
|
| 452 | 452 | |
| 453 | 453 | /** |
| 454 | 454 | * Displays the subscriptions update metabox. |
| 455 | 455 | * |
| 456 | 456 | * @param WPInv_Subscription $subscription |
| 457 | 457 | */ |
| 458 | -function getpaid_admin_subscription_update_metabox( $subscription ) { |
|
| 458 | +function getpaid_admin_subscription_update_metabox($subscription) { |
|
| 459 | 459 | |
| 460 | 460 | ?> |
| 461 | 461 | <div class="mt-3"> |
@@ -468,10 +468,10 @@ discard block |
||
| 468 | 468 | 'id' => 'subscription_status_update_select', |
| 469 | 469 | 'required' => true, |
| 470 | 470 | 'no_wrap' => false, |
| 471 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
| 472 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
| 471 | + 'label' => __('Subscription Status', 'invoicing'), |
|
| 472 | + 'help_text' => __('Updating the status will trigger related actions and hooks', 'invoicing'), |
|
| 473 | 473 | 'select2' => true, |
| 474 | - 'value' => $subscription->get_status( 'edit' ), |
|
| 474 | + 'value' => $subscription->get_status('edit'), |
|
| 475 | 475 | ), |
| 476 | 476 | true |
| 477 | 477 | ); |
@@ -480,14 +480,14 @@ discard block |
||
| 480 | 480 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;"> |
| 481 | 481 | |
| 482 | 482 | <?php |
| 483 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
| 483 | + submit_button(__('Update', 'invoicing'), 'primary', 'submit', false); |
|
| 484 | 484 | |
| 485 | - $url = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
| 486 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
| 487 | - $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' ); |
|
| 485 | + $url = wp_nonce_url(add_query_arg('getpaid-admin-action', 'subscription_manual_renew'), 'getpaid-nonce', 'getpaid-nonce'); |
|
| 486 | + $anchor = __('Renew Subscription', 'invoicing'); |
|
| 487 | + $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'); |
|
| 488 | 488 | |
| 489 | - if ( $subscription->is_active() ) { |
|
| 490 | - echo "<a href='" . esc_url( $url ) . "' class='float-right text-muted' onclick='return confirm(\"" . esc_attr( $title ) . "\")'>" . esc_html( $anchor ) . "</a>"; |
|
| 489 | + if ($subscription->is_active()) { |
|
| 490 | + echo "<a href='" . esc_url($url) . "' class='float-right text-muted' onclick='return confirm(\"" . esc_attr($title) . "\")'>" . esc_html($anchor) . "</a>"; |
|
| 491 | 491 | } |
| 492 | 492 | |
| 493 | 493 | echo '</div></div>'; |
@@ -499,44 +499,44 @@ discard block |
||
| 499 | 499 | * @param WPInv_Subscription $subscription |
| 500 | 500 | * @param bool $strict Whether or not to skip invoices of sibling subscriptions |
| 501 | 501 | */ |
| 502 | -function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) { |
|
| 502 | +function getpaid_admin_subscription_invoice_details_metabox($subscription, $strict = true) { |
|
| 503 | 503 | |
| 504 | 504 | $columns = apply_filters( |
| 505 | 505 | 'getpaid_subscription_related_invoices_columns', |
| 506 | 506 | array( |
| 507 | - 'invoice' => __( 'Invoice', 'invoicing' ), |
|
| 508 | - 'relationship' => __( 'Relationship', 'invoicing' ), |
|
| 509 | - 'date' => __( 'Date', 'invoicing' ), |
|
| 510 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 511 | - 'total' => __( 'Total', 'invoicing' ), |
|
| 507 | + 'invoice' => __('Invoice', 'invoicing'), |
|
| 508 | + 'relationship' => __('Relationship', 'invoicing'), |
|
| 509 | + 'date' => __('Date', 'invoicing'), |
|
| 510 | + 'status' => __('Status', 'invoicing'), |
|
| 511 | + 'total' => __('Total', 'invoicing'), |
|
| 512 | 512 | ), |
| 513 | 513 | $subscription |
| 514 | 514 | ); |
| 515 | 515 | |
| 516 | 516 | // Prepare the invoices. |
| 517 | - $payments = $subscription->get_child_payments( ! is_admin() ); |
|
| 517 | + $payments = $subscription->get_child_payments(!is_admin()); |
|
| 518 | 518 | $parent = $subscription->get_parent_invoice(); |
| 519 | 519 | |
| 520 | - if ( $parent->exists() ) { |
|
| 521 | - $payments = array_merge( array( $parent ), $payments ); |
|
| 520 | + if ($parent->exists()) { |
|
| 521 | + $payments = array_merge(array($parent), $payments); |
|
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | $table_class = 'w-100 bg-white'; |
| 525 | 525 | |
| 526 | - if ( ! is_admin() ) { |
|
| 526 | + if (!is_admin()) { |
|
| 527 | 527 | $table_class = 'table table-bordered'; |
| 528 | 528 | } |
| 529 | 529 | |
| 530 | 530 | ?> |
| 531 | 531 | <div class="m-0" style="overflow: auto;"> |
| 532 | 532 | |
| 533 | - <table class="<?php echo esc_attr( $table_class ); ?>"> |
|
| 533 | + <table class="<?php echo esc_attr($table_class); ?>"> |
|
| 534 | 534 | |
| 535 | 535 | <thead> |
| 536 | 536 | <tr> |
| 537 | 537 | <?php |
| 538 | - foreach ( $columns as $key => $label ) { |
|
| 539 | - echo "<th class='subscription-invoice-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
| 538 | + foreach ($columns as $key => $label) { |
|
| 539 | + echo "<th class='subscription-invoice-field-" . esc_attr($key) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html($label) . "</th>"; |
|
| 540 | 540 | } |
| 541 | 541 | ?> |
| 542 | 542 | </tr> |
@@ -544,71 +544,71 @@ discard block |
||
| 544 | 544 | |
| 545 | 545 | <tbody> |
| 546 | 546 | |
| 547 | - <?php if ( empty( $payments ) ) : ?> |
|
| 547 | + <?php if (empty($payments)) : ?> |
|
| 548 | 548 | <tr> |
| 549 | - <td colspan="<?php echo count( $columns ); ?>" class="p-2 text-left text-muted"> |
|
| 550 | - <?php esc_html_e( 'This subscription has no invoices.', 'invoicing' ); ?> |
|
| 549 | + <td colspan="<?php echo count($columns); ?>" class="p-2 text-left text-muted"> |
|
| 550 | + <?php esc_html_e('This subscription has no invoices.', 'invoicing'); ?> |
|
| 551 | 551 | </td> |
| 552 | 552 | </tr> |
| 553 | 553 | <?php endif; ?> |
| 554 | 554 | |
| 555 | 555 | <?php |
| 556 | 556 | |
| 557 | - foreach ( $payments as $payment ) : |
|
| 557 | + foreach ($payments as $payment) : |
|
| 558 | 558 | |
| 559 | 559 | // Ensure that we have an invoice. |
| 560 | - $payment = new WPInv_Invoice( $payment ); |
|
| 560 | + $payment = new WPInv_Invoice($payment); |
|
| 561 | 561 | |
| 562 | 562 | // Abort if the invoice is invalid... |
| 563 | - if ( ! $payment->exists() ) { |
|
| 563 | + if (!$payment->exists()) { |
|
| 564 | 564 | continue; |
| 565 | 565 | } |
| 566 | 566 | |
| 567 | 567 | // ... or belongs to a different subscription. |
| 568 | - if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
| 568 | + if ($strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id()) { |
|
| 569 | 569 | continue; |
| 570 | 570 | } |
| 571 | 571 | |
| 572 | 572 | echo '<tr>'; |
| 573 | 573 | |
| 574 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 574 | + foreach (array_keys($columns) as $key) { |
|
| 575 | 575 | |
| 576 | 576 | echo "<td class='p-2 text-left'>"; |
| 577 | 577 | |
| 578 | - switch ( $key ) { |
|
| 578 | + switch ($key) { |
|
| 579 | 579 | |
| 580 | 580 | case 'total': |
| 581 | 581 | echo '<strong>'; |
| 582 | - wpinv_the_price( $payment->get_total(), $payment->get_currency() ); |
|
| 582 | + wpinv_the_price($payment->get_total(), $payment->get_currency()); |
|
| 583 | 583 | echo '</strong>'; |
| 584 | 584 | break; |
| 585 | 585 | |
| 586 | 586 | case 'relationship': |
| 587 | - echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' ); |
|
| 587 | + echo $payment->is_renewal() ? esc_html__('Renewal Invoice', 'invoicing') : esc_html__('Initial Invoice', 'invoicing'); |
|
| 588 | 588 | break; |
| 589 | 589 | |
| 590 | 590 | case 'date': |
| 591 | - echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) ); |
|
| 591 | + echo esc_html(getpaid_format_date_value($payment->get_date_created())); |
|
| 592 | 592 | break; |
| 593 | 593 | |
| 594 | 594 | case 'status': |
| 595 | 595 | $status = $payment->get_status_nicename(); |
| 596 | - if ( is_admin() ) { |
|
| 596 | + if (is_admin()) { |
|
| 597 | 597 | $status = $payment->get_status_label_html(); |
| 598 | 598 | } |
| 599 | 599 | |
| 600 | - echo wp_kses_post( $status ); |
|
| 600 | + echo wp_kses_post($status); |
|
| 601 | 601 | break; |
| 602 | 602 | |
| 603 | 603 | case 'invoice': |
| 604 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
| 604 | + $link = esc_url(get_edit_post_link($payment->get_id())); |
|
| 605 | 605 | |
| 606 | - if ( ! is_admin() ) { |
|
| 607 | - $link = esc_url( $payment->get_view_url() ); |
|
| 606 | + if (!is_admin()) { |
|
| 607 | + $link = esc_url($payment->get_view_url()); |
|
| 608 | 608 | } |
| 609 | 609 | |
| 610 | - $invoice = esc_html( $payment->get_number() ); |
|
| 611 | - echo wp_kses_post( "<a href='$link'>$invoice</a>" ); |
|
| 610 | + $invoice = esc_html($payment->get_number()); |
|
| 611 | + echo wp_kses_post("<a href='$link'>$invoice</a>"); |
|
| 612 | 612 | break; |
| 613 | 613 | } |
| 614 | 614 | |
@@ -635,12 +635,12 @@ discard block |
||
| 635 | 635 | * |
| 636 | 636 | * @param WPInv_Subscription $subscription |
| 637 | 637 | */ |
| 638 | -function getpaid_admin_subscription_item_details_metabox( $subscription ) { |
|
| 638 | +function getpaid_admin_subscription_item_details_metabox($subscription) { |
|
| 639 | 639 | |
| 640 | 640 | // Fetch the subscription group. |
| 641 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
| 641 | + $subscription_group = getpaid_get_invoice_subscription_group($subscription->get_parent_payment_id(), $subscription->get_id()); |
|
| 642 | 642 | |
| 643 | - if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
| 643 | + if (empty($subscription_group) || empty($subscription_group['items'])) { |
|
| 644 | 644 | return; |
| 645 | 645 | } |
| 646 | 646 | |
@@ -648,12 +648,12 @@ discard block |
||
| 648 | 648 | $columns = apply_filters( |
| 649 | 649 | 'getpaid_subscription_item_details_columns', |
| 650 | 650 | array( |
| 651 | - 'item_name' => __( 'Item', 'invoicing' ), |
|
| 652 | - 'price' => __( 'Price', 'invoicing' ), |
|
| 653 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
| 654 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
| 651 | + 'item_name' => __('Item', 'invoicing'), |
|
| 652 | + 'price' => __('Price', 'invoicing'), |
|
| 653 | + 'tax' => __('Tax', 'invoicing'), |
|
| 654 | + 'discount' => __('Discount', 'invoicing'), |
|
| 655 | 655 | //'initial' => __( 'Initial Amount', 'invoicing' ), |
| 656 | - 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
| 656 | + 'recurring' => __('Subtotal', 'invoicing'), |
|
| 657 | 657 | ), |
| 658 | 658 | $subscription |
| 659 | 659 | ); |
@@ -662,27 +662,27 @@ discard block |
||
| 662 | 662 | |
| 663 | 663 | $invoice = $subscription->get_parent_invoice(); |
| 664 | 664 | |
| 665 | - if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
| 666 | - unset( $columns['tax'] ); |
|
| 665 | + if ((!wpinv_use_taxes() || !$invoice->is_taxable()) && isset($columns['tax'])) { |
|
| 666 | + unset($columns['tax']); |
|
| 667 | 667 | } |
| 668 | 668 | |
| 669 | 669 | $table_class = 'w-100 bg-white'; |
| 670 | 670 | |
| 671 | - if ( ! is_admin() ) { |
|
| 671 | + if (!is_admin()) { |
|
| 672 | 672 | $table_class = 'table table-bordered'; |
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | ?> |
| 676 | 676 | <div class="m-0" style="overflow: auto;"> |
| 677 | 677 | |
| 678 | - <table class="<?php echo esc_attr( $table_class ); ?>"> |
|
| 678 | + <table class="<?php echo esc_attr($table_class); ?>"> |
|
| 679 | 679 | |
| 680 | 680 | <thead> |
| 681 | 681 | <tr> |
| 682 | 682 | <?php |
| 683 | 683 | |
| 684 | - foreach ( $columns as $key => $label ) { |
|
| 685 | - echo "<th class='subscription-item-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
| 684 | + foreach ($columns as $key => $label) { |
|
| 685 | + echo "<th class='subscription-item-field-" . esc_attr($key) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html($label) . "</th>"; |
|
| 686 | 686 | } |
| 687 | 687 | ?> |
| 688 | 688 | </tr> |
@@ -692,48 +692,48 @@ discard block |
||
| 692 | 692 | |
| 693 | 693 | <?php |
| 694 | 694 | |
| 695 | - foreach ( $subscription_group['items'] as $subscription_group_item ) : |
|
| 695 | + foreach ($subscription_group['items'] as $subscription_group_item) : |
|
| 696 | 696 | |
| 697 | 697 | echo '<tr>'; |
| 698 | 698 | |
| 699 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 699 | + foreach (array_keys($columns) as $key) { |
|
| 700 | 700 | |
| 701 | 701 | $class = 'text-left'; |
| 702 | 702 | |
| 703 | 703 | echo "<td class='p-2 text-left'>"; |
| 704 | 704 | |
| 705 | - switch ( $key ) { |
|
| 705 | + switch ($key) { |
|
| 706 | 706 | |
| 707 | 707 | case 'item_name': |
| 708 | - $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
| 709 | - $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
| 708 | + $item_name = get_the_title($subscription_group_item['item_id']); |
|
| 709 | + $item_name = empty($item_name) ? $subscription_group_item['item_name'] : $item_name; |
|
| 710 | 710 | |
| 711 | - if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
| 712 | - echo esc_html( $item_name ); |
|
| 711 | + if ($invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity']) { |
|
| 712 | + echo esc_html($item_name); |
|
| 713 | 713 | } else { |
| 714 | - printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
| 714 | + printf('%1$s x %2$d', esc_html($item_name), (float) $subscription_group_item['quantity']); |
|
| 715 | 715 | } |
| 716 | 716 | |
| 717 | 717 | break; |
| 718 | 718 | |
| 719 | 719 | case 'price': |
| 720 | - wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
| 720 | + wpinv_the_price($subscription_group_item['item_price'], $invoice->get_currency()); |
|
| 721 | 721 | break; |
| 722 | 722 | |
| 723 | 723 | case 'tax': |
| 724 | - wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
| 724 | + wpinv_the_price($subscription_group_item['tax'], $invoice->get_currency()); |
|
| 725 | 725 | break; |
| 726 | 726 | |
| 727 | 727 | case 'discount': |
| 728 | - wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
| 728 | + wpinv_the_price($subscription_group_item['discount'], $invoice->get_currency()); |
|
| 729 | 729 | break; |
| 730 | 730 | |
| 731 | 731 | case 'initial': |
| 732 | - wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
| 732 | + wpinv_the_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()); |
|
| 733 | 733 | break; |
| 734 | 734 | |
| 735 | 735 | case 'recurring': |
| 736 | - echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' ); |
|
| 736 | + echo wp_kses_post('<strong>' . wpinv_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()) . '</strong>'); |
|
| 737 | 737 | break; |
| 738 | 738 | |
| 739 | 739 | } |
@@ -746,24 +746,24 @@ discard block |
||
| 746 | 746 | |
| 747 | 747 | endforeach; |
| 748 | 748 | |
| 749 | - foreach ( $subscription_group['fees'] as $subscription_group_fee ) : |
|
| 749 | + foreach ($subscription_group['fees'] as $subscription_group_fee) : |
|
| 750 | 750 | |
| 751 | 751 | echo '<tr>'; |
| 752 | 752 | |
| 753 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 753 | + foreach (array_keys($columns) as $key) { |
|
| 754 | 754 | |
| 755 | 755 | $class = 'text-left'; |
| 756 | 756 | |
| 757 | 757 | echo "<td class='p-2 text-left'>"; |
| 758 | 758 | |
| 759 | - switch ( $key ) { |
|
| 759 | + switch ($key) { |
|
| 760 | 760 | |
| 761 | 761 | case 'item_name': |
| 762 | - echo esc_html( $subscription_group_fee['name'] ); |
|
| 762 | + echo esc_html($subscription_group_fee['name']); |
|
| 763 | 763 | break; |
| 764 | 764 | |
| 765 | 765 | case 'price': |
| 766 | - wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
| 766 | + wpinv_the_price($subscription_group_fee['initial_fee'], $invoice->get_currency()); |
|
| 767 | 767 | break; |
| 768 | 768 | |
| 769 | 769 | case 'tax': |
@@ -775,11 +775,11 @@ discard block |
||
| 775 | 775 | break; |
| 776 | 776 | |
| 777 | 777 | case 'initial': |
| 778 | - wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
| 778 | + wpinv_the_price($subscription_group_fee['initial_fee'], $invoice->get_currency()); |
|
| 779 | 779 | break; |
| 780 | 780 | |
| 781 | 781 | case 'recurring': |
| 782 | - echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' ); |
|
| 782 | + echo wp_kses_post('<strong>' . wpinv_price($subscription_group_fee['recurring_fee'], $invoice->get_currency()) . '</strong>'); |
|
| 783 | 783 | break; |
| 784 | 784 | |
| 785 | 785 | } |
@@ -808,12 +808,12 @@ discard block |
||
| 808 | 808 | * @param WPInv_Subscription $subscription |
| 809 | 809 | * @param bool $skip_current |
| 810 | 810 | */ |
| 811 | -function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) { |
|
| 811 | +function getpaid_admin_subscription_related_subscriptions_metabox($subscription, $skip_current = true) { |
|
| 812 | 812 | |
| 813 | 813 | // Fetch the subscription groups. |
| 814 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
| 814 | + $subscription_groups = getpaid_get_invoice_subscription_groups($subscription->get_parent_payment_id()); |
|
| 815 | 815 | |
| 816 | - if ( empty( $subscription_groups ) ) { |
|
| 816 | + if (empty($subscription_groups)) { |
|
| 817 | 817 | return; |
| 818 | 818 | } |
| 819 | 819 | |
@@ -821,37 +821,37 @@ discard block |
||
| 821 | 821 | $columns = apply_filters( |
| 822 | 822 | 'getpaid_subscription_related_subscriptions_columns', |
| 823 | 823 | array( |
| 824 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 825 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 826 | - 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
| 827 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
| 828 | - 'item' => __( 'Items', 'invoicing' ), |
|
| 829 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 824 | + 'subscription' => __('Subscription', 'invoicing'), |
|
| 825 | + 'start_date' => __('Start Date', 'invoicing'), |
|
| 826 | + 'renewal_date' => __('Next Payment', 'invoicing'), |
|
| 827 | + 'renewals' => __('Payments', 'invoicing'), |
|
| 828 | + 'item' => __('Items', 'invoicing'), |
|
| 829 | + 'status' => __('Status', 'invoicing'), |
|
| 830 | 830 | ), |
| 831 | 831 | $subscription |
| 832 | 832 | ); |
| 833 | 833 | |
| 834 | - if ( $subscription->get_status() == 'pending' ) { |
|
| 835 | - unset( $columns['start_date'], $columns['renewal_date'] ); |
|
| 834 | + if ($subscription->get_status() == 'pending') { |
|
| 835 | + unset($columns['start_date'], $columns['renewal_date']); |
|
| 836 | 836 | } |
| 837 | 837 | |
| 838 | 838 | $table_class = 'w-100 bg-white'; |
| 839 | 839 | |
| 840 | - if ( ! is_admin() ) { |
|
| 840 | + if (!is_admin()) { |
|
| 841 | 841 | $table_class = 'table table-bordered'; |
| 842 | 842 | } |
| 843 | 843 | |
| 844 | 844 | ?> |
| 845 | 845 | <div class="m-0" style="overflow: auto;"> |
| 846 | 846 | |
| 847 | - <table class="<?php echo esc_attr( $table_class ); ?>"> |
|
| 847 | + <table class="<?php echo esc_attr($table_class); ?>"> |
|
| 848 | 848 | |
| 849 | 849 | <thead> |
| 850 | 850 | <tr> |
| 851 | 851 | <?php |
| 852 | 852 | |
| 853 | - foreach ( $columns as $key => $label ) { |
|
| 854 | - echo "<th class='related-subscription-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
| 853 | + foreach ($columns as $key => $label) { |
|
| 854 | + echo "<th class='related-subscription-field-" . esc_attr($key) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html($label) . "</th>"; |
|
| 855 | 855 | } |
| 856 | 856 | ?> |
| 857 | 857 | </tr> |
@@ -861,62 +861,62 @@ discard block |
||
| 861 | 861 | |
| 862 | 862 | <?php |
| 863 | 863 | |
| 864 | - foreach ( $subscription_groups as $subscription_group ) : |
|
| 864 | + foreach ($subscription_groups as $subscription_group) : |
|
| 865 | 865 | |
| 866 | 866 | // Do not list current subscription. |
| 867 | - if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
| 867 | + if ($skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id()) { |
|
| 868 | 868 | continue; |
| 869 | 869 | } |
| 870 | 870 | |
| 871 | 871 | // Ensure the subscription exists. |
| 872 | - $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
| 872 | + $_suscription = new WPInv_Subscription($subscription_group['subscription_id']); |
|
| 873 | 873 | |
| 874 | - if ( ! $_suscription->exists() ) { |
|
| 874 | + if (!$_suscription->exists()) { |
|
| 875 | 875 | continue; |
| 876 | 876 | } |
| 877 | 877 | |
| 878 | 878 | echo '<tr>'; |
| 879 | 879 | |
| 880 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 880 | + foreach (array_keys($columns) as $key) { |
|
| 881 | 881 | |
| 882 | 882 | $class = 'text-left'; |
| 883 | 883 | |
| 884 | 884 | echo "<td class='p-2 text-left'>"; |
| 885 | 885 | |
| 886 | - switch ( $key ) { |
|
| 886 | + switch ($key) { |
|
| 887 | 887 | |
| 888 | 888 | case 'status': |
| 889 | - echo wp_kses_post( $_suscription->get_status_label_html() ); |
|
| 889 | + echo wp_kses_post($_suscription->get_status_label_html()); |
|
| 890 | 890 | break; |
| 891 | 891 | |
| 892 | 892 | case 'item': |
| 893 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
| 894 | - echo wp_kses_post( implode( ' | ', $markup ) ); |
|
| 893 | + $markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
| 894 | + echo wp_kses_post(implode(' | ', $markup)); |
|
| 895 | 895 | break; |
| 896 | 896 | |
| 897 | 897 | case 'renewals': |
| 898 | 898 | $max_bills = $_suscription->get_bill_times(); |
| 899 | - echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
| 899 | + echo ((int) $_suscription->get_times_billed()) . ' / ' . (empty($max_bills) ? '∞' : (int) $max_bills); |
|
| 900 | 900 | break; |
| 901 | 901 | |
| 902 | 902 | case 'renewal_date': |
| 903 | - echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '—'; |
|
| 903 | + echo $_suscription->is_active() ? esc_html(getpaid_format_date_value($_suscription->get_expiration())) : '—'; |
|
| 904 | 904 | break; |
| 905 | 905 | |
| 906 | 906 | case 'start_date': |
| 907 | - echo 'pending' == $_suscription->get_status() ? '—' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) ); |
|
| 907 | + echo 'pending' == $_suscription->get_status() ? '—' : esc_html(getpaid_format_date_value($_suscription->get_date_created())); |
|
| 908 | 908 | break; |
| 909 | 909 | |
| 910 | 910 | case 'subscription': |
| 911 | - $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
| 911 | + $url = is_admin() ? admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($_suscription->get_id())) : $_suscription->get_view_url(); |
|
| 912 | 912 | printf( |
| 913 | 913 | '%1$s#%2$s%3$s', |
| 914 | - '<a href="' . esc_url( $url ) . '">', |
|
| 915 | - '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
|
| 914 | + '<a href="' . esc_url($url) . '">', |
|
| 915 | + '<strong>' . intval($_suscription->get_id()) . '</strong>', |
|
| 916 | 916 | '</a>' |
| 917 | 917 | ); |
| 918 | 918 | |
| 919 | - echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) ); |
|
| 919 | + echo wp_kses_post(WPInv_Subscriptions_List_Table::column_amount($_suscription)); |
|
| 920 | 920 | break; |
| 921 | 921 | |
| 922 | 922 | } |
@@ -19,16 +19,16 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | // Define constants. |
| 21 | 21 | if ( ! defined( 'WPINV_PLUGIN_FILE' ) ) { |
| 22 | - define( 'WPINV_PLUGIN_FILE', __FILE__ ); |
|
| 22 | + define( 'WPINV_PLUGIN_FILE', __FILE__ ); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | if ( ! defined( 'WPINV_VERSION' ) ) { |
| 26 | - define( 'WPINV_VERSION', '2.8.8' ); |
|
| 26 | + define( 'WPINV_VERSION', '2.8.8' ); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | // Include the main Invoicing class. |
| 30 | 30 | if ( ! class_exists( 'WPInv_Plugin', false ) ) { |
| 31 | - require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php'; |
|
| 31 | + require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php'; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | $GLOBALS['invoicing'] = new WPInv_Plugin(); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - return $GLOBALS['invoicing']; |
|
| 46 | + return $GLOBALS['invoicing']; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -15,20 +15,20 @@ discard block |
||
| 15 | 15 | * @package GetPaid |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | -defined( 'ABSPATH' ) || exit; |
|
| 18 | +defined('ABSPATH') || exit; |
|
| 19 | 19 | |
| 20 | 20 | // Define constants. |
| 21 | -if ( ! defined( 'WPINV_PLUGIN_FILE' ) ) { |
|
| 22 | - define( 'WPINV_PLUGIN_FILE', __FILE__ ); |
|
| 21 | +if (!defined('WPINV_PLUGIN_FILE')) { |
|
| 22 | + define('WPINV_PLUGIN_FILE', __FILE__); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | -if ( ! defined( 'WPINV_VERSION' ) ) { |
|
| 26 | - define( 'WPINV_VERSION', '2.8.8' ); |
|
| 25 | +if (!defined('WPINV_VERSION')) { |
|
| 26 | + define('WPINV_VERSION', '2.8.8'); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | // Include the main Invoicing class. |
| 30 | -if ( ! class_exists( 'WPInv_Plugin', false ) ) { |
|
| 31 | - require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php'; |
|
| 30 | +if (!class_exists('WPInv_Plugin', false)) { |
|
| 31 | + require_once plugin_dir_path(WPINV_PLUGIN_FILE) . 'includes/class-wpinv.php'; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | function getpaid() { |
| 41 | 41 | |
| 42 | - if ( empty( $GLOBALS['invoicing'] ) ) { |
|
| 42 | + if (empty($GLOBALS['invoicing'])) { |
|
| 43 | 43 | $GLOBALS['invoicing'] = new WPInv_Plugin(); |
| 44 | 44 | } |
| 45 | 45 | |
@@ -52,9 +52,9 @@ discard block |
||
| 52 | 52 | * @since 2.0.8 |
| 53 | 53 | */ |
| 54 | 54 | function getpaid_deactivation_hook() { |
| 55 | - update_option( 'wpinv_flush_permalinks', 1 ); |
|
| 55 | + update_option('wpinv_flush_permalinks', 1); |
|
| 56 | 56 | } |
| 57 | -register_deactivation_hook( __FILE__, 'getpaid_deactivation_hook' ); |
|
| 57 | +register_deactivation_hook(__FILE__, 'getpaid_deactivation_hook'); |
|
| 58 | 58 | |
| 59 | 59 | /** |
| 60 | 60 | * @deprecated |
@@ -64,4 +64,4 @@ discard block |
||
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | // Kickstart the plugin. |
| 67 | -add_action( 'plugins_loaded', 'getpaid', -100 ); |
|
| 67 | +add_action('plugins_loaded', 'getpaid', -100); |
|