@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | function wpinv_subscriptions_page() { |
| 16 | 16 | |
| 17 | - ?> |
|
| 17 | + ?> |
|
| 18 | 18 | |
| 19 | 19 | <div class="wrap"> |
| 20 | 20 | <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> |
@@ -22,27 +22,27 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | <?php |
| 24 | 24 | |
| 25 | - // Verify user permissions. |
|
| 26 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 25 | + // Verify user permissions. |
|
| 26 | + if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 27 | 27 | |
| 28 | - echo aui()->alert( |
|
| 29 | - array( |
|
| 30 | - 'type' => 'danger', |
|
| 31 | - 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
| 32 | - ) |
|
| 33 | - ); |
|
| 28 | + echo aui()->alert( |
|
| 29 | + array( |
|
| 30 | + 'type' => 'danger', |
|
| 31 | + 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
| 32 | + ) |
|
| 33 | + ); |
|
| 34 | 34 | |
| 35 | - } else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
| 35 | + } else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
| 36 | 36 | |
| 37 | - // Display a single subscription. |
|
| 38 | - wpinv_recurring_subscription_details(); |
|
| 39 | - } else { |
|
| 37 | + // Display a single subscription. |
|
| 38 | + wpinv_recurring_subscription_details(); |
|
| 39 | + } else { |
|
| 40 | 40 | |
| 41 | - // Display a list of available subscriptions. |
|
| 42 | - getpaid_print_subscriptions_list(); |
|
| 43 | - } |
|
| 41 | + // Display a list of available subscriptions. |
|
| 42 | + getpaid_print_subscriptions_list(); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - ?> |
|
| 45 | + ?> |
|
| 46 | 46 | |
| 47 | 47 | </div> |
| 48 | 48 | </div> |
@@ -59,10 +59,10 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | function getpaid_print_subscriptions_list() { |
| 61 | 61 | |
| 62 | - $subscribers_table = new WPInv_Subscriptions_List_Table(); |
|
| 63 | - $subscribers_table->prepare_items(); |
|
| 62 | + $subscribers_table = new WPInv_Subscriptions_List_Table(); |
|
| 63 | + $subscribers_table->prepare_items(); |
|
| 64 | 64 | |
| 65 | - ?> |
|
| 65 | + ?> |
|
| 66 | 66 | <form id="subscribers-filter" class="bsui" method="get"> |
| 67 | 67 | <input type="hidden" name="page" value="wpinv-subscriptions" /> |
| 68 | 68 | <?php $subscribers_table->views(); ?> |
@@ -80,27 +80,27 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | function wpinv_recurring_subscription_details() { |
| 82 | 82 | |
| 83 | - // Fetch the subscription. |
|
| 84 | - $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
| 85 | - if ( ! $sub->get_id() ) { |
|
| 83 | + // Fetch the subscription. |
|
| 84 | + $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
| 85 | + if ( ! $sub->get_id() ) { |
|
| 86 | 86 | |
| 87 | - echo aui()->alert( |
|
| 88 | - array( |
|
| 89 | - 'type' => 'danger', |
|
| 90 | - 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
| 91 | - ) |
|
| 92 | - ); |
|
| 87 | + echo aui()->alert( |
|
| 88 | + array( |
|
| 89 | + 'type' => 'danger', |
|
| 90 | + 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
| 91 | + ) |
|
| 92 | + ); |
|
| 93 | 93 | |
| 94 | - return; |
|
| 95 | - } |
|
| 94 | + return; |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - // Use metaboxes to display the subscription details. |
|
| 98 | - add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal' ); |
|
| 99 | - add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
| 100 | - add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
| 101 | - do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
| 97 | + // Use metaboxes to display the subscription details. |
|
| 98 | + add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal' ); |
|
| 99 | + add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
| 100 | + add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
| 101 | + do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
| 102 | 102 | |
| 103 | - ?> |
|
| 103 | + ?> |
|
| 104 | 104 | |
| 105 | 105 | <form method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ); ?>"> |
| 106 | 106 | |
@@ -140,41 +140,41 @@ discard block |
||
| 140 | 140 | */ |
| 141 | 141 | function getpaid_admin_subscription_details_metabox( $sub ) { |
| 142 | 142 | |
| 143 | - // Prepare subscription detail columns. |
|
| 144 | - $fields = apply_filters( |
|
| 145 | - 'getpaid_subscription_admin_page_fields', |
|
| 146 | - array( |
|
| 147 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 148 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
| 149 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
| 150 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 151 | - 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
| 152 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
| 153 | - 'item' => __( 'Item', 'invoicing' ), |
|
| 154 | - 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
| 155 | - 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
| 156 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 157 | - ) |
|
| 158 | - ); |
|
| 159 | - |
|
| 160 | - if ( ! $sub->is_active() ) { |
|
| 161 | - |
|
| 162 | - if ( isset( $fields['renews_on'] ) ) { |
|
| 163 | - unset( $fields['renews_on'] ); |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - if ( isset( $fields['gateway'] ) ) { |
|
| 167 | - unset( $fields['gateway'] ); |
|
| 168 | - } |
|
| 143 | + // Prepare subscription detail columns. |
|
| 144 | + $fields = apply_filters( |
|
| 145 | + 'getpaid_subscription_admin_page_fields', |
|
| 146 | + array( |
|
| 147 | + 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 148 | + 'customer' => __( 'Customer', 'invoicing' ), |
|
| 149 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
| 150 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 151 | + 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
| 152 | + 'renewals' => __( 'Payments', 'invoicing' ), |
|
| 153 | + 'item' => __( 'Item', 'invoicing' ), |
|
| 154 | + 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
| 155 | + 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
| 156 | + 'status' => __( 'Status', 'invoicing' ), |
|
| 157 | + ) |
|
| 158 | + ); |
|
| 159 | + |
|
| 160 | + if ( ! $sub->is_active() ) { |
|
| 161 | + |
|
| 162 | + if ( isset( $fields['renews_on'] ) ) { |
|
| 163 | + unset( $fields['renews_on'] ); |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + if ( isset( $fields['gateway'] ) ) { |
|
| 167 | + unset( $fields['gateway'] ); |
|
| 168 | + } |
|
| 169 | 169 | |
| 170 | - } |
|
| 170 | + } |
|
| 171 | 171 | |
| 172 | - $profile_id = $sub->get_profile_id(); |
|
| 173 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
| 174 | - unset( $fields['profile_id'] ); |
|
| 175 | - } |
|
| 172 | + $profile_id = $sub->get_profile_id(); |
|
| 173 | + if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
| 174 | + unset( $fields['profile_id'] ); |
|
| 175 | + } |
|
| 176 | 176 | |
| 177 | - ?> |
|
| 177 | + ?> |
|
| 178 | 178 | |
| 179 | 179 | <table class="table table-borderless" style="font-size: 14px;"> |
| 180 | 180 | <tbody> |
@@ -208,20 +208,20 @@ discard block |
||
| 208 | 208 | */ |
| 209 | 209 | function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
| 210 | 210 | |
| 211 | - $username = __( '(Missing User)', 'invoicing' ); |
|
| 211 | + $username = __( '(Missing User)', 'invoicing' ); |
|
| 212 | 212 | |
| 213 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
| 214 | - if ( $user ) { |
|
| 213 | + $user = get_userdata( $subscription->get_customer_id() ); |
|
| 214 | + if ( $user ) { |
|
| 215 | 215 | |
| 216 | - $username = sprintf( |
|
| 217 | - '<a href="user-edit.php?user_id=%s">%s</a>', |
|
| 218 | - absint( $user->ID ), |
|
| 219 | - ! empty( $user->display_name ) ? sanitize_text_field( $user->display_name ) : sanitize_email( $user->user_email ) |
|
| 220 | - ); |
|
| 216 | + $username = sprintf( |
|
| 217 | + '<a href="user-edit.php?user_id=%s">%s</a>', |
|
| 218 | + absint( $user->ID ), |
|
| 219 | + ! empty( $user->display_name ) ? sanitize_text_field( $user->display_name ) : sanitize_email( $user->user_email ) |
|
| 220 | + ); |
|
| 221 | 221 | |
| 222 | - } |
|
| 222 | + } |
|
| 223 | 223 | |
| 224 | - echo $username; |
|
| 224 | + echo $username; |
|
| 225 | 225 | } |
| 226 | 226 | add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
| 227 | 227 | |
@@ -231,8 +231,8 @@ discard block |
||
| 231 | 231 | * @param WPInv_Subscription $subscription |
| 232 | 232 | */ |
| 233 | 233 | function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
| 234 | - $amount = sanitize_text_field( getpaid_get_formatted_subscription_amount( $subscription ) ); |
|
| 235 | - echo "<span>$amount</span>"; |
|
| 234 | + $amount = sanitize_text_field( getpaid_get_formatted_subscription_amount( $subscription ) ); |
|
| 235 | + echo "<span>$amount</span>"; |
|
| 236 | 236 | } |
| 237 | 237 | add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
| 238 | 238 | |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | * @param WPInv_Subscription $subscription |
| 243 | 243 | */ |
| 244 | 244 | function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
| 245 | - echo '#' . absint( $subscription->get_id() ); |
|
| 245 | + echo '#' . absint( $subscription->get_id() ); |
|
| 246 | 246 | } |
| 247 | 247 | add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
| 248 | 248 | |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | * @param WPInv_Subscription $subscription |
| 253 | 253 | */ |
| 254 | 254 | function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
| 255 | - echo getpaid_format_date_value( $subscription->get_date_created() ); |
|
| 255 | + echo getpaid_format_date_value( $subscription->get_date_created() ); |
|
| 256 | 256 | } |
| 257 | 257 | add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
| 258 | 258 | |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | * @param WPInv_Subscription $subscription |
| 263 | 263 | */ |
| 264 | 264 | function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
| 265 | - echo getpaid_format_date_value( $subscription->get_expiration() ); |
|
| 265 | + echo getpaid_format_date_value( $subscription->get_expiration() ); |
|
| 266 | 266 | } |
| 267 | 267 | add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
| 268 | 268 | |
@@ -272,8 +272,8 @@ discard block |
||
| 272 | 272 | * @param WPInv_Subscription $subscription |
| 273 | 273 | */ |
| 274 | 274 | function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
| 275 | - $max_bills = $subscription->get_bill_times(); |
|
| 276 | - echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
| 275 | + $max_bills = $subscription->get_bill_times(); |
|
| 276 | + echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
| 277 | 277 | } |
| 278 | 278 | add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
| 279 | 279 | /** |
@@ -283,16 +283,16 @@ discard block |
||
| 283 | 283 | */ |
| 284 | 284 | function getpaid_admin_subscription_metabox_display_item( $subscription ) { |
| 285 | 285 | |
| 286 | - $item = get_post( $subscription->get_product_id() ); |
|
| 286 | + $item = get_post( $subscription->get_product_id() ); |
|
| 287 | 287 | |
| 288 | - if ( ! empty( $item ) ) { |
|
| 289 | - $link = get_edit_post_link( $item ); |
|
| 290 | - $link = esc_url( $link ); |
|
| 291 | - $name = esc_html( get_the_title( $item ) ); |
|
| 292 | - echo "<a href='$link'>$name</a>"; |
|
| 293 | - } else { |
|
| 294 | - echo sprintf( __( 'Item #%s', 'invoicing' ), $subscription->get_product_id() ); |
|
| 295 | - } |
|
| 288 | + if ( ! empty( $item ) ) { |
|
| 289 | + $link = get_edit_post_link( $item ); |
|
| 290 | + $link = esc_url( $link ); |
|
| 291 | + $name = esc_html( get_the_title( $item ) ); |
|
| 292 | + echo "<a href='$link'>$name</a>"; |
|
| 293 | + } else { |
|
| 294 | + echo sprintf( __( 'Item #%s', 'invoicing' ), $subscription->get_product_id() ); |
|
| 295 | + } |
|
| 296 | 296 | |
| 297 | 297 | } |
| 298 | 298 | add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item' ); |
@@ -304,13 +304,13 @@ discard block |
||
| 304 | 304 | */ |
| 305 | 305 | function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
| 306 | 306 | |
| 307 | - $gateway = $subscription->get_gateway(); |
|
| 307 | + $gateway = $subscription->get_gateway(); |
|
| 308 | 308 | |
| 309 | - if ( ! empty( $gateway ) ) { |
|
| 310 | - echo sanitize_text_field( wpinv_get_gateway_admin_label( $gateway ) ); |
|
| 311 | - } else { |
|
| 312 | - echo "—"; |
|
| 313 | - } |
|
| 309 | + if ( ! empty( $gateway ) ) { |
|
| 310 | + echo sanitize_text_field( wpinv_get_gateway_admin_label( $gateway ) ); |
|
| 311 | + } else { |
|
| 312 | + echo "—"; |
|
| 313 | + } |
|
| 314 | 314 | |
| 315 | 315 | } |
| 316 | 316 | add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | * @param WPInv_Subscription $subscription |
| 322 | 322 | */ |
| 323 | 323 | function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
| 324 | - echo $subscription->get_status_label_html(); |
|
| 324 | + echo $subscription->get_status_label_html(); |
|
| 325 | 325 | } |
| 326 | 326 | add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
| 327 | 327 | |
@@ -332,14 +332,14 @@ discard block |
||
| 332 | 332 | */ |
| 333 | 333 | function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
| 334 | 334 | |
| 335 | - $profile_id = $subscription->get_profile_id(); |
|
| 335 | + $profile_id = $subscription->get_profile_id(); |
|
| 336 | 336 | |
| 337 | - if ( ! empty( $profile_id ) ) { |
|
| 338 | - $profile_id = sanitize_text_field( $profile_id ); |
|
| 339 | - echo apply_filters( 'getpaid_subscription_profile_id_display', $profile_id, $subscription ); |
|
| 340 | - } else { |
|
| 341 | - echo "—"; |
|
| 342 | - } |
|
| 337 | + if ( ! empty( $profile_id ) ) { |
|
| 338 | + $profile_id = sanitize_text_field( $profile_id ); |
|
| 339 | + echo apply_filters( 'getpaid_subscription_profile_id_display', $profile_id, $subscription ); |
|
| 340 | + } else { |
|
| 341 | + echo "—"; |
|
| 342 | + } |
|
| 343 | 343 | |
| 344 | 344 | } |
| 345 | 345 | add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
@@ -351,39 +351,39 @@ discard block |
||
| 351 | 351 | */ |
| 352 | 352 | function getpaid_admin_subscription_update_metabox( $subscription ) { |
| 353 | 353 | |
| 354 | - ?> |
|
| 354 | + ?> |
|
| 355 | 355 | <div class="mt-3"> |
| 356 | 356 | |
| 357 | 357 | <?php |
| 358 | - echo aui()->select( |
|
| 359 | - array( |
|
| 360 | - 'options' => getpaid_get_subscription_statuses(), |
|
| 361 | - 'name' => 'subscription_status', |
|
| 362 | - 'id' => 'subscription_status_update_select', |
|
| 363 | - 'required' => true, |
|
| 364 | - 'no_wrap' => false, |
|
| 365 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
| 366 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
| 367 | - 'select2' => true, |
|
| 368 | - 'value' => $subscription->get_status( 'edit' ), |
|
| 369 | - ) |
|
| 370 | - ); |
|
| 371 | - ?> |
|
| 358 | + echo aui()->select( |
|
| 359 | + array( |
|
| 360 | + 'options' => getpaid_get_subscription_statuses(), |
|
| 361 | + 'name' => 'subscription_status', |
|
| 362 | + 'id' => 'subscription_status_update_select', |
|
| 363 | + 'required' => true, |
|
| 364 | + 'no_wrap' => false, |
|
| 365 | + 'label' => __( 'Subscription Status', 'invoicing' ), |
|
| 366 | + 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
| 367 | + 'select2' => true, |
|
| 368 | + 'value' => $subscription->get_status( 'edit' ), |
|
| 369 | + ) |
|
| 370 | + ); |
|
| 371 | + ?> |
|
| 372 | 372 | |
| 373 | 373 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;"> |
| 374 | 374 | |
| 375 | 375 | <?php |
| 376 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
| 376 | + submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
| 377 | 377 | |
| 378 | - $url = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) ); |
|
| 379 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
| 380 | - $title = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' ); |
|
| 378 | + $url = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) ); |
|
| 379 | + $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
| 380 | + $title = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' ); |
|
| 381 | 381 | |
| 382 | - if ( $subscription->is_active() ) { |
|
| 383 | - echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>"; |
|
| 384 | - } |
|
| 382 | + if ( $subscription->is_active() ) { |
|
| 383 | + echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>"; |
|
| 384 | + } |
|
| 385 | 385 | |
| 386 | - echo '</div></div>'; |
|
| 386 | + echo '</div></div>'; |
|
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | /** |
@@ -393,33 +393,33 @@ discard block |
||
| 393 | 393 | */ |
| 394 | 394 | function getpaid_admin_subscription_invoice_details_metabox( $subscription ) { |
| 395 | 395 | |
| 396 | - $columns = apply_filters( |
|
| 397 | - 'getpaid_subscription_related_invoices_columns', |
|
| 398 | - array( |
|
| 399 | - 'invoice' => __( 'Invoice', 'invoicing' ), |
|
| 400 | - 'relationship' => __( 'Relationship', 'invoicing' ), |
|
| 401 | - 'date' => __( 'Date', 'invoicing' ), |
|
| 402 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 403 | - 'total' => __( 'Total', 'invoicing' ), |
|
| 404 | - ), |
|
| 405 | - $subscription |
|
| 406 | - ); |
|
| 407 | - |
|
| 408 | - // Prepare the invoices. |
|
| 409 | - $payments = $subscription->get_child_payments(); |
|
| 410 | - $parent = $subscription->get_parent_invoice(); |
|
| 411 | - |
|
| 412 | - if ( $parent->get_id() ) { |
|
| 413 | - $payments = array_merge( array( $parent ), $payments ); |
|
| 414 | - } |
|
| 396 | + $columns = apply_filters( |
|
| 397 | + 'getpaid_subscription_related_invoices_columns', |
|
| 398 | + array( |
|
| 399 | + 'invoice' => __( 'Invoice', 'invoicing' ), |
|
| 400 | + 'relationship' => __( 'Relationship', 'invoicing' ), |
|
| 401 | + 'date' => __( 'Date', 'invoicing' ), |
|
| 402 | + 'status' => __( 'Status', 'invoicing' ), |
|
| 403 | + 'total' => __( 'Total', 'invoicing' ), |
|
| 404 | + ), |
|
| 405 | + $subscription |
|
| 406 | + ); |
|
| 407 | + |
|
| 408 | + // Prepare the invoices. |
|
| 409 | + $payments = $subscription->get_child_payments(); |
|
| 410 | + $parent = $subscription->get_parent_invoice(); |
|
| 411 | + |
|
| 412 | + if ( $parent->get_id() ) { |
|
| 413 | + $payments = array_merge( array( $parent ), $payments ); |
|
| 414 | + } |
|
| 415 | 415 | |
| 416 | - $table_class = 'w-100 bg-white'; |
|
| 416 | + $table_class = 'w-100 bg-white'; |
|
| 417 | 417 | |
| 418 | - if ( ! is_admin() ) { |
|
| 419 | - $table_class = 'table table-bordered table-striped'; |
|
| 420 | - } |
|
| 418 | + if ( ! is_admin() ) { |
|
| 419 | + $table_class = 'table table-bordered table-striped'; |
|
| 420 | + } |
|
| 421 | 421 | |
| 422 | - ?> |
|
| 422 | + ?> |
|
| 423 | 423 | <div class="m-0" style="overflow: auto;"> |
| 424 | 424 | |
| 425 | 425 | <table class="<?php echo $table_class; ?>"> |
@@ -427,13 +427,13 @@ discard block |
||
| 427 | 427 | <thead> |
| 428 | 428 | <tr> |
| 429 | 429 | <?php |
| 430 | - foreach ( $columns as $key => $label ) { |
|
| 431 | - $key = esc_attr( $key ); |
|
| 432 | - $label = sanitize_text_field( $label ); |
|
| 430 | + foreach ( $columns as $key => $label ) { |
|
| 431 | + $key = esc_attr( $key ); |
|
| 432 | + $label = sanitize_text_field( $label ); |
|
| 433 | 433 | |
| 434 | - echo "<th class='subscription-invoice-field-$key bg-light p-2 text-left color-dark'>$label</th>"; |
|
| 435 | - } |
|
| 436 | - ?> |
|
| 434 | + echo "<th class='subscription-invoice-field-$key bg-light p-2 text-left color-dark'>$label</th>"; |
|
| 435 | + } |
|
| 436 | + ?> |
|
| 437 | 437 | </tr> |
| 438 | 438 | </thead> |
| 439 | 439 | |
@@ -449,66 +449,66 @@ discard block |
||
| 449 | 449 | |
| 450 | 450 | <?php |
| 451 | 451 | |
| 452 | - foreach( $payments as $payment ) : |
|
| 452 | + foreach( $payments as $payment ) : |
|
| 453 | 453 | |
| 454 | - // Ensure that we have an invoice. |
|
| 455 | - $payment = new WPInv_Invoice( $payment ); |
|
| 454 | + // Ensure that we have an invoice. |
|
| 455 | + $payment = new WPInv_Invoice( $payment ); |
|
| 456 | 456 | |
| 457 | - // Abort if the invoice is invalid. |
|
| 458 | - if ( ! $payment->get_id() ) { |
|
| 459 | - continue; |
|
| 460 | - } |
|
| 457 | + // Abort if the invoice is invalid. |
|
| 458 | + if ( ! $payment->get_id() ) { |
|
| 459 | + continue; |
|
| 460 | + } |
|
| 461 | 461 | |
| 462 | - echo '<tr>'; |
|
| 462 | + echo '<tr>'; |
|
| 463 | 463 | |
| 464 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 464 | + foreach ( array_keys( $columns ) as $key ) { |
|
| 465 | 465 | |
| 466 | - echo '<td class="p-2 text-left">'; |
|
| 466 | + echo '<td class="p-2 text-left">'; |
|
| 467 | 467 | |
| 468 | - switch( $key ) { |
|
| 468 | + switch( $key ) { |
|
| 469 | 469 | |
| 470 | - case 'total': |
|
| 471 | - echo '<strong>' . wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $payment->get_total() ) ), $payment->get_currency() ) . '</strong>'; |
|
| 472 | - break; |
|
| 470 | + case 'total': |
|
| 471 | + echo '<strong>' . wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $payment->get_total() ) ), $payment->get_currency() ) . '</strong>'; |
|
| 472 | + break; |
|
| 473 | 473 | |
| 474 | - case 'relationship': |
|
| 475 | - echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' ); |
|
| 476 | - break; |
|
| 474 | + case 'relationship': |
|
| 475 | + echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' ); |
|
| 476 | + break; |
|
| 477 | 477 | |
| 478 | - case 'date': |
|
| 479 | - echo getpaid_format_date_value( $payment->get_date_created() ); |
|
| 480 | - break; |
|
| 478 | + case 'date': |
|
| 479 | + echo getpaid_format_date_value( $payment->get_date_created() ); |
|
| 480 | + break; |
|
| 481 | 481 | |
| 482 | - case 'status': |
|
| 482 | + case 'status': |
|
| 483 | 483 | |
| 484 | - $status = $payment->get_status_nicename(); |
|
| 485 | - if ( is_admin() ) { |
|
| 486 | - $status = $payment->get_status_label_html(); |
|
| 487 | - } |
|
| 484 | + $status = $payment->get_status_nicename(); |
|
| 485 | + if ( is_admin() ) { |
|
| 486 | + $status = $payment->get_status_label_html(); |
|
| 487 | + } |
|
| 488 | 488 | |
| 489 | - echo $status; |
|
| 490 | - break; |
|
| 489 | + echo $status; |
|
| 490 | + break; |
|
| 491 | 491 | |
| 492 | - case 'invoice': |
|
| 493 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
| 492 | + case 'invoice': |
|
| 493 | + $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
| 494 | 494 | |
| 495 | - if ( ! is_admin() ) { |
|
| 496 | - $link = esc_url( $payment->get_view_url() ); |
|
| 497 | - } |
|
| 495 | + if ( ! is_admin() ) { |
|
| 496 | + $link = esc_url( $payment->get_view_url() ); |
|
| 497 | + } |
|
| 498 | 498 | |
| 499 | - $invoice = sanitize_text_field( $payment->get_number() ); |
|
| 500 | - echo "<a href='$link'>$invoice</a>"; |
|
| 501 | - break; |
|
| 502 | - } |
|
| 499 | + $invoice = sanitize_text_field( $payment->get_number() ); |
|
| 500 | + echo "<a href='$link'>$invoice</a>"; |
|
| 501 | + break; |
|
| 502 | + } |
|
| 503 | 503 | |
| 504 | - echo '</td>'; |
|
| 504 | + echo '</td>'; |
|
| 505 | 505 | |
| 506 | - } |
|
| 506 | + } |
|
| 507 | 507 | |
| 508 | - echo '</tr>'; |
|
| 508 | + echo '</tr>'; |
|
| 509 | 509 | |
| 510 | - endforeach; |
|
| 511 | - ?> |
|
| 510 | + endforeach; |
|
| 511 | + ?> |
|
| 512 | 512 | |
| 513 | 513 | </tbody> |
| 514 | 514 | |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | * Contains functions that display the subscriptions admin page. |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | -defined( 'ABSPATH' ) || exit; |
|
| 6 | +defined('ABSPATH') || exit; |
|
| 7 | 7 | |
| 8 | 8 | /** |
| 9 | 9 | * Render the Subscriptions page |
@@ -17,22 +17,22 @@ discard block |
||
| 17 | 17 | ?> |
| 18 | 18 | |
| 19 | 19 | <div class="wrap"> |
| 20 | - <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> |
|
| 20 | + <h1><?php echo esc_html(get_admin_page_title()); ?></h1> |
|
| 21 | 21 | <div class="bsui"> |
| 22 | 22 | |
| 23 | 23 | <?php |
| 24 | 24 | |
| 25 | 25 | // Verify user permissions. |
| 26 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 26 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 27 | 27 | |
| 28 | 28 | echo aui()->alert( |
| 29 | 29 | array( |
| 30 | 30 | 'type' => 'danger', |
| 31 | - 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
| 31 | + 'content' => __('You are not permitted to view this page.', 'invoicing'), |
|
| 32 | 32 | ) |
| 33 | 33 | ); |
| 34 | 34 | |
| 35 | - } else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
| 35 | + } else if (!empty($_GET['id']) && is_numeric($_GET['id'])) { |
|
| 36 | 36 | |
| 37 | 37 | // Display a single subscription. |
| 38 | 38 | wpinv_recurring_subscription_details(); |
@@ -81,13 +81,13 @@ discard block |
||
| 81 | 81 | function wpinv_recurring_subscription_details() { |
| 82 | 82 | |
| 83 | 83 | // Fetch the subscription. |
| 84 | - $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
| 85 | - if ( ! $sub->get_id() ) { |
|
| 84 | + $sub = new WPInv_Subscription((int) $_GET['id']); |
|
| 85 | + if (!$sub->get_id()) { |
|
| 86 | 86 | |
| 87 | 87 | echo aui()->alert( |
| 88 | 88 | array( |
| 89 | 89 | 'type' => 'danger', |
| 90 | - 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
| 90 | + 'content' => __('Subscription not found.', 'invoicing'), |
|
| 91 | 91 | ) |
| 92 | 92 | ); |
| 93 | 93 | |
@@ -95,31 +95,31 @@ discard block |
||
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | // Use metaboxes to display the subscription details. |
| 98 | - add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal' ); |
|
| 99 | - add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
| 100 | - add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
| 101 | - do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
| 98 | + add_meta_box('getpaid_admin_subscription_details_metabox', __('Subscription Details', 'invoicing'), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal'); |
|
| 99 | + add_meta_box('getpaid_admin_subscription_update_metabox', __('Change Status', 'invoicing'), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side'); |
|
| 100 | + add_meta_box('getpaid_admin_subscription_invoice_details_metabox', __('Invoices', 'invoicing'), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced'); |
|
| 101 | + do_action('getpaid_admin_single_subscription_register_metabox', $sub); |
|
| 102 | 102 | |
| 103 | 103 | ?> |
| 104 | 104 | |
| 105 | - <form method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ); ?>"> |
|
| 105 | + <form method="post" action="<?php echo admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($sub->get_id())); ?>"> |
|
| 106 | 106 | |
| 107 | - <?php wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); ?> |
|
| 108 | - <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> |
|
| 109 | - <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> |
|
| 107 | + <?php wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); ?> |
|
| 108 | + <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?> |
|
| 109 | + <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?> |
|
| 110 | 110 | <input type="hidden" name="getpaid-admin-action" value="update_single_subscription" /> |
| 111 | - <input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id() ;?>" /> |
|
| 111 | + <input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id(); ?>" /> |
|
| 112 | 112 | |
| 113 | 113 | <div id="poststuff"> |
| 114 | 114 | <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>"> |
| 115 | 115 | |
| 116 | 116 | <div id="postbox-container-1" class="postbox-container"> |
| 117 | - <?php do_meta_boxes( get_current_screen(), 'side', $sub ); ?> |
|
| 117 | + <?php do_meta_boxes(get_current_screen(), 'side', $sub); ?> |
|
| 118 | 118 | </div> |
| 119 | 119 | |
| 120 | 120 | <div id="postbox-container-2" class="postbox-container"> |
| 121 | - <?php do_meta_boxes( get_current_screen(), 'normal', $sub ); ?> |
|
| 122 | - <?php do_meta_boxes( get_current_screen(), 'advanced', $sub ); ?> |
|
| 121 | + <?php do_meta_boxes(get_current_screen(), 'normal', $sub); ?> |
|
| 122 | + <?php do_meta_boxes(get_current_screen(), 'advanced', $sub); ?> |
|
| 123 | 123 | </div> |
| 124 | 124 | |
| 125 | 125 | </div> |
@@ -138,40 +138,40 @@ discard block |
||
| 138 | 138 | * |
| 139 | 139 | * @param WPInv_Subscription $sub |
| 140 | 140 | */ |
| 141 | -function getpaid_admin_subscription_details_metabox( $sub ) { |
|
| 141 | +function getpaid_admin_subscription_details_metabox($sub) { |
|
| 142 | 142 | |
| 143 | 143 | // Prepare subscription detail columns. |
| 144 | 144 | $fields = apply_filters( |
| 145 | 145 | 'getpaid_subscription_admin_page_fields', |
| 146 | 146 | array( |
| 147 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 148 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
| 149 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
| 150 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 151 | - 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
| 152 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
| 153 | - 'item' => __( 'Item', 'invoicing' ), |
|
| 154 | - 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
| 155 | - 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
| 156 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 147 | + 'subscription' => __('Subscription', 'invoicing'), |
|
| 148 | + 'customer' => __('Customer', 'invoicing'), |
|
| 149 | + 'amount' => __('Amount', 'invoicing'), |
|
| 150 | + 'start_date' => __('Start Date', 'invoicing'), |
|
| 151 | + 'renews_on' => __('Next Payment', 'invoicing'), |
|
| 152 | + 'renewals' => __('Payments', 'invoicing'), |
|
| 153 | + 'item' => __('Item', 'invoicing'), |
|
| 154 | + 'gateway' => __('Payment Method', 'invoicing'), |
|
| 155 | + 'profile_id' => __('Profile ID', 'invoicing'), |
|
| 156 | + 'status' => __('Status', 'invoicing'), |
|
| 157 | 157 | ) |
| 158 | 158 | ); |
| 159 | 159 | |
| 160 | - if ( ! $sub->is_active() ) { |
|
| 160 | + if (!$sub->is_active()) { |
|
| 161 | 161 | |
| 162 | - if ( isset( $fields['renews_on'] ) ) { |
|
| 163 | - unset( $fields['renews_on'] ); |
|
| 162 | + if (isset($fields['renews_on'])) { |
|
| 163 | + unset($fields['renews_on']); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - if ( isset( $fields['gateway'] ) ) { |
|
| 167 | - unset( $fields['gateway'] ); |
|
| 166 | + if (isset($fields['gateway'])) { |
|
| 167 | + unset($fields['gateway']); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | $profile_id = $sub->get_profile_id(); |
| 173 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
| 174 | - unset( $fields['profile_id'] ); |
|
| 173 | + if (empty($profile_id) && isset($fields['profile_id'])) { |
|
| 174 | + unset($fields['profile_id']); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | ?> |
@@ -179,16 +179,16 @@ discard block |
||
| 179 | 179 | <table class="table table-borderless" style="font-size: 14px;"> |
| 180 | 180 | <tbody> |
| 181 | 181 | |
| 182 | - <?php foreach ( $fields as $key => $label ) : ?> |
|
| 182 | + <?php foreach ($fields as $key => $label) : ?> |
|
| 183 | 183 | |
| 184 | - <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class( $key ); ?>"> |
|
| 184 | + <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class($key); ?>"> |
|
| 185 | 185 | |
| 186 | 186 | <th class="w-25" style="font-weight: 500;"> |
| 187 | - <?php echo sanitize_text_field( $label ); ?> |
|
| 187 | + <?php echo sanitize_text_field($label); ?> |
|
| 188 | 188 | </th> |
| 189 | 189 | |
| 190 | 190 | <td class="w-75 text-muted"> |
| 191 | - <?php do_action( 'getpaid_subscription_admin_display_' . sanitize_text_field( $key ), $sub ); ?> |
|
| 191 | + <?php do_action('getpaid_subscription_admin_display_' . sanitize_text_field($key), $sub); ?> |
|
| 192 | 192 | </td> |
| 193 | 193 | |
| 194 | 194 | </tr> |
@@ -206,150 +206,150 @@ discard block |
||
| 206 | 206 | * |
| 207 | 207 | * @param WPInv_Subscription $subscription |
| 208 | 208 | */ |
| 209 | -function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
|
| 209 | +function getpaid_admin_subscription_metabox_display_customer($subscription) { |
|
| 210 | 210 | |
| 211 | - $username = __( '(Missing User)', 'invoicing' ); |
|
| 211 | + $username = __('(Missing User)', 'invoicing'); |
|
| 212 | 212 | |
| 213 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
| 214 | - if ( $user ) { |
|
| 213 | + $user = get_userdata($subscription->get_customer_id()); |
|
| 214 | + if ($user) { |
|
| 215 | 215 | |
| 216 | 216 | $username = sprintf( |
| 217 | 217 | '<a href="user-edit.php?user_id=%s">%s</a>', |
| 218 | - absint( $user->ID ), |
|
| 219 | - ! empty( $user->display_name ) ? sanitize_text_field( $user->display_name ) : sanitize_email( $user->user_email ) |
|
| 218 | + absint($user->ID), |
|
| 219 | + !empty($user->display_name) ? sanitize_text_field($user->display_name) : sanitize_email($user->user_email) |
|
| 220 | 220 | ); |
| 221 | 221 | |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | echo $username; |
| 225 | 225 | } |
| 226 | -add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
|
| 226 | +add_action('getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer'); |
|
| 227 | 227 | |
| 228 | 228 | /** |
| 229 | 229 | * Displays the subscription amount. |
| 230 | 230 | * |
| 231 | 231 | * @param WPInv_Subscription $subscription |
| 232 | 232 | */ |
| 233 | -function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
|
| 234 | - $amount = sanitize_text_field( getpaid_get_formatted_subscription_amount( $subscription ) ); |
|
| 233 | +function getpaid_admin_subscription_metabox_display_amount($subscription) { |
|
| 234 | + $amount = sanitize_text_field(getpaid_get_formatted_subscription_amount($subscription)); |
|
| 235 | 235 | echo "<span>$amount</span>"; |
| 236 | 236 | } |
| 237 | -add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
|
| 237 | +add_action('getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount'); |
|
| 238 | 238 | |
| 239 | 239 | /** |
| 240 | 240 | * Displays the subscription id. |
| 241 | 241 | * |
| 242 | 242 | * @param WPInv_Subscription $subscription |
| 243 | 243 | */ |
| 244 | -function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
|
| 245 | - echo '#' . absint( $subscription->get_id() ); |
|
| 244 | +function getpaid_admin_subscription_metabox_display_id($subscription) { |
|
| 245 | + echo '#' . absint($subscription->get_id()); |
|
| 246 | 246 | } |
| 247 | -add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
|
| 247 | +add_action('getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id'); |
|
| 248 | 248 | |
| 249 | 249 | /** |
| 250 | 250 | * Displays the subscription renewal date. |
| 251 | 251 | * |
| 252 | 252 | * @param WPInv_Subscription $subscription |
| 253 | 253 | */ |
| 254 | -function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
|
| 255 | - echo getpaid_format_date_value( $subscription->get_date_created() ); |
|
| 254 | +function getpaid_admin_subscription_metabox_display_start_date($subscription) { |
|
| 255 | + echo getpaid_format_date_value($subscription->get_date_created()); |
|
| 256 | 256 | } |
| 257 | -add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
|
| 257 | +add_action('getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date'); |
|
| 258 | 258 | |
| 259 | 259 | /** |
| 260 | 260 | * Displays the subscription renewal date. |
| 261 | 261 | * |
| 262 | 262 | * @param WPInv_Subscription $subscription |
| 263 | 263 | */ |
| 264 | -function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
|
| 265 | - echo getpaid_format_date_value( $subscription->get_expiration() ); |
|
| 264 | +function getpaid_admin_subscription_metabox_display_renews_on($subscription) { |
|
| 265 | + echo getpaid_format_date_value($subscription->get_expiration()); |
|
| 266 | 266 | } |
| 267 | -add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
|
| 267 | +add_action('getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on'); |
|
| 268 | 268 | |
| 269 | 269 | /** |
| 270 | 270 | * Displays the subscription renewal count. |
| 271 | 271 | * |
| 272 | 272 | * @param WPInv_Subscription $subscription |
| 273 | 273 | */ |
| 274 | -function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
|
| 274 | +function getpaid_admin_subscription_metabox_display_renewals($subscription) { |
|
| 275 | 275 | $max_bills = $subscription->get_bill_times(); |
| 276 | - echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
| 276 | + echo $subscription->get_times_billed() . ' / ' . (empty($max_bills) ? "∞" : $max_bills); |
|
| 277 | 277 | } |
| 278 | -add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
|
| 278 | +add_action('getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals'); |
|
| 279 | 279 | /** |
| 280 | 280 | * Displays the subscription item. |
| 281 | 281 | * |
| 282 | 282 | * @param WPInv_Subscription $subscription |
| 283 | 283 | */ |
| 284 | -function getpaid_admin_subscription_metabox_display_item( $subscription ) { |
|
| 284 | +function getpaid_admin_subscription_metabox_display_item($subscription) { |
|
| 285 | 285 | |
| 286 | - $item = get_post( $subscription->get_product_id() ); |
|
| 286 | + $item = get_post($subscription->get_product_id()); |
|
| 287 | 287 | |
| 288 | - if ( ! empty( $item ) ) { |
|
| 289 | - $link = get_edit_post_link( $item ); |
|
| 290 | - $link = esc_url( $link ); |
|
| 291 | - $name = esc_html( get_the_title( $item ) ); |
|
| 288 | + if (!empty($item)) { |
|
| 289 | + $link = get_edit_post_link($item); |
|
| 290 | + $link = esc_url($link); |
|
| 291 | + $name = esc_html(get_the_title($item)); |
|
| 292 | 292 | echo "<a href='$link'>$name</a>"; |
| 293 | 293 | } else { |
| 294 | - echo sprintf( __( 'Item #%s', 'invoicing' ), $subscription->get_product_id() ); |
|
| 294 | + echo sprintf(__('Item #%s', 'invoicing'), $subscription->get_product_id()); |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | } |
| 298 | -add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item' ); |
|
| 298 | +add_action('getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item'); |
|
| 299 | 299 | |
| 300 | 300 | /** |
| 301 | 301 | * Displays the subscription gateway. |
| 302 | 302 | * |
| 303 | 303 | * @param WPInv_Subscription $subscription |
| 304 | 304 | */ |
| 305 | -function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
|
| 305 | +function getpaid_admin_subscription_metabox_display_gateway($subscription) { |
|
| 306 | 306 | |
| 307 | 307 | $gateway = $subscription->get_gateway(); |
| 308 | 308 | |
| 309 | - if ( ! empty( $gateway ) ) { |
|
| 310 | - echo sanitize_text_field( wpinv_get_gateway_admin_label( $gateway ) ); |
|
| 309 | + if (!empty($gateway)) { |
|
| 310 | + echo sanitize_text_field(wpinv_get_gateway_admin_label($gateway)); |
|
| 311 | 311 | } else { |
| 312 | 312 | echo "—"; |
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | } |
| 316 | -add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
|
| 316 | +add_action('getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway'); |
|
| 317 | 317 | |
| 318 | 318 | /** |
| 319 | 319 | * Displays the subscription status. |
| 320 | 320 | * |
| 321 | 321 | * @param WPInv_Subscription $subscription |
| 322 | 322 | */ |
| 323 | -function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
|
| 323 | +function getpaid_admin_subscription_metabox_display_status($subscription) { |
|
| 324 | 324 | echo $subscription->get_status_label_html(); |
| 325 | 325 | } |
| 326 | -add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
|
| 326 | +add_action('getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status'); |
|
| 327 | 327 | |
| 328 | 328 | /** |
| 329 | 329 | * Displays the subscription profile id. |
| 330 | 330 | * |
| 331 | 331 | * @param WPInv_Subscription $subscription |
| 332 | 332 | */ |
| 333 | -function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
|
| 333 | +function getpaid_admin_subscription_metabox_display_profile_id($subscription) { |
|
| 334 | 334 | |
| 335 | 335 | $profile_id = $subscription->get_profile_id(); |
| 336 | 336 | |
| 337 | - if ( ! empty( $profile_id ) ) { |
|
| 338 | - $profile_id = sanitize_text_field( $profile_id ); |
|
| 339 | - echo apply_filters( 'getpaid_subscription_profile_id_display', $profile_id, $subscription ); |
|
| 337 | + if (!empty($profile_id)) { |
|
| 338 | + $profile_id = sanitize_text_field($profile_id); |
|
| 339 | + echo apply_filters('getpaid_subscription_profile_id_display', $profile_id, $subscription); |
|
| 340 | 340 | } else { |
| 341 | 341 | echo "—"; |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | } |
| 345 | -add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
|
| 345 | +add_action('getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id'); |
|
| 346 | 346 | |
| 347 | 347 | /** |
| 348 | 348 | * Displays the subscriptions update metabox. |
| 349 | 349 | * |
| 350 | 350 | * @param WPInv_Subscription $subscription |
| 351 | 351 | */ |
| 352 | -function getpaid_admin_subscription_update_metabox( $subscription ) { |
|
| 352 | +function getpaid_admin_subscription_update_metabox($subscription) { |
|
| 353 | 353 | |
| 354 | 354 | ?> |
| 355 | 355 | <div class="mt-3"> |
@@ -362,10 +362,10 @@ discard block |
||
| 362 | 362 | 'id' => 'subscription_status_update_select', |
| 363 | 363 | 'required' => true, |
| 364 | 364 | 'no_wrap' => false, |
| 365 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
| 366 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
| 365 | + 'label' => __('Subscription Status', 'invoicing'), |
|
| 366 | + 'help_text' => __('Updating the status will trigger related actions and hooks', 'invoicing'), |
|
| 367 | 367 | 'select2' => true, |
| 368 | - 'value' => $subscription->get_status( 'edit' ), |
|
| 368 | + 'value' => $subscription->get_status('edit'), |
|
| 369 | 369 | ) |
| 370 | 370 | ); |
| 371 | 371 | ?> |
@@ -373,13 +373,13 @@ discard block |
||
| 373 | 373 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;"> |
| 374 | 374 | |
| 375 | 375 | <?php |
| 376 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
| 376 | + submit_button(__('Update', 'invoicing'), 'primary', 'submit', false); |
|
| 377 | 377 | |
| 378 | - $url = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) ); |
|
| 379 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
| 380 | - $title = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' ); |
|
| 378 | + $url = esc_url(wp_nonce_url(add_query_arg('getpaid-admin-action', 'subscription_manual_renew'), 'getpaid-nonce', 'getpaid-nonce')); |
|
| 379 | + $anchor = __('Renew Subscription', 'invoicing'); |
|
| 380 | + $title = esc_attr__('Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing'); |
|
| 381 | 381 | |
| 382 | - if ( $subscription->is_active() ) { |
|
| 382 | + if ($subscription->is_active()) { |
|
| 383 | 383 | echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>"; |
| 384 | 384 | } |
| 385 | 385 | |
@@ -391,16 +391,16 @@ discard block |
||
| 391 | 391 | * |
| 392 | 392 | * @param WPInv_Subscription $subscription |
| 393 | 393 | */ |
| 394 | -function getpaid_admin_subscription_invoice_details_metabox( $subscription ) { |
|
| 394 | +function getpaid_admin_subscription_invoice_details_metabox($subscription) { |
|
| 395 | 395 | |
| 396 | 396 | $columns = apply_filters( |
| 397 | 397 | 'getpaid_subscription_related_invoices_columns', |
| 398 | 398 | array( |
| 399 | - 'invoice' => __( 'Invoice', 'invoicing' ), |
|
| 400 | - 'relationship' => __( 'Relationship', 'invoicing' ), |
|
| 401 | - 'date' => __( 'Date', 'invoicing' ), |
|
| 402 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 403 | - 'total' => __( 'Total', 'invoicing' ), |
|
| 399 | + 'invoice' => __('Invoice', 'invoicing'), |
|
| 400 | + 'relationship' => __('Relationship', 'invoicing'), |
|
| 401 | + 'date' => __('Date', 'invoicing'), |
|
| 402 | + 'status' => __('Status', 'invoicing'), |
|
| 403 | + 'total' => __('Total', 'invoicing'), |
|
| 404 | 404 | ), |
| 405 | 405 | $subscription |
| 406 | 406 | ); |
@@ -409,13 +409,13 @@ discard block |
||
| 409 | 409 | $payments = $subscription->get_child_payments(); |
| 410 | 410 | $parent = $subscription->get_parent_invoice(); |
| 411 | 411 | |
| 412 | - if ( $parent->get_id() ) { |
|
| 413 | - $payments = array_merge( array( $parent ), $payments ); |
|
| 412 | + if ($parent->get_id()) { |
|
| 413 | + $payments = array_merge(array($parent), $payments); |
|
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | $table_class = 'w-100 bg-white'; |
| 417 | 417 | |
| 418 | - if ( ! is_admin() ) { |
|
| 418 | + if (!is_admin()) { |
|
| 419 | 419 | $table_class = 'table table-bordered table-striped'; |
| 420 | 420 | } |
| 421 | 421 | |
@@ -427,9 +427,9 @@ discard block |
||
| 427 | 427 | <thead> |
| 428 | 428 | <tr> |
| 429 | 429 | <?php |
| 430 | - foreach ( $columns as $key => $label ) { |
|
| 431 | - $key = esc_attr( $key ); |
|
| 432 | - $label = sanitize_text_field( $label ); |
|
| 430 | + foreach ($columns as $key => $label) { |
|
| 431 | + $key = esc_attr($key); |
|
| 432 | + $label = sanitize_text_field($label); |
|
| 433 | 433 | |
| 434 | 434 | echo "<th class='subscription-invoice-field-$key bg-light p-2 text-left color-dark'>$label</th>"; |
| 435 | 435 | } |
@@ -439,50 +439,50 @@ discard block |
||
| 439 | 439 | |
| 440 | 440 | <tbody> |
| 441 | 441 | |
| 442 | - <?php if ( empty( $payments ) ) : ?> |
|
| 442 | + <?php if (empty($payments)) : ?> |
|
| 443 | 443 | <tr> |
| 444 | 444 | <td colspan="<?php echo count($columns); ?>" class="p-2 text-left text-muted"> |
| 445 | - <?php _e( 'This subscription has no invoices.', 'invoicing' ); ?> |
|
| 445 | + <?php _e('This subscription has no invoices.', 'invoicing'); ?> |
|
| 446 | 446 | </td> |
| 447 | 447 | </tr> |
| 448 | 448 | <?php endif; ?> |
| 449 | 449 | |
| 450 | 450 | <?php |
| 451 | 451 | |
| 452 | - foreach( $payments as $payment ) : |
|
| 452 | + foreach ($payments as $payment) : |
|
| 453 | 453 | |
| 454 | 454 | // Ensure that we have an invoice. |
| 455 | - $payment = new WPInv_Invoice( $payment ); |
|
| 455 | + $payment = new WPInv_Invoice($payment); |
|
| 456 | 456 | |
| 457 | 457 | // Abort if the invoice is invalid. |
| 458 | - if ( ! $payment->get_id() ) { |
|
| 458 | + if (!$payment->get_id()) { |
|
| 459 | 459 | continue; |
| 460 | 460 | } |
| 461 | 461 | |
| 462 | 462 | echo '<tr>'; |
| 463 | 463 | |
| 464 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 464 | + foreach (array_keys($columns) as $key) { |
|
| 465 | 465 | |
| 466 | 466 | echo '<td class="p-2 text-left">'; |
| 467 | 467 | |
| 468 | - switch( $key ) { |
|
| 468 | + switch ($key) { |
|
| 469 | 469 | |
| 470 | 470 | case 'total': |
| 471 | - echo '<strong>' . wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $payment->get_total() ) ), $payment->get_currency() ) . '</strong>'; |
|
| 471 | + echo '<strong>' . wpinv_price(wpinv_format_amount(wpinv_sanitize_amount($payment->get_total())), $payment->get_currency()) . '</strong>'; |
|
| 472 | 472 | break; |
| 473 | 473 | |
| 474 | 474 | case 'relationship': |
| 475 | - echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' ); |
|
| 475 | + echo $payment->is_renewal() ? __('Renewal Invoice', 'invoicing') : __('Initial Invoice', 'invoicing'); |
|
| 476 | 476 | break; |
| 477 | 477 | |
| 478 | 478 | case 'date': |
| 479 | - echo getpaid_format_date_value( $payment->get_date_created() ); |
|
| 479 | + echo getpaid_format_date_value($payment->get_date_created()); |
|
| 480 | 480 | break; |
| 481 | 481 | |
| 482 | 482 | case 'status': |
| 483 | 483 | |
| 484 | 484 | $status = $payment->get_status_nicename(); |
| 485 | - if ( is_admin() ) { |
|
| 485 | + if (is_admin()) { |
|
| 486 | 486 | $status = $payment->get_status_label_html(); |
| 487 | 487 | } |
| 488 | 488 | |
@@ -490,13 +490,13 @@ discard block |
||
| 490 | 490 | break; |
| 491 | 491 | |
| 492 | 492 | case 'invoice': |
| 493 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
| 493 | + $link = esc_url(get_edit_post_link($payment->get_id())); |
|
| 494 | 494 | |
| 495 | - if ( ! is_admin() ) { |
|
| 496 | - $link = esc_url( $payment->get_view_url() ); |
|
| 495 | + if (!is_admin()) { |
|
| 496 | + $link = esc_url($payment->get_view_url()); |
|
| 497 | 497 | } |
| 498 | 498 | |
| 499 | - $invoice = sanitize_text_field( $payment->get_number() ); |
|
| 499 | + $invoice = sanitize_text_field($payment->get_number()); |
|
| 500 | 500 | echo "<a href='$link'>$invoice</a>"; |
| 501 | 501 | break; |
| 502 | 502 | } |