Passed
Push — master ( 9ee829...6e3436 )
by Brian
04:40
created
includes/admin/subscriptions.php 3 patches
Indentation   +415 added lines, -415 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,10 +781,10 @@  discard block
 block discarded – undo
781 781
 					<tr>
782 782
 						<?php
783 783
 
784
-							foreach ( $columns as $key => $label ) {
785
-							echo "<th class='related-subscription-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
786
-							}
787
-						?>
784
+                            foreach ( $columns as $key => $label ) {
785
+                            echo "<th class='related-subscription-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
786
+                            }
787
+                        ?>
788 788
 					</tr>
789 789
 				</thead>
790 790
 
@@ -792,74 +792,74 @@  discard block
 block discarded – undo
792 792
 
793 793
 					<?php
794 794
 
795
-						foreach ( $subscription_groups as $subscription_group ) :
795
+                        foreach ( $subscription_groups as $subscription_group ) :
796 796
 
797
-						// Do not list current subscription.
798
-						if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) {
799
-							continue;
800
-							}
797
+                        // Do not list current subscription.
798
+                        if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) {
799
+                            continue;
800
+                            }
801 801
 
802
-						// Ensure the subscription exists.
803
-						$_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] );
802
+                        // Ensure the subscription exists.
803
+                        $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] );
804 804
 
805
-						if ( ! $_suscription->exists() ) {
806
-							continue;
807
-							}
805
+                        if ( ! $_suscription->exists() ) {
806
+                            continue;
807
+                            }
808 808
 
809
-						echo '<tr>';
809
+                        echo '<tr>';
810 810
 
811
-						foreach ( array_keys( $columns ) as $key ) {
811
+                        foreach ( array_keys( $columns ) as $key ) {
812 812
 
813
-							$class = 'text-left';
813
+                            $class = 'text-left';
814 814
 
815
-							echo "<td class='p-2 text-left'>";
815
+                            echo "<td class='p-2 text-left'>";
816 816
 
817
-								switch ( $key ) {
817
+                                switch ( $key ) {
818 818
 
819
-								case 'status':
820
-										echo wp_kses_post( $_suscription->get_status_label_html() );
821
-									break;
819
+                                case 'status':
820
+                                        echo wp_kses_post( $_suscription->get_status_label_html() );
821
+                                    break;
822 822
 
823
-								case 'item':
824
-											$markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
825
-											echo wp_kses_post( implode( ' | ', $markup ) );
826
-									break;
823
+                                case 'item':
824
+                                            $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
825
+                                            echo wp_kses_post( implode( ' | ', $markup ) );
826
+                                    break;
827 827
 
828
-								case 'renewals':
829
-									$max_bills = $_suscription->get_bill_times();
830
-									echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '&infin;' : (int) $max_bills );
831
-									break;
828
+                                case 'renewals':
829
+                                    $max_bills = $_suscription->get_bill_times();
830
+                                    echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '&infin;' : (int) $max_bills );
831
+                                    break;
832 832
 
833
-								case 'renewal_date':
834
-										echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '&mdash;';
835
-									break;
833
+                                case 'renewal_date':
834
+                                        echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '&mdash;';
835
+                                    break;
836 836
 
837
-								case 'start_date':
838
-										echo 'pending' == $_suscription->get_status() ? '&mdash;' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) );
839
-									break;
837
+                                case 'start_date':
838
+                                        echo 'pending' == $_suscription->get_status() ? '&mdash;' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) );
839
+                                    break;
840 840
 
841
-								case 'subscription':
842
-										$url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url();
843
-										printf(
841
+                                case 'subscription':
842
+                                        $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url();
843
+                                        printf(
844 844
                                             '%1$s#%2$s%3$s',
845 845
                                             '<a href="' . esc_url( $url ) . '">',
846 846
                                             '<strong>' . intval( $_suscription->get_id() ) . '</strong>',
847
-											'</a>'
847
+                                            '</a>'
848 848
                                         );
849 849
 
850
-											echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) );
851
-									break;
850
+                                            echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) );
851
+                                    break;
852 852
 
853
-										}
853
+                                        }
854 854
 
855
-								echo '</td>';
855
+                                echo '</td>';
856 856
 
857
-							}
857
+                            }
858 858
 
859
-						echo '</tr>';
859
+                        echo '</tr>';
860 860
 
861
-						endforeach;
862
-					?>
861
+                        endforeach;
862
+                    ?>
863 863
 
864 864
 				</tbody>
865 865
 
Please login to merge, or discard this patch.
Switch Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -508,39 +508,39 @@  discard block
 block discarded – undo
508 508
 
509 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;
516
-
517
-								case 'relationship':
518
-										echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' );
519
-									break;
520
-
521
-								case 'date':
522
-									echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) );
523
-									break;
524
-
525
-								case 'status':
526
-										$status = $payment->get_status_nicename();
527
-										if ( is_admin() ) {
528
-										$status = $payment->get_status_label_html();
529
-										}
530
-
531
-										echo wp_kses_post( $status );
532
-									break;
533
-
534
-								case 'invoice':
535
-										$link    = esc_url( get_edit_post_link( $payment->get_id() ) );
536
-
537
-										if ( ! is_admin() ) {
538
-										$link = esc_url( $payment->get_view_url() );
539
-										}
540
-
541
-										$invoice = esc_html( $payment->get_number() );
542
-										echo wp_kses_post( "<a href='$link'>$invoice</a>" );
543
-									break;
511
+								    case 'total':
512
+										    echo '<strong>';
513
+										    wpinv_the_price( $payment->get_total(), $payment->get_currency() );
514
+										    echo '</strong>';
515
+									    break;
516
+
517
+								    case 'relationship':
518
+										    echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' );
519
+									    break;
520
+
521
+								    case 'date':
522
+									    echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) );
523
+									    break;
524
+
525
+								    case 'status':
526
+										    $status = $payment->get_status_nicename();
527
+										    if ( is_admin() ) {
528
+										    $status = $payment->get_status_label_html();
529
+										    }
530
+
531
+										    echo wp_kses_post( $status );
532
+									    break;
533
+
534
+								    case 'invoice':
535
+										    $link    = esc_url( get_edit_post_link( $payment->get_id() ) );
536
+
537
+										    if ( ! is_admin() ) {
538
+										    $link = esc_url( $payment->get_view_url() );
539
+										    }
540
+
541
+										    $invoice = esc_html( $payment->get_number() );
542
+										    echo wp_kses_post( "<a href='$link'>$invoice</a>" );
543
+									    break;
544 544
 										}
545 545
 
546 546
 								echo '</td>';
@@ -635,37 +635,37 @@  discard block
 block discarded – undo
635 635
 
636 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
 
@@ -689,29 +689,29 @@  discard block
 block discarded – undo
689 689
 
690 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
 
@@ -816,39 +816,39 @@  discard block
 block discarded – undo
816 816
 
817 817
 								switch ( $key ) {
818 818
 
819
-								case 'status':
820
-										echo wp_kses_post( $_suscription->get_status_label_html() );
821
-									break;
822
-
823
-								case 'item':
824
-											$markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
825
-											echo wp_kses_post( implode( ' | ', $markup ) );
826
-									break;
827
-
828
-								case 'renewals':
829
-									$max_bills = $_suscription->get_bill_times();
830
-									echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '&infin;' : (int) $max_bills );
831
-									break;
832
-
833
-								case 'renewal_date':
834
-										echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '&mdash;';
835
-									break;
836
-
837
-								case 'start_date':
838
-										echo 'pending' == $_suscription->get_status() ? '&mdash;' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) );
839
-									break;
840
-
841
-								case 'subscription':
842
-										$url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url();
843
-										printf(
844
-                                            '%1$s#%2$s%3$s',
845
-                                            '<a href="' . esc_url( $url ) . '">',
846
-                                            '<strong>' . intval( $_suscription->get_id() ) . '</strong>',
847
-											'</a>'
848
-                                        );
849
-
850
-											echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) );
851
-									break;
819
+								    case 'status':
820
+										    echo wp_kses_post( $_suscription->get_status_label_html() );
821
+									    break;
822
+
823
+								    case 'item':
824
+											    $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
825
+											    echo wp_kses_post( implode( ' | ', $markup ) );
826
+									    break;
827
+
828
+								    case 'renewals':
829
+									    $max_bills = $_suscription->get_bill_times();
830
+									    echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '&infin;' : (int) $max_bills );
831
+									    break;
832
+
833
+								    case 'renewal_date':
834
+										    echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '&mdash;';
835
+									    break;
836
+
837
+								    case 'start_date':
838
+										    echo 'pending' == $_suscription->get_status() ? '&mdash;' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) );
839
+									    break;
840
+
841
+								    case 'subscription':
842
+										    $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url();
843
+										    printf(
844
+                                                '%1$s#%2$s%3$s',
845
+                                                '<a href="' . esc_url( $url ) . '">',
846
+                                                '<strong>' . intval( $_suscription->get_id() ) . '</strong>',
847
+											    '</a>'
848
+                                            );
849
+
850
+											    echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) );
851
+									    break;
852 852
 
853 853
 										}
854 854
 
Please login to merge, or discard this patch.
Spacing   +203 added lines, -203 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Contains functions that display the subscriptions admin page.
4 4
  */
5 5
 
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * Render the Subscriptions page
@@ -17,23 +17,23 @@  discard block
 block discarded – undo
17 17
 	?>
18 18
 
19 19
 	<div class="wrap">
20
-		<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
20
+		<h1><?php echo esc_html(get_admin_page_title()); ?></h1>
21 21
 		<div class="bsui">
22 22
 
23 23
 			<?php
24 24
 
25 25
 				// Verify user permissions.
26
-				if ( ! wpinv_current_user_can_manage_invoicing() ) {
26
+				if (!wpinv_current_user_can_manage_invoicing()) {
27 27
 
28 28
 				aui()->alert(
29 29
                     array(
30 30
 						'type'    => 'danger',
31
-						'content' => __( 'You are not permitted to view this page.', 'invoicing' ),
31
+						'content' => __('You are not permitted to view this page.', 'invoicing'),
32 32
 					),
33 33
 					true
34 34
                 );
35 35
 
36
-				} elseif ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) {
36
+				} elseif (!empty($_GET['id']) && is_numeric($_GET['id'])) {
37 37
 
38 38
 				// Display a single subscription.
39 39
 				wpinv_recurring_subscription_details();
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	<?php $subscribers_table->views(); ?>
68 68
 	<form id="subscribers-filter" class="bsui" method="get">
69 69
 		<input type="hidden" name="page" value="wpinv-subscriptions" />
70
-		<?php $subscribers_table->search_box( __( 'Search Subscriptions', 'invoicing' ), 'getpaid-search-subscriptions' ); ?>
70
+		<?php $subscribers_table->search_box(__('Search Subscriptions', 'invoicing'), 'getpaid-search-subscriptions'); ?>
71 71
 		<?php $subscribers_table->display(); ?>
72 72
 	</form>
73 73
 	<?php
@@ -83,13 +83,13 @@  discard block
 block discarded – undo
83 83
 function wpinv_recurring_subscription_details() {
84 84
 
85 85
 	// Fetch the subscription.
86
-	$sub = new WPInv_Subscription( (int) $_GET['id'] );
87
-	if ( ! $sub->exists() ) {
86
+	$sub = new WPInv_Subscription((int) $_GET['id']);
87
+	if (!$sub->exists()) {
88 88
 
89 89
 		aui()->alert(
90 90
 			array(
91 91
 				'type'    => 'danger',
92
-				'content' => __( 'Subscription not found.', 'invoicing' ),
92
+				'content' => __('Subscription not found.', 'invoicing'),
93 93
 			),
94 94
 			true
95 95
 		);
@@ -98,32 +98,32 @@  discard block
 block discarded – undo
98 98
 	}
99 99
 
100 100
 	// Use metaboxes to display the subscription details.
101
-	add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' );
102
-	add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' );
101
+	add_meta_box('getpaid_admin_subscription_details_metabox', __('Subscription Details', 'invoicing'), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high');
102
+	add_meta_box('getpaid_admin_subscription_update_metabox', __('Change Status', 'invoicing'), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side');
103 103
 
104 104
 	$subscription_id     = $sub->get_id();
105
-	$subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() );
106
-	$subscription_group  = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) );
105
+	$subscription_groups = getpaid_get_invoice_subscription_groups($sub->get_parent_invoice_id());
106
+	$subscription_group  = wp_list_filter($subscription_groups, compact('subscription_id'));
107 107
 
108
-	if ( 1 < count( $subscription_groups ) ) {
109
-		add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' );
108
+	if (1 < count($subscription_groups)) {
109
+		add_meta_box('getpaid_admin_subscription_related_subscriptions_metabox', __('Related Subscriptions', 'invoicing'), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced');
110 110
 	}
111 111
 
112
-	if ( ! empty( $subscription_group ) ) {
113
-		add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' );
112
+	if (!empty($subscription_group)) {
113
+		add_meta_box('getpaid_admin_subscription_item_details_metabox', __('Subscription Items', 'invoicing'), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low');
114 114
 	}
115 115
 
116
-	add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' );
116
+	add_meta_box('getpaid_admin_subscription_invoice_details_metabox', __('Related Invoices', 'invoicing'), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced');
117 117
 
118
-	do_action( 'getpaid_admin_single_subscription_register_metabox', $sub );
118
+	do_action('getpaid_admin_single_subscription_register_metabox', $sub);
119 119
 
120 120
 	?>
121 121
 
122
-		<form method="post" action="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ) ); ?>">
122
+		<form method="post" action="<?php echo esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($sub->get_id()))); ?>">
123 123
 
124
-			<?php wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); ?>
125
-			<?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
126
-			<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
124
+			<?php wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); ?>
125
+			<?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?>
126
+			<?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?>
127 127
 			<input type="hidden" name="getpaid-admin-action" value="update_single_subscription" />
128 128
 			<input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id(); ?>" />
129 129
 
@@ -131,12 +131,12 @@  discard block
 block discarded – undo
131 131
 				<div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
132 132
 
133 133
 					<div id="postbox-container-1" class="postbox-container">
134
-						<?php do_meta_boxes( get_current_screen(), 'side', $sub ); ?>
134
+						<?php do_meta_boxes(get_current_screen(), 'side', $sub); ?>
135 135
 					</div>
136 136
 
137 137
 					<div id="postbox-container-2" class="postbox-container">
138
-						<?php do_meta_boxes( get_current_screen(), 'normal', $sub ); ?>
139
-						<?php do_meta_boxes( get_current_screen(), 'advanced', $sub ); ?>
138
+						<?php do_meta_boxes(get_current_screen(), 'normal', $sub); ?>
139
+						<?php do_meta_boxes(get_current_screen(), 'advanced', $sub); ?>
140 140
 					</div>
141 141
 
142 142
 				</div>
@@ -155,43 +155,43 @@  discard block
 block discarded – undo
155 155
  *
156 156
  * @param WPInv_Subscription $sub
157 157
  */
158
-function getpaid_admin_subscription_details_metabox( $sub ) {
158
+function getpaid_admin_subscription_details_metabox($sub) {
159 159
 
160 160
 	// Subscription items.
161
-	$subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() );
162
-	$items_count        = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] );
161
+	$subscription_group = getpaid_get_invoice_subscription_group($sub->get_parent_invoice_id(), $sub->get_id());
162
+	$items_count        = empty($subscription_group) ? 1 : count($subscription_group['items']);
163 163
 
164 164
 	// Prepare subscription detail columns.
165 165
 	$fields = apply_filters(
166 166
 		'getpaid_subscription_admin_page_fields',
167 167
 		array(
168
-			'subscription' => __( 'Subscription', 'invoicing' ),
169
-			'customer'     => __( 'Customer', 'invoicing' ),
170
-			'amount'       => __( 'Amount', 'invoicing' ),
171
-			'start_date'   => __( 'Start Date', 'invoicing' ),
172
-			'renews_on'    => __( 'Next Payment', 'invoicing' ),
173
-			'renewals'     => __( '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' ),
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 178
 		)
179 179
 	);
180 180
 
181
-	if ( ! $sub->is_active() ) {
181
+	if (!$sub->is_active()) {
182 182
 
183
-		if ( isset( $fields['renews_on'] ) ) {
184
-			unset( $fields['renews_on'] );
183
+		if (isset($fields['renews_on'])) {
184
+			unset($fields['renews_on']);
185 185
 		}
186 186
 
187
-		if ( isset( $fields['gateway'] ) ) {
188
-			unset( $fields['gateway'] );
187
+		if (isset($fields['gateway'])) {
188
+			unset($fields['gateway']);
189 189
 		}
190 190
 }
191 191
 
192 192
 	$profile_id = $sub->get_profile_id();
193
-	if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) {
194
-		unset( $fields['profile_id'] );
193
+	if (empty($profile_id) && isset($fields['profile_id'])) {
194
+		unset($fields['profile_id']);
195 195
 	}
196 196
 
197 197
 	?>
@@ -199,16 +199,16 @@  discard block
 block discarded – undo
199 199
 		<table class="table table-borderless" style="font-size: 14px;">
200 200
 			<tbody>
201 201
 
202
-				<?php foreach ( $fields as $key => $label ) : ?>
202
+				<?php foreach ($fields as $key => $label) : ?>
203 203
 
204
-					<tr class="getpaid-subscription-meta-<?php echo sanitize_html_class( $key ); ?>">
204
+					<tr class="getpaid-subscription-meta-<?php echo sanitize_html_class($key); ?>">
205 205
 
206 206
 						<th class="w-25" style="font-weight: 500;">
207
-							<?php echo esc_html( $label ); ?>
207
+							<?php echo esc_html($label); ?>
208 208
 						</th>
209 209
 
210 210
 						<td class="w-75 text-muted">
211
-							<?php do_action( 'getpaid_subscription_admin_display_' . sanitize_key( $key ), $sub, $subscription_group ); ?>
211
+							<?php do_action('getpaid_subscription_admin_display_' . sanitize_key($key), $sub, $subscription_group); ?>
212 212
 						</td>
213 213
 
214 214
 					</tr>
@@ -226,135 +226,135 @@  discard block
 block discarded – undo
226 226
  *
227 227
  * @param WPInv_Subscription $subscription
228 228
  */
229
-function getpaid_admin_subscription_metabox_display_customer( $subscription ) {
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 236
 		$username = sprintf(
237 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 )
238
+			absint($user->ID),
239
+			!empty($user->display_name) ? esc_html($user->display_name) : sanitize_email($user->user_email)
240 240
 		);
241 241
 
242 242
 	}
243 243
 
244
-	echo wp_kses_post( $username );
244
+	echo wp_kses_post($username);
245 245
 }
246
-add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' );
246
+add_action('getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer');
247 247
 
248 248
 /**
249 249
  * Displays the subscription amount.
250 250
  *
251 251
  * @param WPInv_Subscription $subscription
252 252
  */
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>" );
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>");
256 256
 }
257
-add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' );
257
+add_action('getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount');
258 258
 
259 259
 /**
260 260
  * Displays the subscription id.
261 261
  *
262 262
  * @param WPInv_Subscription $subscription
263 263
  */
264
-function getpaid_admin_subscription_metabox_display_id( $subscription ) {
264
+function getpaid_admin_subscription_metabox_display_id($subscription) {
265 265
 
266 266
 	printf(
267 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() )
268
+		esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($subscription->get_id()))),
269
+		absint($subscription->get_id())
270 270
 	);
271 271
 
272 272
 }
273
-add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' );
273
+add_action('getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id');
274 274
 
275 275
 /**
276 276
  * Displays the subscription renewal date.
277 277
  *
278 278
  * @param WPInv_Subscription $subscription
279 279
  */
280
-function getpaid_admin_subscription_metabox_display_start_date( $subscription ) {
281
-	echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) );
280
+function getpaid_admin_subscription_metabox_display_start_date($subscription) {
281
+	echo esc_html(getpaid_format_date_value($subscription->get_date_created()));
282 282
 }
283
-add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' );
283
+add_action('getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date');
284 284
 
285 285
 /**
286 286
  * Displays the subscription renewal date.
287 287
  *
288 288
  * @param WPInv_Subscription $subscription
289 289
  */
290
-function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) {
291
-	echo esc_html( getpaid_format_date_value( $subscription->get_expiration() ) );
290
+function getpaid_admin_subscription_metabox_display_renews_on($subscription) {
291
+	echo esc_html(getpaid_format_date_value($subscription->get_expiration()));
292 292
 }
293
-add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' );
293
+add_action('getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on');
294 294
 
295 295
 /**
296 296
  * Displays the subscription renewal count.
297 297
  *
298 298
  * @param WPInv_Subscription $subscription
299 299
  */
300
-function getpaid_admin_subscription_metabox_display_renewals( $subscription ) {
300
+function getpaid_admin_subscription_metabox_display_renewals($subscription) {
301 301
 	$max_bills = $subscription->get_bill_times();
302
-	echo ( (int) $subscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '&infin;' : (int) $max_bills );
302
+	echo ((int) $subscription->get_times_billed()) . ' / ' . (empty($max_bills) ? '&infin;' : (int) $max_bills);
303 303
 }
304
-add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' );
304
+add_action('getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals');
305 305
 /**
306 306
  * Displays the subscription item.
307 307
  *
308 308
  * @param WPInv_Subscription $subscription
309 309
  * @param false|array $subscription_group
310 310
  */
311
-function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) {
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() ) );
313
+	if (empty($subscription_group)) {
314
+		echo wp_kses_post(WPInv_Subscriptions_List_Table::generate_item_markup($subscription->get_product_id()));
315 315
 		return;
316 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
-add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 );
322
+add_action('getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2);
323 323
 
324 324
 /**
325 325
  * Displays the subscription gateway.
326 326
  *
327 327
  * @param WPInv_Subscription $subscription
328 328
  */
329
-function getpaid_admin_subscription_metabox_display_gateway( $subscription ) {
329
+function getpaid_admin_subscription_metabox_display_gateway($subscription) {
330 330
 
331 331
 	$gateway = $subscription->get_gateway();
332 332
 
333
-	if ( ! empty( $gateway ) ) {
334
-		echo esc_html( wpinv_get_gateway_admin_label( $gateway ) );
333
+	if (!empty($gateway)) {
334
+		echo esc_html(wpinv_get_gateway_admin_label($gateway));
335 335
 	} else {
336 336
 		echo '&mdash;';
337 337
 	}
338 338
 
339 339
 }
340
-add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' );
340
+add_action('getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway');
341 341
 
342 342
 /**
343 343
  * Displays the subscription status.
344 344
  *
345 345
  * @param WPInv_Subscription $subscription
346 346
  */
347
-function getpaid_admin_subscription_metabox_display_status( $subscription ) {
348
-	echo wp_kses_post( $subscription->get_status_label_html() );
347
+function getpaid_admin_subscription_metabox_display_status($subscription) {
348
+	echo wp_kses_post($subscription->get_status_label_html());
349 349
 }
350
-add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' );
350
+add_action('getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status');
351 351
 
352 352
 /**
353 353
  * Displays the subscription profile id.
354 354
  *
355 355
  * @param WPInv_Subscription $subscription
356 356
  */
357
-function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) {
357
+function getpaid_admin_subscription_metabox_display_profile_id($subscription) {
358 358
 
359 359
 	$profile_id = $subscription->get_profile_id();
360 360
 
@@ -363,30 +363,30 @@  discard block
 block discarded – undo
363 363
 			'type'              => 'text',
364 364
 			'id'                => 'wpinv_subscription_profile_id',
365 365
 			'name'              => 'wpinv_subscription_profile_id',
366
-			'label'             => __( 'Profile Id', 'invoicing' ),
366
+			'label'             => __('Profile Id', 'invoicing'),
367 367
 			'label_type'        => 'hidden',
368
-			'placeholder'       => __( 'Profile Id', 'invoicing' ),
369
-			'value'             => esc_attr( $profile_id ),
368
+			'placeholder'       => __('Profile Id', 'invoicing'),
369
+			'value'             => esc_attr($profile_id),
370 370
 			'input_group_right' => '',
371 371
 			'no_wrap'           => true,
372 372
 		),
373 373
 		true
374 374
 	);
375 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>';
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 379
 	}
380 380
 
381 381
 }
382
-add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' );
382
+add_action('getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id');
383 383
 
384 384
 /**
385 385
  * Displays the subscriptions update metabox.
386 386
  *
387 387
  * @param WPInv_Subscription $subscription
388 388
  */
389
-function getpaid_admin_subscription_update_metabox( $subscription ) {
389
+function getpaid_admin_subscription_update_metabox($subscription) {
390 390
 
391 391
 	?>
392 392
 	<div class="mt-3">
@@ -399,10 +399,10 @@  discard block
 block discarded – undo
399 399
 					'id'        => 'subscription_status_update_select',
400 400
 					'required'  => true,
401 401
 					'no_wrap'   => false,
402
-					'label'     => __( 'Subscription Status', 'invoicing' ),
403
-					'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ),
402
+					'label'     => __('Subscription Status', 'invoicing'),
403
+					'help_text' => __('Updating the status will trigger related actions and hooks', 'invoicing'),
404 404
 					'select2'   => true,
405
-					'value'     => $subscription->get_status( 'edit' ),
405
+					'value'     => $subscription->get_status('edit'),
406 406
 				),
407 407
 				true
408 408
 			);
@@ -411,14 +411,14 @@  discard block
 block discarded – undo
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>";
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 422
 			}
423 423
 
424 424
 	echo '</div></div>';
@@ -430,44 +430,44 @@  discard block
 block discarded – undo
430 430
  * @param WPInv_Subscription $subscription
431 431
  * @param bool $strict Whether or not to skip invoices of sibling subscriptions
432 432
  */
433
-function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) {
433
+function getpaid_admin_subscription_invoice_details_metabox($subscription, $strict = true) {
434 434
 
435 435
 	$columns = apply_filters(
436 436
 		'getpaid_subscription_related_invoices_columns',
437 437
 		array(
438
-			'invoice'      => __( 'Invoice', 'invoicing' ),
439
-			'relationship' => __( 'Relationship', 'invoicing' ),
440
-			'date'         => __( 'Date', 'invoicing' ),
441
-			'status'       => __( 'Status', 'invoicing' ),
442
-			'total'        => __( 'Total', 'invoicing' ),
438
+			'invoice'      => __('Invoice', 'invoicing'),
439
+			'relationship' => __('Relationship', 'invoicing'),
440
+			'date'         => __('Date', 'invoicing'),
441
+			'status'       => __('Status', 'invoicing'),
442
+			'total'        => __('Total', 'invoicing'),
443 443
 		),
444 444
 		$subscription
445 445
 	);
446 446
 
447 447
 	// Prepare the invoices.
448
-	$payments = $subscription->get_child_payments( ! is_admin() );
448
+	$payments = $subscription->get_child_payments(!is_admin());
449 449
 	$parent   = $subscription->get_parent_invoice();
450 450
 
451
-	if ( $parent->exists() ) {
452
-		$payments = array_merge( array( $parent ), $payments );
451
+	if ($parent->exists()) {
452
+		$payments = array_merge(array($parent), $payments);
453 453
 	}
454 454
 
455 455
 	$table_class = 'w-100 bg-white';
456 456
 
457
-	if ( ! is_admin() ) {
457
+	if (!is_admin()) {
458 458
 		$table_class = 'table table-bordered';
459 459
 	}
460 460
 
461 461
 	?>
462 462
 		<div class="m-0" style="overflow: auto;">
463 463
 
464
-			<table class="<?php echo esc_attr( $table_class ); ?>">
464
+			<table class="<?php echo esc_attr($table_class); ?>">
465 465
 
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>";
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 471
 							}
472 472
 						?>
473 473
 					</tr>
@@ -475,71 +475,71 @@  discard block
 block discarded – undo
475 475
 
476 476
 				<tbody>
477 477
 
478
-					<?php if ( empty( $payments ) ) : ?>
478
+					<?php if (empty($payments)) : ?>
479 479
 						<tr>
480
-							<td colspan="<?php echo count( $columns ); ?>" class="p-2 text-left text-muted">
481
-								<?php esc_html_e( 'This subscription has no invoices.', 'invoicing' ); ?>
480
+							<td colspan="<?php echo count($columns); ?>" class="p-2 text-left text-muted">
481
+								<?php esc_html_e('This subscription has no invoices.', 'invoicing'); ?>
482 482
 							</td>
483 483
 						</tr>
484 484
 					<?php endif; ?>
485 485
 
486 486
 					<?php
487 487
 
488
-						foreach ( $payments as $payment ) :
488
+						foreach ($payments as $payment) :
489 489
 
490 490
 						// Ensure that we have an invoice.
491
-						$payment = new WPInv_Invoice( $payment );
491
+						$payment = new WPInv_Invoice($payment);
492 492
 
493 493
 						// Abort if the invoice is invalid...
494
-						if ( ! $payment->exists() ) {
494
+						if (!$payment->exists()) {
495 495
 							continue;
496 496
 							}
497 497
 
498 498
 						// ... or belongs to a different subscription.
499
-						if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) {
499
+						if ($strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id()) {
500 500
 							continue;
501 501
 							}
502 502
 
503 503
 						echo '<tr>';
504 504
 
505
-						foreach ( array_keys( $columns ) as $key ) {
505
+						foreach (array_keys($columns) as $key) {
506 506
 
507 507
 							echo "<td class='p-2 text-left'>";
508 508
 
509
-								switch ( $key ) {
509
+								switch ($key) {
510 510
 
511 511
 								case 'total':
512 512
 										echo '<strong>';
513
-										wpinv_the_price( $payment->get_total(), $payment->get_currency() );
513
+										wpinv_the_price($payment->get_total(), $payment->get_currency());
514 514
 										echo '</strong>';
515 515
 									break;
516 516
 
517 517
 								case 'relationship':
518
-										echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' );
518
+										echo $payment->is_renewal() ? esc_html__('Renewal Invoice', 'invoicing') : esc_html__('Initial Invoice', 'invoicing');
519 519
 									break;
520 520
 
521 521
 								case 'date':
522
-									echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) );
522
+									echo esc_html(getpaid_format_date_value($payment->get_date_created()));
523 523
 									break;
524 524
 
525 525
 								case 'status':
526 526
 										$status = $payment->get_status_nicename();
527
-										if ( is_admin() ) {
527
+										if (is_admin()) {
528 528
 										$status = $payment->get_status_label_html();
529 529
 										}
530 530
 
531
-										echo wp_kses_post( $status );
531
+										echo wp_kses_post($status);
532 532
 									break;
533 533
 
534 534
 								case 'invoice':
535
-										$link    = esc_url( get_edit_post_link( $payment->get_id() ) );
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() );
537
+										if (!is_admin()) {
538
+										$link = esc_url($payment->get_view_url());
539 539
 										}
540 540
 
541
-										$invoice = esc_html( $payment->get_number() );
542
-										echo wp_kses_post( "<a href='$link'>$invoice</a>" );
541
+										$invoice = esc_html($payment->get_number());
542
+										echo wp_kses_post("<a href='$link'>$invoice</a>");
543 543
 									break;
544 544
 										}
545 545
 
@@ -566,12 +566,12 @@  discard block
 block discarded – undo
566 566
  *
567 567
  * @param WPInv_Subscription $subscription
568 568
  */
569
-function getpaid_admin_subscription_item_details_metabox( $subscription ) {
569
+function getpaid_admin_subscription_item_details_metabox($subscription) {
570 570
 
571 571
 	// Fetch the subscription group.
572
-	$subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() );
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'] ) ) {
574
+	if (empty($subscription_group) || empty($subscription_group['items'])) {
575 575
 		return;
576 576
 	}
577 577
 
@@ -579,12 +579,12 @@  discard block
 block discarded – undo
579 579
 	$columns = apply_filters(
580 580
 		'getpaid_subscription_item_details_columns',
581 581
 		array(
582
-			'item_name' => __( 'Item', 'invoicing' ),
583
-			'price'     => __( 'Price', 'invoicing' ),
584
-			'tax'       => __( 'Tax', 'invoicing' ),
585
-			'discount'  => __( 'Discount', 'invoicing' ),
582
+			'item_name' => __('Item', 'invoicing'),
583
+			'price'     => __('Price', 'invoicing'),
584
+			'tax'       => __('Tax', 'invoicing'),
585
+			'discount'  => __('Discount', 'invoicing'),
586 586
 			//'initial'      => __( 'Initial Amount', 'invoicing' ),
587
-			'recurring' => __( 'Subtotal', 'invoicing' ),
587
+			'recurring' => __('Subtotal', 'invoicing'),
588 588
 		),
589 589
 		$subscription
590 590
 	);
@@ -593,27 +593,27 @@  discard block
 block discarded – undo
593 593
 
594 594
 	$invoice = $subscription->get_parent_invoice();
595 595
 
596
-	if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) {
597
-		unset( $columns['tax'] );
596
+	if ((!wpinv_use_taxes() || !$invoice->is_taxable()) && isset($columns['tax'])) {
597
+		unset($columns['tax']);
598 598
 	}
599 599
 
600 600
 	$table_class = 'w-100 bg-white';
601 601
 
602
-	if ( ! is_admin() ) {
602
+	if (!is_admin()) {
603 603
 		$table_class = 'table table-bordered';
604 604
 	}
605 605
 
606 606
 	?>
607 607
 		<div class="m-0" style="overflow: auto;">
608 608
 
609
-			<table class="<?php echo esc_attr( $table_class ); ?>">
609
+			<table class="<?php echo esc_attr($table_class); ?>">
610 610
 
611 611
 				<thead>
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>";
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 617
 							}
618 618
 						?>
619 619
 					</tr>
@@ -623,48 +623,48 @@  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 628
 						echo '<tr>';
629 629
 
630
-						foreach ( array_keys( $columns ) as $key ) {
630
+						foreach (array_keys($columns) as $key) {
631 631
 
632 632
 							$class = 'text-left';
633 633
 
634 634
 							echo "<td class='p-2 text-left'>";
635 635
 
636
-								switch ( $key ) {
636
+								switch ($key) {
637 637
 
638 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;
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 );
642
+										if ($invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity']) {
643
+										echo esc_html($item_name);
644 644
 										} else {
645
-										printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] );
645
+										printf('%1$s x %2$d', esc_html($item_name), (float) $subscription_group_item['quantity']);
646 646
 											}
647 647
 
648 648
 									break;
649 649
 
650 650
 								case 'price':
651
-									wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() );
651
+									wpinv_the_price($subscription_group_item['item_price'], $invoice->get_currency());
652 652
 									break;
653 653
 
654 654
 								case 'tax':
655
-									wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() );
655
+									wpinv_the_price($subscription_group_item['tax'], $invoice->get_currency());
656 656
 									break;
657 657
 
658 658
 								case 'discount':
659
-									wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() );
659
+									wpinv_the_price($subscription_group_item['discount'], $invoice->get_currency());
660 660
 									break;
661 661
 
662 662
 								case 'initial':
663
-									wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() );
663
+									wpinv_the_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency());
664 664
 									break;
665 665
 
666 666
 								case 'recurring':
667
-										echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' );
667
+										echo wp_kses_post('<strong>' . wpinv_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()) . '</strong>');
668 668
 									break;
669 669
 
670 670
 										}
@@ -677,24 +677,24 @@  discard block
 block discarded – undo
677 677
 
678 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 682
 						echo '<tr>';
683 683
 
684
-						foreach ( array_keys( $columns ) as $key ) {
684
+						foreach (array_keys($columns) as $key) {
685 685
 
686 686
 							$class = 'text-left';
687 687
 
688 688
 							echo "<td class='p-2 text-left'>";
689 689
 
690
-								switch ( $key ) {
690
+								switch ($key) {
691 691
 
692 692
 								case 'item_name':
693
-										echo esc_html( $subscription_group_fee['name'] );
693
+										echo esc_html($subscription_group_fee['name']);
694 694
 									break;
695 695
 
696 696
 								case 'price':
697
-									wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
697
+									wpinv_the_price($subscription_group_fee['initial_fee'], $invoice->get_currency());
698 698
 									break;
699 699
 
700 700
 								case 'tax':
@@ -706,11 +706,11 @@  discard block
 block discarded – undo
706 706
 									break;
707 707
 
708 708
 								case 'initial':
709
-									wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
709
+									wpinv_the_price($subscription_group_fee['initial_fee'], $invoice->get_currency());
710 710
 									break;
711 711
 
712 712
 								case 'recurring':
713
-										echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' );
713
+										echo wp_kses_post('<strong>' . wpinv_price($subscription_group_fee['recurring_fee'], $invoice->get_currency()) . '</strong>');
714 714
 									break;
715 715
 
716 716
 										}
@@ -739,12 +739,12 @@  discard block
 block discarded – undo
739 739
  * @param WPInv_Subscription $subscription
740 740
  * @param bool $skip_current
741 741
  */
742
-function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) {
742
+function getpaid_admin_subscription_related_subscriptions_metabox($subscription, $skip_current = true) {
743 743
 
744 744
 	// Fetch the subscription groups.
745
-	$subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() );
745
+	$subscription_groups = getpaid_get_invoice_subscription_groups($subscription->get_parent_payment_id());
746 746
 
747
-	if ( empty( $subscription_groups ) ) {
747
+	if (empty($subscription_groups)) {
748 748
 		return;
749 749
 	}
750 750
 
@@ -752,37 +752,37 @@  discard block
 block discarded – undo
752 752
 	$columns = apply_filters(
753 753
 		'getpaid_subscription_related_subscriptions_columns',
754 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' ),
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 761
 		),
762 762
 		$subscription
763 763
 	);
764 764
 
765
-	if ( $subscription->get_status() == 'pending' ) {
766
-		unset( $columns['start_date'], $columns['renewal_date'] );
765
+	if ($subscription->get_status() == 'pending') {
766
+		unset($columns['start_date'], $columns['renewal_date']);
767 767
 	}
768 768
 
769 769
 	$table_class = 'w-100 bg-white';
770 770
 
771
-	if ( ! is_admin() ) {
771
+	if (!is_admin()) {
772 772
 		$table_class = 'table table-bordered';
773 773
 	}
774 774
 
775 775
 	?>
776 776
 		<div class="m-0" style="overflow: auto;">
777 777
 
778
-			<table class="<?php echo esc_attr( $table_class ); ?>">
778
+			<table class="<?php echo esc_attr($table_class); ?>">
779 779
 
780 780
 				<thead>
781 781
 					<tr>
782 782
 						<?php
783 783
 
784
-							foreach ( $columns as $key => $label ) {
785
-							echo "<th class='related-subscription-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
784
+							foreach ($columns as $key => $label) {
785
+							echo "<th class='related-subscription-field-" . esc_attr($key) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html($label) . "</th>";
786 786
 							}
787 787
 						?>
788 788
 					</tr>
@@ -792,62 +792,62 @@  discard block
 block discarded – undo
792 792
 
793 793
 					<?php
794 794
 
795
-						foreach ( $subscription_groups as $subscription_group ) :
795
+						foreach ($subscription_groups as $subscription_group) :
796 796
 
797 797
 						// Do not list current subscription.
798
-						if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) {
798
+						if ($skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id()) {
799 799
 							continue;
800 800
 							}
801 801
 
802 802
 						// Ensure the subscription exists.
803
-						$_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] );
803
+						$_suscription = new WPInv_Subscription($subscription_group['subscription_id']);
804 804
 
805
-						if ( ! $_suscription->exists() ) {
805
+						if (!$_suscription->exists()) {
806 806
 							continue;
807 807
 							}
808 808
 
809 809
 						echo '<tr>';
810 810
 
811
-						foreach ( array_keys( $columns ) as $key ) {
811
+						foreach (array_keys($columns) as $key) {
812 812
 
813 813
 							$class = 'text-left';
814 814
 
815 815
 							echo "<td class='p-2 text-left'>";
816 816
 
817
-								switch ( $key ) {
817
+								switch ($key) {
818 818
 
819 819
 								case 'status':
820
-										echo wp_kses_post( $_suscription->get_status_label_html() );
820
+										echo wp_kses_post($_suscription->get_status_label_html());
821 821
 									break;
822 822
 
823 823
 								case 'item':
824
-											$markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
825
-											echo wp_kses_post( implode( ' | ', $markup ) );
824
+											$markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items']));
825
+											echo wp_kses_post(implode(' | ', $markup));
826 826
 									break;
827 827
 
828 828
 								case 'renewals':
829 829
 									$max_bills = $_suscription->get_bill_times();
830
-									echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '&infin;' : (int) $max_bills );
830
+									echo ((int) $_suscription->get_times_billed()) . ' / ' . (empty($max_bills) ? '&infin;' : (int) $max_bills);
831 831
 									break;
832 832
 
833 833
 								case 'renewal_date':
834
-										echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '&mdash;';
834
+										echo $_suscription->is_active() ? esc_html(getpaid_format_date_value($_suscription->get_expiration())) : '&mdash;';
835 835
 									break;
836 836
 
837 837
 								case 'start_date':
838
-										echo 'pending' == $_suscription->get_status() ? '&mdash;' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) );
838
+										echo 'pending' == $_suscription->get_status() ? '&mdash;' : esc_html(getpaid_format_date_value($_suscription->get_date_created()));
839 839
 									break;
840 840
 
841 841
 								case 'subscription':
842
-										$url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url();
842
+										$url = is_admin() ? admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($_suscription->get_id())) : $_suscription->get_view_url();
843 843
 										printf(
844 844
                                             '%1$s#%2$s%3$s',
845
-                                            '<a href="' . esc_url( $url ) . '">',
846
-                                            '<strong>' . intval( $_suscription->get_id() ) . '</strong>',
845
+                                            '<a href="' . esc_url($url) . '">',
846
+                                            '<strong>' . intval($_suscription->get_id()) . '</strong>',
847 847
 											'</a>'
848 848
                                         );
849 849
 
850
-											echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) );
850
+											echo wp_kses_post(WPInv_Subscriptions_List_Table::column_amount($_suscription));
851 851
 									break;
852 852
 
853 853
 										}
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-mb-invoice-notes.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,38 +1,38 @@
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( ! defined( 'WPINC' ) ) {
3
+if (!defined('WPINC')) {
4 4
     exit;
5 5
 }
6 6
 
7 7
 class WPInv_Meta_Box_Notes {
8
-    public static function output( $post ) {
8
+    public static function output($post) {
9 9
         global $post;
10 10
 
11
-        $notes = wpinv_get_invoice_notes( $post->ID );
11
+        $notes = wpinv_get_invoice_notes($post->ID);
12 12
 
13 13
         echo '<ul class="invoice_notes">';
14 14
 
15
-        if ( $notes ) {
16
-            foreach ( $notes as $note ) {
17
-                wpinv_get_invoice_note_line_item( $note );
15
+        if ($notes) {
16
+            foreach ($notes as $note) {
17
+                wpinv_get_invoice_note_line_item($note);
18 18
             }
19 19
 } else {
20
-            echo '<li>' . esc_html__( 'There are no notes yet.', 'invoicing' ) . '</li>';
20
+            echo '<li>' . esc_html__('There are no notes yet.', 'invoicing') . '</li>';
21 21
         }
22 22
 
23 23
         echo '</ul>';
24 24
         ?>
25 25
         <div class="add_note">
26
-            <h4><?php esc_html_e( 'Add note', 'invoicing' ); ?></h4>
26
+            <h4><?php esc_html_e('Add note', 'invoicing'); ?></h4>
27 27
             <p>
28 28
                 <textarea type="text" name="invoice_note" id="add_invoice_note" class="input-text" cols="20" rows="5"></textarea>
29 29
             </p>
30 30
             <p>
31 31
                 <select name="invoice_note_type" id="invoice_note_type" class="regular-text">
32
-                    <option value=""><?php esc_html_e( 'Private note', 'invoicing' ); ?></option>
33
-                    <option value="customer"><?php esc_html_e( 'Note to customer', 'invoicing' ); ?></option>
32
+                    <option value=""><?php esc_html_e('Private note', 'invoicing'); ?></option>
33
+                    <option value="customer"><?php esc_html_e('Note to customer', 'invoicing'); ?></option>
34 34
                 </select>
35
-                <a href="#" class="add_note button"><?php esc_html_e( 'Add', 'invoicing' ); ?></a> <span class="description"><?php esc_html_e( 'Add a note for your reference, or add a customer note (the user will be notified).', 'invoicing' ); ?></span>
35
+                <a href="#" class="add_note button"><?php esc_html_e('Add', 'invoicing'); ?></a> <span class="description"><?php esc_html_e('Add a note for your reference, or add a customer note (the user will be notified).', 'invoicing'); ?></span>
36 36
             </p>
37 37
         </div>
38 38
         <?php
Please login to merge, or discard this patch.
includes/admin/register-settings.php 2 patches
Indentation   +299 added lines, -299 removed lines patch added patch discarded remove patch
@@ -192,13 +192,13 @@  discard block
 block discarded – undo
192 192
     $name       = isset( $option['name'] ) ? $option['name'] : '';
193 193
     $cb         = "wpinv_{$option['type']}_callback";
194 194
     $section    = "wpinv_settings_{$tab}_$section";
195
-	$is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page'];
195
+    $is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page'];
196 196
 
197
-	if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) {
198
-		$tip   = wpinv_clean( $option['desc'] );
199
-		$name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
200
-		unset( $option['desc'] );
201
-	}
197
+    if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) {
198
+        $tip   = wpinv_clean( $option['desc'] );
199
+        $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
200
+        unset( $option['desc'] );
201
+    }
202 202
 
203 203
     // Loop through all tabs.
204 204
     add_settings_field(
@@ -225,9 +225,9 @@  discard block
 block discarded – undo
225 225
             'faux'            => isset( $option['faux'] ) ? $option['faux'] : false,
226 226
             'onchange'        => isset( $option['onchange'] ) ? $option['onchange'] : '',
227 227
             'custom'          => isset( $option['custom'] ) ? $option['custom'] : '',
228
-			'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '',
229
-			'class'           => isset( $option['class'] ) ? $option['class'] : '',
230
-			'style'           => isset( $option['style'] ) ? $option['style'] : '',
228
+            'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '',
229
+            'class'           => isset( $option['class'] ) ? $option['class'] : '',
230
+            'style'           => isset( $option['style'] ) ? $option['style'] : '',
231 231
             'cols'            => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
232 232
             'rows'            => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
233 233
         )
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
  * @return array
242 242
  */
243 243
 function wpinv_get_registered_settings() {
244
-	return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
244
+    return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
245 245
 }
246 246
 
247 247
 /**
@@ -260,18 +260,18 @@  discard block
 block discarded – undo
260 260
  */
261 261
 function wpinv_settings_sanitize( $input = array() ) {
262 262
 
263
-	$wpinv_options = wpinv_get_options();
264
-	$raw_referrer  = wp_get_raw_referer();
263
+    $wpinv_options = wpinv_get_options();
264
+    $raw_referrer  = wp_get_raw_referer();
265 265
 
266 266
     if ( empty( $raw_referrer ) ) {
267
-		return array_merge( $wpinv_options, $input );
267
+        return array_merge( $wpinv_options, $input );
268 268
     }
269 269
 
270 270
     wp_parse_str( $raw_referrer, $referrer );
271 271
 
272
-	if ( in_array( 'gp-setup', $referrer ) ) {
273
-		return array_merge( $wpinv_options, $input );
274
-	}
272
+    if ( in_array( 'gp-setup', $referrer ) ) {
273
+        return array_merge( $wpinv_options, $input );
274
+    }
275 275
 
276 276
     $settings = wpinv_get_registered_settings();
277 277
     $tab      = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
@@ -293,10 +293,10 @@  discard block
 block discarded – undo
293 293
         }
294 294
 
295 295
         // General filter
296
-		$input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
296
+        $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
297 297
 
298
-		// Key specific filter.
299
-		$input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
298
+        // Key specific filter.
299
+        $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
300 300
     }
301 301
 
302 302
     // Loop through the whitelist and unset any that are empty for the tab being saved
@@ -339,14 +339,14 @@  discard block
 block discarded – undo
339 339
 
340 340
     foreach ( $new_rates as $rate ) {
341 341
 
342
-		$rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
343
-		$rate['name']    = sanitize_text_field( $rate['name'] );
344
-		$rate['state']   = sanitize_text_field( $rate['state'] );
345
-		$rate['country'] = sanitize_text_field( $rate['country'] );
346
-		$rate['global']  = empty( $rate['state'] );
347
-		$tax_rates[]     = $rate;
342
+        $rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
343
+        $rate['name']    = sanitize_text_field( $rate['name'] );
344
+        $rate['state']   = sanitize_text_field( $rate['state'] );
345
+        $rate['country'] = sanitize_text_field( $rate['country'] );
346
+        $rate['global']  = empty( $rate['state'] );
347
+        $tax_rates[]     = $rate;
348 348
 
349
-	}
349
+    }
350 350
 
351 351
     update_option( 'wpinv_tax_rates', $tax_rates );
352 352
 
@@ -359,11 +359,11 @@  discard block
 block discarded – undo
359 359
     $tabs['general']  = __( 'General', 'invoicing' );
360 360
     $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
361 361
     $tabs['taxes']    = __( 'Taxes', 'invoicing' );
362
-	$tabs['emails']   = __( 'Emails', 'invoicing' );
362
+    $tabs['emails']   = __( 'Emails', 'invoicing' );
363 363
 
364
-	if ( count( getpaid_get_integration_settings() ) > 0 ) {
365
-		$tabs['integrations'] = __( 'Integrations', 'invoicing' );
366
-	}
364
+    if ( count( getpaid_get_integration_settings() ) > 0 ) {
365
+        $tabs['integrations'] = __( 'Integrations', 'invoicing' );
366
+    }
367 367
 
368 368
     $tabs['privacy']  = __( 'Privacy', 'invoicing' );
369 369
     $tabs['misc']     = __( 'Misc', 'invoicing' );
@@ -394,52 +394,52 @@  discard block
 block discarded – undo
394 394
         'general'      => apply_filters(
395 395
             'wpinv_settings_sections_general',
396 396
             array(
397
-				'main'             => __( 'General Settings', 'invoicing' ),
398
-				'page_section'     => __( 'Page Settings', 'invoicing' ),
399
-				'currency_section' => __( 'Currency Settings', 'invoicing' ),
400
-				'labels'           => __( 'Label Texts', 'invoicing' ),
397
+                'main'             => __( 'General Settings', 'invoicing' ),
398
+                'page_section'     => __( 'Page Settings', 'invoicing' ),
399
+                'currency_section' => __( 'Currency Settings', 'invoicing' ),
400
+                'labels'           => __( 'Label Texts', 'invoicing' ),
401 401
             )
402 402
         ),
403 403
         'gateways'     => apply_filters(
404 404
             'wpinv_settings_sections_gateways',
405 405
             array(
406
-				'main' => __( 'Gateway Settings', 'invoicing' ),
406
+                'main' => __( 'Gateway Settings', 'invoicing' ),
407 407
             )
408 408
         ),
409 409
         'taxes'        => apply_filters(
410 410
             'wpinv_settings_sections_taxes',
411 411
             array(
412
-				'main'  => __( 'Tax Settings', 'invoicing' ),
413
-				'rates' => __( 'Tax Rates', 'invoicing' ),
414
-				'vat'   => __( 'EU VAT Settings', 'invoicing' ),
412
+                'main'  => __( 'Tax Settings', 'invoicing' ),
413
+                'rates' => __( 'Tax Rates', 'invoicing' ),
414
+                'vat'   => __( 'EU VAT Settings', 'invoicing' ),
415 415
             )
416 416
         ),
417 417
         'emails'       => apply_filters(
418 418
             'wpinv_settings_sections_emails',
419 419
             array(
420
-				'main' => __( 'Email Settings', 'invoicing' ),
420
+                'main' => __( 'Email Settings', 'invoicing' ),
421 421
             )
422 422
         ),
423 423
 
424
-		'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
424
+        'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
425 425
 
426 426
         'privacy'      => apply_filters(
427 427
             'wpinv_settings_sections_privacy',
428 428
             array(
429
-				'main' => __( 'Privacy policy', 'invoicing' ),
429
+                'main' => __( 'Privacy policy', 'invoicing' ),
430 430
             )
431 431
         ),
432 432
         'misc'         => apply_filters(
433 433
             'wpinv_settings_sections_misc',
434 434
             array(
435
-				'main'       => __( 'Miscellaneous', 'invoicing' ),
436
-				'custom-css' => __( 'Custom CSS', 'invoicing' ),
435
+                'main'       => __( 'Miscellaneous', 'invoicing' ),
436
+                'custom-css' => __( 'Custom CSS', 'invoicing' ),
437 437
             )
438 438
         ),
439 439
         'tools'        => apply_filters(
440 440
             'wpinv_settings_sections_tools',
441 441
             array(
442
-				'main' => __( 'Diagnostic Tools', 'invoicing' ),
442
+                'main' => __( 'Diagnostic Tools', 'invoicing' ),
443 443
             )
444 444
         ),
445 445
     );
@@ -450,46 +450,46 @@  discard block
 block discarded – undo
450 450
 }
451 451
 
452 452
 function wpinv_get_pages( $with_slug = false, $default_label = null ) {
453
-	$pages_options = array();
453
+    $pages_options = array();
454 454
 
455
-	if ( $default_label !== null && $default_label !== false ) {
456
-		$pages_options = array( '' => $default_label ); // Blank option
457
-	}
455
+    if ( $default_label !== null && $default_label !== false ) {
456
+        $pages_options = array( '' => $default_label ); // Blank option
457
+    }
458 458
 
459
-	$pages = get_pages();
460
-	if ( $pages ) {
461
-		foreach ( $pages as $page ) {
462
-			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
459
+    $pages = get_pages();
460
+    if ( $pages ) {
461
+        foreach ( $pages as $page ) {
462
+            $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
463 463
             $pages_options[ $page->ID ] = $title;
464
-		}
465
-	}
464
+        }
465
+    }
466 466
 
467
-	return $pages_options;
467
+    return $pages_options;
468 468
 }
469 469
 
470 470
 function wpinv_header_callback( $args ) {
471
-	if ( ! empty( $args['desc'] ) ) {
471
+    if ( ! empty( $args['desc'] ) ) {
472 472
         echo wp_kses_post( $args['desc'] );
473 473
     }
474 474
 }
475 475
 
476 476
 function wpinv_hidden_callback( $args ) {
477 477
 
478
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
479
-	$value   = wpinv_get_option( $args['id'], $std );
478
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
479
+    $value   = wpinv_get_option( $args['id'], $std );
480 480
 
481
-	if ( isset( $args['set_value'] ) ) {
482
-		$value = $args['set_value'];
483
-	}
481
+    if ( isset( $args['set_value'] ) ) {
482
+        $value = $args['set_value'];
483
+    }
484 484
 
485
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
486
-		$args['readonly'] = true;
487
-		$name  = '';
488
-	} else {
489
-		$name = 'wpinv_settings[' . esc_attr( $args['id'] ) . ']';
490
-	}
485
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
486
+        $args['readonly'] = true;
487
+        $name  = '';
488
+    } else {
489
+        $name = 'wpinv_settings[' . esc_attr( $args['id'] ) . ']';
490
+    }
491 491
 
492
-	echo '<input type="hidden" id="wpinv_settings[' . esc_attr( $args['id'] ) . ']" name="' . esc_attr( $name ) . '" value="' . esc_attr( stripslashes( $value ) ) . '" />';
492
+    echo '<input type="hidden" id="wpinv_settings[' . esc_attr( $args['id'] ) . ']" name="' . esc_attr( $name ) . '" value="' . esc_attr( stripslashes( $value ) ) . '" />';
493 493
 
494 494
 }
495 495
 
@@ -498,12 +498,12 @@  discard block
 block discarded – undo
498 498
  */
499 499
 function wpinv_checkbox_callback( $args ) {
500 500
 
501
-	$std = isset( $args['std'] ) ? $args['std'] : '';
502
-	$std = wpinv_get_option( $args['id'], $std );
503
-	$id  = esc_attr( $args['id'] );
501
+    $std = isset( $args['std'] ) ? $args['std'] : '';
502
+    $std = wpinv_get_option( $args['id'], $std );
503
+    $id  = esc_attr( $args['id'] );
504 504
 
505
-	getpaid_hidden_field( "wpinv_settings[$id]", '0' );
506
-	?>
505
+    getpaid_hidden_field( "wpinv_settings[$id]", '0' );
506
+    ?>
507 507
 		<fieldset>
508 508
 			<label>
509 509
 				<input id="wpinv-settings-<?php echo esc_attr( $id ); ?>" name="wpinv_settings[<?php echo esc_attr( $id ); ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox">
@@ -515,75 +515,75 @@  discard block
 block discarded – undo
515 515
 
516 516
 function wpinv_multicheck_callback( $args ) {
517 517
 
518
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
519
-	$class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
518
+    $sanitize_id = wpinv_sanitize_key( $args['id'] );
519
+    $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
520 520
 
521
-	if ( ! empty( $args['options'] ) ) {
521
+    if ( ! empty( $args['options'] ) ) {
522 522
 
523
-		$std     = isset( $args['std'] ) ? $args['std'] : array();
524
-		$value   = wpinv_get_option( $args['id'], $std );
523
+        $std     = isset( $args['std'] ) ? $args['std'] : array();
524
+        $value   = wpinv_get_option( $args['id'], $std );
525 525
 
526
-		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr( $sanitize_id . $class ) . '">';
526
+        echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr( $sanitize_id . $class ) . '">';
527 527
         foreach ( $args['options'] as $key => $option ) :
528
-			$sanitize_key = esc_attr( wpinv_sanitize_key( $key ) );
529
-			if ( in_array( $sanitize_key, $value ) ) {
530
-				$enabled = $sanitize_key;
531
-			} else {
532
-				$enabled = null;
533
-			}
534
-			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
535
-			echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']">' . wp_kses_post( $option ) . '</label></div>';
536
-		endforeach;
537
-		echo '</div>';
538
-		echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
539
-	}
528
+            $sanitize_key = esc_attr( wpinv_sanitize_key( $key ) );
529
+            if ( in_array( $sanitize_key, $value ) ) {
530
+                $enabled = $sanitize_key;
531
+            } else {
532
+                $enabled = null;
533
+            }
534
+            echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
535
+            echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']">' . wp_kses_post( $option ) . '</label></div>';
536
+        endforeach;
537
+        echo '</div>';
538
+        echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
539
+    }
540 540
 }
541 541
 
542 542
 function wpinv_payment_icons_callback( $args ) {
543 543
 
544 544
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
545
-	$value   = wpinv_get_option( $args['id'], false );
545
+    $value   = wpinv_get_option( $args['id'], false );
546 546
 
547
-	if ( ! empty( $args['options'] ) ) {
548
-		foreach ( $args['options'] as $key => $option ) {
547
+    if ( ! empty( $args['options'] ) ) {
548
+        foreach ( $args['options'] as $key => $option ) {
549 549
             $sanitize_key = wpinv_sanitize_key( $key );
550 550
 
551
-			if ( empty( $value ) ) {
552
-				$enabled = $option;
553
-			} else {
554
-				$enabled = null;
555
-			}
556
-
557
-			echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
558
-
559
-				echo '<input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
560
-
561
-				if ( wpinv_string_is_image_url( $key ) ) {
562
-				echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
563
-				} else {
564
-				$card = strtolower( str_replace( ' ', '', $option ) );
565
-
566
-				if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
567
-					$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
568
-					} else {
569
-					$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
570
-					$content_dir = WP_CONTENT_DIR;
571
-
572
-					if ( function_exists( 'wp_normalize_path' ) ) {
573
-						// Replaces backslashes with forward slashes for Windows systems
574
-						$image = wp_normalize_path( $image );
575
-						$content_dir = wp_normalize_path( $content_dir );
576
-						}
577
-
578
-					$image = str_replace( $content_dir, content_url(), $image );
579
-					}
580
-
581
-				echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
582
-				}
583
-			echo wp_kses_post( $option ) . '</label>';
584
-		}
585
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
586
-	}
551
+            if ( empty( $value ) ) {
552
+                $enabled = $option;
553
+            } else {
554
+                $enabled = null;
555
+            }
556
+
557
+            echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
558
+
559
+                echo '<input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
560
+
561
+                if ( wpinv_string_is_image_url( $key ) ) {
562
+                echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
563
+                } else {
564
+                $card = strtolower( str_replace( ' ', '', $option ) );
565
+
566
+                if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
567
+                    $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
568
+                    } else {
569
+                    $image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
570
+                    $content_dir = WP_CONTENT_DIR;
571
+
572
+                    if ( function_exists( 'wp_normalize_path' ) ) {
573
+                        // Replaces backslashes with forward slashes for Windows systems
574
+                        $image = wp_normalize_path( $image );
575
+                        $content_dir = wp_normalize_path( $content_dir );
576
+                        }
577
+
578
+                    $image = str_replace( $content_dir, content_url(), $image );
579
+                    }
580
+
581
+                echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
582
+                }
583
+            echo wp_kses_post( $option ) . '</label>';
584
+        }
585
+        echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
586
+    }
587 587
 }
588 588
 
589 589
 /**
@@ -591,9 +591,9 @@  discard block
 block discarded – undo
591 591
  */
592 592
 function wpinv_radio_callback( $args ) {
593 593
 
594
-	$std = isset( $args['std'] ) ? $args['std'] : '';
595
-	$std = wpinv_get_option( $args['id'], $std );
596
-	?>
594
+    $std = isset( $args['std'] ) ? $args['std'] : '';
595
+    $std = wpinv_get_option( $args['id'], $std );
596
+    ?>
597 597
 		<fieldset>
598 598
 			<ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;">
599 599
 				<?php foreach ( $args['options'] as $key => $option ) : ?>
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
 			</ul>
608 608
 		</fieldset>
609 609
 	<?php
610
-	getpaid_settings_description_callback( $args );
610
+    getpaid_settings_description_callback( $args );
611 611
 }
612 612
 
613 613
 /**
@@ -615,10 +615,10 @@  discard block
 block discarded – undo
615 615
  */
616 616
 function getpaid_settings_description_callback( $args ) {
617 617
 
618
-	if ( ! empty( $args['desc'] ) ) {
619
-		$description = $args['desc'];
620
-		echo wp_kses_post( "<p class='description'>$description</p>" );
621
-	}
618
+    if ( ! empty( $args['desc'] ) ) {
619
+        $description = $args['desc'];
620
+        echo wp_kses_post( "<p class='description'>$description</p>" );
621
+    }
622 622
 
623 623
 }
624 624
 
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
  */
628 628
 function wpinv_gateways_callback() {
629 629
 
630
-	?>
630
+    ?>
631 631
 		</td>
632 632
 	</tr>
633 633
 	<tr class="bsui">
@@ -641,26 +641,26 @@  discard block
 block discarded – undo
641 641
 
642 642
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
643 643
     $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
644
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
645
-	$value   = wpinv_get_option( $args['id'], $std );
644
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
645
+    $value   = wpinv_get_option( $args['id'], $std );
646 646
 
647
-	echo '<select name="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" class="' . esc_attr( $class ) . '" >';
647
+    echo '<select name="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" class="' . esc_attr( $class ) . '" >';
648 648
 
649
-	foreach ( $args['options'] as $key => $option ) :
649
+    foreach ( $args['options'] as $key => $option ) :
650 650
 
651
-		echo '<option value="' . esc_attr( $key ) . '" ';
651
+        echo '<option value="' . esc_attr( $key ) . '" ';
652 652
 
653
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
653
+        if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
654 654
             selected( $key, $args['selected'] );
655 655
         } else {
656 656
             selected( $key, $value );
657 657
         }
658 658
 
659
-		echo '>' . esc_html( $option['admin_label'] ) . '</option>';
660
-	endforeach;
659
+        echo '>' . esc_html( $option['admin_label'] ) . '</option>';
660
+    endforeach;
661 661
 
662
-	echo '</select>';
663
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
662
+    echo '</select>';
663
+    echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
664 664
 }
665 665
 
666 666
 /**
@@ -671,38 +671,38 @@  discard block
 block discarded – undo
671 671
  */
672 672
 function wpinv_settings_attrs_helper( $args ) {
673 673
 
674
-	$value = isset( $args['std'] ) ? $args['std'] : '';
675
-	$id    = esc_attr( $args['id'] );
676
-	$value = is_scalar( $value ) ? $value : '';
677
-
678
-	$attrs = array(
679
-		'name'     => ! empty( $args['faux'] ) ? false : "wpinv_settings[$id]",
680
-		'readonly' => ! empty( $args['faux'] ),
681
-		'value'    => ! empty( $args['faux'] ) ? $value : wpinv_get_option( $args['id'], $value ),
682
-		'id'       => 'wpinv-settings-' . $args['id'],
683
-		'style'    => $args['style'],
684
-		'class'    => $args['class'],
685
-		'placeholder' => $args['placeholder'],
686
-		'data-placeholder' => $args['placeholder'],
687
-	);
674
+    $value = isset( $args['std'] ) ? $args['std'] : '';
675
+    $id    = esc_attr( $args['id'] );
676
+    $value = is_scalar( $value ) ? $value : '';
677
+
678
+    $attrs = array(
679
+        'name'     => ! empty( $args['faux'] ) ? false : "wpinv_settings[$id]",
680
+        'readonly' => ! empty( $args['faux'] ),
681
+        'value'    => ! empty( $args['faux'] ) ? $value : wpinv_get_option( $args['id'], $value ),
682
+        'id'       => 'wpinv-settings-' . $args['id'],
683
+        'style'    => $args['style'],
684
+        'class'    => $args['class'],
685
+        'placeholder' => $args['placeholder'],
686
+        'data-placeholder' => $args['placeholder'],
687
+    );
688 688
 
689
-	if ( ! empty( $args['onchange'] ) ) {
690
-		$attrs['onchange'] = $args['onchange'];
691
-	}
689
+    if ( ! empty( $args['onchange'] ) ) {
690
+        $attrs['onchange'] = $args['onchange'];
691
+    }
692 692
 
693
-	foreach ( $attrs as $key => $value ) {
693
+    foreach ( $attrs as $key => $value ) {
694 694
 
695
-		if ( false === $value ) {
696
-			continue;
697
-		}
695
+        if ( false === $value ) {
696
+            continue;
697
+        }
698 698
 
699
-		if ( true === $value ) {
700
-			echo ' ' . esc_attr( $key );
701
-		} else {
702
-			echo ' ' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
703
-		}
699
+        if ( true === $value ) {
700
+            echo ' ' . esc_attr( $key );
701
+        } else {
702
+            echo ' ' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
703
+        }
704 704
 
705
-	}
705
+    }
706 706
 
707 707
 }
708 708
 
@@ -711,9 +711,9 @@  discard block
 block discarded – undo
711 711
  */
712 712
 function wpinv_text_callback( $args ) {
713 713
 
714
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
714
+    $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
715 715
 
716
-	?>
716
+    ?>
717 717
 		<label style="width: 100%;">
718 718
 			<input type="text" <?php wpinv_settings_attrs_helper( $args ); ?>>
719 719
 			<?php echo wp_kses_post( $desc ); ?>
@@ -727,9 +727,9 @@  discard block
 block discarded – undo
727 727
  */
728 728
 function wpinv_number_callback( $args ) {
729 729
 
730
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
730
+    $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
731 731
 
732
-	?>
732
+    ?>
733 733
 		<label style="width: 100%;">
734 734
 			<input type="number" step="<?php echo floatval( $args['step'] ); ?>" max="<?php echo intval( $args['max'] ); ?>" min="<?php echo intval( $args['min'] ); ?>" <?php wpinv_settings_attrs_helper( $args ); ?>>
735 735
 			<?php echo wp_kses_post( $desc ); ?>
@@ -741,34 +741,34 @@  discard block
 block discarded – undo
741 741
 function wpinv_textarea_callback( $args ) {
742 742
 
743 743
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
744
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
745
-	$value   = wpinv_get_option( $args['id'], $std );
744
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
745
+    $value   = wpinv_get_option( $args['id'], $std );
746 746
 
747 747
     $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
748 748
     $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
749 749
 
750
-	echo '<textarea class="' . esc_attr( $class ) . ' txtarea-' . esc_attr( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . esc_attr( $args['cols'] ) . '" rows="' . esc_attr( $args['rows'] ) . '" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
751
-	echo '<br /><label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
750
+    echo '<textarea class="' . esc_attr( $class ) . ' txtarea-' . esc_attr( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . esc_attr( $args['cols'] ) . '" rows="' . esc_attr( $args['rows'] ) . '" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
751
+    echo '<br /><label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
752 752
 
753 753
 }
754 754
 
755 755
 function wpinv_password_callback( $args ) {
756 756
 
757 757
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
758
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
759
-	$value   = wpinv_get_option( $args['id'], $std );
758
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
759
+    $value   = wpinv_get_option( $args['id'], $std );
760 760
 
761
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
762
-	echo '<input type="password" class="' . esc_attr( $size ) . '-text" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
763
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
761
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
762
+    echo '<input type="password" class="' . esc_attr( $size ) . '-text" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
763
+    echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
764 764
 
765 765
 }
766 766
 
767 767
 function wpinv_missing_callback( $args ) {
768
-	printf(
769
-		esc_html__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
770
-		'<strong>' . esc_html( $args['id'] ) . '</strong>'
771
-	);
768
+    printf(
769
+        esc_html__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
770
+        '<strong>' . esc_html( $args['id'] ) . '</strong>'
771
+    );
772 772
 }
773 773
 
774 774
 /**
@@ -776,13 +776,13 @@  discard block
 block discarded – undo
776 776
  */
777 777
 function wpinv_select_callback( $args ) {
778 778
 
779
-	$desc   = wp_kses_post( $args['desc'] );
780
-	$desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
781
-	$value  = isset( $args['std'] ) ? $args['std'] : '';
782
-	$value  = wpinv_get_option( $args['id'], $value );
783
-	$rand   = uniqid( 'random_id' );
779
+    $desc   = wp_kses_post( $args['desc'] );
780
+    $desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
781
+    $value  = isset( $args['std'] ) ? $args['std'] : '';
782
+    $value  = wpinv_get_option( $args['id'], $value );
783
+    $rand   = uniqid( 'random_id' );
784 784
 
785
-	?>
785
+    ?>
786 786
 		<label style="width: 100%;">
787 787
 			<select <?php wpinv_settings_attrs_helper( $args ); ?> data-allow-clear="true">
788 788
 				<?php foreach ( $args['options'] as $option => $name ) : ?>
@@ -815,50 +815,50 @@  discard block
 block discarded – undo
815 815
 function wpinv_color_select_callback( $args ) {
816 816
 
817 817
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
818
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
819
-	$value   = wpinv_get_option( $args['id'], $std );
818
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
819
+    $value   = wpinv_get_option( $args['id'], $std );
820 820
 
821
-	echo '<select id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
821
+    echo '<select id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
822 822
 
823
-	foreach ( $args['options'] as $option => $color ) {
824
-		echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $color['label'] ) . '</option>';
825
-	}
823
+    foreach ( $args['options'] as $option => $color ) {
824
+        echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $color['label'] ) . '</option>';
825
+    }
826 826
 
827
-	echo '</select>';
828
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
827
+    echo '</select>';
828
+    echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
829 829
 
830 830
 }
831 831
 
832 832
 function wpinv_rich_editor_callback( $args ) {
833
-	global $wp_version;
833
+    global $wp_version;
834 834
 
835 835
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
836 836
 
837
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
838
-	$value   = wpinv_get_option( $args['id'], $std );
837
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
838
+    $value   = wpinv_get_option( $args['id'], $std );
839 839
 
840
-	if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) {
841
-		$value = $std;
842
-	}
840
+    if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) {
841
+        $value = $std;
842
+    }
843 843
 
844
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
844
+    $rows = isset( $args['size'] ) ? $args['size'] : 20;
845 845
 
846
-	echo '<div class="getpaid-settings-editor-input">';
847
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
848
-		wp_editor(
846
+    echo '<div class="getpaid-settings-editor-input">';
847
+    if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
848
+        wp_editor(
849 849
             stripslashes( $value ),
850 850
             'wpinv_settings_' . esc_attr( $args['id'] ),
851 851
             array(
852
-				'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']',
853
-				'textarea_rows' => absint( $rows ),
854
-				'media_buttons' => false,
852
+                'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']',
853
+                'textarea_rows' => absint( $rows ),
854
+                'media_buttons' => false,
855 855
             )
856 856
         );
857
-	} else {
858
-		echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
859
-	}
857
+    } else {
858
+        echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
859
+    }
860 860
 
861
-	echo '</div><br/><label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
861
+    echo '</div><br/><label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
862 862
 
863 863
 }
864 864
 
@@ -866,51 +866,51 @@  discard block
 block discarded – undo
866 866
 
867 867
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
868 868
 
869
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
870
-	$value   = wpinv_get_option( $args['id'], $std );
869
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
870
+    $value   = wpinv_get_option( $args['id'], $std );
871 871
 
872
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
873
-	echo '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
874
-	echo '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . esc_attr__( 'Upload File', 'invoicing' ) . '"/></span>';
875
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
872
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
873
+    echo '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
874
+    echo '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . esc_attr__( 'Upload File', 'invoicing' ) . '"/></span>';
875
+    echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
876 876
 
877 877
 }
878 878
 
879 879
 function wpinv_color_callback( $args ) {
880 880
 
881
-	$std         = isset( $args['std'] ) ? $args['std'] : '';
882
-	$value       = wpinv_get_option( $args['id'], $std );
881
+    $std         = isset( $args['std'] ) ? $args['std'] : '';
882
+    $value       = wpinv_get_option( $args['id'], $std );
883 883
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
884 884
 
885
-	echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />';
886
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
885
+    echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />';
886
+    echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
887 887
 
888 888
 }
889 889
 
890 890
 function wpinv_country_states_callback( $args ) {
891 891
 
892
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
893
-	$value   = wpinv_get_option( $args['id'], $std );
892
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
893
+    $value   = wpinv_get_option( $args['id'], $std );
894 894
 
895 895
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
896 896
 
897
-	if ( isset( $args['placeholder'] ) ) {
898
-		$placeholder = $args['placeholder'];
899
-	} else {
900
-		$placeholder = '';
901
-	}
897
+    if ( isset( $args['placeholder'] ) ) {
898
+        $placeholder = $args['placeholder'];
899
+    } else {
900
+        $placeholder = '';
901
+    }
902 902
 
903
-	$states = wpinv_get_country_states();
903
+    $states = wpinv_get_country_states();
904 904
 
905
-	$class = empty( $states ) ? 'wpinv-no-states' : 'wpi_select2';
906
-	echo '<select id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="' . esc_attr( $class ) . '" data-placeholder="' . esc_html( $placeholder ) . '"/>';
905
+    $class = empty( $states ) ? 'wpinv-no-states' : 'wpi_select2';
906
+    echo '<select id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="' . esc_attr( $class ) . '" data-placeholder="' . esc_html( $placeholder ) . '"/>';
907 907
 
908
-	foreach ( $states as $option => $name ) {
909
-		echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $name ) . '</option>';
910
-	}
908
+    foreach ( $states as $option => $name ) {
909
+        echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $name ) . '</option>';
910
+    }
911 911
 
912
-	echo '</select>';
913
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
912
+    echo '</select>';
913
+    echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
914 914
 
915 915
 }
916 916
 
@@ -919,7 +919,7 @@  discard block
 block discarded – undo
919 919
  */
920 920
 function wpinv_tax_rates_callback() {
921 921
 
922
-	?>
922
+    ?>
923 923
 		</td>
924 924
 	</tr>
925 925
 	<tr class="bsui">
@@ -935,9 +935,9 @@  discard block
 block discarded – undo
935 935
  */
936 936
 function wpinv_tax_rate_callback( $tax_rate, $key ) {
937 937
 
938
-	$key                      = sanitize_key( $key );
939
-	$tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
940
-	include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
938
+    $key                      = sanitize_key( $key );
939
+    $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
940
+    include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
941 941
 
942 942
 }
943 943
 
@@ -969,14 +969,14 @@  discard block
 block discarded – undo
969 969
                 <td>
970 970
 					<a href="
971 971
                     <?php
972
-						echo esc_url(
973
-							wp_nonce_url(
974
-								add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
975
-								'getpaid-nonce',
976
-								'getpaid-nonce'
977
-							)
978
-						);
979
-					?>
972
+                        echo esc_url(
973
+                            wp_nonce_url(
974
+                                add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
975
+                                'getpaid-nonce',
976
+                                'getpaid-nonce'
977
+                            )
978
+                        );
979
+                    ?>
980 980
                     " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
981 981
                 </td>
982 982
             </tr>
@@ -988,14 +988,14 @@  discard block
 block discarded – undo
988 988
                 <td>
989 989
 					<a href="
990 990
                     <?php
991
-						echo esc_url(
992
-							wp_nonce_url(
993
-								add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ),
994
-								'getpaid-nonce',
995
-								'getpaid-nonce'
996
-							)
997
-						);
998
-					?>
991
+                        echo esc_url(
992
+                            wp_nonce_url(
993
+                                add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ),
994
+                                'getpaid-nonce',
995
+                                'getpaid-nonce'
996
+                            )
997
+                        );
998
+                    ?>
999 999
                     " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
1000 1000
                 </td>
1001 1001
             </tr>
@@ -1007,14 +1007,14 @@  discard block
 block discarded – undo
1007 1007
                 <td>
1008 1008
 					<a href="
1009 1009
                     <?php
1010
-						echo esc_url(
1011
-							wp_nonce_url(
1012
-								add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ),
1013
-								'getpaid-nonce',
1014
-								'getpaid-nonce'
1015
-							)
1016
-						);
1017
-					?>
1010
+                        echo esc_url(
1011
+                            wp_nonce_url(
1012
+                                add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ),
1013
+                                'getpaid-nonce',
1014
+                                'getpaid-nonce'
1015
+                            )
1016
+                        );
1017
+                    ?>
1018 1018
                     " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
1019 1019
                 </td>
1020 1020
             </tr>
@@ -1027,14 +1027,14 @@  discard block
 block discarded – undo
1027 1027
                 <td>
1028 1028
 					<a href="
1029 1029
                     <?php
1030
-						echo esc_url(
1031
-							wp_nonce_url(
1032
-								add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ),
1033
-								'getpaid-nonce',
1034
-								'getpaid-nonce'
1035
-							)
1036
-						);
1037
-					?>
1030
+                        echo esc_url(
1031
+                            wp_nonce_url(
1032
+                                add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ),
1033
+                                'getpaid-nonce',
1034
+                                'getpaid-nonce'
1035
+                            )
1036
+                        );
1037
+                    ?>
1038 1038
                     " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
1039 1039
                 </td>
1040 1040
             </tr>
@@ -1047,8 +1047,8 @@  discard block
 block discarded – undo
1047 1047
                 <td>
1048 1048
 					<a href="
1049 1049
                     <?php
1050
-						echo esc_url( admin_url( 'index.php?page=gp-setup' ) );
1051
-					?>
1050
+                        echo esc_url( admin_url( 'index.php?page=gp-setup' ) );
1051
+                    ?>
1052 1052
                     " class="button button-primary"><?php esc_html_e( 'Launch', 'invoicing' ); ?></a>
1053 1053
                 </td>
1054 1054
             </tr>
@@ -1062,19 +1062,19 @@  discard block
 block discarded – undo
1062 1062
 
1063 1063
 
1064 1064
 function wpinv_descriptive_text_callback( $args ) {
1065
-	echo wp_kses_post( $args['desc'] );
1065
+    echo wp_kses_post( $args['desc'] );
1066 1066
 }
1067 1067
 
1068 1068
 function wpinv_raw_html_callback( $args ) {
1069
-	echo wp_kses_post( $args['desc'] );
1069
+    echo wp_kses_post( $args['desc'] );
1070 1070
 }
1071 1071
 
1072 1072
 function wpinv_hook_callback( $args ) {
1073
-	do_action( 'wpinv_' . $args['id'], $args );
1073
+    do_action( 'wpinv_' . $args['id'], $args );
1074 1074
 }
1075 1075
 
1076 1076
 function wpinv_set_settings_cap() {
1077
-	return wpinv_get_capability();
1077
+    return wpinv_get_capability();
1078 1078
 }
1079 1079
 add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1080 1080
 
@@ -1098,15 +1098,15 @@  discard block
 block discarded – undo
1098 1098
  */
1099 1099
 function wpinv_get_merge_tags_help_text( $subscription = false ) {
1100 1100
 
1101
-	$url  = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f';
1102
-	$link = sprintf(
1103
-		'<strong><a href="%s" target="_blank">%s</a></strong>',
1104
-		$url,
1105
-		esc_html__( 'View available merge tags.', 'wpinv-quotes' )
1106
-	);
1101
+    $url  = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f';
1102
+    $link = sprintf(
1103
+        '<strong><a href="%s" target="_blank">%s</a></strong>',
1104
+        $url,
1105
+        esc_html__( 'View available merge tags.', 'wpinv-quotes' )
1106
+    );
1107 1107
 
1108
-	$description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' );
1108
+    $description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' );
1109 1109
 
1110
-	return "$description $link";
1110
+    return "$description $link";
1111 1111
 
1112 1112
 }
Please login to merge, or discard this patch.
Spacing   +369 added lines, -369 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @since   1.0.0
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Retrieves all default settings.
@@ -16,13 +16,13 @@  discard block
 block discarded – undo
16 16
 function wpinv_get_settings() {
17 17
     $defaults = array();
18 18
 
19
-    foreach ( array_values( wpinv_get_registered_settings() ) as $tab_settings ) {
19
+    foreach (array_values(wpinv_get_registered_settings()) as $tab_settings) {
20 20
 
21
-        foreach ( array_values( $tab_settings ) as $section_settings ) {
21
+        foreach (array_values($tab_settings) as $section_settings) {
22 22
 
23
-            foreach ( $section_settings as $key => $setting ) {
24
-                if ( isset( $setting['std'] ) ) {
25
-                    $defaults[ $key ] = $setting['std'];
23
+            foreach ($section_settings as $key => $setting) {
24
+                if (isset($setting['std'])) {
25
+                    $defaults[$key] = $setting['std'];
26 26
                 }
27 27
             }
28 28
 }
@@ -41,12 +41,12 @@  discard block
 block discarded – undo
41 41
     global $wpinv_options;
42 42
 
43 43
     // Try fetching the saved options.
44
-    if ( empty( $wpinv_options ) ) {
45
-        $wpinv_options = get_option( 'wpinv_settings' );
44
+    if (empty($wpinv_options)) {
45
+        $wpinv_options = get_option('wpinv_settings');
46 46
     }
47 47
 
48 48
     // If that fails, don't fetch the default settings to prevent a loop.
49
-    if ( ! is_array( $wpinv_options ) ) {
49
+    if (!is_array($wpinv_options)) {
50 50
         $wpinv_options = array();
51 51
     }
52 52
 
@@ -60,13 +60,13 @@  discard block
 block discarded – undo
60 60
  * @param mixed $default The default value to use if the setting has not been set.
61 61
  * @return mixed
62 62
  */
63
-function wpinv_get_option( $key = '', $default = false ) {
63
+function wpinv_get_option($key = '', $default = false) {
64 64
 
65 65
     $options = wpinv_get_options();
66
-    $value   = isset( $options[ $key ] ) ? $options[ $key ] : $default;
67
-    $value   = apply_filters( 'wpinv_get_option', $value, $key, $default );
66
+    $value   = isset($options[$key]) ? $options[$key] : $default;
67
+    $value   = apply_filters('wpinv_get_option', $value, $key, $default);
68 68
 
69
-    return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default );
69
+    return apply_filters('wpinv_get_option_' . $key, $value, $key, $default);
70 70
 }
71 71
 
72 72
 /**
@@ -75,11 +75,11 @@  discard block
 block discarded – undo
75 75
  * @param array $options the new options.
76 76
  * @return bool
77 77
  */
78
-function wpinv_update_options( $options ) {
78
+function wpinv_update_options($options) {
79 79
     global $wpinv_options;
80 80
 
81 81
     // update the option.
82
-    if ( is_array( $options ) && update_option( 'wpinv_settings', $options ) ) {
82
+    if (is_array($options) && update_option('wpinv_settings', $options)) {
83 83
         $wpinv_options = $options;
84 84
         return true;
85 85
     }
@@ -94,24 +94,24 @@  discard block
 block discarded – undo
94 94
  * @param mixed $value The setting value.
95 95
  * @return bool
96 96
  */
97
-function wpinv_update_option( $key = '', $value = false ) {
97
+function wpinv_update_option($key = '', $value = false) {
98 98
 
99 99
     // If no key, exit.
100
-    if ( empty( $key ) ) {
100
+    if (empty($key)) {
101 101
         return false;
102 102
     }
103 103
 
104 104
     // Maybe delete the option instead.
105
-    if ( is_null( $value ) ) {
106
-        return wpinv_delete_option( $key );
105
+    if (is_null($value)) {
106
+        return wpinv_delete_option($key);
107 107
     }
108 108
 
109 109
     // Prepare the new options.
110 110
     $options         = wpinv_get_options();
111
-    $options[ $key ] = apply_filters( 'wpinv_update_option', $value, $key );
111
+    $options[$key] = apply_filters('wpinv_update_option', $value, $key);
112 112
 
113 113
     // Save the new options.
114
-    return wpinv_update_options( $options );
114
+    return wpinv_update_options($options);
115 115
 
116 116
 }
117 117
 
@@ -121,18 +121,18 @@  discard block
 block discarded – undo
121 121
  * @param string $key the setting key.
122 122
  * @return bool
123 123
  */
124
-function wpinv_delete_option( $key = '' ) {
124
+function wpinv_delete_option($key = '') {
125 125
 
126 126
     // If no key, exit
127
-    if ( empty( $key ) ) {
127
+    if (empty($key)) {
128 128
         return false;
129 129
     }
130 130
 
131 131
     $options = wpinv_get_options();
132 132
 
133
-    if ( isset( $options[ $key ] ) ) {
134
-        unset( $options[ $key ] );
135
-        return wpinv_update_options( $options );
133
+    if (isset($options[$key])) {
134
+        unset($options[$key]);
135
+        return wpinv_update_options($options);
136 136
     }
137 137
 
138 138
     return true;
@@ -146,14 +146,14 @@  discard block
 block discarded – undo
146 146
 function wpinv_register_settings() {
147 147
 
148 148
     // Loop through all tabs.
149
-    foreach ( wpinv_get_registered_settings() as $tab => $sections ) {
149
+    foreach (wpinv_get_registered_settings() as $tab => $sections) {
150 150
 
151 151
         // In each tab, loop through sections.
152
-        foreach ( $sections as $section => $settings ) {
152
+        foreach ($sections as $section => $settings) {
153 153
 
154 154
             // Check for backwards compatibility
155
-            $section_tabs = wpinv_get_settings_tab_sections( $tab );
156
-            if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) {
155
+            $section_tabs = wpinv_get_settings_tab_sections($tab);
156
+            if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) {
157 157
                 $section = 'main';
158 158
                 $settings = $sections;
159 159
             }
@@ -166,18 +166,18 @@  discard block
 block discarded – undo
166 166
                 'wpinv_settings_' . $tab . '_' . $section
167 167
             );
168 168
 
169
-            foreach ( $settings as $option ) {
170
-                if ( ! empty( $option['id'] ) ) {
171
-                    wpinv_register_settings_option( $tab, $section, $option );
169
+            foreach ($settings as $option) {
170
+                if (!empty($option['id'])) {
171
+                    wpinv_register_settings_option($tab, $section, $option);
172 172
                 }
173 173
             }
174 174
 }
175 175
     }
176 176
 
177 177
     // Creates our settings in the options table.
178
-    register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' );
178
+    register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize');
179 179
 }
180
-add_action( 'admin_init', 'wpinv_register_settings' );
180
+add_action('admin_init', 'wpinv_register_settings');
181 181
 
182 182
 /**
183 183
  * Register a single settings option.
@@ -187,49 +187,49 @@  discard block
 block discarded – undo
187 187
  * @param string $option
188 188
  *
189 189
  */
190
-function wpinv_register_settings_option( $tab, $section, $option ) {
190
+function wpinv_register_settings_option($tab, $section, $option) {
191 191
 
192
-    $name       = isset( $option['name'] ) ? $option['name'] : '';
192
+    $name       = isset($option['name']) ? $option['name'] : '';
193 193
     $cb         = "wpinv_{$option['type']}_callback";
194 194
     $section    = "wpinv_settings_{$tab}_$section";
195
-	$is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page'];
195
+	$is_wizzard = is_admin() && isset($_GET['page']) && 'gp-setup' == $_GET['page'];
196 196
 
197
-	if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) {
198
-		$tip   = wpinv_clean( $option['desc'] );
197
+	if (isset($option['desc']) && (!$is_wizzard && !empty($option['help-tip']))) {
198
+		$tip   = wpinv_clean($option['desc']);
199 199
 		$name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
200
-		unset( $option['desc'] );
200
+		unset($option['desc']);
201 201
 	}
202 202
 
203 203
     // Loop through all tabs.
204 204
     add_settings_field(
205 205
         'wpinv_settings[' . $option['id'] . ']',
206 206
         $name,
207
-        function_exists( $cb ) ? $cb : 'wpinv_missing_callback',
207
+        function_exists($cb) ? $cb : 'wpinv_missing_callback',
208 208
         $section,
209 209
         $section,
210 210
         array(
211 211
             'section'         => $section,
212
-            'id'              => isset( $option['id'] ) ? $option['id'] : uniqid( 'wpinv-' ),
213
-            'desc'            => isset( $option['desc'] ) ? $option['desc'] : '',
212
+            'id'              => isset($option['id']) ? $option['id'] : uniqid('wpinv-'),
213
+            'desc'            => isset($option['desc']) ? $option['desc'] : '',
214 214
             'name'            => $name,
215
-            'size'            => isset( $option['size'] ) ? $option['size'] : null,
216
-            'options'         => isset( $option['options'] ) ? $option['options'] : '',
217
-            'selected'        => isset( $option['selected'] ) ? $option['selected'] : null,
218
-            'std'             => isset( $option['std'] ) ? $option['std'] : '',
219
-            'min'             => isset( $option['min'] ) ? $option['min'] : 0,
220
-            'max'             => isset( $option['max'] ) ? $option['max'] : 999999,
221
-            'step'            => isset( $option['step'] ) ? $option['step'] : 1,
222
-            'placeholder'     => isset( $option['placeholder'] ) ? $option['placeholder'] : null,
223
-            'allow_blank'     => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true,
224
-            'readonly'        => isset( $option['readonly'] ) ? $option['readonly'] : false,
225
-            'faux'            => isset( $option['faux'] ) ? $option['faux'] : false,
226
-            'onchange'        => isset( $option['onchange'] ) ? $option['onchange'] : '',
227
-            'custom'          => isset( $option['custom'] ) ? $option['custom'] : '',
228
-			'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '',
229
-			'class'           => isset( $option['class'] ) ? $option['class'] : '',
230
-			'style'           => isset( $option['style'] ) ? $option['style'] : '',
231
-            'cols'            => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
232
-            'rows'            => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
215
+            'size'            => isset($option['size']) ? $option['size'] : null,
216
+            'options'         => isset($option['options']) ? $option['options'] : '',
217
+            'selected'        => isset($option['selected']) ? $option['selected'] : null,
218
+            'std'             => isset($option['std']) ? $option['std'] : '',
219
+            'min'             => isset($option['min']) ? $option['min'] : 0,
220
+            'max'             => isset($option['max']) ? $option['max'] : 999999,
221
+            'step'            => isset($option['step']) ? $option['step'] : 1,
222
+            'placeholder'     => isset($option['placeholder']) ? $option['placeholder'] : null,
223
+            'allow_blank'     => isset($option['allow_blank']) ? $option['allow_blank'] : true,
224
+            'readonly'        => isset($option['readonly']) ? $option['readonly'] : false,
225
+            'faux'            => isset($option['faux']) ? $option['faux'] : false,
226
+            'onchange'        => isset($option['onchange']) ? $option['onchange'] : '',
227
+            'custom'          => isset($option['custom']) ? $option['custom'] : '',
228
+			'default_content' => isset($option['default_content']) ? $option['default_content'] : '',
229
+			'class'           => isset($option['class']) ? $option['class'] : '',
230
+			'style'           => isset($option['style']) ? $option['style'] : '',
231
+            'cols'            => isset($option['cols']) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
232
+            'rows'            => isset($option['rows']) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
233 233
         )
234 234
     );
235 235
 
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
  * @return array
242 242
  */
243 243
 function wpinv_get_registered_settings() {
244
-	return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
244
+	return array_filter(apply_filters('wpinv_registered_settings', wpinv_get_data('admin-settings')));
245 245
 }
246 246
 
247 247
 /**
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
  * @return array
251 251
  */
252 252
 function getpaid_get_integration_settings() {
253
-    return apply_filters( 'getpaid_integration_settings', array() );
253
+    return apply_filters('getpaid_integration_settings', array());
254 254
 }
255 255
 
256 256
 /**
@@ -258,126 +258,126 @@  discard block
 block discarded – undo
258 258
  *
259 259
  * @return array
260 260
  */
261
-function wpinv_settings_sanitize( $input = array() ) {
261
+function wpinv_settings_sanitize($input = array()) {
262 262
 
263 263
 	$wpinv_options = wpinv_get_options();
264 264
 	$raw_referrer  = wp_get_raw_referer();
265 265
 
266
-    if ( empty( $raw_referrer ) ) {
267
-		return array_merge( $wpinv_options, $input );
266
+    if (empty($raw_referrer)) {
267
+		return array_merge($wpinv_options, $input);
268 268
     }
269 269
 
270
-    wp_parse_str( $raw_referrer, $referrer );
270
+    wp_parse_str($raw_referrer, $referrer);
271 271
 
272
-	if ( in_array( 'gp-setup', $referrer ) ) {
273
-		return array_merge( $wpinv_options, $input );
272
+	if (in_array('gp-setup', $referrer)) {
273
+		return array_merge($wpinv_options, $input);
274 274
 	}
275 275
 
276 276
     $settings = wpinv_get_registered_settings();
277
-    $tab      = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
278
-    $section  = isset( $referrer['section'] ) ? $referrer['section'] : 'main';
277
+    $tab      = isset($referrer['tab']) ? $referrer['tab'] : 'general';
278
+    $section  = isset($referrer['section']) ? $referrer['section'] : 'main';
279 279
 
280 280
     $input = $input ? $input : array();
281
-    $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input );
282
-    $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input );
281
+    $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input);
282
+    $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input);
283 283
 
284 284
     // Loop through each setting being saved and pass it through a sanitization filter
285
-    foreach ( $input as $key => $value ) {
285
+    foreach ($input as $key => $value) {
286 286
 
287 287
         // Get the setting type (checkbox, select, etc)
288
-        $type = isset( $settings[ $tab ][ $section ][ $key ]['type'] ) ? $settings[ $tab ][ $section ][ $key ]['type'] : false;
288
+        $type = isset($settings[$tab][$section][$key]['type']) ? $settings[$tab][$section][$key]['type'] : false;
289 289
 
290
-        if ( $type ) {
290
+        if ($type) {
291 291
             // Field type specific filter
292
-            $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$type", $value, $key );
292
+            $input[$key] = apply_filters("wpinv_settings_sanitize_$type", $value, $key);
293 293
         }
294 294
 
295 295
         // General filter
296
-		$input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
296
+		$input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key);
297 297
 
298 298
 		// Key specific filter.
299
-		$input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
299
+		$input[$key] = apply_filters("wpinv_settings_sanitize_$key", $input[$key]);
300 300
     }
301 301
 
302 302
     // Loop through the whitelist and unset any that are empty for the tab being saved
303
-    $main_settings    = isset( $settings[ $tab ] ) ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections
304
-    $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array();
303
+    $main_settings    = isset($settings[$tab]) ? $settings[$tab] : array(); // Check for extensions that aren't using new sections
304
+    $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array();
305 305
 
306
-    $found_settings   = array_merge( $main_settings, $section_settings );
306
+    $found_settings   = array_merge($main_settings, $section_settings);
307 307
 
308
-    if ( ! empty( $found_settings ) ) {
309
-        foreach ( $found_settings as $key => $value ) {
308
+    if (!empty($found_settings)) {
309
+        foreach ($found_settings as $key => $value) {
310 310
 
311 311
             // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work
312
-            if ( is_numeric( $key ) ) {
312
+            if (is_numeric($key)) {
313 313
                 $key = $value['id'];
314 314
             }
315 315
 
316
-            if ( ! isset( $input[ $key ] ) && isset( $wpinv_options[ $key ] ) ) {
317
-                unset( $wpinv_options[ $key ] );
316
+            if (!isset($input[$key]) && isset($wpinv_options[$key])) {
317
+                unset($wpinv_options[$key]);
318 318
             }
319 319
         }
320 320
     }
321 321
 
322 322
     // Merge our new settings with the existing
323
-    $output = array_merge( $wpinv_options, $input );
323
+    $output = array_merge($wpinv_options, $input);
324 324
 
325
-    add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' );
325
+    add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated');
326 326
 
327 327
     return $output;
328 328
 }
329
-add_filter( 'wpinv_settings_sanitize_text', 'trim', 10, 1 );
330
-add_filter( 'wpinv_settings_sanitize_tax_rate', 'wpinv_sanitize_amount' );
329
+add_filter('wpinv_settings_sanitize_text', 'trim', 10, 1);
330
+add_filter('wpinv_settings_sanitize_tax_rate', 'wpinv_sanitize_amount');
331 331
 
332
-function wpinv_settings_sanitize_tax_rates( $input ) {
333
-    if ( ! wpinv_current_user_can_manage_invoicing() ) {
332
+function wpinv_settings_sanitize_tax_rates($input) {
333
+    if (!wpinv_current_user_can_manage_invoicing()) {
334 334
         return $input;
335 335
     }
336 336
 
337
-    $new_rates = ! empty( $_POST['tax_rates'] ) ? wp_kses_post_deep( array_values( $_POST['tax_rates'] ) ) : array();
337
+    $new_rates = !empty($_POST['tax_rates']) ? wp_kses_post_deep(array_values($_POST['tax_rates'])) : array();
338 338
     $tax_rates = array();
339 339
 
340
-    foreach ( $new_rates as $rate ) {
340
+    foreach ($new_rates as $rate) {
341 341
 
342
-		$rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
343
-		$rate['name']    = sanitize_text_field( $rate['name'] );
344
-		$rate['state']   = sanitize_text_field( $rate['state'] );
345
-		$rate['country'] = sanitize_text_field( $rate['country'] );
346
-		$rate['global']  = empty( $rate['state'] );
342
+		$rate['rate']    = wpinv_sanitize_amount($rate['rate']);
343
+		$rate['name']    = sanitize_text_field($rate['name']);
344
+		$rate['state']   = sanitize_text_field($rate['state']);
345
+		$rate['country'] = sanitize_text_field($rate['country']);
346
+		$rate['global']  = empty($rate['state']);
347 347
 		$tax_rates[]     = $rate;
348 348
 
349 349
 	}
350 350
 
351
-    update_option( 'wpinv_tax_rates', $tax_rates );
351
+    update_option('wpinv_tax_rates', $tax_rates);
352 352
 
353 353
     return $input;
354 354
 }
355
-add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' );
355
+add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates');
356 356
 
357 357
 function wpinv_get_settings_tabs() {
358 358
     $tabs             = array();
359
-    $tabs['general']  = __( 'General', 'invoicing' );
360
-    $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
361
-    $tabs['taxes']    = __( 'Taxes', 'invoicing' );
362
-	$tabs['emails']   = __( 'Emails', 'invoicing' );
359
+    $tabs['general']  = __('General', 'invoicing');
360
+    $tabs['gateways'] = __('Payment Gateways', 'invoicing');
361
+    $tabs['taxes']    = __('Taxes', 'invoicing');
362
+	$tabs['emails'] = __('Emails', 'invoicing');
363 363
 
364
-	if ( count( getpaid_get_integration_settings() ) > 0 ) {
365
-		$tabs['integrations'] = __( 'Integrations', 'invoicing' );
364
+	if (count(getpaid_get_integration_settings()) > 0) {
365
+		$tabs['integrations'] = __('Integrations', 'invoicing');
366 366
 	}
367 367
 
368
-    $tabs['privacy']  = __( 'Privacy', 'invoicing' );
369
-    $tabs['misc']     = __( 'Misc', 'invoicing' );
370
-    $tabs['tools']    = __( 'Tools', 'invoicing' );
368
+    $tabs['privacy']  = __('Privacy', 'invoicing');
369
+    $tabs['misc']     = __('Misc', 'invoicing');
370
+    $tabs['tools']    = __('Tools', 'invoicing');
371 371
 
372
-    return apply_filters( 'wpinv_settings_tabs', $tabs );
372
+    return apply_filters('wpinv_settings_tabs', $tabs);
373 373
 }
374 374
 
375
-function wpinv_get_settings_tab_sections( $tab = false ) {
375
+function wpinv_get_settings_tab_sections($tab = false) {
376 376
     $tabs     = false;
377 377
     $sections = wpinv_get_registered_settings_sections();
378 378
 
379
-    if ( $tab && ! empty( $sections[ $tab ] ) ) {
380
-        $tabs = $sections[ $tab ];
379
+    if ($tab && !empty($sections[$tab])) {
380
+        $tabs = $sections[$tab];
381 381
     }
382 382
 
383 383
     return $tabs;
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 function wpinv_get_registered_settings_sections() {
387 387
     static $sections = false;
388 388
 
389
-    if ( false !== $sections ) {
389
+    if (false !== $sections) {
390 390
         return $sections;
391 391
     }
392 392
 
@@ -394,230 +394,230 @@  discard block
 block discarded – undo
394 394
         'general'      => apply_filters(
395 395
             'wpinv_settings_sections_general',
396 396
             array(
397
-				'main'             => __( 'General Settings', 'invoicing' ),
398
-				'page_section'     => __( 'Page Settings', 'invoicing' ),
399
-				'currency_section' => __( 'Currency Settings', 'invoicing' ),
400
-				'labels'           => __( 'Label Texts', 'invoicing' ),
397
+				'main'             => __('General Settings', 'invoicing'),
398
+				'page_section'     => __('Page Settings', 'invoicing'),
399
+				'currency_section' => __('Currency Settings', 'invoicing'),
400
+				'labels'           => __('Label Texts', 'invoicing'),
401 401
             )
402 402
         ),
403 403
         'gateways'     => apply_filters(
404 404
             'wpinv_settings_sections_gateways',
405 405
             array(
406
-				'main' => __( 'Gateway Settings', 'invoicing' ),
406
+				'main' => __('Gateway Settings', 'invoicing'),
407 407
             )
408 408
         ),
409 409
         'taxes'        => apply_filters(
410 410
             'wpinv_settings_sections_taxes',
411 411
             array(
412
-				'main'  => __( 'Tax Settings', 'invoicing' ),
413
-				'rates' => __( 'Tax Rates', 'invoicing' ),
414
-				'vat'   => __( 'EU VAT Settings', 'invoicing' ),
412
+				'main'  => __('Tax Settings', 'invoicing'),
413
+				'rates' => __('Tax Rates', 'invoicing'),
414
+				'vat'   => __('EU VAT Settings', 'invoicing'),
415 415
             )
416 416
         ),
417 417
         'emails'       => apply_filters(
418 418
             'wpinv_settings_sections_emails',
419 419
             array(
420
-				'main' => __( 'Email Settings', 'invoicing' ),
420
+				'main' => __('Email Settings', 'invoicing'),
421 421
             )
422 422
         ),
423 423
 
424
-		'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
424
+		'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'label', 'id'),
425 425
 
426 426
         'privacy'      => apply_filters(
427 427
             'wpinv_settings_sections_privacy',
428 428
             array(
429
-				'main' => __( 'Privacy policy', 'invoicing' ),
429
+				'main' => __('Privacy policy', 'invoicing'),
430 430
             )
431 431
         ),
432 432
         'misc'         => apply_filters(
433 433
             'wpinv_settings_sections_misc',
434 434
             array(
435
-				'main'       => __( 'Miscellaneous', 'invoicing' ),
436
-				'custom-css' => __( 'Custom CSS', 'invoicing' ),
435
+				'main'       => __('Miscellaneous', 'invoicing'),
436
+				'custom-css' => __('Custom CSS', 'invoicing'),
437 437
             )
438 438
         ),
439 439
         'tools'        => apply_filters(
440 440
             'wpinv_settings_sections_tools',
441 441
             array(
442
-				'main' => __( 'Diagnostic Tools', 'invoicing' ),
442
+				'main' => __('Diagnostic Tools', 'invoicing'),
443 443
             )
444 444
         ),
445 445
     );
446 446
 
447
-    $sections = apply_filters( 'wpinv_settings_sections', $sections );
447
+    $sections = apply_filters('wpinv_settings_sections', $sections);
448 448
 
449 449
     return $sections;
450 450
 }
451 451
 
452
-function wpinv_get_pages( $with_slug = false, $default_label = null ) {
452
+function wpinv_get_pages($with_slug = false, $default_label = null) {
453 453
 	$pages_options = array();
454 454
 
455
-	if ( $default_label !== null && $default_label !== false ) {
456
-		$pages_options = array( '' => $default_label ); // Blank option
455
+	if ($default_label !== null && $default_label !== false) {
456
+		$pages_options = array('' => $default_label); // Blank option
457 457
 	}
458 458
 
459 459
 	$pages = get_pages();
460
-	if ( $pages ) {
461
-		foreach ( $pages as $page ) {
460
+	if ($pages) {
461
+		foreach ($pages as $page) {
462 462
 			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
463
-            $pages_options[ $page->ID ] = $title;
463
+            $pages_options[$page->ID] = $title;
464 464
 		}
465 465
 	}
466 466
 
467 467
 	return $pages_options;
468 468
 }
469 469
 
470
-function wpinv_header_callback( $args ) {
471
-	if ( ! empty( $args['desc'] ) ) {
472
-        echo wp_kses_post( $args['desc'] );
470
+function wpinv_header_callback($args) {
471
+	if (!empty($args['desc'])) {
472
+        echo wp_kses_post($args['desc']);
473 473
     }
474 474
 }
475 475
 
476
-function wpinv_hidden_callback( $args ) {
476
+function wpinv_hidden_callback($args) {
477 477
 
478
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
479
-	$value   = wpinv_get_option( $args['id'], $std );
478
+	$std     = isset($args['std']) ? $args['std'] : '';
479
+	$value   = wpinv_get_option($args['id'], $std);
480 480
 
481
-	if ( isset( $args['set_value'] ) ) {
481
+	if (isset($args['set_value'])) {
482 482
 		$value = $args['set_value'];
483 483
 	}
484 484
 
485
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
485
+	if (isset($args['faux']) && true === $args['faux']) {
486 486
 		$args['readonly'] = true;
487
-		$name  = '';
487
+		$name = '';
488 488
 	} else {
489
-		$name = 'wpinv_settings[' . esc_attr( $args['id'] ) . ']';
489
+		$name = 'wpinv_settings[' . esc_attr($args['id']) . ']';
490 490
 	}
491 491
 
492
-	echo '<input type="hidden" id="wpinv_settings[' . esc_attr( $args['id'] ) . ']" name="' . esc_attr( $name ) . '" value="' . esc_attr( stripslashes( $value ) ) . '" />';
492
+	echo '<input type="hidden" id="wpinv_settings[' . esc_attr($args['id']) . ']" name="' . esc_attr($name) . '" value="' . esc_attr(stripslashes($value)) . '" />';
493 493
 
494 494
 }
495 495
 
496 496
 /**
497 497
  * Displays a checkbox settings callback.
498 498
  */
499
-function wpinv_checkbox_callback( $args ) {
499
+function wpinv_checkbox_callback($args) {
500 500
 
501
-	$std = isset( $args['std'] ) ? $args['std'] : '';
502
-	$std = wpinv_get_option( $args['id'], $std );
503
-	$id  = esc_attr( $args['id'] );
501
+	$std = isset($args['std']) ? $args['std'] : '';
502
+	$std = wpinv_get_option($args['id'], $std);
503
+	$id  = esc_attr($args['id']);
504 504
 
505
-	getpaid_hidden_field( "wpinv_settings[$id]", '0' );
505
+	getpaid_hidden_field("wpinv_settings[$id]", '0');
506 506
 	?>
507 507
 		<fieldset>
508 508
 			<label>
509
-				<input id="wpinv-settings-<?php echo esc_attr( $id ); ?>" name="wpinv_settings[<?php echo esc_attr( $id ); ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox">
510
-				<?php echo wp_kses_post( $args['desc'] ); ?>
509
+				<input id="wpinv-settings-<?php echo esc_attr($id); ?>" name="wpinv_settings[<?php echo esc_attr($id); ?>]" <?php checked(empty($std), false); ?> value="1" type="checkbox">
510
+				<?php echo wp_kses_post($args['desc']); ?>
511 511
 			</label>
512 512
 		</fieldset>
513 513
 	<?php
514 514
 }
515 515
 
516
-function wpinv_multicheck_callback( $args ) {
516
+function wpinv_multicheck_callback($args) {
517 517
 
518
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
519
-	$class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
518
+	$sanitize_id = wpinv_sanitize_key($args['id']);
519
+	$class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
520 520
 
521
-	if ( ! empty( $args['options'] ) ) {
521
+	if (!empty($args['options'])) {
522 522
 
523
-		$std     = isset( $args['std'] ) ? $args['std'] : array();
524
-		$value   = wpinv_get_option( $args['id'], $std );
523
+		$std     = isset($args['std']) ? $args['std'] : array();
524
+		$value   = wpinv_get_option($args['id'], $std);
525 525
 
526
-		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr( $sanitize_id . $class ) . '">';
527
-        foreach ( $args['options'] as $key => $option ) :
528
-			$sanitize_key = esc_attr( wpinv_sanitize_key( $key ) );
529
-			if ( in_array( $sanitize_key, $value ) ) {
526
+		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr($sanitize_id . $class) . '">';
527
+        foreach ($args['options'] as $key => $option) :
528
+			$sanitize_key = esc_attr(wpinv_sanitize_key($key));
529
+			if (in_array($sanitize_key, $value)) {
530 530
 				$enabled = $sanitize_key;
531 531
 			} else {
532 532
 				$enabled = null;
533 533
 			}
534
-			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
535
-			echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']">' . wp_kses_post( $option ) . '</label></div>';
534
+			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" id="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/>&nbsp;';
535
+			echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']">' . wp_kses_post($option) . '</label></div>';
536 536
 		endforeach;
537 537
 		echo '</div>';
538
-		echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
538
+		echo '<p class="description">' . wp_kses_post($args['desc']) . '</p>';
539 539
 	}
540 540
 }
541 541
 
542
-function wpinv_payment_icons_callback( $args ) {
542
+function wpinv_payment_icons_callback($args) {
543 543
 
544
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
545
-	$value   = wpinv_get_option( $args['id'], false );
544
+    $sanitize_id = wpinv_sanitize_key($args['id']);
545
+	$value = wpinv_get_option($args['id'], false);
546 546
 
547
-	if ( ! empty( $args['options'] ) ) {
548
-		foreach ( $args['options'] as $key => $option ) {
549
-            $sanitize_key = wpinv_sanitize_key( $key );
547
+	if (!empty($args['options'])) {
548
+		foreach ($args['options'] as $key => $option) {
549
+            $sanitize_key = wpinv_sanitize_key($key);
550 550
 
551
-			if ( empty( $value ) ) {
551
+			if (empty($value)) {
552 552
 				$enabled = $option;
553 553
 			} else {
554 554
 				$enabled = null;
555 555
 			}
556 556
 
557
-			echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
557
+			echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
558 558
 
559
-				echo '<input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
559
+				echo '<input name="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" id="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/>&nbsp;';
560 560
 
561
-				if ( wpinv_string_is_image_url( $key ) ) {
562
-				echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
561
+				if (wpinv_string_is_image_url($key)) {
562
+				echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
563 563
 				} else {
564
-				$card = strtolower( str_replace( ' ', '', $option ) );
564
+				$card = strtolower(str_replace(' ', '', $option));
565 565
 
566
-				if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
567
-					$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
566
+				if (has_filter('wpinv_accepted_payment_' . $card . '_image')) {
567
+					$image = apply_filters('wpinv_accepted_payment_' . $card . '_image', '');
568 568
 					} else {
569
-					$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
569
+					$image       = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false);
570 570
 					$content_dir = WP_CONTENT_DIR;
571 571
 
572
-					if ( function_exists( 'wp_normalize_path' ) ) {
572
+					if (function_exists('wp_normalize_path')) {
573 573
 						// Replaces backslashes with forward slashes for Windows systems
574
-						$image = wp_normalize_path( $image );
575
-						$content_dir = wp_normalize_path( $content_dir );
574
+						$image = wp_normalize_path($image);
575
+						$content_dir = wp_normalize_path($content_dir);
576 576
 						}
577 577
 
578
-					$image = str_replace( $content_dir, content_url(), $image );
578
+					$image = str_replace($content_dir, content_url(), $image);
579 579
 					}
580 580
 
581
-				echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
581
+				echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
582 582
 				}
583
-			echo wp_kses_post( $option ) . '</label>';
583
+			echo wp_kses_post($option) . '</label>';
584 584
 		}
585
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
585
+		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>';
586 586
 	}
587 587
 }
588 588
 
589 589
 /**
590 590
  * Displays a radio settings field.
591 591
  */
592
-function wpinv_radio_callback( $args ) {
592
+function wpinv_radio_callback($args) {
593 593
 
594
-	$std = isset( $args['std'] ) ? $args['std'] : '';
595
-	$std = wpinv_get_option( $args['id'], $std );
594
+	$std = isset($args['std']) ? $args['std'] : '';
595
+	$std = wpinv_get_option($args['id'], $std);
596 596
 	?>
597 597
 		<fieldset>
598
-			<ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;">
599
-				<?php foreach ( $args['options'] as $key => $option ) : ?>
598
+			<ul id="wpinv-settings-<?php echo esc_attr($args['id']); ?>" style="margin-top: 0;">
599
+				<?php foreach ($args['options'] as $key => $option) : ?>
600 600
 					<li>
601 601
 						<label>
602
-							<input name="wpinv_settings[<?php echo esc_attr( $args['id'] ); ?>]" <?php checked( $std, $key ); ?> value="<?php echo esc_attr( $key ); ?>" type="radio">
603
-							<?php echo wp_kses_post( $option ); ?>
602
+							<input name="wpinv_settings[<?php echo esc_attr($args['id']); ?>]" <?php checked($std, $key); ?> value="<?php echo esc_attr($key); ?>" type="radio">
603
+							<?php echo wp_kses_post($option); ?>
604 604
 						</label>
605 605
 					</li>
606 606
 				<?php endforeach; ?>
607 607
 			</ul>
608 608
 		</fieldset>
609 609
 	<?php
610
-	getpaid_settings_description_callback( $args );
610
+	getpaid_settings_description_callback($args);
611 611
 }
612 612
 
613 613
 /**
614 614
  * Displays a description if available.
615 615
  */
616
-function getpaid_settings_description_callback( $args ) {
616
+function getpaid_settings_description_callback($args) {
617 617
 
618
-	if ( ! empty( $args['desc'] ) ) {
618
+	if (!empty($args['desc'])) {
619 619
 		$description = $args['desc'];
620
-		echo wp_kses_post( "<p class='description'>$description</p>" );
620
+		echo wp_kses_post("<p class='description'>$description</p>");
621 621
 	}
622 622
 
623 623
 }
@@ -632,35 +632,35 @@  discard block
 block discarded – undo
632 632
 	</tr>
633 633
 	<tr class="bsui">
634 634
     	<td colspan="2" class="p-0">
635
-			<?php include plugin_dir_path( __FILE__ ) . 'views/html-gateways-edit.php'; ?>
635
+			<?php include plugin_dir_path(__FILE__) . 'views/html-gateways-edit.php'; ?>
636 636
 
637 637
 	<?php
638 638
 }
639 639
 
640
-function wpinv_gateway_select_callback( $args ) {
640
+function wpinv_gateway_select_callback($args) {
641 641
 
642
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
643
-    $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
644
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
645
-	$value   = wpinv_get_option( $args['id'], $std );
642
+    $sanitize_id = wpinv_sanitize_key($args['id']);
643
+    $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
644
+	$std     = isset($args['std']) ? $args['std'] : '';
645
+	$value   = wpinv_get_option($args['id'], $std);
646 646
 
647
-	echo '<select name="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" class="' . esc_attr( $class ) . '" >';
647
+	echo '<select name="wpinv_settings[' . esc_attr($sanitize_id) . ']"" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" class="' . esc_attr($class) . '" >';
648 648
 
649
-	foreach ( $args['options'] as $key => $option ) :
649
+	foreach ($args['options'] as $key => $option) :
650 650
 
651
-		echo '<option value="' . esc_attr( $key ) . '" ';
651
+		echo '<option value="' . esc_attr($key) . '" ';
652 652
 
653
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
654
-            selected( $key, $args['selected'] );
653
+		if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) {
654
+            selected($key, $args['selected']);
655 655
         } else {
656
-            selected( $key, $value );
656
+            selected($key, $value);
657 657
         }
658 658
 
659
-		echo '>' . esc_html( $option['admin_label'] ) . '</option>';
659
+		echo '>' . esc_html($option['admin_label']) . '</option>';
660 660
 	endforeach;
661 661
 
662 662
 	echo '</select>';
663
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
663
+	echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>';
664 664
 }
665 665
 
666 666
 /**
@@ -669,16 +669,16 @@  discard block
 block discarded – undo
669 669
  * @param array $args
670 670
  * @return string
671 671
  */
672
-function wpinv_settings_attrs_helper( $args ) {
672
+function wpinv_settings_attrs_helper($args) {
673 673
 
674
-	$value = isset( $args['std'] ) ? $args['std'] : '';
675
-	$id    = esc_attr( $args['id'] );
676
-	$value = is_scalar( $value ) ? $value : '';
674
+	$value = isset($args['std']) ? $args['std'] : '';
675
+	$id    = esc_attr($args['id']);
676
+	$value = is_scalar($value) ? $value : '';
677 677
 
678 678
 	$attrs = array(
679
-		'name'     => ! empty( $args['faux'] ) ? false : "wpinv_settings[$id]",
680
-		'readonly' => ! empty( $args['faux'] ),
681
-		'value'    => ! empty( $args['faux'] ) ? $value : wpinv_get_option( $args['id'], $value ),
679
+		'name'     => !empty($args['faux']) ? false : "wpinv_settings[$id]",
680
+		'readonly' => !empty($args['faux']),
681
+		'value'    => !empty($args['faux']) ? $value : wpinv_get_option($args['id'], $value),
682 682
 		'id'       => 'wpinv-settings-' . $args['id'],
683 683
 		'style'    => $args['style'],
684 684
 		'class'    => $args['class'],
@@ -686,20 +686,20 @@  discard block
 block discarded – undo
686 686
 		'data-placeholder' => $args['placeholder'],
687 687
 	);
688 688
 
689
-	if ( ! empty( $args['onchange'] ) ) {
689
+	if (!empty($args['onchange'])) {
690 690
 		$attrs['onchange'] = $args['onchange'];
691 691
 	}
692 692
 
693
-	foreach ( $attrs as $key => $value ) {
693
+	foreach ($attrs as $key => $value) {
694 694
 
695
-		if ( false === $value ) {
695
+		if (false === $value) {
696 696
 			continue;
697 697
 		}
698 698
 
699
-		if ( true === $value ) {
700
-			echo ' ' . esc_attr( $key );
699
+		if (true === $value) {
700
+			echo ' ' . esc_attr($key);
701 701
 		} else {
702
-			echo ' ' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
702
+			echo ' ' . esc_attr($key) . '="' . esc_attr($value) . '"';
703 703
 		}
704 704
 
705 705
 	}
@@ -709,14 +709,14 @@  discard block
 block discarded – undo
709 709
 /**
710 710
  * Displays a text input settings callback.
711 711
  */
712
-function wpinv_text_callback( $args ) {
712
+function wpinv_text_callback($args) {
713 713
 
714
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
714
+	$desc = empty($desc) ? '' : "<p class='description'>$desc</p>";
715 715
 
716 716
 	?>
717 717
 		<label style="width: 100%;">
718
-			<input type="text" <?php wpinv_settings_attrs_helper( $args ); ?>>
719
-			<?php echo wp_kses_post( $desc ); ?>
718
+			<input type="text" <?php wpinv_settings_attrs_helper($args); ?>>
719
+			<?php echo wp_kses_post($desc); ?>
720 720
 		</label>
721 721
 	<?php
722 722
 
@@ -725,176 +725,176 @@  discard block
 block discarded – undo
725 725
 /**
726 726
  * Displays a number input settings callback.
727 727
  */
728
-function wpinv_number_callback( $args ) {
728
+function wpinv_number_callback($args) {
729 729
 
730
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
730
+	$desc = empty($desc) ? '' : "<p class='description'>$desc</p>";
731 731
 
732 732
 	?>
733 733
 		<label style="width: 100%;">
734
-			<input type="number" step="<?php echo floatval( $args['step'] ); ?>" max="<?php echo intval( $args['max'] ); ?>" min="<?php echo intval( $args['min'] ); ?>" <?php wpinv_settings_attrs_helper( $args ); ?>>
735
-			<?php echo wp_kses_post( $desc ); ?>
734
+			<input type="number" step="<?php echo floatval($args['step']); ?>" max="<?php echo intval($args['max']); ?>" min="<?php echo intval($args['min']); ?>" <?php wpinv_settings_attrs_helper($args); ?>>
735
+			<?php echo wp_kses_post($desc); ?>
736 736
 		</label>
737 737
 	<?php
738 738
 
739 739
 }
740 740
 
741
-function wpinv_textarea_callback( $args ) {
741
+function wpinv_textarea_callback($args) {
742 742
 
743
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
744
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
745
-	$value   = wpinv_get_option( $args['id'], $std );
743
+    $sanitize_id = wpinv_sanitize_key($args['id']);
744
+	$std     = isset($args['std']) ? $args['std'] : '';
745
+	$value   = wpinv_get_option($args['id'], $std);
746 746
 
747
-    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
748
-    $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
747
+    $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
748
+    $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text';
749 749
 
750
-	echo '<textarea class="' . esc_attr( $class ) . ' txtarea-' . esc_attr( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . esc_attr( $args['cols'] ) . '" rows="' . esc_attr( $args['rows'] ) . '" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
751
-	echo '<br /><label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
750
+	echo '<textarea class="' . esc_attr($class) . ' txtarea-' . esc_attr($size) . ' wpi-' . esc_attr(sanitize_html_class($sanitize_id)) . ' " cols="' . esc_attr($args['cols']) . '" rows="' . esc_attr($args['rows']) . '" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']">' . esc_textarea(stripslashes($value)) . '</textarea>';
751
+	echo '<br /><label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>';
752 752
 
753 753
 }
754 754
 
755
-function wpinv_password_callback( $args ) {
755
+function wpinv_password_callback($args) {
756 756
 
757
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
758
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
759
-	$value   = wpinv_get_option( $args['id'], $std );
757
+    $sanitize_id = wpinv_sanitize_key($args['id']);
758
+	$std     = isset($args['std']) ? $args['std'] : '';
759
+	$value   = wpinv_get_option($args['id'], $std);
760 760
 
761
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
762
-	echo '<input type="password" class="' . esc_attr( $size ) . '-text" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
763
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
761
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
762
+	echo '<input type="password" class="' . esc_attr($size) . '-text" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '"/>';
763
+	echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>';
764 764
 
765 765
 }
766 766
 
767
-function wpinv_missing_callback( $args ) {
767
+function wpinv_missing_callback($args) {
768 768
 	printf(
769
-		esc_html__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
770
-		'<strong>' . esc_html( $args['id'] ) . '</strong>'
769
+		esc_html__('The callback function used for the %s setting is missing.', 'invoicing'),
770
+		'<strong>' . esc_html($args['id']) . '</strong>'
771 771
 	);
772 772
 }
773 773
 
774 774
 /**
775 775
  * Displays a number input settings callback.
776 776
  */
777
-function wpinv_select_callback( $args ) {
777
+function wpinv_select_callback($args) {
778 778
 
779
-	$desc   = wp_kses_post( $args['desc'] );
780
-	$desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
781
-	$value  = isset( $args['std'] ) ? $args['std'] : '';
782
-	$value  = wpinv_get_option( $args['id'], $value );
783
-	$rand   = uniqid( 'random_id' );
779
+	$desc   = wp_kses_post($args['desc']);
780
+	$desc   = empty($desc) ? '' : "<p class='description'>$desc</p>";
781
+	$value  = isset($args['std']) ? $args['std'] : '';
782
+	$value  = wpinv_get_option($args['id'], $value);
783
+	$rand   = uniqid('random_id');
784 784
 
785 785
 	?>
786 786
 		<label style="width: 100%;">
787
-			<select <?php wpinv_settings_attrs_helper( $args ); ?> data-allow-clear="true">
788
-				<?php foreach ( $args['options'] as $option => $name ) : ?>
789
-					<option value="<?php echo esc_attr( $option ); ?>" <?php echo selected( $option, $value ); ?>><?php echo esc_html( $name ); ?></option>
787
+			<select <?php wpinv_settings_attrs_helper($args); ?> data-allow-clear="true">
788
+				<?php foreach ($args['options'] as $option => $name) : ?>
789
+					<option value="<?php echo esc_attr($option); ?>" <?php echo selected($option, $value); ?>><?php echo esc_html($name); ?></option>
790 790
 				<?php endforeach; ?>
791 791
 			</select>
792 792
 
793
-			<?php if ( substr( $args['id'], -5 ) === '_page' && is_numeric( $value ) ) : ?>
794
-				<a href="<?php echo esc_url( get_edit_post_link( $value ) ); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php esc_html_e( 'Edit Page', 'invoicing' ); ?></a>
793
+			<?php if (substr($args['id'], -5) === '_page' && is_numeric($value)) : ?>
794
+				<a href="<?php echo esc_url(get_edit_post_link($value)); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php esc_html_e('Edit Page', 'invoicing'); ?></a>
795 795
 			<?php endif; ?>
796 796
 
797
-			<?php if ( substr( $args['id'], -5 ) === '_page' && ! empty( $args['default_content'] ) ) : ?>
798
-				&nbsp;<a href="#TB_inline?&width=400&height=550&inlineId=<?php echo esc_attr( $rand ); ?>" class="button thickbox getpaid-page-setting-view-default"><?php esc_html_e( 'View Default Content', 'invoicing' ); ?></a>
799
-				<div id='<?php echo esc_attr( $rand ); ?>' style='display:none;'>
797
+			<?php if (substr($args['id'], -5) === '_page' && !empty($args['default_content'])) : ?>
798
+				&nbsp;<a href="#TB_inline?&width=400&height=550&inlineId=<?php echo esc_attr($rand); ?>" class="button thickbox getpaid-page-setting-view-default"><?php esc_html_e('View Default Content', 'invoicing'); ?></a>
799
+				<div id='<?php echo esc_attr($rand); ?>' style='display:none;'>
800 800
 					<div>
801
-						<h3><?php esc_html_e( 'Original Content', 'invoicing' ); ?></h3>
802
-						<textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo wp_kses_post( gepaid_trim_lines( $args['default_content'] ) ); ?></textarea>
803
-						<h3><?php esc_html_e( 'Current Content', 'invoicing' ); ?></h3>
804
-						<textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post( $value ); echo empty( $_post ) ? '' : wp_kses_post( gepaid_trim_lines( $_post->post_content ) ); ?></textarea>
801
+						<h3><?php esc_html_e('Original Content', 'invoicing'); ?></h3>
802
+						<textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo wp_kses_post(gepaid_trim_lines($args['default_content'])); ?></textarea>
803
+						<h3><?php esc_html_e('Current Content', 'invoicing'); ?></h3>
804
+						<textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post($value); echo empty($_post) ? '' : wp_kses_post(gepaid_trim_lines($_post->post_content)); ?></textarea>
805 805
 					</div>
806 806
 				</div>
807 807
 			<?php endif; ?>
808 808
 
809
-			<?php echo wp_kses_post( $desc ); ?>
809
+			<?php echo wp_kses_post($desc); ?>
810 810
 		</label>
811 811
 	<?php
812 812
 
813 813
 }
814 814
 
815
-function wpinv_color_select_callback( $args ) {
815
+function wpinv_color_select_callback($args) {
816 816
 
817
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
818
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
819
-	$value   = wpinv_get_option( $args['id'], $std );
817
+    $sanitize_id = wpinv_sanitize_key($args['id']);
818
+	$std     = isset($args['std']) ? $args['std'] : '';
819
+	$value   = wpinv_get_option($args['id'], $std);
820 820
 
821
-	echo '<select id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
821
+	echo '<select id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>';
822 822
 
823
-	foreach ( $args['options'] as $option => $color ) {
824
-		echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $color['label'] ) . '</option>';
823
+	foreach ($args['options'] as $option => $color) {
824
+		echo '<option value="' . esc_attr($option) . '" ' . selected($option, $value) . '>' . esc_html($color['label']) . '</option>';
825 825
 	}
826 826
 
827 827
 	echo '</select>';
828
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
828
+	echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>';
829 829
 
830 830
 }
831 831
 
832
-function wpinv_rich_editor_callback( $args ) {
832
+function wpinv_rich_editor_callback($args) {
833 833
 	global $wp_version;
834 834
 
835
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
835
+    $sanitize_id = wpinv_sanitize_key($args['id']);
836 836
 
837
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
838
-	$value   = wpinv_get_option( $args['id'], $std );
837
+	$std     = isset($args['std']) ? $args['std'] : '';
838
+	$value   = wpinv_get_option($args['id'], $std);
839 839
 
840
-	if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) {
840
+	if (!empty($args['allow_blank']) && empty($value)) {
841 841
 		$value = $std;
842 842
 	}
843 843
 
844
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
844
+	$rows = isset($args['size']) ? $args['size'] : 20;
845 845
 
846 846
 	echo '<div class="getpaid-settings-editor-input">';
847
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
847
+	if ($wp_version >= 3.3 && function_exists('wp_editor')) {
848 848
 		wp_editor(
849
-            stripslashes( $value ),
850
-            'wpinv_settings_' . esc_attr( $args['id'] ),
849
+            stripslashes($value),
850
+            'wpinv_settings_' . esc_attr($args['id']),
851 851
             array(
852
-				'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']',
853
-				'textarea_rows' => absint( $rows ),
852
+				'textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']',
853
+				'textarea_rows' => absint($rows),
854 854
 				'media_buttons' => false,
855 855
             )
856 856
         );
857 857
 	} else {
858
-		echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
858
+		echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="wpi-' . esc_attr(sanitize_html_class($args['id'])) . '">' . esc_textarea(stripslashes($value)) . '</textarea>';
859 859
 	}
860 860
 
861
-	echo '</div><br/><label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
861
+	echo '</div><br/><label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>';
862 862
 
863 863
 }
864 864
 
865
-function wpinv_upload_callback( $args ) {
865
+function wpinv_upload_callback($args) {
866 866
 
867
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
867
+    $sanitize_id = wpinv_sanitize_key($args['id']);
868 868
 
869
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
870
-	$value   = wpinv_get_option( $args['id'], $std );
869
+	$std     = isset($args['std']) ? $args['std'] : '';
870
+	$value   = wpinv_get_option($args['id'], $std);
871 871
 
872
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
873
-	echo '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
874
-	echo '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . esc_attr__( 'Upload File', 'invoicing' ) . '"/></span>';
875
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
872
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
873
+	echo '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr(stripslashes($value)) . '"/>';
874
+	echo '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . esc_attr__('Upload File', 'invoicing') . '"/></span>';
875
+	echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>';
876 876
 
877 877
 }
878 878
 
879
-function wpinv_color_callback( $args ) {
879
+function wpinv_color_callback($args) {
880 880
 
881
-	$std         = isset( $args['std'] ) ? $args['std'] : '';
882
-	$value       = wpinv_get_option( $args['id'], $std );
883
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
881
+	$std         = isset($args['std']) ? $args['std'] : '';
882
+	$value       = wpinv_get_option($args['id'], $std);
883
+    $sanitize_id = wpinv_sanitize_key($args['id']);
884 884
 
885
-	echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />';
886
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
885
+	echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '" data-default-color="' . esc_attr($std) . '" />';
886
+	echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>';
887 887
 
888 888
 }
889 889
 
890
-function wpinv_country_states_callback( $args ) {
890
+function wpinv_country_states_callback($args) {
891 891
 
892
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
893
-	$value   = wpinv_get_option( $args['id'], $std );
892
+	$std     = isset($args['std']) ? $args['std'] : '';
893
+	$value   = wpinv_get_option($args['id'], $std);
894 894
 
895
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
895
+    $sanitize_id = wpinv_sanitize_key($args['id']);
896 896
 
897
-	if ( isset( $args['placeholder'] ) ) {
897
+	if (isset($args['placeholder'])) {
898 898
 		$placeholder = $args['placeholder'];
899 899
 	} else {
900 900
 		$placeholder = '';
@@ -902,15 +902,15 @@  discard block
 block discarded – undo
902 902
 
903 903
 	$states = wpinv_get_country_states();
904 904
 
905
-	$class = empty( $states ) ? 'wpinv-no-states' : 'wpi_select2';
906
-	echo '<select id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="' . esc_attr( $class ) . '" data-placeholder="' . esc_html( $placeholder ) . '"/>';
905
+	$class = empty($states) ? 'wpinv-no-states' : 'wpi_select2';
906
+	echo '<select id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="' . esc_attr($class) . '" data-placeholder="' . esc_html($placeholder) . '"/>';
907 907
 
908
-	foreach ( $states as $option => $name ) {
909
-		echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $name ) . '</option>';
908
+	foreach ($states as $option => $name) {
909
+		echo '<option value="' . esc_attr($option) . '" ' . selected($option, $value) . '>' . esc_html($name) . '</option>';
910 910
 	}
911 911
 
912 912
 	echo '</select>';
913
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
913
+	echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>';
914 914
 
915 915
 }
916 916
 
@@ -924,7 +924,7 @@  discard block
 block discarded – undo
924 924
 	</tr>
925 925
 	<tr class="bsui">
926 926
     	<td colspan="2" class="p-0">
927
-			<?php include plugin_dir_path( __FILE__ ) . 'views/html-tax-rates-edit.php'; ?>
927
+			<?php include plugin_dir_path(__FILE__) . 'views/html-tax-rates-edit.php'; ?>
928 928
 
929 929
 	<?php
930 930
 
@@ -933,161 +933,161 @@  discard block
 block discarded – undo
933 933
 /**
934 934
  * Displays a tax rate' edit row.
935 935
  */
936
-function wpinv_tax_rate_callback( $tax_rate, $key ) {
936
+function wpinv_tax_rate_callback($tax_rate, $key) {
937 937
 
938
-	$key                      = sanitize_key( $key );
939
-	$tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
940
-	include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
938
+	$key                      = sanitize_key($key);
939
+	$tax_rate['reduced_rate'] = empty($tax_rate['reduced_rate']) ? 0 : $tax_rate['reduced_rate'];
940
+	include plugin_dir_path(__FILE__) . 'views/html-tax-rate-edit.php';
941 941
 
942 942
 }
943 943
 
944 944
 
945
-function wpinv_tools_callback( $args ) {
945
+function wpinv_tools_callback($args) {
946 946
     ?>
947 947
     </td><tr>
948 948
     <td colspan="2" class="wpinv_tools_tdbox">
949 949
     <?php
950
-    if ( $args['desc'] ) {
950
+    if ($args['desc']) {
951 951
 ?>
952
-<p><?php echo wp_kses_post( $args['desc'] ); ?></p><?php } ?>
953
-    <?php do_action( 'wpinv_tools_before' ); ?>
952
+<p><?php echo wp_kses_post($args['desc']); ?></p><?php } ?>
953
+    <?php do_action('wpinv_tools_before'); ?>
954 954
     <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts">
955 955
         <thead>
956 956
             <tr>
957
-                <th scope="col" class="wpinv-th-tool"><?php esc_html_e( 'Tool', 'invoicing' ); ?></th>
958
-                <th scope="col" class="wpinv-th-desc"><?php esc_html_e( 'Description', 'invoicing' ); ?></th>
959
-                <th scope="col" class="wpinv-th-action"><?php esc_html_e( 'Action', 'invoicing' ); ?></th>
957
+                <th scope="col" class="wpinv-th-tool"><?php esc_html_e('Tool', 'invoicing'); ?></th>
958
+                <th scope="col" class="wpinv-th-desc"><?php esc_html_e('Description', 'invoicing'); ?></th>
959
+                <th scope="col" class="wpinv-th-action"><?php esc_html_e('Action', 'invoicing'); ?></th>
960 960
             </tr>
961 961
         </thead>
962 962
 
963 963
         <tbody>
964 964
 			<tr>
965
-                <td><?php esc_html_e( 'Check Pages', 'invoicing' ); ?></td>
965
+                <td><?php esc_html_e('Check Pages', 'invoicing'); ?></td>
966 966
                 <td>
967
-                    <small><?php esc_html_e( 'Creates any missing GetPaid pages.', 'invoicing' ); ?></small>
967
+                    <small><?php esc_html_e('Creates any missing GetPaid pages.', 'invoicing'); ?></small>
968 968
                 </td>
969 969
                 <td>
970 970
 					<a href="
971 971
                     <?php
972 972
 						echo esc_url(
973 973
 							wp_nonce_url(
974
-								add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
974
+								add_query_arg('getpaid-admin-action', 'create_missing_pages'),
975 975
 								'getpaid-nonce',
976 976
 								'getpaid-nonce'
977 977
 							)
978 978
 						);
979 979
 					?>
980
-                    " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
980
+                    " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a>
981 981
                 </td>
982 982
             </tr>
983 983
 			<tr>
984
-                <td><?php esc_html_e( 'Create Database Tables', 'invoicing' ); ?></td>
984
+                <td><?php esc_html_e('Create Database Tables', 'invoicing'); ?></td>
985 985
                 <td>
986
-                    <small><?php esc_html_e( 'Run this tool to create any missing database tables.', 'invoicing' ); ?></small>
986
+                    <small><?php esc_html_e('Run this tool to create any missing database tables.', 'invoicing'); ?></small>
987 987
                 </td>
988 988
                 <td>
989 989
 					<a href="
990 990
                     <?php
991 991
 						echo esc_url(
992 992
 							wp_nonce_url(
993
-								add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ),
993
+								add_query_arg('getpaid-admin-action', 'create_missing_tables'),
994 994
 								'getpaid-nonce',
995 995
 								'getpaid-nonce'
996 996
 							)
997 997
 						);
998 998
 					?>
999
-                    " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
999
+                    " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a>
1000 1000
                 </td>
1001 1001
             </tr>
1002 1002
 			<tr>
1003
-                <td><?php esc_html_e( 'Migrate old invoices', 'invoicing' ); ?></td>
1003
+                <td><?php esc_html_e('Migrate old invoices', 'invoicing'); ?></td>
1004 1004
                 <td>
1005
-                    <small><?php esc_html_e( 'If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing' ); ?></small>
1005
+                    <small><?php esc_html_e('If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing'); ?></small>
1006 1006
                 </td>
1007 1007
                 <td>
1008 1008
 					<a href="
1009 1009
                     <?php
1010 1010
 						echo esc_url(
1011 1011
 							wp_nonce_url(
1012
-								add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ),
1012
+								add_query_arg('getpaid-admin-action', 'migrate_old_invoices'),
1013 1013
 								'getpaid-nonce',
1014 1014
 								'getpaid-nonce'
1015 1015
 							)
1016 1016
 						);
1017 1017
 					?>
1018
-                    " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
1018
+                    " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a>
1019 1019
                 </td>
1020 1020
             </tr>
1021 1021
 
1022 1022
 			<tr>
1023
-                <td><?php esc_html_e( 'Recalculate Discounts', 'invoicing' ); ?></td>
1023
+                <td><?php esc_html_e('Recalculate Discounts', 'invoicing'); ?></td>
1024 1024
                 <td>
1025
-                    <small><?php esc_html_e( 'Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing' ); ?></small>
1025
+                    <small><?php esc_html_e('Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing'); ?></small>
1026 1026
                 </td>
1027 1027
                 <td>
1028 1028
 					<a href="
1029 1029
                     <?php
1030 1030
 						echo esc_url(
1031 1031
 							wp_nonce_url(
1032
-								add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ),
1032
+								add_query_arg('getpaid-admin-action', 'recalculate_discounts'),
1033 1033
 								'getpaid-nonce',
1034 1034
 								'getpaid-nonce'
1035 1035
 							)
1036 1036
 						);
1037 1037
 					?>
1038
-                    " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
1038
+                    " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a>
1039 1039
                 </td>
1040 1040
             </tr>
1041 1041
 
1042 1042
 			<tr>
1043
-                <td><?php esc_html_e( 'Set-up Wizard', 'invoicing' ); ?></td>
1043
+                <td><?php esc_html_e('Set-up Wizard', 'invoicing'); ?></td>
1044 1044
                 <td>
1045
-                    <small><?php esc_html_e( 'Launch the quick set-up wizard.', 'invoicing' ); ?></small>
1045
+                    <small><?php esc_html_e('Launch the quick set-up wizard.', 'invoicing'); ?></small>
1046 1046
                 </td>
1047 1047
                 <td>
1048 1048
 					<a href="
1049 1049
                     <?php
1050
-						echo esc_url( admin_url( 'index.php?page=gp-setup' ) );
1050
+						echo esc_url(admin_url('index.php?page=gp-setup'));
1051 1051
 					?>
1052
-                    " class="button button-primary"><?php esc_html_e( 'Launch', 'invoicing' ); ?></a>
1052
+                    " class="button button-primary"><?php esc_html_e('Launch', 'invoicing'); ?></a>
1053 1053
                 </td>
1054 1054
             </tr>
1055 1055
 
1056
-			<?php do_action( 'wpinv_tools_row' ); ?>
1056
+			<?php do_action('wpinv_tools_row'); ?>
1057 1057
         </tbody>
1058 1058
     </table>
1059
-    <?php do_action( 'wpinv_tools_after' ); ?>
1059
+    <?php do_action('wpinv_tools_after'); ?>
1060 1060
     <?php
1061 1061
 }
1062 1062
 
1063 1063
 
1064
-function wpinv_descriptive_text_callback( $args ) {
1065
-	echo wp_kses_post( $args['desc'] );
1064
+function wpinv_descriptive_text_callback($args) {
1065
+	echo wp_kses_post($args['desc']);
1066 1066
 }
1067 1067
 
1068
-function wpinv_raw_html_callback( $args ) {
1069
-	echo wp_kses_post( $args['desc'] );
1068
+function wpinv_raw_html_callback($args) {
1069
+	echo wp_kses_post($args['desc']);
1070 1070
 }
1071 1071
 
1072
-function wpinv_hook_callback( $args ) {
1073
-	do_action( 'wpinv_' . $args['id'], $args );
1072
+function wpinv_hook_callback($args) {
1073
+	do_action('wpinv_' . $args['id'], $args);
1074 1074
 }
1075 1075
 
1076 1076
 function wpinv_set_settings_cap() {
1077 1077
 	return wpinv_get_capability();
1078 1078
 }
1079
-add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1079
+add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap');
1080 1080
 
1081 1081
 
1082
-function wpinv_on_update_settings( $old_value, $value, $option ) {
1083
-    $old = ! empty( $old_value['remove_data_on_unistall'] ) ? 1 : '';
1084
-    $new = ! empty( $value['remove_data_on_unistall'] ) ? 1 : '';
1082
+function wpinv_on_update_settings($old_value, $value, $option) {
1083
+    $old = !empty($old_value['remove_data_on_unistall']) ? 1 : '';
1084
+    $new = !empty($value['remove_data_on_unistall']) ? 1 : '';
1085 1085
 
1086
-    if ( $old != $new ) {
1087
-        update_option( 'wpinv_remove_data_on_invoice_unistall', $new );
1086
+    if ($old != $new) {
1087
+        update_option('wpinv_remove_data_on_invoice_unistall', $new);
1088 1088
     }
1089 1089
 }
1090
-add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 );
1090
+add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3);
1091 1091
 
1092 1092
 /**
1093 1093
  * Returns the merge tags help text.
@@ -1096,16 +1096,16 @@  discard block
 block discarded – undo
1096 1096
  *
1097 1097
  * @return string
1098 1098
  */
1099
-function wpinv_get_merge_tags_help_text( $subscription = false ) {
1099
+function wpinv_get_merge_tags_help_text($subscription = false) {
1100 1100
 
1101 1101
 	$url  = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f';
1102 1102
 	$link = sprintf(
1103 1103
 		'<strong><a href="%s" target="_blank">%s</a></strong>',
1104 1104
 		$url,
1105
-		esc_html__( 'View available merge tags.', 'wpinv-quotes' )
1105
+		esc_html__('View available merge tags.', 'wpinv-quotes')
1106 1106
 	);
1107 1107
 
1108
-	$description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' );
1108
+	$description = esc_html__('The content of the email (Merge Tags and HTML are allowed).', 'invoicing');
1109 1109
 
1110 1110
 	return "$description $link";
1111 1111
 
Please login to merge, or discard this patch.
includes/error-functions.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -126,14 +126,14 @@
 block discarded – undo
126 126
  */
127 127
 function getpaid_doing_it_wrong( $function, $message, $version ) {
128 128
 
129
-	$message .= ' Backtrace: ' . wp_debug_backtrace_summary();
130
-
131
-	if ( wp_doing_ajax() || defined( 'REST_REQUEST' ) ) {
132
-		do_action( 'doing_it_wrong_run', $function, $message, $version );
133
-		error_log( "{$function} was called incorrectly. {$message}. This message was added in version {$version}." );
134
-	} else {
135
-		_doing_it_wrong( esc_html( $function ), wp_kses_post( $message ), esc_html( $version ) );
136
-	}
129
+    $message .= ' Backtrace: ' . wp_debug_backtrace_summary();
130
+
131
+    if ( wp_doing_ajax() || defined( 'REST_REQUEST' ) ) {
132
+        do_action( 'doing_it_wrong_run', $function, $message, $version );
133
+        error_log( "{$function} was called incorrectly. {$message}. This message was added in version {$version}." );
134
+    } else {
135
+        _doing_it_wrong( esc_html( $function ), wp_kses_post( $message ), esc_html( $version ) );
136
+    }
137 137
 
138 138
 }
139 139
 
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Returns the errors as html
@@ -15,35 +15,35 @@  discard block
 block discarded – undo
15 15
  * @param bool $wrap whether or not to wrap the errors.
16 16
  * @since  1.0.19
17 17
  */
18
-function getpaid_get_errors_html( $clear = true, $wrap = true ) {
18
+function getpaid_get_errors_html($clear = true, $wrap = true) {
19 19
 
20 20
     $errors = '';
21
-    foreach ( wpinv_get_errors() as $id => $error ) {
22
-        $type     = 'error';
21
+    foreach (wpinv_get_errors() as $id => $error) {
22
+        $type = 'error';
23 23
 
24
-        if ( is_array( $error ) ) {
24
+        if (is_array($error)) {
25 25
             $type  = $error['type'];
26 26
             $error = $error['text'];
27 27
         }
28 28
 
29
-        if ( $wrap ) {
29
+        if ($wrap) {
30 30
 
31 31
             $errors .= aui()->alert(
32 32
                 array(
33
-                    'content' => wp_kses_post( $error ),
33
+                    'content' => wp_kses_post($error),
34 34
                     'type'    => $type,
35 35
                 )
36 36
             );
37 37
 
38 38
         } else {
39 39
 
40
-            $id      = esc_attr( $id );
41
-            $error   = wp_kses_post( $error );
40
+            $id      = esc_attr($id);
41
+            $error   = wp_kses_post($error);
42 42
             $errors .= "<div data-code='$id'>$error</div>";
43 43
         }
44 44
 }
45 45
 
46
-    if ( $clear ) {
46
+    if ($clear) {
47 47
         wpinv_clear_errors();
48 48
     }
49 49
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
  * Prints (then clears) all available errors.
56 56
  */
57 57
 function wpinv_print_errors() {
58
-    echo wp_kses_post( getpaid_get_errors_html() );
58
+    echo wp_kses_post(getpaid_get_errors_html());
59 59
 }
60 60
 
61 61
 /**
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
  * @return array
65 65
  */
66 66
 function wpinv_get_errors() {
67
-    $errors = getpaid_session()->get( 'wpinv_errors' );
68
-    return is_array( $errors ) ? $errors : array();
67
+    $errors = getpaid_session()->get('wpinv_errors');
68
+    return is_array($errors) ? $errors : array();
69 69
 }
70 70
 
71 71
 /**
@@ -75,15 +75,15 @@  discard block
 block discarded – undo
75 75
  * @param string $error_message The error message.
76 76
  * @param string $type Either error, info, warning, primary, dark, light or success.
77 77
  */
78
-function wpinv_set_error( $error_id, $error_message, $type = 'error' ) {
78
+function wpinv_set_error($error_id, $error_message, $type = 'error') {
79 79
 
80 80
     $errors              = wpinv_get_errors();
81
-    $errors[ $error_id ] = array(
81
+    $errors[$error_id] = array(
82 82
         'type' => $type,
83 83
         'text' => $error_message,
84 84
     );
85 85
 
86
-    getpaid_session()->set( 'wpinv_errors', $errors );
86
+    getpaid_session()->set('wpinv_errors', $errors);
87 87
 }
88 88
 
89 89
 /**
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
  *
92 92
  */
93 93
 function wpinv_has_errors() {
94
-    return count( wpinv_get_errors() ) > 0;
94
+    return count(wpinv_get_errors()) > 0;
95 95
 }
96 96
 
97 97
 /**
@@ -99,21 +99,21 @@  discard block
 block discarded – undo
99 99
  *
100 100
  */
101 101
 function wpinv_clear_errors() {
102
-    getpaid_session()->set( 'wpinv_errors', null );
102
+    getpaid_session()->set('wpinv_errors', null);
103 103
 }
104 104
 
105 105
 /**
106 106
  * Clears a single error.
107 107
  *
108 108
  */
109
-function wpinv_unset_error( $error_id ) {
109
+function wpinv_unset_error($error_id) {
110 110
     $errors = wpinv_get_errors();
111 111
 
112
-    if ( isset( $errors[ $error_id ] ) ) {
113
-        unset( $errors[ $error_id ] );
112
+    if (isset($errors[$error_id])) {
113
+        unset($errors[$error_id]);
114 114
     }
115 115
 
116
-    getpaid_session()->set( 'wpinv_errors', $errors );
116
+    getpaid_session()->set('wpinv_errors', $errors);
117 117
 }
118 118
 
119 119
 /**
@@ -124,15 +124,15 @@  discard block
 block discarded – undo
124 124
  * @param string $message Message to log.
125 125
  * @param string $version Version the message was added in.
126 126
  */
127
-function getpaid_doing_it_wrong( $function, $message, $version ) {
127
+function getpaid_doing_it_wrong($function, $message, $version) {
128 128
 
129 129
 	$message .= ' Backtrace: ' . wp_debug_backtrace_summary();
130 130
 
131
-	if ( wp_doing_ajax() || defined( 'REST_REQUEST' ) ) {
132
-		do_action( 'doing_it_wrong_run', $function, $message, $version );
133
-		error_log( "{$function} was called incorrectly. {$message}. This message was added in version {$version}." );
131
+	if (wp_doing_ajax() || defined('REST_REQUEST')) {
132
+		do_action('doing_it_wrong_run', $function, $message, $version);
133
+		error_log("{$function} was called incorrectly. {$message}. This message was added in version {$version}.");
134 134
 	} else {
135
-		_doing_it_wrong( esc_html( $function ), wp_kses_post( $message ), esc_html( $version ) );
135
+		_doing_it_wrong(esc_html($function), wp_kses_post($message), esc_html($version));
136 136
 	}
137 137
 
138 138
 }
@@ -146,41 +146,41 @@  discard block
 block discarded – undo
146 146
  * @param string $line The line that contains the error.
147 147
  * @param bool $exit Whether or not to exit function execution.
148 148
  */
149
-function wpinv_error_log( $log, $title = '', $file = '', $line = '', $exit = false ) {
149
+function wpinv_error_log($log, $title = '', $file = '', $line = '', $exit = false) {
150 150
 
151
-    if ( true === apply_filters( 'wpinv_log_errors', true ) ) {
151
+    if (true === apply_filters('wpinv_log_errors', true)) {
152 152
 
153 153
         // Ensure the log is a scalar.
154
-        if ( ! is_scalar( $log ) ) {
155
-            $log = print_r( $log, true );
154
+        if (!is_scalar($log)) {
155
+            $log = print_r($log, true);
156 156
         }
157 157
 
158 158
         // Add title.
159
-        if ( ! empty( $title ) ) {
160
-            $log  = $title . ' ' . trim( $log );
159
+        if (!empty($title)) {
160
+            $log = $title . ' ' . trim($log);
161 161
         }
162 162
 
163 163
         // Add the file to the label.
164
-        if ( ! empty( $file ) ) {
164
+        if (!empty($file)) {
165 165
             $log .= ' in ' . $file;
166 166
         }
167 167
 
168 168
         // Add the line number to the label.
169
-        if ( ! empty( $line ) ) {
169
+        if (!empty($line)) {
170 170
             $log .= ' on line ' . $line;
171 171
         }
172 172
 
173 173
         // Log the message.
174
-        error_log( trim( $log ) );
174
+        error_log(trim($log));
175 175
 
176 176
         // ... and a backtrace.
177
-        if ( false !== $title && false !== $file ) {
178
-            error_log( 'Backtrace ' . wp_debug_backtrace_summary() );
177
+        if (false !== $title && false !== $file) {
178
+            error_log('Backtrace ' . wp_debug_backtrace_summary());
179 179
         }
180 180
 }
181 181
 
182 182
     // Maybe exit.
183
-    if ( $exit ) {
183
+    if ($exit) {
184 184
         exit;
185 185
     }
186 186
 
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-bank-transfer-gateway.php 2 patches
Indentation   +221 added lines, -221 removed lines patch added patch discarded remove patch
@@ -13,30 +13,30 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Bank_Transfer_Gateway extends GetPaid_Payment_Gateway {
14 14
 
15 15
     /**
16
-	 * Payment method id.
17
-	 *
18
-	 * @var string
19
-	 */
16
+     * Payment method id.
17
+     *
18
+     * @var string
19
+     */
20 20
     public $id = 'bank_transfer';
21 21
 
22
-	/**
23
-	 * An array of features that this gateway supports.
24
-	 *
25
-	 * @var array
26
-	 */
27
-	protected $supports = array( 'subscription', 'addons', 'single_subscription_group', 'multiple_subscription_groups' );
22
+    /**
23
+     * An array of features that this gateway supports.
24
+     *
25
+     * @var array
26
+     */
27
+    protected $supports = array( 'subscription', 'addons', 'single_subscription_group', 'multiple_subscription_groups' );
28 28
 
29 29
     /**
30
-	 * Payment method order.
31
-	 *
32
-	 * @var int
33
-	 */
34
-	public $order = 8;
30
+     * Payment method order.
31
+     *
32
+     * @var int
33
+     */
34
+    public $order = 8;
35 35
 
36 36
     /**
37
-	 * Class constructor.
38
-	 */
39
-	public function __construct() {
37
+     * Class constructor.
38
+     */
39
+    public function __construct() {
40 40
         parent::__construct();
41 41
 
42 42
         $this->title                = __( 'Direct bank transfer', 'invoicing' );
@@ -44,24 +44,24 @@  discard block
 block discarded – undo
44 44
         $this->checkout_button_text = __( 'Proceed', 'invoicing' );
45 45
         $this->instructions         = apply_filters( 'wpinv_bank_instructions', $this->get_option( 'info' ) );
46 46
 
47
-		add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) );
48
-		add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 );
49
-		add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 );
50
-		add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 );
51
-		add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ) );
52
-		add_action( 'getpaid_invoice_status_publish', array( $this, 'invoice_paid' ), 20 );
47
+        add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) );
48
+        add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 );
49
+        add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 );
50
+        add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 );
51
+        add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ) );
52
+        add_action( 'getpaid_invoice_status_publish', array( $this, 'invoice_paid' ), 20 );
53 53
 
54 54
     }
55 55
 
56 56
     /**
57
-	 * Process Payment.
58
-	 *
59
-	 * @param WPInv_Invoice $invoice Invoice.
60
-	 * @param array $submission_data Posted checkout fields.
61
-	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
62
-	 * @return array
63
-	 */
64
-	public function process_payment( $invoice, $submission_data, $submission ) {
57
+     * Process Payment.
58
+     *
59
+     * @param WPInv_Invoice $invoice Invoice.
60
+     * @param array $submission_data Posted checkout fields.
61
+     * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
62
+     * @return array
63
+     */
64
+    public function process_payment( $invoice, $submission_data, $submission ) {
65 65
 
66 66
         // Add a transaction id.
67 67
         $invoice->set_transaction_id( $invoice->generate_key( 'bt_' ) );
@@ -82,66 +82,66 @@  discard block
 block discarded – undo
82 82
     }
83 83
 
84 84
     /**
85
-	 * Output for the order received page.
86
-	 *
87
-	 * @param WPInv_Invoice $invoice Invoice.
88
-	 */
89
-	public function thankyou_page( $invoice ) {
85
+     * Output for the order received page.
86
+     *
87
+     * @param WPInv_Invoice $invoice Invoice.
88
+     */
89
+    public function thankyou_page( $invoice ) {
90 90
 
91 91
         if ( 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
92 92
 
93
-			echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL;
93
+            echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL;
94 94
 
95 95
             if ( ! empty( $this->instructions ) ) {
96 96
                 echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) );
97
-			}
97
+            }
98 98
 
99
-			$this->bank_details( $invoice );
99
+            $this->bank_details( $invoice );
100 100
 
101
-			echo '</div>';
101
+            echo '</div>';
102 102
 
103 103
         }
104 104
 
105
-	}
105
+    }
106 106
 
107 107
     /**
108
-	 * Add content to the WPI emails.
109
-	 *
110
-	 * @param WPInv_Invoice $invoice Invoice.
111
-	 * @param string     $email_type Email format: plain text or HTML.
112
-	 * @param bool     $sent_to_admin Sent to admin.
113
-	 */
114
-	public function email_instructions( $invoice, $email_type, $sent_to_admin ) {
108
+     * Add content to the WPI emails.
109
+     *
110
+     * @param WPInv_Invoice $invoice Invoice.
111
+     * @param string     $email_type Email format: plain text or HTML.
112
+     * @param bool     $sent_to_admin Sent to admin.
113
+     */
114
+    public function email_instructions( $invoice, $email_type, $sent_to_admin ) {
115 115
 
116
-		if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
116
+        if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
117 117
 
118
-			echo '<div class="wpi-email-row getpaid-bank-transfer-details">';
118
+            echo '<div class="wpi-email-row getpaid-bank-transfer-details">';
119 119
 
120
-			if ( $this->instructions ) {
121
-				echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
120
+            if ( $this->instructions ) {
121
+                echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
122 122
             }
123 123
 
124
-			$this->bank_details( $invoice );
124
+            $this->bank_details( $invoice );
125 125
 
126
-			echo '</div>';
126
+            echo '</div>';
127 127
 
128
-		}
128
+        }
129 129
 
130 130
     }
131 131
 
132 132
     /**
133
-	 * Get bank details and place into a list format.
134
-	 *
135
-	 * @param WPInv_Invoice $invoice Invoice.
136
-	 */
137
-	protected function bank_details( $invoice ) {
133
+     * Get bank details and place into a list format.
134
+     *
135
+     * @param WPInv_Invoice $invoice Invoice.
136
+     */
137
+    protected function bank_details( $invoice ) {
138 138
 
139
-		// Get the invoice country and country $locale.
140
-		$country = $invoice->get_country();
141
-		$locale  = $this->get_country_locale();
139
+        // Get the invoice country and country $locale.
140
+        $country = $invoice->get_country();
141
+        $locale  = $this->get_country_locale();
142 142
 
143
-		// Get sortcode label in the $locale array and use appropriate one.
144
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
143
+        // Get sortcode label in the $locale array and use appropriate one.
144
+        $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
145 145
 
146 146
         $bank_fields = array(
147 147
             'ac_name'   => __( 'Account Name', 'invoicing' ),
@@ -160,9 +160,9 @@  discard block
 block discarded – undo
160 160
 
161 161
             if ( ! empty( $value ) ) {
162 162
                 $bank_info[ $field ] = array(
163
-					'label' => $label,
164
-					'value' => $value,
165
-				);
163
+                    'label' => $label,
164
+                    'value' => $value,
165
+                );
166 166
             }
167 167
 }
168 168
 
@@ -172,139 +172,139 @@  discard block
 block discarded – undo
172 172
             return;
173 173
         }
174 174
 
175
-		echo '<h3 class="getpaid-bank-transfer-title"> ' . esc_html( apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ) ) ) . '</h3>' . PHP_EOL;
175
+        echo '<h3 class="getpaid-bank-transfer-title"> ' . esc_html( apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ) ) ) . '</h3>' . PHP_EOL;
176 176
 
177
-		echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL;
177
+        echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL;
178 178
 
179
-		foreach ( $bank_info as $key => $data ) {
180
-			echo "<tr class='getpaid-bank-transfer-" . esc_attr( $key ) . "'><th class='font-weight-bold'>" . wp_kses_post( $data['label'] ) . "</th><td class='w-75'>" . wp_kses_post( wptexturize( $data['value'] ) ) . "</td></tr>" . PHP_EOL;
181
-		}
179
+        foreach ( $bank_info as $key => $data ) {
180
+            echo "<tr class='getpaid-bank-transfer-" . esc_attr( $key ) . "'><th class='font-weight-bold'>" . wp_kses_post( $data['label'] ) . "</th><td class='w-75'>" . wp_kses_post( wptexturize( $data['value'] ) ) . "</td></tr>" . PHP_EOL;
181
+        }
182 182
 
183
-		echo '</table>';
183
+        echo '</table>';
184 184
 
185 185
     }
186 186
 
187 187
     /**
188
-	 * Get country locale if localized.
189
-	 *
190
-	 * @return array
191
-	 */
192
-	public function get_country_locale() {
193
-
194
-		if ( empty( $this->locale ) ) {
195
-
196
-			// Locale information to be used - only those that are not 'Sort Code'.
197
-			$this->locale = apply_filters(
198
-				'getpaid_get_bank_transfer_locale',
199
-				array(
200
-					'AU' => array(
201
-						'sortcode' => array(
202
-							'label' => __( 'BSB', 'invoicing' ),
203
-						),
204
-					),
205
-					'CA' => array(
206
-						'sortcode' => array(
207
-							'label' => __( 'Bank transit number', 'invoicing' ),
208
-						),
209
-					),
210
-					'IN' => array(
211
-						'sortcode' => array(
212
-							'label' => __( 'IFSC', 'invoicing' ),
213
-						),
214
-					),
215
-					'IT' => array(
216
-						'sortcode' => array(
217
-							'label' => __( 'Branch sort', 'invoicing' ),
218
-						),
219
-					),
220
-					'NZ' => array(
221
-						'sortcode' => array(
222
-							'label' => __( 'Bank code', 'invoicing' ),
223
-						),
224
-					),
225
-					'SE' => array(
226
-						'sortcode' => array(
227
-							'label' => __( 'Bank code', 'invoicing' ),
228
-						),
229
-					),
230
-					'US' => array(
231
-						'sortcode' => array(
232
-							'label' => __( 'Routing number', 'invoicing' ),
233
-						),
234
-					),
235
-					'ZA' => array(
236
-						'sortcode' => array(
237
-							'label' => __( 'Branch code', 'invoicing' ),
238
-						),
239
-					),
240
-				)
241
-			);
242
-
243
-		}
244
-
245
-		return $this->locale;
246
-
247
-	}
248
-
249
-	/**
250
-	 * Filters the gateway settings.
251
-	 *
252
-	 * @param array $admin_settings
253
-	 */
254
-	public function admin_settings( $admin_settings ) {
188
+     * Get country locale if localized.
189
+     *
190
+     * @return array
191
+     */
192
+    public function get_country_locale() {
193
+
194
+        if ( empty( $this->locale ) ) {
195
+
196
+            // Locale information to be used - only those that are not 'Sort Code'.
197
+            $this->locale = apply_filters(
198
+                'getpaid_get_bank_transfer_locale',
199
+                array(
200
+                    'AU' => array(
201
+                        'sortcode' => array(
202
+                            'label' => __( 'BSB', 'invoicing' ),
203
+                        ),
204
+                    ),
205
+                    'CA' => array(
206
+                        'sortcode' => array(
207
+                            'label' => __( 'Bank transit number', 'invoicing' ),
208
+                        ),
209
+                    ),
210
+                    'IN' => array(
211
+                        'sortcode' => array(
212
+                            'label' => __( 'IFSC', 'invoicing' ),
213
+                        ),
214
+                    ),
215
+                    'IT' => array(
216
+                        'sortcode' => array(
217
+                            'label' => __( 'Branch sort', 'invoicing' ),
218
+                        ),
219
+                    ),
220
+                    'NZ' => array(
221
+                        'sortcode' => array(
222
+                            'label' => __( 'Bank code', 'invoicing' ),
223
+                        ),
224
+                    ),
225
+                    'SE' => array(
226
+                        'sortcode' => array(
227
+                            'label' => __( 'Bank code', 'invoicing' ),
228
+                        ),
229
+                    ),
230
+                    'US' => array(
231
+                        'sortcode' => array(
232
+                            'label' => __( 'Routing number', 'invoicing' ),
233
+                        ),
234
+                    ),
235
+                    'ZA' => array(
236
+                        'sortcode' => array(
237
+                            'label' => __( 'Branch code', 'invoicing' ),
238
+                        ),
239
+                    ),
240
+                )
241
+            );
242
+
243
+        }
244
+
245
+        return $this->locale;
246
+
247
+    }
248
+
249
+    /**
250
+     * Filters the gateway settings.
251
+     *
252
+     * @param array $admin_settings
253
+     */
254
+    public function admin_settings( $admin_settings ) {
255 255
 
256 256
         $admin_settings['bank_transfer_desc']['std']    = __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' );
257
-		$admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' );
257
+        $admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' );
258 258
 
259
-		$locale  = $this->get_country_locale();
259
+        $locale  = $this->get_country_locale();
260 260
 
261
-		// Get sortcode label in the $locale array and use appropriate one.
262
-		$country  = wpinv_default_billing_country();
263
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
261
+        // Get sortcode label in the $locale array and use appropriate one.
262
+        $country  = wpinv_default_billing_country();
263
+        $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
264 264
 
265
-		$admin_settings['bank_transfer_ac_name'] = array(
265
+        $admin_settings['bank_transfer_ac_name'] = array(
266 266
             'type' => 'text',
267 267
             'id'   => 'bank_transfer_ac_name',
268 268
             'name' => __( 'Account Name', 'invoicing' ),
269
-		);
269
+        );
270 270
 
271
-		$admin_settings['bank_transfer_ac_no'] = array(
271
+        $admin_settings['bank_transfer_ac_no'] = array(
272 272
             'type' => 'text',
273 273
             'id'   => 'bank_transfer_ac_no',
274 274
             'name' => __( 'Account Number', 'invoicing' ),
275
-		);
275
+        );
276 276
 
277
-		$admin_settings['bank_transfer_bank_name'] = array(
277
+        $admin_settings['bank_transfer_bank_name'] = array(
278 278
             'type' => 'text',
279 279
             'id'   => 'bank_transfer_bank_name',
280 280
             'name' => __( 'Bank Name', 'invoicing' ),
281
-		);
281
+        );
282 282
 
283
-		$admin_settings['bank_transfer_ifsc'] = array(
283
+        $admin_settings['bank_transfer_ifsc'] = array(
284 284
             'type' => 'text',
285 285
             'id'   => 'bank_transfer_ifsc',
286 286
             'name' => __( 'IFSC Code', 'invoicing' ),
287
-		);
287
+        );
288 288
 
289
-		$admin_settings['bank_transfer_iban'] = array(
289
+        $admin_settings['bank_transfer_iban'] = array(
290 290
             'type' => 'text',
291 291
             'id'   => 'bank_transfer_iban',
292 292
             'name' => __( 'IBAN', 'invoicing' ),
293
-		);
293
+        );
294 294
 
295
-		$admin_settings['bank_transfer_bic'] = array(
295
+        $admin_settings['bank_transfer_bic'] = array(
296 296
             'type' => 'text',
297 297
             'id'   => 'bank_transfer_bic',
298 298
             'name' => __( 'BIC/Swift Code', 'invoicing' ),
299
-		);
299
+        );
300 300
 
301
-		$admin_settings['bank_transfer_sort_code'] = array(
302
-			'type' => 'text',
303
-			'id'   => 'bank_transfer_sort_code',
304
-			'name' => $sortcode,
305
-		);
301
+        $admin_settings['bank_transfer_sort_code'] = array(
302
+            'type' => 'text',
303
+            'id'   => 'bank_transfer_sort_code',
304
+            'name' => $sortcode,
305
+        );
306 306
 
307
-		$admin_settings['bank_transfer_info'] = array(
307
+        $admin_settings['bank_transfer_info'] = array(
308 308
             'id'   => 'bank_transfer_info',
309 309
             'name' => __( 'Instructions', 'invoicing' ),
310 310
             'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ),
@@ -314,17 +314,17 @@  discard block
 block discarded – undo
314 314
             'rows' => 5,
315 315
         );
316 316
 
317
-		return $admin_settings;
318
-	}
317
+        return $admin_settings;
318
+    }
319 319
 
320
-	/**
321
-	 * Processes invoice addons.
322
-	 *
323
-	 * @param WPInv_Invoice $invoice
324
-	 * @param GetPaid_Form_Item[] $items
325
-	 * @return WPInv_Invoice
326
-	 */
327
-	public function process_addons( $invoice, $items ) {
320
+    /**
321
+     * Processes invoice addons.
322
+     *
323
+     * @param WPInv_Invoice $invoice
324
+     * @param GetPaid_Form_Item[] $items
325
+     * @return WPInv_Invoice
326
+     */
327
+    public function process_addons( $invoice, $items ) {
328 328
 
329 329
         foreach ( $items as $item ) {
330 330
             $invoice->add_item( $item );
@@ -332,66 +332,66 @@  discard block
 block discarded – undo
332 332
 
333 333
         $invoice->recalculate_total();
334 334
         $invoice->save();
335
-	}
335
+    }
336 336
 
337
-	/**
338
-	 * (Maybe) renews a bank transfer subscription profile.
339
-	 *
340
-	 *
337
+    /**
338
+     * (Maybe) renews a bank transfer subscription profile.
339
+     *
340
+     *
341 341
      * @param WPInv_Subscription $subscription
342
-	 */
343
-	public function maybe_renew_subscription( $subscription ) {
342
+     */
343
+    public function maybe_renew_subscription( $subscription ) {
344 344
 
345 345
         // Ensure its our subscription && it's active.
346 346
         if ( $this->id == $subscription->get_gateway() && $subscription->has_status( 'active trialling' ) ) {
347
-			$subscription->create_payment();
347
+            $subscription->create_payment();
348 348
         }
349 349
 
350 350
     }
351 351
 
352
-	/**
353
-	 * Process a bank transfer payment.
354
-	 *
355
-	 *
352
+    /**
353
+     * Process a bank transfer payment.
354
+     *
355
+     *
356 356
      * @param WPInv_Invoice $invoice
357
-	 */
358
-	public function invoice_paid( $invoice ) {
359
-
360
-		// Abort if not paid by bank transfer.
361
-		if ( $this->id !== $invoice->get_gateway() || ! $invoice->is_recurring() ) {
362
-			return;
363
-		}
364
-
365
-		// Is it a parent payment?
366
-		if ( 0 == $invoice->get_parent_id() ) {
367
-
368
-			// (Maybe) activate subscriptions.
369
-			$subscriptions = getpaid_get_invoice_subscriptions( $invoice );
370
-
371
-			if ( ! empty( $subscriptions ) ) {
372
-				$subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions );
373
-
374
-				foreach ( $subscriptions as $subscription ) {
375
-					if ( $subscription->exists() ) {
376
-						$duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
377
-						$expiry   = date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) );
378
-
379
-						$subscription->set_next_renewal_date( $expiry );
380
-						$subscription->set_date_created( current_time( 'mysql' ) );
381
-						$subscription->set_profile_id( 'bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id() );
382
-						$subscription->activate();
383
-					}
384
-				}
357
+     */
358
+    public function invoice_paid( $invoice ) {
359
+
360
+        // Abort if not paid by bank transfer.
361
+        if ( $this->id !== $invoice->get_gateway() || ! $invoice->is_recurring() ) {
362
+            return;
363
+        }
364
+
365
+        // Is it a parent payment?
366
+        if ( 0 == $invoice->get_parent_id() ) {
367
+
368
+            // (Maybe) activate subscriptions.
369
+            $subscriptions = getpaid_get_invoice_subscriptions( $invoice );
370
+
371
+            if ( ! empty( $subscriptions ) ) {
372
+                $subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions );
373
+
374
+                foreach ( $subscriptions as $subscription ) {
375
+                    if ( $subscription->exists() ) {
376
+                        $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
377
+                        $expiry   = date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) );
378
+
379
+                        $subscription->set_next_renewal_date( $expiry );
380
+                        $subscription->set_date_created( current_time( 'mysql' ) );
381
+                        $subscription->set_profile_id( 'bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id() );
382
+                        $subscription->activate();
383
+                    }
384
+                }
385 385
 }
386 386
 } else {
387 387
 
388
-			$subscription = getpaid_get_subscription( $invoice->get_subscription_id() );
388
+            $subscription = getpaid_get_subscription( $invoice->get_subscription_id() );
389 389
 
390
-			// Renew the subscription.
391
-			if ( $subscription && $subscription->exists() ) {
392
-				$subscription->add_payment( array(), $invoice );
393
-				$subscription->renew();
394
-					}
390
+            // Renew the subscription.
391
+            if ( $subscription && $subscription->exists() ) {
392
+                $subscription->add_payment( array(), $invoice );
393
+                $subscription->renew();
394
+                    }
395 395
 }
396 396
 
397 397
     }
Please login to merge, or discard this patch.
Spacing   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Bank transfer Payment Gateway class.
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 *
25 25
 	 * @var array
26 26
 	 */
27
-	protected $supports = array( 'subscription', 'addons', 'single_subscription_group', 'multiple_subscription_groups' );
27
+	protected $supports = array('subscription', 'addons', 'single_subscription_group', 'multiple_subscription_groups');
28 28
 
29 29
     /**
30 30
 	 * Payment method order.
@@ -39,17 +39,17 @@  discard block
 block discarded – undo
39 39
 	public function __construct() {
40 40
         parent::__construct();
41 41
 
42
-        $this->title                = __( 'Direct bank transfer', 'invoicing' );
43
-        $this->method_title         = __( 'Bank transfer', 'invoicing' );
44
-        $this->checkout_button_text = __( 'Proceed', 'invoicing' );
45
-        $this->instructions         = apply_filters( 'wpinv_bank_instructions', $this->get_option( 'info' ) );
42
+        $this->title                = __('Direct bank transfer', 'invoicing');
43
+        $this->method_title         = __('Bank transfer', 'invoicing');
44
+        $this->checkout_button_text = __('Proceed', 'invoicing');
45
+        $this->instructions         = apply_filters('wpinv_bank_instructions', $this->get_option('info'));
46 46
 
47
-		add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) );
48
-		add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 );
49
-		add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 );
50
-		add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 );
51
-		add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ) );
52
-		add_action( 'getpaid_invoice_status_publish', array( $this, 'invoice_paid' ), 20 );
47
+		add_action('wpinv_receipt_end', array($this, 'thankyou_page'));
48
+		add_action('getpaid_invoice_line_items', array($this, 'thankyou_page'), 40);
49
+		add_action('wpinv_pdf_content_billing', array($this, 'thankyou_page'), 11);
50
+		add_action('wpinv_email_invoice_details', array($this, 'email_instructions'), 10, 3);
51
+		add_action('getpaid_should_renew_subscription', array($this, 'maybe_renew_subscription'));
52
+		add_action('getpaid_invoice_status_publish', array($this, 'invoice_paid'), 20);
53 53
 
54 54
     }
55 55
 
@@ -61,23 +61,23 @@  discard block
 block discarded – undo
61 61
 	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
62 62
 	 * @return array
63 63
 	 */
64
-	public function process_payment( $invoice, $submission_data, $submission ) {
64
+	public function process_payment($invoice, $submission_data, $submission) {
65 65
 
66 66
         // Add a transaction id.
67
-        $invoice->set_transaction_id( $invoice->generate_key( 'bt_' ) );
67
+        $invoice->set_transaction_id($invoice->generate_key('bt_'));
68 68
 
69 69
         // Set it as pending payment.
70
-        if ( ! $invoice->needs_payment() ) {
70
+        if (!$invoice->needs_payment()) {
71 71
             $invoice->mark_paid();
72
-        } elseif ( ! $invoice->is_paid() ) {
73
-            $invoice->set_status( 'wpi-onhold' );
72
+        } elseif (!$invoice->is_paid()) {
73
+            $invoice->set_status('wpi-onhold');
74 74
         }
75 75
 
76 76
         // Save it.
77 77
         $invoice->save();
78 78
 
79 79
         // Send to the success page.
80
-        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
80
+        wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
81 81
 
82 82
     }
83 83
 
@@ -86,17 +86,17 @@  discard block
 block discarded – undo
86 86
 	 *
87 87
 	 * @param WPInv_Invoice $invoice Invoice.
88 88
 	 */
89
-	public function thankyou_page( $invoice ) {
89
+	public function thankyou_page($invoice) {
90 90
 
91
-        if ( 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
91
+        if ('bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment()) {
92 92
 
93 93
 			echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL;
94 94
 
95
-            if ( ! empty( $this->instructions ) ) {
96
-                echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) );
95
+            if (!empty($this->instructions)) {
96
+                echo wp_kses_post(wpautop(wptexturize($this->instructions)));
97 97
 			}
98 98
 
99
-			$this->bank_details( $invoice );
99
+			$this->bank_details($invoice);
100 100
 
101 101
 			echo '</div>';
102 102
 
@@ -111,17 +111,17 @@  discard block
 block discarded – undo
111 111
 	 * @param string     $email_type Email format: plain text or HTML.
112 112
 	 * @param bool     $sent_to_admin Sent to admin.
113 113
 	 */
114
-	public function email_instructions( $invoice, $email_type, $sent_to_admin ) {
114
+	public function email_instructions($invoice, $email_type, $sent_to_admin) {
115 115
 
116
-		if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
116
+		if (!$sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment()) {
117 117
 
118 118
 			echo '<div class="wpi-email-row getpaid-bank-transfer-details">';
119 119
 
120
-			if ( $this->instructions ) {
121
-				echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
120
+			if ($this->instructions) {
121
+				echo wp_kses_post(wpautop(wptexturize($this->instructions)) . PHP_EOL);
122 122
             }
123 123
 
124
-			$this->bank_details( $invoice );
124
+			$this->bank_details($invoice);
125 125
 
126 126
 			echo '</div>';
127 127
 
@@ -134,50 +134,50 @@  discard block
 block discarded – undo
134 134
 	 *
135 135
 	 * @param WPInv_Invoice $invoice Invoice.
136 136
 	 */
137
-	protected function bank_details( $invoice ) {
137
+	protected function bank_details($invoice) {
138 138
 
139 139
 		// Get the invoice country and country $locale.
140 140
 		$country = $invoice->get_country();
141 141
 		$locale  = $this->get_country_locale();
142 142
 
143 143
 		// Get sortcode label in the $locale array and use appropriate one.
144
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
144
+		$sortcode = isset($locale[$country]['sortcode']['label']) ? $locale[$country]['sortcode']['label'] : __('Sort code', 'invoicing');
145 145
 
146 146
         $bank_fields = array(
147
-            'ac_name'   => __( 'Account Name', 'invoicing' ),
148
-            'ac_no'     => __( 'Account Number', 'invoicing' ),
149
-            'bank_name' => __( 'Bank Name', 'invoicing' ),
150
-            'ifsc'      => __( 'IFSC code', 'invoicing' ),
151
-            'iban'      => __( 'IBAN', 'invoicing' ),
152
-            'bic'       => __( 'BIC/Swift code', 'invoicing' ),
147
+            'ac_name'   => __('Account Name', 'invoicing'),
148
+            'ac_no'     => __('Account Number', 'invoicing'),
149
+            'bank_name' => __('Bank Name', 'invoicing'),
150
+            'ifsc'      => __('IFSC code', 'invoicing'),
151
+            'iban'      => __('IBAN', 'invoicing'),
152
+            'bic'       => __('BIC/Swift code', 'invoicing'),
153 153
             'sort_code' => $sortcode,
154 154
         );
155 155
 
156 156
         $bank_info = array();
157 157
 
158
-        foreach ( $bank_fields as $field => $label ) {
159
-            $value = $this->get_option( $field );
158
+        foreach ($bank_fields as $field => $label) {
159
+            $value = $this->get_option($field);
160 160
 
161
-            if ( ! empty( $value ) ) {
162
-                $bank_info[ $field ] = array(
161
+            if (!empty($value)) {
162
+                $bank_info[$field] = array(
163 163
 					'label' => $label,
164 164
 					'value' => $value,
165 165
 				);
166 166
             }
167 167
 }
168 168
 
169
-        $bank_info = apply_filters( 'wpinv_bank_info', $bank_info );
169
+        $bank_info = apply_filters('wpinv_bank_info', $bank_info);
170 170
 
171
-        if ( empty( $bank_info ) ) {
171
+        if (empty($bank_info)) {
172 172
             return;
173 173
         }
174 174
 
175
-		echo '<h3 class="getpaid-bank-transfer-title"> ' . esc_html( apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ) ) ) . '</h3>' . PHP_EOL;
175
+		echo '<h3 class="getpaid-bank-transfer-title"> ' . esc_html(apply_filters('wpinv_receipt_bank_details_title', __('Bank Details', 'invoicing'))) . '</h3>' . PHP_EOL;
176 176
 
177 177
 		echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL;
178 178
 
179
-		foreach ( $bank_info as $key => $data ) {
180
-			echo "<tr class='getpaid-bank-transfer-" . esc_attr( $key ) . "'><th class='font-weight-bold'>" . wp_kses_post( $data['label'] ) . "</th><td class='w-75'>" . wp_kses_post( wptexturize( $data['value'] ) ) . "</td></tr>" . PHP_EOL;
179
+		foreach ($bank_info as $key => $data) {
180
+			echo "<tr class='getpaid-bank-transfer-" . esc_attr($key) . "'><th class='font-weight-bold'>" . wp_kses_post($data['label']) . "</th><td class='w-75'>" . wp_kses_post(wptexturize($data['value'])) . "</td></tr>" . PHP_EOL;
181 181
 		}
182 182
 
183 183
 		echo '</table>';
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 	 */
192 192
 	public function get_country_locale() {
193 193
 
194
-		if ( empty( $this->locale ) ) {
194
+		if (empty($this->locale)) {
195 195
 
196 196
 			// Locale information to be used - only those that are not 'Sort Code'.
197 197
 			$this->locale = apply_filters(
@@ -199,42 +199,42 @@  discard block
 block discarded – undo
199 199
 				array(
200 200
 					'AU' => array(
201 201
 						'sortcode' => array(
202
-							'label' => __( 'BSB', 'invoicing' ),
202
+							'label' => __('BSB', 'invoicing'),
203 203
 						),
204 204
 					),
205 205
 					'CA' => array(
206 206
 						'sortcode' => array(
207
-							'label' => __( 'Bank transit number', 'invoicing' ),
207
+							'label' => __('Bank transit number', 'invoicing'),
208 208
 						),
209 209
 					),
210 210
 					'IN' => array(
211 211
 						'sortcode' => array(
212
-							'label' => __( 'IFSC', 'invoicing' ),
212
+							'label' => __('IFSC', 'invoicing'),
213 213
 						),
214 214
 					),
215 215
 					'IT' => array(
216 216
 						'sortcode' => array(
217
-							'label' => __( 'Branch sort', 'invoicing' ),
217
+							'label' => __('Branch sort', 'invoicing'),
218 218
 						),
219 219
 					),
220 220
 					'NZ' => array(
221 221
 						'sortcode' => array(
222
-							'label' => __( 'Bank code', 'invoicing' ),
222
+							'label' => __('Bank code', 'invoicing'),
223 223
 						),
224 224
 					),
225 225
 					'SE' => array(
226 226
 						'sortcode' => array(
227
-							'label' => __( 'Bank code', 'invoicing' ),
227
+							'label' => __('Bank code', 'invoicing'),
228 228
 						),
229 229
 					),
230 230
 					'US' => array(
231 231
 						'sortcode' => array(
232
-							'label' => __( 'Routing number', 'invoicing' ),
232
+							'label' => __('Routing number', 'invoicing'),
233 233
 						),
234 234
 					),
235 235
 					'ZA' => array(
236 236
 						'sortcode' => array(
237
-							'label' => __( 'Branch code', 'invoicing' ),
237
+							'label' => __('Branch code', 'invoicing'),
238 238
 						),
239 239
 					),
240 240
 				)
@@ -251,51 +251,51 @@  discard block
 block discarded – undo
251 251
 	 *
252 252
 	 * @param array $admin_settings
253 253
 	 */
254
-	public function admin_settings( $admin_settings ) {
254
+	public function admin_settings($admin_settings) {
255 255
 
256
-        $admin_settings['bank_transfer_desc']['std']    = __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' );
257
-		$admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' );
256
+        $admin_settings['bank_transfer_desc']['std'] = __("Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing');
257
+		$admin_settings['bank_transfer_active']['desc'] = __('Enable bank transfer', 'invoicing');
258 258
 
259
-		$locale  = $this->get_country_locale();
259
+		$locale = $this->get_country_locale();
260 260
 
261 261
 		// Get sortcode label in the $locale array and use appropriate one.
262 262
 		$country  = wpinv_default_billing_country();
263
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
263
+		$sortcode = isset($locale[$country]['sortcode']['label']) ? $locale[$country]['sortcode']['label'] : __('Sort code', 'invoicing');
264 264
 
265 265
 		$admin_settings['bank_transfer_ac_name'] = array(
266 266
             'type' => 'text',
267 267
             'id'   => 'bank_transfer_ac_name',
268
-            'name' => __( 'Account Name', 'invoicing' ),
268
+            'name' => __('Account Name', 'invoicing'),
269 269
 		);
270 270
 
271 271
 		$admin_settings['bank_transfer_ac_no'] = array(
272 272
             'type' => 'text',
273 273
             'id'   => 'bank_transfer_ac_no',
274
-            'name' => __( 'Account Number', 'invoicing' ),
274
+            'name' => __('Account Number', 'invoicing'),
275 275
 		);
276 276
 
277 277
 		$admin_settings['bank_transfer_bank_name'] = array(
278 278
             'type' => 'text',
279 279
             'id'   => 'bank_transfer_bank_name',
280
-            'name' => __( 'Bank Name', 'invoicing' ),
280
+            'name' => __('Bank Name', 'invoicing'),
281 281
 		);
282 282
 
283 283
 		$admin_settings['bank_transfer_ifsc'] = array(
284 284
             'type' => 'text',
285 285
             'id'   => 'bank_transfer_ifsc',
286
-            'name' => __( 'IFSC Code', 'invoicing' ),
286
+            'name' => __('IFSC Code', 'invoicing'),
287 287
 		);
288 288
 
289 289
 		$admin_settings['bank_transfer_iban'] = array(
290 290
             'type' => 'text',
291 291
             'id'   => 'bank_transfer_iban',
292
-            'name' => __( 'IBAN', 'invoicing' ),
292
+            'name' => __('IBAN', 'invoicing'),
293 293
 		);
294 294
 
295 295
 		$admin_settings['bank_transfer_bic'] = array(
296 296
             'type' => 'text',
297 297
             'id'   => 'bank_transfer_bic',
298
-            'name' => __( 'BIC/Swift Code', 'invoicing' ),
298
+            'name' => __('BIC/Swift Code', 'invoicing'),
299 299
 		);
300 300
 
301 301
 		$admin_settings['bank_transfer_sort_code'] = array(
@@ -306,10 +306,10 @@  discard block
 block discarded – undo
306 306
 
307 307
 		$admin_settings['bank_transfer_info'] = array(
308 308
             'id'   => 'bank_transfer_info',
309
-            'name' => __( 'Instructions', 'invoicing' ),
310
-            'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ),
309
+            'name' => __('Instructions', 'invoicing'),
310
+            'desc' => __('Instructions that will be added to the thank you page and emails.', 'invoicing'),
311 311
             'type' => 'textarea',
312
-            'std'  => __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' ),
312
+            'std'  => __("Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing'),
313 313
             'cols' => 50,
314 314
             'rows' => 5,
315 315
         );
@@ -324,10 +324,10 @@  discard block
 block discarded – undo
324 324
 	 * @param GetPaid_Form_Item[] $items
325 325
 	 * @return WPInv_Invoice
326 326
 	 */
327
-	public function process_addons( $invoice, $items ) {
327
+	public function process_addons($invoice, $items) {
328 328
 
329
-        foreach ( $items as $item ) {
330
-            $invoice->add_item( $item );
329
+        foreach ($items as $item) {
330
+            $invoice->add_item($item);
331 331
         }
332 332
 
333 333
         $invoice->recalculate_total();
@@ -340,10 +340,10 @@  discard block
 block discarded – undo
340 340
 	 *
341 341
      * @param WPInv_Subscription $subscription
342 342
 	 */
343
-	public function maybe_renew_subscription( $subscription ) {
343
+	public function maybe_renew_subscription($subscription) {
344 344
 
345 345
         // Ensure its our subscription && it's active.
346
-        if ( $this->id == $subscription->get_gateway() && $subscription->has_status( 'active trialling' ) ) {
346
+        if ($this->id == $subscription->get_gateway() && $subscription->has_status('active trialling')) {
347 347
 			$subscription->create_payment();
348 348
         }
349 349
 
@@ -355,41 +355,41 @@  discard block
 block discarded – undo
355 355
 	 *
356 356
      * @param WPInv_Invoice $invoice
357 357
 	 */
358
-	public function invoice_paid( $invoice ) {
358
+	public function invoice_paid($invoice) {
359 359
 
360 360
 		// Abort if not paid by bank transfer.
361
-		if ( $this->id !== $invoice->get_gateway() || ! $invoice->is_recurring() ) {
361
+		if ($this->id !== $invoice->get_gateway() || !$invoice->is_recurring()) {
362 362
 			return;
363 363
 		}
364 364
 
365 365
 		// Is it a parent payment?
366
-		if ( 0 == $invoice->get_parent_id() ) {
366
+		if (0 == $invoice->get_parent_id()) {
367 367
 
368 368
 			// (Maybe) activate subscriptions.
369
-			$subscriptions = getpaid_get_invoice_subscriptions( $invoice );
369
+			$subscriptions = getpaid_get_invoice_subscriptions($invoice);
370 370
 
371
-			if ( ! empty( $subscriptions ) ) {
372
-				$subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions );
371
+			if (!empty($subscriptions)) {
372
+				$subscriptions = is_array($subscriptions) ? $subscriptions : array($subscriptions);
373 373
 
374
-				foreach ( $subscriptions as $subscription ) {
375
-					if ( $subscription->exists() ) {
376
-						$duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
377
-						$expiry   = date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) );
374
+				foreach ($subscriptions as $subscription) {
375
+					if ($subscription->exists()) {
376
+						$duration = strtotime($subscription->get_expiration()) - strtotime($subscription->get_date_created());
377
+						$expiry   = date('Y-m-d H:i:s', (current_time('timestamp') + $duration));
378 378
 
379
-						$subscription->set_next_renewal_date( $expiry );
380
-						$subscription->set_date_created( current_time( 'mysql' ) );
381
-						$subscription->set_profile_id( 'bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id() );
379
+						$subscription->set_next_renewal_date($expiry);
380
+						$subscription->set_date_created(current_time('mysql'));
381
+						$subscription->set_profile_id('bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id());
382 382
 						$subscription->activate();
383 383
 					}
384 384
 				}
385 385
 }
386 386
 } else {
387 387
 
388
-			$subscription = getpaid_get_subscription( $invoice->get_subscription_id() );
388
+			$subscription = getpaid_get_subscription($invoice->get_subscription_id());
389 389
 
390 390
 			// Renew the subscription.
391
-			if ( $subscription && $subscription->exists() ) {
392
-				$subscription->add_payment( array(), $invoice );
391
+			if ($subscription && $subscription->exists()) {
392
+				$subscription->add_payment(array(), $invoice);
393 393
 				$subscription->renew();
394 394
 					}
395 395
 }
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-payment-gateway.php 2 patches
Indentation   +611 added lines, -611 removed lines patch added patch discarded remove patch
@@ -13,462 +13,462 @@  discard block
 block discarded – undo
13 13
  */
14 14
 abstract class GetPaid_Payment_Gateway {
15 15
 
16
-	/**
17
-	 * Set if the place checkout button should be renamed on selection.
18
-	 *
19
-	 * @var string
20
-	 */
21
-	public $checkout_button_text;
22
-
23
-	/**
24
-	 * Boolean whether the method is enabled.
25
-	 *
26
-	 * @var bool
27
-	 */
28
-	public $enabled = true;
29
-
30
-	/**
31
-	 * Payment method id.
32
-	 *
33
-	 * @var string
34
-	 */
35
-	public $id;
36
-
37
-	/**
38
-	 * Payment method order.
39
-	 *
40
-	 * @var int
41
-	 */
42
-	public $order = 10;
43
-
44
-	/**
45
-	 * Payment method title for the frontend.
46
-	 *
47
-	 * @var string
48
-	 */
49
-	public $title;
50
-
51
-	/**
52
-	 * Payment method description for the frontend.
53
-	 *
54
-	 * @var string
55
-	 */
56
-	public $description;
57
-
58
-	/**
59
-	 * Gateway title.
60
-	 *
61
-	 * @var string
62
-	 */
63
-	public $method_title = '';
64
-
65
-	/**
66
-	 * Gateway description.
67
-	 *
68
-	 * @var string
69
-	 */
70
-	public $method_description = '';
71
-
72
-	/**
73
-	 * Countries this gateway is allowed for.
74
-	 *
75
-	 * @var array
76
-	 */
77
-	public $countries;
78
-
79
-	/**
80
-	 * Currencies this gateway is allowed for.
81
-	 *
82
-	 * @var array
83
-	 */
84
-	public $currencies;
85
-
86
-	/**
87
-	 * Currencies this gateway is not allowed for.
88
-	 *
89
-	 * @var array
90
-	 */
91
-	public $exclude_currencies;
92
-
93
-	/**
94
-	 * Maximum transaction amount, zero does not define a maximum.
95
-	 *
96
-	 * @var int
97
-	 */
98
-	public $max_amount = 0;
99
-
100
-	/**
101
-	 * Optional URL to view a transaction.
102
-	 *
103
-	 * @var string
104
-	 */
105
-	public $view_transaction_url = '';
106
-
107
-	/**
108
-	 * Optional URL to view a subscription.
109
-	 *
110
-	 * @var string
111
-	 */
112
-	public $view_subscription_url = '';
113
-
114
-	/**
115
-	 * Optional label to show for "new payment method" in the payment
116
-	 * method/token selection radio selection.
117
-	 *
118
-	 * @var string
119
-	 */
120
-	public $new_method_label = '';
121
-
122
-	/**
123
-	 * Contains a user's saved tokens for this gateway.
124
-	 *
125
-	 * @var array
126
-	 */
127
-	protected $tokens = array();
128
-
129
-	/**
130
-	 * An array of features that this gateway supports.
131
-	 *
132
-	 * @var array
133
-	 */
134
-	protected $supports = array();
135
-
136
-	/**
137
-	 * Class constructor.
138
-	 */
139
-	public function __construct() {
140
-
141
-		// Register gateway.
142
-		add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) );
143
-
144
-		$this->enabled = wpinv_is_gateway_active( $this->id );
145
-
146
-		// Add support for various features.
147
-		foreach ( $this->supports as $feature ) {
148
-			add_filter( "wpinv_{$this->id}_support_{$feature}", '__return_true' );
149
-			add_filter( "getpaid_{$this->id}_support_{$feature}", '__return_true' );
150
-			add_filter( "getpaid_{$this->id}_supports_{$feature}", '__return_true' );
151
-		}
152
-
153
-		// Invoice addons.
154
-		if ( $this->supports( 'addons' ) ) {
155
-			add_action( "getpaid_process_{$this->id}_invoice_addons", array( $this, 'process_addons' ), 10, 2 );
156
-		}
157
-
158
-		// Gateway settings.
159
-		add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) );
160
-
161
-		// Gateway checkout fiellds.
162
-		add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 );
163
-
164
-		// Process payment.
165
-		add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 );
166
-
167
-		// Change the checkout button text.
168
-		if ( ! empty( $this->checkout_button_text ) ) {
169
-			add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) );
170
-		}
171
-
172
-		// Check if a gateway is valid for a given currency.
173
-		add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 );
174
-
175
-		// Generate the transaction url.
176
-		add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 );
177
-
178
-		// Generate the subscription url.
179
-		add_filter( 'getpaid_remote_subscription_profile_url', array( $this, 'generate_subscription_url' ), 10, 2 );
180
-
181
-		// Confirm payments.
182
-		add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 );
183
-
184
-		// Verify IPNs.
185
-		add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) );
186
-
187
-	}
188
-
189
-	/**
190
-	 * Checks if this gateway is a given gateway.
191
-	 *
192
-	 * @since 1.0.19
193
-	 * @return bool
194
-	 */
195
-	public function is( $gateway ) {
196
-		return $gateway == $this->id;
197
-	}
198
-
199
-	/**
200
-	 * Returns a users saved tokens for this gateway.
201
-	 *
202
-	 * @since 1.0.19
203
-	 * @return array
204
-	 */
205
-	public function get_tokens( $sandbox = null ) {
206
-
207
-		if ( is_user_logged_in() && $this->supports( 'tokens' ) && 0 == count( $this->tokens ) ) {
208
-			$tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true );
209
-
210
-			if ( is_array( $tokens ) ) {
211
-				$this->tokens = $tokens;
212
-			}
16
+    /**
17
+     * Set if the place checkout button should be renamed on selection.
18
+     *
19
+     * @var string
20
+     */
21
+    public $checkout_button_text;
22
+
23
+    /**
24
+     * Boolean whether the method is enabled.
25
+     *
26
+     * @var bool
27
+     */
28
+    public $enabled = true;
29
+
30
+    /**
31
+     * Payment method id.
32
+     *
33
+     * @var string
34
+     */
35
+    public $id;
36
+
37
+    /**
38
+     * Payment method order.
39
+     *
40
+     * @var int
41
+     */
42
+    public $order = 10;
43
+
44
+    /**
45
+     * Payment method title for the frontend.
46
+     *
47
+     * @var string
48
+     */
49
+    public $title;
50
+
51
+    /**
52
+     * Payment method description for the frontend.
53
+     *
54
+     * @var string
55
+     */
56
+    public $description;
57
+
58
+    /**
59
+     * Gateway title.
60
+     *
61
+     * @var string
62
+     */
63
+    public $method_title = '';
64
+
65
+    /**
66
+     * Gateway description.
67
+     *
68
+     * @var string
69
+     */
70
+    public $method_description = '';
71
+
72
+    /**
73
+     * Countries this gateway is allowed for.
74
+     *
75
+     * @var array
76
+     */
77
+    public $countries;
78
+
79
+    /**
80
+     * Currencies this gateway is allowed for.
81
+     *
82
+     * @var array
83
+     */
84
+    public $currencies;
85
+
86
+    /**
87
+     * Currencies this gateway is not allowed for.
88
+     *
89
+     * @var array
90
+     */
91
+    public $exclude_currencies;
92
+
93
+    /**
94
+     * Maximum transaction amount, zero does not define a maximum.
95
+     *
96
+     * @var int
97
+     */
98
+    public $max_amount = 0;
99
+
100
+    /**
101
+     * Optional URL to view a transaction.
102
+     *
103
+     * @var string
104
+     */
105
+    public $view_transaction_url = '';
106
+
107
+    /**
108
+     * Optional URL to view a subscription.
109
+     *
110
+     * @var string
111
+     */
112
+    public $view_subscription_url = '';
113
+
114
+    /**
115
+     * Optional label to show for "new payment method" in the payment
116
+     * method/token selection radio selection.
117
+     *
118
+     * @var string
119
+     */
120
+    public $new_method_label = '';
121
+
122
+    /**
123
+     * Contains a user's saved tokens for this gateway.
124
+     *
125
+     * @var array
126
+     */
127
+    protected $tokens = array();
128
+
129
+    /**
130
+     * An array of features that this gateway supports.
131
+     *
132
+     * @var array
133
+     */
134
+    protected $supports = array();
135
+
136
+    /**
137
+     * Class constructor.
138
+     */
139
+    public function __construct() {
140
+
141
+        // Register gateway.
142
+        add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) );
143
+
144
+        $this->enabled = wpinv_is_gateway_active( $this->id );
145
+
146
+        // Add support for various features.
147
+        foreach ( $this->supports as $feature ) {
148
+            add_filter( "wpinv_{$this->id}_support_{$feature}", '__return_true' );
149
+            add_filter( "getpaid_{$this->id}_support_{$feature}", '__return_true' );
150
+            add_filter( "getpaid_{$this->id}_supports_{$feature}", '__return_true' );
151
+        }
152
+
153
+        // Invoice addons.
154
+        if ( $this->supports( 'addons' ) ) {
155
+            add_action( "getpaid_process_{$this->id}_invoice_addons", array( $this, 'process_addons' ), 10, 2 );
156
+        }
157
+
158
+        // Gateway settings.
159
+        add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) );
160
+
161
+        // Gateway checkout fiellds.
162
+        add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 );
163
+
164
+        // Process payment.
165
+        add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 );
166
+
167
+        // Change the checkout button text.
168
+        if ( ! empty( $this->checkout_button_text ) ) {
169
+            add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) );
170
+        }
171
+
172
+        // Check if a gateway is valid for a given currency.
173
+        add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 );
174
+
175
+        // Generate the transaction url.
176
+        add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 );
177
+
178
+        // Generate the subscription url.
179
+        add_filter( 'getpaid_remote_subscription_profile_url', array( $this, 'generate_subscription_url' ), 10, 2 );
180
+
181
+        // Confirm payments.
182
+        add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 );
183
+
184
+        // Verify IPNs.
185
+        add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) );
186
+
187
+    }
188
+
189
+    /**
190
+     * Checks if this gateway is a given gateway.
191
+     *
192
+     * @since 1.0.19
193
+     * @return bool
194
+     */
195
+    public function is( $gateway ) {
196
+        return $gateway == $this->id;
197
+    }
198
+
199
+    /**
200
+     * Returns a users saved tokens for this gateway.
201
+     *
202
+     * @since 1.0.19
203
+     * @return array
204
+     */
205
+    public function get_tokens( $sandbox = null ) {
206
+
207
+        if ( is_user_logged_in() && $this->supports( 'tokens' ) && 0 == count( $this->tokens ) ) {
208
+            $tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true );
209
+
210
+            if ( is_array( $tokens ) ) {
211
+                $this->tokens = $tokens;
212
+            }
213 213
 }
214 214
 
215
-		if ( ! is_bool( $sandbox ) ) {
216
-			return $this->tokens;
217
-		}
218
-
219
-		// Filter tokens.
220
-		$args = array( 'type' => $sandbox ? 'sandbox' : 'live' );
221
-		return wp_list_filter( $this->tokens, $args );
222
-
223
-	}
224
-
225
-	/**
226
-	 * Saves a token for this gateway.
227
-	 *
228
-	 * @since 1.0.19
229
-	 */
230
-	public function save_token( $token ) {
231
-
232
-		$tokens   = $this->get_tokens();
233
-		$tokens[] = $token;
234
-
235
-		update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens );
236
-
237
-		$this->tokens = $tokens;
238
-
239
-	}
240
-
241
-	/**
242
-	 * Return the title for admin screens.
243
-	 *
244
-	 * @return string
245
-	 */
246
-	public function get_method_title() {
247
-		return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this );
248
-	}
249
-
250
-	/**
251
-	 * Return the description for admin screens.
252
-	 *
253
-	 * @return string
254
-	 */
255
-	public function get_method_description() {
256
-		return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this );
257
-	}
258
-
259
-	/**
260
-	 * Get the success url.
261
-	 *
262
-	 * @param WPInv_Invoice $invoice Invoice object.
263
-	 * @return string
264
-	 */
265
-	public function get_return_url( $invoice ) {
266
-
267
-		// Payment success url
268
-		$return_url = add_query_arg(
269
-			array(
270
-				'payment-confirm' => $this->id,
271
-				'invoice_key'     => $invoice->get_key(),
272
-				'utm_nooverride'  => 1,
273
-			),
274
-			wpinv_get_success_page_uri()
275
-		);
276
-
277
-		return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this );
278
-	}
279
-
280
-	/**
281
-	 * Confirms payments when rendering the success page.
282
-	 *
283
-	 * @param string $content Success page content.
284
-	 * @return string
285
-	 */
286
-	public function confirm_payment( $content ) {
287
-
288
-		// Retrieve the invoice.
289
-		$invoice_id = getpaid_get_current_invoice_id();
290
-		$invoice    = wpinv_get_invoice( $invoice_id );
291
-
292
-		// Ensure that it exists and that it is pending payment.
293
-		if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) {
294
-			return $content;
295
-		}
296
-
297
-		// Can the user view this invoice??
298
-		if ( ! wpinv_user_can_view_invoice( $invoice ) ) {
299
-			return $content;
300
-		}
301
-
302
-		// Show payment processing indicator.
303
-		return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) );
304
-	}
305
-
306
-	/**
307
-	 * Processes ipns and marks payments as complete.
308
-	 *
309
-	 * @return void
310
-	 */
311
-	public function verify_ipn() {}
312
-
313
-	/**
314
-	 * Processes invoice addons.
315
-	 *
316
-	 * @param WPInv_Invoice $invoice
317
-	 * @param GetPaid_Form_Item[] $items
318
-	 * @return WPInv_Invoice
319
-	 */
320
-	public function process_addons( $invoice, $items ) {
321
-
322
-	}
323
-
324
-	/**
325
-	 * Get a link to the transaction on the 3rd party gateway site (if applicable).
326
-	 *
327
-	 * @param string $transaction_url transaction url.
328
-	 * @param WPInv_Invoice $invoice Invoice object.
329
-	 * @return string transaction URL, or empty string.
330
-	 */
331
-	public function filter_transaction_url( $transaction_url, $invoice ) {
332
-
333
-		$transaction_id  = $invoice->get_transaction_id();
334
-
335
-		if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) {
336
-			$transaction_url = sprintf( $this->view_transaction_url, $transaction_id );
337
-			$replace         = $this->is_sandbox( $invoice ) ? 'sandbox' : '';
338
-			$transaction_url = str_replace( '{sandbox}', $replace, $transaction_url );
339
-		}
340
-
341
-		return $transaction_url;
342
-	}
343
-
344
-	/**
345
-	 * Get a link to the subscription on the 3rd party gateway site (if applicable).
346
-	 *
347
-	 * @param string $subscription_url transaction url.
348
-	 * @param WPInv_Subscription $subscription Subscription objectt.
349
-	 * @return string subscription URL, or empty string.
350
-	 */
351
-	public function generate_subscription_url( $subscription_url, $subscription ) {
352
-
353
-		$profile_id      = $subscription->get_profile_id();
354
-
355
-		if ( $this->id == $subscription->get_gateway() && ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) {
356
-
357
-			$subscription_url = sprintf( $this->view_subscription_url, $profile_id );
358
-			$replace          = $this->is_sandbox( $subscription->get_parent_invoice() ) ? 'sandbox' : '';
359
-			$subscription_url = str_replace( '{sandbox}', $replace, $subscription_url );
360
-
361
-		}
362
-
363
-		return $subscription_url;
364
-	}
365
-
366
-	/**
367
-	 * Check if the gateway is available for use.
368
-	 *
369
-	 * @return bool
370
-	 */
371
-	public function is_available() {
372
-		return ! empty( $this->enabled );
373
-	}
374
-
375
-	/**
376
-	 * Return the gateway's title.
377
-	 *
378
-	 * @return string
379
-	 */
380
-	public function get_title() {
381
-		return apply_filters( 'getpaid_gateway_title', $this->title, $this );
382
-	}
383
-
384
-	/**
385
-	 * Return the gateway's description.
386
-	 *
387
-	 * @return string
388
-	 */
389
-	public function get_description() {
390
-		return apply_filters( 'getpaid_gateway_description', $this->description, $this );
391
-	}
392
-
393
-	/**
394
-	 * Process Payment.
395
-	 *
396
-	 *
397
-	 * @param WPInv_Invoice $invoice Invoice.
398
-	 * @param array $submission_data Posted checkout fields.
399
-	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
400
-	 * @return void
401
-	 */
402
-	public function process_payment( $invoice, $submission_data, $submission ) {
403
-		// Process the payment then either redirect to the success page or the gateway.
404
-		do_action( 'getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission );
405
-	}
406
-
407
-	/**
408
-	 * Process refund.
409
-	 *
410
-	 * If the gateway declares 'refunds' support, this will allow it to refund.
411
-	 * a passed in amount.
412
-	 *
413
-	 * @param WPInv_Invoice $invoice Invoice.
414
-	 * @param  float  $amount Refund amount.
415
-	 * @param  string $reason Refund reason.
416
-	 * @return WP_Error|bool True or false based on success, or a WP_Error object.
417
-	 */
418
-	public function process_refund( $invoice, $amount = null, $reason = '' ) {
419
-		return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason );
420
-	}
421
-
422
-	/**
423
-	 * Displays the payment fields, credit cards etc.
424
-	 *
425
-	 * @param int $invoice_id 0 or invoice id.
426
-	 * @param GetPaid_Payment_Form $form Current payment form.
427
-	 */
428
-	public function payment_fields( $invoice_id, $form ) {
429
-		do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form );
430
-	}
431
-
432
-	/**
433
-	 * Filters the gateway settings.
434
-	 *
435
-	 * @param array $admin_settings
436
-	 */
437
-	public function admin_settings( $admin_settings ) {
438
-		return $admin_settings;
439
-	}
440
-
441
-	/**
442
-	 * Retrieves the value of a gateway setting.
443
-	 *
444
-	 * @param string $option
445
-	 */
446
-	public function get_option( $option, $default = false ) {
447
-		return wpinv_get_option( $this->id . '_' . $option, $default );
448
-	}
449
-
450
-	/**
451
-	 * Check if a gateway supports a given feature.
452
-	 *
453
-	 * Gateways should override this to declare support (or lack of support) for a feature.
454
-	 * For backward compatibility, gateways support 'products' by default, but nothing else.
455
-	 *
456
-	 * @param string $feature string The name of a feature to test support for.
457
-	 * @return bool True if the gateway supports the feature, false otherwise.
458
-	 * @since 1.0.19
459
-	 */
460
-	public function supports( $feature ) {
461
-		return getpaid_payment_gateway_supports( $this->id, $feature );
462
-	}
463
-
464
-	/**
465
-	 * Returns the credit card form html.
466
-	 *
467
-	 * @param bool $save whether or not to display the save button.
468
-	 */
215
+        if ( ! is_bool( $sandbox ) ) {
216
+            return $this->tokens;
217
+        }
218
+
219
+        // Filter tokens.
220
+        $args = array( 'type' => $sandbox ? 'sandbox' : 'live' );
221
+        return wp_list_filter( $this->tokens, $args );
222
+
223
+    }
224
+
225
+    /**
226
+     * Saves a token for this gateway.
227
+     *
228
+     * @since 1.0.19
229
+     */
230
+    public function save_token( $token ) {
231
+
232
+        $tokens   = $this->get_tokens();
233
+        $tokens[] = $token;
234
+
235
+        update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens );
236
+
237
+        $this->tokens = $tokens;
238
+
239
+    }
240
+
241
+    /**
242
+     * Return the title for admin screens.
243
+     *
244
+     * @return string
245
+     */
246
+    public function get_method_title() {
247
+        return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this );
248
+    }
249
+
250
+    /**
251
+     * Return the description for admin screens.
252
+     *
253
+     * @return string
254
+     */
255
+    public function get_method_description() {
256
+        return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this );
257
+    }
258
+
259
+    /**
260
+     * Get the success url.
261
+     *
262
+     * @param WPInv_Invoice $invoice Invoice object.
263
+     * @return string
264
+     */
265
+    public function get_return_url( $invoice ) {
266
+
267
+        // Payment success url
268
+        $return_url = add_query_arg(
269
+            array(
270
+                'payment-confirm' => $this->id,
271
+                'invoice_key'     => $invoice->get_key(),
272
+                'utm_nooverride'  => 1,
273
+            ),
274
+            wpinv_get_success_page_uri()
275
+        );
276
+
277
+        return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this );
278
+    }
279
+
280
+    /**
281
+     * Confirms payments when rendering the success page.
282
+     *
283
+     * @param string $content Success page content.
284
+     * @return string
285
+     */
286
+    public function confirm_payment( $content ) {
287
+
288
+        // Retrieve the invoice.
289
+        $invoice_id = getpaid_get_current_invoice_id();
290
+        $invoice    = wpinv_get_invoice( $invoice_id );
291
+
292
+        // Ensure that it exists and that it is pending payment.
293
+        if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) {
294
+            return $content;
295
+        }
296
+
297
+        // Can the user view this invoice??
298
+        if ( ! wpinv_user_can_view_invoice( $invoice ) ) {
299
+            return $content;
300
+        }
301
+
302
+        // Show payment processing indicator.
303
+        return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) );
304
+    }
305
+
306
+    /**
307
+     * Processes ipns and marks payments as complete.
308
+     *
309
+     * @return void
310
+     */
311
+    public function verify_ipn() {}
312
+
313
+    /**
314
+     * Processes invoice addons.
315
+     *
316
+     * @param WPInv_Invoice $invoice
317
+     * @param GetPaid_Form_Item[] $items
318
+     * @return WPInv_Invoice
319
+     */
320
+    public function process_addons( $invoice, $items ) {
321
+
322
+    }
323
+
324
+    /**
325
+     * Get a link to the transaction on the 3rd party gateway site (if applicable).
326
+     *
327
+     * @param string $transaction_url transaction url.
328
+     * @param WPInv_Invoice $invoice Invoice object.
329
+     * @return string transaction URL, or empty string.
330
+     */
331
+    public function filter_transaction_url( $transaction_url, $invoice ) {
332
+
333
+        $transaction_id  = $invoice->get_transaction_id();
334
+
335
+        if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) {
336
+            $transaction_url = sprintf( $this->view_transaction_url, $transaction_id );
337
+            $replace         = $this->is_sandbox( $invoice ) ? 'sandbox' : '';
338
+            $transaction_url = str_replace( '{sandbox}', $replace, $transaction_url );
339
+        }
340
+
341
+        return $transaction_url;
342
+    }
343
+
344
+    /**
345
+     * Get a link to the subscription on the 3rd party gateway site (if applicable).
346
+     *
347
+     * @param string $subscription_url transaction url.
348
+     * @param WPInv_Subscription $subscription Subscription objectt.
349
+     * @return string subscription URL, or empty string.
350
+     */
351
+    public function generate_subscription_url( $subscription_url, $subscription ) {
352
+
353
+        $profile_id      = $subscription->get_profile_id();
354
+
355
+        if ( $this->id == $subscription->get_gateway() && ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) {
356
+
357
+            $subscription_url = sprintf( $this->view_subscription_url, $profile_id );
358
+            $replace          = $this->is_sandbox( $subscription->get_parent_invoice() ) ? 'sandbox' : '';
359
+            $subscription_url = str_replace( '{sandbox}', $replace, $subscription_url );
360
+
361
+        }
362
+
363
+        return $subscription_url;
364
+    }
365
+
366
+    /**
367
+     * Check if the gateway is available for use.
368
+     *
369
+     * @return bool
370
+     */
371
+    public function is_available() {
372
+        return ! empty( $this->enabled );
373
+    }
374
+
375
+    /**
376
+     * Return the gateway's title.
377
+     *
378
+     * @return string
379
+     */
380
+    public function get_title() {
381
+        return apply_filters( 'getpaid_gateway_title', $this->title, $this );
382
+    }
383
+
384
+    /**
385
+     * Return the gateway's description.
386
+     *
387
+     * @return string
388
+     */
389
+    public function get_description() {
390
+        return apply_filters( 'getpaid_gateway_description', $this->description, $this );
391
+    }
392
+
393
+    /**
394
+     * Process Payment.
395
+     *
396
+     *
397
+     * @param WPInv_Invoice $invoice Invoice.
398
+     * @param array $submission_data Posted checkout fields.
399
+     * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
400
+     * @return void
401
+     */
402
+    public function process_payment( $invoice, $submission_data, $submission ) {
403
+        // Process the payment then either redirect to the success page or the gateway.
404
+        do_action( 'getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission );
405
+    }
406
+
407
+    /**
408
+     * Process refund.
409
+     *
410
+     * If the gateway declares 'refunds' support, this will allow it to refund.
411
+     * a passed in amount.
412
+     *
413
+     * @param WPInv_Invoice $invoice Invoice.
414
+     * @param  float  $amount Refund amount.
415
+     * @param  string $reason Refund reason.
416
+     * @return WP_Error|bool True or false based on success, or a WP_Error object.
417
+     */
418
+    public function process_refund( $invoice, $amount = null, $reason = '' ) {
419
+        return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason );
420
+    }
421
+
422
+    /**
423
+     * Displays the payment fields, credit cards etc.
424
+     *
425
+     * @param int $invoice_id 0 or invoice id.
426
+     * @param GetPaid_Payment_Form $form Current payment form.
427
+     */
428
+    public function payment_fields( $invoice_id, $form ) {
429
+        do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form );
430
+    }
431
+
432
+    /**
433
+     * Filters the gateway settings.
434
+     *
435
+     * @param array $admin_settings
436
+     */
437
+    public function admin_settings( $admin_settings ) {
438
+        return $admin_settings;
439
+    }
440
+
441
+    /**
442
+     * Retrieves the value of a gateway setting.
443
+     *
444
+     * @param string $option
445
+     */
446
+    public function get_option( $option, $default = false ) {
447
+        return wpinv_get_option( $this->id . '_' . $option, $default );
448
+    }
449
+
450
+    /**
451
+     * Check if a gateway supports a given feature.
452
+     *
453
+     * Gateways should override this to declare support (or lack of support) for a feature.
454
+     * For backward compatibility, gateways support 'products' by default, but nothing else.
455
+     *
456
+     * @param string $feature string The name of a feature to test support for.
457
+     * @return bool True if the gateway supports the feature, false otherwise.
458
+     * @since 1.0.19
459
+     */
460
+    public function supports( $feature ) {
461
+        return getpaid_payment_gateway_supports( $this->id, $feature );
462
+    }
463
+
464
+    /**
465
+     * Returns the credit card form html.
466
+     *
467
+     * @param bool $save whether or not to display the save button.
468
+     */
469 469
     public function get_cc_form( $save = false ) {
470 470
 
471
-		ob_start();
471
+        ob_start();
472 472
 
473 473
         $id_prefix = esc_attr( uniqid( $this->id ) );
474 474
 
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
 
529 529
                                             <?php
530 530
                                                 foreach ( $months as $key => $month ) {
531
-												echo "<option value='" . esc_attr( $key ) . "'>" . esc_html( $month ) . "</option>" . PHP_EOL;
531
+                                                echo "<option value='" . esc_attr( $key ) . "'>" . esc_html( $month ) . "</option>" . PHP_EOL;
532 532
                                                 }
533 533
                                             ?>
534 534
 
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
 
542 542
                                             <?php
543 543
                                                 foreach ( $years as $key => $year ) {
544
-												echo "<option value='" . esc_attr( $key ) . "'>" . esc_html( $year ) . "</option>" . PHP_EOL;
544
+                                                echo "<option value='" . esc_attr( $key ) . "'>" . esc_html( $year ) . "</option>" . PHP_EOL;
545 545
                                                 }
546 546
                                             ?>
547 547
 
@@ -559,13 +559,13 @@  discard block
 block discarded – undo
559 559
                                         'name'             => $this->id . '[cc_cvv2]',
560 560
                                         'id'               => "$id_prefix-cc-cvv2",
561 561
                                         'label'            => __( 'CCV', 'invoicing' ),
562
-										'label_type'       => 'vertical',
563
-										'class'            => 'form-control-sm',
564
-										'extra_attributes' => array(
565
-											'autocomplete' => 'cc-csc',
566
-										),
562
+                                        'label_type'       => 'vertical',
563
+                                        'class'            => 'form-control-sm',
564
+                                        'extra_attributes' => array(
565
+                                            'autocomplete' => 'cc-csc',
566
+                                        ),
567 567
                                     ),
568
-									true
568
+                                    true
569 569
                                 );
570 570
                             ?>
571 571
                         </div>
@@ -574,192 +574,192 @@  discard block
 block discarded – undo
574 574
 					
575 575
 					<?php
576 576
 
577
-						if ( $save ) {
578
-							$this->save_payment_method_checkbox();
579
-						}
577
+                        if ( $save ) {
578
+                            $this->save_payment_method_checkbox();
579
+                        }
580 580
 
581
-					?>
581
+                    ?>
582 582
                 </div>
583 583
 
584 584
             </div>
585 585
 		<?php
586 586
 
587
-		return ob_get_clean();
587
+        return ob_get_clean();
588
+
589
+    }
590
+
591
+    /**
592
+     * Displays a new payment method entry form.
593
+     *
594
+     * @since 1.0.19
595
+     */
596
+    public function new_payment_method_entry( $form ) {
597
+        echo "<div class='getpaid-new-payment-method-form' style='display:none;'> " . wp_kses( $form, getpaid_allowed_html() ) . " . </div>";
598
+    }
599
+
600
+    /**
601
+     * Grab and display our saved payment methods.
602
+     *
603
+     * @since 1.0.19
604
+     */
605
+    public function saved_payment_methods() {
606
+        echo '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr( count( $this->get_tokens( $this->is_sandbox() ) ) ) . '">';
607
+
608
+        foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) {
609
+            $this->get_saved_payment_method_option_html( $token );
610
+        }
611
+
612
+        $this->get_new_payment_method_option_html();
613
+        echo '</ul>';
588 614
 
589 615
     }
590 616
 
591
-	/**
592
-	 * Displays a new payment method entry form.
593
-	 *
594
-	 * @since 1.0.19
595
-	 */
596
-	public function new_payment_method_entry( $form ) {
597
-		echo "<div class='getpaid-new-payment-method-form' style='display:none;'> " . wp_kses( $form, getpaid_allowed_html() ) . " . </div>";
598
-	}
599
-
600
-	/**
601
-	 * Grab and display our saved payment methods.
602
-	 *
603
-	 * @since 1.0.19
604
-	 */
605
-	public function saved_payment_methods() {
606
-		echo '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr( count( $this->get_tokens( $this->is_sandbox() ) ) ) . '">';
607
-
608
-		foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) {
609
-			$this->get_saved_payment_method_option_html( $token );
610
-		}
611
-
612
-		$this->get_new_payment_method_option_html();
613
-		echo '</ul>';
614
-
615
-	}
616
-
617
-	/**
618
-	 * Gets saved payment method HTML from a token.
619
-	 *
620
-	 * @since 1.0.19
621
-	 * @param  array $token Payment Token.
622
-	 * @return string Generated payment method HTML
623
-	 */
624
-	public function get_saved_payment_method_option_html( $token ) {
625
-
626
-		printf(
627
-			'<li class="getpaid-payment-method form-group">
617
+    /**
618
+     * Gets saved payment method HTML from a token.
619
+     *
620
+     * @since 1.0.19
621
+     * @param  array $token Payment Token.
622
+     * @return string Generated payment method HTML
623
+     */
624
+    public function get_saved_payment_method_option_html( $token ) {
625
+
626
+        printf(
627
+            '<li class="getpaid-payment-method form-group">
628 628
 				<label>
629 629
 					<input name="getpaid-%1$s-payment-method" type="radio" value="%2$s" data-currency="%5$s" style="width:auto;" class="getpaid-saved-payment-method-token-input" %4$s />
630 630
 					<span>%3$s</span>
631 631
 				</label>
632 632
 			</li>',
633
-			esc_attr( $this->id ),
634
-			esc_attr( $token['id'] ),
635
-			esc_html( $token['name'] ),
636
-			checked( empty( $token['default'] ), false, false ),
637
-			empty( $token['currency'] ) ? 'none' : esc_attr( $token['currency'] )
638
-		);
639
-
640
-	}
641
-
642
-	/**
643
-	 * Displays a radio button for entering a new payment method (new CC details) instead of using a saved method.
644
-	 *
645
-	 * @since 1.0.19
646
-	 */
647
-	public function get_new_payment_method_option_html() {
648
-
649
-		$label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this );
650
-
651
-		printf(
652
-			'<li class="getpaid-new-payment-method">
633
+            esc_attr( $this->id ),
634
+            esc_attr( $token['id'] ),
635
+            esc_html( $token['name'] ),
636
+            checked( empty( $token['default'] ), false, false ),
637
+            empty( $token['currency'] ) ? 'none' : esc_attr( $token['currency'] )
638
+        );
639
+
640
+    }
641
+
642
+    /**
643
+     * Displays a radio button for entering a new payment method (new CC details) instead of using a saved method.
644
+     *
645
+     * @since 1.0.19
646
+     */
647
+    public function get_new_payment_method_option_html() {
648
+
649
+        $label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this );
650
+
651
+        printf(
652
+            '<li class="getpaid-new-payment-method">
653 653
 				<label>
654 654
 					<input name="getpaid-%1$s-payment-method" type="radio" data-currency="none" value="new" style="width:auto;" />
655 655
 					<span>%2$s</span>
656 656
 				</label>
657 657
 			</li>',
658
-			esc_attr( $this->id ),
659
-			esc_html( $label )
660
-		);
661
-
662
-	}
663
-
664
-	/**
665
-	 * Outputs a checkbox for saving a new payment method to the database.
666
-	 *
667
-	 * @since 1.0.19
668
-	 */
669
-	public function save_payment_method_checkbox() {
670
-
671
-		aui()->input(
672
-			array(
673
-				'type'       => 'checkbox',
674
-				'name'       => esc_attr( "getpaid-$this->id-new-payment-method" ),
675
-				'id'         => esc_attr( uniqid( $this->id ) ),
676
-				'required'   => false,
677
-				'label'      => esc_html__( 'Save payment method', 'invoicing' ),
678
-				'value'      => 'true',
679
-				'checked'    => true,
680
-				'wrap_class' => 'getpaid-save-payment-method pt-1 pb-1',
681
-			),
682
-			true
683
-		);
684
-
685
-	}
686
-
687
-	/**
688
-	 * Registers the gateway.
689
-	 *
690
-	 * @return array
691
-	 */
692
-	public function register_gateway( $gateways ) {
693
-
694
-		$gateways[ $this->id ] = array(
695
-
696
-			'admin_label'    => $this->method_title,
658
+            esc_attr( $this->id ),
659
+            esc_html( $label )
660
+        );
661
+
662
+    }
663
+
664
+    /**
665
+     * Outputs a checkbox for saving a new payment method to the database.
666
+     *
667
+     * @since 1.0.19
668
+     */
669
+    public function save_payment_method_checkbox() {
670
+
671
+        aui()->input(
672
+            array(
673
+                'type'       => 'checkbox',
674
+                'name'       => esc_attr( "getpaid-$this->id-new-payment-method" ),
675
+                'id'         => esc_attr( uniqid( $this->id ) ),
676
+                'required'   => false,
677
+                'label'      => esc_html__( 'Save payment method', 'invoicing' ),
678
+                'value'      => 'true',
679
+                'checked'    => true,
680
+                'wrap_class' => 'getpaid-save-payment-method pt-1 pb-1',
681
+            ),
682
+            true
683
+        );
684
+
685
+    }
686
+
687
+    /**
688
+     * Registers the gateway.
689
+     *
690
+     * @return array
691
+     */
692
+    public function register_gateway( $gateways ) {
693
+
694
+        $gateways[ $this->id ] = array(
695
+
696
+            'admin_label'    => $this->method_title,
697 697
             'checkout_label' => $this->title,
698
-			'ordering'       => $this->order,
698
+            'ordering'       => $this->order,
699 699
 
700
-		);
700
+        );
701 701
 
702
-		return $gateways;
702
+        return $gateways;
703 703
 
704
-	}
704
+    }
705 705
 
706
-	/**
707
-	 * Checks whether or not this is a sandbox request.
708
-	 *
709
-	 * @param  WPInv_Invoice|null $invoice Invoice object or null.
710
-	 * @return bool
711
-	 */
712
-	public function is_sandbox( $invoice = null ) {
706
+    /**
707
+     * Checks whether or not this is a sandbox request.
708
+     *
709
+     * @param  WPInv_Invoice|null $invoice Invoice object or null.
710
+     * @return bool
711
+     */
712
+    public function is_sandbox( $invoice = null ) {
713 713
 
714
-		if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) {
715
-			return $invoice->get_mode() == 'test';
716
-		}
714
+        if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) {
715
+            return $invoice->get_mode() == 'test';
716
+        }
717 717
 
718
-		return wpinv_is_test_mode( $this->id );
718
+        return wpinv_is_test_mode( $this->id );
719 719
 
720
-	}
720
+    }
721 721
 
722
-	/**
723
-	 * Renames the checkout button
724
-	 *
725
-	 * @return string
726
-	 */
727
-	public function rename_checkout_button() {
728
-		return $this->checkout_button_text;
729
-	}
722
+    /**
723
+     * Renames the checkout button
724
+     *
725
+     * @return string
726
+     */
727
+    public function rename_checkout_button() {
728
+        return $this->checkout_button_text;
729
+    }
730 730
 
731
-	/**
732
-	 * Validate gateway currency
733
-	 *
734
-	 * @return bool
735
-	 */
736
-	public function validate_currency( $validation, $currency ) {
731
+    /**
732
+     * Validate gateway currency
733
+     *
734
+     * @return bool
735
+     */
736
+    public function validate_currency( $validation, $currency ) {
737 737
 
738
-		// Required currencies.
739
-		if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) {
740
-			return false;
741
-		}
738
+        // Required currencies.
739
+        if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) {
740
+            return false;
741
+        }
742 742
 
743
-		// Excluded currencies.
744
-		if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) {
745
-			return false;
746
-		}
743
+        // Excluded currencies.
744
+        if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) {
745
+            return false;
746
+        }
747 747
 
748
-		return $validation;
749
-	}
748
+        return $validation;
749
+    }
750 750
 
751
-	/**
752
-	 * Displays an error
753
-	 *
754
-	 */
755
-	public function show_error( $code, $message, $type ) {
751
+    /**
752
+     * Displays an error
753
+     *
754
+     */
755
+    public function show_error( $code, $message, $type ) {
756 756
 
757
-		if ( is_admin() ) {
758
-			getpaid_admin()->{"show_$type"}( $message );
759
-		}
757
+        if ( is_admin() ) {
758
+            getpaid_admin()->{"show_$type"}( $message );
759
+        }
760 760
 
761
-		wpinv_set_error( $code, $message, $type );
761
+        wpinv_set_error( $code, $message, $type );
762 762
 
763
-	}
763
+    }
764 764
 
765 765
 }
Please login to merge, or discard this patch.
Spacing   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Abstaract Payment Gateway class.
@@ -139,50 +139,50 @@  discard block
 block discarded – undo
139 139
 	public function __construct() {
140 140
 
141 141
 		// Register gateway.
142
-		add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) );
142
+		add_filter('wpinv_payment_gateways', array($this, 'register_gateway'));
143 143
 
144
-		$this->enabled = wpinv_is_gateway_active( $this->id );
144
+		$this->enabled = wpinv_is_gateway_active($this->id);
145 145
 
146 146
 		// Add support for various features.
147
-		foreach ( $this->supports as $feature ) {
148
-			add_filter( "wpinv_{$this->id}_support_{$feature}", '__return_true' );
149
-			add_filter( "getpaid_{$this->id}_support_{$feature}", '__return_true' );
150
-			add_filter( "getpaid_{$this->id}_supports_{$feature}", '__return_true' );
147
+		foreach ($this->supports as $feature) {
148
+			add_filter("wpinv_{$this->id}_support_{$feature}", '__return_true');
149
+			add_filter("getpaid_{$this->id}_support_{$feature}", '__return_true');
150
+			add_filter("getpaid_{$this->id}_supports_{$feature}", '__return_true');
151 151
 		}
152 152
 
153 153
 		// Invoice addons.
154
-		if ( $this->supports( 'addons' ) ) {
155
-			add_action( "getpaid_process_{$this->id}_invoice_addons", array( $this, 'process_addons' ), 10, 2 );
154
+		if ($this->supports('addons')) {
155
+			add_action("getpaid_process_{$this->id}_invoice_addons", array($this, 'process_addons'), 10, 2);
156 156
 		}
157 157
 
158 158
 		// Gateway settings.
159
-		add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) );
159
+		add_filter("wpinv_gateway_settings_{$this->id}", array($this, 'admin_settings'));
160 160
 
161 161
 		// Gateway checkout fiellds.
162
-		add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 );
162
+		add_action("wpinv_{$this->id}_cc_form", array($this, 'payment_fields'), 10, 2);
163 163
 
164 164
 		// Process payment.
165
-		add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 );
165
+		add_action("getpaid_gateway_{$this->id}", array($this, 'process_payment'), 10, 3);
166 166
 
167 167
 		// Change the checkout button text.
168
-		if ( ! empty( $this->checkout_button_text ) ) {
169
-			add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) );
168
+		if (!empty($this->checkout_button_text)) {
169
+			add_filter("getpaid_gateway_{$this->id}_checkout_button_label", array($this, 'rename_checkout_button'));
170 170
 		}
171 171
 
172 172
 		// Check if a gateway is valid for a given currency.
173
-		add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 );
173
+		add_filter("getpaid_gateway_{$this->id}_is_valid_for_currency", array($this, 'validate_currency'), 10, 2);
174 174
 
175 175
 		// Generate the transaction url.
176
-		add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 );
176
+		add_filter("getpaid_gateway_{$this->id}_transaction_url", array($this, 'filter_transaction_url'), 10, 2);
177 177
 
178 178
 		// Generate the subscription url.
179
-		add_filter( 'getpaid_remote_subscription_profile_url', array( $this, 'generate_subscription_url' ), 10, 2 );
179
+		add_filter('getpaid_remote_subscription_profile_url', array($this, 'generate_subscription_url'), 10, 2);
180 180
 
181 181
 		// Confirm payments.
182
-		add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 );
182
+		add_filter("wpinv_payment_confirm_{$this->id}", array($this, 'confirm_payment'), 10, 2);
183 183
 
184 184
 		// Verify IPNs.
185
-		add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) );
185
+		add_action("wpinv_verify_{$this->id}_ipn", array($this, 'verify_ipn'));
186 186
 
187 187
 	}
188 188
 
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	 * @since 1.0.19
193 193
 	 * @return bool
194 194
 	 */
195
-	public function is( $gateway ) {
195
+	public function is($gateway) {
196 196
 		return $gateway == $this->id;
197 197
 	}
198 198
 
@@ -202,23 +202,23 @@  discard block
 block discarded – undo
202 202
 	 * @since 1.0.19
203 203
 	 * @return array
204 204
 	 */
205
-	public function get_tokens( $sandbox = null ) {
205
+	public function get_tokens($sandbox = null) {
206 206
 
207
-		if ( is_user_logged_in() && $this->supports( 'tokens' ) && 0 == count( $this->tokens ) ) {
208
-			$tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true );
207
+		if (is_user_logged_in() && $this->supports('tokens') && 0 == count($this->tokens)) {
208
+			$tokens = get_user_meta(get_current_user_id(), "getpaid_{$this->id}_tokens", true);
209 209
 
210
-			if ( is_array( $tokens ) ) {
210
+			if (is_array($tokens)) {
211 211
 				$this->tokens = $tokens;
212 212
 			}
213 213
 }
214 214
 
215
-		if ( ! is_bool( $sandbox ) ) {
215
+		if (!is_bool($sandbox)) {
216 216
 			return $this->tokens;
217 217
 		}
218 218
 
219 219
 		// Filter tokens.
220
-		$args = array( 'type' => $sandbox ? 'sandbox' : 'live' );
221
-		return wp_list_filter( $this->tokens, $args );
220
+		$args = array('type' => $sandbox ? 'sandbox' : 'live');
221
+		return wp_list_filter($this->tokens, $args);
222 222
 
223 223
 	}
224 224
 
@@ -227,12 +227,12 @@  discard block
 block discarded – undo
227 227
 	 *
228 228
 	 * @since 1.0.19
229 229
 	 */
230
-	public function save_token( $token ) {
230
+	public function save_token($token) {
231 231
 
232 232
 		$tokens   = $this->get_tokens();
233 233
 		$tokens[] = $token;
234 234
 
235
-		update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens );
235
+		update_user_meta(get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens);
236 236
 
237 237
 		$this->tokens = $tokens;
238 238
 
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 	 * @return string
245 245
 	 */
246 246
 	public function get_method_title() {
247
-		return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this );
247
+		return apply_filters('getpaid_gateway_method_title', $this->method_title, $this);
248 248
 	}
249 249
 
250 250
 	/**
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 	 * @return string
254 254
 	 */
255 255
 	public function get_method_description() {
256
-		return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this );
256
+		return apply_filters('getpaid_gateway_method_description', $this->method_description, $this);
257 257
 	}
258 258
 
259 259
 	/**
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 	 * @param WPInv_Invoice $invoice Invoice object.
263 263
 	 * @return string
264 264
 	 */
265
-	public function get_return_url( $invoice ) {
265
+	public function get_return_url($invoice) {
266 266
 
267 267
 		// Payment success url
268 268
 		$return_url = add_query_arg(
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 			wpinv_get_success_page_uri()
275 275
 		);
276 276
 
277
-		return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this );
277
+		return apply_filters('getpaid_gateway_success_url', $return_url, $invoice, $this);
278 278
 	}
279 279
 
280 280
 	/**
@@ -283,24 +283,24 @@  discard block
 block discarded – undo
283 283
 	 * @param string $content Success page content.
284 284
 	 * @return string
285 285
 	 */
286
-	public function confirm_payment( $content ) {
286
+	public function confirm_payment($content) {
287 287
 
288 288
 		// Retrieve the invoice.
289 289
 		$invoice_id = getpaid_get_current_invoice_id();
290
-		$invoice    = wpinv_get_invoice( $invoice_id );
290
+		$invoice    = wpinv_get_invoice($invoice_id);
291 291
 
292 292
 		// Ensure that it exists and that it is pending payment.
293
-		if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) {
293
+		if (empty($invoice_id) || !$invoice->needs_payment()) {
294 294
 			return $content;
295 295
 		}
296 296
 
297 297
 		// Can the user view this invoice??
298
-		if ( ! wpinv_user_can_view_invoice( $invoice ) ) {
298
+		if (!wpinv_user_can_view_invoice($invoice)) {
299 299
 			return $content;
300 300
 		}
301 301
 
302 302
 		// Show payment processing indicator.
303
-		return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) );
303
+		return wpinv_get_template_html('wpinv-payment-processing.php', compact('invoice'));
304 304
 	}
305 305
 
306 306
 	/**
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 	 * @param GetPaid_Form_Item[] $items
318 318
 	 * @return WPInv_Invoice
319 319
 	 */
320
-	public function process_addons( $invoice, $items ) {
320
+	public function process_addons($invoice, $items) {
321 321
 
322 322
 	}
323 323
 
@@ -328,14 +328,14 @@  discard block
 block discarded – undo
328 328
 	 * @param WPInv_Invoice $invoice Invoice object.
329 329
 	 * @return string transaction URL, or empty string.
330 330
 	 */
331
-	public function filter_transaction_url( $transaction_url, $invoice ) {
331
+	public function filter_transaction_url($transaction_url, $invoice) {
332 332
 
333
-		$transaction_id  = $invoice->get_transaction_id();
333
+		$transaction_id = $invoice->get_transaction_id();
334 334
 
335
-		if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) {
336
-			$transaction_url = sprintf( $this->view_transaction_url, $transaction_id );
337
-			$replace         = $this->is_sandbox( $invoice ) ? 'sandbox' : '';
338
-			$transaction_url = str_replace( '{sandbox}', $replace, $transaction_url );
335
+		if (!empty($this->view_transaction_url) && !empty($transaction_id)) {
336
+			$transaction_url = sprintf($this->view_transaction_url, $transaction_id);
337
+			$replace         = $this->is_sandbox($invoice) ? 'sandbox' : '';
338
+			$transaction_url = str_replace('{sandbox}', $replace, $transaction_url);
339 339
 		}
340 340
 
341 341
 		return $transaction_url;
@@ -348,15 +348,15 @@  discard block
 block discarded – undo
348 348
 	 * @param WPInv_Subscription $subscription Subscription objectt.
349 349
 	 * @return string subscription URL, or empty string.
350 350
 	 */
351
-	public function generate_subscription_url( $subscription_url, $subscription ) {
351
+	public function generate_subscription_url($subscription_url, $subscription) {
352 352
 
353
-		$profile_id      = $subscription->get_profile_id();
353
+		$profile_id = $subscription->get_profile_id();
354 354
 
355
-		if ( $this->id == $subscription->get_gateway() && ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) {
355
+		if ($this->id == $subscription->get_gateway() && !empty($this->view_subscription_url) && !empty($profile_id)) {
356 356
 
357
-			$subscription_url = sprintf( $this->view_subscription_url, $profile_id );
358
-			$replace          = $this->is_sandbox( $subscription->get_parent_invoice() ) ? 'sandbox' : '';
359
-			$subscription_url = str_replace( '{sandbox}', $replace, $subscription_url );
357
+			$subscription_url = sprintf($this->view_subscription_url, $profile_id);
358
+			$replace          = $this->is_sandbox($subscription->get_parent_invoice()) ? 'sandbox' : '';
359
+			$subscription_url = str_replace('{sandbox}', $replace, $subscription_url);
360 360
 
361 361
 		}
362 362
 
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 	 * @return bool
370 370
 	 */
371 371
 	public function is_available() {
372
-		return ! empty( $this->enabled );
372
+		return !empty($this->enabled);
373 373
 	}
374 374
 
375 375
 	/**
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 	 * @return string
379 379
 	 */
380 380
 	public function get_title() {
381
-		return apply_filters( 'getpaid_gateway_title', $this->title, $this );
381
+		return apply_filters('getpaid_gateway_title', $this->title, $this);
382 382
 	}
383 383
 
384 384
 	/**
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 	 * @return string
388 388
 	 */
389 389
 	public function get_description() {
390
-		return apply_filters( 'getpaid_gateway_description', $this->description, $this );
390
+		return apply_filters('getpaid_gateway_description', $this->description, $this);
391 391
 	}
392 392
 
393 393
 	/**
@@ -399,9 +399,9 @@  discard block
 block discarded – undo
399 399
 	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
400 400
 	 * @return void
401 401
 	 */
402
-	public function process_payment( $invoice, $submission_data, $submission ) {
402
+	public function process_payment($invoice, $submission_data, $submission) {
403 403
 		// Process the payment then either redirect to the success page or the gateway.
404
-		do_action( 'getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission );
404
+		do_action('getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission);
405 405
 	}
406 406
 
407 407
 	/**
@@ -415,8 +415,8 @@  discard block
 block discarded – undo
415 415
 	 * @param  string $reason Refund reason.
416 416
 	 * @return WP_Error|bool True or false based on success, or a WP_Error object.
417 417
 	 */
418
-	public function process_refund( $invoice, $amount = null, $reason = '' ) {
419
-		return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason );
418
+	public function process_refund($invoice, $amount = null, $reason = '') {
419
+		return apply_filters('getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason);
420 420
 	}
421 421
 
422 422
 	/**
@@ -425,8 +425,8 @@  discard block
 block discarded – undo
425 425
 	 * @param int $invoice_id 0 or invoice id.
426 426
 	 * @param GetPaid_Payment_Form $form Current payment form.
427 427
 	 */
428
-	public function payment_fields( $invoice_id, $form ) {
429
-		do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form );
428
+	public function payment_fields($invoice_id, $form) {
429
+		do_action('getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form);
430 430
 	}
431 431
 
432 432
 	/**
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
 	 *
435 435
 	 * @param array $admin_settings
436 436
 	 */
437
-	public function admin_settings( $admin_settings ) {
437
+	public function admin_settings($admin_settings) {
438 438
 		return $admin_settings;
439 439
 	}
440 440
 
@@ -443,8 +443,8 @@  discard block
 block discarded – undo
443 443
 	 *
444 444
 	 * @param string $option
445 445
 	 */
446
-	public function get_option( $option, $default = false ) {
447
-		return wpinv_get_option( $this->id . '_' . $option, $default );
446
+	public function get_option($option, $default = false) {
447
+		return wpinv_get_option($this->id . '_' . $option, $default);
448 448
 	}
449 449
 
450 450
 	/**
@@ -457,8 +457,8 @@  discard block
 block discarded – undo
457 457
 	 * @return bool True if the gateway supports the feature, false otherwise.
458 458
 	 * @since 1.0.19
459 459
 	 */
460
-	public function supports( $feature ) {
461
-		return getpaid_payment_gateway_supports( $this->id, $feature );
460
+	public function supports($feature) {
461
+		return getpaid_payment_gateway_supports($this->id, $feature);
462 462
 	}
463 463
 
464 464
 	/**
@@ -466,36 +466,36 @@  discard block
 block discarded – undo
466 466
 	 *
467 467
 	 * @param bool $save whether or not to display the save button.
468 468
 	 */
469
-    public function get_cc_form( $save = false ) {
469
+    public function get_cc_form($save = false) {
470 470
 
471 471
 		ob_start();
472 472
 
473
-        $id_prefix = esc_attr( uniqid( $this->id ) );
473
+        $id_prefix = esc_attr(uniqid($this->id));
474 474
 
475 475
         $months = array(
476
-            '01' => __( 'January', 'invoicing' ),
477
-            '02' => __( 'February', 'invoicing' ),
478
-            '03' => __( 'March', 'invoicing' ),
479
-            '04' => __( 'April', 'invoicing' ),
480
-            '05' => __( 'May', 'invoicing' ),
481
-            '06' => __( 'June', 'invoicing' ),
482
-            '07' => __( 'July', 'invoicing' ),
483
-            '08' => __( 'August', 'invoicing' ),
484
-            '09' => __( 'September', 'invoicing' ),
485
-            '10' => __( 'October', 'invoicing' ),
486
-            '11' => __( 'November', 'invoicing' ),
487
-            '12' => __( 'December', 'invoicing' ),
476
+            '01' => __('January', 'invoicing'),
477
+            '02' => __('February', 'invoicing'),
478
+            '03' => __('March', 'invoicing'),
479
+            '04' => __('April', 'invoicing'),
480
+            '05' => __('May', 'invoicing'),
481
+            '06' => __('June', 'invoicing'),
482
+            '07' => __('July', 'invoicing'),
483
+            '08' => __('August', 'invoicing'),
484
+            '09' => __('September', 'invoicing'),
485
+            '10' => __('October', 'invoicing'),
486
+            '11' => __('November', 'invoicing'),
487
+            '12' => __('December', 'invoicing'),
488 488
         );
489 489
 
490
-        $year  = (int) date( 'Y', current_time( 'timestamp' ) );
490
+        $year  = (int) date('Y', current_time('timestamp'));
491 491
         $years = array();
492 492
 
493
-        for ( $i = 0; $i <= 10; $i++ ) {
494
-            $years[ $year + $i ] = $year + $i;
493
+        for ($i = 0; $i <= 10; $i++) {
494
+            $years[$year + $i] = $year + $i;
495 495
         }
496 496
 
497 497
         ?>
498
-            <div class="<?php echo esc_attr( $this->id ); ?>-cc-form getpaid-cc-form mt-1">
498
+            <div class="<?php echo esc_attr($this->id); ?>-cc-form getpaid-cc-form mt-1">
499 499
 
500 500
 
501 501
                 <div class="getpaid-cc-card-inner">
@@ -504,14 +504,14 @@  discard block
 block discarded – undo
504 504
                         <div class="col-12">
505 505
 
506 506
 							<div class="form-group">
507
-								<label for="<?php echo esc_attr( "$id_prefix-cc-number" ); ?>"><?php esc_html_e( 'Card number', 'invoicing' ); ?></label>
507
+								<label for="<?php echo esc_attr("$id_prefix-cc-number"); ?>"><?php esc_html_e('Card number', 'invoicing'); ?></label>
508 508
 								<div class="input-group input-group-sm">
509 509
 									<div class="input-group-prepend ">
510 510
 										<span class="input-group-text">
511 511
 											<i class="fa fa-credit-card"></i>
512 512
 										</span>
513 513
 									</div>
514
-									<input type="text" name="<?php echo esc_attr( $this->id . '[cc_number]' ); ?>" id="<?php echo esc_attr( "$id_prefix-cc-number" ); ?>" class="form-control form-control-sm" autocomplete="cc-number">
514
+									<input type="text" name="<?php echo esc_attr($this->id . '[cc_number]'); ?>" id="<?php echo esc_attr("$id_prefix-cc-number"); ?>" class="form-control form-control-sm" autocomplete="cc-number">
515 515
 								</div>
516 516
 							</div>
517 517
 
@@ -519,16 +519,16 @@  discard block
 block discarded – undo
519 519
 
520 520
                         <div class="col-12">
521 521
                             <div class="form-group">
522
-                                <label><?php esc_html_e( 'Expiration', 'invoicing' ); ?></label>
522
+                                <label><?php esc_html_e('Expiration', 'invoicing'); ?></label>
523 523
                                 <div class="form-row">
524 524
 
525 525
                                     <div class="col">
526
-                                        <select class="form-control form-control-sm" autocomplete="cc-exp-month" name="<?php echo esc_attr( $this->id ); ?>[cc_expire_month]">
527
-                                            <option disabled selected="selected"><?php esc_html_e( 'MM', 'invoicing' ); ?></option>
526
+                                        <select class="form-control form-control-sm" autocomplete="cc-exp-month" name="<?php echo esc_attr($this->id); ?>[cc_expire_month]">
527
+                                            <option disabled selected="selected"><?php esc_html_e('MM', 'invoicing'); ?></option>
528 528
 
529 529
                                             <?php
530
-                                                foreach ( $months as $key => $month ) {
531
-												echo "<option value='" . esc_attr( $key ) . "'>" . esc_html( $month ) . "</option>" . PHP_EOL;
530
+                                                foreach ($months as $key => $month) {
531
+												echo "<option value='" . esc_attr($key) . "'>" . esc_html($month) . "</option>" . PHP_EOL;
532 532
                                                 }
533 533
                                             ?>
534 534
 
@@ -536,12 +536,12 @@  discard block
 block discarded – undo
536 536
                                     </div>
537 537
 
538 538
                                     <div class="col">
539
-                                        <select class="form-control form-control-sm" autocomplete="cc-exp-year" name="<?php echo esc_attr( $this->id ); ?>[cc_expire_year]">
540
-                                            <option disabled selected="selected"><?php esc_html_e( 'YY', 'invoicing' ); ?></option>
539
+                                        <select class="form-control form-control-sm" autocomplete="cc-exp-year" name="<?php echo esc_attr($this->id); ?>[cc_expire_year]">
540
+                                            <option disabled selected="selected"><?php esc_html_e('YY', 'invoicing'); ?></option>
541 541
 
542 542
                                             <?php
543
-                                                foreach ( $years as $key => $year ) {
544
-												echo "<option value='" . esc_attr( $key ) . "'>" . esc_html( $year ) . "</option>" . PHP_EOL;
543
+                                                foreach ($years as $key => $year) {
544
+												echo "<option value='" . esc_attr($key) . "'>" . esc_html($year) . "</option>" . PHP_EOL;
545 545
                                                 }
546 546
                                             ?>
547 547
 
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
                                     array(
559 559
                                         'name'             => $this->id . '[cc_cvv2]',
560 560
                                         'id'               => "$id_prefix-cc-cvv2",
561
-                                        'label'            => __( 'CCV', 'invoicing' ),
561
+                                        'label'            => __('CCV', 'invoicing'),
562 562
 										'label_type'       => 'vertical',
563 563
 										'class'            => 'form-control-sm',
564 564
 										'extra_attributes' => array(
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
 					
575 575
 					<?php
576 576
 
577
-						if ( $save ) {
577
+						if ($save) {
578 578
 							$this->save_payment_method_checkbox();
579 579
 						}
580 580
 
@@ -593,8 +593,8 @@  discard block
 block discarded – undo
593 593
 	 *
594 594
 	 * @since 1.0.19
595 595
 	 */
596
-	public function new_payment_method_entry( $form ) {
597
-		echo "<div class='getpaid-new-payment-method-form' style='display:none;'> " . wp_kses( $form, getpaid_allowed_html() ) . " . </div>";
596
+	public function new_payment_method_entry($form) {
597
+		echo "<div class='getpaid-new-payment-method-form' style='display:none;'> " . wp_kses($form, getpaid_allowed_html()) . " . </div>";
598 598
 	}
599 599
 
600 600
 	/**
@@ -603,10 +603,10 @@  discard block
 block discarded – undo
603 603
 	 * @since 1.0.19
604 604
 	 */
605 605
 	public function saved_payment_methods() {
606
-		echo '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr( count( $this->get_tokens( $this->is_sandbox() ) ) ) . '">';
606
+		echo '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr(count($this->get_tokens($this->is_sandbox()))) . '">';
607 607
 
608
-		foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) {
609
-			$this->get_saved_payment_method_option_html( $token );
608
+		foreach ($this->get_tokens($this->is_sandbox()) as $token) {
609
+			$this->get_saved_payment_method_option_html($token);
610 610
 		}
611 611
 
612 612
 		$this->get_new_payment_method_option_html();
@@ -621,7 +621,7 @@  discard block
 block discarded – undo
621 621
 	 * @param  array $token Payment Token.
622 622
 	 * @return string Generated payment method HTML
623 623
 	 */
624
-	public function get_saved_payment_method_option_html( $token ) {
624
+	public function get_saved_payment_method_option_html($token) {
625 625
 
626 626
 		printf(
627 627
 			'<li class="getpaid-payment-method form-group">
@@ -630,11 +630,11 @@  discard block
 block discarded – undo
630 630
 					<span>%3$s</span>
631 631
 				</label>
632 632
 			</li>',
633
-			esc_attr( $this->id ),
634
-			esc_attr( $token['id'] ),
635
-			esc_html( $token['name'] ),
636
-			checked( empty( $token['default'] ), false, false ),
637
-			empty( $token['currency'] ) ? 'none' : esc_attr( $token['currency'] )
633
+			esc_attr($this->id),
634
+			esc_attr($token['id']),
635
+			esc_html($token['name']),
636
+			checked(empty($token['default']), false, false),
637
+			empty($token['currency']) ? 'none' : esc_attr($token['currency'])
638 638
 		);
639 639
 
640 640
 	}
@@ -646,7 +646,7 @@  discard block
 block discarded – undo
646 646
 	 */
647 647
 	public function get_new_payment_method_option_html() {
648 648
 
649
-		$label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this );
649
+		$label = apply_filters('getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __('Use a new payment method', 'invoicing'), $this);
650 650
 
651 651
 		printf(
652 652
 			'<li class="getpaid-new-payment-method">
@@ -655,8 +655,8 @@  discard block
 block discarded – undo
655 655
 					<span>%2$s</span>
656 656
 				</label>
657 657
 			</li>',
658
-			esc_attr( $this->id ),
659
-			esc_html( $label )
658
+			esc_attr($this->id),
659
+			esc_html($label)
660 660
 		);
661 661
 
662 662
 	}
@@ -671,10 +671,10 @@  discard block
 block discarded – undo
671 671
 		aui()->input(
672 672
 			array(
673 673
 				'type'       => 'checkbox',
674
-				'name'       => esc_attr( "getpaid-$this->id-new-payment-method" ),
675
-				'id'         => esc_attr( uniqid( $this->id ) ),
674
+				'name'       => esc_attr("getpaid-$this->id-new-payment-method"),
675
+				'id'         => esc_attr(uniqid($this->id)),
676 676
 				'required'   => false,
677
-				'label'      => esc_html__( 'Save payment method', 'invoicing' ),
677
+				'label'      => esc_html__('Save payment method', 'invoicing'),
678 678
 				'value'      => 'true',
679 679
 				'checked'    => true,
680 680
 				'wrap_class' => 'getpaid-save-payment-method pt-1 pb-1',
@@ -689,9 +689,9 @@  discard block
 block discarded – undo
689 689
 	 *
690 690
 	 * @return array
691 691
 	 */
692
-	public function register_gateway( $gateways ) {
692
+	public function register_gateway($gateways) {
693 693
 
694
-		$gateways[ $this->id ] = array(
694
+		$gateways[$this->id] = array(
695 695
 
696 696
 			'admin_label'    => $this->method_title,
697 697
             'checkout_label' => $this->title,
@@ -709,13 +709,13 @@  discard block
 block discarded – undo
709 709
 	 * @param  WPInv_Invoice|null $invoice Invoice object or null.
710 710
 	 * @return bool
711 711
 	 */
712
-	public function is_sandbox( $invoice = null ) {
712
+	public function is_sandbox($invoice = null) {
713 713
 
714
-		if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) {
714
+		if (!empty($invoice) && !$invoice->needs_payment()) {
715 715
 			return $invoice->get_mode() == 'test';
716 716
 		}
717 717
 
718
-		return wpinv_is_test_mode( $this->id );
718
+		return wpinv_is_test_mode($this->id);
719 719
 
720 720
 	}
721 721
 
@@ -733,15 +733,15 @@  discard block
 block discarded – undo
733 733
 	 *
734 734
 	 * @return bool
735 735
 	 */
736
-	public function validate_currency( $validation, $currency ) {
736
+	public function validate_currency($validation, $currency) {
737 737
 
738 738
 		// Required currencies.
739
-		if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) {
739
+		if (!empty($this->currencies) && !in_array($currency, $this->currencies)) {
740 740
 			return false;
741 741
 		}
742 742
 
743 743
 		// Excluded currencies.
744
-		if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) {
744
+		if (!empty($this->exclude_currencies) && in_array($currency, $this->exclude_currencies)) {
745 745
 			return false;
746 746
 		}
747 747
 
@@ -752,13 +752,13 @@  discard block
 block discarded – undo
752 752
 	 * Displays an error
753 753
 	 *
754 754
 	 */
755
-	public function show_error( $code, $message, $type ) {
755
+	public function show_error($code, $message, $type) {
756 756
 
757
-		if ( is_admin() ) {
758
-			getpaid_admin()->{"show_$type"}( $message );
757
+		if (is_admin()) {
758
+			getpaid_admin()->{"show_$type"}($message);
759 759
 		}
760 760
 
761
-		wpinv_set_error( $code, $message, $type );
761
+		wpinv_set_error($code, $message, $type);
762 762
 
763 763
 	}
764 764
 
Please login to merge, or discard this patch.
includes/reports/class-getpaid-reports.php 2 patches
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -12,49 +12,49 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Reports {
14 14
 
15
-	/**
16
-	 * Class constructor.
17
-	 *
18
-	 */
19
-	public function __construct() {
20
-		add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 );
21
-		add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) );
22
-		add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) );
23
-		add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) );
24
-		add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) );
25
-
26
-	}
27
-
28
-	/**
29
-	 * Registers the reports page.
30
-	 *
31
-	 */
32
-	public function register_reports_page() {
33
-
34
-		add_submenu_page(
15
+    /**
16
+     * Class constructor.
17
+     *
18
+     */
19
+    public function __construct() {
20
+        add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 );
21
+        add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) );
22
+        add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) );
23
+        add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) );
24
+        add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) );
25
+
26
+    }
27
+
28
+    /**
29
+     * Registers the reports page.
30
+     *
31
+     */
32
+    public function register_reports_page() {
33
+
34
+        add_submenu_page(
35 35
             'wpinv',
36 36
             __( 'Reports', 'invoicing' ),
37 37
             __( 'Reports', 'invoicing' ),
38 38
             wpinv_get_capability(),
39 39
             'wpinv-reports',
40 40
             array( $this, 'display_reports_page' )
41
-		);
41
+        );
42 42
 
43
-	}
43
+    }
44 44
 
45
-	/**
46
-	 * Displays the reports page.
47
-	 *
48
-	 */
49
-	public function display_reports_page() {
45
+    /**
46
+     * Displays the reports page.
47
+     *
48
+     */
49
+    public function display_reports_page() {
50 50
 
51
-		// Prepare variables.
52
-		$tabs        = $this->get_tabs();
53
-		$current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports';
54
-		$current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports';
51
+        // Prepare variables.
52
+        $tabs        = $this->get_tabs();
53
+        $current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports';
54
+        $current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports';
55 55
 
56
-		// Display the current tab.
57
-		?>
56
+        // Display the current tab.
57
+        ?>
58 58
 
59 59
         <div class="wrap">
60 60
 
@@ -63,19 +63,19 @@  discard block
 block discarded – undo
63 63
 			<nav class="nav-tab-wrapper">
64 64
 
65 65
 				<?php
66
-					foreach ( $tabs as $key => $label ) {
66
+                    foreach ( $tabs as $key => $label ) {
67 67
 
68
-					$key   = sanitize_key( $key );
69
-					$label = esc_html( $label );
70
-					$class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab';
71
-					$url   = esc_url(
68
+                    $key   = sanitize_key( $key );
69
+                    $label = esc_html( $label );
70
+                    $class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab';
71
+                    $url   = esc_url(
72 72
                         add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) )
73 73
                     );
74 74
 
75
-				echo wp_kses_post( "\n\t\t\t<a href='$url' class='" . $class . "'>$label</a>" );
75
+                echo wp_kses_post( "\n\t\t\t<a href='$url' class='" . $class . "'>$label</a>" );
76 76
 
77
-					}
78
-				?>
77
+                    }
78
+                ?>
79 79
 
80 80
 			</nav>
81 81
 
@@ -86,82 +86,82 @@  discard block
 block discarded – undo
86 86
         </div>
87 87
 		<?php
88 88
 
89
-			// Wordfence loads an unsupported version of chart js on our page.
90
-			wp_deregister_style( 'chart-js' );
91
-			wp_deregister_script( 'chart-js' );
92
-			wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array( 'jquery' ), '3.7.1', true );
89
+            // Wordfence loads an unsupported version of chart js on our page.
90
+            wp_deregister_style( 'chart-js' );
91
+            wp_deregister_script( 'chart-js' );
92
+            wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array( 'jquery' ), '3.7.1', true );
93 93
 
94
-	}
94
+    }
95 95
 
96
-	/**
97
-	 * Retrieves reports page tabs.
98
-	 *
99
-	 * @return array
100
-	 */
101
-	public function get_tabs() {
96
+    /**
97
+     * Retrieves reports page tabs.
98
+     *
99
+     * @return array
100
+     */
101
+    public function get_tabs() {
102 102
 
103
-		$tabs = array(
104
-			'reports' => __( 'Reports', 'invoicing' ),
105
-			'export'  => __( 'Export', 'invoicing' ),
106
-		);
103
+        $tabs = array(
104
+            'reports' => __( 'Reports', 'invoicing' ),
105
+            'export'  => __( 'Export', 'invoicing' ),
106
+        );
107 107
 
108
-		return apply_filters( 'getpaid_report_tabs', $tabs );
109
-	}
108
+        return apply_filters( 'getpaid_report_tabs', $tabs );
109
+    }
110 110
 
111
-	/**
112
-	 * Displays the reports tab.
113
-	 *
114
-	 */
115
-	public function display_reports_tab() {
111
+    /**
112
+     * Displays the reports tab.
113
+     *
114
+     */
115
+    public function display_reports_tab() {
116 116
 
117
-		$reports = new GetPaid_Reports_Report();
118
-		$reports->display();
117
+        $reports = new GetPaid_Reports_Report();
118
+        $reports->display();
119 119
 
120
-	}
120
+    }
121 121
 
122
-	/**
123
-	 * Displays the exports tab.
124
-	 *
125
-	 */
126
-	public function display_exports_tab() {
122
+    /**
123
+     * Displays the exports tab.
124
+     *
125
+     */
126
+    public function display_exports_tab() {
127 127
 
128
-		$exports = new GetPaid_Reports_Export();
129
-		$exports->display();
128
+        $exports = new GetPaid_Reports_Export();
129
+        $exports->display();
130 130
 
131
-	}
131
+    }
132 132
 
133
-	/**
134
-	 * Donwnloads a graph.
135
-	 *
136
-	 * @param array $args
137
-	 */
138
-	public function download_graph( $args ) {
133
+    /**
134
+     * Donwnloads a graph.
135
+     *
136
+     * @param array $args
137
+     */
138
+    public function download_graph( $args ) {
139 139
 
140
-		if ( ! empty( $args['graph'] ) ) {
141
-			$downloader = new GetPaid_Graph_Downloader();
142
-			$downloader->download( $args['graph'] );
143
-		}
140
+        if ( ! empty( $args['graph'] ) ) {
141
+            $downloader = new GetPaid_Graph_Downloader();
142
+            $downloader->download( $args['graph'] );
143
+        }
144 144
 
145
-	}
145
+    }
146 146
 
147
-	/**
148
-	 * Exports invoices.
149
-	 *
150
-	 * @param array $args
151
-	 */
152
-	public function export_invoices( $args ) {
147
+    /**
148
+     * Exports invoices.
149
+     *
150
+     * @param array $args
151
+     */
152
+    public function export_invoices( $args ) {
153 153
 
154
-		if ( ! empty( $args['post_type'] ) ) {
154
+        if ( ! empty( $args['post_type'] ) ) {
155 155
 
156
-			if ( 'subscriptions' === $args['post_type'] ) {
157
-				$downloader = new GetPaid_Subscription_Exporter();
158
-			} else {
159
-				$downloader = new GetPaid_Invoice_Exporter();
160
-			}
156
+            if ( 'subscriptions' === $args['post_type'] ) {
157
+                $downloader = new GetPaid_Subscription_Exporter();
158
+            } else {
159
+                $downloader = new GetPaid_Invoice_Exporter();
160
+            }
161 161
 
162
-			$downloader->export( $args['post_type'], $args );
163
-		}
162
+            $downloader->export( $args['post_type'], $args );
163
+        }
164 164
 
165
-	}
165
+    }
166 166
 
167 167
 }
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 /**
11 11
  * GetPaid_Reports Class.
@@ -17,11 +17,11 @@  discard block
 block discarded – undo
17 17
 	 *
18 18
 	 */
19 19
 	public function __construct() {
20
-		add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 );
21
-		add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) );
22
-		add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) );
23
-		add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) );
24
-		add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) );
20
+		add_action('admin_menu', array($this, 'register_reports_page'), 20);
21
+		add_action('wpinv_reports_tab_reports', array($this, 'display_reports_tab'));
22
+		add_action('wpinv_reports_tab_export', array($this, 'display_exports_tab'));
23
+		add_action('getpaid_authenticated_admin_action_download_graph', array($this, 'download_graph'));
24
+		add_action('getpaid_authenticated_admin_action_export_invoices', array($this, 'export_invoices'));
25 25
 
26 26
 	}
27 27
 
@@ -33,11 +33,11 @@  discard block
 block discarded – undo
33 33
 
34 34
 		add_submenu_page(
35 35
             'wpinv',
36
-            __( 'Reports', 'invoicing' ),
37
-            __( 'Reports', 'invoicing' ),
36
+            __('Reports', 'invoicing'),
37
+            __('Reports', 'invoicing'),
38 38
             wpinv_get_capability(),
39 39
             'wpinv-reports',
40
-            array( $this, 'display_reports_page' )
40
+            array($this, 'display_reports_page')
41 41
 		);
42 42
 
43 43
 	}
@@ -50,46 +50,46 @@  discard block
 block discarded – undo
50 50
 
51 51
 		// Prepare variables.
52 52
 		$tabs        = $this->get_tabs();
53
-		$current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports';
54
-		$current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports';
53
+		$current_tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'reports';
54
+		$current_tab = array_key_exists($current_tab, $tabs) ? $current_tab : 'reports';
55 55
 
56 56
 		// Display the current tab.
57 57
 		?>
58 58
 
59 59
         <div class="wrap">
60 60
 
61
-			<h1><?php echo esc_html( $tabs[ $current_tab ] ); ?></h1>
61
+			<h1><?php echo esc_html($tabs[$current_tab]); ?></h1>
62 62
 
63 63
 			<nav class="nav-tab-wrapper">
64 64
 
65 65
 				<?php
66
-					foreach ( $tabs as $key => $label ) {
66
+					foreach ($tabs as $key => $label) {
67 67
 
68
-					$key   = sanitize_key( $key );
69
-					$label = esc_html( $label );
68
+					$key   = sanitize_key($key);
69
+					$label = esc_html($label);
70 70
 					$class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab';
71 71
 					$url   = esc_url(
72
-                        add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) )
72
+                        add_query_arg('tab', $key, admin_url('admin.php?page=wpinv-reports'))
73 73
                     );
74 74
 
75
-				echo wp_kses_post( "\n\t\t\t<a href='$url' class='" . $class . "'>$label</a>" );
75
+				echo wp_kses_post("\n\t\t\t<a href='$url' class='" . $class . "'>$label</a>");
76 76
 
77 77
 					}
78 78
 				?>
79 79
 
80 80
 			</nav>
81 81
 
82
-			<div class="bsui <?php echo esc_attr( $current_tab ); ?>">
83
-				<?php do_action( "wpinv_reports_tab_{$current_tab}" ); ?>
82
+			<div class="bsui <?php echo esc_attr($current_tab); ?>">
83
+				<?php do_action("wpinv_reports_tab_{$current_tab}"); ?>
84 84
 			</div>
85 85
 
86 86
         </div>
87 87
 		<?php
88 88
 
89 89
 			// Wordfence loads an unsupported version of chart js on our page.
90
-			wp_deregister_style( 'chart-js' );
91
-			wp_deregister_script( 'chart-js' );
92
-			wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array( 'jquery' ), '3.7.1', true );
90
+			wp_deregister_style('chart-js');
91
+			wp_deregister_script('chart-js');
92
+			wp_enqueue_script('chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array('jquery'), '3.7.1', true);
93 93
 
94 94
 	}
95 95
 
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
 	public function get_tabs() {
102 102
 
103 103
 		$tabs = array(
104
-			'reports' => __( 'Reports', 'invoicing' ),
105
-			'export'  => __( 'Export', 'invoicing' ),
104
+			'reports' => __('Reports', 'invoicing'),
105
+			'export'  => __('Export', 'invoicing'),
106 106
 		);
107 107
 
108
-		return apply_filters( 'getpaid_report_tabs', $tabs );
108
+		return apply_filters('getpaid_report_tabs', $tabs);
109 109
 	}
110 110
 
111 111
 	/**
@@ -135,11 +135,11 @@  discard block
 block discarded – undo
135 135
 	 *
136 136
 	 * @param array $args
137 137
 	 */
138
-	public function download_graph( $args ) {
138
+	public function download_graph($args) {
139 139
 
140
-		if ( ! empty( $args['graph'] ) ) {
140
+		if (!empty($args['graph'])) {
141 141
 			$downloader = new GetPaid_Graph_Downloader();
142
-			$downloader->download( $args['graph'] );
142
+			$downloader->download($args['graph']);
143 143
 		}
144 144
 
145 145
 	}
@@ -149,17 +149,17 @@  discard block
 block discarded – undo
149 149
 	 *
150 150
 	 * @param array $args
151 151
 	 */
152
-	public function export_invoices( $args ) {
152
+	public function export_invoices($args) {
153 153
 
154
-		if ( ! empty( $args['post_type'] ) ) {
154
+		if (!empty($args['post_type'])) {
155 155
 
156
-			if ( 'subscriptions' === $args['post_type'] ) {
156
+			if ('subscriptions' === $args['post_type']) {
157 157
 				$downloader = new GetPaid_Subscription_Exporter();
158 158
 			} else {
159 159
 				$downloader = new GetPaid_Invoice_Exporter();
160 160
 			}
161 161
 
162
-			$downloader->export( $args['post_type'], $args );
162
+			$downloader->export($args['post_type'], $args);
163 163
 		}
164 164
 
165 165
 	}
Please login to merge, or discard this patch.
includes/reports/class-getpaid-reports-export.php 2 patches
Indentation   +178 added lines, -178 removed lines patch added patch discarded remove patch
@@ -12,47 +12,47 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Reports_Export {
14 14
 
15
-	/**
16
-	 * Displays the reports tab.
17
-	 *
18
-	 */
19
-	public function display() {
20
-
21
-		echo "<div class='row mt-4' style='max-width: 920px;' >";
22
-		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
23
-			$this->display_post_type_export( $post_type );
24
-		}
25
-		$this->display_subscription_export();
26
-		echo '</div>';
27
-
28
-	}
29
-
30
-	/**
31
-	 * Retrieves the download url.
32
-	 *
33
-	 */
34
-	public function get_download_url( $post_type ) {
35
-
36
-		return wp_nonce_url(
37
-			add_query_arg(
38
-				array(
39
-					'getpaid-admin-action' => 'export_invoices',
40
-					'post_type'            => urlencode( $post_type ),
41
-				)
42
-			),
43
-			'getpaid-nonce',
44
-			'getpaid-nonce'
45
-		);
46
-
47
-	}
48
-
49
-	/**
50
-	 * Displays a single post type export card.
51
-	 *
52
-	 */
53
-	public function display_post_type_export( $post_type ) {
54
-
55
-		?>
15
+    /**
16
+     * Displays the reports tab.
17
+     *
18
+     */
19
+    public function display() {
20
+
21
+        echo "<div class='row mt-4' style='max-width: 920px;' >";
22
+        foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
23
+            $this->display_post_type_export( $post_type );
24
+        }
25
+        $this->display_subscription_export();
26
+        echo '</div>';
27
+
28
+    }
29
+
30
+    /**
31
+     * Retrieves the download url.
32
+     *
33
+     */
34
+    public function get_download_url( $post_type ) {
35
+
36
+        return wp_nonce_url(
37
+            add_query_arg(
38
+                array(
39
+                    'getpaid-admin-action' => 'export_invoices',
40
+                    'post_type'            => urlencode( $post_type ),
41
+                )
42
+            ),
43
+            'getpaid-nonce',
44
+            'getpaid-nonce'
45
+        );
46
+
47
+    }
48
+
49
+    /**
50
+     * Displays a single post type export card.
51
+     *
52
+     */
53
+    public function display_post_type_export( $post_type ) {
54
+
55
+        ?>
56 56
 
57 57
 		<div class="col-12 col-md-6">
58 58
 			<div class="card m-0 p-0" style="max-width:100%">
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
 				<div class="card-header">
61 61
 					<strong>
62 62
 						<?php
63
-							printf(
64
-								esc_html__( 'Export %s', 'invoicing' ),
65
-								esc_html( getpaid_get_post_type_label( $post_type ) )
66
-							);
67
-						?>
63
+                            printf(
64
+                                esc_html__( 'Export %s', 'invoicing' ),
65
+                                esc_html( getpaid_get_post_type_label( $post_type ) )
66
+                            );
67
+                        ?>
68 68
 					</strong>
69 69
 				</div>
70 70
 
@@ -73,12 +73,12 @@  discard block
 block discarded – undo
73 73
 					<form method="post" action="<?php echo esc_url( $this->get_download_url( $post_type ) ); ?>">
74 74
 
75 75
 						<?php
76
-							$this->display_markup( $this->generate_from_date( $post_type ) );
77
-							$this->display_markup( $this->generate_to_date( $post_type ) );
78
-							$this->display_markup( $this->generate_post_status_select( $post_type ) );
79
-							$this->display_markup( $this->generate_file_type_select( $post_type ) );
80
-							submit_button( __( 'Download', 'invoicing' ) );
81
-						?>
76
+                            $this->display_markup( $this->generate_from_date( $post_type ) );
77
+                            $this->display_markup( $this->generate_to_date( $post_type ) );
78
+                            $this->display_markup( $this->generate_post_status_select( $post_type ) );
79
+                            $this->display_markup( $this->generate_file_type_select( $post_type ) );
80
+                            submit_button( __( 'Download', 'invoicing' ) );
81
+                        ?>
82 82
 
83 83
 					</form>
84 84
 
@@ -89,125 +89,125 @@  discard block
 block discarded – undo
89 89
 
90 90
 		<?php
91 91
 
92
-	}
93
-
94
-	/**
95
-	 * Generates the from date input field.
96
-	 *
97
-	 */
98
-	public function generate_from_date( $post_type ) {
99
-
100
-		return aui()->input(
101
-			array(
102
-				'name'        => 'from_date',
103
-				'id'          => esc_attr( "$post_type-from_date" ),
104
-				'placeholder' => 'yy-mm-dd',
105
-				'label'       => __( 'From Date', 'invoicing' ),
106
-				'label_type'  => 'vertical',
107
-				'label_class' => 'd-block',
108
-				'type'        => 'datepicker',
109
-			)
110
-		);
111
-
112
-	}
113
-
114
-	/**
115
-	 * Generates the to date input field.
116
-	 *
117
-	 */
118
-	public function generate_to_date( $post_type ) {
119
-
120
-		return aui()->input(
121
-			array(
122
-				'name'        => 'to_date',
123
-				'id'          => esc_attr( "$post_type-to_date" ),
124
-				'placeholder' => 'yy-mm-dd',
125
-				'label'       => __( 'To Date', 'invoicing' ),
126
-				'label_type'  => 'vertical',
127
-				'label_class' => 'd-block',
128
-				'type'        => 'datepicker',
129
-			)
130
-		);
131
-
132
-	}
133
-
134
-	/**
135
-	 * Generates the to post status select field.
136
-	 *
137
-	 */
138
-	public function generate_post_status_select( $post_type ) {
139
-
140
-		if ( 'subscriptions' === $post_type ) {
141
-			$options = getpaid_get_subscription_statuses();
142
-		} else {
143
-			$options = wpinv_get_invoice_statuses( true, false, $post_type );
144
-		}
145
-
146
-		return aui()->select(
147
-			array(
148
-				'name'        => 'status',
149
-				'id'          => esc_attr( "$post_type-status" ),
150
-				'placeholder' => __( 'All Statuses', 'invoicing' ),
151
-				'label'       => __( 'Status', 'invoicing' ),
152
-				'label_type'  => 'vertical',
153
-				'label_class' => 'd-block',
154
-				'options'     => $options,
155
-			)
156
-		);
157
-
158
-	}
159
-
160
-	/**
161
-	 * Generates the to file type select field.
162
-	 *
163
-	 */
164
-	public function generate_file_type_select( $post_type ) {
165
-
166
-		return aui()->select(
167
-			array(
168
-				'name'        => 'file_type',
169
-				'id'          => esc_attr( "$post_type-file_type" ),
170
-				'placeholder' => __( 'Select File Type', 'invoicing' ),
171
-				'label'       => __( 'Export File', 'invoicing' ),
172
-				'label_type'  => 'vertical',
173
-				'label_class' => 'd-block',
174
-				'options'     => array(
175
-					'csv'  => __( 'CSV', 'invoicing' ),
176
-					'xml'  => __( 'XML', 'invoicing' ),
177
-					'json' => __( 'JSON', 'invoicing' ),
178
-				),
179
-			)
180
-		);
181
-
182
-	}
183
-
184
-	/**
185
-	 * Displays a field's markup.
186
-	 *
187
-	 */
188
-	public function display_markup( $markup ) {
189
-
190
-		echo wp_kses(
191
-			str_replace(
192
-				array(
193
-					'form-control',
194
-					'custom-select',
195
-				),
196
-				'regular-text',
197
-				$markup
198
-			),
199
-			getpaid_allowed_html()
200
-		);
201
-
202
-	}
203
-
204
-	/**
205
-	 * Displays a subscription export card.
206
-	 *
207
-	 */
208
-	public function display_subscription_export() {
209
-
210
-		?>
92
+    }
93
+
94
+    /**
95
+     * Generates the from date input field.
96
+     *
97
+     */
98
+    public function generate_from_date( $post_type ) {
99
+
100
+        return aui()->input(
101
+            array(
102
+                'name'        => 'from_date',
103
+                'id'          => esc_attr( "$post_type-from_date" ),
104
+                'placeholder' => 'yy-mm-dd',
105
+                'label'       => __( 'From Date', 'invoicing' ),
106
+                'label_type'  => 'vertical',
107
+                'label_class' => 'd-block',
108
+                'type'        => 'datepicker',
109
+            )
110
+        );
111
+
112
+    }
113
+
114
+    /**
115
+     * Generates the to date input field.
116
+     *
117
+     */
118
+    public function generate_to_date( $post_type ) {
119
+
120
+        return aui()->input(
121
+            array(
122
+                'name'        => 'to_date',
123
+                'id'          => esc_attr( "$post_type-to_date" ),
124
+                'placeholder' => 'yy-mm-dd',
125
+                'label'       => __( 'To Date', 'invoicing' ),
126
+                'label_type'  => 'vertical',
127
+                'label_class' => 'd-block',
128
+                'type'        => 'datepicker',
129
+            )
130
+        );
131
+
132
+    }
133
+
134
+    /**
135
+     * Generates the to post status select field.
136
+     *
137
+     */
138
+    public function generate_post_status_select( $post_type ) {
139
+
140
+        if ( 'subscriptions' === $post_type ) {
141
+            $options = getpaid_get_subscription_statuses();
142
+        } else {
143
+            $options = wpinv_get_invoice_statuses( true, false, $post_type );
144
+        }
145
+
146
+        return aui()->select(
147
+            array(
148
+                'name'        => 'status',
149
+                'id'          => esc_attr( "$post_type-status" ),
150
+                'placeholder' => __( 'All Statuses', 'invoicing' ),
151
+                'label'       => __( 'Status', 'invoicing' ),
152
+                'label_type'  => 'vertical',
153
+                'label_class' => 'd-block',
154
+                'options'     => $options,
155
+            )
156
+        );
157
+
158
+    }
159
+
160
+    /**
161
+     * Generates the to file type select field.
162
+     *
163
+     */
164
+    public function generate_file_type_select( $post_type ) {
165
+
166
+        return aui()->select(
167
+            array(
168
+                'name'        => 'file_type',
169
+                'id'          => esc_attr( "$post_type-file_type" ),
170
+                'placeholder' => __( 'Select File Type', 'invoicing' ),
171
+                'label'       => __( 'Export File', 'invoicing' ),
172
+                'label_type'  => 'vertical',
173
+                'label_class' => 'd-block',
174
+                'options'     => array(
175
+                    'csv'  => __( 'CSV', 'invoicing' ),
176
+                    'xml'  => __( 'XML', 'invoicing' ),
177
+                    'json' => __( 'JSON', 'invoicing' ),
178
+                ),
179
+            )
180
+        );
181
+
182
+    }
183
+
184
+    /**
185
+     * Displays a field's markup.
186
+     *
187
+     */
188
+    public function display_markup( $markup ) {
189
+
190
+        echo wp_kses(
191
+            str_replace(
192
+                array(
193
+                    'form-control',
194
+                    'custom-select',
195
+                ),
196
+                'regular-text',
197
+                $markup
198
+            ),
199
+            getpaid_allowed_html()
200
+        );
201
+
202
+    }
203
+
204
+    /**
205
+     * Displays a subscription export card.
206
+     *
207
+     */
208
+    public function display_subscription_export() {
209
+
210
+        ?>
211 211
 
212 212
 		<div class="col-12 col-md-6">
213 213
 			<div class="card m-0 p-0" style="max-width:100%">
@@ -223,12 +223,12 @@  discard block
 block discarded – undo
223 223
 					<form method="post" action="<?php echo esc_url( $this->get_download_url( 'subscriptions' ) ); ?>">
224 224
 
225 225
 						<?php
226
-							$this->display_markup( $this->generate_from_date( 'subscriptions' ) );
227
-							$this->display_markup( $this->generate_to_date( 'subscriptions' ) );
228
-							$this->display_markup( $this->generate_post_status_select( 'subscriptions' ) );
229
-							$this->display_markup( $this->generate_file_type_select( 'subscriptions' ) );
230
-							submit_button( __( 'Download', 'invoicing' ) );
231
-						?>
226
+                            $this->display_markup( $this->generate_from_date( 'subscriptions' ) );
227
+                            $this->display_markup( $this->generate_to_date( 'subscriptions' ) );
228
+                            $this->display_markup( $this->generate_post_status_select( 'subscriptions' ) );
229
+                            $this->display_markup( $this->generate_file_type_select( 'subscriptions' ) );
230
+                            submit_button( __( 'Download', 'invoicing' ) );
231
+                        ?>
232 232
 
233 233
 					</form>
234 234
 
@@ -239,6 +239,6 @@  discard block
 block discarded – undo
239 239
 
240 240
 		<?php
241 241
 
242
-	}
242
+    }
243 243
 
244 244
 }
Please login to merge, or discard this patch.
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 /**
11 11
  * GetPaid_Reports_Export Class.
@@ -19,8 +19,8 @@  discard block
 block discarded – undo
19 19
 	public function display() {
20 20
 
21 21
 		echo "<div class='row mt-4' style='max-width: 920px;' >";
22
-		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
23
-			$this->display_post_type_export( $post_type );
22
+		foreach (array_keys(getpaid_get_invoice_post_types()) as $post_type) {
23
+			$this->display_post_type_export($post_type);
24 24
 		}
25 25
 		$this->display_subscription_export();
26 26
 		echo '</div>';
@@ -31,13 +31,13 @@  discard block
 block discarded – undo
31 31
 	 * Retrieves the download url.
32 32
 	 *
33 33
 	 */
34
-	public function get_download_url( $post_type ) {
34
+	public function get_download_url($post_type) {
35 35
 
36 36
 		return wp_nonce_url(
37 37
 			add_query_arg(
38 38
 				array(
39 39
 					'getpaid-admin-action' => 'export_invoices',
40
-					'post_type'            => urlencode( $post_type ),
40
+					'post_type'            => urlencode($post_type),
41 41
 				)
42 42
 			),
43 43
 			'getpaid-nonce',
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 * Displays a single post type export card.
51 51
 	 *
52 52
 	 */
53
-	public function display_post_type_export( $post_type ) {
53
+	public function display_post_type_export($post_type) {
54 54
 
55 55
 		?>
56 56
 
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
 					<strong>
62 62
 						<?php
63 63
 							printf(
64
-								esc_html__( 'Export %s', 'invoicing' ),
65
-								esc_html( getpaid_get_post_type_label( $post_type ) )
64
+								esc_html__('Export %s', 'invoicing'),
65
+								esc_html(getpaid_get_post_type_label($post_type))
66 66
 							);
67 67
 						?>
68 68
 					</strong>
@@ -70,14 +70,14 @@  discard block
 block discarded – undo
70 70
 
71 71
 				<div class="card-body">
72 72
 
73
-					<form method="post" action="<?php echo esc_url( $this->get_download_url( $post_type ) ); ?>">
73
+					<form method="post" action="<?php echo esc_url($this->get_download_url($post_type)); ?>">
74 74
 
75 75
 						<?php
76
-							$this->display_markup( $this->generate_from_date( $post_type ) );
77
-							$this->display_markup( $this->generate_to_date( $post_type ) );
78
-							$this->display_markup( $this->generate_post_status_select( $post_type ) );
79
-							$this->display_markup( $this->generate_file_type_select( $post_type ) );
80
-							submit_button( __( 'Download', 'invoicing' ) );
76
+							$this->display_markup($this->generate_from_date($post_type));
77
+							$this->display_markup($this->generate_to_date($post_type));
78
+							$this->display_markup($this->generate_post_status_select($post_type));
79
+							$this->display_markup($this->generate_file_type_select($post_type));
80
+							submit_button(__('Download', 'invoicing'));
81 81
 						?>
82 82
 
83 83
 					</form>
@@ -95,14 +95,14 @@  discard block
 block discarded – undo
95 95
 	 * Generates the from date input field.
96 96
 	 *
97 97
 	 */
98
-	public function generate_from_date( $post_type ) {
98
+	public function generate_from_date($post_type) {
99 99
 
100 100
 		return aui()->input(
101 101
 			array(
102 102
 				'name'        => 'from_date',
103
-				'id'          => esc_attr( "$post_type-from_date" ),
103
+				'id'          => esc_attr("$post_type-from_date"),
104 104
 				'placeholder' => 'yy-mm-dd',
105
-				'label'       => __( 'From Date', 'invoicing' ),
105
+				'label'       => __('From Date', 'invoicing'),
106 106
 				'label_type'  => 'vertical',
107 107
 				'label_class' => 'd-block',
108 108
 				'type'        => 'datepicker',
@@ -115,14 +115,14 @@  discard block
 block discarded – undo
115 115
 	 * Generates the to date input field.
116 116
 	 *
117 117
 	 */
118
-	public function generate_to_date( $post_type ) {
118
+	public function generate_to_date($post_type) {
119 119
 
120 120
 		return aui()->input(
121 121
 			array(
122 122
 				'name'        => 'to_date',
123
-				'id'          => esc_attr( "$post_type-to_date" ),
123
+				'id'          => esc_attr("$post_type-to_date"),
124 124
 				'placeholder' => 'yy-mm-dd',
125
-				'label'       => __( 'To Date', 'invoicing' ),
125
+				'label'       => __('To Date', 'invoicing'),
126 126
 				'label_type'  => 'vertical',
127 127
 				'label_class' => 'd-block',
128 128
 				'type'        => 'datepicker',
@@ -135,20 +135,20 @@  discard block
 block discarded – undo
135 135
 	 * Generates the to post status select field.
136 136
 	 *
137 137
 	 */
138
-	public function generate_post_status_select( $post_type ) {
138
+	public function generate_post_status_select($post_type) {
139 139
 
140
-		if ( 'subscriptions' === $post_type ) {
140
+		if ('subscriptions' === $post_type) {
141 141
 			$options = getpaid_get_subscription_statuses();
142 142
 		} else {
143
-			$options = wpinv_get_invoice_statuses( true, false, $post_type );
143
+			$options = wpinv_get_invoice_statuses(true, false, $post_type);
144 144
 		}
145 145
 
146 146
 		return aui()->select(
147 147
 			array(
148 148
 				'name'        => 'status',
149
-				'id'          => esc_attr( "$post_type-status" ),
150
-				'placeholder' => __( 'All Statuses', 'invoicing' ),
151
-				'label'       => __( 'Status', 'invoicing' ),
149
+				'id'          => esc_attr("$post_type-status"),
150
+				'placeholder' => __('All Statuses', 'invoicing'),
151
+				'label'       => __('Status', 'invoicing'),
152 152
 				'label_type'  => 'vertical',
153 153
 				'label_class' => 'd-block',
154 154
 				'options'     => $options,
@@ -161,20 +161,20 @@  discard block
 block discarded – undo
161 161
 	 * Generates the to file type select field.
162 162
 	 *
163 163
 	 */
164
-	public function generate_file_type_select( $post_type ) {
164
+	public function generate_file_type_select($post_type) {
165 165
 
166 166
 		return aui()->select(
167 167
 			array(
168 168
 				'name'        => 'file_type',
169
-				'id'          => esc_attr( "$post_type-file_type" ),
170
-				'placeholder' => __( 'Select File Type', 'invoicing' ),
171
-				'label'       => __( 'Export File', 'invoicing' ),
169
+				'id'          => esc_attr("$post_type-file_type"),
170
+				'placeholder' => __('Select File Type', 'invoicing'),
171
+				'label'       => __('Export File', 'invoicing'),
172 172
 				'label_type'  => 'vertical',
173 173
 				'label_class' => 'd-block',
174 174
 				'options'     => array(
175
-					'csv'  => __( 'CSV', 'invoicing' ),
176
-					'xml'  => __( 'XML', 'invoicing' ),
177
-					'json' => __( 'JSON', 'invoicing' ),
175
+					'csv'  => __('CSV', 'invoicing'),
176
+					'xml'  => __('XML', 'invoicing'),
177
+					'json' => __('JSON', 'invoicing'),
178 178
 				),
179 179
 			)
180 180
 		);
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 	 * Displays a field's markup.
186 186
 	 *
187 187
 	 */
188
-	public function display_markup( $markup ) {
188
+	public function display_markup($markup) {
189 189
 
190 190
 		echo wp_kses(
191 191
 			str_replace(
@@ -214,20 +214,20 @@  discard block
 block discarded – undo
214 214
 
215 215
 				<div class="card-header">
216 216
 					<strong>
217
-						<?php esc_html_e( 'Export Subscriptions', 'invoicing' ); ?>
217
+						<?php esc_html_e('Export Subscriptions', 'invoicing'); ?>
218 218
 					</strong>
219 219
 				</div>
220 220
 
221 221
 				<div class="card-body">
222 222
 
223
-					<form method="post" action="<?php echo esc_url( $this->get_download_url( 'subscriptions' ) ); ?>">
223
+					<form method="post" action="<?php echo esc_url($this->get_download_url('subscriptions')); ?>">
224 224
 
225 225
 						<?php
226
-							$this->display_markup( $this->generate_from_date( 'subscriptions' ) );
227
-							$this->display_markup( $this->generate_to_date( 'subscriptions' ) );
228
-							$this->display_markup( $this->generate_post_status_select( 'subscriptions' ) );
229
-							$this->display_markup( $this->generate_file_type_select( 'subscriptions' ) );
230
-							submit_button( __( 'Download', 'invoicing' ) );
226
+							$this->display_markup($this->generate_from_date('subscriptions'));
227
+							$this->display_markup($this->generate_to_date('subscriptions'));
228
+							$this->display_markup($this->generate_post_status_select('subscriptions'));
229
+							$this->display_markup($this->generate_file_type_select('subscriptions'));
230
+							submit_button(__('Download', 'invoicing'));
231 231
 						?>
232 232
 
233 233
 					</form>
Please login to merge, or discard this patch.
includes/reports/class-getpaid-graph-downloader.php 2 patches
Indentation   +202 added lines, -202 removed lines patch added patch discarded remove patch
@@ -12,218 +12,218 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Graph_Downloader {
14 14
 
15
-	/**
16
-	 * @var GetPaid_Reports_Report
17
-	 */
18
-	public $handler;
19
-
20
-	/**
21
-	 * Class constructor.
22
-	 *
23
-	 */
24
-	public function __construct() {
25
-		$this->handler = new GetPaid_Reports_Report();
26
-	}
27
-
28
-	/**
29
-	 * Prepares the datastore handler.
30
-	 *
31
-	 * @return GetPaid_Reports_Report_Items|GetPaid_Reports_Report_Gateways|GetPaid_Reports_Report_Discounts
32
-	 */
33
-	public function prepare_handler( $graph ) {
34
-
35
-		if ( empty( $this->handler->views[ $graph ] ) ) {
36
-			wp_die( esc_html__( 'Invalid Graph', 'invoicing' ), 400 );
37
-		}
38
-
39
-		return new $this->handler->views[ $graph ]['class']();
40
-
41
-	}
42
-
43
-	/**
44
-	 * Prepares the output stream.
45
-	 *
46
-	 * @return resource
47
-	 */
48
-	public function prepare_output() {
49
-
50
-		$output  = fopen( 'php://output', 'w' );
51
-
52
-		if ( false === $output ) {
53
-			wp_die( esc_html__( 'Unsupported server', 'invoicing' ), 500 );
54
-		}
55
-
56
-		return $output;
57
-	}
58
-
59
-	/**
60
-	 * Prepares the file type.
61
-	 *
62
-	 * @return string
63
-	 */
64
-	public function prepare_file_type( $graph ) {
65
-
66
-		$file_type = empty( $_REQUEST['file_type'] ) ? 'csv' : sanitize_text_field( $_REQUEST['file_type'] );
67
-		$file_name = wpinv_sanitize_key( "getpaid-$graph-" . current_time( 'Y-m-d' ) );
68
-
69
-		header( "Content-Type:application/$file_type" );
70
-		header( "Content-Disposition:attachment;filename=$file_name.$file_type" );
71
-
72
-		return $file_type;
73
-	}
74
-
75
-	/**
76
-	 * Handles the actual download.
77
-	 *
78
-	 */
79
-	public function download( $graph ) {
80
-		global $wpdb;
81
-
82
-		$handler   = $this->prepare_handler( $graph );
83
-		$stream    = $this->prepare_output();
84
-		$stats     = $wpdb->get_results( $handler->get_sql( $handler->get_range() ) );
85
-		$headers   = array( $handler->field, 'total', 'total_raw' );
86
-		$file_type = $this->prepare_file_type( $graph );
87
-
88
-		if ( 'csv' == $file_type ) {
89
-			$this->download_csv( $stats, $stream, $headers );
90
-		} elseif ( 'xml' == $file_type ) {
91
-			$this->download_xml( $stats, $stream, $headers );
92
-		} else {
93
-			$this->download_json( $stats, $stream, $headers );
94
-		}
95
-
96
-		fclose( $stream );
97
-		exit;
98
-	}
99
-
100
-	/**
101
-	 * Downloads graph as csv
102
-	 *
103
-	 * @param array $stats The stats being downloaded.
104
-	 * @param resource $stream The stream to output to.
105
-	 * @param array $headers The fields to stream.
106
-	 * @since       1.0.19
107
-	 */
108
-	public function download_csv( $stats, $stream, $headers ) {
109
-
110
-		// Output the csv column headers.
111
-		fputcsv( $stream, $headers );
112
-
113
-		// Loop through
114
-		foreach ( $stats as $stat ) {
115
-			$row  = array_values( $this->prepare_row( $stat, $headers ) );
116
-			$row  = array_map( 'maybe_serialize', $row );
117
-			fputcsv( $stream, $row );
118
-		}
119
-
120
-	}
121
-
122
-	/**
123
-	 * Downloads graph as json
124
-	 *
125
-	 * @param array $stats The stats being downloaded.
126
-	 * @param resource $stream The stream to output to.
127
-	 * @param array $headers The fields to stream.
128
-	 * @since       1.0.19
129
-	 */
130
-	public function download_json( $stats, $stream, $headers ) {
131
-
132
-		$prepared = array();
133
-
134
-		// Loop through
135
-		foreach ( $stats as $stat ) {
136
-			$prepared[] = $this->prepare_row( $stat, $headers );
137
-		}
138
-
139
-		fwrite( $stream, wp_json_encode( $prepared ) );
140
-
141
-	}
142
-
143
-	/**
144
-	 * Downloads graph as xml
145
-	 *
146
-	 * @param array $stats The stats being downloaded.
147
-	 * @param resource $stream The stream to output to.
148
-	 * @param array $headers The fields to stream.
149
-	 * @since       1.0.19
150
-	 */
151
-	public function download_xml( $stats, $stream, $headers ) {
152
-
153
-		$prepared = array();
154
-
155
-		// Loop through
156
-		foreach ( $stats as $stat ) {
157
-			$prepared[] = $this->prepare_row( $stat, $headers );
158
-		}
159
-
160
-		$xml = new SimpleXMLElement( '<?xml version="1.0"?><data></data>' );
161
-		$this->convert_array_xml( $prepared, $xml );
162
-
163
-		fwrite( $stream, $xml->asXML() );
164
-
165
-	}
166
-
167
-	/**
168
-	 * Converts stats array to xml
169
-	 *
170
-	 * @access      public
171
-	 * @since      1.0.19
172
-	 */
173
-	public function convert_array_xml( $data, $xml ) {
174
-
175
-		// Loop through
176
-		foreach ( $data as $key => $value ) {
177
-
178
-			$key = preg_replace( '/[^A-Za-z0-9_\-]/', '', $key );
179
-
180
-			if ( is_array( $value ) ) {
181
-
182
-				if ( is_numeric( $key ) ) {
183
-					$key = 'item' . $key; //dealing with <0/>..<n/> issues
184
-				}
185
-
186
-				$subnode = $xml->addChild( $key );
187
-				$this->convert_array_xml( $value, $subnode );
188
-
189
-			} else {
190
-				$xml->addChild( $key, htmlspecialchars( $value ) );
191
-			}
15
+    /**
16
+     * @var GetPaid_Reports_Report
17
+     */
18
+    public $handler;
19
+
20
+    /**
21
+     * Class constructor.
22
+     *
23
+     */
24
+    public function __construct() {
25
+        $this->handler = new GetPaid_Reports_Report();
26
+    }
27
+
28
+    /**
29
+     * Prepares the datastore handler.
30
+     *
31
+     * @return GetPaid_Reports_Report_Items|GetPaid_Reports_Report_Gateways|GetPaid_Reports_Report_Discounts
32
+     */
33
+    public function prepare_handler( $graph ) {
34
+
35
+        if ( empty( $this->handler->views[ $graph ] ) ) {
36
+            wp_die( esc_html__( 'Invalid Graph', 'invoicing' ), 400 );
37
+        }
38
+
39
+        return new $this->handler->views[ $graph ]['class']();
40
+
41
+    }
42
+
43
+    /**
44
+     * Prepares the output stream.
45
+     *
46
+     * @return resource
47
+     */
48
+    public function prepare_output() {
49
+
50
+        $output  = fopen( 'php://output', 'w' );
51
+
52
+        if ( false === $output ) {
53
+            wp_die( esc_html__( 'Unsupported server', 'invoicing' ), 500 );
54
+        }
55
+
56
+        return $output;
57
+    }
58
+
59
+    /**
60
+     * Prepares the file type.
61
+     *
62
+     * @return string
63
+     */
64
+    public function prepare_file_type( $graph ) {
65
+
66
+        $file_type = empty( $_REQUEST['file_type'] ) ? 'csv' : sanitize_text_field( $_REQUEST['file_type'] );
67
+        $file_name = wpinv_sanitize_key( "getpaid-$graph-" . current_time( 'Y-m-d' ) );
68
+
69
+        header( "Content-Type:application/$file_type" );
70
+        header( "Content-Disposition:attachment;filename=$file_name.$file_type" );
71
+
72
+        return $file_type;
73
+    }
74
+
75
+    /**
76
+     * Handles the actual download.
77
+     *
78
+     */
79
+    public function download( $graph ) {
80
+        global $wpdb;
81
+
82
+        $handler   = $this->prepare_handler( $graph );
83
+        $stream    = $this->prepare_output();
84
+        $stats     = $wpdb->get_results( $handler->get_sql( $handler->get_range() ) );
85
+        $headers   = array( $handler->field, 'total', 'total_raw' );
86
+        $file_type = $this->prepare_file_type( $graph );
87
+
88
+        if ( 'csv' == $file_type ) {
89
+            $this->download_csv( $stats, $stream, $headers );
90
+        } elseif ( 'xml' == $file_type ) {
91
+            $this->download_xml( $stats, $stream, $headers );
92
+        } else {
93
+            $this->download_json( $stats, $stream, $headers );
94
+        }
95
+
96
+        fclose( $stream );
97
+        exit;
98
+    }
99
+
100
+    /**
101
+     * Downloads graph as csv
102
+     *
103
+     * @param array $stats The stats being downloaded.
104
+     * @param resource $stream The stream to output to.
105
+     * @param array $headers The fields to stream.
106
+     * @since       1.0.19
107
+     */
108
+    public function download_csv( $stats, $stream, $headers ) {
109
+
110
+        // Output the csv column headers.
111
+        fputcsv( $stream, $headers );
112
+
113
+        // Loop through
114
+        foreach ( $stats as $stat ) {
115
+            $row  = array_values( $this->prepare_row( $stat, $headers ) );
116
+            $row  = array_map( 'maybe_serialize', $row );
117
+            fputcsv( $stream, $row );
118
+        }
119
+
120
+    }
121
+
122
+    /**
123
+     * Downloads graph as json
124
+     *
125
+     * @param array $stats The stats being downloaded.
126
+     * @param resource $stream The stream to output to.
127
+     * @param array $headers The fields to stream.
128
+     * @since       1.0.19
129
+     */
130
+    public function download_json( $stats, $stream, $headers ) {
131
+
132
+        $prepared = array();
133
+
134
+        // Loop through
135
+        foreach ( $stats as $stat ) {
136
+            $prepared[] = $this->prepare_row( $stat, $headers );
137
+        }
138
+
139
+        fwrite( $stream, wp_json_encode( $prepared ) );
140
+
141
+    }
142
+
143
+    /**
144
+     * Downloads graph as xml
145
+     *
146
+     * @param array $stats The stats being downloaded.
147
+     * @param resource $stream The stream to output to.
148
+     * @param array $headers The fields to stream.
149
+     * @since       1.0.19
150
+     */
151
+    public function download_xml( $stats, $stream, $headers ) {
152
+
153
+        $prepared = array();
154
+
155
+        // Loop through
156
+        foreach ( $stats as $stat ) {
157
+            $prepared[] = $this->prepare_row( $stat, $headers );
158
+        }
159
+
160
+        $xml = new SimpleXMLElement( '<?xml version="1.0"?><data></data>' );
161
+        $this->convert_array_xml( $prepared, $xml );
162
+
163
+        fwrite( $stream, $xml->asXML() );
164
+
165
+    }
166
+
167
+    /**
168
+     * Converts stats array to xml
169
+     *
170
+     * @access      public
171
+     * @since      1.0.19
172
+     */
173
+    public function convert_array_xml( $data, $xml ) {
174
+
175
+        // Loop through
176
+        foreach ( $data as $key => $value ) {
177
+
178
+            $key = preg_replace( '/[^A-Za-z0-9_\-]/', '', $key );
179
+
180
+            if ( is_array( $value ) ) {
181
+
182
+                if ( is_numeric( $key ) ) {
183
+                    $key = 'item' . $key; //dealing with <0/>..<n/> issues
184
+                }
185
+
186
+                $subnode = $xml->addChild( $key );
187
+                $this->convert_array_xml( $value, $subnode );
188
+
189
+            } else {
190
+                $xml->addChild( $key, htmlspecialchars( $value ) );
191
+            }
192 192
 }
193 193
 
194
-	}
194
+    }
195 195
 
196
-	/**
197
-	 * Prepares a single row for download.
198
-	 *
199
-	 * @param stdClass|array $row The row to prepare..
200
-	 * @param array $fields The fields to stream.
201
-	 * @since       1.0.19
202
-	 * @return array
203
-	 */
204
-	public function prepare_row( $row, $fields ) {
196
+    /**
197
+     * Prepares a single row for download.
198
+     *
199
+     * @param stdClass|array $row The row to prepare..
200
+     * @param array $fields The fields to stream.
201
+     * @since       1.0.19
202
+     * @return array
203
+     */
204
+    public function prepare_row( $row, $fields ) {
205 205
 
206
-		$prepared = array();
207
-		$row      = (array) $row;
206
+        $prepared = array();
207
+        $row      = (array) $row;
208 208
 
209
-		foreach ( $fields as $field ) {
209
+        foreach ( $fields as $field ) {
210 210
 
211
-			if ( $field === 'total' ) {
212
-				$prepared[ $field ] = html_entity_decode( strip_tags( wpinv_price( $row['total'] ) ), ENT_QUOTES );
213
-				continue;
214
-			}
211
+            if ( $field === 'total' ) {
212
+                $prepared[ $field ] = html_entity_decode( strip_tags( wpinv_price( $row['total'] ) ), ENT_QUOTES );
213
+                continue;
214
+            }
215 215
 
216
-			if ( $field === 'total_raw' ) {
217
-				$prepared[ $field ] = wpinv_round_amount( wpinv_sanitize_amount( $row['total'] ) );
218
-				continue;
219
-			}
216
+            if ( $field === 'total_raw' ) {
217
+                $prepared[ $field ] = wpinv_round_amount( wpinv_sanitize_amount( $row['total'] ) );
218
+                continue;
219
+            }
220 220
 
221
-			$prepared[ $field ] = strip_tags( $row[ $field ] );
221
+            $prepared[ $field ] = strip_tags( $row[ $field ] );
222 222
 
223
-		}
223
+        }
224 224
 
225
-		return $prepared;
226
-	}
225
+        return $prepared;
226
+    }
227 227
 
228 228
 
229 229
 }
Please login to merge, or discard this patch.
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 /**
11 11
  * GetPaid_Graph_Downloader Class.
@@ -30,13 +30,13 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @return GetPaid_Reports_Report_Items|GetPaid_Reports_Report_Gateways|GetPaid_Reports_Report_Discounts
32 32
 	 */
33
-	public function prepare_handler( $graph ) {
33
+	public function prepare_handler($graph) {
34 34
 
35
-		if ( empty( $this->handler->views[ $graph ] ) ) {
36
-			wp_die( esc_html__( 'Invalid Graph', 'invoicing' ), 400 );
35
+		if (empty($this->handler->views[$graph])) {
36
+			wp_die(esc_html__('Invalid Graph', 'invoicing'), 400);
37 37
 		}
38 38
 
39
-		return new $this->handler->views[ $graph ]['class']();
39
+		return new $this->handler->views[$graph]['class']();
40 40
 
41 41
 	}
42 42
 
@@ -47,10 +47,10 @@  discard block
 block discarded – undo
47 47
 	 */
48 48
 	public function prepare_output() {
49 49
 
50
-		$output  = fopen( 'php://output', 'w' );
50
+		$output = fopen('php://output', 'w');
51 51
 
52
-		if ( false === $output ) {
53
-			wp_die( esc_html__( 'Unsupported server', 'invoicing' ), 500 );
52
+		if (false === $output) {
53
+			wp_die(esc_html__('Unsupported server', 'invoicing'), 500);
54 54
 		}
55 55
 
56 56
 		return $output;
@@ -61,13 +61,13 @@  discard block
 block discarded – undo
61 61
 	 *
62 62
 	 * @return string
63 63
 	 */
64
-	public function prepare_file_type( $graph ) {
64
+	public function prepare_file_type($graph) {
65 65
 
66
-		$file_type = empty( $_REQUEST['file_type'] ) ? 'csv' : sanitize_text_field( $_REQUEST['file_type'] );
67
-		$file_name = wpinv_sanitize_key( "getpaid-$graph-" . current_time( 'Y-m-d' ) );
66
+		$file_type = empty($_REQUEST['file_type']) ? 'csv' : sanitize_text_field($_REQUEST['file_type']);
67
+		$file_name = wpinv_sanitize_key("getpaid-$graph-" . current_time('Y-m-d'));
68 68
 
69
-		header( "Content-Type:application/$file_type" );
70
-		header( "Content-Disposition:attachment;filename=$file_name.$file_type" );
69
+		header("Content-Type:application/$file_type");
70
+		header("Content-Disposition:attachment;filename=$file_name.$file_type");
71 71
 
72 72
 		return $file_type;
73 73
 	}
@@ -76,24 +76,24 @@  discard block
 block discarded – undo
76 76
 	 * Handles the actual download.
77 77
 	 *
78 78
 	 */
79
-	public function download( $graph ) {
79
+	public function download($graph) {
80 80
 		global $wpdb;
81 81
 
82
-		$handler   = $this->prepare_handler( $graph );
82
+		$handler   = $this->prepare_handler($graph);
83 83
 		$stream    = $this->prepare_output();
84
-		$stats     = $wpdb->get_results( $handler->get_sql( $handler->get_range() ) );
85
-		$headers   = array( $handler->field, 'total', 'total_raw' );
86
-		$file_type = $this->prepare_file_type( $graph );
87
-
88
-		if ( 'csv' == $file_type ) {
89
-			$this->download_csv( $stats, $stream, $headers );
90
-		} elseif ( 'xml' == $file_type ) {
91
-			$this->download_xml( $stats, $stream, $headers );
84
+		$stats     = $wpdb->get_results($handler->get_sql($handler->get_range()));
85
+		$headers   = array($handler->field, 'total', 'total_raw');
86
+		$file_type = $this->prepare_file_type($graph);
87
+
88
+		if ('csv' == $file_type) {
89
+			$this->download_csv($stats, $stream, $headers);
90
+		} elseif ('xml' == $file_type) {
91
+			$this->download_xml($stats, $stream, $headers);
92 92
 		} else {
93
-			$this->download_json( $stats, $stream, $headers );
93
+			$this->download_json($stats, $stream, $headers);
94 94
 		}
95 95
 
96
-		fclose( $stream );
96
+		fclose($stream);
97 97
 		exit;
98 98
 	}
99 99
 
@@ -105,16 +105,16 @@  discard block
 block discarded – undo
105 105
 	 * @param array $headers The fields to stream.
106 106
 	 * @since       1.0.19
107 107
 	 */
108
-	public function download_csv( $stats, $stream, $headers ) {
108
+	public function download_csv($stats, $stream, $headers) {
109 109
 
110 110
 		// Output the csv column headers.
111
-		fputcsv( $stream, $headers );
111
+		fputcsv($stream, $headers);
112 112
 
113 113
 		// Loop through
114
-		foreach ( $stats as $stat ) {
115
-			$row  = array_values( $this->prepare_row( $stat, $headers ) );
116
-			$row  = array_map( 'maybe_serialize', $row );
117
-			fputcsv( $stream, $row );
114
+		foreach ($stats as $stat) {
115
+			$row  = array_values($this->prepare_row($stat, $headers));
116
+			$row  = array_map('maybe_serialize', $row);
117
+			fputcsv($stream, $row);
118 118
 		}
119 119
 
120 120
 	}
@@ -127,16 +127,16 @@  discard block
 block discarded – undo
127 127
 	 * @param array $headers The fields to stream.
128 128
 	 * @since       1.0.19
129 129
 	 */
130
-	public function download_json( $stats, $stream, $headers ) {
130
+	public function download_json($stats, $stream, $headers) {
131 131
 
132 132
 		$prepared = array();
133 133
 
134 134
 		// Loop through
135
-		foreach ( $stats as $stat ) {
136
-			$prepared[] = $this->prepare_row( $stat, $headers );
135
+		foreach ($stats as $stat) {
136
+			$prepared[] = $this->prepare_row($stat, $headers);
137 137
 		}
138 138
 
139
-		fwrite( $stream, wp_json_encode( $prepared ) );
139
+		fwrite($stream, wp_json_encode($prepared));
140 140
 
141 141
 	}
142 142
 
@@ -148,19 +148,19 @@  discard block
 block discarded – undo
148 148
 	 * @param array $headers The fields to stream.
149 149
 	 * @since       1.0.19
150 150
 	 */
151
-	public function download_xml( $stats, $stream, $headers ) {
151
+	public function download_xml($stats, $stream, $headers) {
152 152
 
153 153
 		$prepared = array();
154 154
 
155 155
 		// Loop through
156
-		foreach ( $stats as $stat ) {
157
-			$prepared[] = $this->prepare_row( $stat, $headers );
156
+		foreach ($stats as $stat) {
157
+			$prepared[] = $this->prepare_row($stat, $headers);
158 158
 		}
159 159
 
160
-		$xml = new SimpleXMLElement( '<?xml version="1.0"?><data></data>' );
161
-		$this->convert_array_xml( $prepared, $xml );
160
+		$xml = new SimpleXMLElement('<?xml version="1.0"?><data></data>');
161
+		$this->convert_array_xml($prepared, $xml);
162 162
 
163
-		fwrite( $stream, $xml->asXML() );
163
+		fwrite($stream, $xml->asXML());
164 164
 
165 165
 	}
166 166
 
@@ -170,24 +170,24 @@  discard block
 block discarded – undo
170 170
 	 * @access      public
171 171
 	 * @since      1.0.19
172 172
 	 */
173
-	public function convert_array_xml( $data, $xml ) {
173
+	public function convert_array_xml($data, $xml) {
174 174
 
175 175
 		// Loop through
176
-		foreach ( $data as $key => $value ) {
176
+		foreach ($data as $key => $value) {
177 177
 
178
-			$key = preg_replace( '/[^A-Za-z0-9_\-]/', '', $key );
178
+			$key = preg_replace('/[^A-Za-z0-9_\-]/', '', $key);
179 179
 
180
-			if ( is_array( $value ) ) {
180
+			if (is_array($value)) {
181 181
 
182
-				if ( is_numeric( $key ) ) {
182
+				if (is_numeric($key)) {
183 183
 					$key = 'item' . $key; //dealing with <0/>..<n/> issues
184 184
 				}
185 185
 
186
-				$subnode = $xml->addChild( $key );
187
-				$this->convert_array_xml( $value, $subnode );
186
+				$subnode = $xml->addChild($key);
187
+				$this->convert_array_xml($value, $subnode);
188 188
 
189 189
 			} else {
190
-				$xml->addChild( $key, htmlspecialchars( $value ) );
190
+				$xml->addChild($key, htmlspecialchars($value));
191 191
 			}
192 192
 }
193 193
 
@@ -201,24 +201,24 @@  discard block
 block discarded – undo
201 201
 	 * @since       1.0.19
202 202
 	 * @return array
203 203
 	 */
204
-	public function prepare_row( $row, $fields ) {
204
+	public function prepare_row($row, $fields) {
205 205
 
206 206
 		$prepared = array();
207 207
 		$row      = (array) $row;
208 208
 
209
-		foreach ( $fields as $field ) {
209
+		foreach ($fields as $field) {
210 210
 
211
-			if ( $field === 'total' ) {
212
-				$prepared[ $field ] = html_entity_decode( strip_tags( wpinv_price( $row['total'] ) ), ENT_QUOTES );
211
+			if ($field === 'total') {
212
+				$prepared[$field] = html_entity_decode(strip_tags(wpinv_price($row['total'])), ENT_QUOTES);
213 213
 				continue;
214 214
 			}
215 215
 
216
-			if ( $field === 'total_raw' ) {
217
-				$prepared[ $field ] = wpinv_round_amount( wpinv_sanitize_amount( $row['total'] ) );
216
+			if ($field === 'total_raw') {
217
+				$prepared[$field] = wpinv_round_amount(wpinv_sanitize_amount($row['total']));
218 218
 				continue;
219 219
 			}
220 220
 
221
-			$prepared[ $field ] = strip_tags( $row[ $field ] );
221
+			$prepared[$field] = strip_tags($row[$field]);
222 222
 
223 223
 		}
224 224
 
Please login to merge, or discard this patch.