Passed
Push — master ( 9c3281...81bc9f )
by Brian
05:52
created
invoicing.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,16 +19,16 @@  discard block
 block discarded – undo
19 19
 
20 20
 // Define constants.
21 21
 if ( ! defined( 'WPINV_PLUGIN_FILE' ) ) {
22
-	define( 'WPINV_PLUGIN_FILE', __FILE__ );
22
+    define( 'WPINV_PLUGIN_FILE', __FILE__ );
23 23
 }
24 24
 
25 25
 if ( ! defined( 'WPINV_VERSION' ) ) {
26
-	define( 'WPINV_VERSION', '2.0.2-beta' );
26
+    define( 'WPINV_VERSION', '2.0.2-beta' );
27 27
 }
28 28
 
29 29
 // Include the main Invoicing class.
30 30
 if ( ! class_exists( 'WPInv_Plugin', false ) ) {
31
-	require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php';
31
+    require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php';
32 32
 }
33 33
 
34 34
 /**
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
         $GLOBALS['invoicing'] = new WPInv_Plugin();
44 44
     }
45 45
 
46
-	return $GLOBALS['invoicing'];
46
+    return $GLOBALS['invoicing'];
47 47
 }
48 48
 
49 49
 /**
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -15,20 +15,20 @@  discard block
 block discarded – undo
15 15
  * @package GetPaid
16 16
  */
17 17
 
18
-defined( 'ABSPATH' ) || exit;
18
+defined('ABSPATH') || exit;
19 19
 
20 20
 // Define constants.
21
-if ( ! defined( 'WPINV_PLUGIN_FILE' ) ) {
22
-	define( 'WPINV_PLUGIN_FILE', __FILE__ );
21
+if (!defined('WPINV_PLUGIN_FILE')) {
22
+	define('WPINV_PLUGIN_FILE', __FILE__);
23 23
 }
24 24
 
25
-if ( ! defined( 'WPINV_VERSION' ) ) {
26
-	define( 'WPINV_VERSION', '2.0.2-beta' );
25
+if (!defined('WPINV_VERSION')) {
26
+	define('WPINV_VERSION', '2.0.2-beta');
27 27
 }
28 28
 
29 29
 // Include the main Invoicing class.
30
-if ( ! class_exists( 'WPInv_Plugin', false ) ) {
31
-	require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php';
30
+if (!class_exists('WPInv_Plugin', false)) {
31
+	require_once plugin_dir_path(WPINV_PLUGIN_FILE) . 'includes/class-wpinv.php';
32 32
 }
33 33
 
34 34
 /**
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
  */
40 40
 function getpaid() {
41 41
 
42
-    if ( empty( $GLOBALS['invoicing'] ) ) {
42
+    if (empty($GLOBALS['invoicing'])) {
43 43
         $GLOBALS['invoicing'] = new WPInv_Plugin();
44 44
     }
45 45
 
Please login to merge, or discard this patch.
templates/subscriptions/subscription-details.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -9,14 +9,14 @@  discard block
 block discarded – undo
9 9
  * @var WPInv_Subscriptions_Widget $widget
10 10
  */
11 11
 
12
-defined( 'ABSPATH' ) || exit;
12
+defined('ABSPATH') || exit;
13 13
 
14
-do_action( 'getpaid_single_subscription_before_notices', $subscription );
14
+do_action('getpaid_single_subscription_before_notices', $subscription);
15 15
 
16 16
 // Display errors and notices.
17 17
 wpinv_print_errors();
18 18
 
19
-do_action( 'getpaid_before_single_subscription', $subscription );
19
+do_action('getpaid_before_single_subscription', $subscription);
20 20
 
21 21
 ?>
22 22
 
@@ -28,44 +28,44 @@  discard block
 block discarded – undo
28 28
 
29 29
 </style>
30 30
 
31
-<h2 class="mb-1 h4"><?php _e( 'Subscription Details', 'invoicing' ); ?></h2>
31
+<h2 class="mb-1 h4"><?php _e('Subscription Details', 'invoicing'); ?></h2>
32 32
 <table class="table table-bordered">
33 33
 	<tbody>
34 34
 
35
-		<?php foreach ( $widget->get_single_subscription_columns( $subscription ) as $key => $label ) : ?>
35
+		<?php foreach ($widget->get_single_subscription_columns($subscription) as $key => $label) : ?>
36 36
 
37
-			<tr class="getpaid-subscription-meta-<?php echo sanitize_html_class( $key ); ?>">
37
+			<tr class="getpaid-subscription-meta-<?php echo sanitize_html_class($key); ?>">
38 38
 
39 39
 				<th class="w-25 font-weight-bold">
40
-					<?php echo sanitize_text_field( $label ); ?>
40
+					<?php echo sanitize_text_field($label); ?>
41 41
 				</th>
42 42
 
43 43
 				<td class="w-75">
44 44
 					<?php
45 45
 
46
-						switch ( $key ) {
46
+						switch ($key) {
47 47
 
48 48
 							case 'status':
49
-								echo sanitize_text_field( $subscription->get_status_label() );
49
+								echo sanitize_text_field($subscription->get_status_label());
50 50
 								break;
51 51
 
52 52
 							case 'start_date':
53
-								echo sanitize_text_field( getpaid_format_date_value( $subscription->get_date_created() ) );
53
+								echo sanitize_text_field(getpaid_format_date_value($subscription->get_date_created()));
54 54
 								break;
55 55
 
56 56
 							case 'expiry_date':
57
-								echo sanitize_text_field( getpaid_format_date_value( $subscription->get_next_renewal_date() ) );
57
+								echo sanitize_text_field(getpaid_format_date_value($subscription->get_next_renewal_date()));
58 58
 								break;
59 59
 
60 60
 							case 'initial_amount':
61
-								echo wpinv_price( wpinv_format_amount( $subscription->get_initial_amount() ), $subscription->get_parent_payment()->get_currency() );
61
+								echo wpinv_price(wpinv_format_amount($subscription->get_initial_amount()), $subscription->get_parent_payment()->get_currency());
62 62
 
63
-								if ( $subscription->has_trial_period() ) {
63
+								if ($subscription->has_trial_period()) {
64 64
 
65 65
 									echo "<small class='text-muted'>&nbsp;";
66 66
 									printf(
67
-										_x( '( %1$s trial )', 'Subscription trial period. (e.g.: 1 month trial)', 'invoicing' ),
68
-										sanitize_text_field( $subscription->get_trial_period() )
67
+										_x('( %1$s trial )', 'Subscription trial period. (e.g.: 1 month trial)', 'invoicing'),
68
+										sanitize_text_field($subscription->get_trial_period())
69 69
 									);
70 70
 									echo '</small>';
71 71
 
@@ -74,18 +74,18 @@  discard block
 block discarded – undo
74 74
 								break;
75 75
 
76 76
 							case 'recurring_amount':
77
-								$frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' );
78
-								$amount    = wpinv_price( wpinv_format_amount( $subscription->get_recurring_amount() ), $subscription->get_parent_payment()->get_currency() );
79
-								echo strtolower( "<strong style='font-weight: 500;'>$amount</strong> / $frequency" );
77
+								$frequency = getpaid_get_subscription_period_label($subscription->get_period(), $subscription->get_frequency(), '');
78
+								$amount    = wpinv_price(wpinv_format_amount($subscription->get_recurring_amount()), $subscription->get_parent_payment()->get_currency());
79
+								echo strtolower("<strong style='font-weight: 500;'>$amount</strong> / $frequency");
80 80
 								break;
81 81
 
82 82
 							case 'item':
83
-								$item = get_post( $subscription->get_product_id() );
83
+								$item = get_post($subscription->get_product_id());
84 84
 
85
-								if ( ! empty( $item ) ) {
86
-									echo esc_html( get_the_title( $item ) );
85
+								if (!empty($item)) {
86
+									echo esc_html(get_the_title($item));
87 87
 								} else {
88
-									echo sprintf( __( 'Item #%s', 'invoicing' ), $subscription->get_product_id() );
88
+									echo sprintf(__('Item #%s', 'invoicing'), $subscription->get_product_id());
89 89
 								}
90 90
 
91 91
 								break;
@@ -93,12 +93,12 @@  discard block
 block discarded – undo
93 93
 							case 'payments':
94 94
 
95 95
 								$max_activations = (int) $subscription->get_bill_times();
96
-								echo (int) $subscription->get_times_billed() . ' / ' . ( empty( $max_activations ) ? "&infin;" : $max_activations );
96
+								echo (int) $subscription->get_times_billed() . ' / ' . (empty($max_activations) ? "&infin;" : $max_activations);
97 97
 
98 98
 								break;
99 99
 
100 100
 						}
101
-						do_action( "getpaid_render_single_subscription_column_$key", $subscription );
101
+						do_action("getpaid_render_single_subscription_column_$key", $subscription);
102 102
 
103 103
 					?>
104 104
 				</td>
@@ -110,24 +110,24 @@  discard block
 block discarded – undo
110 110
 	</tbody>
111 111
 </table>
112 112
 
113
-<h2 class='mt-5 mb-1 h4'><?php _e( 'Subscription Invoices', 'invoicing' ); ?></h2>
113
+<h2 class='mt-5 mb-1 h4'><?php _e('Subscription Invoices', 'invoicing'); ?></h2>
114 114
 
115
-<?php echo getpaid_admin_subscription_invoice_details_metabox( $subscription ); ?>
115
+<?php echo getpaid_admin_subscription_invoice_details_metabox($subscription); ?>
116 116
 
117 117
 <span class="form-text">
118 118
 
119 119
 	<?php
120
-		if ( $subscription->can_cancel() ) {
120
+		if ($subscription->can_cancel()) {
121 121
 			printf(
122 122
 				'<a href="%s" class="btn btn-danger btn-sm" onclick="return confirm(\'%s\')">%s</a>&nbsp;&nbsp;',
123
-				esc_url( $subscription->get_cancel_url() ),
124
-				esc_attr__( 'Are you sure you want to cancel this subscription?', 'invoicing' ),
125
-				__( 'Cancel Subscription', 'invoicing' )
123
+				esc_url($subscription->get_cancel_url()),
124
+				esc_attr__('Are you sure you want to cancel this subscription?', 'invoicing'),
125
+				__('Cancel Subscription', 'invoicing')
126 126
 			);
127 127
 		}
128 128
 
129
-		do_action( 'getpaid-single-subscription-page-actions', $subscription );
129
+		do_action('getpaid-single-subscription-page-actions', $subscription);
130 130
 	?>
131 131
 
132
-	<a href="<?php echo esc_url( getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ) ); ?>" class="btn btn-secondary btn-sm"><?php _e( 'Go Back', 'invoicing' ); ?></a>
132
+	<a href="<?php echo esc_url(getpaid_get_tab_url('gp-subscriptions', get_permalink((int) wpinv_get_option('invoice_subscription_page')))); ?>" class="btn btn-secondary btn-sm"><?php _e('Go Back', 'invoicing'); ?></a>
133 133
 </span>
134 134
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/subscriptions.php 2 patches
Indentation   +203 added lines, -203 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,27 +22,27 @@  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
-					echo aui()->alert(
29
-						array(
30
-							'type'    => 'danger',
31
-							'content' => __( 'You are not permitted to view this page.', 'invoicing' ),
32
-						)
33
-					);
28
+                    echo aui()->alert(
29
+                        array(
30
+                            'type'    => 'danger',
31
+                            'content' => __( 'You are not permitted to view this page.', 'invoicing' ),
32
+                        )
33
+                    );
34 34
 
35
-				} else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) {
35
+                } else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) {
36 36
 
37
-					// Display a single subscription.
38
-					wpinv_recurring_subscription_details();
39
-				} else {
37
+                    // Display a single subscription.
38
+                    wpinv_recurring_subscription_details();
39
+                } else {
40 40
 
41
-					// Display a list of available subscriptions.
42
-					getpaid_print_subscriptions_list();
43
-				}
41
+                    // Display a list of available subscriptions.
42
+                    getpaid_print_subscriptions_list();
43
+                }
44 44
 
45
-			?>
45
+            ?>
46 46
 
47 47
 		</div>
48 48
 	</div>
@@ -59,10 +59,10 @@  discard block
 block discarded – undo
59 59
  */
60 60
 function getpaid_print_subscriptions_list() {
61 61
 
62
-	$subscribers_table = new WPInv_Subscriptions_List_Table();
63
-	$subscribers_table->prepare_items();
62
+    $subscribers_table = new WPInv_Subscriptions_List_Table();
63
+    $subscribers_table->prepare_items();
64 64
 
65
-	?>
65
+    ?>
66 66
 	<form id="subscribers-filter" class="bsui" method="get">
67 67
 		<input type="hidden" name="page" value="wpinv-subscriptions" />
68 68
 		<?php $subscribers_table->views(); ?>
@@ -80,27 +80,27 @@  discard block
 block discarded – undo
80 80
  */
81 81
 function wpinv_recurring_subscription_details() {
82 82
 
83
-	// Fetch the subscription.
84
-	$sub = new WPInv_Subscription( (int) $_GET['id'] );
85
-	if ( ! $sub->get_id() ) {
83
+    // Fetch the subscription.
84
+    $sub = new WPInv_Subscription( (int) $_GET['id'] );
85
+    if ( ! $sub->get_id() ) {
86 86
 
87
-		echo aui()->alert(
88
-			array(
89
-				'type'    => 'danger',
90
-				'content' => __( 'Subscription not found.', 'invoicing' ),
91
-			)
92
-		);
87
+        echo aui()->alert(
88
+            array(
89
+                'type'    => 'danger',
90
+                'content' => __( 'Subscription not found.', 'invoicing' ),
91
+            )
92
+        );
93 93
 
94
-		return;
95
-	}
94
+        return;
95
+    }
96 96
 
97
-	// Use metaboxes to display the subscription details.
98
-	add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal' );
99
-	add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' );
100
-	add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' );
101
-	do_action( 'getpaid_admin_single_subscription_register_metabox', $sub );
97
+    // Use metaboxes to display the subscription details.
98
+    add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal' );
99
+    add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' );
100
+    add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' );
101
+    do_action( 'getpaid_admin_single_subscription_register_metabox', $sub );
102 102
 
103
-	?>
103
+    ?>
104 104
 
105 105
 		<form method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ); ?>">
106 106
 
@@ -140,41 +140,41 @@  discard block
 block discarded – undo
140 140
  */
141 141
 function getpaid_admin_subscription_details_metabox( $sub ) {
142 142
 
143
-	// Prepare subscription detail columns.
144
-	$fields = apply_filters(
145
-		'getpaid_subscription_admin_page_fields',
146
-		array(
147
-			'subscription'   => __( 'Subscription', 'invoicing' ),
148
-			'customer'       => __( 'Customer', 'invoicing' ),
149
-			'amount'         => __( 'Amount', 'invoicing' ),
150
-			'start_date'     => __( 'Start Date', 'invoicing' ),
151
-			'renews_on'      => __( 'Next Payment', 'invoicing' ),
152
-			'renewals'       => __( 'Payments', 'invoicing' ),
153
-			'item'           => __( 'Item', 'invoicing' ),
154
-			'gateway'        => __( 'Payment Method', 'invoicing' ),
155
-			'profile_id'     => __( 'Profile ID', 'invoicing' ),
156
-			'status'         => __( 'Status', 'invoicing' ),
157
-		)
158
-	);
159
-
160
-	if ( ! $sub->is_active() ) {
161
-
162
-		if ( isset( $fields['renews_on'] ) ) {
163
-			unset( $fields['renews_on'] );
164
-		}
165
-
166
-		if ( isset( $fields['gateway'] ) ) {
167
-			unset( $fields['gateway'] );
168
-		}
143
+    // Prepare subscription detail columns.
144
+    $fields = apply_filters(
145
+        'getpaid_subscription_admin_page_fields',
146
+        array(
147
+            'subscription'   => __( 'Subscription', 'invoicing' ),
148
+            'customer'       => __( 'Customer', 'invoicing' ),
149
+            'amount'         => __( 'Amount', 'invoicing' ),
150
+            'start_date'     => __( 'Start Date', 'invoicing' ),
151
+            'renews_on'      => __( 'Next Payment', 'invoicing' ),
152
+            'renewals'       => __( 'Payments', 'invoicing' ),
153
+            'item'           => __( 'Item', 'invoicing' ),
154
+            'gateway'        => __( 'Payment Method', 'invoicing' ),
155
+            'profile_id'     => __( 'Profile ID', 'invoicing' ),
156
+            'status'         => __( 'Status', 'invoicing' ),
157
+        )
158
+    );
159
+
160
+    if ( ! $sub->is_active() ) {
161
+
162
+        if ( isset( $fields['renews_on'] ) ) {
163
+            unset( $fields['renews_on'] );
164
+        }
165
+
166
+        if ( isset( $fields['gateway'] ) ) {
167
+            unset( $fields['gateway'] );
168
+        }
169 169
 		
170
-	}
170
+    }
171 171
 
172
-	$profile_id = $sub->get_profile_id();
173
-	if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) {
174
-		unset( $fields['profile_id'] );
175
-	}
172
+    $profile_id = $sub->get_profile_id();
173
+    if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) {
174
+        unset( $fields['profile_id'] );
175
+    }
176 176
 
177
-	?>
177
+    ?>
178 178
 
179 179
 		<table class="table table-borderless" style="font-size: 14px;">
180 180
 			<tbody>
@@ -208,20 +208,20 @@  discard block
 block discarded – undo
208 208
  */
209 209
 function getpaid_admin_subscription_metabox_display_customer( $subscription ) {
210 210
 
211
-	$username = __( '(Missing User)', 'invoicing' );
211
+    $username = __( '(Missing User)', 'invoicing' );
212 212
 
213
-	$user = get_userdata( $subscription->get_customer_id() );
214
-	if ( $user ) {
213
+    $user = get_userdata( $subscription->get_customer_id() );
214
+    if ( $user ) {
215 215
 
216
-		$username = sprintf(
217
-			'<a href="user-edit.php?user_id=%s">%s</a>',
218
-			absint( $user->ID ),
219
-			! empty( $user->display_name ) ? sanitize_text_field( $user->display_name ) : sanitize_email( $user->user_email )
220
-		);
216
+        $username = sprintf(
217
+            '<a href="user-edit.php?user_id=%s">%s</a>',
218
+            absint( $user->ID ),
219
+            ! empty( $user->display_name ) ? sanitize_text_field( $user->display_name ) : sanitize_email( $user->user_email )
220
+        );
221 221
 
222
-	}
222
+    }
223 223
 
224
-	echo  $username;
224
+    echo  $username;
225 225
 }
226 226
 add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' );
227 227
 
@@ -231,8 +231,8 @@  discard block
 block discarded – undo
231 231
  * @param WPInv_Subscription $subscription
232 232
  */
233 233
 function getpaid_admin_subscription_metabox_display_amount( $subscription ) {
234
-	$amount    = sanitize_text_field( getpaid_get_formatted_subscription_amount( $subscription ) );
235
-	echo "<span>$amount</span>";
234
+    $amount    = sanitize_text_field( getpaid_get_formatted_subscription_amount( $subscription ) );
235
+    echo "<span>$amount</span>";
236 236
 }
237 237
 add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' );
238 238
 
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
  * @param WPInv_Subscription $subscription
243 243
  */
244 244
 function getpaid_admin_subscription_metabox_display_id( $subscription ) {
245
-	echo  '#' . absint( $subscription->get_id() );
245
+    echo  '#' . absint( $subscription->get_id() );
246 246
 }
247 247
 add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' );
248 248
 
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
  * @param WPInv_Subscription $subscription
253 253
  */
254 254
 function getpaid_admin_subscription_metabox_display_start_date( $subscription ) {
255
-	echo getpaid_format_date_value( $subscription->get_date_created() );
255
+    echo getpaid_format_date_value( $subscription->get_date_created() );
256 256
 }
257 257
 add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' );
258 258
 
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
  * @param WPInv_Subscription $subscription
263 263
  */
264 264
 function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) {
265
-	echo getpaid_format_date_value( $subscription->get_expiration() );
265
+    echo getpaid_format_date_value( $subscription->get_expiration() );
266 266
 }
267 267
 add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' );
268 268
 
@@ -272,8 +272,8 @@  discard block
 block discarded – undo
272 272
  * @param WPInv_Subscription $subscription
273 273
  */
274 274
 function getpaid_admin_subscription_metabox_display_renewals( $subscription ) {
275
-	$max_bills = $subscription->get_bill_times();
276
-	echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "&infin;" : $max_bills );
275
+    $max_bills = $subscription->get_bill_times();
276
+    echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "&infin;" : $max_bills );
277 277
 }
278 278
 add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' );
279 279
 /**
@@ -283,16 +283,16 @@  discard block
 block discarded – undo
283 283
  */
284 284
 function getpaid_admin_subscription_metabox_display_item( $subscription ) {
285 285
 
286
-	$item = get_post( $subscription->get_product_id() );
286
+    $item = get_post( $subscription->get_product_id() );
287 287
 
288
-	if ( ! empty( $item ) ) {
289
-		$link = get_edit_post_link( $item );
290
-		$link = esc_url( $link );
291
-		$name = esc_html( get_the_title( $item ) );
292
-		echo "<a href='$link'>$name</a>";
293
-	} else {
294
-		echo sprintf( __( 'Item #%s', 'invoicing' ), $subscription->get_product_id() );
295
-	}
288
+    if ( ! empty( $item ) ) {
289
+        $link = get_edit_post_link( $item );
290
+        $link = esc_url( $link );
291
+        $name = esc_html( get_the_title( $item ) );
292
+        echo "<a href='$link'>$name</a>";
293
+    } else {
294
+        echo sprintf( __( 'Item #%s', 'invoicing' ), $subscription->get_product_id() );
295
+    }
296 296
 
297 297
 }
298 298
 add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item' );
@@ -304,13 +304,13 @@  discard block
 block discarded – undo
304 304
  */
305 305
 function getpaid_admin_subscription_metabox_display_gateway( $subscription ) {
306 306
 
307
-	$gateway = $subscription->get_gateway();
307
+    $gateway = $subscription->get_gateway();
308 308
 
309
-	if ( ! empty( $gateway ) ) {
310
-		echo sanitize_text_field( wpinv_get_gateway_admin_label( $gateway ) );
311
-	} else {
312
-		echo "&mdash;";
313
-	}
309
+    if ( ! empty( $gateway ) ) {
310
+        echo sanitize_text_field( wpinv_get_gateway_admin_label( $gateway ) );
311
+    } else {
312
+        echo "&mdash;";
313
+    }
314 314
 
315 315
 }
316 316
 add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' );
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
  * @param WPInv_Subscription $subscription
322 322
  */
323 323
 function getpaid_admin_subscription_metabox_display_status( $subscription ) {
324
-	echo $subscription->get_status_label_html();
324
+    echo $subscription->get_status_label_html();
325 325
 }
326 326
 add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' );
327 327
 
@@ -332,14 +332,14 @@  discard block
 block discarded – undo
332 332
  */
333 333
 function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) {
334 334
 
335
-	$profile_id = $subscription->get_profile_id();
335
+    $profile_id = $subscription->get_profile_id();
336 336
 
337
-	if ( ! empty( $profile_id ) ) {
338
-		$profile_id = sanitize_text_field( $profile_id );
339
-		echo apply_filters( 'getpaid_subscription_profile_id_display', $profile_id, $subscription );
340
-	} else {
341
-		echo "&mdash;";
342
-	}
337
+    if ( ! empty( $profile_id ) ) {
338
+        $profile_id = sanitize_text_field( $profile_id );
339
+        echo apply_filters( 'getpaid_subscription_profile_id_display', $profile_id, $subscription );
340
+    } else {
341
+        echo "&mdash;";
342
+    }
343 343
 
344 344
 }
345 345
 add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' );
@@ -351,39 +351,39 @@  discard block
 block discarded – undo
351 351
  */
352 352
 function getpaid_admin_subscription_update_metabox( $subscription ) {
353 353
 
354
-	?>
354
+    ?>
355 355
 	<div class="mt-3">
356 356
 
357 357
 		<?php
358
-			echo aui()->select(
359
-				array(
360
-					'options'          => getpaid_get_subscription_statuses(),
361
-					'name'             => 'subscription_status',
362
-					'id'               => 'subscription_status_update_select',
363
-					'required'         => true,
364
-					'no_wrap'          => false,
365
-					'label'            => __( 'Subscription Status', 'invoicing' ),
366
-					'help_text'        => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ),
367
-					'select2'          => true,
368
-					'value'            => $subscription->get_status( 'edit' ),
369
-				)
370
-			);
371
-		?>
358
+            echo aui()->select(
359
+                array(
360
+                    'options'          => getpaid_get_subscription_statuses(),
361
+                    'name'             => 'subscription_status',
362
+                    'id'               => 'subscription_status_update_select',
363
+                    'required'         => true,
364
+                    'no_wrap'          => false,
365
+                    'label'            => __( 'Subscription Status', 'invoicing' ),
366
+                    'help_text'        => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ),
367
+                    'select2'          => true,
368
+                    'value'            => $subscription->get_status( 'edit' ),
369
+                )
370
+            );
371
+        ?>
372 372
 
373 373
 		<div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;">
374 374
 	
375 375
 		<?php
376
-			submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false );
376
+            submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false );
377 377
 
378
-			$url    = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) );
379
-			$anchor = __( 'Renew Subscription', 'invoicing' );
380
-			$title  = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' );
378
+            $url    = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) );
379
+            $anchor = __( 'Renew Subscription', 'invoicing' );
380
+            $title  = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' );
381 381
 
382
-			if ( $subscription->is_active() ) {
383
-				echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>";
384
-			}
382
+            if ( $subscription->is_active() ) {
383
+                echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>";
384
+            }
385 385
 
386
-	echo '</div></div>';
386
+    echo '</div></div>';
387 387
 }
388 388
 
389 389
 /**
@@ -393,33 +393,33 @@  discard block
 block discarded – undo
393 393
  */
394 394
 function getpaid_admin_subscription_invoice_details_metabox( $subscription ) {
395 395
 
396
-	$columns = apply_filters(
397
-		'getpaid_subscription_related_invoices_columns',
398
-		array(
399
-			'invoice'      => __( 'Invoice', 'invoicing' ),
400
-			'relationship' => __( 'Relationship', 'invoicing' ),
401
-			'date'         => __( 'Date', 'invoicing' ),
402
-			'status'       => __( 'Status', 'invoicing' ),
403
-			'total'        => __( 'Total', 'invoicing' ),
404
-		),
405
-		$subscription
406
-	);
407
-
408
-	// Prepare the invoices.
409
-	$payments = $subscription->get_child_payments( ! is_admin() );
410
-	$parent   = $subscription->get_parent_invoice();
411
-
412
-	if ( $parent->get_id() ) {
413
-		$payments = array_merge( array( $parent ), $payments );
414
-	}
396
+    $columns = apply_filters(
397
+        'getpaid_subscription_related_invoices_columns',
398
+        array(
399
+            'invoice'      => __( 'Invoice', 'invoicing' ),
400
+            'relationship' => __( 'Relationship', 'invoicing' ),
401
+            'date'         => __( 'Date', 'invoicing' ),
402
+            'status'       => __( 'Status', 'invoicing' ),
403
+            'total'        => __( 'Total', 'invoicing' ),
404
+        ),
405
+        $subscription
406
+    );
407
+
408
+    // Prepare the invoices.
409
+    $payments = $subscription->get_child_payments( ! is_admin() );
410
+    $parent   = $subscription->get_parent_invoice();
411
+
412
+    if ( $parent->get_id() ) {
413
+        $payments = array_merge( array( $parent ), $payments );
414
+    }
415 415
 	
416
-	$table_class = 'w-100 bg-white';
416
+    $table_class = 'w-100 bg-white';
417 417
 
418
-	if ( ! is_admin() ) {
419
-		$table_class = 'table table-bordered table-striped';
420
-	}
418
+    if ( ! is_admin() ) {
419
+        $table_class = 'table table-bordered table-striped';
420
+    }
421 421
 
422
-	?>
422
+    ?>
423 423
 		<div class="m-0" style="overflow: auto;">
424 424
 
425 425
 			<table class="<?php echo $table_class; ?>">
@@ -427,13 +427,13 @@  discard block
 block discarded – undo
427 427
 				<thead>
428 428
 					<tr>
429 429
 						<?php
430
-							foreach ( $columns as $key => $label ) {
431
-								$key   = esc_attr( $key );
432
-								$label = sanitize_text_field( $label );
430
+                            foreach ( $columns as $key => $label ) {
431
+                                $key   = esc_attr( $key );
432
+                                $label = sanitize_text_field( $label );
433 433
 
434
-								echo "<th class='subscription-invoice-field-$key bg-light p-2 text-left color-dark font-weight-bold'>$label</th>";
435
-							}
436
-						?>
434
+                                echo "<th class='subscription-invoice-field-$key bg-light p-2 text-left color-dark font-weight-bold'>$label</th>";
435
+                            }
436
+                        ?>
437 437
 					</tr>
438 438
 				</thead>
439 439
 
@@ -449,66 +449,66 @@  discard block
 block discarded – undo
449 449
 
450 450
 					<?php
451 451
 
452
-						foreach( $payments as $payment ) :
452
+                        foreach( $payments as $payment ) :
453 453
 
454
-							// Ensure that we have an invoice.
455
-							$payment = new WPInv_Invoice( $payment );
454
+                            // Ensure that we have an invoice.
455
+                            $payment = new WPInv_Invoice( $payment );
456 456
 
457
-							// Abort if the invoice is invalid.
458
-							if ( ! $payment->get_id() ) {
459
-								continue;
460
-							}
457
+                            // Abort if the invoice is invalid.
458
+                            if ( ! $payment->get_id() ) {
459
+                                continue;
460
+                            }
461 461
 
462
-							echo '<tr>';
462
+                            echo '<tr>';
463 463
 
464
-								foreach ( array_keys( $columns ) as $key ) {
464
+                                foreach ( array_keys( $columns ) as $key ) {
465 465
 
466
-									echo '<td class="p-2 text-left">';
466
+                                    echo '<td class="p-2 text-left">';
467 467
 
468
-										switch( $key ) {
468
+                                        switch( $key ) {
469 469
 
470
-											case 'total':
471
-												echo '<strong>' . wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $payment->get_total() ) ), $payment->get_currency() ) . '</strong>';
472
-												break;
470
+                                            case 'total':
471
+                                                echo '<strong>' . wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $payment->get_total() ) ), $payment->get_currency() ) . '</strong>';
472
+                                                break;
473 473
 
474
-											case 'relationship':
475
-												echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' );
476
-												break;
474
+                                            case 'relationship':
475
+                                                echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' );
476
+                                                break;
477 477
 
478
-											case 'date':
479
-												echo getpaid_format_date_value( $payment->get_date_created() );
480
-												break;
478
+                                            case 'date':
479
+                                                echo getpaid_format_date_value( $payment->get_date_created() );
480
+                                                break;
481 481
 
482
-											case 'status':
482
+                                            case 'status':
483 483
 
484
-												$status = $payment->get_status_nicename();
485
-												if ( is_admin() ) {
486
-													$status = $payment->get_status_label_html();
487
-												}
484
+                                                $status = $payment->get_status_nicename();
485
+                                                if ( is_admin() ) {
486
+                                                    $status = $payment->get_status_label_html();
487
+                                                }
488 488
 
489
-												echo $status;
490
-												break;
489
+                                                echo $status;
490
+                                                break;
491 491
 
492
-											case 'invoice':
493
-												$link    = esc_url( get_edit_post_link( $payment->get_id() ) );
492
+                                            case 'invoice':
493
+                                                $link    = esc_url( get_edit_post_link( $payment->get_id() ) );
494 494
 
495
-												if ( ! is_admin() ) {
496
-													$link = esc_url( $payment->get_view_url() );
497
-												}
495
+                                                if ( ! is_admin() ) {
496
+                                                    $link = esc_url( $payment->get_view_url() );
497
+                                                }
498 498
 
499
-												$invoice = sanitize_text_field( $payment->get_number() );
500
-												echo "<a href='$link'>$invoice</a>";
501
-												break;
502
-										}
499
+                                                $invoice = sanitize_text_field( $payment->get_number() );
500
+                                                echo "<a href='$link'>$invoice</a>";
501
+                                                break;
502
+                                        }
503 503
 
504
-									echo '</td>';
504
+                                    echo '</td>';
505 505
 
506
-								}
506
+                                }
507 507
 
508
-							echo '</tr>';
508
+                            echo '</tr>';
509 509
 
510
-						endforeach;
511
-					?>
510
+                        endforeach;
511
+                    ?>
512 512
 
513 513
 				</tbody>
514 514
 
Please login to merge, or discard this patch.
Spacing   +120 added lines, -120 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,22 +17,22 @@  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
 					echo aui()->alert(
29 29
 						array(
30 30
 							'type'    => 'danger',
31
-							'content' => __( 'You are not permitted to view this page.', 'invoicing' ),
31
+							'content' => __('You are not permitted to view this page.', 'invoicing'),
32 32
 						)
33 33
 					);
34 34
 
35
-				} else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) {
35
+				} else if (!empty($_GET['id']) && is_numeric($_GET['id'])) {
36 36
 
37 37
 					// Display a single subscription.
38 38
 					wpinv_recurring_subscription_details();
@@ -81,13 +81,13 @@  discard block
 block discarded – undo
81 81
 function wpinv_recurring_subscription_details() {
82 82
 
83 83
 	// Fetch the subscription.
84
-	$sub = new WPInv_Subscription( (int) $_GET['id'] );
85
-	if ( ! $sub->get_id() ) {
84
+	$sub = new WPInv_Subscription((int) $_GET['id']);
85
+	if (!$sub->get_id()) {
86 86
 
87 87
 		echo aui()->alert(
88 88
 			array(
89 89
 				'type'    => 'danger',
90
-				'content' => __( 'Subscription not found.', 'invoicing' ),
90
+				'content' => __('Subscription not found.', 'invoicing'),
91 91
 			)
92 92
 		);
93 93
 
@@ -95,31 +95,31 @@  discard block
 block discarded – undo
95 95
 	}
96 96
 
97 97
 	// Use metaboxes to display the subscription details.
98
-	add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal' );
99
-	add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' );
100
-	add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' );
101
-	do_action( 'getpaid_admin_single_subscription_register_metabox', $sub );
98
+	add_meta_box('getpaid_admin_subscription_details_metabox', __('Subscription Details', 'invoicing'), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal');
99
+	add_meta_box('getpaid_admin_subscription_update_metabox', __('Change Status', 'invoicing'), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side');
100
+	add_meta_box('getpaid_admin_subscription_invoice_details_metabox', __('Invoices', 'invoicing'), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced');
101
+	do_action('getpaid_admin_single_subscription_register_metabox', $sub);
102 102
 
103 103
 	?>
104 104
 
105
-		<form method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ); ?>">
105
+		<form method="post" action="<?php echo admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($sub->get_id())); ?>">
106 106
 
107
-			<?php wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); ?>
108
-			<?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
109
-			<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
107
+			<?php wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); ?>
108
+			<?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?>
109
+			<?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?>
110 110
 			<input type="hidden" name="getpaid-admin-action" value="update_single_subscription" />
111
-			<input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id() ;?>" />
111
+			<input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id(); ?>" />
112 112
 
113 113
 			<div id="poststuff">
114 114
 				<div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
115 115
 
116 116
 					<div id="postbox-container-1" class="postbox-container">
117
-						<?php do_meta_boxes( get_current_screen(), 'side', $sub ); ?>
117
+						<?php do_meta_boxes(get_current_screen(), 'side', $sub); ?>
118 118
 					</div>
119 119
 
120 120
 					<div id="postbox-container-2" class="postbox-container">
121
-						<?php do_meta_boxes( get_current_screen(), 'normal', $sub ); ?>
122
-						<?php do_meta_boxes( get_current_screen(), 'advanced', $sub ); ?>
121
+						<?php do_meta_boxes(get_current_screen(), 'normal', $sub); ?>
122
+						<?php do_meta_boxes(get_current_screen(), 'advanced', $sub); ?>
123 123
 					</div>
124 124
 
125 125
 				</div>
@@ -138,40 +138,40 @@  discard block
 block discarded – undo
138 138
  *
139 139
  * @param WPInv_Subscription $sub
140 140
  */
141
-function getpaid_admin_subscription_details_metabox( $sub ) {
141
+function getpaid_admin_subscription_details_metabox($sub) {
142 142
 
143 143
 	// Prepare subscription detail columns.
144 144
 	$fields = apply_filters(
145 145
 		'getpaid_subscription_admin_page_fields',
146 146
 		array(
147
-			'subscription'   => __( 'Subscription', 'invoicing' ),
148
-			'customer'       => __( 'Customer', 'invoicing' ),
149
-			'amount'         => __( 'Amount', 'invoicing' ),
150
-			'start_date'     => __( 'Start Date', 'invoicing' ),
151
-			'renews_on'      => __( 'Next Payment', 'invoicing' ),
152
-			'renewals'       => __( 'Payments', 'invoicing' ),
153
-			'item'           => __( 'Item', 'invoicing' ),
154
-			'gateway'        => __( 'Payment Method', 'invoicing' ),
155
-			'profile_id'     => __( 'Profile ID', 'invoicing' ),
156
-			'status'         => __( 'Status', 'invoicing' ),
147
+			'subscription'   => __('Subscription', 'invoicing'),
148
+			'customer'       => __('Customer', 'invoicing'),
149
+			'amount'         => __('Amount', 'invoicing'),
150
+			'start_date'     => __('Start Date', 'invoicing'),
151
+			'renews_on'      => __('Next Payment', 'invoicing'),
152
+			'renewals'       => __('Payments', 'invoicing'),
153
+			'item'           => __('Item', 'invoicing'),
154
+			'gateway'        => __('Payment Method', 'invoicing'),
155
+			'profile_id'     => __('Profile ID', 'invoicing'),
156
+			'status'         => __('Status', 'invoicing'),
157 157
 		)
158 158
 	);
159 159
 
160
-	if ( ! $sub->is_active() ) {
160
+	if (!$sub->is_active()) {
161 161
 
162
-		if ( isset( $fields['renews_on'] ) ) {
163
-			unset( $fields['renews_on'] );
162
+		if (isset($fields['renews_on'])) {
163
+			unset($fields['renews_on']);
164 164
 		}
165 165
 
166
-		if ( isset( $fields['gateway'] ) ) {
167
-			unset( $fields['gateway'] );
166
+		if (isset($fields['gateway'])) {
167
+			unset($fields['gateway']);
168 168
 		}
169 169
 		
170 170
 	}
171 171
 
172 172
 	$profile_id = $sub->get_profile_id();
173
-	if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) {
174
-		unset( $fields['profile_id'] );
173
+	if (empty($profile_id) && isset($fields['profile_id'])) {
174
+		unset($fields['profile_id']);
175 175
 	}
176 176
 
177 177
 	?>
@@ -179,16 +179,16 @@  discard block
 block discarded – undo
179 179
 		<table class="table table-borderless" style="font-size: 14px;">
180 180
 			<tbody>
181 181
 
182
-				<?php foreach ( $fields as $key => $label ) : ?>
182
+				<?php foreach ($fields as $key => $label) : ?>
183 183
 
184
-					<tr class="getpaid-subscription-meta-<?php echo sanitize_html_class( $key ); ?>">
184
+					<tr class="getpaid-subscription-meta-<?php echo sanitize_html_class($key); ?>">
185 185
 
186 186
 						<th class="w-25" style="font-weight: 500;">
187
-							<?php echo sanitize_text_field( $label ); ?>
187
+							<?php echo sanitize_text_field($label); ?>
188 188
 						</th>
189 189
 
190 190
 						<td class="w-75 text-muted">
191
-							<?php do_action( 'getpaid_subscription_admin_display_' . sanitize_text_field( $key ), $sub ); ?>
191
+							<?php do_action('getpaid_subscription_admin_display_' . sanitize_text_field($key), $sub); ?>
192 192
 						</td>
193 193
 
194 194
 					</tr>
@@ -206,150 +206,150 @@  discard block
 block discarded – undo
206 206
  *
207 207
  * @param WPInv_Subscription $subscription
208 208
  */
209
-function getpaid_admin_subscription_metabox_display_customer( $subscription ) {
209
+function getpaid_admin_subscription_metabox_display_customer($subscription) {
210 210
 
211
-	$username = __( '(Missing User)', 'invoicing' );
211
+	$username = __('(Missing User)', 'invoicing');
212 212
 
213
-	$user = get_userdata( $subscription->get_customer_id() );
214
-	if ( $user ) {
213
+	$user = get_userdata($subscription->get_customer_id());
214
+	if ($user) {
215 215
 
216 216
 		$username = sprintf(
217 217
 			'<a href="user-edit.php?user_id=%s">%s</a>',
218
-			absint( $user->ID ),
219
-			! empty( $user->display_name ) ? sanitize_text_field( $user->display_name ) : sanitize_email( $user->user_email )
218
+			absint($user->ID),
219
+			!empty($user->display_name) ? sanitize_text_field($user->display_name) : sanitize_email($user->user_email)
220 220
 		);
221 221
 
222 222
 	}
223 223
 
224 224
 	echo  $username;
225 225
 }
226
-add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' );
226
+add_action('getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer');
227 227
 
228 228
 /**
229 229
  * Displays the subscription amount.
230 230
  *
231 231
  * @param WPInv_Subscription $subscription
232 232
  */
233
-function getpaid_admin_subscription_metabox_display_amount( $subscription ) {
234
-	$amount    = sanitize_text_field( getpaid_get_formatted_subscription_amount( $subscription ) );
233
+function getpaid_admin_subscription_metabox_display_amount($subscription) {
234
+	$amount = sanitize_text_field(getpaid_get_formatted_subscription_amount($subscription));
235 235
 	echo "<span>$amount</span>";
236 236
 }
237
-add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' );
237
+add_action('getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount');
238 238
 
239 239
 /**
240 240
  * Displays the subscription id.
241 241
  *
242 242
  * @param WPInv_Subscription $subscription
243 243
  */
244
-function getpaid_admin_subscription_metabox_display_id( $subscription ) {
245
-	echo  '#' . absint( $subscription->get_id() );
244
+function getpaid_admin_subscription_metabox_display_id($subscription) {
245
+	echo  '#' . absint($subscription->get_id());
246 246
 }
247
-add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' );
247
+add_action('getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id');
248 248
 
249 249
 /**
250 250
  * Displays the subscription renewal date.
251 251
  *
252 252
  * @param WPInv_Subscription $subscription
253 253
  */
254
-function getpaid_admin_subscription_metabox_display_start_date( $subscription ) {
255
-	echo getpaid_format_date_value( $subscription->get_date_created() );
254
+function getpaid_admin_subscription_metabox_display_start_date($subscription) {
255
+	echo getpaid_format_date_value($subscription->get_date_created());
256 256
 }
257
-add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' );
257
+add_action('getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date');
258 258
 
259 259
 /**
260 260
  * Displays the subscription renewal date.
261 261
  *
262 262
  * @param WPInv_Subscription $subscription
263 263
  */
264
-function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) {
265
-	echo getpaid_format_date_value( $subscription->get_expiration() );
264
+function getpaid_admin_subscription_metabox_display_renews_on($subscription) {
265
+	echo getpaid_format_date_value($subscription->get_expiration());
266 266
 }
267
-add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' );
267
+add_action('getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on');
268 268
 
269 269
 /**
270 270
  * Displays the subscription renewal count.
271 271
  *
272 272
  * @param WPInv_Subscription $subscription
273 273
  */
274
-function getpaid_admin_subscription_metabox_display_renewals( $subscription ) {
274
+function getpaid_admin_subscription_metabox_display_renewals($subscription) {
275 275
 	$max_bills = $subscription->get_bill_times();
276
-	echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "&infin;" : $max_bills );
276
+	echo $subscription->get_times_billed() . ' / ' . (empty($max_bills) ? "&infin;" : $max_bills);
277 277
 }
278
-add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' );
278
+add_action('getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals');
279 279
 /**
280 280
  * Displays the subscription item.
281 281
  *
282 282
  * @param WPInv_Subscription $subscription
283 283
  */
284
-function getpaid_admin_subscription_metabox_display_item( $subscription ) {
284
+function getpaid_admin_subscription_metabox_display_item($subscription) {
285 285
 
286
-	$item = get_post( $subscription->get_product_id() );
286
+	$item = get_post($subscription->get_product_id());
287 287
 
288
-	if ( ! empty( $item ) ) {
289
-		$link = get_edit_post_link( $item );
290
-		$link = esc_url( $link );
291
-		$name = esc_html( get_the_title( $item ) );
288
+	if (!empty($item)) {
289
+		$link = get_edit_post_link($item);
290
+		$link = esc_url($link);
291
+		$name = esc_html(get_the_title($item));
292 292
 		echo "<a href='$link'>$name</a>";
293 293
 	} else {
294
-		echo sprintf( __( 'Item #%s', 'invoicing' ), $subscription->get_product_id() );
294
+		echo sprintf(__('Item #%s', 'invoicing'), $subscription->get_product_id());
295 295
 	}
296 296
 
297 297
 }
298
-add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item' );
298
+add_action('getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item');
299 299
 
300 300
 /**
301 301
  * Displays the subscription gateway.
302 302
  *
303 303
  * @param WPInv_Subscription $subscription
304 304
  */
305
-function getpaid_admin_subscription_metabox_display_gateway( $subscription ) {
305
+function getpaid_admin_subscription_metabox_display_gateway($subscription) {
306 306
 
307 307
 	$gateway = $subscription->get_gateway();
308 308
 
309
-	if ( ! empty( $gateway ) ) {
310
-		echo sanitize_text_field( wpinv_get_gateway_admin_label( $gateway ) );
309
+	if (!empty($gateway)) {
310
+		echo sanitize_text_field(wpinv_get_gateway_admin_label($gateway));
311 311
 	} else {
312 312
 		echo "&mdash;";
313 313
 	}
314 314
 
315 315
 }
316
-add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' );
316
+add_action('getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway');
317 317
 
318 318
 /**
319 319
  * Displays the subscription status.
320 320
  *
321 321
  * @param WPInv_Subscription $subscription
322 322
  */
323
-function getpaid_admin_subscription_metabox_display_status( $subscription ) {
323
+function getpaid_admin_subscription_metabox_display_status($subscription) {
324 324
 	echo $subscription->get_status_label_html();
325 325
 }
326
-add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' );
326
+add_action('getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status');
327 327
 
328 328
 /**
329 329
  * Displays the subscription profile id.
330 330
  *
331 331
  * @param WPInv_Subscription $subscription
332 332
  */
333
-function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) {
333
+function getpaid_admin_subscription_metabox_display_profile_id($subscription) {
334 334
 
335 335
 	$profile_id = $subscription->get_profile_id();
336 336
 
337
-	if ( ! empty( $profile_id ) ) {
338
-		$profile_id = sanitize_text_field( $profile_id );
339
-		echo apply_filters( 'getpaid_subscription_profile_id_display', $profile_id, $subscription );
337
+	if (!empty($profile_id)) {
338
+		$profile_id = sanitize_text_field($profile_id);
339
+		echo apply_filters('getpaid_subscription_profile_id_display', $profile_id, $subscription);
340 340
 	} else {
341 341
 		echo "&mdash;";
342 342
 	}
343 343
 
344 344
 }
345
-add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' );
345
+add_action('getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id');
346 346
 
347 347
 /**
348 348
  * Displays the subscriptions update metabox.
349 349
  * 
350 350
  * @param WPInv_Subscription $subscription
351 351
  */
352
-function getpaid_admin_subscription_update_metabox( $subscription ) {
352
+function getpaid_admin_subscription_update_metabox($subscription) {
353 353
 
354 354
 	?>
355 355
 	<div class="mt-3">
@@ -362,10 +362,10 @@  discard block
 block discarded – undo
362 362
 					'id'               => 'subscription_status_update_select',
363 363
 					'required'         => true,
364 364
 					'no_wrap'          => false,
365
-					'label'            => __( 'Subscription Status', 'invoicing' ),
366
-					'help_text'        => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ),
365
+					'label'            => __('Subscription Status', 'invoicing'),
366
+					'help_text'        => __('Updating the status will trigger related actions and hooks', 'invoicing'),
367 367
 					'select2'          => true,
368
-					'value'            => $subscription->get_status( 'edit' ),
368
+					'value'            => $subscription->get_status('edit'),
369 369
 				)
370 370
 			);
371 371
 		?>
@@ -373,13 +373,13 @@  discard block
 block discarded – undo
373 373
 		<div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;">
374 374
 	
375 375
 		<?php
376
-			submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false );
376
+			submit_button(__('Update', 'invoicing'), 'primary', 'submit', false);
377 377
 
378
-			$url    = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) );
379
-			$anchor = __( 'Renew Subscription', 'invoicing' );
380
-			$title  = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' );
378
+			$url    = esc_url(wp_nonce_url(add_query_arg('getpaid-admin-action', 'subscription_manual_renew'), 'getpaid-nonce', 'getpaid-nonce'));
379
+			$anchor = __('Renew Subscription', 'invoicing');
380
+			$title  = esc_attr__('Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing');
381 381
 
382
-			if ( $subscription->is_active() ) {
382
+			if ($subscription->is_active()) {
383 383
 				echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>";
384 384
 			}
385 385
 
@@ -391,31 +391,31 @@  discard block
 block discarded – undo
391 391
  * 
392 392
  * @param WPInv_Subscription $subscription
393 393
  */
394
-function getpaid_admin_subscription_invoice_details_metabox( $subscription ) {
394
+function getpaid_admin_subscription_invoice_details_metabox($subscription) {
395 395
 
396 396
 	$columns = apply_filters(
397 397
 		'getpaid_subscription_related_invoices_columns',
398 398
 		array(
399
-			'invoice'      => __( 'Invoice', 'invoicing' ),
400
-			'relationship' => __( 'Relationship', 'invoicing' ),
401
-			'date'         => __( 'Date', 'invoicing' ),
402
-			'status'       => __( 'Status', 'invoicing' ),
403
-			'total'        => __( 'Total', 'invoicing' ),
399
+			'invoice'      => __('Invoice', 'invoicing'),
400
+			'relationship' => __('Relationship', 'invoicing'),
401
+			'date'         => __('Date', 'invoicing'),
402
+			'status'       => __('Status', 'invoicing'),
403
+			'total'        => __('Total', 'invoicing'),
404 404
 		),
405 405
 		$subscription
406 406
 	);
407 407
 
408 408
 	// Prepare the invoices.
409
-	$payments = $subscription->get_child_payments( ! is_admin() );
409
+	$payments = $subscription->get_child_payments(!is_admin());
410 410
 	$parent   = $subscription->get_parent_invoice();
411 411
 
412
-	if ( $parent->get_id() ) {
413
-		$payments = array_merge( array( $parent ), $payments );
412
+	if ($parent->get_id()) {
413
+		$payments = array_merge(array($parent), $payments);
414 414
 	}
415 415
 	
416 416
 	$table_class = 'w-100 bg-white';
417 417
 
418
-	if ( ! is_admin() ) {
418
+	if (!is_admin()) {
419 419
 		$table_class = 'table table-bordered table-striped';
420 420
 	}
421 421
 
@@ -427,9 +427,9 @@  discard block
 block discarded – undo
427 427
 				<thead>
428 428
 					<tr>
429 429
 						<?php
430
-							foreach ( $columns as $key => $label ) {
431
-								$key   = esc_attr( $key );
432
-								$label = sanitize_text_field( $label );
430
+							foreach ($columns as $key => $label) {
431
+								$key   = esc_attr($key);
432
+								$label = sanitize_text_field($label);
433 433
 
434 434
 								echo "<th class='subscription-invoice-field-$key bg-light p-2 text-left color-dark font-weight-bold'>$label</th>";
435 435
 							}
@@ -439,50 +439,50 @@  discard block
 block discarded – undo
439 439
 
440 440
 				<tbody>
441 441
 
442
-					<?php if ( empty( $payments ) ) : ?>
442
+					<?php if (empty($payments)) : ?>
443 443
 						<tr>
444 444
 							<td colspan="<?php echo count($columns); ?>" class="p-2 text-left text-muted">
445
-								<?php _e( 'This subscription has no invoices.', 'invoicing' ); ?>
445
+								<?php _e('This subscription has no invoices.', 'invoicing'); ?>
446 446
 							</td>
447 447
 						</tr>
448 448
 					<?php endif; ?>
449 449
 
450 450
 					<?php
451 451
 
452
-						foreach( $payments as $payment ) :
452
+						foreach ($payments as $payment) :
453 453
 
454 454
 							// Ensure that we have an invoice.
455
-							$payment = new WPInv_Invoice( $payment );
455
+							$payment = new WPInv_Invoice($payment);
456 456
 
457 457
 							// Abort if the invoice is invalid.
458
-							if ( ! $payment->get_id() ) {
458
+							if (!$payment->get_id()) {
459 459
 								continue;
460 460
 							}
461 461
 
462 462
 							echo '<tr>';
463 463
 
464
-								foreach ( array_keys( $columns ) as $key ) {
464
+								foreach (array_keys($columns) as $key) {
465 465
 
466 466
 									echo '<td class="p-2 text-left">';
467 467
 
468
-										switch( $key ) {
468
+										switch ($key) {
469 469
 
470 470
 											case 'total':
471
-												echo '<strong>' . wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $payment->get_total() ) ), $payment->get_currency() ) . '</strong>';
471
+												echo '<strong>' . wpinv_price(wpinv_format_amount(wpinv_sanitize_amount($payment->get_total())), $payment->get_currency()) . '</strong>';
472 472
 												break;
473 473
 
474 474
 											case 'relationship':
475
-												echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' );
475
+												echo $payment->is_renewal() ? __('Renewal Invoice', 'invoicing') : __('Initial Invoice', 'invoicing');
476 476
 												break;
477 477
 
478 478
 											case 'date':
479
-												echo getpaid_format_date_value( $payment->get_date_created() );
479
+												echo getpaid_format_date_value($payment->get_date_created());
480 480
 												break;
481 481
 
482 482
 											case 'status':
483 483
 
484 484
 												$status = $payment->get_status_nicename();
485
-												if ( is_admin() ) {
485
+												if (is_admin()) {
486 486
 													$status = $payment->get_status_label_html();
487 487
 												}
488 488
 
@@ -490,13 +490,13 @@  discard block
 block discarded – undo
490 490
 												break;
491 491
 
492 492
 											case 'invoice':
493
-												$link    = esc_url( get_edit_post_link( $payment->get_id() ) );
493
+												$link = esc_url(get_edit_post_link($payment->get_id()));
494 494
 
495
-												if ( ! is_admin() ) {
496
-													$link = esc_url( $payment->get_view_url() );
495
+												if (!is_admin()) {
496
+													$link = esc_url($payment->get_view_url());
497 497
 												}
498 498
 
499
-												$invoice = sanitize_text_field( $payment->get_number() );
499
+												$invoice = sanitize_text_field($payment->get_number());
500 500
 												echo "<a href='$link'>$invoice</a>";
501 501
 												break;
502 502
 										}
Please login to merge, or discard this patch.
includes/admin/register-settings.php 2 patches
Indentation   +288 added lines, -288 removed lines patch added patch discarded remove patch
@@ -196,11 +196,11 @@  discard block
 block discarded – undo
196 196
     $cb      = "wpinv_{$option['type']}_callback";
197 197
     $section = "wpinv_settings_{$tab}_$section";
198 198
 
199
-	if ( isset( $option['desc'] ) && ! empty( $option['help-tip'] ) ) {
200
-		$tip   = esc_attr( $option['desc'] );
201
-		$name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
202
-		unset( $option['desc'] );
203
-	}
199
+    if ( isset( $option['desc'] ) && ! empty( $option['help-tip'] ) ) {
200
+        $tip   = esc_attr( $option['desc'] );
201
+        $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
202
+        unset( $option['desc'] );
203
+    }
204 204
 
205 205
     // Loop through all tabs.
206 206
     add_settings_field(
@@ -227,8 +227,8 @@  discard block
 block discarded – undo
227 227
             'faux'        => isset( $option['faux'] )        ? $option['faux']        : false,
228 228
             'onchange'    => isset( $option['onchange'] )   ? $option['onchange']     : '',
229 229
             'custom'      => isset( $option['custom'] )     ? $option['custom']       : '',
230
-			'class'       => isset( $option['class'] )     ? $option['class']         : '',
231
-			'style'       => isset( $option['style'] )     ? $option['style']         : '',
230
+            'class'       => isset( $option['class'] )     ? $option['class']         : '',
231
+            'style'       => isset( $option['style'] )     ? $option['style']         : '',
232 232
             'cols'        => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
233 233
             'rows'        => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
234 234
         )
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
  * @return array
243 243
  */
244 244
 function wpinv_get_registered_settings() {
245
-	return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
245
+    return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
246 246
 }
247 247
 
248 248
 /**
@@ -289,10 +289,10 @@  discard block
 block discarded – undo
289 289
         }
290 290
 
291 291
         // General filter
292
-		$input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
292
+        $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
293 293
 
294
-		// Key specific filter.
295
-		$input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
294
+        // Key specific filter.
295
+        $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
296 296
     }
297 297
 
298 298
     // Loop through the whitelist and unset any that are empty for the tab being saved
@@ -348,14 +348,14 @@  discard block
 block discarded – undo
348 348
 
349 349
     foreach ( $new_rates as $rate ) {
350 350
 
351
-		$rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
352
-		$rate['name']    = sanitize_text_field( $rate['name'] );
353
-		$rate['state']   = sanitize_text_field( $rate['state'] );
354
-		$rate['country'] = sanitize_text_field( $rate['country'] );
355
-		$rate['global']  = empty( $rate['state'] );
356
-		$tax_rates[]     = $rate;
351
+        $rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
352
+        $rate['name']    = sanitize_text_field( $rate['name'] );
353
+        $rate['state']   = sanitize_text_field( $rate['state'] );
354
+        $rate['country'] = sanitize_text_field( $rate['country'] );
355
+        $rate['global']  = empty( $rate['state'] );
356
+        $tax_rates[]     = $rate;
357 357
 
358
-	}
358
+    }
359 359
 
360 360
     update_option( 'wpinv_tax_rates', $tax_rates );
361 361
 
@@ -373,11 +373,11 @@  discard block
 block discarded – undo
373 373
     $tabs['general']  = __( 'General', 'invoicing' );
374 374
     $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
375 375
     $tabs['taxes']    = __( 'Taxes', 'invoicing' );
376
-	$tabs['emails']   = __( 'Emails', 'invoicing' );
376
+    $tabs['emails']   = __( 'Emails', 'invoicing' );
377 377
 
378
-	if ( count( getpaid_get_integration_settings() ) > 0 ) {
379
-		$tabs['integrations'] = __( 'Integrations', 'invoicing' );
380
-	}
378
+    if ( count( getpaid_get_integration_settings() ) > 0 ) {
379
+        $tabs['integrations'] = __( 'Integrations', 'invoicing' );
380
+    }
381 381
 
382 382
     $tabs['privacy']  = __( 'Privacy', 'invoicing' );
383 383
     $tabs['misc']     = __( 'Misc', 'invoicing' );
@@ -417,14 +417,14 @@  discard block
 block discarded – undo
417 417
         ) ),
418 418
         'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array(
419 419
             'main'  => __( 'Tax Settings', 'invoicing' ),
420
-			'rates' => __( 'Tax Rates', 'invoicing' ),
421
-			'vat'   => __( 'EU VAT Settings', 'invoicing' )
420
+            'rates' => __( 'Tax Rates', 'invoicing' ),
421
+            'vat'   => __( 'EU VAT Settings', 'invoicing' )
422 422
         ) ),
423 423
         'emails' => apply_filters( 'wpinv_settings_sections_emails', array(
424 424
             'main' => __( 'Email Settings', 'invoicing' ),
425
-		) ),
425
+        ) ),
426 426
 
427
-		'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
427
+        'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
428 428
 
429 429
         'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array(
430 430
             'main' => __( 'Privacy policy', 'invoicing' ),
@@ -444,51 +444,51 @@  discard block
 block discarded – undo
444 444
 }
445 445
 
446 446
 function wpinv_get_pages( $with_slug = false, $default_label = NULL ) {
447
-	$pages_options = array();
447
+    $pages_options = array();
448 448
 
449
-	if( $default_label !== NULL && $default_label !== false ) {
450
-		$pages_options = array( '' => $default_label ); // Blank option
451
-	}
449
+    if( $default_label !== NULL && $default_label !== false ) {
450
+        $pages_options = array( '' => $default_label ); // Blank option
451
+    }
452 452
 
453
-	$pages = get_pages();
454
-	if ( $pages ) {
455
-		foreach ( $pages as $page ) {
456
-			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
453
+    $pages = get_pages();
454
+    if ( $pages ) {
455
+        foreach ( $pages as $page ) {
456
+            $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
457 457
             $pages_options[ $page->ID ] = $title;
458
-		}
459
-	}
458
+        }
459
+    }
460 460
 
461
-	return $pages_options;
461
+    return $pages_options;
462 462
 }
463 463
 
464 464
 function wpinv_header_callback( $args ) {
465
-	if ( !empty( $args['desc'] ) ) {
465
+    if ( !empty( $args['desc'] ) ) {
466 466
         echo $args['desc'];
467 467
     }
468 468
 }
469 469
 
470 470
 function wpinv_hidden_callback( $args ) {
471
-	global $wpinv_options;
472
-
473
-	if ( isset( $args['set_value'] ) ) {
474
-		$value = $args['set_value'];
475
-	} elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
476
-		$value = $wpinv_options[ $args['id'] ];
477
-	} else {
478
-		$value = isset( $args['std'] ) ? $args['std'] : '';
479
-	}
480
-
481
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
482
-		$args['readonly'] = true;
483
-		$value = isset( $args['std'] ) ? $args['std'] : '';
484
-		$name  = '';
485
-	} else {
486
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
487
-	}
488
-
489
-	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
471
+    global $wpinv_options;
472
+
473
+    if ( isset( $args['set_value'] ) ) {
474
+        $value = $args['set_value'];
475
+    } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
476
+        $value = $wpinv_options[ $args['id'] ];
477
+    } else {
478
+        $value = isset( $args['std'] ) ? $args['std'] : '';
479
+    }
480
+
481
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
482
+        $args['readonly'] = true;
483
+        $value = isset( $args['std'] ) ? $args['std'] : '';
484
+        $name  = '';
485
+    } else {
486
+        $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
487
+    }
488
+
489
+    $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
490 490
     
491
-	echo $html;
491
+    echo $html;
492 492
 }
493 493
 
494 494
 /**
@@ -496,12 +496,12 @@  discard block
 block discarded – undo
496 496
  */
497 497
 function wpinv_checkbox_callback( $args ) {
498 498
 
499
-	$std = isset( $args['std'] ) ? $args['std'] : '';
500
-	$std = wpinv_get_option( $args['id'], $std );
501
-	$id  = esc_attr( $args['id'] );
499
+    $std = isset( $args['std'] ) ? $args['std'] : '';
500
+    $std = wpinv_get_option( $args['id'], $std );
501
+    $id  = esc_attr( $args['id'] );
502 502
 
503
-	getpaid_hidden_field( "wpinv_settings[$id]", '0' );
504
-	?>
503
+    getpaid_hidden_field( "wpinv_settings[$id]", '0' );
504
+    ?>
505 505
 		<fieldset>
506 506
 			<label>
507 507
 				<input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox">
@@ -513,77 +513,77 @@  discard block
 block discarded – undo
513 513
 
514 514
 function wpinv_multicheck_callback( $args ) {
515 515
 	
516
-	global $wpinv_options;
516
+    global $wpinv_options;
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   = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std;
523
+        $std     = isset( $args['std'] ) ? $args['std'] : array();
524
+        $value   = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std;
525 525
 
526
-		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
526
+        echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
527 527
         foreach( $args['options'] as $key => $option ):
528
-			$sanitize_key = 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[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
535
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
536
-		endforeach;
537
-		echo '</div>';
538
-		echo '<p class="description">' . $args['desc'] . '</p>';
539
-	}
528
+            $sanitize_key = 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[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
535
+            echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
536
+        endforeach;
537
+        echo '</div>';
538
+        echo '<p class="description">' . $args['desc'] . '</p>';
539
+    }
540 540
 }
541 541
 
542 542
 function wpinv_payment_icons_callback( $args ) {
543
-	global $wpinv_options;
543
+    global $wpinv_options;
544 544
     
545 545
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
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( isset( $wpinv_options[$args['id']][$key] ) ) {
552
-				$enabled = $option;
553
-			} else {
554
-				$enabled = NULL;
555
-			}
556
-
557
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
558
-
559
-				echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $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 $option . '</label>';
584
-		}
585
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
586
-	}
551
+            if( isset( $wpinv_options[$args['id']][$key] ) ) {
552
+                $enabled = $option;
553
+            } else {
554
+                $enabled = NULL;
555
+            }
556
+
557
+            echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
558
+
559
+                echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $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 $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,50 +615,50 @@  discard block
 block discarded – undo
615 615
  */
616 616
 function getpaid_settings_description_callback( $args ) {
617 617
 
618
-	if ( ! empty( $args['desc'] ) ) {
619
-		$description = wp_kses_post( $args['desc'] );
620
-		echo "<p class='description'>$description</p>";
621
-	}
618
+    if ( ! empty( $args['desc'] ) ) {
619
+        $description = wp_kses_post( $args['desc'] );
620
+        echo "<p class='description'>$description</p>";
621
+    }
622 622
 
623 623
 }
624 624
 
625 625
 function wpinv_gateways_callback( $args ) {
626
-	global $wpinv_options;
626
+    global $wpinv_options;
627 627
     
628 628
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
629 629
 
630
-	foreach ( $args['options'] as $key => $option ) :
631
-		$sanitize_key = wpinv_sanitize_key( $key );
630
+    foreach ( $args['options'] as $key => $option ) :
631
+        $sanitize_key = wpinv_sanitize_key( $key );
632 632
         
633 633
         if ( isset( $wpinv_options['gateways'][ $key ] ) )
634
-			$enabled = '1';
635
-		else
636
-			$enabled = null;
634
+            $enabled = '1';
635
+        else
636
+            $enabled = null;
637 637
 
638
-		echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/>&nbsp;';
639
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
640
-	endforeach;
638
+        echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/>&nbsp;';
639
+        echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
640
+    endforeach;
641 641
 }
642 642
 
643 643
 function wpinv_gateway_select_callback($args) {
644
-	global $wpinv_options;
644
+    global $wpinv_options;
645 645
     
646 646
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
647 647
     $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
648 648
 
649
-	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
649
+    echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
650 650
 
651
-	foreach ( $args['options'] as $key => $option ) :
652
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
651
+    foreach ( $args['options'] as $key => $option ) :
652
+        if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
653 653
             $selected = selected( $key, $args['selected'], false );
654 654
         } else {
655 655
             $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : '';
656 656
         }
657
-		echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
658
-	endforeach;
657
+        echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
658
+    endforeach;
659 659
 
660
-	echo '</select>';
661
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
660
+    echo '</select>';
661
+    echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
662 662
 }
663 663
 
664 664
 /**
@@ -669,29 +669,29 @@  discard block
 block discarded – undo
669 669
  */
670 670
 function wpinv_settings_attrs_helper( $args ) {
671 671
 
672
-	$value        = isset( $args['std'] ) ? $args['std'] : '';
673
-	$id           = esc_attr( $args['id'] );
674
-	$placeholder  = esc_attr( $args['placeholder'] );
672
+    $value        = isset( $args['std'] ) ? $args['std'] : '';
673
+    $id           = esc_attr( $args['id'] );
674
+    $placeholder  = esc_attr( $args['placeholder'] );
675 675
 
676
-	if ( ! empty( $args['faux'] ) ) {
677
-		$args['readonly'] = true;
678
-		$name             = '';
679
-	} else {
680
-		$value  = wpinv_get_option( $args['id'], $value );
681
-		$name   = "wpinv_settings[$id]";
682
-	}
676
+    if ( ! empty( $args['faux'] ) ) {
677
+        $args['readonly'] = true;
678
+        $name             = '';
679
+    } else {
680
+        $value  = wpinv_get_option( $args['id'], $value );
681
+        $name   = "wpinv_settings[$id]";
682
+    }
683 683
 
684
-	$value    = is_scalar( $value ) ? esc_attr( $value ) : '';
685
-	$class    = esc_attr( $args['class'] );
686
-	$style    = esc_attr( $args['style'] );
687
-	$readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"';
684
+    $value    = is_scalar( $value ) ? esc_attr( $value ) : '';
685
+    $class    = esc_attr( $args['class'] );
686
+    $style    = esc_attr( $args['style'] );
687
+    $readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"';
688 688
 
689
-	$onchange = '';
689
+    $onchange = '';
690 690
     if ( ! empty( $args['onchange'] ) ) {
691 691
         $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
692
-	}
692
+    }
693 693
 
694
-	return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly";
694
+    return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly";
695 695
 }
696 696
 
697 697
 /**
@@ -699,11 +699,11 @@  discard block
 block discarded – undo
699 699
  */
700 700
 function wpinv_text_callback( $args ) {
701 701
 
702
-	$desc = wp_kses_post( $args['desc'] );
703
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
704
-	$attr = wpinv_settings_attrs_helper( $args );
702
+    $desc = wp_kses_post( $args['desc'] );
703
+    $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
704
+    $attr = wpinv_settings_attrs_helper( $args );
705 705
 
706
-	?>
706
+    ?>
707 707
 		<label style="width: 100%;">
708 708
 			<input type="text" <?php echo $attr; ?>>
709 709
 			<?php echo $desc; ?>
@@ -717,14 +717,14 @@  discard block
 block discarded – undo
717 717
  */
718 718
 function wpinv_number_callback( $args ) {
719 719
 
720
-	$desc = wp_kses_post( $args['desc'] );
721
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
722
-	$attr = wpinv_settings_attrs_helper( $args );
723
-	$max  = intval( $args['max'] );
724
-	$min  = intval( $args['min'] );
725
-	$step = floatval( $args['step'] );
720
+    $desc = wp_kses_post( $args['desc'] );
721
+    $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
722
+    $attr = wpinv_settings_attrs_helper( $args );
723
+    $max  = intval( $args['max'] );
724
+    $min  = intval( $args['min'] );
725
+    $step = floatval( $args['step'] );
726 726
 
727
-	?>
727
+    ?>
728 728
 		<label style="width: 100%;">
729 729
 			<input type="number" step="<?php echo $step; ?>" max="<?php echo $max; ?>" min="<?php echo $min; ?>" <?php echo $attr; ?>>
730 730
 			<?php echo $desc; ?>
@@ -734,48 +734,48 @@  discard block
 block discarded – undo
734 734
 }
735 735
 
736 736
 function wpinv_textarea_callback( $args ) {
737
-	global $wpinv_options;
737
+    global $wpinv_options;
738 738
     
739 739
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
740 740
 
741
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
742
-		$value = $wpinv_options[ $args['id'] ];
743
-	} else {
744
-		$value = isset( $args['std'] ) ? $args['std'] : '';
745
-	}
741
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
742
+        $value = $wpinv_options[ $args['id'] ];
743
+    } else {
744
+        $value = isset( $args['std'] ) ? $args['std'] : '';
745
+    }
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
-	$html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
751
-	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
750
+    $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
751
+    $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
752 752
 
753
-	echo $html;
753
+    echo $html;
754 754
 }
755 755
 
756 756
 function wpinv_password_callback( $args ) {
757
-	global $wpinv_options;
757
+    global $wpinv_options;
758 758
     
759 759
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
760 760
 
761
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
762
-		$value = $wpinv_options[ $args['id'] ];
763
-	} else {
764
-		$value = isset( $args['std'] ) ? $args['std'] : '';
765
-	}
761
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
762
+        $value = $wpinv_options[ $args['id'] ];
763
+    } else {
764
+        $value = isset( $args['std'] ) ? $args['std'] : '';
765
+    }
766 766
 
767
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
768
-	$html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
769
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
767
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
768
+    $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
769
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
770 770
 
771
-	echo $html;
771
+    echo $html;
772 772
 }
773 773
 
774 774
 function wpinv_missing_callback($args) {
775
-	printf(
776
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
777
-		'<strong>' . $args['id'] . '</strong>'
778
-	);
775
+    printf(
776
+        __( 'The callback function used for the %s setting is missing.', 'invoicing' ),
777
+        '<strong>' . $args['id'] . '</strong>'
778
+    );
779 779
 }
780 780
 
781 781
 /**
@@ -783,13 +783,13 @@  discard block
 block discarded – undo
783 783
  */
784 784
 function wpinv_select_callback( $args ) {
785 785
 
786
-	$desc   = wp_kses_post( $args['desc'] );
787
-	$desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
788
-	$attr   = wpinv_settings_attrs_helper( $args );
789
-	$value  = isset( $args['std'] ) ? $args['std'] : '';
790
-	$value  = wpinv_get_option( $args['id'], $value );
786
+    $desc   = wp_kses_post( $args['desc'] );
787
+    $desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
788
+    $attr   = wpinv_settings_attrs_helper( $args );
789
+    $value  = isset( $args['std'] ) ? $args['std'] : '';
790
+    $value  = wpinv_get_option( $args['id'], $value );
791 791
 
792
-	?>
792
+    ?>
793 793
 		<label style="width: 100%;">
794 794
 			<select <?php echo $attr; ?>>
795 795
 				<?php foreach ( $args['options'] as $option => $name ) : ?>
@@ -803,123 +803,123 @@  discard block
 block discarded – undo
803 803
 }
804 804
 
805 805
 function wpinv_color_select_callback( $args ) {
806
-	global $wpinv_options;
806
+    global $wpinv_options;
807 807
     
808 808
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
809 809
 
810
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
811
-		$value = $wpinv_options[ $args['id'] ];
812
-	} else {
813
-		$value = isset( $args['std'] ) ? $args['std'] : '';
814
-	}
810
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
811
+        $value = $wpinv_options[ $args['id'] ];
812
+    } else {
813
+        $value = isset( $args['std'] ) ? $args['std'] : '';
814
+    }
815 815
 
816
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
816
+    $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
817 817
 
818
-	foreach ( $args['options'] as $option => $color ) {
819
-		$selected = selected( $option, $value, false );
820
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
821
-	}
818
+    foreach ( $args['options'] as $option => $color ) {
819
+        $selected = selected( $option, $value, false );
820
+        $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
821
+    }
822 822
 
823
-	$html .= '</select>';
824
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
823
+    $html .= '</select>';
824
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
825 825
 
826
-	echo $html;
826
+    echo $html;
827 827
 }
828 828
 
829 829
 function wpinv_rich_editor_callback( $args ) {
830
-	global $wpinv_options, $wp_version;
830
+    global $wpinv_options, $wp_version;
831 831
     
832 832
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
833 833
 
834
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
835
-		$value = $wpinv_options[ $args['id'] ];
834
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
835
+        $value = $wpinv_options[ $args['id'] ];
836 836
 
837
-		if( empty( $args['allow_blank'] ) && empty( $value ) ) {
838
-			$value = isset( $args['std'] ) ? $args['std'] : '';
839
-		}
840
-	} else {
841
-		$value = isset( $args['std'] ) ? $args['std'] : '';
842
-	}
837
+        if( empty( $args['allow_blank'] ) && empty( $value ) ) {
838
+            $value = isset( $args['std'] ) ? $args['std'] : '';
839
+        }
840
+    } else {
841
+        $value = isset( $args['std'] ) ? $args['std'] : '';
842
+    }
843 843
 
844
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
844
+    $rows = isset( $args['size'] ) ? $args['size'] : 20;
845 845
 
846
-	$html = '<div class="getpaid-settings-editor-input">';
847
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
848
-		ob_start();
849
-		wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) );
850
-		$html .= ob_get_clean();
851
-	} else {
852
-		$html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
853
-	}
846
+    $html = '<div class="getpaid-settings-editor-input">';
847
+    if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
848
+        ob_start();
849
+        wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) );
850
+        $html .= ob_get_clean();
851
+    } else {
852
+        $html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
853
+    }
854 854
 
855
-	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
855
+    $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
856 856
 
857
-	echo $html;
857
+    echo $html;
858 858
 }
859 859
 
860 860
 function wpinv_upload_callback( $args ) {
861
-	global $wpinv_options;
861
+    global $wpinv_options;
862 862
     
863 863
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
864 864
 
865
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
866
-		$value = $wpinv_options[$args['id']];
867
-	} else {
868
-		$value = isset($args['std']) ? $args['std'] : '';
869
-	}
865
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
866
+        $value = $wpinv_options[$args['id']];
867
+    } else {
868
+        $value = isset($args['std']) ? $args['std'] : '';
869
+    }
870 870
 
871
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
872
-	$html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
873
-	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
874
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
871
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
872
+    $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
873
+    $html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
874
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
875 875
 
876
-	echo $html;
876
+    echo $html;
877 877
 }
878 878
 
879 879
 function wpinv_color_callback( $args ) {
880
-	global $wpinv_options;
880
+    global $wpinv_options;
881 881
     
882 882
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
883 883
 
884
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
885
-		$value = $wpinv_options[ $args['id'] ];
886
-	} else {
887
-		$value = isset( $args['std'] ) ? $args['std'] : '';
888
-	}
884
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
885
+        $value = $wpinv_options[ $args['id'] ];
886
+    } else {
887
+        $value = isset( $args['std'] ) ? $args['std'] : '';
888
+    }
889 889
 
890
-	$default = isset( $args['std'] ) ? $args['std'] : '';
890
+    $default = isset( $args['std'] ) ? $args['std'] : '';
891 891
 
892
-	$html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />';
893
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
892
+    $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />';
893
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
894 894
 
895
-	echo $html;
895
+    echo $html;
896 896
 }
897 897
 
898 898
 function wpinv_country_states_callback($args) {
899
-	global $wpinv_options;
899
+    global $wpinv_options;
900 900
     
901 901
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
902 902
 
903
-	if ( isset( $args['placeholder'] ) ) {
904
-		$placeholder = $args['placeholder'];
905
-	} else {
906
-		$placeholder = '';
907
-	}
903
+    if ( isset( $args['placeholder'] ) ) {
904
+        $placeholder = $args['placeholder'];
905
+    } else {
906
+        $placeholder = '';
907
+    }
908 908
 
909
-	$states = wpinv_get_country_states();
909
+    $states = wpinv_get_country_states();
910 910
 
911
-	$class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
912
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
911
+    $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
912
+    $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
913 913
 
914
-	foreach ( $states as $option => $name ) {
915
-		$selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
916
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
917
-	}
914
+    foreach ( $states as $option => $name ) {
915
+        $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
916
+        $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
917
+    }
918 918
 
919
-	$html .= '</select>';
920
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
919
+    $html .= '</select>';
920
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
921 921
 
922
-	echo $html;
922
+    echo $html;
923 923
 }
924 924
 
925 925
 /**
@@ -927,7 +927,7 @@  discard block
 block discarded – undo
927 927
  */
928 928
 function wpinv_tax_rates_callback() {
929 929
 	
930
-	?>
930
+    ?>
931 931
 		</td>
932 932
 	</tr>
933 933
 	<tr class="bsui">
@@ -942,17 +942,17 @@  discard block
 block discarded – undo
942 942
  * Displays a tax rate' edit row.
943 943
  */
944 944
 function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) {
945
-	ob_start();
945
+    ob_start();
946 946
 
947
-	$key                      = sanitize_key( $key );
948
-	$tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
949
-	include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
947
+    $key                      = sanitize_key( $key );
948
+    $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
949
+    include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
950 950
 
951
-	if ( $echo ) {
952
-		echo ob_get_clean();
953
-	} else {
954
-		return ob_get_clean(); 
955
-	}
951
+    if ( $echo ) {
952
+        echo ob_get_clean();
953
+    } else {
954
+        return ob_get_clean(); 
955
+    }
956 956
 
957 957
 }
958 958
 
@@ -980,19 +980,19 @@  discard block
 block discarded – undo
980 980
 }
981 981
 
982 982
 function wpinv_descriptive_text_callback( $args ) {
983
-	echo wp_kses_post( $args['desc'] );
983
+    echo wp_kses_post( $args['desc'] );
984 984
 }
985 985
 
986 986
 function wpinv_raw_html_callback( $args ) {
987
-	echo $args['desc'];
987
+    echo $args['desc'];
988 988
 }
989 989
 
990 990
 function wpinv_hook_callback( $args ) {
991
-	do_action( 'wpinv_' . $args['id'], $args );
991
+    do_action( 'wpinv_' . $args['id'], $args );
992 992
 }
993 993
 
994 994
 function wpinv_set_settings_cap() {
995
-	return wpinv_get_capability();
995
+    return wpinv_get_capability();
996 996
 }
997 997
 add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
998 998
 
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
 
@@ -43,12 +43,12 @@  discard block
 block discarded – undo
43 43
     global $wpinv_options;
44 44
 
45 45
     // Try fetching the saved options.
46
-    if ( ! is_array( $wpinv_options ) ) {
47
-        $wpinv_options = get_option( 'wpinv_settings' );
46
+    if (!is_array($wpinv_options)) {
47
+        $wpinv_options = get_option('wpinv_settings');
48 48
     }
49 49
 
50 50
     // If that fails, don't fetch the default settings to prevent a loop.
51
-    if ( ! is_array( $wpinv_options ) ) {
51
+    if (!is_array($wpinv_options)) {
52 52
         $wpinv_options = array();
53 53
     }
54 54
 
@@ -62,13 +62,13 @@  discard block
 block discarded – undo
62 62
  * @param mixed $default The default value to use if the setting has not been set.
63 63
  * @return mixed
64 64
  */
65
-function wpinv_get_option( $key = '', $default = false ) {
65
+function wpinv_get_option($key = '', $default = false) {
66 66
 
67 67
     $options = wpinv_get_options();
68
-    $value   = isset( $options[ $key ] ) ? $options[ $key ] : $default;
69
-    $value   = apply_filters( 'wpinv_get_option', $value, $key, $default );
68
+    $value   = isset($options[$key]) ? $options[$key] : $default;
69
+    $value   = apply_filters('wpinv_get_option', $value, $key, $default);
70 70
 
71
-    return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default );
71
+    return apply_filters('wpinv_get_option_' . $key, $value, $key, $default);
72 72
 }
73 73
 
74 74
 /**
@@ -77,11 +77,11 @@  discard block
 block discarded – undo
77 77
  * @param array $options the new options.
78 78
  * @return bool
79 79
  */
80
-function wpinv_update_options( $options ) {
80
+function wpinv_update_options($options) {
81 81
     global $wpinv_options;
82 82
 
83 83
     // update the option.
84
-    if ( is_array( $options ) && update_option( 'wpinv_settings', $options ) ) {
84
+    if (is_array($options) && update_option('wpinv_settings', $options)) {
85 85
         $wpinv_options = $options;
86 86
         return true;
87 87
     }
@@ -96,24 +96,24 @@  discard block
 block discarded – undo
96 96
  * @param mixed $value The setting value.
97 97
  * @return bool
98 98
  */
99
-function wpinv_update_option( $key = '', $value = false ) {
99
+function wpinv_update_option($key = '', $value = false) {
100 100
 
101 101
     // If no key, exit.
102
-    if ( empty( $key ) ) {
102
+    if (empty($key)) {
103 103
         return false;
104 104
     }
105 105
 
106 106
     // Maybe delete the option instead.
107
-    if ( is_null( $value ) ) {
108
-        return wpinv_delete_option( $key );
107
+    if (is_null($value)) {
108
+        return wpinv_delete_option($key);
109 109
     }
110 110
 
111 111
     // Prepare the new options.
112 112
     $options         = wpinv_get_options();
113
-    $options[ $key ] = apply_filters( 'wpinv_update_option', $value, $key );
113
+    $options[$key] = apply_filters('wpinv_update_option', $value, $key);
114 114
 
115 115
     // Save the new options.
116
-    return wpinv_update_options( $options );
116
+    return wpinv_update_options($options);
117 117
 
118 118
 }
119 119
 
@@ -123,18 +123,18 @@  discard block
 block discarded – undo
123 123
  * @param string $key the setting key.
124 124
  * @return bool
125 125
  */
126
-function wpinv_delete_option( $key = '' ) {
126
+function wpinv_delete_option($key = '') {
127 127
 
128 128
     // If no key, exit
129
-    if ( empty( $key ) ) {
129
+    if (empty($key)) {
130 130
         return false;
131 131
     }
132 132
 
133 133
     $options = wpinv_get_options();
134 134
 
135
-    if ( isset( $options[ $key ] ) ) {
136
-        unset( $options[ $key ] );
137
-        return wpinv_update_options( $options );
135
+    if (isset($options[$key])) {
136
+        unset($options[$key]);
137
+        return wpinv_update_options($options);
138 138
     }
139 139
 
140 140
     return true;
@@ -148,14 +148,14 @@  discard block
 block discarded – undo
148 148
 function wpinv_register_settings() {
149 149
 
150 150
     // Loop through all tabs.
151
-    foreach ( wpinv_get_registered_settings() as $tab => $sections ) {
151
+    foreach (wpinv_get_registered_settings() as $tab => $sections) {
152 152
 
153 153
         // In each tab, loop through sections.
154
-        foreach ( $sections as $section => $settings ) {
154
+        foreach ($sections as $section => $settings) {
155 155
 
156 156
             // Check for backwards compatibility
157
-            $section_tabs = wpinv_get_settings_tab_sections( $tab );
158
-            if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) {
157
+            $section_tabs = wpinv_get_settings_tab_sections($tab);
158
+            if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) {
159 159
                 $section = 'main';
160 160
                 $settings = $sections;
161 161
             }
@@ -168,9 +168,9 @@  discard block
 block discarded – undo
168 168
                 'wpinv_settings_' . $tab . '_' . $section
169 169
             );
170 170
 
171
-            foreach ( $settings as $option ) {
172
-                if ( ! empty( $option['id'] ) ) {
173
-                    wpinv_register_settings_option( $tab, $section, $option );
171
+            foreach ($settings as $option) {
172
+                if (!empty($option['id'])) {
173
+                    wpinv_register_settings_option($tab, $section, $option);
174 174
                 }
175 175
             }
176 176
 
@@ -178,9 +178,9 @@  discard block
 block discarded – undo
178 178
     }
179 179
 
180 180
     // Creates our settings in the options table.
181
-    register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' );
181
+    register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize');
182 182
 }
183
-add_action( 'admin_init', 'wpinv_register_settings' );
183
+add_action('admin_init', 'wpinv_register_settings');
184 184
 
185 185
 /**
186 186
  * Register a single settings option.
@@ -190,47 +190,47 @@  discard block
 block discarded – undo
190 190
  * @param string $option
191 191
  * 
192 192
  */
193
-function wpinv_register_settings_option( $tab, $section, $option ) {
193
+function wpinv_register_settings_option($tab, $section, $option) {
194 194
 
195
-    $name    = isset( $option['name'] ) ? $option['name'] : '';
195
+    $name    = isset($option['name']) ? $option['name'] : '';
196 196
     $cb      = "wpinv_{$option['type']}_callback";
197 197
     $section = "wpinv_settings_{$tab}_$section";
198 198
 
199
-	if ( isset( $option['desc'] ) && ! empty( $option['help-tip'] ) ) {
200
-		$tip   = esc_attr( $option['desc'] );
199
+	if (isset($option['desc']) && !empty($option['help-tip'])) {
200
+		$tip   = esc_attr($option['desc']);
201 201
 		$name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
202
-		unset( $option['desc'] );
202
+		unset($option['desc']);
203 203
 	}
204 204
 
205 205
     // Loop through all tabs.
206 206
     add_settings_field(
207 207
         'wpinv_settings[' . $option['id'] . ']',
208 208
         $name,
209
-        function_exists( $cb ) ? $cb : 'wpinv_missing_callback',
209
+        function_exists($cb) ? $cb : 'wpinv_missing_callback',
210 210
         $section,
211 211
         $section,
212 212
         array(
213 213
             'section'     => $section,
214
-            'id'          => isset( $option['id'] )          ? $option['id']          : uniqid( 'wpinv-' ),
215
-            'desc'        => isset( $option['desc'] )        ? $option['desc']        : '',
214
+            'id'          => isset($option['id']) ? $option['id'] : uniqid('wpinv-'),
215
+            'desc'        => isset($option['desc']) ? $option['desc'] : '',
216 216
             'name'        => $name,
217
-            'size'        => isset( $option['size'] )        ? $option['size']        : null,
218
-            'options'     => isset( $option['options'] )     ? $option['options']     : '',
219
-            'selected'    => isset( $option['selected'] )    ? $option['selected']    : null,
220
-            'std'         => isset( $option['std'] )         ? $option['std']         : '',
221
-            'min'         => isset( $option['min'] )         ? $option['min']         : 0,
222
-            'max'         => isset( $option['max'] )         ? $option['max']         : 999999,
223
-            'step'        => isset( $option['step'] )        ? $option['step']        : 1,
224
-            'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null,
225
-            'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true,
226
-            'readonly'    => isset( $option['readonly'] )    ? $option['readonly']    : false,
227
-            'faux'        => isset( $option['faux'] )        ? $option['faux']        : false,
228
-            'onchange'    => isset( $option['onchange'] )   ? $option['onchange']     : '',
229
-            'custom'      => isset( $option['custom'] )     ? $option['custom']       : '',
230
-			'class'       => isset( $option['class'] )     ? $option['class']         : '',
231
-			'style'       => isset( $option['style'] )     ? $option['style']         : '',
232
-            'cols'        => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
233
-            'rows'        => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
217
+            'size'        => isset($option['size']) ? $option['size'] : null,
218
+            'options'     => isset($option['options']) ? $option['options'] : '',
219
+            'selected'    => isset($option['selected']) ? $option['selected'] : null,
220
+            'std'         => isset($option['std']) ? $option['std'] : '',
221
+            'min'         => isset($option['min']) ? $option['min'] : 0,
222
+            'max'         => isset($option['max']) ? $option['max'] : 999999,
223
+            'step'        => isset($option['step']) ? $option['step'] : 1,
224
+            'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null,
225
+            'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true,
226
+            'readonly'    => isset($option['readonly']) ? $option['readonly'] : false,
227
+            'faux'        => isset($option['faux']) ? $option['faux'] : false,
228
+            'onchange'    => isset($option['onchange']) ? $option['onchange'] : '',
229
+            'custom'      => isset($option['custom']) ? $option['custom'] : '',
230
+			'class'       => isset($option['class']) ? $option['class'] : '',
231
+			'style'       => isset($option['style']) ? $option['style'] : '',
232
+            'cols'        => isset($option['cols']) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
233
+            'rows'        => isset($option['rows']) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
234 234
         )
235 235
     );
236 236
 
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
  * @return array
243 243
  */
244 244
 function wpinv_get_registered_settings() {
245
-	return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
245
+	return array_filter(apply_filters('wpinv_registered_settings', wpinv_get_data('admin-settings')));
246 246
 }
247 247
 
248 248
 /**
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
  * @return array
252 252
  */
253 253
 function getpaid_get_integration_settings() {
254
-    return apply_filters( 'getpaid_integration_settings', array() );
254
+    return apply_filters('getpaid_integration_settings', array());
255 255
 }
256 256
 
257 257
 /**
@@ -259,140 +259,140 @@  discard block
 block discarded – undo
259 259
  * 
260 260
  * @return array
261 261
  */
262
-function wpinv_settings_sanitize( $input = array() ) {
262
+function wpinv_settings_sanitize($input = array()) {
263 263
 
264 264
     $wpinv_options = wpinv_get_options();
265 265
 
266
-    if ( empty( wp_get_raw_referer() ) ) {
266
+    if (empty(wp_get_raw_referer())) {
267 267
         return $input;
268 268
     }
269 269
 
270
-    wp_parse_str( wp_get_raw_referer(), $referrer );
270
+    wp_parse_str(wp_get_raw_referer(), $referrer);
271 271
 
272 272
     $settings = wpinv_get_registered_settings();
273
-    $tab      = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
274
-    $section  = isset( $referrer['section'] ) ? $referrer['section'] : 'main';
273
+    $tab      = isset($referrer['tab']) ? $referrer['tab'] : 'general';
274
+    $section  = isset($referrer['section']) ? $referrer['section'] : 'main';
275 275
 
276 276
     $input = $input ? $input : array();
277
-    $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input );
278
-    $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input );
277
+    $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input);
278
+    $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input);
279 279
 
280 280
     // Loop through each setting being saved and pass it through a sanitization filter
281
-    foreach ( $input as $key => $value ) {
281
+    foreach ($input as $key => $value) {
282 282
 
283 283
         // Get the setting type (checkbox, select, etc)
284
-        $type = isset( $settings[ $tab ][$section][ $key ]['type'] ) ? $settings[ $tab ][$section][ $key ]['type'] : false;
284
+        $type = isset($settings[$tab][$section][$key]['type']) ? $settings[$tab][$section][$key]['type'] : false;
285 285
 
286
-        if ( $type ) {
286
+        if ($type) {
287 287
             // Field type specific filter
288
-            $input[$key] = apply_filters( 'wpinv_settings_sanitize_' . $type, $value, $key );
288
+            $input[$key] = apply_filters('wpinv_settings_sanitize_' . $type, $value, $key);
289 289
         }
290 290
 
291 291
         // General filter
292
-		$input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
292
+		$input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key);
293 293
 
294 294
 		// Key specific filter.
295
-		$input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
295
+		$input[$key] = apply_filters("wpinv_settings_sanitize_$key", $input[$key]);
296 296
     }
297 297
 
298 298
     // Loop through the whitelist and unset any that are empty for the tab being saved
299
-    $main_settings    = $section == 'main' ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections
300
-    $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array();
299
+    $main_settings    = $section == 'main' ? $settings[$tab] : array(); // Check for extensions that aren't using new sections
300
+    $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array();
301 301
 
302
-    $found_settings = array_merge( $main_settings, $section_settings );
302
+    $found_settings = array_merge($main_settings, $section_settings);
303 303
 
304
-    if ( ! empty( $found_settings ) ) {
305
-        foreach ( $found_settings as $key => $value ) {
304
+    if (!empty($found_settings)) {
305
+        foreach ($found_settings as $key => $value) {
306 306
 
307 307
             // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work
308
-            if ( is_numeric( $key ) ) {
308
+            if (is_numeric($key)) {
309 309
                 $key = $value['id'];
310 310
             }
311 311
 
312
-            if ( ! isset( $input[ $key ] ) && isset( $wpinv_options[ $key ] ) ) {
313
-                unset( $wpinv_options[ $key ] );
312
+            if (!isset($input[$key]) && isset($wpinv_options[$key])) {
313
+                unset($wpinv_options[$key]);
314 314
             }
315 315
         }
316 316
     }
317 317
 
318 318
     // Merge our new settings with the existing
319
-    $output = array_merge( $wpinv_options, $input );
319
+    $output = array_merge($wpinv_options, $input);
320 320
 
321
-    add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' );
321
+    add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated');
322 322
 
323 323
     return $output;
324 324
 }
325 325
 
326
-function wpinv_settings_sanitize_misc_accounting( $input ) {
326
+function wpinv_settings_sanitize_misc_accounting($input) {
327 327
 
328
-    if ( ! wpinv_current_user_can_manage_invoicing() ) {
328
+    if (!wpinv_current_user_can_manage_invoicing()) {
329 329
         return $input;
330 330
     }
331 331
 
332
-    if( ! empty( $input['enable_sequential'] ) && !wpinv_get_option( 'enable_sequential' ) ) {
332
+    if (!empty($input['enable_sequential']) && !wpinv_get_option('enable_sequential')) {
333 333
         // Shows an admin notice about upgrading previous order numbers
334
-        getpaid_session()->set( 'upgrade_sequential', '1' );
334
+        getpaid_session()->set('upgrade_sequential', '1');
335 335
     }
336 336
 
337 337
     return $input;
338 338
 }
339
-add_filter( 'wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting' );
339
+add_filter('wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting');
340 340
 
341
-function wpinv_settings_sanitize_tax_rates( $input ) {
342
-    if( ! wpinv_current_user_can_manage_invoicing() ) {
341
+function wpinv_settings_sanitize_tax_rates($input) {
342
+    if (!wpinv_current_user_can_manage_invoicing()) {
343 343
         return $input;
344 344
     }
345 345
 
346
-    $new_rates = ! empty( $_POST['tax_rates'] ) ? array_values( $_POST['tax_rates'] ) : array();
346
+    $new_rates = !empty($_POST['tax_rates']) ? array_values($_POST['tax_rates']) : array();
347 347
     $tax_rates = array();
348 348
 
349
-    foreach ( $new_rates as $rate ) {
349
+    foreach ($new_rates as $rate) {
350 350
 
351
-		$rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
352
-		$rate['name']    = sanitize_text_field( $rate['name'] );
353
-		$rate['state']   = sanitize_text_field( $rate['state'] );
354
-		$rate['country'] = sanitize_text_field( $rate['country'] );
355
-		$rate['global']  = empty( $rate['state'] );
351
+		$rate['rate']    = wpinv_sanitize_amount($rate['rate']);
352
+		$rate['name']    = sanitize_text_field($rate['name']);
353
+		$rate['state']   = sanitize_text_field($rate['state']);
354
+		$rate['country'] = sanitize_text_field($rate['country']);
355
+		$rate['global']  = empty($rate['state']);
356 356
 		$tax_rates[]     = $rate;
357 357
 
358 358
 	}
359 359
 
360
-    update_option( 'wpinv_tax_rates', $tax_rates );
360
+    update_option('wpinv_tax_rates', $tax_rates);
361 361
 
362 362
     return $input;
363 363
 }
364
-add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' );
364
+add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates');
365 365
 
366
-function wpinv_sanitize_text_field( $input ) {
367
-    return trim( $input );
366
+function wpinv_sanitize_text_field($input) {
367
+    return trim($input);
368 368
 }
369
-add_filter( 'wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field' );
369
+add_filter('wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field');
370 370
 
371 371
 function wpinv_get_settings_tabs() {
372 372
     $tabs             = array();
373
-    $tabs['general']  = __( 'General', 'invoicing' );
374
-    $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
375
-    $tabs['taxes']    = __( 'Taxes', 'invoicing' );
376
-	$tabs['emails']   = __( 'Emails', 'invoicing' );
373
+    $tabs['general']  = __('General', 'invoicing');
374
+    $tabs['gateways'] = __('Payment Gateways', 'invoicing');
375
+    $tabs['taxes']    = __('Taxes', 'invoicing');
376
+	$tabs['emails'] = __('Emails', 'invoicing');
377 377
 
378
-	if ( count( getpaid_get_integration_settings() ) > 0 ) {
379
-		$tabs['integrations'] = __( 'Integrations', 'invoicing' );
378
+	if (count(getpaid_get_integration_settings()) > 0) {
379
+		$tabs['integrations'] = __('Integrations', 'invoicing');
380 380
 	}
381 381
 
382
-    $tabs['privacy']  = __( 'Privacy', 'invoicing' );
383
-    $tabs['misc']     = __( 'Misc', 'invoicing' );
384
-    $tabs['tools']    = __( 'Tools', 'invoicing' );
382
+    $tabs['privacy']  = __('Privacy', 'invoicing');
383
+    $tabs['misc']     = __('Misc', 'invoicing');
384
+    $tabs['tools']    = __('Tools', 'invoicing');
385 385
 
386
-    return apply_filters( 'wpinv_settings_tabs', $tabs );
386
+    return apply_filters('wpinv_settings_tabs', $tabs);
387 387
 }
388 388
 
389
-function wpinv_get_settings_tab_sections( $tab = false ) {
389
+function wpinv_get_settings_tab_sections($tab = false) {
390 390
     $tabs     = false;
391 391
     $sections = wpinv_get_registered_settings_sections();
392 392
 
393
-    if( $tab && ! empty( $sections[ $tab ] ) ) {
394
-        $tabs = $sections[ $tab ];
395
-    } else if ( $tab ) {
393
+    if ($tab && !empty($sections[$tab])) {
394
+        $tabs = $sections[$tab];
395
+    } else if ($tab) {
396 396
         $tabs = false;
397 397
     }
398 398
 
@@ -402,91 +402,91 @@  discard block
 block discarded – undo
402 402
 function wpinv_get_registered_settings_sections() {
403 403
     static $sections = false;
404 404
 
405
-    if ( false !== $sections ) {
405
+    if (false !== $sections) {
406 406
         return $sections;
407 407
     }
408 408
 
409 409
     $sections = array(
410
-        'general' => apply_filters( 'wpinv_settings_sections_general', array(
411
-            'main' => __( 'General Settings', 'invoicing' ),
412
-            'currency_section' => __( 'Currency Settings', 'invoicing' ),
413
-            'labels' => __( 'Label Texts', 'invoicing' ),
414
-        ) ),
415
-        'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array(
416
-            'main' => __( 'Gateway Settings', 'invoicing' ),
417
-        ) ),
418
-        'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array(
419
-            'main'  => __( 'Tax Settings', 'invoicing' ),
420
-			'rates' => __( 'Tax Rates', 'invoicing' ),
421
-			'vat'   => __( 'EU VAT Settings', 'invoicing' )
422
-        ) ),
423
-        'emails' => apply_filters( 'wpinv_settings_sections_emails', array(
424
-            'main' => __( 'Email Settings', 'invoicing' ),
425
-		) ),
426
-
427
-		'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
428
-
429
-        'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array(
430
-            'main' => __( 'Privacy policy', 'invoicing' ),
431
-        ) ),
432
-        'misc' => apply_filters( 'wpinv_settings_sections_misc', array(
433
-            'main' => __( 'Miscellaneous', 'invoicing' ),
434
-            'custom-css' => __( 'Custom CSS', 'invoicing' ),
435
-        ) ),
436
-        'tools' => apply_filters( 'wpinv_settings_sections_tools', array(
437
-            'main' => __( 'Diagnostic Tools', 'invoicing' ),
438
-        ) ),
410
+        'general' => apply_filters('wpinv_settings_sections_general', array(
411
+            'main' => __('General Settings', 'invoicing'),
412
+            'currency_section' => __('Currency Settings', 'invoicing'),
413
+            'labels' => __('Label Texts', 'invoicing'),
414
+        )),
415
+        'gateways' => apply_filters('wpinv_settings_sections_gateways', array(
416
+            'main' => __('Gateway Settings', 'invoicing'),
417
+        )),
418
+        'taxes' => apply_filters('wpinv_settings_sections_taxes', array(
419
+            'main'  => __('Tax Settings', 'invoicing'),
420
+			'rates' => __('Tax Rates', 'invoicing'),
421
+			'vat'   => __('EU VAT Settings', 'invoicing')
422
+        )),
423
+        'emails' => apply_filters('wpinv_settings_sections_emails', array(
424
+            'main' => __('Email Settings', 'invoicing'),
425
+		)),
426
+
427
+		'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'label', 'id'),
428
+
429
+        'privacy' => apply_filters('wpinv_settings_sections_privacy', array(
430
+            'main' => __('Privacy policy', 'invoicing'),
431
+        )),
432
+        'misc' => apply_filters('wpinv_settings_sections_misc', array(
433
+            'main' => __('Miscellaneous', 'invoicing'),
434
+            'custom-css' => __('Custom CSS', 'invoicing'),
435
+        )),
436
+        'tools' => apply_filters('wpinv_settings_sections_tools', array(
437
+            'main' => __('Diagnostic Tools', 'invoicing'),
438
+        )),
439 439
     );
440 440
 
441
-    $sections = apply_filters( 'wpinv_settings_sections', $sections );
441
+    $sections = apply_filters('wpinv_settings_sections', $sections);
442 442
 
443 443
     return $sections;
444 444
 }
445 445
 
446
-function wpinv_get_pages( $with_slug = false, $default_label = NULL ) {
446
+function wpinv_get_pages($with_slug = false, $default_label = NULL) {
447 447
 	$pages_options = array();
448 448
 
449
-	if( $default_label !== NULL && $default_label !== false ) {
450
-		$pages_options = array( '' => $default_label ); // Blank option
449
+	if ($default_label !== NULL && $default_label !== false) {
450
+		$pages_options = array('' => $default_label); // Blank option
451 451
 	}
452 452
 
453 453
 	$pages = get_pages();
454
-	if ( $pages ) {
455
-		foreach ( $pages as $page ) {
454
+	if ($pages) {
455
+		foreach ($pages as $page) {
456 456
 			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
457
-            $pages_options[ $page->ID ] = $title;
457
+            $pages_options[$page->ID] = $title;
458 458
 		}
459 459
 	}
460 460
 
461 461
 	return $pages_options;
462 462
 }
463 463
 
464
-function wpinv_header_callback( $args ) {
465
-	if ( !empty( $args['desc'] ) ) {
464
+function wpinv_header_callback($args) {
465
+	if (!empty($args['desc'])) {
466 466
         echo $args['desc'];
467 467
     }
468 468
 }
469 469
 
470
-function wpinv_hidden_callback( $args ) {
470
+function wpinv_hidden_callback($args) {
471 471
 	global $wpinv_options;
472 472
 
473
-	if ( isset( $args['set_value'] ) ) {
473
+	if (isset($args['set_value'])) {
474 474
 		$value = $args['set_value'];
475
-	} elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
476
-		$value = $wpinv_options[ $args['id'] ];
475
+	} elseif (isset($wpinv_options[$args['id']])) {
476
+		$value = $wpinv_options[$args['id']];
477 477
 	} else {
478
-		$value = isset( $args['std'] ) ? $args['std'] : '';
478
+		$value = isset($args['std']) ? $args['std'] : '';
479 479
 	}
480 480
 
481
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
481
+	if (isset($args['faux']) && true === $args['faux']) {
482 482
 		$args['readonly'] = true;
483
-		$value = isset( $args['std'] ) ? $args['std'] : '';
483
+		$value = isset($args['std']) ? $args['std'] : '';
484 484
 		$name  = '';
485 485
 	} else {
486
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
486
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
487 487
 	}
488 488
 
489
-	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
489
+	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />';
490 490
     
491 491
 	echo $html;
492 492
 }
@@ -494,61 +494,61 @@  discard block
 block discarded – undo
494 494
 /**
495 495
  * Displays a checkbox settings callback.
496 496
  */
497
-function wpinv_checkbox_callback( $args ) {
497
+function wpinv_checkbox_callback($args) {
498 498
 
499
-	$std = isset( $args['std'] ) ? $args['std'] : '';
500
-	$std = wpinv_get_option( $args['id'], $std );
501
-	$id  = esc_attr( $args['id'] );
499
+	$std = isset($args['std']) ? $args['std'] : '';
500
+	$std = wpinv_get_option($args['id'], $std);
501
+	$id  = esc_attr($args['id']);
502 502
 
503
-	getpaid_hidden_field( "wpinv_settings[$id]", '0' );
503
+	getpaid_hidden_field("wpinv_settings[$id]", '0');
504 504
 	?>
505 505
 		<fieldset>
506 506
 			<label>
507
-				<input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox">
508
-				<?php echo wp_kses_post( $args['desc'] ); ?>
507
+				<input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked(empty($std), false); ?> value="1" type="checkbox">
508
+				<?php echo wp_kses_post($args['desc']); ?>
509 509
 			</label>
510 510
 		</fieldset>
511 511
 	<?php
512 512
 }
513 513
 
514
-function wpinv_multicheck_callback( $args ) {
514
+function wpinv_multicheck_callback($args) {
515 515
 	
516 516
 	global $wpinv_options;
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   = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std;
523
+		$std     = isset($args['std']) ? $args['std'] : array();
524
+		$value   = isset($wpinv_options[$args['id']]) ? $wpinv_options[$args['id']] : $std;
525 525
 
526 526
 		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
527
-        foreach( $args['options'] as $key => $option ):
528
-			$sanitize_key = wpinv_sanitize_key( $key );
529
-			if ( in_array( $sanitize_key, $value ) ) { 
527
+        foreach ($args['options'] as $key => $option):
528
+			$sanitize_key = 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[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
535
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
534
+			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/>&nbsp;';
535
+			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label></div>';
536 536
 		endforeach;
537 537
 		echo '</div>';
538 538
 		echo '<p class="description">' . $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
 	global $wpinv_options;
544 544
     
545
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
545
+    $sanitize_id = wpinv_sanitize_key($args['id']);
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( isset( $wpinv_options[$args['id']][$key] ) ) {
551
+			if (isset($wpinv_options[$args['id']][$key])) {
552 552
 				$enabled = $option;
553 553
 			} else {
554 554
 				$enabled = NULL;
@@ -556,109 +556,109 @@  discard block
 block discarded – undo
556 556
 
557 557
 			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
558 558
 
559
-				echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
559
+				echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $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 583
 			echo $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'] ) ) {
619
-		$description = wp_kses_post( $args['desc'] );
618
+	if (!empty($args['desc'])) {
619
+		$description = wp_kses_post($args['desc']);
620 620
 		echo "<p class='description'>$description</p>";
621 621
 	}
622 622
 
623 623
 }
624 624
 
625
-function wpinv_gateways_callback( $args ) {
625
+function wpinv_gateways_callback($args) {
626 626
 	global $wpinv_options;
627 627
     
628
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
628
+    $sanitize_id = wpinv_sanitize_key($args['id']);
629 629
 
630
-	foreach ( $args['options'] as $key => $option ) :
631
-		$sanitize_key = wpinv_sanitize_key( $key );
630
+	foreach ($args['options'] as $key => $option) :
631
+		$sanitize_key = wpinv_sanitize_key($key);
632 632
         
633
-        if ( isset( $wpinv_options['gateways'][ $key ] ) )
633
+        if (isset($wpinv_options['gateways'][$key]))
634 634
 			$enabled = '1';
635 635
 		else
636 636
 			$enabled = null;
637 637
 
638
-		echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/>&nbsp;';
639
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
638
+		echo '<input name="wpinv_settings[' . esc_attr($args['id']) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/>&nbsp;';
639
+		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option['admin_label']) . '</label><br/>';
640 640
 	endforeach;
641 641
 }
642 642
 
643 643
 function wpinv_gateway_select_callback($args) {
644 644
 	global $wpinv_options;
645 645
     
646
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
647
-    $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
646
+    $sanitize_id = wpinv_sanitize_key($args['id']);
647
+    $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
648 648
 
649
-	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
649
+	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '" >';
650 650
 
651
-	foreach ( $args['options'] as $key => $option ) :
652
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
653
-            $selected = selected( $key, $args['selected'], false );
651
+	foreach ($args['options'] as $key => $option) :
652
+		if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) {
653
+            $selected = selected($key, $args['selected'], false);
654 654
         } else {
655
-            $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : '';
655
+            $selected = isset($wpinv_options[$args['id']]) ? selected($key, $wpinv_options[$args['id']], false) : '';
656 656
         }
657
-		echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
657
+		echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>';
658 658
 	endforeach;
659 659
 
660 660
 	echo '</select>';
661
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
661
+	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
662 662
 }
663 663
 
664 664
 /**
@@ -667,28 +667,28 @@  discard block
 block discarded – undo
667 667
  * @param array $args
668 668
  * @return string
669 669
  */
670
-function wpinv_settings_attrs_helper( $args ) {
670
+function wpinv_settings_attrs_helper($args) {
671 671
 
672
-	$value        = isset( $args['std'] ) ? $args['std'] : '';
673
-	$id           = esc_attr( $args['id'] );
674
-	$placeholder  = esc_attr( $args['placeholder'] );
672
+	$value        = isset($args['std']) ? $args['std'] : '';
673
+	$id           = esc_attr($args['id']);
674
+	$placeholder  = esc_attr($args['placeholder']);
675 675
 
676
-	if ( ! empty( $args['faux'] ) ) {
676
+	if (!empty($args['faux'])) {
677 677
 		$args['readonly'] = true;
678 678
 		$name             = '';
679 679
 	} else {
680
-		$value  = wpinv_get_option( $args['id'], $value );
680
+		$value  = wpinv_get_option($args['id'], $value);
681 681
 		$name   = "wpinv_settings[$id]";
682 682
 	}
683 683
 
684
-	$value    = is_scalar( $value ) ? esc_attr( $value ) : '';
685
-	$class    = esc_attr( $args['class'] );
686
-	$style    = esc_attr( $args['style'] );
687
-	$readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"';
684
+	$value    = is_scalar($value) ? esc_attr($value) : '';
685
+	$class    = esc_attr($args['class']);
686
+	$style    = esc_attr($args['style']);
687
+	$readonly = empty($args['readonly']) ? '' : 'readonly onclick="this.select()"';
688 688
 
689 689
 	$onchange = '';
690
-    if ( ! empty( $args['onchange'] ) ) {
691
-        $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
690
+    if (!empty($args['onchange'])) {
691
+        $onchange = ' onchange="' . esc_attr($args['onchange']) . '"';
692 692
 	}
693 693
 
694 694
 	return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly";
@@ -697,11 +697,11 @@  discard block
 block discarded – undo
697 697
 /**
698 698
  * Displays a text input settings callback.
699 699
  */
700
-function wpinv_text_callback( $args ) {
700
+function wpinv_text_callback($args) {
701 701
 
702
-	$desc = wp_kses_post( $args['desc'] );
703
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
704
-	$attr = wpinv_settings_attrs_helper( $args );
702
+	$desc = wp_kses_post($args['desc']);
703
+	$desc = empty($desc) ? '' : "<p class='description'>$desc</p>";
704
+	$attr = wpinv_settings_attrs_helper($args);
705 705
 
706 706
 	?>
707 707
 		<label style="width: 100%;">
@@ -715,14 +715,14 @@  discard block
 block discarded – undo
715 715
 /**
716 716
  * Displays a number input settings callback.
717 717
  */
718
-function wpinv_number_callback( $args ) {
718
+function wpinv_number_callback($args) {
719 719
 
720
-	$desc = wp_kses_post( $args['desc'] );
721
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
722
-	$attr = wpinv_settings_attrs_helper( $args );
723
-	$max  = intval( $args['max'] );
724
-	$min  = intval( $args['min'] );
725
-	$step = floatval( $args['step'] );
720
+	$desc = wp_kses_post($args['desc']);
721
+	$desc = empty($desc) ? '' : "<p class='description'>$desc</p>";
722
+	$attr = wpinv_settings_attrs_helper($args);
723
+	$max  = intval($args['max']);
724
+	$min  = intval($args['min']);
725
+	$step = floatval($args['step']);
726 726
 
727 727
 	?>
728 728
 		<label style="width: 100%;">
@@ -733,47 +733,47 @@  discard block
 block discarded – undo
733 733
 
734 734
 }
735 735
 
736
-function wpinv_textarea_callback( $args ) {
736
+function wpinv_textarea_callback($args) {
737 737
 	global $wpinv_options;
738 738
     
739
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
739
+    $sanitize_id = wpinv_sanitize_key($args['id']);
740 740
 
741
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
742
-		$value = $wpinv_options[ $args['id'] ];
741
+	if (isset($wpinv_options[$args['id']])) {
742
+		$value = $wpinv_options[$args['id']];
743 743
 	} else {
744
-		$value = isset( $args['std'] ) ? $args['std'] : '';
744
+		$value = isset($args['std']) ? $args['std'] : '';
745 745
 	}
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
-	$html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
751
-	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
750
+	$html = '<textarea class="' . sanitize_html_class($class) . ' txtarea-' . sanitize_html_class($size) . ' wpi-' . esc_attr(sanitize_html_class($sanitize_id)) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']">' . esc_textarea(stripslashes($value)) . '</textarea>';
751
+	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
752 752
 
753 753
 	echo $html;
754 754
 }
755 755
 
756
-function wpinv_password_callback( $args ) {
756
+function wpinv_password_callback($args) {
757 757
 	global $wpinv_options;
758 758
     
759
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
759
+    $sanitize_id = wpinv_sanitize_key($args['id']);
760 760
 
761
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
762
-		$value = $wpinv_options[ $args['id'] ];
761
+	if (isset($wpinv_options[$args['id']])) {
762
+		$value = $wpinv_options[$args['id']];
763 763
 	} else {
764
-		$value = isset( $args['std'] ) ? $args['std'] : '';
764
+		$value = isset($args['std']) ? $args['std'] : '';
765 765
 	}
766 766
 
767
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
768
-	$html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
769
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
767
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
768
+	$html = '<input type="password" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '"/>';
769
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
770 770
 
771 771
 	echo $html;
772 772
 }
773 773
 
774 774
 function wpinv_missing_callback($args) {
775 775
 	printf(
776
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
776
+		__('The callback function used for the %s setting is missing.', 'invoicing'),
777 777
 		'<strong>' . $args['id'] . '</strong>'
778 778
 	);
779 779
 }
@@ -781,20 +781,20 @@  discard block
 block discarded – undo
781 781
 /**
782 782
  * Displays a number input settings callback.
783 783
  */
784
-function wpinv_select_callback( $args ) {
784
+function wpinv_select_callback($args) {
785 785
 
786
-	$desc   = wp_kses_post( $args['desc'] );
787
-	$desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
788
-	$attr   = wpinv_settings_attrs_helper( $args );
789
-	$value  = isset( $args['std'] ) ? $args['std'] : '';
790
-	$value  = wpinv_get_option( $args['id'], $value );
786
+	$desc   = wp_kses_post($args['desc']);
787
+	$desc   = empty($desc) ? '' : "<p class='description'>$desc</p>";
788
+	$attr   = wpinv_settings_attrs_helper($args);
789
+	$value  = isset($args['std']) ? $args['std'] : '';
790
+	$value  = wpinv_get_option($args['id'], $value);
791 791
 
792 792
 	?>
793 793
 		<label style="width: 100%;">
794 794
 			<select <?php echo $attr; ?>>
795
-				<?php foreach ( $args['options'] as $option => $name ) : ?>
796
-					<option value="<?php echo esc_attr( $option ); ?>" <?php echo selected( is_array( $value ) ? in_array( $option, $value, true ) : $option === $value ); ?>><?php echo wpinv_clean( $name ); ?></option>
797
-				<?php endforeach;?>
795
+				<?php foreach ($args['options'] as $option => $name) : ?>
796
+					<option value="<?php echo esc_attr($option); ?>" <?php echo selected(is_array($value) ? in_array($option, $value, true) : $option === $value); ?>><?php echo wpinv_clean($name); ?></option>
797
+				<?php endforeach; ?>
798 798
 			</select>
799 799
 			<?php echo $desc; ?>
800 800
 		</label>
@@ -802,95 +802,95 @@  discard block
 block discarded – undo
802 802
 
803 803
 }
804 804
 
805
-function wpinv_color_select_callback( $args ) {
805
+function wpinv_color_select_callback($args) {
806 806
 	global $wpinv_options;
807 807
     
808
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
808
+    $sanitize_id = wpinv_sanitize_key($args['id']);
809 809
 
810
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
811
-		$value = $wpinv_options[ $args['id'] ];
810
+	if (isset($wpinv_options[$args['id']])) {
811
+		$value = $wpinv_options[$args['id']];
812 812
 	} else {
813
-		$value = isset( $args['std'] ) ? $args['std'] : '';
813
+		$value = isset($args['std']) ? $args['std'] : '';
814 814
 	}
815 815
 
816
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
816
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>';
817 817
 
818
-	foreach ( $args['options'] as $option => $color ) {
819
-		$selected = selected( $option, $value, false );
820
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
818
+	foreach ($args['options'] as $option => $color) {
819
+		$selected = selected($option, $value, false);
820
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>';
821 821
 	}
822 822
 
823 823
 	$html .= '</select>';
824
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
824
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
825 825
 
826 826
 	echo $html;
827 827
 }
828 828
 
829
-function wpinv_rich_editor_callback( $args ) {
829
+function wpinv_rich_editor_callback($args) {
830 830
 	global $wpinv_options, $wp_version;
831 831
     
832
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
832
+    $sanitize_id = wpinv_sanitize_key($args['id']);
833 833
 
834
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
835
-		$value = $wpinv_options[ $args['id'] ];
834
+	if (isset($wpinv_options[$args['id']])) {
835
+		$value = $wpinv_options[$args['id']];
836 836
 
837
-		if( empty( $args['allow_blank'] ) && empty( $value ) ) {
838
-			$value = isset( $args['std'] ) ? $args['std'] : '';
837
+		if (empty($args['allow_blank']) && empty($value)) {
838
+			$value = isset($args['std']) ? $args['std'] : '';
839 839
 		}
840 840
 	} else {
841
-		$value = isset( $args['std'] ) ? $args['std'] : '';
841
+		$value = isset($args['std']) ? $args['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
 	$html = '<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
 		ob_start();
849
-		wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) );
849
+		wp_editor(stripslashes($value), 'wpinv_settings_' . esc_attr($args['id']), array('textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', 'textarea_rows' => absint($rows), 'media_buttons' => false));
850 850
 		$html .= ob_get_clean();
851 851
 	} else {
852
-		$html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
852
+		$html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="wpi-' . esc_attr(sanitize_html_class($args['id'])) . '">' . esc_textarea(stripslashes($value)) . '</textarea>';
853 853
 	}
854 854
 
855
-	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
855
+	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
856 856
 
857 857
 	echo $html;
858 858
 }
859 859
 
860
-function wpinv_upload_callback( $args ) {
860
+function wpinv_upload_callback($args) {
861 861
 	global $wpinv_options;
862 862
     
863
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
863
+    $sanitize_id = wpinv_sanitize_key($args['id']);
864 864
 
865
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
865
+	if (isset($wpinv_options[$args['id']])) {
866 866
 		$value = $wpinv_options[$args['id']];
867 867
 	} else {
868 868
 		$value = isset($args['std']) ? $args['std'] : '';
869 869
 	}
870 870
 
871
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
872
-	$html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
873
-	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
874
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
871
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
872
+	$html = '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr(stripslashes($value)) . '"/>';
873
+	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>';
874
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
875 875
 
876 876
 	echo $html;
877 877
 }
878 878
 
879
-function wpinv_color_callback( $args ) {
879
+function wpinv_color_callback($args) {
880 880
 	global $wpinv_options;
881 881
     
882
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
882
+    $sanitize_id = wpinv_sanitize_key($args['id']);
883 883
 
884
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
885
-		$value = $wpinv_options[ $args['id'] ];
884
+	if (isset($wpinv_options[$args['id']])) {
885
+		$value = $wpinv_options[$args['id']];
886 886
 	} else {
887
-		$value = isset( $args['std'] ) ? $args['std'] : '';
887
+		$value = isset($args['std']) ? $args['std'] : '';
888 888
 	}
889 889
 
890
-	$default = isset( $args['std'] ) ? $args['std'] : '';
890
+	$default = isset($args['std']) ? $args['std'] : '';
891 891
 
892
-	$html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />';
893
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
892
+	$html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '" data-default-color="' . esc_attr($default) . '" />';
893
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
894 894
 
895 895
 	echo $html;
896 896
 }
@@ -898,9 +898,9 @@  discard block
 block discarded – undo
898 898
 function wpinv_country_states_callback($args) {
899 899
 	global $wpinv_options;
900 900
     
901
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
901
+    $sanitize_id = wpinv_sanitize_key($args['id']);
902 902
 
903
-	if ( isset( $args['placeholder'] ) ) {
903
+	if (isset($args['placeholder'])) {
904 904
 		$placeholder = $args['placeholder'];
905 905
 	} else {
906 906
 		$placeholder = '';
@@ -908,16 +908,16 @@  discard block
 block discarded – undo
908 908
 
909 909
 	$states = wpinv_get_country_states();
910 910
 
911
-	$class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
912
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
911
+	$class = empty($states) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
912
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>';
913 913
 
914
-	foreach ( $states as $option => $name ) {
915
-		$selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
916
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
914
+	foreach ($states as $option => $name) {
915
+		$selected = isset($wpinv_options[$args['id']]) ? selected($option, $wpinv_options[$args['id']], false) : '';
916
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>';
917 917
 	}
918 918
 
919 919
 	$html .= '</select>';
920
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
920
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
921 921
 
922 922
 	echo $html;
923 923
 }
@@ -932,7 +932,7 @@  discard block
 block discarded – undo
932 932
 	</tr>
933 933
 	<tr class="bsui">
934 934
     	<td colspan="2" class="p-0">
935
-			<?php include plugin_dir_path( __FILE__ ) . 'views/html-tax-rates-edit.php'; ?>
935
+			<?php include plugin_dir_path(__FILE__) . 'views/html-tax-rates-edit.php'; ?>
936 936
 
937 937
 	<?php
938 938
 
@@ -941,14 +941,14 @@  discard block
 block discarded – undo
941 941
 /**
942 942
  * Displays a tax rate' edit row.
943 943
  */
944
-function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) {
944
+function wpinv_tax_rate_callback($tax_rate, $key, $echo = true) {
945 945
 	ob_start();
946 946
 
947
-	$key                      = sanitize_key( $key );
948
-	$tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
949
-	include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
947
+	$key                      = sanitize_key($key);
948
+	$tax_rate['reduced_rate'] = empty($tax_rate['reduced_rate']) ? 0 : $tax_rate['reduced_rate'];
949
+	include plugin_dir_path(__FILE__) . 'views/html-tax-rate-edit.php';
950 950
 
951
-	if ( $echo ) {
951
+	if ($echo) {
952 952
 		echo ob_get_clean();
953 953
 	} else {
954 954
 		return ob_get_clean(); 
@@ -960,81 +960,81 @@  discard block
 block discarded – undo
960 960
     ob_start(); ?>
961 961
     </td><tr>
962 962
     <td colspan="2" class="wpinv_tools_tdbox">
963
-    <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
964
-    <?php do_action( 'wpinv_tools_before' ); ?>
963
+    <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
964
+    <?php do_action('wpinv_tools_before'); ?>
965 965
     <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts">
966 966
         <thead>
967 967
             <tr>
968
-                <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th>
969
-                <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th>
970
-                <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th>
968
+                <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th>
969
+                <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th>
970
+                <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th>
971 971
             </tr>
972 972
         </thead>
973
-            <?php do_action( 'wpinv_tools_row' ); ?>
973
+            <?php do_action('wpinv_tools_row'); ?>
974 974
         <tbody>
975 975
         </tbody>
976 976
     </table>
977
-    <?php do_action( 'wpinv_tools_after' ); ?>
977
+    <?php do_action('wpinv_tools_after'); ?>
978 978
     <?php
979 979
     echo ob_get_clean();
980 980
 }
981 981
 
982
-function wpinv_descriptive_text_callback( $args ) {
983
-	echo wp_kses_post( $args['desc'] );
982
+function wpinv_descriptive_text_callback($args) {
983
+	echo wp_kses_post($args['desc']);
984 984
 }
985 985
 
986
-function wpinv_raw_html_callback( $args ) {
986
+function wpinv_raw_html_callback($args) {
987 987
 	echo $args['desc'];
988 988
 }
989 989
 
990
-function wpinv_hook_callback( $args ) {
991
-	do_action( 'wpinv_' . $args['id'], $args );
990
+function wpinv_hook_callback($args) {
991
+	do_action('wpinv_' . $args['id'], $args);
992 992
 }
993 993
 
994 994
 function wpinv_set_settings_cap() {
995 995
 	return wpinv_get_capability();
996 996
 }
997
-add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
997
+add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap');
998 998
 
999
-function wpinv_settings_sanitize_input( $value, $key ) {
999
+function wpinv_settings_sanitize_input($value, $key) {
1000 1000
 
1001
-    if ( $key == 'tax_rate' ) {
1002
-        $value = wpinv_sanitize_amount( $value );
1001
+    if ($key == 'tax_rate') {
1002
+        $value = wpinv_sanitize_amount($value);
1003 1003
         $value = $value >= 100 ? 99 : $value;
1004 1004
     }
1005 1005
 
1006 1006
     return $value;
1007 1007
 }
1008
-add_filter( 'wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2 );
1008
+add_filter('wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2);
1009 1009
 
1010
-function wpinv_on_update_settings( $old_value, $value, $option ) {
1011
-    $old = !empty( $old_value['remove_data_on_unistall'] ) ? 1 : '';
1012
-    $new = !empty( $value['remove_data_on_unistall'] ) ? 1 : '';
1010
+function wpinv_on_update_settings($old_value, $value, $option) {
1011
+    $old = !empty($old_value['remove_data_on_unistall']) ? 1 : '';
1012
+    $new = !empty($value['remove_data_on_unistall']) ? 1 : '';
1013 1013
     
1014
-    if ( $old != $new ) {
1015
-        update_option( 'wpinv_remove_data_on_invoice_unistall', $new );
1014
+    if ($old != $new) {
1015
+        update_option('wpinv_remove_data_on_invoice_unistall', $new);
1016 1016
     }
1017 1017
 }
1018
-add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 );
1019
-add_action( 'wpinv_settings_tab_bottom_emails_new_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1020
-add_action( 'wpinv_settings_tab_bottom_emails_cancelled_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1021
-add_action( 'wpinv_settings_tab_bottom_emails_failed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1022
-add_action( 'wpinv_settings_tab_bottom_emails_onhold_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1023
-add_action( 'wpinv_settings_tab_bottom_emails_processing_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1024
-add_action( 'wpinv_settings_tab_bottom_emails_completed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1025
-add_action( 'wpinv_settings_tab_bottom_emails_refunded_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1026
-add_action( 'wpinv_settings_tab_bottom_emails_user_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1027
-add_action( 'wpinv_settings_tab_bottom_emails_user_note', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1028
-add_action( 'wpinv_settings_tab_bottom_emails_overdue', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1029
-
1030
-function wpinv_settings_tab_bottom_emails( $active_tab, $section ) {
1018
+add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3);
1019
+add_action('wpinv_settings_tab_bottom_emails_new_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1020
+add_action('wpinv_settings_tab_bottom_emails_cancelled_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1021
+add_action('wpinv_settings_tab_bottom_emails_failed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1022
+add_action('wpinv_settings_tab_bottom_emails_onhold_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1023
+add_action('wpinv_settings_tab_bottom_emails_processing_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1024
+add_action('wpinv_settings_tab_bottom_emails_completed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1025
+add_action('wpinv_settings_tab_bottom_emails_refunded_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1026
+add_action('wpinv_settings_tab_bottom_emails_user_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1027
+add_action('wpinv_settings_tab_bottom_emails_user_note', 'wpinv_settings_tab_bottom_emails', 10, 2);
1028
+add_action('wpinv_settings_tab_bottom_emails_overdue', 'wpinv_settings_tab_bottom_emails', 10, 2);
1029
+
1030
+function wpinv_settings_tab_bottom_emails($active_tab, $section) {
1031 1031
     ?>
1032 1032
     <div class="wpinv-email-wc-row ">
1033 1033
         <div class="wpinv-email-wc-td">
1034
-            <h3 class="wpinv-email-wc-title"><?php echo apply_filters( 'wpinv_settings_email_wildcards_title', __( 'Wildcards For Emails', 'invoicing' ) ); ?></h3>
1034
+            <h3 class="wpinv-email-wc-title"><?php echo apply_filters('wpinv_settings_email_wildcards_title', __('Wildcards For Emails', 'invoicing')); ?></h3>
1035 1035
             <p class="wpinv-email-wc-description">
1036 1036
                 <?php
1037
-                $description = __( 'The following wildcards can be used in email subjects, heading and content:<br>
1037
+                $description = __('The following wildcards can be used in email subjects, heading and content:<br>
1038 1038
                     <strong>{site_title} :</strong> Site Title<br>
1039 1039
                     <strong>{name} :</strong> Customer\'s full name<br>
1040 1040
                     <strong>{first_name} :</strong> Customer\'s first name<br>
@@ -1048,7 +1048,7 @@  discard block
 block discarded – undo
1048 1048
                     <strong>{invoice_due_date} :</strong> The date the invoice is due<br>
1049 1049
                     <strong>{date} :</strong> Today\'s date.<br>
1050 1050
                     <strong>{is_was} :</strong> If due date of invoice is past, displays "was" otherwise displays "is"<br>
1051
-                    <strong>{invoice_label} :</strong> Invoices/quotes singular name. Ex: Invoice/Quote<br>', 'invoicing' );
1051
+                    <strong>{invoice_label} :</strong> Invoices/quotes singular name. Ex: Invoice/Quote<br>', 'invoicing');
1052 1052
                 echo apply_filters('wpinv_settings_email_wildcards_description', $description, $active_tab, $section);
1053 1053
                 ?>
1054 1054
             </p>
Please login to merge, or discard this patch.
includes/wpinv-gateway-functions.php 1 patch
Spacing   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Contains gateway functions.
4 4
  *
5 5
  */
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * Returns an array of payment gateways.
@@ -11,82 +11,82 @@  discard block
 block discarded – undo
11 11
  * @return array
12 12
  */
13 13
 function wpinv_get_payment_gateways() {
14
-    return apply_filters( 'wpinv_payment_gateways', array() );
14
+    return apply_filters('wpinv_payment_gateways', array());
15 15
 }
16 16
 
17
-function wpinv_payment_gateway_titles( $all_gateways ) {
17
+function wpinv_payment_gateway_titles($all_gateways) {
18 18
     global $wpinv_options;
19 19
 
20 20
     $gateways = array();
21
-    foreach ( $all_gateways as $key => $gateway ) {
22
-        if ( !empty( $wpinv_options[$key . '_title'] ) ) {
23
-            $all_gateways[$key]['checkout_label'] = __( $wpinv_options[$key . '_title'], 'invoicing' );
21
+    foreach ($all_gateways as $key => $gateway) {
22
+        if (!empty($wpinv_options[$key . '_title'])) {
23
+            $all_gateways[$key]['checkout_label'] = __($wpinv_options[$key . '_title'], 'invoicing');
24 24
         }
25 25
 
26
-        $gateways[$key] = isset( $wpinv_options[$key . '_ordering'] ) ? $wpinv_options[$key . '_ordering'] : ( isset( $gateway['ordering'] ) ? $gateway['ordering'] : '' );
26
+        $gateways[$key] = isset($wpinv_options[$key . '_ordering']) ? $wpinv_options[$key . '_ordering'] : (isset($gateway['ordering']) ? $gateway['ordering'] : '');
27 27
     }
28 28
 
29
-    asort( $gateways );
29
+    asort($gateways);
30 30
 
31
-    foreach ( $gateways as $gateway => $key ) {
31
+    foreach ($gateways as $gateway => $key) {
32 32
         $gateways[$gateway] = $all_gateways[$gateway];
33 33
     }
34 34
 
35 35
     return $gateways;
36 36
 }
37
-add_filter( 'wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1 );
37
+add_filter('wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1);
38 38
 
39
-function wpinv_get_enabled_payment_gateways( $sort = false ) {
39
+function wpinv_get_enabled_payment_gateways($sort = false) {
40 40
     $gateways = wpinv_get_payment_gateways();
41
-    $enabled  = wpinv_get_option( 'gateways', false );
41
+    $enabled  = wpinv_get_option('gateways', false);
42 42
 
43 43
     $gateway_list = array();
44 44
 
45
-    foreach ( $gateways as $key => $gateway ) {
46
-        if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) {
47
-            $gateway_list[ $key ] = $gateway;
45
+    foreach ($gateways as $key => $gateway) {
46
+        if (isset($enabled[$key]) && $enabled[$key] == 1) {
47
+            $gateway_list[$key] = $gateway;
48 48
         }
49 49
     }
50 50
 
51
-    if ( true === $sort ) {
52
-        uasort( $gateway_list, 'wpinv_sort_gateway_order' );
51
+    if (true === $sort) {
52
+        uasort($gateway_list, 'wpinv_sort_gateway_order');
53 53
         
54 54
         // Reorder our gateways so the default is first
55 55
         $default_gateway_id = wpinv_get_default_gateway();
56 56
 
57
-        if ( wpinv_is_gateway_active( $default_gateway_id ) ) {
58
-            $default_gateway    = array( $default_gateway_id => $gateway_list[ $default_gateway_id ] );
59
-            unset( $gateway_list[ $default_gateway_id ] );
57
+        if (wpinv_is_gateway_active($default_gateway_id)) {
58
+            $default_gateway = array($default_gateway_id => $gateway_list[$default_gateway_id]);
59
+            unset($gateway_list[$default_gateway_id]);
60 60
 
61
-            $gateway_list = array_merge( $default_gateway, $gateway_list );
61
+            $gateway_list = array_merge($default_gateway, $gateway_list);
62 62
         }
63 63
     }
64 64
 
65
-    return apply_filters( 'wpinv_enabled_payment_gateways', $gateway_list );
65
+    return apply_filters('wpinv_enabled_payment_gateways', $gateway_list);
66 66
 }
67 67
 
68
-function wpinv_sort_gateway_order( $a, $b ) {
68
+function wpinv_sort_gateway_order($a, $b) {
69 69
     return $a['ordering'] - $b['ordering'];
70 70
 }
71 71
 
72
-function wpinv_is_gateway_active( $gateway ) {
72
+function wpinv_is_gateway_active($gateway) {
73 73
     $gateways = wpinv_get_enabled_payment_gateways();
74 74
 
75
-    $ret = is_array($gateways) && $gateway ?  array_key_exists( $gateway, $gateways ) : false;
75
+    $ret = is_array($gateways) && $gateway ?  array_key_exists($gateway, $gateways) : false;
76 76
 
77
-    return apply_filters( 'wpinv_is_gateway_active', $ret, $gateway, $gateways );
77
+    return apply_filters('wpinv_is_gateway_active', $ret, $gateway, $gateways);
78 78
 }
79 79
 
80 80
 function wpinv_get_default_gateway() {
81
-    $default = wpinv_get_option( 'default_gateway', 'paypal' );
81
+    $default = wpinv_get_option('default_gateway', 'paypal');
82 82
 
83
-    if ( !wpinv_is_gateway_active( $default ) ) {
83
+    if (!wpinv_is_gateway_active($default)) {
84 84
         $gateways = wpinv_get_enabled_payment_gateways();
85
-        $gateways = array_keys( $gateways );
86
-        $default  = reset( $gateways );
85
+        $gateways = array_keys($gateways);
86
+        $default  = reset($gateways);
87 87
     }
88 88
 
89
-    return apply_filters( 'wpinv_default_gateway', $default );
89
+    return apply_filters('wpinv_default_gateway', $default);
90 90
 }
91 91
 
92 92
 /**
@@ -95,17 +95,17 @@  discard block
 block discarded – undo
95 95
  * @param string $gateway The gateway to key.
96 96
  * @return string
97 97
  */
98
-function wpinv_get_gateway_admin_label( $gateway ) {
98
+function wpinv_get_gateway_admin_label($gateway) {
99 99
 
100
-    if ( empty( $gateway ) || 'none' == $gateway ) {
101
-        return esc_html__( 'No Gateway', 'invoicing' );
100
+    if (empty($gateway) || 'none' == $gateway) {
101
+        return esc_html__('No Gateway', 'invoicing');
102 102
     }
103 103
 
104 104
     $gateways = wpinv_get_payment_gateways();
105
-    $label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway;
106
-    $gateway  = apply_filters( 'wpinv_gateway_admin_label', $label, $gateway );
105
+    $label    = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway;
106
+    $gateway  = apply_filters('wpinv_gateway_admin_label', $label, $gateway);
107 107
 
108
-    return wpinv_clean( $gateway );
108
+    return wpinv_clean($gateway);
109 109
 }
110 110
 
111 111
 /**
@@ -113,49 +113,49 @@  discard block
 block discarded – undo
113 113
  * 
114 114
  * @param string $gateway
115 115
  */
116
-function wpinv_get_gateway_description( $gateway ) {
116
+function wpinv_get_gateway_description($gateway) {
117 117
     global $wpinv_options;
118 118
 
119
-    $description = ! empty( $wpinv_options[$gateway . '_desc'] ) ? $wpinv_options[$gateway . '_desc'] : '';
119
+    $description = !empty($wpinv_options[$gateway . '_desc']) ? $wpinv_options[$gateway . '_desc'] : '';
120 120
 
121
-    return apply_filters( 'wpinv_gateway_description', $description, $gateway );
121
+    return apply_filters('wpinv_gateway_description', $description, $gateway);
122 122
 }
123 123
 
124
-function wpinv_get_gateway_button_label( $gateway ) {
125
-    return apply_filters( 'wpinv_gateway_' . $gateway . '_button_label', '' );
124
+function wpinv_get_gateway_button_label($gateway) {
125
+    return apply_filters('wpinv_gateway_' . $gateway . '_button_label', '');
126 126
 }
127 127
 
128
-function wpinv_get_gateway_checkout_label( $gateway ) {
128
+function wpinv_get_gateway_checkout_label($gateway) {
129 129
     $gateways = wpinv_get_payment_gateways();
130
-    $label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway;
130
+    $label    = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway;
131 131
 
132
-    if ( $gateway == 'none' ) {
133
-        $label = __( 'None', 'invoicing' );
132
+    if ($gateway == 'none') {
133
+        $label = __('None', 'invoicing');
134 134
     }
135 135
 
136
-    return apply_filters( 'wpinv_gateway_checkout_label', ucfirst( $label ), $gateway );
136
+    return apply_filters('wpinv_gateway_checkout_label', ucfirst($label), $gateway);
137 137
 }
138 138
 
139
-function wpinv_settings_sections_gateways( $settings ) {
139
+function wpinv_settings_sections_gateways($settings) {
140 140
     $gateways = wpinv_get_payment_gateways();
141 141
     
142 142
     if (!empty($gateways)) {
143
-        foreach  ($gateways as $key => $gateway) {
143
+        foreach ($gateways as $key => $gateway) {
144 144
             $settings[$key] = $gateway['admin_label'];
145 145
         }
146 146
     }
147 147
     
148 148
     return $settings;    
149 149
 }
150
-add_filter( 'wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1 );
150
+add_filter('wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1);
151 151
 
152 152
 /**
153 153
  * Adds GateWay settings.
154 154
  */
155
-function wpinv_settings_gateways( $settings ) {
155
+function wpinv_settings_gateways($settings) {
156 156
 
157 157
     // Loop through each gateway.
158
-    foreach  ( wpinv_get_payment_gateways() as $key => $gateway ) {
158
+    foreach (wpinv_get_payment_gateways() as $key => $gateway) {
159 159
 
160 160
         $gateway_settings = array(
161 161
 
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
             "{$key}_header" => array(
164 164
 
165 165
                 'id'     => "{$key}_gateway_header",
166
-                'name'   => '<h3>' . wp_sprintf( __( '%s Settings', 'invoicing' ), $gateway['admin_label'] ) . '</h3>',
166
+                'name'   => '<h3>' . wp_sprintf(__('%s Settings', 'invoicing'), $gateway['admin_label']) . '</h3>',
167 167
                 'custom' => $key,
168 168
                 'type'   => 'gateway_header',
169 169
 
@@ -172,16 +172,16 @@  discard block
 block discarded – undo
172 172
             // Activate/Deactivate a gateway.
173 173
             "{$key}_active" => array(
174 174
                 'id'   => $key . '_active',
175
-                'name' => __( 'Activate', 'invoicing' ),
176
-                'desc' => wp_sprintf( __( 'Enable %s', 'invoicing' ), $gateway['admin_label'] ),
175
+                'name' => __('Activate', 'invoicing'),
176
+                'desc' => wp_sprintf(__('Enable %s', 'invoicing'), $gateway['admin_label']),
177 177
                 'type' => 'checkbox',
178 178
             ),
179 179
 
180 180
             // Activate/Deactivate sandbox.
181 181
             "{$key}_sandbox" => array(
182 182
                 'id'   => $key . '_sandbox',
183
-                'name' => __( 'Sandbox', 'invoicing' ),
184
-                'desc' => __( 'Enable sandbox to test payments', 'invoicing' ),
183
+                'name' => __('Sandbox', 'invoicing'),
184
+                'desc' => __('Enable sandbox to test payments', 'invoicing'),
185 185
                 'type' => 'checkbox',
186 186
                 'std'  => '1',
187 187
             ),
@@ -189,40 +189,40 @@  discard block
 block discarded – undo
189 189
             // Checkout title.
190 190
             "{$key}_title" => array(
191 191
                 'id'   => $key . '_title',
192
-                'name' => __( 'Checkout Title', 'invoicing' ),
193
-                'std'  => isset( $gateway['checkout_label'] ) ? $gateway['checkout_label'] : '',
192
+                'name' => __('Checkout Title', 'invoicing'),
193
+                'std'  => isset($gateway['checkout_label']) ? $gateway['checkout_label'] : '',
194 194
                 'type' => 'text',
195 195
             ),
196 196
 
197 197
             // Checkout description.
198 198
             "{$key}_desc" => array(
199 199
                 'id'   => $key . '_desc',
200
-                'name' => __( 'Checkout Description', 'invoicing' ),
201
-                'std'  => apply_filters( "getpaid_default_{$key}_checkout_description", '' ),
200
+                'name' => __('Checkout Description', 'invoicing'),
201
+                'std'  => apply_filters("getpaid_default_{$key}_checkout_description", ''),
202 202
                 'type' => 'text',
203 203
             ),
204 204
 
205 205
             // Checkout order.
206 206
             "{$key}_ordering" => array(
207 207
                 'id'   => $key . '_ordering',
208
-                'name' => __( 'Priority', 'invoicing' ),
209
-                'std'  => apply_filters( "getpaid_default_{$key}_checkout_description", '' ),
208
+                'name' => __('Priority', 'invoicing'),
209
+                'std'  => apply_filters("getpaid_default_{$key}_checkout_description", ''),
210 210
                 'type' => 'number',
211 211
                 'step' => '1',
212 212
                 'min'  => '0',
213 213
                 'max'  => '100000',
214
-                'std'  => isset( $gateway['ordering'] ) ? $gateway['ordering'] : '10',
214
+                'std'  => isset($gateway['ordering']) ? $gateway['ordering'] : '10',
215 215
             ),
216 216
 
217 217
         );
218 218
 
219 219
         // Maybe remove the sandbox.
220
-        if ( ! apply_filters( "wpinv_{$key}_supports_sandbox", false ) ) {
221
-            unset( $gateway_settings["{$key}_sandbox"] );
220
+        if (!apply_filters("wpinv_{$key}_supports_sandbox", false)) {
221
+            unset($gateway_settings["{$key}_sandbox"]);
222 222
         }
223 223
   
224
-        $gateway_settings = apply_filters( 'wpinv_gateway_settings', $gateway_settings, $key, $gateway );
225
-        $gateway_settings = apply_filters( 'wpinv_gateway_settings_' . $key, $gateway_settings, $gateway );
224
+        $gateway_settings = apply_filters('wpinv_gateway_settings', $gateway_settings, $key, $gateway);
225
+        $gateway_settings = apply_filters('wpinv_gateway_settings_' . $key, $gateway_settings, $gateway);
226 226
         
227 227
         $settings[$key] = $gateway_settings;
228 228
     }
@@ -230,57 +230,57 @@  discard block
 block discarded – undo
230 230
     return $settings;
231 231
 
232 232
 }
233
-add_filter( 'wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1 );
233
+add_filter('wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1);
234 234
 
235
-function wpinv_gateway_header_callback( $args ) {
236
-    echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr( $args['custom'] ) . '" />';
235
+function wpinv_gateway_header_callback($args) {
236
+    echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr($args['custom']) . '" />';
237 237
 }
238 238
 
239
-function wpinv_get_gateway_supports( $gateway ) {
239
+function wpinv_get_gateway_supports($gateway) {
240 240
     $gateways = wpinv_get_enabled_payment_gateways();
241
-    $supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array();
242
-    return apply_filters( 'wpinv_gateway_supports', $supports, $gateway );
241
+    $supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array();
242
+    return apply_filters('wpinv_gateway_supports', $supports, $gateway);
243 243
 }
244 244
 
245
-function wpinv_get_chosen_gateway( $invoice_id = 0 ) {
246
-	$gateways = array_keys( wpinv_get_enabled_payment_gateways() );
245
+function wpinv_get_chosen_gateway($invoice_id = 0) {
246
+	$gateways = array_keys(wpinv_get_enabled_payment_gateways());
247 247
 
248 248
     $chosen = false;
249
-    if ( $invoice_id > 0 && $invoice = wpinv_get_invoice( $invoice_id ) ) {
249
+    if ($invoice_id > 0 && $invoice = wpinv_get_invoice($invoice_id)) {
250 250
         $chosen = $invoice->get_gateway();
251 251
     }
252 252
 
253
-	$chosen   = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen;
253
+	$chosen = isset($_REQUEST['payment-mode']) ? sanitize_text_field($_REQUEST['payment-mode']) : $chosen;
254 254
 
255
-	if ( false !== $chosen ) {
256
-		$chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen );
255
+	if (false !== $chosen) {
256
+		$chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen);
257 257
 	}
258 258
 
259
-	if ( ! empty ( $chosen ) ) {
260
-		$enabled_gateway = urldecode( $chosen );
261
-	} else if (  !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) {
259
+	if (!empty ($chosen)) {
260
+		$enabled_gateway = urldecode($chosen);
261
+	} else if (!empty($invoice) && (float) $invoice->get_subtotal() <= 0) {
262 262
 		$enabled_gateway = 'manual';
263 263
 	} else {
264 264
 		$enabled_gateway = wpinv_get_default_gateway();
265 265
 	}
266 266
     
267
-    if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) {
268
-        if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){
267
+    if (!wpinv_is_gateway_active($enabled_gateway) && !empty($gateways)) {
268
+        if (wpinv_is_gateway_active(wpinv_get_default_gateway())) {
269 269
             $enabled_gateway = wpinv_get_default_gateway();
270
-        }else{
270
+        } else {
271 271
             $enabled_gateway = $gateways[0];
272 272
         }
273 273
 
274 274
     }
275 275
 
276
-	return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway );
276
+	return apply_filters('wpinv_chosen_gateway', $enabled_gateway);
277 277
 }
278 278
 
279
-function wpinv_record_gateway_error( $title = '', $message = '' ) {
280
-    return wpinv_error_log( $message, $title );
279
+function wpinv_record_gateway_error($title = '', $message = '') {
280
+    return wpinv_error_log($message, $title);
281 281
 }
282 282
 
283
-function wpinv_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) {
283
+function wpinv_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') {
284 284
 	$ret  = 0;
285 285
 	$args = array(
286 286
 		'meta_key'    => '_wpinv_gateway',
@@ -291,48 +291,48 @@  discard block
 block discarded – undo
291 291
 		'fields'      => 'ids'
292 292
 	);
293 293
 
294
-	$payments = new WP_Query( $args );
294
+	$payments = new WP_Query($args);
295 295
 
296
-	if( $payments )
296
+	if ($payments)
297 297
 		$ret = $payments->post_count;
298 298
 	return $ret;
299 299
 }
300 300
 
301
-function wpinv_settings_update_gateways( $input ) {
301
+function wpinv_settings_update_gateways($input) {
302 302
     global $wpinv_options;
303 303
     
304
-    if ( !empty( $input['save_gateway'] ) ) {
305
-        $gateways = wpinv_get_option( 'gateways', false );
304
+    if (!empty($input['save_gateway'])) {
305
+        $gateways = wpinv_get_option('gateways', false);
306 306
         $gateways = !empty($gateways) ? $gateways : array();
307 307
         $gateway = $input['save_gateway'];
308 308
         
309
-        if ( !empty( $input[$gateway . '_active'] ) ) {
309
+        if (!empty($input[$gateway . '_active'])) {
310 310
             $gateways[$gateway] = 1;
311 311
         } else {
312
-            if ( isset( $gateways[$gateway] ) ) {
313
-                unset( $gateways[$gateway] );
312
+            if (isset($gateways[$gateway])) {
313
+                unset($gateways[$gateway]);
314 314
             }
315 315
         }
316 316
         
317 317
         $input['gateways'] = $gateways;
318 318
     }
319 319
     
320
-    if ( !empty( $input['default_gateway'] ) ) {
320
+    if (!empty($input['default_gateway'])) {
321 321
         $gateways = wpinv_get_payment_gateways();
322 322
         
323
-        foreach ( $gateways as $key => $gateway ) {
324
-            $active   = 0;
325
-            if ( !empty( $input['gateways'] ) && !empty( $input['gateways'][$key] ) ) {
323
+        foreach ($gateways as $key => $gateway) {
324
+            $active = 0;
325
+            if (!empty($input['gateways']) && !empty($input['gateways'][$key])) {
326 326
                 $active = 1;
327 327
             }
328 328
             
329 329
             $input[$key . '_active'] = $active;
330 330
             
331
-            if ( empty( $wpinv_options[$key . '_title'] ) ) {
331
+            if (empty($wpinv_options[$key . '_title'])) {
332 332
                 $input[$key . '_title'] = $gateway['checkout_label'];
333 333
             }
334 334
             
335
-            if ( !isset( $wpinv_options[$key . '_ordering'] ) && isset( $gateway['ordering'] ) ) {
335
+            if (!isset($wpinv_options[$key . '_ordering']) && isset($gateway['ordering'])) {
336 336
                 $input[$key . '_ordering'] = $gateway['ordering'];
337 337
             }
338 338
         }
@@ -340,27 +340,27 @@  discard block
 block discarded – undo
340 340
     
341 341
     return $input;
342 342
 }
343
-add_filter( 'wpinv_settings_tab_gateways_sanitize', 'wpinv_settings_update_gateways', 10, 1 );
343
+add_filter('wpinv_settings_tab_gateways_sanitize', 'wpinv_settings_update_gateways', 10, 1);
344 344
 
345 345
 // PayPal Standard settings
346
-function wpinv_gateway_settings_paypal( $setting ) {    
347
-    $setting['paypal_active']['desc'] = $setting['paypal_active']['desc'] . ' ' . __( '( Supported Currencies: AUD, BRL, CAD, CZK, DKK, EUR, HKD, HUF, ILS, JPY, MYR, MXN, NOK, NZD, PHP, PLN, GBP, SGD, SEK, CHF, TWD, THB, USD )', 'invoicing' );
348
-    $setting['paypal_desc']['std'] = __( 'Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing' );
346
+function wpinv_gateway_settings_paypal($setting) {    
347
+    $setting['paypal_active']['desc'] = $setting['paypal_active']['desc'] . ' ' . __('( Supported Currencies: AUD, BRL, CAD, CZK, DKK, EUR, HKD, HUF, ILS, JPY, MYR, MXN, NOK, NZD, PHP, PLN, GBP, SGD, SEK, CHF, TWD, THB, USD )', 'invoicing');
348
+    $setting['paypal_desc']['std'] = __('Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing');
349 349
     
350 350
     $setting['paypal_sandbox'] = array(
351 351
             'type' => 'checkbox',
352 352
             'id'   => 'paypal_sandbox',
353
-            'name' => __( 'PayPal Sandbox', 'invoicing' ),
354
-            'desc' => __( 'PayPal sandbox can be used to test payments.', 'invoicing' ),
353
+            'name' => __('PayPal Sandbox', 'invoicing'),
354
+            'desc' => __('PayPal sandbox can be used to test payments.', 'invoicing'),
355 355
             'std'  => 1
356 356
         );
357 357
         
358 358
     $setting['paypal_email'] = array(
359 359
             'type' => 'text',
360 360
             'id'   => 'paypal_email',
361
-            'name' => __( 'PayPal Email', 'invoicing' ),
362
-            'desc' => __( 'Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing' ),
363
-            'std' => __( '[email protected]', 'invoicing' ),
361
+            'name' => __('PayPal Email', 'invoicing'),
362
+            'desc' => __('Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing'),
363
+            'std' => __('[email protected]', 'invoicing'),
364 364
         );
365 365
     /*
366 366
     $setting['paypal_ipn_url'] = array(
@@ -374,18 +374,18 @@  discard block
 block discarded – undo
374 374
         
375 375
     return $setting;
376 376
 }
377
-add_filter( 'wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1 );
377
+add_filter('wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1);
378 378
 
379 379
 /**
380 380
  * Displays the ipn url field.
381 381
  */
382
-function wpinv_ipn_url_callback( $args ) {
383
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
382
+function wpinv_ipn_url_callback($args) {
383
+    $sanitize_id = wpinv_sanitize_key($args['id']);
384 384
     
385 385
     $attrs = $args['readonly'] ? ' readonly' : '';
386 386
 
387
-    $html = '<input class="regular-text" type="text" ' . $attrs . ' value="' . esc_attr( $args['std'] ) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" onClick="this.select()">';
388
-    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">'  . $args['desc'] . '</label>';
387
+    $html = '<input class="regular-text" type="text" ' . $attrs . ' value="' . esc_attr($args['std']) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" onClick="this.select()">';
388
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">' . $args['desc'] . '</label>';
389 389
 
390 390
     echo $html;
391 391
 }
@@ -397,10 +397,10 @@  discard block
 block discarded – undo
397 397
  *
398 398
  * @return bool
399 399
  */
400
-function wpinv_is_test_mode( $gateway = '' ) {
401
-    $sandbox  = empty( $gateway ) ? false : wpinv_get_option( "{$gateway}_sandbox", true );
402
-    $supports = apply_filters( "wpinv_{$gateway}_supports_sandbox", false );
403
-    return apply_filters( 'wpinv_is_test_mode', $sandbox && $supports, $gateway );
400
+function wpinv_is_test_mode($gateway = '') {
401
+    $sandbox  = empty($gateway) ? false : wpinv_get_option("{$gateway}_sandbox", true);
402
+    $supports = apply_filters("wpinv_{$gateway}_supports_sandbox", false);
403
+    return apply_filters('wpinv_is_test_mode', $sandbox && $supports, $gateway);
404 404
 }
405 405
 
406 406
 /**
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
  * 
412 412
  * @return string
413 413
  */
414
-function wpinv_get_ipn_url( $gateway = false, $args = array() ) {
414
+function wpinv_get_ipn_url($gateway = false, $args = array()) {
415 415
     $args = wp_parse_args(
416 416
         array(
417 417
             'wpi-listener' => 'IPN',
@@ -420,37 +420,37 @@  discard block
 block discarded – undo
420 420
         $args
421 421
     );
422 422
 
423
-    return apply_filters( 'wpinv_ipn_url', add_query_arg( $args,  home_url( 'index.php' ) ), $gateway, $args );
423
+    return apply_filters('wpinv_ipn_url', add_query_arg($args, home_url('index.php')), $gateway, $args);
424 424
 
425 425
 }
426 426
 
427 427
 /**
428 428
  * Retrieves request data with slashes removed slashes.
429 429
  */
430
-function wpinv_get_post_data( $method = 'request' ) {
430
+function wpinv_get_post_data($method = 'request') {
431 431
 
432
-    if ( $method == 'post' ) {
433
-        return wp_unslash( $_POST );
432
+    if ($method == 'post') {
433
+        return wp_unslash($_POST);
434 434
     }
435 435
 
436
-    if ( $method == 'get' ) {
437
-        return wp_unslash( $_GET );
436
+    if ($method == 'get') {
437
+        return wp_unslash($_GET);
438 438
     }
439 439
 
440
-    return wp_unslash( $_REQUEST );
440
+    return wp_unslash($_REQUEST);
441 441
   
442 442
 }
443 443
 
444 444
 /**
445 445
  * Checks if a given gateway supports subscription payments.
446 446
  */
447
-function wpinv_gateway_support_subscription( $gateway ) {
447
+function wpinv_gateway_support_subscription($gateway) {
448 448
     $supports = false;
449 449
 
450
-    if ( wpinv_is_gateway_active( $gateway ) ) {
451
-        $supports = apply_filters( 'wpinv_' . $gateway . '_support_subscription', $supports );
450
+    if (wpinv_is_gateway_active($gateway)) {
451
+        $supports = apply_filters('wpinv_' . $gateway . '_support_subscription', $supports);
452 452
 
453
-        $supports = apply_filters( 'getapid_gateway_supports_subscription', $supports, $gateway );
453
+        $supports = apply_filters('getapid_gateway_supports_subscription', $supports, $gateway);
454 454
     }
455 455
 
456 456
     return $supports;
@@ -462,14 +462,14 @@  discard block
 block discarded – undo
462 462
  * @param array $gateways an array of gateways.
463 463
  * @param GetPaid_Payment_Form $form payment form.
464 464
  */
465
-function wpinv_payment_gateways_on_cart( $gateways, $form ) {
465
+function wpinv_payment_gateways_on_cart($gateways, $form) {
466 466
 
467
-    if ( $form->is_recurring() ) {
467
+    if ($form->is_recurring()) {
468 468
 
469
-        foreach ( array_keys( $gateways ) as $gateway ) {
469
+        foreach (array_keys($gateways) as $gateway) {
470 470
 
471
-            if ( ! wpinv_gateway_support_subscription( $gateway ) ) {
472
-                unset( $gateways[$gateway] );
471
+            if (!wpinv_gateway_support_subscription($gateway)) {
472
+                unset($gateways[$gateway]);
473 473
             }
474 474
 
475 475
         }
@@ -478,4 +478,4 @@  discard block
 block discarded – undo
478 478
 
479 479
     return $gateways;
480 480
 }
481
-add_filter( 'getpaid_payment_form_gateways', 'wpinv_payment_gateways_on_cart', 10, 2 );
481
+add_filter('getpaid_payment_form_gateways', 'wpinv_payment_gateways_on_cart', 10, 2);
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-bank-transfer-gateway.php 2 patches
Indentation   +175 added lines, -175 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( 'addons' );
22
+    /**
23
+     * An array of features that this gateway supports.
24
+     *
25
+     * @var array
26
+     */
27
+    protected $supports = array( 'addons' );
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,23 +44,23 @@  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 );
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 51
 
52 52
     }
53 53
 
54 54
     /**
55
-	 * Process Payment.
56
-	 *
57
-	 *
58
-	 * @param WPInv_Invoice $invoice Invoice.
59
-	 * @param array $submission_data Posted checkout fields.
60
-	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
61
-	 * @return array
62
-	 */
63
-	public function process_payment( $invoice, $submission_data, $submission ) {
55
+     * Process Payment.
56
+     *
57
+     *
58
+     * @param WPInv_Invoice $invoice Invoice.
59
+     * @param array $submission_data Posted checkout fields.
60
+     * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
61
+     * @return array
62
+     */
63
+    public function process_payment( $invoice, $submission_data, $submission ) {
64 64
 
65 65
         // Add a transaction id.
66 66
         $invoice->set_transaction_id( $invoice->generate_key('trans_') );
@@ -81,66 +81,66 @@  discard block
 block discarded – undo
81 81
     }
82 82
 
83 83
     /**
84
-	 * Output for the order received page.
85
-	 *
86
-	 * @param WPInv_Invoice $invoice Invoice.
87
-	 */
88
-	public function thankyou_page( $invoice ) {
84
+     * Output for the order received page.
85
+     *
86
+     * @param WPInv_Invoice $invoice Invoice.
87
+     */
88
+    public function thankyou_page( $invoice ) {
89 89
 
90 90
         if ( 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
91 91
 
92
-			echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL;
92
+            echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL;
93 93
 
94 94
             if ( ! empty( $this->instructions ) ) {
95 95
                 echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) );
96
-			}
96
+            }
97 97
 
98
-			$this->bank_details( $invoice );
98
+            $this->bank_details( $invoice );
99 99
 
100
-			echo '</div>';
100
+            echo '</div>';
101 101
 
102 102
         }
103 103
 
104
-	}
104
+    }
105 105
 
106 106
     /**
107
-	 * Add content to the WPI emails.
108
-	 *
109
-	 * @param WPInv_Invoice $invoice Invoice.
110
-	 * @param string     $email_type Email format: plain text or HTML.
111
-	 * @param bool     $sent_to_admin Sent to admin.
112
-	 */
113
-	public function email_instructions( $invoice, $email_type, $sent_to_admin ) {
107
+     * Add content to the WPI emails.
108
+     *
109
+     * @param WPInv_Invoice $invoice Invoice.
110
+     * @param string     $email_type Email format: plain text or HTML.
111
+     * @param bool     $sent_to_admin Sent to admin.
112
+     */
113
+    public function email_instructions( $invoice, $email_type, $sent_to_admin ) {
114 114
 
115
-		if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
115
+        if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
116 116
 
117
-			echo '<div class="wpi-email-row getpaid-bank-transfer-details">';
117
+            echo '<div class="wpi-email-row getpaid-bank-transfer-details">';
118 118
 
119
-			if ( $this->instructions ) {
120
-				echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
119
+            if ( $this->instructions ) {
120
+                echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
121 121
             }
122 122
 
123
-			$this->bank_details( $invoice );
123
+            $this->bank_details( $invoice );
124 124
 			
125
-			echo '</div>';
125
+            echo '</div>';
126 126
 
127
-		}
127
+        }
128 128
 
129 129
     }
130 130
     
131 131
     /**
132
-	 * Get bank details and place into a list format.
133
-	 *
134
-	 * @param WPInv_Invoice $invoice Invoice.
135
-	 */
136
-	protected function bank_details( $invoice ) {
132
+     * Get bank details and place into a list format.
133
+     *
134
+     * @param WPInv_Invoice $invoice Invoice.
135
+     */
136
+    protected function bank_details( $invoice ) {
137 137
 
138
-		// Get the invoice country and country $locale.
139
-		$country = $invoice->get_country();
140
-		$locale  = $this->get_country_locale();
138
+        // Get the invoice country and country $locale.
139
+        $country = $invoice->get_country();
140
+        $locale  = $this->get_country_locale();
141 141
 
142
-		// Get sortcode label in the $locale array and use appropriate one.
143
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
142
+        // Get sortcode label in the $locale array and use appropriate one.
143
+        $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
144 144
 
145 145
         $bank_fields = array(
146 146
             'ac_name'     => __( 'Account Name', 'invoicing' ),
@@ -169,144 +169,144 @@  discard block
 block discarded – undo
169 169
             return;
170 170
         }
171 171
 
172
-		echo '<h3 class="getpaid-bank-transfer-title"> ' . apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ) ) . '</h3>' . PHP_EOL;
172
+        echo '<h3 class="getpaid-bank-transfer-title"> ' . apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ) ) . '</h3>' . PHP_EOL;
173 173
 
174
-		echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL;
174
+        echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL;
175 175
 
176
-		foreach ( $bank_info as $key => $data ) {
176
+        foreach ( $bank_info as $key => $data ) {
177 177
 
178
-			$key   = sanitize_html_class( $key );
179
-			$label = wp_kses_post( $data['label'] );
180
-			$value = wp_kses_post( wptexturize( $data['value'] ) );
178
+            $key   = sanitize_html_class( $key );
179
+            $label = wp_kses_post( $data['label'] );
180
+            $value = wp_kses_post( wptexturize( $data['value'] ) );
181 181
 
182
-			echo "<tr class='getpaid-bank-transfer-$key'><th>$label</th><td>$value</td></tr>" . PHP_EOL;
183
-		}
182
+            echo "<tr class='getpaid-bank-transfer-$key'><th>$label</th><td>$value</td></tr>" . PHP_EOL;
183
+        }
184 184
 
185
-		echo '</table>';
185
+        echo '</table>';
186 186
 
187 187
     }
188 188
     
189 189
     /**
190
-	 * Get country locale if localized.
191
-	 *
192
-	 * @return array
193
-	 */
194
-	public function get_country_locale() {
195
-
196
-		if ( empty( $this->locale ) ) {
197
-
198
-			// Locale information to be used - only those that are not 'Sort Code'.
199
-			$this->locale = apply_filters(
200
-				'getpaid_get_bank_transfer_locale',
201
-				array(
202
-					'AU' => array(
203
-						'sortcode' => array(
204
-							'label' => __( 'BSB', 'invoicing' ),
205
-						),
206
-					),
207
-					'CA' => array(
208
-						'sortcode' => array(
209
-							'label' => __( 'Bank transit number', 'invoicing' ),
210
-						),
211
-					),
212
-					'IN' => array(
213
-						'sortcode' => array(
214
-							'label' => __( 'IFSC', 'invoicing' ),
215
-						),
216
-					),
217
-					'IT' => array(
218
-						'sortcode' => array(
219
-							'label' => __( 'Branch sort', 'invoicing' ),
220
-						),
221
-					),
222
-					'NZ' => array(
223
-						'sortcode' => array(
224
-							'label' => __( 'Bank code', 'invoicing' ),
225
-						),
226
-					),
227
-					'SE' => array(
228
-						'sortcode' => array(
229
-							'label' => __( 'Bank code', 'invoicing' ),
230
-						),
231
-					),
232
-					'US' => array(
233
-						'sortcode' => array(
234
-							'label' => __( 'Routing number', 'invoicing' ),
235
-						),
236
-					),
237
-					'ZA' => array(
238
-						'sortcode' => array(
239
-							'label' => __( 'Branch code', 'invoicing' ),
240
-						),
241
-					),
242
-				)
243
-			);
244
-
245
-		}
246
-
247
-		return $this->locale;
248
-
249
-	}
250
-
251
-	/**
252
-	 * Filters the gateway settings.
253
-	 * 
254
-	 * @param array $admin_settings
255
-	 */
256
-	public function admin_settings( $admin_settings ) {
190
+     * Get country locale if localized.
191
+     *
192
+     * @return array
193
+     */
194
+    public function get_country_locale() {
195
+
196
+        if ( empty( $this->locale ) ) {
197
+
198
+            // Locale information to be used - only those that are not 'Sort Code'.
199
+            $this->locale = apply_filters(
200
+                'getpaid_get_bank_transfer_locale',
201
+                array(
202
+                    'AU' => array(
203
+                        'sortcode' => array(
204
+                            'label' => __( 'BSB', 'invoicing' ),
205
+                        ),
206
+                    ),
207
+                    'CA' => array(
208
+                        'sortcode' => array(
209
+                            'label' => __( 'Bank transit number', 'invoicing' ),
210
+                        ),
211
+                    ),
212
+                    'IN' => array(
213
+                        'sortcode' => array(
214
+                            'label' => __( 'IFSC', 'invoicing' ),
215
+                        ),
216
+                    ),
217
+                    'IT' => array(
218
+                        'sortcode' => array(
219
+                            'label' => __( 'Branch sort', 'invoicing' ),
220
+                        ),
221
+                    ),
222
+                    'NZ' => array(
223
+                        'sortcode' => array(
224
+                            'label' => __( 'Bank code', 'invoicing' ),
225
+                        ),
226
+                    ),
227
+                    'SE' => array(
228
+                        'sortcode' => array(
229
+                            'label' => __( 'Bank code', 'invoicing' ),
230
+                        ),
231
+                    ),
232
+                    'US' => array(
233
+                        'sortcode' => array(
234
+                            'label' => __( 'Routing number', 'invoicing' ),
235
+                        ),
236
+                    ),
237
+                    'ZA' => array(
238
+                        'sortcode' => array(
239
+                            'label' => __( 'Branch code', 'invoicing' ),
240
+                        ),
241
+                    ),
242
+                )
243
+            );
244
+
245
+        }
246
+
247
+        return $this->locale;
248
+
249
+    }
250
+
251
+    /**
252
+     * Filters the gateway settings.
253
+     * 
254
+     * @param array $admin_settings
255
+     */
256
+    public function admin_settings( $admin_settings ) {
257 257
 
258 258
         $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' );
259
-		$admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' );
259
+        $admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' );
260 260
 
261
-		$locale  = $this->get_country_locale();
261
+        $locale  = $this->get_country_locale();
262 262
 
263
-		// Get sortcode label in the $locale array and use appropriate one.
264
-		$country  = wpinv_default_billing_country();
265
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
263
+        // Get sortcode label in the $locale array and use appropriate one.
264
+        $country  = wpinv_default_billing_country();
265
+        $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
266 266
 
267
-		$admin_settings['bank_transfer_ac_name'] = array(
267
+        $admin_settings['bank_transfer_ac_name'] = array(
268 268
             'type' => 'text',
269 269
             'id'   => 'bank_transfer_ac_name',
270 270
             'name' => __( 'Account Name', 'invoicing' ),
271
-		);
271
+        );
272 272
 		
273
-		$admin_settings['bank_transfer_ac_no'] = array(
273
+        $admin_settings['bank_transfer_ac_no'] = array(
274 274
             'type' => 'text',
275 275
             'id'   => 'bank_transfer_ac_no',
276 276
             'name' => __( 'Account Number', 'invoicing' ),
277
-		);
277
+        );
278 278
 		
279
-		$admin_settings['bank_transfer_bank_name'] = array(
279
+        $admin_settings['bank_transfer_bank_name'] = array(
280 280
             'type' => 'text',
281 281
             'id'   => 'bank_transfer_bank_name',
282 282
             'name' => __( 'Bank Name', 'invoicing' ),
283
-		);
283
+        );
284 284
 
285
-		$admin_settings['bank_transfer_ifsc'] = array(
285
+        $admin_settings['bank_transfer_ifsc'] = array(
286 286
             'type' => 'text',
287 287
             'id'   => 'bank_transfer_ifsc',
288 288
             'name' => __( 'IFSC Code', 'invoicing' ),
289
-		);
289
+        );
290 290
 
291
-		$admin_settings['bank_transfer_iban'] = array(
291
+        $admin_settings['bank_transfer_iban'] = array(
292 292
             'type' => 'text',
293 293
             'id'   => 'bank_transfer_iban',
294 294
             'name' => __( 'IBAN', 'invoicing' ),
295
-		);
295
+        );
296 296
 
297
-		$admin_settings['bank_transfer_bic'] = array(
297
+        $admin_settings['bank_transfer_bic'] = array(
298 298
             'type' => 'text',
299 299
             'id'   => 'bank_transfer_bic',
300 300
             'name' => __( 'BIC/Swift Code', 'invoicing' ),
301
-		);
301
+        );
302 302
 		
303
-		$admin_settings['bank_transfer_sort_code'] = array(
304
-			'type' => 'text',
305
-			'id'   => 'bank_transfer_sort_code',
306
-			'name' => $sortcode,
307
-		);
303
+        $admin_settings['bank_transfer_sort_code'] = array(
304
+            'type' => 'text',
305
+            'id'   => 'bank_transfer_sort_code',
306
+            'name' => $sortcode,
307
+        );
308 308
 
309
-		$admin_settings['bank_transfer_info'] = array(
309
+        $admin_settings['bank_transfer_info'] = array(
310 310
             'id'   => 'bank_transfer_info',
311 311
             'name' => __( 'Instructions', 'invoicing' ),
312 312
             'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ),
@@ -316,17 +316,17 @@  discard block
 block discarded – undo
316 316
             'rows' => 5
317 317
         );
318 318
 
319
-		return $admin_settings;
320
-	}
319
+        return $admin_settings;
320
+    }
321 321
 
322
-	/**
323
-	 * Processes invoice addons.
324
-	 *
325
-	 * @param WPInv_Invoice $invoice
326
-	 * @param GetPaid_Form_Item[] $items
327
-	 * @return WPInv_Invoice
328
-	 */
329
-	public function process_addons( $invoice, $items ) {
322
+    /**
323
+     * Processes invoice addons.
324
+     *
325
+     * @param WPInv_Invoice $invoice
326
+     * @param GetPaid_Form_Item[] $items
327
+     * @return WPInv_Invoice
328
+     */
329
+    public function process_addons( $invoice, $items ) {
330 330
 
331 331
         foreach ( $items as $item ) {
332 332
             $invoice->add_item( $item );
@@ -334,6 +334,6 @@  discard block
 block discarded – undo
334 334
 
335 335
         $invoice->recalculate_total();
336 336
         $invoice->save();
337
-	}
337
+    }
338 338
 
339 339
 }
Please login to merge, or discard this patch.
Spacing   +71 added lines, -71 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( 'addons' );
27
+	protected $supports = array('addons');
28 28
 
29 29
     /**
30 30
 	 * Payment method order.
@@ -39,15 +39,15 @@  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 );
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 51
 
52 52
     }
53 53
 
@@ -60,23 +60,23 @@  discard block
 block discarded – undo
60 60
 	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
61 61
 	 * @return array
62 62
 	 */
63
-	public function process_payment( $invoice, $submission_data, $submission ) {
63
+	public function process_payment($invoice, $submission_data, $submission) {
64 64
 
65 65
         // Add a transaction id.
66
-        $invoice->set_transaction_id( $invoice->generate_key('trans_') );
66
+        $invoice->set_transaction_id($invoice->generate_key('trans_'));
67 67
 
68 68
         // Set it as pending payment.
69
-        if ( ! $invoice->needs_payment() ) {
69
+        if (!$invoice->needs_payment()) {
70 70
             $invoice->mark_paid();
71
-        } else if ( ! $invoice->is_paid() ) {
72
-            $invoice->set_status( 'wpi-onhold' );
71
+        } else if (!$invoice->is_paid()) {
72
+            $invoice->set_status('wpi-onhold');
73 73
         }
74 74
 
75 75
         // Save it.
76 76
         $invoice->save();
77 77
 
78 78
         // Send to the success page.
79
-        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
79
+        wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
80 80
 
81 81
     }
82 82
 
@@ -85,17 +85,17 @@  discard block
 block discarded – undo
85 85
 	 *
86 86
 	 * @param WPInv_Invoice $invoice Invoice.
87 87
 	 */
88
-	public function thankyou_page( $invoice ) {
88
+	public function thankyou_page($invoice) {
89 89
 
90
-        if ( 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
90
+        if ('bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment()) {
91 91
 
92 92
 			echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL;
93 93
 
94
-            if ( ! empty( $this->instructions ) ) {
95
-                echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) );
94
+            if (!empty($this->instructions)) {
95
+                echo wp_kses_post(wpautop(wptexturize($this->instructions)));
96 96
 			}
97 97
 
98
-			$this->bank_details( $invoice );
98
+			$this->bank_details($invoice);
99 99
 
100 100
 			echo '</div>';
101 101
 
@@ -110,17 +110,17 @@  discard block
 block discarded – undo
110 110
 	 * @param string     $email_type Email format: plain text or HTML.
111 111
 	 * @param bool     $sent_to_admin Sent to admin.
112 112
 	 */
113
-	public function email_instructions( $invoice, $email_type, $sent_to_admin ) {
113
+	public function email_instructions($invoice, $email_type, $sent_to_admin) {
114 114
 
115
-		if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
115
+		if (!$sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment()) {
116 116
 
117 117
 			echo '<div class="wpi-email-row getpaid-bank-transfer-details">';
118 118
 
119
-			if ( $this->instructions ) {
120
-				echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
119
+			if ($this->instructions) {
120
+				echo wp_kses_post(wpautop(wptexturize($this->instructions)) . PHP_EOL);
121 121
             }
122 122
 
123
-			$this->bank_details( $invoice );
123
+			$this->bank_details($invoice);
124 124
 			
125 125
 			echo '</div>';
126 126
 
@@ -133,51 +133,51 @@  discard block
 block discarded – undo
133 133
 	 *
134 134
 	 * @param WPInv_Invoice $invoice Invoice.
135 135
 	 */
136
-	protected function bank_details( $invoice ) {
136
+	protected function bank_details($invoice) {
137 137
 
138 138
 		// Get the invoice country and country $locale.
139 139
 		$country = $invoice->get_country();
140 140
 		$locale  = $this->get_country_locale();
141 141
 
142 142
 		// Get sortcode label in the $locale array and use appropriate one.
143
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
143
+		$sortcode = isset($locale[$country]['sortcode']['label']) ? $locale[$country]['sortcode']['label'] : __('Sort code', 'invoicing');
144 144
 
145 145
         $bank_fields = array(
146
-            'ac_name'     => __( 'Account Name', 'invoicing' ),
147
-            'ac_no'       => __( 'Account Number', 'invoicing' ),
148
-            'bank_name'   => __( 'Bank Name', 'invoicing' ),
149
-            'ifsc'        => __( 'IFSC code', 'invoicing' ),
150
-            'iban'        => __( 'IBAN', 'invoicing' ),
151
-            'bic'         => __( 'BIC/Swift code', 'invoicing' ),
146
+            'ac_name'     => __('Account Name', 'invoicing'),
147
+            'ac_no'       => __('Account Number', 'invoicing'),
148
+            'bank_name'   => __('Bank Name', 'invoicing'),
149
+            'ifsc'        => __('IFSC code', 'invoicing'),
150
+            'iban'        => __('IBAN', 'invoicing'),
151
+            'bic'         => __('BIC/Swift code', 'invoicing'),
152 152
             'sort_code'   => $sortcode,
153 153
         );
154 154
 
155 155
         $bank_info = array();
156 156
 
157
-        foreach ( $bank_fields as $field => $label ) {
158
-            $value = $this->get_option( $field );
157
+        foreach ($bank_fields as $field => $label) {
158
+            $value = $this->get_option($field);
159 159
 
160
-            if ( ! empty( $value ) ) {
161
-                $bank_info[$field] = array( 'label' => $label, 'value' => $value );
160
+            if (!empty($value)) {
161
+                $bank_info[$field] = array('label' => $label, 'value' => $value);
162 162
             }
163 163
 
164 164
         }
165 165
 
166
-        $bank_info = apply_filters( 'wpinv_bank_info', $bank_info );
166
+        $bank_info = apply_filters('wpinv_bank_info', $bank_info);
167 167
 
168
-        if ( empty( $bank_info ) ) {
168
+        if (empty($bank_info)) {
169 169
             return;
170 170
         }
171 171
 
172
-		echo '<h3 class="getpaid-bank-transfer-title"> ' . apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ) ) . '</h3>' . PHP_EOL;
172
+		echo '<h3 class="getpaid-bank-transfer-title"> ' . apply_filters('wpinv_receipt_bank_details_title', __('Bank Details', 'invoicing')) . '</h3>' . PHP_EOL;
173 173
 
174 174
 		echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL;
175 175
 
176
-		foreach ( $bank_info as $key => $data ) {
176
+		foreach ($bank_info as $key => $data) {
177 177
 
178
-			$key   = sanitize_html_class( $key );
179
-			$label = wp_kses_post( $data['label'] );
180
-			$value = wp_kses_post( wptexturize( $data['value'] ) );
178
+			$key   = sanitize_html_class($key);
179
+			$label = wp_kses_post($data['label']);
180
+			$value = wp_kses_post(wptexturize($data['value']));
181 181
 
182 182
 			echo "<tr class='getpaid-bank-transfer-$key'><th>$label</th><td>$value</td></tr>" . PHP_EOL;
183 183
 		}
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 	 */
194 194
 	public function get_country_locale() {
195 195
 
196
-		if ( empty( $this->locale ) ) {
196
+		if (empty($this->locale)) {
197 197
 
198 198
 			// Locale information to be used - only those that are not 'Sort Code'.
199 199
 			$this->locale = apply_filters(
@@ -201,42 +201,42 @@  discard block
 block discarded – undo
201 201
 				array(
202 202
 					'AU' => array(
203 203
 						'sortcode' => array(
204
-							'label' => __( 'BSB', 'invoicing' ),
204
+							'label' => __('BSB', 'invoicing'),
205 205
 						),
206 206
 					),
207 207
 					'CA' => array(
208 208
 						'sortcode' => array(
209
-							'label' => __( 'Bank transit number', 'invoicing' ),
209
+							'label' => __('Bank transit number', 'invoicing'),
210 210
 						),
211 211
 					),
212 212
 					'IN' => array(
213 213
 						'sortcode' => array(
214
-							'label' => __( 'IFSC', 'invoicing' ),
214
+							'label' => __('IFSC', 'invoicing'),
215 215
 						),
216 216
 					),
217 217
 					'IT' => array(
218 218
 						'sortcode' => array(
219
-							'label' => __( 'Branch sort', 'invoicing' ),
219
+							'label' => __('Branch sort', 'invoicing'),
220 220
 						),
221 221
 					),
222 222
 					'NZ' => array(
223 223
 						'sortcode' => array(
224
-							'label' => __( 'Bank code', 'invoicing' ),
224
+							'label' => __('Bank code', 'invoicing'),
225 225
 						),
226 226
 					),
227 227
 					'SE' => array(
228 228
 						'sortcode' => array(
229
-							'label' => __( 'Bank code', 'invoicing' ),
229
+							'label' => __('Bank code', 'invoicing'),
230 230
 						),
231 231
 					),
232 232
 					'US' => array(
233 233
 						'sortcode' => array(
234
-							'label' => __( 'Routing number', 'invoicing' ),
234
+							'label' => __('Routing number', 'invoicing'),
235 235
 						),
236 236
 					),
237 237
 					'ZA' => array(
238 238
 						'sortcode' => array(
239
-							'label' => __( 'Branch code', 'invoicing' ),
239
+							'label' => __('Branch code', 'invoicing'),
240 240
 						),
241 241
 					),
242 242
 				)
@@ -253,51 +253,51 @@  discard block
 block discarded – undo
253 253
 	 * 
254 254
 	 * @param array $admin_settings
255 255
 	 */
256
-	public function admin_settings( $admin_settings ) {
256
+	public function admin_settings($admin_settings) {
257 257
 
258
-        $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' );
259
-		$admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' );
258
+        $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');
259
+		$admin_settings['bank_transfer_active']['desc'] = __('Enable bank transfer', 'invoicing');
260 260
 
261
-		$locale  = $this->get_country_locale();
261
+		$locale = $this->get_country_locale();
262 262
 
263 263
 		// Get sortcode label in the $locale array and use appropriate one.
264 264
 		$country  = wpinv_default_billing_country();
265
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
265
+		$sortcode = isset($locale[$country]['sortcode']['label']) ? $locale[$country]['sortcode']['label'] : __('Sort code', 'invoicing');
266 266
 
267 267
 		$admin_settings['bank_transfer_ac_name'] = array(
268 268
             'type' => 'text',
269 269
             'id'   => 'bank_transfer_ac_name',
270
-            'name' => __( 'Account Name', 'invoicing' ),
270
+            'name' => __('Account Name', 'invoicing'),
271 271
 		);
272 272
 		
273 273
 		$admin_settings['bank_transfer_ac_no'] = array(
274 274
             'type' => 'text',
275 275
             'id'   => 'bank_transfer_ac_no',
276
-            'name' => __( 'Account Number', 'invoicing' ),
276
+            'name' => __('Account Number', 'invoicing'),
277 277
 		);
278 278
 		
279 279
 		$admin_settings['bank_transfer_bank_name'] = array(
280 280
             'type' => 'text',
281 281
             'id'   => 'bank_transfer_bank_name',
282
-            'name' => __( 'Bank Name', 'invoicing' ),
282
+            'name' => __('Bank Name', 'invoicing'),
283 283
 		);
284 284
 
285 285
 		$admin_settings['bank_transfer_ifsc'] = array(
286 286
             'type' => 'text',
287 287
             'id'   => 'bank_transfer_ifsc',
288
-            'name' => __( 'IFSC Code', 'invoicing' ),
288
+            'name' => __('IFSC Code', 'invoicing'),
289 289
 		);
290 290
 
291 291
 		$admin_settings['bank_transfer_iban'] = array(
292 292
             'type' => 'text',
293 293
             'id'   => 'bank_transfer_iban',
294
-            'name' => __( 'IBAN', 'invoicing' ),
294
+            'name' => __('IBAN', 'invoicing'),
295 295
 		);
296 296
 
297 297
 		$admin_settings['bank_transfer_bic'] = array(
298 298
             'type' => 'text',
299 299
             'id'   => 'bank_transfer_bic',
300
-            'name' => __( 'BIC/Swift Code', 'invoicing' ),
300
+            'name' => __('BIC/Swift Code', 'invoicing'),
301 301
 		);
302 302
 		
303 303
 		$admin_settings['bank_transfer_sort_code'] = array(
@@ -308,10 +308,10 @@  discard block
 block discarded – undo
308 308
 
309 309
 		$admin_settings['bank_transfer_info'] = array(
310 310
             'id'   => 'bank_transfer_info',
311
-            'name' => __( 'Instructions', 'invoicing' ),
312
-            'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ),
311
+            'name' => __('Instructions', 'invoicing'),
312
+            'desc' => __('Instructions that will be added to the thank you page and emails.', 'invoicing'),
313 313
             'type' => 'textarea',
314
-            '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' ),
314
+            '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'),
315 315
             'cols' => 50,
316 316
             'rows' => 5
317 317
         );
@@ -326,10 +326,10 @@  discard block
 block discarded – undo
326 326
 	 * @param GetPaid_Form_Item[] $items
327 327
 	 * @return WPInv_Invoice
328 328
 	 */
329
-	public function process_addons( $invoice, $items ) {
329
+	public function process_addons($invoice, $items) {
330 330
 
331
-        foreach ( $items as $item ) {
332
-            $invoice->add_item( $item );
331
+        foreach ($items as $item) {
332
+            $invoice->add_item($item);
333 333
         }
334 334
 
335 335
         $invoice->recalculate_total();
Please login to merge, or discard this patch.