Passed
Push — master ( ecf53c...107ebc )
by Brian
05:44
created
includes/admin/subscriptions.php 1 patch
Indentation   +418 added lines, -418 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,44 +157,44 @@  discard block
 block discarded – undo
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'     => __( 'Payments', 'invoicing' ),
174
-			'item'         => _n( 'Item', 'Items', $items_count, '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
-		}
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'     => __( 'Payments', 'invoicing' ),
174
+            'item'         => _n( 'Item', 'Items', $items_count, '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 190
 }
191 191
 
192
-	$profile_id = $sub->get_profile_id();
193
-	if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) {
194
-		unset( $fields['profile_id'] );
195
-	}
192
+    $profile_id = $sub->get_profile_id();
193
+    if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) {
194
+        unset( $fields['profile_id'] );
195
+    }
196 196
 
197
-	?>
197
+    ?>
198 198
 
199 199
 		<table class="table table-borderless" style="font-size: 14px;">
200 200
 			<tbody>
@@ -228,20 +228,20 @@  discard block
 block discarded – undo
228 228
  */
229 229
 function getpaid_admin_subscription_metabox_display_customer( $subscription ) {
230 230
 
231
-	$username = __( '(Missing User)', 'invoicing' );
231
+    $username = __( '(Missing User)', 'invoicing' );
232 232
 
233
-	$user = get_userdata( $subscription->get_customer_id() );
234
-	if ( $user ) {
233
+    $user = get_userdata( $subscription->get_customer_id() );
234
+    if ( $user ) {
235 235
 
236
-		$username = sprintf(
237
-			'<a href="user-edit.php?user_id=%s">%s</a>',
238
-			absint( $user->ID ),
239
-			! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email )
240
-		);
236
+        $username = sprintf(
237
+            '<a href="user-edit.php?user_id=%s">%s</a>',
238
+            absint( $user->ID ),
239
+            ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email )
240
+        );
241 241
 
242
-	}
242
+    }
243 243
 
244
-	echo wp_kses_post( $username );
244
+    echo wp_kses_post( $username );
245 245
 }
246 246
 add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' );
247 247
 
@@ -251,8 +251,8 @@  discard block
 block discarded – undo
251 251
  * @param WPInv_Subscription $subscription
252 252
  */
253 253
 function getpaid_admin_subscription_metabox_display_amount( $subscription ) {
254
-	$amount    = getpaid_get_formatted_subscription_amount( $subscription );
255
-	echo wp_kses_post( "<span>$amount</span>" );
254
+    $amount    = getpaid_get_formatted_subscription_amount( $subscription );
255
+    echo wp_kses_post( "<span>$amount</span>" );
256 256
 }
257 257
 add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' );
258 258
 
@@ -263,11 +263,11 @@  discard block
 block discarded – undo
263 263
  */
264 264
 function getpaid_admin_subscription_metabox_display_id( $subscription ) {
265 265
 
266
-	printf(
267
-		'<a href="%s">#%s</a>',
268
-		esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ),
269
-		absint( $subscription->get_id() )
270
-	);
266
+    printf(
267
+        '<a href="%s">#%s</a>',
268
+        esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ),
269
+        absint( $subscription->get_id() )
270
+    );
271 271
 
272 272
 }
273 273
 add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' );
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
  * @param WPInv_Subscription $subscription
279 279
  */
280 280
 function getpaid_admin_subscription_metabox_display_start_date( $subscription ) {
281
-	echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) );
281
+    echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) );
282 282
 }
283 283
 add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' );
284 284
 
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
  * @param WPInv_Subscription $subscription
289 289
  */
290 290
 function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) {
291
-	echo esc_html( getpaid_format_date_value( $subscription->get_expiration() ) );
291
+    echo esc_html( getpaid_format_date_value( $subscription->get_expiration() ) );
292 292
 }
293 293
 add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' );
294 294
 
@@ -298,8 +298,8 @@  discard block
 block discarded – undo
298 298
  * @param WPInv_Subscription $subscription
299 299
  */
300 300
 function getpaid_admin_subscription_metabox_display_renewals( $subscription ) {
301
-	$max_bills = $subscription->get_bill_times();
302
-	echo ( (int) $subscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '&infin;' : (int) $max_bills );
301
+    $max_bills = $subscription->get_bill_times();
302
+    echo ( (int) $subscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '&infin;' : (int) $max_bills );
303 303
 }
304 304
 add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' );
305 305
 /**
@@ -310,13 +310,13 @@  discard block
 block discarded – undo
310 310
  */
311 311
 function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) {
312 312
 
313
-	if ( empty( $subscription_group ) ) {
314
-		echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) );
315
-		return;
316
-	}
313
+    if ( empty( $subscription_group ) ) {
314
+        echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) );
315
+        return;
316
+    }
317 317
 
318
-	$markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
319
-	echo wp_kses_post( implode( ' | ', $markup ) );
318
+    $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
319
+    echo wp_kses_post( implode( ' | ', $markup ) );
320 320
 
321 321
 }
322 322
 add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 );
@@ -328,13 +328,13 @@  discard block
 block discarded – undo
328 328
  */
329 329
 function getpaid_admin_subscription_metabox_display_gateway( $subscription ) {
330 330
 
331
-	$gateway = $subscription->get_gateway();
331
+    $gateway = $subscription->get_gateway();
332 332
 
333
-	if ( ! empty( $gateway ) ) {
334
-		echo esc_html( wpinv_get_gateway_admin_label( $gateway ) );
335
-	} else {
336
-		echo '&mdash;';
337
-	}
333
+    if ( ! empty( $gateway ) ) {
334
+        echo esc_html( wpinv_get_gateway_admin_label( $gateway ) );
335
+    } else {
336
+        echo '&mdash;';
337
+    }
338 338
 
339 339
 }
340 340
 add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' );
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
  * @param WPInv_Subscription $subscription
346 346
  */
347 347
 function getpaid_admin_subscription_metabox_display_status( $subscription ) {
348
-	echo wp_kses_post( $subscription->get_status_label_html() );
348
+    echo wp_kses_post( $subscription->get_status_label_html() );
349 349
 }
350 350
 add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' );
351 351
 
@@ -356,27 +356,27 @@  discard block
 block discarded – undo
356 356
  */
357 357
 function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) {
358 358
 
359
-	$profile_id = $subscription->get_profile_id();
360
-
361
-	aui()->input(
362
-		array(
363
-			'type'              => 'text',
364
-			'id'                => 'wpinv_subscription_profile_id',
365
-			'name'              => 'wpinv_subscription_profile_id',
366
-			'label'             => __( 'Profile Id', 'invoicing' ),
367
-			'label_type'        => 'hidden',
368
-			'placeholder'       => __( 'Profile Id', 'invoicing' ),
369
-			'value'             => esc_attr( $profile_id ),
370
-			'input_group_right' => '',
371
-			'no_wrap'           => true,
372
-		),
373
-		true
374
-	);
375
-
376
-	$url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription );
377
-	if ( ! empty( $url ) ) {
378
-		echo '&nbsp;<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>';
379
-	}
359
+    $profile_id = $subscription->get_profile_id();
360
+
361
+    aui()->input(
362
+        array(
363
+            'type'              => 'text',
364
+            'id'                => 'wpinv_subscription_profile_id',
365
+            'name'              => 'wpinv_subscription_profile_id',
366
+            'label'             => __( 'Profile Id', 'invoicing' ),
367
+            'label_type'        => 'hidden',
368
+            'placeholder'       => __( 'Profile Id', 'invoicing' ),
369
+            'value'             => esc_attr( $profile_id ),
370
+            'input_group_right' => '',
371
+            'no_wrap'           => true,
372
+        ),
373
+        true
374
+    );
375
+
376
+    $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription );
377
+    if ( ! empty( $url ) ) {
378
+        echo '&nbsp;<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>';
379
+    }
380 380
 
381 381
 }
382 382
 add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' );
@@ -388,40 +388,40 @@  discard block
 block discarded – undo
388 388
  */
389 389
 function getpaid_admin_subscription_update_metabox( $subscription ) {
390 390
 
391
-	?>
391
+    ?>
392 392
 	<div class="mt-3">
393 393
 
394 394
 		<?php
395
-			aui()->select(
396
-				array(
397
-					'options'   => getpaid_get_subscription_statuses(),
398
-					'name'      => 'subscription_status',
399
-					'id'        => 'subscription_status_update_select',
400
-					'required'  => true,
401
-					'no_wrap'   => false,
402
-					'label'     => __( 'Subscription Status', 'invoicing' ),
403
-					'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ),
404
-					'select2'   => true,
405
-					'value'     => $subscription->get_status( 'edit' ),
406
-				),
407
-				true
408
-			);
409
-		?>
395
+            aui()->select(
396
+                array(
397
+                    'options'   => getpaid_get_subscription_statuses(),
398
+                    'name'      => 'subscription_status',
399
+                    'id'        => 'subscription_status_update_select',
400
+                    'required'  => true,
401
+                    'no_wrap'   => false,
402
+                    'label'     => __( 'Subscription Status', 'invoicing' ),
403
+                    'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ),
404
+                    'select2'   => true,
405
+                    'value'     => $subscription->get_status( 'edit' ),
406
+                ),
407
+                true
408
+            );
409
+        ?>
410 410
 
411 411
 		<div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;">
412 412
 
413 413
 		<?php
414
-			submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false );
414
+            submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false );
415 415
 
416
-			$url    = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' );
417
-			$anchor = __( 'Renew Subscription', 'invoicing' );
418
-			$title  = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' );
416
+            $url    = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' );
417
+            $anchor = __( 'Renew Subscription', 'invoicing' );
418
+            $title  = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' );
419 419
 
420
-			if ( $subscription->is_active() ) {
421
-			echo "<a href='" . esc_url( $url ) . "' class='float-right text-muted' onclick='return confirm(\"" . esc_attr( $title ) . "\")'>" . esc_html( $anchor ) . "</a>";
422
-			}
420
+            if ( $subscription->is_active() ) {
421
+            echo "<a href='" . esc_url( $url ) . "' class='float-right text-muted' onclick='return confirm(\"" . esc_attr( $title ) . "\")'>" . esc_html( $anchor ) . "</a>";
422
+            }
423 423
 
424
-	echo '</div></div>';
424
+    echo '</div></div>';
425 425
 }
426 426
 
427 427
 /**
@@ -432,33 +432,33 @@  discard block
 block discarded – undo
432 432
  */
433 433
 function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) {
434 434
 
435
-	$columns = apply_filters(
436
-		'getpaid_subscription_related_invoices_columns',
437
-		array(
438
-			'invoice'      => __( 'Invoice', 'invoicing' ),
439
-			'relationship' => __( 'Relationship', 'invoicing' ),
440
-			'date'         => __( 'Date', 'invoicing' ),
441
-			'status'       => __( 'Status', 'invoicing' ),
442
-			'total'        => __( 'Total', 'invoicing' ),
443
-		),
444
-		$subscription
445
-	);
446
-
447
-	// Prepare the invoices.
448
-	$payments = $subscription->get_child_payments( ! is_admin() );
449
-	$parent   = $subscription->get_parent_invoice();
450
-
451
-	if ( $parent->exists() ) {
452
-		$payments = array_merge( array( $parent ), $payments );
453
-	}
454
-
455
-	$table_class = 'w-100 bg-white';
456
-
457
-	if ( ! is_admin() ) {
458
-		$table_class = 'table table-bordered';
459
-	}
460
-
461
-	?>
435
+    $columns = apply_filters(
436
+        'getpaid_subscription_related_invoices_columns',
437
+        array(
438
+            'invoice'      => __( 'Invoice', 'invoicing' ),
439
+            'relationship' => __( 'Relationship', 'invoicing' ),
440
+            'date'         => __( 'Date', 'invoicing' ),
441
+            'status'       => __( 'Status', 'invoicing' ),
442
+            'total'        => __( 'Total', 'invoicing' ),
443
+        ),
444
+        $subscription
445
+    );
446
+
447
+    // Prepare the invoices.
448
+    $payments = $subscription->get_child_payments( ! is_admin() );
449
+    $parent   = $subscription->get_parent_invoice();
450
+
451
+    if ( $parent->exists() ) {
452
+        $payments = array_merge( array( $parent ), $payments );
453
+    }
454
+
455
+    $table_class = 'w-100 bg-white';
456
+
457
+    if ( ! is_admin() ) {
458
+        $table_class = 'table table-bordered';
459
+    }
460
+
461
+    ?>
462 462
 		<div class="m-0" style="overflow: auto;">
463 463
 
464 464
 			<table class="<?php echo esc_attr( $table_class ); ?>">
@@ -466,10 +466,10 @@  discard block
 block discarded – undo
466 466
 				<thead>
467 467
 					<tr>
468 468
 						<?php
469
-							foreach ( $columns as $key => $label ) {
470
-							echo "<th class='subscription-invoice-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
471
-							}
472
-						?>
469
+                            foreach ( $columns as $key => $label ) {
470
+                            echo "<th class='subscription-invoice-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
471
+                            }
472
+                        ?>
473 473
 					</tr>
474 474
 				</thead>
475 475
 
@@ -485,72 +485,72 @@  discard block
 block discarded – undo
485 485
 
486 486
 					<?php
487 487
 
488
-						foreach ( $payments as $payment ) :
488
+                        foreach ( $payments as $payment ) :
489 489
 
490
-						// Ensure that we have an invoice.
491
-						$payment = new WPInv_Invoice( $payment );
490
+                        // Ensure that we have an invoice.
491
+                        $payment = new WPInv_Invoice( $payment );
492 492
 
493
-						// Abort if the invoice is invalid...
494
-						if ( ! $payment->exists() ) {
495
-							continue;
496
-							}
493
+                        // Abort if the invoice is invalid...
494
+                        if ( ! $payment->exists() ) {
495
+                            continue;
496
+                            }
497 497
 
498
-						// ... or belongs to a different subscription.
499
-						if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) {
500
-							continue;
501
-							}
498
+                        // ... or belongs to a different subscription.
499
+                        if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) {
500
+                            continue;
501
+                            }
502 502
 
503
-						echo '<tr>';
503
+                        echo '<tr>';
504 504
 
505
-						foreach ( array_keys( $columns ) as $key ) {
505
+                        foreach ( array_keys( $columns ) as $key ) {
506 506
 
507
-							echo "<td class='p-2 text-left'>";
507
+                            echo "<td class='p-2 text-left'>";
508 508
 
509
-								switch ( $key ) {
509
+                                switch ( $key ) {
510 510
 
511
-								case 'total':
512
-										echo '<strong>';
513
-										wpinv_the_price( $payment->get_total(), $payment->get_currency() );
514
-										echo '</strong>';
515
-									break;
511
+                                case 'total':
512
+                                        echo '<strong>';
513
+                                        wpinv_the_price( $payment->get_total(), $payment->get_currency() );
514
+                                        echo '</strong>';
515
+                                    break;
516 516
 
517
-								case 'relationship':
518
-										echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' );
519
-									break;
517
+                                case 'relationship':
518
+                                        echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' );
519
+                                    break;
520 520
 
521
-								case 'date':
522
-									echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) );
523
-									break;
521
+                                case 'date':
522
+                                    echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) );
523
+                                    break;
524 524
 
525
-								case 'status':
526
-										$status = $payment->get_status_nicename();
527
-										if ( is_admin() ) {
528
-										$status = $payment->get_status_label_html();
529
-										}
525
+                                case 'status':
526
+                                        $status = $payment->get_status_nicename();
527
+                                        if ( is_admin() ) {
528
+                                        $status = $payment->get_status_label_html();
529
+                                        }
530 530
 
531
-										echo wp_kses_post( $status );
532
-									break;
531
+                                        echo wp_kses_post( $status );
532
+                                    break;
533 533
 
534
-								case 'invoice':
535
-										$link    = esc_url( get_edit_post_link( $payment->get_id() ) );
534
+                                case 'invoice':
535
+                                        $link    = esc_url( get_edit_post_link( $payment->get_id() ) );
536 536
 
537
-										if ( ! is_admin() ) {
538
-										$link = esc_url( $payment->get_view_url() );
539
-										}
537
+                                        if ( ! is_admin() ) {
538
+                                        $link = esc_url( $payment->get_view_url() );
539
+                                        }
540 540
 
541
-										$invoice = esc_html( $payment->get_number() );
542
-										echo wp_kses_post( "<a href='$link'>$invoice</a>" );
543
-									break;
544
-										}
541
+                                        $invoice = esc_html( $payment->get_number() );
542
+                                        echo wp_kses_post( "<a href='$link'>$invoice</a>" );
543
+                                    break;
544
+                                        }
545 545
 
546
-								echo '</td>';
546
+                                echo '</td>';
547 547
 
548
-							}
548
+                            }
549 549
 
550
-						echo '</tr>';
550
+                        echo '</tr>';
551 551
 
552
-						endforeach;
553
-					?>
552
+                        endforeach;
553
+                    ?>
554 554
 
555 555
 				</tbody>
556 556
 
@@ -568,42 +568,42 @@  discard block
 block discarded – undo
568 568
  */
569 569
 function getpaid_admin_subscription_item_details_metabox( $subscription ) {
570 570
 
571
-	// Fetch the subscription group.
572
-	$subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() );
571
+    // Fetch the subscription group.
572
+    $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() );
573 573
 
574
-	if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) {
575
-		return;
576
-	}
574
+    if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) {
575
+        return;
576
+    }
577 577
 
578
-	// Prepare table columns.
579
-	$columns = apply_filters(
580
-		'getpaid_subscription_item_details_columns',
581
-		array(
582
-			'item_name' => __( 'Item', 'invoicing' ),
583
-			'price'     => __( 'Price', 'invoicing' ),
584
-			'tax'       => __( 'Tax', 'invoicing' ),
585
-			'discount'  => __( 'Discount', 'invoicing' ),
586
-			//'initial'      => __( 'Initial Amount', 'invoicing' ),
587
-			'recurring' => __( 'Subtotal', 'invoicing' ),
588
-		),
589
-		$subscription
590
-	);
578
+    // Prepare table columns.
579
+    $columns = apply_filters(
580
+        'getpaid_subscription_item_details_columns',
581
+        array(
582
+            'item_name' => __( 'Item', 'invoicing' ),
583
+            'price'     => __( 'Price', 'invoicing' ),
584
+            'tax'       => __( 'Tax', 'invoicing' ),
585
+            'discount'  => __( 'Discount', 'invoicing' ),
586
+            //'initial'      => __( 'Initial Amount', 'invoicing' ),
587
+            'recurring' => __( 'Subtotal', 'invoicing' ),
588
+        ),
589
+        $subscription
590
+    );
591 591
 
592
-	// Prepare the invoices.
592
+    // Prepare the invoices.
593 593
 
594
-	$invoice = $subscription->get_parent_invoice();
594
+    $invoice = $subscription->get_parent_invoice();
595 595
 
596
-	if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) {
597
-		unset( $columns['tax'] );
598
-	}
596
+    if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) {
597
+        unset( $columns['tax'] );
598
+    }
599 599
 
600
-	$table_class = 'w-100 bg-white';
600
+    $table_class = 'w-100 bg-white';
601 601
 
602
-	if ( ! is_admin() ) {
603
-		$table_class = 'table table-bordered';
604
-	}
602
+    if ( ! is_admin() ) {
603
+        $table_class = 'table table-bordered';
604
+    }
605 605
 
606
-	?>
606
+    ?>
607 607
 		<div class="m-0" style="overflow: auto;">
608 608
 
609 609
 			<table class="<?php echo esc_attr( $table_class ); ?>">
@@ -612,10 +612,10 @@  discard block
 block discarded – undo
612 612
 					<tr>
613 613
 						<?php
614 614
 
615
-							foreach ( $columns as $key => $label ) {
616
-							echo "<th class='subscription-item-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
617
-							}
618
-						?>
615
+                            foreach ( $columns as $key => $label ) {
616
+                            echo "<th class='subscription-item-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
617
+                            }
618
+                        ?>
619 619
 					</tr>
620 620
 				</thead>
621 621
 
@@ -623,106 +623,106 @@  discard block
 block discarded – undo
623 623
 
624 624
 					<?php
625 625
 
626
-						foreach ( $subscription_group['items'] as $subscription_group_item ) :
626
+                        foreach ( $subscription_group['items'] as $subscription_group_item ) :
627 627
 
628
-						echo '<tr>';
628
+                        echo '<tr>';
629 629
 
630
-						foreach ( array_keys( $columns ) as $key ) {
630
+                        foreach ( array_keys( $columns ) as $key ) {
631 631
 
632
-							$class = 'text-left';
632
+                            $class = 'text-left';
633 633
 
634
-							echo "<td class='p-2 text-left'>";
634
+                            echo "<td class='p-2 text-left'>";
635 635
 
636
-								switch ( $key ) {
636
+                                switch ( $key ) {
637 637
 
638
-								case 'item_name':
639
-										$item_name = get_the_title( $subscription_group_item['item_id'] );
640
-										$item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name;
638
+                                case 'item_name':
639
+                                        $item_name = get_the_title( $subscription_group_item['item_id'] );
640
+                                        $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name;
641 641
 
642
-										if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) {
643
-										echo esc_html( $item_name );
644
-										} else {
645
-										printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] );
646
-											}
642
+                                        if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) {
643
+                                        echo esc_html( $item_name );
644
+                                        } else {
645
+                                        printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] );
646
+                                            }
647 647
 
648
-									break;
648
+                                    break;
649 649
 
650
-								case 'price':
651
-									wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() );
652
-									break;
650
+                                case 'price':
651
+                                    wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() );
652
+                                    break;
653 653
 
654
-								case 'tax':
655
-									wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() );
656
-									break;
654
+                                case 'tax':
655
+                                    wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() );
656
+                                    break;
657 657
 
658
-								case 'discount':
659
-									wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() );
660
-									break;
658
+                                case 'discount':
659
+                                    wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() );
660
+                                    break;
661 661
 
662
-								case 'initial':
663
-									wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() );
664
-									break;
662
+                                case 'initial':
663
+                                    wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() );
664
+                                    break;
665 665
 
666
-								case 'recurring':
667
-										echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' );
668
-									break;
666
+                                case 'recurring':
667
+                                        echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' );
668
+                                    break;
669 669
 
670
-										}
670
+                                        }
671 671
 
672
-								echo '</td>';
672
+                                echo '</td>';
673 673
 
674
-							}
674
+                            }
675 675
 
676
-						echo '</tr>';
676
+                        echo '</tr>';
677 677
 
678
-						endforeach;
678
+                        endforeach;
679 679
 
680
-						foreach ( $subscription_group['fees'] as $subscription_group_fee ) :
680
+                        foreach ( $subscription_group['fees'] as $subscription_group_fee ) :
681 681
 
682
-						echo '<tr>';
682
+                        echo '<tr>';
683 683
 
684
-						foreach ( array_keys( $columns ) as $key ) {
684
+                        foreach ( array_keys( $columns ) as $key ) {
685 685
 
686
-							$class = 'text-left';
686
+                            $class = 'text-left';
687 687
 
688
-							echo "<td class='p-2 text-left'>";
688
+                            echo "<td class='p-2 text-left'>";
689 689
 
690
-								switch ( $key ) {
690
+                                switch ( $key ) {
691 691
 
692
-								case 'item_name':
693
-										echo esc_html( $subscription_group_fee['name'] );
694
-									break;
692
+                                case 'item_name':
693
+                                        echo esc_html( $subscription_group_fee['name'] );
694
+                                    break;
695 695
 
696
-								case 'price':
697
-									wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
698
-									break;
696
+                                case 'price':
697
+                                    wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
698
+                                    break;
699 699
 
700
-								case 'tax':
701
-									echo '&mdash;';
702
-									break;
700
+                                case 'tax':
701
+                                    echo '&mdash;';
702
+                                    break;
703 703
 
704
-								case 'discount':
705
-										echo '&mdash;';
706
-									break;
704
+                                case 'discount':
705
+                                        echo '&mdash;';
706
+                                    break;
707 707
 
708
-								case 'initial':
709
-									wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
710
-									break;
708
+                                case 'initial':
709
+                                    wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
710
+                                    break;
711 711
 
712
-								case 'recurring':
713
-										echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' );
714
-									break;
712
+                                case 'recurring':
713
+                                        echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' );
714
+                                    break;
715 715
 
716
-										}
716
+                                        }
717 717
 
718
-								echo '</td>';
718
+                                echo '</td>';
719 719
 
720
-							}
720
+                            }
721 721
 
722
-						echo '</tr>';
722
+                        echo '</tr>';
723 723
 
724
-						endforeach;
725
-					?>
724
+                        endforeach;
725
+                    ?>
726 726
 
727 727
 				</tbody>
728 728
 
@@ -741,38 +741,38 @@  discard block
 block discarded – undo
741 741
  */
742 742
 function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) {
743 743
 
744
-	// Fetch the subscription groups.
745
-	$subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() );
746
-
747
-	if ( empty( $subscription_groups ) ) {
748
-		return;
749
-	}
750
-
751
-	// Prepare table columns.
752
-	$columns = apply_filters(
753
-		'getpaid_subscription_related_subscriptions_columns',
754
-		array(
755
-			'subscription' => __( 'Subscription', 'invoicing' ),
756
-			'start_date'   => __( 'Start Date', 'invoicing' ),
757
-			'renewal_date' => __( 'Next Payment', 'invoicing' ),
758
-			'renewals'     => __( 'Payments', 'invoicing' ),
759
-			'item'         => __( 'Items', 'invoicing' ),
760
-			'status'       => __( 'Status', 'invoicing' ),
761
-		),
762
-		$subscription
763
-	);
764
-
765
-	if ( $subscription->get_status() == 'pending' ) {
766
-		unset( $columns['start_date'], $columns['renewal_date'] );
767
-	}
768
-
769
-	$table_class = 'w-100 bg-white';
770
-
771
-	if ( ! is_admin() ) {
772
-		$table_class = 'table table-bordered';
773
-	}
774
-
775
-	?>
744
+    // Fetch the subscription groups.
745
+    $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() );
746
+
747
+    if ( empty( $subscription_groups ) ) {
748
+        return;
749
+    }
750
+
751
+    // Prepare table columns.
752
+    $columns = apply_filters(
753
+        'getpaid_subscription_related_subscriptions_columns',
754
+        array(
755
+            'subscription' => __( 'Subscription', 'invoicing' ),
756
+            'start_date'   => __( 'Start Date', 'invoicing' ),
757
+            'renewal_date' => __( 'Next Payment', 'invoicing' ),
758
+            'renewals'     => __( 'Payments', 'invoicing' ),
759
+            'item'         => __( 'Items', 'invoicing' ),
760
+            'status'       => __( 'Status', 'invoicing' ),
761
+        ),
762
+        $subscription
763
+    );
764
+
765
+    if ( $subscription->get_status() == 'pending' ) {
766
+        unset( $columns['start_date'], $columns['renewal_date'] );
767
+    }
768
+
769
+    $table_class = 'w-100 bg-white';
770
+
771
+    if ( ! is_admin() ) {
772
+        $table_class = 'table table-bordered';
773
+    }
774
+
775
+    ?>
776 776
 		<div class="m-0" style="overflow: auto;">
777 777
 
778 778
 			<table class="<?php echo esc_attr( $table_class ); ?>">
@@ -781,14 +781,14 @@  discard block
 block discarded – undo
781 781
 					<tr>
782 782
 						<?php
783 783
 
784
-							foreach ( $columns as $key => $label ) {
785
-							$key   = esc_attr( $key );
786
-							$label = esc_html( $label );
787
-							$class = 'text-left';
784
+                            foreach ( $columns as $key => $label ) {
785
+                            $key   = esc_attr( $key );
786
+                            $label = esc_html( $label );
787
+                            $class = 'text-left';
788 788
 
789
-							echo "<th class='related-subscription-field-$key bg-light p-2 text-left color-dark font-weight-bold'>$label</th>";
790
-							}
791
-						?>
789
+                            echo "<th class='related-subscription-field-$key bg-light p-2 text-left color-dark font-weight-bold'>$label</th>";
790
+                            }
791
+                        ?>
792 792
 					</tr>
793 793
 				</thead>
794 794
 
@@ -796,74 +796,74 @@  discard block
 block discarded – undo
796 796
 
797 797
 					<?php
798 798
 
799
-						foreach ( $subscription_groups as $subscription_group ) :
799
+                        foreach ( $subscription_groups as $subscription_group ) :
800 800
 
801
-						// Do not list current subscription.
802
-						if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) {
803
-							continue;
804
-							}
801
+                        // Do not list current subscription.
802
+                        if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) {
803
+                            continue;
804
+                            }
805 805
 
806
-						// Ensure the subscription exists.
807
-						$_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] );
806
+                        // Ensure the subscription exists.
807
+                        $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] );
808 808
 
809
-						if ( ! $_suscription->exists() ) {
810
-							continue;
811
-							}
809
+                        if ( ! $_suscription->exists() ) {
810
+                            continue;
811
+                            }
812 812
 
813
-						echo '<tr>';
813
+                        echo '<tr>';
814 814
 
815
-						foreach ( array_keys( $columns ) as $key ) {
815
+                        foreach ( array_keys( $columns ) as $key ) {
816 816
 
817
-							$class = 'text-left';
817
+                            $class = 'text-left';
818 818
 
819
-							echo "<td class='p-2 text-left'>";
819
+                            echo "<td class='p-2 text-left'>";
820 820
 
821
-								switch ( $key ) {
821
+                                switch ( $key ) {
822 822
 
823
-								case 'status':
824
-										echo wp_kses_post( $_suscription->get_status_label_html() );
825
-									break;
823
+                                case 'status':
824
+                                        echo wp_kses_post( $_suscription->get_status_label_html() );
825
+                                    break;
826 826
 
827
-								case 'item':
828
-											$markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
829
-											echo implode( ' | ', $markup );
830
-									break;
827
+                                case 'item':
828
+                                            $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
829
+                                            echo implode( ' | ', $markup );
830
+                                    break;
831 831
 
832
-								case 'renewals':
833
-									$max_bills = $_suscription->get_bill_times();
834
-									echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '&infin;' : (int) $max_bills );
835
-									break;
832
+                                case 'renewals':
833
+                                    $max_bills = $_suscription->get_bill_times();
834
+                                    echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '&infin;' : (int) $max_bills );
835
+                                    break;
836 836
 
837
-								case 'renewal_date':
838
-										echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : '&mdash;';
839
-									break;
837
+                                case 'renewal_date':
838
+                                        echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : '&mdash;';
839
+                                    break;
840 840
 
841
-								case 'start_date':
842
-										echo 'pending' == $_suscription->get_status() ? '&mdash;' : getpaid_format_date_value( $_suscription->get_date_created() );
843
-									break;
841
+                                case 'start_date':
842
+                                        echo 'pending' == $_suscription->get_status() ? '&mdash;' : getpaid_format_date_value( $_suscription->get_date_created() );
843
+                                    break;
844 844
 
845
-								case 'subscription':
846
-										$url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url();
847
-										printf(
845
+                                case 'subscription':
846
+                                        $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url();
847
+                                        printf(
848 848
                                             '%1$s#%2$s%3$s',
849 849
                                             '<a href="' . esc_url( $url ) . '">',
850 850
                                             '<strong>' . intval( $_suscription->get_id() ) . '</strong>',
851
-											'</a>'
851
+                                            '</a>'
852 852
                                         );
853 853
 
854
-											echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) );
855
-									break;
854
+                                            echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) );
855
+                                    break;
856 856
 
857
-										}
857
+                                        }
858 858
 
859
-								echo '</td>';
859
+                                echo '</td>';
860 860
 
861
-							}
861
+                            }
862 862
 
863
-						echo '</tr>';
863
+                        echo '</tr>';
864 864
 
865
-						endforeach;
866
-					?>
865
+                        endforeach;
866
+                    ?>
867 867
 
868 868
 				</tbody>
869 869
 
Please login to merge, or discard this patch.
includes/user-functions.php 1 patch
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -34,11 +34,11 @@  discard block
 block discarded – undo
34 34
  */
35 35
 function wpinv_get_capability( $capalibilty = 'manage_invoicing' ) {
36 36
 
37
-	if ( current_user_can( 'manage_options' ) ) {
38
-		return 'manage_options';
39
-	};
37
+    if ( current_user_can( 'manage_options' ) ) {
38
+        return 'manage_options';
39
+    };
40 40
 
41
-	return $capalibilty;
41
+    return $capalibilty;
42 42
 }
43 43
 
44 44
 /**
@@ -62,10 +62,10 @@  discard block
 block discarded – undo
62 62
     // Prepare user values.
63 63
     $prefix = preg_replace( '/\s+/', '', $prefix );
64 64
     $prefix = empty( $prefix ) ? $email : $prefix;
65
-	$args   = array(
66
-		'user_login' => wpinv_generate_user_name( $prefix ),
67
-		'user_pass'  => wp_generate_password(),
68
-		'user_email' => $email,
65
+    $args   = array(
66
+        'user_login' => wpinv_generate_user_name( $prefix ),
67
+        'user_pass'  => wp_generate_password(),
68
+        'user_email' => $email,
69 69
         'role'       => 'subscriber',
70 70
     );
71 71
 
@@ -82,16 +82,16 @@  discard block
 block discarded – undo
82 82
 function wpinv_generate_user_name( $prefix = '' ) {
83 83
 
84 84
     // If prefix is an email, retrieve the part before the email.
85
-	$prefix = strtok( $prefix, '@' );
85
+    $prefix = strtok( $prefix, '@' );
86 86
     $prefix = trim( $prefix, '.' );
87 87
 
88
-	// Sanitize the username.
89
-	$prefix = sanitize_user( $prefix, true );
88
+    // Sanitize the username.
89
+    $prefix = sanitize_user( $prefix, true );
90 90
 
91
-	$illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
92
-	if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) {
93
-		$prefix = 'gtp_' . zeroise( wp_rand( 0, 9999 ), 4 );
94
-	}
91
+    $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
92
+    if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) {
93
+        $prefix = 'gtp_' . zeroise( wp_rand( 0, 9999 ), 4 );
94
+    }
95 95
 
96 96
     $username = $prefix;
97 97
     $postfix  = 2;
@@ -220,43 +220,43 @@  discard block
 block discarded – undo
220 220
 
221 221
                     foreach ( getpaid_user_address_fields() as $key => $label ) {
222 222
 
223
-					// Display the country.
224
-					if ( 'country' == $key ) {
225
-
226
-						aui()->select(
227
-							array(
228
-								'options'     => wpinv_get_country_list(),
229
-								'name'        => 'getpaid_address[' . esc_attr( $key ) . ']',
230
-								'id'          => 'wpinv-' . sanitize_html_class( $key ),
231
-								'value'       => sanitize_text_field( getpaid_get_user_address_field( get_current_user_id(), $key ) ),
232
-								'placeholder' => $label,
233
-								'label'       => wp_kses_post( $label ),
234
-								'label_type'  => 'vertical',
235
-								'class'       => 'getpaid-address-field',
223
+                    // Display the country.
224
+                    if ( 'country' == $key ) {
225
+
226
+                        aui()->select(
227
+                            array(
228
+                                'options'     => wpinv_get_country_list(),
229
+                                'name'        => 'getpaid_address[' . esc_attr( $key ) . ']',
230
+                                'id'          => 'wpinv-' . sanitize_html_class( $key ),
231
+                                'value'       => sanitize_text_field( getpaid_get_user_address_field( get_current_user_id(), $key ) ),
232
+                                'placeholder' => $label,
233
+                                'label'       => wp_kses_post( $label ),
234
+                                'label_type'  => 'vertical',
235
+                                'class'       => 'getpaid-address-field',
236 236
                             ),
237 237
                             true
238
-						);
239
-
240
-					}
241
-
242
-					// Display the state.
243
-					elseif ( 'state' == $key ) {
244
-
245
-						getpaid_get_states_select_markup(
246
-							getpaid_get_user_address_field( get_current_user_id(), 'country' ),
247
-							getpaid_get_user_address_field( get_current_user_id(), 'state' ),
248
-							$label,
249
-							$label,
250
-							'',
251
-							false,
252
-							'',
253
-							'getpaid_address[' . esc_attr( $key ) . ']',
238
+                        );
239
+
240
+                    }
241
+
242
+                    // Display the state.
243
+                    elseif ( 'state' == $key ) {
244
+
245
+                        getpaid_get_states_select_markup(
246
+                            getpaid_get_user_address_field( get_current_user_id(), 'country' ),
247
+                            getpaid_get_user_address_field( get_current_user_id(), 'state' ),
248
+                            $label,
249
+                            $label,
250
+                            '',
251
+                            false,
252
+                            '',
253
+                            'getpaid_address[' . esc_attr( $key ) . ']',
254 254
                             true
255
-						);
255
+                        );
256 256
 
257 257
                         } else {
258 258
 
259
-						aui()->input(
259
+                        aui()->input(
260 260
                             array(
261 261
                                 'name'        => 'getpaid_address[' . esc_attr( $key ) . ']',
262 262
                                 'id'          => 'wpinv-' . sanitize_html_class( $key ),
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
                                 'class'       => 'getpaid-address-field',
269 269
                             ),
270 270
                             true
271
-						);
271
+                        );
272 272
 
273 273
                         }
274 274
                     }
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 function getpaid_allowed_html() {
408 408
     $allowed_html = wp_kses_allowed_html( 'post' );
409 409
 
410
-	// form fields
410
+    // form fields
411 411
     $allowed_html['form'] = array(
412 412
         'action'         => true,
413 413
         'accept'         => true,
@@ -419,29 +419,29 @@  discard block
 block discarded – undo
419 419
     );
420 420
     
421 421
     // - input
422
-	$allowed_html['input'] = array(
423
-		'class' => array(),
424
-		'id'    => array(),
425
-		'name'  => array(),
426
-		'value' => array(),
427
-		'type'  => array(),
428
-	);
429
-
430
-	// select
431
-	$allowed_html['select'] = array(
432
-		'class'  => array(),
433
-		'id'     => array(),
434
-		'name'   => array(),
435
-		'value'  => array(),
436
-		'type'   => array(),
437
-	);
438
-
439
-	// select options
440
-	$allowed_html['option'] = array(
441
-		'selected' => array(),
442
-	);
443
-
444
-	return $allowed_html;
422
+    $allowed_html['input'] = array(
423
+        'class' => array(),
424
+        'id'    => array(),
425
+        'name'  => array(),
426
+        'value' => array(),
427
+        'type'  => array(),
428
+    );
429
+
430
+    // select
431
+    $allowed_html['select'] = array(
432
+        'class'  => array(),
433
+        'id'     => array(),
434
+        'name'   => array(),
435
+        'value'  => array(),
436
+        'type'   => array(),
437
+    );
438
+
439
+    // select options
440
+    $allowed_html['option'] = array(
441
+        'selected' => array(),
442
+    );
443
+
444
+    return $allowed_html;
445 445
 
446 446
 }
447 447
 
Please login to merge, or discard this patch.